kindex

package
v0.0.50 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2021 License: Apache-2.0, NCSA Imports: 16 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"

Extension is the 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) 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.

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