summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Efftinge2011-08-04 10:41:03 (EDT)
committerEd Merks2011-08-04 10:41:03 (EDT)
commitcea53a2edf92f9476332caa1979f8f13a9a58ee7 (patch)
tree161a828f4b8139314a2c766e15ff7947c6bf15bf
parent1ffd21cf419c50c88bc171d80268dc9b2445105e (diff)
downloadorg.eclipse.emf-cea53a2edf92f9476332caa1979f8f13a9a58ee7.zip
org.eclipse.emf-cea53a2edf92f9476332caa1979f8f13a9a58ee7.tar.gz
org.eclipse.emf-cea53a2edf92f9476332caa1979f8f13a9a58ee7.tar.bz2
more generator prototyping
-rw-r--r--org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/generator/XcoreGenerator.xtend13
-rw-r--r--org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/util/XcoreJvmInferrer.java6
-rw-r--r--org.eclipse.emf.ecore.xcore/xtend-gen/org/eclipse/emf/ecore/xcore/generator/XcoreGenerator.java25
3 files changed, 30 insertions, 14 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 7ccfbdd..e982297 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
@@ -17,6 +17,9 @@ import org.eclipse.xtext.xbase.compiler.StringBuilderBasedAppendable
import org.eclipse.emf.ecore.EcoreFactory
import org.eclipse.emf.codegen.ecore.genmodel.GenModelPackage
import org.eclipse.emf.codegen.ecore.genmodel.GenModel
+import org.eclipse.emf.codegen.ecore.generator.Generator
+import org.eclipse.emf.codegen.ecore.genmodel.generator.GenBaseGeneratorAdapter
+import org.eclipse.emf.common.util.BasicMonitor
class XcoreGenerator implements IGenerator {
@@ -32,8 +35,8 @@ class XcoreGenerator implements IGenerator {
for (op : pack.allContentsIterable.filter(typeof(XOperation))) {
val eOperation = op.EOperation
val appendable = new StringBuilderBasedAppendable()
- val expectedType = op.jvmOperation.returnType
- compiler.compile(op.body, appendable, expectedType)
+// val expectedType = op.jvmOperation.returnType
+ compiler.compile(op.body, appendable, null)
eOperation.EAnnotations.add(createGenModelAnnotation("body", appendable.toString))
}
@@ -41,7 +44,11 @@ class XcoreGenerator implements IGenerator {
}
def generateGenModel(GenModel genModel) {
- genModel.gen(null)
+ genModel.canGenerate = true
+ val generator = new Generator()
+ generator.input = genModel
+ generator.generate(genModel, GenBaseGeneratorAdapter::MODEL_PROJECT_TYPE,
+ new BasicMonitor());
}
def createGenModelAnnotation(String key, String value) {
diff --git a/org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/util/XcoreJvmInferrer.java b/org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/util/XcoreJvmInferrer.java
index 8cb9c1e..3cb8018 100644
--- a/org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/util/XcoreJvmInferrer.java
+++ b/org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/util/XcoreJvmInferrer.java
@@ -67,9 +67,9 @@ public class XcoreJvmInferrer
jvmGenericType.setPackageName(genClass.getGenPackage().getInterfacePackageName());
jvmGenericType.setVisibility(JvmVisibility.PUBLIC);
- JvmTypeReference eObjectImpl = typeReferences.getTypeForName(EObjectImpl.class, genClass);
- jvmGenericType.getSuperTypes().add(eObjectImpl);
-
+// JvmTypeReference eObjectImpl = typeReferences.getTypeForName(EObjectImpl.class, genClass);
+// jvmGenericType.getSuperTypes().add(eObjectImpl);
+//
result.add(jvmGenericType);
return result;
}
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 ffc929f..aeeae8c 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
@@ -1,8 +1,12 @@
package org.eclipse.emf.ecore.xcore.generator;
import com.google.inject.Inject;
+import org.eclipse.emf.codegen.ecore.generator.Generator;
import org.eclipse.emf.codegen.ecore.genmodel.GenModel;
import org.eclipse.emf.codegen.ecore.genmodel.GenModelPackage;
+import org.eclipse.emf.codegen.ecore.genmodel.generator.GenBaseGeneratorAdapter;
+import org.eclipse.emf.common.util.BasicMonitor;
+import org.eclipse.emf.common.util.Diagnostic;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.EMap;
import org.eclipse.emf.ecore.EAnnotation;
@@ -13,8 +17,6 @@ import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.xcore.XOperation;
import org.eclipse.emf.ecore.xcore.XPackage;
import org.eclipse.emf.ecore.xcore.util.MappingFacade;
-import org.eclipse.xtext.common.types.JvmOperation;
-import org.eclipse.xtext.common.types.JvmTypeReference;
import org.eclipse.xtext.generator.IFileSystemAccess;
import org.eclipse.xtext.generator.IGenerator;
import org.eclipse.xtext.xbase.XBlockExpression;
@@ -45,11 +47,8 @@ public class XcoreGenerator implements IGenerator {
final EOperation eOperation = _eOperation;
StringBuilderBasedAppendable _stringBuilderBasedAppendable = new StringBuilderBasedAppendable();
final StringBuilderBasedAppendable appendable = _stringBuilderBasedAppendable;
- JvmOperation _jvmOperation = this.mappings.getJvmOperation(op);
- JvmTypeReference _returnType = _jvmOperation.getReturnType();
- final JvmTypeReference expectedType = _returnType;
XBlockExpression _body = op.getBody();
- this.compiler.compile(_body, appendable, expectedType);
+ this.compiler.compile(_body, appendable, null);
EList<EAnnotation> _eAnnotations = eOperation.getEAnnotations();
String _string = appendable.toString();
EAnnotation _createGenModelAnnotation = this.createGenModelAnnotation("body", _string);
@@ -62,8 +61,18 @@ public class XcoreGenerator implements IGenerator {
}
}
- public void generateGenModel(final GenModel genModel) {
- genModel.gen(null);
+ public Diagnostic generateGenModel(final GenModel genModel) {
+ Diagnostic _xblockexpression = null;
+ {
+ genModel.setCanGenerate(true);
+ Generator _generator = new Generator();
+ final Generator generator = _generator;
+ generator.setInput(genModel);
+ BasicMonitor _basicMonitor = new BasicMonitor();
+ Diagnostic _generate = generator.generate(genModel, GenBaseGeneratorAdapter.MODEL_PROJECT_TYPE, _basicMonitor);
+ _xblockexpression = (_generate);
+ }
+ return _xblockexpression;
}
public EAnnotation createGenModelAnnotation(final String key, final String value) {