@@ -92,7 +92,7 @@ public struct SwiftCompileCommand: Equatable {
92
92
93
93
public actor SwiftLanguageService : LanguageService {
94
94
/// The ``SourceKitLSPServer`` instance that created this `ClangLanguageService`.
95
- weak var sourceKitServer : SourceKitLSPServer ?
95
+ weak var sourceKitLSPServer : SourceKitLSPServer ?
96
96
97
97
let sourcekitd : SourceKitD
98
98
@@ -136,7 +136,7 @@ public actor SwiftLanguageService: LanguageService {
136
136
handler ( oldValue, state)
137
137
}
138
138
139
- guard let sourceKitServer else {
139
+ guard let sourceKitLSPServer else {
140
140
sourcekitdCrashedWorkDoneProgress = nil
141
141
return
142
142
}
@@ -146,7 +146,7 @@ public actor SwiftLanguageService: LanguageService {
146
146
case . connectionInterrupted, . semanticFunctionalityDisabled:
147
147
if sourcekitdCrashedWorkDoneProgress == nil {
148
148
sourcekitdCrashedWorkDoneProgress = WorkDoneProgressManager (
149
- server: sourceKitServer ,
149
+ server: sourceKitLSPServer ,
150
150
capabilityRegistry: capabilityRegistry,
151
151
title: " SourceKit-LSP: Restoring functionality " ,
152
152
message: " Please run 'sourcekit-lsp diagnose' to file an issue "
@@ -173,13 +173,13 @@ public actor SwiftLanguageService: LanguageService {
173
173
/// parent server to reopen all of its documents.
174
174
/// Returns `nil` if `sourcekitd` couldn't be found.
175
175
public init ? (
176
- sourceKitServer : SourceKitLSPServer ,
176
+ sourceKitLSPServer : SourceKitLSPServer ,
177
177
toolchain: Toolchain ,
178
178
options: SourceKitLSPServer . Options ,
179
179
workspace: Workspace
180
180
) async throws {
181
181
guard let sourcekitd = toolchain. sourcekitd else { return nil }
182
- self . sourceKitServer = sourceKitServer
182
+ self . sourceKitLSPServer = sourceKitLSPServer
183
183
self . swiftFormat = toolchain. swiftFormat
184
184
self . sourcekitd = try await DynamicallyLoadedSourceKitD . getOrCreate ( dylibPath: sourcekitd)
185
185
self . capabilityRegistry = workspace. capabilityRegistry
@@ -203,11 +203,11 @@ public actor SwiftLanguageService: LanguageService {
203
203
}
204
204
205
205
func buildSettings( for document: DocumentURI ) async -> SwiftCompileCommand ? {
206
- guard let sourceKitServer else {
206
+ guard let sourceKitLSPServer else {
207
207
logger. fault ( " Cannot retrieve build settings because SourceKitLSPServer is no longer alive " )
208
208
return nil
209
209
}
210
- guard let workspace = await sourceKitServer . workspaceForDocument ( uri: document) else {
210
+ guard let workspace = await sourceKitLSPServer . workspaceForDocument ( uri: document) else {
211
211
return nil
212
212
}
213
213
if let settings = await workspace. buildSystemManager. buildSettingsInferredFromMainFile (
@@ -365,7 +365,7 @@ extension SwiftLanguageService {
365
365
if buildSettings == nil || buildSettings!. isFallback, let fileUrl = note. textDocument. uri. fileURL {
366
366
// Do not show this notification for non-file URIs to make sure we don't see this notificaiton for newly created
367
367
// files (which get opened as with a `untitled:Unitled-1` URI by VS Code.
368
- await sourceKitServer ? . sendNotificationToClient (
368
+ await sourceKitLSPServer ? . sendNotificationToClient (
369
369
ShowMessageNotification (
370
370
type: . warning,
371
371
message: """
@@ -435,16 +435,16 @@ extension SwiftLanguageService {
435
435
}
436
436
cancelInFlightPublishDiagnosticsTask ( for: document)
437
437
inFlightPublishDiagnosticsTasks [ document] = Task ( priority: . medium) { [ weak self] in
438
- guard let self, let sourceKitServer = await self . sourceKitServer else {
439
- logger. fault ( " Cannot produce PublishDiagnosticsNotification because sourceKitServer was deallocated " )
438
+ guard let self, let sourceKitLSPServer = await self . sourceKitLSPServer else {
439
+ logger. fault ( " Cannot produce PublishDiagnosticsNotification because sourceKitLSPServer was deallocated " )
440
440
return
441
441
}
442
442
do {
443
443
// Sleep for a little bit until triggering the diagnostic generation. This effectively de-bounces diagnostic
444
444
// generation since any later edit will cancel the previous in-flight task, which will thus never go on to send
445
445
// the `DocumentDiagnosticsRequest`.
446
446
try await Task . sleep (
447
- nanoseconds: UInt64 ( sourceKitServer . options. swiftPublishDiagnosticsDebounceDuration * 1_000_000_000 )
447
+ nanoseconds: UInt64 ( sourceKitLSPServer . options. swiftPublishDiagnosticsDebounceDuration * 1_000_000_000 )
448
448
)
449
449
} catch {
450
450
return
@@ -471,7 +471,7 @@ extension SwiftLanguageService {
471
471
throw CancellationError ( )
472
472
}
473
473
474
- await sourceKitServer . sendNotificationToClient (
474
+ await sourceKitLSPServer . sendNotificationToClient (
475
475
PublishDiagnosticsNotification (
476
476
uri: document,
477
477
diagnostics: diagnosticReport. items
@@ -860,7 +860,7 @@ extension SwiftLanguageService {
860
860
861
861
public func executeCommand( _ req: ExecuteCommandRequest ) async throws -> LSPAny ? {
862
862
// TODO: If there's support for several types of commands, we might need to structure this similarly to the code actions request.
863
- guard let sourceKitServer else {
863
+ guard let sourceKitLSPServer else {
864
864
// `SourceKitLSPServer` has been destructed. We are tearing down the language
865
865
// server. Nothing left to do.
866
866
throw ResponseError . unknown ( " Connection to the editor closed " )
@@ -871,7 +871,7 @@ extension SwiftLanguageService {
871
871
let refactor = try await semanticRefactoring ( swiftCommand)
872
872
let edit = refactor. edit
873
873
let req = ApplyEditRequest ( label: refactor. title, edit: edit)
874
- let response = try await sourceKitServer . sendRequestToClient ( req)
874
+ let response = try await sourceKitLSPServer . sendRequestToClient ( req)
875
875
if !response. applied {
876
876
let reason : String
877
877
if let failureReason = response. failureReason {
@@ -910,8 +910,8 @@ extension SwiftLanguageService: SKDNotificationHandler {
910
910
self . state = . semanticFunctionalityDisabled
911
911
912
912
// Ask our parent to re-open all of our documents.
913
- if let sourceKitServer {
914
- await sourceKitServer . reopenDocuments ( for: self )
913
+ if let sourceKitLSPServer {
914
+ await sourceKitLSPServer . reopenDocuments ( for: self )
915
915
} else {
916
916
logger. fault ( " Cannot reopen documents because SourceKitLSPServer is no longer alive " )
917
917
}
0 commit comments