Documentation
¶
Overview ¶
Package treesitter provides Tree-sitter based parser implementations.
Index ¶
Constants ¶
const ( CaptureName = "name" CaptureSignature = "signature" CaptureDoc = "doc" CaptureKind = "kind" )
Capture names used across all language queries.
const ( CaptureImportPath = "import_path" // CaptureLuaRequireFn captures the function name in a Lua function-call import pattern // (e.g., Lua's require()). Used for Go-side filtering when tree-sitter predicates // (such as #eq?) are not evaluated by the binding at runtime. CaptureLuaRequireFn = "_fn" )
Capture names for import queries.
const (
CaptureCallee = "callee"
)
Capture names for call queries.
Variables ¶
var DefaultKindMapping = map[string]string{
"function_declaration": "function",
"method_declaration": "method",
"type_declaration": "type",
"struct_type": "struct",
"interface_type": "interface",
"class_declaration": "class",
"arrow_function": "function",
"function_expression": "function",
"method_definition": "method",
}
DefaultKindMapping provides default kind mappings (can be overridden per language).
Functions ¶
This section is empty.
Types ¶
type LanguageQuery ¶
type LanguageQuery interface {
// Language returns the Tree-sitter language for parsing.
Language() *sitter.Language
// Query returns the Tree-sitter query pattern for signature extraction.
Query() []byte
// ImportQuery returns the Tree-sitter query pattern for import/export extraction.
// Returns nil if the language doesn't support import extraction.
ImportQuery() []byte
// CallQuery returns the Tree-sitter query pattern for function call extraction.
// Returns nil if the language doesn't support call extraction.
CallQuery() []byte
// Captures returns the list of capture names used in the query.
Captures() []string
// KindMapping maps Tree-sitter node types to Signature kinds.
KindMapping() map[string]string
// IsExported reports whether the symbol identified by name and sigText
// is public/exported in the given language. sigText is the full
// signature text which may contain visibility modifiers.
IsExported(name, sigText string) bool
}
LanguageQuery defines the interface for language-specific Tree-sitter queries.
type TreeSitterParser ¶
type TreeSitterParser struct {
// contains filtered or unexported fields
}
TreeSitterParser implements parser.Parser using Tree-sitter.
func NewTreeSitterParser ¶
func NewTreeSitterParser() *TreeSitterParser
NewTreeSitterParser creates a new Tree-sitter based parser.
func (*TreeSitterParser) Close ¶ added in v0.21.0
func (p *TreeSitterParser) Close()
Close releases all cached Tree-sitter Query objects. This should be called when the parser is no longer needed, especially in long-running processes like brfit-mcp.
func (*TreeSitterParser) Languages ¶
func (p *TreeSitterParser) Languages() []string
Languages returns the list of supported languages.
func (*TreeSitterParser) Parse ¶
func (p *TreeSitterParser) Parse(content []byte, opts *parser.Options) (result *parser.ParseResult, err error)
Parse parses the given content and returns extracted signatures.
Directories
¶
| Path | Synopsis |
|---|---|
|
grammars
|
|
|
csharp
Package csharp provides the tree-sitter grammar for C#.
|
Package csharp provides the tree-sitter grammar for C#. |
|
elixir
Package elixir provides the tree-sitter grammar for Elixir.
|
Package elixir provides the tree-sitter grammar for Elixir. |
|
kotlin
Package kotlin provides the tree-sitter grammar for Kotlin.
|
Package kotlin provides the tree-sitter grammar for Kotlin. |
|
lua
Package lua provides the tree-sitter grammar for Lua.
|
Package lua provides the tree-sitter grammar for Lua. |
|
scala
Package scala provides the tree-sitter grammar for Scala.
|
Package scala provides the tree-sitter grammar for Scala. |
|
sql
Package sql provides the tree-sitter grammar for SQL.
|
Package sql provides the tree-sitter grammar for SQL. |
|
swift
Package swift provides the tree-sitter grammar for Swift.
|
Package swift provides the tree-sitter grammar for Swift. |
|
toml
Package toml provides the tree-sitter grammar for TOML.
|
Package toml provides the tree-sitter grammar for TOML. |
|
yaml
Package yaml provides the tree-sitter grammar for YAML.
|
Package yaml provides the tree-sitter grammar for YAML. |
|
Package languages provides language-specific Tree-sitter queries.
|
Package languages provides language-specific Tree-sitter queries. |