xrefs

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: 18 Imported by: 12

Documentation

Overview

Package xrefs defines the xrefs Service interface and some useful utility functions.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrDecorationsNotFound is returned from Decorations when decorations for
	// the given file cannot be found.
	ErrDecorationsNotFound = errors.New("file decorations not found")
)

Functions

func AllEdges added in v0.0.8

func AllEdges(ctx context.Context, es EdgesService, req *xpb.EdgesRequest) (*xpb.EdgesReply, error)

AllEdges returns all edges for a particular EdgesRequest. This means that the returned reply will not have a next page token. WARNING: the paging API exists for a reason; using this can lead to very large memory consumption depending on the request.

func ConvertFilters

func ConvertFilters(filters []string) []*regexp.Regexp

ConvertFilters converts each filter glob into an equivalent regexp.

func EdgesMap

func EdgesMap(edges []*xpb.EdgeSet) map[string]map[string][]string

EdgesMap returns a map from each node ticket to a map of its outward edge kinds.

func FixTickets added in v0.0.18

func FixTickets(rawTickets []string) ([]string, error)

FixTickets returns an equivalent slice of normalized tickets.

func IsDefKind added in v0.0.17

func IsDefKind(requestedKind xpb.CrossReferencesRequest_DefinitionKind, edgeKind string) bool

IsDefKind determines whether the given edgeKind matches the requested definition kind.

func IsDocKind added in v0.0.17

func IsDocKind(requestedKind xpb.CrossReferencesRequest_DocumentationKind, edgeKind string) bool

IsDocKind determines whether the given edgeKind matches the requested documentation kind.

func IsRefKind added in v0.0.17

func IsRefKind(requestedKind xpb.CrossReferencesRequest_ReferenceKind, edgeKind string) bool

IsRefKind determines whether the given edgeKind matches the requested reference kind.

func MatchesAny

func MatchesAny(str string, patterns []*regexp.Regexp) bool

MatchesAny reports whether if str matches any of the patterns

func NodesMap

func NodesMap(nodes []*xpb.NodeInfo) map[string]map[string][]byte

NodesMap returns a map from each node ticket to a map of its facts.

func RegisterHTTPHandlers

func RegisterHTTPHandlers(ctx context.Context, xs Service, mux *http.ServeMux)

RegisterHTTPHandlers registers JSON HTTP handlers with mux using the given xrefs Service. The following methods with be exposed:

GET /nodes
  Request: JSON encoded xrefs.NodesRequest
  Response: JSON encoded xrefs.NodesReply
GET /edges
  Request: JSON encoded xrefs.EdgesRequest
  Response: JSON encoded xrefs.EdgesReply
GET /decorations
  Request: JSON encoded xrefs.DecorationsRequest
  Response: JSON encoded xrefs.DecorationsReply
GET /xrefs
  Request: JSON encoded xrefs.CrossReferencesRequest
  Response: JSON encoded xrefs.CrossReferencesReply
GET /callers
  Request: JSON encoded xrefs.CallersRequest
  Response: JSON encoded xrefs.CallersReply

Note: /nodes, /edges, /decorations, and /xrefs will return their responses as serialized protobufs if the "proto" query parameter is set.

func SlowCallers added in v0.0.19

func SlowCallers(ctx context.Context, service Service, req *xpb.CallersRequest) (*xpb.CallersReply, error)

SlowCallers is an implementation of the Callers API built from other APIs.

Types

type ByName added in v0.0.16

type ByName []*cpb.Fact

ByName implements the sort.Interface for cpb.Facts

func (ByName) Len added in v0.0.16

func (s ByName) Len() int

Implement the sort.Interface

func (ByName) Less added in v0.0.16

func (s ByName) Less(i, j int) bool

func (ByName) Swap added in v0.0.16

func (s ByName) Swap(i, j int)

type CallersService added in v0.0.18

type CallersService interface {
	// Callers takes a set of tickets for semantic objects and returns the set
	// of places where those objects were called.
	Callers(context.Context, *xpb.CallersRequest) (*xpb.CallersReply, error)
}

CallersService provides fast access to the callgraph implied by a Kythe graph.

type CrossReferencesService added in v0.0.13

type CrossReferencesService interface {
	// CrossReferences returns the global references of the given nodes.
	CrossReferences(context.Context, *xpb.CrossReferencesRequest) (*xpb.CrossReferencesReply, error)
}

CrossReferencesService provides fast access to cross-references in a Kythe graph.

type DecorationsService

type DecorationsService interface {
	// Decorations returns an index of the nodes and edges associated with a
	// particular file node.
	Decorations(context.Context, *xpb.DecorationsRequest) (*xpb.DecorationsReply, error)
}

DecorationsService provides fast access to file decorations in a Kythe graph.

type EdgesService

type EdgesService interface {
	// Edges returns a subset of the outbound edges for each of a set of requested
	// nodes.
	Edges(context.Context, *xpb.EdgesRequest) (*xpb.EdgesReply, error)
}

EdgesService provides fast access to edges in a Kythe graph.

type NodesEdgesService

type NodesEdgesService interface {
	NodesService
	EdgesService
}

NodesEdgesService provides fast access to nodes and edges in a Kythe graph.

type NodesService

type NodesService interface {
	// Nodes returns a subset of the facts for each of the requested nodes.
	Nodes(context.Context, *xpb.NodesRequest) (*xpb.NodesReply, error)
}

NodesService provides fast access to nodes in a Kythe graph.

type Normalizer

type Normalizer struct {
	// contains filtered or unexported fields
}

Normalizer fixes xref.Locations within a given source text so that each point has consistent byte_offset, line_number, and column_offset fields within the range of text's length and its line lengths.

func NewNormalizer

func NewNormalizer(text []byte) *Normalizer

NewNormalizer returns a Normalizer for Locations within text.

func (*Normalizer) ByteOffset added in v0.0.9

func (n *Normalizer) ByteOffset(offset int32) *xpb.Location_Point

ByteOffset returns a normalized point based on the given offset within the Normalizer's text. A normalized point has all of its fields set consistently and clamped within the range [0,len(text)).

func (*Normalizer) Location

func (n *Normalizer) Location(loc *xpb.Location) (*xpb.Location, error)

Location returns a normalized location within the Normalizer's text. Normalized FILE locations have no start/end points. Normalized SPAN locations have fully populated start/end points clamped in the range [0, len(text)).

func (*Normalizer) Point

Point returns a normalized point within the Normalizer's text. A normalized point has all of its fields set consistently and clamped within the range [0,len(text)).

type Patcher added in v0.0.5

type Patcher struct {
	// contains filtered or unexported fields
}

Patcher uses a computed diff between two texts to map spans from the original text to the new text.

func NewPatcher added in v0.0.5

func NewPatcher(oldText, newText []byte) *Patcher

NewPatcher returns a Patcher based on the diff between oldText and newText.

func (*Patcher) Patch added in v0.0.5

func (p *Patcher) Patch(spanStart, spanEnd int32) (newStart, newEnd int32, exists bool)

Patch returns the resulting span of mapping the given span from the Patcher's constructed oldText to its newText. If the span no longer exists in newText or is invalid, the returned bool will be false. As a convenience, if p==nil, the original span will be returned.

type Service

Service provides access to a Kythe graph for fast access to cross-references.

func GRPC

GRPC returns an xrefs Service backed by the given GRPC client and context.

func WebClient

func WebClient(addr string) Service

WebClient returns an xrefs Service based on a remote web server.

Jump to

Keyboard shortcuts

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