Documentation
¶
Overview ¶
Package shared provides common utilities for analyzer implementations. This package is separate from the main analyzer package to avoid import cycles when subdirectory packages need these utilities.
Index ¶
- func AnalyzeDirectoryDepth(files []*parser.ParsedTreeSitterFile, rootDir string) (maxDepth int, avgDepth float64)
- func CountLines(content []byte) int
- func FilterTreeSitterFiles(files []*parser.ParsedTreeSitterFile, isTest func(relPath string) bool) []*parser.ParsedTreeSitterFile
- func IsTestFileByPath(path string) bool
- func NodeText(node *tree_sitter.Node, content []byte) string
- func TsIsTestFile(path string) bool
- func TsStripQuotes(s string) string
- func WalkTree(node *tree_sitter.Node, fn func(*tree_sitter.Node))
- type ImportGraph
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AnalyzeDirectoryDepth ¶ added in v0.0.8
func AnalyzeDirectoryDepth(files []*parser.ParsedTreeSitterFile, rootDir string) (maxDepth int, avgDepth float64)
AnalyzeDirectoryDepth computes max and average directory depth from tree-sitter file paths. Used by C3 architecture analyzers for Python and TypeScript.
func FilterTreeSitterFiles ¶ added in v0.0.8
func FilterTreeSitterFiles(files []*parser.ParsedTreeSitterFile, isTest func(relPath string) bool) []*parser.ParsedTreeSitterFile
FilterTreeSitterFiles returns files for which isTest(relPath) is false. Used by C1 and C3 analyzers to strip test files before source analysis.
func IsTestFileByPath ¶
IsTestFileByPath checks if a file path indicates a Python test file. Used by C6 testing analyzer.
func NodeText ¶
func NodeText(node *tree_sitter.Node, content []byte) string
NodeText extracts the text content of a Tree-sitter node.
func TsIsTestFile ¶
TsIsTestFile checks if a TypeScript file path indicates a test file. Used by C6 testing analyzer.
func TsStripQuotes ¶
TsStripQuotes removes surrounding quotes from a string literal. Used by C6 testing analyzer.
func WalkTree ¶
func WalkTree(node *tree_sitter.Node, fn func(*tree_sitter.Node))
WalkTree walks a Tree-sitter tree depth-first, calling fn for each node.
Types ¶
type ImportGraph ¶
type ImportGraph struct {
Forward map[string][]string // package -> packages it imports (efferent)
Reverse map[string][]string // package -> packages that import it (afferent)
}
ImportGraph holds forward and reverse adjacency lists for intra-module imports.
func BuildImportGraph ¶
func BuildImportGraph(pkgs []*parser.ParsedPackage, modulePath string) *ImportGraph
BuildImportGraph constructs an import graph from parsed packages, filtering to only intra-module imports (those with the given module path prefix).