Skip to content

66 generate server client #67

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Mar 12, 2025
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ 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
run: dotnet test --logger GitHubActions
- 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/
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
"Ionide",
"Newtonsoft",
"Supertypes"
]
],
"editor.formatOnSave": true
}
36 changes: 36 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!--
This file allows overriding of properties for all projects in the directory.
See
https://learn.microsoft.com/en-us/visualstudio/msbuild/customize-by-directory?view=vs-2022#directorybuildprops-and-directorybuildtargets
-->
<Project>

<PropertyGroup>
<_BuildProjBaseIntermediateOutputPath>$(MSBuildThisFileDirectory)build/obj/</_BuildProjBaseIntermediateOutputPath>
<_DotnetToolManifestFile>$(MSBuildThisFileDirectory).config/dotnet-tools.json</_DotnetToolManifestFile>
<_DotnetToolRestoreOutputFile>
$(_BuildProjBaseIntermediateOutputPath)/dotnet-tool-restore-$(NETCoreSdkVersion)-$(OS)</_DotnetToolRestoreOutputFile>
<_DotnetFantomasOutputFile>
$(BaseIntermediateOutputPath)dotnet-fantomas-msbuild-$(NETCoreSdkVersion)-$(OS)</_DotnetFantomasOutputFile>
</PropertyGroup>

<!-- Make sure that dotnet tools are restored before restoring any project -->
<Target Name="ToolRestore" BeforeTargets="Restore;CollectPackageReferences"
Inputs="$(_DotnetToolManifestFile)" Outputs="$(_DotnetToolRestoreOutputFile)">
<Exec Command="dotnet tool restore" WorkingDirectory="$(MSBuildThisFileDirectory)"
StandardOutputImportance="High" StandardErrorImportance="High" />
<MakeDir Directories="$(_BuildProjBaseIntermediateOutputPath)" />
<Touch Files="$(_DotnetToolRestoreOutputFile)" AlwaysCreate="True" ForceTouch="True" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Add $(_DotnetToolRestoreOutputFile) to the FileWrites Item so that dotnet clean will remove it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added, just double check if this is the proper way to do it.

</Target>

<!-- Make sure that files are formatted before building -->
<Target Name="Format"
Condition=" '$(MSBuildProjectExtension)' == '.fsproj' AND '$(DesignTimeBuild)' != 'true' "
BeforeTargets="BeforeBuild" Inputs="@(Compile)" Outputs="$(_DotnetFantomasOutputFile)">
<Exec Command="dotnet fantomas $(MSBuildProjectDirectory)" StandardOutputImportance="High"
StandardErrorImportance="High" WorkingDirectory="$(MSBuildThisFileDirectory)"
ContinueOnError="WarnAndContinue" />
<Touch Files="$(_DotnetFantomasOutputFile)" AlwaysCreate="True" ForceTouch="True" />
</Target>

</Project>
4 changes: 2 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "8.0.100",
"rollForward": "major"
"version": "9.0.100",
"rollForward": "latestMinor"
}
}
167 changes: 26 additions & 141 deletions src/Client.fs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -11,131 +12,6 @@ module private ClientUtil =

open ClientUtil

[<Interface>]
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<unit>

/// The show message request is sent from a server to a client to ask the client to display
/// a particular message in the user interface. In addition to the show message notification the
/// request allows to pass actions and to wait for an answer from the client.
abstract member WindowShowMessageRequest: ShowMessageRequestParams -> AsyncLspResult<MessageActionItem option>


/// The log message notification is sent from the server to the client to ask the client to log
///a particular message.
abstract member WindowLogMessage: LogMessageParams -> Async<unit>

/// The show document request is sent from a server to a client to ask the client to display a particular
/// resource referenced by a URI in the user interface.
abstract member WindowShowDocument: ShowDocumentParams -> AsyncLspResult<ShowDocumentResult>

/// The telemetry notification is sent from the server to the client to ask the client to log
/// a telemetry event.
abstract member TelemetryEvent: Newtonsoft.Json.Linq.JToken -> Async<unit>

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

/// The `client/unregisterCapability` request is sent from the server to the client to unregister a previously
/// registered capability.
abstract member ClientUnregisterCapability: UnregistrationParams -> AsyncLspResult<unit>


/// Many tools support more than one root folder per workspace. Examples for this are VS Code’s multi-root
/// support, Atom’s project folder support or Sublime’s project support. If a client workspace consists of
/// multiple roots then a server typically needs to know about this. The protocol up to know assumes one root
/// folder which is announce to the server by the rootUri property of the InitializeParams.
/// If the client supports workspace folders and announces them via the corresponding workspaceFolders client
/// capability the InitializeParams contain an additional property workspaceFolders with the configured
/// workspace folders when the server starts.
///
/// The workspace/workspaceFolders request is sent from the server to the client to fetch the current open
/// list of workspace folders. Returns null in the response if only a single file is open in the tool.
/// Returns an empty array if a workspace is open but no folders are configured.
abstract member WorkspaceWorkspaceFolders: unit -> AsyncLspResult<WorkspaceFolder[] option>

/// The workspace/configuration request is sent from the server to the client to fetch configuration
/// settings from the client.
///
/// The request can fetch n configuration settings in one roundtrip. The order of the returned configuration
/// settings correspond to the order of the passed ConfigurationItems (e.g. the first item in the response
/// is the result for the first configuration item in the params).
abstract member WorkspaceConfiguration: ConfigurationParams -> AsyncLspResult<Newtonsoft.Json.Linq.JToken[]>


abstract member WorkspaceApplyEdit: ApplyWorkspaceEditParams -> AsyncLspResult<ApplyWorkspaceEditResult>

/// 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<unit>


/// 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<unit>


/// 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<unit>


/// 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<unit>


/// Diagnostics notification are sent from the server to the client to signal results of validation runs.
///
/// Diagnostics are “owned” by the server so it is the server’s responsibility to clear them if necessary.
/// The following rule is used for VS Code servers that generate diagnostics:
///
/// * if a language is single file only (for example HTML) then diagnostics are cleared by the server when
/// the file is closed.
/// * if a language has a project system (for example C#) diagnostics are not cleared when a file closes.
/// When a project is opened all diagnostics for all files are recomputed (or read from a cache).
///
/// When a file changes it is the server’s responsibility to re-compute diagnostics and push them to the
/// client. If the computed set is empty it has to push the empty array to clear former diagnostics.
/// Newly pushed diagnostics always replace previously pushed diagnostics. There is no merging that happens
/// on the client side.
abstract member TextDocumentPublishDiagnostics: PublishDiagnosticsParams -> Async<unit>

/// 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<unit>

/// 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<unit>

/// 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<unit>

[<AbstractClass>]
type LspClient() =

Expand Down Expand Up @@ -218,39 +94,39 @@ 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<unit>
abstract member WorkspaceSemanticTokensRefresh: unit -> AsyncLspResult<unit>

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.
/// 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<unit>
abstract member WorkspaceInlayHintRefresh: unit -> AsyncLspResult<unit>

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
/// 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<unit>
abstract member WorkspaceCodeLensRefresh: unit -> AsyncLspResult<unit>

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
/// 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<unit>
abstract member WorkspaceInlineValueRefresh: unit -> AsyncLspResult<unit>

default __.WorkspaceInlineValueRefresh() = ignoreNotification
default __.WorkspaceInlineValueRefresh() = notImplemented

/// Diagnostics notification are sent from the server to the client to signal results of validation runs.
///
Expand All @@ -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<unit>
abstract member WorkspaceDiagnosticRefresh: unit -> AsyncLspResult<unit>

default __.WorkspaceDiagnosticRefresh() = notImplemented

abstract member Progress: ProgressParams -> Async<unit>

default __.WorkspaceDiagnosticRefresh() = ignoreNotification
default __.Progress(p) = ignoreNotification

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

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

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

interface ILspClient with
member this.WindowShowMessage(p: ShowMessageParams) = this.WindowShowMessage(p)
Expand All @@ -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)
member this.WindowWorkDoneProgressCreate(p: WorkDoneProgressCreateParams) = this.WindowWorkDoneProgressCreate(p)
member this.Progress(p: ProgressParams) = this.Progress(p)
member this.CancelRequest(p: CancelParams) : Async<unit> = this.CancelRequest(p)
member this.LogTrace(p: LogTraceParams) : Async<unit> = this.LogTrace(p)
member this.Dispose() : unit = ()
Loading