Skip to content

Commit 31fb9ce

Browse files
committed
convert client to interface-based only
1 parent 99f197c commit 31fb9ce

File tree

2 files changed

+21
-34
lines changed

2 files changed

+21
-34
lines changed

src/Client.fs

Lines changed: 20 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,43 @@
11
namespace Ionide.LanguageServerProtocol
22

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

5-
6-
[<AbstractClass>]
7-
type LspClient() =
8+
[<Interface>]
9+
type ILspClient =
810

911
/// The show message notification is sent from a server to a client to ask the client to display
1012
/// a particular message in the user interface.
11-
abstract member WindowShowMessage: ShowMessageParams -> Async<unit>
12-
13-
default __.WindowShowMessage(_) = ignoreNotification
13+
abstract member ``window/showMessage``: EventHandler<ShowMessageParams>
1414

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

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

26-
default __.WindowLogMessage(_) = ignoreNotification
2725

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

32-
default __.TelemetryEvent(_) = ignoreNotification
3330

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

40-
default __.ClientRegisterCapability(_) = notImplemented
4137

4238
/// The `client/unregisterCapability` request is sent from the server to the client to unregister a previously
4339
/// registered capability.
44-
abstract member ClientUnregisterCapability: UnregistrationParams -> AsyncLspResult<unit>
45-
46-
default __.ClientUnregisterCapability(_) = notImplemented
40+
abstract member ``client/unregisterCapability``: UnregistrationParams * CancellationToken -> Task<unit>
4741

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

61-
default __.WorkspaceWorkspaceFolders() = notImplemented
6255

6356
/// The workspace/configuration request is sent from the server to the client to fetch configuration
6457
/// settings from the client.
6558
///
6659
/// The request can fetch n configuration settings in one roundtrip. The order of the returned configuration
6760
/// settings correspond to the order of the passed ConfigurationItems (e.g. the first item in the response
6861
/// is the result for the first configuration item in the params).
69-
abstract member WorkspaceConfiguration: ConfigurationParams -> AsyncLspResult<Newtonsoft.Json.Linq.JToken []>
62+
abstract member ``workspace/configuration``: ConfigurationParams * CancellationToken -> Task<LSPAny array>
7063

71-
default __.WorkspaceConfiguration(_) = notImplemented
7264

73-
abstract member WorkspaceApplyEdit: ApplyWorkspaceEditParams -> AsyncLspResult<ApplyWorkspaceEditResponse>
74-
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>
7568

7669
/// The workspace/semanticTokens/refresh request is sent from the server to the client.
7770
/// Servers can use it to ask clients to refresh the editors for which this server provides semantic tokens.
7871
/// As a result the client should ask the server to recompute the semantic tokens for these editors.
7972
/// This is useful if a server detects a project wide configuration change which requires a re-calculation
8073
/// of all semantic tokens. Note that the client still has the freedom to delay the re-calculation of
8174
/// the semantic tokens if for example an editor is currently not visible.
82-
abstract member WorkspaceSemanticTokensRefresh: unit -> Async<unit>
83-
84-
default __.WorkspaceSemanticTokensRefresh() = ignoreNotification
75+
abstract member ``workspace/semanticTokens/refresh``: unit * CancellationToken -> Task<unit>
8576

8677
/// The `workspace/inlayHint/refresh` request is sent from the server to the client.
8778
/// Servers can use it to ask clients to refresh the inlay hints currently shown in editors.
8879
/// As a result the client should ask the server to recompute the inlay hints for these editors.
8980
/// This is useful if a server detects a configuration change which requires a re-calculation
9081
/// of all inlay hints. Note that the client still has the freedom to delay the re-calculation of the inlay hints
9182
/// if for example an editor is currently not visible.
92-
abstract member WorkspaceInlayHintRefresh: unit -> Async<unit>
93-
94-
default __.WorkspaceInlayHintRefresh() = ignoreNotification
83+
abstract member ``workspace/inlayHint/refresh``: unit * CancellationToken -> Task<unit>
9584

9685
/// Diagnostics notification are sent from the server to the client to signal results of validation runs.
9786
///
@@ -107,6 +96,4 @@ type LspClient() =
10796
/// client. If the computed set is empty it has to push the empty array to clear former diagnostics.
10897
/// Newly pushed diagnostics always replace previously pushed diagnostics. There is no merging that happens
10998
/// on the client side.
110-
abstract member TextDocumentPublishDiagnostics: PublishDiagnosticsParams -> Async<unit>
111-
112-
default __.TextDocumentPublishDiagnostics(_) = ignoreNotification
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)