Skip to content

Commit 0f90ffc

Browse files
committed
Inline _handleUnknown
Since `ClangLanguageServerShim` calls directly into `SourceKitServer` we also no longer need the logic to forward a message from clangd to the editor in `handle`.
1 parent abf456a commit 0f90ffc

File tree

1 file changed

+2
-22
lines changed

1 file changed

+2
-22
lines changed

Sources/SourceKitLSP/SourceKitServer.swift

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -260,16 +260,6 @@ public actor SourceKitServer {
260260
}
261261

262262

263-
public func _handleUnknown<R>(_ req: Request<R>) {
264-
if req.clientID == ObjectIdentifier(client) {
265-
req.reply(.failure(ResponseError.methodNotFound(R.method)))
266-
return
267-
}
268-
269-
// Unknown requests from a language server are passed on to the client.
270-
sendRequestToClient(req.params, reply: req.reply)
271-
}
272-
273263
/// Send the given notification to the editor.
274264
public func sendNotificationToClient(_ notification: some NotificationType) {
275265
client.send(notification)
@@ -286,16 +276,6 @@ public actor SourceKitServer {
286276
// FIXME: (async) Handle cancellation
287277
}
288278

289-
/// Handle an unknown notification.
290-
public func _handleUnknown<N>(_ note: Notification<N>) {
291-
if note.clientID == ObjectIdentifier(client) {
292-
return
293-
}
294-
295-
// Unknown notifications from a language server are passed on to the client.
296-
client.send(note.params)
297-
}
298-
299279
func toolchain(for uri: DocumentURI, _ language: Language) -> Toolchain? {
300280
let supportsLang = { (toolchain: Toolchain) -> Bool in
301281
// FIXME: the fact that we're looking at clangd/sourcekitd instead of the compiler indicates this method needs a parameter stating what kind of tool we're looking for.
@@ -488,7 +468,7 @@ extension SourceKitServer: MessageHandler {
488468
case let notification as Notification<DidSaveTextDocumentNotification>:
489469
await self.withLanguageServiceAndWorkspace(for: notification, notificationHandler: self.didSaveDocument)
490470
default:
491-
self._handleUnknown(notification)
471+
break
492472
}
493473
}
494474

@@ -567,7 +547,7 @@ extension SourceKitServer: MessageHandler {
567547
case let request as Request<DocumentDiagnosticsRequest>:
568548
await self.withLanguageServiceAndWorkspace(for: request, requestHandler: self.documentDiagnostic, fallback: .full(.init(items: [])))
569549
default:
570-
self._handleUnknown(request)
550+
reply(.failure(ResponseError.methodNotFound(R.method)))
571551
}
572552
}
573553

0 commit comments

Comments
 (0)