mirror of
https://github.com/golang/go
synced 2024-11-18 11:04:42 -07:00
internal/lsp: do not return nil identifiers without errors
Change-Id: I9ffc37dc07f46536a44f7173277d0374fdda1fb8 Reviewed-on: https://go-review.googlesource.com/c/160698 Run-TryBot: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Cottrell <iancottrell@google.com>
This commit is contained in:
parent
8a24307720
commit
021ffbf1e9
@ -423,7 +423,7 @@ func (d definitions) test(t *testing.T, s *server, typ bool) {
|
||||
locs, err = s.Definition(context.Background(), params)
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
t.Fatalf("failed for %s: %v", src, err)
|
||||
}
|
||||
if len(locs) != 1 {
|
||||
t.Errorf("got %d locations for definition, expected 1", len(locs))
|
||||
|
@ -42,7 +42,11 @@ func Identifier(ctx context.Context, v View, f File, pos token.Pos) (*Identifier
|
||||
// If the position is not an identifier but immediately follows
|
||||
// an identifier or selector period (as is common when
|
||||
// requesting a completion), use the path to the preceding node.
|
||||
return identifier(ctx, v, f, pos-1)
|
||||
result, err := identifier(ctx, v, f, pos-1)
|
||||
if result == nil && err == nil {
|
||||
err = fmt.Errorf("no identifier found")
|
||||
}
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (i *IdentifierInfo) Hover(q types.Qualifier) (string, error) {
|
||||
|
Loading…
Reference in New Issue
Block a user