Skip to content

Commit b4cd468

Browse files
stereotype441Commit Queue
authored andcommitted
[analyzer] Enable the comment_references lint.
Fixes trivial typos and adds `@docImport` declarations so that no dangling comment references remain in the `analyzer` package, and enables the `comment_references` lint so that dangling comment references won't be added in the future. Change-Id: I6a6a696466de07d6a07fe9f0afe875019bc44c71 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/450743 Reviewed-by: Konstantin Shcheglov <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]> Auto-Submit: Paul Berry <[email protected]>
1 parent 5a98a97 commit b4cd468

File tree

13 files changed

+38
-23
lines changed

13 files changed

+38
-23
lines changed

pkg/analyzer/analysis_options.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ linter:
5454
- avoid_dynamic_calls
5555
- avoid_redundant_argument_values
5656
- avoid_unused_constructor_parameters
57+
- comment_references
5758
- discarded_futures
5859
- flutter_style_todos
5960
- no_literal_bool_comparisons

pkg/analyzer/lib/dart/analysis/results.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ abstract class ElementDeclarationResult {
6666
/// The [Fragment] that this object describes.
6767
Fragment get fragment;
6868

69-
/// The node that declares the [element]. Depending on whether it is returned
69+
/// The node that declares the [Element]. Depending on whether it is returned
7070
/// from [ResolvedLibraryResult] or [ParsedLibraryResult] it might be resolved
7171
/// or just parsed.
7272
AstNode get node;

pkg/analyzer/lib/src/dart/analysis/results.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ abstract class AnalysisResultImpl implements AnalysisResult {
4444
AnalysisResultImpl({required this.session});
4545
}
4646

47-
/// A visitor which locates the [AstNode] which declares [element].
47+
/// A visitor which locates the [AstNode] which declares an [Element].
4848
class DeclarationByElementLocator extends UnifyingAstVisitor<void> {
4949
// TODO(srawlins): This visitor could be further optimized by special casing each static
5050
// type of [element]. For example, for library-level elements (classes etc),

pkg/analyzer/lib/src/dart/element/element.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3386,7 +3386,7 @@ class FormalParameterFragmentImpl extends VariableFragmentImpl
33863386
}) : assert(nameOffset == null || nameOffset >= 0),
33873387
assert(name == null || name.isNotEmpty);
33883388

3389-
/// Creates a synthetic parameter with [name2], [type] and [parameterKind].
3389+
/// Creates a synthetic parameter with [name2] and [parameterKind].
33903390
factory FormalParameterFragmentImpl.synthetic(
33913391
String? name2,
33923392
ParameterKind parameterKind,
@@ -3600,8 +3600,7 @@ abstract class FragmentImpl with _FragmentImplMixin implements Fragment {
36003600
/// The length of the element's code, or `null` if the element is synthetic.
36013601
int? _codeLength;
36023602

3603-
/// Initialize a newly created element to have the given [name] at the given
3604-
/// [_nameOffset].
3603+
/// Initialize a newly created fragment at the given [firstTokenOffset].
36053604
FragmentImpl({this.firstTokenOffset});
36063605

36073606
/// The length of the element's code, or `null` if the element is synthetic.
@@ -5989,7 +5988,7 @@ class LibraryElementImpl extends ElementImpl
59895988
);
59905989

59915990
/// Initialize a newly created library element in the given [context] to have
5992-
/// the given [name] and [offset].
5991+
/// the given [name] and [nameOffset].
59935992
LibraryElementImpl(
59945993
this._context,
59955994
this._session,

pkg/analyzer/lib/src/dart/element/type_system.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ class TypeSystemImpl implements TypeSystem {
756756
);
757757
}
758758

759-
/// Given uninstantiated [typeFormals], instantiate them to their bounds.
759+
/// Given uninstantiated [typeParameters], instantiate them to their bounds.
760760
/// See the issue for the algorithm description.
761761
///
762762
/// https://github.com/dart-lang/sdk/issues/27526#issuecomment-260021397

pkg/analyzer/lib/src/dart/micro/utils.dart

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ ConstructorElement? _getActualConstructorElement(
7676
return constructor;
7777
}
7878

79-
/// Returns the [LibraryImportElement] that is referenced by [prefixNode] with a
80-
/// [PrefixElement], maybe `null`.
79+
/// Returns the [MockLibraryImportElement] that is referenced by [prefixNode]
80+
/// with a [PrefixElement], maybe `null`.
8181
MockLibraryImportElement? _getImportElementInfo2(SimpleIdentifier prefixNode) {
8282
// prepare environment
8383
var parent = prefixNode.parent;
@@ -114,8 +114,8 @@ MockLibraryImportElement? _getImportElementInfo2(SimpleIdentifier prefixNode) {
114114
);
115115
}
116116

117-
/// Returns the [LibraryImportElement] that is referenced by [prefixNode] with a
118-
/// [PrefixElement], maybe `null`.
117+
/// Returns the [MockLibraryImportElement] that is referenced by [prefixNode]
118+
/// with a [PrefixElement], maybe `null`.
119119
MockLibraryImportElement? _getImportElementInfoFromReference(
120120
ImportPrefixReference prefixNode,
121121
) {
@@ -149,12 +149,13 @@ MockLibraryImportElement? _getImportElementInfoFromReference(
149149
);
150150
}
151151

152-
/// Returns the [LibraryImportElement] that declared [prefix] and imports [element].
152+
/// Returns the [MockLibraryImportElement] that declared [prefix] and imports
153+
/// [element].
153154
///
154155
/// [libraryFragment] - the [LibraryFragmentImpl] where reference is.
155156
/// [prefix] - the import prefix, maybe `null`.
156157
/// [element] - the referenced element.
157-
/// [importElementsMap] - the cache of [Element]s imported by [LibraryImportElement]s.
158+
/// [importElementsMap] - the cache of [Element]s imported by [LibraryImport]s.
158159
MockLibraryImportElement? _getMockImportElement(
159160
LibraryFragmentImpl libraryFragment,
160161
String prefix,

pkg/analyzer/lib/src/error/codes.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
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:analyzer/src/dart/error/syntactic_errors.dart';
6+
/// @docImport 'package:analyzer/src/error/inference_error.dart';
7+
library;
8+
59
import 'package:_fe_analyzer_shared/src/base/errors.dart';
610
import 'package:analyzer/dart/element/element.dart';
711
import 'package:analyzer/dart/element/type.dart';

pkg/analyzer/lib/src/error/ignore_validator.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class IgnoreValidator {
5050

5151
/// Initialize a newly created validator to report any issues with ignore
5252
/// comments in the file being analyzed. The diagnostics will be reported to
53-
/// the [_errorReporter].
53+
/// the [_diagnosticReporter].
5454
IgnoreValidator(
5555
this._diagnosticReporter,
5656
this._reportedDiagnostics,

pkg/analyzer/lib/src/error/listener.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,8 @@ class DiagnosticReporter {
405405
}
406406
}
407407

408-
/// Used by [DiagnosticReporter._convertTypeNames] to keep track of an error
409-
/// argument that is an [Element], that is being converted to a display string.
408+
/// Used by [convertTypeNames] to keep track of an error argument that is an
409+
/// [Element], that is being converted to a display string.
410410
class _ElementToConvert implements _ToConvert {
411411
@override
412412
final int index;
@@ -421,8 +421,8 @@ class _ElementToConvert implements _ToConvert {
421421
: allElements = [element];
422422
}
423423

424-
/// Used by [DiagnosticReporter._convertTypeNames] to keep track of an argument
425-
/// that is being converted to a display string.
424+
/// Used by [convertTypeNames] to keep track of an argument that is being
425+
/// converted to a display string.
426426
abstract class _ToConvert {
427427
/// A list of all elements involved in the [DartType] or [Element]'s display
428428
/// string.
@@ -436,8 +436,8 @@ abstract class _ToConvert {
436436
int get index;
437437
}
438438

439-
/// Used by [DiagnosticReporter._convertTypeNames] to keep track of an error
440-
/// argument that is a [DartType], that is being converted to a display string.
439+
/// Used by [convertTypeNames] to keep track of an error argument that is a
440+
/// [DartType], that is being converted to a display string.
441441
class _TypeToConvert implements _ToConvert {
442442
@override
443443
final int index;

pkg/analyzer/lib/src/generated/exhaustiveness.dart

Lines changed: 5 additions & 2 deletions
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 'package:analyzer/src/error/codes.dart';
6+
library;
7+
58
import 'package:_fe_analyzer_shared/src/exhaustiveness/dart_template_buffer.dart';
69
import 'package:_fe_analyzer_shared/src/exhaustiveness/exhaustive.dart';
710
import 'package:_fe_analyzer_shared/src/exhaustiveness/key.dart';
@@ -477,8 +480,8 @@ class MissingPatternEnumValuePart extends MissingPatternPart {
477480

478481
abstract class MissingPatternPart {
479482
/// Expando associating each
480-
/// [CompileTimeErrorCode.NON_EXHAUSTIVE_SWITCH_EXPRESSION] or
481-
/// [CompileTimeErrorCode.NON_EXHAUSTIVE_SWITCH_STATEMENT] diagnostic with a
483+
/// [CompileTimeErrorCode.nonExhaustiveSwitchExpression] or
484+
/// [CompileTimeErrorCode.nonExhaustiveSwitchStatement] diagnostic with a
482485
/// list of missing patterns; this data is used by the analysis server to add
483486
/// missing switch cases.
484487
static final byDiagnostic = Expando<List<List<MissingPatternPart>>>();

0 commit comments

Comments
 (0)