summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Efftinge2011-08-25 09:17:54 (EDT)
committerEd Merks2011-08-25 09:17:54 (EDT)
commit9998514831f6f19dd4c3eac4c3f14e5a3603a8c5 (patch)
tree91c0da0776f771d4e4db78b33b855e0b44cf6c64
parentdd5b4143e2adb263cb96376e767fdeacd984fabc (diff)
downloadorg.eclipse.emf-9998514831f6f19dd4c3eac4c3f14e5a3603a8c5.zip
org.eclipse.emf-9998514831f6f19dd4c3eac4c3f14e5a3603a8c5.tar.gz
org.eclipse.emf-9998514831f6f19dd4c3eac4c3f14e5a3603a8c5.tar.bz2
adapted EMF's generator to work with Xtext's generator infrastructure
-rw-r--r--org.eclipse.emf.ecore.xcore.tests/src/org/eclipse/emf/ecore/xcore/tests/generator/GeneratorTest.xtend46
-rw-r--r--org.eclipse.emf.ecore.xcore.tests/xtend-gen/org/eclipse/emf/ecore/xcore/tests/generator/GeneratorTest.java63
-rw-r--r--org.eclipse.emf.ecore.xcore.ui/src-gen/org/eclipse/emf/ecore/xcore/ui/AbstractXcoreUiModule.java7
-rw-r--r--org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/generator/XcoreGenModelGeneratorAdapterFactory.java116
-rw-r--r--org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/generator/XcoreGenerator.xtend37
-rw-r--r--org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/generator/XcoreGeneratorImpl.java53
-rw-r--r--org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/util/XcoreGenmodelBuilder.xtend27
-rw-r--r--org.eclipse.emf.ecore.xcore/xtend-gen/org/eclipse/emf/ecore/xcore/generator/XcoreGenerator.java15
8 files changed, 328 insertions, 36 deletions
diff --git a/org.eclipse.emf.ecore.xcore.tests/src/org/eclipse/emf/ecore/xcore/tests/generator/GeneratorTest.xtend b/org.eclipse.emf.ecore.xcore.tests/src/org/eclipse/emf/ecore/xcore/tests/generator/GeneratorTest.xtend
new file mode 100644
index 0000000..f3b8a6f
--- /dev/null
+++ b/org.eclipse.emf.ecore.xcore.tests/src/org/eclipse/emf/ecore/xcore/tests/generator/GeneratorTest.xtend
@@ -0,0 +1,46 @@
+package org.eclipse.emf.ecore.xcore.tests.generator
+
+import com.google.inject.Inject
+import org.eclipse.emf.ecore.xcore.XPackage
+import org.eclipse.emf.ecore.xcore.XcoreInjectorProvider
+import org.eclipse.emf.ecore.xcore.generator.XcoreGenerator
+import org.eclipse.emf.ecore.xcore.mappings.XcoreMapper
+import org.eclipse.xtext.generator.InMemoryFileSystemAccess
+import org.eclipse.xtext.junit4.InjectWith
+import org.eclipse.xtext.junit4.XtextRunner
+import org.eclipse.xtext.junit4.util.ParseHelper
+import org.eclipse.xtext.junit4.validation.ValidationTestHelper
+import org.junit.Test
+import org.junit.runner.RunWith
+
+import static org.junit.Assert.*
+
+@RunWith(typeof(XtextRunner))
+@InjectWith(typeof(XcoreInjectorProvider))
+class GeneratorTest {
+
+ @Inject
+ ParseHelper<XPackage> parser
+
+ @Inject
+ ValidationTestHelper validator
+
+ @Inject
+ extension XcoreMapper mapper
+
+ @Inject
+ XcoreGenerator xcoreGenerator
+
+ @Test
+ def void testGenerator() {
+ val xPackage = parser.parse('''
+ package test
+ class X {}
+ ''')
+ val inmemFsa = new InMemoryFileSystemAccess()
+ xcoreGenerator.doGenerate(xPackage.eResource, inmemFsa)
+ assertEquals(inmemFsa.files.keySet.toString, 8, inmemFsa.files.size)
+
+ assertNotNull(inmemFsa.files.get('test/util/TestSwitch.java'))
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.emf.ecore.xcore.tests/xtend-gen/org/eclipse/emf/ecore/xcore/tests/generator/GeneratorTest.java b/org.eclipse.emf.ecore.xcore.tests/xtend-gen/org/eclipse/emf/ecore/xcore/tests/generator/GeneratorTest.java
new file mode 100644
index 0000000..a771745
--- /dev/null
+++ b/org.eclipse.emf.ecore.xcore.tests/xtend-gen/org/eclipse/emf/ecore/xcore/tests/generator/GeneratorTest.java
@@ -0,0 +1,63 @@
+package org.eclipse.emf.ecore.xcore.tests.generator;
+
+import com.google.inject.Inject;
+import java.util.Map;
+import java.util.Set;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.xcore.XPackage;
+import org.eclipse.emf.ecore.xcore.XcoreInjectorProvider;
+import org.eclipse.emf.ecore.xcore.generator.XcoreGenerator;
+import org.eclipse.emf.ecore.xcore.mappings.XcoreMapper;
+import org.eclipse.xtext.generator.InMemoryFileSystemAccess;
+import org.eclipse.xtext.junit4.InjectWith;
+import org.eclipse.xtext.junit4.XtextRunner;
+import org.eclipse.xtext.junit4.util.ParseHelper;
+import org.eclipse.xtext.junit4.validation.ValidationTestHelper;
+import org.eclipse.xtext.xtend2.lib.StringConcatenation;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@SuppressWarnings("all")
+@RunWith(XtextRunner.class)
+@InjectWith(XcoreInjectorProvider.class)
+public class GeneratorTest {
+
+ @Inject
+ private ParseHelper<XPackage> parser;
+
+ @Inject
+ private ValidationTestHelper validator;
+
+ @Inject
+ private XcoreMapper mapper;
+
+ @Inject
+ private XcoreGenerator xcoreGenerator;
+
+ @Test
+ public void testGenerator() throws Exception {
+ {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("package test");
+ _builder.newLine();
+ _builder.append("class X {}");
+ _builder.newLine();
+ XPackage _parse = this.parser.parse(_builder);
+ final XPackage xPackage = _parse;
+ InMemoryFileSystemAccess _inMemoryFileSystemAccess = new InMemoryFileSystemAccess();
+ final InMemoryFileSystemAccess inmemFsa = _inMemoryFileSystemAccess;
+ Resource _eResource = xPackage.eResource();
+ this.xcoreGenerator.doGenerate(_eResource, inmemFsa);
+ Map<String,CharSequence> _files = inmemFsa.getFiles();
+ Set<String> _keySet = _files.keySet();
+ String _string = _keySet.toString();
+ Map<String,CharSequence> _files_1 = inmemFsa.getFiles();
+ int _size = _files_1.size();
+ Assert.assertEquals(_string, 8, _size);
+ Map<String,CharSequence> _files_2 = inmemFsa.getFiles();
+ CharSequence _get = _files_2.get("test/util/TestSwitch.java");
+ Assert.assertNotNull(_get);
+ }
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.emf.ecore.xcore.ui/src-gen/org/eclipse/emf/ecore/xcore/ui/AbstractXcoreUiModule.java b/org.eclipse.emf.ecore.xcore.ui/src-gen/org/eclipse/emf/ecore/xcore/ui/AbstractXcoreUiModule.java
index ee918ed..51a0b1f 100644
--- a/org.eclipse.emf.ecore.xcore.ui/src-gen/org/eclipse/emf/ecore/xcore/ui/AbstractXcoreUiModule.java
+++ b/org.eclipse.emf.ecore.xcore.ui/src-gen/org/eclipse/emf/ecore/xcore/ui/AbstractXcoreUiModule.java
@@ -115,7 +115,7 @@ public abstract class AbstractXcoreUiModule extends DefaultUiModule {
// contributed by org.eclipse.xtext.generator.generator.GeneratorFragment
public Class<? extends org.eclipse.xtext.builder.IXtextBuilderParticipant> bindIXtextBuilderParticipant() {
- return org.eclipse.xtext.builder.JavaProjectBasedBuilderParticipant.class;
+ return org.eclipse.xtext.builder.BuilderParticipant.class;
}
// contributed by org.eclipse.xtext.generator.generator.GeneratorFragment
@@ -158,6 +158,11 @@ public abstract class AbstractXcoreUiModule extends DefaultUiModule {
return org.eclipse.xtext.ui.editor.contentassist.FQNPrefixMatcher.class;
}
+ // contributed by org.eclipse.xtext.generator.types.TypesGeneratorFragment
+ public Class<? extends org.eclipse.xtext.ui.editor.IValidationJobScheduler> bindIValidationJobScheduler() {
+ return org.eclipse.xtext.common.types.xtext.ui.JdtValidationJobScheduler.class;
+ }
+
// contributed by org.eclipse.xtext.generator.xbase.XbaseGeneratorFragment
public Class<? extends org.eclipse.xtext.ui.editor.syntaxcoloring.AbstractAntlrTokenToAttributeIdMapper> bindAbstractAntlrTokenToAttributeIdMapper() {
return org.eclipse.xtext.xbase.ui.syntaxcoloring.XbaseTokenToAttributeIdMapper.class;
diff --git a/org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/generator/XcoreGenModelGeneratorAdapterFactory.java b/org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/generator/XcoreGenModelGeneratorAdapterFactory.java
new file mode 100644
index 0000000..8b2f0ab
--- /dev/null
+++ b/org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/generator/XcoreGenModelGeneratorAdapterFactory.java
@@ -0,0 +1,116 @@
+package org.eclipse.emf.ecore.xcore.generator;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.eclipse.emf.codegen.ecore.genmodel.generator.GenClassGeneratorAdapter;
+import org.eclipse.emf.codegen.ecore.genmodel.generator.GenEnumGeneratorAdapter;
+import org.eclipse.emf.codegen.ecore.genmodel.generator.GenModelGeneratorAdapter;
+import org.eclipse.emf.codegen.ecore.genmodel.generator.GenModelGeneratorAdapterFactory;
+import org.eclipse.emf.codegen.ecore.genmodel.generator.GenPackageGeneratorAdapter;
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.xtext.generator.IFileSystemAccess;
+
+public class XcoreGenModelGeneratorAdapterFactory extends GenModelGeneratorAdapterFactory
+{
+
+ private IFileSystemAccess fsa;
+
+ public void setFileSystemAccess(IFileSystemAccess fsa)
+ {
+ this.fsa = fsa;
+ }
+
+ protected OutputStream createOutputStream(URI workspacePath)
+ {
+ String string = workspacePath.toString();
+ final String targetFile = string.substring(string.indexOf(XcoreGeneratorImpl.OUTPUT_DIR_MARKER) + XcoreGeneratorImpl.OUTPUT_DIR_MARKER.length()+1);
+ return new ByteArrayOutputStream() {
+ @Override
+ public void close() throws IOException
+ {
+ fsa.generateFile(targetFile, new String(this.toByteArray()));
+ super.close();
+ }
+ };
+ }
+
+ /**
+ * Returns a singleton {@link GenModelGeneratorAdapter}.
+ */
+ @Override
+ public Adapter createGenModelAdapter()
+ {
+ if (genModelGeneratorAdapter == null)
+ {
+ genModelGeneratorAdapter = new GenModelGeneratorAdapter(this){
+ @Override
+ protected OutputStream createOutputStream(URI workspacePath) throws Exception
+ {
+ return XcoreGenModelGeneratorAdapterFactory.this.createOutputStream(workspacePath);
+ }
+ };
+ }
+ return genModelGeneratorAdapter;
+ }
+
+ /**
+ * Returns a singleton {@link GenPackageGeneratorAdapter}.
+ */
+ @Override
+ public Adapter createGenPackageAdapter()
+ {
+ if (genPackageGeneratorAdapter == null)
+ {
+ genPackageGeneratorAdapter = new GenPackageGeneratorAdapter(this) {
+ @Override
+ protected OutputStream createOutputStream(URI workspacePath) throws Exception
+ {
+ return XcoreGenModelGeneratorAdapterFactory.this.createOutputStream(workspacePath);
+ }
+ };
+ }
+ return genPackageGeneratorAdapter;
+ }
+
+ /**
+ * Returns a singleton {@link GenClassGeneratorAdapter}.
+ */
+ @Override
+ public Adapter createGenClassAdapter()
+ {
+ if (genClassGeneratorAdapter == null)
+ {
+ genClassGeneratorAdapter = new GenClassGeneratorAdapter(this){
+ @Override
+ protected OutputStream createOutputStream(URI workspacePath) throws Exception
+ {
+ return XcoreGenModelGeneratorAdapterFactory.this.createOutputStream(workspacePath);
+ }
+ };
+ }
+ return genClassGeneratorAdapter;
+ }
+
+ /**
+ * Returns a singleton {@link GenEnumGeneratorAdapter}.
+ */
+ @Override
+ public Adapter createGenEnumAdapter()
+ {
+ if (genEnumGeneratorAdapter == null)
+ {
+ genEnumGeneratorAdapter = new GenEnumGeneratorAdapter(this){
+ @Override
+ protected OutputStream createOutputStream(URI workspacePath) throws Exception
+ {
+ return XcoreGenModelGeneratorAdapterFactory.this.createOutputStream(workspacePath);
+ }
+ };
+ }
+ return genEnumGeneratorAdapter;
+ }
+
+}
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 81c406e..862ab71 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
@@ -3,25 +3,24 @@
*/
package org.eclipse.emf.ecore.xcore.generator
-import org.eclipse.emf.ecore.resource.Resource
-import org.eclipse.xtext.generator.IGenerator
-import org.eclipse.xtext.generator.IFileSystemAccess
-import org.eclipse.emf.ecore.xcore.XPackage
import com.google.inject.Inject
-import org.eclipse.emf.ecore.xcore.util.MappingFacade
-import org.eclipse.emf.ecore.xcore.XOperation
-import static extension org.eclipse.xtext.xtend2.lib.EObjectExtensions.*
-import org.eclipse.xtext.xbase.compiler.XbaseCompiler
-import org.eclipse.xtext.xbase.compiler.IAppendable
-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.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.ecore.EcoreFactory
+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.mappings.XcoreMapper
-import org.eclipse.xtext.common.types.JvmOperation
+import org.eclipse.xtext.generator.IFileSystemAccess
+import org.eclipse.xtext.generator.IGenerator
+import org.eclipse.xtext.xbase.compiler.StringBuilderBasedAppendable
+import org.eclipse.xtext.xbase.compiler.XbaseCompiler
+
+import static extension org.eclipse.xtext.xtend2.lib.EObjectExtensions.*
+import com.google.inject.Provider
class XcoreGenerator implements IGenerator {
@@ -31,6 +30,9 @@ class XcoreGenerator implements IGenerator {
@Inject
XbaseCompiler compiler
+ @Inject
+ Provider<XcoreGeneratorImpl> xcoreGeneratorImplProvider
+
override void doGenerate(Resource resource, IFileSystemAccess fsa) {
val pack = resource.contents.head as XPackage
// install operation bodies
@@ -43,13 +45,14 @@ class XcoreGenerator implements IGenerator {
eOperation.EAnnotations.add(createGenModelAnnotation("body", appendable.toString))
}
- generateGenModel(resource.contents.filter(typeof(GenModel)).head)
+ generateGenModel(resource.contents.filter(typeof(GenModel)).head, fsa)
}
- def generateGenModel(GenModel genModel) {
+ def generateGenModel(GenModel genModel, IFileSystemAccess fsa) {
genModel.canGenerate = true
- val generator = new Generator()
+ val generator = xcoreGeneratorImplProvider.get
generator.input = genModel
+ generator.fileSystemAccess = fsa
generator.generate(genModel, GenBaseGeneratorAdapter::MODEL_PROJECT_TYPE,
new BasicMonitor());
}
diff --git a/org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/generator/XcoreGeneratorImpl.java b/org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/generator/XcoreGeneratorImpl.java
new file mode 100644
index 0000000..95becda
--- /dev/null
+++ b/org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/generator/XcoreGeneratorImpl.java
@@ -0,0 +1,53 @@
+package org.eclipse.emf.ecore.xcore.generator;
+
+import java.util.Collection;
+
+import org.eclipse.emf.codegen.ecore.generator.Generator;
+import org.eclipse.emf.codegen.ecore.generator.GeneratorAdapterFactory;
+import org.eclipse.emf.codegen.ecore.genmodel.GenModel;
+import org.eclipse.xtext.generator.IFileSystemAccess;
+
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+
+import static java.util.Collections.*;
+
+public class XcoreGeneratorImpl extends Generator
+{
+
+ static final String OUTPUT_DIR_MARKER = "special_model_dir";
+ private IFileSystemAccess fsa;
+
+ public void setFileSystemAccess(IFileSystemAccess fsa)
+ {
+ this.fsa = fsa;
+ }
+
+ @Override
+ public void setInput(Object input)
+ {
+ if (input instanceof GenModel) {
+ final GenModel genModel = (GenModel) input;
+ genModel.setModelDirectory(OUTPUT_DIR_MARKER);
+ genModel.unsetEditDirectory();
+ genModel.unsetEditPluginClass();
+ genModel.unsetEditorDirectory();
+ genModel.unsetEditorPluginClass();
+ genModel.unsetTestsDirectory();
+ genModel.unsetTestSuiteClass();
+ }
+ super.setInput(input);
+ }
+
+ @Inject
+ private Provider<XcoreGenModelGeneratorAdapterFactory> adapterFactoryProvider;
+
+ @Override
+ protected Collection<GeneratorAdapterFactory> getAdapterFactories(Object object)
+ {
+ final XcoreGenModelGeneratorAdapterFactory genAdapterFactory = adapterFactoryProvider.get();
+ genAdapterFactory.setGenerator(this);
+ genAdapterFactory.setFileSystemAccess(fsa);
+ return singleton((GeneratorAdapterFactory) genAdapterFactory);
+ }
+}
diff --git a/org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/util/XcoreGenmodelBuilder.xtend b/org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/util/XcoreGenmodelBuilder.xtend
index dcd922d..24e1f16 100644
--- a/org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/util/XcoreGenmodelBuilder.xtend
+++ b/org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/util/XcoreGenmodelBuilder.xtend
@@ -1,25 +1,26 @@
package org.eclipse.emf.ecore.xcore.util
-import org.eclipse.emf.ecore.xcore.mappings.XcoreMapper
import com.google.inject.Inject
-import org.eclipse.emf.ecore.xcore.XPackage
-import org.eclipse.emf.codegen.ecore.genmodel.GenModelFactory
import java.util.Collections
-import static extension org.eclipse.xtext.xtend2.lib.EObjectExtensions.*
+import java.util.HashSet
import org.eclipse.emf.codegen.ecore.genmodel.GenClass
-import org.eclipse.emf.codegen.ecore.genmodel.GenPackage
-import org.eclipse.emf.ecore.xcore.XClass
+import org.eclipse.emf.codegen.ecore.genmodel.GenDataType
import org.eclipse.emf.codegen.ecore.genmodel.GenFeature
-import org.eclipse.emf.ecore.xcore.XStructuralFeature
+import org.eclipse.emf.codegen.ecore.genmodel.GenModel
+import org.eclipse.emf.codegen.ecore.genmodel.GenModelFactory
import org.eclipse.emf.codegen.ecore.genmodel.GenOperation
-import org.eclipse.emf.ecore.xcore.XOperation
-import org.eclipse.emf.codegen.ecore.genmodel.GenDataType
-import org.eclipse.emf.ecore.xcore.XDataType
-import org.eclipse.emf.ecore.EPackage
+import org.eclipse.emf.codegen.ecore.genmodel.GenPackage
import org.eclipse.emf.ecore.EClassifier
-import java.util.HashSet
+import org.eclipse.emf.ecore.EPackage
import org.eclipse.emf.ecore.EStructuralFeature
-import org.eclipse.emf.codegen.ecore.genmodel.GenModel
+import org.eclipse.emf.ecore.xcore.XClass
+import org.eclipse.emf.ecore.xcore.XDataType
+import org.eclipse.emf.ecore.xcore.XOperation
+import org.eclipse.emf.ecore.xcore.XPackage
+import org.eclipse.emf.ecore.xcore.XStructuralFeature
+import org.eclipse.emf.ecore.xcore.mappings.XcoreMapper
+
+import static extension org.eclipse.xtext.xtend2.lib.EObjectExtensions.*
class XcoreGenmodelBuilder {
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 91d5340..dfab3a8 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,7 +1,7 @@
package org.eclipse.emf.ecore.xcore.generator;
import com.google.inject.Inject;
-import org.eclipse.emf.codegen.ecore.generator.Generator;
+import com.google.inject.Provider;
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;
@@ -16,6 +16,7 @@ import org.eclipse.emf.ecore.EcoreFactory;
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.generator.XcoreGeneratorImpl;
import org.eclipse.emf.ecore.xcore.mappings.XOperationMapping;
import org.eclipse.emf.ecore.xcore.mappings.XcoreMapper;
import org.eclipse.xtext.common.types.JvmDeclaredType;
@@ -37,6 +38,9 @@ public class XcoreGenerator implements IGenerator {
@Inject
private XbaseCompiler compiler;
+ @Inject
+ private Provider<XcoreGeneratorImpl> xcoreGeneratorImplProvider;
+
public void doGenerate(final Resource resource, final IFileSystemAccess fsa) {
{
EList<EObject> _contents = resource.getContents();
@@ -66,17 +70,18 @@ public class XcoreGenerator implements IGenerator {
EList<EObject> _contents_1 = resource.getContents();
Iterable<GenModel> _filter_1 = IterableExtensions.<GenModel>filter(_contents_1, org.eclipse.emf.codegen.ecore.genmodel.GenModel.class);
GenModel _head_1 = IterableExtensions.<GenModel>head(_filter_1);
- this.generateGenModel(_head_1);
+ this.generateGenModel(_head_1, fsa);
}
}
- public Diagnostic generateGenModel(final GenModel genModel) {
+ public Diagnostic generateGenModel(final GenModel genModel, final IFileSystemAccess fsa) {
Diagnostic _xblockexpression = null;
{
genModel.setCanGenerate(true);
- Generator _generator = new Generator();
- final Generator generator = _generator;
+ XcoreGeneratorImpl _get = this.xcoreGeneratorImplProvider.get();
+ final XcoreGeneratorImpl generator = _get;
generator.setInput(genModel);
+ generator.setFileSystemAccess(fsa);
BasicMonitor _basicMonitor = new BasicMonitor();
Diagnostic _generate = generator.generate(genModel, GenBaseGeneratorAdapter.MODEL_PROJECT_TYPE, _basicMonitor);
_xblockexpression = (_generate);