From 35716ff3bceb158be887f21d33877fd284f6bd08 Mon Sep 17 00:00:00 2001 From: Ian Cottrell Date: Tue, 16 Apr 2019 20:27:09 -0400 Subject: [PATCH] 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 TryBot-Result: Gobot Gobot Reviewed-by: Rebecca Stambler --- internal/lsp/diagnostics.go | 6 +----- internal/lsp/source/diagnostics.go | 1 + 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/internal/lsp/diagnostics.go b/internal/lsp/diagnostics.go index 5f91464b..ef14a137 100644 --- a/internal/lsp/diagnostics.go +++ b/internal/lsp/diagnostics.go @@ -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 diff --git a/internal/lsp/source/diagnostics.go b/internal/lsp/source/diagnostics.go index 6c76670c..fb600f7d 100644 --- a/internal/lsp/source/diagnostics.go +++ b/internal/lsp/source/diagnostics.go @@ -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,