Skip to content

Commit 4676055

Browse files
srawlinsCommit Queue
authored andcommitted
[analyzer] Move 5 more Hints to be Warnings, INVALID_USE_*
Bug: #50796 Change-Id: Ifd52af7553f4a90a536cafb79584ffc0fa623407 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281741 Reviewed-by: Konstantin Shcheglov <[email protected]> Commit-Queue: Samuel Rawlins <[email protected]>
1 parent 8157a65 commit 4676055

11 files changed

+308
-303
lines changed

pkg/analysis_server/lib/src/services/correction/error_fix_status.yaml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,17 +1441,6 @@ HintCode.INVALID_NON_VIRTUAL_ANNOTATION:
14411441
status: hasFix
14421442
HintCode.INVALID_OVERRIDE_OF_NON_VIRTUAL_MEMBER:
14431443
status: noFix
1444-
HintCode.INVALID_USE_OF_INTERNAL_MEMBER:
1445-
status: noFix
1446-
HintCode.INVALID_USE_OF_PROTECTED_MEMBER:
1447-
status: noFix
1448-
HintCode.INVALID_USE_OF_VISIBLE_FOR_OVERRIDING_MEMBER:
1449-
status: noFix
1450-
since: ~2.15
1451-
HintCode.INVALID_USE_OF_VISIBLE_FOR_TEMPLATE_MEMBER:
1452-
status: noFix
1453-
HintCode.INVALID_USE_OF_VISIBLE_FOR_TESTING_MEMBER:
1454-
status: noFix
14551444
HintCode.INVALID_VISIBILITY_ANNOTATION:
14561445
status: hasFix
14571446
HintCode.INVALID_VISIBLE_FOR_OVERRIDING_ANNOTATION:
@@ -2792,6 +2781,17 @@ WarningCode.INVALID_REQUIRED_POSITIONAL_PARAM:
27922781
status: hasFix
27932782
WarningCode.INVALID_SEALED_ANNOTATION:
27942783
status: hasFix
2784+
WarningCode.INVALID_USE_OF_INTERNAL_MEMBER:
2785+
status: noFix
2786+
WarningCode.INVALID_USE_OF_PROTECTED_MEMBER:
2787+
status: noFix
2788+
WarningCode.INVALID_USE_OF_VISIBLE_FOR_OVERRIDING_MEMBER:
2789+
status: noFix
2790+
since: ~2.15
2791+
WarningCode.INVALID_USE_OF_VISIBLE_FOR_TEMPLATE_MEMBER:
2792+
status: noFix
2793+
WarningCode.INVALID_USE_OF_VISIBLE_FOR_TESTING_MEMBER:
2794+
status: noFix
27952795
WarningCode.NULLABLE_TYPE_IN_CATCH_CLAUSE:
27962796
status: hasFix
27972797
WarningCode.NULL_ARGUMENT_TO_NON_NULL_TYPE:

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

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -271,57 +271,6 @@ class HintCode extends AnalyzerErrorCode {
271271
hasPublishedDocs: true,
272272
);
273273

274-
/// Parameters:
275-
/// 0: the name of the member
276-
static const HintCode INVALID_USE_OF_INTERNAL_MEMBER = HintCode(
277-
'INVALID_USE_OF_INTERNAL_MEMBER',
278-
"The member '{0}' can only be used within its package.",
279-
hasPublishedDocs: true,
280-
);
281-
282-
/// This hint is generated anywhere where a member annotated with `@protected`
283-
/// is used outside of an instance member of a subclass.
284-
///
285-
/// Parameters:
286-
/// 0: the name of the member
287-
/// 1: the name of the defining class
288-
static const HintCode INVALID_USE_OF_PROTECTED_MEMBER = HintCode(
289-
'INVALID_USE_OF_PROTECTED_MEMBER',
290-
"The member '{0}' can only be used within instance members of subclasses "
291-
"of '{1}'.",
292-
);
293-
294-
/// Parameters:
295-
/// 0: the name of the member
296-
static const HintCode INVALID_USE_OF_VISIBLE_FOR_OVERRIDING_MEMBER = HintCode(
297-
'INVALID_USE_OF_VISIBLE_FOR_OVERRIDING_MEMBER',
298-
"The member '{0}' can only be used for overriding.",
299-
hasPublishedDocs: true,
300-
);
301-
302-
/// This hint is generated anywhere where a member annotated with
303-
/// `@visibleForTemplate` is used outside of a "template" Dart file.
304-
///
305-
/// Parameters:
306-
/// 0: the name of the member
307-
/// 1: the name of the defining class
308-
static const HintCode INVALID_USE_OF_VISIBLE_FOR_TEMPLATE_MEMBER = HintCode(
309-
'INVALID_USE_OF_VISIBLE_FOR_TEMPLATE_MEMBER',
310-
"The member '{0}' can only be used within '{1}' or a template library.",
311-
);
312-
313-
/// This hint is generated anywhere where a member annotated with
314-
/// `@visibleForTesting` is used outside the defining library, or a test.
315-
///
316-
/// Parameters:
317-
/// 0: the name of the member
318-
/// 1: the name of the defining class
319-
static const HintCode INVALID_USE_OF_VISIBLE_FOR_TESTING_MEMBER = HintCode(
320-
'INVALID_USE_OF_VISIBLE_FOR_TESTING_MEMBER',
321-
"The member '{0}' can only be used within '{1}' or a test.",
322-
hasPublishedDocs: true,
323-
);
324-
325274
/// This hint is generated anywhere where a private declaration is annotated
326275
/// with `@visibleForTemplate` or `@visibleForTesting`.
327276
///

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2014,7 +2014,7 @@ class _InvalidAccessVerifier {
20142014
}
20152015

20162016
_errorReporter.reportErrorForToken(
2017-
HintCode.INVALID_USE_OF_VISIBLE_FOR_OVERRIDING_MEMBER,
2017+
WarningCode.INVALID_USE_OF_VISIBLE_FOR_OVERRIDING_MEMBER,
20182018
operator,
20192019
[operator.type.lexeme]);
20202020
}
@@ -2028,8 +2028,10 @@ class _InvalidAccessVerifier {
20282028
// `stringValue` is if its string contains an interpolation, in which case
20292029
// the element would never have resolved in the first place. So we can
20302030
// safely assume `node.uri.stringValue` is non-`null`.
2031-
_errorReporter.reportErrorForNode(HintCode.INVALID_USE_OF_INTERNAL_MEMBER,
2032-
node, [node.uri.stringValue!]);
2031+
_errorReporter.reportErrorForNode(
2032+
WarningCode.INVALID_USE_OF_INTERNAL_MEMBER,
2033+
node,
2034+
[node.uri.stringValue!]);
20332035
}
20342036
}
20352037

@@ -2042,7 +2044,7 @@ class _InvalidAccessVerifier {
20422044
if (_hasInternal(element) &&
20432045
!_isLibraryInWorkspacePackage(element!.library)) {
20442046
_errorReporter.reportErrorForNode(
2045-
HintCode.INVALID_USE_OF_INTERNAL_MEMBER, node, [element.name]);
2047+
WarningCode.INVALID_USE_OF_INTERNAL_MEMBER, node, [element.name]);
20462048
}
20472049
}
20482050

@@ -2064,7 +2066,7 @@ class _InvalidAccessVerifier {
20642066
}
20652067

20662068
_errorReporter.reportErrorForNode(
2067-
HintCode.INVALID_USE_OF_INTERNAL_MEMBER, node, [name]);
2069+
WarningCode.INVALID_USE_OF_INTERNAL_MEMBER, node, [name]);
20682070
}
20692071
}
20702072

@@ -2114,20 +2116,20 @@ class _InvalidAccessVerifier {
21142116
var definingClass = element.enclosingElement;
21152117
if (hasProtected) {
21162118
_errorReporter.reportErrorForNode(
2117-
HintCode.INVALID_USE_OF_PROTECTED_MEMBER,
2119+
WarningCode.INVALID_USE_OF_PROTECTED_MEMBER,
21182120
node,
21192121
[name, definingClass!.source!.uri]);
21202122
}
21212123
if (hasVisibleForTemplate) {
21222124
_errorReporter.reportErrorForNode(
2123-
HintCode.INVALID_USE_OF_VISIBLE_FOR_TEMPLATE_MEMBER,
2125+
WarningCode.INVALID_USE_OF_VISIBLE_FOR_TEMPLATE_MEMBER,
21242126
node,
21252127
[name, definingClass!.source!.uri]);
21262128
}
21272129

21282130
if (hasVisibleForTesting) {
21292131
_errorReporter.reportErrorForNode(
2130-
HintCode.INVALID_USE_OF_VISIBLE_FOR_TESTING_MEMBER,
2132+
WarningCode.INVALID_USE_OF_VISIBLE_FOR_TESTING_MEMBER,
21312133
node,
21322134
[name, definingClass!.source!.uri]);
21332135
}
@@ -2145,7 +2147,7 @@ class _InvalidAccessVerifier {
21452147
}
21462148
if (!validOverride) {
21472149
_errorReporter.reportErrorForNode(
2148-
HintCode.INVALID_USE_OF_VISIBLE_FOR_OVERRIDING_MEMBER,
2150+
WarningCode.INVALID_USE_OF_VISIBLE_FOR_OVERRIDING_MEMBER,
21492151
node,
21502152
[name]);
21512153
}

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

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6119,6 +6119,60 @@ class WarningCode extends AnalyzerErrorCode {
61196119
hasPublishedDocs: true,
61206120
);
61216121

6122+
/// Parameters:
6123+
/// 0: the name of the member
6124+
static const WarningCode INVALID_USE_OF_INTERNAL_MEMBER = WarningCode(
6125+
'INVALID_USE_OF_INTERNAL_MEMBER',
6126+
"The member '{0}' can only be used within its package.",
6127+
hasPublishedDocs: true,
6128+
);
6129+
6130+
/// This hint is generated anywhere where a member annotated with `@protected`
6131+
/// is used outside of an instance member of a subclass.
6132+
///
6133+
/// Parameters:
6134+
/// 0: the name of the member
6135+
/// 1: the name of the defining class
6136+
static const WarningCode INVALID_USE_OF_PROTECTED_MEMBER = WarningCode(
6137+
'INVALID_USE_OF_PROTECTED_MEMBER',
6138+
"The member '{0}' can only be used within instance members of subclasses "
6139+
"of '{1}'.",
6140+
);
6141+
6142+
/// Parameters:
6143+
/// 0: the name of the member
6144+
static const WarningCode INVALID_USE_OF_VISIBLE_FOR_OVERRIDING_MEMBER =
6145+
WarningCode(
6146+
'INVALID_USE_OF_VISIBLE_FOR_OVERRIDING_MEMBER',
6147+
"The member '{0}' can only be used for overriding.",
6148+
hasPublishedDocs: true,
6149+
);
6150+
6151+
/// This hint is generated anywhere where a member annotated with
6152+
/// `@visibleForTemplate` is used outside of a "template" Dart file.
6153+
///
6154+
/// Parameters:
6155+
/// 0: the name of the member
6156+
/// 1: the name of the defining class
6157+
static const WarningCode INVALID_USE_OF_VISIBLE_FOR_TEMPLATE_MEMBER =
6158+
WarningCode(
6159+
'INVALID_USE_OF_VISIBLE_FOR_TEMPLATE_MEMBER',
6160+
"The member '{0}' can only be used within '{1}' or a template library.",
6161+
);
6162+
6163+
/// This hint is generated anywhere where a member annotated with
6164+
/// `@visibleForTesting` is used outside the defining library, or a test.
6165+
///
6166+
/// Parameters:
6167+
/// 0: the name of the member
6168+
/// 1: the name of the defining class
6169+
static const WarningCode INVALID_USE_OF_VISIBLE_FOR_TESTING_MEMBER =
6170+
WarningCode(
6171+
'INVALID_USE_OF_VISIBLE_FOR_TESTING_MEMBER',
6172+
"The member '{0}' can only be used within '{1}' or a test.",
6173+
hasPublishedDocs: true,
6174+
);
6175+
61226176
/// This is the new replacement for [HintCode.NON_CONST_CALL_TO_LITERAL_CONSTRUCTOR].
61236177
static const HintCode NON_CONST_CALL_TO_LITERAL_CONSTRUCTOR =
61246178
HintCode.NON_CONST_CALL_TO_LITERAL_CONSTRUCTOR;

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -599,11 +599,6 @@ const List<ErrorCode> errorCodeValues = [
599599
HintCode.INVALID_LITERAL_ANNOTATION,
600600
HintCode.INVALID_NON_VIRTUAL_ANNOTATION,
601601
HintCode.INVALID_OVERRIDE_OF_NON_VIRTUAL_MEMBER,
602-
HintCode.INVALID_USE_OF_INTERNAL_MEMBER,
603-
HintCode.INVALID_USE_OF_PROTECTED_MEMBER,
604-
HintCode.INVALID_USE_OF_VISIBLE_FOR_OVERRIDING_MEMBER,
605-
HintCode.INVALID_USE_OF_VISIBLE_FOR_TEMPLATE_MEMBER,
606-
HintCode.INVALID_USE_OF_VISIBLE_FOR_TESTING_MEMBER,
607602
HintCode.INVALID_VISIBILITY_ANNOTATION,
608603
HintCode.INVALID_VISIBLE_FOR_OVERRIDING_ANNOTATION,
609604
HintCode.MISSING_OVERRIDE_OF_MUST_BE_OVERRIDDEN_ONE,
@@ -975,6 +970,11 @@ const List<ErrorCode> errorCodeValues = [
975970
WarningCode.INVALID_REQUIRED_OPTIONAL_POSITIONAL_PARAM,
976971
WarningCode.INVALID_REQUIRED_POSITIONAL_PARAM,
977972
WarningCode.INVALID_SEALED_ANNOTATION,
973+
WarningCode.INVALID_USE_OF_INTERNAL_MEMBER,
974+
WarningCode.INVALID_USE_OF_PROTECTED_MEMBER,
975+
WarningCode.INVALID_USE_OF_VISIBLE_FOR_OVERRIDING_MEMBER,
976+
WarningCode.INVALID_USE_OF_VISIBLE_FOR_TEMPLATE_MEMBER,
977+
WarningCode.INVALID_USE_OF_VISIBLE_FOR_TESTING_MEMBER,
978978
WarningCode.NULLABLE_TYPE_IN_CATCH_CLAUSE,
979979
WarningCode.NULL_ARGUMENT_TO_NON_NULL_TYPE,
980980
WarningCode.NULL_AWARE_BEFORE_OPERATOR,

0 commit comments

Comments
 (0)