File tree Expand file tree Collapse file tree 10 files changed +60
-46
lines changed Expand file tree Collapse file tree 10 files changed +60
-46
lines changed Original file line number Diff line number Diff line change @@ -101,10 +101,7 @@ let package = Package(
101
101
// The core LSP types, suitable for any LSP implementation.
102
102
. target(
103
103
name: " LanguageServerProtocol " ,
104
- dependencies: [
105
- " SKSupport " ,
106
- . product( name: " SwiftToolsSupport-auto " , package : " swift-tools-support-core " ) ,
107
- ] ,
104
+ dependencies: [ ] ,
108
105
exclude: [ " CMakeLists.txt " ]
109
106
) ,
110
107
@@ -200,7 +197,9 @@ let package = Package(
200
197
. target(
201
198
name: " SKSupport " ,
202
199
dependencies: [
203
- . product( name: " SwiftToolsSupport-auto " , package : " swift-tools-support-core " )
200
+ . product( name: " SwiftToolsSupport-auto " , package : " swift-tools-support-core " ) ,
201
+ " LanguageServerProtocol " ,
202
+ " LSPLogging "
204
203
] ,
205
204
exclude: [ " CMakeLists.txt " ]
206
205
) ,
Original file line number Diff line number Diff line change 1
1
add_library (LanguageServerProtocol STATIC
2
- AsyncQueue.swift
3
2
Connection.swift
4
3
CustomCodable.swift
5
4
Error.swift
Original file line number Diff line number Diff line change 11
11
//===----------------------------------------------------------------------===//
12
12
13
13
import Dispatch
14
- import SKSupport
15
14
16
15
/// An abstract connection, allow messages to be sent to a (potentially remote) `MessageHandler`.
17
16
public protocol Connection : AnyObject {
@@ -129,23 +128,3 @@ extension LocalConnection: Connection {
129
128
return id
130
129
}
131
130
}
132
-
133
- extension Connection {
134
- /// Send the given request to the connection and await its result.
135
- ///
136
- /// This method automatically sends a `CancelRequestNotification` to the
137
- /// connection if the task it is executing in is being cancelled.
138
- ///
139
- /// - Warning: Because this message is `async`, it does not provide any ordering
140
- /// guarantees. If you need to gurantee that messages are sent in-order
141
- /// use the version with a completion handler.
142
- public func send< R: RequestType > ( _ request: R ) async throws -> R . Response {
143
- return try await withCancellableCheckedThrowingContinuation { continuation in
144
- return self . send ( request) { result in
145
- continuation. resume ( with: result)
146
- }
147
- } cancel: { requestID in
148
- self . send ( CancelRequestNotification ( id: requestID) )
149
- }
150
- }
151
- }
Original file line number Diff line number Diff line change 11
11
//===----------------------------------------------------------------------===//
12
12
13
13
import Foundation
14
- import LSPLogging
15
14
16
- import struct TSCBasic. AbsolutePath
17
- import func TSCBasic. resolveSymlinks
18
-
19
- public struct DocumentURI : Codable , Hashable , CustomLogStringConvertible {
15
+ public struct DocumentURI : Codable , Hashable {
20
16
/// The URL that store the URIs value
21
17
private let storage : URL
22
18
23
19
public var description : String {
24
20
return storage. description
25
21
}
26
22
27
- public var redactedDescription : String {
28
- return " <DocumentURI length= \( storage. description. count) hash= \( description. hashForLogging) > "
29
- }
30
-
31
- public var nativeURI : Self {
32
- get throws {
33
- DocumentURI ( URL ( fileURLWithPath: try resolveSymlinks ( AbsolutePath ( validating: self . pseudoPath) ) . pathString) )
34
- }
35
- }
36
-
37
23
public var fileURL : URL ? {
38
24
if storage. isFileURL {
39
25
return storage
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ extension Task: AnyTask {
24
24
}
25
25
}
26
26
27
- extension NSLock {
27
+ fileprivate extension NSLock {
28
28
/// NOTE: Keep in sync with SwiftPM's 'Sources/Basics/NSLock+Extensions.swift'
29
29
func withLock< T> ( _ body: ( ) throws -> T ) rethrows -> T {
30
30
lock ( )
@@ -48,7 +48,7 @@ public struct Serial: DependencyTracker {
48
48
}
49
49
}
50
50
51
- /// A queue that allows the execution of asyncronous blocks of code.
51
+ /// A queue that allows the execution of asynchronous blocks of code.
52
52
public final class AsyncQueue < TaskMetadata: DependencyTracker > {
53
53
private struct PendingTask {
54
54
/// The task that is pending.
@@ -109,7 +109,7 @@ public final class AsyncQueue<TaskMetadata: DependencyTracker> {
109
109
let id = UUID ( )
110
110
111
111
return pendingTasksLock. withLock {
112
- // Build the list of tasks that need to finishe exeuction before this one
112
+ // Build the list of tasks that need to finished execution before this one
113
113
// can be executed
114
114
let dependencies : [ PendingTask ] = pendingTasks. filter { $0. metadata. isDependency ( of: metadata) }
115
115
Original file line number Diff line number Diff line change 1
1
2
2
add_library (SKSupport STATIC
3
+ AsyncQueue.swift
3
4
AsyncUtils.swift
4
5
BuildConfiguration.swift
5
6
ByteString.swift
7
+ Connection+Send.swift
6
8
dlopen.swift
7
9
FileSystem.swift
8
10
LineTable.swift
11
+ LoggableMessageTypes.swift
9
12
Random.swift
10
13
Result.swift
11
14
ThreadSafeBox.swift
Original file line number Diff line number Diff line change
1
+ //===----------------------------------------------------------------------===//
2
+ //
3
+ // This source file is part of the Swift.org open source project
4
+ //
5
+ // Copyright (c) 2014 - 2023 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
+ import LanguageServerProtocol
14
+
15
+ extension Connection {
16
+ /// Send the given request to the connection and await its result.
17
+ ///
18
+ /// This method automatically sends a `CancelRequestNotification` to the
19
+ /// connection if the task it is executing in is being cancelled.
20
+ ///
21
+ /// - Warning: Because this message is `async`, it does not provide any ordering
22
+ /// guarantees. If you need to guarantee that messages are sent in-order
23
+ /// use the version with a completion handler.
24
+ public func send< R: RequestType > ( _ request: R ) async throws -> R . Response {
25
+ return try await withCancellableCheckedThrowingContinuation { continuation in
26
+ return self . send ( request) { result in
27
+ continuation. resume ( with: result)
28
+ }
29
+ } cancel: { requestID in
30
+ self . send ( CancelRequestNotification ( id: requestID) )
31
+ }
32
+ }
33
+ }
Original file line number Diff line number Diff line change @@ -31,6 +31,16 @@ fileprivate extension Encodable {
31
31
}
32
32
}
33
33
34
+ // MARK: - DocumentURI
35
+
36
+ extension DocumentURI : CustomLogStringConvertible {
37
+ public var redactedDescription : String {
38
+ return " <DocumentURI length= \( description. count) hash= \( description. hashForLogging) > "
39
+ }
40
+ }
41
+
42
+ // MARK: - RequestType
43
+
34
44
fileprivate struct AnyRequestType : CustomLogStringConvertible {
35
45
let request : any RequestType
36
46
@@ -52,6 +62,8 @@ extension RequestType {
52
62
}
53
63
}
54
64
65
+ // MARK: - NotificationType
66
+
55
67
fileprivate struct AnyNotificationType : CustomLogStringConvertible {
56
68
let notification : any NotificationType
57
69
@@ -73,6 +85,8 @@ extension NotificationType {
73
85
}
74
86
}
75
87
88
+ // MARK: - ResponseType
89
+
76
90
fileprivate struct AnyResponseType : CustomLogStringConvertible {
77
91
let response : any ResponseType
78
92
Original file line number Diff line number Diff line change 1
1
2
2
add_library (SourceKitLSP STATIC
3
3
CapabilityRegistry.swift
4
+ Connection+Send.swift
4
5
DocumentManager.swift
5
6
IndexStoreDB+MainFilesProvider.swift
6
- LoggableMessageTypes.swift
7
7
ResponseError+Init.swift
8
8
Sequence+AsyncMap.swift
9
9
SourceKitIndexDelegate.swift
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import Dispatch
14
14
import LSPLogging
15
15
import LanguageServerProtocol
16
16
import SourceKitD
17
+ import SKSupport
17
18
18
19
/// Represents a code-completion session for a given source location that can be efficiently
19
20
/// re-filtered by calling `update()`.
You can’t perform that action at this time.
0 commit comments