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

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

Issue 768233002: Extract DocumentationCommentToken with field. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Keep only last multi-line or continuous single-line documentation comments. 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
« no previous file with comments | « pkg/analyzer/lib/src/generated/parser.dart ('k') | pkg/analyzer/test/generated/parser_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/scanner.dart
diff --git a/pkg/analyzer/lib/src/generated/scanner.dart b/pkg/analyzer/lib/src/generated/scanner.dart
index 2efcb808bf81b177b311e5b4b45c7968702d43aa..893ab3958811daeba4c5d24932243d833de3e138 100644
--- a/pkg/analyzer/lib/src/generated/scanner.dart
+++ b/pkg/analyzer/lib/src/generated/scanner.dart
@@ -239,6 +239,21 @@ class CommentToken extends StringToken {
Token parent;
/**
+ * Initialize a newly created token to represent a token of the given [type]
+ * with the given [value] at the given [offset].
+ */
+ CommentToken(TokenType type, String value, int offset)
+ : super(type, value, offset);
+
+ @override
+ CommentToken copy() => new CommentToken(type, _value, offset);
+}
+
+/**
+ * A documentation comment token.
+ */
+class DocumentationCommentToken extends CommentToken {
+ /**
* The references embedded within the documentation comment.
* This list will be empty unless this is a documentation comment that has
* references embedded within it.
@@ -249,11 +264,11 @@ class CommentToken extends StringToken {
* Initialize a newly created token to represent a token of the given [type]
* with the given [value] at the given [offset].
*/
- CommentToken(TokenType type, String value, int offset)
+ DocumentationCommentToken(TokenType type, String value, int offset)
: super(type, value, offset);
@override
- CommentToken copy() => new CommentToken(type, _value, offset);
+ CommentToken copy() => new DocumentationCommentToken(type, _value, offset);
}
/**
@@ -996,12 +1011,17 @@ class Scanner {
return;
}
// OK, remember comment tokens.
+ CommentToken token;
+ if (_isDocumentationComment(value)) {
+ token = new DocumentationCommentToken(type, value, _tokenStart);
+ } else {
+ token = new CommentToken(type, value, _tokenStart);
+ }
if (_firstComment == null) {
- _firstComment = new CommentToken(type, value, _tokenStart);
+ _firstComment = token;
_lastComment = _firstComment;
} else {
- _lastComment =
- _lastComment.setNext(new CommentToken(type, value, _tokenStart));
+ _lastComment = _lastComment.setNext(token);
}
}
@@ -1780,6 +1800,14 @@ class Scanner {
return next;
}
}
+
+ /**
+ * Checks if [value] is a single-line or multi-line comment.
+ */
+ static bool _isDocumentationComment(String value) {
+ return StringUtilities.startsWith3(value, 0, 0x2F, 0x2F, 0x2F) ||
+ StringUtilities.startsWith3(value, 0, 0x2F, 0x2A, 0x2A);
+ }
}
/**
« no previous file with comments | « pkg/analyzer/lib/src/generated/parser.dart ('k') | pkg/analyzer/test/generated/parser_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698