You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pkg/analyzer/messages.yaml
+91-1Lines changed: 91 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -3879,6 +3879,51 @@ CompileTimeErrorCode:
3879
3879
experiment: dot-shorthands
3880
3880
problemMessage: "A dot shorthand can't be used where there is no context type."
3881
3881
hasPublishedDocs: false
3882
+
documentation: |-
3883
+
#### Description
3884
+
3885
+
The analyzer produces this diagnostic when a dot shorthand is used where
3886
+
there is no context type.
3887
+
3888
+
#### Example
3889
+
3890
+
The following code produces this diagnostic because there is no context
3891
+
type for the expression `.a`:
3892
+
3893
+
```dart
3894
+
void f() {
3895
+
var e = [!.a!];
3896
+
print(e);
3897
+
}
3898
+
3899
+
enum E {a, b}
3900
+
```
3901
+
3902
+
#### Common fixes
3903
+
3904
+
If you want to use a dot shorthand, then add a context type, which in this
3905
+
example means adding the explicit type `E` to the local variable:
3906
+
3907
+
```dart
3908
+
void f() {
3909
+
E e = .a;
3910
+
print(e);
3911
+
}
3912
+
3913
+
enum E {a, b}
3914
+
```
3915
+
3916
+
If you don't want to add a context type, then specify the name of the
3917
+
type containing the member being referenced, which in this case is `E`:
3918
+
3919
+
```dart
3920
+
void f() {
3921
+
var e = E.a;
3922
+
print(e);
3923
+
}
3924
+
3925
+
enum E {a, b}
3926
+
```
3882
3927
DOT_SHORTHAND_UNDEFINED_GETTER:
3883
3928
sharedName: DOT_SHORTHAND_UNDEFINED_MEMBER
3884
3929
experiment: dot-shorthands
@@ -3889,10 +3934,55 @@ CompileTimeErrorCode:
3889
3934
Parameters:
3890
3935
0: the name of the static getter
3891
3936
1: the name of the enclosing type where the getter is being looked for
3937
+
documentation: |-
3938
+
#### Description
3939
+
3940
+
The analyzer produces this diagnostic when a dot shorthand is used to
3941
+
reference a member, but that member doesn't exist.
3942
+
3943
+
#### Example
3944
+
3945
+
The following code produces this diagnostic because the enum `E` doesn't
3946
+
define a static member named `c`:
3947
+
3948
+
```dart
3949
+
void f() {
3950
+
E e = .[!c!];
3951
+
print(e);
3952
+
}
3953
+
3954
+
enum E {a, b}
3955
+
```
3956
+
3957
+
#### Common fixes
3958
+
3959
+
If the name is correct, then define a member with that name in the context
3960
+
type, which in this case is the enum `E`:
3961
+
3962
+
```dart
3963
+
void f() {
3964
+
E e = .c;
3965
+
print(e);
3966
+
}
3967
+
3968
+
enum E {a, b, c}
3969
+
```
3970
+
3971
+
If the name is not correct, then replace the name with the name of an
3972
+
existing member from the context type, which in this case is the enum `E`:
3973
+
3974
+
```dart
3975
+
void f() {
3976
+
E e = .b;
3977
+
print(e);
3978
+
}
3979
+
3980
+
enum E {a, b}
3981
+
```
3892
3982
DOT_SHORTHAND_UNDEFINED_INVOCATION:
3893
3983
sharedName: DOT_SHORTHAND_UNDEFINED_MEMBER
3894
3984
experiment: dot-shorthands
3895
-
problemMessage: "The static method or constructor '{0}' isn't defined for the type '{1}'."
3985
+
problemMessage: "The static method or constructor '{0}' isn't defined for the context type '{1}'."
3896
3986
correctionMessage: "Try correcting the name to the name of an existing static method or constructor, or defining a static method or constructor named '{0}'."
0 commit comments