Skip to content

Commit 410f95d

Browse files
authored
Merge pull request #2299 from ahoppen/in-memory-cross-file-completion
Add test case checking that we show completions from in-memory contents of files within same module
2 parents 48c5604 + c4aecfe commit 410f95d

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

Tests/SourceKitLSPTests/SwiftCompletionTests.swift

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,6 +1410,36 @@ final class SwiftCompletionTests: XCTestCase {
14101410
)
14111411
XCTAssertEqual(completions.items.only?.detail, "String")
14121412
}
1413+
1414+
func testSuggestInMemoryFunctionsFromFilesWithinSameModule() async throws {
1415+
let project = try await SwiftPMTestProject(files: [
1416+
"First.swift": """
1417+
myFancyFunc1️⃣
1418+
""",
1419+
"Second.swift": "2️⃣",
1420+
])
1421+
1422+
let (secondUri, secondPositions) = try project.openDocument("Second.swift")
1423+
project.testClient.send(
1424+
DidChangeTextDocumentNotification(
1425+
textDocument: VersionedTextDocumentIdentifier(secondUri, version: 2),
1426+
contentChanges: [
1427+
TextDocumentContentChangeEvent(
1428+
range: Range(secondPositions["2️⃣"]),
1429+
text: """
1430+
func myFancyFunction() {}
1431+
"""
1432+
)
1433+
]
1434+
)
1435+
)
1436+
1437+
let (firstUri, firstPositions) = try project.openDocument("First.swift")
1438+
let completions = try await project.testClient.send(
1439+
CompletionRequest(textDocument: TextDocumentIdentifier(firstUri), position: firstPositions["1️⃣"])
1440+
)
1441+
XCTAssert(completions.items.contains(where: { $0.label.contains("myFancyFunction") }))
1442+
}
14131443
}
14141444

14151445
private func countFs(_ response: CompletionList) -> Int {

0 commit comments

Comments
 (0)