Skip to content

Commit ae835a6

Browse files
stereotype441Commit Queue
authored andcommitted
[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 <[email protected]> Commit-Queue: Paul Berry <[email protected]> Reviewed-by: Konstantin Shcheglov <[email protected]>
1 parent ac68903 commit ae835a6

File tree

4 files changed

+6
-42
lines changed

4 files changed

+6
-42
lines changed

pkg/analyzer/lib/src/dart/error/hint_codes.g.dart

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,6 @@ class HintCode extends DiagnosticCode {
112112
hasPublishedDocs: true,
113113
);
114114

115-
@Deprecated("Please use unnecessaryImport")
116-
static const HintCode UNNECESSARY_IMPORT = unnecessaryImport;
117-
118115
/// Initialize a newly created error code to have the given [name].
119116
const HintCode(
120117
String name,

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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2542,10 +2542,6 @@ class CompileTimeErrorCode extends DiagnosticCode {
25422542
hasPublishedDocs: true,
25432543
);
25442544

2545-
@Deprecated("Please use importInternalLibrary")
2546-
static const CompileTimeErrorCode IMPORT_INTERNAL_LIBRARY =
2547-
importInternalLibrary;
2548-
25492545
/// Parameters:
25502546
/// String p0: the URI pointing to a non-library declaration
25512547
static const CompileTimeErrorCode importOfNonLibrary = CompileTimeErrorCode(
@@ -7834,9 +7830,6 @@ class WarningCode extends DiagnosticCode {
78347830
hasPublishedDocs: true,
78357831
);
78367832

7837-
@Deprecated("Please use unusedElement")
7838-
static const WarningCode UNUSED_ELEMENT = unusedElement;
7839-
78407833
/// Parameters:
78417834
/// Object p0: the name of the parameter that is declared but not used
78427835
static const WarningCode unusedElementParameter = WarningCode(
@@ -7864,9 +7857,6 @@ class WarningCode extends DiagnosticCode {
78647857
hasPublishedDocs: true,
78657858
);
78667859

7867-
@Deprecated("Please use unusedImport")
7868-
static const WarningCode UNUSED_IMPORT = unusedImport;
7869-
78707860
/// Parameters:
78717861
/// String p0: the label that isn't used
78727862
static const WarningCode unusedLabel = WarningCode(
@@ -7887,9 +7877,6 @@ class WarningCode extends DiagnosticCode {
78877877
hasPublishedDocs: true,
78887878
);
78897879

7890-
@Deprecated("Please use unusedLocalVariable")
7891-
static const WarningCode UNUSED_LOCAL_VARIABLE = unusedLocalVariable;
7892-
78937880
/// Parameters:
78947881
/// String p0: the name of the annotated method, property or function
78957882
static const WarningCode unusedResult = WarningCode(

pkg/analyzer/tool/messages/error_code_info.dart

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ const List<ErrorClassInfo> errorClasses = [
3535
name: 'CompileTimeErrorCode',
3636
type: 'COMPILE_TIME_ERROR',
3737
deprecatedSnakeCaseNames: {
38-
'IMPORT_INTERNAL_LIBRARY', // Referenced by `verify_docs.dart`.
3938
'INSTANCE_ACCESS_TO_STATIC_MEMBER', // Referenced by `messages.yaml`.
4039
'INVALID_OVERRIDE', // Referenced by `messages.yaml`.
4140
'TYPE_ARGUMENT_NOT_MATCHING_BOUNDS', // Referenced by `messages.yaml`.
@@ -58,25 +57,13 @@ const List<ErrorClassInfo> errorClasses = [
5857
name: 'WarningCode',
5958
type: 'STATIC_WARNING',
6059
severity: 'WARNING',
61-
deprecatedSnakeCaseNames: {
62-
'UNUSED_ELEMENT', // Referenced by `verify_docs.dart`.
63-
'UNUSED_IMPORT', // Referenced by `verify_docs.dart`.
64-
'UNUSED_LOCAL_VARIABLE', // Referenced by `verify_docs.dart`.
65-
},
6660
),
6761
ErrorClassInfo(
6862
file: ffiCodesFile,
6963
name: 'FfiCode',
7064
type: 'COMPILE_TIME_ERROR',
7165
),
72-
ErrorClassInfo(
73-
file: hintCodesFile,
74-
name: 'HintCode',
75-
type: 'HINT',
76-
deprecatedSnakeCaseNames: {
77-
'UNNECESSARY_IMPORT', // Referenced by `verify_docs.dart`.
78-
},
79-
),
66+
ErrorClassInfo(file: hintCodesFile, name: 'HintCode', type: 'HINT'),
8067
ErrorClassInfo(
8168
file: syntacticErrorsFile,
8269
name: 'ParserErrorCode',

tools/verify_docs/bin/verify_docs.dart

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@
44

55
// Read the ../README.md file for the recognized syntax.
66

7-
// This file uses some SCREAMING_CAPS diagnostic names that are private to the
8-
// analyzer package. Those names will soon be deprecated since the analyzer will
9-
// switch to using camelCase diagnostic names. This "ignore" comment will
10-
// prevent a bot failure when the deprecation happens. TODO(paulberry): clean
11-
// this up.
12-
// ignore_for_file: deprecated_member_use
13-
147
import 'dart:collection';
158
import 'dart:io';
169

@@ -350,21 +343,21 @@ class ValidateCommentCodeSamplesVisitor extends GeneralizingAstVisitor {
350343
// Filter out unused imports, since we speculatively add imports to some
351344
// samples.
352345
diagnostics
353-
.removeWhere((e) => e.diagnosticCode == WarningCode.UNUSED_IMPORT);
346+
.removeWhere((e) => e.diagnosticCode == WarningCode.unusedImport);
354347

355348
// Also, don't worry about 'unused_local_variable' and related; this may
356349
// be intentional in samples.
357350
diagnostics.removeWhere(
358351
(e) =>
359-
e.diagnosticCode == WarningCode.UNUSED_LOCAL_VARIABLE ||
360-
e.diagnosticCode == WarningCode.UNUSED_ELEMENT,
352+
e.diagnosticCode == WarningCode.unusedLocalVariable ||
353+
e.diagnosticCode == WarningCode.unusedElement,
361354
);
362355

363356
// Handle edge case around dart:_http
364357
diagnostics.removeWhere((e) {
365358
if (e.message.contains("'dart:_http'")) {
366-
return e.diagnosticCode == HintCode.UNNECESSARY_IMPORT ||
367-
e.diagnosticCode == CompileTimeErrorCode.IMPORT_INTERNAL_LIBRARY;
359+
return e.diagnosticCode == HintCode.unnecessaryImport ||
360+
e.diagnosticCode == CompileTimeErrorCode.importInternalLibrary;
368361
}
369362
return false;
370363
});

0 commit comments

Comments
 (0)