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>
diff --git a/internal/lsp/diagnostics.go b/internal/lsp/diagnostics.go
index 5f91464..ef14a13 100644
--- a/internal/lsp/diagnostics.go
+++ b/internal/lsp/diagnostics.go
@@ -75,10 +75,6 @@
 		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 @@
 			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 6c76670..fb600f7 100644
--- a/internal/lsp/source/diagnostics.go
+++ b/internal/lsp/source/diagnostics.go
@@ -88,6 +88,7 @@
 			spn = pointToSpan(ctx, v, spn)
 		}
 		diagnostic := Diagnostic{
+			Source:   "LSP",
 			Span:     spn,
 			Message:  diag.Msg,
 			Severity: SeverityError,