| 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 library analyzer.src.dart.ast.utilities; | 5 library analyzer.src.dart.ast.utilities; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
| 10 import 'package:analyzer/dart/ast/token.dart'; | 10 import 'package:analyzer/dart/ast/token.dart'; |
| (...skipping 2570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2581 @override | 2581 @override |
| 2582 Element visitVariableDeclaration(VariableDeclaration node) => node.element; | 2582 Element visitVariableDeclaration(VariableDeclaration node) => node.element; |
| 2583 } | 2583 } |
| 2584 | 2584 |
| 2585 /** | 2585 /** |
| 2586 * An object that will clone any AST structure that it visits. The cloner will | 2586 * An object that will clone any AST structure that it visits. The cloner will |
| 2587 * clone the structure, replacing the specified ASTNode with a new ASTNode, | 2587 * clone the structure, replacing the specified ASTNode with a new ASTNode, |
| 2588 * mapping the old token stream to a new token stream, and preserving resolution | 2588 * mapping the old token stream to a new token stream, and preserving resolution |
| 2589 * results. | 2589 * results. |
| 2590 */ | 2590 */ |
| 2591 @deprecated |
| 2591 class IncrementalAstCloner implements AstVisitor<AstNode> { | 2592 class IncrementalAstCloner implements AstVisitor<AstNode> { |
| 2592 /** | 2593 /** |
| 2593 * The node to be replaced during the cloning process. | 2594 * The node to be replaced during the cloning process. |
| 2594 */ | 2595 */ |
| 2595 final AstNode _oldNode; | 2596 final AstNode _oldNode; |
| 2596 | 2597 |
| 2597 /** | 2598 /** |
| 2598 * The replacement node used during the cloning process. | 2599 * The replacement node used during the cloning process. |
| 2599 */ | 2600 */ |
| 2600 final AstNode _newNode; | 2601 final AstNode _newNode; |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3094 _cloneNode(node.thenStatement), | 3095 _cloneNode(node.thenStatement), |
| 3095 _mapToken(node.elseKeyword), | 3096 _mapToken(node.elseKeyword), |
| 3096 _cloneNode(node.elseStatement)); | 3097 _cloneNode(node.elseStatement)); |
| 3097 | 3098 |
| 3098 @override | 3099 @override |
| 3099 ImplementsClause visitImplementsClause(ImplementsClause node) => | 3100 ImplementsClause visitImplementsClause(ImplementsClause node) => |
| 3100 new ImplementsClause( | 3101 new ImplementsClause( |
| 3101 _mapToken(node.implementsKeyword), _cloneNodeList(node.interfaces)); | 3102 _mapToken(node.implementsKeyword), _cloneNodeList(node.interfaces)); |
| 3102 | 3103 |
| 3103 @override | 3104 @override |
| 3104 ImportDirective visitImportDirective(ImportDirective node) => | 3105 ImportDirective visitImportDirective(ImportDirective node) { |
| 3105 new ImportDirective( | 3106 ImportDirective copy = new ImportDirective( |
| 3106 _cloneNode(node.documentationComment), | 3107 _cloneNode(node.documentationComment), |
| 3107 _cloneNodeList(node.metadata), | 3108 _cloneNodeList(node.metadata), |
| 3108 _mapToken(node.keyword), | 3109 _mapToken(node.keyword), |
| 3109 _cloneNode(node.uri), | 3110 _cloneNode(node.uri), |
| 3110 _cloneNodeList(node.configurations), | 3111 _cloneNodeList(node.configurations), |
| 3111 _mapToken(node.deferredKeyword), | 3112 _mapToken(node.deferredKeyword), |
| 3112 _mapToken(node.asKeyword), | 3113 _mapToken(node.asKeyword), |
| 3113 _cloneNode(node.prefix), | 3114 _cloneNode(node.prefix), |
| 3114 _cloneNodeList(node.combinators), | 3115 _cloneNodeList(node.combinators), |
| 3115 _mapToken(node.semicolon)); | 3116 _mapToken(node.semicolon)); |
| 3117 copy.element = node.element; |
| 3118 return copy; |
| 3119 } |
| 3116 | 3120 |
| 3117 @override | 3121 @override |
| 3118 IndexExpression visitIndexExpression(IndexExpression node) { | 3122 IndexExpression visitIndexExpression(IndexExpression node) { |
| 3119 Token period = _mapToken(node.period); | 3123 Token period = _mapToken(node.period); |
| 3120 IndexExpression copy; | 3124 IndexExpression copy; |
| 3121 if (period == null) { | 3125 if (period == null) { |
| 3122 copy = new IndexExpression.forTarget( | 3126 copy = new IndexExpression.forTarget( |
| 3123 _cloneNode(node.target), | 3127 _cloneNode(node.target), |
| 3124 _mapToken(node.leftBracket), | 3128 _mapToken(node.leftBracket), |
| 3125 _cloneNode(node.index), | 3129 _cloneNode(node.index), |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3183 @override | 3187 @override |
| 3184 Label visitLabel(Label node) => | 3188 Label visitLabel(Label node) => |
| 3185 new Label(_cloneNode(node.label), _mapToken(node.colon)); | 3189 new Label(_cloneNode(node.label), _mapToken(node.colon)); |
| 3186 | 3190 |
| 3187 @override | 3191 @override |
| 3188 LabeledStatement visitLabeledStatement(LabeledStatement node) => | 3192 LabeledStatement visitLabeledStatement(LabeledStatement node) => |
| 3189 new LabeledStatement( | 3193 new LabeledStatement( |
| 3190 _cloneNodeList(node.labels), _cloneNode(node.statement)); | 3194 _cloneNodeList(node.labels), _cloneNode(node.statement)); |
| 3191 | 3195 |
| 3192 @override | 3196 @override |
| 3193 LibraryDirective visitLibraryDirective(LibraryDirective node) => | 3197 LibraryDirective visitLibraryDirective(LibraryDirective node) { |
| 3194 new LibraryDirective( | 3198 LibraryDirective copy = new LibraryDirective( |
| 3195 _cloneNode(node.documentationComment), | 3199 _cloneNode(node.documentationComment), |
| 3196 _cloneNodeList(node.metadata), | 3200 _cloneNodeList(node.metadata), |
| 3197 _mapToken(node.libraryKeyword), | 3201 _mapToken(node.libraryKeyword), |
| 3198 _cloneNode(node.name), | 3202 _cloneNode(node.name), |
| 3199 _mapToken(node.semicolon)); | 3203 _mapToken(node.semicolon)); |
| 3204 copy.element = node.element; |
| 3205 return copy; |
| 3206 } |
| 3200 | 3207 |
| 3201 @override | 3208 @override |
| 3202 LibraryIdentifier visitLibraryIdentifier(LibraryIdentifier node) { | 3209 LibraryIdentifier visitLibraryIdentifier(LibraryIdentifier node) { |
| 3203 LibraryIdentifier copy = | 3210 LibraryIdentifier copy = |
| 3204 new LibraryIdentifier(_cloneNodeList(node.components)); | 3211 new LibraryIdentifier(_cloneNodeList(node.components)); |
| 3205 copy.propagatedType = node.propagatedType; | 3212 copy.propagatedType = node.propagatedType; |
| 3206 copy.staticType = node.staticType; | 3213 copy.staticType = node.staticType; |
| 3207 return copy; | 3214 return copy; |
| 3208 } | 3215 } |
| 3209 | 3216 |
| (...skipping 4565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7775 * Safely visit the given [token], printing the [suffix] after the token if it | 7782 * Safely visit the given [token], printing the [suffix] after the token if it |
| 7776 * is non-`null`. | 7783 * is non-`null`. |
| 7777 */ | 7784 */ |
| 7778 void _visitTokenWithSuffix(Token token, String suffix) { | 7785 void _visitTokenWithSuffix(Token token, String suffix) { |
| 7779 if (token != null) { | 7786 if (token != null) { |
| 7780 _writer.print(token.lexeme); | 7787 _writer.print(token.lexeme); |
| 7781 _writer.print(suffix); | 7788 _writer.print(suffix); |
| 7782 } | 7789 } |
| 7783 } | 7790 } |
| 7784 } | 7791 } |
| OLD | NEW |