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

Side by Side Diff: pkg/analyzer_experimental/lib/src/generated/parser.dart

Issue 16611004: Improve java2dart code style - relax 'don't reference variable name in its initializer'. (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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // This code was auto-generated, is not intended to be edited, and is subject to 1 // This code was auto-generated, is not intended to be edited, and is subject to
2 // significant change. Please see the README file for more information. 2 // significant change. Please see the README file for more information.
3 library engine.parser; 3 library engine.parser;
4 import 'dart:collection'; 4 import 'dart:collection';
5 import 'java_core.dart'; 5 import 'java_core.dart';
6 import 'java_engine.dart'; 6 import 'java_engine.dart';
7 import 'instrumentation.dart'; 7 import 'instrumentation.dart';
8 import 'error.dart'; 8 import 'error.dart';
9 import 'source.dart'; 9 import 'source.dart';
10 import 'scanner.dart'; 10 import 'scanner.dart';
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 } 583 }
584 584
585 /** 585 /**
586 * Return a list of the ranges of characters in the given comment string that should be treated as 586 * Return a list of the ranges of characters in the given comment string that should be treated as
587 * code blocks. 587 * code blocks.
588 * @param comment the comment being processed 588 * @param comment the comment being processed
589 * @return the ranges of characters that should be treated as code blocks 589 * @return the ranges of characters that should be treated as code blocks
590 */ 590 */
591 List<List<int>> getCodeBlockRanges(String comment) { 591 List<List<int>> getCodeBlockRanges(String comment) {
592 List<List<int>> ranges = new List<List<int>>(); 592 List<List<int>> ranges = new List<List<int>>();
593 int length2 = comment.length; 593 int length = comment.length;
594 int index = 0; 594 int index = 0;
595 if (comment.startsWith("/**") || comment.startsWith("///")) { 595 if (comment.startsWith("/**") || comment.startsWith("///")) {
596 index = 3; 596 index = 3;
597 } 597 }
598 while (index < length2) { 598 while (index < length) {
599 int currentChar = comment.codeUnitAt(index); 599 int currentChar = comment.codeUnitAt(index);
600 if (currentChar == 0xD || currentChar == 0xA) { 600 if (currentChar == 0xD || currentChar == 0xA) {
601 index = index + 1; 601 index = index + 1;
602 while (index < length2 && Character.isWhitespace(comment.codeUnitAt(inde x))) { 602 while (index < length && Character.isWhitespace(comment.codeUnitAt(index ))) {
603 index = index + 1; 603 index = index + 1;
604 } 604 }
605 if (JavaString.startsWithBefore(comment, "* ", index)) { 605 if (JavaString.startsWithBefore(comment, "* ", index)) {
606 int end = index + 6; 606 int end = index + 6;
607 while (end < length2 && comment.codeUnitAt(end) != 0xD && comment.code UnitAt(end) != 0xA) { 607 while (end < length && comment.codeUnitAt(end) != 0xD && comment.codeU nitAt(end) != 0xA) {
608 end = end + 1; 608 end = end + 1;
609 } 609 }
610 ranges.add(<int> [index, end]); 610 ranges.add(<int> [index, end]);
611 index = end; 611 index = end;
612 } 612 }
613 } else if (JavaString.startsWithBefore(comment, "[:", index)) { 613 } else if (JavaString.startsWithBefore(comment, "[:", index)) {
614 int end = comment.indexOf(":]", index + 2); 614 int end = comment.indexOf(":]", index + 2);
615 if (end < 0) { 615 if (end < 0) {
616 end = length2; 616 end = length;
617 } 617 }
618 ranges.add(<int> [index, end]); 618 ranges.add(<int> [index, end]);
619 index = end + 1; 619 index = end + 1;
620 } else { 620 } else {
621 index = index + 1; 621 index = index + 1;
622 } 622 }
623 } 623 }
624 return ranges; 624 return ranges;
625 } 625 }
626 626
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 return !matchesAny(peek(), [TokenType.LT, TokenType.OPEN_CURLY_BRACKET, To kenType.OPEN_SQUARE_BRACKET, TokenType.INDEX]); 725 return !matchesAny(peek(), [TokenType.LT, TokenType.OPEN_CURLY_BRACKET, To kenType.OPEN_SQUARE_BRACKET, TokenType.INDEX]);
726 } 726 }
727 Token token = skipTypeName(_currentToken); 727 Token token = skipTypeName(_currentToken);
728 if (token == null) { 728 if (token == null) {
729 return false; 729 return false;
730 } 730 }
731 token = skipSimpleIdentifier(token); 731 token = skipSimpleIdentifier(token);
732 if (token == null) { 732 if (token == null) {
733 return false; 733 return false;
734 } 734 }
735 TokenType type2 = token.type; 735 TokenType type = token.type;
736 return identical(type2, TokenType.EQ) || identical(type2, TokenType.COMMA) | | identical(type2, TokenType.SEMICOLON) || matches3(token, Keyword.IN); 736 return identical(type, TokenType.EQ) || identical(type, TokenType.COMMA) || identical(type, TokenType.SEMICOLON) || matches3(token, Keyword.IN);
737 } 737 }
738 738
739 /** 739 /**
740 * Given that we have just found bracketed text within a comment, look to see whether that text is 740 * Given that we have just found bracketed text within a comment, look to see whether that text is
741 * (a) followed by a parenthesized link address, (b) followed by a colon, or ( c) followed by 741 * (a) followed by a parenthesized link address, (b) followed by a colon, or ( c) followed by
742 * optional whitespace and another square bracket. 742 * optional whitespace and another square bracket.
743 * <p> 743 * <p>
744 * This method uses the syntax described by the <a 744 * This method uses the syntax described by the <a
745 * href="http://daringfireball.net/projects/markdown/syntax">markdown</a> proj ect. 745 * href="http://daringfireball.net/projects/markdown/syntax">markdown</a> proj ect.
746 * @param comment the comment text in which the bracketed text was found 746 * @param comment the comment text in which the bracketed text was found
747 * @param rightIndex the index of the right bracket 747 * @param rightIndex the index of the right bracket
748 * @return {@code true} if the bracketed text is followed by a link address 748 * @return {@code true} if the bracketed text is followed by a link address
749 */ 749 */
750 bool isLinkText(String comment, int rightIndex) { 750 bool isLinkText(String comment, int rightIndex) {
751 int length2 = comment.length; 751 int length = comment.length;
752 int index = rightIndex + 1; 752 int index = rightIndex + 1;
753 if (index >= length2) { 753 if (index >= length) {
754 return false; 754 return false;
755 } 755 }
756 int nextChar = comment.codeUnitAt(index); 756 int nextChar = comment.codeUnitAt(index);
757 if (nextChar == 0x28 || nextChar == 0x3A) { 757 if (nextChar == 0x28 || nextChar == 0x3A) {
758 return true; 758 return true;
759 } 759 }
760 while (Character.isWhitespace(nextChar)) { 760 while (Character.isWhitespace(nextChar)) {
761 index = index + 1; 761 index = index + 1;
762 if (index >= length2) { 762 if (index >= length) {
763 return false; 763 return false;
764 } 764 }
765 nextChar = comment.codeUnitAt(index); 765 nextChar = comment.codeUnitAt(index);
766 } 766 }
767 return nextChar == 0x5B; 767 return nextChar == 0x5B;
768 } 768 }
769 769
770 /** 770 /**
771 * Return {@code true} if the given token appears to be the beginning of an op erator declaration. 771 * Return {@code true} if the given token appears to be the beginning of an op erator declaration.
772 * @param startToken the token that might be the start of an operator declarat ion 772 * @param startToken the token that might be the start of an operator declarat ion
(...skipping 13 matching lines...) Expand all
786 /** 786 /**
787 * Return {@code true} if the current token appears to be the beginning of a s witch member. 787 * Return {@code true} if the current token appears to be the beginning of a s witch member.
788 * @return {@code true} if the current token appears to be the beginning of a switch member 788 * @return {@code true} if the current token appears to be the beginning of a switch member
789 */ 789 */
790 bool isSwitchMember() { 790 bool isSwitchMember() {
791 Token token = _currentToken; 791 Token token = _currentToken;
792 while (matches4(token, TokenType.IDENTIFIER) && matches4(token.next, TokenTy pe.COLON)) { 792 while (matches4(token, TokenType.IDENTIFIER) && matches4(token.next, TokenTy pe.COLON)) {
793 token = token.next.next; 793 token = token.next.next;
794 } 794 }
795 if (identical(token.type, TokenType.KEYWORD)) { 795 if (identical(token.type, TokenType.KEYWORD)) {
796 Keyword keyword2 = ((token as KeywordToken)).keyword; 796 Keyword keyword = ((token as KeywordToken)).keyword;
797 return identical(keyword2, Keyword.CASE) || identical(keyword2, Keyword.DE FAULT); 797 return identical(keyword, Keyword.CASE) || identical(keyword, Keyword.DEFA ULT);
798 } 798 }
799 return false; 799 return false;
800 } 800 }
801 801
802 /** 802 /**
803 * Compare the given tokens to find the token that appears first in the source being parsed. That 803 * Compare the given tokens to find the token that appears first in the source being parsed. That
804 * is, return the left-most of all of the tokens. The arguments are allowed to be {@code null}. 804 * is, return the left-most of all of the tokens. The arguments are allowed to be {@code null}.
805 * Return the token with the smallest offset, or {@code null} if there are no arguments or if all 805 * Return the token with the smallest offset, or {@code null} if there are no arguments or if all
806 * of the arguments are {@code null}. 806 * of the arguments are {@code null}.
807 * @param tokens the tokens being compared 807 * @param tokens the tokens being compared
808 * @return the token with the smallest offset 808 * @return the token with the smallest offset
809 */ 809 */
810 Token lexicallyFirst(List<Token> tokens) { 810 Token lexicallyFirst(List<Token> tokens) {
811 Token first = null; 811 Token first = null;
812 int firstOffset = 2147483647; 812 int firstOffset = 2147483647;
813 for (Token token in tokens) { 813 for (Token token in tokens) {
814 if (token != null) { 814 if (token != null) {
815 int offset2 = token.offset; 815 int offset = token.offset;
816 if (offset2 < firstOffset) { 816 if (offset < firstOffset) {
817 first = token; 817 first = token;
818 firstOffset = offset2; 818 firstOffset = offset;
819 } 819 }
820 } 820 }
821 } 821 }
822 return first; 822 return first;
823 } 823 }
824 824
825 /** 825 /**
826 * Return {@code true} if the current token matches the given keyword. 826 * Return {@code true} if the current token matches the given keyword.
827 * @param keyword the keyword that can optionally appear in the current locati on 827 * @param keyword the keyword that can optionally appear in the current locati on
828 * @return {@code true} if the current token matches the given keyword 828 * @return {@code true} if the current token matches the given keyword
(...skipping 29 matching lines...) Expand all
858 * particular, if we are attempting to match a '>' and the next token is eithe r a '>>' or '>>>', 858 * particular, if we are attempting to match a '>' and the next token is eithe r a '>>' or '>>>',
859 * the token stream will be re-written and {@code true} will be returned. 859 * the token stream will be re-written and {@code true} will be returned.
860 * @param type the type of token that can optionally appear in the current loc ation 860 * @param type the type of token that can optionally appear in the current loc ation
861 * @return {@code true} if the current token has the given type 861 * @return {@code true} if the current token has the given type
862 */ 862 */
863 bool matches5(TokenType type2) { 863 bool matches5(TokenType type2) {
864 TokenType currentType = _currentToken.type; 864 TokenType currentType = _currentToken.type;
865 if (currentType != type2) { 865 if (currentType != type2) {
866 if (identical(type2, TokenType.GT)) { 866 if (identical(type2, TokenType.GT)) {
867 if (identical(currentType, TokenType.GT_GT)) { 867 if (identical(currentType, TokenType.GT_GT)) {
868 int offset2 = _currentToken.offset; 868 int offset = _currentToken.offset;
869 Token first = new Token(TokenType.GT, offset2); 869 Token first = new Token(TokenType.GT, offset);
870 Token second = new Token(TokenType.GT, offset2 + 1); 870 Token second = new Token(TokenType.GT, offset + 1);
871 second.setNext(_currentToken.next); 871 second.setNext(_currentToken.next);
872 first.setNext(second); 872 first.setNext(second);
873 _currentToken.previous.setNext(first); 873 _currentToken.previous.setNext(first);
874 _currentToken = first; 874 _currentToken = first;
875 return true; 875 return true;
876 } else if (identical(currentType, TokenType.GT_EQ)) { 876 } else if (identical(currentType, TokenType.GT_EQ)) {
877 int offset3 = _currentToken.offset; 877 int offset = _currentToken.offset;
878 Token first = new Token(TokenType.GT, offset3); 878 Token first = new Token(TokenType.GT, offset);
879 Token second = new Token(TokenType.EQ, offset3 + 1); 879 Token second = new Token(TokenType.EQ, offset + 1);
880 second.setNext(_currentToken.next); 880 second.setNext(_currentToken.next);
881 first.setNext(second); 881 first.setNext(second);
882 _currentToken.previous.setNext(first); 882 _currentToken.previous.setNext(first);
883 _currentToken = first; 883 _currentToken = first;
884 return true; 884 return true;
885 } else if (identical(currentType, TokenType.GT_GT_EQ)) { 885 } else if (identical(currentType, TokenType.GT_GT_EQ)) {
886 int offset4 = _currentToken.offset; 886 int offset = _currentToken.offset;
887 Token first = new Token(TokenType.GT, offset4); 887 Token first = new Token(TokenType.GT, offset);
888 Token second = new Token(TokenType.GT, offset4 + 1); 888 Token second = new Token(TokenType.GT, offset + 1);
889 Token third = new Token(TokenType.EQ, offset4 + 2); 889 Token third = new Token(TokenType.EQ, offset + 2);
890 third.setNext(_currentToken.next); 890 third.setNext(_currentToken.next);
891 second.setNext(third); 891 second.setNext(third);
892 first.setNext(second); 892 first.setNext(second);
893 _currentToken.previous.setNext(first); 893 _currentToken.previous.setNext(first);
894 _currentToken = first; 894 _currentToken = first;
895 return true; 895 return true;
896 } 896 }
897 } 897 }
898 return false; 898 return false;
899 } 899 }
(...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after
1716 * libraryReference ::= 1716 * libraryReference ::=
1717 * '(' stringLiteral ')' 1717 * '(' stringLiteral ')'
1718 * </pre> 1718 * </pre>
1719 * @param tokens the comment tokens representing the documentation comments to be parsed 1719 * @param tokens the comment tokens representing the documentation comments to be parsed
1720 * @return the comment references that were parsed 1720 * @return the comment references that were parsed
1721 */ 1721 */
1722 List<CommentReference> parseCommentReferences(List<Token> tokens) { 1722 List<CommentReference> parseCommentReferences(List<Token> tokens) {
1723 List<CommentReference> references = new List<CommentReference>(); 1723 List<CommentReference> references = new List<CommentReference>();
1724 for (Token token in tokens) { 1724 for (Token token in tokens) {
1725 String comment = token.lexeme; 1725 String comment = token.lexeme;
1726 int length2 = comment.length; 1726 int length = comment.length;
1727 List<List<int>> codeBlockRanges = getCodeBlockRanges(comment); 1727 List<List<int>> codeBlockRanges = getCodeBlockRanges(comment);
1728 int leftIndex = comment.indexOf('['); 1728 int leftIndex = comment.indexOf('[');
1729 while (leftIndex >= 0 && leftIndex + 1 < length2) { 1729 while (leftIndex >= 0 && leftIndex + 1 < length) {
1730 List<int> range = findRange(codeBlockRanges, leftIndex); 1730 List<int> range = findRange(codeBlockRanges, leftIndex);
1731 if (range == null) { 1731 if (range == null) {
1732 int rightIndex = comment.indexOf(']', leftIndex); 1732 int rightIndex = comment.indexOf(']', leftIndex);
1733 if (rightIndex >= 0) { 1733 if (rightIndex >= 0) {
1734 int firstChar = comment.codeUnitAt(leftIndex + 1); 1734 int firstChar = comment.codeUnitAt(leftIndex + 1);
1735 if (firstChar != 0x27 && firstChar != 0x22) { 1735 if (firstChar != 0x27 && firstChar != 0x22) {
1736 if (isLinkText(comment, rightIndex)) { 1736 if (isLinkText(comment, rightIndex)) {
1737 } else { 1737 } else {
1738 CommentReference reference = parseCommentReference(comment.subst ring(leftIndex + 1, rightIndex), token.offset + leftIndex + 1); 1738 CommentReference reference = parseCommentReference(comment.subst ring(leftIndex + 1, rightIndex), token.offset + leftIndex + 1);
1739 if (reference != null) { 1739 if (reference != null) {
(...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after
2551 } else if (isInitializedVariableDeclaration()) { 2551 } else if (isInitializedVariableDeclaration()) {
2552 variableList = parseVariableDeclarationList(commentAndMetadata); 2552 variableList = parseVariableDeclarationList(commentAndMetadata);
2553 } else { 2553 } else {
2554 initialization = parseExpression2(); 2554 initialization = parseExpression2();
2555 } 2555 }
2556 if (matches(Keyword.IN)) { 2556 if (matches(Keyword.IN)) {
2557 DeclaredIdentifier loopVariable = null; 2557 DeclaredIdentifier loopVariable = null;
2558 if (variableList == null) { 2558 if (variableList == null) {
2559 reportError7(ParserErrorCode.MISSING_VARIABLE_IN_FOR_EACH, []); 2559 reportError7(ParserErrorCode.MISSING_VARIABLE_IN_FOR_EACH, []);
2560 } else { 2560 } else {
2561 NodeList<VariableDeclaration> variables2 = variableList.variables; 2561 NodeList<VariableDeclaration> variables = variableList.variables;
2562 if (variables2.length > 1) { 2562 if (variables.length > 1) {
2563 reportError7(ParserErrorCode.MULTIPLE_VARIABLES_IN_FOR_EACH, [vari ables2.length.toString()]); 2563 reportError7(ParserErrorCode.MULTIPLE_VARIABLES_IN_FOR_EACH, [vari ables.length.toString()]);
2564 } 2564 }
2565 VariableDeclaration variable = variables2[0]; 2565 VariableDeclaration variable = variables[0];
2566 if (variable.initializer != null) { 2566 if (variable.initializer != null) {
2567 reportError7(ParserErrorCode.INITIALIZED_VARIABLE_IN_FOR_EACH, []) ; 2567 reportError7(ParserErrorCode.INITIALIZED_VARIABLE_IN_FOR_EACH, []) ;
2568 } 2568 }
2569 loopVariable = new DeclaredIdentifier.full(commentAndMetadata.commen t, commentAndMetadata.metadata, variableList.keyword, variableList.type, variabl e.name); 2569 loopVariable = new DeclaredIdentifier.full(commentAndMetadata.commen t, commentAndMetadata.metadata, variableList.keyword, variableList.type, variabl e.name);
2570 } 2570 }
2571 Token inKeyword = expect(Keyword.IN); 2571 Token inKeyword = expect(Keyword.IN);
2572 Expression iterator = parseExpression2(); 2572 Expression iterator = parseExpression2();
2573 Token rightParenthesis = expect2(TokenType.CLOSE_PAREN); 2573 Token rightParenthesis = expect2(TokenType.CLOSE_PAREN);
2574 Statement body = parseStatement2(); 2574 Statement body = parseStatement2();
2575 return new ForEachStatement.full(forKeyword, leftParenthesis, loopVari able, inKeyword, iterator, rightParenthesis, body); 2575 return new ForEachStatement.full(forKeyword, leftParenthesis, loopVari able, inKeyword, iterator, rightParenthesis, body);
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after
3306 CommentAndMetadata commentAndMetadata = parseCommentAndMetadata(); 3306 CommentAndMetadata commentAndMetadata = parseCommentAndMetadata();
3307 if (matches5(TokenType.OPEN_CURLY_BRACKET)) { 3307 if (matches5(TokenType.OPEN_CURLY_BRACKET)) {
3308 if (matches4(peek(), TokenType.STRING)) { 3308 if (matches4(peek(), TokenType.STRING)) {
3309 Token afterString = skipStringLiteral(_currentToken.next); 3309 Token afterString = skipStringLiteral(_currentToken.next);
3310 if (afterString != null && identical(afterString.type, TokenType.COLON)) { 3310 if (afterString != null && identical(afterString.type, TokenType.COLON)) {
3311 return new ExpressionStatement.full(parseExpression2(), expect2(TokenT ype.SEMICOLON)); 3311 return new ExpressionStatement.full(parseExpression2(), expect2(TokenT ype.SEMICOLON));
3312 } 3312 }
3313 } 3313 }
3314 return parseBlock(); 3314 return parseBlock();
3315 } else if (matches5(TokenType.KEYWORD) && !((_currentToken as KeywordToken)) .keyword.isPseudoKeyword()) { 3315 } else if (matches5(TokenType.KEYWORD) && !((_currentToken as KeywordToken)) .keyword.isPseudoKeyword()) {
3316 Keyword keyword2 = ((_currentToken as KeywordToken)).keyword; 3316 Keyword keyword = ((_currentToken as KeywordToken)).keyword;
3317 if (identical(keyword2, Keyword.ASSERT)) { 3317 if (identical(keyword, Keyword.ASSERT)) {
3318 return parseAssertStatement(); 3318 return parseAssertStatement();
3319 } else if (identical(keyword2, Keyword.BREAK)) { 3319 } else if (identical(keyword, Keyword.BREAK)) {
3320 return parseBreakStatement(); 3320 return parseBreakStatement();
3321 } else if (identical(keyword2, Keyword.CONTINUE)) { 3321 } else if (identical(keyword, Keyword.CONTINUE)) {
3322 return parseContinueStatement(); 3322 return parseContinueStatement();
3323 } else if (identical(keyword2, Keyword.DO)) { 3323 } else if (identical(keyword, Keyword.DO)) {
3324 return parseDoStatement(); 3324 return parseDoStatement();
3325 } else if (identical(keyword2, Keyword.FOR)) { 3325 } else if (identical(keyword, Keyword.FOR)) {
3326 return parseForStatement(); 3326 return parseForStatement();
3327 } else if (identical(keyword2, Keyword.IF)) { 3327 } else if (identical(keyword, Keyword.IF)) {
3328 return parseIfStatement(); 3328 return parseIfStatement();
3329 } else if (identical(keyword2, Keyword.RETHROW)) { 3329 } else if (identical(keyword, Keyword.RETHROW)) {
3330 return new ExpressionStatement.full(parseRethrowExpression(), expect2(To kenType.SEMICOLON)); 3330 return new ExpressionStatement.full(parseRethrowExpression(), expect2(To kenType.SEMICOLON));
3331 } else if (identical(keyword2, Keyword.RETURN)) { 3331 } else if (identical(keyword, Keyword.RETURN)) {
3332 return parseReturnStatement(); 3332 return parseReturnStatement();
3333 } else if (identical(keyword2, Keyword.SWITCH)) { 3333 } else if (identical(keyword, Keyword.SWITCH)) {
3334 return parseSwitchStatement(); 3334 return parseSwitchStatement();
3335 } else if (identical(keyword2, Keyword.THROW)) { 3335 } else if (identical(keyword, Keyword.THROW)) {
3336 return new ExpressionStatement.full(parseThrowExpression(), expect2(Toke nType.SEMICOLON)); 3336 return new ExpressionStatement.full(parseThrowExpression(), expect2(Toke nType.SEMICOLON));
3337 } else if (identical(keyword2, Keyword.TRY)) { 3337 } else if (identical(keyword, Keyword.TRY)) {
3338 return parseTryStatement(); 3338 return parseTryStatement();
3339 } else if (identical(keyword2, Keyword.WHILE)) { 3339 } else if (identical(keyword, Keyword.WHILE)) {
3340 return parseWhileStatement(); 3340 return parseWhileStatement();
3341 } else if (identical(keyword2, Keyword.VAR) || identical(keyword2, Keyword .FINAL)) { 3341 } else if (identical(keyword, Keyword.VAR) || identical(keyword, Keyword.F INAL)) {
3342 return parseVariableDeclarationStatement(commentAndMetadata); 3342 return parseVariableDeclarationStatement(commentAndMetadata);
3343 } else if (identical(keyword2, Keyword.VOID)) { 3343 } else if (identical(keyword, Keyword.VOID)) {
3344 TypeName returnType = parseReturnType(); 3344 TypeName returnType = parseReturnType();
3345 if (matchesIdentifier() && matchesAny(peek(), [TokenType.OPEN_PAREN, Tok enType.OPEN_CURLY_BRACKET, TokenType.FUNCTION])) { 3345 if (matchesIdentifier() && matchesAny(peek(), [TokenType.OPEN_PAREN, Tok enType.OPEN_CURLY_BRACKET, TokenType.FUNCTION])) {
3346 return parseFunctionDeclarationStatement2(commentAndMetadata, returnTy pe); 3346 return parseFunctionDeclarationStatement2(commentAndMetadata, returnTy pe);
3347 } else { 3347 } else {
3348 if (matchesIdentifier()) { 3348 if (matchesIdentifier()) {
3349 if (matchesAny(peek(), [TokenType.EQ, TokenType.COMMA, TokenType.SEM ICOLON])) { 3349 if (matchesAny(peek(), [TokenType.EQ, TokenType.COMMA, TokenType.SEM ICOLON])) {
3350 reportError(ParserErrorCode.VOID_VARIABLE, returnType, []); 3350 reportError(ParserErrorCode.VOID_VARIABLE, returnType, []);
3351 return parseVariableDeclarationStatement(commentAndMetadata); 3351 return parseVariableDeclarationStatement(commentAndMetadata);
3352 } 3352 }
3353 } else if (matches5(TokenType.CLOSE_CURLY_BRACKET)) { 3353 } else if (matches5(TokenType.CLOSE_CURLY_BRACKET)) {
3354 return parseVariableDeclarationStatement2(commentAndMetadata, null, returnType); 3354 return parseVariableDeclarationStatement2(commentAndMetadata, null, returnType);
3355 } 3355 }
3356 reportError7(ParserErrorCode.MISSING_STATEMENT, []); 3356 reportError7(ParserErrorCode.MISSING_STATEMENT, []);
3357 return new EmptyStatement.full(createSyntheticToken2(TokenType.SEMICOL ON)); 3357 return new EmptyStatement.full(createSyntheticToken2(TokenType.SEMICOL ON));
3358 } 3358 }
3359 } else if (identical(keyword2, Keyword.CONST)) { 3359 } else if (identical(keyword, Keyword.CONST)) {
3360 if (matchesAny(peek(), [TokenType.LT, TokenType.OPEN_CURLY_BRACKET, Toke nType.OPEN_SQUARE_BRACKET, TokenType.INDEX])) { 3360 if (matchesAny(peek(), [TokenType.LT, TokenType.OPEN_CURLY_BRACKET, Toke nType.OPEN_SQUARE_BRACKET, TokenType.INDEX])) {
3361 return new ExpressionStatement.full(parseExpression2(), expect2(TokenT ype.SEMICOLON)); 3361 return new ExpressionStatement.full(parseExpression2(), expect2(TokenT ype.SEMICOLON));
3362 } else if (matches4(peek(), TokenType.IDENTIFIER)) { 3362 } else if (matches4(peek(), TokenType.IDENTIFIER)) {
3363 Token afterType = skipTypeName(peek()); 3363 Token afterType = skipTypeName(peek());
3364 if (afterType != null) { 3364 if (afterType != null) {
3365 if (matches4(afterType, TokenType.OPEN_PAREN) || (matches4(afterType , TokenType.PERIOD) && matches4(afterType.next, TokenType.IDENTIFIER) && matches 4(afterType.next.next, TokenType.OPEN_PAREN))) { 3365 if (matches4(afterType, TokenType.OPEN_PAREN) || (matches4(afterType , TokenType.PERIOD) && matches4(afterType.next, TokenType.IDENTIFIER) && matches 4(afterType.next.next, TokenType.OPEN_PAREN))) {
3366 return new ExpressionStatement.full(parseExpression2(), expect2(To kenType.SEMICOLON)); 3366 return new ExpressionStatement.full(parseExpression2(), expect2(To kenType.SEMICOLON));
3367 } 3367 }
3368 } 3368 }
3369 } 3369 }
3370 return parseVariableDeclarationStatement(commentAndMetadata); 3370 return parseVariableDeclarationStatement(commentAndMetadata);
3371 } else if (identical(keyword2, Keyword.NEW) || identical(keyword2, Keyword .TRUE) || identical(keyword2, Keyword.FALSE) || identical(keyword2, Keyword.NULL ) || identical(keyword2, Keyword.SUPER) || identical(keyword2, Keyword.THIS)) { 3371 } else if (identical(keyword, Keyword.NEW) || identical(keyword, Keyword.T RUE) || identical(keyword, Keyword.FALSE) || identical(keyword, Keyword.NULL) || identical(keyword, Keyword.SUPER) || identical(keyword, Keyword.THIS)) {
3372 return new ExpressionStatement.full(parseExpression2(), expect2(TokenTyp e.SEMICOLON)); 3372 return new ExpressionStatement.full(parseExpression2(), expect2(TokenTyp e.SEMICOLON));
3373 } else { 3373 } else {
3374 reportError7(ParserErrorCode.MISSING_STATEMENT, []); 3374 reportError7(ParserErrorCode.MISSING_STATEMENT, []);
3375 return new EmptyStatement.full(createSyntheticToken2(TokenType.SEMICOLON )); 3375 return new EmptyStatement.full(createSyntheticToken2(TokenType.SEMICOLON ));
3376 } 3376 }
3377 } else if (matches5(TokenType.SEMICOLON)) { 3377 } else if (matches5(TokenType.SEMICOLON)) {
3378 return parseEmptyStatement(); 3378 return parseEmptyStatement();
3379 } else if (isInitializedVariableDeclaration()) { 3379 } else if (isInitializedVariableDeclaration()) {
3380 return parseVariableDeclarationStatement(commentAndMetadata); 3380 return parseVariableDeclarationStatement(commentAndMetadata);
3381 } else if (isFunctionDeclaration()) { 3381 } else if (isFunctionDeclaration()) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
3414 thisKeyword = andAdvance; 3414 thisKeyword = andAdvance;
3415 period = expect2(TokenType.PERIOD); 3415 period = expect2(TokenType.PERIOD);
3416 } 3416 }
3417 SimpleIdentifier identifier = parseSimpleIdentifier(); 3417 SimpleIdentifier identifier = parseSimpleIdentifier();
3418 if (matches5(TokenType.OPEN_PAREN)) { 3418 if (matches5(TokenType.OPEN_PAREN)) {
3419 if (thisKeyword != null) { 3419 if (thisKeyword != null) {
3420 } 3420 }
3421 FormalParameterList parameters = parseFormalParameterList(); 3421 FormalParameterList parameters = parseFormalParameterList();
3422 return new FunctionTypedFormalParameter.full(commentAndMetadata.comment, c ommentAndMetadata.metadata, holder.type, identifier, parameters); 3422 return new FunctionTypedFormalParameter.full(commentAndMetadata.comment, c ommentAndMetadata.metadata, holder.type, identifier, parameters);
3423 } 3423 }
3424 TypeName type2 = holder.type; 3424 TypeName type = holder.type;
3425 if (type2 != null && matches3(type2.name.beginToken, Keyword.VOID)) { 3425 if (type != null && matches3(type.name.beginToken, Keyword.VOID)) {
3426 reportError8(ParserErrorCode.VOID_PARAMETER, type2.name.beginToken, []); 3426 reportError8(ParserErrorCode.VOID_PARAMETER, type.name.beginToken, []);
3427 } 3427 }
3428 if (thisKeyword != null) { 3428 if (thisKeyword != null) {
3429 return new FieldFormalParameter.full(commentAndMetadata.comment, commentAn dMetadata.metadata, holder.keyword, holder.type, thisKeyword, period, identifier ); 3429 return new FieldFormalParameter.full(commentAndMetadata.comment, commentAn dMetadata.metadata, holder.keyword, holder.type, thisKeyword, period, identifier );
3430 } 3430 }
3431 return new SimpleFormalParameter.full(commentAndMetadata.comment, commentAnd Metadata.metadata, holder.keyword, holder.type, identifier); 3431 return new SimpleFormalParameter.full(commentAndMetadata.comment, commentAnd Metadata.metadata, holder.keyword, holder.type, identifier);
3432 } 3432 }
3433 3433
3434 /** 3434 /**
3435 * Parse an operator declaration. 3435 * Parse an operator declaration.
3436 * <pre> 3436 * <pre>
(...skipping 15 matching lines...) Expand all
3452 operatorKeyword = andAdvance; 3452 operatorKeyword = andAdvance;
3453 } else { 3453 } else {
3454 reportError8(ParserErrorCode.MISSING_KEYWORD_OPERATOR, _currentToken, []); 3454 reportError8(ParserErrorCode.MISSING_KEYWORD_OPERATOR, _currentToken, []);
3455 operatorKeyword = createSyntheticToken(Keyword.OPERATOR); 3455 operatorKeyword = createSyntheticToken(Keyword.OPERATOR);
3456 } 3456 }
3457 if (!_currentToken.isUserDefinableOperator()) { 3457 if (!_currentToken.isUserDefinableOperator()) {
3458 reportError7(ParserErrorCode.NON_USER_DEFINABLE_OPERATOR, [_currentToken.l exeme]); 3458 reportError7(ParserErrorCode.NON_USER_DEFINABLE_OPERATOR, [_currentToken.l exeme]);
3459 } 3459 }
3460 SimpleIdentifier name = new SimpleIdentifier.full(andAdvance); 3460 SimpleIdentifier name = new SimpleIdentifier.full(andAdvance);
3461 if (matches5(TokenType.EQ)) { 3461 if (matches5(TokenType.EQ)) {
3462 Token previous2 = _currentToken.previous; 3462 Token previous = _currentToken.previous;
3463 if ((matches4(previous2, TokenType.EQ_EQ) || matches4(previous2, TokenType .BANG_EQ)) && _currentToken.offset == previous2.offset + 2) { 3463 if ((matches4(previous, TokenType.EQ_EQ) || matches4(previous, TokenType.B ANG_EQ)) && _currentToken.offset == previous.offset + 2) {
3464 reportError7(ParserErrorCode.INVALID_OPERATOR, ["${previous2.lexeme}${_c urrentToken.lexeme}"]); 3464 reportError7(ParserErrorCode.INVALID_OPERATOR, ["${previous.lexeme}${_cu rrentToken.lexeme}"]);
3465 advance(); 3465 advance();
3466 } 3466 }
3467 } 3467 }
3468 FormalParameterList parameters = parseFormalParameterList(); 3468 FormalParameterList parameters = parseFormalParameterList();
3469 validateFormalParameterList(parameters); 3469 validateFormalParameterList(parameters);
3470 FunctionBody body = parseFunctionBody(true, ParserErrorCode.MISSING_FUNCTION _BODY, false); 3470 FunctionBody body = parseFunctionBody(true, ParserErrorCode.MISSING_FUNCTION _BODY, false);
3471 if (externalKeyword != null && body is! EmptyFunctionBody) { 3471 if (externalKeyword != null && body is! EmptyFunctionBody) {
3472 reportError7(ParserErrorCode.EXTERNAL_OPERATOR_WITH_BODY, []); 3472 reportError7(ParserErrorCode.EXTERNAL_OPERATOR_WITH_BODY, []);
3473 } 3473 }
3474 return new MethodDeclaration.full(commentAndMetadata.comment, commentAndMeta data.metadata, externalKeyword, null, returnType, null, operatorKeyword, name, p arameters, body); 3474 return new MethodDeclaration.full(commentAndMetadata.comment, commentAndMeta data.metadata, externalKeyword, null, returnType, null, operatorKeyword, name, p arameters, body);
(...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after
4256 return new PrefixExpression.full(operator, new SuperExpression.full(andA dvance)); 4256 return new PrefixExpression.full(operator, new SuperExpression.full(andA dvance));
4257 } 4257 }
4258 return new PrefixExpression.full(operator, parseUnaryExpression()); 4258 return new PrefixExpression.full(operator, parseUnaryExpression());
4259 } else if (_currentToken.type.isIncrementOperator()) { 4259 } else if (_currentToken.type.isIncrementOperator()) {
4260 Token operator = andAdvance; 4260 Token operator = andAdvance;
4261 if (matches(Keyword.SUPER)) { 4261 if (matches(Keyword.SUPER)) {
4262 if (matches4(peek(), TokenType.OPEN_SQUARE_BRACKET) || matches4(peek(), TokenType.PERIOD)) { 4262 if (matches4(peek(), TokenType.OPEN_SQUARE_BRACKET) || matches4(peek(), TokenType.PERIOD)) {
4263 return new PrefixExpression.full(operator, parseUnaryExpression()); 4263 return new PrefixExpression.full(operator, parseUnaryExpression());
4264 } 4264 }
4265 if (identical(operator.type, TokenType.MINUS_MINUS)) { 4265 if (identical(operator.type, TokenType.MINUS_MINUS)) {
4266 int offset2 = operator.offset; 4266 int offset = operator.offset;
4267 Token firstOperator = new Token(TokenType.MINUS, offset2); 4267 Token firstOperator = new Token(TokenType.MINUS, offset);
4268 Token secondOperator = new Token(TokenType.MINUS, offset2 + 1); 4268 Token secondOperator = new Token(TokenType.MINUS, offset + 1);
4269 secondOperator.setNext(_currentToken); 4269 secondOperator.setNext(_currentToken);
4270 firstOperator.setNext(secondOperator); 4270 firstOperator.setNext(secondOperator);
4271 operator.previous.setNext(firstOperator); 4271 operator.previous.setNext(firstOperator);
4272 return new PrefixExpression.full(firstOperator, new PrefixExpression.f ull(secondOperator, new SuperExpression.full(andAdvance))); 4272 return new PrefixExpression.full(firstOperator, new PrefixExpression.f ull(secondOperator, new SuperExpression.full(andAdvance)));
4273 } else { 4273 } else {
4274 reportError7(ParserErrorCode.INVALID_OPERATOR_FOR_SUPER, [operator.lex eme]); 4274 reportError7(ParserErrorCode.INVALID_OPERATOR_FOR_SUPER, [operator.lex eme]);
4275 return new PrefixExpression.full(operator, new SuperExpression.full(an dAdvance)); 4275 return new PrefixExpression.full(operator, new SuperExpression.full(an dAdvance));
4276 } 4276 }
4277 } 4277 }
4278 return new PrefixExpression.full(operator, parseAssignableExpression(false )); 4278 return new PrefixExpression.full(operator, parseAssignableExpression(false ));
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
4473 * | 'final' type? 4473 * | 'final' type?
4474 * | 'const' type? 4474 * | 'const' type?
4475 * | 'var' 4475 * | 'var'
4476 * | type 4476 * | type
4477 * </pre> 4477 * </pre>
4478 * @param startToken the token at which parsing is to begin 4478 * @param startToken the token at which parsing is to begin
4479 * @return the token following the type that was parsed 4479 * @return the token following the type that was parsed
4480 */ 4480 */
4481 Token skipFinalConstVarOrType(Token startToken) { 4481 Token skipFinalConstVarOrType(Token startToken) {
4482 if (matches3(startToken, Keyword.FINAL) || matches3(startToken, Keyword.CONS T)) { 4482 if (matches3(startToken, Keyword.FINAL) || matches3(startToken, Keyword.CONS T)) {
4483 Token next2 = startToken.next; 4483 Token next = startToken.next;
4484 if (matchesIdentifier2(next2.next) || matches4(next2.next, TokenType.LT) | | matches3(next2.next, Keyword.THIS)) { 4484 if (matchesIdentifier2(next.next) || matches4(next.next, TokenType.LT) || matches3(next.next, Keyword.THIS)) {
4485 return skipTypeName(next2); 4485 return skipTypeName(next);
4486 } 4486 }
4487 } else if (matches3(startToken, Keyword.VAR)) { 4487 } else if (matches3(startToken, Keyword.VAR)) {
4488 return startToken.next; 4488 return startToken.next;
4489 } else if (matchesIdentifier2(startToken)) { 4489 } else if (matchesIdentifier2(startToken)) {
4490 Token next3 = startToken.next; 4490 Token next = startToken.next;
4491 if (matchesIdentifier2(next3) || matches4(next3, TokenType.LT) || matches3 (next3, Keyword.THIS) || (matches4(next3, TokenType.PERIOD) && matchesIdentifier 2(next3.next) && (matchesIdentifier2(next3.next.next) || matches4(next3.next.nex t, TokenType.LT) || matches3(next3.next.next, Keyword.THIS)))) { 4491 if (matchesIdentifier2(next) || matches4(next, TokenType.LT) || matches3(n ext, Keyword.THIS) || (matches4(next, TokenType.PERIOD) && matchesIdentifier2(ne xt.next) && (matchesIdentifier2(next.next.next) || matches4(next.next.next, Toke nType.LT) || matches3(next.next.next, Keyword.THIS)))) {
4492 return skipReturnType(startToken); 4492 return skipReturnType(startToken);
4493 } 4493 }
4494 } 4494 }
4495 return null; 4495 return null;
4496 } 4496 }
4497 4497
4498 /** 4498 /**
4499 * Parse a list of formal parameters, starting at the given token, without act ually creating a 4499 * Parse a list of formal parameters, starting at the given token, without act ually creating a
4500 * formal parameter list or changing the current token. Return the token follo wing the formal 4500 * formal parameter list or changing the current token. Return the token follo wing the formal
4501 * parameter list that was parsed, or {@code null} if the given token is not t he first token in a 4501 * parameter list that was parsed, or {@code null} if the given token is not t he first token in a
(...skipping 21 matching lines...) Expand all
4523 * namedFormalParameters ::= 4523 * namedFormalParameters ::=
4524 * '{' defaultNamedParameter (',' defaultNamedParameter)* '}' 4524 * '{' defaultNamedParameter (',' defaultNamedParameter)* '}'
4525 * </pre> 4525 * </pre>
4526 * @param startToken the token at which parsing is to begin 4526 * @param startToken the token at which parsing is to begin
4527 * @return the token following the formal parameter list that was parsed 4527 * @return the token following the formal parameter list that was parsed
4528 */ 4528 */
4529 Token skipFormalParameterList(Token startToken) { 4529 Token skipFormalParameterList(Token startToken) {
4530 if (!matches4(startToken, TokenType.OPEN_PAREN)) { 4530 if (!matches4(startToken, TokenType.OPEN_PAREN)) {
4531 return null; 4531 return null;
4532 } 4532 }
4533 Token next2 = startToken.next; 4533 Token next = startToken.next;
4534 if (matches4(next2, TokenType.CLOSE_PAREN)) { 4534 if (matches4(next, TokenType.CLOSE_PAREN)) {
4535 return next2.next; 4535 return next.next;
4536 } 4536 }
4537 if (matchesAny(next2, [TokenType.AT, TokenType.OPEN_SQUARE_BRACKET, TokenTyp e.OPEN_CURLY_BRACKET]) || matches3(next2, Keyword.VOID) || (matchesIdentifier2(n ext2) && (matchesAny(next2.next, [TokenType.COMMA, TokenType.CLOSE_PAREN])))) { 4537 if (matchesAny(next, [TokenType.AT, TokenType.OPEN_SQUARE_BRACKET, TokenType .OPEN_CURLY_BRACKET]) || matches3(next, Keyword.VOID) || (matchesIdentifier2(nex t) && (matchesAny(next.next, [TokenType.COMMA, TokenType.CLOSE_PAREN])))) {
4538 return skipPastMatchingToken(startToken); 4538 return skipPastMatchingToken(startToken);
4539 } 4539 }
4540 if (matchesIdentifier2(next2) && matches4(next2.next, TokenType.OPEN_PAREN)) { 4540 if (matchesIdentifier2(next) && matches4(next.next, TokenType.OPEN_PAREN)) {
4541 Token afterParameters = skipFormalParameterList(next2.next); 4541 Token afterParameters = skipFormalParameterList(next.next);
4542 if (afterParameters != null && (matchesAny(afterParameters, [TokenType.COM MA, TokenType.CLOSE_PAREN]))) { 4542 if (afterParameters != null && (matchesAny(afterParameters, [TokenType.COM MA, TokenType.CLOSE_PAREN]))) {
4543 return skipPastMatchingToken(startToken); 4543 return skipPastMatchingToken(startToken);
4544 } 4544 }
4545 } 4545 }
4546 Token afterType = skipFinalConstVarOrType(next2); 4546 Token afterType = skipFinalConstVarOrType(next);
4547 if (afterType == null) { 4547 if (afterType == null) {
4548 return null; 4548 return null;
4549 } 4549 }
4550 if (skipSimpleIdentifier(afterType) == null) { 4550 if (skipSimpleIdentifier(afterType) == null) {
4551 return null; 4551 return null;
4552 } 4552 }
4553 return skipPastMatchingToken(startToken); 4553 return skipPastMatchingToken(startToken);
4554 } 4554 }
4555 4555
4556 /** 4556 /**
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
4641 * actually creating a string literal or changing the current token. Return th e token following 4641 * actually creating a string literal or changing the current token. Return th e token following
4642 * the string literal that was parsed, or {@code null} if the given token is n ot the first token 4642 * the string literal that was parsed, or {@code null} if the given token is n ot the first token
4643 * in a valid string literal. 4643 * in a valid string literal.
4644 * <p> 4644 * <p>
4645 * This method must be kept in sync with {@link #parseStringInterpolation(Toke n)}. 4645 * This method must be kept in sync with {@link #parseStringInterpolation(Toke n)}.
4646 * @param startToken the token at which parsing is to begin 4646 * @param startToken the token at which parsing is to begin
4647 * @return the string literal that was parsed 4647 * @return the string literal that was parsed
4648 */ 4648 */
4649 Token skipStringInterpolation(Token startToken) { 4649 Token skipStringInterpolation(Token startToken) {
4650 Token token = startToken; 4650 Token token = startToken;
4651 TokenType type2 = token.type; 4651 TokenType type = token.type;
4652 while (identical(type2, TokenType.STRING_INTERPOLATION_EXPRESSION) || identi cal(type2, TokenType.STRING_INTERPOLATION_IDENTIFIER)) { 4652 while (identical(type, TokenType.STRING_INTERPOLATION_EXPRESSION) || identic al(type, TokenType.STRING_INTERPOLATION_IDENTIFIER)) {
4653 if (identical(type2, TokenType.STRING_INTERPOLATION_EXPRESSION)) { 4653 if (identical(type, TokenType.STRING_INTERPOLATION_EXPRESSION)) {
4654 token = token.next; 4654 token = token.next;
4655 type2 = token.type; 4655 type = token.type;
4656 int bracketNestingLevel = 1; 4656 int bracketNestingLevel = 1;
4657 while (bracketNestingLevel > 0) { 4657 while (bracketNestingLevel > 0) {
4658 if (identical(type2, TokenType.EOF)) { 4658 if (identical(type, TokenType.EOF)) {
4659 return null; 4659 return null;
4660 } else if (identical(type2, TokenType.OPEN_CURLY_BRACKET)) { 4660 } else if (identical(type, TokenType.OPEN_CURLY_BRACKET)) {
4661 bracketNestingLevel++; 4661 bracketNestingLevel++;
4662 } else if (identical(type2, TokenType.CLOSE_CURLY_BRACKET)) { 4662 } else if (identical(type, TokenType.CLOSE_CURLY_BRACKET)) {
4663 bracketNestingLevel--; 4663 bracketNestingLevel--;
4664 } else if (identical(type2, TokenType.STRING)) { 4664 } else if (identical(type, TokenType.STRING)) {
4665 token = skipStringLiteral(token); 4665 token = skipStringLiteral(token);
4666 if (token == null) { 4666 if (token == null) {
4667 return null; 4667 return null;
4668 } 4668 }
4669 } else { 4669 } else {
4670 token = token.next; 4670 token = token.next;
4671 } 4671 }
4672 type2 = token.type; 4672 type = token.type;
4673 } 4673 }
4674 token = token.next; 4674 token = token.next;
4675 type2 = token.type; 4675 type = token.type;
4676 } else { 4676 } else {
4677 token = token.next; 4677 token = token.next;
4678 if (token.type != TokenType.IDENTIFIER) { 4678 if (token.type != TokenType.IDENTIFIER) {
4679 return null; 4679 return null;
4680 } 4680 }
4681 token = token.next; 4681 token = token.next;
4682 } 4682 }
4683 type2 = token.type; 4683 type = token.type;
4684 if (identical(type2, TokenType.STRING)) { 4684 if (identical(type, TokenType.STRING)) {
4685 token = token.next; 4685 token = token.next;
4686 type2 = token.type; 4686 type = token.type;
4687 } 4687 }
4688 } 4688 }
4689 return token; 4689 return token;
4690 } 4690 }
4691 4691
4692 /** 4692 /**
4693 * Parse a string literal, starting at the given token, without actually creat ing a string literal 4693 * Parse a string literal, starting at the given token, without actually creat ing a string literal
4694 * or changing the current token. Return the token following the string litera l that was parsed, 4694 * or changing the current token. Return the token following the string litera l that was parsed,
4695 * or {@code null} if the given token is not the first token in a valid string literal. 4695 * or {@code null} if the given token is not the first token in a valid string literal.
4696 * <p> 4696 * <p>
4697 * This method must be kept in sync with {@link #parseStringLiteral()}. 4697 * This method must be kept in sync with {@link #parseStringLiteral()}.
4698 * <pre> 4698 * <pre>
4699 * stringLiteral ::= 4699 * stringLiteral ::=
4700 * MULTI_LINE_STRING+ 4700 * MULTI_LINE_STRING+
4701 * | SINGLE_LINE_STRING+ 4701 * | SINGLE_LINE_STRING+
4702 * </pre> 4702 * </pre>
4703 * @param startToken the token at which parsing is to begin 4703 * @param startToken the token at which parsing is to begin
4704 * @return the token following the string literal that was parsed 4704 * @return the token following the string literal that was parsed
4705 */ 4705 */
4706 Token skipStringLiteral(Token startToken) { 4706 Token skipStringLiteral(Token startToken) {
4707 Token token = startToken; 4707 Token token = startToken;
4708 while (token != null && matches4(token, TokenType.STRING)) { 4708 while (token != null && matches4(token, TokenType.STRING)) {
4709 token = token.next; 4709 token = token.next;
4710 TokenType type2 = token.type; 4710 TokenType type = token.type;
4711 if (identical(type2, TokenType.STRING_INTERPOLATION_EXPRESSION) || identic al(type2, TokenType.STRING_INTERPOLATION_IDENTIFIER)) { 4711 if (identical(type, TokenType.STRING_INTERPOLATION_EXPRESSION) || identica l(type, TokenType.STRING_INTERPOLATION_IDENTIFIER)) {
4712 token = skipStringInterpolation(token); 4712 token = skipStringInterpolation(token);
4713 } 4713 }
4714 } 4714 }
4715 if (identical(token, startToken)) { 4715 if (identical(token, startToken)) {
4716 return null; 4716 return null;
4717 } 4717 }
4718 return token; 4718 return token;
4719 } 4719 }
4720 4720
4721 /** 4721 /**
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
4793 * '<' typeParameter (',' typeParameter)* '>' 4793 * '<' typeParameter (',' typeParameter)* '>'
4794 * </pre> 4794 * </pre>
4795 * @param startToken the token at which parsing is to begin 4795 * @param startToken the token at which parsing is to begin
4796 * @return the token following the type parameter list that was parsed 4796 * @return the token following the type parameter list that was parsed
4797 */ 4797 */
4798 Token skipTypeParameterList(Token startToken) { 4798 Token skipTypeParameterList(Token startToken) {
4799 if (!matches4(startToken, TokenType.LT)) { 4799 if (!matches4(startToken, TokenType.LT)) {
4800 return null; 4800 return null;
4801 } 4801 }
4802 int depth = 1; 4802 int depth = 1;
4803 Token next2 = startToken.next; 4803 Token next = startToken.next;
4804 while (depth > 0) { 4804 while (depth > 0) {
4805 if (matches4(next2, TokenType.EOF)) { 4805 if (matches4(next, TokenType.EOF)) {
4806 return null; 4806 return null;
4807 } else if (matches4(next2, TokenType.LT)) { 4807 } else if (matches4(next, TokenType.LT)) {
4808 depth++; 4808 depth++;
4809 } else if (matches4(next2, TokenType.GT)) { 4809 } else if (matches4(next, TokenType.GT)) {
4810 depth--; 4810 depth--;
4811 } else if (matches4(next2, TokenType.GT_EQ)) { 4811 } else if (matches4(next, TokenType.GT_EQ)) {
4812 if (depth == 1) { 4812 if (depth == 1) {
4813 Token fakeEquals = new Token(TokenType.EQ, next2.offset + 2); 4813 Token fakeEquals = new Token(TokenType.EQ, next.offset + 2);
4814 fakeEquals.setNextWithoutSettingPrevious(next2.next); 4814 fakeEquals.setNextWithoutSettingPrevious(next.next);
4815 return fakeEquals; 4815 return fakeEquals;
4816 } 4816 }
4817 depth--; 4817 depth--;
4818 } else if (matches4(next2, TokenType.GT_GT)) { 4818 } else if (matches4(next, TokenType.GT_GT)) {
4819 depth -= 2; 4819 depth -= 2;
4820 } else if (matches4(next2, TokenType.GT_GT_EQ)) { 4820 } else if (matches4(next, TokenType.GT_GT_EQ)) {
4821 if (depth < 2) { 4821 if (depth < 2) {
4822 return null; 4822 return null;
4823 } else if (depth == 2) { 4823 } else if (depth == 2) {
4824 Token fakeEquals = new Token(TokenType.EQ, next2.offset + 2); 4824 Token fakeEquals = new Token(TokenType.EQ, next.offset + 2);
4825 fakeEquals.setNextWithoutSettingPrevious(next2.next); 4825 fakeEquals.setNextWithoutSettingPrevious(next.next);
4826 return fakeEquals; 4826 return fakeEquals;
4827 } 4827 }
4828 depth -= 2; 4828 depth -= 2;
4829 } 4829 }
4830 next2 = next2.next; 4830 next = next.next;
4831 } 4831 }
4832 return next2; 4832 return next;
4833 } 4833 }
4834 4834
4835 /** 4835 /**
4836 * Translate the characters at the given index in the given string, appending the translated 4836 * Translate the characters at the given index in the given string, appending the translated
4837 * character to the given builder. The index is assumed to be valid. 4837 * character to the given builder. The index is assumed to be valid.
4838 * @param builder the builder to which the translated character is to be appen ded 4838 * @param builder the builder to which the translated character is to be appen ded
4839 * @param lexeme the string containing the character(s) to be translated 4839 * @param lexeme the string containing the character(s) to be translated
4840 * @param index the index of the character to be translated 4840 * @param index the index of the character to be translated
4841 * @return the index of the next character to be translated 4841 * @return the index of the next character to be translated
4842 */ 4842 */
4843 int translateCharacter(JavaStringBuilder builder, String lexeme, int index) { 4843 int translateCharacter(JavaStringBuilder builder, String lexeme, int index) {
4844 int currentChar = lexeme.codeUnitAt(index); 4844 int currentChar = lexeme.codeUnitAt(index);
4845 if (currentChar != 0x5C) { 4845 if (currentChar != 0x5C) {
4846 builder.appendChar(currentChar); 4846 builder.appendChar(currentChar);
4847 return index + 1; 4847 return index + 1;
4848 } 4848 }
4849 int length2 = lexeme.length; 4849 int length = lexeme.length;
4850 int currentIndex = index + 1; 4850 int currentIndex = index + 1;
4851 if (currentIndex >= length2) { 4851 if (currentIndex >= length) {
4852 return length2; 4852 return length;
4853 } 4853 }
4854 currentChar = lexeme.codeUnitAt(currentIndex); 4854 currentChar = lexeme.codeUnitAt(currentIndex);
4855 if (currentChar == 0x6E) { 4855 if (currentChar == 0x6E) {
4856 builder.appendChar(0xA); 4856 builder.appendChar(0xA);
4857 } else if (currentChar == 0x72) { 4857 } else if (currentChar == 0x72) {
4858 builder.appendChar(0xD); 4858 builder.appendChar(0xD);
4859 } else if (currentChar == 0x66) { 4859 } else if (currentChar == 0x66) {
4860 builder.appendChar(0xC); 4860 builder.appendChar(0xC);
4861 } else if (currentChar == 0x62) { 4861 } else if (currentChar == 0x62) {
4862 builder.appendChar(0x8); 4862 builder.appendChar(0x8);
4863 } else if (currentChar == 0x74) { 4863 } else if (currentChar == 0x74) {
4864 builder.appendChar(0x9); 4864 builder.appendChar(0x9);
4865 } else if (currentChar == 0x76) { 4865 } else if (currentChar == 0x76) {
4866 builder.appendChar(0xB); 4866 builder.appendChar(0xB);
4867 } else if (currentChar == 0x78) { 4867 } else if (currentChar == 0x78) {
4868 if (currentIndex + 2 >= length2) { 4868 if (currentIndex + 2 >= length) {
4869 reportError7(ParserErrorCode.INVALID_HEX_ESCAPE, []); 4869 reportError7(ParserErrorCode.INVALID_HEX_ESCAPE, []);
4870 return length2; 4870 return length;
4871 } 4871 }
4872 int firstDigit = lexeme.codeUnitAt(currentIndex + 1); 4872 int firstDigit = lexeme.codeUnitAt(currentIndex + 1);
4873 int secondDigit = lexeme.codeUnitAt(currentIndex + 2); 4873 int secondDigit = lexeme.codeUnitAt(currentIndex + 2);
4874 if (!isHexDigit(firstDigit) || !isHexDigit(secondDigit)) { 4874 if (!isHexDigit(firstDigit) || !isHexDigit(secondDigit)) {
4875 reportError7(ParserErrorCode.INVALID_HEX_ESCAPE, []); 4875 reportError7(ParserErrorCode.INVALID_HEX_ESCAPE, []);
4876 } else { 4876 } else {
4877 builder.appendChar((((Character.digit(firstDigit, 16) << 4) + Character. digit(secondDigit, 16)) as int)); 4877 builder.appendChar((((Character.digit(firstDigit, 16) << 4) + Character. digit(secondDigit, 16)) as int));
4878 } 4878 }
4879 return currentIndex + 3; 4879 return currentIndex + 3;
4880 } else if (currentChar == 0x75) { 4880 } else if (currentChar == 0x75) {
4881 currentIndex++; 4881 currentIndex++;
4882 if (currentIndex >= length2) { 4882 if (currentIndex >= length) {
4883 reportError7(ParserErrorCode.INVALID_UNICODE_ESCAPE, []); 4883 reportError7(ParserErrorCode.INVALID_UNICODE_ESCAPE, []);
4884 return length2; 4884 return length;
4885 } 4885 }
4886 currentChar = lexeme.codeUnitAt(currentIndex); 4886 currentChar = lexeme.codeUnitAt(currentIndex);
4887 if (currentChar == 0x7B) { 4887 if (currentChar == 0x7B) {
4888 currentIndex++; 4888 currentIndex++;
4889 if (currentIndex >= length2) { 4889 if (currentIndex >= length) {
4890 reportError7(ParserErrorCode.INVALID_UNICODE_ESCAPE, []); 4890 reportError7(ParserErrorCode.INVALID_UNICODE_ESCAPE, []);
4891 return length2; 4891 return length;
4892 } 4892 }
4893 currentChar = lexeme.codeUnitAt(currentIndex); 4893 currentChar = lexeme.codeUnitAt(currentIndex);
4894 int digitCount = 0; 4894 int digitCount = 0;
4895 int value = 0; 4895 int value = 0;
4896 while (currentChar != 0x7D) { 4896 while (currentChar != 0x7D) {
4897 if (!isHexDigit(currentChar)) { 4897 if (!isHexDigit(currentChar)) {
4898 reportError7(ParserErrorCode.INVALID_UNICODE_ESCAPE, []); 4898 reportError7(ParserErrorCode.INVALID_UNICODE_ESCAPE, []);
4899 currentIndex++; 4899 currentIndex++;
4900 while (currentIndex < length2 && lexeme.codeUnitAt(currentIndex) != 0x7D) { 4900 while (currentIndex < length && lexeme.codeUnitAt(currentIndex) != 0 x7D) {
4901 currentIndex++; 4901 currentIndex++;
4902 } 4902 }
4903 return currentIndex + 1; 4903 return currentIndex + 1;
4904 } 4904 }
4905 digitCount++; 4905 digitCount++;
4906 value = (value << 4) + Character.digit(currentChar, 16); 4906 value = (value << 4) + Character.digit(currentChar, 16);
4907 currentIndex++; 4907 currentIndex++;
4908 if (currentIndex >= length2) { 4908 if (currentIndex >= length) {
4909 reportError7(ParserErrorCode.INVALID_UNICODE_ESCAPE, []); 4909 reportError7(ParserErrorCode.INVALID_UNICODE_ESCAPE, []);
4910 return length2; 4910 return length;
4911 } 4911 }
4912 currentChar = lexeme.codeUnitAt(currentIndex); 4912 currentChar = lexeme.codeUnitAt(currentIndex);
4913 } 4913 }
4914 if (digitCount < 1 || digitCount > 6) { 4914 if (digitCount < 1 || digitCount > 6) {
4915 reportError7(ParserErrorCode.INVALID_UNICODE_ESCAPE, []); 4915 reportError7(ParserErrorCode.INVALID_UNICODE_ESCAPE, []);
4916 } 4916 }
4917 appendScalarValue(builder, lexeme.substring(index, currentIndex + 1), va lue, index, currentIndex); 4917 appendScalarValue(builder, lexeme.substring(index, currentIndex + 1), va lue, index, currentIndex);
4918 return currentIndex + 1; 4918 return currentIndex + 1;
4919 } else { 4919 } else {
4920 if (currentIndex + 3 >= length2) { 4920 if (currentIndex + 3 >= length) {
4921 reportError7(ParserErrorCode.INVALID_UNICODE_ESCAPE, []); 4921 reportError7(ParserErrorCode.INVALID_UNICODE_ESCAPE, []);
4922 return length2; 4922 return length;
4923 } 4923 }
4924 int firstDigit = currentChar; 4924 int firstDigit = currentChar;
4925 int secondDigit = lexeme.codeUnitAt(currentIndex + 1); 4925 int secondDigit = lexeme.codeUnitAt(currentIndex + 1);
4926 int thirdDigit = lexeme.codeUnitAt(currentIndex + 2); 4926 int thirdDigit = lexeme.codeUnitAt(currentIndex + 2);
4927 int fourthDigit = lexeme.codeUnitAt(currentIndex + 3); 4927 int fourthDigit = lexeme.codeUnitAt(currentIndex + 3);
4928 if (!isHexDigit(firstDigit) || !isHexDigit(secondDigit) || !isHexDigit(t hirdDigit) || !isHexDigit(fourthDigit)) { 4928 if (!isHexDigit(firstDigit) || !isHexDigit(secondDigit) || !isHexDigit(t hirdDigit) || !isHexDigit(fourthDigit)) {
4929 reportError7(ParserErrorCode.INVALID_UNICODE_ESCAPE, []); 4929 reportError7(ParserErrorCode.INVALID_UNICODE_ESCAPE, []);
4930 } else { 4930 } else {
4931 appendScalarValue(builder, lexeme.substring(index, currentIndex + 1), ((((((Character.digit(firstDigit, 16) << 4) + Character.digit(secondDigit, 16)) << 4) + Character.digit(thirdDigit, 16)) << 4) + Character.digit(fourthDigit, 16 )), index, currentIndex + 3); 4931 appendScalarValue(builder, lexeme.substring(index, currentIndex + 1), ((((((Character.digit(firstDigit, 16) << 4) + Character.digit(secondDigit, 16)) << 4) + Character.digit(thirdDigit, 16)) << 4) + Character.digit(fourthDigit, 16 )), index, currentIndex + 3);
4932 } 4932 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
4984 } 4984 }
4985 if (modifiers.finalKeyword != null) { 4985 if (modifiers.finalKeyword != null) {
4986 reportError8(ParserErrorCode.FINAL_CONSTRUCTOR, modifiers.finalKeyword, [] ); 4986 reportError8(ParserErrorCode.FINAL_CONSTRUCTOR, modifiers.finalKeyword, [] );
4987 } 4987 }
4988 if (modifiers.staticKeyword != null) { 4988 if (modifiers.staticKeyword != null) {
4989 reportError8(ParserErrorCode.STATIC_CONSTRUCTOR, modifiers.staticKeyword, []); 4989 reportError8(ParserErrorCode.STATIC_CONSTRUCTOR, modifiers.staticKeyword, []);
4990 } 4990 }
4991 if (modifiers.varKeyword != null) { 4991 if (modifiers.varKeyword != null) {
4992 reportError8(ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE, modifiers.varKe yword, []); 4992 reportError8(ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE, modifiers.varKe yword, []);
4993 } 4993 }
4994 Token externalKeyword2 = modifiers.externalKeyword; 4994 Token externalKeyword = modifiers.externalKeyword;
4995 Token constKeyword2 = modifiers.constKeyword; 4995 Token constKeyword = modifiers.constKeyword;
4996 Token factoryKeyword2 = modifiers.factoryKeyword; 4996 Token factoryKeyword = modifiers.factoryKeyword;
4997 if (externalKeyword2 != null && constKeyword2 != null && constKeyword2.offse t < externalKeyword2.offset) { 4997 if (externalKeyword != null && constKeyword != null && constKeyword.offset < externalKeyword.offset) {
4998 reportError8(ParserErrorCode.EXTERNAL_AFTER_CONST, externalKeyword2, []); 4998 reportError8(ParserErrorCode.EXTERNAL_AFTER_CONST, externalKeyword, []);
4999 } 4999 }
5000 if (externalKeyword2 != null && factoryKeyword2 != null && factoryKeyword2.o ffset < externalKeyword2.offset) { 5000 if (externalKeyword != null && factoryKeyword != null && factoryKeyword.offs et < externalKeyword.offset) {
5001 reportError8(ParserErrorCode.EXTERNAL_AFTER_FACTORY, externalKeyword2, []) ; 5001 reportError8(ParserErrorCode.EXTERNAL_AFTER_FACTORY, externalKeyword, []);
5002 } 5002 }
5003 return constKeyword2; 5003 return constKeyword;
5004 } 5004 }
5005 5005
5006 /** 5006 /**
5007 * Validate that the given set of modifiers is appropriate for a field and ret urn the 'final', 5007 * Validate that the given set of modifiers is appropriate for a field and ret urn the 'final',
5008 * 'const' or 'var' keyword if there is one. 5008 * 'const' or 'var' keyword if there is one.
5009 * @param modifiers the modifiers being validated 5009 * @param modifiers the modifiers being validated
5010 * @return the 'final', 'const' or 'var' keyword associated with the field 5010 * @return the 'final', 'const' or 'var' keyword associated with the field
5011 */ 5011 */
5012 Token validateModifiersForField(Modifiers modifiers) { 5012 Token validateModifiersForField(Modifiers modifiers) {
5013 if (modifiers.abstractKeyword != null) { 5013 if (modifiers.abstractKeyword != null) {
5014 reportError7(ParserErrorCode.ABSTRACT_CLASS_MEMBER, []); 5014 reportError7(ParserErrorCode.ABSTRACT_CLASS_MEMBER, []);
5015 } 5015 }
5016 if (modifiers.externalKeyword != null) { 5016 if (modifiers.externalKeyword != null) {
5017 reportError8(ParserErrorCode.EXTERNAL_FIELD, modifiers.externalKeyword, [] ); 5017 reportError8(ParserErrorCode.EXTERNAL_FIELD, modifiers.externalKeyword, [] );
5018 } 5018 }
5019 if (modifiers.factoryKeyword != null) { 5019 if (modifiers.factoryKeyword != null) {
5020 reportError8(ParserErrorCode.NON_CONSTRUCTOR_FACTORY, modifiers.factoryKey word, []); 5020 reportError8(ParserErrorCode.NON_CONSTRUCTOR_FACTORY, modifiers.factoryKey word, []);
5021 } 5021 }
5022 Token staticKeyword2 = modifiers.staticKeyword; 5022 Token staticKeyword = modifiers.staticKeyword;
5023 Token constKeyword2 = modifiers.constKeyword; 5023 Token constKeyword = modifiers.constKeyword;
5024 Token finalKeyword2 = modifiers.finalKeyword; 5024 Token finalKeyword = modifiers.finalKeyword;
5025 Token varKeyword2 = modifiers.varKeyword; 5025 Token varKeyword = modifiers.varKeyword;
5026 if (constKeyword2 != null) { 5026 if (constKeyword != null) {
5027 if (finalKeyword2 != null) { 5027 if (finalKeyword != null) {
5028 reportError8(ParserErrorCode.CONST_AND_FINAL, finalKeyword2, []); 5028 reportError8(ParserErrorCode.CONST_AND_FINAL, finalKeyword, []);
5029 } 5029 }
5030 if (varKeyword2 != null) { 5030 if (varKeyword != null) {
5031 reportError8(ParserErrorCode.CONST_AND_VAR, varKeyword2, []); 5031 reportError8(ParserErrorCode.CONST_AND_VAR, varKeyword, []);
5032 } 5032 }
5033 if (staticKeyword2 != null && constKeyword2.offset < staticKeyword2.offset ) { 5033 if (staticKeyword != null && constKeyword.offset < staticKeyword.offset) {
5034 reportError8(ParserErrorCode.STATIC_AFTER_CONST, staticKeyword2, []); 5034 reportError8(ParserErrorCode.STATIC_AFTER_CONST, staticKeyword, []);
5035 } 5035 }
5036 } else if (finalKeyword2 != null) { 5036 } else if (finalKeyword != null) {
5037 if (varKeyword2 != null) { 5037 if (varKeyword != null) {
5038 reportError8(ParserErrorCode.FINAL_AND_VAR, varKeyword2, []); 5038 reportError8(ParserErrorCode.FINAL_AND_VAR, varKeyword, []);
5039 } 5039 }
5040 if (staticKeyword2 != null && finalKeyword2.offset < staticKeyword2.offset ) { 5040 if (staticKeyword != null && finalKeyword.offset < staticKeyword.offset) {
5041 reportError8(ParserErrorCode.STATIC_AFTER_FINAL, staticKeyword2, []); 5041 reportError8(ParserErrorCode.STATIC_AFTER_FINAL, staticKeyword, []);
5042 } 5042 }
5043 } else if (varKeyword2 != null && staticKeyword2 != null && varKeyword2.offs et < staticKeyword2.offset) { 5043 } else if (varKeyword != null && staticKeyword != null && varKeyword.offset < staticKeyword.offset) {
5044 reportError8(ParserErrorCode.STATIC_AFTER_VAR, staticKeyword2, []); 5044 reportError8(ParserErrorCode.STATIC_AFTER_VAR, staticKeyword, []);
5045 } 5045 }
5046 return lexicallyFirst([constKeyword2, finalKeyword2, varKeyword2]); 5046 return lexicallyFirst([constKeyword, finalKeyword, varKeyword]);
5047 } 5047 }
5048 5048
5049 /** 5049 /**
5050 * Validate that the given set of modifiers is appropriate for a getter, sette r, or method. 5050 * Validate that the given set of modifiers is appropriate for a getter, sette r, or method.
5051 * @param modifiers the modifiers being validated 5051 * @param modifiers the modifiers being validated
5052 */ 5052 */
5053 void validateModifiersForGetterOrSetterOrMethod(Modifiers modifiers) { 5053 void validateModifiersForGetterOrSetterOrMethod(Modifiers modifiers) {
5054 if (modifiers.abstractKeyword != null) { 5054 if (modifiers.abstractKeyword != null) {
5055 reportError7(ParserErrorCode.ABSTRACT_CLASS_MEMBER, []); 5055 reportError7(ParserErrorCode.ABSTRACT_CLASS_MEMBER, []);
5056 } 5056 }
5057 if (modifiers.constKeyword != null) { 5057 if (modifiers.constKeyword != null) {
5058 reportError8(ParserErrorCode.CONST_METHOD, modifiers.constKeyword, []); 5058 reportError8(ParserErrorCode.CONST_METHOD, modifiers.constKeyword, []);
5059 } 5059 }
5060 if (modifiers.factoryKeyword != null) { 5060 if (modifiers.factoryKeyword != null) {
5061 reportError8(ParserErrorCode.NON_CONSTRUCTOR_FACTORY, modifiers.factoryKey word, []); 5061 reportError8(ParserErrorCode.NON_CONSTRUCTOR_FACTORY, modifiers.factoryKey word, []);
5062 } 5062 }
5063 if (modifiers.finalKeyword != null) { 5063 if (modifiers.finalKeyword != null) {
5064 reportError8(ParserErrorCode.FINAL_METHOD, modifiers.finalKeyword, []); 5064 reportError8(ParserErrorCode.FINAL_METHOD, modifiers.finalKeyword, []);
5065 } 5065 }
5066 if (modifiers.varKeyword != null) { 5066 if (modifiers.varKeyword != null) {
5067 reportError8(ParserErrorCode.VAR_RETURN_TYPE, modifiers.varKeyword, []); 5067 reportError8(ParserErrorCode.VAR_RETURN_TYPE, modifiers.varKeyword, []);
5068 } 5068 }
5069 Token externalKeyword2 = modifiers.externalKeyword; 5069 Token externalKeyword = modifiers.externalKeyword;
5070 Token staticKeyword2 = modifiers.staticKeyword; 5070 Token staticKeyword = modifiers.staticKeyword;
5071 if (externalKeyword2 != null && staticKeyword2 != null && staticKeyword2.off set < externalKeyword2.offset) { 5071 if (externalKeyword != null && staticKeyword != null && staticKeyword.offset < externalKeyword.offset) {
5072 reportError8(ParserErrorCode.EXTERNAL_AFTER_STATIC, externalKeyword2, []); 5072 reportError8(ParserErrorCode.EXTERNAL_AFTER_STATIC, externalKeyword, []);
5073 } 5073 }
5074 } 5074 }
5075 5075
5076 /** 5076 /**
5077 * Validate that the given set of modifiers is appropriate for a getter, sette r, or method. 5077 * Validate that the given set of modifiers is appropriate for a getter, sette r, or method.
5078 * @param modifiers the modifiers being validated 5078 * @param modifiers the modifiers being validated
5079 */ 5079 */
5080 void validateModifiersForOperator(Modifiers modifiers) { 5080 void validateModifiersForOperator(Modifiers modifiers) {
5081 if (modifiers.abstractKeyword != null) { 5081 if (modifiers.abstractKeyword != null) {
5082 reportError7(ParserErrorCode.ABSTRACT_CLASS_MEMBER, []); 5082 reportError7(ParserErrorCode.ABSTRACT_CLASS_MEMBER, []);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
5138 * @return the 'final', 'const' or 'var' keyword associated with the field 5138 * @return the 'final', 'const' or 'var' keyword associated with the field
5139 */ 5139 */
5140 Token validateModifiersForTopLevelVariable(Modifiers modifiers) { 5140 Token validateModifiersForTopLevelVariable(Modifiers modifiers) {
5141 validateModifiersForTopLevelDeclaration(modifiers); 5141 validateModifiersForTopLevelDeclaration(modifiers);
5142 if (modifiers.abstractKeyword != null) { 5142 if (modifiers.abstractKeyword != null) {
5143 reportError7(ParserErrorCode.ABSTRACT_TOP_LEVEL_VARIABLE, []); 5143 reportError7(ParserErrorCode.ABSTRACT_TOP_LEVEL_VARIABLE, []);
5144 } 5144 }
5145 if (modifiers.externalKeyword != null) { 5145 if (modifiers.externalKeyword != null) {
5146 reportError8(ParserErrorCode.EXTERNAL_FIELD, modifiers.externalKeyword, [] ); 5146 reportError8(ParserErrorCode.EXTERNAL_FIELD, modifiers.externalKeyword, [] );
5147 } 5147 }
5148 Token constKeyword2 = modifiers.constKeyword; 5148 Token constKeyword = modifiers.constKeyword;
5149 Token finalKeyword2 = modifiers.finalKeyword; 5149 Token finalKeyword = modifiers.finalKeyword;
5150 Token varKeyword2 = modifiers.varKeyword; 5150 Token varKeyword = modifiers.varKeyword;
5151 if (constKeyword2 != null) { 5151 if (constKeyword != null) {
5152 if (finalKeyword2 != null) { 5152 if (finalKeyword != null) {
5153 reportError8(ParserErrorCode.CONST_AND_FINAL, finalKeyword2, []); 5153 reportError8(ParserErrorCode.CONST_AND_FINAL, finalKeyword, []);
5154 } 5154 }
5155 if (varKeyword2 != null) { 5155 if (varKeyword != null) {
5156 reportError8(ParserErrorCode.CONST_AND_VAR, varKeyword2, []); 5156 reportError8(ParserErrorCode.CONST_AND_VAR, varKeyword, []);
5157 } 5157 }
5158 } else if (finalKeyword2 != null) { 5158 } else if (finalKeyword != null) {
5159 if (varKeyword2 != null) { 5159 if (varKeyword != null) {
5160 reportError8(ParserErrorCode.FINAL_AND_VAR, varKeyword2, []); 5160 reportError8(ParserErrorCode.FINAL_AND_VAR, varKeyword, []);
5161 } 5161 }
5162 } 5162 }
5163 return lexicallyFirst([constKeyword2, finalKeyword2, varKeyword2]); 5163 return lexicallyFirst([constKeyword, finalKeyword, varKeyword]);
5164 } 5164 }
5165 5165
5166 /** 5166 /**
5167 * Validate that the given set of modifiers is appropriate for a class and ret urn the 'abstract' 5167 * Validate that the given set of modifiers is appropriate for a class and ret urn the 'abstract'
5168 * keyword if there is one. 5168 * keyword if there is one.
5169 * @param modifiers the modifiers being validated 5169 * @param modifiers the modifiers being validated
5170 */ 5170 */
5171 void validateModifiersForTypedef(Modifiers modifiers) { 5171 void validateModifiersForTypedef(Modifiers modifiers) {
5172 validateModifiersForTopLevelDeclaration(modifiers); 5172 validateModifiersForTopLevelDeclaration(modifiers);
5173 if (modifiers.abstractKeyword != null) { 5173 if (modifiers.abstractKeyword != null) {
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
5541 nl2(); 5541 nl2();
5542 } 5542 }
5543 if (identical(token, node.endToken)) { 5543 if (identical(token, node.endToken)) {
5544 break; 5544 break;
5545 } 5545 }
5546 } 5546 }
5547 return null; 5547 return null;
5548 } 5548 }
5549 Object visitCommentReference(CommentReference node) => null; 5549 Object visitCommentReference(CommentReference node) => null;
5550 Object visitCompilationUnit(CompilationUnit node) { 5550 Object visitCompilationUnit(CompilationUnit node) {
5551 ScriptTag scriptTag2 = node.scriptTag; 5551 ScriptTag scriptTag = node.scriptTag;
5552 NodeList<Directive> directives2 = node.directives; 5552 NodeList<Directive> directives = node.directives;
5553 visit(scriptTag2); 5553 visit(scriptTag);
5554 String prefix = scriptTag2 == null ? "" : " "; 5554 String prefix = scriptTag == null ? "" : " ";
5555 visitList7(prefix, directives2, "\n"); 5555 visitList7(prefix, directives, "\n");
5556 prefix = scriptTag2 == null && directives2.isEmpty ? "" : "\n\n"; 5556 prefix = scriptTag == null && directives.isEmpty ? "" : "\n\n";
5557 visitList7(prefix, node.declarations, "\n"); 5557 visitList7(prefix, node.declarations, "\n");
5558 return null; 5558 return null;
5559 } 5559 }
5560 Object visitConditionalExpression(ConditionalExpression node) { 5560 Object visitConditionalExpression(ConditionalExpression node) {
5561 visit(node.condition); 5561 visit(node.condition);
5562 _writer.print(" ? "); 5562 _writer.print(" ? ");
5563 visit(node.thenExpression); 5563 visit(node.thenExpression);
5564 _writer.print(" : "); 5564 _writer.print(" : ");
5565 visit(node.elseExpression); 5565 visit(node.elseExpression);
5566 return null; 5566 return null;
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
5678 visit(node.loopVariable); 5678 visit(node.loopVariable);
5679 _writer.print(" in "); 5679 _writer.print(" in ");
5680 visit(node.iterator); 5680 visit(node.iterator);
5681 _writer.print(") "); 5681 _writer.print(") ");
5682 visit(node.body); 5682 visit(node.body);
5683 return null; 5683 return null;
5684 } 5684 }
5685 Object visitFormalParameterList(FormalParameterList node) { 5685 Object visitFormalParameterList(FormalParameterList node) {
5686 String groupEnd = null; 5686 String groupEnd = null;
5687 _writer.print('('); 5687 _writer.print('(');
5688 NodeList<FormalParameter> parameters2 = node.parameters; 5688 NodeList<FormalParameter> parameters = node.parameters;
5689 int size2 = parameters2.length; 5689 int size = parameters.length;
5690 for (int i = 0; i < size2; i++) { 5690 for (int i = 0; i < size; i++) {
5691 FormalParameter parameter = parameters2[i]; 5691 FormalParameter parameter = parameters[i];
5692 if (i > 0) { 5692 if (i > 0) {
5693 _writer.print(", "); 5693 _writer.print(", ");
5694 } 5694 }
5695 if (groupEnd == null && parameter is DefaultFormalParameter) { 5695 if (groupEnd == null && parameter is DefaultFormalParameter) {
5696 if (identical(parameter.kind, ParameterKind.NAMED)) { 5696 if (identical(parameter.kind, ParameterKind.NAMED)) {
5697 groupEnd = "}"; 5697 groupEnd = "}";
5698 _writer.print('{'); 5698 _writer.print('{');
5699 } else { 5699 } else {
5700 groupEnd = "]"; 5700 groupEnd = "]";
5701 _writer.print('['); 5701 _writer.print('[');
5702 } 5702 }
5703 } 5703 }
5704 parameter.accept(this); 5704 parameter.accept(this);
5705 } 5705 }
5706 if (groupEnd != null) { 5706 if (groupEnd != null) {
5707 _writer.print(groupEnd); 5707 _writer.print(groupEnd);
5708 } 5708 }
5709 _writer.print(')'); 5709 _writer.print(')');
5710 return null; 5710 return null;
5711 } 5711 }
5712 Object visitForStatement(ForStatement node) { 5712 Object visitForStatement(ForStatement node) {
5713 Expression initialization2 = node.initialization; 5713 Expression initialization = node.initialization;
5714 _writer.print("for ("); 5714 _writer.print("for (");
5715 if (initialization2 != null) { 5715 if (initialization != null) {
5716 visit(initialization2); 5716 visit(initialization);
5717 } else { 5717 } else {
5718 visit(node.variables); 5718 visit(node.variables);
5719 } 5719 }
5720 _writer.print(";"); 5720 _writer.print(";");
5721 visit7(" ", node.condition); 5721 visit7(" ", node.condition);
5722 _writer.print(";"); 5722 _writer.print(";");
5723 visitList7(" ", node.updaters, ", "); 5723 visitList7(" ", node.updaters, ", ");
5724 _writer.print(") "); 5724 _writer.print(") ");
5725 visit(node.body); 5725 visit(node.body);
5726 return null; 5726 return null;
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
5973 _writer.print("this"); 5973 _writer.print("this");
5974 visit7(".", node.constructorName); 5974 visit7(".", node.constructorName);
5975 visit(node.argumentList); 5975 visit(node.argumentList);
5976 return null; 5976 return null;
5977 } 5977 }
5978 Object visitRethrowExpression(RethrowExpression node) { 5978 Object visitRethrowExpression(RethrowExpression node) {
5979 _writer.print("rethrow"); 5979 _writer.print("rethrow");
5980 return null; 5980 return null;
5981 } 5981 }
5982 Object visitReturnStatement(ReturnStatement node) { 5982 Object visitReturnStatement(ReturnStatement node) {
5983 Expression expression2 = node.expression; 5983 Expression expression = node.expression;
5984 if (expression2 == null) { 5984 if (expression == null) {
5985 _writer.print("return;"); 5985 _writer.print("return;");
5986 } else { 5986 } else {
5987 _writer.print("return "); 5987 _writer.print("return ");
5988 expression2.accept(this); 5988 expression.accept(this);
5989 _writer.print(";"); 5989 _writer.print(";");
5990 } 5990 }
5991 return null; 5991 return null;
5992 } 5992 }
5993 Object visitScriptTag(ScriptTag node) { 5993 Object visitScriptTag(ScriptTag node) {
5994 _writer.print(node.scriptTag.lexeme); 5994 _writer.print(node.scriptTag.lexeme);
5995 return null; 5995 return null;
5996 } 5996 }
5997 Object visitShowCombinator(ShowCombinator node) { 5997 Object visitShowCombinator(ShowCombinator node) {
5998 _writer.print("show "); 5998 _writer.print("show ");
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
6207 visitList5(nodes, ""); 6207 visitList5(nodes, "");
6208 } 6208 }
6209 6209
6210 /** 6210 /**
6211 * Print a list of nodes, separated by the given separator. 6211 * Print a list of nodes, separated by the given separator.
6212 * @param nodes the nodes to be printed 6212 * @param nodes the nodes to be printed
6213 * @param separator the separator to be printed between adjacent nodes 6213 * @param separator the separator to be printed between adjacent nodes
6214 */ 6214 */
6215 void visitList5(NodeList<ASTNode> nodes, String separator) { 6215 void visitList5(NodeList<ASTNode> nodes, String separator) {
6216 if (nodes != null) { 6216 if (nodes != null) {
6217 int size2 = nodes.length; 6217 int size = nodes.length;
6218 for (int i = 0; i < size2; i++) { 6218 for (int i = 0; i < size; i++) {
6219 if ("\n" == separator) { 6219 if ("\n" == separator) {
6220 _writer.print("\n"); 6220 _writer.print("\n");
6221 indent(); 6221 indent();
6222 } else if (i > 0) { 6222 } else if (i > 0) {
6223 _writer.print(separator); 6223 _writer.print(separator);
6224 } 6224 }
6225 nodes[i].accept(this); 6225 nodes[i].accept(this);
6226 } 6226 }
6227 } 6227 }
6228 } 6228 }
6229 6229
6230 /** 6230 /**
6231 * Print a list of nodes, separated by the given separator. 6231 * Print a list of nodes, separated by the given separator.
6232 * @param nodes the nodes to be printed 6232 * @param nodes the nodes to be printed
6233 * @param separator the separator to be printed between adjacent nodes 6233 * @param separator the separator to be printed between adjacent nodes
6234 * @param suffix the suffix to be printed if the list is not empty 6234 * @param suffix the suffix to be printed if the list is not empty
6235 */ 6235 */
6236 void visitList6(NodeList<ASTNode> nodes, String separator, String suffix) { 6236 void visitList6(NodeList<ASTNode> nodes, String separator, String suffix) {
6237 if (nodes != null) { 6237 if (nodes != null) {
6238 int size2 = nodes.length; 6238 int size = nodes.length;
6239 if (size2 > 0) { 6239 if (size > 0) {
6240 for (int i = 0; i < size2; i++) { 6240 for (int i = 0; i < size; i++) {
6241 if (i > 0) { 6241 if (i > 0) {
6242 _writer.print(separator); 6242 _writer.print(separator);
6243 } 6243 }
6244 nodes[i].accept(this); 6244 nodes[i].accept(this);
6245 } 6245 }
6246 _writer.print(suffix); 6246 _writer.print(suffix);
6247 } 6247 }
6248 } 6248 }
6249 } 6249 }
6250 6250
6251 /** 6251 /**
6252 * Print a list of nodes, separated by the given separator. 6252 * Print a list of nodes, separated by the given separator.
6253 * @param prefix the prefix to be printed if the list is not empty 6253 * @param prefix the prefix to be printed if the list is not empty
6254 * @param nodes the nodes to be printed 6254 * @param nodes the nodes to be printed
6255 * @param separator the separator to be printed between adjacent nodes 6255 * @param separator the separator to be printed between adjacent nodes
6256 */ 6256 */
6257 void visitList7(String prefix, NodeList<ASTNode> nodes, String separator) { 6257 void visitList7(String prefix, NodeList<ASTNode> nodes, String separator) {
6258 if (nodes != null) { 6258 if (nodes != null) {
6259 int size2 = nodes.length; 6259 int size = nodes.length;
6260 if (size2 > 0) { 6260 if (size > 0) {
6261 _writer.print(prefix); 6261 _writer.print(prefix);
6262 for (int i = 0; i < size2; i++) { 6262 for (int i = 0; i < size; i++) {
6263 if (i > 0) { 6263 if (i > 0) {
6264 _writer.print(separator); 6264 _writer.print(separator);
6265 } 6265 }
6266 nodes[i].accept(this); 6266 nodes[i].accept(this);
6267 } 6267 }
6268 } 6268 }
6269 } 6269 }
6270 } 6270 }
6271 } 6271 }
OLDNEW
« no previous file with comments | « pkg/analyzer_experimental/lib/src/generated/html.dart ('k') | pkg/analyzer_experimental/lib/src/generated/resolver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698