Documentation
¶
Index ¶
- func IsBlock(nodeType string) bool
- func IsCall(nodeType string) bool
- func IsCaseClause(nodeType string) bool
- func IsClosure(nodeType string) bool
- func IsComment(nodeType string) bool
- func IsContainerDeclaration(nodeType string) bool
- func IsDeclaration(nodeType string) bool
- func IsDelimitedContainer(nodeType string) bool
- func IsDelimiter(nodeType, label string) bool
- func IsExpression(nodeType string) bool
- func IsExpressionStatement(nodeType string) bool
- func IsFlattened(nodeType string) bool
- func IsFlattenedType(nodeType string) bool
- func IsIdentifier(nodeType string) bool
- func IsIndexed(nodeType string) bool
- func IsJumpStatement(nodeType string) bool
- func IsKeyword(nodeType, label string) bool
- func IsLocalVarDeclaration(nodeType string) bool
- func IsOperatorLiteral(nodeType string) bool
- func IsPunctuation(token string) bool
- func IsScaffolding(nodeType string) bool
- func IsType(nodeType string) bool
- func IsWrapper(nodeType string) bool
- type LanguageKind
- type Rules
- func (r *Rules) Alias(nodeType, label string) (string, bool)
- func (r *Rules) AreTypesEquivalent(t1, t2 string) bool
- func (r *Rules) CompileSets()
- func (r *Rules) DefaultRootType() string
- func (r *Rules) GetKind() LanguageKind
- func (r *Rules) IsBlock(nodeType string) bool
- func (r *Rules) IsCall(nodeType string) bool
- func (r *Rules) IsCaseClause(nodeType string) bool
- func (r *Rules) IsClosure(nodeType string) bool
- func (r *Rules) IsComment(nodeType string) bool
- func (r *Rules) IsContainerDeclaration(nodeType string) bool
- func (r *Rules) IsDeclaration(nodeType string) bool
- func (r *Rules) IsDelimitedContainer(nodeType string) bool
- func (r *Rules) IsDelimiter(nodeType, label string) bool
- func (r *Rules) IsExpression(nodeType string) bool
- func (r *Rules) IsExpressionStatement(nodeType string) bool
- func (r *Rules) IsFlattened(nodeType string) bool
- func (r *Rules) IsIdentifier(nodeType string) bool
- func (r *Rules) IsIgnored(nodeType, label string) bool
- func (r *Rules) IsIndexed(nodeType string) bool
- func (r *Rules) IsJumpStatement(nodeType string) bool
- func (r *Rules) IsKeyword(nodeType, label string) bool
- func (r *Rules) IsLabelIgnored(nodeType string) bool
- func (r *Rules) IsLocalVarDeclaration(nodeType string) bool
- func (r *Rules) IsOperatorLiteral(nodeType string) bool
- func (r *Rules) IsPair(nodeType string) bool
- func (r *Rules) IsPunctuation(token string) bool
- func (r *Rules) IsScaffolding(nodeType string) bool
- func (r *Rules) IsScopedDeclaration(nodeType string) bool
- func (r *Rules) IsTag(nodeType string) bool
- func (r *Rules) IsTerminalCallPath(calleePath string) bool
- func (r *Rules) IsType(nodeType string) bool
- func (r *Rules) IsUnordered(nodeType string) bool
- func (r *Rules) IsWrapper(nodeType string) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsCaseClause ¶ added in v0.10.0
IsCaseClause reports whether nodeType is configured as a case clause in any language rule set.
func IsClosure ¶ added in v0.8.0
IsClosure reports whether nodeType is configured as a closure in any language rule set.
func IsComment ¶
IsComment reports whether nodeType is configured as a comment in any language rule set.
func IsContainerDeclaration ¶ added in v0.8.0
IsContainerDeclaration reports whether nodeType is configured as a container declaration in any language rule set.
func IsDeclaration ¶
IsDeclaration reports whether nodeType is configured as a declaration in any language rule set.
func IsDelimitedContainer ¶ added in v0.9.0
IsDelimitedContainer reports whether nodeType is a delimited container in any registered language.
func IsDelimiter ¶
IsDelimiter reports whether nodeType or label is a delimiter token (semicolon or comma).
func IsExpression ¶ added in v0.10.0
IsExpression reports whether nodeType is configured as an expression in any language rule set.
func IsExpressionStatement ¶ added in v0.10.0
IsExpressionStatement reports whether nodeType represents an expression statement.
func IsFlattened ¶
IsFlattened reports whether nodeType is configured as flattened in any language rule set.
func IsFlattenedType ¶
IsFlattenedType reports whether nodeType is configured as flattened in any language rule set.
func IsIdentifier ¶
IsIdentifier reports whether nodeType is configured as an identifier in any language rule set.
func IsIndexed ¶ added in v0.8.0
IsIndexed reports whether nodeType is configured as an indexed container in any language rule set.
func IsJumpStatement ¶ added in v0.9.0
IsJumpStatement reports whether nodeType is configured as a jump statement in any language rule set.
func IsKeyword ¶
IsKeyword reports whether nodeType or label is configured as a keyword in any language rule set.
func IsLocalVarDeclaration ¶ added in v0.8.0
IsLocalVarDeclaration reports whether nodeType is configured as a local variable declaration in any language rule set.
func IsOperatorLiteral ¶
IsOperatorLiteral reports whether nodeType is configured as an operator literal in any language rule set.
func IsPunctuation ¶ added in v0.8.0
IsPunctuation reports whether a string is a structural punctuation token in any language rule set.
func IsScaffolding ¶
IsScaffolding reports whether nodeType is configured as scaffolding in any language rule set.
Types ¶
type LanguageKind ¶ added in v0.8.0
type LanguageKind uint8
LanguageKind classifies grammars into high-level parsing and diffing categories.
const ( // KindCode is for general programming languages (Go, Rust, Python, C++, etc.). KindCode LanguageKind = iota // KindData is for structured key-value formats (JSON, YAML, TOML). KindData // KindMarkup is for markup and styling languages (HTML, CSS). KindMarkup )
type Rules ¶
type Rules struct {
Kind LanguageKind
Flattened []string
Ignored []string
Aliased map[string]string
LabelIgnored []string
Scaffolding []string
Keywords []string
Declarations []string
Identifiers []string
Blocks []string
Wrappers []string
Pairs []string
Unordered []string
EquivalentTypes [][]string
Comments []string
Calls []string
ScopedDeclarations []string
Indexed []string // Subscript nodes with prefix receivers (e.g. arr[i]).
LocalVarDeclarations []string
ContainerDeclarations []string // Major declaration scope boundaries (functions, classes, structs, etc.).
Closures []string // Anonymous functions, lambdas, and callbacks.
Types []string // Type annotations and type expressions.
JumpStatements []string // Control-flow exit statements (return, break, continue, goto, throw, raise).
TerminalCalls []string // Dotted callee paths for execution-terminating calls (os.Exit, sys.exit, panic, etc.).
DelimitedContainers []string // Containers whose elements are separated by delimiters (like commas).
Expressions []string // Expression container node types.
CaseClauses []string // Arms that hold statements directly without curly braces (case, default, when, match_arm).
Tags []string // Markup elements and tags (e.g. element, start_tag, jsx_element, jsx_opening_element).
// contains filtered or unexported fields
}
Rules configures language-specific AST transformations and node matching.
func Get ¶
Get returns the compiled AST rules for a language, or a default empty rule set if none exist.
func (*Rules) Alias ¶
Alias returns the replacement node type if one exists for the label or node type.
func (*Rules) AreTypesEquivalent ¶
AreTypesEquivalent reports whether t1 and t2 belong to the same equivalent_types group.
func (*Rules) CompileSets ¶
func (r *Rules) CompileSets()
CompileSets builds the internal lookup sets for fast querying.
func (*Rules) DefaultRootType ¶
DefaultRootType returns the top-level root AST node type for the language.
func (*Rules) GetKind ¶ added in v0.8.0
func (r *Rules) GetKind() LanguageKind
GetKind returns the language category (KindCode, KindData, or KindMarkup).
func (*Rules) IsCaseClause ¶ added in v0.10.0
IsCaseClause reports whether nodeType is a branch or pattern arm in a switch/match/select statement.
func (*Rules) IsClosure ¶ added in v0.8.0
IsClosure reports whether nodeType is an anonymous function, closure, or lambda callback.
func (*Rules) IsContainerDeclaration ¶ added in v0.8.0
IsContainerDeclaration reports whether nodeType is a major container declaration (such as a function, method, class, struct, interface, trait, or enum).
func (*Rules) IsDeclaration ¶
IsDeclaration reports whether nodeType is a declaration.
func (*Rules) IsDelimitedContainer ¶ added in v0.9.0
IsDelimitedContainer reports whether nodeType is a comma-delimited container (like an argument list or array).
func (*Rules) IsDelimiter ¶
IsDelimiter reports whether nodeType or label is a delimiter token (semicolon or comma).
func (*Rules) IsExpression ¶ added in v0.10.0
IsExpression reports whether nodeType represents an expression node.
func (*Rules) IsExpressionStatement ¶ added in v0.10.0
IsExpressionStatement reports whether nodeType represents an expression statement.
func (*Rules) IsFlattened ¶
IsFlattened checks if intermediate nodes of this type should merge into their parent.
func (*Rules) IsIdentifier ¶
IsIdentifier reports whether nodeType is an identifier token.
func (*Rules) IsIgnored ¶
IsIgnored checks if a node type or label is filtered out when building the AST.
func (*Rules) IsIndexed ¶ added in v0.8.0
IsIndexed reports whether nodeType is a subscript container with a prefix receiver.
func (*Rules) IsJumpStatement ¶ added in v0.9.0
IsJumpStatement reports whether nodeType is an early-exit jump statement (such as return, break, continue, goto, throw, raise, yield).
func (*Rules) IsLabelIgnored ¶
IsLabelIgnored checks if node labels should be dropped for this type.
func (*Rules) IsLocalVarDeclaration ¶ added in v0.8.0
IsLocalVarDeclaration reports whether nodeType is a local variable declaration.
func (*Rules) IsOperatorLiteral ¶
IsOperatorLiteral reports whether nodeType is an aliased operator literal.
func (*Rules) IsPair ¶ added in v0.8.0
IsPair checks if nodeType represents a key-value property pair.
func (*Rules) IsPunctuation ¶ added in v0.8.0
IsPunctuation reports whether a string is a structural punctuation token (braces, brackets, parentheses, delimiters).
func (*Rules) IsScaffolding ¶
IsScaffolding reports whether nodeType is scaffolding.
func (*Rules) IsScopedDeclaration ¶
IsScopedDeclaration reports whether nodeType is a declaration with an explicit signature receiver or scope.
func (*Rules) IsTag ¶ added in v0.10.0
IsTag reports whether nodeType represents a markup element or tag.
func (*Rules) IsTerminalCallPath ¶ added in v0.9.0
IsTerminalCallPath reports whether calleePath matches an execution-terminating call. The path is a dot-joined identifier (e.g. "os.Exit", "sys.exit", "panic").
func (*Rules) IsType ¶ added in v0.8.0
IsType reports whether nodeType is a type annotation or type expression in the language.
func (*Rules) IsUnordered ¶
IsUnordered checks if child order doesn't matter for this container.