Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Willink2016-05-18 04:55:59 -0400
committerEd Willink2016-05-18 09:18:05 -0400
commit9b53545e2054b2aadfb2146a2c0cadc811fe282d (patch)
tree01b85bff5748ad2b83c296d891bb667bac8249c6
parent0d7f31fb1979c6d494813a1329ece79c82d1d2ac (diff)
downloadorg.eclipse.qvtd-9b53545e2054b2aadfb2146a2c0cadc811fe282d.tar.gz
org.eclipse.qvtd-9b53545e2054b2aadfb2146a2c0cadc811fe282d.tar.xz
org.eclipse.qvtd-9b53545e2054b2aadfb2146a2c0cadc811fe282d.zip
[486722] Determine NavigationCallExp usage more sensibly from Property
annotations/containment
-rw-r--r--plugins/org.eclipse.qvtd.pivot.qvtcore/src/org/eclipse/qvtd/pivot/qvtcore/utilities/QVTcoreDomainUsageAnalysis.java7
-rw-r--r--plugins/org.eclipse.qvtd.pivot.qvtcorebase/src/org/eclipse/qvtd/pivot/qvtcorebase/analysis/AbstractDomainUsageAnalysis.java189
-rw-r--r--plugins/org.eclipse.qvtd.pivot.qvtcorebase/src/org/eclipse/qvtd/pivot/qvtcorebase/analysis/RootDomainUsageAnalysis.java56
-rw-r--r--plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiTransformationAnalysis.java7
-rw-r--r--plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/utilities/QVTimperativeDomainUsageAnalysis.java31
5 files changed, 147 insertions, 143 deletions
diff --git a/plugins/org.eclipse.qvtd.pivot.qvtcore/src/org/eclipse/qvtd/pivot/qvtcore/utilities/QVTcoreDomainUsageAnalysis.java b/plugins/org.eclipse.qvtd.pivot.qvtcore/src/org/eclipse/qvtd/pivot/qvtcore/utilities/QVTcoreDomainUsageAnalysis.java
index 492355617..c68aba9b3 100644
--- a/plugins/org.eclipse.qvtd.pivot.qvtcore/src/org/eclipse/qvtd/pivot/qvtcore/utilities/QVTcoreDomainUsageAnalysis.java
+++ b/plugins/org.eclipse.qvtd.pivot.qvtcore/src/org/eclipse/qvtd/pivot/qvtcore/utilities/QVTcoreDomainUsageAnalysis.java
@@ -11,7 +11,6 @@
package org.eclipse.qvtd.pivot.qvtcore.utilities;
import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.ocl.pivot.utilities.EnvironmentFactory;
import org.eclipse.qvtd.pivot.qvtbase.Rule;
import org.eclipse.qvtd.pivot.qvtcore.CoreModel;
@@ -23,7 +22,7 @@ import org.eclipse.qvtd.pivot.qvtcorebase.analysis.RootDomainUsageAnalysis;
/**
* A QVTcoreDomainUsageAnalysis identifies a constrained domain result from the DomainUsageAnalysis of an OCL AST node.
*/
-public class QVTcoreDomainUsageAnalysis extends RootDomainUsageAnalysis implements QVTcoreVisitor<DomainUsage>
+public class QVTcoreDomainUsageAnalysis extends RootDomainUsageAnalysis implements QVTcoreVisitor<@NonNull DomainUsage>
{
public QVTcoreDomainUsageAnalysis(@NonNull EnvironmentFactory environmentFactory) {
super(environmentFactory);
@@ -42,12 +41,12 @@ public class QVTcoreDomainUsageAnalysis extends RootDomainUsageAnalysis implemen
}
@Override
- public @Nullable DomainUsage visitCoreModel(@NonNull CoreModel object) {
+ public @NonNull DomainUsage visitCoreModel(@NonNull CoreModel object) {
return visitBaseModel(object);
}
@Override
- public @Nullable DomainUsage visitMapping(@NonNull Mapping object) {
+ public @NonNull DomainUsage visitMapping(@NonNull Mapping object) {
DomainUsage usage = getRootAnalysis().getNoneUsage();
setUsage(object, usage);
visitRule(object);
diff --git a/plugins/org.eclipse.qvtd.pivot.qvtcorebase/src/org/eclipse/qvtd/pivot/qvtcorebase/analysis/AbstractDomainUsageAnalysis.java b/plugins/org.eclipse.qvtd.pivot.qvtcorebase/src/org/eclipse/qvtd/pivot/qvtcorebase/analysis/AbstractDomainUsageAnalysis.java
index 236cf02cc..6b3b01ecc 100644
--- a/plugins/org.eclipse.qvtd.pivot.qvtcorebase/src/org/eclipse/qvtd/pivot/qvtcorebase/analysis/AbstractDomainUsageAnalysis.java
+++ b/plugins/org.eclipse.qvtd.pivot.qvtcorebase/src/org/eclipse/qvtd/pivot/qvtcorebase/analysis/AbstractDomainUsageAnalysis.java
@@ -92,10 +92,10 @@ import org.eclipse.qvtd.pivot.qvtcorebase.utilities.QVTcoreBaseUtil;
/**
* AbstractDomainUsageAnalysis provides shared functionality for the overall analysis and for nested operational analyses.
*/
-public abstract class AbstractDomainUsageAnalysis extends AbstractExtendingQVTcoreBaseVisitor<DomainUsage, @NonNull EnvironmentFactory> implements DomainUsageAnalysis.Internal
+public abstract class AbstractDomainUsageAnalysis extends AbstractExtendingQVTcoreBaseVisitor<@NonNull DomainUsage, @NonNull EnvironmentFactory> implements DomainUsageAnalysis.Internal
{
private DomainUsage selfUsage = null;
- protected final @NonNull Map<Element, DomainUsage> element2usage = new HashMap<Element, DomainUsage>();
+ protected final @NonNull Map<@NonNull Element, @NonNull DomainUsage> element2usage = new HashMap<@NonNull Element, @NonNull DomainUsage>();
protected AbstractDomainUsageAnalysis(@NonNull EnvironmentFactory environmentFactory) {
super(environmentFactory);
@@ -111,7 +111,7 @@ public abstract class AbstractDomainUsageAnalysis extends AbstractExtendingQVTco
DomainUsage valueUsage = visit(object.getValue());
DomainUsage knownSourceUsage = getRootAnalysis().property2containingClassUsage.get(property);
if (knownSourceUsage != null) {
- DomainUsage knownTargetUsage = getRootAnalysis().property2referredTypeUsage.get(property);
+ DomainUsage knownTargetUsage = getRootAnalysis().getUsage(property);
assert knownTargetUsage != null;
intersection(knownSourceUsage, slotUsage);
intersection(knownTargetUsage, valueUsage);
@@ -122,23 +122,24 @@ public abstract class AbstractDomainUsageAnalysis extends AbstractExtendingQVTco
}
}
- protected @NonNull DomainUsage doPropertyCallExp(Property property, @NonNull NavigationCallExp object) {
+ protected @NonNull DomainUsage doNavigationCallExp(@NonNull Property property, @NonNull NavigationCallExp object) {
DomainUsage actualSourceUsage = visit(object.getOwnedSource());
- DomainUsage knownSourceUsage = getRootAnalysis().property2containingClassUsage.get(property);
- if (knownSourceUsage != null) {
- DomainUsage knownTargetUsage = getRootAnalysis().property2referredTypeUsage.get(property);
- assert knownTargetUsage != null;
- if (knownTargetUsage.isPrimitive()) { // Primitive usage is primitive from whereever.
- return knownTargetUsage;
- }
- if (actualSourceUsage.isInput() && !property.isIsTransient()) { // Inputs can only persist input model elements
- return actualSourceUsage;
- }
- return knownTargetUsage;
- }
- else {
- return actualSourceUsage;
+ DomainUsage knownPropertyUsage = visit(property);
+ DomainUsage usage = knownPropertyUsage;
+ RootDomainUsageAnalysis rootAnalysis = getRootAnalysis();
+ Property oppositeProperty = property.getOpposite();
+ if (property.isIsComposite() // Composite properties have both ends in the sme domain
+ || ((oppositeProperty != null) && oppositeProperty.isIsComposite())
+ || (property == rootAnalysis.getOclContainerProperty()) // FIXME ensure these are isComposite
+ || (property == rootAnalysis.getOclContentsProperty())) {
+ usage = intersection(usage, actualSourceUsage);
+ }
+ else if (!property.isIsImplicit() && !rootAnalysis.isDirty(property) // Simple input domain nodes cannot reference middle or output domains
+ && (usage.isMiddle() || usage.isOutput())
+ && actualSourceUsage.isInput() && !actualSourceUsage.isMiddle() && !actualSourceUsage.isOutput()) {
+ usage = intersection(usage, actualSourceUsage);
}
+ return usage;
}
protected @NonNull DomainUsage getAllInstancesUsage(@NonNull OperationCallExp object, @NonNull DomainUsage sourceUsage) {
@@ -155,7 +156,7 @@ public abstract class AbstractDomainUsageAnalysis extends AbstractExtendingQVTco
}
}
- public @NonNull Map<Element, DomainUsage> getElements2Usage() {
+ public @NonNull Map<@NonNull Element, @NonNull DomainUsage> getElements2Usage() {
return element2usage;
}
@@ -170,9 +171,9 @@ public abstract class AbstractDomainUsageAnalysis extends AbstractExtendingQVTco
DomainUsage usage = element2usage.get(element);
if (usage == null) {
usage = element.accept(this);
- if ((usage == null) || usage.isNone()) { // FIXME debugging
- usage = element.accept(this);
- }
+// if ((usage == null) || usage.isNone()) { // FIXME debugging
+// usage = element.accept(this);
+// }
assert usage != null : "null usage for " + element.eClass().getName() + " " + element;
setUsage(element, usage);
}
@@ -220,8 +221,8 @@ public abstract class AbstractDomainUsageAnalysis extends AbstractExtendingQVTco
}
}
- protected void popSelfUsage(DomainUsage savedUsage) {
- selfUsage = savedUsage;
+ protected void popSelfUsage(@Nullable DomainUsage savedUsage) {
+ selfUsage = savedUsage;
}
protected DomainUsage pushSelfUsage(@NonNull DomainUsage usage) {
@@ -294,9 +295,9 @@ public abstract class AbstractDomainUsageAnalysis extends AbstractExtendingQVTco
@Override
public String toString() {
- Map<String, DomainUsage> map = new HashMap<String, DomainUsage>(element2usage.size());
- List<String> keys = new ArrayList<String>(element2usage.size());
- for (Map.Entry<Element, DomainUsage> entry : element2usage.entrySet()) {
+ Map<@NonNull String, @NonNull DomainUsage> map = new HashMap<@NonNull String, @NonNull DomainUsage>(element2usage.size());
+ List<@NonNull String> keys = new ArrayList<@NonNull String>(element2usage.size());
+ for (Map.Entry<@NonNull Element, @NonNull DomainUsage> entry : element2usage.entrySet()) {
Element element = entry.getKey();
String key = element.eClass().getName() + " : " + element;
map.put(key, entry.getValue());
@@ -304,7 +305,7 @@ public abstract class AbstractDomainUsageAnalysis extends AbstractExtendingQVTco
}
Collections.sort(keys);
StringBuilder s = new StringBuilder();
- for (String key : keys) {
+ for (@NonNull String key : keys) {
DomainUsage usage = map.get(key);
if (s.length() > 0) {
s.append("\n");
@@ -345,9 +346,9 @@ public abstract class AbstractDomainUsageAnalysis extends AbstractExtendingQVTco
// element.toString();
// }
usage = element.accept(this);
- if (usage == null) { // FIXME debugging
- usage = element.accept(this);
- }
+// if (usage == null) { // FIXME debugging
+// usage = element.accept(this);
+// }
assert usage != null : "null usage for " + element.eClass().getName() + " " + element;
setUsage(element, usage);
}
@@ -355,12 +356,12 @@ public abstract class AbstractDomainUsageAnalysis extends AbstractExtendingQVTco
}
@Override
- public @Nullable DomainUsage visiting(@NonNull Visitable visitable) {
+ public @NonNull DomainUsage visiting(@NonNull Visitable visitable) {
throw new UnsupportedOperationException("Unsupported " + visitable.eClass().getName() + " for " + getClass().getSimpleName());
}
@Override
- public @Nullable DomainUsage visitBottomPattern(@NonNull BottomPattern object) {
+ public @NonNull DomainUsage visitBottomPattern(@NonNull BottomPattern object) {
for (Variable variable : object.getVariable()) {
visit(variable);
}
@@ -377,7 +378,7 @@ public abstract class AbstractDomainUsageAnalysis extends AbstractExtendingQVTco
}
@Override
- public @Nullable DomainUsage visitClass(org.eclipse.ocl.pivot.@NonNull Class object) {
+ public @NonNull DomainUsage visitClass(org.eclipse.ocl.pivot.@NonNull Class object) {
DomainUsage usage = getRootAnalysis().class2usage.get(object);
if (usage != null) {
return usage;
@@ -388,12 +389,12 @@ public abstract class AbstractDomainUsageAnalysis extends AbstractExtendingQVTco
}
@Override
- public @Nullable DomainUsage visitCollectionItem(@NonNull CollectionItem object) {
+ public @NonNull DomainUsage visitCollectionItem(@NonNull CollectionItem object) {
return visit(object.getOwnedItem());
}
@Override
- public @Nullable DomainUsage visitCollectionLiteralExp(@NonNull CollectionLiteralExp object) {
+ public @NonNull DomainUsage visitCollectionLiteralExp(@NonNull CollectionLiteralExp object) {
DomainUsage usage = visit(((CollectionType)object.getType()).getElementType());
// DomainUsage usage = getRootAnalysis().getAnyUsage();
for (@SuppressWarnings("null")@NonNull CollectionLiteralPart part : object.getOwnedParts()) {
@@ -403,18 +404,18 @@ public abstract class AbstractDomainUsageAnalysis extends AbstractExtendingQVTco
}
@Override
- public @Nullable DomainUsage visitCollectionRange(@NonNull CollectionRange object) {
+ public @NonNull DomainUsage visitCollectionRange(@NonNull CollectionRange object) {
DomainUsage firstUsage = visit(object.getOwnedFirst());
DomainUsage lastUsage = visit(object.getOwnedLast());
return intersection(firstUsage, lastUsage);
}
@Override
- public @Nullable DomainUsage visitCollectionType(@NonNull CollectionType object) {
+ public @NonNull DomainUsage visitCollectionType(@NonNull CollectionType object) {
return visit(object.getElementType());
}
@Override
- public @Nullable DomainUsage visitCoreDomain(@NonNull CoreDomain object) {
+ public @NonNull DomainUsage visitCoreDomain(@NonNull CoreDomain object) {
DomainUsage usage = visit(object.getTypedModel());
setUsage(object, usage);
visit(object.getGuardPattern());
@@ -423,7 +424,7 @@ public abstract class AbstractDomainUsageAnalysis extends AbstractExtendingQVTco
}
@Override
- public @Nullable DomainUsage visitExpressionInOCL(@NonNull ExpressionInOCL object) {
+ public @NonNull DomainUsage visitExpressionInOCL(@NonNull ExpressionInOCL object) {
OCLExpression ownedBody = object.getOwnedBody();
if ((ownedBody == null) && (object.getBody() != null)) {
try {
@@ -448,7 +449,7 @@ public abstract class AbstractDomainUsageAnalysis extends AbstractExtendingQVTco
}
@Override
- public @Nullable DomainUsage visitFunction(@NonNull Function object) {
+ public @NonNull DomainUsage visitFunction(@NonNull Function object) {
for (@SuppressWarnings("null")@NonNull Parameter parameter : object.getOwnedParameters()) {
visit(parameter);
}
@@ -462,7 +463,7 @@ public abstract class AbstractDomainUsageAnalysis extends AbstractExtendingQVTco
}
@Override
- public @Nullable DomainUsage visitIfExp(@NonNull IfExp object) {
+ public @NonNull DomainUsage visitIfExp(@NonNull IfExp object) {
@SuppressWarnings("unused") DomainUsage conditionUsage = visit(object.getOwnedCondition());
DomainUsage thenUsage = visit(object.getOwnedThen());
DomainUsage elseUsage = visit(object.getOwnedElse());
@@ -470,7 +471,7 @@ public abstract class AbstractDomainUsageAnalysis extends AbstractExtendingQVTco
}
@Override
- public @Nullable DomainUsage visitGuardPattern(@NonNull GuardPattern object) {
+ public @NonNull DomainUsage visitGuardPattern(@NonNull GuardPattern object) {
DomainUsage domainUsage = getDomainUsage(object);
// for (Variable variable : object.getVariable()) { // In visitTransformation
// setUsage(variable, domainUsage);
@@ -482,7 +483,7 @@ public abstract class AbstractDomainUsageAnalysis extends AbstractExtendingQVTco
}
@Override
- public @Nullable DomainUsage visitIterateExp(@NonNull IterateExp object) {
+ public @NonNull DomainUsage visitIterateExp(@NonNull IterateExp object) {
DomainUsage sourceUsage = visit(object.getOwnedSource());
for (Variable iterator : object.getOwnedIterators()) {
if (iterator != null) {
@@ -512,7 +513,7 @@ public abstract class AbstractDomainUsageAnalysis extends AbstractExtendingQVTco
}
@Override
- public @Nullable DomainUsage visitIteratorExp(@NonNull IteratorExp object) {
+ public @NonNull DomainUsage visitIteratorExp(@NonNull IteratorExp object) {
DomainUsage sourceUsage = visit(object.getOwnedSource());
for (Variable iterator : object.getOwnedIterators()) {
if (iterator != null) {
@@ -541,18 +542,18 @@ public abstract class AbstractDomainUsageAnalysis extends AbstractExtendingQVTco
}
@Override
- public @Nullable DomainUsage visitLetExp(@NonNull LetExp object) {
+ public @NonNull DomainUsage visitLetExp(@NonNull LetExp object) {
visit(object.getOwnedVariable());
return visit(object.getOwnedIn());
}
@Override
- public @Nullable DomainUsage visitLiteralExp(@NonNull LiteralExp object) {
+ public @NonNull DomainUsage visitLiteralExp(@NonNull LiteralExp object) {
return getRootAnalysis().getPrimitiveUsage();
}
@Override
- public @Nullable DomainUsage visitMapLiteralExp(@NonNull MapLiteralExp object) {
+ public @NonNull DomainUsage visitMapLiteralExp(@NonNull MapLiteralExp object) {
DomainUsage usage = getRootAnalysis().getAnyUsage();
for (@SuppressWarnings("null")@NonNull MapLiteralPart part : object.getOwnedParts()) {
usage = intersection(usage, visit(part));
@@ -561,14 +562,14 @@ public abstract class AbstractDomainUsageAnalysis extends AbstractExtendingQVTco
}
@Override
- public @Nullable DomainUsage visitMapLiteralPart(@NonNull MapLiteralPart object) {
+ public @NonNull DomainUsage visitMapLiteralPart(@NonNull MapLiteralPart object) {
DomainUsage keyUsage = visit(object.getOwnedKey());
DomainUsage valueUsage = visit(object.getOwnedValue());
return intersection(keyUsage, valueUsage);
}
@Override
- public @Nullable DomainUsage visitNavigationAssignment(@NonNull NavigationAssignment object) {
+ public @NonNull DomainUsage visitNavigationAssignment(@NonNull NavigationAssignment object) {
Property property = QVTcoreBaseUtil.getTargetProperty(object);
// if ("middleRoot.name := hsvRoot.name".equals(object.toString())) {
// property = object.getTargetProperty();
@@ -577,12 +578,12 @@ public abstract class AbstractDomainUsageAnalysis extends AbstractExtendingQVTco
}
@Override
- public @Nullable DomainUsage visitNullLiteralExp(@NonNull NullLiteralExp object) {
+ public @NonNull DomainUsage visitNullLiteralExp(@NonNull NullLiteralExp object) {
return getRootAnalysis().createVariableUsage(getRootAnalysis().getAnyMask());
}
@Override
- public @Nullable DomainUsage visitOperation(@NonNull Operation object) {
+ public @NonNull DomainUsage visitOperation(@NonNull Operation object) {
// System.out.println(" " + getClass().getSimpleName() + "@" + Integer.toHexString(System.identityHashCode(this)) + " : " + object);
DomainUsage savedUsage = pushSelfUsage(visit(object.getOwningClass()));
try {
@@ -611,7 +612,7 @@ public abstract class AbstractDomainUsageAnalysis extends AbstractExtendingQVTco
}
@Override
- public @Nullable DomainUsage visitOperationCallExp(@NonNull OperationCallExp object) {
+ public @NonNull DomainUsage visitOperationCallExp(@NonNull OperationCallExp object) {
DomainUsage sourceUsage = visit(object.getOwnedSource());
DomainUsage savedUsage = pushSelfUsage(sourceUsage);
try {
@@ -706,19 +707,19 @@ public abstract class AbstractDomainUsageAnalysis extends AbstractExtendingQVTco
}
@Override
- public @Nullable DomainUsage visitOppositePropertyAssignment(@NonNull OppositePropertyAssignment object) {
+ public @NonNull DomainUsage visitOppositePropertyAssignment(@NonNull OppositePropertyAssignment object) {
return visitNavigationAssignment(object);
}
@Override
- public @Nullable DomainUsage visitOppositePropertyCallExp(@NonNull OppositePropertyCallExp object) {
- Property property = object.getReferredProperty();
- Property oppositeProperty = property != null ? property.getOpposite() : null;
- return doPropertyCallExp(oppositeProperty, object);
+ public @NonNull DomainUsage visitOppositePropertyCallExp(@NonNull OppositePropertyCallExp object) {
+ Property property = ClassUtil.nonNullState(object.getReferredProperty());
+ Property oppositeProperty = ClassUtil.nonNullState(property.getOpposite());
+ return doNavigationCallExp(oppositeProperty, object);
}
@Override
- public @Nullable DomainUsage visitParameter(@NonNull Parameter object) {
+ public @NonNull DomainUsage visitParameter(@NonNull Parameter object) {
// Operation operation = object.getOwningOperation();
// Map<Element, DomainUsage> map = analyzeOperation(operation);
// return map.get(object);
@@ -727,39 +728,45 @@ public abstract class AbstractDomainUsageAnalysis extends AbstractExtendingQVTco
}
@Override
- public @Nullable DomainUsage visitPredicate(@NonNull Predicate object) {
+ public @NonNull DomainUsage visitPredicate(@NonNull Predicate object) {
return visit(object.getConditionExpression());
}
@Override
- public @Nullable DomainUsage visitPrimitiveType(@NonNull PrimitiveType object) {
+ public @NonNull DomainUsage visitPrimitiveType(@NonNull PrimitiveType object) {
return getRootAnalysis().getPrimitiveUsage();
}
@Override
- public @Nullable DomainUsage visitPropertyAssignment(@NonNull PropertyAssignment object) {
+ public @NonNull DomainUsage visitProperty(@NonNull Property property) {
+ DomainUsage annotatedUsage = getRootAnalysis().getAnnotatedUsage(property);
+ DomainUsage superUsage = super.visitProperty(property);
+ if (annotatedUsage != null) {
+ return intersection(annotatedUsage, superUsage);
+ }
+ else {
+ return superUsage;
+ }
+ }
+
+ @Override
+ public @NonNull DomainUsage visitPropertyAssignment(@NonNull PropertyAssignment object) {
return visitNavigationAssignment(object);
}
@Override
- public @Nullable DomainUsage visitPropertyCallExp(@NonNull PropertyCallExp object) {
- Property property = object.getReferredProperty();
- RootDomainUsageAnalysis rootAnalysis = getRootAnalysis();
- if ((property == rootAnalysis.getOclContainerProperty()) || (property == rootAnalysis.getOclContentsProperty())) {
- return visit(object.getOwnedSource());
- }
- else {
- return doPropertyCallExp(property, object);
- }
+ public @NonNull DomainUsage visitPropertyCallExp(@NonNull PropertyCallExp object) {
+ Property property = ClassUtil.nonNullState(object.getReferredProperty());
+ return doNavigationCallExp(property, object);
}
@Override
- public @Nullable DomainUsage visitRealizedVariable(@NonNull RealizedVariable object) {
+ public @NonNull DomainUsage visitRealizedVariable(@NonNull RealizedVariable object) {
return getDomainUsage(object);
}
@Override
- public @Nullable DomainUsage visitRule(@NonNull Rule object) {
+ public @NonNull DomainUsage visitRule(@NonNull Rule object) {
for (Domain domain : object.getDomain()) {
visit(domain);
}
@@ -767,12 +774,12 @@ public abstract class AbstractDomainUsageAnalysis extends AbstractExtendingQVTco
}
@Override
- public @Nullable DomainUsage visitSelfType(@NonNull SelfType object) {
- return selfUsage;
+ public @NonNull DomainUsage visitSelfType(@NonNull SelfType object) {
+ return ClassUtil.nonNullState(selfUsage);
}
@Override
- public @Nullable DomainUsage visitShadowExp(@NonNull ShadowExp object) {
+ public @NonNull DomainUsage visitShadowExp(@NonNull ShadowExp object) {
DomainUsage usage = visit(object.getType());
for (@SuppressWarnings("null")@NonNull ShadowPart part : object.getOwnedParts()) {
/*usage = intersection(usage,*/ visit(part); //);
@@ -781,13 +788,13 @@ public abstract class AbstractDomainUsageAnalysis extends AbstractExtendingQVTco
}
@Override
- public @Nullable DomainUsage visitShadowPart(@NonNull ShadowPart object) {
+ public @NonNull DomainUsage visitShadowPart(@NonNull ShadowPart object) {
visit(object.getOwnedInit());
return visit(object.getType());
}
@Override
- public @Nullable DomainUsage visitTemplateParameter(@NonNull TemplateParameter object) {
+ public @NonNull DomainUsage visitTemplateParameter(@NonNull TemplateParameter object) {
RootDomainUsageAnalysis rootAnalysis = getRootAnalysis();
int anyMask = rootAnalysis.getAnyMask();
DomainUsage usage = rootAnalysis.getValidUsage(anyMask);
@@ -798,7 +805,7 @@ public abstract class AbstractDomainUsageAnalysis extends AbstractExtendingQVTco
}
@Override
- public @Nullable DomainUsage visitTransformation(@NonNull Transformation object) {
+ public @NonNull DomainUsage visitTransformation(@NonNull Transformation object) {
// for (TypedModel typedModel : object.getModelParameter()) { -- done in analyzeTransformation
// visit(typedModel);
// }
@@ -831,7 +838,7 @@ public abstract class AbstractDomainUsageAnalysis extends AbstractExtendingQVTco
}
@Override
- public @Nullable DomainUsage visitTupleLiteralExp(@NonNull TupleLiteralExp object) {
+ public @NonNull DomainUsage visitTupleLiteralExp(@NonNull TupleLiteralExp object) {
DomainUsage usage = getRootAnalysis().getAnyUsage();
for (@SuppressWarnings("null")@NonNull TupleLiteralPart part : object.getOwnedParts()) {
usage = intersection(usage, visit(part)); // FIXME need HYBRID
@@ -840,12 +847,12 @@ public abstract class AbstractDomainUsageAnalysis extends AbstractExtendingQVTco
}
@Override
- public @Nullable DomainUsage visitTupleLiteralPart(@NonNull TupleLiteralPart object) {
+ public @NonNull DomainUsage visitTupleLiteralPart(@NonNull TupleLiteralPart object) {
return visit(object.getType());
}
@Override
- public @Nullable DomainUsage visitTupleType(@NonNull TupleType object) {
+ public @NonNull DomainUsage visitTupleType(@NonNull TupleType object) {
DomainUsage usage = getRootAnalysis().getAnyUsage();
for (@SuppressWarnings("null")@NonNull Property part : object.getOwnedProperties()) {
usage = intersection(usage, visit(part.getType()));
@@ -854,28 +861,28 @@ public abstract class AbstractDomainUsageAnalysis extends AbstractExtendingQVTco
}
@Override
- public @Nullable DomainUsage visitType(@NonNull Type object) {
+ public @NonNull DomainUsage visitType(@NonNull Type object) {
return getRootAnalysis().getPrimitiveUsage();
}
@Override
- public @Nullable DomainUsage visitTypeExp(@NonNull TypeExp object) {
+ public @NonNull DomainUsage visitTypeExp(@NonNull TypeExp object) {
DomainUsage usage = visit(object.getReferredType());
return getRootAnalysis().getValidOrVariableUsage(usage);
}
@Override
- public @Nullable DomainUsage visitTypedElement(@NonNull TypedElement object) {
+ public @NonNull DomainUsage visitTypedElement(@NonNull TypedElement object) {
return visit(object.getType());
}
@Override
- public @Nullable DomainUsage visitTypedModel(@NonNull TypedModel object) {
- return element2usage.get(object);
+ public @NonNull DomainUsage visitTypedModel(@NonNull TypedModel object) {
+ return ClassUtil.nonNullState(element2usage.get(object));
}
@Override
- public @Nullable DomainUsage visitVariable(@NonNull Variable object) {
+ public @NonNull DomainUsage visitVariable(@NonNull Variable object) {
OCLExpression ownedInit = object.getOwnedInit();
if (ownedInit != null) {
return visit(ownedInit);
@@ -890,19 +897,19 @@ public abstract class AbstractDomainUsageAnalysis extends AbstractExtendingQVTco
}
@Override
- public @Nullable DomainUsage visitVariableAssignment(@NonNull VariableAssignment object) {
+ public @NonNull DomainUsage visitVariableAssignment(@NonNull VariableAssignment object) {
DomainUsage valueUsage = visit(object.getValue());
DomainUsage variableUsage = visit(object.getTargetVariable());
return intersection(variableUsage, valueUsage);
}
@Override
- public @Nullable DomainUsage visitVariableDeclaration(@NonNull VariableDeclaration object) {
+ public @NonNull DomainUsage visitVariableDeclaration(@NonNull VariableDeclaration object) {
return visit(object.getType());
}
@Override
- public @Nullable DomainUsage visitVariableExp(@NonNull VariableExp object) {
+ public @NonNull DomainUsage visitVariableExp(@NonNull VariableExp object) {
VariableDeclaration referredVariable = object.getReferredVariable();
DomainUsage usage = visit(referredVariable);
assert usage != null : referredVariable + " usage not defined";
diff --git a/plugins/org.eclipse.qvtd.pivot.qvtcorebase/src/org/eclipse/qvtd/pivot/qvtcorebase/analysis/RootDomainUsageAnalysis.java b/plugins/org.eclipse.qvtd.pivot.qvtcorebase/src/org/eclipse/qvtd/pivot/qvtcorebase/analysis/RootDomainUsageAnalysis.java
index fd1770080..8d6c8bcc8 100644
--- a/plugins/org.eclipse.qvtd.pivot.qvtcorebase/src/org/eclipse/qvtd/pivot/qvtcorebase/analysis/RootDomainUsageAnalysis.java
+++ b/plugins/org.eclipse.qvtd.pivot.qvtcorebase/src/org/eclipse/qvtd/pivot/qvtcorebase/analysis/RootDomainUsageAnalysis.java
@@ -56,7 +56,7 @@ import org.eclipse.qvtd.pivot.qvtcorebase.PropertyAssignment;
import org.eclipse.qvtd.pivot.qvtcorebase.util.QVTcoreBaseVisitor;
import org.eclipse.qvtd.pivot.qvtcorebase.utilities.QVTcoreBaseUtil;
-public class RootDomainUsageAnalysis extends AbstractDomainUsageAnalysis implements QVTcoreBaseVisitor<DomainUsage>
+public class RootDomainUsageAnalysis extends AbstractDomainUsageAnalysis implements QVTcoreBaseVisitor<@NonNull DomainUsage>
{
protected abstract class AbstractDomainUsage implements DomainUsage.Internal
{
@@ -316,11 +316,6 @@ public class RootDomainUsageAnalysis extends AbstractDomainUsageAnalysis impleme
* The domains in which the containing class of a property may be used.
*/
protected final @NonNull Map<@NonNull Property, @NonNull DomainUsage> property2containingClassUsage = new HashMap<@NonNull Property, @NonNull DomainUsage>();
-
- /**
- * The domains in which the referred type of a property may be used.
- */
- protected final @NonNull Map<@NonNull Property, @NonNull DomainUsage> property2referredTypeUsage = new HashMap<@NonNull Property, @NonNull DomainUsage>();
/**
* The nested analyses for declared operations.
@@ -474,32 +469,12 @@ public class RootDomainUsageAnalysis extends AbstractDomainUsageAnalysis impleme
assert newUsage != null;
for (@NonNull Property property : ClassUtil.nullFree(asClass.getOwnedProperties())) {
property2containingClassUsage.put(property, newUsage);
- DomainUsage referredTypeUsage = null;
- for (Element annotation : property.getOwnedAnnotations()) {
- if (annotation instanceof Annotation) {
- Annotation annotation2 = (Annotation)annotation;
- if (DomainUsage.QVT_DOMAINS_ANNOTATION_SOURCE.equals(annotation2.getName())) {
- for (Detail detail : annotation2.getOwnedDetails()) {
- if (DomainUsage.QVT_DOMAINS_ANNOTATION_REFERRED_DOMAIN.equals(detail.getName())) {
- int mask = 0;
- for (String value : detail.getValues()) {
- Integer bit = name2bit.get(value.trim());
- if (bit != null) {
- mask |= 1 << bit;
- }
- }
- referredTypeUsage = getValidUsage(mask);
- }
- }
- }
-
- }
- }
+ DomainUsage referredTypeUsage = getAnnotatedUsage(property);
if (referredTypeUsage == null) {
referredTypeUsage = visit(property.getType());
}
// System.out.println(property + " => " + referredTypeUsage);
- property2referredTypeUsage.put(property, referredTypeUsage);
+// property2referredTypeUsage.put(property, referredTypeUsage);
}
}
class2usage.put(((StandardLibraryInternal)context.getStandardLibrary()).getOclTypeType(), getAnyUsage()); // Needed by oclIsKindOf() etc
@@ -575,6 +550,31 @@ public class RootDomainUsageAnalysis extends AbstractDomainUsageAnalysis impleme
return analysis;
}
+ protected @Nullable DomainUsage getAnnotatedUsage(@NonNull Property property) {
+ DomainUsage referredTypeUsage = null;
+ for (Element annotation : property.getOwnedAnnotations()) {
+ if (annotation instanceof Annotation) {
+ Annotation annotation2 = (Annotation)annotation;
+ if (DomainUsage.QVT_DOMAINS_ANNOTATION_SOURCE.equals(annotation2.getName())) {
+ for (Detail detail : annotation2.getOwnedDetails()) {
+ if (DomainUsage.QVT_DOMAINS_ANNOTATION_REFERRED_DOMAIN.equals(detail.getName())) {
+ int mask = 0;
+ for (String value : detail.getValues()) {
+ Integer bit = name2bit.get(value.trim());
+ if (bit != null) {
+ mask |= 1 << bit;
+ }
+ }
+ referredTypeUsage = getValidUsage(mask);
+ }
+ }
+ }
+
+ }
+ }
+ return referredTypeUsage;
+ }
+
protected int getAnyMask() {
return (1 << bit2typedModel.size()) - 1;
}
diff --git a/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiTransformationAnalysis.java b/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiTransformationAnalysis.java
index 3d8d75d6d..ff74e6d63 100644
--- a/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiTransformationAnalysis.java
+++ b/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiTransformationAnalysis.java
@@ -530,9 +530,9 @@ public class QVTiTransformationAnalysis
public boolean isHazardousRead(@NonNull Mapping asMapping, @NonNull NavigationCallExp asNavigationCallExp) {
Property asProperty = PivotUtil.getReferredProperty(asNavigationCallExp);
OCLExpression asSource = asNavigationCallExp.getOwnedSource();
- DomainUsage domainUsage = domainAnalysis.basicGetUsage(asSource);
- if (domainUsage != null) {
- TypedModel typedModel = domainUsage.getTypedModel(asSource);
+ DomainUsage domainUsage1 = domainAnalysis.basicGetUsage(asSource);
+ if (domainUsage1 != null) {
+ TypedModel typedModel = domainUsage1.getTypedModel(asSource);
if (typedModel != null) {
Area area = QVTcoreBaseUtil.getArea(asMapping, typedModel);
if ((area instanceof ImperativeArea) && ((ImperativeArea)area).getCheckedProperties().contains(asProperty)) {
@@ -541,7 +541,6 @@ public class QVTiTransformationAnalysis
}
}
Property asOppositeProperty = asProperty.getOpposite();
- domainUsage = domainAnalysis.basicGetUsage(asProperty.getType());
DomainUsage domainUsage2 = domainAnalysis.basicGetUsage(asNavigationCallExp);
if (domainUsage2 != null) {
TypedModel typedModel = domainUsage2.getTypedModel(asProperty);
diff --git a/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/utilities/QVTimperativeDomainUsageAnalysis.java b/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/utilities/QVTimperativeDomainUsageAnalysis.java
index 8c4432b0c..2be61ae79 100644
--- a/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/utilities/QVTimperativeDomainUsageAnalysis.java
+++ b/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/utilities/QVTimperativeDomainUsageAnalysis.java
@@ -11,7 +11,6 @@
package org.eclipse.qvtd.pivot.qvtimperative.utilities;
import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.ocl.pivot.Element;
import org.eclipse.ocl.pivot.Type;
import org.eclipse.ocl.pivot.Variable;
@@ -38,7 +37,7 @@ import org.eclipse.qvtd.pivot.qvtimperative.util.QVTimperativeVisitor;
/**
* A QVTimperativeDomainUsageAnalysis identifies a constrained domain result from the DomainUsageAnalysis of an OCL AST node.
*/
-public class QVTimperativeDomainUsageAnalysis extends RootDomainUsageAnalysis implements QVTimperativeVisitor<DomainUsage>
+public class QVTimperativeDomainUsageAnalysis extends RootDomainUsageAnalysis implements QVTimperativeVisitor<@NonNull DomainUsage>
{
public QVTimperativeDomainUsageAnalysis(@NonNull EnvironmentFactory environmentFactory) {
super(environmentFactory);
@@ -50,41 +49,41 @@ public class QVTimperativeDomainUsageAnalysis extends RootDomainUsageAnalysis im
}
@Override
- public @Nullable DomainUsage visitConnectionAssignment(@NonNull ConnectionAssignment object) {
+ public @NonNull DomainUsage visitConnectionAssignment(@NonNull ConnectionAssignment object) {
DomainUsage valueUsage = visit(object.getValue());
DomainUsage variableUsage = visit(object.getTargetVariable());
return intersection(variableUsage, valueUsage);
}
@Override
- public @Nullable DomainUsage visitConnectionStatement(@NonNull ConnectionStatement object) {
+ public @NonNull DomainUsage visitConnectionStatement(@NonNull ConnectionStatement object) {
DomainUsage valueUsage = visit(object.getValue());
DomainUsage variableUsage = visit(object.getTargetVariable());
return intersection(variableUsage, valueUsage);
}
@Override
- public @Nullable DomainUsage visitConnectionVariable(@NonNull ConnectionVariable object) {
+ public @NonNull DomainUsage visitConnectionVariable(@NonNull ConnectionVariable object) {
return visitVariable(object);
}
@Override
- public @Nullable DomainUsage visitImperativeBottomPattern(@NonNull ImperativeBottomPattern object) {
+ public @NonNull DomainUsage visitImperativeBottomPattern(@NonNull ImperativeBottomPattern object) {
return visitBottomPattern(object);
}
@Override
- public @Nullable DomainUsage visitImperativeDomain(@NonNull ImperativeDomain object) {
+ public @NonNull DomainUsage visitImperativeDomain(@NonNull ImperativeDomain object) {
return visitCoreDomain(object);
}
@Override
- public @Nullable DomainUsage visitImperativeModel(@NonNull ImperativeModel object) {
+ public @NonNull DomainUsage visitImperativeModel(@NonNull ImperativeModel object) {
return visitBaseModel(object);
}
@Override
- public @Nullable DomainUsage visitMapping(@NonNull Mapping object) {
+ public @NonNull DomainUsage visitMapping(@NonNull Mapping object) {
DomainUsage usage = getNoneUsage();
setUsage(object, usage);
visitRule(object);
@@ -95,7 +94,7 @@ public class QVTimperativeDomainUsageAnalysis extends RootDomainUsageAnalysis im
}
@Override
- public @Nullable DomainUsage visitMappingCall(@NonNull MappingCall object) {
+ public @NonNull DomainUsage visitMappingCall(@NonNull MappingCall object) {
for (MappingCallBinding mappingCallBinding : object.getBinding()) {
visit(mappingCallBinding);
}
@@ -103,14 +102,14 @@ public class QVTimperativeDomainUsageAnalysis extends RootDomainUsageAnalysis im
}
@Override
- public @Nullable DomainUsage visitMappingCallBinding(@NonNull MappingCallBinding object) {
+ public @NonNull DomainUsage visitMappingCallBinding(@NonNull MappingCallBinding object) {
DomainUsage valueUsage = visit(object.getValue());
DomainUsage variableUsage = visit(object.getBoundVariable());
return intersection(valueUsage, variableUsage);
}
@Override
- public @Nullable DomainUsage visitMappingLoop(@NonNull MappingLoop object) {
+ public @NonNull DomainUsage visitMappingLoop(@NonNull MappingLoop object) {
DomainUsage sourceUsage = visit(object.getOwnedSource());
for (Variable iterator : object.getOwnedIterators()) {
if (iterator != null) {
@@ -122,7 +121,7 @@ public class QVTimperativeDomainUsageAnalysis extends RootDomainUsageAnalysis im
}
@Override
- public @Nullable DomainUsage visitMappingSequence(@NonNull MappingSequence object) {
+ public @NonNull DomainUsage visitMappingSequence(@NonNull MappingSequence object) {
for (MappingStatement mappingStatement : object.getMappingStatements()) {
visit(mappingStatement);
}
@@ -130,12 +129,12 @@ public class QVTimperativeDomainUsageAnalysis extends RootDomainUsageAnalysis im
}
@Override
- public @Nullable DomainUsage visitMappingStatement(@NonNull MappingStatement object) {
+ public @NonNull DomainUsage visitMappingStatement(@NonNull MappingStatement object) {
return visitOCLExpression(object);
}
@Override
- public @Nullable DomainUsage visitVariableExp(@NonNull VariableExp object) {
+ public @NonNull DomainUsage visitVariableExp(@NonNull VariableExp object) {
StandardLibraryInternal standardLibrary = (StandardLibraryInternal) context.getStandardLibrary();
Type transformationType = standardLibrary.getLibraryType("Transformation");
if ((transformationType != null) && object.getType().conformsTo(standardLibrary, transformationType)) {
@@ -145,7 +144,7 @@ public class QVTimperativeDomainUsageAnalysis extends RootDomainUsageAnalysis im
}
@Override
- public @Nullable DomainUsage visitVariablePredicate(@NonNull VariablePredicate object) {
+ public @NonNull DomainUsage visitVariablePredicate(@NonNull VariablePredicate object) {
return visitPredicate(object);
}
}

Back to the top