mirror of https://github.com/golang/go.git
internal/lsp: don't search other packages for unexported references
Updates golang/go#35597 Change-Id: Ib17e94a99d49fe78f09f711b86f9115ac4aadeb9 Reviewed-on: https://go-review.googlesource.com/c/tools/+/207601 Run-TryBot: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org>
This commit is contained in:
parent
5091d647ee
commit
faf0e61b8a
|
|
@ -70,9 +70,16 @@ func (i *IdentifierInfo) References(ctx context.Context) ([]*ReferenceInfo, erro
|
|||
mappedRange: rng,
|
||||
}}, references...)
|
||||
}
|
||||
// TODO(matloob): This only needs to look into reverse-dependencies.
|
||||
// Avoid checking types of other packages.
|
||||
for _, pkg := range i.Snapshot.KnownPackages(ctx) {
|
||||
var searchpkgs []Package
|
||||
if i.Declaration.obj.Exported() {
|
||||
// Only search all packages if the identifier is exported.
|
||||
// TODO(matloob): This only needs to look into reverse-dependencies.
|
||||
// Avoid checking types of other packages.
|
||||
searchpkgs = i.Snapshot.KnownPackages(ctx)
|
||||
} else {
|
||||
searchpkgs = []Package{i.pkg}
|
||||
}
|
||||
for _, pkg := range searchpkgs {
|
||||
for ident, obj := range pkg.GetTypesInfo().Uses {
|
||||
if obj == nil || !(sameObj(obj, i.Declaration.obj)) {
|
||||
continue
|
||||
|
|
|
|||
Loading…
Reference in New Issue