Skip to content

Commit

Permalink
Fix PublishDiagnosticsCapabilities type
Browse files Browse the repository at this point in the history
Per the 3.15 spec, this should be a nested type, not a bool option.

Closes #567
  • Loading branch information
Gastove authored and Krzysztof-Cieslak committed Mar 18, 2020
1 parent c8c2ff9 commit 0ab77c9
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 37 deletions.
25 changes: 15 additions & 10 deletions src/LanguageServerProtocol/LanguageServerProtocol.fs
Original file line number Diff line number Diff line change
Expand Up @@ -466,15 +466,28 @@ module Types =
SymbolKind: SymbolKindCapabilities option
}

[<RequireQualifiedAccess>]
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 = {
Expand Down Expand Up @@ -1365,14 +1378,6 @@ module Types =
/// Reports a hint.
| Hint = 4

[<RequireQualifiedAccess>]
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.
Expand Down
55 changes: 28 additions & 27 deletions test/FsAutoComplete.Tests.Lsp/Helpers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -184,8 +185,8 @@ let waitForWorkspaceFinishedParsing (event : Event<string * obj>) =
|> 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)
Expand All @@ -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)

0 comments on commit 0ab77c9

Please sign in to comment.