Documentation
¶
Overview ¶
Package extract turns a source file into graph fragments using tree-sitter. Each extractor emits definition nodes (file, function, type, method) plus the structural edges it can see locally (contains, imports). Calls and imports that cross files are recorded raw and stitched together by Resolve, which has the whole-corpus view needed to point a call at the right definition.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Call ¶
type Call struct {
CallerID, Callee, File, Loc string
}
Call is an unresolved call site: CallerID invoked a symbol named Callee.
type Def ¶
type Def struct {
ID, Name, File string
}
Def records a named definition so cross-file calls can resolve to it by name.
type Imp ¶
type Imp struct {
FileID, File, Spec, Loc string
}
Imp is an unresolved import: File imported the module named Spec.
type ModInvoke ¶ added in v0.5.0
ModInvoke carries one `module` block's arguments so Resolve can follow a local wrapper chain. Dir is the invoking directory (its dirScope). Args holds literal scalar/list arguments by name; ArgVarRefs maps an argument name to the bare variable it passes through (`arg = var.<name>`).
type ModRef ¶ added in v0.4.0
type ModRef struct {
FromID, Source, File, Loc string
}
ModRef is a Terraform module block's source before resolution: the module node FromID declared `source = Source` in File. Resolve turns a local source into an edge to the target directory node, and a registry/private-registry source into an external concept node.
type NullLabelRef ¶ added in v0.5.0
type NullLabelRef struct {
NodeID, Scope string
Inputs labelInputs
}
NullLabelRef carries a captured cloudposse null-label module so Resolve can fill in segments that come from input variables or an inherited context. NodeID is the module node; Scope is its directory (used to find the caller); Inputs are the locally-captured label fields.
type Result ¶
type Result struct {
Nodes []model.Node
Edges []model.Edge
Defs []Def
Calls []Call
Imps []Imp
ModRefs []ModRef
NullLabels []NullLabelRef
ModInvokes []ModInvoke
}
Result is one file's extraction before cross-file resolution.
func File ¶
File extracts rel (a path relative to root). Unsupported extensions return an empty result, not an error, so the caller can skip them silently.
func FileFromBytes ¶ added in v0.3.0
FileFromBytes extracts rel from already-read source bytes. It lets callers that have hashed the file (e.g. the incremental cache) avoid a second read. Unsupported extensions return an empty result.