internal/lsp/template: add missed hover cases

Templates were reporting 'oops' when hovering over a string.

Fixes: golang/go#50031

Change-Id: I9e256b1f7d193bf090590c1ec71e85fc8493d7f7
Reviewed-on: https://go-review.googlesource.com/c/tools/+/369956
Run-TryBot: Peter Weinberger <pjw@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Peter Weinberger <pjw@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
This commit is contained in:
pjw 2021-12-07 15:39:00 -05:00 committed by Peter Weinberger
parent d3358c1fb7
commit 68cbf4169f
1 changed files with 6 additions and 0 deletions

View File

@ -118,6 +118,12 @@ func Hover(ctx context.Context, snapshot source.Snapshot, fh source.FileHandle,
ans.Contents.Value = fmt.Sprintf("template %s\n(add definition)", sym.name)
case protocol.Namespace:
ans.Contents.Value = fmt.Sprintf("template %s defined", sym.name)
case protocol.Number:
ans.Contents.Value = "number"
case protocol.String:
ans.Contents.Value = "string"
case protocol.Boolean:
ans.Contents.Value = "boolean"
default:
ans.Contents.Value = fmt.Sprintf("oops, sym=%#v", sym)
}