Skip to content

Commit d5e19c6

Browse files
FMorschelCommit Queue
authored andcommitted
Fix for completion inside late final fields
[email protected] Fixes #56936 Change-Id: Ib1a5ca0c27df2d19bca36f7385c30b02811c2e33 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393043 Auto-Submit: Felipe Morschel <[email protected]> Reviewed-by: Samuel Rawlins <[email protected]> Commit-Queue: Brian Wilkerson <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent 784af8f commit d5e19c6

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

pkg/analysis_server/lib/src/services/completion/dart/in_scope_completion_pass.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3940,6 +3940,9 @@ extension on AstNode {
39403940
} else if (enclosingMember is FunctionBody &&
39413941
enclosingMember.parent is ConstructorDeclaration) {
39423942
return false;
3943+
} else if (enclosingMember is VariableDeclarationList &&
3944+
enclosingMember.parent is FieldDeclaration) {
3945+
return !enclosingMember.isLate;
39433946
}
39443947
enclosingMember = enclosingMember.parent;
39453948
}

pkg/analysis_server/test/lsp/completion_dart_test.dart

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2179,6 +2179,29 @@ import 'dart:^';
21792179
expect(item.insertTextMode, isNull);
21802180
}
21812181

2182+
Future<void> test_inside_lateFinal() async {
2183+
await checkCompleteFunctionCallInsertText('''
2184+
class MyClass {
2185+
String get myGetter => '';
2186+
late final myField = [!myG^!]
2187+
}
2188+
''', 'myGetter', editText: 'myGetter');
2189+
}
2190+
2191+
Future<void> test_inside_nonLateFinal() async {
2192+
var content = '''
2193+
class MyClass {
2194+
String get myGetter => '';
2195+
final myField = myG^
2196+
}
2197+
''';
2198+
await initialize();
2199+
var code = TestCode.parse(content);
2200+
await openFile(mainFileUri, code.code);
2201+
var res = await getCompletion(mainFileUri, code.position.position);
2202+
expect(res, isEmpty);
2203+
}
2204+
21822205
Future<void> test_insideString() async {
21832206
var content = '''
21842207
var a = "This is ^a test"

0 commit comments

Comments
 (0)