Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Willink2016-10-08 13:37:09 +0000
committerEd Willink2016-10-30 11:36:51 +0000
commit5f5aa3cd4459e9fd70e85778d26e414b73255afa (patch)
treeced803dfd56789e94c3992c01801c5aec2c553f4
parent55205fb971e38d377a84c6e6434ddb90deb09ac3 (diff)
downloadorg.eclipse.qvtd-5f5aa3cd4459e9fd70e85778d26e414b73255afa.tar.gz
org.eclipse.qvtd-5f5aa3cd4459e9fd70e85778d26e414b73255afa.tar.xz
org.eclipse.qvtd-5f5aa3cd4459e9fd70e85778d26e414b73255afa.zip
[500962] Invocation Constructors are named
-rw-r--r--plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiCG2JavaVisitor.java4
-rw-r--r--plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/utilities/QVTiCGUtil.java10
-rw-r--r--plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiIncrementalExecutor.java2
-rw-r--r--plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/utilities/QVTimperativeUtil.java4
-rw-r--r--plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/Invocation.java6
-rw-r--r--plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/AbstractInvocationConstructor.java69
6 files changed, 59 insertions, 36 deletions
diff --git a/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiCG2JavaVisitor.java b/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiCG2JavaVisitor.java
index fd86172c8..d39a865d5 100644
--- a/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiCG2JavaVisitor.java
+++ b/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiCG2JavaVisitor.java
@@ -993,7 +993,9 @@ public class QVTiCG2JavaVisitor extends CG2JavaVisitor<@NonNull QVTiCodeGenerato
js.appendClassReference(AbstractInvocationConstructor.class);
js.append(" " + getMappingCtorName(cgMapping) + " = new ");
js.appendClassReference(AbstractInvocationConstructor.class);
- js.append("(idResolver)\n");
+ js.append("(idResolver, ");
+ js.appendString(QVTiCGUtil.getName(cgMapping));
+ js.append(")\n");
js.append("{\n");
js.pushIndentation(null);
js.append("@Override\n");
diff --git a/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/utilities/QVTiCGUtil.java b/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/utilities/QVTiCGUtil.java
index 14e83fa76..565c02fb2 100644
--- a/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/utilities/QVTiCGUtil.java
+++ b/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/utilities/QVTiCGUtil.java
@@ -4,7 +4,7 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* E.D.Willink - Initial API and implementation
*******************************************************************************/
@@ -14,9 +14,11 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.ocl.examples.codegen.cgmodel.CGElement;
+import org.eclipse.ocl.examples.codegen.utilities.CGUtil;
+import org.eclipse.ocl.pivot.utilities.ClassUtil;
import org.eclipse.qvtd.codegen.qvticgmodel.CGMapping;
-public class QVTiCGUtil
+public class QVTiCGUtil extends CGUtil
{
public static @Nullable CGMapping getContainingCGMapping(@NonNull CGElement cgElement) {
for (EObject eObject = cgElement; eObject != null; eObject = eObject.eContainer()) {
@@ -26,4 +28,8 @@ public class QVTiCGUtil
}
return null;
}
+
+ public static @NonNull String getName(@NonNull CGMapping cgMapping) {
+ return ClassUtil.nonNullState(cgMapping.getName());
+ }
}
diff --git a/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiIncrementalExecutor.java b/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiIncrementalExecutor.java
index f4edb7c3c..de0b4e6c9 100644
--- a/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiIncrementalExecutor.java
+++ b/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiIncrementalExecutor.java
@@ -163,7 +163,7 @@ public class QVTiIncrementalExecutor extends BasicQVTiExecutor
}
Invocation.Constructor invocationConstructor = mapping2invocationConstructor2.get(asMapping);
if (invocationConstructor == null) {
- invocationConstructor = new AbstractInvocationConstructor(idResolver)
+ invocationConstructor = new AbstractInvocationConstructor(idResolver, QVTimperativeUtil.getName(asMapping))
{
@Override
public @NonNull Invocation newInstance(@NonNull Object @NonNull [] theseValues) {
diff --git a/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/utilities/QVTimperativeUtil.java b/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/utilities/QVTimperativeUtil.java
index f956e6a15..41ef7cea6 100644
--- a/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/utilities/QVTimperativeUtil.java
+++ b/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/utilities/QVTimperativeUtil.java
@@ -256,6 +256,10 @@ public class QVTimperativeUtil extends QVTbaseUtil
return null;
}
+ public static @NonNull String getName(@NonNull Mapping asMapping) {
+ return ClassUtil.nonNullState(asMapping.getName());
+ }
+
public static @NonNull Mapping getOwnedMapping(@NonNull ImperativeTransformation transformation, @Nullable String name) {
return ClassUtil.nonNullState(NameUtil.getNameable(getOwnedMappings(transformation), name));
}
diff --git a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/Invocation.java b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/Invocation.java
index abfff4a2a..6f0a46735 100644
--- a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/Invocation.java
+++ b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/evaluation/Invocation.java
@@ -13,6 +13,7 @@ package org.eclipse.qvtd.runtime.evaluation;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.ocl.pivot.ids.IdResolver;
+import org.eclipse.ocl.pivot.utilities.Nameable;
/**
* An Invocation identifies a unique invocation of a Mapping and the objects/values bound to its guard variables.
@@ -43,7 +44,7 @@ public interface Invocation extends ExecutionVisitable
*/
void remove();
- public interface Constructor
+ public interface Constructor extends Nameable
{
/**
* Return the first invocation of this constructor with argValues, using newInstance(argValues) to
@@ -51,6 +52,9 @@ public interface Invocation extends ExecutionVisitable
*/
@Nullable Invocation getFirstInvocation(@NonNull Object @NonNull [] argValues);
+ @Override
+ @NonNull String getName();
+
/**
* Create the invocation identified by this constructor and values.
*/
diff --git a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/AbstractInvocationConstructor.java b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/AbstractInvocationConstructor.java
index 9d8330769..aebb0951f 100644
--- a/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/AbstractInvocationConstructor.java
+++ b/plugins/org.eclipse.qvtd.runtime/src/org/eclipse/qvtd/runtime/internal/evaluation/AbstractInvocationConstructor.java
@@ -4,7 +4,7 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* E.D.Willink - Initial API and implementation
*******************************************************************************/
@@ -23,7 +23,8 @@ import org.eclipse.qvtd.runtime.evaluation.Invocation;
public abstract class AbstractInvocationConstructor implements Invocation.Constructor
{
protected final IdResolver.@NonNull IdResolverExtension idResolver;
-
+ protected final @NonNull String name;
+
/**
* Map from invocation hashCode to one or more invocations with that hashCode. Single map entries use the
* Invocation directly as the entry. Colliding entries use a List<@NonNull Invocation> for the collisions.
@@ -31,44 +32,45 @@ public abstract class AbstractInvocationConstructor implements Invocation.Constr
* This map is used to inhibit repeated invocations.
*/
private final @NonNull Map<@NonNull Integer, @NonNull Object> hashCode2invocations = new HashMap<@NonNull Integer, @NonNull Object>();
-
- protected AbstractInvocationConstructor(@NonNull IdResolver idResolver) {
+
+ protected AbstractInvocationConstructor(@NonNull IdResolver idResolver, @NonNull String name) {
this.idResolver = (IdResolver.IdResolverExtension)idResolver;
+ this.name = name;
}
-
+
@Override
public @Nullable Invocation getFirstInvocation(@NonNull Object @NonNull [] argValues) {
int hashCode = 0;
- for (@Nullable Object argValue : argValues) {
- hashCode = 3 * hashCode + idResolver.oclHashCode(argValue);
- }
- synchronized (hashCode2invocations) {
- Object zeroOrMoreInvocations = hashCode2invocations.get(hashCode);
- Invocation oneInvocation = null;
+ for (@Nullable Object argValue : argValues) {
+ hashCode = 3 * hashCode + idResolver.oclHashCode(argValue);
+ }
+ synchronized (hashCode2invocations) {
+ Object zeroOrMoreInvocations = hashCode2invocations.get(hashCode);
+ Invocation oneInvocation = null;
List<@NonNull Invocation> twoOrMoreInvocations = null;
- if (zeroOrMoreInvocations instanceof Invocation) {
- oneInvocation = (Invocation)zeroOrMoreInvocations;
- if (oneInvocation.isEqual(idResolver, argValues)) {
- return null;
- }
- }
- else if (zeroOrMoreInvocations instanceof List<?>) {
- @SuppressWarnings("unchecked")@NonNull List<@NonNull Invocation> zeroOrMoreInvocations2 = (List<@NonNull Invocation>)zeroOrMoreInvocations;
- twoOrMoreInvocations = zeroOrMoreInvocations2;
+ if (zeroOrMoreInvocations instanceof Invocation) {
+ oneInvocation = (Invocation)zeroOrMoreInvocations;
+ if (oneInvocation.isEqual(idResolver, argValues)) {
+ return null;
+ }
+ }
+ else if (zeroOrMoreInvocations instanceof List<?>) {
+ @SuppressWarnings("unchecked")@NonNull List<@NonNull Invocation> zeroOrMoreInvocations2 = (List<@NonNull Invocation>)zeroOrMoreInvocations;
+ twoOrMoreInvocations = zeroOrMoreInvocations2;
for (@NonNull Invocation anInvocation : zeroOrMoreInvocations2) {
- if (anInvocation.isEqual(idResolver, argValues)) {
- return null;
- }
- }
- }
- Invocation theInvocation = newInstance(argValues);
+ if (anInvocation.isEqual(idResolver, argValues)) {
+ return null;
+ }
+ }
+ }
+ Invocation theInvocation = newInstance(argValues);
if (zeroOrMoreInvocations == null) {
hashCode2invocations.put(hashCode, theInvocation);
}
else if (twoOrMoreInvocations == null) {
- twoOrMoreInvocations = new ArrayList<@NonNull Invocation>(4);
- assert oneInvocation != null;
- twoOrMoreInvocations.add(oneInvocation);
+ twoOrMoreInvocations = new ArrayList<@NonNull Invocation>(4);
+ assert oneInvocation != null;
+ twoOrMoreInvocations.add(oneInvocation);
twoOrMoreInvocations.add(theInvocation);
hashCode2invocations.put(hashCode, twoOrMoreInvocations);
}
@@ -76,6 +78,11 @@ public abstract class AbstractInvocationConstructor implements Invocation.Constr
twoOrMoreInvocations.add(theInvocation);
}
return theInvocation;
- }
- }
+ }
+ }
+
+ @Override
+ public @NonNull String getName() {
+ return name;
+ }
} \ No newline at end of file

Back to the top