Skip to content

Commit 685944d

Browse files
committed
Remove unnecessary semantic tokens capability check
1 parent d8df379 commit 685944d

File tree

2 files changed

+3
-29
lines changed

2 files changed

+3
-29
lines changed

Sources/SourceKitLSP/CapabilityRegistry.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,6 @@ public final class CapabilityRegistry {
142142
}
143143
}
144144

145-
/// Checks whether a registration for semantic tokens for the given language exists.
146-
public func hasSemanticTokensRegistration(for language: Language) -> Bool {
147-
registration(for: [language], in: semanticTokens) != nil
148-
}
149-
150145
private func documentSelector(for langauges: [Language]) -> DocumentSelector {
151146
return DocumentSelector(langauges.map { DocumentFilter(language: $0.rawValue) })
152147
}

Sources/SourceKitLSP/SourceKitServer.swift

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -855,49 +855,28 @@ extension SourceKitServer {
855855
languageService.documentColor(req)
856856
}
857857

858-
private func supportsSemanticTokens(in uri: DocumentURI) -> Bool {
859-
guard let workspace = workspace,
860-
let snapshot = workspace.documentManager.latestSnapshot(uri) else {
861-
return false
862-
}
863-
let language = snapshot.document.language
864-
return workspace.capabilityRegistry.hasSemanticTokensRegistration(for: language)
865-
}
866-
867858
func documentSemanticTokens(
868859
_ req: Request<DocumentSemanticTokensRequest>,
869860
workspace: Workspace,
870861
languageService: ToolchainLanguageServer
871862
) {
872-
if supportsSemanticTokens(in: req.params.textDocument.uri) {
873-
languageService.documentSemanticTokens(req)
874-
} else {
875-
req.reply(DocumentSemanticTokensResponse(data: []))
876-
}
863+
languageService.documentSemanticTokens(req)
877864
}
878865

879866
func documentSemanticTokensDelta(
880867
_ req: Request<DocumentSemanticTokensDeltaRequest>,
881868
workspace: Workspace,
882869
languageService: ToolchainLanguageServer
883870
) {
884-
if supportsSemanticTokens(in: req.params.textDocument.uri) {
885-
languageService.documentSemanticTokensDelta(req)
886-
} else {
887-
req.reply(.tokens(.init(data: [])))
888-
}
871+
languageService.documentSemanticTokensDelta(req)
889872
}
890873

891874
func documentSemanticTokensRange(
892875
_ req: Request<DocumentSemanticTokensRangeRequest>,
893876
workspace: Workspace,
894877
languageService: ToolchainLanguageServer
895878
) {
896-
if supportsSemanticTokens(in: req.params.textDocument.uri) {
897-
languageService.documentSemanticTokensRange(req)
898-
} else {
899-
req.reply(DocumentSemanticTokensResponse(data: []))
900-
}
879+
languageService.documentSemanticTokensRange(req)
901880
}
902881

903882
func colorPresentation(

0 commit comments

Comments
 (0)