internal/lsp/cache: add a scheme for types error code links

Links in the new LSP diagnostic CodeDescription for go/types errors are
missing a scheme (unclear why they work in some clients). Fix this by
delegating to the existing source.BuildLink helper (this also adds the
utm_source query parameter for pkg.go.dev).

Fixes golang/go#44360

Change-Id: Ife8969f32bb11840c0fdd31765b6051b3d997a93
Reviewed-on: https://go-review.googlesource.com/c/tools/+/293509
Trust: Rebecca Stambler <rstambler@golang.org>
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
This commit is contained in:
Rob Findley 2021-02-17 23:03:24 -05:00 committed by Rebecca Stambler
parent 799b6824f9
commit cb5dc85ca1
1 changed files with 1 additions and 1 deletions

View File

@ -244,7 +244,7 @@ func onlyDeletions(fixes []source.SuggestedFix) bool {
func typesCodeHref(snapshot *snapshot, code typesinternal.ErrorCode) string {
target := snapshot.View().Options().LinkTarget
return fmt.Sprintf("https://%s/golang.org/x/tools/internal/typesinternal#%s", target, code.String())
return source.BuildLink(target, "golang.org/x/tools/internal/typesinternal", code.String())
}
func suggestedAnalysisFixes(snapshot *snapshot, pkg *pkg, diag *analysis.Diagnostic, kinds []protocol.CodeActionKind) ([]source.SuggestedFix, error) {