Skip to content

Commit 56a50e8

Browse files
stereotype441Commit Queue
authored and
Commit Queue
committed
Fix comment references in shared parser and scanner.
Fix bracketed references in doc comments that previously pointed to nowhere, in the shared parser (pkg/_fe_analyzer_shared/lib/src/parser/...) and scanner (pkg/_fe_analyzer_shared/lib/src/scanner/...). This is part of a larger effort to clean up _fe_analyzer_shared to the point where the `comment_references` lint can be enabled. Change-Id: I60c402d9b4df50208ed51587e71a0663e369d622 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/375221 Reviewed-by: Johnni Winther <[email protected]> Commit-Queue: Paul Berry <[email protected]>
1 parent 8e8a013 commit 56a50e8

10 files changed

+35
-27
lines changed

pkg/_fe_analyzer_shared/lib/src/parser/class_member_parser.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5+
/// @docImport 'top_level_parser.dart';
56
library _fe_analyzer_shared.parser.class_member_parser;
67

78
import '../scanner/token.dart' show Token;

pkg/_fe_analyzer_shared/lib/src/parser/identifier_context.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -321,15 +321,15 @@ abstract class IdentifierContext {
321321
/// Ensure that the next token is an identifier (or keyword which should be
322322
/// treated as an identifier) and return that identifier.
323323
/// Report errors as necessary via [parser].
324-
/// If [recovered] implementers could allow 'token' to be used as an
324+
/// If [isRecovered] implementers could allow 'token' to be used as an
325325
/// identifier, even if it isn't a valid identifier.
326326
Token ensureIdentifierPotentiallyRecovered(
327327
Token token, Parser parser, bool isRecovered) =>
328328
ensureIdentifier(token, parser);
329329
}
330330

331-
/// Return `true` if the given [token] should be treated like the start of
332-
/// an expression for the purposes of recovery.
331+
/// Return `true` if [next] should be treated like the start of an expression
332+
/// for the purposes of recovery.
333333
bool looksLikeExpressionStart(Token next) =>
334334
next.isIdentifier ||
335335
next.isKeyword && !looksLikeStatementStart(next) ||
@@ -353,8 +353,8 @@ bool looksLikeExpressionStart(Token next) =>
353353
optional('++', next) ||
354354
optional('--', next);
355355

356-
/// Returns `true` if the given [token] should be treated like the start of a
357-
/// pattern for the purposes of recovery.
356+
/// Returns `true` if [next] should be treated like the start of a pattern for
357+
/// the purposes of recovery.
358358
///
359359
/// Note: since the syntax for patterns is very similar to that for expressions,
360360
/// we mostly re-use [looksLikeExpressionStart].

pkg/_fe_analyzer_shared/lib/src/parser/listener.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5+
/// @docImport 'parser_impl.dart';
56
library _fe_analyzer_shared.parser.listener;
67

78
import '../experiments/errors.dart';
@@ -315,7 +316,7 @@ class Listener implements UnescapeErrorListener {
315316
/// This method exists for analyzer compatibility only
316317
/// and will be removed once analyzer/fasta integration is complete.
317318
///
318-
/// This is called when [parseDirectives] has parsed all directives
319+
/// This is called when [Parser.parseDirectives] has parsed all directives
319320
/// and is skipping the remainder of the file. Substructures:
320321
/// - metadata
321322
void handleDirectivesOnly() {}

pkg/_fe_analyzer_shared/lib/src/parser/parser_impl.dart

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5+
/// @docImport '../scanner/scanner.dart';
6+
/// @docImport 'util.dart';
57
library _fe_analyzer_shared.parser.parser;
68

79
import '../experiments/flags.dart';
@@ -181,9 +183,9 @@ import 'util.dart'
181183
/// to the keyword table.
182184
///
183185
/// As a consequence of this, one should not use `==` to compare strings in the
184-
/// parser. One should favor the methods [optional] and [expect] to recognize
185-
/// keywords or identifiers. In some cases, it's possible to compare a token's
186-
/// `stringValue` using [identical], but normally [optional] will suffice.
186+
/// parser. One should favor the method [optional] to recognize keywords or
187+
/// identifiers. In some cases, it's possible to compare a token's `stringValue`
188+
/// using [identical], but normally [optional] will suffice.
187189
///
188190
/// Historically, we over-used identical, and when identical is used on objects
189191
/// other than strings, it can often be replaced by `==`.
@@ -229,7 +231,7 @@ import 'util.dart'
229231
///
230232
/// When attempting to parse this function, the parser eventually calls
231233
/// [parseFunctionBody]. This method will report an unrecoverable error to the
232-
/// listener with the code [fasta.messageExpectedFunctionBody]. The listener can
234+
/// listener with the code [codes.codeExpectedFunctionBody]. The listener can
233235
/// then look at the error code and the token and use the methods in
234236
/// [native_support.dart](native_support.dart) to parse the native syntax.
235237
///
@@ -4191,11 +4193,10 @@ class Parser {
41914193
return token;
41924194
}
41934195

4194-
/// If the next token is an opening curly brace, return it. Otherwise, use the
4195-
/// given [template] or [missingBlockName] to report an error, insert an
4196-
/// opening and a closing curly brace, and return the newly inserted opening
4197-
/// curly brace. If [template] and [missingBlockName] are `null`, then use
4198-
/// a default error message instead.
4196+
/// If the next token is an opening curly brace, return it. Otherwise, use
4197+
/// [missingBlockKind] to report an error, insert an opening and a closing
4198+
/// curly brace, and return the newly inserted opening curly brace. If
4199+
/// [missingBlockKind] is `null`, then use a default error message instead.
41994200
Token ensureBlock(Token token, BlockKind? missingBlockKind) {
42004201
Token next = token.next!;
42014202
if (optional('{', next)) return next;
@@ -5251,9 +5252,9 @@ class Parser {
52515252
beforeName, start.next!, formals, /* isFunctionExpression = */ true);
52525253
}
52535254

5254-
/// Parses the rest of a named function declaration starting from its [name]
5255-
/// but then skips any type parameters and continue parsing from [formals]
5256-
/// (the formal parameters).
5255+
/// Parses the rest of a named function declaration starting from its name
5256+
/// (the token following [beforeName]) but then skips any type parameters and
5257+
/// continue parsing from [formals] (the formal parameters).
52575258
///
52585259
/// If [isFunctionExpression] is true, this method parses the rest of named
52595260
/// function expression which isn't legal syntax in Dart. Useful for
@@ -6143,7 +6144,7 @@ class Parser {
61436144
return token;
61446145
}
61456146

6146-
/// Attempt a recovery where [token.next] is replaced.
6147+
/// Attempt a recovery where [token].next is replaced.
61476148
bool _attemptPrecedenceLevelRecovery(Token token, int precedence,
61486149
int currentLevel, bool allowCascades, TypeParamOrArgInfo typeArg) {
61496150
// Attempt recovery.
@@ -7983,7 +7984,7 @@ class Parser {
79837984
return parseExpressionStatementOrDeclaration(start);
79847985
}
79857986

7986-
/// This method has two modes based upon [onlyParseVariableDeclarationStart].
7987+
/// This method has two modes based upon [forPartsContext].
79877988
///
79887989
/// If [forPartsContext] is `null` (the default), then the parser is currently
79897990
/// processing a statement or declaration. This method will parse a local

pkg/_fe_analyzer_shared/lib/src/parser/stack_listener.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -422,16 +422,16 @@ abstract class StackListener extends Listener with StackChecker {
422422

423423
abstract class Stack {
424424
/// Pops [count] elements from the stack and puts it into [list].
425-
/// Returns [null] if a [ParserRecovery] value is found, or [list] otherwise.
425+
/// Returns `null` if a [ParserRecovery] value is found, or [list] otherwise.
426426
List<T?>? popList<T>(int count, List<T?> list, NullValue? nullValue);
427427

428428
/// Pops [count] elements from the stack and puts it into [list].
429-
/// Returns [null] if a [ParserRecovery] value is found, or [list] otherwise.
429+
/// Returns `null` if a [ParserRecovery] value is found, or [list] otherwise.
430430
List<T>? popNonNullableList<T>(int count, List<T> list);
431431

432432
void push(Object value);
433433

434-
/// Will return [null] instead of [NullValue].
434+
/// Will return `null` instead of [NullValue].
435435
Object? get last;
436436

437437
bool get isNotEmpty;
@@ -442,7 +442,7 @@ abstract class Stack {
442442

443443
int get length;
444444

445-
/// Raw, i.e. [NullValue]s will be returned instead of [null].
445+
/// Raw, i.e. [NullValue]s will be returned instead of `null`.
446446
Object? operator [](int index);
447447
}
448448

pkg/_fe_analyzer_shared/lib/src/parser/token_stream_rewriter.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ abstract class TokenStreamRewriter {
2424
}
2525

2626
/// Insert a synthetic open and close parenthesis and return the new synthetic
27-
/// open parenthesis. If [insertIdentifier] is true, then a synthetic
27+
/// open parenthesis. If [includeIdentifier] is true, then a synthetic
2828
/// identifier is included between the open and close parenthesis.
2929
Token insertParens(Token token, bool includeIdentifier) {
3030
// Throw if the token is eof, though allow an eof-token if the offset

pkg/_fe_analyzer_shared/lib/src/parser/top_level_parser.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5+
/// @docImport 'parser_impl.dart';
56
library _fe_analyzer_shared.parser.top_level_parser;
67

78
import '../scanner/token.dart' show Token;

pkg/_fe_analyzer_shared/lib/src/scanner/abstract_scanner.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5+
/// @docImport 'string_scanner.dart';
6+
/// @docImport 'utf8_bytes_scanner.dart';
7+
/// @docImport '../parser/class_member_parser.dart';
58
library _fe_analyzer_shared.scanner.abstract_scanner;
69

710
import 'dart:collection' show ListMixin;
@@ -660,7 +663,7 @@ abstract class AbstractScanner implements Scanner {
660663
/**
661664
* This method is called to discard '<' from the "grouping" stack.
662665
*
663-
* [PartialParser.skipExpression] relies on the fact that we do not
666+
* [ClassMemberParser.skipExpression] relies on the fact that we do not
664667
* create groups for stuff like:
665668
* [:a = b < c, d = e > f:].
666669
*

pkg/_fe_analyzer_shared/lib/src/scanner/token.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,7 @@ abstract class Token implements SyntacticEntity {
998998
* For symbol and keyword tokens, returns the string value represented by this
999999
* token. For [StringToken]s this method returns [:null:].
10001000
*
1001-
* For [SymbolToken]s and [KeywordToken]s, the string value is a compile-time
1001+
* For symbol [Token]s and [KeywordToken]s, the string value is a compile-time
10021002
* constant originating in the [TokenType] or in the [Keyword] instance.
10031003
* This allows testing for keywords and symbols using [:identical:], e.g.,
10041004
* [:identical('class', token.value):].

pkg/_fe_analyzer_shared/lib/src/scanner/utf8_bytes_scanner.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5+
/// @docImport 'package:compiler/src/io/source_file.dart';
56
library _fe_analyzer_shared.scanner.utf8_bytes_scanner;
67

78
import 'dart:typed_data' show Uint8List;

0 commit comments

Comments
 (0)