Help us shape the future of Go! Take the 2026 Go Developer Survey

source

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SafePath

func SafePath(root, relative string) (string, error)

SafePath resolves a repository-relative path against root and confines the result to that root: absolute paths and ".." are rejected, symlinks are resolved, and a path escaping the root after resolution is an error. It is exported so other bounded readers reuse one implementation.

Types

type Excerpt

type Excerpt struct {
	Node        graph.Node `json:"node"`
	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

type ProjectLocator interface {
	ProjectForNode(context.Context, string) (indexer.Project, error)
}

func NewSingleProjectLocator

func NewSingleProjectLocator(repository graph.QueryRepository, project indexer.Project) ProjectLocator

type ReaderFunc

type ReaderFunc func(context.Context, string, graph.NodeKind, int, int) (Excerpt, error)

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.

Jump to

Keyboard shortcuts

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