Documentation
¶
Overview ¶
Package ts is the shared tree-sitter parse + capture helper used by per-language analyzers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Parse ¶
func Parse( ctx context.Context, psr *treesitter.Parser, dirFS fs.FS, path string, ) (*treesitter.Tree, []byte, error)
Parse reads path from dirFS and parses it with psr, returning the syntax tree and the file contents.
func Query ¶
func Query( _ context.Context, _ *treesitter.Parser, language *treesitter.Language, _ *treesitter.Tree, _ []byte, query string, ) (*treesitter.Query, *treesitter.QueryCursor, error)
Query compiles query for language and returns the compiled query together with a fresh query cursor.
Types ¶
type CapturePair ¶
type CapturePair struct {
CaptureName string
NodeStr string
StartRow uint
StartCol uint
EndRow uint
EndCol uint
}
CapturePair is a single tree-sitter capture: its name, text, and source span.
func ProcessCaptures ¶
func ProcessCaptures( ctx context.Context, match *treesitter.QueryMatch, captureNames []string, text []byte, ) []CapturePair
ProcessCaptures converts a single match's captures into CapturePairs.
func ProcessMatches ¶
func ProcessMatches( ctx context.Context, matches treesitter.QueryMatches, captureNames []string, text []byte, ) []CapturePair
ProcessMatches flattens all matches into a single slice of CapturePair.
Click to show internal directories.
Click to hide internal directories.