internal/lsp: set the diagnostic source earlier

We now set the diagnostic source in the diagnostics call rather than when
converting it to the LSP protocol.

Change-Id: Ic762aaab1b2bf93b75c4c3d78aa84e2f918398fc
Reviewed-on: https://go-review.googlesource.com/c/tools/+/172408
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
This commit is contained in:
Ian Cottrell 2019-04-16 20:27:09 -04:00
parent 49a1609436
commit 35716ff3bc
2 changed files with 2 additions and 5 deletions

View File

@ -75,10 +75,6 @@ func toProtocolDiagnostics(ctx context.Context, v source.View, diagnostics []sou
if err != nil {
return nil, err
}
src := diag.Source
if src == "" {
src = "LSP"
}
var severity protocol.DiagnosticSeverity
switch diag.Severity {
case source.SeverityError:
@ -94,7 +90,7 @@ func toProtocolDiagnostics(ctx context.Context, v source.View, diagnostics []sou
Message: diag.Message,
Range: rng,
Severity: severity,
Source: src,
Source: diag.Source,
})
}
return reports, nil

View File

@ -88,6 +88,7 @@ func Diagnostics(ctx context.Context, v View, uri span.URI) (map[span.URI][]Diag
spn = pointToSpan(ctx, v, spn)
}
diagnostic := Diagnostic{
Source: "LSP",
Span: spn,
Message: diag.Msg,
Severity: SeverityError,