forked from ionide/LanguageServerProtocol
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClient.fs
More file actions
191 lines (149 loc) · 11.3 KB
/
Client.fs
File metadata and controls
191 lines (149 loc) · 11.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
namespace Ionide.LanguageServerProtocol
open Ionide.LanguageServerProtocol.Types
open Ionide.LanguageServerProtocol.JsonRpc
module private ClientUtil =
/// Return the JSON-RPC "not implemented" error
let notImplemented<'t> = async.Return LspResult.notImplemented<'t>
/// Do nothing and ignore the notification
let ignoreNotification = async.Return(())
open ClientUtil
[<AbstractClass>]
type LspClient() =
/// The show message notification is sent from a server to a client to ask the client to display
/// a particular message in the user interface.
abstract member WindowShowMessage: ShowMessageParams -> Async<unit>
default __.WindowShowMessage(_) = ignoreNotification
/// The show message request is sent from a server to a client to ask the client to display
/// a particular message in the user interface. In addition to the show message notification the
/// request allows to pass actions and to wait for an answer from the client.
abstract member WindowShowMessageRequest: ShowMessageRequestParams -> AsyncLspResult<MessageActionItem option>
default __.WindowShowMessageRequest(_) = notImplemented
/// The log message notification is sent from the server to the client to ask the client to log
///a particular message.
abstract member WindowLogMessage: LogMessageParams -> Async<unit>
default __.WindowLogMessage(_) = ignoreNotification
/// The show document request is sent from a server to a client to ask the client to display a particular
/// resource referenced by a URI in the user interface.
abstract member WindowShowDocument: ShowDocumentParams -> AsyncLspResult<ShowDocumentResult>
default __.WindowShowDocument(_) = notImplemented
/// The telemetry notification is sent from the server to the client to ask the client to log
/// a telemetry event.
abstract member TelemetryEvent: Newtonsoft.Json.Linq.JToken -> Async<unit>
default __.TelemetryEvent(_) = ignoreNotification
/// The `client/registerCapability` request is sent from the server to the client to register for a new
/// capability on the client side. Not all clients need to support dynamic capability registration.
/// A client opts in via the dynamicRegistration property on the specific client capabilities. A client
/// can even provide dynamic registration for capability A but not for capability B.
abstract member ClientRegisterCapability: RegistrationParams -> AsyncLspResult<unit>
default __.ClientRegisterCapability(_) = notImplemented
/// The `client/unregisterCapability` request is sent from the server to the client to unregister a previously
/// registered capability.
abstract member ClientUnregisterCapability: UnregistrationParams -> AsyncLspResult<unit>
default __.ClientUnregisterCapability(_) = notImplemented
/// Many tools support more than one root folder per workspace. Examples for this are VS Code’s multi-root
/// support, Atom’s project folder support or Sublime’s project support. If a client workspace consists of
/// multiple roots then a server typically needs to know about this. The protocol up to know assumes one root
/// folder which is announce to the server by the rootUri property of the InitializeParams.
/// If the client supports workspace folders and announces them via the corresponding workspaceFolders client
/// capability the InitializeParams contain an additional property workspaceFolders with the configured
/// workspace folders when the server starts.
///
/// The workspace/workspaceFolders request is sent from the server to the client to fetch the current open
/// list of workspace folders. Returns null in the response if only a single file is open in the tool.
/// Returns an empty array if a workspace is open but no folders are configured.
abstract member WorkspaceWorkspaceFolders: unit -> AsyncLspResult<WorkspaceFolder[] option>
default __.WorkspaceWorkspaceFolders() = notImplemented
/// The workspace/configuration request is sent from the server to the client to fetch configuration
/// settings from the client.
///
/// The request can fetch n configuration settings in one roundtrip. The order of the returned configuration
/// settings correspond to the order of the passed ConfigurationItems (e.g. the first item in the response
/// is the result for the first configuration item in the params).
abstract member WorkspaceConfiguration: ConfigurationParams -> AsyncLspResult<Newtonsoft.Json.Linq.JToken[]>
default __.WorkspaceConfiguration(_) = notImplemented
abstract member WorkspaceApplyEdit: ApplyWorkspaceEditParams -> AsyncLspResult<ApplyWorkspaceEditResult>
default __.WorkspaceApplyEdit(_) = notImplemented
/// The workspace/semanticTokens/refresh request is sent from the server to the client.
/// Servers can use it to ask clients to refresh the editors for which this server provides semantic tokens.
/// As a result the client should ask the server to recompute the semantic tokens for these editors.
/// This is useful if a server detects a project wide configuration change which requires a re-calculation
/// of all semantic tokens. Note that the client still has the freedom to delay the re-calculation of
/// the semantic tokens if for example an editor is currently not visible.
abstract member WorkspaceSemanticTokensRefresh: unit -> AsyncLspResult<unit>
default __.WorkspaceSemanticTokensRefresh() = notImplemented
/// The `workspace/inlayHint/refresh` request is sent from the server to the client.
/// Servers can use it to ask clients to refresh the inlay hints currently shown in editors.
/// As a result the client should ask the server to recompute the inlay hints for these editors.
/// This is useful if a server detects a configuration change which requires a re-calculation
/// of all inlay hints. Note that the client still has the freedom to delay the re-calculation of the inlay hints
/// if for example an editor is currently not visible.
abstract member WorkspaceInlayHintRefresh: unit -> AsyncLspResult<unit>
default __.WorkspaceInlayHintRefresh() = notImplemented
/// The workspace/codeLens/refresh request is sent from the server to the client. Servers can use it to ask
/// clients to refresh the code lenses currently shown in editors. As a result the client should ask the
/// server to recompute the code lenses for these editors. This is useful if a server detects a
/// configuration change which requires a re-calculation of all code lenses. Note that the client still has
/// the freedom to delay the re-calculation of the code lenses if for example an editor is currently not
/// visible.
abstract member WorkspaceCodeLensRefresh: unit -> AsyncLspResult<unit>
default __.WorkspaceCodeLensRefresh() = notImplemented
/// The workspace/inlineValue/refresh request is sent from the server to the client. Servers can use it to
/// ask clients to refresh the inline values currently shown in editors. As a result the client should ask
/// the server to recompute the inline values for these editors. This is useful if a server detects a
/// configuration change which requires a re-calculation of all inline values. Note that the client still
/// has the freedom to delay the re-calculation of the inline values if for example an editor is currently
/// not visible.
abstract member WorkspaceInlineValueRefresh: unit -> AsyncLspResult<unit>
default __.WorkspaceInlineValueRefresh() = notImplemented
/// Diagnostics notification are sent from the server to the client to signal results of validation runs.
///
/// Diagnostics are “owned” by the server so it is the server’s responsibility to clear them if necessary.
/// The following rule is used for VS Code servers that generate diagnostics:
///
/// * if a language is single file only (for example HTML) then diagnostics are cleared by the server when
/// the file is closed.
/// * if a language has a project system (for example C#) diagnostics are not cleared when a file closes.
/// When a project is opened all diagnostics for all files are recomputed (or read from a cache).
///
/// When a file changes it is the server’s responsibility to re-compute diagnostics and push them to the
/// client. If the computed set is empty it has to push the empty array to clear former diagnostics.
/// Newly pushed diagnostics always replace previously pushed diagnostics. There is no merging that happens
/// on the client side.
abstract member TextDocumentPublishDiagnostics: PublishDiagnosticsParams -> Async<unit>
default __.TextDocumentPublishDiagnostics(_) = ignoreNotification
/// The workspace/diagnostic/refresh request is sent from the server to the client. Servers can use it to
/// ask clients to refresh all needed document and workspace diagnostics. This is useful if a server detects
/// a project wide configuration change which requires a re-calculation of all diagnostics.
abstract member WorkspaceDiagnosticRefresh: unit -> AsyncLspResult<unit>
default __.WorkspaceDiagnosticRefresh() = notImplemented
abstract member Progress: ProgressParams -> Async<unit>
default __.Progress(p) = ignoreNotification
abstract member CancelRequest: CancelParams -> Async<unit>
default __.CancelRequest(_) = ignoreNotification
abstract member LogTrace: LogTraceParams -> Async<unit>
default __.LogTrace(_) = ignoreNotification
/// The window/workDoneProgress/create request is sent from the server to the client to ask the client to create a work done progress.
abstract member WindowWorkDoneProgressCreate: WorkDoneProgressCreateParams -> AsyncLspResult<unit>
default __.WindowWorkDoneProgressCreate(_) = notImplemented
interface ILspClient with
member this.WindowShowMessage(p: ShowMessageParams) = this.WindowShowMessage(p)
member this.WindowShowMessageRequest(p: ShowMessageRequestParams) = this.WindowShowMessageRequest(p)
member this.WindowLogMessage(p: LogMessageParams) = this.WindowLogMessage(p)
member this.WindowShowDocument(p: ShowDocumentParams) = this.WindowShowDocument(p)
member this.TelemetryEvent(p: Newtonsoft.Json.Linq.JToken) = this.TelemetryEvent(p)
member this.ClientRegisterCapability(p: RegistrationParams) = this.ClientRegisterCapability(p)
member this.ClientUnregisterCapability(p: UnregistrationParams) = this.ClientUnregisterCapability(p)
member this.WorkspaceWorkspaceFolders() = this.WorkspaceWorkspaceFolders()
member this.WorkspaceConfiguration(p: ConfigurationParams) = this.WorkspaceConfiguration(p)
member this.WorkspaceApplyEdit(p: ApplyWorkspaceEditParams) = this.WorkspaceApplyEdit(p)
member this.WorkspaceSemanticTokensRefresh() = this.WorkspaceSemanticTokensRefresh()
member this.WorkspaceInlayHintRefresh() = this.WorkspaceInlayHintRefresh()
member this.WorkspaceCodeLensRefresh() = this.WorkspaceCodeLensRefresh()
member this.WorkspaceInlineValueRefresh() = this.WorkspaceInlineValueRefresh()
member this.TextDocumentPublishDiagnostics(p: PublishDiagnosticsParams) = this.TextDocumentPublishDiagnostics(p)
member this.WorkspaceDiagnosticRefresh() = this.WorkspaceDiagnosticRefresh()
member this.WindowWorkDoneProgressCreate(p: WorkDoneProgressCreateParams) = this.WindowWorkDoneProgressCreate(p)
member this.Progress(p: ProgressParams) = this.Progress(p)
member this.CancelRequest(p: CancelParams) : Async<unit> = this.CancelRequest(p)
member this.LogTrace(p: LogTraceParams) : Async<unit> = this.LogTrace(p)
member this.Dispose() : unit = ()