Skip to content

rune-langium / core/src / collectNamespaceDependencies

Function: collectNamespaceDependencies() ​

ts
function collectNamespaceDependencies(documents): Map<string, Set<string>>;

Defined in: packages/core/src/analysis/cross-namespace-refs.ts:86

Walk every parsed document and return a per-namespace dependency map: Map<sourceNamespace, Set<targetNamespace>>. A key S lists every namespace T ≠ S that some type in S directly references.

The auto-select cascade in the Download modal computes the transitive closure on top of this map — a fixed-point set-union that terminates naturally when no new namespaces are added (cycles absorb cleanly).

Walks the spec §5.2 reference set in full:

  1. Data superType (extends)
  2. Data attributes[].typeCall.type (attribute type refs)
  3. RosettaTypeAlias typeCall.type (alias target refs)
  4. Choice attributes[].typeCall.type (choice arm refs)
  5. RosettaFunction inputs[].typeCall.type + output.typeCall.type + superFunction (function I/O refs)

NOT walked yet:

  • Function body operation type refs (the §5.2 "rule conditions" bullet). The Langium AST's Operation / Condition shapes have many possible type-bearing children, and the body refs are typically subset of the function's input/output anyway. If a real deselection test ever produces a broken emit because of a body-only reference, extend here.

Parameters ​

ParameterType
documentsreadonly LangiumDocument<AstNode>[]

Returns ​

Map<string, Set<string>>

Core packages released under MIT. Studio app released under FSL-1.1-ALv2.