Skip to content

Commit 1209747

Browse files
authored
Merge pull request #2001 from ahoppen/add-call-with-no-defaulted-arguments
Add calls with no defaulted arguments to code completion results
2 parents 1009657 + bcdf91c commit 1209747

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

Sources/SourceKitLSP/Swift/CodeCompletionSession.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ class CodeCompletionSession {
353353
keys.hideByName: 0,
354354
keys.addInnerOperators: 0,
355355
keys.topNonLiteral: 0,
356+
keys.addCallWithNoDefaultArgs: 1,
356357
// Filtering options.
357358
keys.filterText: filterText,
358359
keys.requestLimit: 200,

Tests/SourceKitLSPTests/SwiftCompletionTests.swift

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,6 +1125,27 @@ final class SwiftCompletionTests: XCTestCase {
11251125
.markupContent(MarkupContent(kind: .markdown, value: "Creates a true value"))
11261126
)
11271127
}
1128+
1129+
func testCallDefaultedArguments() async throws {
1130+
let testClient = try await TestSourceKitLSPClient()
1131+
let uri = DocumentURI(for: .swift)
1132+
let positions = testClient.openDocument(
1133+
"""
1134+
struct Foo {
1135+
func makeBool(value: Bool = true) -> Bool { value }
1136+
}
1137+
func test(foo: Foo) {
1138+
foo.make1️⃣
1139+
}
1140+
""",
1141+
uri: uri
1142+
)
1143+
1144+
let completions = try await testClient.send(
1145+
CompletionRequest(textDocument: TextDocumentIdentifier(uri), position: positions["1️⃣"])
1146+
)
1147+
XCTAssertEqual(completions.items.map(\.insertText), ["makeBool()", "makeBool(value: )"])
1148+
}
11281149
}
11291150

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

0 commit comments

Comments
 (0)