Skip to content

Commit f03ae0b

Browse files
rename request to textDocument/doccDocumentation
1 parent ca9d2e9 commit f03ae0b

File tree

7 files changed

+58
-57
lines changed

7 files changed

+58
-57
lines changed

Contributor Documentation/LSP Extensions.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ interface SKCompletionOptions {
169169
}
170170
```
171171
172-
## `textDocument/convertDocumentation`
172+
## `textDocument/doccDocumentation`
173173
174174
New request that returns a RenderNode for a symbol at a given location that can then be
175175
rendered in an editor by `swiftlang/swift-docc-render`.
@@ -180,11 +180,11 @@ or an error if the documentation could not be converted. This error message can
180180
to the user in the live preview editor.
181181
182182
At the moment this request is only available on macOS and Linux. If SourceKit-LSP supports
183-
this request it will add `textDocument/convertDocumentation` to its experimental server
183+
this request it will add `textDocument/doccDocumentation` to its experimental server
184184
capabilities.
185185
186186
```ts
187-
export interface ConvertDocumentationParams {
187+
export interface DoccDocumentationParams {
188188
/**
189189
* The document to render documentation for.
190190
*/
@@ -199,7 +199,7 @@ export interface ConvertDocumentationParams {
199199
position: Position;
200200
}
201201

202-
export type ConvertDocumentationResponse = RenderNodeResponse | ErrorResponse;
202+
export type DoccDocumentationResponse = RenderNodeResponse | ErrorResponse;
203203

204204
interface RenderNodeResponse {
205205
/**
@@ -222,10 +222,10 @@ interface ErrorResponse {
222222
/**
223223
* The error that occurred.
224224
*/
225-
error: ConvertDocumentationError;
225+
error: DoccDocumentationError;
226226
}
227227

228-
export type ConvertDocumentationError = ErrorWithNoParams | SymbolNotFoundError;
228+
export type DoccDocumentationError = ErrorWithNoParams | SymbolNotFoundError;
229229

230230
interface ErrorWithNoParams {
231231
/**

Sources/LanguageServerProtocol/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ add_library(LanguageServerProtocol STATIC
3838
Requests/ColorPresentationRequest.swift
3939
Requests/CompletionItemResolveRequest.swift
4040
Requests/CompletionRequest.swift
41-
Requests/ConvertDocumentationRequest.swift
4241
Requests/CreateWorkDoneProgressRequest.swift
4342
Requests/DeclarationRequest.swift
4443
Requests/DefinitionRequest.swift
4544
Requests/DiagnosticsRefreshRequest.swift
45+
Requests/DoccDocumentationRequest.swift
4646
Requests/DocumentColorRequest.swift
4747
Requests/DocumentDiagnosticsRequest.swift
4848
Requests/DocumentHighlightRequest.swift

Sources/LanguageServerProtocol/Messages.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public let builtinRequests: [_RequestType.Type] = [
3333
DeclarationRequest.self,
3434
DefinitionRequest.self,
3535
DiagnosticsRefreshRequest.self,
36+
DoccDocumentationRequest.self,
3637
DocumentColorRequest.self,
3738
DocumentDiagnosticsRequest.self,
3839
DocumentFormattingRequest.self,
@@ -70,7 +71,6 @@ public let builtinRequests: [_RequestType.Type] = [
7071
ShowMessageRequest.self,
7172
ShutdownRequest.self,
7273
SignatureHelpRequest.self,
73-
ConvertDocumentationRequest.self,
7474
SymbolInfoRequest.self,
7575
TriggerReindexRequest.self,
7676
TypeDefinitionRequest.self,

Sources/LanguageServerProtocol/Requests/ConvertDocumentationRequest.swift renamed to Sources/LanguageServerProtocol/Requests/DoccDocumentationRequest.swift

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,46 +10,46 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
/// Request for converting documentation for the symbol at a given location **(LSP Extension)**.
13+
/// Request for generating documentation for the symbol at a given location **(LSP Extension)**.
1414
///
1515
/// This request looks up the symbol (if any) at a given text document location and returns a
16-
/// ``ConvertDocumentationResponse`` for that location. This request is primarily designed for editors
16+
/// ``DoccDocumentationResponse`` for that location. This request is primarily designed for editors
1717
/// to support live preview of Swift documentation.
1818
///
1919
/// - Parameters:
2020
/// - textDocument: The document to render documentation for.
21-
/// - position: The document location at which to lookup symbol information.
21+
/// - position: The document location at which to lookup symbol information. (optional)
2222
///
23-
/// - Returns: A ``ConvertDocumentationResponse`` for the given location, which may contain an error
23+
/// - Returns: A ``DoccDocumentationResponse`` for the given location, which may contain an error
2424
/// message if documentation could not be converted. This error message can be displayed to the user
2525
/// in the live preview editor.
2626
///
2727
/// ### LSP Extension
2828
///
2929
/// This request is an extension to LSP supported by SourceKit-LSP.
3030
/// The client is expected to display the documentation in an editor using swift-docc-render.
31-
public struct ConvertDocumentationRequest: TextDocumentRequest, Hashable {
32-
public static let method: String = "textDocument/convertDocumentation"
33-
public typealias Response = ConvertDocumentationResponse
31+
public struct DoccDocumentationRequest: TextDocumentRequest, Hashable {
32+
public static let method: String = "textDocument/doccDocumentation"
33+
public typealias Response = DoccDocumentationResponse
3434

3535
/// The document in which to lookup the symbol location.
3636
public var textDocument: TextDocumentIdentifier
3737

3838
/// The document location at which to lookup symbol information.
39-
public var position: Position
39+
public var position: Position?
4040

41-
public init(textDocument: TextDocumentIdentifier, position: Position) {
41+
public init(textDocument: TextDocumentIdentifier, position: Position?) {
4242
self.textDocument = textDocument
4343
self.position = position
4444
}
4545
}
4646

47-
public enum ConvertDocumentationResponse: ResponseType {
47+
public enum DoccDocumentationResponse: ResponseType {
4848
case renderNode(String)
49-
case error(ConvertDocumentationError)
49+
case error(DoccDocumentationError)
5050
}
5151

52-
public enum ConvertDocumentationError: ResponseType, Equatable {
52+
public enum DoccDocumentationError: ResponseType, Equatable {
5353
case indexNotAvailable
5454
case noDocumentation
5555
case symbolNotFound(String)
@@ -66,7 +66,7 @@ public enum ConvertDocumentationError: ResponseType, Equatable {
6666
}
6767
}
6868

69-
extension ConvertDocumentationError: Codable {
69+
extension DoccDocumentationError: Codable {
7070
enum CodingKeys: String, CodingKey {
7171
case kind
7272
case message
@@ -108,7 +108,7 @@ extension ConvertDocumentationError: Codable {
108108
}
109109
}
110110

111-
extension ConvertDocumentationResponse: Codable {
111+
extension DoccDocumentationResponse: Codable {
112112
enum CodingKeys: String, CodingKey {
113113
case type
114114
case renderNode
@@ -123,7 +123,7 @@ extension ConvertDocumentationResponse: Codable {
123123
let renderNode = try values.decode(String.self, forKey: .renderNode)
124124
self = .renderNode(renderNode)
125125
case "error":
126-
let error = try values.decode(ConvertDocumentationError.self, forKey: .error)
126+
let error = try values.decode(DoccDocumentationError.self, forKey: .error)
127127
self = .error(error)
128128
default:
129129
throw DecodingError.dataCorruptedError(

Sources/SourceKitLSP/Documentation/DocumentationManager.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ package final actor DocumentationManager {
3333

3434
func convertDocumentation(
3535
_ documentURI: DocumentURI,
36-
at position: Position = Position(line: 0, utf16index: 0)
37-
) async throws -> ConvertDocumentationResponse {
36+
at position: Position? = nil
37+
) async throws -> DoccDocumentationResponse {
38+
let position = position ?? Position(line: 0, utf16index: 0)
3839
guard let sourceKitLSPServer = sourceKitLSPServer else {
3940
throw ResponseError.internalError("SourceKit-LSP is shutting down")
4041
}

Sources/SourceKitLSP/SourceKitLSPServer.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ extension SourceKitLSPServer: QueueBasedMessageHandler {
791791
case let request as RequestAndReply<ShutdownRequest>:
792792
await request.reply { try await shutdown(request.params) }
793793
#if canImport(SwiftDocC)
794-
case let request as RequestAndReply<ConvertDocumentationRequest>:
794+
case let request as RequestAndReply<DoccDocumentationRequest>:
795795
await request.reply {
796796
try await documentationManager.convertDocumentation(
797797
request.params.textDocument.uri,
@@ -1056,7 +1056,7 @@ extension SourceKitLSPServer {
10561056
"workspace/getReferenceDocument": .dictionary(["version": .int(1)]),
10571057
]
10581058
#if canImport(SwiftDocC)
1059-
experimentalCapabilities["textDocument/convertDocumentation"] = .dictionary(["version": .int(1)])
1059+
experimentalCapabilities["textDocument/doccDocumentation"] = .dictionary(["version": .int(1)])
10601060
#endif
10611061

10621062
return ServerCapabilities(

0 commit comments

Comments
 (0)