@@ -20,8 +20,8 @@ import struct TSCBasic.AbsolutePath
20
20
/// Options that can be used to modify SourceKit-LSP's behavior.
21
21
///
22
22
/// See `ConfigurationFile.md` for a description of the configuration file's behavior.
23
- public struct SourceKitLSPOptions : Sendable , Codable , CustomLogStringConvertible {
24
- public struct SwiftPMOptions : Sendable , Codable , CustomLogStringConvertible {
23
+ public struct SourceKitLSPOptions : Sendable , Codable , Equatable , CustomLogStringConvertible {
24
+ public struct SwiftPMOptions : Sendable , Codable , Equatable , CustomLogStringConvertible {
25
25
/// Build configuration (debug|release).
26
26
///
27
27
/// Equivalent to SwiftPM's `--configuration` option.
@@ -104,7 +104,7 @@ public struct SourceKitLSPOptions: Sendable, Codable, CustomLogStringConvertible
104
104
}
105
105
}
106
106
107
- public struct CompilationDatabaseOptions : Sendable , Codable , CustomLogStringConvertible {
107
+ public struct CompilationDatabaseOptions : Sendable , Codable , Equatable , CustomLogStringConvertible {
108
108
/// Additional paths to search for a compilation database, relative to a workspace root.
109
109
public var searchPaths : [ String ] ?
110
110
@@ -128,7 +128,7 @@ public struct SourceKitLSPOptions: Sendable, Codable, CustomLogStringConvertible
128
128
}
129
129
}
130
130
131
- public struct FallbackBuildSystemOptions : Sendable , Codable , CustomLogStringConvertible {
131
+ public struct FallbackBuildSystemOptions : Sendable , Codable , Equatable , CustomLogStringConvertible {
132
132
public var cCompilerFlags : [ String ] ?
133
133
public var cxxCompilerFlags : [ String ] ?
134
134
public var swiftCompilerFlags : [ String ] ?
@@ -163,7 +163,7 @@ public struct SourceKitLSPOptions: Sendable, Codable, CustomLogStringConvertible
163
163
}
164
164
}
165
165
166
- public struct IndexOptions : Sendable , Codable , CustomLogStringConvertible {
166
+ public struct IndexOptions : Sendable , Codable , Equatable , CustomLogStringConvertible {
167
167
public var indexStorePath : String ?
168
168
public var indexDatabasePath : String ?
169
169
public var indexPrefixMap : [ String : String ] ?
@@ -216,7 +216,7 @@ public struct SourceKitLSPOptions: Sendable, Codable, CustomLogStringConvertible
216
216
}
217
217
}
218
218
219
- public struct LoggingOptions : Sendable , Codable , CustomLogStringConvertible {
219
+ public struct LoggingOptions : Sendable , Codable , Equatable , CustomLogStringConvertible {
220
220
/// The level from which one onwards log messages should be written.
221
221
public var level : String ?
222
222
/// Whether potentially sensitive information should be redacted.
@@ -259,12 +259,38 @@ public struct SourceKitLSPOptions: Sendable, Codable, CustomLogStringConvertible
259
259
case enabled
260
260
}
261
261
262
- public var swiftPM : SwiftPMOptions
263
- public var compilationDatabase : CompilationDatabaseOptions
264
- public var fallbackBuildSystem : FallbackBuildSystemOptions
262
+ // Pretend that all of these keys are
263
+ private var swiftPM : SwiftPMOptions ?
264
+ public var swiftPMOrDefault : SwiftPMOptions {
265
+ get { swiftPM ?? . init( ) }
266
+ set { swiftPM = newValue }
267
+ }
268
+
269
+ private var compilationDatabase : CompilationDatabaseOptions ?
270
+ public var compilationDatabaseOrDefault : CompilationDatabaseOptions {
271
+ get { compilationDatabase ?? . init( ) }
272
+ set { compilationDatabase = newValue }
273
+ }
274
+
275
+ private var fallbackBuildSystem : FallbackBuildSystemOptions ?
276
+ public var fallbackBuildSystemOrDefault : FallbackBuildSystemOptions {
277
+ get { fallbackBuildSystem ?? . init( ) }
278
+ set { fallbackBuildSystem = newValue }
279
+ }
280
+
265
281
public var clangdOptions : [ String ] ?
266
- public var index : IndexOptions
267
- public var logging : LoggingOptions
282
+
283
+ private var index : IndexOptions ?
284
+ public var indexOrDefault : IndexOptions {
285
+ get { index ?? . init( ) }
286
+ set { index = newValue }
287
+ }
288
+
289
+ private var logging : LoggingOptions ?
290
+ public var loggingOrDefault : LoggingOptions {
291
+ get { logging ?? . init( ) }
292
+ set { logging = newValue }
293
+ }
268
294
269
295
/// Default workspace type (buildserver|compdb|swiftpm). Overrides workspace type selection logic.
270
296
public var defaultWorkspaceType : WorkspaceType ?
@@ -406,18 +432,18 @@ public struct SourceKitLSPOptions: Sendable, Codable, CustomLogStringConvertible
406
432
407
433
public static func merging( base: SourceKitLSPOptions , override: SourceKitLSPOptions ? ) -> SourceKitLSPOptions {
408
434
return SourceKitLSPOptions (
409
- swiftPM: SwiftPMOptions . merging ( base: base. swiftPM , override: override? . swiftPM) ,
435
+ swiftPM: SwiftPMOptions . merging ( base: base. swiftPMOrDefault , override: override? . swiftPM) ,
410
436
fallbackBuildSystem: FallbackBuildSystemOptions . merging (
411
- base: base. fallbackBuildSystem ,
437
+ base: base. fallbackBuildSystemOrDefault ,
412
438
override: override? . fallbackBuildSystem
413
439
) ,
414
440
compilationDatabase: CompilationDatabaseOptions . merging (
415
- base: base. compilationDatabase ,
441
+ base: base. compilationDatabaseOrDefault ,
416
442
override: override? . compilationDatabase
417
443
) ,
418
444
clangdOptions: override? . clangdOptions ?? base. clangdOptions,
419
- index: IndexOptions . merging ( base: base. index , override: override? . index) ,
420
- logging: LoggingOptions . merging ( base: base. logging , override: override? . logging) ,
445
+ index: IndexOptions . merging ( base: base. indexOrDefault , override: override? . index) ,
446
+ logging: LoggingOptions . merging ( base: base. loggingOrDefault , override: override? . logging) ,
421
447
defaultWorkspaceType: override? . defaultWorkspaceType ?? base. defaultWorkspaceType,
422
448
generatedFilesPath: override? . generatedFilesPath ?? base. generatedFilesPath,
423
449
backgroundIndexing: override? . backgroundIndexing ?? base. backgroundIndexing,
@@ -447,37 +473,6 @@ public struct SourceKitLSPOptions: Sendable, Codable, CustomLogStringConvertible
447
473
return experimentalFeatures. contains ( feature)
448
474
}
449
475
450
- public init ( from decoder: any Decoder ) throws {
451
- let container = try decoder. container ( keyedBy: CodingKeys . self)
452
-
453
- self . swiftPM = try container. decodeIfPresent ( SwiftPMOptions . self, forKey: CodingKeys . swiftPM) ?? . init( )
454
- self . compilationDatabase =
455
- try container. decodeIfPresent ( CompilationDatabaseOptions . self, forKey: CodingKeys . compilationDatabase) ?? . init( )
456
- self . fallbackBuildSystem =
457
- try container. decodeIfPresent ( FallbackBuildSystemOptions . self, forKey: CodingKeys . fallbackBuildSystem) ?? . init( )
458
- self . clangdOptions = try container. decodeIfPresent ( [ String ] . self, forKey: CodingKeys . clangdOptions)
459
- self . index = try container. decodeIfPresent ( IndexOptions . self, forKey: CodingKeys . index) ?? . init( )
460
- self . logging = try container. decodeIfPresent ( LoggingOptions . self, forKey: . logging) ?? . init( )
461
- self . defaultWorkspaceType = try container. decodeIfPresent (
462
- WorkspaceType . self,
463
- forKey: CodingKeys . defaultWorkspaceType
464
- )
465
- self . generatedFilesPath = try container. decodeIfPresent ( String . self, forKey: CodingKeys . generatedFilesPath)
466
- self . backgroundIndexing = try container. decodeIfPresent ( Bool . self, forKey: CodingKeys . backgroundIndexing)
467
- self . experimentalFeatures = try container. decodeIfPresent (
468
- Set< ExperimentalFeature> . self ,
469
- forKey: CodingKeys . experimentalFeatures
470
- )
471
- self . swiftPublishDiagnosticsDebounceDuration = try container. decodeIfPresent (
472
- Double . self,
473
- forKey: CodingKeys . swiftPublishDiagnosticsDebounceDuration
474
- )
475
- self . workDoneProgressDebounceDuration = try container. decodeIfPresent (
476
- Double . self,
477
- forKey: CodingKeys . workDoneProgressDebounceDuration
478
- )
479
- }
480
-
481
476
public var description : String {
482
477
recursiveDescription ( of: self )
483
478
}
0 commit comments