kindex

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2015 License: Apache-2.0 Imports: 14 Imported by: 0

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

View Source
const Extension = ".kindex"

Standard file extension for Kythe compilation index files.

Variables

This section is empty.

Functions

func FileData

func FileData(path string, r io.Reader) (*apb.FileData, error)

FileData creates a file data protobuf message by fully reading the contents of r, having the designated path.

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

func (c *Compilation) WriteTo(w io.Writer) (int64, error)

WriteTo implements the io.WriterTo interface, writing the contents of the Compilation in index file format. Returns the total number of bytes written after GZip compression was applied.

Jump to

Keyboard shortcuts

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