Skip to content

Commit d2e7fd5

Browse files
committed
Generate ClientServer Interfaces
1 parent ccaef3e commit d2e7fd5

File tree

5 files changed

+675
-350
lines changed

5 files changed

+675
-350
lines changed

src/Client.fs

Lines changed: 24 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -11,131 +11,6 @@ module private ClientUtil =
1111

1212
open ClientUtil
1313

14-
[<Interface>]
15-
type ILspClient =
16-
/// The show message notification is sent from a server to a client to ask the client to display
17-
/// a particular message in the user interface.
18-
abstract member WindowShowMessage: ShowMessageParams -> Async<unit>
19-
20-
/// The show message request is sent from a server to a client to ask the client to display
21-
/// a particular message in the user interface. In addition to the show message notification the
22-
/// request allows to pass actions and to wait for an answer from the client.
23-
abstract member WindowShowMessageRequest: ShowMessageRequestParams -> AsyncLspResult<MessageActionItem option>
24-
25-
26-
/// The log message notification is sent from the server to the client to ask the client to log
27-
///a particular message.
28-
abstract member WindowLogMessage: LogMessageParams -> Async<unit>
29-
30-
/// The show document request is sent from a server to a client to ask the client to display a particular
31-
/// resource referenced by a URI in the user interface.
32-
abstract member WindowShowDocument: ShowDocumentParams -> AsyncLspResult<ShowDocumentResult>
33-
34-
/// The telemetry notification is sent from the server to the client to ask the client to log
35-
/// a telemetry event.
36-
abstract member TelemetryEvent: Newtonsoft.Json.Linq.JToken -> Async<unit>
37-
38-
/// The `client/registerCapability` request is sent from the server to the client to register for a new
39-
/// capability on the client side. Not all clients need to support dynamic capability registration.
40-
/// A client opts in via the dynamicRegistration property on the specific client capabilities. A client
41-
/// can even provide dynamic registration for capability A but not for capability B.
42-
abstract member ClientRegisterCapability: RegistrationParams -> AsyncLspResult<unit>
43-
44-
/// The `client/unregisterCapability` request is sent from the server to the client to unregister a previously
45-
/// registered capability.
46-
abstract member ClientUnregisterCapability: UnregistrationParams -> AsyncLspResult<unit>
47-
48-
49-
/// Many tools support more than one root folder per workspace. Examples for this are VS Code’s multi-root
50-
/// support, Atom’s project folder support or Sublime’s project support. If a client workspace consists of
51-
/// multiple roots then a server typically needs to know about this. The protocol up to know assumes one root
52-
/// folder which is announce to the server by the rootUri property of the InitializeParams.
53-
/// If the client supports workspace folders and announces them via the corresponding workspaceFolders client
54-
/// capability the InitializeParams contain an additional property workspaceFolders with the configured
55-
/// workspace folders when the server starts.
56-
///
57-
/// The workspace/workspaceFolders request is sent from the server to the client to fetch the current open
58-
/// list of workspace folders. Returns null in the response if only a single file is open in the tool.
59-
/// Returns an empty array if a workspace is open but no folders are configured.
60-
abstract member WorkspaceWorkspaceFolders: unit -> AsyncLspResult<WorkspaceFolder[] option>
61-
62-
/// The workspace/configuration request is sent from the server to the client to fetch configuration
63-
/// settings from the client.
64-
///
65-
/// The request can fetch n configuration settings in one roundtrip. The order of the returned configuration
66-
/// settings correspond to the order of the passed ConfigurationItems (e.g. the first item in the response
67-
/// is the result for the first configuration item in the params).
68-
abstract member WorkspaceConfiguration: ConfigurationParams -> AsyncLspResult<Newtonsoft.Json.Linq.JToken[]>
69-
70-
71-
abstract member WorkspaceApplyEdit: ApplyWorkspaceEditParams -> AsyncLspResult<ApplyWorkspaceEditResult>
72-
73-
/// The workspace/semanticTokens/refresh request is sent from the server to the client.
74-
/// Servers can use it to ask clients to refresh the editors for which this server provides semantic tokens.
75-
/// As a result the client should ask the server to recompute the semantic tokens for these editors.
76-
/// This is useful if a server detects a project wide configuration change which requires a re-calculation
77-
/// of all semantic tokens. Note that the client still has the freedom to delay the re-calculation of
78-
/// the semantic tokens if for example an editor is currently not visible.
79-
abstract member WorkspaceSemanticTokensRefresh: unit -> Async<unit>
80-
81-
82-
/// The `workspace/inlayHint/refresh` request is sent from the server to the client.
83-
/// Servers can use it to ask clients to refresh the inlay hints currently shown in editors.
84-
/// As a result the client should ask the server to recompute the inlay hints for these editors.
85-
/// This is useful if a server detects a configuration change which requires a re-calculation
86-
/// of all inlay hints. Note that the client still has the freedom to delay the re-calculation of the inlay hints
87-
/// if for example an editor is currently not visible.
88-
abstract member WorkspaceInlayHintRefresh: unit -> Async<unit>
89-
90-
91-
/// The workspace/codeLens/refresh request is sent from the server to the client. Servers can use it to ask
92-
/// clients to refresh the code lenses currently shown in editors. As a result the client should ask the
93-
/// server to recompute the code lenses for these editors. This is useful if a server detects a
94-
/// configuration change which requires a re-calculation of all code lenses. Note that the client still has
95-
/// the freedom to delay the re-calculation of the code lenses if for example an editor is currently not
96-
/// visible.
97-
abstract member WorkspaceCodeLensRefresh: unit -> Async<unit>
98-
99-
100-
/// The workspace/inlineValue/refresh request is sent from the server to the client. Servers can use it to
101-
/// ask clients to refresh the inline values currently shown in editors. As a result the client should ask
102-
/// the server to recompute the inline values for these editors. This is useful if a server detects a
103-
/// configuration change which requires a re-calculation of all inline values. Note that the client still
104-
/// has the freedom to delay the re-calculation of the inline values if for example an editor is currently
105-
/// not visible.
106-
abstract member WorkspaceInlineValueRefresh: unit -> Async<unit>
107-
108-
109-
/// Diagnostics notification are sent from the server to the client to signal results of validation runs.
110-
///
111-
/// Diagnostics are “owned” by the server so it is the server’s responsibility to clear them if necessary.
112-
/// The following rule is used for VS Code servers that generate diagnostics:
113-
///
114-
/// * if a language is single file only (for example HTML) then diagnostics are cleared by the server when
115-
/// the file is closed.
116-
/// * if a language has a project system (for example C#) diagnostics are not cleared when a file closes.
117-
/// When a project is opened all diagnostics for all files are recomputed (or read from a cache).
118-
///
119-
/// When a file changes it is the server’s responsibility to re-compute diagnostics and push them to the
120-
/// client. If the computed set is empty it has to push the empty array to clear former diagnostics.
121-
/// Newly pushed diagnostics always replace previously pushed diagnostics. There is no merging that happens
122-
/// on the client side.
123-
abstract member TextDocumentPublishDiagnostics: PublishDiagnosticsParams -> Async<unit>
124-
125-
/// The workspace/diagnostic/refresh request is sent from the server to the client. Servers can use it to
126-
/// ask clients to refresh all needed document and workspace diagnostics. This is useful if a server detects
127-
/// a project wide configuration change which requires a re-calculation of all diagnostics.
128-
abstract member WorkspaceDiagnosticRefresh: unit -> Async<unit>
129-
130-
/// The window/workDoneProgress/create request is sent from the server to the client to ask the client to create a work done progress.
131-
abstract member WorkDoneProgressCreate: ProgressToken -> AsyncLspResult<unit>
132-
133-
/// The base protocol offers also support to report progress in a generic fashion.
134-
/// This mechanism can be used to report any kind of progress including work done progress
135-
/// (usually used to report progress in the user interface using a progress bar) and
136-
/// partial result progress to support streaming of results.
137-
abstract member Progress: ProgressToken * 'Progress -> Async<unit>
138-
13914
[<AbstractClass>]
14015
type LspClient() =
14116

@@ -218,39 +93,39 @@ type LspClient() =
21893
/// This is useful if a server detects a project wide configuration change which requires a re-calculation
21994
/// of all semantic tokens. Note that the client still has the freedom to delay the re-calculation of
22095
/// the semantic tokens if for example an editor is currently not visible.
221-
abstract member WorkspaceSemanticTokensRefresh: unit -> Async<unit>
96+
abstract member WorkspaceSemanticTokensRefresh: unit -> AsyncLspResult<unit>
22297

223-
default __.WorkspaceSemanticTokensRefresh() = ignoreNotification
98+
default __.WorkspaceSemanticTokensRefresh() = notImplemented
22499

225100
/// The `workspace/inlayHint/refresh` request is sent from the server to the client.
226101
/// Servers can use it to ask clients to refresh the inlay hints currently shown in editors.
227102
/// As a result the client should ask the server to recompute the inlay hints for these editors.
228103
/// This is useful if a server detects a configuration change which requires a re-calculation
229104
/// of all inlay hints. Note that the client still has the freedom to delay the re-calculation of the inlay hints
230105
/// if for example an editor is currently not visible.
231-
abstract member WorkspaceInlayHintRefresh: unit -> Async<unit>
106+
abstract member WorkspaceInlayHintRefresh: unit -> AsyncLspResult<unit>
232107

233-
default __.WorkspaceInlayHintRefresh() = ignoreNotification
108+
default __.WorkspaceInlayHintRefresh() = notImplemented
234109

235110
/// The workspace/codeLens/refresh request is sent from the server to the client. Servers can use it to ask
236111
/// clients to refresh the code lenses currently shown in editors. As a result the client should ask the
237112
/// server to recompute the code lenses for these editors. This is useful if a server detects a
238113
/// configuration change which requires a re-calculation of all code lenses. Note that the client still has
239114
/// the freedom to delay the re-calculation of the code lenses if for example an editor is currently not
240115
/// visible.
241-
abstract member WorkspaceCodeLensRefresh: unit -> Async<unit>
116+
abstract member WorkspaceCodeLensRefresh: unit -> AsyncLspResult<unit>
242117

243-
default __.WorkspaceCodeLensRefresh() = ignoreNotification
118+
default __.WorkspaceCodeLensRefresh() = notImplemented
244119

245120
/// The workspace/inlineValue/refresh request is sent from the server to the client. Servers can use it to
246121
/// ask clients to refresh the inline values currently shown in editors. As a result the client should ask
247122
/// the server to recompute the inline values for these editors. This is useful if a server detects a
248123
/// configuration change which requires a re-calculation of all inline values. Note that the client still
249124
/// has the freedom to delay the re-calculation of the inline values if for example an editor is currently
250125
/// not visible.
251-
abstract member WorkspaceInlineValueRefresh: unit -> Async<unit>
126+
abstract member WorkspaceInlineValueRefresh: unit -> AsyncLspResult<unit>
252127

253-
default __.WorkspaceInlineValueRefresh() = ignoreNotification
128+
default __.WorkspaceInlineValueRefresh() = notImplemented
254129

255130
/// Diagnostics notification are sent from the server to the client to signal results of validation runs.
256131
///
@@ -273,17 +148,23 @@ type LspClient() =
273148
/// The workspace/diagnostic/refresh request is sent from the server to the client. Servers can use it to
274149
/// ask clients to refresh all needed document and workspace diagnostics. This is useful if a server detects
275150
/// a project wide configuration change which requires a re-calculation of all diagnostics.
276-
abstract member WorkspaceDiagnosticRefresh: unit -> Async<unit>
151+
abstract member WorkspaceDiagnosticRefresh: unit -> AsyncLspResult<unit>
152+
153+
default __.WorkspaceDiagnosticRefresh() = notImplemented
154+
155+
abstract member Progress: ProgressParams -> Async<unit>
277156

278-
default __.WorkspaceDiagnosticRefresh() = ignoreNotification
157+
default __.Progress(p) = ignoreNotification
279158

280-
abstract member Progress: ProgressToken * 'Progress -> Async<unit>
159+
abstract member CancelRequest: CancelParams -> Async<unit>
160+
default __.CancelRequest(_) = ignoreNotification
281161

282-
default __.Progress(_, _) = ignoreNotification
162+
abstract member LogTrace: LogTraceParams -> Async<unit>
163+
default __.LogTrace(_) = ignoreNotification
283164

284165
/// The window/workDoneProgress/create request is sent from the server to the client to ask the client to create a work done progress.
285-
abstract member WorkDoneProgressCreate: ProgressToken -> AsyncLspResult<unit>
286-
default __.WorkDoneProgressCreate(_) = notImplemented
166+
abstract member WindowWorkDoneProgressCreate: WorkDoneProgressCreateParams -> AsyncLspResult<unit>
167+
default __.WindowWorkDoneProgressCreate(_) = notImplemented
287168

288169
interface ILspClient with
289170
member this.WindowShowMessage(p: ShowMessageParams) = this.WindowShowMessage(p)
@@ -302,5 +183,7 @@ type LspClient() =
302183
member this.WorkspaceInlineValueRefresh() = this.WorkspaceInlineValueRefresh()
303184
member this.TextDocumentPublishDiagnostics(p: PublishDiagnosticsParams) = this.TextDocumentPublishDiagnostics(p)
304185
member this.WorkspaceDiagnosticRefresh() = this.WorkspaceDiagnosticRefresh()
305-
member this.WorkDoneProgressCreate(token: ProgressToken) = this.WorkDoneProgressCreate(token)
306-
member this.Progress(token, data) = this.Progress(token, data)
186+
member this.WindowWorkDoneProgressCreate(p: WorkDoneProgressCreateParams) = this.WindowWorkDoneProgressCreate(p)
187+
member this.Progress(p: ProgressParams) = this.Progress(p)
188+
member this.CancelRequest(p: CancelParams) : Async<unit> = this.CancelRequest(p)
189+
member this.LogTrace(p: LogTraceParams) : Async<unit> = this.LogTrace(p)

0 commit comments

Comments
 (0)