Class IrReport
java.lang.Object
com.darkcollective.relix.semantic.internal.IrReport
Produces a concise human-readable IR report from a
SemanticModel.
The report is plain UTF-8 text (no BOM), at most 80 characters wide per line, and contains these sections:
- Header — namespace and key for all codes used.
- Symbols — every registered symbol, sorted alphabetically, with its kind code and schema/signature.
- Relationships — the schema graph's edges, one line per relationship with its endpoints, any non-default bounds, and an origin tag for non-declared edges. Omitted entirely when the graph is empty, so pre-existing reports are unchanged.
- Expression Trees — one indented ASCII tree per named
view (
QueryRelationSymbol), rendered in alphabetical order. - Root Queries — the ordered
querystatements from the root file; inline expression queries expand their tree.
Code keys
kind: SRC=source INL=inline SYS=system QR=view DB=database
FN=function TVF=table-fn LIT=truth-literal
type: N=number S=string B=boolean ?=any [x]=array {…}=struct
D=date T=time TS=timestamp DUR=duration
mat: [bag]=bag [set]=dedup-set [sort]=sorted (stream=no label)
Materialisation tags ([bag], [set], [sort]) are
appended to the node label in expression trees for operators that must
accumulate all rows before emitting output. Streaming operators carry no
tag. See MaterializationMode for the
full mapping.
Lines that would exceed 80 characters are truncated with
a trailing ….
Usage
SemanticResult result = analyzer.analyze("script.relix");
result.model().ifPresent(m -> System.out.print(IrReport.generate(m)));
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic Stringgenerate(SemanticModel model) Generates the IR report formodeland returns it as a UTF-8 string.static StringgenerateFocused(SemanticModel model, Set<String> focus) Generates a focused IR report restricted to the relations named infocus— used by interactive tooling (the REPL:treecommand) where the user names a single query and expects to see only its tree and the relations it actually uses, not every symbol in the script.referencedRelations(RelNode root) Collects the names of everyRelationNodeleaf reachable fromroot.
-
Field Details
-
WIDTH
public static final int WIDTHMaximum line width (characters).- See Also:
-
-
Method Details
-
generate
Generates the IR report formodeland returns it as a UTF-8 string. No BOM is included.- Parameters:
model- the semantic model to report on; must not be null- Returns:
- the formatted report; never null or empty
-
generateFocused
Generates a focused IR report restricted to the relations named infocus— used by interactive tooling (the REPL:treecommand) where the user names a single query and expects to see only its tree and the relations it actually uses, not every symbol in the script.The SYMBOLS and EXPRESSION TREES sections include only relations whose
declared nameis infocus(matched case-insensitively). Non-relation symbols (functions) are always omitted. The ROOT QUERIES section is unchanged — it already contains only the query the user asked about.- Parameters:
model- the semantic model to report on; must not be nullfocus- the set of relation names to include; must not be null- Returns:
- the formatted report; never null or empty
-
referencedRelations
Collects the names of everyRelationNodeleaf reachable fromroot. Relation references only ever appear asRelationNodeleaves, so a recursive child walk (vianodeChildren(com.darkcollective.relix.ast.RelNode)) finds them all.- Parameters:
root- the root node of the tree; must not be null- Returns:
- the referenced relation names, in first-seen order; never null
-