Skip to content

Commit 21f0f4e

Browse files
bwilkersonCommit Queue
authored andcommitted
Add documentation for a few warnings
Change-Id: I10ad9f7a980b6559e5e906028741ea7fbde814ae Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433960 Commit-Queue: Brian Wilkerson <[email protected]> Reviewed-by: Samuel Rawlins <[email protected]> Reviewed-by: Amanda Fitch <[email protected]>
1 parent d353937 commit 21f0f4e

File tree

1 file changed

+246
-0
lines changed

1 file changed

+246
-0
lines changed

pkg/analyzer/messages.yaml

Lines changed: 246 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24144,18 +24144,124 @@ WarningCode:
2414424144
problemMessage: "Doc imports can't be deferred."
2414524145
correctionMessage: Try removing the 'deferred' keyword.
2414624146
hasPublishedDocs: false
24147+
documentation: |-
24148+
#### Description
24149+
24150+
The analyzer produces this diagnostic when a documentation import uses the
24151+
`deferred` keyword.
24152+
24153+
Documentation imports can't be deferred because deferring them wouldn't
24154+
impact the size of the compiled code.
24155+
24156+
#### Example
24157+
24158+
The following code produces this diagnostic because the documentation
24159+
import has a `deferred` keyword:
24160+
24161+
```dart
24162+
// ignore:missing_prefix_in_deferred_import
24163+
/// @docImport 'package:meta/meta.dart' [!deferred!];
24164+
library;
24165+
```
24166+
24167+
#### Common fixes
24168+
24169+
Remove the `deferred` keyword:
24170+
24171+
```dart
24172+
/// @docImport 'package:meta/meta.dart';
24173+
library;
24174+
```
2414724175
DOC_IMPORT_CANNOT_HAVE_COMBINATORS:
2414824176
problemMessage: "Doc imports can't have show or hide combinators."
2414924177
correctionMessage: Try removing the combinator.
2415024178
hasPublishedDocs: false
24179+
documentation: |-
24180+
#### Description
24181+
24182+
The analyzer produces this diagnostic when a documentation import has one
24183+
or more `hide` or `show` combinators.
24184+
24185+
Using combinators isn't supported for documentation imports.
24186+
24187+
#### Example
24188+
24189+
The following code produces this diagnostic because the documentation
24190+
import has a `show` combinator:
24191+
24192+
```dart
24193+
/// @docImport 'package:meta/meta.dart' [!show max!];
24194+
library;
24195+
```
24196+
24197+
#### Common fixes
24198+
24199+
Remove the `hide` and `show` combinators:
24200+
24201+
```dart
24202+
/// @docImport 'package:meta/meta.dart';
24203+
library;
24204+
```
2415124205
DOC_IMPORT_CANNOT_HAVE_CONFIGURATIONS:
2415224206
problemMessage: "Doc imports can't have configurations."
2415324207
correctionMessage: Try removing the configurations.
2415424208
hasPublishedDocs: false
24209+
documentation: |-
24210+
#### Description
24211+
24212+
The analyzer produces this diagnostic when a documentation import has one
24213+
or more `if` clauses.
24214+
24215+
Documentation imports aren't configurable.
24216+
24217+
#### Example
24218+
24219+
The following code produces this diagnostic because the documentation
24220+
import has an `if` clause:
24221+
24222+
```dart
24223+
/// @docImport 'package:meta/meta.dart' [!if (dart.library.io) 'dart:io'!];
24224+
library;
24225+
```
24226+
24227+
#### Common fixes
24228+
24229+
Remove the `if` clauses:
24230+
24231+
```dart
24232+
/// @docImport 'package:meta/meta.dart';
24233+
library;
24234+
```
2415524235
DOC_IMPORT_CANNOT_HAVE_PREFIX:
2415624236
problemMessage: "Doc imports can't have prefixes."
2415724237
correctionMessage: Try removing the prefix.
2415824238
hasPublishedDocs: false
24239+
documentation: |-
24240+
#### Description
24241+
24242+
The analyzer produces this diagnostic when a documentation import has a
24243+
prefix.
24244+
24245+
Using prefixes isn't supported for documentation imports.
24246+
24247+
#### Example
24248+
24249+
The following code produces this diagnostic because the documentation
24250+
import declares a prefix:
24251+
24252+
```dart
24253+
/// @docImport 'package:meta/meta.dart' as [!a!];
24254+
library;
24255+
```
24256+
24257+
#### Common fixes
24258+
24259+
Remove the prefix:
24260+
24261+
```dart
24262+
/// @docImport 'package:meta/meta.dart';
24263+
library;
24264+
```
2415924265
DUPLICATE_EXPORT:
2416024266
problemMessage: Duplicate export.
2416124267
correctionMessage: Try removing all but one export of the library.
@@ -25240,6 +25346,47 @@ WarningCode:
2524025346
Parameters:
2524125347
0: the name of the member
2524225348
1: the name of the defining class
25349+
documentation: |-
25350+
#### Description
25351+
25352+
The analyzer produces this diagnostic when a getter, setter, field, or
25353+
method that has been annotated with `@protected` is referenced anywhere
25354+
other than in the library in which it is declared or in a subclass of the
25355+
class in which it is declared.
25356+
25357+
#### Example
25358+
25359+
Given a file `a.dart` that contains
25360+
25361+
```dart
25362+
%uri="lib/a.dart"
25363+
import 'package:meta/meta.dart';
25364+
25365+
class A {
25366+
@protected
25367+
void a() {}
25368+
}
25369+
```
25370+
25371+
The following code produces this diagnostic because the method `a` is
25372+
being invoked in code that isn't in a subclass of `A`:
25373+
25374+
```dart
25375+
import 'a.dart';
25376+
25377+
void b(A a) {
25378+
a.[!a!]();
25379+
}
25380+
```
25381+
25382+
#### Common fixes
25383+
25384+
If it's reasonable for the member to be marked as `@protected`, then
25385+
remove the reference to the protected member, replacing it with some
25386+
equivalent code.
25387+
25388+
If it isn't reasonable for the member to be marked as `@protected`, and
25389+
you have the ability to do so, remove the annotation.
2524325390
INVALID_USE_OF_VISIBLE_FOR_OVERRIDING_MEMBER:
2524425391
problemMessage: "The member '{0}' can only be used for overriding."
2524525392
hasPublishedDocs: true
@@ -25578,6 +25725,49 @@ WarningCode:
2557825725
did not reopen any type.
2557925726

2558025727
No parameters.
25728+
documentation: |-
25729+
#### Description
25730+
25731+
The analyzer produces this diagnostic when a `@reopen` annotation has been
25732+
placed on a class or mixin that does not remove restrictions placed on the
25733+
superclass.
25734+
25735+
#### Example
25736+
25737+
The following code produces this diagnostic because the class `B` is
25738+
annotated with `@reopen` even though it doesn't expand the ability of `A`
25739+
to be subclassed:
25740+
25741+
```dart
25742+
import 'package:meta/meta.dart';
25743+
25744+
sealed class A {}
25745+
25746+
@[!reopen!]
25747+
class B extends A {}
25748+
```
25749+
25750+
#### Common fixes
25751+
25752+
If the superclass should be restricted in a way that the subclass would
25753+
change, then modify the superclass to reflect those restrictions:
25754+
25755+
```dart
25756+
import 'package:meta/meta.dart';
25757+
25758+
interface class A {}
25759+
25760+
@reopen
25761+
class B extends A {}
25762+
```
25763+
25764+
If the superclass is correct, then remove the annotation:
25765+
25766+
```dart
25767+
sealed class A {}
25768+
25769+
class B extends A {}
25770+
```
2558125771
INVALID_SEALED_ANNOTATION:
2558225772
removedIn: "3.5"
2558325773
problemMessage: "The annotation '@sealed' can only be applied to classes."
@@ -26228,6 +26418,36 @@ WarningCode:
2622826418
correctionMessage: Try using a non-nullable type.
2622926419
hasPublishedDocs: false
2623026420
comment: No parameters.
26421+
documentation: |-
26422+
#### Description
26423+
26424+
The analyzer produces this diagnostic when an override of the operator
26425+
`==` has a parameter whose type is nullable. The language spec makes it
26426+
impossible for the argument of the method to be `null`, and the
26427+
parameter's type should reflect that.
26428+
26429+
#### Example
26430+
26431+
The following code produces this diagnostic because the implementation of
26432+
the operator `==` in `C` :
26433+
26434+
```dart
26435+
class C {
26436+
@override
26437+
bool operator [!==!](Object? other) => false;
26438+
}
26439+
```
26440+
26441+
#### Common fixes
26442+
26443+
Make the parameter type be non-nullable:
26444+
26445+
```dart
26446+
class C {
26447+
@override
26448+
bool operator ==(Object other) => false;
26449+
}
26450+
```
2623126451
NULLABLE_TYPE_IN_CATCH_CLAUSE:
2623226452
problemMessage: "A potentially nullable type can't be used in an 'on' clause because it isn't valid to throw a nullable expression."
2623326453
correctionMessage: Try using a non-nullable type.
@@ -27939,6 +28159,32 @@ WarningCode:
2793928159
correctionMessage: Try removing the wildcard pattern.
2794028160
hasPublishedDocs: false
2794128161
comment: No parameters.
28162+
documentation: |-
28163+
#### Description
28164+
28165+
The analyzer produces this diagnostic when a wildcard pattern is used in
28166+
either an and (`&&`) pattern or an or (`||`) pattern.
28167+
28168+
#### Example
28169+
28170+
The following code produces this diagnostic because the wildcard pattern
28171+
(`_`) will always succeed, making it's use in an and pattern unnecessary:
28172+
28173+
```dart
28174+
void f(Object? x) {
28175+
if (x case [!_!] && 0) {}
28176+
}
28177+
```
28178+
28179+
#### Common fixes
28180+
28181+
Remove the use of the wildcard pattern:
28182+
28183+
```dart
28184+
void f(Object? x) {
28185+
if (x case 0) {}
28186+
}
28187+
```
2794228188
UNREACHABLE_SWITCH_CASE:
2794328189
problemMessage: "This case is covered by the previous cases."
2794428190
correctionMessage: Try removing the case clause, or restructuring the preceding patterns.

0 commit comments

Comments
 (0)