From 0ab77c9e471b6d5a2f8edae818c28e36ca4578d1 Mon Sep 17 00:00:00 2001 From: Ross Donaldson Date: Sun, 15 Mar 2020 12:08:20 -0700 Subject: [PATCH] Fix `PublishDiagnosticsCapabilities` type Per the 3.15 spec, this should be a nested type, not a bool option. Closes #567 --- .../LanguageServerProtocol.fs | 25 +++++---- test/FsAutoComplete.Tests.Lsp/Helpers.fs | 55 ++++++++++--------- 2 files changed, 43 insertions(+), 37 deletions(-) diff --git a/src/LanguageServerProtocol/LanguageServerProtocol.fs b/src/LanguageServerProtocol/LanguageServerProtocol.fs index 57b1b816b..747548274 100644 --- a/src/LanguageServerProtocol/LanguageServerProtocol.fs +++ b/src/LanguageServerProtocol/LanguageServerProtocol.fs @@ -466,15 +466,28 @@ module Types = SymbolKind: SymbolKindCapabilities option } + [] + type DiagnosticTag = + /// Unused or unnecessary code. + /// + /// Clients are allowed to render diagnostics with this tag faded out instead of having + /// an error squiggle. + | Unnecessary = 1 + + type DiagnosticTagSupport = { + + /// Represents the tags supported by the client + ValueSet: DiagnosticTag[] + } + /// Capabilities specific to `textDocument/publishDiagnostics`. type PublishDiagnosticsCapabilites = { /// Whether the clients accepts diagnostics with related information. RelatedInformation: bool option - /// Client supports the tag property to provide meta data about a diagnostic. - TagSupport: bool option + TagSupport: DiagnosticTagSupport option } type FoldingRangeCapabilities = { @@ -1365,14 +1378,6 @@ module Types = /// Reports a hint. | Hint = 4 - [] - type DiagnosticTag = - /// Unused or unnecessary code. - /// - /// Clients are allowed to render diagnostics with this tag faded out instead of having - /// an error squiggle. - | Unnecessary = 1 - /// Represents a related message and source code location for a diagnostic. This should be /// used to point to code locations that cause or related to a diagnostics, e.g when duplicating /// a symbol in a scope. diff --git a/test/FsAutoComplete.Tests.Lsp/Helpers.fs b/test/FsAutoComplete.Tests.Lsp/Helpers.fs index 85f0c588f..ba314aaac 100644 --- a/test/FsAutoComplete.Tests.Lsp/Helpers.fs +++ b/test/FsAutoComplete.Tests.Lsp/Helpers.fs @@ -69,8 +69,9 @@ let clientCaps : ClientCapabilities = DidSave = Some true} let diagCaps: PublishDiagnosticsCapabilites = + let diagnosticTags: DiagnosticTagSupport = { ValueSet = [||] } { RelatedInformation = Some true - TagSupport = Some true} + TagSupport = Some diagnosticTags } let ciCaps: CompletionItemCapabilities = { SnippetSupport = Some true @@ -140,12 +141,12 @@ let serverInitialize path (config: FSharpConfigDto) = |> Event.add logEvent let p : InitializeParams = - { ProcessId = Some 1 - RootPath = Some path - RootUri = Some (sprintf "file://%s" path) - InitializationOptions = Some (Server.serialize config) - Capabilities = Some clientCaps - trace = None} + { ProcessId = Some 1 + RootPath = Some path + RootUri = Some (sprintf "file://%s" path) + InitializationOptions = Some (Server.serialize config) + Capabilities = Some clientCaps + trace = None} let result = server.Initialize p |> Async.RunSynchronously match result with @@ -184,8 +185,8 @@ let waitForWorkspaceFinishedParsing (event : Event) = |> Async.AwaitEvent |> Async.RunSynchronously |> fun o -> - if o.Content.Contains """{"Kind":"error",""" - then failtestf "error loading project: %A" o + if o.Content.Contains """{"Kind":"error",""" + then failtestf "error loading project: %A" o let expectExitCodeZero (exitCode, _) = Expect.equal exitCode 0 (sprintf "expected exit code zero but was %i" exitCode) @@ -199,27 +200,27 @@ let dotnetCleanup baseDir = let runProcess (log: string -> unit) (workingDir: string) (exePath: string) (args: string) = - let psi = System.Diagnostics.ProcessStartInfo() - psi.FileName <- exePath - psi.WorkingDirectory <- workingDir - psi.RedirectStandardOutput <- true - psi.RedirectStandardError <- true - psi.Arguments <- args - psi.CreateNoWindow <- true - psi.UseShellExecute <- false + let psi = System.Diagnostics.ProcessStartInfo() + psi.FileName <- exePath + psi.WorkingDirectory <- workingDir + psi.RedirectStandardOutput <- true + psi.RedirectStandardError <- true + psi.Arguments <- args + psi.CreateNoWindow <- true + psi.UseShellExecute <- false - use p = new System.Diagnostics.Process() - p.StartInfo <- psi + use p = new System.Diagnostics.Process() + p.StartInfo <- psi - p.OutputDataReceived.Add(fun ea -> log (ea.Data)) + p.OutputDataReceived.Add(fun ea -> log (ea.Data)) - p.ErrorDataReceived.Add(fun ea -> log (ea.Data)) + p.ErrorDataReceived.Add(fun ea -> log (ea.Data)) - p.Start() |> ignore - p.BeginOutputReadLine() - p.BeginErrorReadLine() - p.WaitForExit() + p.Start() |> ignore + p.BeginOutputReadLine() + p.BeginErrorReadLine() + p.WaitForExit() - let exitCode = p.ExitCode + let exitCode = p.ExitCode - exitCode, (workingDir, exePath, args) + exitCode, (workingDir, exePath, args)