OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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.task.incremental_element_builder; | 5 library analyzer.src.task.incremental_element_builder; |
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 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 offsetMap[oldToken.offset] = newToken.offset; | 569 offsetMap[oldToken.offset] = newToken.offset; |
570 offsetMap[oldToken.end] = newToken.end; | 570 offsetMap[oldToken.end] = newToken.end; |
571 oldToken.offset = newToken.offset; | 571 oldToken.offset = newToken.offset; |
572 // Update (otherwise unlinked) reference tokens in documentation. | 572 // Update (otherwise unlinked) reference tokens in documentation. |
573 if (oldToken is DocumentationCommentToken && | 573 if (oldToken is DocumentationCommentToken && |
574 newToken is DocumentationCommentToken) { | 574 newToken is DocumentationCommentToken) { |
575 List<Token> oldReferences = oldToken.references; | 575 List<Token> oldReferences = oldToken.references; |
576 List<Token> newReferences = newToken.references; | 576 List<Token> newReferences = newToken.references; |
577 assert(oldReferences.length == newReferences.length); | 577 assert(oldReferences.length == newReferences.length); |
578 for (int i = 0; i < oldReferences.length; i++) { | 578 for (int i = 0; i < oldReferences.length; i++) { |
579 copyTokenOffsets(offsetMap, oldReferences[i], newReferences[i], | 579 Token oldToken = oldReferences[i]; |
580 oldEndToken, newEndToken); | 580 Token newToken = newReferences[i]; |
| 581 // For [new Name] the 'Name' token is the reference. |
| 582 // But we need to process all tokens, including 'new'. |
| 583 while (oldToken.previous != null && |
| 584 oldToken.previous.type != TokenType.EOF) { |
| 585 oldToken = oldToken.previous; |
| 586 } |
| 587 while (newToken.previous != null && |
| 588 newToken.previous.type != TokenType.EOF) { |
| 589 newToken = newToken.previous; |
| 590 } |
| 591 copyTokenOffsets( |
| 592 offsetMap, oldToken, newToken, oldEndToken, newEndToken); |
581 } | 593 } |
582 } | 594 } |
583 // Next tokens. | 595 // Next tokens. |
584 oldToken = oldToken.next; | 596 oldToken = oldToken.next; |
585 newToken = newToken.next; | 597 newToken = newToken.next; |
586 } | 598 } |
587 assert(oldToken == null); | 599 assert(oldToken == null); |
588 assert(newToken == null); | 600 assert(newToken == null); |
589 return; | 601 return; |
590 } | 602 } |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
720 } | 732 } |
721 } | 733 } |
722 super.visitElement(element); | 734 super.visitElement(element); |
723 } | 735 } |
724 | 736 |
725 static bool _isVariableInitializer(Element element) { | 737 static bool _isVariableInitializer(Element element) { |
726 return element is FunctionElement && | 738 return element is FunctionElement && |
727 element.enclosingElement is VariableElement; | 739 element.enclosingElement is VariableElement; |
728 } | 740 } |
729 } | 741 } |
OLD | NEW |