Motivation
A language server's definitions, references, rename, and completion; an explainer's "where does this atom come from"; a REPL's introspection. All ask the same question: for a signature, where does it occur and in what role. DependencyGraph already visits every occurrence to build its edges and then discards the positions, so the fact is computed today and not reported.
This is the analysis-level occurrence: per predicate signature, across a whole Program. It is distinct from the per-statement raise occurrences of #1, which it can be built over.
Proposed surface, in themelios-analysis
A pure, total reading of a Program yielding, per Signature, its occurrences in source order. Each occurrence carries the WithProvenance node it was read from and a role drawn from a closed enumeration: head literal; positive body literal; default-negated body literal; condition; aggregate element; and one variant per declaring directive (#show, #external, #defined, #project, #heuristic). The existing DependencyKind distinguishes positive from negative body dependence and should be reused rather than mirrored.
Cost
One walk: O(program) time and space. Owned plain data (Send + Sync + 'static), as everywhere in the tier.
Laws to state
- Every edge of
DependencyGraph is witnessed by a head occurrence and a body occurrence of its two signatures.
- Equality over the occurrence set is provenance-blind, as everywhere in the tier.
- A program recovered from a malformed parse yields occurrences for what was raised; never a panic.
Extends
analysis.md §4, beside the dependency graph, whose construction it shares.
Motivation
A language server's definitions, references, rename, and completion; an explainer's "where does this atom come from"; a REPL's introspection. All ask the same question: for a signature, where does it occur and in what role.
DependencyGraphalready visits every occurrence to build its edges and then discards the positions, so the fact is computed today and not reported.This is the analysis-level occurrence: per predicate signature, across a whole
Program. It is distinct from the per-statement raise occurrences of #1, which it can be built over.Proposed surface, in
themelios-analysisA pure, total reading of a
Programyielding, perSignature, its occurrences in source order. Each occurrence carries theWithProvenancenode it was read from and a role drawn from a closed enumeration: head literal; positive body literal; default-negated body literal; condition; aggregate element; and one variant per declaring directive (#show,#external,#defined,#project,#heuristic). The existingDependencyKinddistinguishes positive from negative body dependence and should be reused rather than mirrored.Cost
One walk: O(program) time and space. Owned plain data (
Send + Sync + 'static), as everywhere in the tier.Laws to state
DependencyGraphis witnessed by a head occurrence and a body occurrence of its two signatures.Extends
analysis.md §4, beside the dependency graph, whose construction it shares.