[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 <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Paul Berry <paulberry@google.com>
diff --git a/pkg/analyzer/analysis_options.yaml b/pkg/analyzer/analysis_options.yaml
index 71169b9..d089f28 100644
--- a/pkg/analyzer/analysis_options.yaml
+++ b/pkg/analyzer/analysis_options.yaml
@@ -54,6 +54,7 @@
- avoid_dynamic_calls
- avoid_redundant_argument_values
- avoid_unused_constructor_parameters
+ - comment_references
- discarded_futures
- flutter_style_todos
- no_literal_bool_comparisons
diff --git a/pkg/analyzer/lib/dart/analysis/results.dart b/pkg/analyzer/lib/dart/analysis/results.dart
index ad4ccde..5575659 100644
--- a/pkg/analyzer/lib/dart/analysis/results.dart
+++ b/pkg/analyzer/lib/dart/analysis/results.dart
@@ -66,7 +66,7 @@
/// The [Fragment] that this object describes.
Fragment get fragment;
- /// The node that declares the [element]. Depending on whether it is returned
+ /// The node that declares the [Element]. Depending on whether it is returned
/// from [ResolvedLibraryResult] or [ParsedLibraryResult] it might be resolved
/// or just parsed.
AstNode get node;
diff --git a/pkg/analyzer/lib/src/dart/analysis/results.dart b/pkg/analyzer/lib/src/dart/analysis/results.dart
index afd92ca..c6f2bf7 100644
--- a/pkg/analyzer/lib/src/dart/analysis/results.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/results.dart
@@ -44,7 +44,7 @@
AnalysisResultImpl({required this.session});
}
-/// A visitor which locates the [AstNode] which declares [element].
+/// A visitor which locates the [AstNode] which declares an [Element].
class DeclarationByElementLocator extends UnifyingAstVisitor<void> {
// TODO(srawlins): This visitor could be further optimized by special casing each static
// type of [element]. For example, for library-level elements (classes etc),
diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart
index 8175593..78a4775 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -3386,7 +3386,7 @@
}) : assert(nameOffset == null || nameOffset >= 0),
assert(name == null || name.isNotEmpty);
- /// Creates a synthetic parameter with [name2], [type] and [parameterKind].
+ /// Creates a synthetic parameter with [name2] and [parameterKind].
factory FormalParameterFragmentImpl.synthetic(
String? name2,
ParameterKind parameterKind,
@@ -3600,8 +3600,7 @@
/// The length of the element's code, or `null` if the element is synthetic.
int? _codeLength;
- /// Initialize a newly created element to have the given [name] at the given
- /// [_nameOffset].
+ /// Initialize a newly created fragment at the given [firstTokenOffset].
FragmentImpl({this.firstTokenOffset});
/// The length of the element's code, or `null` if the element is synthetic.
@@ -5989,7 +5988,7 @@
);
/// Initialize a newly created library element in the given [context] to have
- /// the given [name] and [offset].
+ /// the given [name] and [nameOffset].
LibraryElementImpl(
this._context,
this._session,
diff --git a/pkg/analyzer/lib/src/dart/element/type_system.dart b/pkg/analyzer/lib/src/dart/element/type_system.dart
index 107d973..e02ef3d 100644
--- a/pkg/analyzer/lib/src/dart/element/type_system.dart
+++ b/pkg/analyzer/lib/src/dart/element/type_system.dart
@@ -756,7 +756,7 @@
);
}
- /// Given uninstantiated [typeFormals], instantiate them to their bounds.
+ /// Given uninstantiated [typeParameters], instantiate them to their bounds.
/// See the issue for the algorithm description.
///
/// https://github.com/dart-lang/sdk/issues/27526#issuecomment-260021397
diff --git a/pkg/analyzer/lib/src/dart/micro/utils.dart b/pkg/analyzer/lib/src/dart/micro/utils.dart
index 316eed9..86adeeb 100644
--- a/pkg/analyzer/lib/src/dart/micro/utils.dart
+++ b/pkg/analyzer/lib/src/dart/micro/utils.dart
@@ -76,8 +76,8 @@
return constructor;
}
-/// Returns the [LibraryImportElement] that is referenced by [prefixNode] with a
-/// [PrefixElement], maybe `null`.
+/// Returns the [MockLibraryImportElement] that is referenced by [prefixNode]
+/// with a [PrefixElement], maybe `null`.
MockLibraryImportElement? _getImportElementInfo2(SimpleIdentifier prefixNode) {
// prepare environment
var parent = prefixNode.parent;
@@ -114,8 +114,8 @@
);
}
-/// Returns the [LibraryImportElement] that is referenced by [prefixNode] with a
-/// [PrefixElement], maybe `null`.
+/// Returns the [MockLibraryImportElement] that is referenced by [prefixNode]
+/// with a [PrefixElement], maybe `null`.
MockLibraryImportElement? _getImportElementInfoFromReference(
ImportPrefixReference prefixNode,
) {
@@ -149,12 +149,13 @@
);
}
-/// Returns the [LibraryImportElement] that declared [prefix] and imports [element].
+/// Returns the [MockLibraryImportElement] that declared [prefix] and imports
+/// [element].
///
/// [libraryFragment] - the [LibraryFragmentImpl] where reference is.
/// [prefix] - the import prefix, maybe `null`.
/// [element] - the referenced element.
-/// [importElementsMap] - the cache of [Element]s imported by [LibraryImportElement]s.
+/// [importElementsMap] - the cache of [Element]s imported by [LibraryImport]s.
MockLibraryImportElement? _getMockImportElement(
LibraryFragmentImpl libraryFragment,
String prefix,
diff --git a/pkg/analyzer/lib/src/error/codes.dart b/pkg/analyzer/lib/src/error/codes.dart
index ab34390..2f1fd8a 100644
--- a/pkg/analyzer/lib/src/error/codes.dart
+++ b/pkg/analyzer/lib/src/error/codes.dart
@@ -2,6 +2,10 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+/// @docImport 'package:analyzer/src/dart/error/syntactic_errors.dart';
+/// @docImport 'package:analyzer/src/error/inference_error.dart';
+library;
+
import 'package:_fe_analyzer_shared/src/base/errors.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
diff --git a/pkg/analyzer/lib/src/error/ignore_validator.dart b/pkg/analyzer/lib/src/error/ignore_validator.dart
index a8bc2ba..7239137 100644
--- a/pkg/analyzer/lib/src/error/ignore_validator.dart
+++ b/pkg/analyzer/lib/src/error/ignore_validator.dart
@@ -50,7 +50,7 @@
/// Initialize a newly created validator to report any issues with ignore
/// comments in the file being analyzed. The diagnostics will be reported to
- /// the [_errorReporter].
+ /// the [_diagnosticReporter].
IgnoreValidator(
this._diagnosticReporter,
this._reportedDiagnostics,
diff --git a/pkg/analyzer/lib/src/error/listener.dart b/pkg/analyzer/lib/src/error/listener.dart
index 787ac2b..149f991 100644
--- a/pkg/analyzer/lib/src/error/listener.dart
+++ b/pkg/analyzer/lib/src/error/listener.dart
@@ -405,8 +405,8 @@
}
}
-/// Used by [DiagnosticReporter._convertTypeNames] to keep track of an error
-/// argument that is an [Element], that is being converted to a display string.
+/// Used by [convertTypeNames] to keep track of an error argument that is an
+/// [Element], that is being converted to a display string.
class _ElementToConvert implements _ToConvert {
@override
final int index;
@@ -421,8 +421,8 @@
: allElements = [element];
}
-/// Used by [DiagnosticReporter._convertTypeNames] to keep track of an argument
-/// that is being converted to a display string.
+/// Used by [convertTypeNames] to keep track of an argument that is being
+/// converted to a display string.
abstract class _ToConvert {
/// A list of all elements involved in the [DartType] or [Element]'s display
/// string.
@@ -436,8 +436,8 @@
int get index;
}
-/// Used by [DiagnosticReporter._convertTypeNames] to keep track of an error
-/// argument that is a [DartType], that is being converted to a display string.
+/// Used by [convertTypeNames] to keep track of an error argument that is a
+/// [DartType], that is being converted to a display string.
class _TypeToConvert implements _ToConvert {
@override
final int index;
diff --git a/pkg/analyzer/lib/src/generated/exhaustiveness.dart b/pkg/analyzer/lib/src/generated/exhaustiveness.dart
index 5caacb8..364d16e 100644
--- a/pkg/analyzer/lib/src/generated/exhaustiveness.dart
+++ b/pkg/analyzer/lib/src/generated/exhaustiveness.dart
@@ -2,6 +2,9 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+/// @docImport 'package:analyzer/src/error/codes.dart';
+library;
+
import 'package:_fe_analyzer_shared/src/exhaustiveness/dart_template_buffer.dart';
import 'package:_fe_analyzer_shared/src/exhaustiveness/exhaustive.dart';
import 'package:_fe_analyzer_shared/src/exhaustiveness/key.dart';
@@ -477,8 +480,8 @@
abstract class MissingPatternPart {
/// Expando associating each
- /// [CompileTimeErrorCode.NON_EXHAUSTIVE_SWITCH_EXPRESSION] or
- /// [CompileTimeErrorCode.NON_EXHAUSTIVE_SWITCH_STATEMENT] diagnostic with a
+ /// [CompileTimeErrorCode.nonExhaustiveSwitchExpression] or
+ /// [CompileTimeErrorCode.nonExhaustiveSwitchStatement] diagnostic with a
/// list of missing patterns; this data is used by the analysis server to add
/// missing switch cases.
static final byDiagnostic = Expando<List<List<MissingPatternPart>>>();
diff --git a/pkg/analyzer/lib/src/summary/format.dart b/pkg/analyzer/lib/src/summary/format.dart
index 4bb4c6d..45298da 100644
--- a/pkg/analyzer/lib/src/summary/format.dart
+++ b/pkg/analyzer/lib/src/summary/format.dart
@@ -10,6 +10,9 @@
// The generator sometimes generates unnecessary 'this' references.
// ignore_for_file: unnecessary_this
+/// @docImport 'package:analyzer/src/summary/idl.dart';
+library;
+
import 'dart:convert' as convert;
import 'dart:typed_data' as typed_data;
diff --git a/pkg/analyzer/lib/src/summary2/bundle_writer.dart b/pkg/analyzer/lib/src/summary2/bundle_writer.dart
index 1f5c4ad..be219e6 100644
--- a/pkg/analyzer/lib/src/summary2/bundle_writer.dart
+++ b/pkg/analyzer/lib/src/summary2/bundle_writer.dart
@@ -784,7 +784,7 @@
_resolutionSink.writeType(fragment.element.defaultType);
}
- /// Add [typeParameters] to the indexing scope, so make them available
+ /// Add [typeParameterFragments] to the indexing scope, so make them available
/// when writing types that might reference them, and write the elements.
void _writeTypeParameters(
List<TypeParameterFragmentImpl> typeParameterFragments,
diff --git a/pkg/analyzer/tool/summary/generate.dart b/pkg/analyzer/tool/summary/generate.dart
index 7e0e9ac..bfd43ab 100644
--- a/pkg/analyzer/tool/summary/generate.dart
+++ b/pkg/analyzer/tool/summary/generate.dart
@@ -677,6 +677,9 @@
out("// The generator sometimes generates unnecessary 'this' references.");
out('// ignore_for_file: unnecessary_this');
out();
+ out("/// @docImport 'package:analyzer/src/summary/idl.dart';");
+ out('library;');
+ out();
out("import 'dart:convert' as convert;");
out("import 'dart:typed_data' as typed_data;");
out();
@@ -684,6 +687,7 @@
out("import 'package:analyzer/src/summary/flat_buffers.dart' as fb;");
out("import 'package:analyzer/src/summary/idl.dart' as idl;");
out();
+
for (idl_model.EnumDeclaration enum_ in _idl.enums.values) {
_EnumReaderGenerator(_idl, _outBuffer, enum_).generate();
out();