diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json
index 3abe23a..800e578 100644
--- a/.config/dotnet-tools.json
+++ b/.config/dotnet-tools.json
@@ -2,14 +2,8 @@
"version": 1,
"isRoot": true,
"tools": {
- "paket": {
- "version": "6.2.1",
- "commands": [
- "paket"
- ]
- },
"fantomas": {
- "version": "6.2.3",
+ "version": "7.0.1",
"commands": [
"fantomas"
]
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 65e2eb3..5b6f989 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -21,7 +21,7 @@ jobs:
global-json-file: global.json
dotnet-version: |
8.x
- 6.x
+ 9.x
- name: Run build
run: dotnet build -c Release src
- name: Run tests
@@ -29,7 +29,7 @@ jobs:
- name: Run publish
run: dotnet pack -o release src
- name: Upload NuGet packages
- uses: actions/upload-artifact@v2
+ uses: actions/upload-artifact@v4
with:
- name: packages
+ name: packages-${{ matrix.os }}
path: release/
diff --git a/.vscode/settings.json b/.vscode/settings.json
index ebcf8fd..10ff91d 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -7,5 +7,6 @@
"Ionide",
"Newtonsoft",
"Supertypes"
- ]
+ ],
+ "editor.formatOnSave": true
}
\ No newline at end of file
diff --git a/Directory.Build.targets b/Directory.Build.targets
new file mode 100644
index 0000000..54a4472
--- /dev/null
+++ b/Directory.Build.targets
@@ -0,0 +1,42 @@
+
+
+
+
+ <_BuildProjBaseIntermediateOutputPath>$(MSBuildThisFileDirectory)build/obj/
+ <_DotnetToolManifestFile>$(MSBuildThisFileDirectory).config/dotnet-tools.json
+ <_DotnetToolRestoreOutputFile>
+ $(_BuildProjBaseIntermediateOutputPath)/dotnet-tool-restore-$(NETCoreSdkVersion)-$(OS)
+ <_DotnetFantomasOutputFile>
+ $(BaseIntermediateOutputPath)dotnet-fantomas-msbuild-$(NETCoreSdkVersion)-$(OS)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/global.json b/global.json
index cf2164e..f15a959 100644
--- a/global.json
+++ b/global.json
@@ -1,6 +1,6 @@
{
"sdk": {
- "version": "8.0.100",
- "rollForward": "major"
+ "version": "9.0.100",
+ "rollForward": "latestMinor"
}
}
\ No newline at end of file
diff --git a/src/Client.fs b/src/Client.fs
index c6e88d3..c828e5c 100644
--- a/src/Client.fs
+++ b/src/Client.fs
@@ -1,6 +1,7 @@
namespace Ionide.LanguageServerProtocol
open Ionide.LanguageServerProtocol.Types
+open Ionide.LanguageServerProtocol.JsonRpc
module private ClientUtil =
/// Return the JSON-RPC "not implemented" error
@@ -11,131 +12,6 @@ module private ClientUtil =
open ClientUtil
-[]
-type ILspClient =
- /// 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
-
- /// 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
-
-
- /// 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
-
- /// 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
-
- /// 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
-
- /// 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
-
- /// The `client/unregisterCapability` request is sent from the server to the client to unregister a previously
- /// registered capability.
- abstract member ClientUnregisterCapability: UnregistrationParams -> AsyncLspResult
-
-
- /// 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
-
- /// 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
-
-
- abstract member WorkspaceApplyEdit: ApplyWorkspaceEditParams -> AsyncLspResult
-
- /// 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 -> Async
-
-
- /// 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 -> Async
-
-
- /// 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 -> Async
-
-
- /// 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 -> Async
-
-
- /// 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
-
- /// 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 -> Async
-
- /// 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 WorkDoneProgressCreate: ProgressToken -> AsyncLspResult
-
- /// The base protocol offers also support to report progress in a generic fashion.
- /// This mechanism can be used to report any kind of progress including work done progress
- /// (usually used to report progress in the user interface using a progress bar) and
- /// partial result progress to support streaming of results.
- abstract member Progress: ProgressToken * 'Progress -> Async
-
[]
type LspClient() =
@@ -218,9 +94,9 @@ type LspClient() =
/// 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 -> Async
+ abstract member WorkspaceSemanticTokensRefresh: unit -> AsyncLspResult
- default __.WorkspaceSemanticTokensRefresh() = ignoreNotification
+ 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.
@@ -228,9 +104,9 @@ type LspClient() =
/// 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 -> Async
+ abstract member WorkspaceInlayHintRefresh: unit -> AsyncLspResult
- default __.WorkspaceInlayHintRefresh() = ignoreNotification
+ 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
@@ -238,9 +114,9 @@ type LspClient() =
/// 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 -> Async
+ abstract member WorkspaceCodeLensRefresh: unit -> AsyncLspResult
- default __.WorkspaceCodeLensRefresh() = ignoreNotification
+ 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
@@ -248,9 +124,9 @@ type LspClient() =
/// 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 -> Async
+ abstract member WorkspaceInlineValueRefresh: unit -> AsyncLspResult
- default __.WorkspaceInlineValueRefresh() = ignoreNotification
+ default __.WorkspaceInlineValueRefresh() = notImplemented
/// Diagnostics notification are sent from the server to the client to signal results of validation runs.
///
@@ -273,17 +149,23 @@ type LspClient() =
/// 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 -> Async
+ abstract member WorkspaceDiagnosticRefresh: unit -> AsyncLspResult
+
+ default __.WorkspaceDiagnosticRefresh() = notImplemented
+
+ abstract member Progress: ProgressParams -> Async
- default __.WorkspaceDiagnosticRefresh() = ignoreNotification
+ default __.Progress(p) = ignoreNotification
- abstract member Progress: ProgressToken * 'Progress -> Async
+ abstract member CancelRequest: CancelParams -> Async
+ default __.CancelRequest(_) = ignoreNotification
- default __.Progress(_, _) = ignoreNotification
+ abstract member LogTrace: LogTraceParams -> Async
+ 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 WorkDoneProgressCreate: ProgressToken -> AsyncLspResult
- default __.WorkDoneProgressCreate(_) = notImplemented
+ abstract member WindowWorkDoneProgressCreate: WorkDoneProgressCreateParams -> AsyncLspResult
+ default __.WindowWorkDoneProgressCreate(_) = notImplemented
interface ILspClient with
member this.WindowShowMessage(p: ShowMessageParams) = this.WindowShowMessage(p)
@@ -302,5 +184,8 @@ type LspClient() =
member this.WorkspaceInlineValueRefresh() = this.WorkspaceInlineValueRefresh()
member this.TextDocumentPublishDiagnostics(p: PublishDiagnosticsParams) = this.TextDocumentPublishDiagnostics(p)
member this.WorkspaceDiagnosticRefresh() = this.WorkspaceDiagnosticRefresh()
- member this.WorkDoneProgressCreate(token: ProgressToken) = this.WorkDoneProgressCreate(token)
- member this.Progress(token, data) = this.Progress(token, data)
\ No newline at end of file
+ member this.WindowWorkDoneProgressCreate(p: WorkDoneProgressCreateParams) = this.WindowWorkDoneProgressCreate(p)
+ member this.Progress(p: ProgressParams) = this.Progress(p)
+ member this.CancelRequest(p: CancelParams) : Async = this.CancelRequest(p)
+ member this.LogTrace(p: LogTraceParams) : Async = this.LogTrace(p)
+ member this.Dispose() : unit = ()
\ No newline at end of file
diff --git a/src/ClientServer.cg.fs b/src/ClientServer.cg.fs
new file mode 100644
index 0000000..a899f79
--- /dev/null
+++ b/src/ClientServer.cg.fs
@@ -0,0 +1,593 @@
+namespace Ionide.LanguageServerProtocol
+
+open Ionide.LanguageServerProtocol.Types
+open Ionide.LanguageServerProtocol.JsonRpc
+
+type ILspServer =
+ inherit System.IDisposable
+ // Notifications
+ /// The `workspace/didChangeWorkspaceFolders` notification is sent from the client to the server when the workspace
+ /// folder configuration changes.
+ abstract WorkspaceDidChangeWorkspaceFolders: DidChangeWorkspaceFoldersParams -> Async
+ /// The `window/workDoneProgress/cancel` notification is sent from the client to the server to cancel a progress
+ /// initiated on the server side.
+ abstract WindowWorkDoneProgressCancel: WorkDoneProgressCancelParams -> Async
+ /// The did create files notification is sent from the client to the server when
+ /// files were created from within the client.
+ ///
+ /// @since 3.16.0
+ abstract WorkspaceDidCreateFiles: CreateFilesParams -> Async
+ /// The did rename files notification is sent from the client to the server when
+ /// files were renamed from within the client.
+ ///
+ /// @since 3.16.0
+ abstract WorkspaceDidRenameFiles: RenameFilesParams -> Async
+ /// The will delete files request is sent from the client to the server before files are actually
+ /// deleted as long as the deletion is triggered from within the client.
+ ///
+ /// @since 3.16.0
+ abstract WorkspaceDidDeleteFiles: DeleteFilesParams -> Async
+ /// A notification sent when a notebook opens.
+ ///
+ /// @since 3.17.0
+ abstract NotebookDocumentDidOpen: DidOpenNotebookDocumentParams -> Async
+ abstract NotebookDocumentDidChange: DidChangeNotebookDocumentParams -> Async
+ /// A notification sent when a notebook document is saved.
+ ///
+ /// @since 3.17.0
+ abstract NotebookDocumentDidSave: DidSaveNotebookDocumentParams -> Async
+ /// A notification sent when a notebook closes.
+ ///
+ /// @since 3.17.0
+ abstract NotebookDocumentDidClose: DidCloseNotebookDocumentParams -> Async
+ /// The initialized notification is sent from the client to the
+ /// server after the client is fully initialized and the server
+ /// is allowed to send requests from the server to the client.
+ abstract Initialized: InitializedParams -> Async
+ /// The exit event is sent from the client to the server to
+ /// ask the server to exit its process.
+ abstract Exit: unit -> Async
+ /// The configuration change notification is sent from the client to the server
+ /// when the client's configuration has changed. The notification contains
+ /// the changed configuration as defined by the language client.
+ abstract WorkspaceDidChangeConfiguration: DidChangeConfigurationParams -> Async
+ /// The document open notification is sent from the client to the server to signal
+ /// newly opened text documents. The document's truth is now managed by the client
+ /// and the server must not try to read the document's truth using the document's
+ /// uri. Open in this sense means it is managed by the client. It doesn't necessarily
+ /// mean that its content is presented in an editor. An open notification must not
+ /// be sent more than once without a corresponding close notification send before.
+ /// This means open and close notification must be balanced and the max open count
+ /// is one.
+ abstract TextDocumentDidOpen: DidOpenTextDocumentParams -> Async
+ /// The document change notification is sent from the client to the server to signal
+ /// changes to a text document.
+ abstract TextDocumentDidChange: DidChangeTextDocumentParams -> Async
+ /// The document close notification is sent from the client to the server when
+ /// the document got closed in the client. The document's truth now exists where
+ /// the document's uri points to (e.g. if the document's uri is a file uri the
+ /// truth now exists on disk). As with the open notification the close notification
+ /// is about managing the document's content. Receiving a close notification
+ /// doesn't mean that the document was open in an editor before. A close
+ /// notification requires a previous open notification to be sent.
+ abstract TextDocumentDidClose: DidCloseTextDocumentParams -> Async
+ /// The document save notification is sent from the client to the server when
+ /// the document got saved in the client.
+ abstract TextDocumentDidSave: DidSaveTextDocumentParams -> Async
+ /// A document will save notification is sent from the client to the server before
+ /// the document is actually saved.
+ abstract TextDocumentWillSave: WillSaveTextDocumentParams -> Async
+ /// The watched files notification is sent from the client to the server when
+ /// the client detects changes to file watched by the language client.
+ abstract WorkspaceDidChangeWatchedFiles: DidChangeWatchedFilesParams -> Async
+ abstract SetTrace: SetTraceParams -> Async
+ abstract CancelRequest: CancelParams -> Async
+ abstract Progress: ProgressParams -> Async
+ // Requests
+ /// A request to resolve the implementation locations of a symbol at a given text
+ /// document position. The request's parameter is of type {@link TextDocumentPositionParams}
+ /// the response is of type {@link Definition} or a Thenable that resolves to such.
+ abstract TextDocumentImplementation:
+ ImplementationParams -> AsyncLspResult>>>
+
+ /// A request to resolve the type definition locations of a symbol at a given text
+ /// document position. The request's parameter is of type {@link TextDocumentPositionParams}
+ /// the response is of type {@link Definition} or a Thenable that resolves to such.
+ abstract TextDocumentTypeDefinition:
+ TypeDefinitionParams -> AsyncLspResult >>>
+
+ /// A request to list all color symbols found in a given text document. The request's
+ /// parameter is of type {@link DocumentColorParams} the
+ /// response is of type {@link ColorInformation ColorInformation[]} or a Thenable
+ /// that resolves to such.
+ abstract TextDocumentDocumentColor: DocumentColorParams -> AsyncLspResult>
+ /// A request to list all presentation for a color. The request's
+ /// parameter is of type {@link ColorPresentationParams} the
+ /// response is of type {@link ColorInformation ColorInformation[]} or a Thenable
+ /// that resolves to such.
+ abstract TextDocumentColorPresentation: ColorPresentationParams -> AsyncLspResult>
+ /// A request to provide folding ranges in a document. The request's
+ /// parameter is of type {@link FoldingRangeParams}, the
+ /// response is of type {@link FoldingRangeList} or a Thenable
+ /// that resolves to such.
+ abstract TextDocumentFoldingRange: FoldingRangeParams -> AsyncLspResult>>
+
+ /// A request to resolve the type definition locations of a symbol at a given text
+ /// document position. The request's parameter is of type {@link TextDocumentPositionParams}
+ /// the response is of type {@link Declaration} or a typed array of {@link DeclarationLink}
+ /// or a Thenable that resolves to such.
+ abstract TextDocumentDeclaration: DeclarationParams -> AsyncLspResult >>>
+
+ /// A request to provide selection ranges in a document. The request's
+ /// parameter is of type {@link SelectionRangeParams}, the
+ /// response is of type {@link SelectionRange SelectionRange[]} or a Thenable
+ /// that resolves to such.
+ abstract TextDocumentSelectionRange: SelectionRangeParams -> AsyncLspResult >>
+
+ /// A request to result a `CallHierarchyItem` in a document at a given position.
+ /// Can be used as an input to an incoming or outgoing call hierarchy.
+ ///
+ /// @since 3.16.0
+ abstract TextDocumentPrepareCallHierarchy:
+ CallHierarchyPrepareParams -> AsyncLspResult >>
+
+ /// A request to resolve the incoming calls for a given `CallHierarchyItem`.
+ ///
+ /// @since 3.16.0
+ abstract CallHierarchyIncomingCalls:
+ CallHierarchyIncomingCallsParams -> AsyncLspResult >>
+
+ /// A request to resolve the outgoing calls for a given `CallHierarchyItem`.
+ ///
+ /// @since 3.16.0
+ abstract CallHierarchyOutgoingCalls:
+ CallHierarchyOutgoingCallsParams -> AsyncLspResult >>
+
+ /// @since 3.16.0
+ abstract TextDocumentSemanticTokensFull: SemanticTokensParams -> AsyncLspResult >
+
+ /// @since 3.16.0
+ abstract TextDocumentSemanticTokensFullDelta:
+ SemanticTokensDeltaParams -> AsyncLspResult >>
+
+ /// @since 3.16.0
+ abstract TextDocumentSemanticTokensRange: SemanticTokensRangeParams -> AsyncLspResult >
+ /// A request to provide ranges that can be edited together.
+ ///
+ /// @since 3.16.0
+ abstract TextDocumentLinkedEditingRange: LinkedEditingRangeParams -> AsyncLspResult >
+ /// The will create files request is sent from the client to the server before files are actually
+ /// created as long as the creation is triggered from within the client.
+ ///
+ /// The request can return a `WorkspaceEdit` which will be applied to workspace before the
+ /// files are created. Hence the `WorkspaceEdit` can not manipulate the content of the file
+ /// to be created.
+ ///
+ /// @since 3.16.0
+ abstract WorkspaceWillCreateFiles: CreateFilesParams -> AsyncLspResult >
+ /// The will rename files request is sent from the client to the server before files are actually
+ /// renamed as long as the rename is triggered from within the client.
+ ///
+ /// @since 3.16.0
+ abstract WorkspaceWillRenameFiles: RenameFilesParams -> AsyncLspResult >
+ /// The did delete files notification is sent from the client to the server when
+ /// files were deleted from within the client.
+ ///
+ /// @since 3.16.0
+ abstract WorkspaceWillDeleteFiles: DeleteFilesParams -> AsyncLspResult >
+ /// A request to get the moniker of a symbol at a given text document position.
+ /// The request parameter is of type {@link TextDocumentPositionParams}.
+ /// The response is of type {@link Moniker Moniker[]} or `null`.
+ abstract TextDocumentMoniker: MonikerParams -> AsyncLspResult >>
+
+ /// A request to result a `TypeHierarchyItem` in a document at a given position.
+ /// Can be used as an input to a subtypes or supertypes type hierarchy.
+ ///
+ /// @since 3.17.0
+ abstract TextDocumentPrepareTypeHierarchy:
+ TypeHierarchyPrepareParams -> AsyncLspResult >>
+
+ /// A request to resolve the supertypes for a given `TypeHierarchyItem`.
+ ///
+ /// @since 3.17.0
+ abstract TypeHierarchySupertypes: TypeHierarchySupertypesParams -> AsyncLspResult >>
+ /// A request to resolve the subtypes for a given `TypeHierarchyItem`.
+ ///
+ /// @since 3.17.0
+ abstract TypeHierarchySubtypes: TypeHierarchySubtypesParams -> AsyncLspResult >>
+ /// A request to provide inline values in a document. The request's parameter is of
+ /// type {@link InlineValueParams}, the response is of type
+ /// {@link InlineValue InlineValue[]} or a Thenable that resolves to such.
+ ///
+ /// @since 3.17.0
+ abstract TextDocumentInlineValue: InlineValueParams -> AsyncLspResult >>
+ /// A request to provide inlay hints in a document. The request's parameter is of
+ /// type {@link InlayHintsParams}, the response is of type
+ /// {@link InlayHint InlayHint[]} or a Thenable that resolves to such.
+ ///
+ /// @since 3.17.0
+ abstract TextDocumentInlayHint: InlayHintParams -> AsyncLspResult >>
+ /// A request to resolve additional properties for an inlay hint.
+ /// The request's parameter is of type {@link InlayHint}, the response is
+ /// of type {@link InlayHint} or a Thenable that resolves to such.
+ ///
+ /// @since 3.17.0
+ abstract InlayHintResolve: InlayHint -> AsyncLspResult
+ /// The document diagnostic request definition.
+ ///
+ /// @since 3.17.0
+ abstract TextDocumentDiagnostic: DocumentDiagnosticParams -> AsyncLspResult
+ /// The workspace diagnostic request definition.
+ ///
+ /// @since 3.17.0
+ abstract WorkspaceDiagnostic: WorkspaceDiagnosticParams -> AsyncLspResult
+ /// The initialize request is sent from the client to the server.
+ /// It is sent once as the request after starting up the server.
+ /// The requests parameter is of type {@link InitializeParams}
+ /// the response if of type {@link InitializeResult} of a Thenable that
+ /// resolves to such.
+ abstract Initialize: InitializeParams -> AsyncLspResult
+ /// A shutdown request is sent from the client to the server.
+ /// It is sent once when the client decides to shutdown the
+ /// server. The only notification that is sent after a shutdown request
+ /// is the exit event.
+ abstract Shutdown: unit -> AsyncLspResult
+ /// A document will save request is sent from the client to the server before
+ /// the document is actually saved. The request can return an array of TextEdits
+ /// which will be applied to the text document before it is saved. Please note that
+ /// clients might drop results if computing the text edits took too long or if a
+ /// server constantly fails on this request. This is done to keep the save fast and
+ /// reliable.
+ abstract TextDocumentWillSaveWaitUntil: WillSaveTextDocumentParams -> AsyncLspResult>>
+
+ /// Request to request completion at a given text document position. The request's
+ /// parameter is of type {@link TextDocumentPosition} the response
+ /// is of type {@link CompletionItem CompletionItem[]} or {@link CompletionList}
+ /// or a Thenable that resolves to such.
+ ///
+ /// The request can delay the computation of the {@link CompletionItem.detail `detail`}
+ /// and {@link CompletionItem.documentation `documentation`} properties to the `completionItem/resolve`
+ /// request. However, properties that are needed for the initial sorting and filtering, like `sortText`,
+ /// `filterText`, `insertText`, and `textEdit`, must not be changed during resolve.
+ abstract TextDocumentCompletion: CompletionParams -> AsyncLspResult , CompletionList>>>
+
+ /// Request to resolve additional information for a given completion item.The request's
+ /// parameter is of type {@link CompletionItem} the response
+ /// is of type {@link CompletionItem} or a Thenable that resolves to such.
+ abstract CompletionItemResolve: CompletionItem -> AsyncLspResult
+ /// Request to request hover information at a given text document position. The request's
+ /// parameter is of type {@link TextDocumentPosition} the response is of
+ /// type {@link Hover} or a Thenable that resolves to such.
+ abstract TextDocumentHover: HoverParams -> AsyncLspResult>
+ abstract TextDocumentSignatureHelp: SignatureHelpParams -> AsyncLspResult >
+ /// A request to resolve the definition location of a symbol at a given text
+ /// document position. The request's parameter is of type {@link TextDocumentPosition}
+ /// the response is of either type {@link Definition} or a typed array of
+ /// {@link DefinitionLink} or a Thenable that resolves to such.
+ abstract TextDocumentDefinition: DefinitionParams -> AsyncLspResult >>>
+ /// A request to resolve project-wide references for the symbol denoted
+ /// by the given text document position. The request's parameter is of
+ /// type {@link ReferenceParams} the response is of type
+ /// {@link Location Location[]} or a Thenable that resolves to such.
+ abstract TextDocumentReferences: ReferenceParams -> AsyncLspResult >>
+ /// Request to resolve a {@link DocumentHighlight} for a given
+ /// text document position. The request's parameter is of type {@link TextDocumentPosition}
+ /// the request response is an array of type {@link DocumentHighlight}
+ /// or a Thenable that resolves to such.
+ abstract TextDocumentDocumentHighlight: DocumentHighlightParams -> AsyncLspResult >>
+
+ /// A request to list all symbols found in a given text document. The request's
+ /// parameter is of type {@link TextDocumentIdentifier} the
+ /// response is of type {@link SymbolInformation SymbolInformation[]} or a Thenable
+ /// that resolves to such.
+ abstract TextDocumentDocumentSymbol:
+ DocumentSymbolParams -> AsyncLspResult , array>>>
+
+ /// A request to provide commands for the given text document and range.
+ abstract TextDocumentCodeAction: CodeActionParams -> AsyncLspResult>>>
+ /// Request to resolve additional information for a given code action.The request's
+ /// parameter is of type {@link CodeAction} the response
+ /// is of type {@link CodeAction} or a Thenable that resolves to such.
+ abstract CodeActionResolve: CodeAction -> AsyncLspResult
+
+ /// A request to list project-wide symbols matching the query string given
+ /// by the {@link WorkspaceSymbolParams}. The response is
+ /// of type {@link SymbolInformation SymbolInformation[]} or a Thenable that
+ /// resolves to such.
+ ///
+ /// @since 3.17.0 - support for WorkspaceSymbol in the returned data. Clients
+ /// need to advertise support for WorkspaceSymbols via the client capability
+ /// `workspace.symbol.resolveSupport`.
+ abstract WorkspaceSymbol:
+ WorkspaceSymbolParams -> AsyncLspResult, array>>>
+
+ /// A request to resolve the range inside the workspace
+ /// symbol's location.
+ ///
+ /// @since 3.17.0
+ abstract WorkspaceSymbolResolve: WorkspaceSymbol -> AsyncLspResult
+ /// A request to provide code lens for the given text document.
+ abstract TextDocumentCodeLens: CodeLensParams -> AsyncLspResult>>
+ /// A request to resolve a command for a given code lens.
+ abstract CodeLensResolve: CodeLens -> AsyncLspResult
+ /// A request to provide document links
+ abstract TextDocumentDocumentLink: DocumentLinkParams -> AsyncLspResult>>
+ /// Request to resolve additional information for a given document link. The request's
+ /// parameter is of type {@link DocumentLink} the response
+ /// is of type {@link DocumentLink} or a Thenable that resolves to such.
+ abstract DocumentLinkResolve: DocumentLink -> AsyncLspResult
+ /// A request to format a whole document.
+ abstract TextDocumentFormatting: DocumentFormattingParams -> AsyncLspResult>>
+ /// A request to format a range in a document.
+ abstract TextDocumentRangeFormatting: DocumentRangeFormattingParams -> AsyncLspResult >>
+ /// A request to format a document on type.
+ abstract TextDocumentOnTypeFormatting: DocumentOnTypeFormattingParams -> AsyncLspResult >>
+ /// A request to rename a symbol.
+ abstract TextDocumentRename: RenameParams -> AsyncLspResult >
+ /// A request to test and perform the setup necessary for a rename.
+ ///
+ /// @since 3.16 - support for default behavior
+ abstract TextDocumentPrepareRename: PrepareRenameParams -> AsyncLspResult >
+ /// A request send from the client to the server to execute a command. The request might return
+ /// a workspace edit which the client will apply to the workspace.
+ abstract WorkspaceExecuteCommand: ExecuteCommandParams -> AsyncLspResult >
+
+type ILspClient =
+ inherit System.IDisposable
+ // Notifications
+ /// 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 WindowShowMessage: ShowMessageParams -> Async
+ /// The log message notification is sent from the server to the client to ask
+ /// the client to log a particular message.
+ abstract WindowLogMessage: LogMessageParams -> Async
+ /// The telemetry event notification is sent from the server to the client to ask
+ /// the client to log telemetry data.
+ abstract TelemetryEvent: LSPAny -> Async
+ /// Diagnostics notification are sent from the server to the client to signal
+ /// results of validation runs.
+ abstract TextDocumentPublishDiagnostics: PublishDiagnosticsParams -> Async
+ abstract LogTrace: LogTraceParams -> Async
+ abstract CancelRequest: CancelParams -> Async
+ abstract Progress: ProgressParams -> Async
+ // Requests
+ /// The `workspace/workspaceFolders` is sent from the server to the client to fetch the open workspace folders.
+ abstract WorkspaceWorkspaceFolders: unit -> AsyncLspResult>>
+ /// The 'workspace/configuration' request is sent from the server to the client to fetch a certain
+ /// configuration setting.
+ ///
+ /// This pull model replaces the old push model where the client signaled configuration change via an
+ /// event. If the server still needs to react to configuration changes (since the server caches the
+ /// result of `workspace/configuration` requests) the server should register for an empty configuration
+ /// change event and empty the cache if such an event is received.
+ abstract WorkspaceConfiguration: ConfigurationParams -> AsyncLspResult>
+ /// The `window/workDoneProgress/create` request is sent from the server to the client to initiate progress
+ /// reporting from the server.
+ abstract WindowWorkDoneProgressCreate: WorkDoneProgressCreateParams -> AsyncLspResult
+ /// @since 3.16.0
+ abstract WorkspaceSemanticTokensRefresh: unit -> AsyncLspResult
+ /// A request to show a document. This request might open an
+ /// external program depending on the value of the URI to open.
+ /// For example a request to open `https://code.visualstudio.com/`
+ /// will very likely open the URI in a WEB browser.
+ ///
+ /// @since 3.16.0
+ abstract WindowShowDocument: ShowDocumentParams -> AsyncLspResult
+ /// @since 3.17.0
+ abstract WorkspaceInlineValueRefresh: unit -> AsyncLspResult
+ /// @since 3.17.0
+ abstract WorkspaceInlayHintRefresh: unit -> AsyncLspResult
+ /// The diagnostic refresh request definition.
+ ///
+ /// @since 3.17.0
+ abstract WorkspaceDiagnosticRefresh: unit -> AsyncLspResult
+ /// The `client/registerCapability` request is sent from the server to the client to register a new capability
+ /// handler on the client side.
+ abstract ClientRegisterCapability: RegistrationParams -> AsyncLspResult
+ /// The `client/unregisterCapability` request is sent from the server to the client to unregister a previously registered capability
+ /// handler on the client side.
+ abstract ClientUnregisterCapability: UnregistrationParams -> AsyncLspResult
+ /// The show message request is sent from the server to the client to show a message
+ /// and a set of options actions to the user.
+ abstract WindowShowMessageRequest: ShowMessageRequestParams -> AsyncLspResult>
+ /// A request to refresh all code actions
+ ///
+ /// @since 3.16.0
+ abstract WorkspaceCodeLensRefresh: unit -> AsyncLspResult
+ /// A request sent from the server to the client to modified certain resources.
+ abstract WorkspaceApplyEdit: ApplyWorkspaceEditParams -> AsyncLspResult
+
+module Mappings =
+ type ServerRequestHandling<'server when 'server :> ILspServer> = { Run: 'server -> System.Delegate }
+
+ let routeMappings () =
+ let serverRequestHandling run = {
+ Run =
+ fun server ->
+ run server
+ |> JsonRpc.Requests.requestHandling
+ }
+
+ [
+ "textDocument/implementation",
+ serverRequestHandling (fun server request -> server.TextDocumentImplementation(request))
+ "textDocument/typeDefinition",
+ serverRequestHandling (fun server request -> server.TextDocumentTypeDefinition(request))
+ "textDocument/documentColor",
+ serverRequestHandling (fun server request -> server.TextDocumentDocumentColor(request))
+ "textDocument/colorPresentation",
+ serverRequestHandling (fun server request -> server.TextDocumentColorPresentation(request))
+ "textDocument/foldingRange",
+ serverRequestHandling (fun server request -> server.TextDocumentFoldingRange(request))
+ "textDocument/declaration", serverRequestHandling (fun server request -> server.TextDocumentDeclaration(request))
+ "textDocument/selectionRange",
+ serverRequestHandling (fun server request -> server.TextDocumentSelectionRange(request))
+ "textDocument/prepareCallHierarchy",
+ serverRequestHandling (fun server request -> server.TextDocumentPrepareCallHierarchy(request))
+ "callHierarchy/incomingCalls",
+ serverRequestHandling (fun server request -> server.CallHierarchyIncomingCalls(request))
+ "callHierarchy/outgoingCalls",
+ serverRequestHandling (fun server request -> server.CallHierarchyOutgoingCalls(request))
+ "textDocument/semanticTokens/full",
+ serverRequestHandling (fun server request -> server.TextDocumentSemanticTokensFull(request))
+ "textDocument/semanticTokens/full/delta",
+ serverRequestHandling (fun server request -> server.TextDocumentSemanticTokensFullDelta(request))
+ "textDocument/semanticTokens/range",
+ serverRequestHandling (fun server request -> server.TextDocumentSemanticTokensRange(request))
+ "textDocument/linkedEditingRange",
+ serverRequestHandling (fun server request -> server.TextDocumentLinkedEditingRange(request))
+ "workspace/willCreateFiles",
+ serverRequestHandling (fun server request -> server.WorkspaceWillCreateFiles(request))
+ "workspace/willRenameFiles",
+ serverRequestHandling (fun server request -> server.WorkspaceWillRenameFiles(request))
+ "workspace/willDeleteFiles",
+ serverRequestHandling (fun server request -> server.WorkspaceWillDeleteFiles(request))
+ "textDocument/moniker", serverRequestHandling (fun server request -> server.TextDocumentMoniker(request))
+ "textDocument/prepareTypeHierarchy",
+ serverRequestHandling (fun server request -> server.TextDocumentPrepareTypeHierarchy(request))
+ "typeHierarchy/supertypes", serverRequestHandling (fun server request -> server.TypeHierarchySupertypes(request))
+ "typeHierarchy/subtypes", serverRequestHandling (fun server request -> server.TypeHierarchySubtypes(request))
+ "textDocument/inlineValue", serverRequestHandling (fun server request -> server.TextDocumentInlineValue(request))
+ "textDocument/inlayHint", serverRequestHandling (fun server request -> server.TextDocumentInlayHint(request))
+ "inlayHint/resolve", serverRequestHandling (fun server request -> server.InlayHintResolve(request))
+ "textDocument/diagnostic", serverRequestHandling (fun server request -> server.TextDocumentDiagnostic(request))
+ "workspace/diagnostic", serverRequestHandling (fun server request -> server.WorkspaceDiagnostic(request))
+ "initialize", serverRequestHandling (fun server request -> server.Initialize(request))
+ "shutdown", serverRequestHandling (fun server request -> server.Shutdown())
+ "textDocument/willSaveWaitUntil",
+ serverRequestHandling (fun server request -> server.TextDocumentWillSaveWaitUntil(request))
+ "textDocument/completion", serverRequestHandling (fun server request -> server.TextDocumentCompletion(request))
+ "completionItem/resolve", serverRequestHandling (fun server request -> server.CompletionItemResolve(request))
+ "textDocument/hover", serverRequestHandling (fun server request -> server.TextDocumentHover(request))
+ "textDocument/signatureHelp",
+ serverRequestHandling (fun server request -> server.TextDocumentSignatureHelp(request))
+ "textDocument/definition", serverRequestHandling (fun server request -> server.TextDocumentDefinition(request))
+ "textDocument/references", serverRequestHandling (fun server request -> server.TextDocumentReferences(request))
+ "textDocument/documentHighlight",
+ serverRequestHandling (fun server request -> server.TextDocumentDocumentHighlight(request))
+ "textDocument/documentSymbol",
+ serverRequestHandling (fun server request -> server.TextDocumentDocumentSymbol(request))
+ "textDocument/codeAction", serverRequestHandling (fun server request -> server.TextDocumentCodeAction(request))
+ "codeAction/resolve", serverRequestHandling (fun server request -> server.CodeActionResolve(request))
+ "workspace/symbol", serverRequestHandling (fun server request -> server.WorkspaceSymbol(request))
+ "workspaceSymbol/resolve", serverRequestHandling (fun server request -> server.WorkspaceSymbolResolve(request))
+ "textDocument/codeLens", serverRequestHandling (fun server request -> server.TextDocumentCodeLens(request))
+ "codeLens/resolve", serverRequestHandling (fun server request -> server.CodeLensResolve(request))
+ "textDocument/documentLink",
+ serverRequestHandling (fun server request -> server.TextDocumentDocumentLink(request))
+ "documentLink/resolve", serverRequestHandling (fun server request -> server.DocumentLinkResolve(request))
+ "textDocument/formatting", serverRequestHandling (fun server request -> server.TextDocumentFormatting(request))
+ "textDocument/rangeFormatting",
+ serverRequestHandling (fun server request -> server.TextDocumentRangeFormatting(request))
+ "textDocument/onTypeFormatting",
+ serverRequestHandling (fun server request -> server.TextDocumentOnTypeFormatting(request))
+ "textDocument/rename", serverRequestHandling (fun server request -> server.TextDocumentRename(request))
+ "textDocument/prepareRename",
+ serverRequestHandling (fun server request -> server.TextDocumentPrepareRename(request))
+ "workspace/executeCommand", serverRequestHandling (fun server request -> server.WorkspaceExecuteCommand(request))
+ "workspace/didChangeWorkspaceFolders",
+ serverRequestHandling (fun server request ->
+ server.WorkspaceDidChangeWorkspaceFolders(request)
+ |> Requests.notificationSuccess
+ )
+ "window/workDoneProgress/cancel",
+ serverRequestHandling (fun server request ->
+ server.WindowWorkDoneProgressCancel(request)
+ |> Requests.notificationSuccess
+ )
+ "workspace/didCreateFiles",
+ serverRequestHandling (fun server request ->
+ server.WorkspaceDidCreateFiles(request)
+ |> Requests.notificationSuccess
+ )
+ "workspace/didRenameFiles",
+ serverRequestHandling (fun server request ->
+ server.WorkspaceDidRenameFiles(request)
+ |> Requests.notificationSuccess
+ )
+ "workspace/didDeleteFiles",
+ serverRequestHandling (fun server request ->
+ server.WorkspaceDidDeleteFiles(request)
+ |> Requests.notificationSuccess
+ )
+ "notebookDocument/didOpen",
+ serverRequestHandling (fun server request ->
+ server.NotebookDocumentDidOpen(request)
+ |> Requests.notificationSuccess
+ )
+ "notebookDocument/didChange",
+ serverRequestHandling (fun server request ->
+ server.NotebookDocumentDidChange(request)
+ |> Requests.notificationSuccess
+ )
+ "notebookDocument/didSave",
+ serverRequestHandling (fun server request ->
+ server.NotebookDocumentDidSave(request)
+ |> Requests.notificationSuccess
+ )
+ "notebookDocument/didClose",
+ serverRequestHandling (fun server request ->
+ server.NotebookDocumentDidClose(request)
+ |> Requests.notificationSuccess
+ )
+ "initialized",
+ serverRequestHandling (fun server request ->
+ server.Initialized(request)
+ |> Requests.notificationSuccess
+ )
+ "exit",
+ serverRequestHandling (fun server request ->
+ server.Exit()
+ |> Requests.notificationSuccess
+ )
+ "workspace/didChangeConfiguration",
+ serverRequestHandling (fun server request ->
+ server.WorkspaceDidChangeConfiguration(request)
+ |> Requests.notificationSuccess
+ )
+ "textDocument/didOpen",
+ serverRequestHandling (fun server request ->
+ server.TextDocumentDidOpen(request)
+ |> Requests.notificationSuccess
+ )
+ "textDocument/didChange",
+ serverRequestHandling (fun server request ->
+ server.TextDocumentDidChange(request)
+ |> Requests.notificationSuccess
+ )
+ "textDocument/didClose",
+ serverRequestHandling (fun server request ->
+ server.TextDocumentDidClose(request)
+ |> Requests.notificationSuccess
+ )
+ "textDocument/didSave",
+ serverRequestHandling (fun server request ->
+ server.TextDocumentDidSave(request)
+ |> Requests.notificationSuccess
+ )
+ "textDocument/willSave",
+ serverRequestHandling (fun server request ->
+ server.TextDocumentWillSave(request)
+ |> Requests.notificationSuccess
+ )
+ "workspace/didChangeWatchedFiles",
+ serverRequestHandling (fun server request ->
+ server.WorkspaceDidChangeWatchedFiles(request)
+ |> Requests.notificationSuccess
+ )
+ "$/setTrace",
+ serverRequestHandling (fun server request ->
+ server.SetTrace(request)
+ |> Requests.notificationSuccess
+ )
+ "$/cancelRequest",
+ serverRequestHandling (fun server request ->
+ server.CancelRequest(request)
+ |> Requests.notificationSuccess
+ )
+ "$/progress",
+ serverRequestHandling (fun server request ->
+ server.Progress(request)
+ |> Requests.notificationSuccess
+ )
+ ]
\ No newline at end of file
diff --git a/src/FsLibLog.fs b/src/FsLibLog.fs
index a84ffb0..f14de48 100644
--- a/src/FsLibLog.fs
+++ b/src/FsLibLog.fs
@@ -26,19 +26,21 @@ module Types =
type MappedContext = string -> obj -> bool -> IDisposable
/// Type representing a Log
- type Log =
- { LogLevel: LogLevel
- Message: MessageThunk
- Exception: exn option
- Parameters: obj list
- AdditionalNamedParameters: ((string * obj * bool) list) }
-
- static member StartLogLevel(logLevel: LogLevel) =
- { LogLevel = logLevel
- Message = None
- Exception = None
- Parameters = List.empty
- AdditionalNamedParameters = List.empty }
+ type Log = {
+ LogLevel: LogLevel
+ Message: MessageThunk
+ Exception: exn option
+ Parameters: obj list
+ AdditionalNamedParameters: ((string * obj * bool) list)
+ } with
+
+ static member StartLogLevel(logLevel: LogLevel) = {
+ LogLevel = logLevel
+ Message = None
+ Exception = None
+ Parameters = List.empty
+ AdditionalNamedParameters = List.empty
+ }
/// An interface wrapper for `Logger`. Useful when using depedency injection frameworks.
type ILog =
@@ -58,7 +60,10 @@ module Types =
stack.Pop().Dispose()
member __.Push(item: IDisposable) = stack.Push item
- member __.Push(items: IDisposable list) = items |> List.iter stack.Push
+
+ member __.Push(items: IDisposable list) =
+ items
+ |> List.iter stack.Push
static member Create(items: IDisposable list) =
let ds = new DisposableStack()
@@ -110,7 +115,9 @@ module Types =
///
/// **Output Type**
/// * `unit`
- member logger.fatal(logConfig: Log -> Log) = logger.fatal' logConfig |> ignore
+ member logger.fatal(logConfig: Log -> Log) =
+ logger.fatal' logConfig
+ |> ignore
/// **Description**
///
@@ -135,7 +142,9 @@ module Types =
///
/// **Output Type**
/// * `unit`
- member logger.error(logConfig: Log -> Log) = logger.error' logConfig |> ignore
+ member logger.error(logConfig: Log -> Log) =
+ logger.error' logConfig
+ |> ignore
/// **Description**
///
@@ -160,7 +169,9 @@ module Types =
///
/// **Output Type**
/// * `unit`
- member logger.warn(logConfig: Log -> Log) = logger.warn' logConfig |> ignore
+ member logger.warn(logConfig: Log -> Log) =
+ logger.warn' logConfig
+ |> ignore
/// **Description**
///
@@ -185,7 +196,9 @@ module Types =
///
/// **Output Type**
/// * `unit`
- member logger.info(logConfig: Log -> Log) = logger.info' logConfig |> ignore
+ member logger.info(logConfig: Log -> Log) =
+ logger.info' logConfig
+ |> ignore
/// **Description**
///
@@ -210,7 +223,9 @@ module Types =
///
/// **Output Type**
/// * `unit`
- member logger.debug(logConfig: Log -> Log) = logger.debug' logConfig |> ignore
+ member logger.debug(logConfig: Log -> Log) =
+ logger.debug' logConfig
+ |> ignore
/// **Description**
///
@@ -235,7 +250,9 @@ module Types =
///
/// **Output Type**
/// * `unit`
- member logger.trace(logConfig: Log -> Log) = logger.trace' logConfig |> ignore
+ member logger.trace(logConfig: Log -> Log) =
+ logger.trace' logConfig
+ |> ignore
/// An interface for retrieving a concrete logger such as Serilog, Nlog, etc.
@@ -302,9 +319,16 @@ module Types =
/// **Exceptions**
///
let addParameters (``params``: obj list) (log: Log) =
- let ``params`` = ``params`` |> List.map box
- { log with Parameters = log.Parameters @ ``params`` }
+ let ``params`` =
+ ``params``
+ |> List.map box
+ {
+ log with
+ Parameters =
+ log.Parameters
+ @ ``params``
+ }
/// **Description**
@@ -323,9 +347,10 @@ module Types =
///
/// **Exceptions**
///
- let addContext (key: string) (value: obj) (log: Log) =
- { log with
- AdditionalNamedParameters = List.append log.AdditionalNamedParameters [ key, (box value), false ] }
+ let addContext (key: string) (value: obj) (log: Log) = {
+ log with
+ AdditionalNamedParameters = List.append log.AdditionalNamedParameters [ key, (box value), false ]
+ }
/// **Description**
@@ -346,9 +371,10 @@ module Types =
///
/// **Exceptions**
///
- let addContextDestructured (key: string) (value: obj) (log: Log) =
- { log with
- AdditionalNamedParameters = List.append log.AdditionalNamedParameters [ key, (box value), true ] }
+ let addContextDestructured (key: string) (value: obj) (log: Log) = {
+ log with
+ AdditionalNamedParameters = List.append log.AdditionalNamedParameters [ key, (box value), true ]
+ }
/// **Description**
@@ -402,7 +428,11 @@ module Providers =
open System.Linq.Expressions
let getLogManagerType () = Type.GetType("Serilog.Log, Serilog")
- let isAvailable () = getLogManagerType () |> isNull |> not
+
+ let isAvailable () =
+ getLogManagerType ()
+ |> isNull
+ |> not
let getPushProperty () =
@@ -414,7 +444,14 @@ module Providers =
()
let pushPropertyMethod =
- ndcContextType.GetMethod("PushProperty", [| typedefof; typedefof; typedefof |])
+ ndcContextType.GetMethod(
+ "PushProperty",
+ [|
+ typedefof
+ typedefof
+ typedefof
+ |]
+ )
let nameParam = Expression.Parameter(typedefof, "name")
let valueParam = Expression.Parameter(typedefof, "value")
@@ -438,11 +475,27 @@ module Providers =
let getForContextMethodCall () =
let logManagerType = getLogManagerType ()
- let method = logManagerType.GetMethod("ForContext", [| typedefof; typedefof; typedefof |])
+
+ let method =
+ logManagerType.GetMethod(
+ "ForContext",
+ [|
+ typedefof
+ typedefof
+ typedefof
+ |]
+ )
+
let propertyNameParam = Expression.Parameter(typedefof, "propertyName")
let valueParam = Expression.Parameter(typedefof, "value")
let destructureObjectsParam = Expression.Parameter(typedefof, "destructureObjects")
- let exrs: Expression[] = [| propertyNameParam; valueParam; destructureObjectsParam |]
+
+ let exrs: Expression[] = [|
+ propertyNameParam
+ valueParam
+ destructureObjectsParam
+ |]
+
let methodCall = Expression.Call(null, method, exrs)
let func =
@@ -452,16 +505,20 @@ module Providers =
fun name -> func.Invoke("SourceContext", name, false)
- type SerilogGateway =
- { Write: obj -> obj -> string -> obj[] -> unit
- WriteException: obj -> obj -> exn -> string -> obj[] -> unit
- IsEnabled: obj -> obj -> bool
- TranslateLevel: LogLevel -> obj }
+ type SerilogGateway = {
+ Write: obj -> obj -> string -> obj[] -> unit
+ WriteException: obj -> obj -> exn -> string -> obj[] -> unit
+ IsEnabled: obj -> obj -> bool
+ TranslateLevel: LogLevel -> obj
+ } with
static member Create() =
let logEventLevelType = Type.GetType("Serilog.Events.LogEventLevel, Serilog")
- if (logEventLevelType |> isNull) then
+ if
+ (logEventLevelType
+ |> isNull)
+ then
failwith ("Type Serilog.Events.LogEventLevel was not found.")
let debugLevel = Enum.Parse(logEventLevelType, "Debug", false)
@@ -483,7 +540,10 @@ module Providers =
let loggerType = Type.GetType("Serilog.ILogger, Serilog")
- if (loggerType |> isNull) then
+ if
+ (loggerType
+ |> isNull)
+ then
failwith ("Type Serilog.ILogger was not found.")
let isEnabledMethodInfo = loggerType.GetMethod("IsEnabled", [| logEventLevelType |])
@@ -497,7 +557,14 @@ module Providers =
Expression.Lambda>(isEnabledMethodCall, instanceParam, levelParam).Compile()
let writeMethodInfo =
- loggerType.GetMethod("Write", [| logEventLevelType; typedefof; typedefof |])
+ loggerType.GetMethod(
+ "Write",
+ [|
+ logEventLevelType
+ typedefof
+ typedefof
+ |]
+ )
let messageParam = Expression.Parameter(typedefof)
let propertyValuesParam = Expression.Parameter(typedefof)
@@ -517,7 +584,15 @@ module Providers =
let write = expression.Compile()
let writeExceptionMethodInfo =
- loggerType.GetMethod("Write", [| logEventLevelType; typedefof; typedefof; typedefof |])
+ loggerType.GetMethod(
+ "Write",
+ [|
+ logEventLevelType
+ typedefof
+ typedefof
+ typedefof
+ |]
+ )
let exceptionParam = Expression.Parameter(typedefof)
@@ -543,13 +618,15 @@ module Providers =
)
.Compile()
- { Write =
+ {
+ Write =
(fun logger level message formattedParmeters -> write.Invoke(logger, level, message, formattedParmeters))
WriteException =
fun logger level ex message formattedParmeters ->
writeException.Invoke(logger, level, ex, message, formattedParmeters)
IsEnabled = fun logger level -> isEnabled.Invoke(logger, level)
- TranslateLevel = translateLevel }
+ TranslateLevel = translateLevel
+ }
type private SerigLogProvider() =
let getLoggerByName = getForContextMethodCall ()
@@ -562,7 +639,11 @@ module Providers =
match messageFunc with
| None -> serilogGateway.IsEnabled logger translatedValue
- | Some _ when serilogGateway.IsEnabled logger translatedValue |> not -> false
+ | Some _ when
+ serilogGateway.IsEnabled logger translatedValue
+ |> not
+ ->
+ false
| Some m ->
match ``exception`` with
| Some ex -> serilogGateway.WriteException logger translatedValue ex (m ()) formatParams
@@ -571,7 +652,9 @@ module Providers =
true
interface ILogProvider with
- member this.GetLogger(name: string) : Logger = getLoggerByName name |> writeMessage
+ member this.GetLogger(name: string) : Logger =
+ getLoggerByName name
+ |> writeMessage
member this.OpenMappedContext (key: string) (value: obj) (destructure: bool) : IDisposable =
pushProperty key value destructure
@@ -602,7 +685,8 @@ module LogProvider =
let private noopDisposable =
{ new IDisposable with
- member __.Dispose() = () }
+ member __.Dispose() = ()
+ }
/// **Description**
///
@@ -687,7 +771,8 @@ module LogProvider =
{ new ILog with
member x.Log = logFunc
- member x.MappedContext = openMappedContextDestucturable }
+ member x.MappedContext = openMappedContextDestucturable
+ }
/// **Description**
///
@@ -698,7 +783,10 @@ module LogProvider =
///
/// **Output Type**
/// * `ILog`
- let getLoggerByType (``type``: Type) = ``type`` |> string |> getLoggerByName
+ let getLoggerByType (``type``: Type) =
+ ``type``
+ |> string
+ |> getLoggerByName
/// **Description**
///
@@ -735,8 +823,9 @@ module LogProvider =
///
/// **Exceptions**
///
- let getLoggerByQuotation (quotation: Quotations.Expr) = getModuleType quotation |> getLoggerByType
-
+ let getLoggerByQuotation (quotation: Quotations.Expr) =
+ getModuleType quotation
+ |> getLoggerByType
/// **Description**
diff --git a/src/Ionide.LanguageServerProtocol.fsproj b/src/Ionide.LanguageServerProtocol.fsproj
index d615540..61da048 100644
--- a/src/Ionide.LanguageServerProtocol.fsproj
+++ b/src/Ionide.LanguageServerProtocol.fsproj
@@ -20,10 +20,11 @@
repo.
-->
-
-
+
+
+
@@ -41,20 +42,39 @@
- <_MetaModelInputs Include="$(MSBuildThisFileDirectory)../data/$(LSPVersion)/metaModel.json" />
+ <_MetaModelInputs
+ Include="$(MSBuildThisFileDirectory)../data/$(LSPVersion)/metaModel.json" />
+ <_GenerationInputs
+ Include="$(MSBuildThisFileDirectory)../tools/**/*.fs;$(MSBuildThisFileDirectory)../tools/**/*.fsproj" />
+
+
<_MetaModelOutputs Include="$(MSBuildThisFileDirectory)Types.cg.fs" />
+ <_MetaModelClientServerOutputs Include="$(MSBuildThisFileDirectory)ClientServer.cg.fs" />
+
+
-
<_GeneratorProject Include="../tools/MetaModelGenerator/MetaModelGenerator.fsproj" />
+
+
+
+
+
@@ -70,5 +90,18 @@
+
+
+ <_GenerateCommand2 Include="dotnet;@(_GeneratorApp)" />
+ <_GenerateCommand2 Include="clientserver" />
+ <_GenerateCommand2 Include="--metamodelpath" />
+ <_GenerateCommand2 Include="%(_MetaModelInputs.FullPath)" />
+ <_GenerateCommand2 Include="--outputfilepath" />
+ <_GenerateCommand2 Include="%(_MetaModelClientServerOutputs.FullPath)" />
+
+
+
+
\ No newline at end of file
diff --git a/src/JsonRpc.fs b/src/JsonRpc.fs
index aa6a467..7e73b88 100644
--- a/src/JsonRpc.fs
+++ b/src/JsonRpc.fs
@@ -3,11 +3,12 @@ module Ionide.LanguageServerProtocol.JsonRpc
open Newtonsoft.Json
open Newtonsoft.Json.Linq
-type MessageTypeTest =
- { []
- Version: string
- Id: int option
- Method: string option }
+type MessageTypeTest = {
+ []
+ Version: string
+ Id: int option
+ Method: string option
+}
[]
type MessageType =
@@ -23,115 +24,175 @@ let getMessageType messageTest =
| { Version = "2.0"; Id = None; Method = Some _ } -> MessageType.Notification
| _ -> MessageType.Error
-type Request =
- { []
- Version: string
- Id: int
- Method: string
- Params: JToken option }
-
- static member Create(id: int, method': string, rpcParams: JToken option) =
- { Version = "2.0"; Id = id; Method = method'; Params = rpcParams }
-
-type Notification =
- { []
- Version: string
- Method: string
- Params: JToken option }
-
- static member Create(method': string, rpcParams: JToken option) =
- { Version = "2.0"; Method = method'; Params = rpcParams }
+type Request = {
+ []
+ Version: string
+ Id: int
+ Method: string
+ Params: JToken option
+} with
+
+ static member Create(id: int, method': string, rpcParams: JToken option) = {
+ Version = "2.0"
+ Id = id
+ Method = method'
+ Params = rpcParams
+ }
+
+type Notification = {
+ []
+ Version: string
+ Method: string
+ Params: JToken option
+} with
+
+ static member Create(method': string, rpcParams: JToken option) = {
+ Version = "2.0"
+ Method = method'
+ Params = rpcParams
+ }
module ErrorCodes =
- open System
- let parseError = -32700
- let invalidRequest = -32600
- let methodNotFound = -32601
- let invalidParams = -32602
- let internalError = -32603
-
-
///This is the start range of JSON-RPC reserved error codes.
///It doesn't denote a real error code. No LSP error codes should
///be defined between the start and end range. For backwards
///compatibility the and the
///are left in the range.
let jsonrpcReservedErrorRangeStart = -32099
-
- []
- let serverErrorStart = jsonrpcReservedErrorRangeStart
-
- /// Error code indicating that a server received a notification or
- /// request before the server has received the `initialize` request.
- let serverNotInitialized = -32002
-
///This is the end range of JSON-RPC reserved error codes. It doesn't denote a real error code.
let jsonrpcReservedErrorRangeEnd = -32000
- []
- let serverErrorEnd = jsonrpcReservedErrorRangeEnd
-
-
/// This is the start range of LSP reserved error codes. It doesn't denote a real error code.
let lspReservedErrorRangeStart = -32899
-
- /// A request failed but it was syntactically correct, e.g the
- /// method name was known and the parameters were valid. The error
- /// message should contain human readable information about why
- /// the request failed.
- /// @since 3.17.0
- let RequestFailed = -32803
-
-
- /// The server cancelled the request. This error code should
- /// only be used for requests that explicitly support being
- /// server cancellable.
- ///
- /// @since 3.17.0
- let serverCancelled = -32802
-
- /// The server detected that the content of a document got
- /// modified outside normal conditions. A server should
- /// NOT send this error code if it detects a content change
- /// in it unprocessed messages. The result even computed
- /// on an older state might still be useful for the client.
- ///
- /// If a client decides that a result is not of any use anymore
- /// the client should cancel the request.
- let contentModified = -32801
-
- /// The client has canceled a request and a server has detected the cancel.
- let requestCancelled = -32800
/// This is the end range of LSP reserved error codes. It doesn't denote a real error code.
let lspReservedErrorRangeEnd = -32899
-type Error =
- { Code: int
- Message: string
- Data: JToken option }
+open Ionide.LanguageServerProtocol.Types
+
+type Error = {
+ Code: int
+ Message: string
+ Data: JToken option
+} with
static member Create(code: int, message: string) = { Code = code; Message = message; Data = None }
- static member ParseError = Error.Create(ErrorCodes.parseError, "Parse error")
- static member InvalidRequest = Error.Create(ErrorCodes.invalidRequest, "Invalid Request")
- static member MethodNotFound = Error.Create(ErrorCodes.methodNotFound, "Method not found")
- static member InvalidParams = Error.Create(ErrorCodes.invalidParams, "Invalid params")
- static member InternalError = Error.Create(ErrorCodes.internalError, "Internal error")
- static member InternalErrorMessage message = Error.Create(ErrorCodes.internalError, message)
- static member RequestCancelled = Error.Create(ErrorCodes.requestCancelled, "Request cancelled")
- static member RequestCancelledMessage message = Error.Create(ErrorCodes.requestCancelled, message)
-
-type Response =
- { []
- Version: string
- Id: int option
- Error: Error option
- []
- Result: JToken option }
+
+ static member ParseError(?message) =
+ let message = defaultArg message "Parse error"
+ Error.Create(int ErrorCodes.ParseError, message)
+
+ static member InvalidRequest(?message) =
+ let message = defaultArg message "Invalid Request"
+ Error.Create(int ErrorCodes.InvalidRequest, message)
+
+ static member MethodNotFound(?message) =
+ let message = defaultArg message "Method not found"
+ Error.Create(int ErrorCodes.MethodNotFound, message)
+
+ static member InvalidParams(?message) =
+ let message = defaultArg message "Invalid params"
+ Error.Create(int ErrorCodes.InvalidParams, message)
+
+ static member InternalError(?message: string) =
+ let message = defaultArg message "Internal error"
+ Error.Create(int ErrorCodes.InternalError, message)
+
+ static member RequestCancelled(?message) =
+ let message = defaultArg message "Request cancelled"
+ Error.Create(int LSPErrorCodes.RequestCancelled, message)
+
+type Response = {
+ []
+ Version: string
+ Id: int option
+ Error: Error option
+ []
+ Result: JToken option
+} with
/// Json.NET conditional property serialization, controlled by naming convention
member x.ShouldSerializeResult() = x.Error.IsNone
- static member Success(id: int, result: JToken option) =
- { Version = "2.0"; Id = Some id; Result = result; Error = None }
+ static member Success(id: int, result: JToken option) = {
+ Version = "2.0"
+ Id = Some id
+ Result = result
+ Error = None
+ }
+
+ static member Failure(id: int, error: Error) = { Version = "2.0"; Id = Some id; Result = None; Error = Some error }
+
+
+/// Result type composed of a success value or an error of type JsonRpc.Error
+type LspResult<'t> = Result<'t, Error>
+/// Async Result type composed of a success value or an error of type JsonRpc.Error
+type AsyncLspResult<'t> = Async>
+
+
+module LspResult =
+
+ let success x : LspResult<_> = Result.Ok x
+
+ let invalidParams message : LspResult<_> = Result.Error(Error.InvalidParams message)
+
+ let internalError<'a> (message: string) : LspResult<'a> =
+ Result.Error(Error.Create(int ErrorCodes.InvalidParams, message))
+
+ let notImplemented<'a> : LspResult<'a> = Result.Error(Error.MethodNotFound())
- static member Failure(id: int, error: Error) = { Version = "2.0"; Id = Some id; Result = None; Error = Some error }
\ No newline at end of file
+ let requestCancelled<'a> : LspResult<'a> = Result.Error(Error.RequestCancelled())
+
+module AsyncLspResult =
+
+ let success x : AsyncLspResult<_> = async.Return(Result.Ok x)
+
+ let invalidParams message : AsyncLspResult<_> = async.Return(LspResult.invalidParams message)
+
+ let internalError message : AsyncLspResult<_> = async.Return(LspResult.internalError message)
+
+ let notImplemented<'a> : AsyncLspResult<'a> = async.Return LspResult.notImplemented
+
+ let requestCancelled<'a> : AsyncLspResult<'a> = async.Return LspResult.requestCancelled
+
+
+module Requests =
+ open StreamJsonRpc
+ open System
+ open System.Threading
+ open System.Threading.Tasks
+
+ let requestHandling<'param, 'result> (run: 'param -> AsyncLspResult<'result>) : Delegate =
+ let runAsTask param ct =
+ // Execute non-async portion of `run` before forking the async portion into a task.
+ // This is needed to avoid reordering of messages from a client.
+ let asyncLspResult = run param
+
+ let asyncContinuation =
+ async {
+ let! lspResult = asyncLspResult
+
+ return
+ match lspResult with
+ | Ok result -> result
+ | Error error ->
+ let rpcException = LocalRpcException(error.Message)
+ rpcException.ErrorCode <- error.Code
+
+ rpcException.ErrorData <-
+ error.Data
+ |> Option.defaultValue null
+
+ raise rpcException
+ }
+
+ Async.StartAsTask(asyncContinuation, cancellationToken = ct)
+
+ Func<'param, CancellationToken, Task<'result>>(runAsTask) :> Delegate
+
+ /// Notifications don't generate a response or error, but to unify things we consider them as always successful.
+ /// They will still not send any response because their ID is null.
+ let internal notificationSuccess (response: Async) =
+ async {
+ do! response
+ return Result.Ok()
+ }
\ No newline at end of file
diff --git a/src/JsonUtils.fs b/src/JsonUtils.fs
index 315c62f..8e1d182 100644
--- a/src/JsonUtils.fs
+++ b/src/JsonUtils.fs
@@ -63,8 +63,6 @@ type OptionAndCamelCasePropertyNamesContractResolver() as this =
prop
-
-
/// Newtonsoft.Json parses parses a number inside quotations as number too:
/// `"42"` -> can be parsed to `42: int`
/// This converter prevents that. `"42"` cannot be parsed to `int` (or `float`) any more
@@ -74,7 +72,9 @@ type StrictNumberConverter() =
static let defaultSerializer = JsonSerializer()
- override _.CanConvert(t) = t |> Type.isNumeric
+ override _.CanConvert(t) =
+ t
+ |> Type.isNumeric
override __.ReadJson(reader, t, _, serializer) =
match reader.TokenType with
@@ -93,7 +93,9 @@ type StrictNumberConverter() =
type StrictStringConverter() =
inherit JsonConverter()
- override _.CanConvert(t) = t |> Type.isString
+ override _.CanConvert(t) =
+ t
+ |> Type.isString
override __.ReadJson(reader, t, _, serializer) =
match reader.TokenType with
@@ -110,7 +112,9 @@ type StrictStringConverter() =
type StrictBoolConverter() =
inherit JsonConverter()
- override _.CanConvert(t) = t |> Type.isBool
+ override _.CanConvert(t) =
+ t
+ |> Type.isBool
override __.ReadJson(reader, t, _, serializer) =
match reader.TokenType with
@@ -132,7 +136,8 @@ type ErasedUnionConverter() =
t.GetCustomAttributes(typedefof, false).Length > 0
||
// Case
- t.BaseType.GetCustomAttributes(typedefof, false).Length > 0))
+ t.BaseType.GetCustomAttributes(typedefof, false).Length > 0)
+ )
override __.CanConvert(t) = canConvert t
@@ -150,47 +155,73 @@ type ErasedUnionConverter() =
let tryReadPrimitive (json: JToken) (targetType: Type) =
if Type.isString targetType then
if json.Type = JTokenType.String then
- reader.Value |> Some
+ reader.Value
+ |> Some
else
None
elif Type.isBool targetType then
if json.Type = JTokenType.Boolean then
- reader.Value |> Some
+ reader.Value
+ |> Some
else
None
elif Type.isNumeric targetType then
match json.Type with
| JTokenType.Integer
- | JTokenType.Float -> json.ToObject(targetType, serializer) |> Some
+ | JTokenType.Float ->
+ json.ToObject(targetType, serializer)
+ |> Some
| _ -> None
else
None
+
let tryReadUnionKind (json: JToken) (targetType: Type) =
- try
- let fields =
- json.Children()
- let props =
- targetType.GetProperties()
-
- match fields |> Seq.tryFind(fun f -> f.Name.ToLowerInvariant() = "kind"),
- props |> Seq.tryFind (fun p -> p.Name.ToLowerInvariant() = "kind") with
- | Some f, Some p ->
- match p.GetCustomAttribute(typeof) |> Option.ofObj with
- | Some (:? UnionKindAttribute as k) when k.Value = string f.Value ->
- json.ToObject(targetType, serializer) |> Some
- | _ -> None
+ try
+ let fields = json.Children()
+ let props = targetType.GetProperties()
+
+ match
+ fields
+ |> Seq.tryFind (fun f -> f.Name.ToLowerInvariant() = "kind"),
+ props
+ |> Seq.tryFind (fun p -> p.Name.ToLowerInvariant() = "kind")
+ with
+ | Some f, Some p ->
+ match
+ p.GetCustomAttribute(typeof)
+ |> Option.ofObj
+ with
+ | Some(:? UnionKindAttribute as k) when k.Value = string f.Value ->
+ json.ToObject(targetType, serializer)
+ |> Some
| _ -> None
- with _ -> None
+ | _ -> None
+ with _ ->
+ None
+
let tryReadAllMatchingFields (json: JToken) (targetType: Type) =
- try
- let fields = json.Children() |> Seq.map (fun f -> f.Name.ToLowerInvariant())
- let props = targetType.GetProperties() |> Seq.map(fun p -> p.Name.ToLowerInvariant())
- if fields |> Seq.forall (fun f -> props |> Seq.contains f) then
- json.ToObject(targetType, serializer) |> Some
- else
- None
- with _ ->
+ try
+ let fields =
+ json.Children()
+ |> Seq.map (fun f -> f.Name.ToLowerInvariant())
+
+ let props =
+ targetType.GetProperties()
+ |> Seq.map (fun p -> p.Name.ToLowerInvariant())
+
+ if
+ fields
+ |> Seq.forall (fun f ->
+ props
+ |> Seq.contains f
+ )
+ then
+ json.ToObject(targetType, serializer)
+ |> Some
+ else
None
+ with _ ->
+ None
let union = UnionInfo.get t
let json = JToken.ReadFrom reader
@@ -202,18 +233,23 @@ type ErasedUnionConverter() =
match tryReadValue json ty with
| None -> None
- | Some value -> case.Create [| value |] |> Some
+ | Some value ->
+ case.Create [| value |]
+ |> Some
| fields ->
failwith
$"Expected union {case.Info.DeclaringType.Name} to have exactly one field in each case, but case {case.Info.Name} has {fields.Length} fields"
- let c =
- union.Cases |> Array.tryPick (tryMakeUnionCase tryReadPrimitive json)
+ let c =
+ union.Cases
+ |> Array.tryPick (tryMakeUnionCase tryReadPrimitive json)
|> Option.orElseWith (fun () ->
- union.Cases |> Array.tryPick (tryMakeUnionCase tryReadUnionKind json)
+ union.Cases
+ |> Array.tryPick (tryMakeUnionCase tryReadUnionKind json)
)
|> Option.orElseWith (fun () ->
- union.Cases |> Array.tryPick (tryMakeUnionCase tryReadAllMatchingFields json)
+ union.Cases
+ |> Array.tryPick (tryMakeUnionCase tryReadAllMatchingFields json)
)
match c with
@@ -231,7 +267,8 @@ type SingleCaseUnionConverter() =
memoriseByHash (fun t ->
FSharpType.IsUnion t
&& allCases t
- |> Array.forall (fun c -> c.GetFields().Length = 0))
+ |> Array.forall (fun c -> c.GetFields().Length = 0)
+ )
override _.CanConvert t = canConvert t
@@ -249,4 +286,4 @@ type SingleCaseUnionConverter() =
match case with
| Some case -> case.Create [||]
- | None -> failwith $"Could not create an instance of the type '%s{t.Name}' with the name '%s{caseName}'"
+ | None -> failwith $"Could not create an instance of the type '%s{t.Name}' with the name '%s{caseName}'"
\ No newline at end of file
diff --git a/src/LanguageServerProtocol.fs b/src/LanguageServerProtocol.fs
index 505a8fe..fdfb11e 100644
--- a/src/LanguageServerProtocol.fs
+++ b/src/LanguageServerProtocol.fs
@@ -15,6 +15,7 @@ module Server =
open StreamJsonRpc
open StreamJsonRpc.Protocol
open JsonRpc
+ open Mappings
let logger = LogProvider.getLoggerByName "LSP Server"
@@ -237,9 +238,6 @@ module Server =
use jsonRpcHandler = new WebSocketMessageHandler(socket, defaultJsonRpcFormatter ())
startWithSetupCore setupRequestHandlings jsonRpcHandler clientCreator customizeRpc
- type ServerRequestHandling<'server when 'server :> Ionide.LanguageServerProtocol.ILspServer> = {
- Run: 'server -> Delegate
- }
let serverRequestHandling<'server, 'param, 'result when 'server :> Ionide.LanguageServerProtocol.ILspServer>
(run: 'server -> 'param -> AsyncLspResult<'result>)
@@ -247,135 +245,7 @@ module Server =
{ Run = fun s -> requestHandling (run s) }
let defaultRequestHandlings () : Map> =
- let requestHandling = serverRequestHandling
-
- [
- "initialize", requestHandling (fun s p -> s.Initialize(p))
- "initialized",
- requestHandling (fun s () ->
- s.Initialized()
- |> notificationSuccess
- )
- "textDocument/hover", requestHandling (fun s p -> s.TextDocumentHover(p))
- "textDocument/didOpen",
- requestHandling (fun s p ->
- s.TextDocumentDidOpen(p)
- |> notificationSuccess
- )
- "textDocument/didChange",
- requestHandling (fun s p ->
- s.TextDocumentDidChange(p)
- |> notificationSuccess
- )
- "textDocument/completion", requestHandling (fun s p -> s.TextDocumentCompletion(p))
- "completionItem/resolve", requestHandling (fun s p -> s.CompletionItemResolve(p))
- "textDocument/rename", requestHandling (fun s p -> s.TextDocumentRename(p))
- "textDocument/prepareRename", requestHandling (fun s p -> s.TextDocumentPrepareRename(p))
- "textDocument/declaration", requestHandling (fun s p -> s.TextDocumentDeclaration(p))
- "textDocument/definition", requestHandling (fun s p -> s.TextDocumentDefinition(p))
- "textDocument/typeDefinition", requestHandling (fun s p -> s.TextDocumentTypeDefinition(p))
- "textDocument/implementation", requestHandling (fun s p -> s.TextDocumentImplementation(p))
- "textDocument/codeAction", requestHandling (fun s p -> s.TextDocumentCodeAction(p))
- "codeAction/resolve", requestHandling (fun s p -> s.CodeActionResolve(p))
- "textDocument/codeLens", requestHandling (fun s p -> s.TextDocumentCodeLens(p))
- "codeLens/resolve", requestHandling (fun s p -> s.CodeLensResolve(p))
- "textDocument/references", requestHandling (fun s p -> s.TextDocumentReferences(p))
- "textDocument/documentHighlight", requestHandling (fun s p -> s.TextDocumentDocumentHighlight(p))
- "textDocument/documentLink", requestHandling (fun s p -> s.TextDocumentDocumentLink(p))
- "textDocument/signatureHelp", requestHandling (fun s p -> s.TextDocumentSignatureHelp(p))
- "documentLink/resolve", requestHandling (fun s p -> s.DocumentLinkResolve(p))
- "textDocument/documentColor", requestHandling (fun s p -> s.TextDocumentDocumentColor(p))
- "textDocument/colorPresentation", requestHandling (fun s p -> s.TextDocumentColorPresentation(p))
- "textDocument/formatting", requestHandling (fun s p -> s.TextDocumentFormatting(p))
- "textDocument/rangeFormatting", requestHandling (fun s p -> s.TextDocumentRangeFormatting(p))
- "textDocument/onTypeFormatting", requestHandling (fun s p -> s.TextDocumentOnTypeFormatting(p))
- "textDocument/willSave",
- requestHandling (fun s p ->
- s.TextDocumentWillSave(p)
- |> notificationSuccess
- )
- "textDocument/willSaveWaitUntil", requestHandling (fun s p -> s.TextDocumentWillSaveWaitUntil(p))
- "textDocument/didSave",
- requestHandling (fun s p ->
- s.TextDocumentDidSave(p)
- |> notificationSuccess
- )
- "textDocument/didClose",
- requestHandling (fun s p ->
- s.TextDocumentDidClose(p)
- |> notificationSuccess
- )
- "textDocument/documentSymbol", requestHandling (fun s p -> s.TextDocumentDocumentSymbol(p))
- "textDocument/moniker", requestHandling (fun s p -> s.TextDocumentMoniker(p))
- "textDocument/linkedEditingRange", requestHandling (fun s p -> s.TextDocumentLinkedEditingRange(p))
- "textDocument/foldingRange", requestHandling (fun s p -> s.TextDocumentFoldingRange(p))
- "textDocument/selectionRange", requestHandling (fun s p -> s.TextDocumentSelectionRange(p))
- "textDocument/prepareCallHierarchy", requestHandling (fun s p -> s.TextDocumentPrepareCallHierarchy(p))
- "callHierarchy/incomingCalls", requestHandling (fun s p -> s.CallHierarchyIncomingCalls(p))
- "callHierarchy/outgoingCalls", requestHandling (fun s p -> s.CallHierarchyOutgoingCalls(p))
- "textDocument/prepareTypeHierarchy", requestHandling (fun s p -> s.TextDocumentPrepareTypeHierarchy(p))
- "typeHierarchy/supertypes", requestHandling (fun s p -> s.TypeHierarchySupertypes(p))
- "typeHierarchy/subtypes", requestHandling (fun s p -> s.TypeHierarchySubtypes(p))
- "textDocument/semanticTokens/full", requestHandling (fun s p -> s.TextDocumentSemanticTokensFull(p))
- "textDocument/semanticTokens/full/delta", requestHandling (fun s p -> s.TextDocumentSemanticTokensFullDelta(p))
- "textDocument/semanticTokens/range", requestHandling (fun s p -> s.TextDocumentSemanticTokensRange(p))
- "textDocument/inlayHint", requestHandling (fun s p -> s.TextDocumentInlayHint(p))
- "inlayHint/resolve", requestHandling (fun s p -> s.InlayHintResolve(p))
- "textDocument/inlineValue", requestHandling (fun s p -> s.TextDocumentInlineValue(p))
- "textDocument/diagnostic", requestHandling (fun s p -> s.TextDocumentDiagnostic(p))
- "workspace/didChangeWatchedFiles",
- requestHandling (fun s p ->
- s.WorkspaceDidChangeWatchedFiles(p)
- |> notificationSuccess
- )
- "workspace/didChangeWorkspaceFolders",
- requestHandling (fun s p ->
- s.WorkspaceDidChangeWorkspaceFolders(p)
- |> notificationSuccess
- )
- "workspace/didChangeConfiguration",
- requestHandling (fun s p ->
- s.WorkspaceDidChangeConfiguration(p)
- |> notificationSuccess
- )
- "workspace/willCreateFiles", requestHandling (fun s p -> s.WorkspaceWillCreateFiles(p))
- "workspace/didCreateFiles",
- requestHandling (fun s p ->
- s.WorkspaceDidCreateFiles(p)
- |> notificationSuccess
- )
- "workspace/willRenameFiles", requestHandling (fun s p -> s.WorkspaceWillRenameFiles(p))
- "workspace/didRenameFiles",
- requestHandling (fun s p ->
- s.WorkspaceDidRenameFiles(p)
- |> notificationSuccess
- )
- "workspace/willDeleteFiles", requestHandling (fun s p -> s.WorkspaceWillDeleteFiles(p))
- "workspace/didDeleteFiles",
- requestHandling (fun s p ->
- s.WorkspaceDidDeleteFiles(p)
- |> notificationSuccess
- )
- "workspace/symbol", requestHandling (fun s p -> s.WorkspaceSymbol(p))
- "workspaceSymbol/resolve", requestHandling (fun s p -> s.WorkspaceSymbolResolve(p))
- "workspace/executeCommand", requestHandling (fun s p -> s.WorkspaceExecuteCommand(p))
- "window/workDoneProgress/cancel",
- requestHandling (fun s p ->
- s.WorkDoneProgressCancel(p)
- |> notificationSuccess
- )
- "workspace/diagnostic", requestHandling (fun s p -> s.WorkspaceDiagnostic(p))
- "shutdown",
- requestHandling (fun s () ->
- s.Shutdown()
- |> notificationSuccess
- )
- "exit",
- requestHandling (fun s () ->
- s.Exit()
- |> notificationSuccess
- )
- ]
+ routeMappings ()
|> Map.ofList
let private requestHandlingSetupFunc<'client, 'server
@@ -629,13 +499,15 @@ module Client =
| Some handling ->
try
match notification.Params with
- | None -> return Result.Error(JsonRpc.Error.InvalidParams)
+ | None -> return Result.Error(JsonRpc.Error.InvalidParams())
| Some prms ->
let! result = handling.Run prms
return Result.Ok()
with ex ->
- return Result.Error(JsonRpc.Error.Create(JsonRpc.ErrorCodes.internalError, ex.ToString()))
- | None -> return Result.Error(JsonRpc.Error.MethodNotFound)
+ return
+ JsonRpc.Error.InternalError(ex.ToString())
+ |> Result.Error
+ | None -> return Result.Error(JsonRpc.Error.MethodNotFound())
}
let messageHandler str =
diff --git a/src/OptionConverter.fs b/src/OptionConverter.fs
index 796b30c..5d9431a 100644
--- a/src/OptionConverter.fs
+++ b/src/OptionConverter.fs
@@ -1,4 +1,5 @@
namespace Ionide.LanguageServerProtocol.JsonUtils
+
open Newtonsoft.Json
open Microsoft.FSharp.Reflection
open System
@@ -6,9 +7,9 @@ open System.Collections.Concurrent
open System.Reflection
-
module internal Converters =
open System.Collections.Concurrent
+
let inline memorise (f: 'a -> 'b) : 'a -> 'b =
let d = ConcurrentDictionary<'a, 'b>()
fun key -> d.GetOrAdd(key, f)
@@ -23,52 +24,66 @@ module internal Converters =
| (true, value) -> value
| _ ->
let value = f key
- d.TryAdd(hash, value) |> ignore
+
+ d.TryAdd(hash, value)
+ |> ignore
+
value
+
open Converters
-type private CaseInfo =
- { Info: UnionCaseInfo
- Fields: PropertyInfo[]
- GetFieldValues: obj -> obj[]
- Create: obj[] -> obj }
+type private CaseInfo = {
+ Info: UnionCaseInfo
+ Fields: PropertyInfo[]
+ GetFieldValues: obj -> obj[]
+ Create: obj[] -> obj
+}
-type private UnionInfo =
- { Cases: CaseInfo[]
- GetTag: obj -> int }
+type private UnionInfo = {
+ Cases: CaseInfo[]
+ GetTag: obj -> int
+} with
member u.GetCaseOf(value: obj) =
let tag = u.GetTag value
- u.Cases |> Array.find (fun case -> case.Info.Tag = tag)
+
+ u.Cases
+ |> Array.find (fun case -> case.Info.Tag = tag)
module private UnionInfo =
-
+
let private create (ty: Type) =
- assert (ty |> FSharpType.IsUnion)
+ assert
+ (ty
+ |> FSharpType.IsUnion)
let cases =
FSharpType.GetUnionCases ty
- |> Array.map (fun case ->
- { Info = case
- Fields = case.GetFields()
- GetFieldValues = FSharpValue.PreComputeUnionReader case
- Create = FSharpValue.PreComputeUnionConstructor case })
+ |> Array.map (fun case -> {
+ Info = case
+ Fields = case.GetFields()
+ GetFieldValues = FSharpValue.PreComputeUnionReader case
+ Create = FSharpValue.PreComputeUnionConstructor case
+ })
{ Cases = cases; GetTag = FSharpValue.PreComputeUnionTagReader ty }
let get: Type -> _ = memoriseByHash (create)
module Type =
- let numerics =
- [| typeof
- typeof
- typeof
- typeof
- //ENHANCEMENT: other number types
- |]
-
- let numericHashes = numerics |> Array.map (fun t -> t.GetHashCode())
+ let numerics = [|
+ typeof
+ typeof
+ typeof
+ typeof
+ //ENHANCEMENT: other number types
+ |]
+
+ let numericHashes =
+ numerics
+ |> Array.map (fun t -> t.GetHashCode())
+
let stringHash = typeof.GetHashCode()
let boolHash = typeof.GetHashCode()
@@ -81,7 +96,9 @@ module Type =
let inline isNumeric (t: Type) =
let hash = t.GetHashCode()
- numericHashes |> Array.contains hash
+
+ numericHashes
+ |> Array.contains hash
[]
type OptionConverter() =
@@ -94,7 +111,8 @@ type OptionConverter() =
if innerType.IsValueType then
typedefof>.MakeGenericType([| innerType |])
else
- innerType)
+ innerType
+ )
let canConvert = memoriseByHash (Type.isOption)
@@ -107,7 +125,9 @@ type OptionConverter() =
else
let union = UnionInfo.get (value.GetType())
let case = union.GetCaseOf value
- case.GetFieldValues value |> Array.head
+
+ case.GetFieldValues value
+ |> Array.head
serializer.Serialize(writer, value)
diff --git a/src/Server.fs b/src/Server.fs
index 3ba64aa..f7335ef 100644
--- a/src/Server.fs
+++ b/src/Server.fs
@@ -1,6 +1,7 @@
namespace Ionide.LanguageServerProtocol
open Ionide.LanguageServerProtocol.Types
+open Ionide.LanguageServerProtocol.JsonRpc
module private ServerUtil =
/// Return the JSON-RPC "not implemented" error
@@ -11,381 +12,6 @@ module private ServerUtil =
open ServerUtil
-[]
-type ILspServer =
- inherit System.IDisposable
-
- /// The initialize request is sent as the first request from the client to the server.
- /// The initialize request may only be sent once.
- abstract member Initialize: InitializeParams -> AsyncLspResult
-
- /// The initialized notification is sent from the client to the server after the client received the result
- /// of the initialize request but before the client is sending any other request or notification to the server.
- /// The server can use the initialized notification for example to dynamically register capabilities.
- /// The initialized notification may only be sent once.
- abstract member Initialized: InitializedParams -> Async
-
- /// The shutdown request is sent from the client to the server. It asks the server to shut down, but to not
- /// exit (otherwise the response might not be delivered correctly to the client). There is a separate exit
- /// notification that asks the server to exit.
- abstract member Shutdown: unit -> Async
-
-
- /// A notification to ask the server to exit its process.
- abstract member Exit: unit -> Async
-
- /// The hover request is sent from the client to the server to request hover information at a given text
- /// document position.
- abstract member TextDocumentHover: TextDocumentPositionParams -> AsyncLspResult
-
-
- /// The document open notification is sent from the client to the server to signal newly opened text
- /// documents.
- ///
- /// The document’s truth is now managed by the client and the server must not try to read the document’s
- /// truth using the document’s uri. Open in this sense means it is managed by the client. It doesn't
- /// necessarily mean that its content is presented in an editor. An open notification must not be sent
- /// more than once without a corresponding close notification send before. This means open and close
- /// notification must be balanced and the max open count for a particular textDocument is one.
- abstract member TextDocumentDidOpen: DidOpenTextDocumentParams -> Async
-
-
- /// The document change notification is sent from the client to the server to signal changes to a text document.
- abstract member TextDocumentDidChange: DidChangeTextDocumentParams -> Async
-
- /// The Completion request is sent from the client to the server to compute completion items at a given
- /// cursor position. Completion items are presented in the IntelliSense user interface.
- ///
- /// If computing full completion items is expensive, servers can additionally provide a handler for the
- /// completion item resolve request (‘completionItem/resolve’). This request is sent when a completion
- /// item is selected in the user interface. A typical use case is for example: the ‘textDocument/completion’
- /// request doesn’t fill in the documentation property for returned completion items since it is expensive
- /// to compute. When the item is selected in the user interface then a ‘completionItem/resolve’ request is
- /// sent with the selected completion item as a param. The returned completion item should have the
- /// documentation property filled in. The request can delay the computation of the detail and documentation
- /// properties. However, properties that are needed for the initial sorting and filtering, like sortText,
- /// filterText, insertText, and textEdit must be provided in the textDocument/completion request and must
- /// not be changed during resolve.
- abstract member TextDocumentCompletion: CompletionParams -> AsyncLspResult
-
-
- /// The request is sent from the client to the server to resolve additional information for a given
- /// completion item.
- abstract member CompletionItemResolve: CompletionItem -> AsyncLspResult
-
-
- /// The rename request is sent from the client to the server to perform a workspace-wide rename of a symbol.
- abstract member TextDocumentRename: RenameParams -> AsyncLspResult
-
- /// The prepare rename request is sent from the client to the server to setup and test the validity of a rename operation at a given location.
- /// If None is returned then it is deemed that a ‘textDocument/rename’ request is not valid at the given position.
- abstract member TextDocumentPrepareRename: PrepareRenameParams -> AsyncLspResult
-
-
- /// The go to declaration request is sent from the client to the server to resolve the declaration location
- /// of a symbol at a given text document position
- abstract member TextDocumentDeclaration: TextDocumentPositionParams -> AsyncLspResult
-
- /// The goto definition request is sent from the client to the server to resolve the definition location of
- /// a symbol at a given text document position.
- abstract member TextDocumentDefinition: TextDocumentPositionParams -> AsyncLspResult
-
-
- /// The references request is sent from the client to the server to resolve project-wide references for
- /// the symbol denoted by the given text document position.
- abstract member TextDocumentReferences: ReferenceParams -> AsyncLspResult
-
-
- /// The document highlight request is sent from the client to the server to resolve a document highlights
- /// for a given text document position. For programming languages this usually highlights all references
- /// to the symbol scoped to this file.
- ///
- /// However we kept `textDocument/documentHighlight` and `textDocument/references` separate requests since
- /// the first one is allowed to be more fuzzy. Symbol matches usually have a DocumentHighlightKind of Read
- /// or Write whereas fuzzy or textual matches use Text as the kind.
- abstract member TextDocumentDocumentHighlight:
- TextDocumentPositionParams -> AsyncLspResult
-
-
- /// The document links request is sent from the client to the server to request the location of links
- /// in a document.
- abstract member TextDocumentDocumentLink: DocumentLinkParams -> AsyncLspResult
-
-
- /// The goto type definition request is sent from the client to the server to resolve the type definition
- /// location of a symbol at a given text document position.
- abstract member TextDocumentTypeDefinition: TextDocumentPositionParams -> AsyncLspResult
-
-
- /// The goto implementation request is sent from the client to the server to resolve the implementation
- /// location of a symbol at a given text document position.
- abstract member TextDocumentImplementation: TextDocumentPositionParams -> AsyncLspResult
-
-
- /// The code action request is sent from the client to the server to compute commands for a given text
- /// document and range. These commands are typically code fixes to either fix problems or to
- /// beautify/refactor code. The result of a textDocument/codeAction request is an array of Command literals
- /// which are typically presented in the user interface. When the command is selected the server should be
- /// contacted again (via the workspace/executeCommand) request to execute the command.
- abstract member TextDocumentCodeAction: CodeActionParams -> AsyncLspResult
-
-
- /// The code action request is sent from the client to the server to compute commands for a given text
- /// document and range. These commands are typically code fixes to either fix problems or to
- /// beautify/refactor code. The result of a textDocument/codeAction request is an array of Command literals
- /// which are typically presented in the user interface. When the command is selected the server should be
- /// contacted again (via the workspace/executeCommand) request to execute the command.
- abstract member CodeActionResolve: CodeAction -> AsyncLspResult
-
-
- /// The code lens request is sent from the client to the server to compute code lenses for a given
- /// text document.
- abstract member TextDocumentCodeLens: CodeLensParams -> AsyncLspResult
-
-
- /// The code lens resolve request is sent from the client to the server to resolve the command for
- /// a given code lens item.
- abstract member CodeLensResolve: CodeLens -> AsyncLspResult
-
-
- /// The signature help request is sent from the client to the server to request signature information at
- /// a given cursor position.
- abstract member TextDocumentSignatureHelp: SignatureHelpParams -> AsyncLspResult
-
-
- /// The document link resolve request is sent from the client to the server to resolve the target of
- /// a given document link.
- abstract member DocumentLinkResolve: DocumentLink -> AsyncLspResult
-
-
- /// The document color request is sent from the client to the server to list all color references
- /// found in a given text document. Along with the range, a color value in RGB is returned.
- abstract member TextDocumentDocumentColor: DocumentColorParams -> AsyncLspResult
-
- /// The color presentation request is sent from the client to the server to obtain a list of
- /// presentations for a color value at a given location. Clients can use the result to
- abstract member TextDocumentColorPresentation: ColorPresentationParams -> AsyncLspResult
-
-
- /// The document formatting request is sent from the client to the server to format a whole document.
- abstract member TextDocumentFormatting: DocumentFormattingParams -> AsyncLspResult
-
- /// The document range formatting request is sent from the client to the server to format a given
- /// range in a document.
- abstract member TextDocumentRangeFormatting: DocumentRangeFormattingParams -> AsyncLspResult
-
-
- /// The document on type formatting request is sent from the client to the server to format parts
- /// of the document during typing.
- abstract member TextDocumentOnTypeFormatting: DocumentOnTypeFormattingParams -> AsyncLspResult
-
-
- /// The document symbol request is sent from the client to the server to return a flat list of all symbols
- /// found in a given text document. Neither the symbol’s location range nor the symbol’s container name
- /// should be used to infer a hierarchy.
- abstract member TextDocumentDocumentSymbol:
- DocumentSymbolParams -> AsyncLspResult option>
-
-
- /// The textDocument/moniker request is sent from the client to the server to get the symbol monikers for a
- /// given text document position. An array of Moniker types is returned as response to indicate possible
- /// monikers at the given location. If no monikers can be calculated, an empty array or null should be
- /// returned.
- abstract member TextDocumentMoniker: TextDocumentPositionParams -> AsyncLspResult
-
-
- /// The linked editing request is sent from the client to the server to return for a given position in a document the
- /// range of the symbol at the position and all ranges that have the same content. Optionally a word pattern can be
- /// returned to describe valid contents. A rename to one of the ranges can be applied to all other ranges if the new
- /// content is valid. If no result-specific word pattern is provided, the word pattern from the client’s language
- /// configuration is used.
- abstract member TextDocumentLinkedEditingRange:
- TextDocumentPositionParams -> AsyncLspResult
-
-
- /// The watched files notification is sent from the client to the server when the client detects changes
- /// to files watched by the language client. It is recommended that servers register for these file
- /// events using the registration mechanism. In former implementations clients pushed file events without
- /// the server actively asking for it.
- abstract member WorkspaceDidChangeWatchedFiles: DidChangeWatchedFilesParams -> Async
-
-
- /// The `workspace/didChangeWorkspaceFolders` notification is sent from the client to the server to inform
- /// the server about workspace folder configuration changes. The notification is sent by default if both
- /// *ServerCapabilities/workspace/workspaceFolders* and *ClientCapabilities/workspace/workspaceFolders* are
- /// true; or if the server has registered to receive this notification it first.
- abstract member WorkspaceDidChangeWorkspaceFolders: DidChangeWorkspaceFoldersParams -> Async
-
-
- /// A notification sent from the client to the server to signal the change of configuration settings.
- abstract member WorkspaceDidChangeConfiguration: DidChangeConfigurationParams -> Async
-
- /// The will create files request is sent from the client to the server before files are actually created
- /// as long as the creation is triggered from within the client either by a user action or by applying a
- /// workspace edit
- abstract member WorkspaceWillCreateFiles: CreateFilesParams -> AsyncLspResult
-
-
- /// The did create files notification is sent from the client to the server when files were created
- /// from within the client.
- abstract member WorkspaceDidCreateFiles: CreateFilesParams -> Async
-
-
- /// The will rename files request is sent from the client to the server before files are actually renamed
- /// as long as the rename is triggered from within the client either by a user action or by applying a
- /// workspace edit.
- abstract member WorkspaceWillRenameFiles: RenameFilesParams -> AsyncLspResult
-
-
- /// The did rename files notification is sent from the client to the server when files were renamed from
- /// within the client.
- abstract member WorkspaceDidRenameFiles: RenameFilesParams -> Async
-
-
- /// The will delete files request is sent from the client to the server before files are actually deleted
- /// as long as the deletion is triggered from within the client either by a user action or by applying a
- /// workspace edit.
- abstract member WorkspaceWillDeleteFiles: DeleteFilesParams -> AsyncLspResult
-
-
- /// The did delete files notification is sent from the client to the server when files were deleted from
- /// within the client.
- abstract member WorkspaceDidDeleteFiles: DeleteFilesParams -> Async
-
-
- /// The workspace symbol request is sent from the client to the server to list project-wide symbols matching
- /// the query string.
- abstract member WorkspaceSymbol:
- WorkspaceSymbolParams -> AsyncLspResult option>
-
-
- /// The request is sent from the client to the server to resolve additional information for a given workspace symbol.
- abstract member WorkspaceSymbolResolve: WorkspaceSymbol -> AsyncLspResult
-
-
- /// The `workspace/executeCommand` request is sent from the client to the server to trigger command execution
- /// on the server. In most cases the server creates a `WorkspaceEdit` structure and applies the changes to the
- /// workspace using the request `workspace/applyEdit` which is sent from the server to the client.
- abstract member WorkspaceExecuteCommand: ExecuteCommandParams -> AsyncLspResult
-
-
- /// The document will save notification is sent from the client to the server before the document is
- /// actually saved.
- abstract member TextDocumentWillSave: WillSaveTextDocumentParams -> Async
-
-
- /// The document will save request is sent from the client to the server before the document is actually saved.
- /// The request can return an array of TextEdits which will be applied to the text document before it is saved.
- /// Please note that clients might drop results if computing the text edits took too long or if a server
- /// constantly fails on this request. This is done to keep the save fast and reliable.
- abstract member TextDocumentWillSaveWaitUntil: WillSaveTextDocumentParams -> AsyncLspResult
-
-
- /// The document save notification is sent from the client to the server when the document was saved
- /// in the client.
- abstract member TextDocumentDidSave: DidSaveTextDocumentParams -> Async
-
-
- /// The document close notification is sent from the client to the server when the document got closed in the
- /// client. The document’s truth now exists where the document’s uri points to (e.g. if the document’s uri is
- /// a file uri the truth now exists on disk). As with the open notification the close notification is about
- /// managing the document’s content. Receiving a close notification doesn't mean that the document was open in
- /// an editor before. A close notification requires a previous open notification to be sent.
- abstract member TextDocumentDidClose: DidCloseTextDocumentParams -> Async
-
-
- /// The folding range request is sent from the client to the server to return all folding ranges found in a given text document.
- abstract member TextDocumentFoldingRange: FoldingRangeParams -> AsyncLspResult
-
- /// The selection range request is sent from the client to the server to return suggested selection ranges at an array of given positions.
- /// A selection range is a range around the cursor position which the user might be interested in selecting.
- abstract member TextDocumentSelectionRange: SelectionRangeParams -> AsyncLspResult
-
- abstract member TextDocumentSemanticTokensFull: SemanticTokensParams -> AsyncLspResult
-
- abstract member TextDocumentSemanticTokensFullDelta:
- SemanticTokensDeltaParams -> AsyncLspResult option>
-
- abstract member TextDocumentSemanticTokensRange: SemanticTokensRangeParams -> AsyncLspResult
-
- /// The inlay hints request is sent from the client to the server to compute inlay hints for a given [text document, range] tuple
- /// that may be rendered in the editor in place with other text.
- abstract member TextDocumentInlayHint: InlayHintParams -> AsyncLspResult
-
- /// The request is sent from the client to the server to resolve additional information for a given inlay hint.
- /// This is usually used to compute the `tooltip`, `location` or `command` properties of a inlay hint’s label part
- /// to avoid its unnecessary computation during the `textDocument/inlayHint` request.
- ///
- /// Consider the clients announces the `label.location` property as a property that can be resolved lazy using the client capability
- /// ```typescript
- /// textDocument.inlayHint.resolveSupport = { properties: ['label.location'] };
- /// ```
- /// then an inlay hint with a label part without a location needs to be resolved using the `inlayHint/resolve` request before it can be used.
- abstract member InlayHintResolve: InlayHint -> AsyncLspResult
-
- /// The `window/workDoneProgress/cancel` notification is sent from the client to the server to cancel a
- /// progress initiated on the server side using the `window/workDoneProgress/create`. The progress need
- /// not be marked as cancellable to be cancelled and a client may cancel a progress for any number of
- /// reasons: in case of error, reloading a workspace etc.
- abstract member WorkDoneProgressCancel: WorkDoneProgressCancelParams -> Async
-
- /// The inline value request is sent from the client to the server to compute inline values for a given text document
- /// that may be rendered in the editor at the end of lines.
- abstract member TextDocumentInlineValue: InlineValueParams -> AsyncLspResult
-
- /// The call hierarchy request is sent from the client to the server to return a call hierarchy for the
- /// language element of given text document positions. The call hierarchy requests are executed in two
- /// steps:
- /// 1. first a call hierarchy item is resolved for the given text document position
- /// 2. for a call hierarchy item the incoming or outgoing call hierarchy items are resolved.
- abstract member TextDocumentPrepareCallHierarchy:
- CallHierarchyPrepareParams -> AsyncLspResult
-
- /// The request is sent from the client to the server to resolve incoming calls for a given call hierarchy
- /// item. The request doesn't define its own client and server capabilities. It is only issued if a server
- /// registers for the `textDocument/prepareCallHierarchy` request.
- abstract member CallHierarchyIncomingCalls:
- CallHierarchyIncomingCallsParams -> AsyncLspResult
-
- /// The request is sent from the client to the server to resolve outgoing calls for a given call hierarchy
- /// item. The request doesn't define its own client and server capabilities. It is only issued if a server
- /// registers for the `textDocument/prepareCallHierarchy` request.
- abstract member CallHierarchyOutgoingCalls:
- CallHierarchyOutgoingCallsParams -> AsyncLspResult
-
- /// The type hierarchy request is sent from the client to the server to return a type hierarchy for the
- /// language element of given text document positions. Will return `null` if the server couldn't infer a
- /// valid type from the position. The type hierarchy requests are executed in two steps:
- /// 1. first a type hierarchy item is prepared for the given text document position.
- /// 2. for a type hierarchy item the supertype or subtype type hierarchy items are resolved.
- abstract member TextDocumentPrepareTypeHierarchy:
- TypeHierarchyPrepareParams -> AsyncLspResult
-
- /// The request is sent from the client to the server to resolve the supertype for a given type hierarchy
- /// item. Will return `null` is the serve couldn't infer a valid type from `item` in the params. The request
- /// doesn't defines its own client and server capabilities. It is only issued if a server registers for the
- /// `textDocument/prepareTypeHierarchy` request.
- abstract member TypeHierarchySupertypes: TypeHierarchySupertypesParams -> AsyncLspResult
-
- /// The request is sent from the client to the server to resolve the supertype for a given type hierarchy
- /// item. Will return `null` is the serve couldn't infer a valid type from `item` in the params. The request
- /// doesn't defines its own client and server capabilities. It is only issued if a server registers for the
- /// `textDocument/prepareTypeHierarchy` request.
- abstract member TypeHierarchySubtypes: TypeHierarchySubtypesParams -> AsyncLspResult
-
- /// The text document diagnostic request is sent from the client to the server to ask the server to compute
- /// the diagnostics for a given document. As with other pull requests the server is asked to compute the
- /// diagnostics for the currently synced version of the document.
- abstract member TextDocumentDiagnostic: DocumentDiagnosticParams -> AsyncLspResult
-
- /// The workspace diagnostic request is sent from the client to the server to ask the server to compute
- /// workspace wide diagnostics which previously where pushed from the server to the client. In contrast to
- /// the document diagnostic request the workspace request can be long running and is not bound to a specific
- /// workspace or document state. If the client supports streaming for the workspace diagnostic pull it is
- /// legal to provide a document diagnostic report multiple times for the same document URI. The last one
- /// reported will win over previous reports.
- abstract member WorkspaceDiagnostic: WorkspaceDiagnosticParams -> AsyncLspResult
-
[]
type LspServer() =
abstract member Dispose: unit -> unit
@@ -402,14 +28,14 @@ type LspServer() =
/// The initialized notification may only be sent once.
abstract member Initialized: InitializedParams -> Async
- default __.Initialized() = ignoreNotification
+ default __.Initialized(_) = ignoreNotification
/// The shutdown request is sent from the client to the server. It asks the server to shut down, but to not
/// exit (otherwise the response might not be delivered correctly to the client). There is a separate exit
/// notification that asks the server to exit.
- abstract member Shutdown: unit -> Async
+ abstract member Shutdown: unit -> AsyncLspResult
- default __.Shutdown() = ignoreNotification
+ default __.Shutdown() = notImplemented
/// A notification to ask the server to exit its process.
abstract member Exit: unit -> Async
@@ -417,7 +43,7 @@ type LspServer() =
/// The hover request is sent from the client to the server to request hover information at a given text
/// document position.
- abstract member TextDocumentHover: TextDocumentPositionParams -> AsyncLspResult
+ abstract member TextDocumentHover: HoverParams -> AsyncLspResult
default __.TextDocumentHover(_) = notImplemented
@@ -450,7 +76,8 @@ type LspServer() =
/// properties. However, properties that are needed for the initial sorting and filtering, like sortText,
/// filterText, insertText, and textEdit must be provided in the textDocument/completion request and must
/// not be changed during resolve.
- abstract member TextDocumentCompletion: CompletionParams -> AsyncLspResult
+ abstract member TextDocumentCompletion:
+ CompletionParams -> AsyncLspResult option>
default __.TextDocumentCompletion(_) = notImplemented
@@ -472,13 +99,15 @@ type LspServer() =
/// The go to declaration request is sent from the client to the server to resolve the declaration location
/// of a symbol at a given text document position.
- abstract member TextDocumentDeclaration: TextDocumentPositionParams -> AsyncLspResult
+ abstract member TextDocumentDeclaration:
+ DeclarationParams -> AsyncLspResult>>>
default __.TextDocumentDeclaration(_) = notImplemented
/// The goto definition request is sent from the client to the server to resolve the definition location of
/// a symbol at a given text document position.
- abstract member TextDocumentDefinition: TextDocumentPositionParams -> AsyncLspResult
+ abstract member TextDocumentDefinition:
+ DefinitionParams -> AsyncLspResult option>
default __.TextDocumentDefinition(_) = notImplemented
@@ -495,8 +124,7 @@ type LspServer() =
/// However we kept `textDocument/documentHighlight` and `textDocument/references` separate requests since
/// the first one is allowed to be more fuzzy. Symbol matches usually have a DocumentHighlightKind of Read
/// or Write whereas fuzzy or textual matches use Text as the kind.
- abstract member TextDocumentDocumentHighlight:
- TextDocumentPositionParams -> AsyncLspResult
+ abstract member TextDocumentDocumentHighlight: DocumentHighlightParams -> AsyncLspResult
default __.TextDocumentDocumentHighlight(_) = notImplemented
@@ -508,13 +136,15 @@ type LspServer() =
/// The goto type definition request is sent from the client to the server to resolve the type definition
/// location of a symbol at a given text document position.
- abstract member TextDocumentTypeDefinition: TextDocumentPositionParams -> AsyncLspResult
+ abstract member TextDocumentTypeDefinition:
+ TypeDefinitionParams -> AsyncLspResult option>
default __.TextDocumentTypeDefinition(_) = notImplemented
/// The goto implementation request is sent from the client to the server to resolve the implementation
/// location of a symbol at a given text document position.
- abstract member TextDocumentImplementation: TextDocumentPositionParams -> AsyncLspResult
+ abstract member TextDocumentImplementation:
+ ImplementationParams -> AsyncLspResult