Skip to content

Commit 18ea540

Browse files
committed
gopls: Add TODO for handling cross-package references and refine local reference matching logic
Updated the code in xrefs.go and references.go. Updates golang/go#71754
1 parent d376e74 commit 18ea540

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

gopls/internal/cache/xrefs/xrefs.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ func Index(files []*parsego.File, pkg *types.Package, info *types.Info, asmFiles
124124
}
125125
obj := pkg.Scope().Lookup(name)
126126
if obj == nil {
127+
// TODO(grootguo): If the object is not found in the current package,
128+
// consider handling cross-package references.
127129
continue
128130
}
129131
objects := getObjects(pkg)

gopls/internal/golang/references.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,10 @@ func localReferences(pkg *cache.Package, targets map[types.Object]bool, correspo
623623
if obj == nil {
624624
continue
625625
}
626-
if rng, err := pgf.NodeRange(id); err == nil && matches(obj) {
626+
if !matches(obj) {
627+
continue
628+
}
629+
if rng, err := pgf.NodeRange(id); err == nil {
627630
asmLocation := protocol.Location{
628631
URI: pgf.URI,
629632
Range: rng,

0 commit comments

Comments
 (0)