Documentation
¶
Overview ¶
Package language provides language-specific AST analyzers.
Index ¶
- type Base
- func (b Base) BuildModulePathFromPath(filePath, extension string) string
- func (b Base) BuildQualifiedName(modulePath, simpleName string) string
- func (b Base) ExtractFirstChildComment(node *sitter.Node, source []byte) string
- func (b Base) ExtractIdentifier(node *sitter.Node, source []byte) string
- func (b Base) ExtractPrecedingComment(node *sitter.Node, source []byte) string
- func (b Base) Language() slicing.Language
- func (b Base) NodeText(node *sitter.Node, source []byte) string
- func (b Base) Walker() slicing.Walker
- type C
- func (c *C) Classes(tree *sitter.Tree, source []byte) []slicing.ClassDefinition
- func (c *C) Docstring(node *sitter.Node, source []byte) string
- func (c *C) ExtractParameters(node *sitter.Node, source []byte) []string
- func (c *C) ExtractReturnType(node *sitter.Node, source []byte) string
- func (c *C) FunctionName(node *sitter.Node, source []byte) string
- func (c *C) IsMethod(_ *sitter.Node) bool
- func (c *C) IsPublic(_ *sitter.Node, _ string, _ []byte) bool
- func (c *C) ModulePath(file slicing.ParsedFile) string
- func (c *C) Types(tree *sitter.Tree, source []byte) []slicing.TypeDefinition
- type CPP
- type CSharp
- func (cs *CSharp) Classes(tree *sitter.Tree, source []byte) []slicing.ClassDefinition
- func (cs *CSharp) Docstring(node *sitter.Node, source []byte) string
- func (cs *CSharp) FunctionName(node *sitter.Node, source []byte) string
- func (cs *CSharp) IsMethod(node *sitter.Node) bool
- func (cs *CSharp) IsPublic(_ *sitter.Node, _ string, _ []byte) bool
- func (cs *CSharp) ModulePath(file slicing.ParsedFile) string
- func (cs *CSharp) Types(_ *sitter.Tree, _ []byte) []slicing.TypeDefinition
- type Factory
- type Go
- func (g *Go) Classes(_ *sitter.Tree, _ []byte) []slicing.ClassDefinition
- func (g *Go) Docstring(node *sitter.Node, source []byte) string
- func (g *Go) ExtractParameters(node *sitter.Node, source []byte) []string
- func (g *Go) ExtractReceiver(node *sitter.Node, source []byte) string
- func (g *Go) ExtractReturnType(node *sitter.Node, source []byte) string
- func (g *Go) FunctionName(node *sitter.Node, source []byte) string
- func (g *Go) IsMethod(node *sitter.Node) bool
- func (g *Go) IsPublic(_ *sitter.Node, name string, _ []byte) bool
- func (g *Go) ModulePath(file slicing.ParsedFile) string
- func (g *Go) Types(tree *sitter.Tree, source []byte) []slicing.TypeDefinition
- type Java
- func (j *Java) Classes(tree *sitter.Tree, source []byte) []slicing.ClassDefinition
- func (j *Java) Docstring(node *sitter.Node, source []byte) string
- func (j *Java) FunctionName(node *sitter.Node, source []byte) string
- func (j *Java) IsMethod(_ *sitter.Node) bool
- func (j *Java) IsPublic(_ *sitter.Node, _ string, _ []byte) bool
- func (j *Java) ModulePath(file slicing.ParsedFile) string
- func (j *Java) Types(_ *sitter.Tree, _ []byte) []slicing.TypeDefinition
- type JavaScript
- func (j *JavaScript) Classes(tree *sitter.Tree, source []byte) []slicing.ClassDefinition
- func (j *JavaScript) Docstring(node *sitter.Node, source []byte) string
- func (j *JavaScript) FunctionName(node *sitter.Node, source []byte) string
- func (j *JavaScript) IsMethod(node *sitter.Node) bool
- func (j *JavaScript) IsPublic(_ *sitter.Node, _ string, _ []byte) bool
- func (j *JavaScript) ModulePath(file slicing.ParsedFile) string
- func (j *JavaScript) Types(_ *sitter.Tree, _ []byte) []slicing.TypeDefinition
- type Python
- func (p *Python) Classes(tree *sitter.Tree, source []byte) []slicing.ClassDefinition
- func (p *Python) Docstring(node *sitter.Node, source []byte) string
- func (p *Python) FunctionName(node *sitter.Node, source []byte) string
- func (p *Python) IsMethod(_ *sitter.Node) bool
- func (p *Python) IsPublic(_ *sitter.Node, name string, _ []byte) bool
- func (p *Python) ModulePath(file slicing.ParsedFile) string
- func (p *Python) Types(_ *sitter.Tree, _ []byte) []slicing.TypeDefinition
- type Rust
- func (r *Rust) Classes(tree *sitter.Tree, source []byte) []slicing.ClassDefinition
- func (r *Rust) Docstring(node *sitter.Node, source []byte) string
- func (r *Rust) FunctionName(node *sitter.Node, source []byte) string
- func (r *Rust) IsMethod(node *sitter.Node) bool
- func (r *Rust) IsPublic(_ *sitter.Node, _ string, _ []byte) bool
- func (r *Rust) ModulePath(file slicing.ParsedFile) string
- func (r *Rust) Types(tree *sitter.Tree, source []byte) []slicing.TypeDefinition
- type TypeScript
- func (t *TypeScript) ExtractJSXReturns(node *sitter.Node, source []byte) []string
- func (t *TypeScript) ExtractTypeReferences(node *sitter.Node, source []byte) []string
- func (t *TypeScript) ModulePath(file slicing.ParsedFile) string
- func (t *TypeScript) Types(tree *sitter.Tree, source []byte) []slicing.TypeDefinition
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Base ¶
type Base struct {
// contains filtered or unexported fields
}
Base provides common analyzer functionality.
func (Base) BuildModulePathFromPath ¶
BuildModulePathFromPath builds a module path from a file path.
func (Base) BuildQualifiedName ¶
BuildQualifiedName builds a qualified name from module path and simple name.
func (Base) ExtractFirstChildComment ¶
ExtractFirstChildComment extracts the first child comment/string (for Python docstrings).
func (Base) ExtractIdentifier ¶
ExtractIdentifier extracts an identifier from a node using the language's name field.
func (Base) ExtractPrecedingComment ¶
ExtractPrecedingComment extracts comment text from nodes preceding the given node.
type C ¶
type C struct {
Base
}
C implements Analyzer for C code.
func (*C) ExtractParameters ¶
ExtractParameters extracts function parameters.
func (*C) ExtractReturnType ¶
ExtractReturnType extracts the return type from a function.
func (*C) FunctionName ¶
FunctionName extracts the function name from a function_definition node.
func (*C) ModulePath ¶
func (c *C) ModulePath(file slicing.ParsedFile) string
ModulePath builds the module path from file information.
type CPP ¶
type CPP struct {
C
}
CPP implements Analyzer for C++ code.
func (*CPP) ModulePath ¶
func (c *CPP) ModulePath(file slicing.ParsedFile) string
ModulePath builds the module path from file information.
type CSharp ¶
type CSharp struct {
Base
}
CSharp implements Analyzer for C# code.
func (*CSharp) FunctionName ¶
FunctionName extracts the method name from a method_declaration node.
func (*CSharp) ModulePath ¶
func (cs *CSharp) ModulePath(file slicing.ParsedFile) string
ModulePath builds the module path from namespace declaration.
type Factory ¶
type Factory struct {
// contains filtered or unexported fields
}
Factory creates language-specific analyzers.
func NewFactory ¶
func NewFactory(config slicing.LanguageConfig) *Factory
NewFactory creates a new Factory.
func (*Factory) ByExtension ¶
ByExtension returns an analyzer for the specified file extension.
type Go ¶
type Go struct {
Base
}
Go implements Analyzer for Go code.
func (*Go) ExtractParameters ¶
ExtractParameters extracts function parameters.
func (*Go) ExtractReceiver ¶
ExtractReceiver extracts the receiver type from a method declaration.
func (*Go) ExtractReturnType ¶
ExtractReturnType extracts the return type from a function.
func (*Go) FunctionName ¶
FunctionName extracts the function name from a function or method declaration.
func (*Go) ModulePath ¶
func (g *Go) ModulePath(file slicing.ParsedFile) string
ModulePath builds the module path from file information (package name).
type Java ¶
type Java struct {
Base
}
Java implements Analyzer for Java code.
func (*Java) FunctionName ¶
FunctionName extracts the method name from a method_declaration node.
func (*Java) IsMethod ¶
IsMethod returns false for Java (methods are handled within class extraction).
func (*Java) IsPublic ¶
IsPublic always returns true for Java (we treat all methods as public for indexing).
func (*Java) ModulePath ¶
func (j *Java) ModulePath(file slicing.ParsedFile) string
ModulePath builds the module path from package declaration.
type JavaScript ¶
type JavaScript struct {
Base
}
JavaScript implements Analyzer for JavaScript code.
func NewJavaScript ¶
func NewJavaScript(language slicing.Language) *JavaScript
NewJavaScript creates a new JavaScript analyzer.
func (*JavaScript) Classes ¶
func (j *JavaScript) Classes(tree *sitter.Tree, source []byte) []slicing.ClassDefinition
Classes extracts class definitions from the AST.
func (*JavaScript) Docstring ¶
func (j *JavaScript) Docstring(node *sitter.Node, source []byte) string
Docstring extracts JSDoc comments preceding a function.
func (*JavaScript) FunctionName ¶
func (j *JavaScript) FunctionName(node *sitter.Node, source []byte) string
FunctionName extracts the function name from various function nodes.
func (*JavaScript) IsMethod ¶
func (j *JavaScript) IsMethod(node *sitter.Node) bool
IsMethod returns true if the node is a method_definition.
func (*JavaScript) IsPublic ¶
IsPublic always returns true for JavaScript (no private convention in standard JS).
func (*JavaScript) ModulePath ¶
func (j *JavaScript) ModulePath(file slicing.ParsedFile) string
ModulePath builds the module path from file information.
func (*JavaScript) Types ¶
func (j *JavaScript) Types(_ *sitter.Tree, _ []byte) []slicing.TypeDefinition
Types returns nil for JavaScript (no type definitions in vanilla JS).
type Python ¶
type Python struct {
Base
}
Python implements Analyzer for Python code.
func (*Python) FunctionName ¶
FunctionName extracts the function name from a function_definition node.
func (*Python) IsMethod ¶
IsMethod returns false for Python (methods are extracted within class walk).
func (*Python) IsPublic ¶
IsPublic returns true if the function name does not start with underscore.
func (*Python) ModulePath ¶
func (p *Python) ModulePath(file slicing.ParsedFile) string
ModulePath builds the module path from file information.
type Rust ¶
type Rust struct {
Base
}
Rust implements Analyzer for Rust code.
func (*Rust) FunctionName ¶
FunctionName extracts the function name from a function_item node.
func (*Rust) ModulePath ¶
func (r *Rust) ModulePath(file slicing.ParsedFile) string
ModulePath builds the module path from file information.
type TypeScript ¶
type TypeScript struct {
JavaScript
// contains filtered or unexported fields
}
TypeScript implements Analyzer for TypeScript code.
func NewTypeScript ¶
func NewTypeScript(language slicing.Language) *TypeScript
NewTypeScript creates a new TypeScript analyzer.
func (*TypeScript) ExtractJSXReturns ¶
func (t *TypeScript) ExtractJSXReturns(node *sitter.Node, source []byte) []string
ExtractJSXReturns extracts JSX return statements (for TSX).
func (*TypeScript) ExtractTypeReferences ¶
func (t *TypeScript) ExtractTypeReferences(node *sitter.Node, source []byte) []string
ExtractTypeReferences extracts type names referenced in a node.
func (*TypeScript) ModulePath ¶
func (t *TypeScript) ModulePath(file slicing.ParsedFile) string
ModulePath builds the module path from file information.
func (*TypeScript) Types ¶
func (t *TypeScript) Types(tree *sitter.Tree, source []byte) []slicing.TypeDefinition
Types extracts type definitions from the AST.