// Definition handles the textDocument/definition request for Go files. func Definition(ctx context.Context, snapshot *cache.Snapshot, fh file.Handle, position protocol.Position) ([]protocol.Location, error) { … } // builtinDefinition returns the location of the fake source // declaration of a built-in in {builtin,unsafe}.go. func builtinDefinition(ctx context.Context, snapshot *cache.Snapshot, obj types.Object) ([]protocol.Location, error) { … } // builtinDecl returns the parsed Go file and node corresponding to a builtin // object, which may be a universe object or part of types.Unsafe, as well as // its declaring identifier. func builtinDecl(ctx context.Context, snapshot *cache.Snapshot, obj types.Object) (*parsego.File, *ast.Ident, error) { … } // referencedObject returns the identifier and object referenced at the // specified position, which must be within the file pgf, for the purposes of // definition/hover/call hierarchy operations. It returns a nil object if no // object was found at the given position. // // If the returned identifier is a type-switch implicit (i.e. the x in x := // e.(type)), the third result will be the type of the expression being // switched on (the type of e in the example). This facilitates workarounds for // limitations of the go/types API, which does not report an object for the // identifier x. // // For embedded fields, referencedObject returns the type name object rather // than the var (field) object. // // TODO(rfindley): this function exists to preserve the pre-existing behavior // of golang.Identifier. Eliminate this helper in favor of sharing // functionality with objectsAt, after choosing suitable primitives. func referencedObject(pkg *cache.Package, pgf *parsego.File, pos token.Pos) (*ast.Ident, types.Object, types.Type) { … } // importDefinition returns locations defining a package referenced by the // import spec containing pos. // // If pos is not inside an import spec, it returns nil, nil. func importDefinition(ctx context.Context, s *cache.Snapshot, pkg *cache.Package, pgf *parsego.File, pos token.Pos) ([]protocol.Location, error) { … } // TODO(rfindley): avoid the duplicate column mapping here, by associating a // column mapper with each file handle. func mapPosition(ctx context.Context, fset *token.FileSet, s file.Source, start, end token.Pos) (protocol.Location, error) { … } // nonGoDefinition returns the location of the definition of a non-Go symbol. // Only assembly is supported for now. func nonGoDefinition(ctx context.Context, snapshot *cache.Snapshot, pkg *cache.Package, symbol string) ([]protocol.Location, error) { … }