[tools] Switch error code references in verify_docs.dart to camelCase

This is a follow-up to
https://dart-review.googlesource.com/c/sdk/+/444921, which renamed
analyzer error codes from SCREAMING_CAPS conventions to camelCase
conventions. That CL left a few deprecated error codes in place
because they were referred to in
`tools/verify_docs/bin/verify_docs.dart`, and those references
couldn't be fixed in an automated fashion.

This CL cleans up the references in `verify_docs.dart` to use the new
camelCase constants, and removes the deprecated SCREAMING_CAPS
constants that are no longer needed.

Change-Id: I6a6a69644eb8cfe7841d7582fd520f081010544d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/445106
Reviewed-by: Moritz Sümmermann <mosum@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
Paul Berry
2025-08-14 09:27:53 -07:00
committed by Commit Queue
parent ac68903f1f
commit ae835a68d9
4 changed files with 6 additions and 42 deletions
@@ -112,9 +112,6 @@ class HintCode extends DiagnosticCode {
hasPublishedDocs: true,
);
@Deprecated("Please use unnecessaryImport")
static const HintCode UNNECESSARY_IMPORT = unnecessaryImport;
/// Initialize a newly created error code to have the given [name].
const HintCode(
String name,
-13
View File
@@ -2542,10 +2542,6 @@ class CompileTimeErrorCode extends DiagnosticCode {
hasPublishedDocs: true,
);
@Deprecated("Please use importInternalLibrary")
static const CompileTimeErrorCode IMPORT_INTERNAL_LIBRARY =
importInternalLibrary;
/// Parameters:
/// String p0: the URI pointing to a non-library declaration
static const CompileTimeErrorCode importOfNonLibrary = CompileTimeErrorCode(
@@ -7834,9 +7830,6 @@ class WarningCode extends DiagnosticCode {
hasPublishedDocs: true,
);
@Deprecated("Please use unusedElement")
static const WarningCode UNUSED_ELEMENT = unusedElement;
/// Parameters:
/// Object p0: the name of the parameter that is declared but not used
static const WarningCode unusedElementParameter = WarningCode(
@@ -7864,9 +7857,6 @@ class WarningCode extends DiagnosticCode {
hasPublishedDocs: true,
);
@Deprecated("Please use unusedImport")
static const WarningCode UNUSED_IMPORT = unusedImport;
/// Parameters:
/// String p0: the label that isn't used
static const WarningCode unusedLabel = WarningCode(
@@ -7887,9 +7877,6 @@ class WarningCode extends DiagnosticCode {
hasPublishedDocs: true,
);
@Deprecated("Please use unusedLocalVariable")
static const WarningCode UNUSED_LOCAL_VARIABLE = unusedLocalVariable;
/// Parameters:
/// String p0: the name of the annotated method, property or function
static const WarningCode unusedResult = WarningCode(
@@ -35,7 +35,6 @@ const List<ErrorClassInfo> errorClasses = [
name: 'CompileTimeErrorCode',
type: 'COMPILE_TIME_ERROR',
deprecatedSnakeCaseNames: {
'IMPORT_INTERNAL_LIBRARY', // Referenced by `verify_docs.dart`.
'INSTANCE_ACCESS_TO_STATIC_MEMBER', // Referenced by `messages.yaml`.
'INVALID_OVERRIDE', // Referenced by `messages.yaml`.
'TYPE_ARGUMENT_NOT_MATCHING_BOUNDS', // Referenced by `messages.yaml`.
@@ -58,25 +57,13 @@ const List<ErrorClassInfo> errorClasses = [
name: 'WarningCode',
type: 'STATIC_WARNING',
severity: 'WARNING',
deprecatedSnakeCaseNames: {
'UNUSED_ELEMENT', // Referenced by `verify_docs.dart`.
'UNUSED_IMPORT', // Referenced by `verify_docs.dart`.
'UNUSED_LOCAL_VARIABLE', // Referenced by `verify_docs.dart`.
},
),
ErrorClassInfo(
file: ffiCodesFile,
name: 'FfiCode',
type: 'COMPILE_TIME_ERROR',
),
ErrorClassInfo(
file: hintCodesFile,
name: 'HintCode',
type: 'HINT',
deprecatedSnakeCaseNames: {
'UNNECESSARY_IMPORT', // Referenced by `verify_docs.dart`.
},
),
ErrorClassInfo(file: hintCodesFile, name: 'HintCode', type: 'HINT'),
ErrorClassInfo(
file: syntacticErrorsFile,
name: 'ParserErrorCode',
+5 -12
View File
@@ -4,13 +4,6 @@
// Read the ../README.md file for the recognized syntax.
// This file uses some SCREAMING_CAPS diagnostic names that are private to the
// analyzer package. Those names will soon be deprecated since the analyzer will
// switch to using camelCase diagnostic names. This "ignore" comment will
// prevent a bot failure when the deprecation happens. TODO(paulberry): clean
// this up.
// ignore_for_file: deprecated_member_use
import 'dart:collection';
import 'dart:io';
@@ -350,21 +343,21 @@ class ValidateCommentCodeSamplesVisitor extends GeneralizingAstVisitor {
// Filter out unused imports, since we speculatively add imports to some
// samples.
diagnostics
.removeWhere((e) => e.diagnosticCode == WarningCode.UNUSED_IMPORT);
.removeWhere((e) => e.diagnosticCode == WarningCode.unusedImport);
// Also, don't worry about 'unused_local_variable' and related; this may
// be intentional in samples.
diagnostics.removeWhere(
(e) =>
e.diagnosticCode == WarningCode.UNUSED_LOCAL_VARIABLE ||
e.diagnosticCode == WarningCode.UNUSED_ELEMENT,
e.diagnosticCode == WarningCode.unusedLocalVariable ||
e.diagnosticCode == WarningCode.unusedElement,
);
// Handle edge case around dart:_http
diagnostics.removeWhere((e) {
if (e.message.contains("'dart:_http'")) {
return e.diagnosticCode == HintCode.UNNECESSARY_IMPORT ||
e.diagnosticCode == CompileTimeErrorCode.IMPORT_INTERNAL_LIBRARY;
return e.diagnosticCode == HintCode.unnecessaryImport ||
e.diagnosticCode == CompileTimeErrorCode.importInternalLibrary;
}
return false;
});