Skip to content

Commit e94cceb

Browse files
FMorschelCommit Queue
authored andcommitted
[DAS] Fixes completion for pattern destructing
Fixes: #61920 Change-Id: I7a2baa3a075b6416ab34031c8bb13e99db726671 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/460142 Reviewed-by: Samuel Rawlins <[email protected]> Auto-Submit: Felipe Morschel <[email protected]> Reviewed-by: Keerti Parthasarathy <[email protected]> Commit-Queue: Keerti Parthasarathy <[email protected]>
1 parent ab4fc52 commit e94cceb

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2325,7 +2325,9 @@ class InScopeCompletionPass extends SimpleAstVisitor<void> {
23252325
collector.completionLocation = 'PatternField_pattern';
23262326
}
23272327
_forPatternFieldName(node, isKeywordNeeded: false, isTypeNeeded: false);
2328+
return;
23282329
}
2330+
node.parent?.accept(this);
23292331
}
23302332

23312333
@override

pkg/analysis_server/test/services/completion/dart/location/object_pattern_test.dart

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,33 @@ suggestions
666666
''');
667667
}
668668

669+
Future<void> test_patternFieldName_afterColon() async {
670+
await computeSuggestions('''
671+
void f(MyClassWithReallyBigName parameter) {
672+
if (parameter case MyClassWithReallyBigName(
673+
fieldWithBigName: var fieldWithReallyVeryBigName,
674+
:^
675+
)) {}
676+
}
677+
678+
abstract class MyClassWithReallyBigName {
679+
int get fieldWithBigName;
680+
int get g01;
681+
}
682+
''');
683+
assertResponse(r'''
684+
location: PatternField_pattern
685+
locationOpType: PatternField_pattern
686+
suggestions
687+
final
688+
kind: keyword
689+
var
690+
kind: keyword
691+
var g01
692+
kind: getter
693+
''');
694+
}
695+
669696
Future<void> test_property_first() async {
670697
await computeSuggestions('''
671698
void f1(Object x0) {

0 commit comments

Comments
 (0)