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

Unified Diff: pkg/analyzer/lib/src/generated/incremental_resolver.dart

Issue 764243003: Updated detached tokens of references in documentation comments. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years 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 side-by-side diff with in-line comments
Download patch
Index: pkg/analyzer/lib/src/generated/incremental_resolver.dart
diff --git a/pkg/analyzer/lib/src/generated/incremental_resolver.dart b/pkg/analyzer/lib/src/generated/incremental_resolver.dart
index 5dd1b0bd5d26d0730d1fe8ac71a6cc1f6d6bef9e..35461dc2ee81478e77a614478b0347e27b75dd20 100644
--- a/pkg/analyzer/lib/src/generated/incremental_resolver.dart
+++ b/pkg/analyzer/lib/src/generated/incremental_resolver.dart
@@ -941,13 +941,14 @@ class PoorMansIncrementalResolver {
_updateDelta = newUnit.length - oldUnit.length;
if (firstPair.atComment && lastPair.atComment) {
_resolveComment(oldUnit, newUnit, firstPair);
+ } else {
+ _shiftTokens(firstPair.oldToken);
+ IncrementalResolver._updateElementNameOffsets(
+ oldUnit.element,
+ _updateOffset,
+ _updateDelta);
+ _updateEntry();
}
- _shiftTokens(firstPair.oldToken, _updateDelta);
- IncrementalResolver._updateElementNameOffsets(
- oldUnit.element,
- _updateOffset,
- _updateDelta);
- _updateEntry();
return true;
}
// Find nodes covering the "old" and "new" token ranges.
@@ -1004,7 +1005,7 @@ class PoorMansIncrementalResolver {
oldBeginToken.previous.setNext(newBeginToken);
}
newNode.endToken.setNext(oldNode.endToken.next);
- _shiftTokens(oldNode.endToken.next, _updateDelta);
+ _shiftTokens(oldNode.endToken.next);
}
// perform incremental resolution
CompilationUnitElement oldUnitElement = oldUnit.element;
@@ -1045,11 +1046,18 @@ class PoorMansIncrementalResolver {
int offset = oldToken.precedingComments.offset;
Comment oldComment = _findNodeCovering(oldUnit, offset, offset);
Comment newComment = _findNodeCovering(newUnit, offset, offset);
- _updateOffset = offset + 1;
- // replace node
- NodeReplacer.replace(oldComment, newComment);
+ _updateOffset = oldToken.offset - 1;
// update token references
+ _shiftTokens(firstPair.oldToken);
_setPrecedingComments(oldToken, newComment.tokens.first);
+ // replace node
+ NodeReplacer.replace(oldComment, newComment);
+ // update elements
+ IncrementalResolver._updateElementNameOffsets(
+ oldUnit.element,
+ _updateOffset,
+ _updateDelta);
+ _updateEntry();
// resolve references in the comment
CompilationUnitElement oldUnitElement = oldUnit.element;
IncrementalResolver incrementalResolver =
@@ -1066,12 +1074,19 @@ class PoorMansIncrementalResolver {
return token;
}
- void _shiftTokens(Token token, int delta) {
+ void _shiftTokens(Token token) {
while (token != null) {
if (token.offset > _updateOffset) {
- token.offset += delta;
+ token.offset += _updateDelta;
+ }
+ // comments
+ _shiftTokens(token.precedingComments);
+ if (token is CommentToken) {
+ for (Token reference in token.references) {
+ _shiftTokens(reference);
+ }
}
- _shiftTokens(token.precedingComments, delta);
+ // next
if (token.type == TokenType.EOF) {
break;
}
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/parser.dart » ('j') | pkg/analyzer/lib/src/generated/scanner.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698