Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Willink2019-12-01 14:43:31 +0000
committerEd Willink2019-12-01 14:43:31 +0000
commit8e38919b8b9e9653cf8714086e50b45552627079 (patch)
treea5df0ccc86f405c4f9a5a65f56136295d5ff2276
parentc7aa44f7e70a5ad61c248fd69888320ddba03f62 (diff)
downloadorg.eclipse.qvtd-8e38919b8b9e9653cf8714086e50b45552627079.tar.gz
org.eclipse.qvtd-8e38919b8b9e9653cf8714086e50b45552627079.tar.xz
org.eclipse.qvtd-8e38919b8b9e9653cf8714086e50b45552627079.zip
3
-rw-r--r--plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtb2qvts/ExpressionSynthesizer.java20
-rw-r--r--plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtb2qvts/RegionHelper.java7
-rw-r--r--plugins/org.eclipse.qvtd.pivot.qvtschedule/src/org/eclipse/qvtd/pivot/qvtschedule/utilities/QVTscheduleUtil.java59
3 files changed, 15 insertions, 71 deletions
diff --git a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtb2qvts/ExpressionSynthesizer.java b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtb2qvts/ExpressionSynthesizer.java
index ff624aa3d..c0ba8a083 100644
--- a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtb2qvts/ExpressionSynthesizer.java
+++ b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtb2qvts/ExpressionSynthesizer.java
@@ -381,7 +381,7 @@ public abstract class ExpressionSynthesizer extends AbstractExtendingQVTbaseVisi
}
protected @NonNull Node createStepNode(@NonNull InitUtility initUtility, @NonNull String name, @NonNull CallExp callExp, @NonNull Node sourceNode) {
- boolean isMatched = !initUtility.isConditional() && sourceNode.isMatched() && QVTscheduleUtil.isMatched(callExp);
+ boolean isMatched = !initUtility.isConditional() && sourceNode.isMatched() && callExp.isIsRequired();
return context.createStepNode(initUtility, name, callExp, sourceNode, isMatched);
}
@@ -481,7 +481,7 @@ public abstract class ExpressionSynthesizer extends AbstractExtendingQVTbaseVisi
}
protected @Nullable Node doOperationCallExp(@NonNull OperationCallExp operationCallExp, @Nullable Node sourceNode) {
- boolean isMatched = QVTscheduleUtil.isMatched(operationCallExp);
+ boolean isMatched = operationCallExp.isIsRequired();
Operation referredOperation = QVTbaseUtil.getReferredOperation(operationCallExp);
String operationName = ClassUtil.nonNullState(referredOperation.getName());
OCLExpression ownedSource = operationCallExp.getOwnedSource();
@@ -1248,7 +1248,7 @@ public abstract class ExpressionSynthesizer extends AbstractExtendingQVTbaseVisi
partNodes[i] = synthesize(collectionPart);
collectionParts[i] = collectionPart;
}
- boolean isMatched = QVTscheduleUtil.isMatched(collectionLiteralExp);
+ boolean isMatched = collectionLiteralExp.isIsRequired();
ExpressionSynthesizer nestedAnalyzer = getRequiredExpressionSynthesizer(isMatched);
return nestedAnalyzer.createCollectionLiteral(resultUtility, collectionLiteralExp, collectionParts, partNodes);
}
@@ -1262,7 +1262,7 @@ public abstract class ExpressionSynthesizer extends AbstractExtendingQVTbaseVisi
public @NonNull Node visitCollectionRange(@NonNull CollectionRange collectionRange) {
Node firstNode = synthesize(collectionRange.getOwnedFirst());
Node lastNode = synthesize(collectionRange.getOwnedLast());
- boolean isMatched = QVTscheduleUtil.isMatched(collectionRange);
+ boolean isMatched = collectionRange.isIsRequired();
ExpressionSynthesizer nestedAnalyzer = getRequiredExpressionSynthesizer(isMatched);
return nestedAnalyzer.createCollectionRange(resultUtility, collectionRange, firstNode, lastNode);
}
@@ -1365,7 +1365,7 @@ public abstract class ExpressionSynthesizer extends AbstractExtendingQVTbaseVisi
partNodes[i] = synthesize(mapPart);
mapParts[i] = mapPart;
}
- boolean isMatched = QVTscheduleUtil.isMatched(mapLiteralExp);
+ boolean isMatched = mapLiteralExp.isIsRequired();
ExpressionSynthesizer nestedAnalyzer = getRequiredExpressionSynthesizer(isMatched);
return nestedAnalyzer.createMapLiteral(resultUtility, mapLiteralExp, mapParts, partNodes);
}
@@ -1374,7 +1374,9 @@ public abstract class ExpressionSynthesizer extends AbstractExtendingQVTbaseVisi
public @NonNull Node visitMapLiteralPart(@NonNull MapLiteralPart mapLiteralPart) {
Node keyNode = synthesize(QVTbaseUtil.getOwnedKey(mapLiteralPart));
Node valueNode = synthesize(QVTbaseUtil.getOwnedValue(mapLiteralPart));
- boolean isMatched = QVTscheduleUtil.isMatched(mapLiteralPart);
+ OCLExpression key = QVTbaseUtil.getOwnedKey(mapLiteralPart);
+ OCLExpression value = QVTbaseUtil.getOwnedValue(mapLiteralPart);
+ boolean isMatched = key.isIsRequired() && value.isIsRequired();
ExpressionSynthesizer nestedAnalyzer = getRequiredExpressionSynthesizer(isMatched);
return nestedAnalyzer.createMapPart(mapLiteralPart, keyNode, valueNode);
}
@@ -1403,7 +1405,7 @@ public abstract class ExpressionSynthesizer extends AbstractExtendingQVTbaseVisi
@Override
public @Nullable Node visitOperationCallExp(@NonNull OperationCallExp operationCallExp) {
- boolean isMatched = !resultUtility.isConditional() || QVTscheduleUtil.isMatched(operationCallExp);
+ boolean isMatched = !resultUtility.isConditional() || operationCallExp.isIsRequired();
if (!resultUtility.isConditional() && !isMatched) {
return getExpressionSynthesizer(getConditionalUtility()).visitOperationCallExp(operationCallExp);
}
@@ -1442,7 +1444,7 @@ public abstract class ExpressionSynthesizer extends AbstractExtendingQVTbaseVisi
partNodes[i] = synthesize(shadowPart);
shadowParts[i] = shadowPart;
}
- boolean isMatched = QVTscheduleUtil.isMatched(shadowExp);
+ boolean isMatched = shadowExp.isIsRequired();
ExpressionSynthesizer nestedAnalyzer = getRequiredExpressionSynthesizer(isMatched);
return nestedAnalyzer.createShadow(shadowExp, shadowParts, partNodes);
}
@@ -1470,7 +1472,7 @@ public abstract class ExpressionSynthesizer extends AbstractExtendingQVTbaseVisi
partNodes[i] = synthesize(tuplePart);
tupleParts[i] = tuplePart;
}
- boolean isMatched = QVTscheduleUtil.isMatched(tupleLiteralExp);
+ boolean isMatched = tupleLiteralExp.isIsRequired();
ExpressionSynthesizer nestedAnalyzer = getRequiredExpressionSynthesizer(isMatched);
return nestedAnalyzer.createTupleLiteral(tupleLiteralExp, tupleParts, partNodes);
}
diff --git a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtb2qvts/RegionHelper.java b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtb2qvts/RegionHelper.java
index 249e3080c..ca765b2e8 100644
--- a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtb2qvts/RegionHelper.java
+++ b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvtb2qvts/RegionHelper.java
@@ -150,7 +150,8 @@ public class RegionHelper<R extends Region> extends QVTscheduleUtil implements N
ClassDatum classDatum = scheduleManager.getBooleanClassDatum();
BooleanLiteralNode booleanLiteralNode = QVTscheduleFactory.eINSTANCE.createBooleanLiteralNode();
booleanLiteralNode.initialize(nodeRole, region, utility, Boolean.toString(booleanValue), classDatum);
- booleanLiteralNode.setMatched(QVTscheduleUtil.isMatched(utility));
+ boolean isMatched = (utility == InitUtility.DISPATCH) || (utility == InitUtility.TRACE) || (utility == InitUtility.NON_NULL_MATCHED) || (utility == InitUtility.NULLABLE_MATCHED) || (utility == InitUtility.COMPOSED);
+ booleanLiteralNode.setMatched(isMatched);
booleanLiteralNode.setBooleanValue(booleanValue);
if (booleanLiteralExp != null) {
booleanLiteralNode.setOriginatingElement(booleanLiteralExp);
@@ -205,7 +206,7 @@ public class RegionHelper<R extends Region> extends QVTscheduleUtil implements N
public @NonNull Node createDataTypeNode(@NonNull InitUtility utility, @NonNull String name, @NonNull Node sourceNode, @NonNull NavigationCallExp navigationCallExp) {
Property property = PivotUtil.getReferredProperty(navigationCallExp);
- boolean isMatched = sourceNode.isMatched() && isMatched(property);
+ boolean isMatched = sourceNode.isMatched() && property.isIsRequired();
Role nodeRole = getPatternNodeRole(sourceNode, property);
assert sourceNode.isClass() || (property.getOpposite() != null); // FIXME review is this relevant?
// String name = property.getName();
@@ -237,7 +238,7 @@ public class RegionHelper<R extends Region> extends QVTscheduleUtil implements N
public @NonNull Node createDataTypeNode(@NonNull InitUtility utility, @NonNull Node sourceNode, @NonNull Property property) {
Role nodeRole = getPatternNodeRole(sourceNode, property);
- return createPatternNode(nodeRole, utility, sourceNode, property, sourceNode.isMatched() && isMatched(property));
+ return createPatternNode(nodeRole, utility, sourceNode, property, sourceNode.isMatched() && property.isIsRequired());
}
public @NonNull Node createDependencyClassNode(@NonNull InitUtility utility, @NonNull Node parentNode, @NonNull NavigationAssignment navigationAssignment) {
diff --git a/plugins/org.eclipse.qvtd.pivot.qvtschedule/src/org/eclipse/qvtd/pivot/qvtschedule/utilities/QVTscheduleUtil.java b/plugins/org.eclipse.qvtd.pivot.qvtschedule/src/org/eclipse/qvtd/pivot/qvtschedule/utilities/QVTscheduleUtil.java
index 56a10e1cf..17df4881a 100644
--- a/plugins/org.eclipse.qvtd.pivot.qvtschedule/src/org/eclipse/qvtd/pivot/qvtschedule/utilities/QVTscheduleUtil.java
+++ b/plugins/org.eclipse.qvtd.pivot.qvtschedule/src/org/eclipse/qvtd/pivot/qvtschedule/utilities/QVTscheduleUtil.java
@@ -17,19 +17,13 @@ import java.util.function.BinaryOperator;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.ocl.pivot.CollectionType;
import org.eclipse.ocl.pivot.CompleteClass;
import org.eclipse.ocl.pivot.Element;
import org.eclipse.ocl.pivot.EnumerationLiteral;
-import org.eclipse.ocl.pivot.IfExp;
-import org.eclipse.ocl.pivot.LoopExp;
-import org.eclipse.ocl.pivot.MapLiteralPart;
-import org.eclipse.ocl.pivot.OCLExpression;
import org.eclipse.ocl.pivot.Operation;
import org.eclipse.ocl.pivot.OperationCallExp;
import org.eclipse.ocl.pivot.Property;
import org.eclipse.ocl.pivot.ShadowPart;
-import org.eclipse.ocl.pivot.Type;
import org.eclipse.ocl.pivot.TypedElement;
import org.eclipse.ocl.pivot.utilities.ClassUtil;
import org.eclipse.ocl.pivot.utilities.Nameable;
@@ -733,35 +727,6 @@ public class QVTscheduleUtil extends QVTscheduleConstants
return false;
}
- public static boolean isMatched(@NonNull Element element) {
- if (element instanceof MapLiteralPart) {
- MapLiteralPart mapLiteralPart = (MapLiteralPart)element;
- OCLExpression key = QVTbaseUtil.getOwnedKey(mapLiteralPart);
- OCLExpression value = QVTbaseUtil.getOwnedValue(mapLiteralPart);
- return isMatched(key) && isMatched(value);
- }
- else if (element instanceof TypedElement) {
- TypedElement typedElement = (TypedElement)element;
- Type type = typedElement.getType();
- if (type instanceof CollectionType) {
- // IntegerValue lowerValue = ((CollectionType)type).getLowerValue();
- // if (lowerValue.signum() > 0) {
- assert typedElement.isIsRequired();
- // }
- }
- else if (!typedElement.isIsRequired()) {
- return false;
- }
- return true; //isUnconditional(typedElement);
- }
- throw new UnsupportedOperationException();
- }
-
- @Deprecated /* @deprecated temporary migration aide */
- public static boolean isMatched(@Nullable InitUtility utility) {
- return (utility == InitUtility.DISPATCH) || (utility == InitUtility.TRACE) || (utility == InitUtility.NON_NULL_MATCHED) || (utility == InitUtility.NULLABLE_MATCHED) || (utility == InitUtility.COMPOSED);
- }
-
/* public static boolean isRealizedIncludes(@NonNull Edge edge) { // FIXME includes should be a pseudo-navigation edge
if (!edge.isRealized()) {
return false;
@@ -772,30 +737,6 @@ public class QVTscheduleUtil extends QVTscheduleConstants
return "«includes»".equals(edge.getName()) || "«includesAll»".equals(edge.getName());
} */
- private static boolean isUnconditional(@NonNull TypedElement typedElement) {
- EObject eContainer = typedElement.eContainer();
- if (eContainer instanceof IfExp) {
- IfExp ifExp = (IfExp)eContainer;
- if ((typedElement == ifExp.getOwnedThen()) || (typedElement == ifExp.getOwnedElse())) {
- return false;
- }
- }
- else if (eContainer instanceof LoopExp) {
- LoopExp loopExp = (LoopExp)eContainer;
- if (typedElement == loopExp.getOwnedBody()) {
- return false;
- }
- }
- if (eContainer instanceof TypedElement) {
- return isUnconditional((TypedElement) eContainer);
- }
- return true;
- }
-
- // public static boolean isUnconditional(@Nullable Utility utility) {
- // return (utility == Utility.DISPATCH) || (utility == Utility.TRACE) || (utility == Utility.STRONGLY_MATCHED) || (utility == Utility.WEAKLY_MATCHED) || (utility == Utility.COMPOSED);
- // }
-
public static @NonNull Role mergeToLessKnownPhase(Role firstRole, Role secondRole) {
if (firstRole == Role.REALIZED) {
return firstRole;

Back to the top