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

Unified Diff: pkg/analyzer/lib/src/dart/ast/token.dart

Issue 1686173002: fix #25739, incorrectly expanding a generic comment multiple times (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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
Index: pkg/analyzer/lib/src/dart/ast/token.dart
diff --git a/pkg/analyzer/lib/src/dart/ast/token.dart b/pkg/analyzer/lib/src/dart/ast/token.dart
index 607df7b1506a3ccbd39e9d6150cff510ac9632ef..02d28e5ec2edd54ec0e6b7819ba1c37d0e4795db 100644
--- a/pkg/analyzer/lib/src/dart/ast/token.dart
+++ b/pkg/analyzer/lib/src/dart/ast/token.dart
@@ -35,7 +35,7 @@ class BeginToken extends SimpleToken {
/**
* A begin token that is preceded by comments.
*/
-class BeginTokenWithComment extends BeginToken {
+class BeginTokenWithComment extends BeginToken implements TokenWithComment {
/**
* The first comment in the list of comments that precede this token.
*/
@@ -79,9 +79,9 @@ class BeginTokenWithComment extends BeginToken {
*/
class CommentToken extends StringToken {
/**
- * The [Token] that contains this comment.
+ * The token that contains this comment.
*/
- Token parent;
+ TokenWithComment parent;
/**
* Initialize a newly created token to represent a token of the given [type]
@@ -92,6 +92,21 @@ class CommentToken extends StringToken {
@override
CommentToken copy() => new CommentToken(type, _value, offset);
+
+ /**
+ * Remove this comment token from the list.
+ *
+ * This is used when we decide to interpret the comment as syntax.
+ */
+ void remove() {
+ if (previous != null) {
+ previous.setNextWithoutSettingPrevious(next);
+ next?.previous = previous;
+ } else {
+ assert(parent.precedingComments == this);
+ parent.precedingComments = next;
+ }
+ }
}
/**
@@ -149,7 +164,7 @@ class KeywordToken extends SimpleToken {
/**
* A keyword token that is preceded by comments.
*/
-class KeywordTokenWithComment extends KeywordToken {
+class KeywordTokenWithComment extends KeywordToken implements TokenWithComment {
/**
* The first comment in the list of comments that precede this token.
*/
@@ -340,7 +355,7 @@ class StringToken extends SimpleToken {
/**
* A string token that is preceded by comments.
*/
-class StringTokenWithComment extends StringToken {
+class StringTokenWithComment extends StringToken implements TokenWithComment {
/**
* The first comment in the list of comments that precede this token.
*/
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/parser.dart » ('j') | pkg/analyzer/lib/src/generated/parser.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698