Documentation
¶
Index ¶
- func BuildTypedCallGraph(dir string) (*callgraph.CallGraph, error)
- func BuildTypedCallGraphWithOptions(dir string, opts BuildOptions) (*callgraph.CallGraph, error)
- func CalculateCouplingScore(calls []CallInfo, allResults []*processor.Result) float64
- type BuildOptions
- type CallInfo
- type CallVisitor
- type Processor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildTypedCallGraph ¶
BuildTypedCallGraph loads the Go module rooted at dir and constructs a call graph using full type information. Unlike the AST-only path, callees are resolved to their declared functions/methods, so a call such as scanner.Scan() and the declared func Scan share a single node, and standard library / third-party calls are identified precisely rather than by name.
It returns an error (so callers can fall back to the AST graph) when the module cannot be loaded or type-checked.
func BuildTypedCallGraphWithOptions ¶ added in v0.0.2
func BuildTypedCallGraphWithOptions(dir string, opts BuildOptions) (*callgraph.CallGraph, error)
BuildTypedCallGraphWithOptions is BuildTypedCallGraph with diagnostic instrumentation controlled by opts.
Types ¶
type BuildOptions ¶ added in v0.0.2
type BuildOptions struct {
// Logf, when non-nil, receives phase-level progress and timing messages
// (package load time, package counts, per-package walk timing, final tallies)
// — useful for understanding why the build is slow on a large repo.
Logf func(format string, args ...any)
// PerPackage, when true, logs per-package walk timing and counts via Logf.
PerPackage bool
// TracePackages, when true, routes go/packages driver logging through Logf.
// This surfaces every underlying `go list` invocation and its timing, which
// is the most granular view of where the type-checking phase spends time.
TracePackages bool
}
BuildOptions controls diagnostic instrumentation for the typed call-graph build. The zero value is silent and behaves exactly like the original build.
type CallInfo ¶
type CallInfo struct {
CallerName string // The name of the code that makes the call (e.g., "append")
CalleeName string // The name/function being called
File string // Source file path where call occurs
Line int // Line number in source
Column int // Column number in source
ParentFunc string // Name of function/method containing this call (e.g., "Process")
}
CallInfo contains information about a function call.
type CallVisitor ¶
type CallVisitor struct {
Calls map[string][]CallInfo // Map of callee name to list of CallInfo
// contains filtered or unexported fields
}
CallVisitor traverses Go AST nodes and identifies all function calls.
func NewCallVisitor ¶
func NewCallVisitor() *CallVisitor
NewCallVisitor creates a new CallVisitor instance.
func NewCallVisitorWithFileSet ¶
func NewCallVisitorWithFileSet(fset *token.FileSet) *CallVisitor
NewCallVisitorWithFileSet creates a new CallVisitor with a specific FileSet.
type Processor ¶
type Processor struct {
ExcludeGenerated bool
}
Processor implements processor.Processor for Go source files.