| Index: pkg/analyzer_experimental/lib/src/generated/parser.dart
|
| diff --git a/pkg/analyzer_experimental/lib/src/generated/parser.dart b/pkg/analyzer_experimental/lib/src/generated/parser.dart
|
| index 4ab24aa22dbbd298275f4eed62a27ef4a4bcc519..89069e377e4fe59e88338bc41ad7d9ede63314dd 100644
|
| --- a/pkg/analyzer_experimental/lib/src/generated/parser.dart
|
| +++ b/pkg/analyzer_experimental/lib/src/generated/parser.dart
|
| @@ -201,7 +201,9 @@ class Parser {
|
| InstrumentationBuilder instrumentation = Instrumentation.builder2("dart.engine.Parser.parseCompilationUnit");
|
| try {
|
| _currentToken = token;
|
| - return parseCompilationUnit2();
|
| + CompilationUnit compilationUnit = parseCompilationUnit2();
|
| + gatherTodoComments(token);
|
| + return compilationUnit;
|
| } finally {
|
| instrumentation.log();
|
| }
|
| @@ -397,7 +399,7 @@ class Parser {
|
| *
|
| * @return the synthetic token that was created
|
| */
|
| - Token createSyntheticToken(Keyword keyword) => new KeywordToken_14(keyword, _currentToken.offset);
|
| + Token createSyntheticToken(Keyword keyword) => new KeywordToken_13(keyword, _currentToken.offset);
|
|
|
| /**
|
| * Create a synthetic token with the given type.
|
| @@ -480,6 +482,18 @@ class Parser {
|
| }
|
| return null;
|
| }
|
| + void gatherTodoComments(Token token) {
|
| + while (token != null && token.type != TokenType.EOF) {
|
| + Token commentToken = token.precedingComments;
|
| + while (commentToken != null) {
|
| + if (identical(commentToken.type, TokenType.SINGLE_LINE_COMMENT) || identical(commentToken.type, TokenType.MULTI_LINE_COMMENT)) {
|
| + scrapeTodoComment(commentToken);
|
| + }
|
| + commentToken = commentToken.next;
|
| + }
|
| + token = token.next;
|
| + }
|
| + }
|
|
|
| /**
|
| * Advance to the next token in the token stream, making it the new current token.
|
| @@ -586,7 +600,17 @@ class Parser {
|
| if (afterIdentifier == null) {
|
| return false;
|
| }
|
| - return isFunctionExpression(afterIdentifier);
|
| + if (isFunctionExpression(afterIdentifier)) {
|
| + return true;
|
| + }
|
| + if (matches(Keyword.GET)) {
|
| + Token afterName = skipSimpleIdentifier(_currentToken.next);
|
| + if (afterName == null) {
|
| + return false;
|
| + }
|
| + return matches4(afterName, TokenType.FUNCTION) || matches4(afterName, TokenType.OPEN_CURLY_BRACKET);
|
| + }
|
| + return false;
|
| }
|
|
|
| /**
|
| @@ -1641,7 +1665,7 @@ class Parser {
|
| }
|
|
|
| /**
|
| - * Parse the documentation comment and metadata preceeding a declaration. This method allows any
|
| + * Parse the documentation comment and metadata preceding a declaration. This method allows any
|
| * number of documentation comments to occur before, after or between the metadata, but only
|
| * returns the last (right-most) documentation comment that is found.
|
| *
|
| @@ -1684,7 +1708,7 @@ class Parser {
|
| }
|
| try {
|
| List<bool> errorFound = [false];
|
| - AnalysisErrorListener listener = new AnalysisErrorListener_15(errorFound);
|
| + AnalysisErrorListener listener = new AnalysisErrorListener_14(errorFound);
|
| StringScanner scanner = new StringScanner(null, referenceSource, listener);
|
| scanner.setSourceStart(1, 1, sourceOffset);
|
| Token firstToken = scanner.tokenize();
|
| @@ -1833,8 +1857,8 @@ class Parser {
|
| if (partOfDirectiveFound) {
|
| reportError8(ParserErrorCode.MULTIPLE_PART_OF_DIRECTIVES, []);
|
| } else {
|
| - for (Directive preceedingDirective in directives) {
|
| - reportError9(ParserErrorCode.NON_PART_OF_DIRECTIVE_IN_PART, preceedingDirective.keyword, []);
|
| + for (Directive precedingDirective in directives) {
|
| + reportError9(ParserErrorCode.NON_PART_OF_DIRECTIVE_IN_PART, precedingDirective.keyword, []);
|
| }
|
| partOfDirectiveFound = true;
|
| }
|
| @@ -2652,6 +2676,7 @@ class Parser {
|
| }
|
| if (matches(Keyword.IN)) {
|
| DeclaredIdentifier loopVariable = null;
|
| + SimpleIdentifier identifier = null;
|
| if (variableList == null) {
|
| reportError8(ParserErrorCode.MISSING_VARIABLE_IN_FOR_EACH, []);
|
| } else {
|
| @@ -2663,13 +2688,24 @@ class Parser {
|
| if (variable.initializer != null) {
|
| reportError8(ParserErrorCode.INITIALIZED_VARIABLE_IN_FOR_EACH, []);
|
| }
|
| - loopVariable = new DeclaredIdentifier.full(commentAndMetadata.comment, commentAndMetadata.metadata, variableList.keyword, variableList.type, variable.name);
|
| + Token keyword = variableList.keyword;
|
| + TypeName type = variableList.type;
|
| + if (keyword != null || type != null) {
|
| + loopVariable = new DeclaredIdentifier.full(commentAndMetadata.comment, commentAndMetadata.metadata, keyword, type, variable.name);
|
| + } else {
|
| + if (!commentAndMetadata.metadata.isEmpty) {
|
| + }
|
| + identifier = variable.name;
|
| + }
|
| }
|
| Token inKeyword = expect(Keyword.IN);
|
| Expression iterator = parseExpression2();
|
| Token rightParenthesis = expect2(TokenType.CLOSE_PAREN);
|
| Statement body = parseStatement2();
|
| - return new ForEachStatement.full(forKeyword, leftParenthesis, loopVariable, inKeyword, iterator, rightParenthesis, body);
|
| + if (loopVariable == null) {
|
| + return new ForEachStatement.con2_full(forKeyword, leftParenthesis, identifier, inKeyword, iterator, rightParenthesis, body);
|
| + }
|
| + return new ForEachStatement.con1_full(forKeyword, leftParenthesis, loopVariable, inKeyword, iterator, rightParenthesis, body);
|
| }
|
| }
|
| Token leftSeparator = expect2(TokenType.SEMICOLON);
|
| @@ -2823,7 +2859,18 @@ class Parser {
|
| * @param returnType the return type, or `null` if there is no return type
|
| * @return the function declaration statement that was parsed
|
| */
|
| - Statement parseFunctionDeclarationStatement2(CommentAndMetadata commentAndMetadata, TypeName returnType) => new FunctionDeclarationStatement.full(parseFunctionDeclaration(commentAndMetadata, null, returnType));
|
| + Statement parseFunctionDeclarationStatement2(CommentAndMetadata commentAndMetadata, TypeName returnType) {
|
| + FunctionDeclaration declaration = parseFunctionDeclaration(commentAndMetadata, null, returnType);
|
| + Token propertyKeyword = declaration.propertyKeyword;
|
| + if (propertyKeyword != null) {
|
| + if (identical(((propertyKeyword as KeywordToken)).keyword, Keyword.GET)) {
|
| + reportError9(ParserErrorCode.GETTER_IN_FUNCTION, propertyKeyword, []);
|
| + } else {
|
| + reportError9(ParserErrorCode.SETTER_IN_FUNCTION, propertyKeyword, []);
|
| + }
|
| + }
|
| + return new FunctionDeclarationStatement.full(declaration);
|
| + }
|
|
|
| /**
|
| * Parse a function expression.
|
| @@ -4805,6 +4852,20 @@ class Parser {
|
| }
|
|
|
| /**
|
| + * Look for user defined tasks in comments and convert them into info level analysis issues.
|
| + *
|
| + * @param commentToken the comment token to analyze
|
| + */
|
| + void scrapeTodoComment(Token commentToken) {
|
| + JavaPatternMatcher matcher = new JavaPatternMatcher(TodoCode.TODO_REGEX, commentToken.lexeme);
|
| + if (matcher.find()) {
|
| + int offset = commentToken.offset + matcher.start() + matcher.group(1).length;
|
| + int length = matcher.group(2).length;
|
| + _errorListener.onError(new AnalysisError.con2(_source, offset, length, TodoCode.TODO, [matcher.group(2)]));
|
| + }
|
| + }
|
| +
|
| + /**
|
| * Parse the 'final', 'const', 'var' or type preceding a variable declaration, starting at the
|
| * given token, without actually creating a type or changing the current token. Return the token
|
| * following the type that was parsed, or `null` if the given token is not the first token
|
| @@ -5580,13 +5641,13 @@ class Parser {
|
| }
|
| }
|
| }
|
| -class KeywordToken_14 extends KeywordToken {
|
| - KeywordToken_14(Keyword arg0, int arg1) : super(arg0, arg1);
|
| +class KeywordToken_13 extends KeywordToken {
|
| + KeywordToken_13(Keyword arg0, int arg1) : super(arg0, arg1);
|
| int get length => 0;
|
| }
|
| -class AnalysisErrorListener_15 implements AnalysisErrorListener {
|
| +class AnalysisErrorListener_14 implements AnalysisErrorListener {
|
| List<bool> errorFound;
|
| - AnalysisErrorListener_15(this.errorFound);
|
| + AnalysisErrorListener_14(this.errorFound);
|
| void onError(AnalysisError error) {
|
| errorFound[0] = true;
|
| }
|
| @@ -5651,82 +5712,84 @@ class ParserErrorCode extends Enum<ParserErrorCode> implements ErrorCode {
|
| static final ParserErrorCode FINAL_METHOD = new ParserErrorCode.con3('FINAL_METHOD', 48, "Getters, setters and methods cannot be declared to be 'final'");
|
| static final ParserErrorCode FINAL_TYPEDEF = new ParserErrorCode.con3('FINAL_TYPEDEF', 49, "Type aliases cannot be declared to be 'final'");
|
| static final ParserErrorCode FUNCTION_TYPED_PARAMETER_VAR = new ParserErrorCode.con3('FUNCTION_TYPED_PARAMETER_VAR', 50, "Function typed parameters cannot specify 'const', 'final' or 'var' instead of return type");
|
| - static final ParserErrorCode GETTER_WITH_PARAMETERS = new ParserErrorCode.con3('GETTER_WITH_PARAMETERS', 51, "Getter should be declared without a parameter list");
|
| - static final ParserErrorCode ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE = new ParserErrorCode.con3('ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE', 52, "Illegal assignment to non-assignable expression");
|
| - static final ParserErrorCode IMPLEMENTS_BEFORE_EXTENDS = new ParserErrorCode.con3('IMPLEMENTS_BEFORE_EXTENDS', 53, "The extends clause must be before the implements clause");
|
| - static final ParserErrorCode IMPLEMENTS_BEFORE_WITH = new ParserErrorCode.con3('IMPLEMENTS_BEFORE_WITH', 54, "The with clause must be before the implements clause");
|
| - static final ParserErrorCode IMPORT_DIRECTIVE_AFTER_PART_DIRECTIVE = new ParserErrorCode.con3('IMPORT_DIRECTIVE_AFTER_PART_DIRECTIVE', 55, "Import directives must preceed part directives");
|
| - static final ParserErrorCode INITIALIZED_VARIABLE_IN_FOR_EACH = new ParserErrorCode.con3('INITIALIZED_VARIABLE_IN_FOR_EACH', 56, "The loop variable in a for-each loop cannot be initialized");
|
| - static final ParserErrorCode INVALID_CODE_POINT = new ParserErrorCode.con3('INVALID_CODE_POINT', 57, "The escape sequence '%s' is not a valid code point");
|
| - static final ParserErrorCode INVALID_COMMENT_REFERENCE = new ParserErrorCode.con3('INVALID_COMMENT_REFERENCE', 58, "Comment references should contain a possibly prefixed identifier and can start with 'new', but should not contain anything else");
|
| - static final ParserErrorCode INVALID_HEX_ESCAPE = new ParserErrorCode.con3('INVALID_HEX_ESCAPE', 59, "An escape sequence starting with '\\x' must be followed by 2 hexidecimal digits");
|
| - static final ParserErrorCode INVALID_OPERATOR = new ParserErrorCode.con3('INVALID_OPERATOR', 60, "The string '%s' is not a valid operator");
|
| - static final ParserErrorCode INVALID_OPERATOR_FOR_SUPER = new ParserErrorCode.con3('INVALID_OPERATOR_FOR_SUPER', 61, "The operator '%s' cannot be used with 'super'");
|
| - static final ParserErrorCode INVALID_UNICODE_ESCAPE = new ParserErrorCode.con3('INVALID_UNICODE_ESCAPE', 62, "An escape sequence starting with '\\u' must be followed by 4 hexidecimal digits or from 1 to 6 digits between '{' and '}'");
|
| - static final ParserErrorCode LIBRARY_DIRECTIVE_NOT_FIRST = new ParserErrorCode.con3('LIBRARY_DIRECTIVE_NOT_FIRST', 63, "The library directive must appear before all other directives");
|
| - static final ParserErrorCode LOCAL_FUNCTION_DECLARATION_MODIFIER = new ParserErrorCode.con3('LOCAL_FUNCTION_DECLARATION_MODIFIER', 64, "Local function declarations cannot specify any modifier");
|
| - static final ParserErrorCode MISSING_ASSIGNABLE_SELECTOR = new ParserErrorCode.con3('MISSING_ASSIGNABLE_SELECTOR', 65, "Missing selector such as \".<identifier>\" or \"[0]\"");
|
| - static final ParserErrorCode MISSING_CATCH_OR_FINALLY = new ParserErrorCode.con3('MISSING_CATCH_OR_FINALLY', 66, "A try statement must have either a catch or finally clause");
|
| - static final ParserErrorCode MISSING_CLASS_BODY = new ParserErrorCode.con3('MISSING_CLASS_BODY', 67, "A class definition must have a body, even if it is empty");
|
| - static final ParserErrorCode MISSING_CLOSING_PARENTHESIS = new ParserErrorCode.con3('MISSING_CLOSING_PARENTHESIS', 68, "The closing parenthesis is missing");
|
| - static final ParserErrorCode MISSING_CONST_FINAL_VAR_OR_TYPE = new ParserErrorCode.con3('MISSING_CONST_FINAL_VAR_OR_TYPE', 69, "Variables must be declared using the keywords 'const', 'final', 'var' or a type name");
|
| - static final ParserErrorCode MISSING_EXPRESSION_IN_THROW = new ParserErrorCode.con3('MISSING_EXPRESSION_IN_THROW', 70, "Throw expressions must compute the object to be thrown");
|
| - static final ParserErrorCode MISSING_FUNCTION_BODY = new ParserErrorCode.con3('MISSING_FUNCTION_BODY', 71, "A function body must be provided");
|
| - static final ParserErrorCode MISSING_FUNCTION_PARAMETERS = new ParserErrorCode.con3('MISSING_FUNCTION_PARAMETERS', 72, "Functions must have an explicit list of parameters");
|
| - static final ParserErrorCode MISSING_IDENTIFIER = new ParserErrorCode.con3('MISSING_IDENTIFIER', 73, "Expected an identifier");
|
| - static final ParserErrorCode MISSING_KEYWORD_OPERATOR = new ParserErrorCode.con3('MISSING_KEYWORD_OPERATOR', 74, "Operator declarations must be preceeded by the keyword 'operator'");
|
| - static final ParserErrorCode MISSING_NAME_IN_LIBRARY_DIRECTIVE = new ParserErrorCode.con3('MISSING_NAME_IN_LIBRARY_DIRECTIVE', 75, "Library directives must include a library name");
|
| - static final ParserErrorCode MISSING_NAME_IN_PART_OF_DIRECTIVE = new ParserErrorCode.con3('MISSING_NAME_IN_PART_OF_DIRECTIVE', 76, "Library directives must include a library name");
|
| - static final ParserErrorCode MISSING_STATEMENT = new ParserErrorCode.con3('MISSING_STATEMENT', 77, "Expected a statement");
|
| - static final ParserErrorCode MISSING_TERMINATOR_FOR_PARAMETER_GROUP = new ParserErrorCode.con3('MISSING_TERMINATOR_FOR_PARAMETER_GROUP', 78, "There is no '%s' to close the parameter group");
|
| - static final ParserErrorCode MISSING_TYPEDEF_PARAMETERS = new ParserErrorCode.con3('MISSING_TYPEDEF_PARAMETERS', 79, "Type aliases for functions must have an explicit list of parameters");
|
| - static final ParserErrorCode MISSING_VARIABLE_IN_FOR_EACH = new ParserErrorCode.con3('MISSING_VARIABLE_IN_FOR_EACH', 80, "A loop variable must be declared in a for-each loop before the 'in', but none were found");
|
| - static final ParserErrorCode MIXED_PARAMETER_GROUPS = new ParserErrorCode.con3('MIXED_PARAMETER_GROUPS', 81, "Cannot have both positional and named parameters in a single parameter list");
|
| - static final ParserErrorCode MULTIPLE_EXTENDS_CLAUSES = new ParserErrorCode.con3('MULTIPLE_EXTENDS_CLAUSES', 82, "Each class definition can have at most one extends clause");
|
| - static final ParserErrorCode MULTIPLE_IMPLEMENTS_CLAUSES = new ParserErrorCode.con3('MULTIPLE_IMPLEMENTS_CLAUSES', 83, "Each class definition can have at most one implements clause");
|
| - static final ParserErrorCode MULTIPLE_LIBRARY_DIRECTIVES = new ParserErrorCode.con3('MULTIPLE_LIBRARY_DIRECTIVES', 84, "Only one library directive may be declared in a file");
|
| - static final ParserErrorCode MULTIPLE_NAMED_PARAMETER_GROUPS = new ParserErrorCode.con3('MULTIPLE_NAMED_PARAMETER_GROUPS', 85, "Cannot have multiple groups of named parameters in a single parameter list");
|
| - static final ParserErrorCode MULTIPLE_PART_OF_DIRECTIVES = new ParserErrorCode.con3('MULTIPLE_PART_OF_DIRECTIVES', 86, "Only one part-of directive may be declared in a file");
|
| - static final ParserErrorCode MULTIPLE_POSITIONAL_PARAMETER_GROUPS = new ParserErrorCode.con3('MULTIPLE_POSITIONAL_PARAMETER_GROUPS', 87, "Cannot have multiple groups of positional parameters in a single parameter list");
|
| - static final ParserErrorCode MULTIPLE_VARIABLES_IN_FOR_EACH = new ParserErrorCode.con3('MULTIPLE_VARIABLES_IN_FOR_EACH', 88, "A single loop variable must be declared in a for-each loop before the 'in', but %s were found");
|
| - static final ParserErrorCode MULTIPLE_WITH_CLAUSES = new ParserErrorCode.con3('MULTIPLE_WITH_CLAUSES', 89, "Each class definition can have at most one with clause");
|
| - static final ParserErrorCode NAMED_FUNCTION_EXPRESSION = new ParserErrorCode.con3('NAMED_FUNCTION_EXPRESSION', 90, "Function expressions cannot be named");
|
| - static final ParserErrorCode NAMED_PARAMETER_OUTSIDE_GROUP = new ParserErrorCode.con3('NAMED_PARAMETER_OUTSIDE_GROUP', 91, "Named parameters must be enclosed in curly braces ('{' and '}')");
|
| - static final ParserErrorCode NATIVE_CLAUSE_IN_NON_SDK_CODE = new ParserErrorCode.con3('NATIVE_CLAUSE_IN_NON_SDK_CODE', 92, "Native clause can only be used in the SDK and code that is loaded through native extensions");
|
| - static final ParserErrorCode NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE = new ParserErrorCode.con3('NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE', 93, "Native functions can only be declared in the SDK and code that is loaded through native extensions");
|
| - static final ParserErrorCode NON_CONSTRUCTOR_FACTORY = new ParserErrorCode.con3('NON_CONSTRUCTOR_FACTORY', 94, "Only constructors can be declared to be a 'factory'");
|
| - static final ParserErrorCode NON_IDENTIFIER_LIBRARY_NAME = new ParserErrorCode.con3('NON_IDENTIFIER_LIBRARY_NAME', 95, "The name of a library must be an identifier");
|
| - static final ParserErrorCode NON_PART_OF_DIRECTIVE_IN_PART = new ParserErrorCode.con3('NON_PART_OF_DIRECTIVE_IN_PART', 96, "The part-of directive must be the only directive in a part");
|
| - static final ParserErrorCode NON_USER_DEFINABLE_OPERATOR = new ParserErrorCode.con3('NON_USER_DEFINABLE_OPERATOR', 97, "The operator '%s' is not user definable");
|
| - static final ParserErrorCode NORMAL_BEFORE_OPTIONAL_PARAMETERS = new ParserErrorCode.con3('NORMAL_BEFORE_OPTIONAL_PARAMETERS', 98, "Normal parameters must occur before optional parameters");
|
| - static final ParserErrorCode POSITIONAL_AFTER_NAMED_ARGUMENT = new ParserErrorCode.con3('POSITIONAL_AFTER_NAMED_ARGUMENT', 99, "Positional arguments must occur before named arguments");
|
| - static final ParserErrorCode POSITIONAL_PARAMETER_OUTSIDE_GROUP = new ParserErrorCode.con3('POSITIONAL_PARAMETER_OUTSIDE_GROUP', 100, "Positional parameters must be enclosed in square brackets ('[' and ']')");
|
| - static final ParserErrorCode REDIRECTION_IN_NON_FACTORY_CONSTRUCTOR = new ParserErrorCode.con3('REDIRECTION_IN_NON_FACTORY_CONSTRUCTOR', 101, "Only factory constructor can specify '=' redirection.");
|
| - static final ParserErrorCode STATIC_AFTER_CONST = new ParserErrorCode.con3('STATIC_AFTER_CONST', 102, "The modifier 'static' should be before the modifier 'const'");
|
| - static final ParserErrorCode STATIC_AFTER_FINAL = new ParserErrorCode.con3('STATIC_AFTER_FINAL', 103, "The modifier 'static' should be before the modifier 'final'");
|
| - static final ParserErrorCode STATIC_AFTER_VAR = new ParserErrorCode.con3('STATIC_AFTER_VAR', 104, "The modifier 'static' should be before the modifier 'var'");
|
| - static final ParserErrorCode STATIC_CONSTRUCTOR = new ParserErrorCode.con3('STATIC_CONSTRUCTOR', 105, "Constructors cannot be static");
|
| - static final ParserErrorCode STATIC_GETTER_WITHOUT_BODY = new ParserErrorCode.con3('STATIC_GETTER_WITHOUT_BODY', 106, "A 'static' getter must have a body");
|
| - static final ParserErrorCode STATIC_OPERATOR = new ParserErrorCode.con3('STATIC_OPERATOR', 107, "Operators cannot be static");
|
| - static final ParserErrorCode STATIC_SETTER_WITHOUT_BODY = new ParserErrorCode.con3('STATIC_SETTER_WITHOUT_BODY', 108, "A 'static' setter must have a body");
|
| - static final ParserErrorCode STATIC_TOP_LEVEL_DECLARATION = new ParserErrorCode.con3('STATIC_TOP_LEVEL_DECLARATION', 109, "Top-level declarations cannot be declared to be 'static'");
|
| - static final ParserErrorCode SWITCH_HAS_CASE_AFTER_DEFAULT_CASE = new ParserErrorCode.con3('SWITCH_HAS_CASE_AFTER_DEFAULT_CASE', 110, "The 'default' case should be the last case in a switch statement");
|
| - static final ParserErrorCode SWITCH_HAS_MULTIPLE_DEFAULT_CASES = new ParserErrorCode.con3('SWITCH_HAS_MULTIPLE_DEFAULT_CASES', 111, "The 'default' case can only be declared once");
|
| - static final ParserErrorCode TOP_LEVEL_OPERATOR = new ParserErrorCode.con3('TOP_LEVEL_OPERATOR', 112, "Operators must be declared within a class");
|
| - static final ParserErrorCode UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP = new ParserErrorCode.con3('UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP', 113, "There is no '%s' to open a parameter group");
|
| - static final ParserErrorCode UNEXPECTED_TOKEN = new ParserErrorCode.con3('UNEXPECTED_TOKEN', 114, "Unexpected token '%s'");
|
| - static final ParserErrorCode WITH_BEFORE_EXTENDS = new ParserErrorCode.con3('WITH_BEFORE_EXTENDS', 115, "The extends clause must be before the with clause");
|
| - static final ParserErrorCode WITH_WITHOUT_EXTENDS = new ParserErrorCode.con3('WITH_WITHOUT_EXTENDS', 116, "The with clause cannot be used without an extends clause");
|
| - static final ParserErrorCode WRONG_SEPARATOR_FOR_NAMED_PARAMETER = new ParserErrorCode.con3('WRONG_SEPARATOR_FOR_NAMED_PARAMETER', 117, "The default value of a named parameter should be preceeded by ':'");
|
| - static final ParserErrorCode WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER = new ParserErrorCode.con3('WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER', 118, "The default value of a positional parameter should be preceeded by '='");
|
| - static final ParserErrorCode WRONG_TERMINATOR_FOR_PARAMETER_GROUP = new ParserErrorCode.con3('WRONG_TERMINATOR_FOR_PARAMETER_GROUP', 119, "Expected '%s' to close parameter group");
|
| - static final ParserErrorCode VAR_AND_TYPE = new ParserErrorCode.con3('VAR_AND_TYPE', 120, "Variables cannot be declared using both 'var' and a type name; remove the 'var'");
|
| - static final ParserErrorCode VAR_AS_TYPE_NAME = new ParserErrorCode.con3('VAR_AS_TYPE_NAME', 121, "The keyword 'var' cannot be used as a type name");
|
| - static final ParserErrorCode VAR_CLASS = new ParserErrorCode.con3('VAR_CLASS', 122, "Classes cannot be declared to be 'var'");
|
| - static final ParserErrorCode VAR_RETURN_TYPE = new ParserErrorCode.con3('VAR_RETURN_TYPE', 123, "The return type cannot be 'var'");
|
| - static final ParserErrorCode VAR_TYPEDEF = new ParserErrorCode.con3('VAR_TYPEDEF', 124, "Type aliases cannot be declared to be 'var'");
|
| - static final ParserErrorCode VOID_PARAMETER = new ParserErrorCode.con3('VOID_PARAMETER', 125, "Parameters cannot have a type of 'void'");
|
| - static final ParserErrorCode VOID_VARIABLE = new ParserErrorCode.con3('VOID_VARIABLE', 126, "Variables cannot have a type of 'void'");
|
| + static final ParserErrorCode GETTER_IN_FUNCTION = new ParserErrorCode.con3('GETTER_IN_FUNCTION', 51, "Getters cannot be defined within methods or functions");
|
| + static final ParserErrorCode GETTER_WITH_PARAMETERS = new ParserErrorCode.con3('GETTER_WITH_PARAMETERS', 52, "Getter should be declared without a parameter list");
|
| + static final ParserErrorCode ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE = new ParserErrorCode.con3('ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE', 53, "Illegal assignment to non-assignable expression");
|
| + static final ParserErrorCode IMPLEMENTS_BEFORE_EXTENDS = new ParserErrorCode.con3('IMPLEMENTS_BEFORE_EXTENDS', 54, "The extends clause must be before the implements clause");
|
| + static final ParserErrorCode IMPLEMENTS_BEFORE_WITH = new ParserErrorCode.con3('IMPLEMENTS_BEFORE_WITH', 55, "The with clause must be before the implements clause");
|
| + static final ParserErrorCode IMPORT_DIRECTIVE_AFTER_PART_DIRECTIVE = new ParserErrorCode.con3('IMPORT_DIRECTIVE_AFTER_PART_DIRECTIVE', 56, "Import directives must preceed part directives");
|
| + static final ParserErrorCode INITIALIZED_VARIABLE_IN_FOR_EACH = new ParserErrorCode.con3('INITIALIZED_VARIABLE_IN_FOR_EACH', 57, "The loop variable in a for-each loop cannot be initialized");
|
| + static final ParserErrorCode INVALID_CODE_POINT = new ParserErrorCode.con3('INVALID_CODE_POINT', 58, "The escape sequence '%s' is not a valid code point");
|
| + static final ParserErrorCode INVALID_COMMENT_REFERENCE = new ParserErrorCode.con3('INVALID_COMMENT_REFERENCE', 59, "Comment references should contain a possibly prefixed identifier and can start with 'new', but should not contain anything else");
|
| + static final ParserErrorCode INVALID_HEX_ESCAPE = new ParserErrorCode.con3('INVALID_HEX_ESCAPE', 60, "An escape sequence starting with '\\x' must be followed by 2 hexidecimal digits");
|
| + static final ParserErrorCode INVALID_OPERATOR = new ParserErrorCode.con3('INVALID_OPERATOR', 61, "The string '%s' is not a valid operator");
|
| + static final ParserErrorCode INVALID_OPERATOR_FOR_SUPER = new ParserErrorCode.con3('INVALID_OPERATOR_FOR_SUPER', 62, "The operator '%s' cannot be used with 'super'");
|
| + static final ParserErrorCode INVALID_UNICODE_ESCAPE = new ParserErrorCode.con3('INVALID_UNICODE_ESCAPE', 63, "An escape sequence starting with '\\u' must be followed by 4 hexidecimal digits or from 1 to 6 digits between '{' and '}'");
|
| + static final ParserErrorCode LIBRARY_DIRECTIVE_NOT_FIRST = new ParserErrorCode.con3('LIBRARY_DIRECTIVE_NOT_FIRST', 64, "The library directive must appear before all other directives");
|
| + static final ParserErrorCode LOCAL_FUNCTION_DECLARATION_MODIFIER = new ParserErrorCode.con3('LOCAL_FUNCTION_DECLARATION_MODIFIER', 65, "Local function declarations cannot specify any modifier");
|
| + static final ParserErrorCode MISSING_ASSIGNABLE_SELECTOR = new ParserErrorCode.con3('MISSING_ASSIGNABLE_SELECTOR', 66, "Missing selector such as \".<identifier>\" or \"[0]\"");
|
| + static final ParserErrorCode MISSING_CATCH_OR_FINALLY = new ParserErrorCode.con3('MISSING_CATCH_OR_FINALLY', 67, "A try statement must have either a catch or finally clause");
|
| + static final ParserErrorCode MISSING_CLASS_BODY = new ParserErrorCode.con3('MISSING_CLASS_BODY', 68, "A class definition must have a body, even if it is empty");
|
| + static final ParserErrorCode MISSING_CLOSING_PARENTHESIS = new ParserErrorCode.con3('MISSING_CLOSING_PARENTHESIS', 69, "The closing parenthesis is missing");
|
| + static final ParserErrorCode MISSING_CONST_FINAL_VAR_OR_TYPE = new ParserErrorCode.con3('MISSING_CONST_FINAL_VAR_OR_TYPE', 70, "Variables must be declared using the keywords 'const', 'final', 'var' or a type name");
|
| + static final ParserErrorCode MISSING_EXPRESSION_IN_THROW = new ParserErrorCode.con3('MISSING_EXPRESSION_IN_THROW', 71, "Throw expressions must compute the object to be thrown");
|
| + static final ParserErrorCode MISSING_FUNCTION_BODY = new ParserErrorCode.con3('MISSING_FUNCTION_BODY', 72, "A function body must be provided");
|
| + static final ParserErrorCode MISSING_FUNCTION_PARAMETERS = new ParserErrorCode.con3('MISSING_FUNCTION_PARAMETERS', 73, "Functions must have an explicit list of parameters");
|
| + static final ParserErrorCode MISSING_IDENTIFIER = new ParserErrorCode.con3('MISSING_IDENTIFIER', 74, "Expected an identifier");
|
| + static final ParserErrorCode MISSING_KEYWORD_OPERATOR = new ParserErrorCode.con3('MISSING_KEYWORD_OPERATOR', 75, "Operator declarations must be preceeded by the keyword 'operator'");
|
| + static final ParserErrorCode MISSING_NAME_IN_LIBRARY_DIRECTIVE = new ParserErrorCode.con3('MISSING_NAME_IN_LIBRARY_DIRECTIVE', 76, "Library directives must include a library name");
|
| + static final ParserErrorCode MISSING_NAME_IN_PART_OF_DIRECTIVE = new ParserErrorCode.con3('MISSING_NAME_IN_PART_OF_DIRECTIVE', 77, "Library directives must include a library name");
|
| + static final ParserErrorCode MISSING_STATEMENT = new ParserErrorCode.con3('MISSING_STATEMENT', 78, "Expected a statement");
|
| + static final ParserErrorCode MISSING_TERMINATOR_FOR_PARAMETER_GROUP = new ParserErrorCode.con3('MISSING_TERMINATOR_FOR_PARAMETER_GROUP', 79, "There is no '%s' to close the parameter group");
|
| + static final ParserErrorCode MISSING_TYPEDEF_PARAMETERS = new ParserErrorCode.con3('MISSING_TYPEDEF_PARAMETERS', 80, "Type aliases for functions must have an explicit list of parameters");
|
| + static final ParserErrorCode MISSING_VARIABLE_IN_FOR_EACH = new ParserErrorCode.con3('MISSING_VARIABLE_IN_FOR_EACH', 81, "A loop variable must be declared in a for-each loop before the 'in', but none were found");
|
| + static final ParserErrorCode MIXED_PARAMETER_GROUPS = new ParserErrorCode.con3('MIXED_PARAMETER_GROUPS', 82, "Cannot have both positional and named parameters in a single parameter list");
|
| + static final ParserErrorCode MULTIPLE_EXTENDS_CLAUSES = new ParserErrorCode.con3('MULTIPLE_EXTENDS_CLAUSES', 83, "Each class definition can have at most one extends clause");
|
| + static final ParserErrorCode MULTIPLE_IMPLEMENTS_CLAUSES = new ParserErrorCode.con3('MULTIPLE_IMPLEMENTS_CLAUSES', 84, "Each class definition can have at most one implements clause");
|
| + static final ParserErrorCode MULTIPLE_LIBRARY_DIRECTIVES = new ParserErrorCode.con3('MULTIPLE_LIBRARY_DIRECTIVES', 85, "Only one library directive may be declared in a file");
|
| + static final ParserErrorCode MULTIPLE_NAMED_PARAMETER_GROUPS = new ParserErrorCode.con3('MULTIPLE_NAMED_PARAMETER_GROUPS', 86, "Cannot have multiple groups of named parameters in a single parameter list");
|
| + static final ParserErrorCode MULTIPLE_PART_OF_DIRECTIVES = new ParserErrorCode.con3('MULTIPLE_PART_OF_DIRECTIVES', 87, "Only one part-of directive may be declared in a file");
|
| + static final ParserErrorCode MULTIPLE_POSITIONAL_PARAMETER_GROUPS = new ParserErrorCode.con3('MULTIPLE_POSITIONAL_PARAMETER_GROUPS', 88, "Cannot have multiple groups of positional parameters in a single parameter list");
|
| + static final ParserErrorCode MULTIPLE_VARIABLES_IN_FOR_EACH = new ParserErrorCode.con3('MULTIPLE_VARIABLES_IN_FOR_EACH', 89, "A single loop variable must be declared in a for-each loop before the 'in', but %s were found");
|
| + static final ParserErrorCode MULTIPLE_WITH_CLAUSES = new ParserErrorCode.con3('MULTIPLE_WITH_CLAUSES', 90, "Each class definition can have at most one with clause");
|
| + static final ParserErrorCode NAMED_FUNCTION_EXPRESSION = new ParserErrorCode.con3('NAMED_FUNCTION_EXPRESSION', 91, "Function expressions cannot be named");
|
| + static final ParserErrorCode NAMED_PARAMETER_OUTSIDE_GROUP = new ParserErrorCode.con3('NAMED_PARAMETER_OUTSIDE_GROUP', 92, "Named parameters must be enclosed in curly braces ('{' and '}')");
|
| + static final ParserErrorCode NATIVE_CLAUSE_IN_NON_SDK_CODE = new ParserErrorCode.con3('NATIVE_CLAUSE_IN_NON_SDK_CODE', 93, "Native clause can only be used in the SDK and code that is loaded through native extensions");
|
| + static final ParserErrorCode NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE = new ParserErrorCode.con3('NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE', 94, "Native functions can only be declared in the SDK and code that is loaded through native extensions");
|
| + static final ParserErrorCode NON_CONSTRUCTOR_FACTORY = new ParserErrorCode.con3('NON_CONSTRUCTOR_FACTORY', 95, "Only constructors can be declared to be a 'factory'");
|
| + static final ParserErrorCode NON_IDENTIFIER_LIBRARY_NAME = new ParserErrorCode.con3('NON_IDENTIFIER_LIBRARY_NAME', 96, "The name of a library must be an identifier");
|
| + static final ParserErrorCode NON_PART_OF_DIRECTIVE_IN_PART = new ParserErrorCode.con3('NON_PART_OF_DIRECTIVE_IN_PART', 97, "The part-of directive must be the only directive in a part");
|
| + static final ParserErrorCode NON_USER_DEFINABLE_OPERATOR = new ParserErrorCode.con3('NON_USER_DEFINABLE_OPERATOR', 98, "The operator '%s' is not user definable");
|
| + static final ParserErrorCode NORMAL_BEFORE_OPTIONAL_PARAMETERS = new ParserErrorCode.con3('NORMAL_BEFORE_OPTIONAL_PARAMETERS', 99, "Normal parameters must occur before optional parameters");
|
| + static final ParserErrorCode POSITIONAL_AFTER_NAMED_ARGUMENT = new ParserErrorCode.con3('POSITIONAL_AFTER_NAMED_ARGUMENT', 100, "Positional arguments must occur before named arguments");
|
| + static final ParserErrorCode POSITIONAL_PARAMETER_OUTSIDE_GROUP = new ParserErrorCode.con3('POSITIONAL_PARAMETER_OUTSIDE_GROUP', 101, "Positional parameters must be enclosed in square brackets ('[' and ']')");
|
| + static final ParserErrorCode REDIRECTION_IN_NON_FACTORY_CONSTRUCTOR = new ParserErrorCode.con3('REDIRECTION_IN_NON_FACTORY_CONSTRUCTOR', 102, "Only factory constructor can specify '=' redirection.");
|
| + static final ParserErrorCode SETTER_IN_FUNCTION = new ParserErrorCode.con3('SETTER_IN_FUNCTION', 103, "Setters cannot be defined within methods or functions");
|
| + static final ParserErrorCode STATIC_AFTER_CONST = new ParserErrorCode.con3('STATIC_AFTER_CONST', 104, "The modifier 'static' should be before the modifier 'const'");
|
| + static final ParserErrorCode STATIC_AFTER_FINAL = new ParserErrorCode.con3('STATIC_AFTER_FINAL', 105, "The modifier 'static' should be before the modifier 'final'");
|
| + static final ParserErrorCode STATIC_AFTER_VAR = new ParserErrorCode.con3('STATIC_AFTER_VAR', 106, "The modifier 'static' should be before the modifier 'var'");
|
| + static final ParserErrorCode STATIC_CONSTRUCTOR = new ParserErrorCode.con3('STATIC_CONSTRUCTOR', 107, "Constructors cannot be static");
|
| + static final ParserErrorCode STATIC_GETTER_WITHOUT_BODY = new ParserErrorCode.con3('STATIC_GETTER_WITHOUT_BODY', 108, "A 'static' getter must have a body");
|
| + static final ParserErrorCode STATIC_OPERATOR = new ParserErrorCode.con3('STATIC_OPERATOR', 109, "Operators cannot be static");
|
| + static final ParserErrorCode STATIC_SETTER_WITHOUT_BODY = new ParserErrorCode.con3('STATIC_SETTER_WITHOUT_BODY', 110, "A 'static' setter must have a body");
|
| + static final ParserErrorCode STATIC_TOP_LEVEL_DECLARATION = new ParserErrorCode.con3('STATIC_TOP_LEVEL_DECLARATION', 111, "Top-level declarations cannot be declared to be 'static'");
|
| + static final ParserErrorCode SWITCH_HAS_CASE_AFTER_DEFAULT_CASE = new ParserErrorCode.con3('SWITCH_HAS_CASE_AFTER_DEFAULT_CASE', 112, "The 'default' case should be the last case in a switch statement");
|
| + static final ParserErrorCode SWITCH_HAS_MULTIPLE_DEFAULT_CASES = new ParserErrorCode.con3('SWITCH_HAS_MULTIPLE_DEFAULT_CASES', 113, "The 'default' case can only be declared once");
|
| + static final ParserErrorCode TOP_LEVEL_OPERATOR = new ParserErrorCode.con3('TOP_LEVEL_OPERATOR', 114, "Operators must be declared within a class");
|
| + static final ParserErrorCode UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP = new ParserErrorCode.con3('UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP', 115, "There is no '%s' to open a parameter group");
|
| + static final ParserErrorCode UNEXPECTED_TOKEN = new ParserErrorCode.con3('UNEXPECTED_TOKEN', 116, "Unexpected token '%s'");
|
| + static final ParserErrorCode WITH_BEFORE_EXTENDS = new ParserErrorCode.con3('WITH_BEFORE_EXTENDS', 117, "The extends clause must be before the with clause");
|
| + static final ParserErrorCode WITH_WITHOUT_EXTENDS = new ParserErrorCode.con3('WITH_WITHOUT_EXTENDS', 118, "The with clause cannot be used without an extends clause");
|
| + static final ParserErrorCode WRONG_SEPARATOR_FOR_NAMED_PARAMETER = new ParserErrorCode.con3('WRONG_SEPARATOR_FOR_NAMED_PARAMETER', 119, "The default value of a named parameter should be preceeded by ':'");
|
| + static final ParserErrorCode WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER = new ParserErrorCode.con3('WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER', 120, "The default value of a positional parameter should be preceeded by '='");
|
| + static final ParserErrorCode WRONG_TERMINATOR_FOR_PARAMETER_GROUP = new ParserErrorCode.con3('WRONG_TERMINATOR_FOR_PARAMETER_GROUP', 121, "Expected '%s' to close parameter group");
|
| + static final ParserErrorCode VAR_AND_TYPE = new ParserErrorCode.con3('VAR_AND_TYPE', 122, "Variables cannot be declared using both 'var' and a type name; remove the 'var'");
|
| + static final ParserErrorCode VAR_AS_TYPE_NAME = new ParserErrorCode.con3('VAR_AS_TYPE_NAME', 123, "The keyword 'var' cannot be used as a type name");
|
| + static final ParserErrorCode VAR_CLASS = new ParserErrorCode.con3('VAR_CLASS', 124, "Classes cannot be declared to be 'var'");
|
| + static final ParserErrorCode VAR_RETURN_TYPE = new ParserErrorCode.con3('VAR_RETURN_TYPE', 125, "The return type cannot be 'var'");
|
| + static final ParserErrorCode VAR_TYPEDEF = new ParserErrorCode.con3('VAR_TYPEDEF', 126, "Type aliases cannot be declared to be 'var'");
|
| + static final ParserErrorCode VOID_PARAMETER = new ParserErrorCode.con3('VOID_PARAMETER', 127, "Parameters cannot have a type of 'void'");
|
| + static final ParserErrorCode VOID_VARIABLE = new ParserErrorCode.con3('VOID_VARIABLE', 128, "Variables cannot have a type of 'void'");
|
| static final List<ParserErrorCode> values = [
|
| ABSTRACT_CLASS_MEMBER,
|
| ABSTRACT_STATIC_METHOD,
|
| @@ -5779,6 +5842,7 @@ class ParserErrorCode extends Enum<ParserErrorCode> implements ErrorCode {
|
| FINAL_METHOD,
|
| FINAL_TYPEDEF,
|
| FUNCTION_TYPED_PARAMETER_VAR,
|
| + GETTER_IN_FUNCTION,
|
| GETTER_WITH_PARAMETERS,
|
| ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE,
|
| IMPLEMENTS_BEFORE_EXTENDS,
|
| @@ -5830,6 +5894,7 @@ class ParserErrorCode extends Enum<ParserErrorCode> implements ErrorCode {
|
| POSITIONAL_AFTER_NAMED_ARGUMENT,
|
| POSITIONAL_PARAMETER_OUTSIDE_GROUP,
|
| REDIRECTION_IN_NON_FACTORY_CONSTRUCTOR,
|
| + SETTER_IN_FUNCTION,
|
| STATIC_AFTER_CONST,
|
| STATIC_AFTER_FINAL,
|
| STATIC_AFTER_VAR,
|
| @@ -6210,8 +6275,13 @@ class ToFormattedSourceVisitor implements ASTVisitor<Object> {
|
| return null;
|
| }
|
| Object visitForEachStatement(ForEachStatement node) {
|
| + DeclaredIdentifier loopVariable = node.loopVariable;
|
| _writer.print("for (");
|
| - visit(node.loopVariable);
|
| + if (loopVariable == null) {
|
| + visit(node.identifier);
|
| + } else {
|
| + visit(loopVariable);
|
| + }
|
| _writer.print(" in ");
|
| visit(node.iterator);
|
| _writer.print(") ");
|
|
|