Documentation
¶
Index ¶
- func SafePath(root, relative string) (string, error)
- type Excerpt
- type ProjectLocator
- type ReaderFunc
- type Service
- func (s *Service) Read(ctx context.Context, selector string, contextLines, maxLines int) (Excerpt, error)
- func (s *Service) ReadKind(ctx context.Context, selector string, kind graph.NodeKind, ...) (Excerpt, error)
- func (s *Service) ReadNodeSource(ctx context.Context, nodeID string, contextLines, maxLines int) (query.SourceExcerpt, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Excerpt ¶
type Excerpt struct {
Node graph.Node `json:"node"`
// GeneratedNode is present when a generated symbol selector was projected
// to its canonical handwritten declaration. Supplying the generated node ID
// explicitly bypasses this projection and reads the generated source itself.
GeneratedNode *graph.Node `json:"generated_node,omitempty"`
Repository string `json:"repository"`
Branch string `json:"branch"`
Path string `json:"path"`
StartLine int `json:"start_line"`
EndLine int `json:"end_line"`
SymbolStart int `json:"symbol_start_line"`
SymbolEnd int `json:"symbol_end_line"`
Content string `json:"content"`
Truncated bool `json:"truncated"`
}
type ProjectLocator ¶
func NewSingleProjectLocator ¶
func NewSingleProjectLocator(repository graph.QueryRepository, project indexer.Project) ProjectLocator
type ReaderFunc ¶
ReaderFunc adapts a bounded excerpt reader to query.SourceReader so impact reports can include source without internal/query importing this package, which would close an import cycle.
func (ReaderFunc) ReadNodeSource ¶
func (f ReaderFunc) ReadNodeSource(ctx context.Context, nodeID string, contextLines, maxLines int) (query.SourceExcerpt, error)
ReadNodeSource resolves a node ID as a selector and narrows the excerpt to the fields internal/query declares. Bounds stay enforced by the reader.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func NewService(repository graph.QueryRepository, locator ProjectLocator) *Service
func (*Service) Read ¶
func (s *Service) Read(ctx context.Context, selector string, contextLines, maxLines int) (Excerpt, error)
Read resolves a selector and returns its bounded source excerpt. It accepts any node kind; ReadKind narrows resolution to one kind.
func (*Service) ReadKind ¶
func (s *Service) ReadKind(ctx context.Context, selector string, kind graph.NodeKind, contextLines, maxLines int) (Excerpt, error)
ReadKind resolves a selector restricted to one node kind and returns its bounded source excerpt. Resolution runs through query.Service, so an ambiguous selector fails here with *query.AmbiguousError instead of reading confident source for an arbitrary one of several matches.
func (*Service) ReadNodeSource ¶
func (s *Service) ReadNodeSource(ctx context.Context, nodeID string, contextLines, maxLines int) (query.SourceExcerpt, error)
ReadNodeSource lets a Service satisfy query.SourceReader directly.