Skip to content

Commit c380558

Browse files
keertipCommit Queue
authored andcommitted
Completion: Issue 55014: Add named constructors to suggestions for enum values.
Fixes #55014 Change-Id: I6635c76fd84d0fe364febf6264cd38f0c17c2f19 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/356120 Commit-Queue: Keerti Parthasarathy <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent 692624b commit c380558

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ class DeclarationHelper {
383383
var augmented = element.augmented;
384384
_addStaticMembers(
385385
accessors: augmented?.accessors ?? element.accessors,
386-
constructors: const [],
386+
constructors: augmented?.constructors ?? element.constructors,
387387
containingElement: element,
388388
fields: augmented?.fields ?? element.fields,
389389
methods: augmented?.methods ?? element.methods);

pkg/analysis_server/test/services/completion/dart/declaration/enum_test.dart

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,29 @@ suggestions
184184
''');
185185
}
186186

187+
Future<void> test_afterPeriod_namedConstructor() async {
188+
allowedIdentifiers = {'named'};
189+
await computeSuggestions('''
190+
enum E0 {
191+
o0, t0;
192+
193+
factory E0.named() => E0.o0;
194+
}
195+
void f() {
196+
E0.^
197+
}
198+
''');
199+
assertResponse(r'''
200+
suggestions
201+
named
202+
kind: constructorInvocation
203+
o0
204+
kind: enumConstant
205+
t0
206+
kind: enumConstant
207+
''');
208+
}
209+
187210
Future<void> test_afterPeriod_partial() async {
188211
await computeSuggestions('''
189212
enum E0 {

0 commit comments

Comments
 (0)