Skip to content

Commit a788c66

Browse files
committed
review comments
1 parent b43d56c commit a788c66

File tree

2 files changed

+37
-35
lines changed

2 files changed

+37
-35
lines changed

lib/src/comment_references/parser.dart

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class CommentReferenceParser {
9393
/// ```text
9494
/// <rawCommentReference> ::= <prefix>?<commentReference><suffix>?
9595
///
96-
/// <commentReference> ::= (<packageName> '.')? (<libraryName> '.')? <dartdocIdentifier> <typeParameters> ('.' <identifier> <typeParameters>)*
96+
/// <commentReference> ::= (<packageName> '.')? (<libraryName> '.')? <dartdocIdentifier> <typeArguments> ('.' <identifier> <typeArguments>)*
9797
/// ```
9898
List<CommentReferenceNode> _parseRawCommentReference() {
9999
var children = <CommentReferenceNode>[];
@@ -121,16 +121,16 @@ class CommentReferenceParser {
121121
} else if (identifierResult.type ==
122122
_IdentifierResultType.parsedIdentifier) {
123123
children.add(identifierResult.node);
124-
var typeParametersResult = _parseTypeParameters();
125-
if (typeParametersResult.type == _TypeParametersResultType.endOfFile) {
124+
var typeVariablesResult = _parseTypeVariables();
125+
if (typeVariablesResult.type == _TypeVariablesResultType.endOfFile) {
126126
break;
127-
} else if (typeParametersResult.type ==
128-
_TypeParametersResultType.notTypeParameters) {
127+
} else if (typeVariablesResult.type ==
128+
_TypeVariablesResultType.notTypeVariables) {
129129
// Do nothing, _index has not moved.
130130
;
131-
} else if (typeParametersResult.type ==
132-
_TypeParametersResultType.parsedTypeParameters) {
133-
children.add(typeParametersResult.node);
131+
} else if (typeVariablesResult.type ==
132+
_TypeVariablesResultType.parsedTypeVariables) {
133+
children.add(typeVariablesResult.node);
134134
}
135135
}
136136
if (_atEnd || _thisChar != $dot) {
@@ -247,20 +247,20 @@ class CommentReferenceParser {
247247
IdentifierNode(codeRef.substring(startIndex, _index)));
248248
}
249249

250-
/// Parse a list of type parameters.
250+
/// Parse a list of type variables (arguments or parameters).
251251
///
252252
/// Dartdoc isolates these where present and potentially valid, but we don't
253253
/// break them down.
254-
_TypeParametersParseResult _parseTypeParameters() {
254+
_TypeVariablesParseResult _parseTypeVariables() {
255255
if (_atEnd) {
256-
return _TypeParametersParseResult.endOfFile;
256+
return _TypeVariablesParseResult.endOfFile;
257257
}
258258
var startIndex = _index;
259259
if (_matchBraces($lt, $gt)) {
260-
return _TypeParametersParseResult.ok(
261-
TypeParametersNode(codeRef.substring(startIndex + 1, _index - 1)));
260+
return _TypeVariablesParseResult.ok(
261+
TypeVariablesNode(codeRef.substring(startIndex + 1, _index - 1)));
262262
}
263-
return _TypeParametersParseResult.notIdentifier;
263+
return _TypeVariablesParseResult.notIdentifier;
264264
}
265265

266266
static const _callableHintSuffix = '()';
@@ -421,30 +421,30 @@ class _IdentifierParseResult {
421421
_IdentifierParseResult._(_IdentifierResultType.notIdentifier, null);
422422
}
423423

424-
enum _TypeParametersResultType {
424+
enum _TypeVariablesResultType {
425425
endOfFile, // Found end of file instead of the beginning of a list of type
426-
// parameters.
427-
notTypeParameters, // Found something, but it isn't type parameters.
428-
parsedTypeParameters, // Found type parameters.
426+
// variables.
427+
notTypeVariables, // Found something, but it isn't type variables.
428+
parsedTypeVariables, // Found type variables.
429429
}
430430

431-
class _TypeParametersParseResult {
432-
final _TypeParametersResultType type;
431+
class _TypeVariablesParseResult {
432+
final _TypeVariablesResultType type;
433433

434-
final TypeParametersNode node;
434+
final TypeVariablesNode node;
435435

436-
const _TypeParametersParseResult._(this.type, this.node);
436+
const _TypeVariablesParseResult._(this.type, this.node);
437437

438-
factory _TypeParametersParseResult.ok(TypeParametersNode node) =>
439-
_TypeParametersParseResult._(
440-
_TypeParametersResultType.parsedTypeParameters, node);
438+
factory _TypeVariablesParseResult.ok(TypeVariablesNode node) =>
439+
_TypeVariablesParseResult._(
440+
_TypeVariablesResultType.parsedTypeVariables, node);
441441

442-
static const _TypeParametersParseResult endOfFile =
443-
_TypeParametersParseResult._(_TypeParametersResultType.endOfFile, null);
442+
static const _TypeVariablesParseResult endOfFile =
443+
_TypeVariablesParseResult._(_TypeVariablesResultType.endOfFile, null);
444444

445-
static const _TypeParametersParseResult notIdentifier =
446-
_TypeParametersParseResult._(
447-
_TypeParametersResultType.notTypeParameters, null);
445+
static const _TypeVariablesParseResult notIdentifier =
446+
_TypeVariablesParseResult._(
447+
_TypeVariablesResultType.notTypeVariables, null);
448448
}
449449

450450
enum _SuffixResultType {
@@ -512,18 +512,18 @@ class IdentifierNode extends CommentReferenceNode {
512512
String toString() => 'Identifier["$text"]';
513513
}
514514

515-
/// Represents one or more type parameters, may be
515+
/// Represents one or more type variables, may be
516516
/// comma separated.
517-
class TypeParametersNode extends CommentReferenceNode {
517+
class TypeVariablesNode extends CommentReferenceNode {
518518
@override
519519

520520
/// Note that this will contain commas, spaces, and other text, as
521-
/// generally type parameters are a form of junk that comment references
521+
/// generally type variables are a form of junk that comment references
522522
/// should ignore.
523523
final String text;
524524

525-
TypeParametersNode(this.text);
525+
TypeVariablesNode(this.text);
526526

527527
@override
528-
String toString() => 'TypeParametersNode["$text"]';
528+
String toString() => 'TypeVariablesNode["$text"]';
529529
}

test/comment_referable/parser_test.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ void main() {
8383

8484
test('Check that embedded types within tearoff-like constructs parse', () {
8585
expectParseEquivalent('this<stuff>.isValid', ['this', 'isValid']);
86+
expectParseEquivalent(
87+
'this<stuff, is, also>.isValid', ['this', 'isValid']);
8688
expectParseEquivalent('this<stuff<that<is, real>, complicated>>.isValid',
8789
['this', 'isValid']);
8890
expectParseError('this<stuff.isntValid');

0 commit comments

Comments
 (0)