@@ -32,11 +32,12 @@ const Map<String, String> operatorNames = {
3232class StringTrie {
3333 final Map <int , StringTrie > children = {};
3434
35- /// Does [ this] node represent a valid entry in the trie?
35+ /// Does ` this` node represent a valid entry in the trie?
3636 bool valid = false ;
3737
38- /// Greedily match on the string trie starting at the given index. Returns
39- /// the index of the first non-operator character if a match is valid,
38+ /// Greedily matches on the string trie starting at the given index.
39+ ///
40+ /// Returns the index of the first non-operator character if a match is valid,
4041 /// otherwise -1.
4142 int match (String toMatch, [int index = 0 , int lastValid = - 1 ]) {
4243 if (index < 0 || index > toMatch.length) {
@@ -76,11 +77,11 @@ final StringTrie operatorParseTrie = () {
7677// TODO(jcollins-g): align with [CommentReference] from analyzer AST.
7778class CommentReferenceParser {
7879 /// Original, unparsed reference.
79- final String codeRef ;
80+ final String _codeRef ;
8081
8182 final int _referenceLength;
8283
83- CommentReferenceParser (this .codeRef ) : _referenceLength = codeRef .length;
84+ CommentReferenceParser (this ._codeRef ) : _referenceLength = _codeRef .length;
8485
8586 int _index = 0 ;
8687
@@ -194,28 +195,29 @@ class CommentReferenceParser {
194195 };
195196
196197 /// Advances the index forward to the end of the operator if one is
197- /// present and returns the operator's name. Otherwise, leaves _index
198- /// unchanged and returns null.
198+ /// present and returns the operator's name.
199+ ///
200+ /// Otherwise, leaves `_index` unchanged and returns `null` .
199201 String ? _tryParseOperator () {
200202 var tryIndex = _index;
201- if (tryIndex + _operatorKeyword.length < codeRef .length &&
202- codeRef .substring (tryIndex, tryIndex + _operatorKeyword.length) ==
203+ if (tryIndex + _operatorKeyword.length < _codeRef .length &&
204+ _codeRef .substring (tryIndex, tryIndex + _operatorKeyword.length) ==
203205 _operatorKeyword) {
204206 tryIndex = tryIndex + _operatorKeyword.length;
205- while (_whitespace.contains (codeRef .codeUnitAt (tryIndex))) {
207+ while (_whitespace.contains (_codeRef .codeUnitAt (tryIndex))) {
206208 tryIndex++ ;
207209 }
208210 }
209211
210- var result = operatorParseTrie.match (codeRef , tryIndex);
212+ var result = operatorParseTrie.match (_codeRef , tryIndex);
211213 if (result == - 1 ) {
212214 return null ;
213215 }
214216 _index = result;
215- return codeRef .substring (tryIndex, result);
217+ return _codeRef .substring (tryIndex, result);
216218 }
217219
218- /// Parse a dartdoc identifier.
220+ /// Parses a dartdoc identifier.
219221 ///
220222 /// Dartdoc identifiers can include some operators.
221223 _IdentifierParseResult _parseIdentifier () {
@@ -240,10 +242,10 @@ class CommentReferenceParser {
240242 _index++ ;
241243 }
242244 return _IdentifierParseResult .ok (
243- IdentifierNode (codeRef .substring (startIndex, _index)));
245+ IdentifierNode (_codeRef .substring (startIndex, _index)));
244246 }
245247
246- /// Parse a list of type variables (arguments or parameters).
248+ /// Parses a list of type variables (arguments or parameters).
247249 ///
248250 /// Dartdoc isolates these where present and potentially valid, but we don't
249251 /// break them down.
@@ -254,7 +256,7 @@ class CommentReferenceParser {
254256 var startIndex = _index;
255257 if (_matchBraces ($lt, $gt)) {
256258 return _TypeVariablesParseResult .ok (
257- TypeVariablesNode (codeRef .substring (startIndex + 1 , _index - 1 )));
259+ TypeVariablesNode (_codeRef .substring (startIndex + 1 , _index - 1 )));
258260 }
259261 return _TypeVariablesParseResult .notIdentifier;
260262 }
@@ -282,7 +284,7 @@ class CommentReferenceParser {
282284 if (_tryMatchLiteral (_callableHintSuffix)) {
283285 if (_atEnd) {
284286 return _SuffixParseResult .ok (
285- CallableHintEndNode (codeRef .substring (startIndex, _index)));
287+ CallableHintEndNode (_codeRef .substring (startIndex, _index)));
286288 }
287289 return _SuffixParseResult .notSuffix;
288290 }
@@ -299,7 +301,7 @@ class CommentReferenceParser {
299301
300302 bool get _atEnd => _index >= _referenceLength;
301303 bool get _nextAtEnd => _index + 1 >= _referenceLength;
302- int get _thisChar => codeRef .codeUnitAt (_index);
304+ int get _thisChar => _codeRef .codeUnitAt (_index);
303305
304306 /// Advances [_index] on match, preserves on non-match.
305307 bool _tryMatchLiteral (String characters,
@@ -310,7 +312,7 @@ class CommentReferenceParser {
310312 for (startIndex = _index;
311313 _index - startIndex < characters.length;
312314 _index++ ) {
313- if (codeRef .codeUnitAt (_index) !=
315+ if (_codeRef .codeUnitAt (_index) !=
314316 characters.codeUnitAt (_index - startIndex)) {
315317 _index = startIndex;
316318 return false ;
@@ -343,8 +345,9 @@ class CommentReferenceParser {
343345 return ;
344346 }
345347
346- /// Returns `true` if we started with [startChar] and ended with [endChar]
347- /// with a matching number of braces.
348+ /// Returns whether we started with [startChar] and ended with [endChar] with
349+ /// a matching number of braces.
350+ ///
348351 /// Restores [_index] to state when called if returning `false` .
349352 bool _matchBraces (int startChar, int endChar) {
350353 var braceCount = 0 ;
@@ -414,10 +417,14 @@ class _IdentifierParseResult {
414417}
415418
416419enum _TypeVariablesResultType {
417- endOfFile, // Found end of file instead of the beginning of a list of type
418- // variables.
419- notTypeVariables, // Found something, but it isn't type variables.
420- parsedTypeVariables, // Found type variables.
420+ /// Found end of file instead of the beginning of a list of type variables.
421+ endOfFile,
422+
423+ /// Found something, but it isn't type variables.
424+ notTypeVariables,
425+
426+ /// Found type variables.
427+ parsedTypeVariables,
421428}
422429
423430class _TypeVariablesParseResult {
0 commit comments