Documentation
¶
Overview ¶
Package uast provides a universal abstract syntax tree (UAST) representation and utilities for parsing, navigating, querying, and mutating code structure in a language-agnostic way.
Index ¶
- Constants
- func GetPatternMatchStats() map[string]int64
- func GetPatternMatcher(language string) interface{}
- func RecordPatternMatch(language, pattern string, matched bool)
- type Change
- type ChangeType
- type DSLParser
- type LanguageParser
- type Loader
- type Map
- type NodeChange
- type Parser
- func (parser *Parser) GetEmbeddedMappings() map[string]Map
- func (parser *Parser) GetEmbeddedMappingsList() map[string]map[string]any
- func (parser *Parser) GetLanguage(filename string) string
- func (parser *Parser) GetMapping(language string) (*Map, error)
- func (parser *Parser) IsSupported(filename string) bool
- func (parser *Parser) Parse(ctx context.Context, filename string, content []byte) (*node.Node, error)
- func (parser *Parser) WithMap(uastMaps map[string]Map) *Parser
- type PrecompiledMapping
Constants ¶
const ConfigUASTProvider = "UAST.Provider"
ConfigUASTProvider is the configuration key for the UAST provider.
const DependencyUastChanges = "uast_changes"
DependencyUastChanges is the name of the dependency provided by Changes.
Variables ¶
This section is empty.
Functions ¶
func GetPatternMatchStats ¶
func GetPatternMatcher ¶
func GetPatternMatcher(language string) interface{}
GetPatternMatcher returns a pre-compiled pattern matcher for the given language
func RecordPatternMatch ¶
Types ¶
type ChangeType ¶
type ChangeType int
ChangeType represents the type of change between two nodes.
const ( ChangeAdded ChangeType = iota ChangeRemoved ChangeModified )
Change type constants.
func (ChangeType) String ¶
func (ct ChangeType) String() string
type DSLParser ¶
type DSLParser struct {
IncludeUnmapped bool
// contains filtered or unexported fields
}
DSLParser implements the UAST LanguageParser interface using DSL-based mappings.
func NewDSLParser ¶
NewDSLParser creates a new DSL-based parser with the given language and mapping rules.
func (*DSLParser) Extensions ¶
Extensions returns the supported file extensions for this parser.
func (*DSLParser) GetOriginalDSL ¶
GetOriginalDSL returns the original DSL content that was used to create this parser.
type LanguageParser ¶
type LanguageParser interface {
Parse(ctx context.Context, filename string, content []byte) (*node.Node, error)
Language() string
Extensions() []string
}
LanguageParser is responsible for parsing source code into UAST nodes.
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader loads UAST parsers for different languages.
func (*Loader) GetParsers ¶
func (l *Loader) GetParsers() map[string]LanguageParser
GetParsers returns all loaded parsers.
func (*Loader) LanguageParser ¶
func (l *Loader) LanguageParser(extension string) (LanguageParser, bool)
LanguageParser returns the parser for the given file extension.
func (*Loader) LoadParser ¶
func (l *Loader) LoadParser(reader io.Reader) (LanguageParser, error)
LoadParser loads a parser by reading the uastmap file through the reader
type NodeChange ¶
NodeChange represents a structural change between two UAST nodes.
func DetectChanges ¶
func DetectChanges(before, after *node.Node) []NodeChange
DetectChanges detects structural changes between two UAST nodes.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser implements LanguageParser using embedded parsers. Entry point for UAST parsing. Parser is the main entry point for UAST parsing. It manages language parsers and their configurations.
func NewParser ¶
NewParser creates a new Parser with DSL-based language parsers. It loads parser configurations and instantiates parsers for each supported language. Returns a pointer to the Parser or an error if loading parsers fails.
func (*Parser) GetEmbeddedMappings ¶
GetEmbeddedMappings returns all embedded UAST mappings.
func (*Parser) GetEmbeddedMappingsList ¶
GetEmbeddedMappingsList returns a lightweight list of embedded UAST mappings (without full content).
func (*Parser) GetLanguage ¶
GetLanguage returns the language name for the given filename if supported, or empty string.
func (*Parser) GetMapping ¶
GetMapping returns a specific embedded UAST mapping by name.
func (*Parser) IsSupported ¶
IsSupported returns true if the given filename is supported by any parser.
type PrecompiledMapping ¶
type PrecompiledMapping struct {
Language string `json:"language"`
Extensions []string `json:"extensions"`
Rules []mapping.Rule `json:"rules"`
Patterns map[string]interface{} `json:"patterns"`
CompiledAt string `json:"compiled_at"`
}
PrecompiledMapping represents the pre-compiled mapping data
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package lsp provides a Language Server Protocol (LSP) server for the mapping DSL used in the UAST framework.
|
Package lsp provides a Language Server Protocol (LSP) server for the mapping DSL used in the UAST framework. |
|
pkg
|
|
|
mapping
Package mapping provides Tree-Sitter to UAST mapping rules and grammar analysis.
|
Package mapping provides Tree-Sitter to UAST mapping rules and grammar analysis. |
|
node
Package node provides the canonical UAST node structure and operations for tree traversal, querying, and transformation.
|
Package node provides the canonical UAST node structure and operations for tree traversal, querying, and transformation. |
|
spec
Package spec provides embedded UAST schema specifications.
|
Package spec provides embedded UAST schema specifications. |