// References returns a list of all references (sorted with // definitions before uses) to the object denoted by the identifier at // the given file/position, searching the entire workspace. func References(ctx context.Context, snapshot *cache.Snapshot, fh file.Handle, pp protocol.Position, includeDeclaration bool) ([]protocol.Location, error) { … } type reference … // references returns a list of all references (sorted with // definitions before uses) to the object denoted by the identifier at // the given file/position, searching the entire workspace. func references(ctx context.Context, snapshot *cache.Snapshot, f file.Handle, pp protocol.Position, includeDeclaration bool) ([]reference, error) { … } // packageReferences returns a list of references to the package // declaration of the specified name and uri by searching among the // import declarations of all packages that directly import the target // package. func packageReferences(ctx context.Context, snapshot *cache.Snapshot, uri protocol.DocumentURI) ([]reference, error) { … } // ordinaryReferences computes references for all ordinary objects (not package declarations). func ordinaryReferences(ctx context.Context, snapshot *cache.Snapshot, uri protocol.DocumentURI, pp protocol.Position) ([]reference, error) { … } // expandMethodSearch expands the scope and targets of a global search // for an exported method to include all methods in the workspace // that correspond to it through interface satisfaction. // // Each package that declares a corresponding type is added to // expansions so that we can also find local references to the type // within the package, which of course requires type checking. // // The scope is expanded by a sequence of calls (not concurrent) to addRdeps. // // recv is the method's effective receiver type, for method-set computations. func expandMethodSearch(ctx context.Context, snapshot *cache.Snapshot, workspaceIDs []PackageID, method *types.Func, recv types.Type, addRdeps func(id PackageID, transitive bool) error, targets map[PackagePath]map[objectpath.Path]unit, expansions map[PackageID]unit) error { … } // localReferences traverses syntax and reports each reference to one // of the target objects, or (if correspond is set) an object that // corresponds to one of them via interface satisfaction. func localReferences(pkg *cache.Package, targets map[types.Object]bool, correspond bool, report func(loc protocol.Location, isDecl bool)) error { … } // effectiveReceiver returns the effective receiver type for method-set // comparisons for obj, if it is a method, or nil otherwise. func effectiveReceiver(obj types.Object) types.Type { … } // objectsAt returns the non-empty set of objects denoted (def or use) // by the specified position within a file syntax tree, or an error if // none were found. // // The result may contain more than one element because all case // variables of a type switch appear to be declared at the same // position. // // Each object is mapped to the syntax node that was treated as an // identifier, which is not always an ast.Ident. The second component // of the result is the innermost node enclosing pos. // // TODO(adonovan): factor in common with referencedObject. func objectsAt(info *types.Info, file *ast.File, pos token.Pos) (map[types.Object]ast.Node, ast.Node, error) { … } // mustLocation reports the location interval a syntax node, // which must belong to m.File. // // Safe for use only by references and implementations. func mustLocation(pgf *parsego.File, n ast.Node) protocol.Location { … }