Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComputeMaxBranching ¶
func ComputeMaxBranching(root *tree_sitter.Node) int
ComputeMaxBranching finds the maximum branching factor of any decision point in the file. A 40-case switch/match has branching factor 40.
func ComputeMaxNestingDepth ¶
func ComputeMaxNestingDepth(root *tree_sitter.Node) int
ComputeMaxNestingDepth walks the AST to find the maximum nesting depth.
func ComputeNodeDiversity ¶
func ComputeNodeDiversity(root *tree_sitter.Node) int
ComputeNodeDiversity counts the number of distinct AST node types in the tree. Files with more distinct types have more varied structure (complex control flow, mixed patterns). Files with fewer types are repetitive (catalogs, registries). Validated against SWE-bench: partial r=+0.165 controlling for file size, median +0.474 per-repo, positive on 29/29 repos.
Types ¶
type Definition ¶
type Definition struct {
Name string // Short name: "_validate"
QualifiedName string // Class-qualified: "MyClass._validate"
Kind string // "function" | "method" | "class" | "constant" | "type"
Line int
EndLine int // last line of the definition (0 if unknown)
ParamCount int // number of parameters (excluding self/cls/receiver)
}
Definition is a named symbol defined in a file.
type FileAnalysis ¶
type FileAnalysis struct {
Path string
Lines int
MaxNestingDepth int // deepest control flow / scope nesting
NodeDiversity int // count of distinct AST node types
MaxBranching int // largest branching factor (switch/match cases)
Definitions []Definition
Imports []Import
}
FileAnalysis is the result of parsing a single file.
type Frontend ¶
type Frontend interface {
// Extensions returns file extensions this frontend handles (e.g. [".py"]).
Extensions() []string
// Analyze parses a source file and extracts definitions and imports.
Analyze(path string, src []byte) (*FileAnalysis, error)
}
Frontend parses source files for a specific language.
type GoFrontend ¶
type GoFrontend struct {
// contains filtered or unexported fields
}
GoFrontend extracts definitions and imports from Go files.
func NewGoFrontend ¶
func NewGoFrontend() *GoFrontend
func (*GoFrontend) Analyze ¶
func (f *GoFrontend) Analyze(path string, src []byte) (*FileAnalysis, error)
func (*GoFrontend) Extensions ¶
func (f *GoFrontend) Extensions() []string
type Import ¶
type Import struct {
Name string // Imported symbol name
SourceModule string // Module path (relative or absolute)
Kind string // "constant" | "function" | "type" | "unknown"
Line int
}
Import is a symbol imported from another module.
type PythonFrontend ¶
type PythonFrontend struct {
// contains filtered or unexported fields
}
PythonFrontend extracts definitions and imports from Python files.
func NewPythonFrontend ¶
func NewPythonFrontend() *PythonFrontend
func (*PythonFrontend) Analyze ¶
func (f *PythonFrontend) Analyze(path string, src []byte) (*FileAnalysis, error)
func (*PythonFrontend) Extensions ¶
func (f *PythonFrontend) Extensions() []string
type TypeScriptFrontend ¶
type TypeScriptFrontend struct {
// contains filtered or unexported fields
}
TypeScriptFrontend extracts definitions and imports from TypeScript/TSX files.
func NewTypeScriptFrontend ¶
func NewTypeScriptFrontend() *TypeScriptFrontend
func (*TypeScriptFrontend) Analyze ¶
func (f *TypeScriptFrontend) Analyze(path string, src []byte) (*FileAnalysis, error)
func (*TypeScriptFrontend) Extensions ¶
func (f *TypeScriptFrontend) Extensions() []string