Skip to content

Commit e225e61

Browse files
committed
Issue 25827. Don't propose to remove the type of an incomplete variable declaration.
R=brianwilkerson@google.com BUG= #25827 Review URL: https://codereview.chromium.org/1753893002 .
1 parent 88acc8a commit e225e61

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

pkg/analysis_server/lib/src/services/correction/assist_internal.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,6 +1444,12 @@ class AssistProcessor {
14441444
_coverageMarker();
14451445
return;
14461446
}
1447+
// ignore if an incomplete variable declaration
1448+
if (declarationList.variables.length == 1 &&
1449+
declarationList.variables[0].name.isSynthetic) {
1450+
_coverageMarker();
1451+
return;
1452+
}
14471453
// must be not after the name of the variable
14481454
VariableDeclaration firstVariable = declarationList.variables[0];
14491455
if (selectionOffset > firstVariable.name.end) {

pkg/analysis_server/test/services/correction/assist_test.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3317,6 +3317,14 @@ main() {
33173317
''');
33183318
}
33193319

3320+
test_removeTypeAnnotation_topLevelVariable_BAD_syntheticName() async {
3321+
verifyNoTestUnitErrors = false;
3322+
resolveTestUnit('''
3323+
MyType
3324+
''');
3325+
await assertNoAssistAt('MyType', DartAssistKind.REMOVE_TYPE_ANNOTATION);
3326+
}
3327+
33203328
test_removeTypeAnnotation_topLevelVariable_OK() async {
33213329
resolveTestUnit('''
33223330
int V = 1;

0 commit comments

Comments
 (0)