Enrichment

object Enrichment

Layers extra information on top of a freshly loaded Vista — demangled display names, per-function metrics from clang-tidy, doxygen-style descriptions, and node-kind icons.

Why view overlays, not entity mutation

The underlying com.stigway.metamodels.highway.MetamodelEntity instances are immutable — their name / description / asil are vals set at construction. Enrichment writes only to the overlay slots on the views (CodeConstructView.name, CodeConstructView.description, CodeConstructView.iconKey, CodeConstructView.metrics); it never reaches the wrapped entity. Renderers read view.name ?: view.construct.name, so the override transparently takes priority when present.

Mangled vs demangled

The analyzer emits mangled LLVM symbol names (e.g. _ZN3foo3barEv) — the loader stamps them onto CodeInstruction.mangledName / CodeFunction.mangledName. The metrics + descriptions JSON files key on the unmangled C++ function-name token reported by clang-tidy diagnostics. So:

  1. applyDemangling populates view.name by demangling each construct's mangled symbol.

  2. addCodeMetrics / addDescriptions then key on a simple-name token extracted from view.name.

Steps are exposed as separate named functions because each joins on a different key and each input is optional. enrich is the canonical-order convenience wrapper.

Functions

Link copied to clipboard
fun addCodeMetrics(graph: Vista, metricsJsonText: String?): Vista

Parses the metrics JSON produced by analyzeFunctionMetrics and folds each function's metrics into the matching CodeConstructViews.

Link copied to clipboard
fun addDescriptions(graph: Vista, descriptionsJsonText: String?): Vista

Parses the descriptions JSON produced by analyzeFunctionDescriptions and folds each function's description text into the matching CodeConstructViews by writing view.description.

Link copied to clipboard
fun addIcons(graph: Vista): Vista

Assigns each view's diagram-node iconKey (a sprite ID stig-icons-<slug>): code-construct views from their CodeConstructKind, element views from the element's ElementType. SVG export emits <use href="#stig-icons-...">; cytoscape resolves the same sprite via background-image data URLs.

Link copied to clipboard

Synthesises a class-level compound layer above the existing instruction → function nesting. For every function view whose demangled name contains a :: qualifier (e.g. harness::Entry::Execute()), this step:

Link copied to clipboard
fun applyDemangling(graph: Vista, demangle: (String) -> String?): Vista

Populates view.name on non-instruction CodeConstructViews whose underlying construct carries a mangled symbol the demangler can resolve. Instruction views keep their IR labels; their mangledName is the enclosing function symbol, not the instruction's own display identity.

Link copied to clipboard
fun applyElementNesting(graph: Vista, element: Element?): Vista

Outermost compound layer (issue 17 batch D / issue 24 multi-level boxing). Adds an ElementView for the analysed highway element and reparents every top-level code box (no existing parent) under it, so the cytoscape compound chain becomes Element → … → Instruction. SVG / sigma exporters ignore the parent link.

Link copied to clipboard

Populates view.sourceUrl from view.construct.source + view.construct.line. For each source file, picks the CodeBrowserUrl.Context whose gitRoot is the deepest ancestor of the file — handling the multi-repo case where a kotlin module's softwareUnderAnalysis { include(repos["sourceRepo"]/...) } pulls in C++ sources from a repo different from the module's own. Files outside every configured repo (e.g. bazel-out generated headers) keep sourceUrl = null.

Link copied to clipboard
fun enrich(graph: Vista, demangle: (String) -> String? = { null }, metricsJsonText: String? = null, descriptionsJsonText: String? = null, codeBrowserContexts: List<CodeBrowserUrl.Context> = emptyList(), analyzedElement: Element? = null, showFileLayer: Boolean = true, showSourceLines: Boolean = false): Vista

Canonical-order convenience wrapper: demangle → class-nesting → source URLs → icons → metrics → descriptions.

Generated with STIG