summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Efftinge2011-10-19 10:45:35 (EDT)
committer Ed Merks2011-10-19 10:45:35 (EDT)
commit08d21ced8249606f9bed6472a3d63d8b9e0886af (patch)
tree936fcdaa41097fde6fb5431276f10a1598a23e8a
parent3d8b6ed946caf4c7e1113e2ccf445596b8e76187 (diff)
downloadorg.eclipse.emf-08d21ced8249606f9bed6472a3d63d8b9e0886af.zip
org.eclipse.emf-08d21ced8249606f9bed6472a3d63d8b9e0886af.tar.gz
org.eclipse.emf-08d21ced8249606f9bed6472a3d63d8b9e0886af.tar.bz2
added indexing of EPackages
-rw-r--r--org.eclipse.emf.ecore.xcore.tests/xtend-gen/org/eclipse/emf/ecore/xcore/tests/MultiFileTest.java328
-rw-r--r--org.eclipse.emf.ecore.xcore.tests/xtend-gen/org/eclipse/emf/ecore/xcore/tests/ParsingTest.java848
-rw-r--r--org.eclipse.emf.ecore.xcore.tests/xtend-gen/org/eclipse/emf/ecore/xcore/tests/interpreter/XcoreInterpreterTest.java648
-rw-r--r--org.eclipse.emf.ecore.xcore.tests/xtend-gen/org/eclipse/emf/ecore/xcore/tests/mapping/XcoreMapperTest.java370
-rw-r--r--org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/generator/XcoreGenerator.xtend15
-rw-r--r--org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/scoping/LazyCreationProxyUriConverter.java7
-rw-r--r--org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/scoping/XcoreQualifiedNameProvider.java7
-rw-r--r--org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/scoping/XcoreResourceDescriptionStrategy.java16
-rw-r--r--org.eclipse.emf.ecore.xcore/xtend-gen/org/eclipse/emf/ecore/xcore/XcoreExtensions.java90
-rw-r--r--org.eclipse.emf.ecore.xcore/xtend-gen/org/eclipse/emf/ecore/xcore/generator/XcoreGenerator.java462
-rw-r--r--org.eclipse.emf.ecore.xcore/xtend-gen/org/eclipse/emf/ecore/xcore/util/XcoreGenmodelBuilder.java594
11 files changed, 1704 insertions, 1681 deletions
diff --git a/org.eclipse.emf.ecore.xcore.tests/xtend-gen/org/eclipse/emf/ecore/xcore/tests/MultiFileTest.java b/org.eclipse.emf.ecore.xcore.tests/xtend-gen/org/eclipse/emf/ecore/xcore/tests/MultiFileTest.java
index 23f55d7..25e8e2a 100644
--- a/org.eclipse.emf.ecore.xcore.tests/xtend-gen/org/eclipse/emf/ecore/xcore/tests/MultiFileTest.java
+++ b/org.eclipse.emf.ecore.xcore.tests/xtend-gen/org/eclipse/emf/ecore/xcore/tests/MultiFileTest.java
@@ -1,164 +1,164 @@
-package org.eclipse.emf.ecore.xcore.tests;
-
-import com.google.inject.Inject;
-import java.io.IOException;
-import org.eclipse.emf.codegen.ecore.genmodel.GenBase;
-import org.eclipse.emf.codegen.ecore.genmodel.GenClass;
-import org.eclipse.emf.codegen.ecore.genmodel.GenFeature;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.xcore.XClass;
-import org.eclipse.emf.ecore.xcore.XGenericType;
-import org.eclipse.emf.ecore.xcore.XMember;
-import org.eclipse.emf.ecore.xcore.XReference;
-import org.eclipse.emf.ecore.xcore.XStructuralFeature;
-import org.eclipse.emf.ecore.xcore.XcoreInjectorProvider;
-import org.eclipse.emf.ecore.xcore.mappings.XcoreMapper;
-import org.eclipse.xtext.junit4.InjectWith;
-import org.eclipse.xtext.junit4.XtextRunner;
-import org.eclipse.xtext.junit4.validation.ValidationTestHelper;
-import org.eclipse.xtext.resource.IResourceDescriptions;
-import org.eclipse.xtext.resource.XtextResourceSet;
-import org.eclipse.xtext.util.StringInputStream;
-import org.eclipse.xtext.xbase.lib.IterableExtensions;
-import org.eclipse.xtext.xtend2.lib.ResourceExtensions;
-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 MultiFileTest {
- @Inject
- private XtextResourceSet resourceSet;
-
- @Inject
- private ValidationTestHelper validator;
-
- @Inject
- private IResourceDescriptions descriptions;
-
- @Inject
- private XcoreMapper mapper;
-
- @Test
- public void testReferenceBetweenTwoModels() throws IOException {
- URI _createURI = URI.createURI("file:/modelA.xcore");
- Resource _createResource = this.resourceSet.createResource(_createURI);
- final Resource resourceA = _createResource;
- URI _createURI_1 = URI.createURI("file:/modelB.xcore");
- Resource _createResource_1 = this.resourceSet.createResource(_createURI_1);
- final Resource resourceB = _createResource_1;
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("package packB");
- _builder.newLine();
- _builder.newLine();
- _builder.append("class TypeB {");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- String _string = _builder.toString();
- StringInputStream _stringInputStream = new StringInputStream(_string);
- resourceB.load(_stringInputStream, null);
- StringConcatenation _builder_1 = new StringConcatenation();
- _builder_1.append("package packA");
- _builder_1.newLine();
- _builder_1.newLine();
- _builder_1.append("class TypeA {");
- _builder_1.newLine();
- _builder_1.append("\t");
- _builder_1.append("refers packB.TypeB refToB ");
- _builder_1.newLine();
- _builder_1.append("}");
- _builder_1.newLine();
- String _string_1 = _builder_1.toString();
- StringInputStream _stringInputStream_1 = new StringInputStream(_string_1);
- resourceA.load(_stringInputStream_1, null);
- EList<EObject> _contents = resourceA.getContents();
- EObject _head = IterableExtensions.<EObject>head(_contents);
- this.validator.assertNoErrors(_head);
- EList<EObject> _contents_1 = resourceB.getContents();
- EObject _head_1 = IterableExtensions.<EObject>head(_contents_1);
- this.validator.assertNoErrors(_head_1);
- Iterable<EObject> _allContentsIterable = ResourceExtensions.allContentsIterable(resourceA);
- final Iterable<EObject> allContents = _allContentsIterable;
- Iterable<XClass> _filter = IterableExtensions.<XClass>filter(allContents, org.eclipse.emf.ecore.xcore.XClass.class);
- XClass _head_2 = IterableExtensions.<XClass>head(_filter);
- final XClass xclass = _head_2;
- EList<XMember> _members = xclass.getMembers();
- XMember _head_3 = IterableExtensions.<XMember>head(_members);
- XGenericType _type = _head_3.getType();
- GenBase _type_1 = _type.getType();
- final GenBase referencedGenClass = _type_1;
- String _name = ((GenClass) referencedGenClass).getName();
- Assert.assertEquals("TypeB", _name);
- }
-
- @Test
- public void testBidirectionalReferenceBetweenTwoModels() throws IOException {
- URI _createURI = URI.createURI("file:/modelA.xcore");
- Resource _createResource = this.resourceSet.createResource(_createURI);
- final Resource resourceA = _createResource;
- URI _createURI_1 = URI.createURI("file:/modelB.xcore");
- Resource _createResource_1 = this.resourceSet.createResource(_createURI_1);
- final Resource resourceB = _createResource_1;
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("package packB");
- _builder.newLine();
- _builder.newLine();
- _builder.append("class TypeB {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("refers packA.TypeA refToA opposite refToB");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- String _string = _builder.toString();
- StringInputStream _stringInputStream = new StringInputStream(_string);
- resourceB.load(_stringInputStream, null);
- StringConcatenation _builder_1 = new StringConcatenation();
- _builder_1.append("package packA");
- _builder_1.newLine();
- _builder_1.newLine();
- _builder_1.append("class TypeA {");
- _builder_1.newLine();
- _builder_1.append("\t");
- _builder_1.append("refers packB.TypeB refToB opposite refToA");
- _builder_1.newLine();
- _builder_1.append("}");
- _builder_1.newLine();
- String _string_1 = _builder_1.toString();
- StringInputStream _stringInputStream_1 = new StringInputStream(_string_1);
- resourceA.load(_stringInputStream_1, null);
- EList<EObject> _contents = resourceA.getContents();
- EObject _head = IterableExtensions.<EObject>head(_contents);
- this.validator.assertNoErrors(_head);
- EList<EObject> _contents_1 = resourceB.getContents();
- EObject _head_1 = IterableExtensions.<EObject>head(_contents_1);
- this.validator.assertNoErrors(_head_1);
- Iterable<EObject> _allContentsIterable = ResourceExtensions.allContentsIterable(resourceA);
- final Iterable<EObject> allContents = _allContentsIterable;
- Iterable<XClass> _filter = IterableExtensions.<XClass>filter(allContents, org.eclipse.emf.ecore.xcore.XClass.class);
- XClass _head_2 = IterableExtensions.<XClass>head(_filter);
- final XClass xclass = _head_2;
- EList<XMember> _members = xclass.getMembers();
- XMember _head_3 = IterableExtensions.<XMember>head(_members);
- XGenericType _type = _head_3.getType();
- GenBase _type_1 = _type.getType();
- final GenBase referencedGenClass = _type_1;
- String _name = ((GenClass) referencedGenClass).getName();
- Assert.assertEquals("TypeB", _name);
- EList<XMember> _members_1 = xclass.getMembers();
- XMember _head_4 = IterableExtensions.<XMember>head(_members_1);
- final XReference ref = ((XReference) _head_4);
- GenFeature _opposite = ref.getOpposite();
- XStructuralFeature _xFeature = this.mapper.getXFeature(_opposite);
- GenFeature _opposite_1 = ((XReference) _xFeature).getOpposite();
- XStructuralFeature _xFeature_1 = this.mapper.getXFeature(_opposite_1);
- Assert.assertEquals(ref, _xFeature_1);
- }
-}
+package org.eclipse.emf.ecore.xcore.tests;
+
+import com.google.inject.Inject;
+import java.io.IOException;
+import org.eclipse.emf.codegen.ecore.genmodel.GenBase;
+import org.eclipse.emf.codegen.ecore.genmodel.GenClass;
+import org.eclipse.emf.codegen.ecore.genmodel.GenFeature;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.xcore.XClass;
+import org.eclipse.emf.ecore.xcore.XGenericType;
+import org.eclipse.emf.ecore.xcore.XMember;
+import org.eclipse.emf.ecore.xcore.XReference;
+import org.eclipse.emf.ecore.xcore.XStructuralFeature;
+import org.eclipse.emf.ecore.xcore.XcoreInjectorProvider;
+import org.eclipse.emf.ecore.xcore.mappings.XcoreMapper;
+import org.eclipse.xtext.junit4.InjectWith;
+import org.eclipse.xtext.junit4.XtextRunner;
+import org.eclipse.xtext.junit4.validation.ValidationTestHelper;
+import org.eclipse.xtext.resource.IResourceDescriptions;
+import org.eclipse.xtext.resource.XtextResourceSet;
+import org.eclipse.xtext.util.StringInputStream;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xtend2.lib.ResourceExtensions;
+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 MultiFileTest {
+ @Inject
+ private XtextResourceSet resourceSet;
+
+ @Inject
+ private ValidationTestHelper validator;
+
+ @Inject
+ private IResourceDescriptions descriptions;
+
+ @Inject
+ private XcoreMapper mapper;
+
+ @Test
+ public void testReferenceBetweenTwoModels() throws IOException {
+ URI _createURI = URI.createURI("file:/modelA.xcore");
+ Resource _createResource = this.resourceSet.createResource(_createURI);
+ final Resource resourceA = _createResource;
+ URI _createURI_1 = URI.createURI("file:/modelB.xcore");
+ Resource _createResource_1 = this.resourceSet.createResource(_createURI_1);
+ final Resource resourceB = _createResource_1;
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("package packB");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("class TypeB {");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ String _string = _builder.toString();
+ StringInputStream _stringInputStream = new StringInputStream(_string);
+ resourceB.load(_stringInputStream, null);
+ StringConcatenation _builder_1 = new StringConcatenation();
+ _builder_1.append("package packA");
+ _builder_1.newLine();
+ _builder_1.newLine();
+ _builder_1.append("class TypeA {");
+ _builder_1.newLine();
+ _builder_1.append("\t");
+ _builder_1.append("refers packB.TypeB refToB ");
+ _builder_1.newLine();
+ _builder_1.append("}");
+ _builder_1.newLine();
+ String _string_1 = _builder_1.toString();
+ StringInputStream _stringInputStream_1 = new StringInputStream(_string_1);
+ resourceA.load(_stringInputStream_1, null);
+ EList<EObject> _contents = resourceA.getContents();
+ EObject _head = IterableExtensions.<EObject>head(_contents);
+ this.validator.assertNoErrors(_head);
+ EList<EObject> _contents_1 = resourceB.getContents();
+ EObject _head_1 = IterableExtensions.<EObject>head(_contents_1);
+ this.validator.assertNoErrors(_head_1);
+ Iterable<EObject> _allContentsIterable = ResourceExtensions.allContentsIterable(resourceA);
+ final Iterable<EObject> allContents = _allContentsIterable;
+ Iterable<XClass> _filter = IterableExtensions.<XClass>filter(allContents, org.eclipse.emf.ecore.xcore.XClass.class);
+ XClass _head_2 = IterableExtensions.<XClass>head(_filter);
+ final XClass xclass = _head_2;
+ EList<XMember> _members = xclass.getMembers();
+ XMember _head_3 = IterableExtensions.<XMember>head(_members);
+ XGenericType _type = _head_3.getType();
+ GenBase _type_1 = _type.getType();
+ final GenBase referencedGenClass = _type_1;
+ String _name = ((GenClass) referencedGenClass).getName();
+ Assert.assertEquals("TypeB", _name);
+ }
+
+ @Test
+ public void testBidirectionalReferenceBetweenTwoModels() throws IOException {
+ URI _createURI = URI.createURI("file:/modelA.xcore");
+ Resource _createResource = this.resourceSet.createResource(_createURI);
+ final Resource resourceA = _createResource;
+ URI _createURI_1 = URI.createURI("file:/modelB.xcore");
+ Resource _createResource_1 = this.resourceSet.createResource(_createURI_1);
+ final Resource resourceB = _createResource_1;
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("package packB");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("class TypeB {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("refers packA.TypeA refToA opposite refToB");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ String _string = _builder.toString();
+ StringInputStream _stringInputStream = new StringInputStream(_string);
+ resourceB.load(_stringInputStream, null);
+ StringConcatenation _builder_1 = new StringConcatenation();
+ _builder_1.append("package packA");
+ _builder_1.newLine();
+ _builder_1.newLine();
+ _builder_1.append("class TypeA {");
+ _builder_1.newLine();
+ _builder_1.append("\t");
+ _builder_1.append("refers packB.TypeB refToB opposite refToA");
+ _builder_1.newLine();
+ _builder_1.append("}");
+ _builder_1.newLine();
+ String _string_1 = _builder_1.toString();
+ StringInputStream _stringInputStream_1 = new StringInputStream(_string_1);
+ resourceA.load(_stringInputStream_1, null);
+ EList<EObject> _contents = resourceA.getContents();
+ EObject _head = IterableExtensions.<EObject>head(_contents);
+ this.validator.assertNoErrors(_head);
+ EList<EObject> _contents_1 = resourceB.getContents();
+ EObject _head_1 = IterableExtensions.<EObject>head(_contents_1);
+ this.validator.assertNoErrors(_head_1);
+ Iterable<EObject> _allContentsIterable = ResourceExtensions.allContentsIterable(resourceA);
+ final Iterable<EObject> allContents = _allContentsIterable;
+ Iterable<XClass> _filter = IterableExtensions.<XClass>filter(allContents, org.eclipse.emf.ecore.xcore.XClass.class);
+ XClass _head_2 = IterableExtensions.<XClass>head(_filter);
+ final XClass xclass = _head_2;
+ EList<XMember> _members = xclass.getMembers();
+ XMember _head_3 = IterableExtensions.<XMember>head(_members);
+ XGenericType _type = _head_3.getType();
+ GenBase _type_1 = _type.getType();
+ final GenBase referencedGenClass = _type_1;
+ String _name = ((GenClass) referencedGenClass).getName();
+ Assert.assertEquals("TypeB", _name);
+ EList<XMember> _members_1 = xclass.getMembers();
+ XMember _head_4 = IterableExtensions.<XMember>head(_members_1);
+ final XReference ref = ((XReference) _head_4);
+ GenFeature _opposite = ref.getOpposite();
+ XStructuralFeature _xFeature = this.mapper.getXFeature(_opposite);
+ GenFeature _opposite_1 = ((XReference) _xFeature).getOpposite();
+ XStructuralFeature _xFeature_1 = this.mapper.getXFeature(_opposite_1);
+ Assert.assertEquals(ref, _xFeature_1);
+ }
+}
diff --git a/org.eclipse.emf.ecore.xcore.tests/xtend-gen/org/eclipse/emf/ecore/xcore/tests/ParsingTest.java b/org.eclipse.emf.ecore.xcore.tests/xtend-gen/org/eclipse/emf/ecore/xcore/tests/ParsingTest.java
index 8723a7a..01304f9 100644
--- a/org.eclipse.emf.ecore.xcore.tests/xtend-gen/org/eclipse/emf/ecore/xcore/tests/ParsingTest.java
+++ b/org.eclipse.emf.ecore.xcore.tests/xtend-gen/org/eclipse/emf/ecore/xcore/tests/ParsingTest.java
@@ -1,424 +1,424 @@
-package org.eclipse.emf.ecore.xcore.tests;
-
-import com.google.inject.Inject;
-import java.io.IOException;
-import java.util.Iterator;
-import org.eclipse.emf.codegen.ecore.genmodel.GenBase;
-import org.eclipse.emf.codegen.ecore.genmodel.GenClass;
-import org.eclipse.emf.codegen.ecore.genmodel.GenClassifier;
-import org.eclipse.emf.codegen.ecore.genmodel.GenFeature;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.Resource.Diagnostic;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.emf.ecore.xcore.XAnnotation;
-import org.eclipse.emf.ecore.xcore.XAnnotationDirective;
-import org.eclipse.emf.ecore.xcore.XAttribute;
-import org.eclipse.emf.ecore.xcore.XClass;
-import org.eclipse.emf.ecore.xcore.XClassifier;
-import org.eclipse.emf.ecore.xcore.XGenericType;
-import org.eclipse.emf.ecore.xcore.XMember;
-import org.eclipse.emf.ecore.xcore.XOperation;
-import org.eclipse.emf.ecore.xcore.XPackage;
-import org.eclipse.emf.ecore.xcore.XReference;
-import org.eclipse.emf.ecore.xcore.XcoreExtensions;
-import org.eclipse.emf.ecore.xcore.XcoreInjectorProvider;
-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.resource.XtextResource;
-import org.eclipse.xtext.xbase.lib.ComparableExtensions;
-import org.eclipse.xtext.xbase.lib.IterableExtensions;
-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 ParsingTest {
- @Inject
- private ParseHelper<XPackage> parser;
-
- @Inject
- private XcoreExtensions exts;
-
- @Inject
- private ValidationTestHelper vth;
-
- @Test
- public void parseSimpleFile() throws Exception {
- XPackage _parse = this.parser.parse("package foo");
- final XPackage parse = _parse;
- String _name = parse.getName();
- Assert.assertEquals("foo", _name);
- }
-
- @Test
- public void testJvmTypes() throws Exception {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("package foo ");
- _builder.newLine();
- _builder.append("class A ");
- _builder.newLine();
- _builder.append("{ ");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("refers A a");
- _builder.newLine();
- _builder.append("} ");
- _builder.newLine();
- XPackage _parse = this.parser.parse(_builder);
- final XPackage pack = _parse;
- Resource _eResource = pack.eResource();
- EcoreUtil.resolveAll(_eResource);
- this.vth.assertNoErrors(pack);
- }
-
- @Test
- public void testSuperTypeLinking_1() throws Exception {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("package foo ");
- _builder.newLine();
- _builder.append("class A {} ");
- _builder.newLine();
- _builder.append("class B extends A {}");
- _builder.newLine();
- XPackage _parse = this.parser.parse(_builder);
- final XPackage pack = _parse;
- EList<XClassifier> _classifiers = pack.getClassifiers();
- XClassifier _get = _classifiers.get(1);
- final XClass clazz = ((XClass) _get);
- EList<XGenericType> _superTypes = clazz.getSuperTypes();
- XGenericType _head = IterableExtensions.<XGenericType>head(_superTypes);
- GenClass _genClass = this.exts.getGenClass(_head);
- String _name = _genClass.getName();
- Assert.assertEquals("A", _name);
- }
-
- @Test
- public void testSuperTypeLinking_2() throws Exception {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("package foo ");
- _builder.newLine();
- _builder.append("class A {} ");
- _builder.newLine();
- _builder.append("class B extends foo.A {}");
- _builder.newLine();
- XPackage _parse = this.parser.parse(_builder);
- final XPackage pack = _parse;
- EList<XClassifier> _classifiers = pack.getClassifiers();
- XClassifier _get = _classifiers.get(1);
- final XClass clazz = ((XClass) _get);
- EList<XGenericType> _superTypes = clazz.getSuperTypes();
- XGenericType _head = IterableExtensions.<XGenericType>head(_superTypes);
- GenClass _genClass = this.exts.getGenClass(_head);
- String _name = _genClass.getName();
- Assert.assertEquals("A", _name);
- }
-
- @Test
- public void testReferenceToAnnotation() throws Exception {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("package foo ");
- _builder.newLine();
- _builder.append("annotation \'foo/bar\' as foo");
- _builder.newLine();
- _builder.append("@foo(holla=\'bar\')");
- _builder.newLine();
- _builder.append("class A {} ");
- _builder.newLine();
- XPackage _parse = this.parser.parse(_builder);
- final XPackage pack = _parse;
- EList<XClassifier> _classifiers = pack.getClassifiers();
- XClassifier _get = _classifiers.get(0);
- final XClass clazz = ((XClass) _get);
- EList<XAnnotationDirective> _annotationDirectives = pack.getAnnotationDirectives();
- XAnnotationDirective _head = IterableExtensions.<XAnnotationDirective>head(_annotationDirectives);
- EList<XAnnotation> _annotations = clazz.getAnnotations();
- XAnnotation _head_1 = IterableExtensions.<XAnnotation>head(_annotations);
- XAnnotationDirective _source = _head_1.getSource();
- Assert.assertEquals(_head, _source);
- }
-
- @Test
- public void testReferenceToOpposite() throws IOException, Exception {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("package foo");
- _builder.newLine();
- _builder.append("class X");
- _builder.newLine();
- _builder.append("{");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("refers X x opposite y ");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("refers X y opposite x");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("op void foo() {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("val X x = null");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- String _string = _builder.toString();
- final String text = _string;
- XPackage _parse = this.parser.parse(text);
- final XPackage pack = _parse;
- {
- EList<XClassifier> _classifiers = pack.getClassifiers();
- XClassifier _get = _classifiers.get(0);
- final XClass clazz = ((XClass) _get);
- EList<XMember> _members = clazz.getMembers();
- Iterable<XReference> _filter = IterableExtensions.<XReference>filter(_members, org.eclipse.emf.ecore.xcore.XReference.class);
- Iterator<XReference> _iterator = _filter.iterator();
- final Iterator<XReference> refs = _iterator;
- XReference _next = refs.next();
- XReference refX = _next;
- XReference _next_1 = refs.next();
- XReference refY = _next_1;
- String _name = refY.getName();
- GenFeature _opposite = refX.getOpposite();
- String _name_1 = _opposite.getName();
- Assert.assertEquals(_name, _name_1);
- String _name_2 = refX.getName();
- GenFeature _opposite_1 = refY.getOpposite();
- String _name_3 = _opposite_1.getName();
- Assert.assertEquals(_name_2, _name_3);
- }
- Resource _eResource = pack.eResource();
- final XtextResource resource = ((XtextResource) _eResource);
- EList<EObject> _contents = resource.getContents();
- int _size = _contents.size();
- final int elements = _size;
- int _length = text.length();
- resource.update(0, _length, text);
- {
- EList<EObject> _contents_1 = resource.getContents();
- EObject _get_1 = _contents_1.get(0);
- EList<XClassifier> _classifiers_1 = ((XPackage) _get_1).getClassifiers();
- XClassifier _get_2 = _classifiers_1.get(0);
- final XClass clazz_1 = ((XClass) _get_2);
- EList<XMember> _members_1 = clazz_1.getMembers();
- Iterable<XReference> _filter_1 = IterableExtensions.<XReference>filter(_members_1, org.eclipse.emf.ecore.xcore.XReference.class);
- Iterator<XReference> _iterator_1 = _filter_1.iterator();
- final Iterator<XReference> refs_1 = _iterator_1;
- XReference _next_2 = refs_1.next();
- XReference refX_1 = _next_2;
- XReference _next_3 = refs_1.next();
- XReference refY_1 = _next_3;
- String _name_4 = refY_1.getName();
- GenFeature _opposite_2 = refX_1.getOpposite();
- String _name_5 = _opposite_2.getName();
- Assert.assertEquals(_name_4, _name_5);
- String _name_6 = refX_1.getName();
- GenFeature _opposite_3 = refY_1.getOpposite();
- String _name_7 = _opposite_3.getName();
- Assert.assertEquals(_name_6, _name_7);
- EList<EObject> _contents_2 = resource.getContents();
- int _size_1 = _contents_2.size();
- Assert.assertEquals(elements, _size_1);
- }
- resource.reparse(text);
- {
- EList<EObject> _contents_3 = resource.getContents();
- EObject _get_3 = _contents_3.get(0);
- EList<XClassifier> _classifiers_2 = ((XPackage) _get_3).getClassifiers();
- XClassifier _get_4 = _classifiers_2.get(0);
- final XClass clazz_2 = ((XClass) _get_4);
- EList<XMember> _members_2 = clazz_2.getMembers();
- Iterable<XReference> _filter_2 = IterableExtensions.<XReference>filter(_members_2, org.eclipse.emf.ecore.xcore.XReference.class);
- Iterator<XReference> _iterator_2 = _filter_2.iterator();
- final Iterator<XReference> refs_2 = _iterator_2;
- XReference _next_4 = refs_2.next();
- XReference refX_2 = _next_4;
- XReference _next_5 = refs_2.next();
- XReference refY_2 = _next_5;
- String _name_8 = refY_2.getName();
- GenFeature _opposite_4 = refX_2.getOpposite();
- String _name_9 = _opposite_4.getName();
- Assert.assertEquals(_name_8, _name_9);
- String _name_10 = refX_2.getName();
- GenFeature _opposite_5 = refY_2.getOpposite();
- String _name_11 = _opposite_5.getName();
- Assert.assertEquals(_name_10, _name_11);
- EList<EObject> _contents_4 = resource.getContents();
- int _size_2 = _contents_4.size();
- Assert.assertEquals(elements, _size_2);
- }
- }
-
- @Test
- public void operationReturnsVoid() throws Exception {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("package foo");
- _builder.newLine();
- _builder.append("class Bar {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("op void operation() {}");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- XPackage _parse = this.parser.parse(_builder);
- final XPackage pack = _parse;
- EList<XClassifier> _classifiers = pack.getClassifiers();
- XClassifier _head = IterableExtensions.<XClassifier>head(_classifiers);
- final XClass clazz = ((XClass) _head);
- EList<XMember> _members = clazz.getMembers();
- XMember _head_1 = IterableExtensions.<XMember>head(_members);
- final XOperation operation = ((XOperation) _head_1);
- Resource _eResource = clazz.eResource();
- EList<Diagnostic> _errors = _eResource.getErrors();
- boolean _isEmpty = _errors.isEmpty();
- Assert.assertTrue(_isEmpty);
- XGenericType _type = operation.getType();
- Assert.assertNull(_type);
- }
-
- @Test
- public void referenceMayNotBeVoid() throws Exception {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("package foo");
- _builder.newLine();
- _builder.append("class Bar {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("refers void referenceName");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- XPackage _parse = this.parser.parse(_builder);
- final XPackage pack = _parse;
- Resource _eResource = pack.eResource();
- EList<Diagnostic> _errors = _eResource.getErrors();
- String _string = _errors.toString();
- Resource _eResource_1 = pack.eResource();
- EList<Diagnostic> _errors_1 = _eResource_1.getErrors();
- int _size = _errors_1.size();
- boolean _operator_lessEqualsThan = ComparableExtensions.<Integer>operator_lessEqualsThan(((Integer)1), ((Integer)_size));
- Assert.assertTrue(_string, _operator_lessEqualsThan);
- }
-
- @Test
- public void stringResolvesToEString() throws Exception {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("package foo");
- _builder.newLine();
- _builder.append("class Bar {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("String value");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- XPackage _parse = this.parser.parse(_builder);
- final XPackage pack = _parse;
- EList<XClassifier> _classifiers = pack.getClassifiers();
- XClassifier _head = IterableExtensions.<XClassifier>head(_classifiers);
- final XClass clazz = ((XClass) _head);
- EList<XMember> _members = clazz.getMembers();
- XMember _head_1 = IterableExtensions.<XMember>head(_members);
- final XAttribute attribute = ((XAttribute) _head_1);
- XGenericType _type = attribute.getType();
- GenBase _type_1 = _type.getType();
- Assert.assertTrue((_type_1 instanceof GenClassifier));
- XGenericType _type_2 = attribute.getType();
- GenBase _type_3 = _type_2.getType();
- String _name = ((GenClassifier) _type_3).getName();
- Assert.assertEquals("EString", _name);
- }
-
- @Test
- public void testEcoreDataTypeAliases() throws Exception {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("package foo ");
- _builder.newLine();
- _builder.append("class A ");
- _builder.newLine();
- _builder.append("{ ");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("java.math.BigDecimal _bigDecimal");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("java.math.BigInteger _bigInteger");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("boolean _boolean");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("Boolean _Boolean");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("byte _byte");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("Byte _Byte");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("char _char");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("Character _Character");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("java.util.Date _date");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("double _double");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("Double _Double");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("float _float");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("Float _Float");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("int _int");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("Integer _Integer");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("Class _class");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("Object _object");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("long _long");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("Long _Long");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("short _short");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("Short _Short");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("String _String");
- _builder.newLine();
- _builder.append("} ");
- _builder.newLine();
- XPackage _parse = this.parser.parse(_builder);
- final XPackage pack = _parse;
- Resource _eResource = pack.eResource();
- EcoreUtil.resolveAll(_eResource);
- this.vth.assertNoErrors(pack);
- }
-}
+package org.eclipse.emf.ecore.xcore.tests;
+
+import com.google.inject.Inject;
+import java.io.IOException;
+import java.util.Iterator;
+import org.eclipse.emf.codegen.ecore.genmodel.GenBase;
+import org.eclipse.emf.codegen.ecore.genmodel.GenClass;
+import org.eclipse.emf.codegen.ecore.genmodel.GenClassifier;
+import org.eclipse.emf.codegen.ecore.genmodel.GenFeature;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.Resource.Diagnostic;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.ecore.xcore.XAnnotation;
+import org.eclipse.emf.ecore.xcore.XAnnotationDirective;
+import org.eclipse.emf.ecore.xcore.XAttribute;
+import org.eclipse.emf.ecore.xcore.XClass;
+import org.eclipse.emf.ecore.xcore.XClassifier;
+import org.eclipse.emf.ecore.xcore.XGenericType;
+import org.eclipse.emf.ecore.xcore.XMember;
+import org.eclipse.emf.ecore.xcore.XOperation;
+import org.eclipse.emf.ecore.xcore.XPackage;
+import org.eclipse.emf.ecore.xcore.XReference;
+import org.eclipse.emf.ecore.xcore.XcoreExtensions;
+import org.eclipse.emf.ecore.xcore.XcoreInjectorProvider;
+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.resource.XtextResource;
+import org.eclipse.xtext.xbase.lib.ComparableExtensions;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+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 ParsingTest {
+ @Inject
+ private ParseHelper<XPackage> parser;
+
+ @Inject
+ private XcoreExtensions exts;
+
+ @Inject
+ private ValidationTestHelper vth;
+
+ @Test
+ public void parseSimpleFile() throws Exception {
+ XPackage _parse = this.parser.parse("package foo");
+ final XPackage parse = _parse;
+ String _name = parse.getName();
+ Assert.assertEquals("foo", _name);
+ }
+
+ @Test
+ public void testJvmTypes() throws Exception {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("package foo ");
+ _builder.newLine();
+ _builder.append("class A ");
+ _builder.newLine();
+ _builder.append("{ ");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("refers A a");
+ _builder.newLine();
+ _builder.append("} ");
+ _builder.newLine();
+ XPackage _parse = this.parser.parse(_builder);
+ final XPackage pack = _parse;
+ Resource _eResource = pack.eResource();
+ EcoreUtil.resolveAll(_eResource);
+ this.vth.assertNoErrors(pack);
+ }
+
+ @Test
+ public void testSuperTypeLinking_1() throws Exception {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("package foo ");
+ _builder.newLine();
+ _builder.append("class A {} ");
+ _builder.newLine();
+ _builder.append("class B extends A {}");
+ _builder.newLine();
+ XPackage _parse = this.parser.parse(_builder);
+ final XPackage pack = _parse;
+ EList<XClassifier> _classifiers = pack.getClassifiers();
+ XClassifier _get = _classifiers.get(1);
+ final XClass clazz = ((XClass) _get);
+ EList<XGenericType> _superTypes = clazz.getSuperTypes();
+ XGenericType _head = IterableExtensions.<XGenericType>head(_superTypes);
+ GenClass _genClass = this.exts.getGenClass(_head);
+ String _name = _genClass.getName();
+ Assert.assertEquals("A", _name);
+ }
+
+ @Test
+ public void testSuperTypeLinking_2() throws Exception {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("package foo ");
+ _builder.newLine();
+ _builder.append("class A {} ");
+ _builder.newLine();
+ _builder.append("class B extends foo.A {}");
+ _builder.newLine();
+ XPackage _parse = this.parser.parse(_builder);
+ final XPackage pack = _parse;
+ EList<XClassifier> _classifiers = pack.getClassifiers();
+ XClassifier _get = _classifiers.get(1);
+ final XClass clazz = ((XClass) _get);
+ EList<XGenericType> _superTypes = clazz.getSuperTypes();
+ XGenericType _head = IterableExtensions.<XGenericType>head(_superTypes);
+ GenClass _genClass = this.exts.getGenClass(_head);
+ String _name = _genClass.getName();
+ Assert.assertEquals("A", _name);
+ }
+
+ @Test
+ public void testReferenceToAnnotation() throws Exception {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("package foo ");
+ _builder.newLine();
+ _builder.append("annotation \'foo/bar\' as foo");
+ _builder.newLine();
+ _builder.append("@foo(holla=\'bar\')");
+ _builder.newLine();
+ _builder.append("class A {} ");
+ _builder.newLine();
+ XPackage _parse = this.parser.parse(_builder);
+ final XPackage pack = _parse;
+ EList<XClassifier> _classifiers = pack.getClassifiers();
+ XClassifier _get = _classifiers.get(0);
+ final XClass clazz = ((XClass) _get);
+ EList<XAnnotationDirective> _annotationDirectives = pack.getAnnotationDirectives();
+ XAnnotationDirective _head = IterableExtensions.<XAnnotationDirective>head(_annotationDirectives);
+ EList<XAnnotation> _annotations = clazz.getAnnotations();
+ XAnnotation _head_1 = IterableExtensions.<XAnnotation>head(_annotations);
+ XAnnotationDirective _source = _head_1.getSource();
+ Assert.assertEquals(_head, _source);
+ }
+
+ @Test
+ public void testReferenceToOpposite() throws IOException, Exception {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("package foo");
+ _builder.newLine();
+ _builder.append("class X");
+ _builder.newLine();
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("refers X x opposite y ");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("refers X y opposite x");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("op void foo() {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("val X x = null");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ String _string = _builder.toString();
+ final String text = _string;
+ XPackage _parse = this.parser.parse(text);
+ final XPackage pack = _parse;
+ {
+ EList<XClassifier> _classifiers = pack.getClassifiers();
+ XClassifier _get = _classifiers.get(0);
+ final XClass clazz = ((XClass) _get);
+ EList<XMember> _members = clazz.getMembers();
+ Iterable<XReference> _filter = IterableExtensions.<XReference>filter(_members, org.eclipse.emf.ecore.xcore.XReference.class);
+ Iterator<XReference> _iterator = _filter.iterator();
+ final Iterator<XReference> refs = _iterator;
+ XReference _next = refs.next();
+ XReference refX = _next;
+ XReference _next_1 = refs.next();
+ XReference refY = _next_1;
+ String _name = refY.getName();
+ GenFeature _opposite = refX.getOpposite();
+ String _name_1 = _opposite.getName();
+ Assert.assertEquals(_name, _name_1);
+ String _name_2 = refX.getName();
+ GenFeature _opposite_1 = refY.getOpposite();
+ String _name_3 = _opposite_1.getName();
+ Assert.assertEquals(_name_2, _name_3);
+ }
+ Resource _eResource = pack.eResource();
+ final XtextResource resource = ((XtextResource) _eResource);
+ EList<EObject> _contents = resource.getContents();
+ int _size = _contents.size();
+ final int elements = _size;
+ int _length = text.length();
+ resource.update(0, _length, text);
+ {
+ EList<EObject> _contents_1 = resource.getContents();
+ EObject _get_1 = _contents_1.get(0);
+ EList<XClassifier> _classifiers_1 = ((XPackage) _get_1).getClassifiers();
+ XClassifier _get_2 = _classifiers_1.get(0);
+ final XClass clazz_1 = ((XClass) _get_2);
+ EList<XMember> _members_1 = clazz_1.getMembers();
+ Iterable<XReference> _filter_1 = IterableExtensions.<XReference>filter(_members_1, org.eclipse.emf.ecore.xcore.XReference.class);
+ Iterator<XReference> _iterator_1 = _filter_1.iterator();
+ final Iterator<XReference> refs_1 = _iterator_1;
+ XReference _next_2 = refs_1.next();
+ XReference refX_1 = _next_2;
+ XReference _next_3 = refs_1.next();
+ XReference refY_1 = _next_3;
+ String _name_4 = refY_1.getName();
+ GenFeature _opposite_2 = refX_1.getOpposite();
+ String _name_5 = _opposite_2.getName();
+ Assert.assertEquals(_name_4, _name_5);
+ String _name_6 = refX_1.getName();
+ GenFeature _opposite_3 = refY_1.getOpposite();
+ String _name_7 = _opposite_3.getName();
+ Assert.assertEquals(_name_6, _name_7);
+ EList<EObject> _contents_2 = resource.getContents();
+ int _size_1 = _contents_2.size();
+ Assert.assertEquals(elements, _size_1);
+ }
+ resource.reparse(text);
+ {
+ EList<EObject> _contents_3 = resource.getContents();
+ EObject _get_3 = _contents_3.get(0);
+ EList<XClassifier> _classifiers_2 = ((XPackage) _get_3).getClassifiers();
+ XClassifier _get_4 = _classifiers_2.get(0);
+ final XClass clazz_2 = ((XClass) _get_4);
+ EList<XMember> _members_2 = clazz_2.getMembers();
+ Iterable<XReference> _filter_2 = IterableExtensions.<XReference>filter(_members_2, org.eclipse.emf.ecore.xcore.XReference.class);
+ Iterator<XReference> _iterator_2 = _filter_2.iterator();
+ final Iterator<XReference> refs_2 = _iterator_2;
+ XReference _next_4 = refs_2.next();
+ XReference refX_2 = _next_4;
+ XReference _next_5 = refs_2.next();
+ XReference refY_2 = _next_5;
+ String _name_8 = refY_2.getName();
+ GenFeature _opposite_4 = refX_2.getOpposite();
+ String _name_9 = _opposite_4.getName();
+ Assert.assertEquals(_name_8, _name_9);
+ String _name_10 = refX_2.getName();
+ GenFeature _opposite_5 = refY_2.getOpposite();
+ String _name_11 = _opposite_5.getName();
+ Assert.assertEquals(_name_10, _name_11);
+ EList<EObject> _contents_4 = resource.getContents();
+ int _size_2 = _contents_4.size();
+ Assert.assertEquals(elements, _size_2);
+ }
+ }
+
+ @Test
+ public void operationReturnsVoid() throws Exception {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("package foo");
+ _builder.newLine();
+ _builder.append("class Bar {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("op void operation() {}");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ XPackage _parse = this.parser.parse(_builder);
+ final XPackage pack = _parse;
+ EList<XClassifier> _classifiers = pack.getClassifiers();
+ XClassifier _head = IterableExtensions.<XClassifier>head(_classifiers);
+ final XClass clazz = ((XClass) _head);
+ EList<XMember> _members = clazz.getMembers();
+ XMember _head_1 = IterableExtensions.<XMember>head(_members);
+ final XOperation operation = ((XOperation) _head_1);
+ Resource _eResource = clazz.eResource();
+ EList<Diagnostic> _errors = _eResource.getErrors();
+ boolean _isEmpty = _errors.isEmpty();
+ Assert.assertTrue(_isEmpty);
+ XGenericType _type = operation.getType();
+ Assert.assertNull(_type);
+ }
+
+ @Test
+ public void referenceMayNotBeVoid() throws Exception {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("package foo");
+ _builder.newLine();
+ _builder.append("class Bar {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("refers void referenceName");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ XPackage _parse = this.parser.parse(_builder);
+ final XPackage pack = _parse;
+ Resource _eResource = pack.eResource();
+ EList<Diagnostic> _errors = _eResource.getErrors();
+ String _string = _errors.toString();
+ Resource _eResource_1 = pack.eResource();
+ EList<Diagnostic> _errors_1 = _eResource_1.getErrors();
+ int _size = _errors_1.size();
+ boolean _operator_lessEqualsThan = ComparableExtensions.<Integer>operator_lessEqualsThan(((Integer)1), ((Integer)_size));
+ Assert.assertTrue(_string, _operator_lessEqualsThan);
+ }
+
+ @Test
+ public void stringResolvesToEString() throws Exception {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("package foo");
+ _builder.newLine();
+ _builder.append("class Bar {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("String value");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ XPackage _parse = this.parser.parse(_builder);
+ final XPackage pack = _parse;
+ EList<XClassifier> _classifiers = pack.getClassifiers();
+ XClassifier _head = IterableExtensions.<XClassifier>head(_classifiers);
+ final XClass clazz = ((XClass) _head);
+ EList<XMember> _members = clazz.getMembers();
+ XMember _head_1 = IterableExtensions.<XMember>head(_members);
+ final XAttribute attribute = ((XAttribute) _head_1);
+ XGenericType _type = attribute.getType();
+ GenBase _type_1 = _type.getType();
+ Assert.assertTrue((_type_1 instanceof GenClassifier));
+ XGenericType _type_2 = attribute.getType();
+ GenBase _type_3 = _type_2.getType();
+ String _name = ((GenClassifier) _type_3).getName();
+ Assert.assertEquals("EString", _name);
+ }
+
+ @Test
+ public void testEcoreDataTypeAliases() throws Exception {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("package foo ");
+ _builder.newLine();
+ _builder.append("class A ");
+ _builder.newLine();
+ _builder.append("{ ");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("java.math.BigDecimal _bigDecimal");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("java.math.BigInteger _bigInteger");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("boolean _boolean");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("Boolean _Boolean");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("byte _byte");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("Byte _Byte");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("char _char");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("Character _Character");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("java.util.Date _date");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("double _double");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("Double _Double");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("float _float");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("Float _Float");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("int _int");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("Integer _Integer");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("Class _class");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("Object _object");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("long _long");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("Long _Long");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("short _short");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("Short _Short");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("String _String");
+ _builder.newLine();
+ _builder.append("} ");
+ _builder.newLine();
+ XPackage _parse = this.parser.parse(_builder);
+ final XPackage pack = _parse;
+ Resource _eResource = pack.eResource();
+ EcoreUtil.resolveAll(_eResource);
+ this.vth.assertNoErrors(pack);
+ }
+}
diff --git a/org.eclipse.emf.ecore.xcore.tests/xtend-gen/org/eclipse/emf/ecore/xcore/tests/interpreter/XcoreInterpreterTest.java b/org.eclipse.emf.ecore.xcore.tests/xtend-gen/org/eclipse/emf/ecore/xcore/tests/interpreter/XcoreInterpreterTest.java
index 2f92b7c..811d060 100644
--- a/org.eclipse.emf.ecore.xcore.tests/xtend-gen/org/eclipse/emf/ecore/xcore/tests/interpreter/XcoreInterpreterTest.java
+++ b/org.eclipse.emf.ecore.xcore.tests/xtend-gen/org/eclipse/emf/ecore/xcore/tests/interpreter/XcoreInterpreterTest.java
@@ -1,324 +1,324 @@
-package org.eclipse.emf.ecore.xcore.tests.interpreter;
-
-import com.google.inject.Inject;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.List;
-import org.eclipse.emf.common.util.BasicEList;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EDataType;
-import org.eclipse.emf.ecore.EEnum;
-import org.eclipse.emf.ecore.EEnumLiteral;
-import org.eclipse.emf.ecore.EFactory;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EOperation;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.xcore.XPackage;
-import org.eclipse.emf.ecore.xcore.XcoreInjectorProvider;
-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.xbase.lib.CollectionLiterals;
-import org.eclipse.xtext.xbase.lib.IterableExtensions;
-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 XcoreInterpreterTest {
- @Inject
- private ParseHelper<XPackage> parse;
-
- @Inject
- private ValidationTestHelper validator;
-
- @Test
- public void testInterpretation() throws Exception, InvocationTargetException {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("package foo.bar");
- _builder.newLine();
- _builder.newLine();
- _builder.append("class Foo {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("op String doStuff(String msg) {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("return \"Foo says hi to \"+msg");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- XPackage _parse = this.parse.parse(_builder);
- final XPackage pack = _parse;
- this.validator.assertNoErrors(pack);
- Resource _eResource = pack.eResource();
- EList<EObject> _contents = _eResource.getContents();
- EObject _get = _contents.get(2);
- final EPackage ePackage = ((EPackage) _get);
- EClassifier _eClassifier = ePackage.getEClassifier("Foo");
- final EClass fooClass = ((EClass) _eClassifier);
- EFactory _eFactoryInstance = ePackage.getEFactoryInstance();
- EObject _create = _eFactoryInstance.create(fooClass);
- final EObject foo = _create;
- EList<EOperation> _eOperations = fooClass.getEOperations();
- EOperation _head = IterableExtensions.<EOperation>head(_eOperations);
- ArrayList<String> _newArrayList = CollectionLiterals.<String>newArrayList("Bar");
- BasicEList<String> _basicEList = new BasicEList<String>(_newArrayList);
- Object _eInvoke = foo.eInvoke(_head, _basicEList);
- Assert.assertEquals("Foo says hi to Bar", _eInvoke);
- }
-
- @Test
- public void testInterpretation_2() throws Exception, InvocationTargetException {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("package foo.bar");
- _builder.newLine();
- _builder.newLine();
- _builder.append("class Foo {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("op String call1(String msg) {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("return \"call1\"+call2(\"call1\"+msg)");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("op String call2(String msg) {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("return \"call2\"+msg");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- XPackage _parse = this.parse.parse(_builder);
- final XPackage pack = _parse;
- this.validator.assertNoErrors(pack);
- Resource _eResource = pack.eResource();
- EList<EObject> _contents = _eResource.getContents();
- EObject _get = _contents.get(2);
- final EPackage ePackage = ((EPackage) _get);
- EClassifier _eClassifier = ePackage.getEClassifier("Foo");
- final EClass fooClass = ((EClass) _eClassifier);
- EFactory _eFactoryInstance = ePackage.getEFactoryInstance();
- EObject _create = _eFactoryInstance.create(fooClass);
- final EObject foo = _create;
- EList<EOperation> _eOperations = fooClass.getEOperations();
- EOperation _head = IterableExtensions.<EOperation>head(_eOperations);
- ArrayList<String> _newArrayList = CollectionLiterals.<String>newArrayList("Bar");
- BasicEList<String> _basicEList = new BasicEList<String>(_newArrayList);
- Object _eInvoke = foo.eInvoke(_head, _basicEList);
- Assert.assertEquals("call1call2call1Bar", _eInvoke);
- }
-
- @Test
- public void testFeatureAccessors() throws Exception, InvocationTargetException {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("package foo.bar");
- _builder.newLine();
- _builder.newLine();
- _builder.append("class Foo {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("String value");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("op void storeValue(String newValue) {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("value = newValue");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("op String fetchValue() {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("return value");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- XPackage _parse = this.parse.parse(_builder);
- final XPackage pack = _parse;
- this.validator.assertNoErrors(pack);
- Resource _eResource = pack.eResource();
- EList<EObject> _contents = _eResource.getContents();
- EObject _get = _contents.get(2);
- final EPackage ePackage = ((EPackage) _get);
- EClassifier _eClassifier = ePackage.getEClassifier("Foo");
- final EClass fooClass = ((EClass) _eClassifier);
- EFactory _eFactoryInstance = ePackage.getEFactoryInstance();
- EObject _create = _eFactoryInstance.create(fooClass);
- final EObject foo = _create;
- EList<EOperation> _eOperations = fooClass.getEOperations();
- EOperation _head = IterableExtensions.<EOperation>head(_eOperations);
- ArrayList<String> _newArrayList = CollectionLiterals.<String>newArrayList("Bar");
- BasicEList<String> _basicEList = new BasicEList<String>(_newArrayList);
- foo.eInvoke(_head, _basicEList);
- EList<EOperation> _eOperations_1 = fooClass.getEOperations();
- EOperation _get_1 = _eOperations_1.get(1);
- Object _eInvoke = foo.eInvoke(_get_1, null);
- Assert.assertEquals("Bar", _eInvoke);
- }
-
- @Test
- public void testConversionDelegates() throws Exception {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("package foo.bar ");
- _builder.newLine();
- _builder.newLine();
- _builder.append("type URI wraps org.eclipse.emf.common.util.URI ");
- _builder.newLine();
- _builder.append("create { if (it == null) null else org::eclipse::emf::common::util::URI::createURI(it) } ");
- _builder.newLine();
- _builder.append("convert { it?.toString }");
- _builder.newLine();
- XPackage _parse = this.parse.parse(_builder);
- final XPackage pack = _parse;
- this.validator.assertNoErrors(pack);
- Resource _eResource = pack.eResource();
- EList<EObject> _contents = _eResource.getContents();
- EObject _get = _contents.get(2);
- final EPackage ePackage = ((EPackage) _get);
- EClassifier _eClassifier = ePackage.getEClassifier("URI");
- final EDataType uriDataType = ((EDataType) _eClassifier);
- final String literal = "http://www.eclipse.org";
- EFactory _eFactoryInstance = ePackage.getEFactoryInstance();
- Object _createFromString = _eFactoryInstance.createFromString(uriDataType, literal);
- final URI uri = ((URI) _createFromString);
- EFactory _eFactoryInstance_1 = ePackage.getEFactoryInstance();
- String _convertToString = _eFactoryInstance_1.convertToString(uriDataType, uri);
- Assert.assertEquals(literal, _convertToString);
- }
-
- @Test
- public void testSettingDelegates() throws Exception {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("package foo.bar");
- _builder.newLine();
- _builder.append("class Foo");
- _builder.newLine();
- _builder.append("{");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("String name");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("String alias get { name}");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- XPackage _parse = this.parse.parse(_builder);
- final XPackage pack = _parse;
- this.validator.assertNoErrors(pack);
- Resource _eResource = pack.eResource();
- EList<EObject> _contents = _eResource.getContents();
- EObject _get = _contents.get(2);
- final EPackage ePackage = ((EPackage) _get);
- EClassifier _eClassifier = ePackage.getEClassifier("Foo");
- final EClass fooClass = ((EClass) _eClassifier);
- EFactory _eFactoryInstance = ePackage.getEFactoryInstance();
- EObject _create = _eFactoryInstance.create(fooClass);
- final EObject foo = _create;
- EStructuralFeature _eStructuralFeature = fooClass.getEStructuralFeature("name");
- foo.eSet(_eStructuralFeature, "Sven");
- EStructuralFeature _eStructuralFeature_1 = fooClass.getEStructuralFeature("alias");
- Object _eGet = foo.eGet(_eStructuralFeature_1);
- Assert.assertEquals("Sven", _eGet);
- }
-
- @Test
- public void testEnum() throws Exception {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("package foo.bar");
- _builder.newLine();
- _builder.append("enum NodeKind { Singleton Root Intermediate Leaf }");
- _builder.newLine();
- _builder.append("class Node");
- _builder.newLine();
- _builder.append("{");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("refers Node parent opposite children");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("contains Node[0..*] children opposite parent");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("op boolean hasChildren() { !children.empty }");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("transient volatile derived readonly NodeKind nodeKind");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("get");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("{");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("if (hasChildren()) {if (parent == null) {NodeKind::ROOT} else {NodeKind::INTERMEDIATE}}");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("else {if (parent == null) {NodeKind::SINGLETON} else {NodeKind::LEAF}}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- XPackage _parse = this.parse.parse(_builder);
- final XPackage pack = _parse;
- this.validator.assertNoErrors(pack);
- Resource _eResource = pack.eResource();
- EList<EObject> _contents = _eResource.getContents();
- EObject _get = _contents.get(2);
- final EPackage ePackage = ((EPackage) _get);
- EClassifier _eClassifier = ePackage.getEClassifier("NodeKind");
- final EEnum nodeKindEnum = ((EEnum) _eClassifier);
- EClassifier _eClassifier_1 = ePackage.getEClassifier("Node");
- final EClass nodeClass = ((EClass) _eClassifier_1);
- EFactory _eFactoryInstance = ePackage.getEFactoryInstance();
- EObject _create = _eFactoryInstance.create(nodeClass);
- final EObject node = _create;
- EEnumLiteral _eEnumLiteral = nodeKindEnum.getEEnumLiteral("Singleton");
- EStructuralFeature _eStructuralFeature = nodeClass.getEStructuralFeature("nodeKind");
- Object _eGet = node.eGet(_eStructuralFeature);
- Assert.assertEquals(_eEnumLiteral, _eGet);
- EFactory _eFactoryInstance_1 = ePackage.getEFactoryInstance();
- EObject _create_1 = _eFactoryInstance_1.create(nodeClass);
- final EObject childNode = _create_1;
- EStructuralFeature _eStructuralFeature_1 = nodeClass.getEStructuralFeature("children");
- Object _eGet_1 = node.eGet(_eStructuralFeature_1);
- ((List) _eGet_1).add(childNode);
- EEnumLiteral _eEnumLiteral_1 = nodeKindEnum.getEEnumLiteral("Root");
- EStructuralFeature _eStructuralFeature_2 = nodeClass.getEStructuralFeature("nodeKind");
- Object _eGet_2 = node.eGet(_eStructuralFeature_2);
- Assert.assertEquals(_eEnumLiteral_1, _eGet_2);
- }
-}
+package org.eclipse.emf.ecore.xcore.tests.interpreter;
+
+import com.google.inject.Inject;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.emf.common.util.BasicEList;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.EEnum;
+import org.eclipse.emf.ecore.EEnumLiteral;
+import org.eclipse.emf.ecore.EFactory;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EOperation;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.xcore.XPackage;
+import org.eclipse.emf.ecore.xcore.XcoreInjectorProvider;
+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.xbase.lib.CollectionLiterals;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+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 XcoreInterpreterTest {
+ @Inject
+ private ParseHelper<XPackage> parse;
+
+ @Inject
+ private ValidationTestHelper validator;
+
+ @Test
+ public void testInterpretation() throws Exception, InvocationTargetException {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("package foo.bar");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("class Foo {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("op String doStuff(String msg) {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("return \"Foo says hi to \"+msg");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ XPackage _parse = this.parse.parse(_builder);
+ final XPackage pack = _parse;
+ this.validator.assertNoErrors(pack);
+ Resource _eResource = pack.eResource();
+ EList<EObject> _contents = _eResource.getContents();
+ EObject _get = _contents.get(2);
+ final EPackage ePackage = ((EPackage) _get);
+ EClassifier _eClassifier = ePackage.getEClassifier("Foo");
+ final EClass fooClass = ((EClass) _eClassifier);
+ EFactory _eFactoryInstance = ePackage.getEFactoryInstance();
+ EObject _create = _eFactoryInstance.create(fooClass);
+ final EObject foo = _create;
+ EList<EOperation> _eOperations = fooClass.getEOperations();
+ EOperation _head = IterableExtensions.<EOperation>head(_eOperations);
+ ArrayList<String> _newArrayList = CollectionLiterals.<String>newArrayList("Bar");
+ BasicEList<String> _basicEList = new BasicEList<String>(_newArrayList);
+ Object _eInvoke = foo.eInvoke(_head, _basicEList);
+ Assert.assertEquals("Foo says hi to Bar", _eInvoke);
+ }
+
+ @Test
+ public void testInterpretation_2() throws Exception, InvocationTargetException {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("package foo.bar");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("class Foo {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("op String call1(String msg) {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("return \"call1\"+call2(\"call1\"+msg)");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("op String call2(String msg) {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("return \"call2\"+msg");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ XPackage _parse = this.parse.parse(_builder);
+ final XPackage pack = _parse;
+ this.validator.assertNoErrors(pack);
+ Resource _eResource = pack.eResource();
+ EList<EObject> _contents = _eResource.getContents();
+ EObject _get = _contents.get(2);
+ final EPackage ePackage = ((EPackage) _get);
+ EClassifier _eClassifier = ePackage.getEClassifier("Foo");
+ final EClass fooClass = ((EClass) _eClassifier);
+ EFactory _eFactoryInstance = ePackage.getEFactoryInstance();
+ EObject _create = _eFactoryInstance.create(fooClass);
+ final EObject foo = _create;
+ EList<EOperation> _eOperations = fooClass.getEOperations();
+ EOperation _head = IterableExtensions.<EOperation>head(_eOperations);
+ ArrayList<String> _newArrayList = CollectionLiterals.<String>newArrayList("Bar");
+ BasicEList<String> _basicEList = new BasicEList<String>(_newArrayList);
+ Object _eInvoke = foo.eInvoke(_head, _basicEList);
+ Assert.assertEquals("call1call2call1Bar", _eInvoke);
+ }
+
+ @Test
+ public void testFeatureAccessors() throws Exception, InvocationTargetException {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("package foo.bar");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("class Foo {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("String value");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("op void storeValue(String newValue) {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("value = newValue");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("op String fetchValue() {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("return value");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ XPackage _parse = this.parse.parse(_builder);
+ final XPackage pack = _parse;
+ this.validator.assertNoErrors(pack);
+ Resource _eResource = pack.eResource();
+ EList<EObject> _contents = _eResource.getContents();
+ EObject _get = _contents.get(2);
+ final EPackage ePackage = ((EPackage) _get);
+ EClassifier _eClassifier = ePackage.getEClassifier("Foo");
+ final EClass fooClass = ((EClass) _eClassifier);
+ EFactory _eFactoryInstance = ePackage.getEFactoryInstance();
+ EObject _create = _eFactoryInstance.create(fooClass);
+ final EObject foo = _create;
+ EList<EOperation> _eOperations = fooClass.getEOperations();
+ EOperation _head = IterableExtensions.<EOperation>head(_eOperations);
+ ArrayList<String> _newArrayList = CollectionLiterals.<String>newArrayList("Bar");
+ BasicEList<String> _basicEList = new BasicEList<String>(_newArrayList);
+ foo.eInvoke(_head, _basicEList);
+ EList<EOperation> _eOperations_1 = fooClass.getEOperations();
+ EOperation _get_1 = _eOperations_1.get(1);
+ Object _eInvoke = foo.eInvoke(_get_1, null);
+ Assert.assertEquals("Bar", _eInvoke);
+ }
+
+ @Test
+ public void testConversionDelegates() throws Exception {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("package foo.bar ");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("type URI wraps org.eclipse.emf.common.util.URI ");
+ _builder.newLine();
+ _builder.append("create { if (it == null) null else org::eclipse::emf::common::util::URI::createURI(it) } ");
+ _builder.newLine();
+ _builder.append("convert { it?.toString }");
+ _builder.newLine();
+ XPackage _parse = this.parse.parse(_builder);
+ final XPackage pack = _parse;
+ this.validator.assertNoErrors(pack);
+ Resource _eResource = pack.eResource();
+ EList<EObject> _contents = _eResource.getContents();
+ EObject _get = _contents.get(2);
+ final EPackage ePackage = ((EPackage) _get);
+ EClassifier _eClassifier = ePackage.getEClassifier("URI");
+ final EDataType uriDataType = ((EDataType) _eClassifier);
+ final String literal = "http://www.eclipse.org";
+ EFactory _eFactoryInstance = ePackage.getEFactoryInstance();
+ Object _createFromString = _eFactoryInstance.createFromString(uriDataType, literal);
+ final URI uri = ((URI) _createFromString);
+ EFactory _eFactoryInstance_1 = ePackage.getEFactoryInstance();
+ String _convertToString = _eFactoryInstance_1.convertToString(uriDataType, uri);
+ Assert.assertEquals(literal, _convertToString);
+ }
+
+ @Test
+ public void testSettingDelegates() throws Exception {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("package foo.bar");
+ _builder.newLine();
+ _builder.append("class Foo");
+ _builder.newLine();
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("String name");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("String alias get { name}");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ XPackage _parse = this.parse.parse(_builder);
+ final XPackage pack = _parse;
+ this.validator.assertNoErrors(pack);
+ Resource _eResource = pack.eResource();
+ EList<EObject> _contents = _eResource.getContents();
+ EObject _get = _contents.get(2);
+ final EPackage ePackage = ((EPackage) _get);
+ EClassifier _eClassifier = ePackage.getEClassifier("Foo");
+ final EClass fooClass = ((EClass) _eClassifier);
+ EFactory _eFactoryInstance = ePackage.getEFactoryInstance();
+ EObject _create = _eFactoryInstance.create(fooClass);
+ final EObject foo = _create;
+ EStructuralFeature _eStructuralFeature = fooClass.getEStructuralFeature("name");
+ foo.eSet(_eStructuralFeature, "Sven");
+ EStructuralFeature _eStructuralFeature_1 = fooClass.getEStructuralFeature("alias");
+ Object _eGet = foo.eGet(_eStructuralFeature_1);
+ Assert.assertEquals("Sven", _eGet);
+ }
+
+ @Test
+ public void testEnum() throws Exception {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("package foo.bar");
+ _builder.newLine();
+ _builder.append("enum NodeKind { Singleton Root Intermediate Leaf }");
+ _builder.newLine();
+ _builder.append("class Node");
+ _builder.newLine();
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("refers Node parent opposite children");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("contains Node[0..*] children opposite parent");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("op boolean hasChildren() { !children.empty }");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("transient volatile derived readonly NodeKind nodeKind");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("get");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("if (hasChildren()) {if (parent == null) {NodeKind::ROOT} else {NodeKind::INTERMEDIATE}}");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("else {if (parent == null) {NodeKind::SINGLETON} else {NodeKind::LEAF}}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ XPackage _parse = this.parse.parse(_builder);
+ final XPackage pack = _parse;
+ this.validator.assertNoErrors(pack);
+ Resource _eResource = pack.eResource();
+ EList<EObject> _contents = _eResource.getContents();
+ EObject _get = _contents.get(2);
+ final EPackage ePackage = ((EPackage) _get);
+ EClassifier _eClassifier = ePackage.getEClassifier("NodeKind");
+ final EEnum nodeKindEnum = ((EEnum) _eClassifier);
+ EClassifier _eClassifier_1 = ePackage.getEClassifier("Node");
+ final EClass nodeClass = ((EClass) _eClassifier_1);
+ EFactory _eFactoryInstance = ePackage.getEFactoryInstance();
+ EObject _create = _eFactoryInstance.create(nodeClass);
+ final EObject node = _create;
+ EEnumLiteral _eEnumLiteral = nodeKindEnum.getEEnumLiteral("Singleton");
+ EStructuralFeature _eStructuralFeature = nodeClass.getEStructuralFeature("nodeKind");
+ Object _eGet = node.eGet(_eStructuralFeature);
+ Assert.assertEquals(_eEnumLiteral, _eGet);
+ EFactory _eFactoryInstance_1 = ePackage.getEFactoryInstance();
+ EObject _create_1 = _eFactoryInstance_1.create(nodeClass);
+ final EObject childNode = _create_1;
+ EStructuralFeature _eStructuralFeature_1 = nodeClass.getEStructuralFeature("children");
+ Object _eGet_1 = node.eGet(_eStructuralFeature_1);
+ ((List) _eGet_1).add(childNode);
+ EEnumLiteral _eEnumLiteral_1 = nodeKindEnum.getEEnumLiteral("Root");
+ EStructuralFeature _eStructuralFeature_2 = nodeClass.getEStructuralFeature("nodeKind");
+ Object _eGet_2 = node.eGet(_eStructuralFeature_2);
+ Assert.assertEquals(_eEnumLiteral_1, _eGet_2);
+ }
+}
diff --git a/org.eclipse.emf.ecore.xcore.tests/xtend-gen/org/eclipse/emf/ecore/xcore/tests/mapping/XcoreMapperTest.java b/org.eclipse.emf.ecore.xcore.tests/xtend-gen/org/eclipse/emf/ecore/xcore/tests/mapping/XcoreMapperTest.java
index 2b1c471..345538a 100644
--- a/org.eclipse.emf.ecore.xcore.tests/xtend-gen/org/eclipse/emf/ecore/xcore/tests/mapping/XcoreMapperTest.java
+++ b/org.eclipse.emf.ecore.xcore.tests/xtend-gen/org/eclipse/emf/ecore/xcore/tests/mapping/XcoreMapperTest.java
@@ -1,185 +1,185 @@
-package org.eclipse.emf.ecore.xcore.tests.mapping;
-
-import com.google.inject.Inject;
-import org.eclipse.emf.codegen.ecore.genmodel.GenClass;
-import org.eclipse.emf.codegen.ecore.genmodel.GenFeature;
-import org.eclipse.emf.codegen.ecore.genmodel.GenOperation;
-import org.eclipse.emf.codegen.ecore.genmodel.GenPackage;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EOperation;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.xcore.XClass;
-import org.eclipse.emf.ecore.xcore.XClassifier;
-import org.eclipse.emf.ecore.xcore.XMember;
-import org.eclipse.emf.ecore.xcore.XNamedElement;
-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.XcoreInjectorProvider;
-import org.eclipse.emf.ecore.xcore.mappings.ToXcoreMapping;
-import org.eclipse.emf.ecore.xcore.mappings.XClassMapping;
-import org.eclipse.emf.ecore.xcore.mappings.XFeatureMapping;
-import org.eclipse.emf.ecore.xcore.mappings.XOperationMapping;
-import org.eclipse.emf.ecore.xcore.mappings.XPackageMapping;
-import org.eclipse.emf.ecore.xcore.mappings.XcoreMapper;
-import org.eclipse.xtext.junit4.InjectWith;
-import org.eclipse.xtext.junit4.XtextRunner;
-import org.eclipse.xtext.junit4.util.ParseHelper;
-import org.eclipse.xtext.xbase.lib.IterableExtensions;
-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 XcoreMapperTest {
- @Inject
- private ParseHelper<XPackage> parser;
-
- @Inject
- private XcoreMapper mapper;
-
- @Test
- public void testMapping() throws Exception {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("package foo.bar");
- _builder.newLine();
- _builder.newLine();
- _builder.append("type String wraps java.lang.String");
- _builder.newLine();
- _builder.newLine();
- _builder.append("class X {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("attr String name");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("refers Y reference");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- _builder.append("class Y extends X {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("op String toString(X x) {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("return null");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- XPackage _parse = this.parser.parse(_builder);
- final XPackage pack = _parse;
- XPackageMapping _mapping = this.mapper.getMapping(pack);
- EPackage _ePackage = _mapping.getEPackage();
- Assert.assertNotNull(_ePackage);
- XPackageMapping _mapping_1 = this.mapper.getMapping(pack);
- EPackage _ePackage_1 = _mapping_1.getEPackage();
- XPackageMapping _mapping_2 = this.mapper.getMapping(pack);
- GenPackage _genPackage = _mapping_2.getGenPackage();
- EPackage _ecorePackage = _genPackage.getEcorePackage();
- Assert.assertEquals(_ePackage_1, _ecorePackage);
- XPackageMapping _mapping_3 = this.mapper.getMapping(pack);
- GenPackage _genPackage_1 = _mapping_3.getGenPackage();
- ToXcoreMapping _xcoreMapping = this.mapper.getToXcoreMapping(_genPackage_1);
- XNamedElement _xcoreElement = _xcoreMapping.getXcoreElement();
- Assert.assertEquals(pack, _xcoreElement);
- XPackageMapping _mapping_4 = this.mapper.getMapping(pack);
- EPackage _ePackage_2 = _mapping_4.getEPackage();
- ToXcoreMapping _xcoreMapping_1 = this.mapper.getToXcoreMapping(_ePackage_2);
- XNamedElement _xcoreElement_1 = _xcoreMapping_1.getXcoreElement();
- Assert.assertEquals(pack, _xcoreElement_1);
- EList<XClassifier> _classifiers = pack.getClassifiers();
- Iterable<XClass> _filter = IterableExtensions.<XClass>filter(_classifiers, org.eclipse.emf.ecore.xcore.XClass.class);
- for (final XClass clazz : _filter) {
- {
- XClassMapping _mapping_5 = this.mapper.getMapping(clazz);
- EClass _eClass = _mapping_5.getEClass();
- Assert.assertNotNull(_eClass);
- XClassMapping _mapping_6 = this.mapper.getMapping(clazz);
- EClass _eClass_1 = _mapping_6.getEClass();
- XClassMapping _mapping_7 = this.mapper.getMapping(clazz);
- GenClass _genClass = _mapping_7.getGenClass();
- EClass _ecoreClass = _genClass.getEcoreClass();
- Assert.assertEquals(_eClass_1, _ecoreClass);
- XClassMapping _mapping_8 = this.mapper.getMapping(clazz);
- GenClass _genClass_1 = _mapping_8.getGenClass();
- ToXcoreMapping _xcoreMapping_2 = this.mapper.getToXcoreMapping(_genClass_1);
- XNamedElement _xcoreElement_2 = _xcoreMapping_2.getXcoreElement();
- Assert.assertEquals(clazz, _xcoreElement_2);
- XClassMapping _mapping_9 = this.mapper.getMapping(clazz);
- EClass _eClass_2 = _mapping_9.getEClass();
- ToXcoreMapping _xcoreMapping_3 = this.mapper.getToXcoreMapping(_eClass_2);
- XNamedElement _xcoreElement_3 = _xcoreMapping_3.getXcoreElement();
- Assert.assertEquals(clazz, _xcoreElement_3);
- EList<XMember> _members = clazz.getMembers();
- for (final XMember member : _members) {
- final XMember member_1 = member;
- boolean matched = false;
- if (!matched) {
- if (member_1 instanceof XStructuralFeature) {
- final XStructuralFeature member_2 = (XStructuralFeature) member_1;
- matched=true;
- {
- XFeatureMapping _mapping_10 = this.mapper.getMapping(member_2);
- EStructuralFeature _eStructuralFeature = _mapping_10.getEStructuralFeature();
- Assert.assertNotNull(_eStructuralFeature);
- XFeatureMapping _mapping_11 = this.mapper.getMapping(member_2);
- EStructuralFeature _eStructuralFeature_1 = _mapping_11.getEStructuralFeature();
- XFeatureMapping _mapping_12 = this.mapper.getMapping(member_2);
- GenFeature _genFeature = _mapping_12.getGenFeature();
- EStructuralFeature _ecoreFeature = _genFeature.getEcoreFeature();
- Assert.assertEquals(_eStructuralFeature_1, _ecoreFeature);
- XFeatureMapping _mapping_13 = this.mapper.getMapping(member_2);
- EStructuralFeature _eStructuralFeature_2 = _mapping_13.getEStructuralFeature();
- ToXcoreMapping _xcoreMapping_4 = this.mapper.getToXcoreMapping(_eStructuralFeature_2);
- XNamedElement _xcoreElement_4 = _xcoreMapping_4.getXcoreElement();
- Assert.assertEquals(member_2, _xcoreElement_4);
- XFeatureMapping _mapping_14 = this.mapper.getMapping(member_2);
- GenFeature _genFeature_1 = _mapping_14.getGenFeature();
- ToXcoreMapping _xcoreMapping_5 = this.mapper.getToXcoreMapping(_genFeature_1);
- XNamedElement _xcoreElement_5 = _xcoreMapping_5.getXcoreElement();
- Assert.assertEquals(member_2, _xcoreElement_5);
- }
- }
- }
- if (!matched) {
- if (member_1 instanceof XOperation) {
- final XOperation member_3 = (XOperation) member_1;
- matched=true;
- {
- XOperationMapping _mapping_15 = this.mapper.getMapping(member_3);
- EOperation _eOperation = _mapping_15.getEOperation();
- Assert.assertNotNull(_eOperation);
- XOperationMapping _mapping_16 = this.mapper.getMapping(member_3);
- EOperation _eOperation_1 = _mapping_16.getEOperation();
- XOperationMapping _mapping_17 = this.mapper.getMapping(member_3);
- GenOperation _genOperation = _mapping_17.getGenOperation();
- EOperation _ecoreOperation = _genOperation.getEcoreOperation();
- Assert.assertEquals(_eOperation_1, _ecoreOperation);
- XOperationMapping _mapping_18 = this.mapper.getMapping(member_3);
- EOperation _eOperation_2 = _mapping_18.getEOperation();
- ToXcoreMapping _xcoreMapping_6 = this.mapper.getToXcoreMapping(_eOperation_2);
- XNamedElement _xcoreElement_6 = _xcoreMapping_6.getXcoreElement();
- Assert.assertEquals(member_3, _xcoreElement_6);
- XOperationMapping _mapping_19 = this.mapper.getMapping(member_3);
- GenOperation _genOperation_1 = _mapping_19.getGenOperation();
- ToXcoreMapping _xcoreMapping_7 = this.mapper.getToXcoreMapping(_genOperation_1);
- XNamedElement _xcoreElement_7 = _xcoreMapping_7.getXcoreElement();
- Assert.assertEquals(member_3, _xcoreElement_7);
- }
- }
- }
- }
- }
- }
- }
-}
+package org.eclipse.emf.ecore.xcore.tests.mapping;
+
+import com.google.inject.Inject;
+import org.eclipse.emf.codegen.ecore.genmodel.GenClass;
+import org.eclipse.emf.codegen.ecore.genmodel.GenFeature;
+import org.eclipse.emf.codegen.ecore.genmodel.GenOperation;
+import org.eclipse.emf.codegen.ecore.genmodel.GenPackage;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EOperation;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.xcore.XClass;
+import org.eclipse.emf.ecore.xcore.XClassifier;
+import org.eclipse.emf.ecore.xcore.XMember;
+import org.eclipse.emf.ecore.xcore.XNamedElement;
+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.XcoreInjectorProvider;
+import org.eclipse.emf.ecore.xcore.mappings.ToXcoreMapping;
+import org.eclipse.emf.ecore.xcore.mappings.XClassMapping;
+import org.eclipse.emf.ecore.xcore.mappings.XFeatureMapping;
+import org.eclipse.emf.ecore.xcore.mappings.XOperationMapping;
+import org.eclipse.emf.ecore.xcore.mappings.XPackageMapping;
+import org.eclipse.emf.ecore.xcore.mappings.XcoreMapper;
+import org.eclipse.xtext.junit4.InjectWith;
+import org.eclipse.xtext.junit4.XtextRunner;
+import org.eclipse.xtext.junit4.util.ParseHelper;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+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 XcoreMapperTest {
+ @Inject
+ private ParseHelper<XPackage> parser;
+
+ @Inject
+ private XcoreMapper mapper;
+
+ @Test
+ public void testMapping() throws Exception {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("package foo.bar");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("type String wraps java.lang.String");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("class X {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("attr String name");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("refers Y reference");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("class Y extends X {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("op String toString(X x) {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("return null");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ XPackage _parse = this.parser.parse(_builder);
+ final XPackage pack = _parse;
+ XPackageMapping _mapping = this.mapper.getMapping(pack);
+ EPackage _ePackage = _mapping.getEPackage();
+ Assert.assertNotNull(_ePackage);
+ XPackageMapping _mapping_1 = this.mapper.getMapping(pack);
+ EPackage _ePackage_1 = _mapping_1.getEPackage();
+ XPackageMapping _mapping_2 = this.mapper.getMapping(pack);
+ GenPackage _genPackage = _mapping_2.getGenPackage();
+ EPackage _ecorePackage = _genPackage.getEcorePackage();
+ Assert.assertEquals(_ePackage_1, _ecorePackage);
+ XPackageMapping _mapping_3 = this.mapper.getMapping(pack);
+ GenPackage _genPackage_1 = _mapping_3.getGenPackage();
+ ToXcoreMapping _xcoreMapping = this.mapper.getToXcoreMapping(_genPackage_1);
+ XNamedElement _xcoreElement = _xcoreMapping.getXcoreElement();
+ Assert.assertEquals(pack, _xcoreElement);
+ XPackageMapping _mapping_4 = this.mapper.getMapping(pack);
+ EPackage _ePackage_2 = _mapping_4.getEPackage();
+ ToXcoreMapping _xcoreMapping_1 = this.mapper.getToXcoreMapping(_ePackage_2);
+ XNamedElement _xcoreElement_1 = _xcoreMapping_1.getXcoreElement();
+ Assert.assertEquals(pack, _xcoreElement_1);
+ EList<XClassifier> _classifiers = pack.getClassifiers();
+ Iterable<XClass> _filter = IterableExtensions.<XClass>filter(_classifiers, org.eclipse.emf.ecore.xcore.XClass.class);
+ for (final XClass clazz : _filter) {
+ {
+ XClassMapping _mapping_5 = this.mapper.getMapping(clazz);
+ EClass _eClass = _mapping_5.getEClass();
+ Assert.assertNotNull(_eClass);
+ XClassMapping _mapping_6 = this.mapper.getMapping(clazz);
+ EClass _eClass_1 = _mapping_6.getEClass();
+ XClassMapping _mapping_7 = this.mapper.getMapping(clazz);
+ GenClass _genClass = _mapping_7.getGenClass();
+ EClass _ecoreClass = _genClass.getEcoreClass();
+ Assert.assertEquals(_eClass_1, _ecoreClass);
+ XClassMapping _mapping_8 = this.mapper.getMapping(clazz);
+ GenClass _genClass_1 = _mapping_8.getGenClass();
+ ToXcoreMapping _xcoreMapping_2 = this.mapper.getToXcoreMapping(_genClass_1);
+ XNamedElement _xcoreElement_2 = _xcoreMapping_2.getXcoreElement();
+ Assert.assertEquals(clazz, _xcoreElement_2);
+ XClassMapping _mapping_9 = this.mapper.getMapping(clazz);
+ EClass _eClass_2 = _mapping_9.getEClass();
+ ToXcoreMapping _xcoreMapping_3 = this.mapper.getToXcoreMapping(_eClass_2);
+ XNamedElement _xcoreElement_3 = _xcoreMapping_3.getXcoreElement();
+ Assert.assertEquals(clazz, _xcoreElement_3);
+ EList<XMember> _members = clazz.getMembers();
+ for (final XMember member : _members) {
+ final XMember member_1 = member;
+ boolean matched = false;
+ if (!matched) {
+ if (member_1 instanceof XStructuralFeature) {
+ final XStructuralFeature member_2 = (XStructuralFeature) member_1;
+ matched=true;
+ {
+ XFeatureMapping _mapping_10 = this.mapper.getMapping(member_2);
+ EStructuralFeature _eStructuralFeature = _mapping_10.getEStructuralFeature();
+ Assert.assertNotNull(_eStructuralFeature);
+ XFeatureMapping _mapping_11 = this.mapper.getMapping(member_2);
+ EStructuralFeature _eStructuralFeature_1 = _mapping_11.getEStructuralFeature();
+ XFeatureMapping _mapping_12 = this.mapper.getMapping(member_2);
+ GenFeature _genFeature = _mapping_12.getGenFeature();
+ EStructuralFeature _ecoreFeature = _genFeature.getEcoreFeature();
+ Assert.assertEquals(_eStructuralFeature_1, _ecoreFeature);
+ XFeatureMapping _mapping_13 = this.mapper.getMapping(member_2);
+ EStructuralFeature _eStructuralFeature_2 = _mapping_13.getEStructuralFeature();
+ ToXcoreMapping _xcoreMapping_4 = this.mapper.getToXcoreMapping(_eStructuralFeature_2);
+ XNamedElement _xcoreElement_4 = _xcoreMapping_4.getXcoreElement();
+ Assert.assertEquals(member_2, _xcoreElement_4);
+ XFeatureMapping _mapping_14 = this.mapper.getMapping(member_2);
+ GenFeature _genFeature_1 = _mapping_14.getGenFeature();
+ ToXcoreMapping _xcoreMapping_5 = this.mapper.getToXcoreMapping(_genFeature_1);
+ XNamedElement _xcoreElement_5 = _xcoreMapping_5.getXcoreElement();
+ Assert.assertEquals(member_2, _xcoreElement_5);
+ }
+ }
+ }
+ if (!matched) {
+ if (member_1 instanceof XOperation) {
+ final XOperation member_3 = (XOperation) member_1;
+ matched=true;
+ {
+ XOperationMapping _mapping_15 = this.mapper.getMapping(member_3);
+ EOperation _eOperation = _mapping_15.getEOperation();
+ Assert.assertNotNull(_eOperation);
+ XOperationMapping _mapping_16 = this.mapper.getMapping(member_3);
+ EOperation _eOperation_1 = _mapping_16.getEOperation();
+ XOperationMapping _mapping_17 = this.mapper.getMapping(member_3);
+ GenOperation _genOperation = _mapping_17.getGenOperation();
+ EOperation _ecoreOperation = _genOperation.getEcoreOperation();
+ Assert.assertEquals(_eOperation_1, _ecoreOperation);
+ XOperationMapping _mapping_18 = this.mapper.getMapping(member_3);
+ EOperation _eOperation_2 = _mapping_18.getEOperation();
+ ToXcoreMapping _xcoreMapping_6 = this.mapper.getToXcoreMapping(_eOperation_2);
+ XNamedElement _xcoreElement_6 = _xcoreMapping_6.getXcoreElement();
+ Assert.assertEquals(member_3, _xcoreElement_6);
+ XOperationMapping _mapping_19 = this.mapper.getMapping(member_3);
+ GenOperation _genOperation_1 = _mapping_19.getGenOperation();
+ ToXcoreMapping _xcoreMapping_7 = this.mapper.getToXcoreMapping(_genOperation_1);
+ XNamedElement _xcoreElement_7 = _xcoreMapping_7.getXcoreElement();
+ Assert.assertEquals(member_3, _xcoreElement_7);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
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 4fa9f28..67b1cab 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
@@ -4,29 +4,24 @@
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
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.util.EcoreUtil
+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 org.eclipse.xtext.common.types.util.TypeReferences
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
-import org.eclipse.emf.ecore.xcore.XStructuralFeature
-import org.eclipse.xtext.xbase.compiler.ImportManager
-import org.eclipse.emf.ecore.EDataType
-import org.eclipse.emf.ecore.xcore.XDataType
-import org.eclipse.xtext.common.types.util.TypeReferences
-import org.eclipse.emf.ecore.util.EcoreUtil
class XcoreGenerator implements IGenerator {
diff --git a/org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/scoping/LazyCreationProxyUriConverter.java b/org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/scoping/LazyCreationProxyUriConverter.java
index 8859b2e..d7123fc 100644
--- a/org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/scoping/LazyCreationProxyUriConverter.java
+++ b/org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/scoping/LazyCreationProxyUriConverter.java
@@ -25,12 +25,14 @@ public class LazyCreationProxyUriConverter {
private Map<String, EClass> types = newHashMap();
{
+ EClass ePackage = EcorePackage.Literals.EPACKAGE;
EClass eclass = EcorePackage.Literals.ECLASS;
EClass genClass = GenModelPackage.Literals.GEN_CLASS;
EClass genDatatype = GenModelPackage.Literals.GEN_DATA_TYPE;
EClass genEnum = GenModelPackage.Literals.GEN_ENUM;
EClass jvmGenericType = TypesPackage.Literals.JVM_GENERIC_TYPE;
EClass jvmEnumerationType = TypesPackage.Literals.JVM_ENUMERATION_TYPE;
+ types.put(ePackage.getName(), ePackage);
types.put(eclass.getName(), eclass);
types.put(genClass.getName(), genClass);
types.put(genDatatype.getName(), genDatatype);
@@ -94,7 +96,10 @@ public class LazyCreationProxyUriConverter {
String clazzName = segments[0];
QualifiedName name = nameConverter.toQualifiedName(segments[1]);
if (types.containsKey(clazzName)) {
- return Tuples.create(types.get(clazzName), name);
+ final EClass a = types.get(clazzName);
+ if (a == EcorePackage.Literals.EPACKAGE)
+ name = QualifiedName.create(segments[1]);
+ return Tuples.create(a, name);
}
}
return null;
diff --git a/org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/scoping/XcoreQualifiedNameProvider.java b/org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/scoping/XcoreQualifiedNameProvider.java
index e0aed96..5c0e13c 100644
--- a/org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/scoping/XcoreQualifiedNameProvider.java
+++ b/org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/scoping/XcoreQualifiedNameProvider.java
@@ -3,6 +3,7 @@ package org.eclipse.emf.ecore.xcore.scoping;
import org.eclipse.emf.codegen.ecore.genmodel.GenClassifier;
import org.eclipse.emf.codegen.ecore.genmodel.GenPackage;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
import org.eclipse.xtext.common.types.JvmType;
import org.eclipse.xtext.naming.DefaultDeclarativeQualifiedNameProvider;
import org.eclipse.xtext.naming.IQualifiedNameConverter;
@@ -38,6 +39,12 @@ public class XcoreQualifiedNameProvider extends DefaultDeclarativeQualifiedNameP
String typeName = type.getQualifiedName();
return typeName == null ? null : nameConverter.toQualifiedName(typeName);
}
+ else if (eObject instanceof EPackage)
+ {
+ EPackage pack = (EPackage) eObject;
+ String typeName = pack.getNsURI();
+ return typeName == null ? null : QualifiedName.create(typeName);
+ }
else
{
return super.getFullyQualifiedName(eObject);
diff --git a/org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/scoping/XcoreResourceDescriptionStrategy.java b/org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/scoping/XcoreResourceDescriptionStrategy.java
index e9332f7..9d45692 100644
--- a/org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/scoping/XcoreResourceDescriptionStrategy.java
+++ b/org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/scoping/XcoreResourceDescriptionStrategy.java
@@ -1,16 +1,20 @@
package org.eclipse.emf.ecore.xcore.scoping;
+import java.util.Collections;
+
import org.eclipse.emf.codegen.ecore.genmodel.GenClass;
import org.eclipse.emf.codegen.ecore.genmodel.GenDataType;
import org.eclipse.emf.codegen.ecore.genmodel.GenModelFactory;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EcoreFactory;
import org.eclipse.emf.ecore.xcore.XAnnotationDirective;
import org.eclipse.emf.ecore.xcore.XClass;
import org.eclipse.emf.ecore.xcore.XDataType;
import org.eclipse.emf.ecore.xcore.XEnum;
+import org.eclipse.emf.ecore.xcore.XPackage;
import org.eclipse.xtext.common.types.JvmEnumerationType;
import org.eclipse.xtext.common.types.JvmGenericType;
import org.eclipse.xtext.common.types.TypesFactory;
@@ -42,6 +46,12 @@ public class XcoreResourceDescriptionStrategy extends DefaultResourceDescription
@Override
public boolean createEObjectDescriptions(EObject eObject, IAcceptor<IEObjectDescription> acceptor) {
+ if (eObject instanceof XPackage) {
+ QualifiedName qn = nameProvider.getFullyQualifiedName(eObject);
+ qn = QualifiedName.create(qn.toString());
+ URI uri = eObject.eResource().getURI();
+ createEPackageDescription(uri, acceptor, qn);
+ }
if (eObject instanceof XClass) {
QualifiedName qn = nameProvider.getFullyQualifiedName(eObject);
if (qn != null) {
@@ -103,6 +113,12 @@ public class XcoreResourceDescriptionStrategy extends DefaultResourceDescription
proxyTool.installProxyURI(resourceURI, eclass, qn);
acceptor.accept(EObjectDescription.create(qn, eclass));
}
+
+ protected void createEPackageDescription(URI resourceURI, IAcceptor<IEObjectDescription> acceptor, QualifiedName qn) {
+ EPackage ePackage = ecoreFactory.createEPackage();
+ proxyTool.installProxyURI(resourceURI, ePackage, qn);
+ acceptor.accept(EObjectDescription.create(qn, ePackage, Collections.singletonMap("nsURI", "true")));
+ }
protected void createGenModelDescription(URI resourceURI, IAcceptor<IEObjectDescription> acceptor, QualifiedName qn) {
GenClass genClass = genFactory.createGenClass();
diff --git a/org.eclipse.emf.ecore.xcore/xtend-gen/org/eclipse/emf/ecore/xcore/XcoreExtensions.java b/org.eclipse.emf.ecore.xcore/xtend-gen/org/eclipse/emf/ecore/xcore/XcoreExtensions.java
index 05d8d17..cb51031 100644
--- a/org.eclipse.emf.ecore.xcore/xtend-gen/org/eclipse/emf/ecore/xcore/XcoreExtensions.java
+++ b/org.eclipse.emf.ecore.xcore/xtend-gen/org/eclipse/emf/ecore/xcore/XcoreExtensions.java
@@ -1,45 +1,45 @@
-package org.eclipse.emf.ecore.xcore;
-
-import org.eclipse.emf.codegen.ecore.genmodel.GenBase;
-import org.eclipse.emf.codegen.ecore.genmodel.GenClass;
-import org.eclipse.emf.codegen.ecore.genmodel.GenTypeParameter;
-import org.eclipse.emf.ecore.xcore.XGenericType;
-
-@SuppressWarnings("all")
-public class XcoreExtensions {
- public GenClass getGenClass(final XGenericType type) {
- GenClass _switchResult = null;
- GenBase _type = type.getType();
- final GenBase t = _type;
- boolean matched = false;
- if (!matched) {
- if (t instanceof GenClass) {
- final GenClass t_1 = (GenClass) t;
- matched=true;
- _switchResult = t_1;
- }
- }
- if (!matched) {
- _switchResult = null;
- }
- return _switchResult;
- }
-
- public GenTypeParameter getGenTypeParameter(final XGenericType type) {
- GenTypeParameter _switchResult = null;
- GenBase _type = type.getType();
- final GenBase t = _type;
- boolean matched = false;
- if (!matched) {
- if (t instanceof GenTypeParameter) {
- final GenTypeParameter t_1 = (GenTypeParameter) t;
- matched=true;
- _switchResult = t_1;
- }
- }
- if (!matched) {
- _switchResult = null;
- }
- return _switchResult;
- }
-}
+package org.eclipse.emf.ecore.xcore;
+
+import org.eclipse.emf.codegen.ecore.genmodel.GenBase;
+import org.eclipse.emf.codegen.ecore.genmodel.GenClass;
+import org.eclipse.emf.codegen.ecore.genmodel.GenTypeParameter;
+import org.eclipse.emf.ecore.xcore.XGenericType;
+
+@SuppressWarnings("all")
+public class XcoreExtensions {
+ public GenClass getGenClass(final XGenericType type) {
+ GenClass _switchResult = null;
+ GenBase _type = type.getType();
+ final GenBase t = _type;
+ boolean matched = false;
+ if (!matched) {
+ if (t instanceof GenClass) {
+ final GenClass t_1 = (GenClass) t;
+ matched=true;
+ _switchResult = t_1;
+ }
+ }
+ if (!matched) {
+ _switchResult = null;
+ }
+ return _switchResult;
+ }
+
+ public GenTypeParameter getGenTypeParameter(final XGenericType type) {
+ GenTypeParameter _switchResult = null;
+ GenBase _type = type.getType();
+ final GenBase t = _type;
+ boolean matched = false;
+ if (!matched) {
+ if (t instanceof GenTypeParameter) {
+ final GenTypeParameter t_1 = (GenTypeParameter) t;
+ matched=true;
+ _switchResult = t_1;
+ }
+ }
+ if (!matched) {
+ _switchResult = null;
+ }
+ return _switchResult;
+ }
+}
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 6165986..50d241e 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,231 +1,231 @@
-package org.eclipse.emf.ecore.xcore.generator;
-
-import com.google.inject.Inject;
-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;
-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.ecore.EDataType;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EOperation;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-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.generator.XcoreAppendable;
-import org.eclipse.emf.ecore.xcore.generator.XcoreGeneratorImpl;
-import org.eclipse.emf.ecore.xcore.mappings.XDataTypeMapping;
-import org.eclipse.emf.ecore.xcore.mappings.XFeatureMapping;
-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.JvmFormalParameter;
-import org.eclipse.xtext.common.types.JvmOperation;
-import org.eclipse.xtext.common.types.util.TypeReferences;
-import org.eclipse.xtext.generator.IFileSystemAccess;
-import org.eclipse.xtext.generator.IGenerator;
-import org.eclipse.xtext.xbase.XBlockExpression;
-import org.eclipse.xtext.xbase.compiler.XbaseCompiler;
-import org.eclipse.xtext.xbase.lib.BooleanExtensions;
-import org.eclipse.xtext.xbase.lib.IntegerExtensions;
-import org.eclipse.xtext.xbase.lib.IterableExtensions;
-import org.eclipse.xtext.xbase.lib.ObjectExtensions;
-import org.eclipse.xtext.xtend2.lib.EObjectExtensions;
-
-@SuppressWarnings("all")
-public class XcoreGenerator implements IGenerator {
- @Inject
- private XcoreMapper mappings;
-
- @Inject
- private XbaseCompiler compiler;
-
- @Inject
- private Provider<XcoreGeneratorImpl> xcoreGeneratorImplProvider;
-
- @Inject
- private TypeReferences typeReferences;
-
- public void doGenerate(final Resource resource, final IFileSystemAccess fsa) {
- EList<EObject> _contents = resource.getContents();
- EObject _head = IterableExtensions.<EObject>head(_contents);
- final XPackage pack = ((XPackage) _head);
- Iterable<EObject> _allContentsIterable = EObjectExtensions.allContentsIterable(pack);
- Iterable<XOperation> _filter = IterableExtensions.<XOperation>filter(_allContentsIterable, org.eclipse.emf.ecore.xcore.XOperation.class);
- for (final XOperation op : _filter) {
- {
- XOperationMapping _mapping = this.mappings.getMapping(op);
- EOperation _eOperation = _mapping.getEOperation();
- final EOperation eOperation = _eOperation;
- XBlockExpression _body = op.getBody();
- final XBlockExpression body = _body;
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(body, null);
- if (_operator_notEquals) {
- {
- XcoreAppendable _createAppendable = this.createAppendable();
- final XcoreAppendable appendable = _createAppendable;
- XOperationMapping _mapping_1 = this.mappings.getMapping(op);
- JvmOperation _jvmOperation = _mapping_1.getJvmOperation();
- JvmDeclaredType _declaringType = _jvmOperation.getDeclaringType();
- appendable.declareVariable(_declaringType, "this");
- this.compiler.compile(body, appendable, null);
- String _string = appendable.toString();
- String _extractBody = this.extractBody(_string);
- EcoreUtil.setAnnotation(eOperation, GenModelPackage.eNS_URI, "body", _extractBody);
- }
- }
- }
- }
- Iterable<EObject> _allContentsIterable_1 = EObjectExtensions.allContentsIterable(pack);
- Iterable<XStructuralFeature> _filter_1 = IterableExtensions.<XStructuralFeature>filter(_allContentsIterable_1, org.eclipse.emf.ecore.xcore.XStructuralFeature.class);
- for (final XStructuralFeature feature : _filter_1) {
- {
- XFeatureMapping _mapping_2 = this.mappings.getMapping(feature);
- EStructuralFeature _eStructuralFeature = _mapping_2.getEStructuralFeature();
- final EStructuralFeature eStructuralFeature = _eStructuralFeature;
- XBlockExpression _getBody = feature.getGetBody();
- final XBlockExpression getBody = _getBody;
- boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(getBody, null);
- if (_operator_notEquals_1) {
- {
- XFeatureMapping _mapping_3 = this.mappings.getMapping(feature);
- JvmOperation _getter = _mapping_3.getGetter();
- final JvmOperation getter = _getter;
- XcoreAppendable _createAppendable_1 = this.createAppendable();
- final XcoreAppendable appendable_1 = _createAppendable_1;
- JvmDeclaredType _declaringType_1 = getter.getDeclaringType();
- appendable_1.declareVariable(_declaringType_1, "this");
- this.compiler.compile(getBody, appendable_1, null);
- String _string_1 = appendable_1.toString();
- String _extractBody_1 = this.extractBody(_string_1);
- EcoreUtil.setAnnotation(eStructuralFeature, GenModelPackage.eNS_URI, "get", _extractBody_1);
- }
- }
- }
- }
- Iterable<EObject> _allContentsIterable_2 = EObjectExtensions.allContentsIterable(pack);
- Iterable<XDataType> _filter_2 = IterableExtensions.<XDataType>filter(_allContentsIterable_2, org.eclipse.emf.ecore.xcore.XDataType.class);
- for (final XDataType dataType : _filter_2) {
- {
- XDataTypeMapping _mapping_4 = this.mappings.getMapping(dataType);
- EDataType _eDataType = _mapping_4.getEDataType();
- final EDataType eDataType = _eDataType;
- XBlockExpression _createBody = dataType.getCreateBody();
- final XBlockExpression createBody = _createBody;
- XDataTypeMapping _mapping_5 = this.mappings.getMapping(dataType);
- JvmOperation _creator = _mapping_5.getCreator();
- final JvmOperation creator = _creator;
- boolean _operator_and = false;
- boolean _operator_notEquals_2 = ObjectExtensions.operator_notEquals(createBody, null);
- if (!_operator_notEquals_2) {
- _operator_and = false;
- } else {
- boolean _operator_notEquals_3 = ObjectExtensions.operator_notEquals(creator, null);
- _operator_and = BooleanExtensions.operator_and(_operator_notEquals_2, _operator_notEquals_3);
- }
- if (_operator_and) {
- {
- XcoreAppendable _createAppendable_2 = this.createAppendable();
- final XcoreAppendable appendable_2 = _createAppendable_2;
- EList<JvmFormalParameter> _parameters = creator.getParameters();
- JvmFormalParameter _get = _parameters.get(0);
- appendable_2.declareVariable(_get, "it");
- this.compiler.compile(createBody, appendable_2, null);
- String _string_2 = appendable_2.toString();
- String _extractBody_2 = this.extractBody(_string_2);
- EcoreUtil.setAnnotation(eDataType, GenModelPackage.eNS_URI, "create", _extractBody_2);
- }
- }
- XBlockExpression _convertBody = dataType.getConvertBody();
- final XBlockExpression convertBody = _convertBody;
- XDataTypeMapping _mapping_6 = this.mappings.getMapping(dataType);
- JvmOperation _converter = _mapping_6.getConverter();
- final JvmOperation converter = _converter;
- boolean _operator_and_1 = false;
- boolean _operator_notEquals_4 = ObjectExtensions.operator_notEquals(convertBody, null);
- if (!_operator_notEquals_4) {
- _operator_and_1 = false;
- } else {
- boolean _operator_notEquals_5 = ObjectExtensions.operator_notEquals(converter, null);
- _operator_and_1 = BooleanExtensions.operator_and(_operator_notEquals_4, _operator_notEquals_5);
- }
- if (_operator_and_1) {
- {
- XcoreAppendable _createAppendable_3 = this.createAppendable();
- final XcoreAppendable appendable_3 = _createAppendable_3;
- EList<JvmFormalParameter> _parameters_1 = converter.getParameters();
- JvmFormalParameter _get_1 = _parameters_1.get(0);
- appendable_3.declareVariable(_get_1, "it");
- this.compiler.compile(convertBody, appendable_3, null);
- String _string_3 = appendable_3.toString();
- String _extractBody_3 = this.extractBody(_string_3);
- EcoreUtil.setAnnotation(eDataType, GenModelPackage.eNS_URI, "convert", _extractBody_3);
- }
- }
- }
- }
- EList<EObject> _contents_1 = resource.getContents();
- Iterable<GenModel> _filter_3 = IterableExtensions.<GenModel>filter(_contents_1, org.eclipse.emf.codegen.ecore.genmodel.GenModel.class);
- GenModel _head_1 = IterableExtensions.<GenModel>head(_filter_3);
- this.generateGenModel(_head_1, fsa);
- }
-
- public XcoreAppendable createAppendable() {
- XcoreAppendable _xcoreAppendable = new XcoreAppendable();
- return _xcoreAppendable;
- }
-
- public String extractBody(final String body) {
- String _xblockexpression = null;
- {
- String _xifexpression = null;
- boolean _startsWith = body.startsWith("\n");
- if (_startsWith) {
- String _substring = body.substring(1);
- _xifexpression = _substring;
- } else {
- _xifexpression = body;
- }
- String result = _xifexpression;
- String _xifexpression_1 = null;
- boolean _startsWith_1 = result.startsWith("{\n");
- if (_startsWith_1) {
- String _xblockexpression_1 = null;
- {
- String _replace = result.replace("\n\t", "\n");
- result = _replace;
- int _length = result.length();
- int _operator_minus = IntegerExtensions.operator_minus(((Integer)_length), ((Integer)2));
- String _substring_1 = result.substring(1, _operator_minus);
- _xblockexpression_1 = (_substring_1);
- }
- _xifexpression_1 = _xblockexpression_1;
- } else {
- _xifexpression_1 = result;
- }
- _xblockexpression = (_xifexpression_1);
- }
- return _xblockexpression;
- }
-
- public Diagnostic generateGenModel(final GenModel genModel, final IFileSystemAccess fsa) {
- Diagnostic _xblockexpression = null;
- {
- genModel.setCanGenerate(true);
- 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);
- }
- return _xblockexpression;
- }
-}
+package org.eclipse.emf.ecore.xcore.generator;
+
+import com.google.inject.Inject;
+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;
+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.ecore.EDataType;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EOperation;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+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.generator.XcoreAppendable;
+import org.eclipse.emf.ecore.xcore.generator.XcoreGeneratorImpl;
+import org.eclipse.emf.ecore.xcore.mappings.XDataTypeMapping;
+import org.eclipse.emf.ecore.xcore.mappings.XFeatureMapping;
+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.JvmFormalParameter;
+import org.eclipse.xtext.common.types.JvmOperation;
+import org.eclipse.xtext.common.types.util.TypeReferences;
+import org.eclipse.xtext.generator.IFileSystemAccess;
+import org.eclipse.xtext.generator.IGenerator;
+import org.eclipse.xtext.xbase.XBlockExpression;
+import org.eclipse.xtext.xbase.compiler.XbaseCompiler;
+import org.eclipse.xtext.xbase.lib.BooleanExtensions;
+import org.eclipse.xtext.xbase.lib.IntegerExtensions;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.ObjectExtensions;
+import org.eclipse.xtext.xtend2.lib.EObjectExtensions;
+
+@SuppressWarnings("all")
+public class XcoreGenerator implements IGenerator {
+ @Inject
+ private XcoreMapper mappings;
+
+ @Inject
+ private XbaseCompiler compiler;
+
+ @Inject
+ private Provider<XcoreGeneratorImpl> xcoreGeneratorImplProvider;
+
+ @Inject
+ private TypeReferences typeReferences;
+
+ public void doGenerate(final Resource resource, final IFileSystemAccess fsa) {
+ EList<EObject> _contents = resource.getContents();
+ EObject _head = IterableExtensions.<EObject>head(_contents);
+ final XPackage pack = ((XPackage) _head);
+ Iterable<EObject> _allContentsIterable = EObjectExtensions.allContentsIterable(pack);
+ Iterable<XOperation> _filter = IterableExtensions.<XOperation>filter(_allContentsIterable, org.eclipse.emf.ecore.xcore.XOperation.class);
+ for (final XOperation op : _filter) {
+ {
+ XOperationMapping _mapping = this.mappings.getMapping(op);
+ EOperation _eOperation = _mapping.getEOperation();
+ final EOperation eOperation = _eOperation;
+ XBlockExpression _body = op.getBody();
+ final XBlockExpression body = _body;
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(body, null);
+ if (_operator_notEquals) {
+ {
+ XcoreAppendable _createAppendable = this.createAppendable();
+ final XcoreAppendable appendable = _createAppendable;
+ XOperationMapping _mapping_1 = this.mappings.getMapping(op);
+ JvmOperation _jvmOperation = _mapping_1.getJvmOperation();
+ JvmDeclaredType _declaringType = _jvmOperation.getDeclaringType();
+ appendable.declareVariable(_declaringType, "this");
+ this.compiler.compile(body, appendable, null);
+ String _string = appendable.toString();
+ String _extractBody = this.extractBody(_string);
+ EcoreUtil.setAnnotation(eOperation, GenModelPackage.eNS_URI, "body", _extractBody);
+ }
+ }
+ }
+ }
+ Iterable<EObject> _allContentsIterable_1 = EObjectExtensions.allContentsIterable(pack);
+ Iterable<XStructuralFeature> _filter_1 = IterableExtensions.<XStructuralFeature>filter(_allContentsIterable_1, org.eclipse.emf.ecore.xcore.XStructuralFeature.class);
+ for (final XStructuralFeature feature : _filter_1) {
+ {
+ XFeatureMapping _mapping_2 = this.mappings.getMapping(feature);
+ EStructuralFeature _eStructuralFeature = _mapping_2.getEStructuralFeature();
+ final EStructuralFeature eStructuralFeature = _eStructuralFeature;
+ XBlockExpression _getBody = feature.getGetBody();
+ final XBlockExpression getBody = _getBody;
+ boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(getBody, null);
+ if (_operator_notEquals_1) {
+ {
+ XFeatureMapping _mapping_3 = this.mappings.getMapping(feature);
+ JvmOperation _getter = _mapping_3.getGetter();
+ final JvmOperation getter = _getter;
+ XcoreAppendable _createAppendable_1 = this.createAppendable();
+ final XcoreAppendable appendable_1 = _createAppendable_1;
+ JvmDeclaredType _declaringType_1 = getter.getDeclaringType();
+ appendable_1.declareVariable(_declaringType_1, "this");
+ this.compiler.compile(getBody, appendable_1, null);
+ String _string_1 = appendable_1.toString();
+ String _extractBody_1 = this.extractBody(_string_1);
+ EcoreUtil.setAnnotation(eStructuralFeature, GenModelPackage.eNS_URI, "get", _extractBody_1);
+ }
+ }
+ }
+ }
+ Iterable<EObject> _allContentsIterable_2 = EObjectExtensions.allContentsIterable(pack);
+ Iterable<XDataType> _filter_2 = IterableExtensions.<XDataType>filter(_allContentsIterable_2, org.eclipse.emf.ecore.xcore.XDataType.class);
+ for (final XDataType dataType : _filter_2) {
+ {
+ XDataTypeMapping _mapping_4 = this.mappings.getMapping(dataType);
+ EDataType _eDataType = _mapping_4.getEDataType();
+ final EDataType eDataType = _eDataType;
+ XBlockExpression _createBody = dataType.getCreateBody();
+ final XBlockExpression createBody = _createBody;
+ XDataTypeMapping _mapping_5 = this.mappings.getMapping(dataType);
+ JvmOperation _creator = _mapping_5.getCreator();
+ final JvmOperation creator = _creator;
+ boolean _operator_and = false;
+ boolean _operator_notEquals_2 = ObjectExtensions.operator_notEquals(createBody, null);
+ if (!_operator_notEquals_2) {
+ _operator_and = false;
+ } else {
+ boolean _operator_notEquals_3 = ObjectExtensions.operator_notEquals(creator, null);
+ _operator_and = BooleanExtensions.operator_and(_operator_notEquals_2, _operator_notEquals_3);
+ }
+ if (_operator_and) {
+ {
+ XcoreAppendable _createAppendable_2 = this.createAppendable();
+ final XcoreAppendable appendable_2 = _createAppendable_2;
+ EList<JvmFormalParameter> _parameters = creator.getParameters();
+ JvmFormalParameter _get = _parameters.get(0);
+ appendable_2.declareVariable(_get, "it");
+ this.compiler.compile(createBody, appendable_2, null);
+ String _string_2 = appendable_2.toString();
+ String _extractBody_2 = this.extractBody(_string_2);
+ EcoreUtil.setAnnotation(eDataType, GenModelPackage.eNS_URI, "create", _extractBody_2);
+ }
+ }
+ XBlockExpression _convertBody = dataType.getConvertBody();
+ final XBlockExpression convertBody = _convertBody;
+ XDataTypeMapping _mapping_6 = this.mappings.getMapping(dataType);
+ JvmOperation _converter = _mapping_6.getConverter();
+ final JvmOperation converter = _converter;
+ boolean _operator_and_1 = false;
+ boolean _operator_notEquals_4 = ObjectExtensions.operator_notEquals(convertBody, null);
+ if (!_operator_notEquals_4) {
+ _operator_and_1 = false;
+ } else {
+ boolean _operator_notEquals_5 = ObjectExtensions.operator_notEquals(converter, null);
+ _operator_and_1 = BooleanExtensions.operator_and(_operator_notEquals_4, _operator_notEquals_5);
+ }
+ if (_operator_and_1) {
+ {
+ XcoreAppendable _createAppendable_3 = this.createAppendable();
+ final XcoreAppendable appendable_3 = _createAppendable_3;
+ EList<JvmFormalParameter> _parameters_1 = converter.getParameters();
+ JvmFormalParameter _get_1 = _parameters_1.get(0);
+ appendable_3.declareVariable(_get_1, "it");
+ this.compiler.compile(convertBody, appendable_3, null);
+ String _string_3 = appendable_3.toString();
+ String _extractBody_3 = this.extractBody(_string_3);
+ EcoreUtil.setAnnotation(eDataType, GenModelPackage.eNS_URI, "convert", _extractBody_3);
+ }
+ }
+ }
+ }
+ EList<EObject> _contents_1 = resource.getContents();
+ Iterable<GenModel> _filter_3 = IterableExtensions.<GenModel>filter(_contents_1, org.eclipse.emf.codegen.ecore.genmodel.GenModel.class);
+ GenModel _head_1 = IterableExtensions.<GenModel>head(_filter_3);
+ this.generateGenModel(_head_1, fsa);
+ }
+
+ public XcoreAppendable createAppendable() {
+ XcoreAppendable _xcoreAppendable = new XcoreAppendable();
+ return _xcoreAppendable;
+ }
+
+ public String extractBody(final String body) {
+ String _xblockexpression = null;
+ {
+ String _xifexpression = null;
+ boolean _startsWith = body.startsWith("\n");
+ if (_startsWith) {
+ String _substring = body.substring(1);
+ _xifexpression = _substring;
+ } else {
+ _xifexpression = body;
+ }
+ String result = _xifexpression;
+ String _xifexpression_1 = null;
+ boolean _startsWith_1 = result.startsWith("{\n");
+ if (_startsWith_1) {
+ String _xblockexpression_1 = null;
+ {
+ String _replace = result.replace("\n\t", "\n");
+ result = _replace;
+ int _length = result.length();
+ int _operator_minus = IntegerExtensions.operator_minus(((Integer)_length), ((Integer)2));
+ String _substring_1 = result.substring(1, _operator_minus);
+ _xblockexpression_1 = (_substring_1);
+ }
+ _xifexpression_1 = _xblockexpression_1;
+ } else {
+ _xifexpression_1 = result;
+ }
+ _xblockexpression = (_xifexpression_1);
+ }
+ return _xblockexpression;
+ }
+
+ public Diagnostic generateGenModel(final GenModel genModel, final IFileSystemAccess fsa) {
+ Diagnostic _xblockexpression = null;
+ {
+ genModel.setCanGenerate(true);
+ 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);
+ }
+ return _xblockexpression;
+ }
+}
diff --git a/org.eclipse.emf.ecore.xcore/xtend-gen/org/eclipse/emf/ecore/xcore/util/XcoreGenmodelBuilder.java b/org.eclipse.emf.ecore.xcore/xtend-gen/org/eclipse/emf/ecore/xcore/util/XcoreGenmodelBuilder.java
index c741f28..2b01ba9 100644
--- a/org.eclipse.emf.ecore.xcore/xtend-gen/org/eclipse/emf/ecore/xcore/util/XcoreGenmodelBuilder.java
+++ b/org.eclipse.emf.ecore.xcore/xtend-gen/org/eclipse/emf/ecore/xcore/util/XcoreGenmodelBuilder.java
@@ -1,297 +1,297 @@
-package org.eclipse.emf.ecore.xcore.util;
-
-import com.google.inject.Inject;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-import org.eclipse.emf.codegen.ecore.genmodel.GenBase;
-import org.eclipse.emf.codegen.ecore.genmodel.GenClass;
-import org.eclipse.emf.codegen.ecore.genmodel.GenDataType;
-import org.eclipse.emf.codegen.ecore.genmodel.GenEnumLiteral;
-import org.eclipse.emf.codegen.ecore.genmodel.GenFeature;
-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.codegen.ecore.genmodel.GenPackage;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EDataType;
-import org.eclipse.emf.ecore.EEnumLiteral;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EOperation;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.xcore.XClass;
-import org.eclipse.emf.ecore.xcore.XDataType;
-import org.eclipse.emf.ecore.xcore.XEnumLiteral;
-import org.eclipse.emf.ecore.xcore.XNamedElement;
-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.ToXcoreMapping;
-import org.eclipse.emf.ecore.xcore.mappings.XClassMapping;
-import org.eclipse.emf.ecore.xcore.mappings.XDataTypeMapping;
-import org.eclipse.emf.ecore.xcore.mappings.XEnumLiteralMapping;
-import org.eclipse.emf.ecore.xcore.mappings.XFeatureMapping;
-import org.eclipse.emf.ecore.xcore.mappings.XOperationMapping;
-import org.eclipse.emf.ecore.xcore.mappings.XPackageMapping;
-import org.eclipse.emf.ecore.xcore.mappings.XcoreMapper;
-import org.eclipse.emf.ecore.xcore.util.XcoreGenModelInitializer;
-import org.eclipse.xtext.xbase.lib.ComparableExtensions;
-import org.eclipse.xtext.xbase.lib.IntegerExtensions;
-import org.eclipse.xtext.xbase.lib.ObjectExtensions;
-import org.eclipse.xtext.xtend2.lib.EObjectExtensions;
-
-@SuppressWarnings("all")
-public class XcoreGenmodelBuilder {
- @Inject
- private XcoreMapper mapper;
-
- @Inject
- private XcoreGenModelInitializer genModelInitializer;
-
- public GenModel getGenModel(final XPackage pack) {
- XPackageMapping _mapping = this.mapper.getMapping(pack);
- EPackage _ePackage = _mapping.getEPackage();
- final EPackage ePackage = _ePackage;
- GenModel _createGenModel = GenModelFactory.eINSTANCE.createGenModel();
- final GenModel genModel = _createGenModel;
- Set<EPackage> _singleton = Collections.<EPackage>singleton(ePackage);
- genModel.initialize(_singleton);
- Resource _eResource = pack.eResource();
- EList<EObject> _contents = _eResource.getContents();
- _contents.add(1, genModel);
- this.genModelInitializer.initialize(genModel);
- this.buildMap(genModel);
- return genModel;
- }
-
- public void buildMap(final GenModel genModel) {
- Iterable<EObject> _allContentsIterable = EObjectExtensions.allContentsIterable(genModel);
- for (final EObject genElement : _allContentsIterable) {
- final EObject genElement_1 = genElement;
- boolean matched = false;
- if (!matched) {
- if (genElement_1 instanceof GenPackage) {
- final GenPackage genElement_2 = (GenPackage) genElement_1;
- matched=true;
- {
- EPackage _ecorePackage = genElement_2.getEcorePackage();
- ToXcoreMapping _xcoreMapping = this.mapper.getToXcoreMapping(_ecorePackage);
- XNamedElement _xcoreElement = _xcoreMapping.getXcoreElement();
- final XPackage xPack = ((XPackage) _xcoreElement);
- XPackageMapping _mapping = this.mapper.getMapping(xPack);
- _mapping.setGenPackage(genElement_2);
- ToXcoreMapping _xcoreMapping_1 = this.mapper.getToXcoreMapping(genElement_2);
- _xcoreMapping_1.setXcoreElement(xPack);
- }
- }
- }
- if (!matched) {
- if (genElement_1 instanceof GenClass) {
- final GenClass genElement_3 = (GenClass) genElement_1;
- matched=true;
- {
- EClass _ecoreClass = genElement_3.getEcoreClass();
- ToXcoreMapping _xcoreMapping_2 = this.mapper.getToXcoreMapping(_ecoreClass);
- XNamedElement _xcoreElement_1 = _xcoreMapping_2.getXcoreElement();
- final XClass xClass = ((XClass) _xcoreElement_1);
- XClassMapping _mapping_1 = this.mapper.getMapping(xClass);
- _mapping_1.setGenClass(genElement_3);
- ToXcoreMapping _xcoreMapping_3 = this.mapper.getToXcoreMapping(genElement_3);
- _xcoreMapping_3.setXcoreElement(xClass);
- }
- }
- }
- if (!matched) {
- if (genElement_1 instanceof GenDataType) {
- final GenDataType genElement_4 = (GenDataType) genElement_1;
- matched=true;
- {
- EDataType _ecoreDataType = genElement_4.getEcoreDataType();
- ToXcoreMapping _xcoreMapping_4 = this.mapper.getToXcoreMapping(_ecoreDataType);
- XNamedElement _xcoreElement_2 = _xcoreMapping_4.getXcoreElement();
- final XDataType xDataType = ((XDataType) _xcoreElement_2);
- XDataTypeMapping _mapping_2 = this.mapper.getMapping(xDataType);
- _mapping_2.setGenDataType(genElement_4);
- ToXcoreMapping _xcoreMapping_5 = this.mapper.getToXcoreMapping(genElement_4);
- _xcoreMapping_5.setXcoreElement(xDataType);
- }
- }
- }
- if (!matched) {
- if (genElement_1 instanceof GenFeature) {
- final GenFeature genElement_5 = (GenFeature) genElement_1;
- matched=true;
- {
- EStructuralFeature _ecoreFeature = genElement_5.getEcoreFeature();
- ToXcoreMapping _xcoreMapping_6 = this.mapper.getToXcoreMapping(_ecoreFeature);
- XNamedElement _xcoreElement_3 = _xcoreMapping_6.getXcoreElement();
- final XStructuralFeature xFeature = ((XStructuralFeature) _xcoreElement_3);
- XFeatureMapping _mapping_3 = this.mapper.getMapping(xFeature);
- _mapping_3.setGenFeature(genElement_5);
- ToXcoreMapping _xcoreMapping_7 = this.mapper.getToXcoreMapping(genElement_5);
- _xcoreMapping_7.setXcoreElement(xFeature);
- }
- }
- }
- if (!matched) {
- if (genElement_1 instanceof GenOperation) {
- final GenOperation genElement_6 = (GenOperation) genElement_1;
- matched=true;
- {
- EOperation _ecoreOperation = genElement_6.getEcoreOperation();
- ToXcoreMapping _xcoreMapping_8 = this.mapper.getToXcoreMapping(_ecoreOperation);
- XNamedElement _xcoreElement_4 = _xcoreMapping_8.getXcoreElement();
- final XOperation xOperation = ((XOperation) _xcoreElement_4);
- XOperationMapping _mapping_4 = this.mapper.getMapping(xOperation);
- _mapping_4.setGenOperation(genElement_6);
- ToXcoreMapping _xcoreMapping_9 = this.mapper.getToXcoreMapping(genElement_6);
- _xcoreMapping_9.setXcoreElement(xOperation);
- }
- }
- }
- if (!matched) {
- if (genElement_1 instanceof GenEnumLiteral) {
- final GenEnumLiteral genElement_7 = (GenEnumLiteral) genElement_1;
- matched=true;
- {
- EEnumLiteral _ecoreEnumLiteral = genElement_7.getEcoreEnumLiteral();
- ToXcoreMapping _xcoreMapping_10 = this.mapper.getToXcoreMapping(_ecoreEnumLiteral);
- XNamedElement _xcoreElement_5 = _xcoreMapping_10.getXcoreElement();
- final XEnumLiteral xEnumLiteral = ((XEnumLiteral) _xcoreElement_5);
- XEnumLiteralMapping _mapping_5 = this.mapper.getMapping(xEnumLiteral);
- _mapping_5.setGenEnumLiteral(genElement_7);
- ToXcoreMapping _xcoreMapping_11 = this.mapper.getToXcoreMapping(genElement_7);
- _xcoreMapping_11.setXcoreElement(xEnumLiteral);
- }
- }
- }
- }
- }
-
- public void initializeUsedGenPackages(final GenModel genModel) {
- HashSet<EPackage> _hashSet = new HashSet<EPackage>();
- final HashSet<EPackage> referencedEPackages = _hashSet;
- EList<GenPackage> _genPackages = genModel.getGenPackages();
- for (final GenPackage genPackage : _genPackages) {
- EPackage _ecorePackage = genPackage.getEcorePackage();
- Iterable<EObject> _allContentsIterable = EObjectExtensions.allContentsIterable(_ecorePackage);
- for (final EObject eObject : _allContentsIterable) {
- EList<EObject> _eCrossReferences = eObject.eCrossReferences();
- for (final EObject eCrossReference : _eCrossReferences) {
- final EObject eCrossReference_1 = eCrossReference;
- boolean matched = false;
- if (!matched) {
- if (eCrossReference_1 instanceof EClassifier) {
- final EClassifier eCrossReference_2 = (EClassifier) eCrossReference_1;
- matched=true;
- EPackage _ePackage = eCrossReference_2.getEPackage();
- referencedEPackages.add(_ePackage);
- }
- }
- if (!matched) {
- if (eCrossReference_1 instanceof EStructuralFeature) {
- final EStructuralFeature eCrossReference_3 = (EStructuralFeature) eCrossReference_1;
- matched=true;
- EClass _eContainingClass = eCrossReference_3.getEContainingClass();
- EPackage _ePackage_1 = _eContainingClass.getEPackage();
- referencedEPackages.add(_ePackage_1);
- }
- }
- }
- }
- }
- for (final EPackage referencedEPackage : referencedEPackages) {
- GenPackage _findGenPackage = genModel.findGenPackage(referencedEPackage);
- boolean _operator_equals = ObjectExtensions.operator_equals(_findGenPackage, null);
- if (_operator_equals) {
- {
- ToXcoreMapping _xcoreMapping = this.mapper.getToXcoreMapping(referencedEPackage);
- XNamedElement _xcoreElement = _xcoreMapping.getXcoreElement();
- GenBase _gen = this.mapper.getGen(_xcoreElement);
- GenPackage usedGenPackage = ((GenPackage) _gen);
- boolean _operator_equals_1 = ObjectExtensions.operator_equals(usedGenPackage, null);
- if (_operator_equals_1) {
- GenPackage _findLocalGenPackage = this.findLocalGenPackage(referencedEPackage);
- usedGenPackage = _findLocalGenPackage;
- }
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(usedGenPackage, null);
- if (_operator_notEquals) {
- EList<GenPackage> _usedGenPackages = genModel.getUsedGenPackages();
- _usedGenPackages.add(usedGenPackage);
- } else {
- {
- Resource _eResource = genModel.eResource();
- ResourceSet _resourceSet = _eResource.getResourceSet();
- EList<Resource> _resources = _resourceSet.getResources();
- final EList<Resource> resources = _resources;
- int i = 0;
- boolean found = false;
- int _size = resources.size();
- boolean _operator_lessThan = ComparableExtensions.<Integer>operator_lessThan(((Integer)i), ((Integer)_size));
- Boolean _xwhileexpression = _operator_lessThan;
- while (_xwhileexpression) {
- {
- Resource _get = resources.get(i);
- final Resource resource = _get;
- URI _uRI = resource.getURI();
- String _fileExtension = _uRI.fileExtension();
- boolean _equals = "genmodel".equals(_fileExtension);
- if (_equals) {
- {
- EList<EObject> _contents = resource.getContents();
- EObject _get_1 = _contents.get(0);
- GenPackage _findGenPackage_1 = ((GenModel) _get_1).findGenPackage(referencedEPackage);
- usedGenPackage = _findGenPackage_1;
- boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(usedGenPackage, null);
- if (_operator_notEquals_1) {
- {
- EList<GenPackage> _usedGenPackages_1 = genModel.getUsedGenPackages();
- _usedGenPackages_1.add(usedGenPackage);
- found = true;
- }
- }
- }
- }
- int _operator_plus = IntegerExtensions.operator_plus(((Integer)i), ((Integer)1));
- i = _operator_plus;
- }
- int _size_1 = resources.size();
- boolean _operator_lessThan_1 = ComparableExtensions.<Integer>operator_lessThan(((Integer)i), ((Integer)_size_1));
- _xwhileexpression = _operator_lessThan_1;
- }
- }
- }
- }
- }
- }
- }
-
- public GenPackage findLocalGenPackage(final EPackage ePackage) {
- GenPackage _xifexpression = null;
- Resource _eResource = ePackage.eResource();
- boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_eResource, null);
- if (_operator_notEquals) {
- Resource _eResource_1 = ePackage.eResource();
- EList<EObject> _contents = _eResource_1.getContents();
- for (final EObject content : _contents) {
- if ((content instanceof GenModel)) {
- {
- GenPackage _findGenPackage = ((GenModel) content).findGenPackage(ePackage);
- final GenPackage genPackage = _findGenPackage;
- boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(genPackage, null);
- if (_operator_notEquals_1) {
- return genPackage;
- }
- }
- }
- }
- }
- return _xifexpression;
- }
-}
+package org.eclipse.emf.ecore.xcore.util;
+
+import com.google.inject.Inject;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+import org.eclipse.emf.codegen.ecore.genmodel.GenBase;
+import org.eclipse.emf.codegen.ecore.genmodel.GenClass;
+import org.eclipse.emf.codegen.ecore.genmodel.GenDataType;
+import org.eclipse.emf.codegen.ecore.genmodel.GenEnumLiteral;
+import org.eclipse.emf.codegen.ecore.genmodel.GenFeature;
+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.codegen.ecore.genmodel.GenPackage;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.EEnumLiteral;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EOperation;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.xcore.XClass;
+import org.eclipse.emf.ecore.xcore.XDataType;
+import org.eclipse.emf.ecore.xcore.XEnumLiteral;
+import org.eclipse.emf.ecore.xcore.XNamedElement;
+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.ToXcoreMapping;
+import org.eclipse.emf.ecore.xcore.mappings.XClassMapping;
+import org.eclipse.emf.ecore.xcore.mappings.XDataTypeMapping;
+import org.eclipse.emf.ecore.xcore.mappings.XEnumLiteralMapping;
+import org.eclipse.emf.ecore.xcore.mappings.XFeatureMapping;
+import org.eclipse.emf.ecore.xcore.mappings.XOperationMapping;
+import org.eclipse.emf.ecore.xcore.mappings.XPackageMapping;
+import org.eclipse.emf.ecore.xcore.mappings.XcoreMapper;
+import org.eclipse.emf.ecore.xcore.util.XcoreGenModelInitializer;
+import org.eclipse.xtext.xbase.lib.ComparableExtensions;
+import org.eclipse.xtext.xbase.lib.IntegerExtensions;
+import org.eclipse.xtext.xbase.lib.ObjectExtensions;
+import org.eclipse.xtext.xtend2.lib.EObjectExtensions;
+
+@SuppressWarnings("all")
+public class XcoreGenmodelBuilder {
+ @Inject
+ private XcoreMapper mapper;
+
+ @Inject
+ private XcoreGenModelInitializer genModelInitializer;
+
+ public GenModel getGenModel(final XPackage pack) {
+ XPackageMapping _mapping = this.mapper.getMapping(pack);
+ EPackage _ePackage = _mapping.getEPackage();
+ final EPackage ePackage = _ePackage;
+ GenModel _createGenModel = GenModelFactory.eINSTANCE.createGenModel();
+ final GenModel genModel = _createGenModel;
+ Set<EPackage> _singleton = Collections.<EPackage>singleton(ePackage);
+ genModel.initialize(_singleton);
+ Resource _eResource = pack.eResource();
+ EList<EObject> _contents = _eResource.getContents();
+ _contents.add(1, genModel);
+ this.genModelInitializer.initialize(genModel);
+ this.buildMap(genModel);
+ return genModel;
+ }
+
+ public void buildMap(final GenModel genModel) {
+ Iterable<EObject> _allContentsIterable = EObjectExtensions.allContentsIterable(genModel);
+ for (final EObject genElement : _allContentsIterable) {
+ final EObject genElement_1 = genElement;
+ boolean matched = false;
+ if (!matched) {
+ if (genElement_1 instanceof GenPackage) {
+ final GenPackage genElement_2 = (GenPackage) genElement_1;
+ matched=true;
+ {
+ EPackage _ecorePackage = genElement_2.getEcorePackage();
+ ToXcoreMapping _xcoreMapping = this.mapper.getToXcoreMapping(_ecorePackage);
+ XNamedElement _xcoreElement = _xcoreMapping.getXcoreElement();
+ final XPackage xPack = ((XPackage) _xcoreElement);
+ XPackageMapping _mapping = this.mapper.getMapping(xPack);
+ _mapping.setGenPackage(genElement_2);
+ ToXcoreMapping _xcoreMapping_1 = this.mapper.getToXcoreMapping(genElement_2);
+ _xcoreMapping_1.setXcoreElement(xPack);
+ }
+ }
+ }
+ if (!matched) {
+ if (genElement_1 instanceof GenClass) {
+ final GenClass genElement_3 = (GenClass) genElement_1;
+ matched=true;
+ {
+ EClass _ecoreClass = genElement_3.getEcoreClass();
+ ToXcoreMapping _xcoreMapping_2 = this.mapper.getToXcoreMapping(_ecoreClass);
+ XNamedElement _xcoreElement_1 = _xcoreMapping_2.getXcoreElement();
+ final XClass xClass = ((XClass) _xcoreElement_1);
+ XClassMapping _mapping_1 = this.mapper.getMapping(xClass);
+ _mapping_1.setGenClass(genElement_3);
+ ToXcoreMapping _xcoreMapping_3 = this.mapper.getToXcoreMapping(genElement_3);
+ _xcoreMapping_3.setXcoreElement(xClass);
+ }
+ }
+ }
+ if (!matched) {
+ if (genElement_1 instanceof GenDataType) {
+ final GenDataType genElement_4 = (GenDataType) genElement_1;
+ matched=true;
+ {
+ EDataType _ecoreDataType = genElement_4.getEcoreDataType();
+ ToXcoreMapping _xcoreMapping_4 = this.mapper.getToXcoreMapping(_ecoreDataType);
+ XNamedElement _xcoreElement_2 = _xcoreMapping_4.getXcoreElement();
+ final XDataType xDataType = ((XDataType) _xcoreElement_2);
+ XDataTypeMapping _mapping_2 = this.mapper.getMapping(xDataType);
+ _mapping_2.setGenDataType(genElement_4);
+ ToXcoreMapping _xcoreMapping_5 = this.mapper.getToXcoreMapping(genElement_4);
+ _xcoreMapping_5.setXcoreElement(xDataType);
+ }
+ }
+ }
+ if (!matched) {
+ if (genElement_1 instanceof GenFeature) {
+ final GenFeature genElement_5 = (GenFeature) genElement_1;
+ matched=true;
+ {
+ EStructuralFeature _ecoreFeature = genElement_5.getEcoreFeature();
+ ToXcoreMapping _xcoreMapping_6 = this.mapper.getToXcoreMapping(_ecoreFeature);
+ XNamedElement _xcoreElement_3 = _xcoreMapping_6.getXcoreElement();
+ final XStructuralFeature xFeature = ((XStructuralFeature) _xcoreElement_3);
+ XFeatureMapping _mapping_3 = this.mapper.getMapping(xFeature);
+ _mapping_3.setGenFeature(genElement_5);
+ ToXcoreMapping _xcoreMapping_7 = this.mapper.getToXcoreMapping(genElement_5);
+ _xcoreMapping_7.setXcoreElement(xFeature);
+ }
+ }
+ }
+ if (!matched) {
+ if (genElement_1 instanceof GenOperation) {
+ final GenOperation genElement_6 = (GenOperation) genElement_1;
+ matched=true;
+ {
+ EOperation _ecoreOperation = genElement_6.getEcoreOperation();
+ ToXcoreMapping _xcoreMapping_8 = this.mapper.getToXcoreMapping(_ecoreOperation);
+ XNamedElement _xcoreElement_4 = _xcoreMapping_8.getXcoreElement();
+ final XOperation xOperation = ((XOperation) _xcoreElement_4);
+ XOperationMapping _mapping_4 = this.mapper.getMapping(xOperation);
+ _mapping_4.setGenOperation(genElement_6);
+ ToXcoreMapping _xcoreMapping_9 = this.mapper.getToXcoreMapping(genElement_6);
+ _xcoreMapping_9.setXcoreElement(xOperation);
+ }
+ }
+ }
+ if (!matched) {
+ if (genElement_1 instanceof GenEnumLiteral) {
+ final GenEnumLiteral genElement_7 = (GenEnumLiteral) genElement_1;
+ matched=true;
+ {
+ EEnumLiteral _ecoreEnumLiteral = genElement_7.getEcoreEnumLiteral();
+ ToXcoreMapping _xcoreMapping_10 = this.mapper.getToXcoreMapping(_ecoreEnumLiteral);
+ XNamedElement _xcoreElement_5 = _xcoreMapping_10.getXcoreElement();
+ final XEnumLiteral xEnumLiteral = ((XEnumLiteral) _xcoreElement_5);
+ XEnumLiteralMapping _mapping_5 = this.mapper.getMapping(xEnumLiteral);
+ _mapping_5.setGenEnumLiteral(genElement_7);
+ ToXcoreMapping _xcoreMapping_11 = this.mapper.getToXcoreMapping(genElement_7);
+ _xcoreMapping_11.setXcoreElement(xEnumLiteral);
+ }
+ }
+ }
+ }
+ }
+
+ public void initializeUsedGenPackages(final GenModel genModel) {
+ HashSet<EPackage> _hashSet = new HashSet<EPackage>();
+ final HashSet<EPackage> referencedEPackages = _hashSet;
+ EList<GenPackage> _genPackages = genModel.getGenPackages();
+ for (final GenPackage genPackage : _genPackages) {
+ EPackage _ecorePackage = genPackage.getEcorePackage();
+ Iterable<EObject> _allContentsIterable = EObjectExtensions.allContentsIterable(_ecorePackage);
+ for (final EObject eObject : _allContentsIterable) {
+ EList<EObject> _eCrossReferences = eObject.eCrossReferences();
+ for (final EObject eCrossReference : _eCrossReferences) {
+ final EObject eCrossReference_1 = eCrossReference;
+ boolean matched = false;
+ if (!matched) {
+ if (eCrossReference_1 instanceof EClassifier) {
+ final EClassifier eCrossReference_2 = (EClassifier) eCrossReference_1;
+ matched=true;
+ EPackage _ePackage = eCrossReference_2.getEPackage();
+ referencedEPackages.add(_ePackage);
+ }
+ }
+ if (!matched) {
+ if (eCrossReference_1 instanceof EStructuralFeature) {
+ final EStructuralFeature eCrossReference_3 = (EStructuralFeature) eCrossReference_1;
+ matched=true;
+ EClass _eContainingClass = eCrossReference_3.getEContainingClass();
+ EPackage _ePackage_1 = _eContainingClass.getEPackage();
+ referencedEPackages.add(_ePackage_1);
+ }
+ }
+ }
+ }
+ }
+ for (final EPackage referencedEPackage : referencedEPackages) {
+ GenPackage _findGenPackage = genModel.findGenPackage(referencedEPackage);
+ boolean _operator_equals = ObjectExtensions.operator_equals(_findGenPackage, null);
+ if (_operator_equals) {
+ {
+ ToXcoreMapping _xcoreMapping = this.mapper.getToXcoreMapping(referencedEPackage);
+ XNamedElement _xcoreElement = _xcoreMapping.getXcoreElement();
+ GenBase _gen = this.mapper.getGen(_xcoreElement);
+ GenPackage usedGenPackage = ((GenPackage) _gen);
+ boolean _operator_equals_1 = ObjectExtensions.operator_equals(usedGenPackage, null);
+ if (_operator_equals_1) {
+ GenPackage _findLocalGenPackage = this.findLocalGenPackage(referencedEPackage);
+ usedGenPackage = _findLocalGenPackage;
+ }
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(usedGenPackage, null);
+ if (_operator_notEquals) {
+ EList<GenPackage> _usedGenPackages = genModel.getUsedGenPackages();
+ _usedGenPackages.add(usedGenPackage);
+ } else {
+ {
+ Resource _eResource = genModel.eResource();
+ ResourceSet _resourceSet = _eResource.getResourceSet();
+ EList<Resource> _resources = _resourceSet.getResources();
+ final EList<Resource> resources = _resources;
+ int i = 0;
+ boolean found = false;
+ int _size = resources.size();
+ boolean _operator_lessThan = ComparableExtensions.<Integer>operator_lessThan(((Integer)i), ((Integer)_size));
+ Boolean _xwhileexpression = _operator_lessThan;
+ while (_xwhileexpression) {
+ {
+ Resource _get = resources.get(i);
+ final Resource resource = _get;
+ URI _uRI = resource.getURI();
+ String _fileExtension = _uRI.fileExtension();
+ boolean _equals = "genmodel".equals(_fileExtension);
+ if (_equals) {
+ {
+ EList<EObject> _contents = resource.getContents();
+ EObject _get_1 = _contents.get(0);
+ GenPackage _findGenPackage_1 = ((GenModel) _get_1).findGenPackage(referencedEPackage);
+ usedGenPackage = _findGenPackage_1;
+ boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(usedGenPackage, null);
+ if (_operator_notEquals_1) {
+ {
+ EList<GenPackage> _usedGenPackages_1 = genModel.getUsedGenPackages();
+ _usedGenPackages_1.add(usedGenPackage);
+ found = true;
+ }
+ }
+ }
+ }
+ int _operator_plus = IntegerExtensions.operator_plus(((Integer)i), ((Integer)1));
+ i = _operator_plus;
+ }
+ int _size_1 = resources.size();
+ boolean _operator_lessThan_1 = ComparableExtensions.<Integer>operator_lessThan(((Integer)i), ((Integer)_size_1));
+ _xwhileexpression = _operator_lessThan_1;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public GenPackage findLocalGenPackage(final EPackage ePackage) {
+ GenPackage _xifexpression = null;
+ Resource _eResource = ePackage.eResource();
+ boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_eResource, null);
+ if (_operator_notEquals) {
+ Resource _eResource_1 = ePackage.eResource();
+ EList<EObject> _contents = _eResource_1.getContents();
+ for (final EObject content : _contents) {
+ if ((content instanceof GenModel)) {
+ {
+ GenPackage _findGenPackage = ((GenModel) content).findGenPackage(ePackage);
+ final GenPackage genPackage = _findGenPackage;
+ boolean _operator_notEquals_1 = ObjectExtensions.operator_notEquals(genPackage, null);
+ if (_operator_notEquals_1) {
+ return genPackage;
+ }
+ }
+ }
+ }
+ }
+ return _xifexpression;
+ }
+}