Skip to content

Commit f8c90ed

Browse files
authored
66 generate server client (#67)
* Update Fabulous Ast [1.0.0-pre16] * Generating LspServer interface * Generate ClientServer Interfaces * fix CI * Rearrange types to support codegen serverclient * Better incremental build when gentool changes * Bump FabulousAST 1.2.0 * Remove stringly types * Fixing watch * Incremental write and comment fixes * Fix Base Class implementations * Add designtime check to code gen * Generate Route mappings * refactor Generate ClientServer * Move Generate ClientServer to own file * fix build? * fantomas the world * fix build?? * Fix warnings * fix artifact uploads * Format on build * purge paket remnants * Delete old ILspServer * Add to FileWrites to Cleanup
1 parent 36c5f7c commit f8c90ed

30 files changed

+9503
-8649
lines changed

.config/dotnet-tools.json

+1-7
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,8 @@
22
"version": 1,
33
"isRoot": true,
44
"tools": {
5-
"paket": {
6-
"version": "6.2.1",
7-
"commands": [
8-
"paket"
9-
]
10-
},
115
"fantomas": {
12-
"version": "6.2.3",
6+
"version": "7.0.1",
137
"commands": [
148
"fantomas"
159
]

.github/workflows/build.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ jobs:
2121
global-json-file: global.json
2222
dotnet-version: |
2323
8.x
24-
6.x
24+
9.x
2525
- name: Run build
2626
run: dotnet build -c Release src
2727
- name: Run tests
2828
run: dotnet test --logger GitHubActions
2929
- name: Run publish
3030
run: dotnet pack -o release src
3131
- name: Upload NuGet packages
32-
uses: actions/upload-artifact@v2
32+
uses: actions/upload-artifact@v4
3333
with:
34-
name: packages
34+
name: packages-${{ matrix.os }}
3535
path: release/

.vscode/settings.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
"Ionide",
88
"Newtonsoft",
99
"Supertypes"
10-
]
10+
],
11+
"editor.formatOnSave": true
1112
}

Directory.Build.targets

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<!--
2+
This file allows overriding of properties for all projects in the directory.
3+
See
4+
https://learn.microsoft.com/en-us/visualstudio/msbuild/customize-by-directory?view=vs-2022#directorybuildprops-and-directorybuildtargets
5+
-->
6+
<Project>
7+
8+
<PropertyGroup>
9+
<_BuildProjBaseIntermediateOutputPath>$(MSBuildThisFileDirectory)build/obj/</_BuildProjBaseIntermediateOutputPath>
10+
<_DotnetToolManifestFile>$(MSBuildThisFileDirectory).config/dotnet-tools.json</_DotnetToolManifestFile>
11+
<_DotnetToolRestoreOutputFile>
12+
$(_BuildProjBaseIntermediateOutputPath)/dotnet-tool-restore-$(NETCoreSdkVersion)-$(OS)</_DotnetToolRestoreOutputFile>
13+
<_DotnetFantomasOutputFile>
14+
$(BaseIntermediateOutputPath)dotnet-fantomas-msbuild-$(NETCoreSdkVersion)-$(OS)</_DotnetFantomasOutputFile>
15+
</PropertyGroup>
16+
17+
<!-- Make sure that dotnet tools are restored before restoring any project -->
18+
<Target Name="ToolRestore" BeforeTargets="Restore;CollectPackageReferences"
19+
Inputs="$(_DotnetToolManifestFile)" Outputs="$(_DotnetToolRestoreOutputFile)">
20+
<Exec Command="dotnet tool restore" WorkingDirectory="$(MSBuildThisFileDirectory)"
21+
StandardOutputImportance="High" StandardErrorImportance="High" />
22+
<MakeDir Directories="$(_BuildProjBaseIntermediateOutputPath)" />
23+
<Touch Files="$(_DotnetToolRestoreOutputFile)" AlwaysCreate="True" ForceTouch="True" />
24+
<ItemGroup>
25+
<FileWrites Include="@(_DotnetToolRestoreOutputFile)" />
26+
</ItemGroup>
27+
</Target>
28+
29+
<!-- Make sure that files are formatted before building -->
30+
<Target Name="Format"
31+
Condition=" '$(MSBuildProjectExtension)' == '.fsproj' AND '$(DesignTimeBuild)' != 'true' "
32+
BeforeTargets="BeforeBuild" Inputs="@(Compile)" Outputs="$(_DotnetFantomasOutputFile)">
33+
<Exec Command="dotnet fantomas $(MSBuildProjectDirectory)" StandardOutputImportance="High"
34+
StandardErrorImportance="High" WorkingDirectory="$(MSBuildThisFileDirectory)"
35+
ContinueOnError="WarnAndContinue" />
36+
<Touch Files="$(_DotnetFantomasOutputFile)" AlwaysCreate="True" ForceTouch="True" />
37+
<ItemGroup>
38+
<FileWrites Include="@(_DotnetFantomasOutputFile)" />
39+
</ItemGroup>
40+
</Target>
41+
42+
</Project>

global.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "8.0.100",
4-
"rollForward": "major"
3+
"version": "9.0.100",
4+
"rollForward": "latestMinor"
55
}
66
}

src/Client.fs

+26-141
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
namespace Ionide.LanguageServerProtocol
22

33
open Ionide.LanguageServerProtocol.Types
4+
open Ionide.LanguageServerProtocol.JsonRpc
45

56
module private ClientUtil =
67
/// Return the JSON-RPC "not implemented" error
@@ -11,131 +12,6 @@ module private ClientUtil =
1112

1213
open ClientUtil
1314

14-
[<Interface>]
15-
type ILspClient =
16-
/// The show message notification is sent from a server to a client to ask the client to display
17-
/// a particular message in the user interface.
18-
abstract member WindowShowMessage: ShowMessageParams -> Async<unit>
19-
20-
/// The show message request is sent from a server to a client to ask the client to display
21-
/// a particular message in the user interface. In addition to the show message notification the
22-
/// request allows to pass actions and to wait for an answer from the client.
23-
abstract member WindowShowMessageRequest: ShowMessageRequestParams -> AsyncLspResult<MessageActionItem option>
24-
25-
26-
/// The log message notification is sent from the server to the client to ask the client to log
27-
///a particular message.
28-
abstract member WindowLogMessage: LogMessageParams -> Async<unit>
29-
30-
/// The show document request is sent from a server to a client to ask the client to display a particular
31-
/// resource referenced by a URI in the user interface.
32-
abstract member WindowShowDocument: ShowDocumentParams -> AsyncLspResult<ShowDocumentResult>
33-
34-
/// The telemetry notification is sent from the server to the client to ask the client to log
35-
/// a telemetry event.
36-
abstract member TelemetryEvent: Newtonsoft.Json.Linq.JToken -> Async<unit>
37-
38-
/// The `client/registerCapability` request is sent from the server to the client to register for a new
39-
/// capability on the client side. Not all clients need to support dynamic capability registration.
40-
/// A client opts in via the dynamicRegistration property on the specific client capabilities. A client
41-
/// can even provide dynamic registration for capability A but not for capability B.
42-
abstract member ClientRegisterCapability: RegistrationParams -> AsyncLspResult<unit>
43-
44-
/// The `client/unregisterCapability` request is sent from the server to the client to unregister a previously
45-
/// registered capability.
46-
abstract member ClientUnregisterCapability: UnregistrationParams -> AsyncLspResult<unit>
47-
48-
49-
/// Many tools support more than one root folder per workspace. Examples for this are VS Code’s multi-root
50-
/// support, Atom’s project folder support or Sublime’s project support. If a client workspace consists of
51-
/// multiple roots then a server typically needs to know about this. The protocol up to know assumes one root
52-
/// folder which is announce to the server by the rootUri property of the InitializeParams.
53-
/// If the client supports workspace folders and announces them via the corresponding workspaceFolders client
54-
/// capability the InitializeParams contain an additional property workspaceFolders with the configured
55-
/// workspace folders when the server starts.
56-
///
57-
/// The workspace/workspaceFolders request is sent from the server to the client to fetch the current open
58-
/// list of workspace folders. Returns null in the response if only a single file is open in the tool.
59-
/// Returns an empty array if a workspace is open but no folders are configured.
60-
abstract member WorkspaceWorkspaceFolders: unit -> AsyncLspResult<WorkspaceFolder[] option>
61-
62-
/// The workspace/configuration request is sent from the server to the client to fetch configuration
63-
/// settings from the client.
64-
///
65-
/// The request can fetch n configuration settings in one roundtrip. The order of the returned configuration
66-
/// settings correspond to the order of the passed ConfigurationItems (e.g. the first item in the response
67-
/// is the result for the first configuration item in the params).
68-
abstract member WorkspaceConfiguration: ConfigurationParams -> AsyncLspResult<Newtonsoft.Json.Linq.JToken[]>
69-
70-
71-
abstract member WorkspaceApplyEdit: ApplyWorkspaceEditParams -> AsyncLspResult<ApplyWorkspaceEditResult>
72-
73-
/// The workspace/semanticTokens/refresh request is sent from the server to the client.
74-
/// Servers can use it to ask clients to refresh the editors for which this server provides semantic tokens.
75-
/// As a result the client should ask the server to recompute the semantic tokens for these editors.
76-
/// This is useful if a server detects a project wide configuration change which requires a re-calculation
77-
/// of all semantic tokens. Note that the client still has the freedom to delay the re-calculation of
78-
/// the semantic tokens if for example an editor is currently not visible.
79-
abstract member WorkspaceSemanticTokensRefresh: unit -> Async<unit>
80-
81-
82-
/// The `workspace/inlayHint/refresh` request is sent from the server to the client.
83-
/// Servers can use it to ask clients to refresh the inlay hints currently shown in editors.
84-
/// As a result the client should ask the server to recompute the inlay hints for these editors.
85-
/// This is useful if a server detects a configuration change which requires a re-calculation
86-
/// of all inlay hints. Note that the client still has the freedom to delay the re-calculation of the inlay hints
87-
/// if for example an editor is currently not visible.
88-
abstract member WorkspaceInlayHintRefresh: unit -> Async<unit>
89-
90-
91-
/// The workspace/codeLens/refresh request is sent from the server to the client. Servers can use it to ask
92-
/// clients to refresh the code lenses currently shown in editors. As a result the client should ask the
93-
/// server to recompute the code lenses for these editors. This is useful if a server detects a
94-
/// configuration change which requires a re-calculation of all code lenses. Note that the client still has
95-
/// the freedom to delay the re-calculation of the code lenses if for example an editor is currently not
96-
/// visible.
97-
abstract member WorkspaceCodeLensRefresh: unit -> Async<unit>
98-
99-
100-
/// The workspace/inlineValue/refresh request is sent from the server to the client. Servers can use it to
101-
/// ask clients to refresh the inline values currently shown in editors. As a result the client should ask
102-
/// the server to recompute the inline values for these editors. This is useful if a server detects a
103-
/// configuration change which requires a re-calculation of all inline values. Note that the client still
104-
/// has the freedom to delay the re-calculation of the inline values if for example an editor is currently
105-
/// not visible.
106-
abstract member WorkspaceInlineValueRefresh: unit -> Async<unit>
107-
108-
109-
/// Diagnostics notification are sent from the server to the client to signal results of validation runs.
110-
///
111-
/// Diagnostics are “owned” by the server so it is the server’s responsibility to clear them if necessary.
112-
/// The following rule is used for VS Code servers that generate diagnostics:
113-
///
114-
/// * if a language is single file only (for example HTML) then diagnostics are cleared by the server when
115-
/// the file is closed.
116-
/// * if a language has a project system (for example C#) diagnostics are not cleared when a file closes.
117-
/// When a project is opened all diagnostics for all files are recomputed (or read from a cache).
118-
///
119-
/// When a file changes it is the server’s responsibility to re-compute diagnostics and push them to the
120-
/// client. If the computed set is empty it has to push the empty array to clear former diagnostics.
121-
/// Newly pushed diagnostics always replace previously pushed diagnostics. There is no merging that happens
122-
/// on the client side.
123-
abstract member TextDocumentPublishDiagnostics: PublishDiagnosticsParams -> Async<unit>
124-
125-
/// The workspace/diagnostic/refresh request is sent from the server to the client. Servers can use it to
126-
/// ask clients to refresh all needed document and workspace diagnostics. This is useful if a server detects
127-
/// a project wide configuration change which requires a re-calculation of all diagnostics.
128-
abstract member WorkspaceDiagnosticRefresh: unit -> Async<unit>
129-
130-
/// The window/workDoneProgress/create request is sent from the server to the client to ask the client to create a work done progress.
131-
abstract member WorkDoneProgressCreate: ProgressToken -> AsyncLspResult<unit>
132-
133-
/// The base protocol offers also support to report progress in a generic fashion.
134-
/// This mechanism can be used to report any kind of progress including work done progress
135-
/// (usually used to report progress in the user interface using a progress bar) and
136-
/// partial result progress to support streaming of results.
137-
abstract member Progress: ProgressToken * 'Progress -> Async<unit>
138-
13915
[<AbstractClass>]
14016
type LspClient() =
14117

@@ -218,39 +94,39 @@ type LspClient() =
21894
/// This is useful if a server detects a project wide configuration change which requires a re-calculation
21995
/// of all semantic tokens. Note that the client still has the freedom to delay the re-calculation of
22096
/// the semantic tokens if for example an editor is currently not visible.
221-
abstract member WorkspaceSemanticTokensRefresh: unit -> Async<unit>
97+
abstract member WorkspaceSemanticTokensRefresh: unit -> AsyncLspResult<unit>
22298

223-
default __.WorkspaceSemanticTokensRefresh() = ignoreNotification
99+
default __.WorkspaceSemanticTokensRefresh() = notImplemented
224100

225101
/// The `workspace/inlayHint/refresh` request is sent from the server to the client.
226102
/// Servers can use it to ask clients to refresh the inlay hints currently shown in editors.
227103
/// As a result the client should ask the server to recompute the inlay hints for these editors.
228104
/// This is useful if a server detects a configuration change which requires a re-calculation
229105
/// of all inlay hints. Note that the client still has the freedom to delay the re-calculation of the inlay hints
230106
/// if for example an editor is currently not visible.
231-
abstract member WorkspaceInlayHintRefresh: unit -> Async<unit>
107+
abstract member WorkspaceInlayHintRefresh: unit -> AsyncLspResult<unit>
232108

233-
default __.WorkspaceInlayHintRefresh() = ignoreNotification
109+
default __.WorkspaceInlayHintRefresh() = notImplemented
234110

235111
/// The workspace/codeLens/refresh request is sent from the server to the client. Servers can use it to ask
236112
/// clients to refresh the code lenses currently shown in editors. As a result the client should ask the
237113
/// server to recompute the code lenses for these editors. This is useful if a server detects a
238114
/// configuration change which requires a re-calculation of all code lenses. Note that the client still has
239115
/// the freedom to delay the re-calculation of the code lenses if for example an editor is currently not
240116
/// visible.
241-
abstract member WorkspaceCodeLensRefresh: unit -> Async<unit>
117+
abstract member WorkspaceCodeLensRefresh: unit -> AsyncLspResult<unit>
242118

243-
default __.WorkspaceCodeLensRefresh() = ignoreNotification
119+
default __.WorkspaceCodeLensRefresh() = notImplemented
244120

245121
/// The workspace/inlineValue/refresh request is sent from the server to the client. Servers can use it to
246122
/// ask clients to refresh the inline values currently shown in editors. As a result the client should ask
247123
/// the server to recompute the inline values for these editors. This is useful if a server detects a
248124
/// configuration change which requires a re-calculation of all inline values. Note that the client still
249125
/// has the freedom to delay the re-calculation of the inline values if for example an editor is currently
250126
/// not visible.
251-
abstract member WorkspaceInlineValueRefresh: unit -> Async<unit>
127+
abstract member WorkspaceInlineValueRefresh: unit -> AsyncLspResult<unit>
252128

253-
default __.WorkspaceInlineValueRefresh() = ignoreNotification
129+
default __.WorkspaceInlineValueRefresh() = notImplemented
254130

255131
/// Diagnostics notification are sent from the server to the client to signal results of validation runs.
256132
///
@@ -273,17 +149,23 @@ type LspClient() =
273149
/// The workspace/diagnostic/refresh request is sent from the server to the client. Servers can use it to
274150
/// ask clients to refresh all needed document and workspace diagnostics. This is useful if a server detects
275151
/// a project wide configuration change which requires a re-calculation of all diagnostics.
276-
abstract member WorkspaceDiagnosticRefresh: unit -> Async<unit>
152+
abstract member WorkspaceDiagnosticRefresh: unit -> AsyncLspResult<unit>
153+
154+
default __.WorkspaceDiagnosticRefresh() = notImplemented
155+
156+
abstract member Progress: ProgressParams -> Async<unit>
277157

278-
default __.WorkspaceDiagnosticRefresh() = ignoreNotification
158+
default __.Progress(p) = ignoreNotification
279159

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

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

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

288170
interface ILspClient with
289171
member this.WindowShowMessage(p: ShowMessageParams) = this.WindowShowMessage(p)
@@ -302,5 +184,8 @@ type LspClient() =
302184
member this.WorkspaceInlineValueRefresh() = this.WorkspaceInlineValueRefresh()
303185
member this.TextDocumentPublishDiagnostics(p: PublishDiagnosticsParams) = this.TextDocumentPublishDiagnostics(p)
304186
member this.WorkspaceDiagnosticRefresh() = this.WorkspaceDiagnosticRefresh()
305-
member this.WorkDoneProgressCreate(token: ProgressToken) = this.WorkDoneProgressCreate(token)
306-
member this.Progress(token, data) = this.Progress(token, data)
187+
member this.WindowWorkDoneProgressCreate(p: WorkDoneProgressCreateParams) = this.WindowWorkDoneProgressCreate(p)
188+
member this.Progress(p: ProgressParams) = this.Progress(p)
189+
member this.CancelRequest(p: CancelParams) : Async<unit> = this.CancelRequest(p)
190+
member this.LogTrace(p: LogTraceParams) : Async<unit> = this.LogTrace(p)
191+
member this.Dispose() : unit = ()

0 commit comments

Comments
 (0)