Enhance AST and rendering for annotations, enums, and requirements#32
Merged
Malcolmnixon merged 7 commits intoJul 13, 2026
Merged
Conversation
added 7 commits
July 12, 2026 19:03
…r gaps Comment/doc annotation text is already captured semantically but never read by GeneralViewLayoutStrategy; enum literal values, constraint bodies, and requirement subject/constraints/doc are not captured in the AST at all yet. Cites the spec's stereotype-style compartment title conventions (subject, doc, constraint).
…e constraints in AstBuilder - Add nullable ExpressionText to SysmlFeatureNode, mirroring SysmlTransitionNode.Guard, for constraint-kind features' raw expression text. - VisitEnumerationDefinition: full body-collecting visitor via new CollectEnumerationBodyChildren helper, since enumerationBody uniquely alternates annotatingMember/enumerationUsageMember directly rather than wrapping them in a single rule. VisitEnumeratedValue builds an 'enum value'-keyword feature for each literal (bare, value-assignment, and redefinition-body forms). - VisitRequirementDefinition/VisitConcernDefinition: full body-collecting visitor (push-scope/CollectChildren(requirementBodyItem)/register), mirroring VisitStateUsage's established pattern. Also extend VisitRequirementUsage/VisitConcernUsage the same way, beyond a literal *Definition-only reading of the plan, because the dominant real OMG corpus idiom nests subject/assume constraint inside a requirement usage that specializes a def, not inside the def's own body. - New VisitSubjectUsage/VisitActorUsage/VisitStakeholderUsage (subject/actor/stakeholder keywords) and VisitRequirementConstraintMember/BuildConstraintFeatureNode (require constraint/assume constraint keywords, capturing raw expression text for both the reference and inline requirementConstraintUsage grammar alternatives). - New VisitConstraintUsage (previously entirely absent) and rewritten VisitConstraintDefinition, synthesizing a 'constraint'-keyword child feature carrying the raw calculationBody text. - New VisitRequirementVerificationMember/VisitFramedConcernMember returning null: once body-collection reaches requirementBodyItem, ANTLR's default dispatch would otherwise recurse into a nested verify/frame member's own body and incorrectly hoist its content onto the outer enclosing requirement.
- Add DefBox.Annotations, threaded through CollectDefinitions. - New AddAnnotationNote/BuildNoteText/ComputeNoteBoxSize helpers: emit one BoxShape.Note box per annotated definition (concatenating multiple Documentation/Comment annotations into a single note), connected by a plain solid line with no end marker. Implemented as ordinary LayoutGraph nodes/edges added during the existing single-pass BuildGraph traversal, a documented deviation from a literal post-layout marker-decoration approach (this strategy has no equivalent decoration phase). - Pluralize: add guillemet stereotype titles for subject/assume constraint/require constraint/constraint compartments, reusing the pre-existing «allocate» edge-label convention. - FormatFeatureRow: render a constraint-kind feature's raw ExpressionText instead of the generic name : Type [multiplicity] row shape.
…t rendering - WorkspaceLoaderTests: enum def bare/value-assignment literal capture, requirement def/usage subject+constraint capture, actor/stakeholder capture, standalone constraint usage/definition, and a verify-member no-hoist regression guard. - OmgModelsTests: regression fixtures against the real OMG corpus for enumeration definitions, requirement definitions/usages, and comment/documentation examples. - GeneralViewLayoutStrategyTests: note-box emission (including the no-note and multiple-annotations-combine-into-one cases), «subject» guillemet compartment title, constraint expression-text rows, and the enum values compartment title.
…ent changes - ast-builder.md/general-view-layout-strategy.md design docs: describe the new visitor methods, the deliberate VisitRequirementUsage/VisitConcernUsage extension, the verify/frame null-suppression safeguard, and the AddAnnotationNote architectural deviation from a post-layout marker-decoration approach. - sysml-node.md: document the new SysmlFeatureNode.ExpressionText field. - Verification docs: add Test Scenarios entries for every new test. - Reqstream YAMLs: add new requirement IDs with test traces, following the shape established by PR #30/#31.
…roadmap item delivered - 01-drone-general.sysml: Battery gains a doc annotation, FlightMode is now an enum def with literal values, and FlightTimeRequirement gains a subject/require constraint body. - Regenerate DroneGeneralView/BatterySubsystemView SVG and PNG. - Update gallery README caption for the new content. - ROADMAP.md: mark 'Annotating elements & compartment depth' delivered.
…ility gap in ast-builder requirement The RequirementSubjectAndConstraints requirement in ast-builder.yaml claims coverage of both requirement and concern definition/usage paths (VisitConcernDefinition/VisitConcernUsage), but WorkspaceLoaderTests.cs only exercised requirement cases. - Add WorkspaceLoader_LoadAsync_ConcernDefinitionAndUsage_CapturesSubject to WorkspaceLoaderTests.cs, verifying that a concern def and a concern usage each capture their subject member as a Children entry. - Reference the new test in the RequirementSubjectAndConstraints requirement's tests list in docs/reqstream/sysml2-tools-language/semantic/model/ast-builder.yaml. - Add the corresponding row to docs/verification/sysml2-tools-language/semantic/model/ast-builder.md.
This was referenced Jul 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request delivers the "Annotating elements & compartment depth" feature for the SysML2 tools, improving both the semantic model and the General View layout to support documentation notes, enumeration literal values, and deeper compartment rendering for requirements, concerns, and constraints. It also updates the documentation and gallery model to demonstrate these capabilities. The most important changes are grouped below:
Semantic Model & AST Builder Enhancements:
AstBuildernow captures all relevant content for compartment depth: enumeration values (with a newVisitEnumeratedValueandCollectEnumerationBodyChildren), requirement/concernsubject,actor,stakeholder, and constraint members (with new visitors and helpers), and standalone constraint usages/definitions. It also adds a safeguard to prevent nestedverify/framebodies from being incorrectly hoisted. [1] [2] [3] [4]SysmlFeatureNodetype gains anExpressionTextfield to capture raw constraint expressions, which is used for rendering constraint-kind features.General View Layout & Rendering:
GeneralViewLayoutStrategyis updated to thread through definition annotations, enabling the rendering ofBoxShape.Notenodes (folded-corner notes) attached to annotated elements, with concatenated annotation text. The layout also pluralizes certain compartment titles using guillemets for stereotype-style headings and renders constraint expressions as raw text. [1] [2] [3] [4]Documentation & Gallery Model Updates:
01-drone-general.sysml) is extended with annotated elements, anenum defwith values, and a requirement with subject and constraint body to demonstrate the new features. The gallery README is updated to describe these additions.Scope and Limitations:
docannotations within constraint bodies or support views other than General View. [1] [2]Summary of Most Important Changes:
SysmlFeatureNodegainsExpressionTextfor constraint-kind features, enabling raw expression rendering.docinside constraint bodies is intentionally omitted. [1] [2]