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'; |
11 import 'package:analyzer/dart/ast/visitor.dart'; | 11 import 'package:analyzer/dart/ast/visitor.dart'; |
12 import 'package:analyzer/dart/element/element.dart'; | 12 import 'package:analyzer/dart/element/element.dart'; |
13 import 'package:analyzer/exception/exception.dart'; | 13 import 'package:analyzer/exception/exception.dart'; |
| 14 import 'package:analyzer/src/dart/ast/ast.dart'; |
14 import 'package:analyzer/src/dart/ast/token.dart'; | 15 import 'package:analyzer/src/dart/ast/token.dart'; |
15 import 'package:analyzer/src/generated/engine.dart' show AnalysisEngine; | 16 import 'package:analyzer/src/generated/engine.dart' show AnalysisEngine; |
16 import 'package:analyzer/src/generated/utilities_collection.dart' show TokenMap; | 17 import 'package:analyzer/src/generated/utilities_collection.dart' show TokenMap; |
17 import 'package:analyzer/src/generated/utilities_dart.dart'; | 18 import 'package:analyzer/src/generated/utilities_dart.dart'; |
18 | 19 |
19 /** | 20 /** |
20 * An AST visitor that will clone any AST structure that it visits. The cloner | 21 * An AST visitor that will clone any AST structure that it visits. The cloner |
21 * will only clone the structure, it will not preserve any resolution results or | 22 * will only clone the structure, it will not preserve any resolution results or |
22 * properties associated with the nodes. | 23 * properties associated with the nodes. |
23 */ | 24 */ |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 cloneNode(node.documentationComment), | 368 cloneNode(node.documentationComment), |
368 cloneNodeList(node.metadata), | 369 cloneNodeList(node.metadata), |
369 cloneToken(node.enumKeyword), | 370 cloneToken(node.enumKeyword), |
370 cloneNode(node.name), | 371 cloneNode(node.name), |
371 cloneToken(node.leftBracket), | 372 cloneToken(node.leftBracket), |
372 cloneNodeList(node.constants), | 373 cloneNodeList(node.constants), |
373 cloneToken(node.rightBracket)); | 374 cloneToken(node.rightBracket)); |
374 | 375 |
375 @override | 376 @override |
376 ExportDirective visitExportDirective(ExportDirective node) { | 377 ExportDirective visitExportDirective(ExportDirective node) { |
377 ExportDirective directive = new ExportDirective( | 378 ExportDirectiveImpl directive = new ExportDirective( |
378 cloneNode(node.documentationComment), | 379 cloneNode(node.documentationComment), |
379 cloneNodeList(node.metadata), | 380 cloneNodeList(node.metadata), |
380 cloneToken(node.keyword), | 381 cloneToken(node.keyword), |
381 cloneNode(node.uri), | 382 cloneNode(node.uri), |
382 cloneNodeList(node.configurations), | 383 cloneNodeList(node.configurations), |
383 cloneNodeList(node.combinators), | 384 cloneNodeList(node.combinators), |
384 cloneToken(node.semicolon)); | 385 cloneToken(node.semicolon)); |
385 directive.source = node.source; | 386 directive.selectedSource = node.selectedSource; |
| 387 directive.uriSource = node.uriSource; |
386 directive.uriContent = node.uriContent; | 388 directive.uriContent = node.uriContent; |
387 return directive; | 389 return directive; |
388 } | 390 } |
389 | 391 |
390 @override | 392 @override |
391 ExpressionFunctionBody visitExpressionFunctionBody( | 393 ExpressionFunctionBody visitExpressionFunctionBody( |
392 ExpressionFunctionBody node) => | 394 ExpressionFunctionBody node) => |
393 new ExpressionFunctionBody( | 395 new ExpressionFunctionBody( |
394 cloneToken(node.keyword), | 396 cloneToken(node.keyword), |
395 cloneToken(node.functionDefinition), | 397 cloneToken(node.functionDefinition), |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 cloneToken(node.elseKeyword), | 540 cloneToken(node.elseKeyword), |
539 cloneNode(node.elseStatement)); | 541 cloneNode(node.elseStatement)); |
540 | 542 |
541 @override | 543 @override |
542 ImplementsClause visitImplementsClause(ImplementsClause node) => | 544 ImplementsClause visitImplementsClause(ImplementsClause node) => |
543 new ImplementsClause( | 545 new ImplementsClause( |
544 cloneToken(node.implementsKeyword), cloneNodeList(node.interfaces)); | 546 cloneToken(node.implementsKeyword), cloneNodeList(node.interfaces)); |
545 | 547 |
546 @override | 548 @override |
547 ImportDirective visitImportDirective(ImportDirective node) { | 549 ImportDirective visitImportDirective(ImportDirective node) { |
548 ImportDirective directive = new ImportDirective( | 550 ImportDirectiveImpl directive = new ImportDirective( |
549 cloneNode(node.documentationComment), | 551 cloneNode(node.documentationComment), |
550 cloneNodeList(node.metadata), | 552 cloneNodeList(node.metadata), |
551 cloneToken(node.keyword), | 553 cloneToken(node.keyword), |
552 cloneNode(node.uri), | 554 cloneNode(node.uri), |
553 cloneNodeList(node.configurations), | 555 cloneNodeList(node.configurations), |
554 cloneToken(node.deferredKeyword), | 556 cloneToken(node.deferredKeyword), |
555 cloneToken(node.asKeyword), | 557 cloneToken(node.asKeyword), |
556 cloneNode(node.prefix), | 558 cloneNode(node.prefix), |
557 cloneNodeList(node.combinators), | 559 cloneNodeList(node.combinators), |
558 cloneToken(node.semicolon)); | 560 cloneToken(node.semicolon)); |
559 directive.source = node.source; | 561 directive.selectedSource = node.selectedSource; |
| 562 directive.uriSource = node.uriSource; |
560 directive.uriContent = node.uriContent; | 563 directive.uriContent = node.uriContent; |
561 return directive; | 564 return directive; |
562 } | 565 } |
563 | 566 |
564 @override | 567 @override |
565 IndexExpression visitIndexExpression(IndexExpression node) { | 568 IndexExpression visitIndexExpression(IndexExpression node) { |
566 Token period = node.period; | 569 Token period = node.period; |
567 if (period == null) { | 570 if (period == null) { |
568 return new IndexExpression.forTarget( | 571 return new IndexExpression.forTarget( |
569 cloneNode(node.target), | 572 cloneNode(node.target), |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
697 cloneNode(node.expression), cloneToken(node.rightParenthesis)); | 700 cloneNode(node.expression), cloneToken(node.rightParenthesis)); |
698 | 701 |
699 @override | 702 @override |
700 PartDirective visitPartDirective(PartDirective node) { | 703 PartDirective visitPartDirective(PartDirective node) { |
701 PartDirective directive = new PartDirective( | 704 PartDirective directive = new PartDirective( |
702 cloneNode(node.documentationComment), | 705 cloneNode(node.documentationComment), |
703 cloneNodeList(node.metadata), | 706 cloneNodeList(node.metadata), |
704 cloneToken(node.partKeyword), | 707 cloneToken(node.partKeyword), |
705 cloneNode(node.uri), | 708 cloneNode(node.uri), |
706 cloneToken(node.semicolon)); | 709 cloneToken(node.semicolon)); |
707 directive.source = node.source; | 710 directive.uriSource = node.uriSource; |
708 directive.uriContent = node.uriContent; | 711 directive.uriContent = node.uriContent; |
709 return directive; | 712 return directive; |
710 } | 713 } |
711 | 714 |
712 @override | 715 @override |
713 PartOfDirective visitPartOfDirective(PartOfDirective node) => | 716 PartOfDirective visitPartOfDirective(PartOfDirective node) => |
714 new PartOfDirective( | 717 new PartOfDirective( |
715 cloneNode(node.documentationComment), | 718 cloneNode(node.documentationComment), |
716 cloneNodeList(node.metadata), | 719 cloneNodeList(node.metadata), |
717 cloneToken(node.partKeyword), | 720 cloneToken(node.partKeyword), |
(...skipping 7106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7824 * Safely visit the given [token], printing the [suffix] after the token if it | 7827 * Safely visit the given [token], printing the [suffix] after the token if it |
7825 * is non-`null`. | 7828 * is non-`null`. |
7826 */ | 7829 */ |
7827 void _visitTokenWithSuffix(Token token, String suffix) { | 7830 void _visitTokenWithSuffix(Token token, String suffix) { |
7828 if (token != null) { | 7831 if (token != null) { |
7829 _buffer.write(token.lexeme); | 7832 _buffer.write(token.lexeme); |
7830 _buffer.write(suffix); | 7833 _buffer.write(suffix); |
7831 } | 7834 } |
7832 } | 7835 } |
7833 } | 7836 } |
OLD | NEW |