Skip to content

Commit f2123a8

Browse files
stereotype441Commit Queue
authored andcommitted
[analyzer] Rename error constants to camelCase.
This change was generated by the following process: - The script `pkg/analyzer/tool/messages/rename_error_constants.dart` was run. This generated the vast majority of the diffs. - Then all modified files were reformatted using `tools/sdk/dart-sdk/bin/dart/format`. - Finally, the script `pkg/analyzer/tool/messages/generate.dart` was run, to rebuild generated code. Change-Id: I6a6a69644ed8740ad6269d98cb169076151824ed Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/444921 Reviewed-by: Konstantin Shcheglov <[email protected]> Reviewed-by: Samuel Rawlins <[email protected]> Commit-Queue: Paul Berry <[email protected]>
1 parent 919d503 commit f2123a8

File tree

1,080 files changed

+16340
-20381
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,080 files changed

+16340
-20381
lines changed

pkg/_fe_analyzer_shared/lib/src/scanner/errors.dart

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ void translateErrorToken(ErrorToken token, ReportError reportError) {
3838
// TODO(paulberry,ahe): Fasta reports the error location as the entire
3939
// string; analyzer expects the end of the string.
4040
reportError(
41-
ScannerErrorCode.UNTERMINATED_STRING_LITERAL,
41+
ScannerErrorCode.unterminatedStringLiteral,
4242
endOffset - 1,
4343
null,
4444
);
@@ -48,7 +48,7 @@ void translateErrorToken(ErrorToken token, ReportError reportError) {
4848
// TODO(paulberry,ahe): Fasta reports the error location as the entire
4949
// comment; analyzer expects the end of the comment.
5050
reportError(
51-
ScannerErrorCode.UNTERMINATED_MULTI_LINE_COMMENT,
51+
ScannerErrorCode.unterminatedMultiLineComment,
5252
endOffset - 1,
5353
null,
5454
);
@@ -58,24 +58,24 @@ void translateErrorToken(ErrorToken token, ReportError reportError) {
5858
// TODO(paulberry,ahe): Fasta reports the error location as the entire
5959
// number; analyzer expects the end of the number.
6060
charOffset = endOffset - 1;
61-
return _makeError(ScannerErrorCode.MISSING_DIGIT, null);
61+
return _makeError(ScannerErrorCode.missingDigit, null);
6262

6363
case "MISSING_HEX_DIGIT":
6464
// TODO(paulberry,ahe): Fasta reports the error location as the entire
6565
// number; analyzer expects the end of the number.
6666
charOffset = endOffset - 1;
67-
return _makeError(ScannerErrorCode.MISSING_HEX_DIGIT, null);
67+
return _makeError(ScannerErrorCode.missingHexDigit, null);
6868

6969
case "ILLEGAL_CHARACTER":
7070
// We can safely assume `token.character` is non-`null` because this error
7171
// is only reported when there is a character associated with the token.
72-
return _makeError(ScannerErrorCode.ILLEGAL_CHARACTER, [token.character!]);
72+
return _makeError(ScannerErrorCode.illegalCharacter, [token.character!]);
7373

7474
case "UNEXPECTED_SEPARATOR_IN_NUMBER":
75-
return _makeError(ScannerErrorCode.UNEXPECTED_SEPARATOR_IN_NUMBER, null);
75+
return _makeError(ScannerErrorCode.unexpectedSeparatorInNumber, null);
7676

7777
case "UNSUPPORTED_OPERATOR":
78-
return _makeError(ScannerErrorCode.UNSUPPORTED_OPERATOR, [
78+
return _makeError(ScannerErrorCode.unsupportedOperator, [
7979
(token as UnsupportedOperator).token.lexeme,
8080
]);
8181

@@ -85,19 +85,19 @@ void translateErrorToken(ErrorToken token, ReportError reportError) {
8585
TokenType type = token.begin!.type;
8686
if (type == TokenType.OPEN_CURLY_BRACKET ||
8787
type == TokenType.STRING_INTERPOLATION_EXPRESSION) {
88-
return _makeError(ScannerErrorCode.EXPECTED_TOKEN, ['}']);
88+
return _makeError(ScannerErrorCode.expectedToken, ['}']);
8989
}
9090
if (type == TokenType.OPEN_SQUARE_BRACKET) {
91-
return _makeError(ScannerErrorCode.EXPECTED_TOKEN, [']']);
91+
return _makeError(ScannerErrorCode.expectedToken, [']']);
9292
}
9393
if (type == TokenType.OPEN_PAREN) {
94-
return _makeError(ScannerErrorCode.EXPECTED_TOKEN, [')']);
94+
return _makeError(ScannerErrorCode.expectedToken, [')']);
9595
}
9696
if (type == TokenType.LT) {
97-
return _makeError(ScannerErrorCode.EXPECTED_TOKEN, ['>']);
97+
return _makeError(ScannerErrorCode.expectedToken, ['>']);
9898
}
9999
} else if (errorCode == codeUnexpectedDollarInString) {
100-
return _makeError(ScannerErrorCode.MISSING_IDENTIFIER, null);
100+
return _makeError(ScannerErrorCode.missingIdentifier, null);
101101
}
102102
throw new UnimplementedError(
103103
'$errorCode "${errorCode.analyzerCodes?.first}"',

pkg/_fe_analyzer_shared/lib/src/scanner/errors.g.dart

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,52 +29,52 @@ import "package:_fe_analyzer_shared/src/base/errors.dart";
2929
class ScannerErrorCode extends DiagnosticCode {
3030
/// Parameters:
3131
/// String p0: the token that was expected but not found
32-
static const ScannerErrorCode EXPECTED_TOKEN = const ScannerErrorCode(
32+
static const ScannerErrorCode expectedToken = const ScannerErrorCode(
3333
'EXPECTED_TOKEN',
3434
"Expected to find '{0}'.",
3535
);
3636

3737
/// Parameters:
3838
/// Object p0: the illegal character
39-
static const ScannerErrorCode ILLEGAL_CHARACTER = const ScannerErrorCode(
39+
static const ScannerErrorCode illegalCharacter = const ScannerErrorCode(
4040
'ILLEGAL_CHARACTER',
4141
"Illegal character '{0}'.",
4242
);
4343

4444
/// No parameters.
45-
static const ScannerErrorCode MISSING_DIGIT = const ScannerErrorCode(
45+
static const ScannerErrorCode missingDigit = const ScannerErrorCode(
4646
'MISSING_DIGIT',
4747
"Decimal digit expected.",
4848
);
4949

5050
/// No parameters.
51-
static const ScannerErrorCode MISSING_HEX_DIGIT = const ScannerErrorCode(
51+
static const ScannerErrorCode missingHexDigit = const ScannerErrorCode(
5252
'MISSING_HEX_DIGIT',
5353
"Hexadecimal digit expected.",
5454
);
5555

5656
/// No parameters.
57-
static const ScannerErrorCode MISSING_IDENTIFIER = const ScannerErrorCode(
57+
static const ScannerErrorCode missingIdentifier = const ScannerErrorCode(
5858
'MISSING_IDENTIFIER',
5959
"Expected an identifier.",
6060
);
6161

6262
/// No parameters.
63-
static const ScannerErrorCode MISSING_QUOTE = const ScannerErrorCode(
63+
static const ScannerErrorCode missingQuote = const ScannerErrorCode(
6464
'MISSING_QUOTE',
6565
"Expected quote (' or \").",
6666
);
6767

6868
/// Parameters:
6969
/// Object p0: the path of the file that cannot be read
70-
static const ScannerErrorCode UNABLE_GET_CONTENT = const ScannerErrorCode(
70+
static const ScannerErrorCode unableGetContent = const ScannerErrorCode(
7171
'UNABLE_GET_CONTENT',
7272
"Unable to get content of '{0}'.",
7373
);
7474

7575
/// No parameters.
7676
static const ScannerErrorCode
77-
UNEXPECTED_DOLLAR_IN_STRING = const ScannerErrorCode(
77+
unexpectedDollarInString = const ScannerErrorCode(
7878
'UNEXPECTED_DOLLAR_IN_STRING',
7979
"A '\$' has special meaning inside a string, and must be followed by an "
8080
"identifier or an expression in curly braces ({}).",
@@ -83,7 +83,7 @@ class ScannerErrorCode extends DiagnosticCode {
8383

8484
/// No parameters.
8585
static const ScannerErrorCode
86-
UNEXPECTED_SEPARATOR_IN_NUMBER = const ScannerErrorCode(
86+
unexpectedSeparatorInNumber = const ScannerErrorCode(
8787
'UNEXPECTED_SEPARATOR_IN_NUMBER',
8888
"Digit separators ('_') in a number literal can only be placed between two "
8989
"digits.",
@@ -92,13 +92,13 @@ class ScannerErrorCode extends DiagnosticCode {
9292

9393
/// Parameters:
9494
/// String p0: the unsupported operator
95-
static const ScannerErrorCode UNSUPPORTED_OPERATOR = const ScannerErrorCode(
95+
static const ScannerErrorCode unsupportedOperator = const ScannerErrorCode(
9696
'UNSUPPORTED_OPERATOR',
9797
"The '{0}' operator is not supported.",
9898
);
9999

100100
/// No parameters.
101-
static const ScannerErrorCode UNTERMINATED_MULTI_LINE_COMMENT =
101+
static const ScannerErrorCode unterminatedMultiLineComment =
102102
const ScannerErrorCode(
103103
'UNTERMINATED_MULTI_LINE_COMMENT',
104104
"Unterminated multi-line comment.",
@@ -108,7 +108,7 @@ class ScannerErrorCode extends DiagnosticCode {
108108
);
109109

110110
/// No parameters.
111-
static const ScannerErrorCode UNTERMINATED_STRING_LITERAL =
111+
static const ScannerErrorCode unterminatedStringLiteral =
112112
const ScannerErrorCode(
113113
'UNTERMINATED_STRING_LITERAL',
114114
"Unterminated string literal.",

pkg/analysis_server/lib/src/lsp/mapping.dart

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,19 @@ final completionFilterTextSplitPattern = RegExp(r'=>|[\(]');
5252
final completionSetterTypePattern = RegExp(r'^\((\S+)\s+\S+\)$');
5353

5454
final diagnosticTagsForErrorCode = <String, List<lsp.DiagnosticTag>>{
55-
_diagnosticCode(WarningCode.DEAD_CODE): [lsp.DiagnosticTag.Unnecessary],
56-
_diagnosticCode(HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE): [
55+
_diagnosticCode(WarningCode.deadCode): [lsp.DiagnosticTag.Unnecessary],
56+
_diagnosticCode(HintCode.deprecatedMemberUseFromSamePackage): [
5757
lsp.DiagnosticTag.Deprecated,
5858
],
59-
_diagnosticCode(
60-
HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE_WITH_MESSAGE,
61-
): [lsp.DiagnosticTag.Deprecated],
62-
_diagnosticCode(HintCode.DEPRECATED_MEMBER_USE): [
59+
_diagnosticCode(HintCode.deprecatedMemberUseFromSamePackageWithMessage): [
6360
lsp.DiagnosticTag.Deprecated,
6461
],
62+
_diagnosticCode(HintCode.deprecatedMemberUse): [lsp.DiagnosticTag.Deprecated],
6563
'deprecated_member_use_from_same_package': [lsp.DiagnosticTag.Deprecated],
6664
'deprecated_member_use_from_same_package_with_message': [
6765
lsp.DiagnosticTag.Deprecated,
6866
],
69-
_diagnosticCode(HintCode.DEPRECATED_MEMBER_USE_WITH_MESSAGE): [
67+
_diagnosticCode(HintCode.deprecatedMemberUseWithMessage): [
7068
lsp.DiagnosticTag.Deprecated,
7169
],
7270
};

pkg/analysis_server/lib/src/services/completion/statement/statement_completion.dart

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ class StatementCompletionProcessor {
313313
: null;
314314
}
315315

316-
var expr = diagnosticMatching(ScannerErrorCode.UNTERMINATED_STRING_LITERAL);
316+
var expr = diagnosticMatching(ScannerErrorCode.unterminatedStringLiteral);
317317
if (expr != null) {
318318
var source = utils.getNodeText(expr);
319319
var content = source;
@@ -339,18 +339,15 @@ class StatementCompletionProcessor {
339339
delimiter = content.substring(0, 1);
340340
loc = expr.offset + source.length;
341341
}
342-
_removeError(ScannerErrorCode.UNTERMINATED_STRING_LITERAL);
342+
_removeError(ScannerErrorCode.unterminatedStringLiteral);
343343
_addInsertEdit(loc, delimiter);
344344
}
345345
expr =
346346
diagnosticMatching(
347-
ParserErrorCode.EXPECTED_TOKEN,
347+
ParserErrorCode.expectedToken,
348348
partialMatch: "']'",
349349
) ??
350-
diagnosticMatching(
351-
ScannerErrorCode.EXPECTED_TOKEN,
352-
partialMatch: "']'",
353-
);
350+
diagnosticMatching(ScannerErrorCode.expectedToken, partialMatch: "']'");
354351
if (expr != null) {
355352
expr = expr.thisOrAncestorOfType<ListLiteral>();
356353
if (expr is ListLiteral) {
@@ -363,8 +360,8 @@ class StatementCompletionProcessor {
363360
} else {
364361
_addInsertEdit(loc, ']');
365362
}
366-
_removeError(ParserErrorCode.EXPECTED_TOKEN, partialMatch: "']'");
367-
_removeError(ScannerErrorCode.EXPECTED_TOKEN, partialMatch: "']'");
363+
_removeError(ParserErrorCode.expectedToken, partialMatch: "']'");
364+
_removeError(ScannerErrorCode.expectedToken, partialMatch: "']'");
368365
}
369366
}
370367
}
@@ -436,7 +433,7 @@ class StatementCompletionProcessor {
436433
var delta = 0;
437434
if (diagnostics.isNotEmpty) {
438435
var error = _findDiagnostic(
439-
ParserErrorCode.EXPECTED_TOKEN,
436+
ParserErrorCode.expectedToken,
440437
partialMatch: "';'",
441438
);
442439
if (error != null) {
@@ -752,9 +749,7 @@ class StatementCompletionProcessor {
752749
var needsParen = false;
753750
int computeExitPos(FormalParameterList parameters) {
754751
if (needsParen = parameters.rightParenthesis.isSynthetic) {
755-
var error = _findDiagnostic(
756-
ParserErrorCode.MISSING_CLOSING_PARENTHESIS,
757-
);
752+
var error = _findDiagnostic(ParserErrorCode.missingClosingParenthesis);
758753
if (error != null) {
759754
return error.offset - 1;
760755
}
@@ -794,7 +789,7 @@ class StatementCompletionProcessor {
794789
return false;
795790
}
796791
var error = _findDiagnostic(
797-
ParserErrorCode.EXPECTED_TOKEN,
792+
ParserErrorCode.expectedToken,
798793
partialMatch: "';'",
799794
);
800795
if (error != null) {
@@ -928,8 +923,8 @@ class StatementCompletionProcessor {
928923

929924
bool _complete_methodCall(AstNode node) {
930925
var parenError =
931-
_findDiagnostic(ParserErrorCode.EXPECTED_TOKEN, partialMatch: "')'") ??
932-
_findDiagnostic(ScannerErrorCode.EXPECTED_TOKEN, partialMatch: "')'");
926+
_findDiagnostic(ParserErrorCode.expectedToken, partialMatch: "')'") ??
927+
_findDiagnostic(ScannerErrorCode.expectedToken, partialMatch: "')'");
933928
if (parenError == null) {
934929
return false;
935930
}
@@ -947,7 +942,7 @@ class StatementCompletionProcessor {
947942
var loc = min(selectionOffset, argList.end);
948943
_addInsertEdit(loc, ')');
949944
var semicolonError = _findDiagnostic(
950-
ParserErrorCode.EXPECTED_TOKEN,
945+
ParserErrorCode.expectedToken,
951946
partialMatch: "';'",
952947
);
953948
if (semicolonError != null) {
@@ -982,7 +977,7 @@ class StatementCompletionProcessor {
982977
return false;
983978
}
984979
var error = _findDiagnostic(
985-
ParserErrorCode.EXPECTED_TOKEN,
980+
ParserErrorCode.expectedToken,
986981
partialMatch: "';'",
987982
);
988983
if (error != null) {
@@ -1075,7 +1070,7 @@ class StatementCompletionProcessor {
10751070
if (onKeyword != null && exceptionType != null) {
10761071
if (exceptionType.length == 0 ||
10771072
_findDiagnostic(
1078-
CompileTimeErrorCode.NON_TYPE_IN_CATCH_CLAUSE,
1073+
CompileTimeErrorCode.nonTypeInCatchClause,
10791074
partialMatch: "name 'catch",
10801075
) !=
10811076
null) {

0 commit comments

Comments
 (0)