Documentation
¶
Index ¶
- type Query
- type QueryBuilder
- func (qb *QueryBuilder) Run(ctx context.Context, options ...RunOption) (QueryResults, error)
- func (qb *QueryBuilder) RunWithProcessor(ctx context.Context, processor any, options ...RunOption) (any, error)
- func (qb *QueryBuilder) RunWithTemplate(ctx context.Context, templateText string, options ...RunOption) (string, error)
- func (qb *QueryBuilder) RunWithTemplateFile(ctx context.Context, templatePath string, options ...RunOption) (string, error)
- func (qb *QueryBuilder) ToLispExpression(ctx context.Context, filePath string, includeAnonymous bool) (pm.Expression, error)
- type QueryOption
- type QueryResults
- type RunConfig
- type RunOption
- type TemplatedResults
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type QueryBuilder ¶
type QueryBuilder struct {
// contains filtered or unexported fields
}
QueryBuilder provides an API for building and running tree-sitter queries
func NewQueryBuilder ¶
func NewQueryBuilder(options ...QueryOption) *QueryBuilder
NewQueryBuilder creates a new query builder with the given options
func (*QueryBuilder) Run ¶
func (qb *QueryBuilder) Run( ctx context.Context, options ...RunOption, ) (QueryResults, error)
Run executes the queries and returns the raw results
func (*QueryBuilder) RunWithProcessor ¶
func (qb *QueryBuilder) RunWithProcessor( ctx context.Context, processor any, options ...RunOption, ) (any, error)
RunWithProcessor runs the queries and processes the results with a processor function
func (*QueryBuilder) RunWithTemplate ¶
func (qb *QueryBuilder) RunWithTemplate( ctx context.Context, templateText string, options ...RunOption, ) (string, error)
RunWithTemplate runs the queries and processes the results with a template
func (*QueryBuilder) RunWithTemplateFile ¶
func (qb *QueryBuilder) RunWithTemplateFile( ctx context.Context, templatePath string, options ...RunOption, ) (string, error)
RunWithTemplateFile runs the queries and processes the results with a template file
func (*QueryBuilder) ToLispExpression ¶
func (qb *QueryBuilder) ToLispExpression( ctx context.Context, filePath string, includeAnonymous bool, ) (pm.Expression, error)
ToLispExpression parses the provided file and returns the root node as a patternmatcher Expression S-expression. It skips anonymous nodes by default for readability unless includeAnonymous is true.
type QueryOption ¶
type QueryOption func(*QueryBuilder)
QueryOption is a functional option for configuring the QueryBuilder
func FromYAML ¶
func FromYAML(path string) QueryOption
FromYAML loads queries from a YAML file in the existing Oak format
func WithLanguage ¶
func WithLanguage(language string) QueryOption
WithLanguage sets the language for the query builder
func WithQuery ¶
func WithQuery(name, query string) QueryOption
WithQuery adds a query to the builder
func WithQueryFromFile ¶
func WithQueryFromFile(name, path string) QueryOption
WithQueryFromFile adds a query from a file to the builder
type QueryResults ¶
QueryResults represents the raw query results by file
type RunOption ¶
type RunOption func(*RunConfig)
RunOption is a functional option for configuring query execution
func WithDirectory ¶
WithDirectory specifies a directory to scan for files
func WithMaxWorkers ¶
WithMaxWorkers sets the maximum number of worker goroutines
func WithRecursive ¶
WithRecursive enables recursive directory scanning
type TemplatedResults ¶
type TemplatedResults struct {
Language string
ResultsByFile map[string]map[string]*tree_sitter.Result
}
TemplatedResults is the data structure passed to templates