forked from ZenUml/core
-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
Context
- In invalid DSL like
ref(), ANTLR error recovery synthesizes a NameContext soRefContext.prototype.Content()returns a context even when no name was provided. This can surface as an editable label/range at runtime for an invalid input.
What happens today
FragmentRefusesref().Content()and token start/stop to buildlabelTextandlabelPosition. Forref(),this.name()[0]can be a synthesized node, producing misleading UI/edit ranges.
Proposal
- Add a safe helper for fragment refs:
labelRangeOfRef(ctx)that returns an inclusive[start, end]or[-1, -1]when the first name is missing/synthesized. - Harden
RefContext.prototype.Contentto returnundefinedfor synthesized names (e.g., start/stoptokenIndex < 0) or empty formatted text. - Update
FragmentRefto use the helper + guard (render empty label and non-editable range when undefined). - Add focused tests covering:
ref(a),ref(a,b,c),ref()+ recovery, and mixed whitespace/quotes in names.
Why this aligns with our direction
- Keeps label/range logic centralized in helpers (like
labelRangeOfMessage). - Maintains renderer/parser decoupling and consistent editing behavior.
- Plays nicely with the IR adoption: no parser internals leak into components.
Out of scope
- Changing the grammar to accept empty refs. This is purely runtime tolerance and UX.
Acceptance criteria
ref()produces no editable label (labelRange[-1,-1]) and no runtime warnings/errors.- Existing valid
ref(...)labels remain unchanged. - Tests pass across the new cases.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels