Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Willink2015-06-07 09:22:09 +0000
committerEd Willink2015-06-07 09:26:51 +0000
commit166901bec89471c3abe6eeb33c2ce61ec225be58 (patch)
treef936cb4e56f3b5774942cef10bb310f7c76bab0a
parent832217dcbd5dd69b8d39f8a43dc7191355eb3553 (diff)
downloadorg.eclipse.qvtd-166901bec89471c3abe6eeb33c2ce61ec225be58.tar.gz
org.eclipse.qvtd-166901bec89471c3abe6eeb33c2ce61ec225be58.tar.xz
org.eclipse.qvtd-166901bec89471c3abe6eeb33c2ce61ec225be58.zip
[469559] Provided extended VariableFinder
-rw-r--r--plugins/org.eclipse.qvtd.debug/src/org/eclipse/qvtd/debug/evaluator/QVTiVMNestedEvaluationEnvironment.java10
-rw-r--r--plugins/org.eclipse.qvtd.debug/src/org/eclipse/qvtd/debug/evaluator/QVTiVMRootEvaluationEnvironment.java10
-rw-r--r--plugins/org.eclipse.qvtd.debug/src/org/eclipse/qvtd/debug/vm/QVTiVMVirtualMachine.java1
-rw-r--r--plugins/org.eclipse.qvtd.debug/src/org/eclipse/qvtd/debug/vm/QVTiVariableFinder.java180
-rw-r--r--plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiModelManager.java16
5 files changed, 214 insertions, 3 deletions
diff --git a/plugins/org.eclipse.qvtd.debug/src/org/eclipse/qvtd/debug/evaluator/QVTiVMNestedEvaluationEnvironment.java b/plugins/org.eclipse.qvtd.debug/src/org/eclipse/qvtd/debug/evaluator/QVTiVMNestedEvaluationEnvironment.java
index d8752056a..b7bb20d7e 100644
--- a/plugins/org.eclipse.qvtd.debug/src/org/eclipse/qvtd/debug/evaluator/QVTiVMNestedEvaluationEnvironment.java
+++ b/plugins/org.eclipse.qvtd.debug/src/org/eclipse/qvtd/debug/evaluator/QVTiVMNestedEvaluationEnvironment.java
@@ -18,19 +18,22 @@ import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.ocl.examples.debug.vm.UnitLocation;
+import org.eclipse.ocl.examples.debug.vm.VariableFinder;
import org.eclipse.ocl.examples.debug.vm.core.VMDebugCore;
import org.eclipse.ocl.examples.debug.vm.evaluator.IVMEnvironmentFactory;
import org.eclipse.ocl.examples.debug.vm.evaluator.IVMEvaluationEnvironment;
+import org.eclipse.ocl.examples.debug.vm.evaluator.IVMEvaluationEnvironmentExtension;
import org.eclipse.ocl.examples.debug.vm.utils.ASTBindingHelper;
import org.eclipse.ocl.examples.debug.vm.utils.VMRuntimeException;
import org.eclipse.ocl.examples.debug.vm.utils.VMStackTraceBuilder;
import org.eclipse.ocl.pivot.Element;
import org.eclipse.ocl.pivot.NamedElement;
import org.eclipse.ocl.pivot.Variable;
+import org.eclipse.qvtd.debug.vm.QVTiVariableFinder;
import org.eclipse.qvtd.pivot.qvtbase.Transformation;
import org.eclipse.qvtd.pivot.qvtimperative.evaluation.QVTiNestedEvaluationEnvironment;
-public class QVTiVMNestedEvaluationEnvironment extends QVTiNestedEvaluationEnvironment implements IQVTiVMEvaluationEnvironment
+public class QVTiVMNestedEvaluationEnvironment extends QVTiNestedEvaluationEnvironment implements IQVTiVMEvaluationEnvironment, IVMEvaluationEnvironmentExtension
{
protected final @NonNull IVMEnvironmentFactory vmEnvironmentFactory;
private @NonNull Element myCurrentIP;
@@ -52,6 +55,11 @@ public class QVTiVMNestedEvaluationEnvironment extends QVTiNestedEvaluationEnvir
public @NonNull IQVTiVMEvaluationEnvironment createClonedEvaluationEnvironment() {
throw new UnsupportedOperationException();
}
+
+ @Override
+ public @NonNull VariableFinder createVariableFinder(boolean isStoreValues) {
+ return new QVTiVariableFinder(this, isStoreValues);
+ }
@Override
public @NonNull Element getCurrentIP() {
diff --git a/plugins/org.eclipse.qvtd.debug/src/org/eclipse/qvtd/debug/evaluator/QVTiVMRootEvaluationEnvironment.java b/plugins/org.eclipse.qvtd.debug/src/org/eclipse/qvtd/debug/evaluator/QVTiVMRootEvaluationEnvironment.java
index a79e036de..94709e7c8 100644
--- a/plugins/org.eclipse.qvtd.debug/src/org/eclipse/qvtd/debug/evaluator/QVTiVMRootEvaluationEnvironment.java
+++ b/plugins/org.eclipse.qvtd.debug/src/org/eclipse/qvtd/debug/evaluator/QVTiVMRootEvaluationEnvironment.java
@@ -21,7 +21,9 @@ import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.ocl.examples.debug.vm.UnitLocation;
+import org.eclipse.ocl.examples.debug.vm.VariableFinder;
import org.eclipse.ocl.examples.debug.vm.evaluator.IVMEnvironmentFactory;
+import org.eclipse.ocl.examples.debug.vm.evaluator.IVMEvaluationEnvironmentExtension;
import org.eclipse.ocl.examples.debug.vm.utils.ASTBindingHelper;
import org.eclipse.ocl.examples.debug.vm.utils.VMRuntimeException;
import org.eclipse.ocl.examples.debug.vm.utils.VMStackTraceBuilder;
@@ -32,12 +34,13 @@ import org.eclipse.ocl.pivot.PivotPackage;
import org.eclipse.ocl.pivot.Variable;
import org.eclipse.ocl.pivot.utilities.ClassUtil;
import org.eclipse.qvtd.debug.core.QVTiDebugCore;
+import org.eclipse.qvtd.debug.vm.QVTiVariableFinder;
import org.eclipse.qvtd.pivot.qvtbase.Transformation;
import org.eclipse.qvtd.pivot.qvtbase.TypedModel;
import org.eclipse.qvtd.pivot.qvtimperative.evaluation.QVTiModelManager;
import org.eclipse.qvtd.pivot.qvtimperative.evaluation.QVTiRootEvaluationEnvironment;
-public class QVTiVMRootEvaluationEnvironment extends QVTiRootEvaluationEnvironment implements IQVTiVMEvaluationEnvironment
+public class QVTiVMRootEvaluationEnvironment extends QVTiRootEvaluationEnvironment implements IQVTiVMEvaluationEnvironment, IVMEvaluationEnvironmentExtension
{
protected final @NonNull IVMEnvironmentFactory vmEnvironmentFactory;
// private IContext myContext;
@@ -67,6 +70,11 @@ public class QVTiVMRootEvaluationEnvironment extends QVTiRootEvaluationEnvironme
public @NonNull IQVTiVMEvaluationEnvironment createClonedEvaluationEnvironment() {
throw new UnsupportedOperationException();
}
+
+ @Override
+ public @NonNull VariableFinder createVariableFinder(boolean isStoreValues) {
+ return new QVTiVariableFinder(this, isStoreValues);
+ }
// @Override
// IContext getContext() {
diff --git a/plugins/org.eclipse.qvtd.debug/src/org/eclipse/qvtd/debug/vm/QVTiVMVirtualMachine.java b/plugins/org.eclipse.qvtd.debug/src/org/eclipse/qvtd/debug/vm/QVTiVMVirtualMachine.java
index 161a1a03b..039daf3c0 100644
--- a/plugins/org.eclipse.qvtd.debug/src/org/eclipse/qvtd/debug/vm/QVTiVMVirtualMachine.java
+++ b/plugins/org.eclipse.qvtd.debug/src/org/eclipse/qvtd/debug/vm/QVTiVMVirtualMachine.java
@@ -156,7 +156,6 @@ public class QVTiVMVirtualMachine extends VMVirtualMachine
return vmStackFrame;
}
-
public QVTiVMVirtualMachine(@NonNull DebuggableRunner runner, @NonNull QVTiEvaluationContext evaluationContext) {
super(runner, runner.createDebuggableAdapter(evaluationContext));
}
diff --git a/plugins/org.eclipse.qvtd.debug/src/org/eclipse/qvtd/debug/vm/QVTiVariableFinder.java b/plugins/org.eclipse.qvtd.debug/src/org/eclipse/qvtd/debug/vm/QVTiVariableFinder.java
new file mode 100644
index 000000000..bfd4a7c2d
--- /dev/null
+++ b/plugins/org.eclipse.qvtd.debug/src/org/eclipse/qvtd/debug/vm/QVTiVariableFinder.java
@@ -0,0 +1,180 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Willink Transformations and others.
+ * All rights reserved. This program and the accompanying materials
+ * 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
+ *******************************************************************************/
+package org.eclipse.qvtd.debug.vm;
+
+import java.util.List;
+
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.ocl.examples.debug.vm.VariableFinder;
+import org.eclipse.ocl.examples.debug.vm.data.VMVariableData;
+import org.eclipse.ocl.examples.debug.vm.evaluator.IVMEvaluationEnvironment;
+import org.eclipse.ocl.pivot.TypedElement;
+import org.eclipse.ocl.pivot.Variable;
+import org.eclipse.qvtd.pivot.qvtbase.Transformation;
+import org.eclipse.qvtd.pivot.qvtbase.TypedModel;
+import org.eclipse.qvtd.pivot.qvtimperative.evaluation.QVTiModelManager;
+import org.eclipse.qvtd.pivot.qvtimperative.evaluation.QVTiModelManager.QVTiTransformationInstance;
+import org.eclipse.qvtd.pivot.qvtimperative.evaluation.QVTiModelManager.QVTiTypedModelInstance;
+
+public class QVTiVariableFinder extends VariableFinder
+{
+ public QVTiVariableFinder(@NonNull IVMEvaluationEnvironment vmEvaluationEnvironment, boolean isStoreValues) {
+ super(vmEvaluationEnvironment, isStoreValues);
+ }
+
+ @Override
+ public void collectChildVars(Object valueObject, @NonNull String[] parentPath, @Nullable String containerType, @NonNull List<VMVariableData> result) {
+ if (valueObject instanceof QVTiTransformationInstance) {
+ String childPath[] = new String[parentPath.length + 1];
+ System.arraycopy(parentPath, 0, childPath, 0, parentPath.length);
+ QVTiTransformationInstance transformationInstance = (QVTiTransformationInstance)valueObject;
+ Transformation transformation = transformationInstance.getTransformation();
+ for (TypedModel typedModel : transformation.getModelParameter()) {
+ Variable variable = typedModel.getOwnedContext();
+ String varName = typedModel.getName();
+ assert varName != null;
+ childPath[childPath.length - 1] = varName;
+ VMVariableData elementVar = new VMVariableData(varName, createURI(childPath).toString());
+ elementVar.kind = VMVariableData.MODEL_PARAMETER;
+ QVTiModelManager modelManager = transformationInstance.getModelManager();
+ Resource model = modelManager.getModel(typedModel);
+ setValueAndType(elementVar, model, "TypedModel");
+ if (fIsStoreValues) {
+ elementVar.valueObject = variable;
+ }
+ result.add(elementVar);
+ }
+ }
+ else if (valueObject instanceof QVTiTypedModelInstance) {
+ QVTiTypedModelInstance typedModelInstance = (QVTiTypedModelInstance)valueObject;
+ QVTiModelManager modelManager = typedModelInstance.getModelManager();
+ TypedModel typedModel = typedModelInstance.getTypedModel();
+ Resource model = modelManager.getModel(typedModel);
+ super.collectChildVars(model, parentPath, containerType, result);
+ }
+ else {
+ super.collectChildVars(valueObject, parentPath, containerType, result);
+ }
+ }
+
+ @Override
+ protected Object findChildObject(Object parentObj, @Nullable String optParentDeclaredType,
+ @NonNull String[] varTreePath, int pathIndex) {
+ Object nextObject = null;
+ String nextDeclaredType = null;
+ if (parentObj instanceof QVTiTransformationInstance) {
+ QVTiTransformationInstance transformationInstance = (QVTiTransformationInstance)parentObj;
+ Transformation transformation = transformationInstance.getTransformation();
+ TypedModel typedModel = transformation.getModelParameter(varTreePath[pathIndex]);
+ QVTiModelManager modelManager = transformationInstance.getModelManager();
+ nextObject = typedModel != null ? modelManager.getModel(typedModel) : null;
+ nextDeclaredType = "Resource";
+ }
+ else if (parentObj instanceof QVTiTypedModelInstance) {
+ QVTiTypedModelInstance typedModelInstance = (QVTiTypedModelInstance)parentObj;
+ QVTiModelManager modelManager = typedModelInstance.getModelManager();
+ TypedModel typedModel = typedModelInstance.getTypedModel();
+ Resource model = modelManager.getModel(typedModel);
+ return super.findChildObject(model, optParentDeclaredType, varTreePath, pathIndex);
+ }
+ else {
+ return super.findChildObject(parentObj, optParentDeclaredType, varTreePath, pathIndex);
+ }
+ int nextIndex = pathIndex + 1;
+ if (nextIndex < varTreePath.length) {
+ if (nextObject != null) {
+ // continue navigation in the hierarchy
+ return findChildObject(nextObject, nextDeclaredType, varTreePath, nextIndex);
+ } else {
+ // we can't navigate further via the path due to <null> termination object
+ return null;
+ }
+ }
+
+// this.fTargetVar = childVar;
+ return nextObject;
+ }
+
+ @Override
+ protected String getDeclaredType(Object valueObject) {
+ if (valueObject instanceof QVTiTransformationInstance) {
+ return "qvtbaselibrary::Transformation";
+// return super.getDeclaredType(((QVTiTransformationInstance)valueObject).getTransformation());
+ }
+ else if (valueObject instanceof QVTiTypedModelInstance) {
+ return "qvtbaselibrary::Model";
+/* QVTiTypedModelInstance typedModelInstance = (QVTiTypedModelInstance)valueObject;
+ QVTiModelManager modelManager = typedModelInstance.getModelManager();
+ TypedModel typedModel = typedModelInstance.getTypedModel();
+ Resource model = modelManager.getModel(typedModel);
+ return "Resource"; */
+ }
+ else {
+ return super.getDeclaredType(valueObject);
+ }
+ }
+
+ @Override
+ protected @Nullable VMVariableData getVariable(@NonNull TypedElement variable, @Nullable Object pcObject) {
+/* EObject eContainer = variable.eContainer();
+ if (eContainer instanceof Transformation) {
+ Transformation transformation = (Transformation)eContainer;
+ String varName = variable.getName();
+ if (varName != null) {
+ VMVariableData var = new VMVariableData(varName, null);
+ var.valueObject = transformation;
+ setValueAndType(var, transformation, "Transformation");
+ return var;
+ }
+ }
+ else if (eContainer instanceof TypedModel) {
+ TypedModel typedModel = (TypedModel)eContainer;
+
+
+ QVTiModelManager modelManager = (QVTiModelManager) fEvalEnv.getModelManager();
+ Resource model = modelManager.getModel(typedModel);
+
+ String varName = variable.getName();
+ if (varName != null) {
+ VMVariableData var = new VMVariableData(varName, null);
+ var.valueObject = model;
+ setValueAndType(var, model, "Resource");
+ return var;
+ }
+ } */
+ return super.getVariable(variable, pcObject);
+ }
+
+ @Override
+ public void setValueAndType(@NonNull VMVariableData variable, @Nullable Object value, @Nullable String declaredTypeName) {
+ if (value instanceof QVTiTransformationInstance) {
+ super.setValueAndType(variable, ((QVTiTransformationInstance)value).getTransformation(), declaredTypeName);
+ }
+ else if (value instanceof QVTiTypedModelInstance) {
+ QVTiTypedModelInstance typedModelInstance = (QVTiTypedModelInstance)value;
+ QVTiModelManager modelManager = typedModelInstance.getModelManager();
+ TypedModel typedModel = typedModelInstance.getTypedModel();
+ Resource model = modelManager.getModel(typedModel);
+ super.setValueAndType(variable, model, declaredTypeName);
+// Resource resource = (Resource) value;
+// EClass eClass = eObject.eClass();
+// @SuppressWarnings("null")@NonNull String strVal = String.valueOf(resource.getURI());
+// variable.value = new VMValueData(VMValueData.RESOURCE, strVal, true);
+// @SuppressWarnings("null")@NonNull String className = resource.getClass().getSimpleName();
+// variable.type = new VMTypeData(VMTypeData.RESOURCE, className, declaredTypeName);
+ }
+ else {
+ super.setValueAndType(variable, value, declaredTypeName);
+ }
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiModelManager.java b/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiModelManager.java
index 89c87c7dd..1e269f1ba 100644
--- a/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiModelManager.java
+++ b/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiModelManager.java
@@ -335,6 +335,14 @@ public class QVTiModelManager implements ModelManager
this.modelManager = modelManager;
this.transformation = transformation;
}
+
+ public @NonNull QVTiModelManager getModelManager() {
+ return modelManager;
+ }
+
+ public @NonNull Transformation getTransformation() {
+ return transformation;
+ }
}
public static class QVTiTypedModelInstance implements TypedModelInstance
@@ -370,10 +378,18 @@ public class QVTiModelManager implements ModelManager
throw new UnsupportedOperationException();
}
+ public @NonNull QVTiModelManager getModelManager() {
+ return modelManager;
+ }
+
@Override
public @NonNull Collection<EObject> getRootObjects() {
throw new UnsupportedOperationException();
}
+
+ public @NonNull TypedModel getTypedModel() {
+ return typedModel;
+ }
}
public Object getTransformationInstance(@NonNull Transformation transformation) {

Back to the top