Skip to content

Commit

Permalink
[394] Fix some minor issue with redefine feature
Browse files Browse the repository at this point in the history
Bug: eclipse-syson#394
Signed-off-by: Arthur Daussy <arthur.daussy@obeo.fr>
  • Loading branch information
adaussy committed Jun 13, 2024
1 parent 3be75ba commit 5763a5f
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.eclipse.syson.sysml.EndFeatureMembership;
import org.eclipse.syson.sysml.Feature;
import org.eclipse.syson.sysml.FeatureDirectionKind;
import org.eclipse.syson.sysml.FeatureMembership;
import org.eclipse.syson.sysml.FeatureReferenceExpression;
import org.eclipse.syson.sysml.FeatureTyping;
import org.eclipse.syson.sysml.FeatureValue;
Expand Down Expand Up @@ -164,6 +165,8 @@ public boolean isReadOnly(Element element, EStructuralFeature eStructuralFeature
if ((element instanceof StateUsage && SysmlPackage.eINSTANCE.getStateUsage_IsParallel().equals(eStructuralFeature))
|| (element instanceof StateDefinition && SysmlPackage.eINSTANCE.getStateDefinition_IsParallel().equals(eStructuralFeature))) {
isReadOnly = isReadOnly || ((Type) element).getOwnedFeature().stream().filter(TransitionUsage.class::isInstance).findAny().isPresent();
} else if (element instanceof FeatureMembership && SysmlPackage.eINSTANCE.getFeaturing_Feature().equals(eStructuralFeature)) {
isReadOnly = true;
}
}
return isReadOnly;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ public PortDefinition getOriginalPortDefinition() {
* @generated NOT
*/
public PortDefinition basicGetOriginalPortDefinition() {
Namespace owningNamespace = this.getOwningNamespace();
if (owningNamespace instanceof PortDefinition portDefinition) {
return portDefinition;
PortConjugation conjugator = this.getOwnedPortConjugator();
if (conjugator != null) {
return conjugator.getOriginalPortDefinition();
}
return null;
}
Expand Down Expand Up @@ -171,4 +171,14 @@ public Conjugation getOwnedConjugator() {
return this.getOwnedPortConjugator();
}

/**
* <!-- begin-user-doc --> Redefines getter generated from eAnnotation <!-- end-user-doc -->
*
* @generated NOT
*/
@Override
public Namespace getOwningNamespace() {
return this.getOriginalPortDefinition();
}

} // ConjugatedPortDefinitionImpl
Original file line number Diff line number Diff line change
Expand Up @@ -80,50 +80,23 @@ protected EClass eStaticClass() {
return SysmlPackage.eINSTANCE.getFeatureMembership();
}

/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public Feature getFeature() {
if (this.feature != null && this.feature.eIsProxy()) {
InternalEObject oldFeature = (InternalEObject) this.feature;
this.feature = (Feature) this.eResolveProxy(oldFeature);
if (this.feature != oldFeature) {
if (this.eNotificationRequired()) {
this.eNotify(new ENotificationImpl(this, Notification.RESOLVE, SysmlPackage.FEATURE_MEMBERSHIP__FEATURE, oldFeature, this.feature));
}
}
}
return this.feature;
}

/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated NOT
*/
public Feature basicGetFeature() {
Feature ownedMemberFeature = this.getOwnedMemberFeature();
if (ownedMemberFeature != null) {
return ownedMemberFeature;
}
return this.feature;
return this.getFeature();
}

/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
* @generated NOT
*/
@Override
public void setFeature(Feature newFeature) {
Feature oldFeature = this.feature;
this.feature = newFeature;
if (this.eNotificationRequired()) {
this.eNotify(new ENotificationImpl(this, Notification.SET, SysmlPackage.FEATURE_MEMBERSHIP__FEATURE, oldFeature, this.feature));
}
// It redefines "feature" feature from Featuring
}

/**
Expand Down Expand Up @@ -390,4 +363,14 @@ public Namespace getMembershipOwningNamespace() {
return this.getOwningType();
}

/**
* <!-- begin-user-doc --> Redefines getter generated from eAnnotation <!-- end-user-doc -->
*
* @generated NOT
*/
@Override
public Feature getFeature() {
return this.getOwnedMemberFeature();
}

} // FeatureMembershipImpl
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,10 @@ public ActionUsage getPerformedAction() {
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
* @generated NOT
*/
public ActionUsage basicGetPerformedAction() {
// TODO: implement this method to return the 'Performed Action' reference
// -> do not perform proxy resolution
// Ensure that you remove @generated or mark it @generated NOT
return null;
return this.getUseCaseIncluded();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ public Object eInvoke(int operationID, EList<?> arguments) throws InvocationTarg
/**
* <!-- begin-user-doc --> Redefines getter generated from eAnnotation <!-- end-user-doc -->
*
* @generated
* @generated NOT
*/
@Override
public EList<Structure> getItemDefinition() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.syson.sysml.Element;
import org.eclipse.syson.sysml.Feature;
import org.eclipse.syson.sysml.ReferenceSubsetting;
import org.eclipse.syson.sysml.SysmlPackage;
Expand Down Expand Up @@ -124,7 +125,7 @@ public Feature getReferencingFeature() {
* @generated NOT
*/
public Feature basicGetReferencingFeature() {
return this.getSubsettingFeature();
return this.getOwningFeature();
}

/**
Expand Down Expand Up @@ -222,7 +223,20 @@ public void setSubsettedFeature(Feature newSubsettedFeature) {
*/
@Override
public Feature getOwningFeature() {
return this.getReferencingFeature();
Element owner = this.getOwningRelatedElement();
if (owner instanceof Feature feature) {
return feature;
}
return null;
}

/**
* <!-- begin-user-doc --> Redefines getter generated from eAnnotation <!-- end-user-doc -->
*
* @generated NOT
*/
@Override
public Feature getSubsettingFeature() {
return this.getReferencingFeature();
}
} // ReferenceSubsettingImpl
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ public ActionUsage getAction() {
* @generated NOT
*/
public ActionUsage basicGetAction() {
Feature ownedMemberFeature = this.getOwnedMemberFeature();
if (ownedMemberFeature instanceof ActionUsage au) {
return au;
}
return null;
return this.getOwnedRelatedElement().stream()
.filter(ActionUsage.class::isInstance)
.map(ActionUsage.class::cast)
.findFirst()
.orElse(null);
}

/**
Expand Down Expand Up @@ -214,4 +214,14 @@ public String toString() {
return result.toString();
}

/**
* <!-- begin-user-doc --> Redefines getter generated from eAnnotation <!-- end-user-doc -->
*
* @generated NOT
*/
@Override
public Feature getOwnedMemberFeature() {
return this.getAction();
}

} // StateSubactionMembershipImpl
Original file line number Diff line number Diff line change
Expand Up @@ -1049,7 +1049,7 @@ public String toString() {
/**
* <!-- begin-user-doc --> Redefines getter generated from eAnnotation <!-- end-user-doc -->
*
* @generated
* @generated NOT
*/
@Override
public EList<Type> getType() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;

import org.eclipse.syson.sysml.ConjugatedPortDefinition;
import org.eclipse.syson.sysml.PortConjugation;
import org.eclipse.syson.sysml.PortDefinition;
import org.eclipse.syson.sysml.helper.LabelConstants;
import org.eclipse.syson.sysml.util.ModelBuilder;
Expand All @@ -39,6 +40,7 @@ public void setUp() {
public void getNames() {
PortDefinition port = this.builder.createWithName(PortDefinition.class, "p1");
ConjugatedPortDefinition conjugatedPort = this.builder.createInWithName(ConjugatedPortDefinition.class, port, "unusedName");
this.builder.createIn(PortConjugation.class, conjugatedPort).setOriginalPortDefinition(port);
assertEquals(LabelConstants.CONJUGATED + "p1", conjugatedPort.getName());

}
Expand Down

0 comments on commit 5763a5f

Please sign in to comment.