Skip to content

Commit e6c2256

Browse files
committed
convert client to interface-based only
1 parent bd45871 commit e6c2256

File tree

2 files changed

+19
-135
lines changed

2 files changed

+19
-135
lines changed

src/Client.fs

Lines changed: 18 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -1,138 +1,43 @@
11
namespace Ionide.LanguageServerProtocol
22

33
open Ionide.LanguageServerProtocol.Types
4-
4+
open System
5+
open System.Threading
6+
open System.Threading.Tasks
57

68
[<Interface>]
79
type ILspClient =
8-
/// The show message notification is sent from a server to a client to ask the client to display
9-
/// a particular message in the user interface.
10-
abstract member WindowShowMessage: ShowMessageParams -> Async<unit>
11-
12-
/// The show message request is sent from a server to a client to ask the client to display
13-
/// a particular message in the user interface. In addition to the show message notification the
14-
/// request allows to pass actions and to wait for an answer from the client.
15-
abstract member WindowShowMessageRequest: ShowMessageRequestParams -> AsyncLspResult<MessageActionItem option>
16-
17-
18-
/// The log message notification is sent from the server to the client to ask the client to log
19-
///a particular message.
20-
abstract member WindowLogMessage: LogMessageParams -> Async<unit>
21-
22-
/// The telemetry notification is sent from the server to the client to ask the client to log
23-
/// a telemetry event.
24-
abstract member TelemetryEvent: Newtonsoft.Json.Linq.JToken -> Async<unit>
25-
26-
/// The `client/registerCapability` request is sent from the server to the client to register for a new
27-
/// capability on the client side. Not all clients need to support dynamic capability registration.
28-
/// A client opts in via the dynamicRegistration property on the specific client capabilities. A client
29-
/// can even provide dynamic registration for capability A but not for capability B.
30-
abstract member ClientRegisterCapability: RegistrationParams -> AsyncLspResult<unit>
31-
32-
/// The `client/unregisterCapability` request is sent from the server to the client to unregister a previously
33-
/// registered capability.
34-
abstract member ClientUnregisterCapability: UnregistrationParams -> AsyncLspResult<unit>
35-
36-
37-
/// Many tools support more than one root folder per workspace. Examples for this are VS Code’s multi-root
38-
/// support, Atom’s project folder support or Sublime’s project support. If a client workspace consists of
39-
/// multiple roots then a server typically needs to know about this. The protocol up to know assumes one root
40-
/// folder which is announce to the server by the rootUri property of the InitializeParams.
41-
/// If the client supports workspace folders and announces them via the corresponding workspaceFolders client
42-
/// capability the InitializeParams contain an additional property workspaceFolders with the configured
43-
/// workspace folders when the server starts.
44-
///
45-
/// The workspace/workspaceFolders request is sent from the server to the client to fetch the current open
46-
/// list of workspace folders. Returns null in the response if only a single file is open in the tool.
47-
/// Returns an empty array if a workspace is open but no folders are configured.
48-
abstract member WorkspaceWorkspaceFolders: unit -> AsyncLspResult<WorkspaceFolder [] option>
49-
50-
/// The workspace/configuration request is sent from the server to the client to fetch configuration
51-
/// settings from the client.
52-
///
53-
/// The request can fetch n configuration settings in one roundtrip. The order of the returned configuration
54-
/// settings correspond to the order of the passed ConfigurationItems (e.g. the first item in the response
55-
/// is the result for the first configuration item in the params).
56-
abstract member WorkspaceConfiguration: ConfigurationParams -> AsyncLspResult<Newtonsoft.Json.Linq.JToken []>
57-
58-
59-
abstract member WorkspaceApplyEdit: ApplyWorkspaceEditParams -> AsyncLspResult<ApplyWorkspaceEditResponse>
60-
61-
/// The workspace/semanticTokens/refresh request is sent from the server to the client.
62-
/// Servers can use it to ask clients to refresh the editors for which this server provides semantic tokens.
63-
/// As a result the client should ask the server to recompute the semantic tokens for these editors.
64-
/// This is useful if a server detects a project wide configuration change which requires a re-calculation
65-
/// of all semantic tokens. Note that the client still has the freedom to delay the re-calculation of
66-
/// the semantic tokens if for example an editor is currently not visible.
67-
abstract member WorkspaceSemanticTokensRefresh: unit -> Async<unit>
68-
69-
70-
/// The `workspace/inlayHint/refresh` request is sent from the server to the client.
71-
/// Servers can use it to ask clients to refresh the inlay hints currently shown in editors.
72-
/// As a result the client should ask the server to recompute the inlay hints for these editors.
73-
/// This is useful if a server detects a configuration change which requires a re-calculation
74-
/// of all inlay hints. Note that the client still has the freedom to delay the re-calculation of the inlay hints
75-
/// if for example an editor is currently not visible.
76-
abstract member WorkspaceInlayHintRefresh: unit -> Async<unit>
77-
78-
79-
/// Diagnostics notification are sent from the server to the client to signal results of validation runs.
80-
///
81-
/// Diagnostics are “owned” by the server so it is the server’s responsibility to clear them if necessary.
82-
/// The following rule is used for VS Code servers that generate diagnostics:
83-
///
84-
/// * if a language is single file only (for example HTML) then diagnostics are cleared by the server when
85-
/// the file is closed.
86-
/// * if a language has a project system (for example C#) diagnostics are not cleared when a file closes.
87-
/// When a project is opened all diagnostics for all files are recomputed (or read from a cache).
88-
///
89-
/// When a file changes it is the server’s responsibility to re-compute diagnostics and push them to the
90-
/// client. If the computed set is empty it has to push the empty array to clear former diagnostics.
91-
/// Newly pushed diagnostics always replace previously pushed diagnostics. There is no merging that happens
92-
/// on the client side.
93-
abstract member TextDocumentPublishDiagnostics: PublishDiagnosticsParams -> Async<unit>
94-
95-
[<AbstractClass>]
96-
type LspClient() =
9710

9811
/// The show message notification is sent from a server to a client to ask the client to display
9912
/// a particular message in the user interface.
100-
abstract member WindowShowMessage: ShowMessageParams -> Async<unit>
101-
102-
default __.WindowShowMessage(_) = ignoreNotification
13+
abstract member ``window/showMessage``: EventHandler<ShowMessageParams>
10314

10415
/// The show message request is sent from a server to a client to ask the client to display
10516
/// a particular message in the user interface. In addition to the show message notification the
10617
/// request allows to pass actions and to wait for an answer from the client.
107-
abstract member WindowShowMessageRequest: ShowMessageRequestParams -> AsyncLspResult<MessageActionItem option>
108-
109-
default __.WindowShowMessageRequest(_) = notImplemented
18+
abstract member ``window/showMessageRequest``:
19+
ShowMessageRequestParams * CancellationToken -> Task<MessageActionItem option>
11020

11121
/// The log message notification is sent from the server to the client to ask the client to log
11222
///a particular message.
113-
abstract member WindowLogMessage: LogMessageParams -> Async<unit>
23+
abstract member ``window/logMessage``: EventHandler<LogMessageParams>
11424

115-
default __.WindowLogMessage(_) = ignoreNotification
11625

11726
/// The telemetry notification is sent from the server to the client to ask the client to log
11827
/// a telemetry event.
119-
abstract member TelemetryEvent: Newtonsoft.Json.Linq.JToken -> Async<unit>
28+
abstract member ``telemetry/event``: EventHandler<LSPAny>
12029

121-
default __.TelemetryEvent(_) = ignoreNotification
12230

12331
/// The `client/registerCapability` request is sent from the server to the client to register for a new
12432
/// capability on the client side. Not all clients need to support dynamic capability registration.
12533
/// A client opts in via the dynamicRegistration property on the specific client capabilities. A client
12634
/// can even provide dynamic registration for capability A but not for capability B.
127-
abstract member ClientRegisterCapability: RegistrationParams -> AsyncLspResult<unit>
35+
abstract member ``client/registerCapability``: RegistrationParams * CancellationToken -> Task<unit>
12836

129-
default __.ClientRegisterCapability(_) = notImplemented
13037

13138
/// The `client/unregisterCapability` request is sent from the server to the client to unregister a previously
13239
/// registered capability.
133-
abstract member ClientUnregisterCapability: UnregistrationParams -> AsyncLspResult<unit>
134-
135-
default __.ClientUnregisterCapability(_) = notImplemented
40+
abstract member ``client/unregisterCapability``: UnregistrationParams * CancellationToken -> Task<unit>
13641

13742
/// Many tools support more than one root folder per workspace. Examples for this are VS Code’s multi-root
13843
/// support, Atom’s project folder support or Sublime’s project support. If a client workspace consists of
@@ -145,42 +50,37 @@ type LspClient() =
14550
/// The workspace/workspaceFolders request is sent from the server to the client to fetch the current open
14651
/// list of workspace folders. Returns null in the response if only a single file is open in the tool.
14752
/// Returns an empty array if a workspace is open but no folders are configured.
148-
abstract member WorkspaceWorkspaceFolders: unit -> AsyncLspResult<WorkspaceFolder [] option>
53+
abstract member ``workspace/workspaceFolders``: unit * CancellationToken -> Task<WorkspaceFolder array option>
14954

150-
default __.WorkspaceWorkspaceFolders() = notImplemented
15155

15256
/// The workspace/configuration request is sent from the server to the client to fetch configuration
15357
/// settings from the client.
15458
///
15559
/// The request can fetch n configuration settings in one roundtrip. The order of the returned configuration
15660
/// settings correspond to the order of the passed ConfigurationItems (e.g. the first item in the response
15761
/// is the result for the first configuration item in the params).
158-
abstract member WorkspaceConfiguration: ConfigurationParams -> AsyncLspResult<Newtonsoft.Json.Linq.JToken []>
62+
abstract member ``workspace/configuration``: ConfigurationParams * CancellationToken -> Task<LSPAny array>
15963

160-
default __.WorkspaceConfiguration(_) = notImplemented
16164

162-
abstract member WorkspaceApplyEdit: ApplyWorkspaceEditParams -> AsyncLspResult<ApplyWorkspaceEditResponse>
163-
default __.WorkspaceApplyEdit(_) = notImplemented
65+
/// The workspace/applyEdit request is sent from the server to the client to modify resource on the client side.
66+
abstract member ``workspace/applyEdit``:
67+
ApplyWorkspaceEditParams * CancellationToken -> Task<ApplyWorkspaceEditResponse>
16468

16569
/// The workspace/semanticTokens/refresh request is sent from the server to the client.
16670
/// Servers can use it to ask clients to refresh the editors for which this server provides semantic tokens.
16771
/// As a result the client should ask the server to recompute the semantic tokens for these editors.
16872
/// This is useful if a server detects a project wide configuration change which requires a re-calculation
16973
/// of all semantic tokens. Note that the client still has the freedom to delay the re-calculation of
17074
/// the semantic tokens if for example an editor is currently not visible.
171-
abstract member WorkspaceSemanticTokensRefresh: unit -> Async<unit>
172-
173-
default __.WorkspaceSemanticTokensRefresh() = ignoreNotification
75+
abstract member ``workspace/semanticTokens/refresh``: unit * CancellationToken -> Task<unit>
17476

17577
/// The `workspace/inlayHint/refresh` request is sent from the server to the client.
17678
/// Servers can use it to ask clients to refresh the inlay hints currently shown in editors.
17779
/// As a result the client should ask the server to recompute the inlay hints for these editors.
17880
/// This is useful if a server detects a configuration change which requires a re-calculation
17981
/// of all inlay hints. Note that the client still has the freedom to delay the re-calculation of the inlay hints
18082
/// if for example an editor is currently not visible.
181-
abstract member WorkspaceInlayHintRefresh: unit -> Async<unit>
182-
183-
default __.WorkspaceInlayHintRefresh() = ignoreNotification
83+
abstract member ``workspace/inlayHint/refresh``: unit * CancellationToken -> Task<unit>
18484

18585
/// Diagnostics notification are sent from the server to the client to signal results of validation runs.
18686
///
@@ -196,20 +96,4 @@ type LspClient() =
19696
/// client. If the computed set is empty it has to push the empty array to clear former diagnostics.
19797
/// Newly pushed diagnostics always replace previously pushed diagnostics. There is no merging that happens
19898
/// on the client side.
199-
abstract member TextDocumentPublishDiagnostics: PublishDiagnosticsParams -> Async<unit>
200-
201-
default __.TextDocumentPublishDiagnostics(_) = ignoreNotification
202-
203-
interface ILspClient with
204-
member this.WindowShowMessage(p: ShowMessageParams) = this.WindowShowMessage(p)
205-
member this.WindowShowMessageRequest(p: ShowMessageRequestParams) = this.WindowShowMessageRequest(p)
206-
member this.WindowLogMessage(p: LogMessageParams) = this.WindowLogMessage(p)
207-
member this.TelemetryEvent(p: Newtonsoft.Json.Linq.JToken) = this.TelemetryEvent(p)
208-
member this.ClientRegisterCapability(p: RegistrationParams) = this.ClientRegisterCapability(p)
209-
member this.ClientUnregisterCapability(p: UnregistrationParams) = this.ClientUnregisterCapability(p)
210-
member this.WorkspaceWorkspaceFolders() = this.WorkspaceWorkspaceFolders()
211-
member this.WorkspaceConfiguration(p: ConfigurationParams) = this.WorkspaceConfiguration(p)
212-
member this.WorkspaceApplyEdit(p: ApplyWorkspaceEditParams) = this.WorkspaceApplyEdit(p)
213-
member this.WorkspaceSemanticTokensRefresh() = this.WorkspaceSemanticTokensRefresh()
214-
member this.WorkspaceInlayHintRefresh() = this.WorkspaceInlayHintRefresh()
215-
member this.TextDocumentPublishDiagnostics(p: PublishDiagnosticsParams) = this.TextDocumentPublishDiagnostics(p)
99+
abstract member ``textDocument/publishDiagnostics``: EventHandler<PublishDiagnosticsParams>

src/Server.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ open System.Threading
77
open System.Threading.Tasks
88

99
[<Interface>]
10-
type LspServer =
10+
type ILspServer =
1111
inherit System.IDisposable
1212

1313
abstract member Dispose: unit -> unit

0 commit comments

Comments
 (0)