Skip to content
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

port handler from proposed LSP PR to test emacs failure conditions #1013

Merged
merged 2 commits into from
Sep 24, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ Requirements:

* .NET Core Sdk, see [global.json](global.json) for the exact version.

1. Restore dotnet tools to install local Paket and FAKE `dotnet tool restore`
2. Build FSAC with `dotnet fake build`
1. Restore dotnet tools to install local Paket `dotnet tool restore`
2. Build FSAC with `dotnet run --project build`
3. Optionally specify a target with the `-t` parameter: `dotnet run --project build -t ....`

* To build release fsautocomplete binaries in `~/bin` directory, do run `dotnet fake build --target LocalRelease`
* To build, run all tests and create packages, do run `dotnet fake build --target All`
* To build release fsautocomplete binaries in `~/bin` directory, use the `LocalRelease` target
* To build, run all tests and create packages, use the `All` target

### DevContainer

Expand All @@ -57,7 +58,7 @@ This repository is prepared to use Gitpod for a web-based VSCode-style IDE. Clic

* Update CHANGELOG.md with the release notes from the current release in the `Unreleased` section. Use section headings like `Added`, `Fixed`, etc from keepachangelog.com.
* For individual section items in the Changelog, use headings like `BUGFIX`, `FEATURE`, and `ENHANCEMENT` followed by a link to the PR with the PR title.
* Run the `Promote` FAKE target via `dotnet fake build -t Promote` to create the appropriate release version from the current `Unreleased` section and stamp the date, as well as create a commit and tag for this promotion
* Run the `Promote` FAKE target via the `Promote` target to create the appropriate release version from the current `Unreleased` section and stamp the date, as well as create a commit and tag for this promotion
* push this commit and tag to main
* the CI pipeline will publish a release from the tag.

Expand Down
6 changes: 2 additions & 4 deletions build/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ let init args =
if result.ExitCode = 0 then
Trace.log "No files need formatting"
elif result.ExitCode = 99 then
failwith "Some files need formatting, run `dotnet fake build -t Format` to format them"
failwith "Some files need formatting, run the `Format` target to format them"
else
Trace.logf "Errors while formatting: %A" result.Errors
failwith "Unknown errors while formatting")
Expand Down Expand Up @@ -223,16 +223,14 @@ let init args =

"ReleaseArchive" ==> "All" |> ignore<string>

Target.runOrDefaultWithArguments "Build"

[<EntryPoint>]
let main args =
init ((args |> List.ofArray))

try
match args with
| [| target |] -> Target.runOrDefaultWithArguments target
| _ -> Target.runOrDefaultWithArguments "Default"
| _ -> Target.runOrDefaultWithArguments "Test"

0
with e ->
Expand Down
2 changes: 1 addition & 1 deletion paket.lock
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ NUGET
System.Collections.Immutable (>= 5.0)
System.Reflection.Metadata (>= 5.0)
Ionide.KeepAChangelog.Tasks (0.1.8) - copy_local: true
Ionide.LanguageServerProtocol (0.4.7)
Ionide.LanguageServerProtocol (0.4.9)
FSharp.Core (>= 6.0)
Newtonsoft.Json (>= 13.0.1)
StreamJsonRpc (>= 2.10.44)
Expand Down
31 changes: 29 additions & 2 deletions src/FsAutoComplete/FsAutoComplete.Lsp.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2882,6 +2882,28 @@ type FSharpLspServer(state: State, lspClient: FSharpLspClient) =

override x.Dispose() = x.Shutdown() |> Async.Start

open System.Threading.Tasks
open StreamJsonRpc

let createRpc (handler: IJsonRpcMessageHandler) : JsonRpc =
let rec (|HandleableException|_|) (e: exn) =
match e with
| :? LocalRpcException -> Some()
| :? TaskCanceledException -> Some()
| :? OperationCanceledException -> Some()
| :? System.AggregateException as aex ->
if aex.InnerExceptions.Count = 1 then
(|HandleableException|_|) aex.InnerException
else
None
| _ -> None

{ new JsonRpc(handler) with
member this.IsFatalException(ex: Exception) =
match ex with
| HandleableException -> false
| _ -> true }

let startCore toolsPath stateStorageDir workspaceLoaderFactory =
use input = Console.OpenStandardInput()
use output = Console.OpenStandardOutput()
Expand Down Expand Up @@ -2922,8 +2944,13 @@ let startCore toolsPath stateStorageDir workspaceLoaderFactory =

FSharp.Compiler.IO.FileSystemAutoOpens.FileSystem <- FsAutoComplete.FileSystem(originalFs, state.Files.TryFind)

Ionide.LanguageServerProtocol.Server.start requestsHandlings input output FSharpLspClient (fun lspClient ->
new FSharpLspServer(state, lspClient))
Ionide.LanguageServerProtocol.Server.start
requestsHandlings
input
output
FSharpLspClient
(fun lspClient -> new FSharpLspServer(state, lspClient))
createRpc

let start toolsPath stateStorageDir workspaceLoaderFactory =
let logger = LogProvider.getLoggerByName "Startup"
Expand Down