feat(migrate): write v1 views, viewpoints, use cases, Expression trees and InterfaceRealizations as v2 - #514
Merged
Conversation
Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>
…ors and inclusions A UseCase becomes a use case def whatever incidental stereotype it carries. Its subject is the case's subject (a further one a reference usage), the actors its associations link it to are actor usages, an Include an include use case usage, and an Extend a dependency on the extended case since v2 has no extend; extension points are refused explicitly. Co-Authored-By: jason.han <hanhuijun@gmail.com>
… views and viewpoints Co-Authored-By: jason.han <hanhuijun@gmail.com>
…L operators The XMI reader adopts a uml:ElementValue a tool keeps in an xmi:Extension block as an owned operand of the block's owner; the expression lowering resolves it as a feature reference and reads operators spelled by name (Plus, Equal, Power). A viewpoint's subject precedes its stakeholders, a use case's precedes its actors, and an operation of a port def is a referential action, as the pilot validator requires. Adds the changelog fragment and the migration-guide rows. Co-Authored-By: jason.han <hanhuijun@gmail.com>
Contributor
Author
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
…ge-typed subjects A placeholder standing for an instance or element operand of a UML Expression tree could take a name the tree itself spells, so a like-named feature read resolved to the instance. Placeholders now avoid every word the tree's symbols and opaque bodies spell. A use case subject whose classifier is written as a view or viewpoint usage was typed with ':', which is invalid for a usage; it is now subset with ':>', as the general feature writer already does. Co-Authored-By: jason.han <hanhuijun@gmail.com>
6 tasks
…ressions Co-Authored-By: jason.han <hanhuijun@gmail.com>
…rite root «View» packages as views An opaque operand of a UML Expression tree is translated in its own language through a placeholder leaf that keeps its precedence, so a Java body keeps Java's integer division instead of being refused. An instance classified by a «View» or «Viewpoint» is left unmapped with a reason rather than written as an individual specializing a usage. A «View» package that is the document root is written as a view like any other. Co-Authored-By: jason.han <hanhuijun@gmail.com>
… opaque tree operands Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>
…subjects honest Restrict the extension ElementValues the XMI reader adopts to operands of an Expression, so other tool metadata stays in the extension accounting. A power over several tree operands is written with its accumulated left side in parentheses, since the script reads ** right to left. An Extend's unresolved extension points are kept in its comment and note, and a use-case subject that is a feature of another definition is refused with the reason rather than named where it cannot resolve. Co-Authored-By: jason.han <hanhuijun@gmail.com>
6 tasks
…ed name A featured usage is accessible to its definition's members alone, but a nested definition is a namespace member any scope can name, so the accessibility check now applies to usage subjects only. Co-Authored-By: jason.han <hanhuijun@gmail.com>
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.
What and why
The SysML v1 → v2 migrator refused four families of UML/SysML v1 constructs that have a direct or near-direct v2 form. Each is now written, with an explicit report note wherever v2 genuinely has no form, so nothing is dropped silently. All mappings are generic: they key on UML metaclasses, SysML profile stereotypes and the tool provenance the migrator already uses, never on a model's names or paths.
Views and viewpoints (
views.go)Standard v2 admits
exposeonly in aviewusage body (in aview defit is an OpenSysML extension flagged with a warning) andsatisfyonly against a viewpoint usage, so a v1 «View» class becomes a package-levelviewusage and a «Viewpoint» class a package-levelviewpointusage; a property typed by a view is a nestedview x :> Other;(the type becomes subsetting, since the type is now a usage).A viewpoint's
subject;is written before its stakeholders, and only stakeholders that are written part defs get astakeholdermember; a missing, proxied, unwritten or non-part stakeholder keeps a reason. The bundled OMG standard library has no genericStakeholderdefinition (only the non-standard OOSEM library does), so «Stakeholder» stays a plainpart def, which thestakeholdermembers reference.concernListcomments becomeframe concernmembers and are not repeated asdoc.Use cases (
usecase.go)uml:UseCaseis classified asuse case defregardless of incidental stereotypes («HyperlinkOwner» etc.). The body getssubject(an anonymoussubject;first when actors exist but no writable explicit subject does — the validator requires the subject to be the first parameter),actor a : Afor each association to a written Actor and for owned attributes typed by one,include use case i : I;for UML Include,objectivefrom the owned comments. UML Extend is kept as an approximation with a reason: v2 has noextend.UML Expression trees (
expression.go, XMI reader)uml:Expression/StringExpressiontrees are lowered recursively over the operator set the opaque-expression translator already uses: arithmetic+ - * / % **, comparison,and or not, unary minus, calls in the translated function table (Math.*), literals,InstanceValue, opaque-string operands and feature references, with the same scope-visibility checks (featureResolver). Operators spelled by name (Plus,Minus,Times,Equal,Power, …) are read case-insensitively. Anything else — an unknown symbol, a symbol-less node, an unsupported opaque language, an interval or time construct, an inaccessible or unnamed reference, an instance value naming no instance — is refused with the construct spelled out.MagicDraw keeps a feature reference inside an Expression as a
uml:ElementValue(no such UML metaclass) under anxmi:Extension. The XMI reader now adopts those nodes as operands of the owning element, in document order; other extension content (diagrams, layout) is still skipped and still recorded inModel.Extensions.InterfaceRealization (
realization.go)A part def specializing a port def is not valid v2, so the mapping depends on how the interface is written: a realizing Block gets a
port : Ityped by the interface's port def; a realizing InterfaceBlock (itself a port def) specializes it with:>. An external, unwritten or notation-only endpoint keeps a refusal naming why.Also fixed along the way: an operation of a port def is written
ref action, notaction(owned usages of a port def other than ports must be referential); nested feature references use dot notation (Outer.inner) rather than::; a nilupperValueno longer dereferences.Specification basis
SysML v2 v2.0 §7.24 Views and Viewpoints (
ViewUsage,Expose,ViewpointUsage,StakeholderMember,FramedConcernMember), §7.23 Use Cases (SubjectMember,ActorMember,IncludeUseCaseUsage), §7.9 Expressions, and thesysml-v1-migration.mdmapping table (rows added for each construct). No row ofdocs/project/spec-compliance.mdmoves: this is the v1 → v2 translator, not the v2 semantics.How it was verified
Fixtures (hand-written, model-neutral, each golden output validates with 0 errors through the same analyser the fixture test runs):
report_views.xmi(views, viewpoints, stakeholders, expose of an element / a package / a diagram / an external element, conform, a view property),parking_usecases.xmi(actors, subject, include, extend),tree_constraints.xmi(a Pythagorean constraint whose base operands are extension-held ElementValues, arithmetic, comparison, Boolean, unary minus, a translated call, and a refusedxor),realized_interfaces.xmi(interface realized by a block and by an interface block, plus an unwritten one). Focused unit tests inviews_internal_test.go,usecase_internal_test.go,expression_internal_test.go,realization_internal_test.go,xmi_test.go.Gates (all run from a clean tree at the head commit):
No corpus expectation file changed: neither
training_examples_expected.txtnor the pilot / PSSM ratchets moved.Leakage audit over the changed production files (
internal/translate/migrate/*.go,internal/translate/xmi/sysmlv1/xmi.go, tests excluded):The only numeric literals in the added production lines are 0, 1, 2 and 4 (arity checks, loop starts). The four fixtures contain none of those names either.
Real-model proof (a Cameo 2024x
.mdzip, used only as evidence):sysml <model> -convert sysml -o out.sysml -migration-report r.txt -migration-results results.jsonondevelopand on this branch, thensysml out.sysml -validateandsysml out.sysml -compare-results results.jsonon each.-validateerrors-validatewarningsThe 2 990 additional rows are the contents of the «View»/«Viewpoint» classes — their properties, owned activities (the view-method queries), comments and constraints — which
developnever reported because a refused classifier's body was not walked; they are now written or refused individually. The warning increase isDuplicate of inherited member namefrom views that expose several packages declaring same-named members plus the nested views subsetting them; both this validator and the pilot's treat that as a warning, and a minimal probe (view Overview { expose A::**; expose B::**; }withpart def Xin both) reproduces it with 0 errors.Rows that moved between categories (by report kind):
porttyped by the interface's port def)cp1 ** 2 + cp2 ** 2 == cp3 ** 2), 8 unmappedview :> …)The 8 remaining Expression-tree constraints, and 349 more now reached inside view classes, are the tool's view bookkeeping: symbol-less Expression nodes, and
InstanceValueoperands with noinstance(606 such in the source XMI). Each is refused with that reason.Pilot validator (
validate-sysml-batch, pinned byscripts/download-pilot-sysml-validator.sh) on both outputs: 1 577 errors and 13 warnings each, and the two message lists are identical line for line once file positions are stripped. The errors are 1 440 unresolved references (requirement text), 53A usage must be typed by definitions, 6An action must be typed by action definitions, and 78 parse errors on OpenSysML-only state notation (defer,accept,transition); since the lists are identical, none arises from the newly written constructs.-compare-resultson both: the same 24 configurations cannot run (their runs draw at random and name no seed), the same 17 run once and reproduce the same standing tables; the only textual difference is the addedview … :> …;context lines in warnings.Checklist
make testandmake lintpass locallydocs/reference/sysml-v1-migration.md)changes/unreleased/migrate-views-usecases-expressions.added.md, not as an edit toCHANGELOG.mdmake docs-countsrun if a gate count moved — no gate count moved