summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Efftinge2011-08-05 07:56:07 (EDT)
committerEd Merks2011-08-05 07:56:07 (EDT)
commitc41f2ded5be8dc23350beb8253921b12839922b7 (patch)
treec78e184dd5d4695654949be4c96c18abf66de6d0
parent16954f514a3765ce31b3fc7375fdedee9237634d (diff)
downloadorg.eclipse.emf-c41f2ded5be8dc23350beb8253921b12839922b7.zip
org.eclipse.emf-c41f2ded5be8dc23350beb8253921b12839922b7.tar.gz
org.eclipse.emf-c41f2ded5be8dc23350beb8253921b12839922b7.tar.bz2
make compiler compile reference to 'this' properly
-rw-r--r--org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/generator/XcoreGenerator.xtend2
-rw-r--r--org.eclipse.emf.ecore.xcore/xtend-gen/org/eclipse/emf/ecore/xcore/generator/XcoreGenerator.java6
2 files changed, 8 insertions, 0 deletions
diff --git a/org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/generator/XcoreGenerator.xtend b/org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/generator/XcoreGenerator.xtend
index 3307fb1..81c406e 100644
--- a/org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/generator/XcoreGenerator.xtend
+++ b/org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/generator/XcoreGenerator.xtend
@@ -21,6 +21,7 @@ import org.eclipse.emf.codegen.ecore.generator.Generator
import org.eclipse.emf.codegen.ecore.genmodel.generator.GenBaseGeneratorAdapter
import org.eclipse.emf.common.util.BasicMonitor
import org.eclipse.emf.ecore.xcore.mappings.XcoreMapper
+import org.eclipse.xtext.common.types.JvmOperation
class XcoreGenerator implements IGenerator {
@@ -36,6 +37,7 @@ class XcoreGenerator implements IGenerator {
for (op : pack.allContentsIterable.filter(typeof(XOperation))) {
val eOperation = op.mapping.EOperation
val appendable = new StringBuilderBasedAppendable()
+ appendable.declareVariable(mappings.getMapping(op).jvmOperation.declaringType,"this");
// val expectedType = op.jvmOperation.returnType
compiler.compile(op.body, appendable, null)
eOperation.EAnnotations.add(createGenModelAnnotation("body", appendable.toString))
diff --git a/org.eclipse.emf.ecore.xcore/xtend-gen/org/eclipse/emf/ecore/xcore/generator/XcoreGenerator.java b/org.eclipse.emf.ecore.xcore/xtend-gen/org/eclipse/emf/ecore/xcore/generator/XcoreGenerator.java
index 952f2ab..4eb704a 100644
--- a/org.eclipse.emf.ecore.xcore/xtend-gen/org/eclipse/emf/ecore/xcore/generator/XcoreGenerator.java
+++ b/org.eclipse.emf.ecore.xcore/xtend-gen/org/eclipse/emf/ecore/xcore/generator/XcoreGenerator.java
@@ -18,6 +18,8 @@ import org.eclipse.emf.ecore.xcore.XOperation;
import org.eclipse.emf.ecore.xcore.XPackage;
import org.eclipse.emf.ecore.xcore.mappings.XOperationMapping;
import org.eclipse.emf.ecore.xcore.mappings.XcoreMapper;
+import org.eclipse.xtext.common.types.JvmDeclaredType;
+import org.eclipse.xtext.common.types.JvmOperation;
import org.eclipse.xtext.generator.IFileSystemAccess;
import org.eclipse.xtext.generator.IGenerator;
import org.eclipse.xtext.xbase.XBlockExpression;
@@ -49,6 +51,10 @@ public class XcoreGenerator implements IGenerator {
final EOperation eOperation = _eOperation;
StringBuilderBasedAppendable _stringBuilderBasedAppendable = new StringBuilderBasedAppendable();
final StringBuilderBasedAppendable appendable = _stringBuilderBasedAppendable;
+ XOperationMapping _mapping_1 = this.mappings.getMapping(op);
+ JvmOperation _jvmOperation = _mapping_1.getJvmOperation();
+ JvmDeclaredType _declaringType = _jvmOperation.getDeclaringType();
+ appendable.declareVariable(_declaringType, "this");
XBlockExpression _body = op.getBody();
this.compiler.compile(_body, appendable, null);
EList<EAnnotation> _eAnnotations = eOperation.getEAnnotations();