Repository navigation
Conversation
Test methods - testTransitionShorthandNotation, checks that, when a transition is parsed from the shorthand notation, and then moved programmatically in the model, it retains its already computed source and target values. (Test passes with implementationf from master.) - Tests for longhand transitions with and without a feature chain as source. (Test with source feature chain fails.)
- Adopted an approach for the "source" property shorthand using implied reference subsetting, analogously to what is done for the plain succession shorthand. Changed the derivation of the "source" to get the source of the succession contained in the transition usage. - Added a TransitionUsageParsePostProcessor to add a transitionLink feature at the end of a transition usage. - Removed adding the source and transitionLink features as additional members in the TransitionUsageAdapter.
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 PR continues the line of changes in previous PRs #814 (ST6RI-947), #818 (ST6RI-979) and #822 (ST6RI-981) to separate model preparation from model queries. It can also be considered a proactive prototype for expanding the resolution of the following issue on the succession shorthand to also cover transitions.
Background
Previously, the various textual notations for transitions were all parsed into a
TransitionUsagewithout a requiredtransitionLinkfeature. This was physically inserted into the abstract syntax tree (AST) later by overriding the methodaddAdditionalMembersin classTransitionUsageAdapter. Further, the shorthand transition notation in which thesourceis determined lexically (e.g, of the form "then...") was parsed into aTransitionUsagewithout the initial owned membership that usually determines the transitionsource. Thesourcewas determined later, also as part of theaddAdditionalMembersfunctionality.Normally,
addAdditionalMembersis called fromNamespace::doTransformas part of the semantic transformation of a model. However, it was also possible to callTransactionUsage.getSource()before a full transformation was done, in which case the implementation calledTransitionUsageAdapter.addAdditionalMemberson-demand. This coupled model queries with structural model mutations and adapter initialization. Such couplings are being systematically removed from the implementation.For example, consider following model, with a transition that explicitly declares both the source and target states:
A transition declaration in this form was parsed as referencing it's
sourcestate using an alias membership and containing a succession whose target feature was the transition target. Transforming the transition then resulted in an implied reference subsetting from the source end of the contained succession to the alias member, establishing that member as the succession source feature. The methodTransitionUsage.getSourcereturned the alias member reference to the transition source state.Now consider a version of this model that uses the implied-source shorthand notaion. In this shorthand, the source state is not explicitly denoted in the transaction, but is determined as the lexically nearest previous state before the transition.
This was parsed similarly to the previous version of the model, but without an alias membership for the source state. The correct source state was computed during transformation and an alias membership referencing this state was physically added to the
TransitionUsage. At this point, theTransitionUsagein the AST has the same form as when parsed from the full notation.So, during semantic transformation of the model, calling
TransitionUsageAdapter.transformincluded an initial call toTransitionUsageAdapter.addAdditionalMembers. The methodTransitionUsageAdapter.addAdditionalMembersdid two things:computeSource, which added a source alias membership to theTransitionUsageif it had been missing.computeTransitionLinkConnectors, which (among other things) added atransitionLinkFeatureto theTransitionUsageas necessary.The property getter
getSourceon theTransitionUsagewas also implemented to calladdAdditionalMemberson theTransitionUsagebefore actually getting the source element. This ensured that aTransitionUsageparsed from the shorthand notation actually had its source added to the parse tree, so it could be returned by the getter, in the case that the getter was called beforetransform. However, in this case, thegetSourcequery could result in the physical mutations to the parsed model as described above.Changes
TransitionUsageParsePostProcessor, which adds an ownedtransitionLinkfeature to a just-parsedTransitionUsage. This is similar to the approach taken in the other PRs mentioned earlier, in which functionality is moved from the adapter for a syntactic element to the post-processor for the element.computeSourcecompletely from theTransitionUsageAdapter.transitionLinkFeaturefrom the methodcomputeTransitionLinkConnectors, but left other processing.computeTransitionLinkConnectionsfromaddAdditionalMemberstodoTransform, and removedaddAdditionalMembers.UsageUtil.getSourceFeatureOf(Transition)to remove the call toTransitionUsageAdapter.addAdditionalMembers, which no longer exists. Revised the functionality of this method so that, if there is not source alias membership, it determines the proper source element and returns that. No alias membership is added to theTransitionUsage.TransitionUsage.getSourceso that it returns the source feature of thesuccessionof aTransitionUsage. If thesuccessionhas no source feature, then the proper source is obtained by callinggetSourceFeatureOfand attached to thesuccessionsource end using an implicitReferenceSubsettingspecialization.Tests
Added
org.omg.sysml.interactive.tests.TransitionUsageTest:testTransitionSource– Tests that the source (and target) of a longhand transition declaration are computed correctly.testTransitionSourceWithFeatureChain- Tests that the source feature and source of a transition usage are computed correctly when the source is a feature chain.testTransitionShorthandNotation– Tests:TransitionUsageparsed from the shorthand notation has itssourceset correctly.TransitionUsageparsed from the shorthand notation, thatTransitionUsagecan change position in the abstract syntax tree for a model, and it's source feature won't change.testSuccessionInTransitionUsage– Tests that the source of a transition is set properly, whether or not theTransitionUsagehas been transformed.