Skip to content

Commit 0ea3588

Browse files
committed
Rename sourceKitServer -> sourceKitLSPServer
I forgot to rename the variables when renaming the class from `SourceKitServer` to `SourceKitLSPServer`.
1 parent ed5c7e2 commit 0ea3588

File tree

5 files changed

+31
-31
lines changed

5 files changed

+31
-31
lines changed

Sources/SourceKitLSP/Clang/ClangLanguageService.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ actor ClangLanguageService: LanguageService, MessageHandler {
7474
/// The ``SourceKitLSPServer`` instance that created this `ClangLanguageService`.
7575
///
7676
/// Used to send requests and notifications to the editor.
77-
private weak var sourceKitServer: SourceKitLSPServer?
77+
private weak var sourceKitLSPServer: SourceKitLSPServer?
7878

7979
/// The connection to the clangd LSP. `nil` until `startClangdProcesss` has been called.
8080
var clangd: Connection!
@@ -133,7 +133,7 @@ actor ClangLanguageService: LanguageService, MessageHandler {
133133
/// Creates a language server for the given client referencing the clang binary specified in `toolchain`.
134134
/// Returns `nil` if `clangd` can't be found.
135135
public init?(
136-
sourceKitServer: SourceKitLSPServer,
136+
sourceKitLSPServer: SourceKitLSPServer,
137137
toolchain: Toolchain,
138138
options: SourceKitLSPServer.Options,
139139
workspace: Workspace
@@ -146,7 +146,7 @@ actor ClangLanguageService: LanguageService, MessageHandler {
146146
self.clangdOptions = options.clangdOptions
147147
self.workspace = WeakWorkspace(workspace)
148148
self.state = .connected
149-
self.sourceKitServer = sourceKitServer
149+
self.sourceKitLSPServer = sourceKitLSPServer
150150
try startClangdProcess()
151151
}
152152

@@ -286,8 +286,8 @@ actor ClangLanguageService: LanguageService, MessageHandler {
286286
// But since SourceKitLSPServer more or less ignores them right now anyway, this should be fine for now.
287287
_ = try await self.initialize(initializeRequest)
288288
self.clientInitialized(InitializedNotification())
289-
if let sourceKitServer {
290-
await sourceKitServer.reopenDocuments(for: self)
289+
if let sourceKitLSPServer {
290+
await sourceKitLSPServer.reopenDocuments(for: self)
291291
} else {
292292
logger.fault("Cannot reopen documents because SourceKitLSPServer is no longer alive")
293293
}
@@ -337,15 +337,15 @@ actor ClangLanguageService: LanguageService, MessageHandler {
337337
"""
338338
)
339339
clangdMessageHandlingQueue.async {
340-
guard let sourceKitServer = await self.sourceKitServer else {
340+
guard let sourceKitLSPServer = await self.sourceKitLSPServer else {
341341
// `SourceKitLSPServer` has been destructed. We are tearing down the language
342342
// server. Nothing left to do.
343343
reply(.failure(.unknown("Connection to the editor closed")))
344344
return
345345
}
346346

347347
do {
348-
let result = try await sourceKitServer.sendRequestToClient(params)
348+
let result = try await sourceKitLSPServer.sendRequestToClient(params)
349349
reply(.success(result))
350350
} catch {
351351
reply(.failure(ResponseError(error)))
@@ -404,21 +404,21 @@ extension ClangLanguageService {
404404
// non-fallback settings very shortly after, which will override the
405405
// incorrect result, making it very temporary.
406406
let buildSettings = await self.buildSettings(for: notification.uri)
407-
guard let sourceKitServer else {
407+
guard let sourceKitLSPServer else {
408408
logger.fault("Cannot publish diagnostics because SourceKitLSPServer has been destroyed")
409409
return
410410
}
411411
if buildSettings?.isFallback ?? true {
412412
// Fallback: send empty publish notification instead.
413-
await sourceKitServer.sendNotificationToClient(
413+
await sourceKitLSPServer.sendNotificationToClient(
414414
PublishDiagnosticsNotification(
415415
uri: notification.uri,
416416
version: notification.version,
417417
diagnostics: []
418418
)
419419
)
420420
} else {
421-
await sourceKitServer.sendNotificationToClient(notification)
421+
await sourceKitLSPServer.sendNotificationToClient(notification)
422422
}
423423
}
424424

Sources/SourceKitLSP/LanguageService.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public protocol LanguageService: AnyObject {
6969
// MARK: - Creation
7070

7171
init?(
72-
sourceKitServer: SourceKitLSPServer,
72+
sourceKitLSPServer: SourceKitLSPServer,
7373
toolchain: Toolchain,
7474
options: SourceKitLSPServer.Options,
7575
workspace: Workspace

Sources/SourceKitLSP/SourceKitLSPServer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ public actor SourceKitLSPServer {
700700
// Start a new service.
701701
return await orLog("failed to start language service", level: .error) {
702702
let service = try await serverType.serverType.init(
703-
sourceKitServer: self,
703+
sourceKitLSPServer: self,
704704
toolchain: toolchain,
705705
options: options,
706706
workspace: workspace

Sources/SourceKitLSP/Swift/SwiftLanguageService.swift

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public struct SwiftCompileCommand: Equatable {
9292

9393
public actor SwiftLanguageService: LanguageService {
9494
/// The ``SourceKitLSPServer`` instance that created this `ClangLanguageService`.
95-
weak var sourceKitServer: SourceKitLSPServer?
95+
weak var sourceKitLSPServer: SourceKitLSPServer?
9696

9797
let sourcekitd: SourceKitD
9898

@@ -136,7 +136,7 @@ public actor SwiftLanguageService: LanguageService {
136136
handler(oldValue, state)
137137
}
138138

139-
guard let sourceKitServer else {
139+
guard let sourceKitLSPServer else {
140140
sourcekitdCrashedWorkDoneProgress = nil
141141
return
142142
}
@@ -146,7 +146,7 @@ public actor SwiftLanguageService: LanguageService {
146146
case .connectionInterrupted, .semanticFunctionalityDisabled:
147147
if sourcekitdCrashedWorkDoneProgress == nil {
148148
sourcekitdCrashedWorkDoneProgress = WorkDoneProgressManager(
149-
server: sourceKitServer,
149+
server: sourceKitLSPServer,
150150
capabilityRegistry: capabilityRegistry,
151151
title: "SourceKit-LSP: Restoring functionality",
152152
message: "Please run 'sourcekit-lsp diagnose' to file an issue"
@@ -173,13 +173,13 @@ public actor SwiftLanguageService: LanguageService {
173173
/// parent server to reopen all of its documents.
174174
/// Returns `nil` if `sourcekitd` couldn't be found.
175175
public init?(
176-
sourceKitServer: SourceKitLSPServer,
176+
sourceKitLSPServer: SourceKitLSPServer,
177177
toolchain: Toolchain,
178178
options: SourceKitLSPServer.Options,
179179
workspace: Workspace
180180
) async throws {
181181
guard let sourcekitd = toolchain.sourcekitd else { return nil }
182-
self.sourceKitServer = sourceKitServer
182+
self.sourceKitLSPServer = sourceKitLSPServer
183183
self.swiftFormat = toolchain.swiftFormat
184184
self.sourcekitd = try await DynamicallyLoadedSourceKitD.getOrCreate(dylibPath: sourcekitd)
185185
self.capabilityRegistry = workspace.capabilityRegistry
@@ -203,11 +203,11 @@ public actor SwiftLanguageService: LanguageService {
203203
}
204204

205205
func buildSettings(for document: DocumentURI) async -> SwiftCompileCommand? {
206-
guard let sourceKitServer else {
206+
guard let sourceKitLSPServer else {
207207
logger.fault("Cannot retrieve build settings because SourceKitLSPServer is no longer alive")
208208
return nil
209209
}
210-
guard let workspace = await sourceKitServer.workspaceForDocument(uri: document) else {
210+
guard let workspace = await sourceKitLSPServer.workspaceForDocument(uri: document) else {
211211
return nil
212212
}
213213
if let settings = await workspace.buildSystemManager.buildSettingsInferredFromMainFile(
@@ -365,7 +365,7 @@ extension SwiftLanguageService {
365365
if buildSettings == nil || buildSettings!.isFallback, let fileUrl = note.textDocument.uri.fileURL {
366366
// Do not show this notification for non-file URIs to make sure we don't see this notificaiton for newly created
367367
// files (which get opened as with a `untitled:Unitled-1` URI by VS Code.
368-
await sourceKitServer?.sendNotificationToClient(
368+
await sourceKitLSPServer?.sendNotificationToClient(
369369
ShowMessageNotification(
370370
type: .warning,
371371
message: """
@@ -435,16 +435,16 @@ extension SwiftLanguageService {
435435
}
436436
cancelInFlightPublishDiagnosticsTask(for: document)
437437
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")
440440
return
441441
}
442442
do {
443443
// Sleep for a little bit until triggering the diagnostic generation. This effectively de-bounces diagnostic
444444
// generation since any later edit will cancel the previous in-flight task, which will thus never go on to send
445445
// the `DocumentDiagnosticsRequest`.
446446
try await Task.sleep(
447-
nanoseconds: UInt64(sourceKitServer.options.swiftPublishDiagnosticsDebounceDuration * 1_000_000_000)
447+
nanoseconds: UInt64(sourceKitLSPServer.options.swiftPublishDiagnosticsDebounceDuration * 1_000_000_000)
448448
)
449449
} catch {
450450
return
@@ -471,7 +471,7 @@ extension SwiftLanguageService {
471471
throw CancellationError()
472472
}
473473

474-
await sourceKitServer.sendNotificationToClient(
474+
await sourceKitLSPServer.sendNotificationToClient(
475475
PublishDiagnosticsNotification(
476476
uri: document,
477477
diagnostics: diagnosticReport.items
@@ -860,7 +860,7 @@ extension SwiftLanguageService {
860860

861861
public func executeCommand(_ req: ExecuteCommandRequest) async throws -> LSPAny? {
862862
// 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 {
864864
// `SourceKitLSPServer` has been destructed. We are tearing down the language
865865
// server. Nothing left to do.
866866
throw ResponseError.unknown("Connection to the editor closed")
@@ -871,7 +871,7 @@ extension SwiftLanguageService {
871871
let refactor = try await semanticRefactoring(swiftCommand)
872872
let edit = refactor.edit
873873
let req = ApplyEditRequest(label: refactor.title, edit: edit)
874-
let response = try await sourceKitServer.sendRequestToClient(req)
874+
let response = try await sourceKitLSPServer.sendRequestToClient(req)
875875
if !response.applied {
876876
let reason: String
877877
if let failureReason = response.failureReason {
@@ -910,8 +910,8 @@ extension SwiftLanguageService: SKDNotificationHandler {
910910
self.state = .semanticFunctionalityDisabled
911911

912912
// 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)
915915
} else {
916916
logger.fault("Cannot reopen documents because SourceKitLSPServer is no longer alive")
917917
}

Tests/SourceKitLSPTests/SwiftPMIntegration.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ final class SwiftPMIntegrationTests: XCTestCase {
183183
}
184184

185185
func testNestedPackage() async throws {
186-
let ws = try await MultiFileTestWorkspace(files: [
186+
let project = try await MultiFileTestProject(files: [
187187
"pkg/Sources/lib/lib.swift": "",
188188
"pkg/Package.swift": """
189189
// swift-tools-version:4.2
@@ -209,9 +209,9 @@ final class SwiftPMIntegrationTests: XCTestCase {
209209
""",
210210
])
211211

212-
let (uri, positions) = try ws.openDocument("b.swift")
212+
let (uri, positions) = try project.openDocument("b.swift")
213213

214-
let result = try await ws.testClient.send(
214+
let result = try await project.testClient.send(
215215
CompletionRequest(textDocument: TextDocumentIdentifier(uri), position: positions["1️⃣"])
216216
)
217217

0 commit comments

Comments
 (0)