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

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

Issue 829133007: Enable enum and deferred import support (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 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 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine.parser; 8 library engine.parser;
9 9
10 import "dart:math" as math; 10 import "dart:math" as math;
(...skipping 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after
1105 //return parser.parseDeclaredIdentifier(); 1105 //return parser.parseDeclaredIdentifier();
1106 } else if (identical(_oldNode, node.identifier)) { 1106 } else if (identical(_oldNode, node.identifier)) {
1107 return _parser.parseSimpleIdentifier(); 1107 return _parser.parseSimpleIdentifier();
1108 } else if (identical(_oldNode, node.body)) { 1108 } else if (identical(_oldNode, node.body)) {
1109 return _parser.parseStatement2(); 1109 return _parser.parseStatement2();
1110 } 1110 }
1111 return _notAChild(node); 1111 return _notAChild(node);
1112 } 1112 }
1113 1113
1114 @override 1114 @override
1115 AstNode visitFormalParameterList(FormalParameterList node) {
1116 // We don't know which kind of parameter to parse.
1117 throw new InsufficientContextException();
1118 }
1119
1120 @override
1121 AstNode visitForStatement(ForStatement node) { 1115 AstNode visitForStatement(ForStatement node) {
1122 if (identical(_oldNode, node.variables)) { 1116 if (identical(_oldNode, node.variables)) {
1123 throw new InsufficientContextException(); 1117 throw new InsufficientContextException();
1124 } else if (identical(_oldNode, node.initialization)) { 1118 } else if (identical(_oldNode, node.initialization)) {
1125 throw new InsufficientContextException(); 1119 throw new InsufficientContextException();
1126 } else if (identical(_oldNode, node.condition)) { 1120 } else if (identical(_oldNode, node.condition)) {
1127 return _parser.parseExpression2(); 1121 return _parser.parseExpression2();
1128 } else if (node.updaters.contains(_oldNode)) { 1122 } else if (node.updaters.contains(_oldNode)) {
1129 return _parser.parseExpression2(); 1123 return _parser.parseExpression2();
1130 } else if (identical(_oldNode, node.body)) { 1124 } else if (identical(_oldNode, node.body)) {
1131 return _parser.parseStatement2(); 1125 return _parser.parseStatement2();
1132 } 1126 }
1133 return _notAChild(node); 1127 return _notAChild(node);
1134 } 1128 }
1135 1129
1136 @override 1130 @override
1131 AstNode visitFormalParameterList(FormalParameterList node) {
1132 // We don't know which kind of parameter to parse.
1133 throw new InsufficientContextException();
1134 }
1135
1136 @override
1137 AstNode visitFunctionDeclaration(FunctionDeclaration node) { 1137 AstNode visitFunctionDeclaration(FunctionDeclaration node) {
1138 if (identical(_oldNode, node.documentationComment)) { 1138 if (identical(_oldNode, node.documentationComment)) {
1139 throw new InsufficientContextException(); 1139 throw new InsufficientContextException();
1140 } else if (node.metadata.contains(_oldNode)) { 1140 } else if (node.metadata.contains(_oldNode)) {
1141 return _parser.parseAnnotation(); 1141 return _parser.parseAnnotation();
1142 } else if (identical(_oldNode, node.returnType)) { 1142 } else if (identical(_oldNode, node.returnType)) {
1143 return _parser.parseReturnType(); 1143 return _parser.parseReturnType();
1144 } else if (identical(_oldNode, node.name)) { 1144 } else if (identical(_oldNode, node.name)) {
1145 return _parser.parseSimpleIdentifier(); 1145 return _parser.parseSimpleIdentifier();
1146 } else if (identical(_oldNode, node.functionExpression)) { 1146 } else if (identical(_oldNode, node.functionExpression)) {
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
1475 1475
1476 @override 1476 @override
1477 AstNode visitPostfixExpression(PostfixExpression node) { 1477 AstNode visitPostfixExpression(PostfixExpression node) {
1478 if (identical(_oldNode, node.operand)) { 1478 if (identical(_oldNode, node.operand)) {
1479 throw new InsufficientContextException(); 1479 throw new InsufficientContextException();
1480 } 1480 }
1481 return _notAChild(node); 1481 return _notAChild(node);
1482 } 1482 }
1483 1483
1484 @override 1484 @override
1485 AstNode visitPrefixExpression(PrefixExpression node) {
1486 if (identical(_oldNode, node.operand)) {
1487 throw new InsufficientContextException();
1488 }
1489 return _notAChild(node);
1490 }
1491
1492 @override
1485 AstNode visitPrefixedIdentifier(PrefixedIdentifier node) { 1493 AstNode visitPrefixedIdentifier(PrefixedIdentifier node) {
1486 if (identical(_oldNode, node.prefix)) { 1494 if (identical(_oldNode, node.prefix)) {
1487 return _parser.parseSimpleIdentifier(); 1495 return _parser.parseSimpleIdentifier();
1488 } else if (identical(_oldNode, node.identifier)) { 1496 } else if (identical(_oldNode, node.identifier)) {
1489 return _parser.parseSimpleIdentifier(); 1497 return _parser.parseSimpleIdentifier();
1490 } 1498 }
1491 return _notAChild(node); 1499 return _notAChild(node);
1492 } 1500 }
1493
1494 @override
1495 AstNode visitPrefixExpression(PrefixExpression node) {
1496 if (identical(_oldNode, node.operand)) {
1497 throw new InsufficientContextException();
1498 }
1499 return _notAChild(node);
1500 }
1501 1501
1502 @override 1502 @override
1503 AstNode visitPropertyAccess(PropertyAccess node) { 1503 AstNode visitPropertyAccess(PropertyAccess node) {
1504 if (identical(_oldNode, node.target)) { 1504 if (identical(_oldNode, node.target)) {
1505 throw new InsufficientContextException(); 1505 throw new InsufficientContextException();
1506 } else if (identical(_oldNode, node.propertyName)) { 1506 } else if (identical(_oldNode, node.propertyName)) {
1507 return _parser.parseSimpleIdentifier(); 1507 return _parser.parseSimpleIdentifier();
1508 } 1508 }
1509 return _notAChild(node); 1509 return _notAChild(node);
1510 } 1510 }
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
1818 1818
1819 /** 1819 /**
1820 * Initialize a newly created exception to have no message and to have the giv en cause. 1820 * Initialize a newly created exception to have no message and to have the giv en cause.
1821 * 1821 *
1822 * @param cause the exception that caused this exception 1822 * @param cause the exception that caused this exception
1823 */ 1823 */
1824 IncrementalParseException.con2(Exception cause) : super(cause: cause); 1824 IncrementalParseException.con2(Exception cause) : super(cause: cause);
1825 } 1825 }
1826 1826
1827 /** 1827 /**
1828 * Visitor capable of inferring the correct parser state for incremental
1829 * parsing. This visitor visits each parent/child relationship in the chain of
1830 * ancestors of the node to be replaced (starting with the root of the parse
1831 * tree), updating the parser to the correct state for parsing the child of the
1832 * given parent. Once it has visited all of these relationships, the parser
1833 * will be in the correct state for reparsing the node to be replaced.
1834 *
1835 * TODO(paulberry): add support for other pieces of parser state (_inAsync,
1836 * _inGenerator, _inLoop, and _inSwitch). Note that _inLoop and _inSwitch only
1837 * affect error message generation.
1838 */
1839 class IncrementalParseStateBuilder extends SimpleAstVisitor {
1840 /**
1841 * The parser whose state should be built.
1842 */
1843 final Parser _parser;
1844
1845 /**
1846 * The child node in the parent/child relationship currently being visited.
1847 * (The corresponding parent is the node passed to the visit...() function.)
1848 */
1849 AstNode _childNode;
1850
1851 /**
1852 * Create an IncrementalParseStateBuilder which will build the correct state
1853 * for [_parser].
1854 */
1855 IncrementalParseStateBuilder(this._parser);
1856
1857 /**
1858 * Build the correct parser state for parsing a replacement for [node].
1859 */
1860 void buildState(AstNode node) {
1861 List<AstNode> ancestors = <AstNode>[];
1862 while (node != null) {
1863 ancestors.add(node);
1864 node = node.parent;
1865 }
1866 _parser._inInitializer = false;
1867 for (int i = ancestors.length - 2; i >= 0; i--) {
1868 _childNode = ancestors[i];
1869 ancestors[i + 1].accept(this);
1870 }
1871 }
1872
1873 @override
1874 void visitArgumentList(ArgumentList node) {
1875 _parser._inInitializer = false;
1876 }
1877
1878 @override
1879 void visitConstructorFieldInitializer(ConstructorFieldInitializer node) {
1880 if (identical(_childNode, node.expression)) {
1881 _parser._inInitializer = true;
1882 }
1883 }
1884
1885 @override
1886 void visitIndexExpression(IndexExpression node) {
1887 if (identical(_childNode, node.index)) {
1888 _parser._inInitializer = false;
1889 }
1890 }
1891
1892 @override
1893 void visitInterpolationExpression(InterpolationExpression node) {
1894 if (identical(_childNode, node.expression)) {
1895 _parser._inInitializer = false;
1896 }
1897 }
1898
1899 @override
1900 void visitListLiteral(ListLiteral node) {
1901 if (node.elements.contains(_childNode)) {
1902 _parser._inInitializer = false;
1903 }
1904 }
1905
1906 @override
1907 void visitMapLiteral(MapLiteral node) {
1908 if (node.entries.contains(_childNode)) {
1909 _parser._inInitializer = false;
1910 }
1911 }
1912
1913 @override
1914 void visitParenthesizedExpression(ParenthesizedExpression node) {
1915 if (identical(_childNode, node.expression)) {
1916 _parser._inInitializer = false;
1917 }
1918 }
1919 }
1920
1921 /**
1828 * Instances of the class `IncrementalParser` re-parse a single AST structure wi thin a larger 1922 * Instances of the class `IncrementalParser` re-parse a single AST structure wi thin a larger
1829 * AST structure. 1923 * AST structure.
1830 */ 1924 */
1831 class IncrementalParser { 1925 class IncrementalParser {
1832 /** 1926 /**
1833 * The source being parsed. 1927 * The source being parsed.
1834 */ 1928 */
1835 final Source _source; 1929 final Source _source;
1836 1930
1837 /** 1931 /**
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1995 */ 2089 */
1996 Token _findTokenAt(Token firstToken, int offset) { 2090 Token _findTokenAt(Token firstToken, int offset) {
1997 while (firstToken.offset > offset && firstToken.type != TokenType.EOF) { 2091 while (firstToken.offset > offset && firstToken.type != TokenType.EOF) {
1998 firstToken = firstToken.previous; 2092 firstToken = firstToken.previous;
1999 } 2093 }
2000 return firstToken; 2094 return firstToken;
2001 } 2095 }
2002 } 2096 }
2003 2097
2004 /** 2098 /**
2005 * Visitor capable of inferring the correct parser state for incremental
2006 * parsing. This visitor visits each parent/child relationship in the chain of
2007 * ancestors of the node to be replaced (starting with the root of the parse
2008 * tree), updating the parser to the correct state for parsing the child of the
2009 * given parent. Once it has visited all of these relationships, the parser
2010 * will be in the correct state for reparsing the node to be replaced.
2011 *
2012 * TODO(paulberry): add support for other pieces of parser state (_inAsync,
2013 * _inGenerator, _inLoop, and _inSwitch). Note that _inLoop and _inSwitch only
2014 * affect error message generation.
2015 */
2016 class IncrementalParseStateBuilder extends SimpleAstVisitor {
2017 /**
2018 * The parser whose state should be built.
2019 */
2020 final Parser _parser;
2021
2022 /**
2023 * The child node in the parent/child relationship currently being visited.
2024 * (The corresponding parent is the node passed to the visit...() function.)
2025 */
2026 AstNode _childNode;
2027
2028 /**
2029 * Create an IncrementalParseStateBuilder which will build the correct state
2030 * for [_parser].
2031 */
2032 IncrementalParseStateBuilder(this._parser);
2033
2034 /**
2035 * Build the correct parser state for parsing a replacement for [node].
2036 */
2037 void buildState(AstNode node) {
2038 List<AstNode> ancestors = <AstNode>[];
2039 while (node != null) {
2040 ancestors.add(node);
2041 node = node.parent;
2042 }
2043 _parser._inInitializer = false;
2044 for (int i = ancestors.length - 2; i >= 0; i--) {
2045 _childNode = ancestors[i];
2046 ancestors[i + 1].accept(this);
2047 }
2048 }
2049
2050 @override
2051 void visitArgumentList(ArgumentList node) {
2052 _parser._inInitializer = false;
2053 }
2054
2055 @override
2056 void visitConstructorFieldInitializer(ConstructorFieldInitializer node) {
2057 if (identical(_childNode, node.expression)) {
2058 _parser._inInitializer = true;
2059 }
2060 }
2061
2062 @override
2063 void visitIndexExpression(IndexExpression node) {
2064 if (identical(_childNode, node.index)) {
2065 _parser._inInitializer = false;
2066 }
2067 }
2068
2069 @override
2070 void visitInterpolationExpression(InterpolationExpression node) {
2071 if (identical(_childNode, node.expression)) {
2072 _parser._inInitializer = false;
2073 }
2074 }
2075
2076 @override
2077 void visitListLiteral(ListLiteral node) {
2078 if (node.elements.contains(_childNode)) {
2079 _parser._inInitializer = false;
2080 }
2081 }
2082
2083 @override
2084 void visitMapLiteral(MapLiteral node) {
2085 if (node.entries.contains(_childNode)) {
2086 _parser._inInitializer = false;
2087 }
2088 }
2089
2090 @override
2091 void visitParenthesizedExpression(ParenthesizedExpression node) {
2092 if (identical(_childNode, node.expression)) {
2093 _parser._inInitializer = false;
2094 }
2095 }
2096 }
2097
2098 /**
2099 * Instances of the class `InsufficientContextException` represent a situation i n which an AST 2099 * Instances of the class `InsufficientContextException` represent a situation i n which an AST
2100 * node cannot be re-parsed because there is not enough context to know how to r e-parse the node. 2100 * node cannot be re-parsed because there is not enough context to know how to r e-parse the node.
2101 * Clients can attempt to re-parse the parent of the node. 2101 * Clients can attempt to re-parse the parent of the node.
2102 */ 2102 */
2103 class InsufficientContextException extends IncrementalParseException { 2103 class InsufficientContextException extends IncrementalParseException {
2104 /** 2104 /**
2105 * Initialize a newly created exception to have no message and to be its own c ause. 2105 * Initialize a newly created exception to have no message and to be its own c ause.
2106 */ 2106 */
2107 InsufficientContextException() : super(); 2107 InsufficientContextException() : super();
2108 2108
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
2265 * An [errorListener] lock, if more than `0`, then errors are not reported. 2265 * An [errorListener] lock, if more than `0`, then errors are not reported.
2266 */ 2266 */
2267 int _errorListenerLock = 0; 2267 int _errorListenerLock = 0;
2268 2268
2269 /** 2269 /**
2270 * A flag indicating whether parser is to parse function bodies. 2270 * A flag indicating whether parser is to parse function bodies.
2271 */ 2271 */
2272 bool _parseFunctionBodies = true; 2272 bool _parseFunctionBodies = true;
2273 2273
2274 /** 2274 /**
2275 * A flag indicating whether the parser is to parse deferred libraries.
2276 */
2277 bool _parseDeferredLibraries =
2278 AnalysisOptionsImpl.DEFAULT_ENABLE_DEFERRED_LOADING;
2279
2280 /**
2281 * A flag indicating whether the parser is to parse enum declarations.
2282 */
2283 bool _parseEnum = AnalysisOptionsImpl.DEFAULT_ENABLE_ENUM;
2284
2285 /**
2286 * The next token to be parsed. 2275 * The next token to be parsed.
2287 */ 2276 */
2288 Token _currentToken; 2277 Token _currentToken;
2289 2278
2290 /** 2279 /**
2291 * A flag indicating whether the parser is currently in a function body marked as being 'async'. 2280 * A flag indicating whether the parser is currently in a function body marked as being 'async'.
2292 */ 2281 */
2293 bool _inAsync = false; 2282 bool _inAsync = false;
2294 2283
2295 /** 2284 /**
(...skipping 24 matching lines...) Expand all
2320 * @param errorListener the error listener that will be informed of any errors that are found 2309 * @param errorListener the error listener that will be informed of any errors that are found
2321 * during the parse 2310 * during the parse
2322 */ 2311 */
2323 Parser(this._source, this._errorListener); 2312 Parser(this._source, this._errorListener);
2324 2313
2325 void set currentToken(Token currentToken) { 2314 void set currentToken(Token currentToken) {
2326 this._currentToken = currentToken; 2315 this._currentToken = currentToken;
2327 } 2316 }
2328 2317
2329 /** 2318 /**
2330 * Advance to the next token in the token stream, making it the new current
2331 * token and return the token that was current before this method was invoked.
2332 */
2333 Token getAndAdvance() {
2334 Token token = _currentToken;
2335 _advance();
2336 return token;
2337 }
2338
2339 /**
2340 * Return `true` if the current token is the first token of a return type that is followed 2319 * Return `true` if the current token is the first token of a return type that is followed
2341 * by an identifier, possibly followed by a list of type parameters, followed by a 2320 * by an identifier, possibly followed by a list of type parameters, followed by a
2342 * left-parenthesis. This is used by parseTypeAlias to determine whether or no t to parse a return 2321 * left-parenthesis. This is used by parseTypeAlias to determine whether or no t to parse a return
2343 * type. 2322 * type.
2344 * 2323 *
2345 * @return `true` if we can successfully parse the rest of a type alias if we first parse a 2324 * @return `true` if we can successfully parse the rest of a type alias if we first parse a
2346 * return type. 2325 * return type.
2347 */ 2326 */
2348 bool get hasReturnTypeInTypeAlias { 2327 bool get hasReturnTypeInTypeAlias {
2349 Token next = _skipReturnType(_currentToken); 2328 Token next = _skipReturnType(_currentToken);
2350 if (next == null) { 2329 if (next == null) {
2351 return false; 2330 return false;
2352 } 2331 }
2353 return _tokenMatchesIdentifier(next); 2332 return _tokenMatchesIdentifier(next);
2354 } 2333 }
2355 2334
2356 /** 2335 /**
2336 * Set whether the parser is to parse the async support.
2337 *
2338 * @param parseAsync `true` if the parser is to parse the async support
2339 */
2340 void set parseAsync(bool parseAsync) {
2341 // Async support cannot be disabled
2342 }
2343
2344 /**
2357 * Set whether the parser is to parse deferred libraries. 2345 * Set whether the parser is to parse deferred libraries.
2358 * 2346 *
2359 * @param parseDeferredLibraries `true` if the parser is to parse deferred lib raries 2347 * @param parseDeferredLibraries `true` if the parser is to parse deferred lib raries
2360 */ 2348 */
2361 void set parseDeferredLibraries(bool parseDeferredLibraries) { 2349 void set parseDeferredLibraries(bool parseDeferredLibraries) {
2362 this._parseDeferredLibraries = parseDeferredLibraries; 2350 // Deferred libraries support cannot be disabled
2363 } 2351 }
2364 2352
2365 /** 2353 /**
2366 * Set whether the parser is to parse enum declarations. 2354 * Set whether the parser is to parse enum declarations.
2367 * 2355 *
2368 * @param parseEnum `true` if the parser is to parse enum declarations 2356 * @param parseEnum `true` if the parser is to parse enum declarations
2369 */ 2357 */
2370 void set parseEnum(bool parseEnum) { 2358 void set parseEnum(bool parseEnum) {
2371 this._parseEnum = parseEnum; 2359 // Enum support cannot be disabled
2372 } 2360 }
2373 2361
2374 /** 2362 /**
2375 * Set whether parser is to parse function bodies. 2363 * Set whether parser is to parse function bodies.
2376 * 2364 *
2377 * @param parseFunctionBodies `true` if parser is to parse function bodies 2365 * @param parseFunctionBodies `true` if parser is to parse function bodies
2378 */ 2366 */
2379 void set parseFunctionBodies(bool parseFunctionBodies) { 2367 void set parseFunctionBodies(bool parseFunctionBodies) {
2380 this._parseFunctionBodies = parseFunctionBodies; 2368 this._parseFunctionBodies = parseFunctionBodies;
2381 } 2369 }
2382 2370
2383 /** 2371 /**
2372 * Advance to the next token in the token stream, making it the new current
2373 * token and return the token that was current before this method was invoked.
2374 */
2375 Token getAndAdvance() {
2376 Token token = _currentToken;
2377 _advance();
2378 return token;
2379 }
2380
2381 /**
2384 * Parse an annotation. 2382 * Parse an annotation.
2385 * 2383 *
2386 * <pre> 2384 * <pre>
2387 * annotation ::= 2385 * annotation ::=
2388 * '@' qualified ('.' identifier)? arguments? 2386 * '@' qualified ('.' identifier)? arguments?
2389 * </pre> 2387 * </pre>
2390 * 2388 *
2391 * @return the annotation that was parsed 2389 * @return the annotation that was parsed
2392 */ 2390 */
2393 Annotation parseAnnotation() { 2391 Annotation parseAnnotation() {
(...skipping 3127 matching lines...) Expand 10 before | Expand all | Expand 10 after
5521 if (_matchesKeyword(Keyword.CLASS)) { 5519 if (_matchesKeyword(Keyword.CLASS)) {
5522 return _parseClassDeclaration( 5520 return _parseClassDeclaration(
5523 commentAndMetadata, 5521 commentAndMetadata,
5524 _validateModifiersForClass(modifiers)); 5522 _validateModifiersForClass(modifiers));
5525 } else if (_matchesKeyword(Keyword.TYPEDEF) && 5523 } else if (_matchesKeyword(Keyword.TYPEDEF) &&
5526 !_tokenMatches(_peek(), TokenType.PERIOD) && 5524 !_tokenMatches(_peek(), TokenType.PERIOD) &&
5527 !_tokenMatches(_peek(), TokenType.LT) && 5525 !_tokenMatches(_peek(), TokenType.LT) &&
5528 !_tokenMatches(_peek(), TokenType.OPEN_PAREN)) { 5526 !_tokenMatches(_peek(), TokenType.OPEN_PAREN)) {
5529 _validateModifiersForTypedef(modifiers); 5527 _validateModifiersForTypedef(modifiers);
5530 return _parseTypeAlias(commentAndMetadata); 5528 return _parseTypeAlias(commentAndMetadata);
5531 } else if (_parseEnum && _matchesKeyword(Keyword.ENUM)) { 5529 } else if (_matchesKeyword(Keyword.ENUM)) {
5532 _validateModifiersForEnum(modifiers); 5530 _validateModifiersForEnum(modifiers);
5533 return _parseEnumDeclaration(commentAndMetadata); 5531 return _parseEnumDeclaration(commentAndMetadata);
5534 } 5532 }
5535 if (_matchesKeyword(Keyword.VOID)) { 5533 if (_matchesKeyword(Keyword.VOID)) {
5536 TypeName returnType = parseReturnType(); 5534 TypeName returnType = parseReturnType();
5537 if ((_matchesKeyword(Keyword.GET) || _matchesKeyword(Keyword.SET)) && 5535 if ((_matchesKeyword(Keyword.GET) || _matchesKeyword(Keyword.SET)) &&
5538 _tokenMatchesIdentifier(_peek())) { 5536 _tokenMatchesIdentifier(_peek())) {
5539 _validateModifiersForTopLevelFunction(modifiers); 5537 _validateModifiersForTopLevelFunction(modifiers);
5540 return _parseFunctionDeclaration( 5538 return _parseFunctionDeclaration(
5541 commentAndMetadata, 5539 commentAndMetadata,
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
5979 } 5977 }
5980 return new CompilationUnit( 5978 return new CompilationUnit(
5981 firstToken, 5979 firstToken,
5982 scriptTag, 5980 scriptTag,
5983 directives, 5981 directives,
5984 new List<CompilationUnitMember>(), 5982 new List<CompilationUnitMember>(),
5985 _currentToken); 5983 _currentToken);
5986 } 5984 }
5987 5985
5988 /** 5986 /**
5987 * Parse a do statement.
5988 *
5989 * <pre>
5990 * doStatement ::=
5991 * 'do' statement 'while' '(' expression ')' ';'
5992 * </pre>
5993 *
5994 * @return the do statement that was parsed
5995 */
5996 Statement _parseDoStatement() {
5997 bool wasInLoop = _inLoop;
5998 _inLoop = true;
5999 try {
6000 Token doKeyword = _expectKeyword(Keyword.DO);
6001 Statement body = parseStatement2();
6002 Token whileKeyword = _expectKeyword(Keyword.WHILE);
6003 Token leftParenthesis = _expect(TokenType.OPEN_PAREN);
6004 Expression condition = parseExpression2();
6005 Token rightParenthesis = _expect(TokenType.CLOSE_PAREN);
6006 Token semicolon = _expect(TokenType.SEMICOLON);
6007 return new DoStatement(
6008 doKeyword,
6009 body,
6010 whileKeyword,
6011 leftParenthesis,
6012 condition,
6013 rightParenthesis,
6014 semicolon);
6015 } finally {
6016 _inLoop = wasInLoop;
6017 }
6018 }
6019
6020 /**
5989 * Parse a documentation comment. 6021 * Parse a documentation comment.
5990 * 6022 *
5991 * <pre> 6023 * <pre>
5992 * documentationComment ::= 6024 * documentationComment ::=
5993 * multiLineComment? 6025 * multiLineComment?
5994 * | singleLineComment* 6026 * | singleLineComment*
5995 * </pre> 6027 * </pre>
5996 * 6028 *
5997 * @return the documentation comment that was parsed, or `null` if there was n o comment 6029 * @return the documentation comment that was parsed, or `null` if there was n o comment
5998 */ 6030 */
(...skipping 21 matching lines...) Expand all
6020 return null; 6052 return null;
6021 } 6053 }
6022 List<CommentReference> references = 6054 List<CommentReference> references =
6023 _parseCommentReferences(documentationTokens); 6055 _parseCommentReferences(documentationTokens);
6024 return Comment.createDocumentationCommentWithReferences( 6056 return Comment.createDocumentationCommentWithReferences(
6025 documentationTokens, 6057 documentationTokens,
6026 references); 6058 references);
6027 } 6059 }
6028 6060
6029 /** 6061 /**
6030 * Parse a do statement.
6031 *
6032 * <pre>
6033 * doStatement ::=
6034 * 'do' statement 'while' '(' expression ')' ';'
6035 * </pre>
6036 *
6037 * @return the do statement that was parsed
6038 */
6039 Statement _parseDoStatement() {
6040 bool wasInLoop = _inLoop;
6041 _inLoop = true;
6042 try {
6043 Token doKeyword = _expectKeyword(Keyword.DO);
6044 Statement body = parseStatement2();
6045 Token whileKeyword = _expectKeyword(Keyword.WHILE);
6046 Token leftParenthesis = _expect(TokenType.OPEN_PAREN);
6047 Expression condition = parseExpression2();
6048 Token rightParenthesis = _expect(TokenType.CLOSE_PAREN);
6049 Token semicolon = _expect(TokenType.SEMICOLON);
6050 return new DoStatement(
6051 doKeyword,
6052 body,
6053 whileKeyword,
6054 leftParenthesis,
6055 condition,
6056 rightParenthesis,
6057 semicolon);
6058 } finally {
6059 _inLoop = wasInLoop;
6060 }
6061 }
6062
6063 /**
6064 * Parse an empty statement. 6062 * Parse an empty statement.
6065 * 6063 *
6066 * <pre> 6064 * <pre>
6067 * emptyStatement ::= 6065 * emptyStatement ::=
6068 * ';' 6066 * ';'
6069 * </pre> 6067 * </pre>
6070 * 6068 *
6071 * @return the empty statement that was parsed 6069 * @return the empty statement that was parsed
6072 */ 6070 */
6073 Statement _parseEmptyStatement() => new EmptyStatement(getAndAdvance()); 6071 Statement _parseEmptyStatement() => new EmptyStatement(getAndAdvance());
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
6245 type = parseReturnType(); 6243 type = parseReturnType();
6246 } else if (!optional) { 6244 } else if (!optional) {
6247 _reportErrorForCurrentToken( 6245 _reportErrorForCurrentToken(
6248 ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE); 6246 ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE);
6249 } 6247 }
6250 } 6248 }
6251 return new FinalConstVarOrType(keyword, type); 6249 return new FinalConstVarOrType(keyword, type);
6252 } 6250 }
6253 6251
6254 /** 6252 /**
6255 * Parse a formal parameter. At most one of `isOptional` and `isNamed` can be
6256 * `true`.
6257 *
6258 * <pre>
6259 * defaultFormalParameter ::=
6260 * normalFormalParameter ('=' expression)?
6261 *
6262 * defaultNamedParameter ::=
6263 * normalFormalParameter (':' expression)?
6264 * </pre>
6265 *
6266 * @param kind the kind of parameter being expected based on the presence or a bsence of group
6267 * delimiters
6268 * @return the formal parameter that was parsed
6269 */
6270 FormalParameter _parseFormalParameter(ParameterKind kind) {
6271 NormalFormalParameter parameter = parseNormalFormalParameter();
6272 if (_matches(TokenType.EQ)) {
6273 Token seperator = getAndAdvance();
6274 Expression defaultValue = parseExpression2();
6275 if (kind == ParameterKind.NAMED) {
6276 _reportErrorForToken(
6277 ParserErrorCode.WRONG_SEPARATOR_FOR_NAMED_PARAMETER,
6278 seperator);
6279 } else if (kind == ParameterKind.REQUIRED) {
6280 _reportErrorForNode(
6281 ParserErrorCode.POSITIONAL_PARAMETER_OUTSIDE_GROUP,
6282 parameter);
6283 }
6284 return new DefaultFormalParameter(
6285 parameter,
6286 kind,
6287 seperator,
6288 defaultValue);
6289 } else if (_matches(TokenType.COLON)) {
6290 Token seperator = getAndAdvance();
6291 Expression defaultValue = parseExpression2();
6292 if (kind == ParameterKind.POSITIONAL) {
6293 _reportErrorForToken(
6294 ParserErrorCode.WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER,
6295 seperator);
6296 } else if (kind == ParameterKind.REQUIRED) {
6297 _reportErrorForNode(
6298 ParserErrorCode.NAMED_PARAMETER_OUTSIDE_GROUP,
6299 parameter);
6300 }
6301 return new DefaultFormalParameter(
6302 parameter,
6303 kind,
6304 seperator,
6305 defaultValue);
6306 } else if (kind != ParameterKind.REQUIRED) {
6307 return new DefaultFormalParameter(parameter, kind, null, null);
6308 }
6309 return parameter;
6310 }
6311
6312 /**
6313 * Parse a for statement. 6253 * Parse a for statement.
6314 * 6254 *
6315 * <pre> 6255 * <pre>
6316 * forStatement ::= 6256 * forStatement ::=
6317 * 'for' '(' forLoopParts ')' statement 6257 * 'for' '(' forLoopParts ')' statement
6318 * 6258 *
6319 * forLoopParts ::= 6259 * forLoopParts ::=
6320 * forInitializerStatement expression? ';' expressionList? 6260 * forInitializerStatement expression? ';' expressionList?
6321 * | declaredIdentifier 'in' expression 6261 * | declaredIdentifier 'in' expression
6322 * | identifier 'in' expression 6262 * | identifier 'in' expression
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
6454 rightSeparator, 6394 rightSeparator,
6455 updaters, 6395 updaters,
6456 rightParenthesis, 6396 rightParenthesis,
6457 body); 6397 body);
6458 } finally { 6398 } finally {
6459 _inLoop = wasInLoop; 6399 _inLoop = wasInLoop;
6460 } 6400 }
6461 } 6401 }
6462 6402
6463 /** 6403 /**
6404 * Parse a formal parameter. At most one of `isOptional` and `isNamed` can be
6405 * `true`.
6406 *
6407 * <pre>
6408 * defaultFormalParameter ::=
6409 * normalFormalParameter ('=' expression)?
6410 *
6411 * defaultNamedParameter ::=
6412 * normalFormalParameter (':' expression)?
6413 * </pre>
6414 *
6415 * @param kind the kind of parameter being expected based on the presence or a bsence of group
6416 * delimiters
6417 * @return the formal parameter that was parsed
6418 */
6419 FormalParameter _parseFormalParameter(ParameterKind kind) {
6420 NormalFormalParameter parameter = parseNormalFormalParameter();
6421 if (_matches(TokenType.EQ)) {
6422 Token seperator = getAndAdvance();
6423 Expression defaultValue = parseExpression2();
6424 if (kind == ParameterKind.NAMED) {
6425 _reportErrorForToken(
6426 ParserErrorCode.WRONG_SEPARATOR_FOR_NAMED_PARAMETER,
6427 seperator);
6428 } else if (kind == ParameterKind.REQUIRED) {
6429 _reportErrorForNode(
6430 ParserErrorCode.POSITIONAL_PARAMETER_OUTSIDE_GROUP,
6431 parameter);
6432 }
6433 return new DefaultFormalParameter(
6434 parameter,
6435 kind,
6436 seperator,
6437 defaultValue);
6438 } else if (_matches(TokenType.COLON)) {
6439 Token seperator = getAndAdvance();
6440 Expression defaultValue = parseExpression2();
6441 if (kind == ParameterKind.POSITIONAL) {
6442 _reportErrorForToken(
6443 ParserErrorCode.WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER,
6444 seperator);
6445 } else if (kind == ParameterKind.REQUIRED) {
6446 _reportErrorForNode(
6447 ParserErrorCode.NAMED_PARAMETER_OUTSIDE_GROUP,
6448 parameter);
6449 }
6450 return new DefaultFormalParameter(
6451 parameter,
6452 kind,
6453 seperator,
6454 defaultValue);
6455 } else if (kind != ParameterKind.REQUIRED) {
6456 return new DefaultFormalParameter(parameter, kind, null, null);
6457 }
6458 return parameter;
6459 }
6460
6461 /**
6464 * Parse a function body. 6462 * Parse a function body.
6465 * 6463 *
6466 * <pre> 6464 * <pre>
6467 * functionBody ::= 6465 * functionBody ::=
6468 * '=>' expression ';' 6466 * '=>' expression ';'
6469 * | block 6467 * | block
6470 * 6468 *
6471 * functionExpressionBody ::= 6469 * functionExpressionBody ::=
6472 * '=>' expression 6470 * '=>' expression
6473 * | block 6471 * | block
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
6888 * @param commentAndMetadata the metadata to be associated with the directive 6886 * @param commentAndMetadata the metadata to be associated with the directive
6889 * @return the import directive that was parsed 6887 * @return the import directive that was parsed
6890 */ 6888 */
6891 ImportDirective _parseImportDirective(CommentAndMetadata commentAndMetadata) { 6889 ImportDirective _parseImportDirective(CommentAndMetadata commentAndMetadata) {
6892 Token importKeyword = _expectKeyword(Keyword.IMPORT); 6890 Token importKeyword = _expectKeyword(Keyword.IMPORT);
6893 StringLiteral libraryUri = _parseUri(); 6891 StringLiteral libraryUri = _parseUri();
6894 Token deferredToken = null; 6892 Token deferredToken = null;
6895 Token asToken = null; 6893 Token asToken = null;
6896 SimpleIdentifier prefix = null; 6894 SimpleIdentifier prefix = null;
6897 if (_matchesKeyword(Keyword.DEFERRED)) { 6895 if (_matchesKeyword(Keyword.DEFERRED)) {
6898 if (_parseDeferredLibraries) { 6896 deferredToken = getAndAdvance();
6899 deferredToken = getAndAdvance();
6900 } else {
6901 _reportErrorForCurrentToken(
6902 ParserErrorCode.DEFERRED_IMPORTS_NOT_SUPPORTED);
6903 _advance();
6904 }
6905 } 6897 }
6906 if (_matchesKeyword(Keyword.AS)) { 6898 if (_matchesKeyword(Keyword.AS)) {
6907 asToken = getAndAdvance(); 6899 asToken = getAndAdvance();
6908 prefix = parseSimpleIdentifier(); 6900 prefix = parseSimpleIdentifier();
6909 } else if (deferredToken != null) { 6901 } else if (deferredToken != null) {
6910 _reportErrorForCurrentToken( 6902 _reportErrorForCurrentToken(
6911 ParserErrorCode.MISSING_PREFIX_IN_DEFERRED_IMPORT); 6903 ParserErrorCode.MISSING_PREFIX_IN_DEFERRED_IMPORT);
6912 } 6904 }
6913 List<Combinator> combinators = _parseCombinators(); 6905 List<Combinator> combinators = _parseCombinators();
6914 Token semicolon = _expectSemicolon(); 6906 Token semicolon = _expectSemicolon();
(...skipping 3062 matching lines...) Expand 10 before | Expand all | Expand 10 after
9977 _reportErrorForToken( 9969 _reportErrorForToken(
9978 ParserErrorCode.FINAL_TYPEDEF, 9970 ParserErrorCode.FINAL_TYPEDEF,
9979 modifiers.finalKeyword); 9971 modifiers.finalKeyword);
9980 } 9972 }
9981 if (modifiers.varKeyword != null) { 9973 if (modifiers.varKeyword != null) {
9982 _reportErrorForToken(ParserErrorCode.VAR_TYPEDEF, modifiers.varKeyword); 9974 _reportErrorForToken(ParserErrorCode.VAR_TYPEDEF, modifiers.varKeyword);
9983 } 9975 }
9984 } 9976 }
9985 } 9977 }
9986 /** 9978 /**
9987 * Instances of the class `SyntheticKeywordToken` implement a synthetic keyword token.
9988 */
9989 class Parser_SyntheticKeywordToken extends KeywordToken {
9990 /**
9991 * Initialize a newly created token to represent the given keyword.
9992 *
9993 * @param keyword the keyword being represented by this token
9994 * @param offset the offset from the beginning of the file to the first charac ter in the token
9995 */
9996 Parser_SyntheticKeywordToken(Keyword keyword, int offset)
9997 : super(keyword, offset);
9998
9999 @override
10000 int get length => 0;
10001
10002 @override
10003 Token copy() => new Parser_SyntheticKeywordToken(keyword, offset);
10004 }
10005
10006
10007 /**
10008 * The enumeration `ParserErrorCode` defines the error codes used for errors 9979 * The enumeration `ParserErrorCode` defines the error codes used for errors
10009 * detected by the parser. The convention for this class is for the name of the 9980 * detected by the parser. The convention for this class is for the name of the
10010 * error code to indicate the problem that caused the error to be generated and 9981 * error code to indicate the problem that caused the error to be generated and
10011 * for the error message to explain what is wrong and, when appropriate, how the 9982 * for the error message to explain what is wrong and, when appropriate, how the
10012 * problem can be corrected. 9983 * problem can be corrected.
10013 */ 9984 */
10014 class ParserErrorCode extends ErrorCode { 9985 class ParserErrorCode extends ErrorCode {
10015 static const ParserErrorCode ABSTRACT_CLASS_MEMBER = const ParserErrorCode( 9986 static const ParserErrorCode ABSTRACT_CLASS_MEMBER = const ParserErrorCode(
10016 'ABSTRACT_CLASS_MEMBER', 9987 'ABSTRACT_CLASS_MEMBER',
10017 "Members of classes cannot be declared to be 'abstract'"); 9988 "Members of classes cannot be declared to be 'abstract'");
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
10109 10080
10110 static const ParserErrorCode CONTINUE_OUTSIDE_OF_LOOP = const ParserErrorCode( 10081 static const ParserErrorCode CONTINUE_OUTSIDE_OF_LOOP = const ParserErrorCode(
10111 'CONTINUE_OUTSIDE_OF_LOOP', 10082 'CONTINUE_OUTSIDE_OF_LOOP',
10112 "A continue statement cannot be used outside of a loop or switch statement "); 10083 "A continue statement cannot be used outside of a loop or switch statement ");
10113 10084
10114 static const ParserErrorCode CONTINUE_WITHOUT_LABEL_IN_CASE = 10085 static const ParserErrorCode CONTINUE_WITHOUT_LABEL_IN_CASE =
10115 const ParserErrorCode( 10086 const ParserErrorCode(
10116 'CONTINUE_WITHOUT_LABEL_IN_CASE', 10087 'CONTINUE_WITHOUT_LABEL_IN_CASE',
10117 "A continue statement in a switch statement must have a label as a tar get"); 10088 "A continue statement in a switch statement must have a label as a tar get");
10118 10089
10119 static const ParserErrorCode DEFERRED_IMPORTS_NOT_SUPPORTED =
10120 const ParserErrorCode(
10121 'DEFERRED_IMPORTS_NOT_SUPPORTED',
10122 "Deferred imports are not supported by default");
10123
10124 static const ParserErrorCode DEPRECATED_CLASS_TYPE_ALIAS = 10090 static const ParserErrorCode DEPRECATED_CLASS_TYPE_ALIAS =
10125 const ParserErrorCode( 10091 const ParserErrorCode(
10126 'DEPRECATED_CLASS_TYPE_ALIAS', 10092 'DEPRECATED_CLASS_TYPE_ALIAS',
10127 "The 'typedef' mixin application was replaced with 'class'"); 10093 "The 'typedef' mixin application was replaced with 'class'");
10128 10094
10129 static const ParserErrorCode DIRECTIVE_AFTER_DECLARATION = 10095 static const ParserErrorCode DIRECTIVE_AFTER_DECLARATION =
10130 const ParserErrorCode( 10096 const ParserErrorCode(
10131 'DIRECTIVE_AFTER_DECLARATION', 10097 'DIRECTIVE_AFTER_DECLARATION',
10132 "Directives must appear before any declarations"); 10098 "Directives must appear before any declarations");
10133 10099
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
10705 10671
10706 @override 10672 @override
10707 ErrorSeverity get errorSeverity => ErrorSeverity.ERROR; 10673 ErrorSeverity get errorSeverity => ErrorSeverity.ERROR;
10708 10674
10709 @override 10675 @override
10710 ErrorType get type => ErrorType.SYNTACTIC_ERROR; 10676 ErrorType get type => ErrorType.SYNTACTIC_ERROR;
10711 } 10677 }
10712 10678
10713 10679
10714 /** 10680 /**
10681 * Instances of the class `SyntheticKeywordToken` implement a synthetic keyword token.
10682 */
10683 class Parser_SyntheticKeywordToken extends KeywordToken {
10684 /**
10685 * Initialize a newly created token to represent the given keyword.
10686 *
10687 * @param keyword the keyword being represented by this token
10688 * @param offset the offset from the beginning of the file to the first charac ter in the token
10689 */
10690 Parser_SyntheticKeywordToken(Keyword keyword, int offset)
10691 : super(keyword, offset);
10692
10693 @override
10694 int get length => 0;
10695
10696 @override
10697 Token copy() => new Parser_SyntheticKeywordToken(keyword, offset);
10698 }
10699
10700
10701 /**
10715 * Instances of the class `ResolutionCopier` copies resolution information from one AST 10702 * Instances of the class `ResolutionCopier` copies resolution information from one AST
10716 * structure to another as long as the structures of the corresponding children of a pair of nodes 10703 * structure to another as long as the structures of the corresponding children of a pair of nodes
10717 * are the same. 10704 * are the same.
10718 */ 10705 */
10719 class ResolutionCopier implements AstVisitor<bool> { 10706 class ResolutionCopier implements AstVisitor<bool> {
10720 /** 10707 /**
10721 * The AST node with which the node being visited is to be compared. This is o nly valid at the 10708 * The AST node with which the node being visited is to be compared. This is o nly valid at the
10722 * beginning of each visit method (until [isEqualNodes] is invoked). 10709 * beginning of each visit method (until [isEqualNodes] is invoked).
10723 */ 10710 */
10724 AstNode _toNode; 10711 AstNode _toNode;
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
11181 _isEqualTokens(node.forKeyword, toNode.forKeyword), 11168 _isEqualTokens(node.forKeyword, toNode.forKeyword),
11182 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis), 11169 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis),
11183 _isEqualNodes(node.loopVariable, toNode.loopVariable), 11170 _isEqualNodes(node.loopVariable, toNode.loopVariable),
11184 _isEqualTokens(node.inKeyword, toNode.inKeyword), 11171 _isEqualTokens(node.inKeyword, toNode.inKeyword),
11185 _isEqualNodes(node.iterable, toNode.iterable), 11172 _isEqualNodes(node.iterable, toNode.iterable),
11186 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis), 11173 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis),
11187 _isEqualNodes(node.body, toNode.body)); 11174 _isEqualNodes(node.body, toNode.body));
11188 } 11175 }
11189 11176
11190 @override 11177 @override
11191 bool visitFormalParameterList(FormalParameterList node) {
11192 FormalParameterList toNode = this._toNode as FormalParameterList;
11193 return _and(
11194 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis),
11195 _isEqualNodeLists(node.parameters, toNode.parameters),
11196 _isEqualTokens(node.leftDelimiter, toNode.leftDelimiter),
11197 _isEqualTokens(node.rightDelimiter, toNode.rightDelimiter),
11198 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis));
11199 }
11200
11201 @override
11202 bool visitForStatement(ForStatement node) { 11178 bool visitForStatement(ForStatement node) {
11203 ForStatement toNode = this._toNode as ForStatement; 11179 ForStatement toNode = this._toNode as ForStatement;
11204 return _and( 11180 return _and(
11205 _isEqualTokens(node.forKeyword, toNode.forKeyword), 11181 _isEqualTokens(node.forKeyword, toNode.forKeyword),
11206 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis), 11182 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis),
11207 _isEqualNodes(node.variables, toNode.variables), 11183 _isEqualNodes(node.variables, toNode.variables),
11208 _isEqualNodes(node.initialization, toNode.initialization), 11184 _isEqualNodes(node.initialization, toNode.initialization),
11209 _isEqualTokens(node.leftSeparator, toNode.leftSeparator), 11185 _isEqualTokens(node.leftSeparator, toNode.leftSeparator),
11210 _isEqualNodes(node.condition, toNode.condition), 11186 _isEqualNodes(node.condition, toNode.condition),
11211 _isEqualTokens(node.rightSeparator, toNode.rightSeparator), 11187 _isEqualTokens(node.rightSeparator, toNode.rightSeparator),
11212 _isEqualNodeLists(node.updaters, toNode.updaters), 11188 _isEqualNodeLists(node.updaters, toNode.updaters),
11213 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis), 11189 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis),
11214 _isEqualNodes(node.body, toNode.body)); 11190 _isEqualNodes(node.body, toNode.body));
11215 } 11191 }
11216 11192
11217 @override 11193 @override
11194 bool visitFormalParameterList(FormalParameterList node) {
11195 FormalParameterList toNode = this._toNode as FormalParameterList;
11196 return _and(
11197 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis),
11198 _isEqualNodeLists(node.parameters, toNode.parameters),
11199 _isEqualTokens(node.leftDelimiter, toNode.leftDelimiter),
11200 _isEqualTokens(node.rightDelimiter, toNode.rightDelimiter),
11201 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis));
11202 }
11203
11204 @override
11218 bool visitFunctionDeclaration(FunctionDeclaration node) { 11205 bool visitFunctionDeclaration(FunctionDeclaration node) {
11219 FunctionDeclaration toNode = this._toNode as FunctionDeclaration; 11206 FunctionDeclaration toNode = this._toNode as FunctionDeclaration;
11220 return _and( 11207 return _and(
11221 _isEqualNodes(node.documentationComment, toNode.documentationComment), 11208 _isEqualNodes(node.documentationComment, toNode.documentationComment),
11222 _isEqualNodeLists(node.metadata, toNode.metadata), 11209 _isEqualNodeLists(node.metadata, toNode.metadata),
11223 _isEqualTokens(node.externalKeyword, toNode.externalKeyword), 11210 _isEqualTokens(node.externalKeyword, toNode.externalKeyword),
11224 _isEqualNodes(node.returnType, toNode.returnType), 11211 _isEqualNodes(node.returnType, toNode.returnType),
11225 _isEqualTokens(node.propertyKeyword, toNode.propertyKeyword), 11212 _isEqualTokens(node.propertyKeyword, toNode.propertyKeyword),
11226 _isEqualNodes(node.name, toNode.name), 11213 _isEqualNodes(node.name, toNode.name),
11227 _isEqualNodes(node.functionExpression, toNode.functionExpression)); 11214 _isEqualNodes(node.functionExpression, toNode.functionExpression));
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
11621 toNode.propagatedElement = node.propagatedElement; 11608 toNode.propagatedElement = node.propagatedElement;
11622 toNode.propagatedType = node.propagatedType; 11609 toNode.propagatedType = node.propagatedType;
11623 toNode.staticElement = node.staticElement; 11610 toNode.staticElement = node.staticElement;
11624 toNode.staticType = node.staticType; 11611 toNode.staticType = node.staticType;
11625 return true; 11612 return true;
11626 } 11613 }
11627 return false; 11614 return false;
11628 } 11615 }
11629 11616
11630 @override 11617 @override
11631 bool visitPrefixedIdentifier(PrefixedIdentifier node) { 11618 bool visitPrefixExpression(PrefixExpression node) {
11632 PrefixedIdentifier toNode = this._toNode as PrefixedIdentifier; 11619 PrefixExpression toNode = this._toNode as PrefixExpression;
11633 if (_and( 11620 if (_and(
11634 _isEqualNodes(node.prefix, toNode.prefix), 11621 _isEqualTokens(node.operator, toNode.operator),
11635 _isEqualTokens(node.period, toNode.period), 11622 _isEqualNodes(node.operand, toNode.operand))) {
11636 _isEqualNodes(node.identifier, toNode.identifier))) { 11623 toNode.propagatedElement = node.propagatedElement;
11637 toNode.propagatedType = node.propagatedType; 11624 toNode.propagatedType = node.propagatedType;
11625 toNode.staticElement = node.staticElement;
11638 toNode.staticType = node.staticType; 11626 toNode.staticType = node.staticType;
11639 return true; 11627 return true;
11640 } 11628 }
11641 return false; 11629 return false;
11642 } 11630 }
11643 11631
11644 @override 11632 @override
11645 bool visitPrefixExpression(PrefixExpression node) { 11633 bool visitPrefixedIdentifier(PrefixedIdentifier node) {
11646 PrefixExpression toNode = this._toNode as PrefixExpression; 11634 PrefixedIdentifier toNode = this._toNode as PrefixedIdentifier;
11647 if (_and( 11635 if (_and(
11648 _isEqualTokens(node.operator, toNode.operator), 11636 _isEqualNodes(node.prefix, toNode.prefix),
11649 _isEqualNodes(node.operand, toNode.operand))) { 11637 _isEqualTokens(node.period, toNode.period),
11650 toNode.propagatedElement = node.propagatedElement; 11638 _isEqualNodes(node.identifier, toNode.identifier))) {
11651 toNode.propagatedType = node.propagatedType; 11639 toNode.propagatedType = node.propagatedType;
11652 toNode.staticElement = node.staticElement;
11653 toNode.staticType = node.staticType; 11640 toNode.staticType = node.staticType;
11654 return true; 11641 return true;
11655 } 11642 }
11656 return false; 11643 return false;
11657 } 11644 }
11658 11645
11659 @override 11646 @override
11660 bool visitPropertyAccess(PropertyAccess node) { 11647 bool visitPropertyAccess(PropertyAccess node) {
11661 PropertyAccess toNode = this._toNode as PropertyAccess; 11648 PropertyAccess toNode = this._toNode as PropertyAccess;
11662 if (_and( 11649 if (_and(
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
12116 * Copy resolution data from one node to another. 12103 * Copy resolution data from one node to another.
12117 * 12104 *
12118 * @param fromNode the node from which resolution information will be copied 12105 * @param fromNode the node from which resolution information will be copied
12119 * @param toNode the node to which resolution information will be copied 12106 * @param toNode the node to which resolution information will be copied
12120 */ 12107 */
12121 static void copyResolutionData(AstNode fromNode, AstNode toNode) { 12108 static void copyResolutionData(AstNode fromNode, AstNode toNode) {
12122 ResolutionCopier copier = new ResolutionCopier(); 12109 ResolutionCopier copier = new ResolutionCopier();
12123 copier._isEqualNodes(fromNode, toNode); 12110 copier._isEqualNodes(fromNode, toNode);
12124 } 12111 }
12125 } 12112 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/engine.dart ('k') | pkg/analyzer/test/generated/compile_time_error_code_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698