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

Unified Diff: pkg/front_end/lib/src/fasta/scanner/array_based_scanner.dart

Issue 2763833002: fasta.CommentToken implement analyzer.CommentToken (Closed)
Patch Set: merge Created 3 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
Index: pkg/front_end/lib/src/fasta/scanner/array_based_scanner.dart
diff --git a/pkg/front_end/lib/src/fasta/scanner/array_based_scanner.dart b/pkg/front_end/lib/src/fasta/scanner/array_based_scanner.dart
index dba3246a6672aefeb3a34008c56fbe292eb49e4e..48933b1222debe45b4ec49b3fffedd0a87c2e492 100644
--- a/pkg/front_end/lib/src/fasta/scanner/array_based_scanner.dart
+++ b/pkg/front_end/lib/src/fasta/scanner/array_based_scanner.dart
@@ -11,7 +11,14 @@ import 'keyword.dart' show Keyword;
import 'precedence.dart' show EOF_INFO, PrecedenceInfo;
import 'token.dart'
- show BeginGroupToken, KeywordToken, StringToken, SymbolToken, Token;
+ show
+ BeginGroupToken,
+ CommentToken,
+ DartDocToken,
+ KeywordToken,
+ StringToken,
+ SymbolToken,
+ Token;
import 'token_constants.dart'
show
@@ -47,7 +54,7 @@ abstract class ArrayBasedScanner extends AbstractScanner {
tail.next.previousToken = tail;
tail = tail.next;
if (comments != null) {
- tail.precedingComments = comments;
+ tail.precedingCommentTokens = comments;
comments = null;
commentsTail = null;
}
@@ -227,7 +234,17 @@ abstract class ArrayBasedScanner extends AbstractScanner {
void appendComment(start, PrecedenceInfo info, bool asciiOnly) {
if (!includeComments) return;
- Token newComment = createSubstringToken(info, start, asciiOnly);
+ Token newComment = createCommentToken(info, start, asciiOnly);
+ _appendToCommentStream(newComment);
+ }
+
+ void appendDartDoc(start, PrecedenceInfo info, bool asciiOnly) {
+ if (!includeComments) return;
+ Token newComment = createDartDocToken(info, start, asciiOnly);
+ _appendToCommentStream(newComment);
+ }
+
+ void _appendToCommentStream(Token newComment) {
if (comments == null) {
comments = newComment;
commentsTail = comments;
@@ -262,6 +279,32 @@ abstract class ArrayBasedScanner extends AbstractScanner {
[int extraOffset = 0]);
/**
+ * Returns a new comment from the scan offset [start] to the current
+ * [scanOffset] plus the [extraOffset]. For example, if the current
+ * scanOffset is 10, then [appendSubstringToken(5, -1)] will append the
+ * substring string [5,9).
+ *
+ * Note that [extraOffset] can only be used if the covered character(s) are
+ * known to be ASCII.
+ */
+ CommentToken createCommentToken(
+ PrecedenceInfo info, int start, bool asciiOnly,
+ [int extraOffset = 0]);
+
+ /**
+ * Returns a new dartdoc from the scan offset [start] to the current
+ * [scanOffset] plus the [extraOffset]. For example, if the current
+ * scanOffset is 10, then [appendSubstringToken(5, -1)] will append the
+ * substring string [5,9).
+ *
+ * Note that [extraOffset] can only be used if the covered character(s) are
+ * known to be ASCII.
+ */
+ DartDocToken createDartDocToken(
+ PrecedenceInfo info, int start, bool asciiOnly,
+ [int extraOffset = 0]);
+
+ /**
* This method is called to discard '<' from the "grouping" stack.
*
* [PartialParser.skipExpression] relies on the fact that we do not
« no previous file with comments | « pkg/front_end/lib/src/fasta/scanner/abstract_scanner.dart ('k') | pkg/front_end/lib/src/fasta/scanner/string_scanner.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698