Skip to content

Commit 4b5f7ff

Browse files
committed
Rename SourceKitServer -> SourceKitLSPServer
This avoid ambiguities whether `SourceKitServer` handles sourcekitd or `sourcekit-lsp`.
1 parent 83837ce commit 4b5f7ff

17 files changed

+85
-86
lines changed

Sources/SKTestSupport/IndexedSingleSwiftFileWorkspace.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public struct IndexedSingleSwiftFileWorkspace {
9595
}
9696

9797
// Create the test client
98-
var options = SourceKitServer.Options.testDefault
98+
var options = SourceKitLSPServer.Options.testDefault
9999
options.indexOptions = IndexOptions(
100100
indexStorePath: try AbsolutePath(validating: indexURL.path),
101101
indexDatabasePath: try AbsolutePath(validating: indexDBURL.path)

Sources/SKTestSupport/TestSourceKitLSPClient.swift

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import SourceKitLSP
2020
import SwiftSyntax
2121
import XCTest
2222

23-
extension SourceKitServer.Options {
24-
/// The default SourceKitServer options for testing.
23+
extension SourceKitLSPServer.Options {
24+
/// The default SourceKitLSPServer options for testing.
2525
public static var testDefault = Self(swiftPublishDiagnosticsDebounceDuration: 0)
2626
}
2727

@@ -44,7 +44,7 @@ public final class TestSourceKitLSPClient: MessageHandler {
4444
private let moduleCache: URL?
4545

4646
/// The server that handles the requests.
47-
public let server: SourceKitServer
47+
public let server: SourceKitLSPServer
4848

4949
/// Whether pull or push-model diagnostics should be used.
5050
///
@@ -87,7 +87,7 @@ public final class TestSourceKitLSPClient: MessageHandler {
8787
/// This allows e.g. a `IndexedSingleSwiftFileWorkspace` to delete its temporary files when they are no longer
8888
/// needed.
8989
public init(
90-
serverOptions: SourceKitServer.Options = .testDefault,
90+
serverOptions: SourceKitLSPServer.Options = .testDefault,
9191
useGlobalModuleCache: Bool = true,
9292
initialize: Bool = true,
9393
initializationOptions: LSPAny? = nil,
@@ -114,7 +114,7 @@ public final class TestSourceKitLSPClient: MessageHandler {
114114

115115
let serverToClientConnection = LocalConnection()
116116
self.serverToClientConnection = serverToClientConnection
117-
server = SourceKitServer(
117+
server = SourceKitLSPServer(
118118
client: serverToClientConnection,
119119
toolchainRegistry: ToolchainRegistry.forTesting,
120120
options: serverOptions,
@@ -262,26 +262,25 @@ public final class TestSourceKitLSPClient: MessageHandler {
262262

263263
/// Handle the next request that is sent to the client with the given handler.
264264
///
265-
/// By default, `TestSourceKitServer` emits an `XCTFail` if a request is sent
265+
/// By default, `TestSourceKitLSPClient` emits an `XCTFail` if a request is sent
266266
/// to the client, since it doesn't know how to handle it. This allows the
267267
/// simulation of a single request's handling on the client.
268268
///
269269
/// If the next request that is sent to the client is of a different kind than
270-
/// the given handler, `TestSourceKitServer` will emit an `XCTFail`.
270+
/// the given handler, `TestSourceKitLSPClient` will emit an `XCTFail`.
271271
public func handleNextRequest<R: RequestType>(_ requestHandler: @escaping RequestHandler<R>) {
272272
requestHandlers.append(requestHandler)
273273
}
274274

275275
// MARK: - Conformance to MessageHandler
276276

277-
/// - Important: Implementation detail of `TestSourceKitServer`. Do not call
277+
/// - Important: Implementation detail of `TestSourceKitLSPServer`. Do not call
278278
/// from tests.
279279
public func handle(_ params: some NotificationType) {
280280
notificationYielder.yield(params)
281281
}
282282

283-
/// - Important: Implementation detail of `TestSourceKitServer`. Do not call
284-
/// from tests.
283+
/// - Important: Implementation detail of `TestSourceKitLSPClient`. Do not call from tests.
285284
public func handle<Request: RequestType>(
286285
_ params: Request,
287286
id: LanguageServerProtocol.RequestID,
@@ -393,8 +392,8 @@ public struct DocumentPositions {
393392

394393
/// Wrapper around a weak `MessageHandler`.
395394
///
396-
/// This allows us to set the ``TestSourceKitServer`` as the message handler of
397-
/// `SourceKitServer` without retaining it.
395+
/// This allows us to set the ``TestSourceKitLSPClient`` as the message handler of
396+
/// `SourceKitLSPServer` without retaining it.
398397
private class WeakMessageHandler: MessageHandler {
399398
private weak var handler: (any MessageHandler)?
400399

Sources/SourceKitLSP/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ add_library(SourceKitLSP STATIC
88
Sequence+AsyncMap.swift
99
SourceKitIndexDelegate.swift
1010
SourceKitLSPCommandMetadata.swift
11-
SourceKitServer.swift
12-
SourceKitServer+Options.swift
11+
SourceKitLSPServer.swift
12+
SourceKitLSPServer+Options.swift
1313
TestDiscovery.swift
1414
ToolchainLanguageServer.swift
1515
WorkDoneProgressManager.swift

Sources/SourceKitLSP/CapabilityRegistry.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public final actor CapabilityRegistry {
135135
options: Options,
136136
forMethod method: String,
137137
languages: [Language],
138-
in server: SourceKitServer,
138+
in server: SourceKitLSPServer,
139139
registrationDict: [CapabilityRegistration: Options],
140140
setRegistrationDict: (CapabilityRegistration, Options?) -> Void
141141
) async {
@@ -176,7 +176,7 @@ public final actor CapabilityRegistry {
176176
public func registerCompletionIfNeeded(
177177
options: CompletionOptions,
178178
for languages: [Language],
179-
server: SourceKitServer
179+
server: SourceKitLSPServer
180180
) async {
181181
guard clientHasDynamicCompletionRegistration else { return }
182182

@@ -195,7 +195,7 @@ public final actor CapabilityRegistry {
195195

196196
public func registerDidChangeWatchedFiles(
197197
watchers: [FileSystemWatcher],
198-
server: SourceKitServer
198+
server: SourceKitLSPServer
199199
) async {
200200
guard clientHasDynamicDidChangeWatchedFilesRegistration else { return }
201201
if let registration = didChangeWatchedFiles {
@@ -230,7 +230,7 @@ public final actor CapabilityRegistry {
230230
public func registerFoldingRangeIfNeeded(
231231
options: FoldingRangeOptions,
232232
for languages: [Language],
233-
server: SourceKitServer
233+
server: SourceKitLSPServer
234234
) async {
235235
guard clientHasDynamicFoldingRangeRegistration else { return }
236236

@@ -253,7 +253,7 @@ public final actor CapabilityRegistry {
253253
public func registerSemanticTokensIfNeeded(
254254
options: SemanticTokensOptions,
255255
for languages: [Language],
256-
server: SourceKitServer
256+
server: SourceKitLSPServer
257257
) async {
258258
guard clientHasDynamicSemanticTokensRegistration else { return }
259259

@@ -276,7 +276,7 @@ public final actor CapabilityRegistry {
276276
public func registerInlayHintIfNeeded(
277277
options: InlayHintOptions,
278278
for languages: [Language],
279-
server: SourceKitServer
279+
server: SourceKitLSPServer
280280
) async {
281281
guard clientHasDynamicInlayHintRegistration else { return }
282282
await registerLanguageSpecificCapability(
@@ -297,7 +297,7 @@ public final actor CapabilityRegistry {
297297
public func registerDiagnosticIfNeeded(
298298
options: DiagnosticOptions,
299299
for languages: [Language],
300-
server: SourceKitServer
300+
server: SourceKitLSPServer
301301
) async {
302302
guard clientHasDynamicDocumentDiagnosticsRegistration else { return }
303303

@@ -318,7 +318,7 @@ public final actor CapabilityRegistry {
318318
/// it and we haven't yet registered the given command IDs yet.
319319
public func registerExecuteCommandIfNeeded(
320320
commands: [String],
321-
server: SourceKitServer
321+
server: SourceKitLSPServer
322322
) {
323323
guard clientHasDynamicExecuteCommandRegistration else { return }
324324

Sources/SourceKitLSP/Clang/ClangLanguageServer.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ actor ClangLanguageServerShim: ToolchainLanguageServer, MessageHandler {
7171
/// requests and notifications sent from clangd to the client is quite small.
7272
public let clangdMessageHandlingQueue = AsyncQueue<Serial>()
7373

74-
/// The ``SourceKitServer`` instance that created this `ClangLanguageServerShim`.
74+
/// The ``SourceKitLSPServer`` instance that created this `ClangLanguageServerShim`.
7575
///
7676
/// Used to send requests and notifications to the editor.
77-
private weak var sourceKitServer: SourceKitServer?
77+
private weak var sourceKitServer: SourceKitLSPServer?
7878

7979
/// The connection to the clangd LSP. `nil` until `startClangdProcesss` has been called.
8080
var clangd: Connection!
@@ -133,9 +133,9 @@ actor ClangLanguageServerShim: ToolchainLanguageServer, 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: SourceKitServer,
136+
sourceKitServer: SourceKitLSPServer,
137137
toolchain: Toolchain,
138-
options: SourceKitServer.Options,
138+
options: SourceKitLSPServer.Options,
139139
workspace: Workspace
140140
) async throws {
141141
guard let clangdPath = toolchain.clangd else {
@@ -282,14 +282,14 @@ actor ClangLanguageServerShim: ToolchainLanguageServer, MessageHandler {
282282
do {
283283
try self.startClangdProcess()
284284
// FIXME: We assume that clangd will return the same capabilities after restarting.
285-
// Theoretically they could have changed and we would need to inform SourceKitServer about them.
286-
// But since SourceKitServer more or less ignores them right now anyway, this should be fine for now.
285+
// Theoretically they could have changed and we would need to inform SourceKitLSPServer about them.
286+
// 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())
289289
if let sourceKitServer {
290290
await sourceKitServer.reopenDocuments(for: self)
291291
} else {
292-
logger.fault("Cannot reopen documents because SourceKitServer is no longer alive")
292+
logger.fault("Cannot reopen documents because SourceKitLSPServer is no longer alive")
293293
}
294294
self.state = .connected
295295
} catch {
@@ -338,7 +338,7 @@ actor ClangLanguageServerShim: ToolchainLanguageServer, MessageHandler {
338338
)
339339
clangdMessageHandlingQueue.async {
340340
guard let sourceKitServer = await self.sourceKitServer else {
341-
// `SourceKitServer` has been destructed. We are tearing down the language
341+
// `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
@@ -405,7 +405,7 @@ extension ClangLanguageServerShim {
405405
// incorrect result, making it very temporary.
406406
let buildSettings = await self.buildSettings(for: notification.uri)
407407
guard let sourceKitServer else {
408-
logger.fault("Cannot publish diagnostics because SourceKitServer has been destroyed")
408+
logger.fault("Cannot publish diagnostics because SourceKitLSPServer has been destroyed")
409409
return
410410
}
411411
if buildSettings?.isFallback ?? true {

Sources/SourceKitLSP/Rename.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ public struct CrossLanguageName {
495495
}
496496
}
497497

498-
// MARK: - SourceKitServer
498+
// MARK: - SourceKitLSPServer
499499

500500
/// The kinds of symbol occurrence roles that should be renamed.
501501
fileprivate let renameRoles: SymbolRole = [.declaration, .definition, .reference]
@@ -508,7 +508,7 @@ extension DocumentManager {
508508
}
509509
}
510510

511-
extension SourceKitServer {
511+
extension SourceKitLSPServer {
512512
/// Returns a `DocumentSnapshot`, a position and the corresponding language service that references
513513
/// `usr` from a Swift file. If `usr` is not referenced from Swift, returns `nil`.
514514
private func getReferenceFromSwift(

Sources/SourceKitLSP/SourceKitServer+Options.swift renamed to Sources/SourceKitLSP/SourceKitLSPServer+Options.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import SKSupport
1818
import struct TSCBasic.AbsolutePath
1919
import struct TSCBasic.RelativePath
2020

21-
extension SourceKitServer {
21+
extension SourceKitLSPServer {
2222

2323
/// Configuration options for the SourceKitServer.
2424
public struct Options {

Sources/SourceKitLSP/SourceKitServer.swift renamed to Sources/SourceKitLSP/SourceKitLSPServer.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ final actor WorkDoneProgressState {
132132
/// Start a new task, creating a new `WorkDoneProgress` if none is running right now.
133133
///
134134
/// - Parameter server: The server that is used to create the `WorkDoneProgress` on the client
135-
func startProgress(server: SourceKitServer) async {
135+
func startProgress(server: SourceKitLSPServer) async {
136136
activeTasks += 1
137137
guard await server.capabilityRegistry?.clientCapabilities.window?.workDoneProgress ?? false else {
138138
// If the client doesn't support workDoneProgress, keep track of the active task count but don't update the state.
@@ -154,7 +154,7 @@ final actor WorkDoneProgressState {
154154

155155
private func handleCreateWorkDoneProgressResponse(
156156
_ result: Result<VoidResponse, ResponseError>,
157-
server: SourceKitServer
157+
server: SourceKitLSPServer
158158
) {
159159
if result.success != nil {
160160
if self.activeTasks == 0 {
@@ -177,7 +177,7 @@ final actor WorkDoneProgressState {
177177
/// If this drops the active task count to 0, the work done progress is ended on the client.
178178
///
179179
/// - Parameter server: The server that is used to send and update of the `WorkDoneProgress` to the client
180-
func endProgress(server: SourceKitServer) async {
180+
func endProgress(server: SourceKitLSPServer) async {
181181
assert(activeTasks > 0, "Unbalanced startProgress/endProgress calls")
182182
activeTasks -= 1
183183
guard await server.capabilityRegistry?.clientCapabilities.window?.workDoneProgress ?? false else {
@@ -385,12 +385,12 @@ fileprivate enum TaskMetadata: DependencyTracker {
385385
}
386386
}
387387

388-
/// The SourceKit language server.
388+
/// The SourceKit-LSP server.
389389
///
390390
/// This is the client-facing language server implementation, providing indexing, multiple-toolchain
391391
/// and cross-language support. Requests may be dispatched to language-specific services or handled
392392
/// centrally, but this is transparent to the client.
393-
public actor SourceKitServer {
393+
public actor SourceKitLSPServer {
394394
/// The queue on which all messages (notifications, requests, responses) are
395395
/// handled.
396396
///
@@ -422,7 +422,7 @@ public actor SourceKitServer {
422422
let documentManager = DocumentManager()
423423

424424
private var packageLoadingWorkDoneProgress = WorkDoneProgressState(
425-
"SourceKitLSP.SourceKitServer.reloadPackage",
425+
"SourceKitLSP.SourceKitLSPServer.reloadPackage",
426426
title: "SourceKit-LSP: Reloading Package"
427427
)
428428

@@ -813,7 +813,7 @@ private func getNextNotificationIDForLogging() -> Int {
813813
}
814814
}
815815

816-
extension SourceKitServer: MessageHandler {
816+
extension SourceKitLSPServer: MessageHandler {
817817
public nonisolated func handle(_ params: some NotificationType) {
818818
if let params = params as? CancelRequestNotification {
819819
// Request cancellation needs to be able to overtake any other message we
@@ -1018,7 +1018,7 @@ extension SourceKitServer: MessageHandler {
10181018

10191019
// MARK: - Build System Delegate
10201020

1021-
extension SourceKitServer: BuildSystemDelegate {
1021+
extension SourceKitLSPServer: BuildSystemDelegate {
10221022
public func buildTargetsChanged(_ changes: [BuildTargetEvent]) {
10231023
// TODO: do something with these changes once build target support is in place
10241024
}
@@ -1104,7 +1104,7 @@ private extension LanguageServerProtocol.WorkspaceType {
11041104

11051105
// MARK: - Request and notification handling
11061106

1107-
extension SourceKitServer {
1107+
extension SourceKitLSPServer {
11081108

11091109
// MARK: - General
11101110

@@ -1328,7 +1328,7 @@ extension SourceKitServer {
13281328
registry: CapabilityRegistry
13291329
) async {
13301330
// IMPORTANT: When adding new capabilities here, also add the value of that capability in `SwiftLanguageServer`
1331-
// to SourceKitServer.serverCapabilities. That way the capabilities get registered for all languages in case the
1331+
// to SourceKitLSPServer.serverCapabilities. That way the capabilities get registered for all languages in case the
13321332
// client does not support dynamic capability registration.
13331333

13341334
if let completionOptions = server.completionProvider {
@@ -1544,7 +1544,7 @@ extension SourceKitServer {
15441544
// In practice, it is fine: sourcekit-lsp will not handle any new messages
15451545
// while we are executing this function and thus there's no risk of
15461546
// documents or workspaces changing. To hit the race condition, you need
1547-
// to invoke the API of `SourceKitServer` directly and open documents
1547+
// to invoke the API of `SourceKitLSPServer` directly and open documents
15481548
// while this function is executing. Even in such an API use case, hitting
15491549
// that race condition seems very unlikely.
15501550
var preChangeWorkspaces: [DocumentURI: Workspace] = [:]
@@ -2492,7 +2492,7 @@ fileprivate struct NotificationRequestOperation {
24922492
/// Used to queue up notifications and requests for documents which are blocked
24932493
/// on `BuildSystem` operations such as fetching build settings.
24942494
///
2495-
/// Note: This is not thread safe. Must be called from the `SourceKitServer.queue`.
2495+
/// Note: This is not thread safe. Must be called from the `SourceKitLSPServer.queue`.
24962496
fileprivate struct DocumentNotificationRequestQueue {
24972497
fileprivate var queue = [NotificationRequestOperation]()
24982498

0 commit comments

Comments
 (0)