base

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2025 License: MIT Imports: 15 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 *sitter.Parser, 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 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 added in v1.5.0

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

Stats returns the current parser pool metrics for this provider.

func (*Provider) SupportedQueryTypes added in v1.5.0

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 SmartAppendConfig added in v1.5.0

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

SmartAppendConfig allows language configs to provide smarter append behaviour.

Jump to

Keyboard shortcuts

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