Documentation ¶
Overview ¶
Package xrefs defines the xrefs Service interface and some useful utility functions.
Index ¶
- Variables
- func AllEdges(ctx context.Context, es GraphService, req *xpb.EdgesRequest) (*xpb.EdgesReply, error)
- func ConvertFilters(filters []string) []*regexp.Regexp
- func EdgesMap(edges map[string]*xpb.EdgeSet) map[string]map[string]map[string]map[int32]struct{}
- func FixTickets(tickets []string) ([]string, error)
- func InSpanBounds(kind xpb.DecorationsRequest_SpanKind, ...) bool
- func IsDeclKind(requestedKind xpb.CrossReferencesRequest_DeclarationKind, edgeKind string, ...) bool
- func IsDefKind(requestedKind xpb.CrossReferencesRequest_DefinitionKind, edgeKind string, ...) bool
- func IsDocKind(requestedKind xpb.CrossReferencesRequest_DocumentationKind, edgeKind string) bool
- func IsRefKind(requestedKind xpb.CrossReferencesRequest_ReferenceKind, edgeKind string) bool
- func MatchesAny(str string, patterns []*regexp.Regexp) bool
- func NodesMap(nodes map[string]*xpb.NodeInfo) map[string]map[string][]byte
- func RegisterHTTPHandlers(ctx context.Context, xs Service, mux *http.ServeMux)
- func SlowCallersForCrossReferences(ctx context.Context, service Service, ...) ([]*xpb.CrossReferencesReply_RelatedAnchor, error)
- func SlowDefinitions(ctx context.Context, xs Service, tickets []string) (map[string]*xpb.Anchor, error)
- func SlowDocumentation(ctx context.Context, service Service, req *xpb.DocumentationRequest) (*xpb.DocumentationReply, error)
- func SlowOverrides(ctx context.Context, xs Service, tickets []string) (map[string][]*xpb.DecorationsReply_Override, error)
- func SlowSignature(ctx context.Context, service Service, ticket string) (*xpb.Printable, error)
- type ByName
- type ByOrdinal
- type GraphService
- type Normalizer
- type Patcher
- type Service
- type SignatureDetails
Constants ¶
This section is empty.
Variables ¶
var ErrDecorationsNotFound = errors.New("file decorations not found")
ErrDecorationsNotFound is returned by an implementation of the Decorations method when decorations for the given file cannot be found.
Functions ¶
func AllEdges ¶ added in v0.0.8
func AllEdges(ctx context.Context, es GraphService, 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 ¶
ConvertFilters converts each filter glob into an equivalent regexp.
func FixTickets ¶ added in v0.0.18
FixTickets converts the specified tickets, which are expected to be Kythe URIs, into canonical form. It is an error if len(tickets) == 0.
func InSpanBounds ¶ added in v0.0.21
func InSpanBounds(kind xpb.DecorationsRequest_SpanKind, start, end, startBoundary, endBoundary int32) bool
InSpanBounds reports whether [start,end) is bounded by the specified [startBoundary,endBoundary) span.
func IsDeclKind ¶ added in v0.0.21
func IsDeclKind(requestedKind xpb.CrossReferencesRequest_DeclarationKind, edgeKind string, incomplete bool) bool
IsDeclKind reportsa whether the given edgeKind matches the requested declaration kind
func IsDefKind ¶ added in v0.0.17
func IsDefKind(requestedKind xpb.CrossReferencesRequest_DefinitionKind, edgeKind string, incomplete bool) bool
IsDefKind reports 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 ¶
MatchesAny reports whether if str matches any of the patterns
func RegisterHTTPHandlers ¶
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 /documentation Request: JSON encoded xrefs.DocumentationRequest Response: JSON encoded xrefs.DocumentationReply
Note: /nodes, /edges, /decorations, and /xrefs will return their responses as serialized protobufs if the "proto" query parameter is set.
func SlowCallersForCrossReferences ¶ added in v0.0.22
func SlowCallersForCrossReferences(ctx context.Context, service Service, includeOverrides, generateSignatures bool, ticket string) ([]*xpb.CrossReferencesReply_RelatedAnchor, error)
SlowCallersForCrossReferences is an implementation of callgraph support meant for intermediate-term use by CrossReferences.
func SlowDefinitions ¶ added in v0.0.21
func SlowDefinitions(ctx context.Context, xs Service, tickets []string) (map[string]*xpb.Anchor, error)
SlowDefinitions attempts to return a definition location for every node ticket given. A definition will be returned only if it is unambiguous, but the definition may be indirect (through an intermediary node).
func SlowDocumentation ¶ added in v0.0.21
func SlowDocumentation(ctx context.Context, service Service, req *xpb.DocumentationRequest) (*xpb.DocumentationReply, error)
SlowDocumentation is an implementation of the Documentation API built from other APIs.
func SlowOverrides ¶ added in v0.0.24
func SlowOverrides(ctx context.Context, xs Service, tickets []string) (map[string][]*xpb.DecorationsReply_Override, error)
SlowOverrides retrieves the list of Overrides for every input ticket. The map that it returns will only contain entries for input tickets that have at least one Override.
func SlowSignature ¶ added in v0.0.21
SlowSignature uses formats to generate a xpb.DocumentationReply_Printable given a ticket. In the simplest case, if a node's format is some literal "foo", the Printable's text would be "foo". Other formats may refer to related nodes; for example, "%^::bar" would append "::bar" to a node's parent's (recursively-defined) signature. See http://www.kythe.io/docs/schema/#formats for details.
Types ¶
type ByOrdinal ¶ added in v0.0.21
type ByOrdinal []*xpb.EdgeSet_Group_Edge
ByOrdinal orders the edges in an edge group by their ordinals, with ties broken by ticket.
type GraphService ¶ added in v0.0.25
type GraphService interface { Nodes(context.Context, *xpb.NodesRequest) (*xpb.NodesReply, error) Edges(context.Context, *xpb.EdgesRequest) (*xpb.EdgesReply, error) }
GraphService exposes direct access to nodes and edges 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 ¶
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 ¶
func (n *Normalizer) Point(p *xpb.Location_Point) *xpb.Location_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
NewPatcher returns a Patcher based on the diff between oldText and newText.
func (*Patcher) Patch ¶ added in v0.0.5
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 ¶
type Service interface { GraphService // Decorations returns an index of the nodes associated with a specified file. Decorations(context.Context, *xpb.DecorationsRequest) (*xpb.DecorationsReply, error) // CrossReferences returns the global cross-references for the given nodes. CrossReferences(context.Context, *xpb.CrossReferencesRequest) (*xpb.CrossReferencesReply, error) // Documentation takes a set of tickets and returns documentation for them. Documentation(context.Context, *xpb.DocumentationRequest) (*xpb.DocumentationReply, error) }
Service defines the interface for file based cross-references. Informally, the cross-references of an entity comprise the definitions of that entity, together with all the places where those definitions are referenced through constructs such as type declarations, variable references, function calls, and so on.
func GRPC ¶
func GRPC(c xpb.XRefServiceClient) Service
GRPC returns an xrefs Service backed by the given GRPC client and context.
type SignatureDetails ¶ added in v0.0.21
type SignatureDetails struct {
// contains filtered or unexported fields
}
SignatureDetails contains information from the graph used by slowSignatureLevel to build signatures.