indexer

package
v0.0.19 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 26, 2016 License: Apache-2.0 Imports: 14 Imported by: 2

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

func AllTypeInfo() *types.Info

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

type Fetcher interface {
	Fetch(path, digest string) ([]byte, error)
}

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

	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) String

func (pi *PackageInfo) String() string

String renders a human-readable synopsis of the package information.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL