@@ -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,37 @@ 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
+ private var swiftPM : SwiftPMOptions ?
263
+ public var swiftPMOrDefault : SwiftPMOptions {
264
+ get { swiftPM ?? . init( ) }
265
+ set { swiftPM = newValue }
266
+ }
267
+
268
+ private var compilationDatabase : CompilationDatabaseOptions ?
269
+ public var compilationDatabaseOrDefault : CompilationDatabaseOptions {
270
+ get { compilationDatabase ?? . init( ) }
271
+ set { compilationDatabase = newValue }
272
+ }
273
+
274
+ private var fallbackBuildSystem : FallbackBuildSystemOptions ?
275
+ public var fallbackBuildSystemOrDefault : FallbackBuildSystemOptions {
276
+ get { fallbackBuildSystem ?? . init( ) }
277
+ set { fallbackBuildSystem = newValue }
278
+ }
279
+
265
280
public var clangdOptions : [ String ] ?
266
- public var index : IndexOptions
267
- public var logging : LoggingOptions
281
+
282
+ private var index : IndexOptions ?
283
+ public var indexOrDefault : IndexOptions {
284
+ get { index ?? . init( ) }
285
+ set { index = newValue }
286
+ }
287
+
288
+ private var logging : LoggingOptions ?
289
+ public var loggingOrDefault : LoggingOptions {
290
+ get { logging ?? . init( ) }
291
+ set { logging = newValue }
292
+ }
268
293
269
294
/// Default workspace type (buildserver|compdb|swiftpm). Overrides workspace type selection logic.
270
295
public var defaultWorkspaceType : WorkspaceType ?
@@ -406,18 +431,18 @@ public struct SourceKitLSPOptions: Sendable, Codable, CustomLogStringConvertible
406
431
407
432
public static func merging( base: SourceKitLSPOptions , override: SourceKitLSPOptions ? ) -> SourceKitLSPOptions {
408
433
return SourceKitLSPOptions (
409
- swiftPM: SwiftPMOptions . merging ( base: base. swiftPM , override: override? . swiftPM) ,
434
+ swiftPM: SwiftPMOptions . merging ( base: base. swiftPMOrDefault , override: override? . swiftPM) ,
410
435
fallbackBuildSystem: FallbackBuildSystemOptions . merging (
411
- base: base. fallbackBuildSystem ,
436
+ base: base. fallbackBuildSystemOrDefault ,
412
437
override: override? . fallbackBuildSystem
413
438
) ,
414
439
compilationDatabase: CompilationDatabaseOptions . merging (
415
- base: base. compilationDatabase ,
440
+ base: base. compilationDatabaseOrDefault ,
416
441
override: override? . compilationDatabase
417
442
) ,
418
443
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) ,
444
+ index: IndexOptions . merging ( base: base. indexOrDefault , override: override? . index) ,
445
+ logging: LoggingOptions . merging ( base: base. loggingOrDefault , override: override? . logging) ,
421
446
defaultWorkspaceType: override? . defaultWorkspaceType ?? base. defaultWorkspaceType,
422
447
generatedFilesPath: override? . generatedFilesPath ?? base. generatedFilesPath,
423
448
backgroundIndexing: override? . backgroundIndexing ?? base. backgroundIndexing,
@@ -447,37 +472,6 @@ public struct SourceKitLSPOptions: Sendable, Codable, CustomLogStringConvertible
447
472
return experimentalFeatures. contains ( feature)
448
473
}
449
474
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
475
public var description : String {
482
476
recursiveDescription ( of: self )
483
477
}
0 commit comments