Documentation
¶
Overview ¶
Package indexer implements a Kythe indexer for the Go language.
Usage example: Indexing a Kythe CompilationUnit message.
// Obtain a compilation from some source, e.g., an index pack. var pack *indexpack.Archive = ... var unit *apb.CompilationUnit = ... // Parse the sources and resolve types. pi, err := indexer.Resolve(unit, pack, indexer.AllTypeInfo()) if err != nil { log.Fatal("Resolving failed: %v", err) } // Type information from http://godoc.org/go/types is now available // from pi.Info, which is a *types.Info record.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllTypeInfo ¶
AllTypeInfo creates a new types.Info value with empty maps for each of the fields that can be filled in by the type-checker.
Types ¶
type Fetcher ¶
A Fetcher retrieves the contents of a file given its path and/or hex-encoded SHA256 digest, at least one of which must be set.
type PackageInfo ¶
type PackageInfo struct { Name string // The (short) name of the package ImportPath string // The nominal import path of the package Package *types.Package // The package for this compilation Dependencies map[string]*types.Package // Packages imported from dependencies VNames map[*types.Package]*spb.VName // Resolved package to vname FileSet *token.FileSet // Location info for the source files Files []*ast.File // The parsed ASTs of the source files SourceText map[string]string // The text of the source files, by path Info *types.Info // If non-nil, contains type-checker results Errors []error // All errors reported by the type checker // contains filtered or unexported fields }
PackageInfo records information about the Go packages defined by a compilation unit and its dependencies.
func Resolve ¶
func Resolve(unit *apb.CompilationUnit, f Fetcher, info *types.Info) (*PackageInfo, error)
Resolve resolves the package information for unit and its dependencies. On success the package corresponding to unit is located via ImportPath in the Packages map of the returned value.
If info != nil, it is used to populate the Info field of the return value and will contain the output of the type checker in each user-provided map field.
func (*PackageInfo) Import ¶
func (pi *PackageInfo) Import(importPath string) (*types.Package, error)
Import satisfies the types.Importer interface using the captured data from the compilation unit.
func (*PackageInfo) Signature ¶
func (pi *PackageInfo) Signature(obj types.Object) string
Signature returns a signature for obj, suitable for use in a vname.
func (*PackageInfo) Span ¶ added in v0.0.21
func (pi *PackageInfo) Span(node ast.Node) (start, end int)
Span returns the 0-based offset range of the given AST node. The range is half-open, including the start position but excluding the end. If node == nil or lacks a valid start position, Span returns -1, -1. If the end position of node is invalid, start == end.
func (*PackageInfo) String ¶
func (pi *PackageInfo) String() string
String renders a human-readable synopsis of the package information.