Skip to content

Commit b888cb7

Browse files
stereotype441Commit Queue
authored andcommitted
[messages] Convert builtInIdentifierAs...Name to use literate diagnostic API.
Converts the code that reports the diagnostic codes `builtInIdentifierAsExtensionName`, `builtInIdentifierAsExtensionTypeName`, `builtInIdentifierAsPrefixName`, `builtInIdentifierAsTypedefName`, `builtInIdentifierAsTypeName`, and `builtInIdentifierAsTypeParameterName` to use the literate diagnostic reporting API. Change-Id: I6a6a69646530d4def48a6382d7d4ce6d4c30415a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/467720 Commit-Queue: Paul Berry <paulberry@google.com> Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Reviewed-by: Johnni Winther <johnniwinther@google.com>
1 parent ace5af0 commit b888cb7

File tree

3 files changed

+47
-38
lines changed

3 files changed

+47
-38
lines changed

pkg/analyzer/lib/src/diagnostic/diagnostic.g.dart

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,9 +1172,9 @@ breakOutsideOfLoop = DiagnosticWithoutArgumentsImpl(
11721172
);
11731173

11741174
/// Parameters:
1175-
/// String p0: the built-in identifier that is being used
1175+
/// String name: the built-in identifier that is being used
11761176
const DiagnosticWithArguments<
1177-
LocatableDiagnostic Function({required String p0})
1177+
LocatableDiagnostic Function({required String name})
11781178
>
11791179
builtInIdentifierAsExtensionName = DiagnosticWithArguments(
11801180
name: 'built_in_identifier_in_declaration',
@@ -1189,9 +1189,9 @@ builtInIdentifierAsExtensionName = DiagnosticWithArguments(
11891189
);
11901190

11911191
/// Parameters:
1192-
/// String p0: the built-in identifier that is being used
1192+
/// String name: the built-in identifier that is being used
11931193
const DiagnosticWithArguments<
1194-
LocatableDiagnostic Function({required String p0})
1194+
LocatableDiagnostic Function({required String name})
11951195
>
11961196
builtInIdentifierAsExtensionTypeName = DiagnosticWithArguments(
11971197
name: 'built_in_identifier_in_declaration',
@@ -1206,9 +1206,9 @@ builtInIdentifierAsExtensionTypeName = DiagnosticWithArguments(
12061206
);
12071207

12081208
/// Parameters:
1209-
/// String p0: the built-in identifier that is being used
1209+
/// String name: the built-in identifier that is being used
12101210
const DiagnosticWithArguments<
1211-
LocatableDiagnostic Function({required String p0})
1211+
LocatableDiagnostic Function({required String name})
12121212
>
12131213
builtInIdentifierAsPrefixName = DiagnosticWithArguments(
12141214
name: 'built_in_identifier_in_declaration',
@@ -1239,9 +1239,9 @@ builtInIdentifierAsType = DiagnosticWithArguments(
12391239
);
12401240

12411241
/// Parameters:
1242-
/// String p0: the built-in identifier that is being used
1242+
/// String name: the built-in identifier that is being used
12431243
const DiagnosticWithArguments<
1244-
LocatableDiagnostic Function({required String p0})
1244+
LocatableDiagnostic Function({required String name})
12451245
>
12461246
builtInIdentifierAsTypedefName = DiagnosticWithArguments(
12471247
name: 'built_in_identifier_in_declaration',
@@ -1256,9 +1256,9 @@ builtInIdentifierAsTypedefName = DiagnosticWithArguments(
12561256
);
12571257

12581258
/// Parameters:
1259-
/// String p0: the built-in identifier that is being used
1259+
/// String name: the built-in identifier that is being used
12601260
const DiagnosticWithArguments<
1261-
LocatableDiagnostic Function({required String p0})
1261+
LocatableDiagnostic Function({required String name})
12621262
>
12631263
builtInIdentifierAsTypeName = DiagnosticWithArguments(
12641264
name: 'built_in_identifier_in_declaration',
@@ -1272,9 +1272,9 @@ builtInIdentifierAsTypeName = DiagnosticWithArguments(
12721272
);
12731273

12741274
/// Parameters:
1275-
/// String p0: the built-in identifier that is being used
1275+
/// String name: the built-in identifier that is being used
12761276
const DiagnosticWithArguments<
1277-
LocatableDiagnostic Function({required String p0})
1277+
LocatableDiagnostic Function({required String name})
12781278
>
12791279
builtInIdentifierAsTypeParameterName = DiagnosticWithArguments(
12801280
name: 'built_in_identifier_in_declaration',
@@ -17927,23 +17927,23 @@ LocatableDiagnostic _withArgumentsBodyMightCompleteNormallyNullable({
1792717927
}
1792817928

1792917929
LocatableDiagnostic _withArgumentsBuiltInIdentifierAsExtensionName({
17930-
required String p0,
17930+
required String name,
1793117931
}) {
17932-
return LocatableDiagnosticImpl(diag.builtInIdentifierAsExtensionName, [p0]);
17932+
return LocatableDiagnosticImpl(diag.builtInIdentifierAsExtensionName, [name]);
1793317933
}
1793417934

1793517935
LocatableDiagnostic _withArgumentsBuiltInIdentifierAsExtensionTypeName({
17936-
required String p0,
17936+
required String name,
1793717937
}) {
1793817938
return LocatableDiagnosticImpl(diag.builtInIdentifierAsExtensionTypeName, [
17939-
p0,
17939+
name,
1794017940
]);
1794117941
}
1794217942

1794317943
LocatableDiagnostic _withArgumentsBuiltInIdentifierAsPrefixName({
17944-
required String p0,
17944+
required String name,
1794517945
}) {
17946-
return LocatableDiagnosticImpl(diag.builtInIdentifierAsPrefixName, [p0]);
17946+
return LocatableDiagnosticImpl(diag.builtInIdentifierAsPrefixName, [name]);
1794717947
}
1794817948

1794917949
LocatableDiagnostic _withArgumentsBuiltInIdentifierAsType({
@@ -17953,22 +17953,22 @@ LocatableDiagnostic _withArgumentsBuiltInIdentifierAsType({
1795317953
}
1795417954

1795517955
LocatableDiagnostic _withArgumentsBuiltInIdentifierAsTypedefName({
17956-
required String p0,
17956+
required String name,
1795717957
}) {
17958-
return LocatableDiagnosticImpl(diag.builtInIdentifierAsTypedefName, [p0]);
17958+
return LocatableDiagnosticImpl(diag.builtInIdentifierAsTypedefName, [name]);
1795917959
}
1796017960

1796117961
LocatableDiagnostic _withArgumentsBuiltInIdentifierAsTypeName({
17962-
required String p0,
17962+
required String name,
1796317963
}) {
17964-
return LocatableDiagnosticImpl(diag.builtInIdentifierAsTypeName, [p0]);
17964+
return LocatableDiagnosticImpl(diag.builtInIdentifierAsTypeName, [name]);
1796517965
}
1796617966

1796717967
LocatableDiagnostic _withArgumentsBuiltInIdentifierAsTypeParameterName({
17968-
required String p0,
17968+
required String name,
1796917969
}) {
1797017970
return LocatableDiagnosticImpl(diag.builtInIdentifierAsTypeParameterName, [
17971-
p0,
17971+
name,
1797217972
]);
1797317973
}
1797417974

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import 'package:analyzer/src/dart/resolver/scope.dart';
3636
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
3737
import 'package:analyzer/src/diagnostic/diagnostic_factory.dart';
3838
import 'package:analyzer/src/diagnostic/diagnostic_message.dart';
39+
import 'package:analyzer/src/error/codes.dart';
3940
import 'package:analyzer/src/error/const_argument_verifier.dart';
4041
import 'package:analyzer/src/error/constructor_fields_verifier.dart';
4142
import 'package:analyzer/src/error/correct_override.dart';
@@ -2152,9 +2153,17 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
21522153
/// [diag.builtInIdentifierAsTypeName],
21532154
/// [diag.builtInIdentifierAsTypeParameterName], and
21542155
/// [diag.builtInIdentifierAsTypedefName].
2155-
void _checkForBuiltInIdentifierAsName(Token token, DiagnosticCode code) {
2156+
void _checkForBuiltInIdentifierAsName(
2157+
Token token,
2158+
DiagnosticWithArguments<
2159+
LocatableDiagnostic Function({required String name})
2160+
>
2161+
code,
2162+
) {
21562163
if (token.type.isKeyword && token.keyword?.isPseudo != true) {
2157-
diagnosticReporter.atToken(token, code, arguments: [token.lexeme]);
2164+
diagnosticReporter.report(
2165+
code.withArguments(name: token.lexeme).at(token),
2166+
);
21582167
}
21592168
}
21602169

pkg/analyzer/messages.yaml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2214,9 +2214,9 @@ CompileTimeErrorCode:
22142214
builtInIdentifierAsExtensionName:
22152215
type: compileTimeError
22162216
parameters:
2217-
String p0: the built-in identifier that is being used
2217+
String name: the built-in identifier that is being used
22182218
sharedName: builtInIdentifierInDeclaration
2219-
problemMessage: "The built-in identifier '#p0' can't be used as an extension name."
2219+
problemMessage: "The built-in identifier '#name' can't be used as an extension name."
22202220
correctionMessage: Try choosing a different name for the extension.
22212221
hasPublishedDocs: true
22222222
documentation: |-
@@ -2242,41 +2242,41 @@ CompileTimeErrorCode:
22422242
builtInIdentifierAsExtensionTypeName:
22432243
type: compileTimeError
22442244
parameters:
2245-
String p0: the built-in identifier that is being used
2245+
String name: the built-in identifier that is being used
22462246
sharedName: builtInIdentifierInDeclaration
2247-
problemMessage: "The built-in identifier '#p0' can't be used as an extension type name."
2247+
problemMessage: "The built-in identifier '#name' can't be used as an extension type name."
22482248
correctionMessage: Try choosing a different name for the extension type.
22492249
hasPublishedDocs: true
22502250
builtInIdentifierAsPrefixName:
22512251
type: compileTimeError
22522252
parameters:
2253-
String p0: the built-in identifier that is being used
2253+
String name: the built-in identifier that is being used
22542254
sharedName: builtInIdentifierInDeclaration
2255-
problemMessage: "The built-in identifier '#p0' can't be used as a prefix name."
2255+
problemMessage: "The built-in identifier '#name' can't be used as a prefix name."
22562256
correctionMessage: Try choosing a different name for the prefix.
22572257
hasPublishedDocs: true
22582258
builtInIdentifierAsTypeName:
22592259
type: compileTimeError
22602260
parameters:
2261-
String p0: the built-in identifier that is being used
2261+
String name: the built-in identifier that is being used
22622262
sharedName: builtInIdentifierInDeclaration
2263-
problemMessage: "The built-in identifier '#p0' can't be used as a type name."
2263+
problemMessage: "The built-in identifier '#name' can't be used as a type name."
22642264
correctionMessage: Try choosing a different name for the type.
22652265
hasPublishedDocs: true
22662266
builtInIdentifierAsTypeParameterName:
22672267
type: compileTimeError
22682268
parameters:
2269-
String p0: the built-in identifier that is being used
2269+
String name: the built-in identifier that is being used
22702270
sharedName: builtInIdentifierInDeclaration
2271-
problemMessage: "The built-in identifier '#p0' can't be used as a type parameter name."
2271+
problemMessage: "The built-in identifier '#name' can't be used as a type parameter name."
22722272
correctionMessage: Try choosing a different name for the type parameter.
22732273
hasPublishedDocs: true
22742274
builtInIdentifierAsTypedefName:
22752275
type: compileTimeError
22762276
parameters:
2277-
String p0: the built-in identifier that is being used
2277+
String name: the built-in identifier that is being used
22782278
sharedName: builtInIdentifierInDeclaration
2279-
problemMessage: "The built-in identifier '#p0' can't be used as a typedef name."
2279+
problemMessage: "The built-in identifier '#name' can't be used as a typedef name."
22802280
correctionMessage: Try choosing a different name for the typedef.
22812281
hasPublishedDocs: true
22822282
caseBlockNotTerminated:

0 commit comments

Comments
 (0)