base

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GlobalCache = &ASTCache{
	maxAge: 5 * time.Minute,
}

GlobalCache is the singleton cache instance shared across all providers

Functions

This section is empty.

Types

type ASTCache

type ASTCache struct {
	// contains filtered or unexported fields
}

ASTCache is a lock-free cache for parsed ASTs (shared across all providers)

func (*ASTCache) GetOrParse

func (c *ASTCache) GetOrParse(parser cacheParser, source []byte) (*sitter.Tree, bool)

GetOrParse returns cached AST or parses new one

func (*ASTCache) Stats

func (c *ASTCache) Stats() map[string]int64

Stats returns cache statistics

type CachedAST

type CachedAST struct {
	// contains filtered or unexported fields
}

CachedAST holds parsed tree with metadata

type LanguageConfig

type LanguageConfig interface {
	// Metadata
	Language() string
	Extensions() []string
	GetLanguage() *sitter.Language

	// Language-specific AST mapping
	MapQueryTypeToNodeTypes(queryType string) []string
	ExtractNodeName(node *sitter.Node, source string) string
	IsExported(name string) bool // For confidence calculation

	// For discovery/specification
	SupportedQueryTypes() []string
}

LanguageConfig defines language-specific behavior that must be implemented

type Match

type Match struct {
	Name      string
	Type      string
	NodeType  string
	StartByte uint32
	EndByte   uint32
	Line      uint32
	Column    uint32
}

Match is provider-local match metadata derived from a tree-sitter node.

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

Provider provides common functionality for all language providers

func New

func New(config LanguageConfig) *Provider

New creates a base provider with language-specific config

func (*Provider) Extensions

func (p *Provider) Extensions() []string

Extensions returns supported file extensions

func (*Provider) Language

func (p *Provider) Language() string

Language returns language identifier

func (*Provider) Query

func (p *Provider) Query(source string, query core.AgentQuery) core.QueryResult

Query finds code elements matching the query

func (*Provider) Stats

func (p *Provider) Stats() providers.Stats

Stats returns the current parser pool metrics for this provider.

func (*Provider) SupportedQueryTypes

func (p *Provider) SupportedQueryTypes() []string

SupportedQueryTypes lists human-friendly query types/aliases

func (*Provider) Transform

func (p *Provider) Transform(source string, op core.TransformOp) core.TransformResult

Transform applies a transformation operation

func (*Provider) Validate

func (p *Provider) Validate(source string) providers.ValidationResult

Validate checks syntax

type QueryTypeNormalizer added in v0.3.0

type QueryTypeNormalizer interface {
	NormalizeQueryType(queryType string) string
}

QueryTypeNormalizer lets providers own DSL/query aliases for their language.

type SmartAppendConfig

type SmartAppendConfig interface {
	SmartAppend(source string, target *sitter.Node, content string) (string, bool)
}

SmartAppendConfig allows language configs to provide smarter append behaviour.

type Target

type Target struct {
	Match
	Node *sitter.Node
}

Target is a provider-local transformation target that retains the parser node.

func NewTarget

func NewTarget(node *sitter.Node, queryType, name string) Target

NewTarget captures provider-local match metadata while keeping the parser node private to providers.

Jump to

Keyboard shortcuts

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