Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdolfo SBH2016-07-01 14:54:55 +0000
committerEd Willink2016-10-05 04:13:11 +0000
commit4ed0795b71d749f34419bdf6c3f53d1f8e54e17e (patch)
tree0ca92197911f6101ae819be4b6da24311ace4338 /plugins
parent057d71a2b750a1bc514b2c7f92c326b111d3a79f (diff)
downloadorg.eclipse.qvtd-4ed0795b71d749f34419bdf6c3f53d1f8e54e17e.tar.gz
org.eclipse.qvtd-4ed0795b71d749f34419bdf6c3f53d1f8e54e17e.tar.xz
org.eclipse.qvtd-4ed0795b71d749f34419bdf6c3f53d1f8e54e17e.zip
[497159] - Avoid to handle lookup errors when the lookup argument is a
constant (String-typed)
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.qvtd.cs2as.compiler/src/org/eclipse/qvtd/cs2as/compiler/internal/CS2ASJavaCompilerImpl.java33
1 files changed, 27 insertions, 6 deletions
diff --git a/plugins/org.eclipse.qvtd.cs2as.compiler/src/org/eclipse/qvtd/cs2as/compiler/internal/CS2ASJavaCompilerImpl.java b/plugins/org.eclipse.qvtd.cs2as.compiler/src/org/eclipse/qvtd/cs2as/compiler/internal/CS2ASJavaCompilerImpl.java
index 55760fb4c..0cf072542 100644
--- a/plugins/org.eclipse.qvtd.cs2as.compiler/src/org/eclipse/qvtd/cs2as/compiler/internal/CS2ASJavaCompilerImpl.java
+++ b/plugins/org.eclipse.qvtd.cs2as.compiler/src/org/eclipse/qvtd/cs2as/compiler/internal/CS2ASJavaCompilerImpl.java
@@ -41,6 +41,8 @@ import org.eclipse.ocl.pivot.OCLExpression;
import org.eclipse.ocl.pivot.Operation;
import org.eclipse.ocl.pivot.OperationCallExp;
import org.eclipse.ocl.pivot.Parameter;
+import org.eclipse.ocl.pivot.ids.ElementId;
+import org.eclipse.ocl.pivot.ids.TypeId;
import org.eclipse.ocl.pivot.utilities.ClassUtil;
import org.eclipse.qvtd.codegen.qvti.QVTiCodeGenOptions;
import org.eclipse.qvtd.codegen.qvti.analyzer.QVTiAS2CGVisitor;
@@ -235,12 +237,13 @@ public class CS2ASJavaCompilerImpl implements CS2ASJavaCompiler {
CGValuedElement lookupArg = cgArguments.get(0); // FIXMe improve handleLookupError
CGValuedElement initialSource = initialSourceCG(lookupArg);
- js.append("handleLookupError(");
- js.appendReferenceTo(initialSource);
- js.append(",");
- js.appendReferenceTo(lookupArg);
- js.append(");\n");
-
+ if (shouldHandleError(initialSource)) {
+ js.append("handleLookupError(");
+ js.appendReferenceTo(initialSource);
+ js.append(",");
+ js.appendReferenceTo(lookupArg);
+ js.append(");\n");
+ }
js.popIndentation();
js.append("};\n");
return true;
@@ -287,6 +290,24 @@ public class CS2ASJavaCompilerImpl implements CS2ASJavaCompiler {
}
return cgValue;
}
+
+ /**
+ * helper to decide if lookup error should be handled or not.
+ * For the time being, just the lookup arg source is the considered.
+ *
+ * FIXME FTB we exclude all String-typed lookup arguments to avoid the
+ * generation error. This incorrectly exclude valid String-based lookups
+ * where that string appears in the text. In that case, the containing object
+ * should be considered by further analysis of the CGValuedElement (See {@link #initialSourceCG(CGValuedElement)}
+ *
+ * @param cgValue
+ * @return <code>true</code>, if lookup error should be handled.
+ */
+ private boolean shouldHandleError(CGValuedElement cgValue) {
+ TypeId stringTypeId = context.getEnvironmentFactory().getStandardLibrary().getStringType().getTypeId();
+ ElementId valueTypeId = cgValue.getTypeId().getElementId();
+ return ! stringTypeId.equals(valueTypeId);
+ }
}
protected static class CS2ASAS2CGVisitor extends QVTiAS2CGVisitor {

Back to the top