1
0
mirror of https://github.com/golang/go synced 2024-10-01 20:38:32 -06:00
go/internal/lsp/testdata/godef/b/b.go
Muir Manders 63859f3815 internal/lsp: add definition support for packages
Now the "type" of a *ast.PkgName is the package it points to. Of
course, a package is not a real types.Type, but we can still jump you
there. We have to pick one of the package's files, so we choose the
longest one, hoping it is the most interesting.

Similarly, the "definition" of an *ast.ImportSpec is the package being
imported.

I also added a nil check for the package in SignatureHelp. This panics
for me occasionally.

Change-Id: Ide4640530a28bcec9da6de36723eb7f0e4cc941c
GitHub-Last-Rev: 8190baa0b908065db5b53f236de03d2f3bff39b5
GitHub-Pull-Request: golang/tools#92
Reviewed-on: https://go-review.googlesource.com/c/tools/+/174081
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-05-10 15:10:30 +00:00

36 lines
764 B
Go

package b
import (
myFoo "golang.org/x/tools/internal/lsp/foo" //@godef("foo", PackageFoo),godef("myFoo", PackageFoo)
"golang.org/x/tools/internal/lsp/godef/a" //@mark(AImport, "\"")
)
type S1 struct { //@S1
F1 int //@mark(S1F1, "F1")
S2 //@godef("S2", S2), mark(S1S2, "S2")
a.A //@godef("A", A)
}
type S2 struct { //@S2
F1 string //@mark(S2F1, "F1")
F2 int //@mark(S2F2, "F2")
*a.A //@godef("A", A),godef("a",AImport)
}
type S3 struct {
F1 struct {
a.A //@godef("A", A)
}
}
func Bar() {
a.Stuff() //@godef("Stuff", Stuff)
var x S1 //@godef("S1", S1)
_ = x.S2 //@godef("S2", S1S2)
_ = x.F1 //@godef("F1", S1F1)
_ = x.F2 //@godef("F2", S2F2)
_ = x.S2.F1 //@godef("F1", S2F1)
var _ *myFoo.StructFoo
}