Skip to content

Commit cc1ba63

Browse files
authored
Merge pull request #28 from swiftlang/owenv/send
Add an async Connection.send in LanguageServerProtocolTransport
2 parents 3a331d3 + f8c5f44 commit cc1ba63

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

Sources/LanguageServerProtocolTransport/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
add_library(LanguageServerProtocolTransport
22
BuildServerMessageDependencyTracker.swift
3+
Connection+Send.swift
34
DisableSigpipe.swift
45
DocumentURI+CustomLogStringConvertible.swift
56
JSONRPCConnection.swift
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2025 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
public import LanguageServerProtocol
14+
@_spi(SourceKitLSP) private import ToolsProtocolsSwiftExtensions
15+
16+
extension Connection {
17+
public func send<R: RequestType>(_ request: R) async throws -> R.Response {
18+
return try await withCancellableCheckedThrowingContinuation { continuation in
19+
return self.send(request) { result in
20+
continuation.resume(with: result)
21+
}
22+
} cancel: { requestID in
23+
self.send(CancelRequestNotification(id: requestID))
24+
}
25+
}
26+
}

0 commit comments

Comments
 (0)