@@ -119,11 +119,12 @@ public struct SourceItemDataKind: RawRepresentable, Codable, Hashable, Sendable
119
119
}
120
120
121
121
/// **(BSP Extension)**
122
- public struct SourceKitSourceItemData : LSPAnyCodable , Codable {
123
- /// The language of the source file. If `nil`, the language is inferred from the file extension.
124
- public var language : Language ?
125
122
126
- /// Whether the file is a header file that is clearly associated with one target.
123
+ public enum SourceKitSourceItemKind : String , Codable {
124
+ /// A source file that belongs to the target
125
+ case source = " source "
126
+
127
+ /// A header file that is clearly associated with one target.
127
128
///
128
129
/// For example header files in SwiftPM projects are always associated to one target and SwiftPM can provide build
129
130
/// settings for that header file.
@@ -132,7 +133,19 @@ public struct SourceKitSourceItemData: LSPAnyCodable, Codable {
132
133
/// functionality for header files is usually provided by finding a main file that includes the header file and
133
134
/// inferring build settings from it. Listing header files in `buildTarget/sources` allows SourceKit-LSP to provide
134
135
/// semantic functionality for header files if they haven't been included by any main file.
135
- public var isHeader : Bool ?
136
+ case header = " header "
137
+
138
+ /// A SwiftDocC documentation catalog usually ending in the ".docc" extension.
139
+ case doccCatalog = " doccCatalog "
140
+ }
141
+
142
+ public struct SourceKitSourceItemData : LSPAnyCodable , Codable {
143
+ /// The language of the source file. If `nil`, the language is inferred from the file extension.
144
+ public var language : Language ?
145
+
146
+ /// The kind of source file that this source item represents. If omitted, the item is assumed to be a normal source file,
147
+ /// ie. omitting this key is equivalent to specifying it as `source`.
148
+ public var kind : SourceKitSourceItemKind ?
136
149
137
150
/// The output path that is used during indexing for this file, ie. the `-index-unit-output-path`, if it is specified
138
151
/// in the compiler arguments or the file that is passed as `-o`, if `-index-unit-output-path` is not specified.
@@ -144,18 +157,22 @@ public struct SourceKitSourceItemData: LSPAnyCodable, Codable {
144
157
/// `outputPathsProvider: true` in `SourceKitInitializeBuildResponseData`.
145
158
public var outputPath : String ?
146
159
147
- public init ( language: Language ? = nil , isHeader : Bool ? = nil , outputPath: String ? = nil ) {
160
+ public init ( language: Language ? = nil , kind : SourceKitSourceItemKind ? = nil , outputPath: String ? = nil ) {
148
161
self . language = language
149
- self . isHeader = isHeader
162
+ self . kind = kind
150
163
self . outputPath = outputPath
151
164
}
152
165
153
166
public init ? ( fromLSPDictionary dictionary: [ String : LanguageServerProtocol . LSPAny ] ) {
154
167
if case . string( let language) = dictionary [ CodingKeys . language. stringValue] {
155
168
self . language = Language ( rawValue: language)
156
169
}
157
- if case . bool( let isHeader) = dictionary [ CodingKeys . isHeader. stringValue] {
158
- self . isHeader = isHeader
170
+ if case . string( let rawKind) = dictionary [ CodingKeys . kind. stringValue] {
171
+ self . kind = SourceKitSourceItemKind ( rawValue: rawKind)
172
+ }
173
+ // Backwards compatibility for isHeader
174
+ if case . bool( let isHeader) = dictionary [ " isHeader " ] , isHeader {
175
+ self . kind = . header
159
176
}
160
177
if case . string( let outputFilePath) = dictionary [ CodingKeys . outputPath. stringValue] {
161
178
self . outputPath = outputFilePath
@@ -167,8 +184,8 @@ public struct SourceKitSourceItemData: LSPAnyCodable, Codable {
167
184
if let language {
168
185
result [ CodingKeys . language. stringValue] = . string( language. rawValue)
169
186
}
170
- if let isHeader {
171
- result [ CodingKeys . isHeader . stringValue] = . bool ( isHeader )
187
+ if let kind {
188
+ result [ CodingKeys . kind . stringValue] = . string ( kind . rawValue )
172
189
}
173
190
if let outputPath {
174
191
result [ CodingKeys . outputPath. stringValue] = . string( outputPath)
0 commit comments