api

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: May 29, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Query

type Query struct {
	Name  string
	Query string
}

Query represents a named tree-sitter query

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

type QueryResults map[string]map[string]*tree_sitter.Result

QueryResults represents the raw query results by file

type RunConfig

type RunConfig struct {
	Files      []string
	Glob       string
	Directory  string
	Recursive  bool
	MaxWorkers int
}

RunConfig holds configuration for running queries

type RunOption

type RunOption func(*RunConfig)

RunOption is a functional option for configuring query execution

func WithDirectory

func WithDirectory(dir string) RunOption

WithDirectory specifies a directory to scan for files

func WithFiles

func WithFiles(files []string) RunOption

WithFiles specifies files to run queries on

func WithGlob

func WithGlob(pattern string) RunOption

WithGlob specifies a glob pattern to find files

func WithMaxWorkers

func WithMaxWorkers(n int) RunOption

WithMaxWorkers sets the maximum number of worker goroutines

func WithRecursive

func WithRecursive(recursive bool) RunOption

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

Jump to

Keyboard shortcuts

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