Skip to content

Fix __ctrlFlow.enable annotation handling #601

Description

@AntoineGautier

Supersedes the parser part of #492 (see the behavior audit there). Depends on #600 (lookup fix)

Decision

__ctrlFlow(enable=false) becomes a hard parse skip: the class instantiated (or aliased, or
extended) with this annotation is not parsed at all — no ancestors, no elements; childInputs is
empty as a consequence. Rationale: today's implementation only prunes reachability (the inputs
reference lists) but still eagerly loads and recursively walks the dead-ended type
(parser.ts:893, 935-938; 704-705). Once modelica-json fixes the gap where classes aliased by short
classes get no JSON output, medium packages would be walked into and severely impact parse time —
the skip is what keeps them out. Parse time is expected to decrease relative to today.

Library-side contract (MBL refactoring, tracked separately): __ctrlFlow(enable=false) must not be
used on declarations whose parameters are referenced in expressions ctrl-flow must evaluate
(enable annotations, configuration bindings).

Parser implementation

  • Lazy skip, not a blacklist: skip means "don't trigger loading from this declaration site". A
    class dead-ended at one site but instantiated live elsewhere (e.g. Configuration records: dead in
    the model, live in the Data record) must still be parsed and resolvable through the global store.
  • Constructor ordering (with Fix potential unbounded file/type lookup #600 item 3): parse the annotation from the raw definition and set
    deadEnd before any typeStore.get. Today all three load first: Component :829 vs :879,
    ShortClass :503 (no deadEnd wiring at all), Extend :1033/:1055 around :1050.
  • Implement for ShortClass (bug in Fix parser logic for __ctrlFlow.enable and Dialog.enable annotations #492): requires also parsing the description annotation in
    the non-replaceable path (today only initializeReplaceable populates this.annotation, and only
    with a constraining clause). Note MediumAir = Buildings.Media.Air carries the annotation and is
    silently ignored today.
  • Guard the lazy re-entry points, or the skip is illusory: Component.getInputs
    (typeStore.get at :893, unconditional recursion at :935-938) and getChildElements's
    getInputs({}, false) filter (:678-680) would still trigger the load on first traversal.
  • Note: parser.ts:1050 is Extend, not Enumeration; Enumeration never parses annotations —
    no wiring needed there.
  • Diagnostic: correctness now rests on a library convention the parser can't verify locally, so
    parseTemplateJSON should warn when an enable expression or binding operand fails to resolve
    into a skipped scope — turns a misplaced annotation in MBL into a build diagnostic instead of a
    silently-null enable in the UI.
  • Regression test: a class referenced only through dead-end instantiations produces no entries;
    verify nothing external (e.g. datAll) resolves into it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions