Skip to content

Commit ade4bf8

Browse files
FMorschelCommit Queue
authored andcommitted
[DAS] Fixes record extension field completion
Bug: #60625 Change-Id: I23e4a5a85dc15059c9b1e658fb2fc3f868fa91a7 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/424684 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Brian Wilkerson <[email protected]> Commit-Queue: Samuel Rawlins <[email protected]> Reviewed-by: Samuel Rawlins <[email protected]> Auto-Submit: Felipe Morschel <[email protected]>
1 parent b40b806 commit ade4bf8

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,6 +1317,8 @@ class DeclarationHelper {
13171317
includeMethods: true,
13181318
includeSetters: true,
13191319
);
1320+
} else if (thisType is RecordType) {
1321+
_addFieldsOfRecordType(type: thisType, excludedFields: {});
13201322
}
13211323
}
13221324

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,20 @@ suggestions
125125
''');
126126
}
127127

128+
Future<void> test_inMethod_namedRecordFields() async {
129+
allowedIdentifiers = {'value1'};
130+
await computeSuggestions('''
131+
extension E on ({int value1,}) {foo() { val^;} }
132+
''');
133+
assertResponse(r'''
134+
replacement
135+
left: 3
136+
suggestions
137+
value1
138+
kind: identifier
139+
''');
140+
}
141+
128142
Future<void> test_inMethod_parameterShadowField() async {
129143
allowedIdentifiers = {'aaa'};
130144
await computeSuggestions('''
@@ -142,6 +156,22 @@ suggestions
142156
kind: parameter
143157
assert
144158
kind: keyword
159+
''');
160+
}
161+
162+
Future<void> test_inMethod_positionalRecordFields() async {
163+
allowedIdentifiers = {r'$1', r'$2'};
164+
await computeSuggestions(r'''
165+
extension E on (int, String,) {foo() { $^;} }
166+
''');
167+
assertResponse(r'''
168+
replacement
169+
left: 1
170+
suggestions
171+
$1
172+
kind: identifier
173+
$2
174+
kind: identifier
145175
''');
146176
}
147177
}

0 commit comments

Comments
 (0)