Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2713)

Unified Diff: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/parser/Parser.java

Issue 17582003: Report ParserErrorCode.NORMAL_BEFORE_OPTIONAL_PARAMETERS (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/parser/ParserErrorCode.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/parser/Parser.java
diff --git a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/parser/Parser.java b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/parser/Parser.java
index 201c536ad7267b186f5358db686f94d9110c4baa..001de940344aa08579c56cd88a2d71f253c69358 100644
--- a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/parser/Parser.java
+++ b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/parser/Parser.java
@@ -2778,6 +2778,7 @@ public class Parser {
boolean reportedMuliplePositionalGroups = false;
boolean reportedMulipleNamedGroups = false;
boolean reportedMixedGroups = false;
+ boolean wasOptionalParameter = false;
Token initialToken = null;
do {
if (firstParameter) {
@@ -2796,6 +2797,7 @@ public class Parser {
// Handle the beginning of parameter groups.
//
if (matches(TokenType.OPEN_SQUARE_BRACKET)) {
+ wasOptionalParameter = true;
if (leftSquareBracket != null && !reportedMuliplePositionalGroups) {
reportError(ParserErrorCode.MULTIPLE_POSITIONAL_PARAMETER_GROUPS);
reportedMuliplePositionalGroups = true;
@@ -2808,6 +2810,7 @@ public class Parser {
currentParameters = positionalParameters;
kind = ParameterKind.POSITIONAL;
} else if (matches(TokenType.OPEN_CURLY_BRACKET)) {
+ wasOptionalParameter = true;
if (leftCurlyBracket != null && !reportedMulipleNamedGroups) {
reportError(ParserErrorCode.MULTIPLE_NAMED_PARAMETER_GROUPS);
reportedMulipleNamedGroups = true;
@@ -2826,6 +2829,9 @@ public class Parser {
FormalParameter parameter = parseFormalParameter(kind);
parameters.add(parameter);
currentParameters.add(parameter);
+ if (kind == ParameterKind.REQUIRED && wasOptionalParameter) {
+ reportError(ParserErrorCode.NORMAL_BEFORE_OPTIONAL_PARAMETERS, parameter);
+ }
//
// Handle the end of parameter groups.
//
« no previous file with comments | « no previous file | editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/parser/ParserErrorCode.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698