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
14
15
public typealias URI = DocumentURI
15
16
16
17
/// The workspace build targets request is sent from the client to the server to
17
18
/// ask for the list of all available build targets in the workspace.
18
- public struct BuildTargets : RequestType , Hashable {
19
+ public struct BuildTargetsRequest : RequestType , Hashable {
19
20
public static let method : String = " workspace/buildTargets "
20
- public typealias Response = BuildTargetsResult
21
+ public typealias Response = BuildTargetsResponse
21
22
22
23
public init ( ) { }
23
24
}
24
25
25
- public struct BuildTargetsResult : ResponseType , Hashable {
26
+ public struct BuildTargetsResponse : ResponseType , Hashable {
26
27
public var targets : [ BuildTarget ]
28
+
29
+ public init ( targets: [ BuildTarget ] ) {
30
+ self . targets = targets
31
+ }
27
32
}
28
33
29
34
public struct BuildTarget : Codable , Hashable , Sendable {
@@ -52,16 +57,23 @@ public struct BuildTarget: Codable, Hashable, Sendable {
52
57
/// are free to define new tags for custom purposes.
53
58
public var tags : [ BuildTargetTag ]
54
59
55
- /// The capabilities of this build target.
56
- public var capabilities : BuildTargetCapabilities
57
-
58
60
/// The set of languages that this target contains.
59
61
/// The ID string for each language is defined in the LSP.
60
62
public var languageIds : [ Language ]
61
63
62
64
/// The direct upstream build target dependencies of this build target
63
65
public var dependencies : [ BuildTargetIdentifier ]
64
66
67
+ /// The capabilities of this build target.
68
+ public var capabilities : BuildTargetCapabilities
69
+
70
+ /// Kind of data to expect in the `data` field. If this field is not set, the kind of data is not specified.
71
+ public var dataKind : BuildTargetDataKind ?
72
+
73
+ /// Language-specific metadata about this target.
74
+ /// See ScalaBuildTarget as an example.
75
+ public var data : LSPAny ?
76
+
65
77
public init (
66
78
id: BuildTargetIdentifier ,
67
79
displayName: String ? ,
@@ -96,17 +108,13 @@ public struct BuildTargetTag: Codable, Hashable, RawRepresentable, Sendable {
96
108
self . rawValue = rawValue
97
109
}
98
110
99
- /// Target contains re-usable functionality for downstream targets. May have
100
- /// any combination of capabilities.
101
- public static let library : Self = Self ( rawValue: " library " )
102
-
103
111
/// Target contains source code for producing any kind of application, may
104
112
/// have but does not require the `canRun` capability.
105
113
public static let application : Self = Self ( rawValue: " application " )
106
114
107
- /// Target contains source code for testing purposes, may have but does not
108
- /// require the `canTest` capability.
109
- public static let test : Self = Self ( rawValue: " test " )
115
+ /// Target contains source code to measure performance of a program, may have
116
+ /// but does not require the `canRun` build target capability.
117
+ public static let benchmark : Self = Self ( rawValue: " benchmark " )
110
118
111
119
/// Target contains source code for integration testing purposes, may have
112
120
/// but does not require the `canTest` capability. The difference between
@@ -115,77 +123,76 @@ public struct BuildTargetTag: Codable, Hashable, RawRepresentable, Sendable {
115
123
/// execute.
116
124
public static let integrationTest : Self = Self ( rawValue: " integration-test " )
117
125
118
- /// Target contains source code to measure performance of a program, may have
119
- /// but does not require the `canRun` build target capability.
120
- public static let benchmark : Self = Self ( rawValue: " benchmark " )
126
+ /// Target contains re-usable functionality for downstream targets. May have
127
+ /// any combination of capabilities.
128
+ public static let library : Self = Self ( rawValue: " library " )
129
+
130
+ /// Actions on the target such as build and test should only be invoked manually
131
+ /// and explicitly. For example, triggering a build on all targets in the workspace
132
+ /// should by default not include this target.
133
+ /// The original motivation to add the "manual" tag comes from a similar functionality
134
+ /// that exists in Bazel, where targets with this tag have to be specified explicitly
135
+ /// on the command line.
136
+ public static let manual : Self = Self ( rawValue: " manual " )
121
137
122
138
/// Target should be ignored by IDEs.
123
139
public static let noIDE : Self = Self ( rawValue: " no-ide " )
140
+
141
+ /// Target contains source code for testing purposes, may have but does not
142
+ /// require the `canTest` capability.
143
+ public static let test : Self = Self ( rawValue: " test " )
144
+
145
+ /// This is a target of a dependency from the project the user opened, eg. a target that builds a SwiftPM dependency.
146
+ ///
147
+ /// **(BSP Extension)**
148
+ public static let dependency : Self = Self ( rawValue: " dependency " )
124
149
}
125
150
126
151
public struct BuildTargetCapabilities : Codable , Hashable , Sendable {
127
152
/// This target can be compiled by the BSP server.
128
- public var canCompile : Bool
153
+ public var canCompile : Bool ?
129
154
130
155
/// This target can be tested by the BSP server.
131
- public var canTest : Bool
156
+ public var canTest : Bool ?
132
157
133
158
/// This target can be run by the BSP server.
134
- public var canRun : Bool
159
+ public var canRun : Bool ?
160
+
161
+ /// This target can be debugged by the BSP server.
162
+ public var canDebug : Bool ?
135
163
136
- public init ( canCompile: Bool , canTest: Bool , canRun: Bool ) {
164
+ public init ( canCompile: Bool ? = nil , canTest: Bool ? = nil , canRun: Bool ? = nil , canDebug : Bool ? = nil ) {
137
165
self . canCompile = canCompile
138
166
self . canTest = canTest
139
167
self . canRun = canRun
168
+ self . canDebug = canDebug
140
169
}
141
170
}
142
171
143
- /// The build target sources request is sent from the client to the server to
144
- /// query for the list of text documents and directories that are belong to a
145
- /// build target. The sources response must not include sources that are
146
- /// external to the workspace.
147
- public struct BuildTargetSources : RequestType , Hashable {
148
- public static let method : String = " buildTarget/sources "
149
- public typealias Response = BuildTargetSourcesResult
150
-
151
- public var targets : [ BuildTargetIdentifier ]
172
+ public struct BuildTargetDataKind : RawRepresentable , Codable , Hashable , Sendable {
173
+ public var rawValue : String
152
174
153
- public init ( targets : [ BuildTargetIdentifier ] ) {
154
- self . targets = targets
175
+ public init ( rawValue : String ) {
176
+ self . rawValue = rawValue
155
177
}
156
- }
157
-
158
- public struct BuildTargetSourcesResult : ResponseType , Hashable {
159
- public var items : [ SourcesItem ]
160
- }
161
-
162
- public struct SourcesItem : Codable , Hashable , Sendable {
163
- public var target : BuildTargetIdentifier
164
178
165
- /// The text documents and directories that belong to this build target.
166
- public var sources : [ SourceItem ]
167
- }
179
+ /// `data` field must contain a CargoBuildTarget object.
180
+ public static let cargo = " cargo "
168
181
169
- public struct SourceItem : Codable , Hashable , Sendable {
170
- /// Either a text document or a directory. A directory entry must end with a
171
- /// forward slash "/" and a directory entry implies that every nested text
172
- /// document within the directory belongs to this source item.
173
- public var uri : URI
182
+ /// `data` field must contain a CppBuildTarget object.
183
+ public static let cpp = " cpp "
174
184
175
- /// Type of file of the source item, such as whether it is file or directory .
176
- public var kind : SourceItemKind
185
+ /// `data` field must contain a JvmBuildTarget object .
186
+ public static let jvm = " jvm "
177
187
178
- /// Indicates if this source is automatically generated by the build and is
179
- /// not intended to be manually edited by the user.
180
- public var generated : Bool
181
- }
188
+ /// `data` field must contain a PythonBuildTarget object.
189
+ public static let python = " python "
182
190
183
- public enum SourceItemKind : Int , Codable , Hashable , Sendable {
184
- /// The source item references a normal file.
185
- case file = 1
191
+ /// `data` field must contain a SbtBuildTarget object.
192
+ public static let sbt = " sbt "
186
193
187
- /// The source item references a directory .
188
- case directory = 2
194
+ /// `data` field must contain a ScalaBuildTarget object .
195
+ public static let scala = " scala "
189
196
}
190
197
191
198
/// The build target output paths request is sent from the client to the server
0 commit comments