File tree Expand file tree Collapse file tree 2 files changed +42
-1
lines changed
lib/src/services/completion/dart Expand file tree Collapse file tree 2 files changed +42
-1
lines changed Original file line number Diff line number Diff line change @@ -2242,7 +2242,7 @@ class InScopeCompletionPass extends SimpleAstVisitor<void> {
2242
2242
_forVariablePattern ();
2243
2243
}
2244
2244
var isKeywordNeeded = false ;
2245
- if (node.parent ? .parent is GuardedPattern ) {
2245
+ if (node.thisOrAncestorOfType < GuardedPattern >() != null ) {
2246
2246
isKeywordNeeded = true ;
2247
2247
}
2248
2248
_forPatternFieldName (
Original file line number Diff line number Diff line change @@ -255,6 +255,47 @@ void f() {
255
255
expectDocumentation (resolved, contains ('Enum Member.' ));
256
256
}
257
257
258
+ Future <void > test_innerPatternKeyword () async {
259
+ content = '''
260
+ class A {
261
+ A([this.value]);
262
+ A? value;
263
+ }
264
+
265
+ void main() {
266
+ final value = A(A(A()));
267
+ if (value case A(value: A(:^))) {}
268
+ }
269
+ ''' ;
270
+ await initializeServer ();
271
+
272
+ var code = TestCode .parse (content);
273
+ var completion = await getCompletionItem ('value' );
274
+ expect (completion, isNotNull);
275
+
276
+ // Resolve the completion item to get its edits.
277
+ var resolved = await resolveCompletion (completion);
278
+
279
+ // Apply all current-document edits.
280
+ var newContent = applyTextEdits (code.code, [
281
+ toTextEdit (resolved.textEdit! ),
282
+ ]);
283
+ expect (
284
+ newContent,
285
+ equals ('''
286
+ class A {
287
+ A([this.value]);
288
+ A? value;
289
+ }
290
+
291
+ void main() {
292
+ final value = A(A(A()));
293
+ if (value case A(value: A(:var value))) {}
294
+ }
295
+ ''' ),
296
+ );
297
+ }
298
+
258
299
/// We should not show `var` , `final` or the member type on the display text.
259
300
Future <void > test_pattern_member_name_only () async {
260
301
content = '''
You can’t perform that action at this time.
0 commit comments