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

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

Issue 913573002: Fix for incremental resolution in case of inserting a new token into elegant comments. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 months 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
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/incremental_resolver_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 038d0f05385237cf85862e4dff3989f5900fe0c4..ef8b8079d36b379360c238a00914e2dd34f427bb 100644
--- a/pkg/analyzer/lib/src/generated/incremental_resolver.dart
+++ b/pkg/analyzer/lib/src/generated/incremental_resolver.dart
@@ -1170,8 +1170,8 @@ class PoorMansIncrementalResolver {
List<AnalysisError> _newScanErrors = <AnalysisError>[];
List<AnalysisError> _newParseErrors = <AnalysisError>[];
- PoorMansIncrementalResolver(this._typeProvider, this._unitSource,
- this._entry, this._oldUnit, bool resolveApiChanges) {
+ PoorMansIncrementalResolver(this._typeProvider, this._unitSource, this._entry,
+ this._oldUnit, bool resolveApiChanges) {
_resolveApiChanges = resolveApiChanges;
}
@@ -1426,21 +1426,29 @@ class PoorMansIncrementalResolver {
}
static _TokenDifferenceKind _compareToken(Token oldToken, Token newToken,
- int delta) {
- if (oldToken == null && newToken == null) {
- return null;
- }
- if (oldToken == null || newToken == null) {
- return _TokenDifferenceKind.CONTENT;
- }
- if (oldToken.type != newToken.type) {
- return _TokenDifferenceKind.CONTENT;
- }
- if (oldToken.lexeme != newToken.lexeme) {
- return _TokenDifferenceKind.CONTENT;
- }
- if (newToken.offset - oldToken.offset != delta) {
- return _TokenDifferenceKind.OFFSET;
+ int delta, bool forComment) {
+ while (true) {
+ if (oldToken == null && newToken == null) {
+ return null;
+ }
+ if (oldToken == null || newToken == null) {
+ return _TokenDifferenceKind.CONTENT;
+ }
+ if (oldToken.type != newToken.type) {
+ return _TokenDifferenceKind.CONTENT;
+ }
+ if (oldToken.lexeme != newToken.lexeme) {
+ return _TokenDifferenceKind.CONTENT;
+ }
+ if (newToken.offset - oldToken.offset != delta) {
+ return _TokenDifferenceKind.OFFSET;
+ }
+ // continue if comment tokens are being checked
+ if (!forComment) {
+ break;
+ }
+ oldToken = oldToken.next;
+ newToken = newToken.next;
}
return null;
}
@@ -1457,7 +1465,7 @@ class PoorMansIncrementalResolver {
{
Token oldComment = oldToken.precedingComments;
Token newComment = newToken.precedingComments;
- if (_compareToken(oldComment, newComment, 0) != null) {
+ if (_compareToken(oldComment, newComment, 0, true) != null) {
_TokenDifferenceKind diffKind = _TokenDifferenceKind.COMMENT;
if (oldComment is DocumentationCommentToken ||
newComment is DocumentationCommentToken) {
@@ -1467,7 +1475,8 @@ class PoorMansIncrementalResolver {
}
}
// compare tokens
- _TokenDifferenceKind diffKind = _compareToken(oldToken, newToken, 0);
+ _TokenDifferenceKind diffKind =
+ _compareToken(oldToken, newToken, 0, false);
if (diffKind != null) {
return new _TokenPair(diffKind, oldToken, newToken);
}
@@ -1483,7 +1492,8 @@ class PoorMansIncrementalResolver {
int delta = newToken.offset - oldToken.offset;
while (oldToken.previous != oldToken && newToken.previous != newToken) {
// compare tokens
- _TokenDifferenceKind diffKind = _compareToken(oldToken, newToken, delta);
+ _TokenDifferenceKind diffKind =
+ _compareToken(oldToken, newToken, delta, false);
if (diffKind != null) {
return new _TokenPair(diffKind, oldToken.next, newToken.next);
}
@@ -1491,7 +1501,7 @@ class PoorMansIncrementalResolver {
{
Token oldComment = oldToken.precedingComments;
Token newComment = newToken.precedingComments;
- if (_compareToken(oldComment, newComment, delta) != null) {
+ if (_compareToken(oldComment, newComment, delta, true) != null) {
_TokenDifferenceKind diffKind = _TokenDifferenceKind.COMMENT;
if (oldComment is DocumentationCommentToken ||
newComment is DocumentationCommentToken) {
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/incremental_resolver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698