Documentation
¶
Overview ¶
Package lang provides a language registry mapping file extensions to tree-sitter languages and their embedded query files.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Languages = map[string]*Language{}
Languages maps language names to their configuration. Populated by init() functions in per-language files.
Functions ¶
func CollapseWhitespace ¶
CollapseWhitespace replaces runs of whitespace with a single space and trims.
func ForExtension ¶
ForExtension returns the language name for a file extension, or "" if unsupported.
Types ¶
type Language ¶
type Language struct {
Name string
Extensions []string
// FindMethodClass returns the enclosing class name if a @definition.function
// is actually a method (Python/Ruby style). Returns "" if not a method.
FindMethodClass func(node *sitter.Node, source []byte) string
// FindReceiverType returns the receiver type name for a @definition.method
// node (Go style). Returns "" if not applicable.
FindReceiverType func(node *sitter.Node, source []byte) string
// ExtractSignature returns a signature string for a definition node.
ExtractSignature func(node *sitter.Node, kind model.SymbolKind, source []byte) string
// FindEnclosingDef returns the qualified name of the enclosing function/method
// for a call-site node (e.g., "MyType.Method" or "funcName").
// Returns "" if the call is at top-level or inside an anonymous function.
FindEnclosingDef func(node *sitter.Node, source []byte) string
// FindEnclosingType returns the type name that owns a field/member node
// (e.g. the struct or class containing a field declaration). Returns ""
// if the node is not inside a named type definition.
FindEnclosingType func(node *sitter.Node, source []byte) string
// contains filtered or unexported fields
}
Language holds tree-sitter configuration for a supported language.
func (*Language) GetLanguage ¶
GetLanguage returns the tree-sitter Language pointer.
func (*Language) GetTagQuery ¶
GetTagQuery returns the compiled tree-sitter query (safe to share across goroutines).
Click to show internal directories.
Click to hide internal directories.