File tree 5 files changed +60
-4
lines changed
lib/src/services/correction
test/src/services/correction 5 files changed +60
-4
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,9 @@ class ReplaceIfElseWithConditional extends CorrectionProducer {
22
22
return ;
23
23
}
24
24
var ifStatement = node as IfStatement ;
25
+ if (ifStatement.caseClause != null ) {
26
+ return ;
27
+ }
25
28
// single then/else statements
26
29
var thenStatement = getSingleStatement (ifStatement.thenStatement);
27
30
var elseStatement = getSingleStatement (ifStatement.elseStatement);
Original file line number Diff line number Diff line change @@ -1193,7 +1193,7 @@ CompileTimeErrorCode.VALUES_DECLARATION_IN_ENUM:
1193
1193
to think about what they were trying to do and it seems more likely that the
1194
1194
right fix is to rename the member.
1195
1195
CompileTimeErrorCode.VARIABLE_PATTERN_KEYWORD_IN_DECLARATION_CONTEXT :
1196
- status : needsEvaluation
1196
+ status : hasFix
1197
1197
CompileTimeErrorCode.VARIABLE_TYPE_MISMATCH :
1198
1198
status : needsEvaluation
1199
1199
CompileTimeErrorCode.WRONG_EXPLICIT_TYPE_PARAMETER_VARIANCE_IN_SUPERINTERFACE :
Original file line number Diff line number Diff line change @@ -961,6 +961,9 @@ class FixProcessor extends BaseProcessor {
961
961
CompileTimeErrorCode .CONST_WITH_NON_TYPE : [
962
962
ChangeTo .classOrMixin,
963
963
],
964
+ CompileTimeErrorCode .CONSTANT_PATTERN_WITH_NON_CONSTANT_EXPRESSION : [
965
+ AddConst .new ,
966
+ ],
964
967
CompileTimeErrorCode .DEFAULT_VALUE_ON_REQUIRED_PARAMETER : [
965
968
RemoveDefaultValue .new ,
966
969
RemoveRequired .new ,
@@ -1299,16 +1302,16 @@ class FixProcessor extends BaseProcessor {
1299
1302
CompileTimeErrorCode .URI_DOES_NOT_EXIST : [
1300
1303
CreateFile .new ,
1301
1304
],
1305
+ CompileTimeErrorCode .VARIABLE_PATTERN_KEYWORD_IN_DECLARATION_CONTEXT : [
1306
+ RemoveVar .new ,
1307
+ ],
1302
1308
CompileTimeErrorCode .WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR : [
1303
1309
MoveTypeArgumentsToClass .new ,
1304
1310
RemoveTypeArguments .new ,
1305
1311
],
1306
1312
CompileTimeErrorCode .YIELD_OF_INVALID_TYPE : [
1307
1313
MakeReturnTypeNullable .new ,
1308
1314
],
1309
- CompileTimeErrorCode .CONSTANT_PATTERN_WITH_NON_CONSTANT_EXPRESSION : [
1310
- AddConst .new ,
1311
- ],
1312
1315
FfiCode .SUBTYPE_OF_FFI_CLASS_IN_EXTENDS : [
1313
1316
RemoveNameFromDeclarationClause .new ,
1314
1317
],
Original file line number Diff line number Diff line change @@ -51,6 +51,21 @@ void f() {
51
51
await assertNoAssistAt ('else' );
52
52
}
53
53
54
+ Future <void > test_ifCasePattern () async {
55
+ await resolveTestCode ('''
56
+ f() {
57
+ var json = [1, 2, 3];
58
+ int vvv;
59
+ if (json case [3, 4]) {
60
+ vvv = 111;
61
+ } else {
62
+ vvv = 222;
63
+ }
64
+ }
65
+ ''' );
66
+ await assertNoAssistAt ('if (json case [3, 4])' );
67
+ }
68
+
54
69
Future <void > test_notIfStatement () async {
55
70
await resolveTestCode ('''
56
71
void f() {
Original file line number Diff line number Diff line change @@ -29,6 +29,41 @@ f() {}
29
29
''' );
30
30
}
31
31
32
+ Future <void > test_pattern_declaration () async {
33
+ await resolveTestCode ('''
34
+ f() {
35
+ var [var x] = [1];
36
+ print(x);
37
+ }
38
+ ''' );
39
+ await assertHasFix ('''
40
+ f() {
41
+ var [x] = [1];
42
+ print(x);
43
+ }
44
+ ''' );
45
+ }
46
+
47
+ @FailingTest (
48
+ issue: "https://github.com/dart-lang/sdk/issues/49960" ,
49
+ reason: "Fix once error is reported" )
50
+ Future <void > test_pattern_in_assignment () async {
51
+ await resolveTestCode ('''
52
+ f() {
53
+ var a = 1;
54
+ var b = 2;
55
+ (var a, int b) = (3, 4);
56
+ }
57
+ ''' );
58
+ await assertHasFix ('''
59
+ f() {
60
+ var a = 1;
61
+ var b = 2;
62
+ (a, int b) = (3, 4);
63
+ }
64
+ ''' );
65
+ }
66
+
32
67
Future <void > test_setter () async {
33
68
await resolveTestCode ('''
34
69
class C {
You can’t perform that action at this time.
0 commit comments