Skip to content

Commit 615dead

Browse files
committed
Remove a couple references to DocCDocumentation
1 parent 83cc023 commit 615dead

File tree

8 files changed

+25
-19
lines changed

8 files changed

+25
-19
lines changed

Package.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ var targets: [Target] = [
246246
"DocCDocumentation",
247247
"LanguageServerProtocol",
248248
"SKUtilities",
249+
"SourceKitLSP",
249250
"SemanticIndex",
250251
.product(name: "Markdown", package: "swift-markdown"),
251252
],

Sources/ClangLanguageService/ClangLanguageService.swift

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ package import SwiftSyntax
2424
import TSCExtensions
2525
package import ToolchainRegistry
2626

27-
#if canImport(DocCDocumentation)
28-
import DocCDocumentation
29-
#endif
30-
3127
#if os(Windows)
3228
import WinSDK
3329
#endif
@@ -497,16 +493,16 @@ extension ClangLanguageService {
497493
return try await forwardRequestToClangd(req)
498494
}
499495

500-
#if canImport(DocCDocumentation)
501496
package func doccDocumentation(_ req: DoccDocumentationRequest) async throws -> DoccDocumentationResponse {
502497
guard let sourceKitLSPServer else {
503498
throw ResponseError.unknown("Connection to the editor closed")
504499
}
505500

506501
let snapshot = try sourceKitLSPServer.documentManager.latestSnapshot(req.textDocument.uri)
507-
throw ResponseError.requestFailed(doccDocumentationError: .unsupportedLanguage(snapshot.language))
502+
throw ResponseError.requestFailed(
503+
"Documentation preview is not available for \(snapshot.language.description) files"
504+
)
508505
}
509-
#endif
510506

511507
package func symbolInfo(_ req: SymbolInfoRequest) async throws -> [SymbolDetails] {
512508
return try await forwardRequestToClangd(req)

Sources/LanguageServerProtocol/Error.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ public struct ErrorCode: RawRepresentable, Codable, Hashable, Sendable {
8383

8484
// MARK: SourceKit-LSP specific error codes
8585
public static let workspaceNotOpen: ErrorCode = ErrorCode(rawValue: -32003)
86+
87+
/// The method is not implemented in this `LanguageService`.
88+
public static let requestNotImplemented: ErrorCode = ErrorCode(rawValue: -32004)
8689
}
8790

8891
/// An error response represented by a code and message.
@@ -131,6 +134,10 @@ extension ResponseError {
131134
public static func internalError(_ message: String) -> ResponseError {
132135
return ResponseError(code: .internalError, message: message)
133136
}
137+
138+
public static func requestNotImplemented(_ method: any RequestType.Type) -> ResponseError {
139+
return ResponseError(code: .requestNotImplemented, message: "request not implemented: \(method.method)")
140+
}
134141
}
135142

136143
/// An error during message decoding.

Sources/SourceKitLSP/LanguageService.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,7 @@ package protocol LanguageService: AnyObject, Sendable {
176176
func completion(_ req: CompletionRequest) async throws -> CompletionList
177177
func completionItemResolve(_ req: CompletionItemResolveRequest) async throws -> CompletionItem
178178
func hover(_ req: HoverRequest) async throws -> HoverResponse?
179-
#if canImport(DocCDocumentation)
180179
func doccDocumentation(_ req: DoccDocumentationRequest) async throws -> DoccDocumentationResponse
181-
#endif
182180
func symbolInfo(_ request: SymbolInfoRequest) async throws -> [SymbolDetails]
183181

184182
/// Return the symbol graph at the given location for the contents of the document as they are on-disk (opposed to the

Sources/SourceKitLSP/SourceKitLSPServer.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -757,10 +757,8 @@ extension SourceKitLSPServer: QueueBasedMessageHandler {
757757
await self.handleRequest(for: request, requestHandler: self.declaration)
758758
case let request as RequestAndReply<DefinitionRequest>:
759759
await self.handleRequest(for: request, requestHandler: self.definition)
760-
#if canImport(DocCDocumentation)
761760
case let request as RequestAndReply<DoccDocumentationRequest>:
762761
await self.handleRequest(for: request, requestHandler: self.doccDocumentation)
763-
#endif
764762
case let request as RequestAndReply<DocumentColorRequest>:
765763
await self.handleRequest(for: request, requestHandler: self.documentColor)
766764
case let request as RequestAndReply<DocumentDiagnosticsRequest>:
@@ -1573,15 +1571,13 @@ extension SourceKitLSPServer {
15731571
return try await documentService(for: uri).completionItemResolve(request)
15741572
}
15751573

1576-
#if canImport(DocCDocumentation)
15771574
func doccDocumentation(
15781575
_ req: DoccDocumentationRequest,
15791576
workspace: Workspace,
15801577
languageService: LanguageService
15811578
) async throws -> DoccDocumentationResponse {
15821579
return try await languageService.doccDocumentation(req)
15831580
}
1584-
#endif
15851581

15861582
func hover(
15871583
_ req: HoverRequest,

Sources/SwiftLanguageService/DoccDocumentation.swift

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,23 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#if canImport(DocCDocumentation)
1413
import BuildServerIntegration
15-
import DocCDocumentation
1614
import Foundation
1715
import IndexStoreDB
1816
package import LanguageServerProtocol
19-
import SemanticIndex
2017
import SKLogging
18+
import SemanticIndex
19+
import SourceKitLSP
2120
import SwiftExtensions
2221
import SwiftSyntax
23-
import SourceKitLSP
22+
23+
#if canImport(DocCDocumentation)
24+
import DocCDocumentation
25+
#endif
2426

2527
extension SwiftLanguageService {
2628
package func doccDocumentation(_ req: DoccDocumentationRequest) async throws -> DoccDocumentationResponse {
29+
#if canImport(DocCDocumentation)
2730
guard let sourceKitLSPServer else {
2831
throw ResponseError.internalError("SourceKit-LSP is shutting down")
2932
}
@@ -100,8 +103,12 @@ extension SwiftLanguageService {
100103
moduleName: moduleName,
101104
catalogURL: catalogURL
102105
)
106+
#else
107+
throw ResponseError.requestFailed("Documentation preview is not available in this build of SourceKit-LSP")
108+
#endif
103109
}
104110

111+
#if canImport(DocCDocumentation)
105112
private func findMarkupExtensionFile(
106113
workspace: Workspace,
107114
documentationManager: DocCDocumentationManager,
@@ -127,6 +134,7 @@ extension SwiftLanguageService {
127134
language: .markdown
128135
)?.text
129136
}
137+
#endif
130138
}
131139

132140
private struct DocumentableSymbol {
@@ -216,4 +224,3 @@ private struct DocumentableSymbol {
216224
return nil
217225
}
218226
}
219-
#endif

Tests/SourceKitLSPTests/DoccDocumentationTests.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import SwiftDocC
2121
import XCTest
2222

2323
final class DoccDocumentationTests: XCTestCase {
24-
2524
func testUnsupportedLanguage() async throws {
2625
try await renderDocumentation(
2726
markedText: "1️⃣",

Tests/SourceKitLSPTests/DocumentationLanguageServiceTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
#if canImport(DocCDocumentation)
1314
import LanguageServerProtocol
1415
import SKTestSupport
1516
import SourceKitLSP
@@ -39,3 +40,4 @@ private func assertHandles(language: Language) async throws {
3940
)
4041
XCTAssertEqual(completions, .init(isIncomplete: false, items: []))
4142
}
43+
#endif

0 commit comments

Comments
 (0)