Skip to content

Commit

Permalink
Refactor comment reference parsing, away from stack.
Browse files Browse the repository at this point in the history
Now that comment reference parsing is done entirely in ast_builder, we
can simplify the implementation.

Work towards #50702

Change-Id: I0650706dfe31542454c7bc9832ec6104c141bd5d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316643
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
  • Loading branch information
srawlins authored and Commit Queue committed Jul 31, 2023
1 parent c9d6986 commit 1934efb
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 302 deletions.
22 changes: 0 additions & 22 deletions pkg/_fe_analyzer_shared/lib/src/parser/forwarding_listener.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1407,23 +1407,6 @@ class ForwardingListener implements Listener {
listener?.handleMixinWithClause(withKeyword);
}

@override
void handleCommentReference(
Token? newKeyword,
Token? firstToken,
Token? firstPeriod,
Token? secondToken,
Token? secondPeriod,
Token thirdToken) {
listener?.handleCommentReference(newKeyword, firstToken, firstPeriod,
secondToken, secondPeriod, thirdToken);
}

@override
void handleCommentReferenceText(String referenceSource, int referenceOffset) {
listener?.handleCommentReferenceText(referenceSource, referenceOffset);
}

@override
void handleConditionalExpressionColon() {
listener?.handleConditionalExpressionColon();
Expand Down Expand Up @@ -1752,11 +1735,6 @@ class ForwardingListener implements Listener {
listener?.handleNoArguments(token);
}

@override
void handleNoCommentReference() {
listener?.handleNoCommentReference();
}

@override
void handleNoConstructorReferenceContinuationAfterTypeArguments(Token token) {
listener?.handleNoConstructorReferenceContinuationAfterTypeArguments(token);
Expand Down
33 changes: 0 additions & 33 deletions pkg/_fe_analyzer_shared/lib/src/parser/listener.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2287,39 +2287,6 @@ class Listener implements UnescapeErrorListener {
logEvent("Script");
}

/// A single comment reference has been found
/// where [referenceSource] is the text between the `[` and `]`
/// and [referenceOffset] is the character offset in the token stream.
///
/// This event is generated by the parser when the parser's
/// `parseCommentReferences` method is called. For further processing,
/// a listener may scan the [referenceSource] and then pass the resulting
/// token stream to the parser's `parseOneCommentReference` method.
void handleCommentReferenceText(String referenceSource, int referenceOffset) {
logEvent("CommentReferenceText");
}

/// A single comment reference has been parsed.
/// * [newKeyword] may be null.
/// * [firstToken] and [firstPeriod] are either both tokens or both
/// `null`.
/// * [secondToken] and [secondPeriod] are either both tokens or both `null`.
/// * [thirdToken] can be an identifier or an operator.
///
/// This event is generated by the parser when the parser's
/// `parseOneCommentReference` method is called.
void handleCommentReference(
Token? newKeyword,
Token? firstToken,
Token? firstPeriod,
Token? secondToken,
Token? secondPeriod,
Token thirdToken) {}

/// This event is generated by the parser when the parser's
/// `parseOneCommentReference` method is called.
void handleNoCommentReference() {}

/// An expression was encountered consisting of type arguments applied to a
/// subexpression. This could validly represent any of the following:
/// - A type literal (`var x = List<int>;`)
Expand Down
Loading

0 comments on commit 1934efb

Please sign in to comment.