Conversation
Removed non-generated code for: - CommentImpl.setBody - ElementImpl.setDeclaredName and setDeclaredShortName - LiteralString.setValue - Membership.setMemberName and setMemberShortName - RequirementDefinition.setReqId - RequirementUsage.setReqId - TextualRepresentation.setLanguage and setBody
- Removed overrides of isComposite in subclasses, setting isComposite in constructors instead.
- For UsageImpl and PortIsageImpl
In subclasses of: - ExportImpl (isImportAll) - OperatorImpl (operator) - RequirementConstraintMembership (kind)
- Setting isEnd for EndFeatureMembership moved to EndFeatureMembershipAdapter.postProcess. - Setting direction for ParameterMembership moved to ParameterMembershipAdapter.postProcess. (Note that this means that simply being owned via a ParameterMembership no longer ensures that the parameter direction will be "in".) - Setting direction for the owned Feature of a FlowEnd moved to FlowEndAdapter.doTransform(). (Can't be done in postProcess, because of need for proxy resolution.)
- This was left over and no longer necessary.
- Updated CustomUML2EcoreConverter to add SysML EAnnotation to the Feature::isNonunique EAttribute, when it adds that to the Ecore metamodel.
- This a prospective redefinition pending resolution to SYSML21-302.
- Creation of IDs overridden in NamespaceAdapter, LibraryPackageAdapter and OwningMembershipAdapter. - Updated CustomUML2EcoreConverter to add SysML EAnnotation to the Element::elementID EAttribute, so that a setting delegation is generated.
- Updated CustomUML2EcoreConverter to add SysML EAnnotation to the Element::operand EAttribute, when it adds that to the Ecore metamodel, so that a setting delegation is generated. - Also changed uses of getOperand to getArgument in plantuml/VPath and VSequence.
- Re-introduced necessary remaining non-generated code, eliminating any remaining non-generated legacy code not previously identified.
- This avoids a possible infinite recursion in the construction of elementIds on demand.
himi
left a comment
There was a problem hiding this comment.
I confirmed it works. I found we need to be more careful because before post processing, many critical features are not set, which is initiated by postProcessAllCrossReferences().
Post-processing happens automatically after a model is parsed by Xtext, so it shouldn't be a problem when using the textual notation. However, you are correct that certain processing will now not be done automatically when a model is constructed in the abstract syntax, such as the un-escaping of names, or the setting of the direction of the owned parameter of a ParameterMembership. But the updated implementation is a more conformant with the abstract syntax per the specifications. |
This PR removes certain non-generated code from the EMF
Implclasses that was not removed by the update in PR #570.Moved to
postProcessMoved non-generated code to the
postProcessmethod of various adapter classes.Implclass:CommentImpl.setBodyElementImpl.setDeclaredNameandsetDeclaredShortNameFlowUsage.isAbstractLiteralString.setValueMembership.setMemberNameandsetMemberShortNamePortUsageImpl.isCompositeRequirementDefinition.setReqIdRequirementUsage.setReqIdTextualRepresentation.setLanguageandsetBodyUsageImpl.isCompositeFeatureImpl.isEndtoEndFeatureMembershipAdapter.postProcess.ownedMemberFeatureof anEndFeatureMembershipnow has itsisEndproperty set when parsed from the textual notation, but it is no longer set automatically if the relationship is created directly in the abstract syntax.FeatureImpl.isDirectiontoParameterMembershipAdapter.postProcess.ownedMemberParameterof aParameterMembership(including aReturnParameterMembership) now has itsdirectionproperty set when parsed from the textual notation, but it is no longer set automatically if the relationship is created directly in the abstract syntax.FlowEndmoved toFlowEndAdapter.transformrather thanpostProcess. This cannot be handled in parse post-processing because the computation requires proxy resolution.Moved to delegates
Moved non-generated code to setting or invocation delegates.
Updated
CustomUML2EoreConverterso that theSysMLEAnnotation is added to the propertiesElement::elementId,Feature::isNonuniqueandInvocationExpression::operand(the latter two of which are added to the Ecore metamodel by the converter). Non-generated code has then been moved into new setting delegates for these properties.Element.getElementIdandsetElementId–Element_elementId_SettingDelegatecalls through togetElementIdandsetElementIdmethods onElementAdapter, which also maintains theelementIdstate for anElement. If not set explicitly, anelementIdis created using thecreateElementIdmethod, which is overridden inNamspaceAdapter,LibraryPackageAdapterandOwningMembershipAdapterto handle creating stable IDs for library elements.Element::elementIdhasisId = truein the MOF abstract syntax model, the corresponding attribute in the Ecore metamodel was generated withID = true. This meant thatelementIdwas used internally by Eclipse as the ID for identifying objects within a resource. However, in certain cases, computation ofelementIdcould trigger proxy resolution that searched for an object by ID, causing a circularelementIdcomputation. To avoid this,CustomUML2EoreConverterhas been updated to setID = falseforelementId. This does not affect the use ofelementIdas the XMI ID in serialized XMI files.Feature.isNonuniqueandsetIsNonunique–Feature_isNonUnique_SettingDelegategets and setsisNonuniqueas the logical inverse ofisUnique.InvocationExpression.getOperand–InvocationExpression_operand_SettingDelegatecalls through to thegetOperandmethod onInvocationExpressionAdapter, which also maintains theoperandstate for anInvocationExpression, as an instance oforg.omg.sysml.util.OperandEList. AnOperandEListis a wrapper that, when anExpressionis added to it, actually adds theExpressionas an argument of theInvocationExpression.operandmechanism is a workaround to make the Xtext grammar tractable for parsing operator expressions. For this to work,operandneeds to be a containment reference, even though the resulting argument expression is actually contaned as the feature value of an owned parameter of theInvocationExpression. To avoidoperandexpressions from appearing duplicatively in serialized XMI for anInvocationExpression, it is not possible to read values back from anOperandEList(which is different than it worked before). Instead,Expression.getArgumentmust be used to get a normal list of theargumentexpressions of anInvocationExpression.Moved the overriding of
RenderingUsage.namingFeatureto the newRenderingUsage_namingFeature_InvocationDelegate, which extendsFeature_namingFeature_InvocationDelegate.Enumeration default values
There are a number of cases in the KerML and SysML MOF abstract syntax models in which an enumeration property has no default value. In this case, the implemented
EDEFAULTshould be null. However, Eclipse always generates a non-null default for a property with an enumeration type. In these cases, the generatedEDEFAULTdeclarations had been hand-modified to change the value to null and marked as@generated NOT. This PR does not change this non-generated code.Redefined default values
There are a number of cases in the KerML and SysML MOF abstract syntax models in which a property is redefined in order to add a default value or change the default value of the redefined property. For example, the various subclasses of
OperatorExpressionredefine theoperatorproperty to give it a default value appropriate to that kind of expression (e.g.,"collect"for aCollectExpression). This was previously implemented by hand-coded overrides of the getters for these properties in the correspondingImplclasses that returned the appropriate value (e.g., thegetOperatormethod was overridden inCollectExpressionImplto return"collect"). These overriding methods have now been removed and, instead, the appropriate default value is set in theImplclass constructor (e.g.,operator = "collect";in theCollectExpressionImplconstructor). The new approach still requires non-generated code inImplclass constructors. However, it more closely corresponds to the MOF semantics of default initial values.KerML
ImportImpl.isImportAll– Set totruein the following:MembershipExportImplNamespaceExportImplOperatorExpressonImpl.operator– Set to the appropriate operator in the following:CollectExpressionFeatureChainExpressionIndexExpressionSelectExpressionRequirementConstraintMembershipImpl.kind– Set toRequirementConstraintKind.REQUIREMENTin the following:FramedConcernMembershipRequirementVerificationMembershipNote. In addition, the
EDEFAULTvalues for the above properties are also set to the redefined default value (e.g.,operator = OPERATOR_EDEFAULT = "collect";). This ensures that the property is not serialized to XMI when it has the new default value. However, it requires that theEDEFAULTfield declaration be changed so that it is no longerstatic final.SysML
FeatureImpl.isCompositetrueinUsageImpl.falsein the following:AttributeUsageImplBindingConnectorAsUsageImplEventOccurrenceUsageImplExhibitStateUsageImplIncludeUseCaseUsageImplPerformActionUsageImplReferenceUsageImplSuccessionAsUsageImplNote. For kinds of SysML usages other than those listed above, the usage must be parsed with
isComposite = trueunless the keywordrefis included in the declaration, even though the default for KerML isisComposite = false. To implement this,isCompositeis set totruein the constructor ofUsageImpl, even though the default value forisCompositeis not actually overridden inUsagein the SysML abstract syntax. However, the value forIS_COMPOSITE_EDEFAULTis not changed, and remains asfalse. This means that the serialization ofisCompositeto XMI will now be the same for SysML usages as for KerML features (that is,isComposite=truewill always be serialized butisComposite=falsewill not). This is a change from the previous implementation, in whichisComposite=falsewas incorrectly serialized for usages required to be referential.Validation
In the above cases of the redefinition of the default value of a property, there are also validation constraints that require that the given default value not change. When previously implemented using overriding methods, these constraints were automatically satisfied and did not need to be checked. With the update in this PR, it is possible to change these properties in the abstract syntax representation to invalid values, so the relevant explicit validation checks have been implemented.
KerMLValidatorvalidateEndFeatureMembershipvalidateParameterMembershipvalidateCollectExpressionOperatorvalidateFeatureChainExpressionOperatorvalidateIndexExpressionOperatorvalidateSelectExpressionOperatorvalidateFlowEndIsEndSysMLValidatorvalidateUsageIsReferentialvalidateReferenceUsageIsReferentialvalidateAttributeUsageIsReferentialvalidateEnumerationDefinitionIsVariationvalidateEventOccurrenceUsageIsReferencevalidatePortUsageIsReferencevalidateExposeIsImportAll(this was actually already implemented)