|
1 | 1 | /******************************************************************************* |
2 | 2 | * SysML 2 Pilot Implementation |
3 | | - * Copyright (c) 2021-2025 Model Driven Solutions, Inc. |
| 3 | + * Copyright (c) 2021-2026 Model Driven Solutions, Inc. |
4 | 4 | * |
5 | 5 | * This program is free software: you can redistribute it and/or modify |
6 | 6 | * it under the terms of the GNU Lesser General Public License as published by |
|
35 | 35 | import org.eclipse.emf.common.util.EList; |
36 | 36 | import org.eclipse.emf.ecore.EClass; |
37 | 37 | import org.eclipse.emf.ecore.InternalEObject; |
| 38 | +import org.omg.sysml.lang.sysml.AssignmentActionUsage; |
38 | 39 | import org.omg.sysml.lang.sysml.Association; |
39 | 40 | import org.omg.sysml.lang.sysml.BindingConnector; |
40 | 41 | import org.omg.sysml.lang.sysml.Connector; |
@@ -216,7 +217,6 @@ protected Feature getBoundValueResult() { |
216 | 217 | * @satisfies checkFeatureCrossingSpecialization |
217 | 218 | * @satisfies checkFeatureOwnedCrossFeatureSpecialization |
218 | 219 | * @satisfies checkFeatureOwnedCrossFeatureRedefinitionSpecialization |
219 | | - * |
220 | 220 | */ |
221 | 221 | @Override |
222 | 222 | public void addDefaultGeneralType() { |
@@ -592,10 +592,47 @@ public void addComputedRedefinitions(Element skip) { |
592 | 592 | // NOTE: Set flag before adding redefinitions, to avoid possible infinite |
593 | 593 | // recursion if computeImplicitGeneralTypes is called again on this Feature. |
594 | 594 | isComputeRedefinitions = false; |
| 595 | + addFeatureWriteTypes(); |
595 | 596 | addRedefinitions(skip); |
596 | 597 | } |
597 | 598 | } |
598 | 599 |
|
| 600 | + /** |
| 601 | + * @satisfies checkAssignmentActionUsageReferentRedefinition |
| 602 | + * @satisfies checkAssignmentActionUsageAccessedFeatureRedefinition |
| 603 | + * @satisfies checkAssignmentActionUsageStartingAtRedefinition |
| 604 | + */ |
| 605 | + protected void addFeatureWriteTypes() { |
| 606 | + Feature feature = getTarget(); |
| 607 | + if (isStartingAtFeature(feature)) { |
| 608 | + addDefaultGeneralType(SysMLPackage.eINSTANCE.getRedefinition(), getDefaultSupertype("startingAt")); |
| 609 | + } else if (isAccessedFeature(feature)) { |
| 610 | + addDefaultGeneralType(SysMLPackage.eINSTANCE.getRedefinition(), getDefaultSupertype("accessedFeature")); |
| 611 | + AssignmentActionUsage actionUsage = (AssignmentActionUsage)(feature.getOwner().getOwner().getOwner()); |
| 612 | + Feature referent = actionUsage.getReferent(); |
| 613 | + if (referent != null) { |
| 614 | + addImplicitGeneralType(SysMLPackage.eINSTANCE.getRedefinition(), referent); |
| 615 | + } |
| 616 | + } |
| 617 | + } |
| 618 | + |
| 619 | + public static boolean isStartingAtFeature(Feature feature) { |
| 620 | + Type owningType = feature.getOwningType(); |
| 621 | + if (owningType instanceof Feature) { |
| 622 | + Type actionUsage = ((Feature)owningType).getOwningType(); |
| 623 | + if (actionUsage instanceof AssignmentActionUsage) { |
| 624 | + return ((AssignmentActionUsage)actionUsage).getParameter().indexOf(owningType) == 0; |
| 625 | + } |
| 626 | + } |
| 627 | + return false; |
| 628 | + } |
| 629 | + |
| 630 | + public static boolean isAccessedFeature(Feature feature) { |
| 631 | + Type owningType = feature.getOwningType(); |
| 632 | + return owningType instanceof Feature && isStartingAtFeature((Feature)owningType) && |
| 633 | + owningType.getOwnedFeature().indexOf(feature) == 0; |
| 634 | + } |
| 635 | + |
599 | 636 | /** |
600 | 637 | * Compute relevant Redefinitions and add them to this Feature. By default, if this Feature is relevant for its |
601 | 638 | * owning Type, then it is paired with relevant Features in the same position in Generalizations of the |
@@ -789,27 +826,6 @@ protected BindingConnector addBindingConnector(Collection<Type> featuringTypes, |
789 | 826 | return connector; |
790 | 827 | } |
791 | 828 |
|
792 | | - protected void addFeatureWriteTypes(List<Feature> parameters, Feature referent) { |
793 | | - if (!parameters.isEmpty()) { |
794 | | - Feature targetFeature = parameters.get(0); |
795 | | - List<Feature> features = targetFeature.getOwnedFeature(); |
796 | | - if (!features.isEmpty()) { |
797 | | - Feature startingAtFeature = features.get(0); |
798 | | - TypeUtil.addDefaultGeneralTypeTo(startingAtFeature, SysMLPackage.eINSTANCE.getRedefinition(), getDefaultSupertype("startingAt")); |
799 | | - TypeUtil.setIsAddImplicitGeneralTypesFor(startingAtFeature, false); |
800 | | - features = startingAtFeature.getOwnedFeature(); |
801 | | - if (!features.isEmpty()) { |
802 | | - Feature accessedFeature = features.get(0); |
803 | | - TypeUtil.addDefaultGeneralTypeTo(accessedFeature, SysMLPackage.eINSTANCE.getRedefinition(), getDefaultSupertype("accessedFeature")); |
804 | | - if (referent != null) { |
805 | | - TypeUtil.addImplicitGeneralTypeTo(accessedFeature, SysMLPackage.eINSTANCE.getRedefinition(), referent); |
806 | | - } |
807 | | - TypeUtil.setIsAddImplicitGeneralTypesFor(accessedFeature, false); |
808 | | - } |
809 | | - } |
810 | | - } |
811 | | - } |
812 | | - |
813 | 829 | /** |
814 | 830 | * @satisfies checkFeatureValueBindingConnector |
815 | 831 | */ |
|
0 commit comments