Documentation ¶
Overview ¶
Package kindex implements an interface to compilation index files which are standalone CompilationUnits with all of their required inputs.
Example: Reading an index file.
c, err := kindex.Open("path/to/unit.kindex") if err != nil { log.Fatal(err) }
Example: Writing an index file.
var buf bytes.Buffer c.WriteTo(&buf)
On disk, a kindex file is a GZip compressed stream of varint-prefixed data blocks containing wire-format protobuf messages. The first message is a CompilationUnit, the remaining messages are FileData messages, one for each of the required inputs for the CompilationUnit.
These proto messages are defined in //kythe/proto:analysis_proto
Index ¶
- Constants
- func FileData(path string, r io.Reader) (*apb.FileData, error)
- type Compilation
- func (c *Compilation) AddDetails(msg proto.Message) error
- func (c *Compilation) AddFile(path string, r io.Reader, v *spb.VName, details ...proto.Message) error
- func (c *Compilation) Fetch(path, digest string) ([]byte, error)
- func (c *Compilation) Unit() *apb.CompilationUnit
- func (c *Compilation) WriteTo(w io.Writer) (int64, error)
Constants ¶
const Extension = ".kindex"
Extension is the standard file extension for Kythe compilation index files.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Compilation ¶
type Compilation struct { Proto *apb.CompilationUnit `json:"compilation"` Files []*apb.FileData `json:"files"` }
Compilation is a CompilationUnit with the contents for all of its required inputs.
func FromUnit ¶
func FromUnit(unit *apb.CompilationUnit, f analysis.Fetcher) (*Compilation, error)
FromUnit creates a compilation index by fetching all the required inputs of unit from f.
func New ¶
func New(r io.Reader) (*Compilation, error)
New reads a kindex file from r, which is expected to be positioned at the beginning of an index file or a data source of equivalent format.
func Open ¶
func Open(ctx context.Context, path string) (*Compilation, error)
Open opens a kindex file at the given path (using vfs.Open) and reads its contents into memory.
func (*Compilation) AddDetails ¶ added in v0.0.27
func (c *Compilation) AddDetails(msg proto.Message) error
AddDetails adds the specified details message to the compilation.
func (*Compilation) AddFile ¶ added in v0.0.27
func (c *Compilation) AddFile(path string, r io.Reader, v *spb.VName, details ...proto.Message) error
AddFile adds an input file to the compilation by fully reading r. The file is added to the required inputs, attributed to the designated path, and also to the file data slice. If v != nil it is used as the vname of the input added.
func (*Compilation) Fetch ¶
func (c *Compilation) Fetch(path, digest string) ([]byte, error)
Fetch implements the analysis.Fetcher interface for files attached to c. If digest == "", files are matched by path only.
func (*Compilation) Unit ¶ added in v0.0.27
func (c *Compilation) Unit() *apb.CompilationUnit
Unit returns the CompilationUnit associated with c, creating a new empty one if necessary.