@@ -181,4 +181,64 @@ final class SwiftPMIntegrationTests: XCTestCase {
181
181
)
182
182
XCTAssert ( oldFileCompletions. items. contains ( where: { $0. label == " baz(l: Lib) " } ) )
183
183
}
184
+
185
+ func testNestedPackage( ) async throws {
186
+ let ws = try await MultiFileTestWorkspace ( files: [
187
+ " pkg/Sources/lib/lib.swift " : " " ,
188
+ " pkg/Package.swift " : """
189
+ // swift-tools-version:4.2
190
+ import PackageDescription
191
+ let package = Package(name: " a " , products: [], dependencies: [],
192
+ targets: [.target(name: " lib " , dependencies: [])])
193
+ """ ,
194
+ " nested/pkg/Sources/lib/a.swift.swift " : """
195
+ struct Foo {
196
+ func bar() {}
197
+ }
198
+ """ ,
199
+ " nested/pkg/Sources/lib/b.swift " : """
200
+ func test(foo: Foo) {
201
+ foo.1️⃣
202
+ }
203
+ """ ,
204
+ " nested/pkg/Package.swift " : """
205
+ // swift-tools-version:4.2
206
+ import PackageDescription
207
+ let package = Package(name: " a " , products: [], dependencies: [],
208
+ targets: [.target(name: " lib " , dependencies: [])])
209
+ """ ,
210
+ ] )
211
+
212
+ let ( uri, positions) = try ws. openDocument ( " b.swift " )
213
+
214
+ let result = try await ws. testClient. send (
215
+ CompletionRequest ( textDocument: TextDocumentIdentifier ( uri) , position: positions [ " 1️⃣ " ] )
216
+ )
217
+
218
+ XCTAssertEqual (
219
+ result. items,
220
+ [
221
+ CompletionItem (
222
+ label: " bar() " ,
223
+ kind: . method,
224
+ detail: " Void " ,
225
+ deprecated: false ,
226
+ filterText: " bar() " ,
227
+ insertText: " bar() " ,
228
+ insertTextFormat: . plain,
229
+ textEdit: . textEdit( TextEdit ( range: positions [ " 1️⃣ " ] ..< positions [ " 1️⃣ " ] , newText: " bar() " ) )
230
+ ) ,
231
+ CompletionItem (
232
+ label: " self " ,
233
+ kind: . keyword,
234
+ detail: " Foo " ,
235
+ deprecated: false ,
236
+ filterText: " self " ,
237
+ insertText: " self " ,
238
+ insertTextFormat: . plain,
239
+ textEdit: . textEdit( TextEdit ( range: positions [ " 1️⃣ " ] ..< positions [ " 1️⃣ " ] , newText: " self " ) )
240
+ ) ,
241
+ ]
242
+ )
243
+ }
184
244
}
0 commit comments