| OLD | NEW |
| 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.ast; | 8 library engine.ast; |
| 9 | 9 |
| 10 import 'dart:collection'; | 10 import 'dart:collection'; |
| (...skipping 12706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12717 } | 12717 } |
| 12718 if (parent is LibraryIdentifier) { | 12718 if (parent is LibraryIdentifier) { |
| 12719 AstNode grandParent = parent.parent; | 12719 AstNode grandParent = parent.parent; |
| 12720 if (grandParent is PartOfDirective) { | 12720 if (grandParent is PartOfDirective) { |
| 12721 Element element = grandParent.element; | 12721 Element element = grandParent.element; |
| 12722 if (element is LibraryElement) { | 12722 if (element is LibraryElement) { |
| 12723 return element.definingCompilationUnit; | 12723 return element.definingCompilationUnit; |
| 12724 } | 12724 } |
| 12725 } | 12725 } |
| 12726 } | 12726 } |
| 12727 Element element = node.bestElement; | 12727 return node.bestElement; |
| 12728 if (element == null) { | |
| 12729 element = node.staticElement; | |
| 12730 } | |
| 12731 return element; | |
| 12732 } | 12728 } |
| 12733 | 12729 |
| 12734 @override | 12730 @override |
| 12735 Element visitImportDirective(ImportDirective node) => node.element; | 12731 Element visitImportDirective(ImportDirective node) => node.element; |
| 12736 | 12732 |
| 12737 @override | 12733 @override |
| 12738 Element visitIndexExpression(IndexExpression node) => node.bestElement; | 12734 Element visitIndexExpression(IndexExpression node) => node.bestElement; |
| 12739 | 12735 |
| 12740 @override | 12736 @override |
| 12741 Element visitInstanceCreationExpression(InstanceCreationExpression node) => no
de.staticElement; | 12737 Element visitInstanceCreationExpression(InstanceCreationExpression node) => no
de.staticElement; |
| (...skipping 3173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15915 @override | 15911 @override |
| 15916 SwitchCase visitSwitchCase(SwitchCase node) => new SwitchCase(_cloneNodeList(n
ode.labels), node.keyword, _cloneNode(node.expression), node.colon, _cloneNodeLi
st(node.statements)); | 15912 SwitchCase visitSwitchCase(SwitchCase node) => new SwitchCase(_cloneNodeList(n
ode.labels), node.keyword, _cloneNode(node.expression), node.colon, _cloneNodeLi
st(node.statements)); |
| 15917 | 15913 |
| 15918 @override | 15914 @override |
| 15919 SwitchDefault visitSwitchDefault(SwitchDefault node) => new SwitchDefault(_clo
neNodeList(node.labels), node.keyword, node.colon, _cloneNodeList(node.statement
s)); | 15915 SwitchDefault visitSwitchDefault(SwitchDefault node) => new SwitchDefault(_clo
neNodeList(node.labels), node.keyword, node.colon, _cloneNodeList(node.statement
s)); |
| 15920 | 15916 |
| 15921 @override | 15917 @override |
| 15922 SwitchStatement visitSwitchStatement(SwitchStatement node) => new SwitchStatem
ent(node.keyword, node.leftParenthesis, _cloneNode(node.expression), node.rightP
arenthesis, node.leftBracket, _cloneNodeList(node.members), node.rightBracket); | 15918 SwitchStatement visitSwitchStatement(SwitchStatement node) => new SwitchStatem
ent(node.keyword, node.leftParenthesis, _cloneNode(node.expression), node.rightP
arenthesis, node.leftBracket, _cloneNodeList(node.members), node.rightBracket); |
| 15923 | 15919 |
| 15924 @override | 15920 @override |
| 15925 AstNode visitSymbolLiteral(SymbolLiteral node) => new SymbolLiteral(node.pound
Sign, node.components); | 15921 SymbolLiteral visitSymbolLiteral(SymbolLiteral node) => new SymbolLiteral(node
.poundSign, node.components); |
| 15926 | 15922 |
| 15927 @override | 15923 @override |
| 15928 ThisExpression visitThisExpression(ThisExpression node) => new ThisExpression(
node.keyword); | 15924 ThisExpression visitThisExpression(ThisExpression node) => new ThisExpression(
node.keyword); |
| 15929 | 15925 |
| 15930 @override | 15926 @override |
| 15931 ThrowExpression visitThrowExpression(ThrowExpression node) => new ThrowExpress
ion(node.keyword, _cloneNode(node.expression)); | 15927 ThrowExpression visitThrowExpression(ThrowExpression node) => new ThrowExpress
ion(node.keyword, _cloneNode(node.expression)); |
| 15932 | 15928 |
| 15933 @override | 15929 @override |
| 15934 TopLevelVariableDeclaration visitTopLevelVariableDeclaration(TopLevelVariableD
eclaration node) => new TopLevelVariableDeclaration(_cloneNode(node.documentatio
nComment), _cloneNodeList(node.metadata), _cloneNode(node.variables), node.semic
olon); | 15930 TopLevelVariableDeclaration visitTopLevelVariableDeclaration(TopLevelVariableD
eclaration node) => new TopLevelVariableDeclaration(_cloneNode(node.documentatio
nComment), _cloneNodeList(node.metadata), _cloneNode(node.variables), node.semic
olon); |
| 15935 | 15931 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15985 * they are equal. | 15981 * they are equal. |
| 15986 */ | 15982 */ |
| 15987 class AstComparator implements AstVisitor<bool> { | 15983 class AstComparator implements AstVisitor<bool> { |
| 15988 /** | 15984 /** |
| 15989 * Return `true` if the two AST nodes are equal. | 15985 * Return `true` if the two AST nodes are equal. |
| 15990 * | 15986 * |
| 15991 * @param first the first node being compared | 15987 * @param first the first node being compared |
| 15992 * @param second the second node being compared | 15988 * @param second the second node being compared |
| 15993 * @return `true` if the two AST nodes are equal | 15989 * @return `true` if the two AST nodes are equal |
| 15994 */ | 15990 */ |
| 15995 static bool equalUnits(CompilationUnit first, CompilationUnit second) { | 15991 static bool equalNodes(AstNode first, AstNode second) { |
| 15996 AstComparator comparator = new AstComparator(); | 15992 AstComparator comparator = new AstComparator(); |
| 15997 return comparator._isEqualNodes(first, second); | 15993 return comparator._isEqualNodes(first, second); |
| 15998 } | 15994 } |
| 15999 | 15995 |
| 16000 /** | 15996 /** |
| 16001 * The AST node with which the node being visited is to be compared. This is o
nly valid at the | 15997 * The AST node with which the node being visited is to be compared. This is o
nly valid at the |
| 16002 * beginning of each visit method (until [isEqualNodes] is invoked). | 15998 * beginning of each visit method (until [isEqualNodes] is invoked). |
| 16003 */ | 15999 */ |
| 16004 AstNode _other; | 16000 AstNode _other; |
| 16005 | 16001 |
| (...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16675 * @param second the second node being compared | 16671 * @param second the second node being compared |
| 16676 * @return `true` if the given arrays of tokens have the same length and corre
sponding | 16672 * @return `true` if the given arrays of tokens have the same length and corre
sponding |
| 16677 * elements are equal | 16673 * elements are equal |
| 16678 */ | 16674 */ |
| 16679 bool _isEqualTokenLists(List<Token> first, List<Token> second) { | 16675 bool _isEqualTokenLists(List<Token> first, List<Token> second) { |
| 16680 int length = first.length; | 16676 int length = first.length; |
| 16681 if (second.length != length) { | 16677 if (second.length != length) { |
| 16682 return false; | 16678 return false; |
| 16683 } | 16679 } |
| 16684 for (int i = 0; i < length; i++) { | 16680 for (int i = 0; i < length; i++) { |
| 16685 if (_isEqualTokens(first[i], second[i])) { | 16681 if (!_isEqualTokens(first[i], second[i])) { |
| 16686 return false; | 16682 return false; |
| 16687 } | 16683 } |
| 16688 } | 16684 } |
| 16689 return true; | 16685 return true; |
| 16690 } | 16686 } |
| 16691 | 16687 |
| 16692 /** | 16688 /** |
| 16693 * Return `true` if the given tokens have the same structure. | 16689 * Return `true` if the given tokens have the same structure. |
| 16694 * | 16690 * |
| 16695 * @param first the first node being compared | 16691 * @param first the first node being compared |
| 16696 * @param second the second node being compared | 16692 * @param second the second node being compared |
| 16697 * @return `true` if the given tokens have the same structure | 16693 * @return `true` if the given tokens have the same structure |
| 16698 */ | 16694 */ |
| 16699 bool _isEqualTokens(Token first, Token second) { | 16695 bool _isEqualTokens(Token first, Token second) { |
| 16700 if (first == null) { | 16696 if (first == null) { |
| 16701 return second == null; | 16697 return second == null; |
| 16702 } else if (second == null) { | 16698 } else if (second == null) { |
| 16703 return false; | 16699 return false; |
| 16700 } else if (identical(first, second)) { |
| 16701 return true; |
| 16704 } | 16702 } |
| 16705 return first.offset == second.offset && first.length == second.length && fir
st.lexeme == second.lexeme; | 16703 return first.offset == second.offset && first.length == second.length && fir
st.lexeme == second.lexeme; |
| 16706 } | 16704 } |
| 16707 } | 16705 } |
| 16708 | 16706 |
| 16709 /** | 16707 /** |
| 16710 * Instances of the class `IncrementalAstCloner` implement an object that will c
lone any AST | 16708 * Instances of the class `IncrementalAstCloner` implement an object that will c
lone any AST |
| 16711 * structure that it visits. The cloner will clone the structure, replacing the
specified ASTNode | 16709 * structure that it visits. The cloner will clone the structure, replacing the
specified ASTNode |
| 16712 * with a new ASTNode, mapping the old token stream to a new token stream, and p
reserving resolution | 16710 * with a new ASTNode, mapping the old token stream to a new token stream, and p
reserving resolution |
| 16713 * results. | 16711 * results. |
| (...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17634 _elements[index] = node; | 17632 _elements[index] = node; |
| 17635 } | 17633 } |
| 17636 void clear() { | 17634 void clear() { |
| 17637 _elements = <E> []; | 17635 _elements = <E> []; |
| 17638 } | 17636 } |
| 17639 int get length => _elements.length; | 17637 int get length => _elements.length; |
| 17640 void set length(int value) { | 17638 void set length(int value) { |
| 17641 throw new UnsupportedError("Cannot resize NodeList."); | 17639 throw new UnsupportedError("Cannot resize NodeList."); |
| 17642 } | 17640 } |
| 17643 } | 17641 } |
| OLD | NEW |