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

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

Issue 982243002: Disable incremental resolution of comments outside function bodies. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 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 2fdf505ef7d000d67b40316b2bab9320487ab261..4a456199214ffed0ab3652516e44600d95fbff87 100644
--- a/pkg/analyzer/lib/src/generated/incremental_resolver.dart
+++ b/pkg/analyzer/lib/src/generated/incremental_resolver.dart
@@ -1189,12 +1189,6 @@ class PoorMansIncrementalResolver {
_updateEndOld = endOffsetOld;
_updateEndNew = endOffsetNew;
_updateDelta = newUnit.length - _oldUnit.length;
- // A comment change.
- if (firstPair.kind == _TokenDifferenceKind.COMMENT) {
- bool success = _resolveComment(newUnit, firstPair);
- logger.log('Comment change: $success');
- return success;
- }
// A Dart documentation comment change.
if (firstPair.kind == _TokenDifferenceKind.COMMENT_DOC) {
bool success = _resolveCommentDoc(newUnit, firstPair);
@@ -1254,6 +1248,13 @@ class PoorMansIncrementalResolver {
logger.log('Failure: no enclosing function body or executable.');
return false;
}
+ // fail if a comment change outside the bodies
+ if (firstPair.kind == _TokenDifferenceKind.COMMENT) {
+ if (beginOffsetOld <= oldNode.offset || beginOffsetNew <= newNode.offset) {
+ logger.log('Failure: comment outside a function body.');
+ return false;
+ }
+ }
}
logger.log(() => 'oldNode: $oldNode');
logger.log(() => 'newNode: $newNode');
@@ -1315,28 +1316,6 @@ class PoorMansIncrementalResolver {
}
/**
- * Attempts to resolve a comment change.
- * Returns `true` if success.
- */
- bool _resolveComment(CompilationUnit newUnit, _TokenPair firstPair) {
- Token oldToken = firstPair.oldToken;
- Token newToken = firstPair.newToken;
- CommentToken newComments = newToken.precedingComments;
- // update token references
- _updateOffset = oldToken.offset - 1;
- _shiftTokens(firstPair.oldToken);
- _setPrecedingComments(oldToken, newComments);
- // update elements
- IncrementalResolver incrementalResolver = new IncrementalResolver(
- _unitElement, _updateOffset, _updateEndOld, _updateEndNew);
- incrementalResolver._updateElementNameOffsets();
- incrementalResolver._shiftEntryErrors();
- _updateEntry();
- // OK
- return true;
- }
-
- /**
* Attempts to resolve a documentation comment change.
* Returns `true` if success.
*/
@@ -1390,24 +1369,8 @@ class PoorMansIncrementalResolver {
token.precedingComments = comment;
} else if (token is KeywordTokenWithComment) {
token.precedingComments = comment;
- } else if (token is KeywordToken) {
- KeywordTokenWithComment newToken =
- new KeywordTokenWithComment(token.keyword, token.offset, comment);
- token.previous.setNext(newToken);
- newToken.setNext(token.next);
- if (_oldUnit.beginToken == token) {
- _oldUnit.beginToken = newToken;
- }
} else if (token is StringTokenWithComment) {
token.precedingComments = comment;
- } else if (token is StringToken) {
- StringTokenWithComment newToken = new StringTokenWithComment(
- token.type, token.value(), token.offset, comment);
- token.previous.setNext(newToken);
- newToken.setNext(token.next);
- if (_oldUnit.beginToken == token) {
- _oldUnit.beginToken = newToken;
- }
} else if (token is TokenWithComment) {
token.precedingComments = comment;
} else {
« 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