Documentation
¶
Index ¶
- Variables
- func FindNodes(root *sitter.Node, source []byte, predicate func(*sitter.Node) bool) []*sitter.Node
- func FindNodesByType(root *sitter.Node, source []byte, nodeType string) []*sitter.Node
- func GetNodeText(node *sitter.Node, source []byte) string
- func GetTreeSitterLanguage(lang Language) (*sitter.Language, error)
- func Walk(node *sitter.Node, source []byte, visitor NodeVisitor)
- func WalkTyped(node *sitter.Node, source []byte, visitor TypedNodeVisitor)
- type ClassNode
- type FunctionNode
- type Language
- type NodeVisitor
- type ParseResult
- type Parser
- type TypedNodeVisitor
Constants ¶
This section is empty.
Variables ¶
var ErrFileTooLarge = fmt.Errorf("file too large")
ErrFileTooLarge is returned when a file exceeds the maximum size limit.
Functions ¶
func FindNodesByType ¶
FindNodesByType returns all nodes of a specific type.
func GetNodeText ¶
GetNodeText extracts the source text for a node. Returns empty string if node is nil or byte offsets are out of bounds.
func GetTreeSitterLanguage ¶
GetTreeSitterLanguage returns the tree-sitter language for a Language enum.
Types ¶
type ClassNode ¶
type ClassNode struct {
Name string
StartLine uint32
EndLine uint32
Methods []FunctionNode
}
ClassNode represents a parsed class/struct.
func GetClasses ¶
func GetClasses(result *ParseResult) []ClassNode
GetClasses extracts all class definitions from parsed code.
type FunctionNode ¶
type FunctionNode struct {
Name string
StartLine uint32
EndLine uint32
Parameters []string
Body *sitter.Node
}
FunctionNode represents a parsed function.
func GetFunctions ¶
func GetFunctions(result *ParseResult) []FunctionNode
GetFunctions extracts all function definitions from parsed code.
type Language ¶
type Language string
Language represents a supported programming language.
const ( LangGo Language = "go" LangRust Language = "rust" LangPython Language = "python" LangTypeScript Language = "typescript" LangJavaScript Language = "javascript" LangTSX Language = "tsx" LangJava Language = "java" LangC Language = "c" LangCPP Language = "cpp" LangCSharp Language = "csharp" LangRuby Language = "ruby" LangPHP Language = "php" LangBash Language = "bash" LangUnknown Language = "unknown" )
func DetectLanguage ¶
DetectLanguage determines the language from a file path.
type NodeVisitor ¶
NodeVisitor is a function that visits AST nodes.
type ParseResult ¶
ParseResult contains the parsed AST and metadata.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser wraps tree-sitter for multi-language parsing.
func (*Parser) ParseFile ¶
func (p *Parser) ParseFile(path string) (*ParseResult, error)
ParseFile parses a source file and returns the AST.
func (*Parser) ParseFileWithLimit ¶
func (p *Parser) ParseFileWithLimit(path string, maxSize int64) (*ParseResult, error)
ParseFileWithLimit parses a source file with a maximum size limit. If maxSize is 0, no limit is enforced.