Repository navigation
Commit a9d7a96
committed
feat(infra): a Terraform reference USAGEs the block of its module declaring it
Terraform references were resolved by the generic name matcher: by their
last name segment, across the whole repository. `format()` CALLS a
variable named format of another module, `local.x` meets a resource named
local, `.id` an output id anywhere. Measured on the 7 Terraform
repositories of 17 infrastructure corpora: 12,437 edges, recall 0.63 and
precision 0.39 against an independent reading of the references, and not
one of them left the block holding its reference.
A reference -- var.X, local.X, module.X, data.T.N, T.N -- now USAGEs
{ref, via: terraform, line}, from the top-level block holding it, the
block declaring it in the same module: the .tf / .tofu files of its
directory (a locals entry: its locals block); an entry of the block's
depends_on list DEPENDS_ON the object instead. The generic matcher makes
no edge for a .tf / .tofu file any more; a name only mentioned in string
text is no reference, nor is a block's reference to itself. A changed
file re-resolves its whole directory, so an unchanged file's reference
meets the declaration a change adds and loses the one it removes.
A bare block label (`variable region {}`, valid HCL) now names its block
like a quoted one; such blocks used to share the keyword's name and QN.
Measured: 7,771 of 7,771 file-level and 13,397 of 13,397 block-level
reference pairs (edge type included) and nothing else; the 10 other
corpora are unchanged; deterministic over three runs; the incremental
re-index equals a full index in 7 scenarios (rename a variable, a module,
a locals entry; delete the variables file; add a file; add a declaration
an unchanged file references; quote a bare label); index time unchanged
(within 1 % on the four largest Terraform corpora).
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>1 parent e58c5ba commit a9d7a96
10 files changed
Lines changed: 541 additions & 27 deletions
File tree
- internal/cbm
- src/pipeline
- tests
- fixtures/complexity/HCL
- repro
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
256 | 256 | | |
257 | 257 | | |
258 | 258 | | |
| 259 | + | |
259 | 260 | | |
260 | 261 | | |
261 | 262 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7192 | 7192 | | |
7193 | 7193 | | |
7194 | 7194 | | |
7195 | | - | |
| 7195 | + | |
| 7196 | + | |
| 7197 | + | |
7196 | 7198 | | |
7197 | 7199 | | |
7198 | 7200 | | |
7199 | | - | |
7200 | | - | |
7201 | | - | |
7202 | | - | |
7203 | | - | |
7204 | | - | |
| 7201 | + | |
| 7202 | + | |
| 7203 | + | |
| 7204 | + | |
| 7205 | + | |
| 7206 | + | |
7205 | 7207 | | |
7206 | | - | |
7207 | 7208 | | |
7208 | 7209 | | |
7209 | 7210 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2634 | 2634 | | |
2635 | 2635 | | |
2636 | 2636 | | |
| 2637 | + | |
| 2638 | + | |
| 2639 | + | |
| 2640 | + | |
| 2641 | + | |
| 2642 | + | |
2637 | 2643 | | |
2638 | 2644 | | |
2639 | 2645 | | |
| |||
2659 | 2665 | | |
2660 | 2666 | | |
2661 | 2667 | | |
2662 | | - | |
2663 | | - | |
| 2668 | + | |
| 2669 | + | |
| 2670 | + | |
| 2671 | + | |
| 2672 | + | |
2664 | 2673 | | |
2665 | 2674 | | |
2666 | 2675 | | |
| |||
0 commit comments