Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions Sources/LanguageServerProtocol/Requests/ShutdownRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,17 @@
/// - Returns: Void.
public struct ShutdownRequest: RequestType, Hashable {
public static let method: String = "shutdown"
public typealias Response = VoidResponse

public struct Response: ResponseType, Equatable {
public init() {}

public init(from decoder: any Decoder) throws {}

public func encode(to encoder: any Encoder) throws {
var container = encoder.singleValueContainer()
try container.encodeNil()
}
}

public init() {}
}

@available(*, deprecated, renamed: "ShutdownRequest")
public typealias Shutdown = ShutdownRequest
4 changes: 2 additions & 2 deletions Sources/SourceKitLSP/SourceKitLSPServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1128,7 +1128,7 @@ extension SourceKitLSPServer {
}
}

func shutdown(_ request: ShutdownRequest) async throws -> VoidResponse {
func shutdown(_ request: ShutdownRequest) async throws -> ShutdownRequest.Response {
await prepareForExit()

await withTaskGroup(of: Void.self) { taskGroup in
Expand Down Expand Up @@ -1159,7 +1159,7 @@ extension SourceKitLSPServer {
// Otherwise we might terminate sourcekit-lsp while it still has open
// connections to the toolchain servers, which could send messages to
// sourcekit-lsp while it is being deallocated, causing crashes.
return VoidResponse()
return ShutdownRequest.Response()
}

func exit(_ notification: ExitNotification) async {
Expand Down
4 changes: 4 additions & 0 deletions Tests/LanguageServerProtocolTests/CodingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1343,6 +1343,10 @@ final class CodingTests: XCTestCase {
"""
)
}

func testShutdownResponse() {
checkCoding(ShutdownRequest.Response(), json: "null")
}
}

func with<T>(_ value: T, mutate: (inout T) -> Void) -> T {
Expand Down
2 changes: 1 addition & 1 deletion Tests/SourceKitLSPTests/IndexTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ final class IndexTests: XCTestCase {
"Received unexpected version: \(versionContentsBefore.first?.lastPathComponent ?? "<nil>")"
)

try await project.testClient.send(ShutdownRequest())
_ = try await project.testClient.send(ShutdownRequest())
return versionedPath
}

Expand Down