9
9
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10
10
//
11
11
//===----------------------------------------------------------------------===//
12
+
12
13
import LanguageServerProtocol
13
14
15
+ public struct InitializeBuildRequestDataKind : RawRepresentable , Hashable , Codable , Sendable {
16
+ public let rawValue : String
17
+
18
+ public init ( rawValue: String ) {
19
+ self . rawValue = rawValue
20
+ }
21
+ }
22
+
14
23
/// Like the language server protocol, the initialize request is sent
15
24
/// as the first request from the client to the server. If the server
16
25
/// receives a request or notification before the initialize request
@@ -25,9 +34,9 @@ import LanguageServerProtocol
25
34
/// Until the server has responded to the initialize request with an
26
35
/// InitializeBuildResult, the client must not send any additional
27
36
/// requests or notifications to the server.
28
- public struct InitializeBuild : RequestType , Hashable {
37
+ public struct InitializeBuildRequest : RequestType , Hashable {
29
38
public static let method : String = " build/initialize "
30
- public typealias Response = InitializeBuildResult
39
+ public typealias Response = InitializeBuildResponse
31
40
32
41
/// Name of the client
33
42
public var displayName : String
@@ -44,18 +53,28 @@ public struct InitializeBuild: RequestType, Hashable {
44
53
/// The capabilities of the client
45
54
public var capabilities : BuildClientCapabilities
46
55
56
+ /// Kind of data to expect in the `data` field. If this field is not set, the kind of data is not specified. */
57
+ public var dataKind : InitializeBuildRequestDataKind ?
58
+
59
+ /// Additional metadata about the client
60
+ public var data : LSPAny ?
61
+
47
62
public init (
48
63
displayName: String ,
49
64
version: String ,
50
65
bspVersion: String ,
51
66
rootUri: URI ,
52
- capabilities: BuildClientCapabilities
67
+ capabilities: BuildClientCapabilities ,
68
+ dataKind: InitializeBuildRequestDataKind ? = nil ,
69
+ data: LSPAny ? = nil
53
70
) {
54
71
self . displayName = displayName
55
72
self . version = version
56
73
self . bspVersion = bspVersion
57
74
self . rootUri = rootUri
58
75
self . capabilities = capabilities
76
+ self . dataKind = dataKind
77
+ self . data = data
59
78
}
60
79
}
61
80
@@ -66,12 +85,67 @@ public struct BuildClientCapabilities: Codable, Hashable, Sendable {
66
85
/// languages than those that appear in this list.
67
86
public var languageIds : [ Language ]
68
87
69
- public init ( languageIds: [ Language ] ) {
88
+ /// Mirror capability to BuildServerCapabilities.jvmCompileClasspathProvider
89
+ /// The client will request classpath via `buildTarget/jvmCompileClasspath` so
90
+ /// it's safe to return classpath in ScalacOptionsItem empty. */
91
+ public var jvmCompileClasspathReceiver : Bool ?
92
+
93
+ public init ( languageIds: [ Language ] , jvmCompileClasspathReceiver: Bool ? = nil ) {
70
94
self . languageIds = languageIds
95
+ self . jvmCompileClasspathReceiver = jvmCompileClasspathReceiver
71
96
}
72
97
}
73
98
74
- public struct InitializeBuildResult : ResponseType , Hashable {
99
+ public struct InitializeBuildResponseDataKind : RawRepresentable , Hashable , Codable , Sendable {
100
+ public let rawValue : String
101
+
102
+ public init ( rawValue: String ) {
103
+ self . rawValue = rawValue
104
+ }
105
+
106
+ /// `data` field must contain a `SourceKitInitializeBuildResponseData` object.
107
+ public static let sourceKit = InitializeBuildResponseDataKind ( rawValue: " sourcekit " )
108
+ }
109
+
110
+ public struct SourceKitInitializeBuildResponseData : LSPAnyCodable , Codable , Sendable {
111
+ public var indexDatabasePath : String ?
112
+ public var indexStorePath : String ?
113
+ public var supportsPreparation : Bool ?
114
+
115
+ public init ( indexDatabasePath: String ? , indexStorePath: String ? , supportsPreparation: Bool ? ) {
116
+ self . indexDatabasePath = indexDatabasePath
117
+ self . indexStorePath = indexStorePath
118
+ self . supportsPreparation = supportsPreparation
119
+ }
120
+
121
+ public init ? ( fromLSPDictionary dictionary: [ String : LanguageServerProtocol . LSPAny ] ) {
122
+ if case . string( let indexDatabasePath) = dictionary [ CodingKeys . indexDatabasePath. stringValue] {
123
+ self . indexDatabasePath = indexDatabasePath
124
+ }
125
+ if case . string( let indexStorePath) = dictionary [ CodingKeys . indexStorePath. stringValue] {
126
+ self . indexStorePath = indexStorePath
127
+ }
128
+ if case . bool( let supportsPreparation) = dictionary [ CodingKeys . supportsPreparation. stringValue] {
129
+ self . supportsPreparation = supportsPreparation
130
+ }
131
+ }
132
+
133
+ public func encodeToLSPAny( ) -> LanguageServerProtocol . LSPAny {
134
+ var result : [ String : LSPAny ] = [ : ]
135
+ if let indexDatabasePath {
136
+ result [ CodingKeys . indexDatabasePath. stringValue] = . string( indexDatabasePath)
137
+ }
138
+ if let indexStorePath {
139
+ result [ CodingKeys . indexStorePath. stringValue] = . string( indexStorePath)
140
+ }
141
+ if let supportsPreparation {
142
+ result [ CodingKeys . supportsPreparation. stringValue] = . bool( supportsPreparation)
143
+ }
144
+ return . dictionary( result)
145
+ }
146
+ }
147
+
148
+ public struct InitializeBuildResponse : ResponseType , Hashable {
75
149
/// Name of the server
76
150
public var displayName : String
77
151
@@ -84,6 +158,9 @@ public struct InitializeBuildResult: ResponseType, Hashable {
84
158
/// The capabilities of the build server
85
159
public var capabilities : BuildServerCapabilities
86
160
161
+ /// Kind of data to expect in the `data` field. If this field is not set, the kind of data is not specified.
162
+ public var dataKind : InitializeBuildResponseDataKind ?
163
+
87
164
/// Optional metadata about the server
88
165
public var data : LSPAny ?
89
166
@@ -92,41 +169,103 @@ public struct InitializeBuildResult: ResponseType, Hashable {
92
169
version: String ,
93
170
bspVersion: String ,
94
171
capabilities: BuildServerCapabilities ,
172
+ dataKind: InitializeBuildResponseDataKind ? = nil ,
95
173
data: LSPAny ? = nil
96
174
) {
97
175
self . displayName = displayName
98
176
self . version = version
99
177
self . bspVersion = bspVersion
100
178
self . capabilities = capabilities
179
+ self . dataKind = dataKind
101
180
self . data = data
102
181
}
103
182
}
104
183
105
184
public struct BuildServerCapabilities : Codable , Hashable , Sendable {
106
185
/// The languages the server supports compilation via method buildTarget/compile.
107
- public var compileProvider : CompileProvider ? = nil
186
+ public var compileProvider : CompileProvider ?
108
187
109
188
/// The languages the server supports test execution via method buildTarget/test
110
- public var testProvider : TestProvider ? = nil
189
+ public var testProvider : TestProvider ?
111
190
112
191
/// The languages the server supports run via method buildTarget/run
113
- public var runProvider : RunProvider ? = nil
192
+ public var runProvider : RunProvider ?
193
+
194
+ /// The languages the server supports debugging via method debugSession/start.
195
+ public var debugProvider : DebugProvider ?
114
196
115
197
/// The server can provide a list of targets that contain a
116
198
/// single text document via the method buildTarget/inverseSources
117
- public var inverseSourcesProvider : Bool ? = nil
199
+ public var inverseSourcesProvider : Bool ?
118
200
119
201
/// The server provides sources for library dependencies
120
202
/// via method buildTarget/dependencySources
121
- public var dependencySourcesProvider : Bool ? = nil
203
+ public var dependencySourcesProvider : Bool ?
122
204
123
205
/// The server provides all the resource dependencies
124
206
/// via method buildTarget/resources
125
- public var resourcesProvider : Bool ? = nil
207
+ public var resourcesProvider : Bool ?
208
+
209
+ /// The server provides all output paths
210
+ /// via method buildTarget/outputPaths
211
+ public var outputPathsProvider : Bool ?
126
212
127
213
/// The server sends notifications to the client on build
128
- /// target change events via buildTarget/didChange
129
- public var buildTargetChangedProvider : Bool ? = nil
214
+ /// target change events via `buildTarget/didChange`
215
+ public var buildTargetChangedProvider : Bool ?
216
+
217
+ /// The server can respond to `buildTarget/jvmRunEnvironment` requests with the
218
+ /// necessary information required to launch a Java process to run a main class.
219
+ public var jvmRunEnvironmentProvider : Bool ?
220
+
221
+ /// The server can respond to `buildTarget/jvmTestEnvironment` requests with the
222
+ /// necessary information required to launch a Java process for testing or
223
+ /// debugging.
224
+ public var jvmTestEnvironmentProvider : Bool ?
225
+
226
+ /// The server can respond to `workspace/cargoFeaturesState` and
227
+ /// `setCargoFeatures` requests. In other words, supports Cargo Features extension.
228
+ public var cargoFeaturesProvider : Bool ?
229
+
230
+ /// Reloading the build state through workspace/reload is supported
231
+ public var canReload : Bool ?
232
+
233
+ /// The server can respond to `buildTarget/jvmCompileClasspath` requests with the
234
+ /// necessary information about the target's classpath.
235
+ public var jvmCompileClasspathProvider : Bool ?
236
+
237
+ public init (
238
+ compileProvider: CompileProvider ? = nil ,
239
+ testProvider: TestProvider ? = nil ,
240
+ runProvider: RunProvider ? = nil ,
241
+ debugProvider: DebugProvider ? = nil ,
242
+ inverseSourcesProvider: Bool ? = nil ,
243
+ dependencySourcesProvider: Bool ? = nil ,
244
+ resourcesProvider: Bool ? = nil ,
245
+ outputPathsProvider: Bool ? = nil ,
246
+ buildTargetChangedProvider: Bool ? = nil ,
247
+ jvmRunEnvironmentProvider: Bool ? = nil ,
248
+ jvmTestEnvironmentProvider: Bool ? = nil ,
249
+ cargoFeaturesProvider: Bool ? = nil ,
250
+ canReload: Bool ? = nil ,
251
+ jvmCompileClasspathProvider: Bool ? = nil
252
+ ) {
253
+ self . compileProvider = compileProvider
254
+ self . testProvider = testProvider
255
+ self . runProvider = runProvider
256
+ self . debugProvider = debugProvider
257
+ self . inverseSourcesProvider = inverseSourcesProvider
258
+ self . dependencySourcesProvider = dependencySourcesProvider
259
+ self . resourcesProvider = resourcesProvider
260
+ self . outputPathsProvider = outputPathsProvider
261
+ self . buildTargetChangedProvider = buildTargetChangedProvider
262
+ self . jvmRunEnvironmentProvider = jvmRunEnvironmentProvider
263
+ self . jvmTestEnvironmentProvider = jvmTestEnvironmentProvider
264
+ self . cargoFeaturesProvider = cargoFeaturesProvider
265
+ self . canReload = canReload
266
+ self . jvmCompileClasspathProvider = jvmCompileClasspathProvider
267
+ }
268
+
130
269
}
131
270
132
271
public struct CompileProvider : Codable , Hashable , Sendable {
@@ -153,6 +292,14 @@ public struct TestProvider: Codable, Hashable, Sendable {
153
292
}
154
293
}
155
294
295
+ public struct DebugProvider : Codable , Hashable , Sendable {
296
+ public var languageIds : [ Language ]
297
+
298
+ public init ( languageIds: [ Language ] ) {
299
+ self . languageIds = languageIds
300
+ }
301
+ }
302
+
156
303
public struct InitializedBuildNotification : NotificationType {
157
304
public static let method : String = " build/initialized "
158
305
0 commit comments