Skip to content

Commit f3f91ac

Browse files
stereotype441Commit Queue
authored andcommitted
[analyzer] Improve parameter names for recently converted diagnostics.
This addresses code review feedback from Brian in https://dart-review.googlesource.com/c/sdk/+/447060. Change-Id: I6a6a6964eaaccde4e699c0954a751f4fafeb564d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/447403 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Paul Berry <[email protected]>
1 parent 21c0b4a commit f3f91ac

File tree

6 files changed

+39
-31
lines changed

6 files changed

+39
-31
lines changed

pkg/analyzer/lib/src/dart/resolver/method_invocation_resolver.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1026,7 +1026,7 @@ class MethodInvocationResolver with ScopeHelpers {
10261026

10271027
_resolver.diagnosticReporter.report(
10281028
CompileTimeErrorCode.abstractSuperMemberReference
1029-
.withArguments(kind: target.kind.displayName, name: name)
1029+
.withArguments(memberKind: target.kind.displayName, name: name)
10301030
.at(nameNode),
10311031
);
10321032
return null;

pkg/analyzer/lib/src/dart/resolver/property_element_resolver.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,7 @@ class PropertyElementResolver with ScopeHelpers {
945945
diagnosticReporter.report(
946946
CompileTimeErrorCode.abstractSuperMemberReference
947947
.withArguments(
948-
kind: readElement.kind.displayName,
948+
memberKind: readElement.kind.displayName,
949949
name: propertyName.name,
950950
)
951951
.at(propertyName),
@@ -996,7 +996,7 @@ class PropertyElementResolver with ScopeHelpers {
996996
diagnosticReporter.report(
997997
CompileTimeErrorCode.abstractSuperMemberReference
998998
.withArguments(
999-
kind: writeElement.kind.displayName,
999+
memberKind: writeElement.kind.displayName,
10001000
name: propertyName.name,
10011001
)
10021002
.at(propertyName),

pkg/analyzer/lib/src/error/base_or_final_type_verifier.dart

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -240,16 +240,17 @@ class BaseOrFinalTypeVerifier {
240240
superElement.isSealed &&
241241
baseOrFinalSuperElement.library != element.library) {
242242
if (baseOrFinalSuperElement.isBase) {
243-
var errorCode = baseOrFinalSuperElement is MixinElement
243+
var error = baseOrFinalSuperElement is MixinElement
244244
? CompileTimeErrorCode.baseMixinImplementedOutsideOfLibrary
245-
: CompileTimeErrorCode.baseClassImplementedOutsideOfLibrary;
245+
.withArguments(
246+
implementedMixinName: baseOrFinalSuperElement.displayName,
247+
)
248+
: CompileTimeErrorCode.baseClassImplementedOutsideOfLibrary
249+
.withArguments(
250+
implementedClassName: baseOrFinalSuperElement.displayName,
251+
);
246252
_diagnosticReporter.report(
247-
errorCode
248-
.withArguments(
249-
superElementName: baseOrFinalSuperElement.displayName,
250-
)
251-
.withContextMessages(contextMessages)
252-
.at(implementsNamedType),
253+
error.withContextMessages(contextMessages).at(implementsNamedType),
253254
);
254255
return true;
255256
}

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

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,14 @@ class CompileTimeErrorCode extends DiagnosticCodeWithExpectedTypes {
4242
);
4343

4444
/// Parameters:
45-
/// String kind: the display name for the kind of the found abstract member
45+
/// String memberKind: the display name for the kind of the found abstract
46+
/// member
4647
/// String name: the name of the member
4748
static const CompileTimeErrorTemplate<
48-
LocatableDiagnostic Function({required String kind, required String name})
49+
LocatableDiagnostic Function({
50+
required String memberKind,
51+
required String name,
52+
})
4953
>
5054
abstractSuperMemberReference = CompileTimeErrorTemplate(
5155
'ABSTRACT_SUPER_MEMBER_REFERENCE',
@@ -470,9 +474,9 @@ class CompileTimeErrorCode extends DiagnosticCodeWithExpectedTypes {
470474
);
471475

472476
/// Parameters:
473-
/// String superElementName: the name of the base class being implemented
477+
/// String implementedClassName: the name of the base class being implemented
474478
static const CompileTimeErrorTemplate<
475-
LocatableDiagnostic Function({required String superElementName})
479+
LocatableDiagnostic Function({required String implementedClassName})
476480
>
477481
baseClassImplementedOutsideOfLibrary = CompileTimeErrorTemplate(
478482
'INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY',
@@ -485,9 +489,9 @@ class CompileTimeErrorCode extends DiagnosticCodeWithExpectedTypes {
485489
);
486490

487491
/// Parameters:
488-
/// String superElementName: the name of the base mixin being implemented
492+
/// String implementedMixinName: the name of the base mixin being implemented
489493
static const CompileTimeErrorTemplate<
490-
LocatableDiagnostic Function({required String superElementName})
494+
LocatableDiagnostic Function({required String implementedMixinName})
491495
>
492496
baseMixinImplementedOutsideOfLibrary = CompileTimeErrorTemplate(
493497
'INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY',
@@ -8065,10 +8069,13 @@ class CompileTimeErrorCode extends DiagnosticCodeWithExpectedTypes {
80658069
DiagnosticType get type => DiagnosticType.COMPILE_TIME_ERROR;
80668070

80678071
static LocatableDiagnostic _withArgumentsAbstractSuperMemberReference({
8068-
required String kind,
8072+
required String memberKind,
80698073
required String name,
80708074
}) {
8071-
return LocatableDiagnosticImpl(abstractSuperMemberReference, [kind, name]);
8075+
return LocatableDiagnosticImpl(abstractSuperMemberReference, [
8076+
memberKind,
8077+
name,
8078+
]);
80728079
}
80738080

80748081
static LocatableDiagnostic _withArgumentsAmbiguousExport({
@@ -8167,19 +8174,19 @@ class CompileTimeErrorCode extends DiagnosticCodeWithExpectedTypes {
81678174

81688175
static LocatableDiagnostic
81698176
_withArgumentsBaseClassImplementedOutsideOfLibrary({
8170-
required String superElementName,
8177+
required String implementedClassName,
81718178
}) {
81728179
return LocatableDiagnosticImpl(baseClassImplementedOutsideOfLibrary, [
8173-
superElementName,
8180+
implementedClassName,
81748181
]);
81758182
}
81768183

81778184
static LocatableDiagnostic
81788185
_withArgumentsBaseMixinImplementedOutsideOfLibrary({
8179-
required String superElementName,
8186+
required String implementedMixinName,
81808187
}) {
81818188
return LocatableDiagnosticImpl(baseMixinImplementedOutsideOfLibrary, [
8182-
superElementName,
8189+
implementedMixinName,
81838190
]);
81848191
}
81858192

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2152,13 +2152,13 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
21522152
!interfaceElement.isSealed) {
21532153
diagnosticReporter.report(
21542154
CompileTimeErrorCode.baseClassImplementedOutsideOfLibrary
2155-
.withArguments(superElementName: interfaceElement.name!)
2155+
.withArguments(implementedClassName: interfaceElement.name!)
21562156
.at(interface),
21572157
);
21582158
} else if (interfaceElement is MixinElement) {
21592159
diagnosticReporter.report(
21602160
CompileTimeErrorCode.baseMixinImplementedOutsideOfLibrary
2161-
.withArguments(superElementName: interfaceElement.name!)
2161+
.withArguments(implementedMixinName: interfaceElement.name!)
21622162
.at(interface),
21632163
);
21642164
}

pkg/analyzer/messages.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -340,9 +340,9 @@ CompileTimeErrorCode:
340340
hasPublishedDocs: true
341341
ABSTRACT_SUPER_MEMBER_REFERENCE:
342342
parameters:
343-
String kind: the display name for the kind of the found abstract member
343+
String memberKind: the display name for the kind of the found abstract member
344344
String name: the name of the member
345-
problemMessage: "The #kind '#name' is always abstract in the supertype."
345+
problemMessage: "The #memberKind '#name' is always abstract in the supertype."
346346
hasPublishedDocs: true
347347
documentation: |-
348348
#### Description
@@ -1331,9 +1331,9 @@ CompileTimeErrorCode:
13311331
```
13321332
BASE_CLASS_IMPLEMENTED_OUTSIDE_OF_LIBRARY:
13331333
parameters:
1334-
String superElementName: the name of the base class being implemented
1334+
String implementedClassName: the name of the base class being implemented
13351335
sharedName: INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
1336-
problemMessage: "The class '#superElementName' can't be implemented outside of its library because it's a base class."
1336+
problemMessage: "The class '#implementedClassName' can't be implemented outside of its library because it's a base class."
13371337
hasPublishedDocs: true
13381338
documentation: |-
13391339
#### Description
@@ -1383,9 +1383,9 @@ CompileTimeErrorCode:
13831383
```
13841384
BASE_MIXIN_IMPLEMENTED_OUTSIDE_OF_LIBRARY:
13851385
parameters:
1386-
String superElementName: the name of the base mixin being implemented
1386+
String implementedMixinName: the name of the base mixin being implemented
13871387
sharedName: INVALID_USE_OF_TYPE_OUTSIDE_LIBRARY
1388-
problemMessage: "The mixin '#superElementName' can't be implemented outside of its library because it's a base mixin."
1388+
problemMessage: "The mixin '#implementedMixinName' can't be implemented outside of its library because it's a base mixin."
13891389
hasPublishedDocs: true
13901390
BODY_MIGHT_COMPLETE_NORMALLY:
13911391
parameters:

0 commit comments

Comments
 (0)