summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjkohnlein2008-10-21 03:32:51 (EDT)
committer jkohnlein2008-10-21 03:32:51 (EDT)
commita801029e5f6fb9725a4600d9ea5b8c0bd2bef45b (patch)
tree252991d89a642064a17895d4e134f8a374316a3d
parentb10ab13397f417bb39834bf0cd839c81d3469149 (diff)
downloadorg.eclipse.xpand-a801029e5f6fb9725a4600d9ea5b8c0bd2bef45b.zip
org.eclipse.xpand-a801029e5f6fb9725a4600d9ea5b8c0bd2bef45b.tar.gz
org.eclipse.xpand-a801029e5f6fb9725a4600d9ea5b8c0bd2bef45b.tar.bz2
Added EValidator Check adapter and tests
-rw-r--r--plugins/org.eclipse.xtend.tests/META-INF/MANIFEST.MF12
-rw-r--r--plugins/org.eclipse.xtend.tests/plugin.xml32
-rw-r--r--plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/AllAllTests.java2
-rw-r--r--plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/AllTests.java27
-rw-r--r--plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/OawValidatorPluginTests.java55
-rw-r--r--plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/OawValidatorStandaloneTests.java81
-rw-r--r--plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/cache/AllTests.java26
-rw-r--r--plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/cache/Cached.ext4
-rw-r--r--plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/cache/CachedExtension.chk7
-rw-r--r--plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/cache/CachedExtensionTest.java46
-rw-r--r--plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/HelloPDE.java5
-rw-r--r--plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/MyExtension.ext1
-rw-r--r--plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/check.chk16
-rw-r--r--plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test.ecore23
-rw-r--r--plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test.genmodel22
-rw-r--r--plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/MyEnum.java212
-rw-r--r--plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/MyMetaClass.java131
-rw-r--r--plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/TestFactory.java46
-rw-r--r--plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/TestPackage.java270
-rw-r--r--plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/impl/MyMetaClassImpl.java347
-rw-r--r--plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/impl/TestFactoryImpl.java150
-rw-r--r--plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/impl/TestPackageImpl.java261
-rw-r--r--plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/SubpackageFactory.java46
-rw-r--r--plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/SubpackageMetaClass.java54
-rw-r--r--plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/SubpackagePackage.java153
-rw-r--r--plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/impl/SubpackageFactoryImpl.java99
-rw-r--r--plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/impl/SubpackageMetaClassImpl.java167
-rw-r--r--plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/impl/SubpackagePackageImpl.java194
-rw-r--r--plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/util/SubpackageAdapterFactory.java124
-rw-r--r--plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/util/SubpackageSwitch.java130
-rw-r--r--plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/util/TestAdapterFactory.java124
-rw-r--r--plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/util/TestSwitch.java130
-rw-r--r--plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/validation/MyMetaClassValidator.java24
-rw-r--r--plugins/org.eclipse.xtend.typesystem.emf/META-INF/MANIFEST.MF10
-rw-r--r--plugins/org.eclipse.xtend.typesystem.emf/plugin.xml6
-rw-r--r--plugins/org.eclipse.xtend.typesystem.emf/schema/checks.exsd158
-rw-r--r--plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/check/CheckEValidatorAdapter.java190
-rw-r--r--plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/check/CheckFileWithContext.java37
-rw-r--r--plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/check/CheckRegistry.java114
-rw-r--r--plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/internal/emf/XtendTypesytemEmfPlugin.java49
-rw-r--r--plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/ResourceManagerDefaultImpl.java2
41 files changed, 3582 insertions, 5 deletions
diff --git a/plugins/org.eclipse.xtend.tests/META-INF/MANIFEST.MF b/plugins/org.eclipse.xtend.tests/META-INF/MANIFEST.MF
index 7a5c011..49d7433 100644
--- a/plugins/org.eclipse.xtend.tests/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.xtend.tests/META-INF/MANIFEST.MF
@@ -1,6 +1,6 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
-Bundle-SymbolicName: org.eclipse.xtend.tests
+Bundle-SymbolicName: org.eclipse.xtend.tests;singleton:=true
Bundle-Name: %pluginName (Incubation)
Bundle-Version: 0.7.0.qualifier
Bundle-Localization: plugin
@@ -15,6 +15,12 @@ Export-Package: org.eclipse.xtend,
org.eclipse.xtend.parser,
org.eclipse.xtend.typesystem.baseimpl,
org.eclipse.xtend.typesystem.baseimpl.types,
+ org.eclipse.xtend.typesystem.emf.check.model.test,
+ org.eclipse.xtend.typesystem.emf.check.model.test.impl,
+ org.eclipse.xtend.typesystem.emf.check.model.test.subpackage,
+ org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.impl,
+ org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.util,
+ org.eclipse.xtend.typesystem.emf.check.model.test.util,
org.eclipse.xtend.typesystem.impl.javabeans,
org.eclipse.xtend.typesystem.impl.oawclassic,
org.eclipse.xtend.typesystem.javabeansimpl.test
@@ -23,5 +29,7 @@ Require-Bundle: org.junit,
org.eclipse.xtend,
org.antlr.runtime,
org.eclipse.emf.common,
- org.apache.commons.logging
+ org.apache.commons.logging,
+ org.eclipse.xtend.typesystem.emf;bundle-version="0.7.0",
+ org.eclipse.emf.ecore;bundle-version="2.4.0"
Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/plugins/org.eclipse.xtend.tests/plugin.xml b/plugins/org.eclipse.xtend.tests/plugin.xml
new file mode 100644
index 0000000..11b0f84
--- /dev/null
+++ b/plugins/org.eclipse.xtend.tests/plugin.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<plugin>
+
+ <extension
+ point="org.eclipse.xtend.typesystem.emf.checks">
+ <metaModel
+ nsURI="http://www.itemis.de/emf.oaw.check.test"
+ override="true">
+ <checkFile
+ path="org/eclipse/xtend/typesystem/emf/check/model/check.chk">
+ <referencedMetaModel nsURI="http://oaw.org/test/subpackage">
+ </referencedMetaModel>
+ </checkFile>
+ </metaModel>
+ </extension>
+
+ <extension point="org.eclipse.emf.ecore.generated_package">
+ <package
+ uri = "http://www.itemis.de/emf.oaw.check.test"
+ class = "org.eclipse.xtend.typesystem.emf.check.model.test.TestPackage"
+ genModel = "src/org/eclipse/xtend/typesystem/emf/check/model/test.genmodel" />
+ </extension>
+
+ <extension point="org.eclipse.emf.ecore.generated_package">
+ <package
+ uri = "http://oaw.org/test/subpackage"
+ class = "org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.SubpackagePackage"
+ genModel = "src/org/eclipse/xtend/typesystem/emf/check/model/test.genmodel" />
+ </extension>
+
+</plugin>
diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/AllAllTests.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/AllAllTests.java
index 50b00a8..ccf62c1 100644
--- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/AllAllTests.java
+++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/AllAllTests.java
@@ -21,6 +21,8 @@ public class AllAllTests extends TestSuite {
addTest(org.eclipse.xtend.parser.AllTests.suite());
addTest(org.eclipse.xtend.typesystem.baseimpl.AllTests.suite());
addTest(org.eclipse.xtend.typesystem.baseimpl.types.AllTests.suite());
+ addTest(org.eclipse.xtend.typesystem.emf.check.AllTests.suite());
+ addTest(org.eclipse.xtend.typesystem.emf.check.cache.AllTests.suite());
addTest(org.eclipse.xtend.typesystem.impl.javabeans.AllTests.suite());
addTest(org.eclipse.xtend.typesystem.impl.oawclassic.AllTests.suite());
addTest(org.eclipse.xtend.typesystem.javabeansimpl.test.AllTests.suite());
diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/AllTests.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/AllTests.java
new file mode 100644
index 0000000..f77f68d
--- /dev/null
+++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/AllTests.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2008 itemis AG (http://www.itemis.eu) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.eclipse.xtend.typesystem.emf.check;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author Jan Köhnlein - Initial contribution and API
+ */
+public class AllTests {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite("Test for org.eclipse.xtend.typesystem.emf.check");
+ //$JUnit-BEGIN$
+ suite.addTestSuite(OawValidatorPluginTests.class);
+ suite.addTestSuite(OawValidatorStandaloneTests.class);
+ //$JUnit-END$
+ return suite;
+ }
+
+}
diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/OawValidatorPluginTests.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/OawValidatorPluginTests.java
new file mode 100644
index 0000000..95e1ef7
--- /dev/null
+++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/OawValidatorPluginTests.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * <copyright>
+ * Copyright (c) 2008 itemis AG and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * committers of openArchitectureWare - initial API and implementation
+ * </copyright>
+ *******************************************************************************/
+
+package org.eclipse.xtend.typesystem.emf.check;
+
+import junit.framework.TestCase;
+
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.ecore.EValidator;
+import org.eclipse.emf.ecore.util.Diagnostician;
+import org.eclipse.xtend.typesystem.emf.check.model.test.MyEnum;
+import org.eclipse.xtend.typesystem.emf.check.model.test.MyMetaClass;
+import org.eclipse.xtend.typesystem.emf.check.model.test.TestFactory;
+import org.eclipse.xtend.typesystem.emf.check.model.test.TestPackage;
+
+/**
+ * @author Jan Köhnlein
+ */
+public class OawValidatorPluginTests extends TestCase {
+
+ public void testOawValidator() {
+ // Plugin test
+ CheckRegistry.getInstance();
+ EValidator validator = EValidator.Registry.INSTANCE
+ .getEValidator(TestPackage.eINSTANCE);
+ assertNotNull("Validator registration failed", validator);
+ assertTrue("Wrong validator class",
+ validator instanceof CheckEValidatorAdapter);
+ MyMetaClass myClass = TestFactory.eINSTANCE.createMyMetaClass();
+ Diagnostic diagnostic = Diagnostician.INSTANCE.validate(myClass);
+ assertEquals("Validation should have failed", Diagnostic.ERROR,
+ diagnostic.getSeverity());
+ myClass.setName("Hugo");
+ myClass.setEnumAttr(MyEnum.X);
+ diagnostic = Diagnostician.INSTANCE.validate(myClass);
+ assertEquals("Validation should have succeeded", Diagnostic.OK,
+ diagnostic.getSeverity());
+ MyMetaClass childClass = TestFactory.eINSTANCE.createMyMetaClass();
+ childClass.setName("");
+ myClass.getChildren().add(childClass);
+ diagnostic = Diagnostician.INSTANCE.validate(myClass);
+ assertEquals("Validation should have a warning", Diagnostic.WARNING,
+ diagnostic.getSeverity());
+ }
+}
diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/OawValidatorStandaloneTests.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/OawValidatorStandaloneTests.java
new file mode 100644
index 0000000..14e59f9
--- /dev/null
+++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/OawValidatorStandaloneTests.java
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * <copyright>
+ * Copyright (c) 2008 itemis AG and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * committers of openArchitectureWare - initial API and implementation
+ * </copyright>
+ *******************************************************************************/
+
+package org.eclipse.xtend.typesystem.emf.check;
+
+import junit.framework.TestCase;
+
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.ecore.EValidator;
+import org.eclipse.emf.ecore.util.Diagnostician;
+import org.eclipse.xtend.typesystem.emf.check.model.test.MyEnum;
+import org.eclipse.xtend.typesystem.emf.check.model.test.MyMetaClass;
+import org.eclipse.xtend.typesystem.emf.check.model.test.TestFactory;
+import org.eclipse.xtend.typesystem.emf.check.model.test.TestPackage;
+import org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.SubpackageFactory;
+import org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.SubpackageMetaClass;
+import org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.SubpackagePackage;
+
+/**
+ * @author Jan Köhnlein
+ */
+public class OawValidatorStandaloneTests extends TestCase {
+
+ public void testOawValidator() {
+ // workaround for MacOSX classloader bug
+ ClassLoader classLoader = this.getClass().getClassLoader();
+ Thread.currentThread().setContextClassLoader(classLoader);
+
+ TestPackage testPackage = TestPackage.eINSTANCE;
+ CheckEValidatorAdapter validator = new CheckEValidatorAdapter(
+ testPackage);
+ CheckFileWithContext checkFileWithContext = new CheckFileWithContext("org/eclipse/xtend/typesystem/emf/check/model/check.chk");
+ checkFileWithContext.addImportedEPackageNsUri("http://oaw.org/test/subpackage");
+ validator
+ .addCheckFile(checkFileWithContext);
+ EValidator.Registry.INSTANCE.put(testPackage, validator);
+
+ MyMetaClass myClass = TestFactory.eINSTANCE.createMyMetaClass();
+ Diagnostic diagnostic = Diagnostician.INSTANCE.validate(myClass);
+ assertEquals("Validation should have failed", Diagnostic.ERROR,
+ diagnostic.getSeverity());
+ myClass.setName("Hugo");
+ myClass.setEnumAttr(MyEnum.X);
+ diagnostic = Diagnostician.INSTANCE.validate(myClass);
+ assertEquals("Validation should have succeeded", Diagnostic.OK,
+ diagnostic.getSeverity());
+ MyMetaClass childClass = TestFactory.eINSTANCE.createMyMetaClass();
+ childClass.setName("");
+ myClass.getChildren().add(childClass);
+ diagnostic = Diagnostician.INSTANCE.validate(myClass);
+ assertEquals("Validation should have a warning", Diagnostic.WARNING,
+ diagnostic.getSeverity());
+
+ myClass.getChildren().remove(childClass);
+ SubpackageMetaClass subpackageObject = SubpackageFactory.eINSTANCE.createSubpackageMetaClass();
+ myClass.setSubPackageRef(subpackageObject);
+ diagnostic = Diagnostician.INSTANCE.validate(myClass);
+ assertEquals("Validation should have a warning", Diagnostic.WARNING,
+ diagnostic.getSeverity());
+
+ CheckEValidatorAdapter subValidator = new CheckEValidatorAdapter(SubpackagePackage.eINSTANCE);
+ checkFileWithContext = new CheckFileWithContext("org/openarchitectureware/adapter/emf/check/model/check.chk");
+ checkFileWithContext.addImportedEPackageNsUri("http://oaw.org/test/subpackage");
+ subValidator.addCheckFile(checkFileWithContext);
+ EValidator.Registry.INSTANCE.put(SubpackagePackage.eINSTANCE, validator);
+ diagnostic = Diagnostician.INSTANCE.validate(subpackageObject);
+ assertEquals("Validation should have a warning", Diagnostic.WARNING,
+ diagnostic.getSeverity());
+
+ }
+}
diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/cache/AllTests.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/cache/AllTests.java
new file mode 100644
index 0000000..f70306d
--- /dev/null
+++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/cache/AllTests.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2008 itemis AG (http://www.itemis.eu) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.eclipse.xtend.typesystem.emf.check.cache;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author Jan Köhnlein - Initial contribution and API
+ */
+public class AllTests {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite("Test for org.eclipse.xtend.typesystem.emf.check.cache");
+ //$JUnit-BEGIN$
+ suite.addTestSuite(CachedExtensionTest.class);
+ //$JUnit-END$
+ return suite;
+ }
+
+}
diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/cache/Cached.ext b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/cache/Cached.ext
new file mode 100644
index 0000000..e508da0
--- /dev/null
+++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/cache/Cached.ext
@@ -0,0 +1,4 @@
+import test;
+
+cached boolean nameIsSet(MyMetaClass this) :
+ name!=null; \ No newline at end of file
diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/cache/CachedExtension.chk b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/cache/CachedExtension.chk
new file mode 100644
index 0000000..5ac8aaa
--- /dev/null
+++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/cache/CachedExtension.chk
@@ -0,0 +1,7 @@
+import test;
+
+extension org::openarchitectureware::adapter::emf::check::cache::Cached;
+
+context MyMetaClass ERROR "Name not set":
+ nameIsSet();
+
diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/cache/CachedExtensionTest.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/cache/CachedExtensionTest.java
new file mode 100644
index 0000000..ddca185
--- /dev/null
+++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/cache/CachedExtensionTest.java
@@ -0,0 +1,46 @@
+package org.eclipse.xtend.typesystem.emf.check.cache;
+
+import junit.framework.TestCase;
+
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.ecore.EValidator;
+import org.eclipse.emf.ecore.util.Diagnostician;
+import org.eclipse.xtend.typesystem.emf.check.CheckEValidatorAdapter;
+import org.eclipse.xtend.typesystem.emf.check.CheckFileWithContext;
+import org.eclipse.xtend.typesystem.emf.check.model.test.MyMetaClass;
+import org.eclipse.xtend.typesystem.emf.check.model.test.TestFactory;
+import org.eclipse.xtend.typesystem.emf.check.model.test.TestPackage;
+
+public class CachedExtensionTest extends TestCase {
+
+ public void testCachedExtension() throws Exception {
+ ClassLoader classLoader = this.getClass().getClassLoader();
+ Thread.currentThread().setContextClassLoader(classLoader);
+ TestPackage testPackage = TestPackage.eINSTANCE;
+ CheckEValidatorAdapter validator = new CheckEValidatorAdapter(
+ testPackage);
+ CheckFileWithContext checkFileWithContext = new CheckFileWithContext(
+ "org/eclipse/xtend/typesystem/emf/check/model/check.chk");
+ checkFileWithContext
+ .addImportedEPackageNsUri("http://oaw.org/test/subpackage");
+ validator.addCheckFile(checkFileWithContext);
+ EValidator.Registry.INSTANCE.put(testPackage, validator);
+
+ MyMetaClass myClass = TestFactory.eINSTANCE.createMyMetaClass();
+ Diagnostic diagnostic = Diagnostician.INSTANCE.validate(myClass);
+ assertEquals("Validation should have failed", Diagnostic.ERROR,
+ diagnostic.getSeverity());
+ myClass.setName("Hugo");
+ diagnostic = Diagnostician.INSTANCE.validate(myClass);
+ assertEquals("Validation should have succeded", Diagnostic.OK,
+ diagnostic.getSeverity());
+ /*
+ * problem is that the extension file needs to be reparsed
+ * (reinstantiatd) as the cache is inside the extensions. We need a new
+ * resource manager for each validation pass, as this one caches the
+ * resources and will therefore never reparse an extension file.
+ *
+ * TODO: Implement this
+ */
+ }
+}
diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/HelloPDE.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/HelloPDE.java
new file mode 100644
index 0000000..125eaae
--- /dev/null
+++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/HelloPDE.java
@@ -0,0 +1,5 @@
+package org.eclipse.xtend.typesystem.emf.check.model;
+
+public class HelloPDE {
+
+}
diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/MyExtension.ext b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/MyExtension.ext
new file mode 100644
index 0000000..3c2a153
--- /dev/null
+++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/MyExtension.ext
@@ -0,0 +1 @@
+String doSomething() : 'USA!USA!';
diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/check.chk b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/check.chk
new file mode 100644
index 0000000..6537fa4
--- /dev/null
+++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/check.chk
@@ -0,0 +1,16 @@
+import test;
+import subpackage;
+
+extension org::eclipse::xtend::typesystem::emf::check::model::MyExtension;
+
+context MyMetaClass ERROR "Name must be set" :
+ name != null;
+
+context MyMetaClass WARNING "Name should not be empty" :
+ name != "" && name != doSomething();
+
+context MyMetaClass WARNING "Subpackage should not be set!" :
+ subPackageRef == null;
+
+context subpackage::SubpackageMetaClass WARNING "Subpackage name must be set" :
+ name != null && name != "";
diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test.ecore b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test.ecore
new file mode 100644
index 0000000..34076c6
--- /dev/null
+++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test.ecore
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ecore:EPackage xmi:version="2.0"
+ xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="test"
+ nsURI="http://www.itemis.de/emf.oaw.check.test" nsPrefix="test">
+ <eClassifiers xsi:type="ecore:EClass" name="MyMetaClass">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="children" upperBound="-1"
+ eType="#//MyMetaClass" containment="true"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="subPackageRef" eType="#//subpackage/SubpackageMetaClass"
+ containment="true"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="enumAttr" eType="#//MyEnum"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EEnum" name="MyEnum">
+ <eLiterals name="X"/>
+ <eLiterals name="Y" value="1"/>
+ </eClassifiers>
+ <eSubpackages name="subpackage" nsURI="http://oaw.org/test/subpackage" nsPrefix="subpackage">
+ <eClassifiers xsi:type="ecore:EClass" name="SubpackageMetaClass">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ </eClassifiers>
+ </eSubpackages>
+</ecore:EPackage>
diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test.genmodel b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test.genmodel
new file mode 100644
index 0000000..3c7da0c
--- /dev/null
+++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test.genmodel
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<genmodel:GenModel xmi:version="2.0"
+ xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
+ xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel" modelDirectory="/org.openarchitectureware.adapter.emf.check.tests/src"
+ modelPluginID="org.openarchitectureware.adapter.emf.check.tests" modelName="Test"
+ importerID="org.eclipse.emf.importer.ecore" complianceLevel="5.0" copyrightFields="false">
+ <foreignModel>test.ecore</foreignModel>
+ <genPackages prefix="Test" basePackage="org.openarchitectureware.adapter.emf.check.model"
+ disposableProviderFactory="true" ecorePackage="test.ecore#/">
+ <genClasses ecoreClass="test.ecore#//MyMetaClass">
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute test.ecore#//MyMetaClass/name"/>
+ <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference test.ecore#//MyMetaClass/children"/>
+ <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference test.ecore#//MyMetaClass/subPackageRef"/>
+ </genClasses>
+ <nestedGenPackages prefix="Subpackage" basePackage="org.openarchitectureware.adapter.emf.check.model.test"
+ disposableProviderFactory="true" ecorePackage="test.ecore#//subpackage">
+ <genClasses ecoreClass="test.ecore#//subpackage/SubpackageMetaClass">
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute test.ecore#//subpackage/SubpackageMetaClass/name"/>
+ </genClasses>
+ </nestedGenPackages>
+ </genPackages>
+</genmodel:GenModel>
diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/MyEnum.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/MyEnum.java
new file mode 100644
index 0000000..fc7a480
--- /dev/null
+++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/MyEnum.java
@@ -0,0 +1,212 @@
+/**
+ * <copyright>
+ * </copyright>
+ *
+ * $Id: MyEnum.java,v 1.1 2008/10/21 07:32:51 jkohnlein Exp $
+ */
+package org.eclipse.xtend.typesystem.emf.check.model.test;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.emf.common.util.Enumerator;
+
+/**
+ * <!-- begin-user-doc -->
+ * A representation of the literals of the enumeration '<em><b>My Enum</b></em>',
+ * and utility methods for working with them.
+ * <!-- end-user-doc -->
+ * @see org.eclipse.xtend.typesystem.emf.check.model.test.TestPackage#getMyEnum()
+ * @model
+ * @generated
+ */
+public enum MyEnum implements Enumerator {
+ /**
+ * The '<em><b>X</b></em>' literal object.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #X_VALUE
+ * @generated
+ * @ordered
+ */
+ X(0, "X", "X"),
+
+ /**
+ * The '<em><b>Y</b></em>' literal object.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #Y_VALUE
+ * @generated
+ * @ordered
+ */
+ Y(1, "Y", "Y");
+
+ /**
+ * The '<em><b>X</b></em>' literal value.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of '<em><b>X</b></em>' literal object isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @see #X
+ * @model
+ * @generated
+ * @ordered
+ */
+ public static final int X_VALUE = 0;
+
+ /**
+ * The '<em><b>Y</b></em>' literal value.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of '<em><b>Y</b></em>' literal object isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @see #Y
+ * @model
+ * @generated
+ * @ordered
+ */
+ public static final int Y_VALUE = 1;
+
+ /**
+ * An array of all the '<em><b>My Enum</b></em>' enumerators.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private static final MyEnum[] VALUES_ARRAY =
+ new MyEnum[] {
+ X,
+ Y,
+ };
+
+ /**
+ * A public read-only list of all the '<em><b>My Enum</b></em>' enumerators.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final List<MyEnum> VALUES = Collections.unmodifiableList(Arrays.asList(VALUES_ARRAY));
+
+ /**
+ * Returns the '<em><b>My Enum</b></em>' literal with the specified literal value.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static MyEnum get(String literal) {
+ for (int i = 0; i < VALUES_ARRAY.length; ++i) {
+ MyEnum result = VALUES_ARRAY[i];
+ if (result.toString().equals(literal)) {
+ return result;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the '<em><b>My Enum</b></em>' literal with the specified name.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static MyEnum getByName(String name) {
+ for (int i = 0; i < VALUES_ARRAY.length; ++i) {
+ MyEnum result = VALUES_ARRAY[i];
+ if (result.getName().equals(name)) {
+ return result;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the '<em><b>My Enum</b></em>' literal with the specified integer value.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static MyEnum get(int value) {
+ switch (value) {
+ case X_VALUE: return X;
+ case Y_VALUE: return Y;
+ }
+ return null;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private final int value;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private final String name;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private final String literal;
+
+ /**
+ * Only this class can construct instances.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private MyEnum(int value, String name, String literal) {
+ this.value = value;
+ this.name = name;
+ this.literal = literal;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public int getValue() {
+ return value;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String getLiteral() {
+ return literal;
+ }
+
+ /**
+ * Returns the literal value of the enumerator, which is its string representation.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public String toString() {
+ return literal;
+ }
+
+} //MyEnum
diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/MyMetaClass.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/MyMetaClass.java
new file mode 100644
index 0000000..80f975c
--- /dev/null
+++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/MyMetaClass.java
@@ -0,0 +1,131 @@
+/**
+ * <copyright>
+ * </copyright>
+ *
+ * $Id: MyMetaClass.java,v 1.1 2008/10/21 07:32:51 jkohnlein Exp $
+ */
+package org.eclipse.xtend.typesystem.emf.check.model.test;
+
+import org.eclipse.emf.common.util.EList;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.SubpackageMetaClass;
+
+/**
+ * <!-- begin-user-doc -->
+ * A representation of the model object '<em><b>My Meta Class</b></em>'.
+ * <!-- end-user-doc -->
+ *
+ * <p>
+ * The following features are supported:
+ * <ul>
+ * <li>{@link org.eclipse.xtend.typesystem.emf.check.model.test.MyMetaClass#getName <em>Name</em>}</li>
+ * <li>{@link org.eclipse.xtend.typesystem.emf.check.model.test.MyMetaClass#getChildren <em>Children</em>}</li>
+ * <li>{@link org.eclipse.xtend.typesystem.emf.check.model.test.MyMetaClass#getSubPackageRef <em>Sub Package Ref</em>}</li>
+ * <li>{@link org.eclipse.xtend.typesystem.emf.check.model.test.MyMetaClass#getEnumAttr <em>Enum Attr</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @see org.eclipse.xtend.typesystem.emf.check.model.test.TestPackage#getMyMetaClass()
+ * @model
+ * @generated
+ */
+public interface MyMetaClass extends EObject {
+ /**
+ * Returns the value of the '<em><b>Name</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Name</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Name</em>' attribute.
+ * @see #setName(String)
+ * @see org.eclipse.xtend.typesystem.emf.check.model.test.TestPackage#getMyMetaClass_Name()
+ * @model
+ * @generated
+ */
+ String getName();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.xtend.typesystem.emf.check.model.test.MyMetaClass#getName <em>Name</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Name</em>' attribute.
+ * @see #getName()
+ * @generated
+ */
+ void setName(String value);
+
+ /**
+ * Returns the value of the '<em><b>Children</b></em>' containment reference list.
+ * The list contents are of type {@link org.eclipse.xtend.typesystem.emf.check.model.test.MyMetaClass}.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Children</em>' containment reference list isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Children</em>' containment reference list.
+ * @see org.eclipse.xtend.typesystem.emf.check.model.test.TestPackage#getMyMetaClass_Children()
+ * @model containment="true"
+ * @generated
+ */
+ EList<MyMetaClass> getChildren();
+
+ /**
+ * Returns the value of the '<em><b>Sub Package Ref</b></em>' containment reference.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Sub Package Ref</em>' containment reference isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Sub Package Ref</em>' containment reference.
+ * @see #setSubPackageRef(SubpackageMetaClass)
+ * @see org.eclipse.xtend.typesystem.emf.check.model.test.TestPackage#getMyMetaClass_SubPackageRef()
+ * @model containment="true"
+ * @generated
+ */
+ SubpackageMetaClass getSubPackageRef();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.xtend.typesystem.emf.check.model.test.MyMetaClass#getSubPackageRef <em>Sub Package Ref</em>}' containment reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Sub Package Ref</em>' containment reference.
+ * @see #getSubPackageRef()
+ * @generated
+ */
+ void setSubPackageRef(SubpackageMetaClass value);
+
+ /**
+ * Returns the value of the '<em><b>Enum Attr</b></em>' attribute.
+ * The literals are from the enumeration {@link org.eclipse.xtend.typesystem.emf.check.model.test.MyEnum}.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Enum Attr</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Enum Attr</em>' attribute.
+ * @see org.eclipse.xtend.typesystem.emf.check.model.test.MyEnum
+ * @see #setEnumAttr(MyEnum)
+ * @see org.eclipse.xtend.typesystem.emf.check.model.test.TestPackage#getMyMetaClass_EnumAttr()
+ * @model
+ * @generated
+ */
+ MyEnum getEnumAttr();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.xtend.typesystem.emf.check.model.test.MyMetaClass#getEnumAttr <em>Enum Attr</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Enum Attr</em>' attribute.
+ * @see org.eclipse.xtend.typesystem.emf.check.model.test.MyEnum
+ * @see #getEnumAttr()
+ * @generated
+ */
+ void setEnumAttr(MyEnum value);
+
+} // MyMetaClass
diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/TestFactory.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/TestFactory.java
new file mode 100644
index 0000000..9044962
--- /dev/null
+++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/TestFactory.java
@@ -0,0 +1,46 @@
+/**
+ * <copyright>
+ * </copyright>
+ *
+ * $Id: TestFactory.java,v 1.1 2008/10/21 07:32:51 jkohnlein Exp $
+ */
+package org.eclipse.xtend.typesystem.emf.check.model.test;
+
+import org.eclipse.emf.ecore.EFactory;
+
+/**
+ * <!-- begin-user-doc -->
+ * The <b>Factory</b> for the model.
+ * It provides a create method for each non-abstract class of the model.
+ * <!-- end-user-doc -->
+ * @see org.eclipse.xtend.typesystem.emf.check.model.test.TestPackage
+ * @generated
+ */
+public interface TestFactory extends EFactory {
+ /**
+ * The singleton instance of the factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ TestFactory eINSTANCE = org.eclipse.xtend.typesystem.emf.check.model.test.impl.TestFactoryImpl.init();
+
+ /**
+ * Returns a new object of class '<em>My Meta Class</em>'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return a new object of class '<em>My Meta Class</em>'.
+ * @generated
+ */
+ MyMetaClass createMyMetaClass();
+
+ /**
+ * Returns the package supported by this factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the package supported by this factory.
+ * @generated
+ */
+ TestPackage getTestPackage();
+
+} //TestFactory
diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/TestPackage.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/TestPackage.java
new file mode 100644
index 0000000..c9a2d77
--- /dev/null
+++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/TestPackage.java
@@ -0,0 +1,270 @@
+/**
+ * <copyright>
+ * </copyright>
+ *
+ * $Id: TestPackage.java,v 1.1 2008/10/21 07:32:51 jkohnlein Exp $
+ */
+package org.eclipse.xtend.typesystem.emf.check.model.test;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EEnum;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+
+/**
+ * <!-- begin-user-doc -->
+ * The <b>Package</b> for the model.
+ * It contains accessors for the meta objects to represent
+ * <ul>
+ * <li>each class,</li>
+ * <li>each feature of each class,</li>
+ * <li>each enum,</li>
+ * <li>and each data type</li>
+ * </ul>
+ * <!-- end-user-doc -->
+ * @see org.eclipse.xtend.typesystem.emf.check.model.test.TestFactory
+ * @model kind="package"
+ * @generated
+ */
+public interface TestPackage extends EPackage {
+ /**
+ * The package name.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ String eNAME = "test";
+
+ /**
+ * The package namespace URI.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ String eNS_URI = "http://www.itemis.de/emf.oaw.check.test";
+
+ /**
+ * The package namespace name.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ String eNS_PREFIX = "test";
+
+ /**
+ * The singleton instance of the package.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ TestPackage eINSTANCE = org.eclipse.xtend.typesystem.emf.check.model.test.impl.TestPackageImpl.init();
+
+ /**
+ * The meta object id for the '{@link org.eclipse.xtend.typesystem.emf.check.model.test.impl.MyMetaClassImpl <em>My Meta Class</em>}' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see org.eclipse.xtend.typesystem.emf.check.model.test.impl.MyMetaClassImpl
+ * @see org.eclipse.xtend.typesystem.emf.check.model.test.impl.TestPackageImpl#getMyMetaClass()
+ * @generated
+ */
+ int MY_META_CLASS = 0;
+
+ /**
+ * The feature id for the '<em><b>Name</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int MY_META_CLASS__NAME = 0;
+
+ /**
+ * The feature id for the '<em><b>Children</b></em>' containment reference list.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int MY_META_CLASS__CHILDREN = 1;
+
+ /**
+ * The feature id for the '<em><b>Sub Package Ref</b></em>' containment reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int MY_META_CLASS__SUB_PACKAGE_REF = 2;
+
+ /**
+ * The feature id for the '<em><b>Enum Attr</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int MY_META_CLASS__ENUM_ATTR = 3;
+
+ /**
+ * The number of structural features of the '<em>My Meta Class</em>' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int MY_META_CLASS_FEATURE_COUNT = 4;
+
+
+ /**
+ * The meta object id for the '{@link org.eclipse.xtend.typesystem.emf.check.model.test.MyEnum <em>My Enum</em>}' enum.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see org.eclipse.xtend.typesystem.emf.check.model.test.MyEnum
+ * @see org.eclipse.xtend.typesystem.emf.check.model.test.impl.TestPackageImpl#getMyEnum()
+ * @generated
+ */
+ int MY_ENUM = 1;
+
+
+ /**
+ * Returns the meta object for class '{@link org.eclipse.xtend.typesystem.emf.check.model.test.MyMetaClass <em>My Meta Class</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for class '<em>My Meta Class</em>'.
+ * @see org.eclipse.xtend.typesystem.emf.check.model.test.MyMetaClass
+ * @generated
+ */
+ EClass getMyMetaClass();
+
+ /**
+ * Returns the meta object for the attribute '{@link org.eclipse.xtend.typesystem.emf.check.model.test.MyMetaClass#getName <em>Name</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the attribute '<em>Name</em>'.
+ * @see org.eclipse.xtend.typesystem.emf.check.model.test.MyMetaClass#getName()
+ * @see #getMyMetaClass()
+ * @generated
+ */
+ EAttribute getMyMetaClass_Name();
+
+ /**
+ * Returns the meta object for the containment reference list '{@link org.eclipse.xtend.typesystem.emf.check.model.test.MyMetaClass#getChildren <em>Children</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the containment reference list '<em>Children</em>'.
+ * @see org.eclipse.xtend.typesystem.emf.check.model.test.MyMetaClass#getChildren()
+ * @see #getMyMetaClass()
+ * @generated
+ */
+ EReference getMyMetaClass_Children();
+
+ /**
+ * Returns the meta object for the containment reference '{@link org.eclipse.xtend.typesystem.emf.check.model.test.MyMetaClass#getSubPackageRef <em>Sub Package Ref</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the containment reference '<em>Sub Package Ref</em>'.
+ * @see org.eclipse.xtend.typesystem.emf.check.model.test.MyMetaClass#getSubPackageRef()
+ * @see #getMyMetaClass()
+ * @generated
+ */
+ EReference getMyMetaClass_SubPackageRef();
+
+ /**
+ * Returns the meta object for the attribute '{@link org.eclipse.xtend.typesystem.emf.check.model.test.MyMetaClass#getEnumAttr <em>Enum Attr</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the attribute '<em>Enum Attr</em>'.
+ * @see org.eclipse.xtend.typesystem.emf.check.model.test.MyMetaClass#getEnumAttr()
+ * @see #getMyMetaClass()
+ * @generated
+ */
+ EAttribute getMyMetaClass_EnumAttr();
+
+ /**
+ * Returns the meta object for enum '{@link org.eclipse.xtend.typesystem.emf.check.model.test.MyEnum <em>My Enum</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for enum '<em>My Enum</em>'.
+ * @see org.eclipse.xtend.typesystem.emf.check.model.test.MyEnum
+ * @generated
+ */
+ EEnum getMyEnum();
+
+ /**
+ * Returns the factory that creates the instances of the model.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the factory that creates the instances of the model.
+ * @generated
+ */
+ TestFactory getTestFactory();
+
+ /**
+ * <!-- begin-user-doc -->
+ * Defines literals for the meta objects that represent
+ * <ul>
+ * <li>each class,</li>
+ * <li>each feature of each class,</li>
+ * <li>each enum,</li>
+ * <li>and each data type</li>
+ * </ul>
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ interface Literals {
+ /**
+ * The meta object literal for the '{@link org.eclipse.xtend.typesystem.emf.check.model.test.impl.MyMetaClassImpl <em>My Meta Class</em>}' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see org.eclipse.xtend.typesystem.emf.check.model.test.impl.MyMetaClassImpl
+ * @see org.eclipse.xtend.typesystem.emf.check.model.test.impl.TestPackageImpl#getMyMetaClass()
+ * @generated
+ */
+ EClass MY_META_CLASS = eINSTANCE.getMyMetaClass();
+
+ /**
+ * The meta object literal for the '<em><b>Name</b></em>' attribute feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ EAttribute MY_META_CLASS__NAME = eINSTANCE.getMyMetaClass_Name();
+
+ /**
+ * The meta object literal for the '<em><b>Children</b></em>' containment reference list feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ EReference MY_META_CLASS__CHILDREN = eINSTANCE.getMyMetaClass_Children();
+
+ /**
+ * The meta object literal for the '<em><b>Sub Package Ref</b></em>' containment reference feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ EReference MY_META_CLASS__SUB_PACKAGE_REF = eINSTANCE.getMyMetaClass_SubPackageRef();
+
+ /**
+ * The meta object literal for the '<em><b>Enum Attr</b></em>' attribute feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ EAttribute MY_META_CLASS__ENUM_ATTR = eINSTANCE.getMyMetaClass_EnumAttr();
+
+ /**
+ * The meta object literal for the '{@link org.eclipse.xtend.typesystem.emf.check.model.test.MyEnum <em>My Enum</em>}' enum.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see org.eclipse.xtend.typesystem.emf.check.model.test.MyEnum
+ * @see org.eclipse.xtend.typesystem.emf.check.model.test.impl.TestPackageImpl#getMyEnum()
+ * @generated
+ */
+ EEnum MY_ENUM = eINSTANCE.getMyEnum();
+
+ }
+
+} //TestPackage
diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/impl/MyMetaClassImpl.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/impl/MyMetaClassImpl.java
new file mode 100644
index 0000000..49ffa27
--- /dev/null
+++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/impl/MyMetaClassImpl.java
@@ -0,0 +1,347 @@
+/**
+ * <copyright>
+ * </copyright>
+ *
+ * $Id: MyMetaClassImpl.java,v 1.1 2008/10/21 07:32:52 jkohnlein Exp $
+ */
+package org.eclipse.xtend.typesystem.emf.check.model.test.impl;
+
+
+import java.util.Collection;
+
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.NotificationChain;
+
+import org.eclipse.emf.common.util.EList;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.InternalEObject;
+
+import org.eclipse.emf.ecore.impl.ENotificationImpl;
+import org.eclipse.emf.ecore.impl.EObjectImpl;
+
+import org.eclipse.emf.ecore.util.EObjectContainmentEList;
+import org.eclipse.emf.ecore.util.InternalEList;
+import org.eclipse.xtend.typesystem.emf.check.model.test.MyEnum;
+import org.eclipse.xtend.typesystem.emf.check.model.test.MyMetaClass;
+import org.eclipse.xtend.typesystem.emf.check.model.test.TestPackage;
+import org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.SubpackageMetaClass;
+
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model object '<em><b>My Meta Class</b></em>'.
+ * <!-- end-user-doc -->
+ * <p>
+ * The following features are implemented:
+ * <ul>
+ * <li>{@link org.eclipse.xtend.typesystem.emf.check.model.test.impl.MyMetaClassImpl#getName <em>Name</em>}</li>
+ * <li>{@link org.eclipse.xtend.typesystem.emf.check.model.test.impl.MyMetaClassImpl#getChildren <em>Children</em>}</li>
+ * <li>{@link org.eclipse.xtend.typesystem.emf.check.model.test.impl.MyMetaClassImpl#getSubPackageRef <em>Sub Package Ref</em>}</li>
+ * <li>{@link org.eclipse.xtend.typesystem.emf.check.model.test.impl.MyMetaClassImpl#getEnumAttr <em>Enum Attr</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @generated
+ */
+public class MyMetaClassImpl extends EObjectImpl implements MyMetaClass {
+ /**
+ * The default value of the '{@link #getName() <em>Name</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getName()
+ * @generated
+ * @ordered
+ */
+ protected static final String NAME_EDEFAULT = null;
+
+ /**
+ * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getName()
+ * @generated
+ * @ordered
+ */
+ protected String name = NAME_EDEFAULT;
+
+ /**
+ * The cached value of the '{@link #getChildren() <em>Children</em>}' containment reference list.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getChildren()
+ * @generated
+ * @ordered
+ */
+ protected EList<MyMetaClass> children;
+
+ /**
+ * The cached value of the '{@link #getSubPackageRef() <em>Sub Package Ref</em>}' containment reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getSubPackageRef()
+ * @generated
+ * @ordered
+ */
+ protected SubpackageMetaClass subPackageRef;
+
+ /**
+ * The default value of the '{@link #getEnumAttr() <em>Enum Attr</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getEnumAttr()
+ * @generated
+ * @ordered
+ */
+ protected static final MyEnum ENUM_ATTR_EDEFAULT = MyEnum.X;
+
+ /**
+ * The cached value of the '{@link #getEnumAttr() <em>Enum Attr</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getEnumAttr()
+ * @generated
+ * @ordered
+ */
+ protected MyEnum enumAttr = ENUM_ATTR_EDEFAULT;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected MyMetaClassImpl() {
+ super();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected EClass eStaticClass() {
+ return TestPackage.Literals.MY_META_CLASS;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setName(String newName) {
+ String oldName = name;
+ name = newName;
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, TestPackage.MY_META_CLASS__NAME, oldName, name));
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EList<MyMetaClass> getChildren() {
+ if (children == null) {
+ children = new EObjectContainmentEList<MyMetaClass>(MyMetaClass.class, this, TestPackage.MY_META_CLASS__CHILDREN);
+ }
+ return children;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public SubpackageMetaClass getSubPackageRef() {
+ return subPackageRef;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public NotificationChain basicSetSubPackageRef(SubpackageMetaClass newSubPackageRef, NotificationChain msgs) {
+ SubpackageMetaClass oldSubPackageRef = subPackageRef;
+ subPackageRef = newSubPackageRef;
+ if (eNotificationRequired()) {
+ ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, TestPackage.MY_META_CLASS__SUB_PACKAGE_REF, oldSubPackageRef, newSubPackageRef);
+ if (msgs == null) msgs = notification; else msgs.add(notification);
+ }
+ return msgs;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setSubPackageRef(SubpackageMetaClass newSubPackageRef) {
+ if (newSubPackageRef != subPackageRef) {
+ NotificationChain msgs = null;
+ if (subPackageRef != null)
+ msgs = ((InternalEObject)subPackageRef).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - TestPackage.MY_META_CLASS__SUB_PACKAGE_REF, null, msgs);
+ if (newSubPackageRef != null)
+ msgs = ((InternalEObject)newSubPackageRef).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - TestPackage.MY_META_CLASS__SUB_PACKAGE_REF, null, msgs);
+ msgs = basicSetSubPackageRef(newSubPackageRef, msgs);
+ if (msgs != null) msgs.dispatch();
+ }
+ else if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, TestPackage.MY_META_CLASS__SUB_PACKAGE_REF, newSubPackageRef, newSubPackageRef));
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public MyEnum getEnumAttr() {
+ return enumAttr;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setEnumAttr(MyEnum newEnumAttr) {
+ MyEnum oldEnumAttr = enumAttr;
+ enumAttr = newEnumAttr == null ? ENUM_ATTR_EDEFAULT : newEnumAttr;
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, TestPackage.MY_META_CLASS__ENUM_ATTR, oldEnumAttr, enumAttr));
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
+ switch (featureID) {
+ case TestPackage.MY_META_CLASS__CHILDREN:
+ return ((InternalEList<?>)getChildren()).basicRemove(otherEnd, msgs);
+ case TestPackage.MY_META_CLASS__SUB_PACKAGE_REF:
+ return basicSetSubPackageRef(null, msgs);
+ }
+ return super.eInverseRemove(otherEnd, featureID, msgs);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Object eGet(int featureID, boolean resolve, boolean coreType) {
+ switch (featureID) {
+ case TestPackage.MY_META_CLASS__NAME:
+ return getName();
+ case TestPackage.MY_META_CLASS__CHILDREN:
+ return getChildren();
+ case TestPackage.MY_META_CLASS__SUB_PACKAGE_REF:
+ return getSubPackageRef();
+ case TestPackage.MY_META_CLASS__ENUM_ATTR:
+ return getEnumAttr();
+ }
+ return super.eGet(featureID, resolve, coreType);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public void eSet(int featureID, Object newValue) {
+ switch (featureID) {
+ case TestPackage.MY_META_CLASS__NAME:
+ setName((String)newValue);
+ return;
+ case TestPackage.MY_META_CLASS__CHILDREN:
+ getChildren().clear();
+ getChildren().addAll((Collection<? extends MyMetaClass>)newValue);
+ return;
+ case TestPackage.MY_META_CLASS__SUB_PACKAGE_REF:
+ setSubPackageRef((SubpackageMetaClass)newValue);
+ return;
+ case TestPackage.MY_META_CLASS__ENUM_ATTR:
+ setEnumAttr((MyEnum)newValue);
+ return;
+ }
+ super.eSet(featureID, newValue);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void eUnset(int featureID) {
+ switch (featureID) {
+ case TestPackage.MY_META_CLASS__NAME:
+ setName(NAME_EDEFAULT);
+ return;
+ case TestPackage.MY_META_CLASS__CHILDREN:
+ getChildren().clear();
+ return;
+ case TestPackage.MY_META_CLASS__SUB_PACKAGE_REF:
+ setSubPackageRef((SubpackageMetaClass)null);
+ return;
+ case TestPackage.MY_META_CLASS__ENUM_ATTR:
+ setEnumAttr(ENUM_ATTR_EDEFAULT);
+ return;
+ }
+ super.eUnset(featureID);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public boolean eIsSet(int featureID) {
+ switch (featureID) {
+ case TestPackage.MY_META_CLASS__NAME:
+ return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
+ case TestPackage.MY_META_CLASS__CHILDREN:
+ return children != null && !children.isEmpty();
+ case TestPackage.MY_META_CLASS__SUB_PACKAGE_REF:
+ return subPackageRef != null;
+ case TestPackage.MY_META_CLASS__ENUM_ATTR:
+ return enumAttr != ENUM_ATTR_EDEFAULT;
+ }
+ return super.eIsSet(featureID);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public String toString() {
+ if (eIsProxy()) return super.toString();
+
+ StringBuffer result = new StringBuffer(super.toString());
+ result.append(" (name: ");
+ result.append(name);
+ result.append(", enumAttr: ");
+ result.append(enumAttr);
+ result.append(')');
+ return result.toString();
+ }
+
+} //MyMetaClassImpl
diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/impl/TestFactoryImpl.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/impl/TestFactoryImpl.java
new file mode 100644
index 0000000..22aeac2
--- /dev/null
+++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/impl/TestFactoryImpl.java
@@ -0,0 +1,150 @@
+/**
+ * <copyright>
+ * </copyright>
+ *
+ * $Id: TestFactoryImpl.java,v 1.1 2008/10/21 07:32:52 jkohnlein Exp $
+ */
+package org.eclipse.xtend.typesystem.emf.check.model.test.impl;
+
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+
+import org.eclipse.emf.ecore.impl.EFactoryImpl;
+
+import org.eclipse.emf.ecore.plugin.EcorePlugin;
+import org.eclipse.xtend.typesystem.emf.check.model.test.*;
+
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model <b>Factory</b>.
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class TestFactoryImpl extends EFactoryImpl implements TestFactory {
+ /**
+ * Creates the default factory implementation.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static TestFactory init() {
+ try {
+ TestFactory theTestFactory = (TestFactory)EPackage.Registry.INSTANCE.getEFactory("http://www.itemis.de/emf.oaw.check.test");
+ if (theTestFactory != null) {
+ return theTestFactory;
+ }
+ }
+ catch (Exception exception) {
+ EcorePlugin.INSTANCE.log(exception);
+ }
+ return new TestFactoryImpl();
+ }
+
+ /**
+ * Creates an instance of the factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public TestFactoryImpl() {
+ super();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public EObject create(EClass eClass) {
+ switch (eClass.getClassifierID()) {
+ case TestPackage.MY_META_CLASS: return createMyMetaClass();
+ default:
+ throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier");
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Object createFromString(EDataType eDataType, String initialValue) {
+ switch (eDataType.getClassifierID()) {
+ case TestPackage.MY_ENUM:
+ return createMyEnumFromString(eDataType, initialValue);
+ default:
+ throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public String convertToString(EDataType eDataType, Object instanceValue) {
+ switch (eDataType.getClassifierID()) {
+ case TestPackage.MY_ENUM:
+ return convertMyEnumToString(eDataType, instanceValue);
+ default:
+ throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public MyMetaClass createMyMetaClass() {
+ MyMetaClassImpl myMetaClass = new MyMetaClassImpl();
+ return myMetaClass;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public MyEnum createMyEnumFromString(EDataType eDataType, String initialValue) {
+ MyEnum result = MyEnum.get(initialValue);
+ if (result == null) throw new IllegalArgumentException("The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'");
+ return result;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String convertMyEnumToString(EDataType eDataType, Object instanceValue) {
+ return instanceValue == null ? null : instanceValue.toString();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public TestPackage getTestPackage() {
+ return (TestPackage)getEPackage();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @deprecated
+ * @generated
+ */
+ @Deprecated
+ public static TestPackage getPackage() {
+ return TestPackage.eINSTANCE;
+ }
+
+} //TestFactoryImpl
diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/impl/TestPackageImpl.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/impl/TestPackageImpl.java
new file mode 100644
index 0000000..be3014a
--- /dev/null
+++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/impl/TestPackageImpl.java
@@ -0,0 +1,261 @@
+/**
+ * <copyright>
+ * </copyright>
+ *
+ * $Id: TestPackageImpl.java,v 1.1 2008/10/21 07:32:52 jkohnlein Exp $
+ */
+package org.eclipse.xtend.typesystem.emf.check.model.test.impl;
+
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EEnum;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+
+import org.eclipse.emf.ecore.impl.EPackageImpl;
+import org.eclipse.xtend.typesystem.emf.check.model.test.MyEnum;
+import org.eclipse.xtend.typesystem.emf.check.model.test.MyMetaClass;
+import org.eclipse.xtend.typesystem.emf.check.model.test.TestFactory;
+import org.eclipse.xtend.typesystem.emf.check.model.test.TestPackage;
+import org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.SubpackagePackage;
+import org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.impl.SubpackagePackageImpl;
+
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model <b>Package</b>.
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class TestPackageImpl extends EPackageImpl implements TestPackage {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private EClass myMetaClassEClass = null;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private EEnum myEnumEEnum = null;
+
+ /**
+ * Creates an instance of the model <b>Package</b>, registered with
+ * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package
+ * package URI value.
+ * <p>Note: the correct way to create the package is via the static
+ * factory method {@link #init init()}, which also performs
+ * initialization of the package, or returns the registered package,
+ * if one already exists.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see org.eclipse.emf.ecore.EPackage.Registry
+ * @see org.eclipse.xtend.typesystem.emf.check.model.test.TestPackage#eNS_URI
+ * @see #init()
+ * @generated
+ */
+ private TestPackageImpl() {
+ super(eNS_URI, TestFactory.eINSTANCE);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private static boolean isInited = false;
+
+ /**
+ * Creates, registers, and initializes the <b>Package</b> for this
+ * model, and for any others upon which it depends. Simple
+ * dependencies are satisfied by calling this method on all
+ * dependent packages before doing anything else. This method drives
+ * initialization for interdependent packages directly, in parallel
+ * with this package, itself.
+ * <p>Of this package and its interdependencies, all packages which
+ * have not yet been registered by their URI values are first created
+ * and registered. The packages are then initialized in two steps:
+ * meta-model objects for all of the packages are created before any
+ * are initialized, since one package's meta-model objects may refer to
+ * those of another.
+ * <p>Invocation of this method will not affect any packages that have
+ * already been initialized.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #eNS_URI
+ * @see #createPackageContents()
+ * @see #initializePackageContents()
+ * @generated
+ */
+ public static TestPackage init() {
+ if (isInited) return (TestPackage)EPackage.Registry.INSTANCE.getEPackage(TestPackage.eNS_URI);
+
+ // Obtain or create and register package
+ TestPackageImpl theTestPackage = (TestPackageImpl)(EPackage.Registry.INSTANCE.getEPackage(eNS_URI) instanceof TestPackageImpl ? EPackage.Registry.INSTANCE.getEPackage(eNS_URI) : new TestPackageImpl());
+
+ isInited = true;
+
+ // Obtain or create and register interdependencies
+ SubpackagePackageImpl theSubpackagePackage = (SubpackagePackageImpl)(EPackage.Registry.INSTANCE.getEPackage(SubpackagePackage.eNS_URI) instanceof SubpackagePackageImpl ? EPackage.Registry.INSTANCE.getEPackage(SubpackagePackage.eNS_URI) : SubpackagePackage.eINSTANCE);
+
+ // Create package meta-data objects
+ theTestPackage.createPackageContents();
+ theSubpackagePackage.createPackageContents();
+
+ // Initialize created meta-data
+ theTestPackage.initializePackageContents();
+ theSubpackagePackage.initializePackageContents();
+
+ // Mark meta-data to indicate it can't be changed
+ theTestPackage.freeze();
+
+ return theTestPackage;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EClass getMyMetaClass() {
+ return myMetaClassEClass;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EAttribute getMyMetaClass_Name() {
+ return (EAttribute)myMetaClassEClass.getEStructuralFeatures().get(0);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EReference getMyMetaClass_Children() {
+ return (EReference)myMetaClassEClass.getEStructuralFeatures().get(1);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EReference getMyMetaClass_SubPackageRef() {
+ return (EReference)myMetaClassEClass.getEStructuralFeatures().get(2);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EAttribute getMyMetaClass_EnumAttr() {
+ return (EAttribute)myMetaClassEClass.getEStructuralFeatures().get(3);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EEnum getMyEnum() {
+ return myEnumEEnum;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public TestFactory getTestFactory() {
+ return (TestFactory)getEFactoryInstance();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private boolean isCreated = false;
+
+ /**
+ * Creates the meta-model objects for the package. This method is
+ * guarded to have no affect on any invocation but its first.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void createPackageContents() {
+ if (isCreated) return;
+ isCreated = true;
+
+ // Create classes and their features
+ myMetaClassEClass = createEClass(MY_META_CLASS);
+ createEAttribute(myMetaClassEClass, MY_META_CLASS__NAME);
+ createEReference(myMetaClassEClass, MY_META_CLASS__CHILDREN);
+ createEReference(myMetaClassEClass, MY_META_CLASS__SUB_PACKAGE_REF);
+ createEAttribute(myMetaClassEClass, MY_META_CLASS__ENUM_ATTR);
+
+ // Create enums
+ myEnumEEnum = createEEnum(MY_ENUM);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private boolean isInitialized = false;
+
+ /**
+ * Complete the initialization of the package and its meta-model. This
+ * method is guarded to have no affect on any invocation but its first.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void initializePackageContents() {
+ if (isInitialized) return;
+ isInitialized = true;
+
+ // Initialize package
+ setName(eNAME);
+ setNsPrefix(eNS_PREFIX);
+ setNsURI(eNS_URI);
+
+ // Obtain other dependent packages
+ SubpackagePackage theSubpackagePackage = (SubpackagePackage)EPackage.Registry.INSTANCE.getEPackage(SubpackagePackage.eNS_URI);
+
+ // Add subpackages
+ getESubpackages().add(theSubpackagePackage);
+
+ // Create type parameters
+
+ // Set bounds for type parameters
+
+ // Add supertypes to classes
+
+ // Initialize classes and features; add operations and parameters
+ initEClass(myMetaClassEClass, MyMetaClass.class, "MyMetaClass", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
+ initEAttribute(getMyMetaClass_Name(), ecorePackage.getEString(), "name", null, 0, 1, MyMetaClass.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEReference(getMyMetaClass_Children(), this.getMyMetaClass(), null, "children", null, 0, -1, MyMetaClass.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEReference(getMyMetaClass_SubPackageRef(), theSubpackagePackage.getSubpackageMetaClass(), null, "subPackageRef", null, 0, 1, MyMetaClass.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEAttribute(getMyMetaClass_EnumAttr(), this.getMyEnum(), "enumAttr", null, 0, 1, MyMetaClass.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+
+ // Initialize enums and add enum literals
+ initEEnum(myEnumEEnum, MyEnum.class, "MyEnum");
+ addEEnumLiteral(myEnumEEnum, MyEnum.X);
+ addEEnumLiteral(myEnumEEnum, MyEnum.Y);
+
+ // Create resource
+ createResource(eNS_URI);
+ }
+
+} //TestPackageImpl
diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/SubpackageFactory.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/SubpackageFactory.java
new file mode 100644
index 0000000..2747ac9
--- /dev/null
+++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/SubpackageFactory.java
@@ -0,0 +1,46 @@
+/**
+ * <copyright>
+ * </copyright>
+ *
+ * $Id: SubpackageFactory.java,v 1.1 2008/10/21 07:32:51 jkohnlein Exp $
+ */
+package org.eclipse.xtend.typesystem.emf.check.model.test.subpackage;
+
+import org.eclipse.emf.ecore.EFactory;
+
+/**
+ * <!-- begin-user-doc -->
+ * The <b>Factory</b> for the model.
+ * It provides a create method for each non-abstract class of the model.
+ * <!-- end-user-doc -->
+ * @see org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.SubpackagePackage
+ * @generated
+ */
+public interface SubpackageFactory extends EFactory {
+ /**
+ * The singleton instance of the factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ SubpackageFactory eINSTANCE = org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.impl.SubpackageFactoryImpl.init();
+
+ /**
+ * Returns a new object of class '<em>Meta Class</em>'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return a new object of class '<em>Meta Class</em>'.
+ * @generated
+ */
+ SubpackageMetaClass createSubpackageMetaClass();
+
+ /**
+ * Returns the package supported by this factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the package supported by this factory.
+ * @generated
+ */
+ SubpackagePackage getSubpackagePackage();
+
+} //SubpackageFactory
diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/SubpackageMetaClass.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/SubpackageMetaClass.java
new file mode 100644
index 0000000..b894227
--- /dev/null
+++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/SubpackageMetaClass.java
@@ -0,0 +1,54 @@
+/**
+ * <copyright>
+ * </copyright>
+ *
+ * $Id: SubpackageMetaClass.java,v 1.1 2008/10/21 07:32:51 jkohnlein Exp $
+ */
+package org.eclipse.xtend.typesystem.emf.check.model.test.subpackage;
+
+import org.eclipse.emf.ecore.EObject;
+
+/**
+ * <!-- begin-user-doc -->
+ * A representation of the model object '<em><b>Meta Class</b></em>'.
+ * <!-- end-user-doc -->
+ *
+ * <p>
+ * The following features are supported:
+ * <ul>
+ * <li>{@link org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.SubpackageMetaClass#getName <em>Name</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @see org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.SubpackagePackage#getSubpackageMetaClass()
+ * @model
+ * @generated
+ */
+public interface SubpackageMetaClass extends EObject {
+ /**
+ * Returns the value of the '<em><b>Name</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Name</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Name</em>' attribute.
+ * @see #setName(String)
+ * @see org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.SubpackagePackage#getSubpackageMetaClass_Name()
+ * @model
+ * @generated
+ */
+ String getName();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.SubpackageMetaClass#getName <em>Name</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Name</em>' attribute.
+ * @see #getName()
+ * @generated
+ */
+ void setName(String value);
+
+} // SubpackageMetaClass
diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/SubpackagePackage.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/SubpackagePackage.java
new file mode 100644
index 0000000..89bc346
--- /dev/null
+++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/SubpackagePackage.java
@@ -0,0 +1,153 @@
+/**
+ * <copyright>
+ * </copyright>
+ *
+ * $Id: SubpackagePackage.java,v 1.1 2008/10/21 07:32:51 jkohnlein Exp $
+ */
+package org.eclipse.xtend.typesystem.emf.check.model.test.subpackage;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EPackage;
+
+/**
+ * <!-- begin-user-doc -->
+ * The <b>Package</b> for the model.
+ * It contains accessors for the meta objects to represent
+ * <ul>
+ * <li>each class,</li>
+ * <li>each feature of each class,</li>
+ * <li>each enum,</li>
+ * <li>and each data type</li>
+ * </ul>
+ * <!-- end-user-doc -->
+ * @see org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.SubpackageFactory
+ * @model kind="package"
+ * @generated
+ */
+public interface SubpackagePackage extends EPackage {
+ /**
+ * The package name.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ String eNAME = "subpackage";
+
+ /**
+ * The package namespace URI.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ String eNS_URI = "http://oaw.org/test/subpackage";
+
+ /**
+ * The package namespace name.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ String eNS_PREFIX = "subpackage";
+
+ /**
+ * The singleton instance of the package.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ SubpackagePackage eINSTANCE = org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.impl.SubpackagePackageImpl.init();
+
+ /**
+ * The meta object id for the '{@link org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.impl.SubpackageMetaClassImpl <em>Meta Class</em>}' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.impl.SubpackageMetaClassImpl
+ * @see org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.impl.SubpackagePackageImpl#getSubpackageMetaClass()
+ * @generated
+ */
+ int SUBPACKAGE_META_CLASS = 0;
+
+ /**
+ * The feature id for the '<em><b>Name</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int SUBPACKAGE_META_CLASS__NAME = 0;
+
+ /**
+ * The number of structural features of the '<em>Meta Class</em>' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int SUBPACKAGE_META_CLASS_FEATURE_COUNT = 1;
+
+
+ /**
+ * Returns the meta object for class '{@link org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.SubpackageMetaClass <em>Meta Class</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for class '<em>Meta Class</em>'.
+ * @see org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.SubpackageMetaClass
+ * @generated
+ */
+ EClass getSubpackageMetaClass();
+
+ /**
+ * Returns the meta object for the attribute '{@link org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.SubpackageMetaClass#getName <em>Name</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the attribute '<em>Name</em>'.
+ * @see org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.SubpackageMetaClass#getName()
+ * @see #getSubpackageMetaClass()
+ * @generated
+ */
+ EAttribute getSubpackageMetaClass_Name();
+
+ /**
+ * Returns the factory that creates the instances of the model.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the factory that creates the instances of the model.
+ * @generated
+ */
+ SubpackageFactory getSubpackageFactory();
+
+ /**
+ * <!-- begin-user-doc -->
+ * Defines literals for the meta objects that represent
+ * <ul>
+ * <li>each class,</li>
+ * <li>each feature of each class,</li>
+ * <li>each enum,</li>
+ * <li>and each data type</li>
+ * </ul>
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ interface Literals {
+ /**
+ * The meta object literal for the '{@link org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.impl.SubpackageMetaClassImpl <em>Meta Class</em>}' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.impl.SubpackageMetaClassImpl
+ * @see org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.impl.SubpackagePackageImpl#getSubpackageMetaClass()
+ * @generated
+ */
+ EClass SUBPACKAGE_META_CLASS = eINSTANCE.getSubpackageMetaClass();
+
+ /**
+ * The meta object literal for the '<em><b>Name</b></em>' attribute feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ EAttribute SUBPACKAGE_META_CLASS__NAME = eINSTANCE.getSubpackageMetaClass_Name();
+
+ }
+
+} //SubpackagePackage
diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/impl/SubpackageFactoryImpl.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/impl/SubpackageFactoryImpl.java
new file mode 100644
index 0000000..a38f9e5
--- /dev/null
+++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/impl/SubpackageFactoryImpl.java
@@ -0,0 +1,99 @@
+/**
+ * <copyright>
+ * </copyright>
+ *
+ * $Id: SubpackageFactoryImpl.java,v 1.1 2008/10/21 07:32:51 jkohnlein Exp $
+ */
+package org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.impl;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+
+import org.eclipse.emf.ecore.impl.EFactoryImpl;
+
+import org.eclipse.emf.ecore.plugin.EcorePlugin;
+import org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.*;
+
+
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model <b>Factory</b>.
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class SubpackageFactoryImpl extends EFactoryImpl implements SubpackageFactory {
+ /**
+ * Creates the default factory implementation.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static SubpackageFactory init() {
+ try {
+ SubpackageFactory theSubpackageFactory = (SubpackageFactory)EPackage.Registry.INSTANCE.getEFactory("http://oaw.org/test/subpackage");
+ if (theSubpackageFactory != null) {
+ return theSubpackageFactory;
+ }
+ }
+ catch (Exception exception) {
+ EcorePlugin.INSTANCE.log(exception);
+ }
+ return new SubpackageFactoryImpl();
+ }
+
+ /**
+ * Creates an instance of the factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public SubpackageFactoryImpl() {
+ super();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public EObject create(EClass eClass) {
+ switch (eClass.getClassifierID()) {
+ case SubpackagePackage.SUBPACKAGE_META_CLASS: return createSubpackageMetaClass();
+ default:
+ throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier");
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public SubpackageMetaClass createSubpackageMetaClass() {
+ SubpackageMetaClassImpl subpackageMetaClass = new SubpackageMetaClassImpl();
+ return subpackageMetaClass;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public SubpackagePackage getSubpackagePackage() {
+ return (SubpackagePackage)getEPackage();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @deprecated
+ * @generated
+ */
+ @Deprecated
+ public static SubpackagePackage getPackage() {
+ return SubpackagePackage.eINSTANCE;
+ }
+
+} //SubpackageFactoryImpl
diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/impl/SubpackageMetaClassImpl.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/impl/SubpackageMetaClassImpl.java
new file mode 100644
index 0000000..6e60704
--- /dev/null
+++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/impl/SubpackageMetaClassImpl.java
@@ -0,0 +1,167 @@
+/**
+ * <copyright>
+ * </copyright>
+ *
+ * $Id: SubpackageMetaClassImpl.java,v 1.1 2008/10/21 07:32:51 jkohnlein Exp $
+ */
+package org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.impl;
+
+import org.eclipse.emf.common.notify.Notification;
+
+import org.eclipse.emf.ecore.EClass;
+
+import org.eclipse.emf.ecore.impl.ENotificationImpl;
+import org.eclipse.emf.ecore.impl.EObjectImpl;
+import org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.SubpackageMetaClass;
+import org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.SubpackagePackage;
+
+
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model object '<em><b>Meta Class</b></em>'.
+ * <!-- end-user-doc -->
+ * <p>
+ * The following features are implemented:
+ * <ul>
+ * <li>{@link org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.impl.SubpackageMetaClassImpl#getName <em>Name</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @generated
+ */
+public class SubpackageMetaClassImpl extends EObjectImpl implements SubpackageMetaClass {
+ /**
+ * The default value of the '{@link #getName() <em>Name</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getName()
+ * @generated
+ * @ordered
+ */
+ protected static final String NAME_EDEFAULT = null;
+
+ /**
+ * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getName()
+ * @generated
+ * @ordered
+ */
+ protected String name = NAME_EDEFAULT;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected SubpackageMetaClassImpl() {
+ super();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected EClass eStaticClass() {
+ return SubpackagePackage.Literals.SUBPACKAGE_META_CLASS;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setName(String newName) {
+ String oldName = name;
+ name = newName;
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, SubpackagePackage.SUBPACKAGE_META_CLASS__NAME, oldName, name));
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Object eGet(int featureID, boolean resolve, boolean coreType) {
+ switch (featureID) {
+ case SubpackagePackage.SUBPACKAGE_META_CLASS__NAME:
+ return getName();
+ }
+ return super.eGet(featureID, resolve, coreType);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void eSet(int featureID, Object newValue) {
+ switch (featureID) {
+ case SubpackagePackage.SUBPACKAGE_META_CLASS__NAME:
+ setName((String)newValue);
+ return;
+ }
+ super.eSet(featureID, newValue);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void eUnset(int featureID) {
+ switch (featureID) {
+ case SubpackagePackage.SUBPACKAGE_META_CLASS__NAME:
+ setName(NAME_EDEFAULT);
+ return;
+ }
+ super.eUnset(featureID);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public boolean eIsSet(int featureID) {
+ switch (featureID) {
+ case SubpackagePackage.SUBPACKAGE_META_CLASS__NAME:
+ return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
+ }
+ return super.eIsSet(featureID);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public String toString() {
+ if (eIsProxy()) return super.toString();
+
+ StringBuffer result = new StringBuffer(super.toString());
+ result.append(" (name: ");
+ result.append(name);
+ result.append(')');
+ return result.toString();
+ }
+
+} //SubpackageMetaClassImpl
diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/impl/SubpackagePackageImpl.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/impl/SubpackagePackageImpl.java
new file mode 100644
index 0000000..d8d47bd
--- /dev/null
+++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/impl/SubpackagePackageImpl.java
@@ -0,0 +1,194 @@
+/**
+ * <copyright>
+ * </copyright>
+ *
+ * $Id: SubpackagePackageImpl.java,v 1.1 2008/10/21 07:32:51 jkohnlein Exp $
+ */
+package org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.impl;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EPackage;
+
+import org.eclipse.emf.ecore.impl.EPackageImpl;
+import org.eclipse.xtend.typesystem.emf.check.model.test.TestPackage;
+import org.eclipse.xtend.typesystem.emf.check.model.test.impl.TestPackageImpl;
+import org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.SubpackageFactory;
+import org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.SubpackageMetaClass;
+import org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.SubpackagePackage;
+
+
+
+
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model <b>Package</b>.
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class SubpackagePackageImpl extends EPackageImpl implements SubpackagePackage {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private EClass subpackageMetaClassEClass = null;
+
+ /**
+ * Creates an instance of the model <b>Package</b>, registered with
+ * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package
+ * package URI value.
+ * <p>Note: the correct way to create the package is via the static
+ * factory method {@link #init init()}, which also performs
+ * initialization of the package, or returns the registered package,
+ * if one already exists.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see org.eclipse.emf.ecore.EPackage.Registry
+ * @see org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.SubpackagePackage#eNS_URI
+ * @see #init()
+ * @generated
+ */
+ private SubpackagePackageImpl() {
+ super(eNS_URI, SubpackageFactory.eINSTANCE);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private static boolean isInited = false;
+
+ /**
+ * Creates, registers, and initializes the <b>Package</b> for this
+ * model, and for any others upon which it depends. Simple
+ * dependencies are satisfied by calling this method on all
+ * dependent packages before doing anything else. This method drives
+ * initialization for interdependent packages directly, in parallel
+ * with this package, itself.
+ * <p>Of this package and its interdependencies, all packages which
+ * have not yet been registered by their URI values are first created
+ * and registered. The packages are then initialized in two steps:
+ * meta-model objects for all of the packages are created before any
+ * are initialized, since one package's meta-model objects may refer to
+ * those of another.
+ * <p>Invocation of this method will not affect any packages that have
+ * already been initialized.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #eNS_URI
+ * @see #createPackageContents()
+ * @see #initializePackageContents()
+ * @generated
+ */
+ public static SubpackagePackage init() {
+ if (isInited) return (SubpackagePackage)EPackage.Registry.INSTANCE.getEPackage(SubpackagePackage.eNS_URI);
+
+ // Obtain or create and register package
+ SubpackagePackageImpl theSubpackagePackage = (SubpackagePackageImpl)(EPackage.Registry.INSTANCE.getEPackage(eNS_URI) instanceof SubpackagePackageImpl ? EPackage.Registry.INSTANCE.getEPackage(eNS_URI) : new SubpackagePackageImpl());
+
+ isInited = true;
+
+ // Obtain or create and register interdependencies
+ TestPackageImpl theTestPackage = (TestPackageImpl)(EPackage.Registry.INSTANCE.getEPackage(TestPackage.eNS_URI) instanceof TestPackageImpl ? EPackage.Registry.INSTANCE.getEPackage(TestPackage.eNS_URI) : TestPackage.eINSTANCE);
+
+ // Create package meta-data objects
+ theSubpackagePackage.createPackageContents();
+ theTestPackage.createPackageContents();
+
+ // Initialize created meta-data
+ theSubpackagePackage.initializePackageContents();
+ theTestPackage.initializePackageContents();
+
+ // Mark meta-data to indicate it can't be changed
+ theSubpackagePackage.freeze();
+
+ return theSubpackagePackage;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EClass getSubpackageMetaClass() {
+ return subpackageMetaClassEClass;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EAttribute getSubpackageMetaClass_Name() {
+ return (EAttribute)subpackageMetaClassEClass.getEStructuralFeatures().get(0);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public SubpackageFactory getSubpackageFactory() {
+ return (SubpackageFactory)getEFactoryInstance();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private boolean isCreated = false;
+
+ /**
+ * Creates the meta-model objects for the package. This method is
+ * guarded to have no affect on any invocation but its first.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void createPackageContents() {
+ if (isCreated) return;
+ isCreated = true;
+
+ // Create classes and their features
+ subpackageMetaClassEClass = createEClass(SUBPACKAGE_META_CLASS);
+ createEAttribute(subpackageMetaClassEClass, SUBPACKAGE_META_CLASS__NAME);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private boolean isInitialized = false;
+
+ /**
+ * Complete the initialization of the package and its meta-model. This
+ * method is guarded to have no affect on any invocation but its first.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void initializePackageContents() {
+ if (isInitialized) return;
+ isInitialized = true;
+
+ // Initialize package
+ setName(eNAME);
+ setNsPrefix(eNS_PREFIX);
+ setNsURI(eNS_URI);
+
+ // Create type parameters
+
+ // Set bounds for type parameters
+
+ // Add supertypes to classes
+
+ // Initialize classes and features; add operations and parameters
+ initEClass(subpackageMetaClassEClass, SubpackageMetaClass.class, "SubpackageMetaClass", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
+ initEAttribute(getSubpackageMetaClass_Name(), ecorePackage.getEString(), "name", null, 0, 1, SubpackageMetaClass.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ }
+
+} //SubpackagePackageImpl
diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/util/SubpackageAdapterFactory.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/util/SubpackageAdapterFactory.java
new file mode 100644
index 0000000..0d1e1ca
--- /dev/null
+++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/util/SubpackageAdapterFactory.java
@@ -0,0 +1,124 @@
+/**
+ * <copyright>
+ * </copyright>
+ *
+ * $Id: SubpackageAdapterFactory.java,v 1.1 2008/10/21 07:32:51 jkohnlein Exp $
+ */
+package org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.util;
+
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notifier;
+
+import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.*;
+
+
+/**
+ * <!-- begin-user-doc -->
+ * The <b>Adapter Factory</b> for the model.
+ * It provides an adapter <code>createXXX</code> method for each class of the model.
+ * <!-- end-user-doc -->
+ * @see org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.SubpackagePackage
+ * @generated
+ */
+public class SubpackageAdapterFactory extends AdapterFactoryImpl {
+ /**
+ * The cached model package.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected static SubpackagePackage modelPackage;
+
+ /**
+ * Creates an instance of the adapter factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public SubpackageAdapterFactory() {
+ if (modelPackage == null) {
+ modelPackage = SubpackagePackage.eINSTANCE;
+ }
+ }
+
+ /**
+ * Returns whether this factory is applicable for the type of the object.
+ * <!-- begin-user-doc -->
+ * This implementation returns <code>true</code> if the object is either the model's package or is an instance object of the model.
+ * <!-- end-user-doc -->
+ * @return whether this factory is applicable for the type of the object.
+ * @generated
+ */
+ @Override
+ public boolean isFactoryForType(Object object) {
+ if (object == modelPackage) {
+ return true;
+ }
+ if (object instanceof EObject) {
+ return ((EObject)object).eClass().getEPackage() == modelPackage;
+ }
+ return false;
+ }
+
+ /**
+ * The switch that delegates to the <code>createXXX</code> methods.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected SubpackageSwitch<Adapter> modelSwitch =
+ new SubpackageSwitch<Adapter>() {
+ @Override
+ public Adapter caseSubpackageMetaClass(SubpackageMetaClass object) {
+ return createSubpackageMetaClassAdapter();
+ }
+ @Override
+ public Adapter defaultCase(EObject object) {
+ return createEObjectAdapter();
+ }
+ };
+
+ /**
+ * Creates an adapter for the <code>target</code>.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param target the object to adapt.
+ * @return the adapter for the <code>target</code>.
+ * @generated
+ */
+ @Override
+ public Adapter createAdapter(Notifier target) {
+ return modelSwitch.doSwitch((EObject)target);
+ }
+
+
+ /**
+ * Creates a new adapter for an object of class '{@link org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.SubpackageMetaClass <em>Meta Class</em>}'.
+ * <!-- begin-user-doc -->
+ * This default implementation returns null so that we can easily ignore cases;
+ * it's useful to ignore a case when inheritance will catch all the cases anyway.
+ * <!-- end-user-doc -->
+ * @return the new adapter.
+ * @see org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.SubpackageMetaClass
+ * @generated
+ */
+ public Adapter createSubpackageMetaClassAdapter() {
+ return null;
+ }
+
+ /**
+ * Creates a new adapter for the default case.
+ * <!-- begin-user-doc -->
+ * This default implementation returns null.
+ * <!-- end-user-doc -->
+ * @return the new adapter.
+ * @generated
+ */
+ public Adapter createEObjectAdapter() {
+ return null;
+ }
+
+} //SubpackageAdapterFactory
diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/util/SubpackageSwitch.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/util/SubpackageSwitch.java
new file mode 100644
index 0000000..322b679
--- /dev/null
+++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/util/SubpackageSwitch.java
@@ -0,0 +1,130 @@
+/**
+ * <copyright>
+ * </copyright>
+ *
+ * $Id: SubpackageSwitch.java,v 1.1 2008/10/21 07:32:51 jkohnlein Exp $
+ */
+package org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.util;
+
+import java.util.List;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.*;
+
+
+/**
+ * <!-- begin-user-doc -->
+ * The <b>Switch</b> for the model's inheritance hierarchy.
+ * It supports the call {@link #doSwitch(EObject) doSwitch(object)}
+ * to invoke the <code>caseXXX</code> method for each class of the model,
+ * starting with the actual class of the object
+ * and proceeding up the inheritance hierarchy
+ * until a non-null result is returned,
+ * which is the result of the switch.
+ * <!-- end-user-doc -->
+ * @see org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.SubpackagePackage
+ * @generated
+ */
+public class SubpackageSwitch<T> {
+ /**
+ * The cached model package
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected static SubpackagePackage modelPackage;
+
+ /**
+ * Creates an instance of the switch.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public SubpackageSwitch() {
+ if (modelPackage == null) {
+ modelPackage = SubpackagePackage.eINSTANCE;
+ }
+ }
+
+ /**
+ * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the first non-null result returned by a <code>caseXXX</code> call.
+ * @generated
+ */
+ public T doSwitch(EObject theEObject) {
+ return doSwitch(theEObject.eClass(), theEObject);
+ }
+
+ /**
+ * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the first non-null result returned by a <code>caseXXX</code> call.
+ * @generated
+ */
+ protected T doSwitch(EClass theEClass, EObject theEObject) {
+ if (theEClass.eContainer() == modelPackage) {
+ return doSwitch(theEClass.getClassifierID(), theEObject);
+ }
+ else {
+ List<EClass> eSuperTypes = theEClass.getESuperTypes();
+ return
+ eSuperTypes.isEmpty() ?
+ defaultCase(theEObject) :
+ doSwitch(eSuperTypes.get(0), theEObject);
+ }
+ }
+
+ /**
+ * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the first non-null result returned by a <code>caseXXX</code> call.
+ * @generated
+ */
+ protected T doSwitch(int classifierID, EObject theEObject) {
+ switch (classifierID) {
+ case SubpackagePackage.SUBPACKAGE_META_CLASS: {
+ SubpackageMetaClass subpackageMetaClass = (SubpackageMetaClass)theEObject;
+ T result = caseSubpackageMetaClass(subpackageMetaClass);
+ if (result == null) result = defaultCase(theEObject);
+ return result;
+ }
+ default: return defaultCase(theEObject);
+ }
+ }
+
+ /**
+ * Returns the result of interpreting the object as an instance of '<em>Meta Class</em>'.
+ * <!-- begin-user-doc -->
+ * This implementation returns null;
+ * returning a non-null result will terminate the switch.
+ * <!-- end-user-doc -->
+ * @param object the target of the switch.
+ * @return the result of interpreting the object as an instance of '<em>Meta Class</em>'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
+ * @generated
+ */
+ public T caseSubpackageMetaClass(SubpackageMetaClass object) {
+ return null;
+ }
+
+ /**
+ * Returns the result of interpreting the object as an instance of '<em>EObject</em>'.
+ * <!-- begin-user-doc -->
+ * This implementation returns null;
+ * returning a non-null result will terminate the switch, but this is the last case anyway.
+ * <!-- end-user-doc -->
+ * @param object the target of the switch.
+ * @return the result of interpreting the object as an instance of '<em>EObject</em>'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject)
+ * @generated
+ */
+ public T defaultCase(EObject object) {
+ return null;
+ }
+
+} //SubpackageSwitch
diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/util/TestAdapterFactory.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/util/TestAdapterFactory.java
new file mode 100644
index 0000000..3f5226f
--- /dev/null
+++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/util/TestAdapterFactory.java
@@ -0,0 +1,124 @@
+/**
+ * <copyright>
+ * </copyright>
+ *
+ * $Id: TestAdapterFactory.java,v 1.1 2008/10/21 07:32:51 jkohnlein Exp $
+ */
+package org.eclipse.xtend.typesystem.emf.check.model.test.util;
+
+
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notifier;
+
+import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.xtend.typesystem.emf.check.model.test.*;
+
+/**
+ * <!-- begin-user-doc -->
+ * The <b>Adapter Factory</b> for the model.
+ * It provides an adapter <code>createXXX</code> method for each class of the model.
+ * <!-- end-user-doc -->
+ * @see org.eclipse.xtend.typesystem.emf.check.model.test.TestPackage
+ * @generated
+ */
+public class TestAdapterFactory extends AdapterFactoryImpl {
+ /**
+ * The cached model package.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected static TestPackage modelPackage;
+
+ /**
+ * Creates an instance of the adapter factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public TestAdapterFactory() {
+ if (modelPackage == null) {
+ modelPackage = TestPackage.eINSTANCE;
+ }
+ }
+
+ /**
+ * Returns whether this factory is applicable for the type of the object.
+ * <!-- begin-user-doc -->
+ * This implementation returns <code>true</code> if the object is either the model's package or is an instance object of the model.
+ * <!-- end-user-doc -->
+ * @return whether this factory is applicable for the type of the object.
+ * @generated
+ */
+ @Override
+ public boolean isFactoryForType(Object object) {
+ if (object == modelPackage) {
+ return true;
+ }
+ if (object instanceof EObject) {
+ return ((EObject)object).eClass().getEPackage() == modelPackage;
+ }
+ return false;
+ }
+
+ /**
+ * The switch that delegates to the <code>createXXX</code> methods.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected TestSwitch<Adapter> modelSwitch =
+ new TestSwitch<Adapter>() {
+ @Override
+ public Adapter caseMyMetaClass(MyMetaClass object) {
+ return createMyMetaClassAdapter();
+ }
+ @Override
+ public Adapter defaultCase(EObject object) {
+ return createEObjectAdapter();
+ }
+ };
+
+ /**
+ * Creates an adapter for the <code>target</code>.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param target the object to adapt.
+ * @return the adapter for the <code>target</code>.
+ * @generated
+ */
+ @Override
+ public Adapter createAdapter(Notifier target) {
+ return modelSwitch.doSwitch((EObject)target);
+ }
+
+
+ /**
+ * Creates a new adapter for an object of class '{@link org.eclipse.xtend.typesystem.emf.check.model.test.MyMetaClass <em>My Meta Class</em>}'.
+ * <!-- begin-user-doc -->
+ * This default implementation returns null so that we can easily ignore cases;
+ * it's useful to ignore a case when inheritance will catch all the cases anyway.
+ * <!-- end-user-doc -->
+ * @return the new adapter.
+ * @see org.eclipse.xtend.typesystem.emf.check.model.test.MyMetaClass
+ * @generated
+ */
+ public Adapter createMyMetaClassAdapter() {
+ return null;
+ }
+
+ /**
+ * Creates a new adapter for the default case.
+ * <!-- begin-user-doc -->
+ * This default implementation returns null.
+ * <!-- end-user-doc -->
+ * @return the new adapter.
+ * @generated
+ */
+ public Adapter createEObjectAdapter() {
+ return null;
+ }
+
+} //TestAdapterFactory
diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/util/TestSwitch.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/util/TestSwitch.java
new file mode 100644
index 0000000..44baae9
--- /dev/null
+++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/util/TestSwitch.java
@@ -0,0 +1,130 @@
+/**
+ * <copyright>
+ * </copyright>
+ *
+ * $Id: TestSwitch.java,v 1.1 2008/10/21 07:32:51 jkohnlein Exp $
+ */
+package org.eclipse.xtend.typesystem.emf.check.model.test.util;
+
+
+import java.util.List;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.xtend.typesystem.emf.check.model.test.*;
+
+/**
+ * <!-- begin-user-doc -->
+ * The <b>Switch</b> for the model's inheritance hierarchy.
+ * It supports the call {@link #doSwitch(EObject) doSwitch(object)}
+ * to invoke the <code>caseXXX</code> method for each class of the model,
+ * starting with the actual class of the object
+ * and proceeding up the inheritance hierarchy
+ * until a non-null result is returned,
+ * which is the result of the switch.
+ * <!-- end-user-doc -->
+ * @see org.eclipse.xtend.typesystem.emf.check.model.test.TestPackage
+ * @generated
+ */
+public class TestSwitch<T> {
+ /**
+ * The cached model package
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected static TestPackage modelPackage;
+
+ /**
+ * Creates an instance of the switch.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public TestSwitch() {
+ if (modelPackage == null) {
+ modelPackage = TestPackage.eINSTANCE;
+ }
+ }
+
+ /**
+ * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the first non-null result returned by a <code>caseXXX</code> call.
+ * @generated
+ */
+ public T doSwitch(EObject theEObject) {
+ return doSwitch(theEObject.eClass(), theEObject);
+ }
+
+ /**
+ * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the first non-null result returned by a <code>caseXXX</code> call.
+ * @generated
+ */
+ protected T doSwitch(EClass theEClass, EObject theEObject) {
+ if (theEClass.eContainer() == modelPackage) {
+ return doSwitch(theEClass.getClassifierID(), theEObject);
+ }
+ else {
+ List<EClass> eSuperTypes = theEClass.getESuperTypes();
+ return
+ eSuperTypes.isEmpty() ?
+ defaultCase(theEObject) :
+ doSwitch(eSuperTypes.get(0), theEObject);
+ }
+ }
+
+ /**
+ * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the first non-null result returned by a <code>caseXXX</code> call.
+ * @generated
+ */
+ protected T doSwitch(int classifierID, EObject theEObject) {
+ switch (classifierID) {
+ case TestPackage.MY_META_CLASS: {
+ MyMetaClass myMetaClass = (MyMetaClass)theEObject;
+ T result = caseMyMetaClass(myMetaClass);
+ if (result == null) result = defaultCase(theEObject);
+ return result;
+ }
+ default: return defaultCase(theEObject);
+ }
+ }
+
+ /**
+ * Returns the result of interpreting the object as an instance of '<em>My Meta Class</em>'.
+ * <!-- begin-user-doc -->
+ * This implementation returns null;
+ * returning a non-null result will terminate the switch.
+ * <!-- end-user-doc -->
+ * @param object the target of the switch.
+ * @return the result of interpreting the object as an instance of '<em>My Meta Class</em>'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
+ * @generated
+ */
+ public T caseMyMetaClass(MyMetaClass object) {
+ return null;
+ }
+
+ /**
+ * Returns the result of interpreting the object as an instance of '<em>EObject</em>'.
+ * <!-- begin-user-doc -->
+ * This implementation returns null;
+ * returning a non-null result will terminate the switch, but this is the last case anyway.
+ * <!-- end-user-doc -->
+ * @param object the target of the switch.
+ * @return the result of interpreting the object as an instance of '<em>EObject</em>'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject)
+ * @generated
+ */
+ public T defaultCase(EObject object) {
+ return null;
+ }
+
+} //TestSwitch
diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/validation/MyMetaClassValidator.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/validation/MyMetaClassValidator.java
new file mode 100644
index 0000000..ec5cc63
--- /dev/null
+++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/validation/MyMetaClassValidator.java
@@ -0,0 +1,24 @@
+/**
+ * <copyright>
+ * </copyright>
+ *
+ * $Id: MyMetaClassValidator.java,v 1.1 2008/10/21 07:32:51 jkohnlein Exp $
+ */
+package org.eclipse.xtend.typesystem.emf.check.model.test.validation;
+
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.xtend.typesystem.emf.check.model.test.MyMetaClass;
+
+/**
+ * A sample validator interface for {@link org.eclipse.xtend.typesystem.emf.check.model.test.MyMetaClass}.
+ * This doesn't really do anything, and it's not a real EMF artifact.
+ * It was generated by the org.eclipse.emf.examples.generator.validator plug-in to illustrate how EMF's code generator can be extended.
+ * This can be disabled with -vmargs -Dorg.eclipse.emf.examples.generator.validator=false.
+ */
+public interface MyMetaClassValidator {
+ boolean validate();
+
+ boolean validateName(String value);
+ boolean validateChildren(EList<MyMetaClass> value);
+}
diff --git a/plugins/org.eclipse.xtend.typesystem.emf/META-INF/MANIFEST.MF b/plugins/org.eclipse.xtend.typesystem.emf/META-INF/MANIFEST.MF
index f1ea828..860fc5e 100644
--- a/plugins/org.eclipse.xtend.typesystem.emf/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.xtend.typesystem.emf/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName (Incubation)
-Bundle-SymbolicName: org.eclipse.xtend.typesystem.emf
+Bundle-SymbolicName: org.eclipse.xtend.typesystem.emf;singleton:=true
Bundle-Version: 0.7.0.qualifier
Bundle-Localization: plugin
Bundle-Vendor: %providerName
@@ -9,6 +9,10 @@ Require-Bundle: org.eclipse.xtend,
org.eclipse.emf.ecore.xmi,
org.apache.commons.logging,
org.eclipse.emf.mwe.core,
- org.eclipse.emf.mwe.utils
-Export-Package: org.eclipse.xtend.typesystem.emf
+ org.eclipse.emf.mwe.utils,
+ org.eclipse.core.runtime;bundle-version="3.4.0";resolution:=optional
+Export-Package: org.eclipse.xtend.typesystem.emf,
+ org.eclipse.xtend.typesystem.emf.check
Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-ActivationPolicy: lazy
+Bundle-Activator: org.eclipse.xtend.typesystem.internal.emf.XtendTypesytemEmfPlugin
diff --git a/plugins/org.eclipse.xtend.typesystem.emf/plugin.xml b/plugins/org.eclipse.xtend.typesystem.emf/plugin.xml
new file mode 100644
index 0000000..156d44f
--- /dev/null
+++ b/plugins/org.eclipse.xtend.typesystem.emf/plugin.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension-point id="checks" name="Checks" schema="schema/checks.exsd"/>
+
+</plugin>
diff --git a/plugins/org.eclipse.xtend.typesystem.emf/schema/checks.exsd b/plugins/org.eclipse.xtend.typesystem.emf/schema/checks.exsd
new file mode 100644
index 0000000..a878508
--- /dev/null
+++ b/plugins/org.eclipse.xtend.typesystem.emf/schema/checks.exsd
@@ -0,0 +1,158 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.xtend.typesystem.emf" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.xtend.typesystem.emf" id="checks" name="Checks"/>
+ </appinfo>
+ <documentation>
+ This extension point is used to register EValidators that execute Check files to validate Ecore models (EPackages). Having registered a Check file on an Ecore model, instances of that meta-model can be validated using the common EMF-API:
+
+&lt;pre&gt;
+org.eclipse.emf.ecore.util.Diagnstician.INSTANCE.validate(rootModelObject)
+&lt;/pre&gt;
+
+Already registered EValidators are nested by default. If you disable nesting make sure all other defining plug-ins are initialized before the overriding plug-in is started.
+
+To enable this extension point, make sure the plug-in is loaded, e.g. by calling &lt;code&gt;Activator.getDefault()&lt;/code&gt; explicitly. Otherwise the extensions will not be parsed and no EValidator will be registered.
+
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="metaModel" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="metaModel">
+ <annotation>
+ <appinfo>
+ <meta.element labelAttribute="nsURI"/>
+ </appinfo>
+ <documentation>
+ The Ecore model (EPackage) to be checked.
+ </documentation>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <element ref="checkFile"/>
+ </sequence>
+ <attribute name="nsURI" type="string" use="required">
+ <annotation>
+ <documentation>
+ The namespace URI of the EPackage that should be checked. The EPackage must be registered to the global EPackage.Registry using the extension point &lt;code&gt;org.eclipse.emf.ecore.generated_package&lt;/code&gt;.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="override" type="boolean">
+ <annotation>
+ <documentation>
+ If &lt;code&gt;true&lt;/code&gt;, already registered EValidators are replaced. Otherwise, they are nested.
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="checkFile">
+ <annotation>
+ <documentation>
+ The openArchitectureWare Check file.
+ </documentation>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="0" maxOccurs="unbounded">
+ <element ref="referencedMetaModel"/>
+ </sequence>
+ <attribute name="path" type="string" use="required">
+ <annotation>
+ <documentation>
+ The plug-in relative path of the check file. The extension &lt;code&gt;.chk&lt;/code&gt; can be omitted. The openArchitectureWare specific namespace delimiter &lt;code&gt;::&lt;/code&gt; can be used.
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="referencedMetaModel">
+ <annotation>
+ <appinfo>
+ <meta.element labelAttribute="nsURI"/>
+ </appinfo>
+ </annotation>
+ <complexType>
+ <attribute name="nsURI" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+
+ <annotation>
+ <appinfo>
+ <meta.section type="examples"/>
+ </appinfo>
+ <documentation>
+ &lt;pre&gt;
+&lt;extension point=&quot;org.eclipse.xtend.typesystem.emf.checks&quot;&gt;
+ &lt;metaModel nsURI=&quot;http://www.myproject.org/my/metamodel/nsURI&quot;&gt;
+ &lt;checkFile path=&quot;some/java/package/location/check.chk&quot;/&gt;
+ &lt;/metaModel&gt;
+&lt;/extension&gt;
+&lt;/pre&gt;
+ </documentation>
+ </annotation>
+
+
+
+ <annotation>
+ <appinfo>
+ <meta.section type="copyright"/>
+ </appinfo>
+ <documentation>
+ Copyright (c) 2008 itemis AG and others.
+
+All rights reserved. This program and the accompanying materials
+are made available under the terms of the Eclipse Public License v1.0
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/epl-v10.html
+
+Contributors:
+koehnlein, huebner - initial API and implementation
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/check/CheckEValidatorAdapter.java b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/check/CheckEValidatorAdapter.java
new file mode 100644
index 0000000..da6dff0
--- /dev/null
+++ b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/check/CheckEValidatorAdapter.java
@@ -0,0 +1,190 @@
+/*******************************************************************************
+ * <copyright>
+ * Copyright (c) 2008 itemis AG and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * committers of openArchitectureWare - initial API and implementation
+ * </copyright>
+ *******************************************************************************/
+package org.eclipse.xtend.typesystem.emf.check;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.eclipse.emf.common.util.DiagnosticChain;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EValidator;
+import org.eclipse.emf.mwe.core.issues.Issues;
+import org.eclipse.emf.mwe.core.issues.IssuesImpl;
+import org.eclipse.emf.mwe.core.issues.MWEDiagnostic;
+import org.eclipse.internal.xtend.xtend.ast.ExtensionFile;
+import org.eclipse.xtend.check.CheckUtils;
+import org.eclipse.xtend.expression.ExecutionContext;
+import org.eclipse.xtend.expression.ExecutionContextImpl;
+import org.eclipse.xtend.expression.ResourceManager;
+import org.eclipse.xtend.expression.ResourceManagerDefaultImpl;
+import org.eclipse.xtend.expression.TypeSystemImpl;
+import org.eclipse.xtend.typesystem.emf.EmfMetaModel;
+
+/**
+ * An implementation of {@link org.eclipse.emf.ecore.EValidator} that executes
+ * oAW checks. Further EValidators can be nested.
+ *
+ * Check files can be added with reparse option. If true, the check files are
+ * reparse on each validation.
+ *
+ * @author Jan Köhnlein
+ */
+public class CheckEValidatorAdapter implements EValidator {
+
+ private final Log log = LogFactory.getLog(CheckEValidatorAdapter.class);
+
+ private List<CheckFileWithContext> _checkFiles;
+
+ private EValidator _nestedValidator;
+
+ private EPackage _ePackage;
+
+ private ResourceManager _externalResourceManager;
+
+ public CheckEValidatorAdapter(EPackage ePackage) {
+ _ePackage = ePackage;
+ _checkFiles = new ArrayList<CheckFileWithContext>();
+ }
+
+ public CheckEValidatorAdapter(EPackage ePackage,
+ EValidator existingValidator) {
+ this(ePackage);
+ if (existingValidator != null) {
+ _nestedValidator = existingValidator;
+ }
+ }
+
+ public void addCheckFile(CheckFileWithContext checkFile) {
+ _checkFiles.add(checkFile);
+ }
+
+ public boolean validate(EObject eObject, DiagnosticChain diagnostics,
+ Map<Object, Object> context) {
+ return validate(eObject.eClass(), eObject, diagnostics, context);
+ }
+
+ public boolean validate(EClass eClass, EObject eObject,
+ DiagnosticChain diagnostics, Map<Object, Object> context) {
+ List<EObject> allElements = Collections.singletonList(eObject);
+ boolean isValid = runOawCheck(diagnostics, allElements);
+ if (_nestedValidator != null) {
+ isValid &= _nestedValidator.validate(eClass, eObject, diagnostics,
+ context);
+ }
+ return isValid;
+ }
+
+ public boolean validate(EDataType dataType, Object value,
+ DiagnosticChain diagnostics, Map<Object, Object> context) {
+ List<?> allElements = Collections.singletonList(dataType);
+ boolean isValid = runOawCheck(diagnostics, allElements);
+ if (_nestedValidator != null) {
+ isValid &= _nestedValidator.validate(dataType, value, diagnostics,
+ context);
+ }
+ return isValid;
+ }
+
+
+ public void setExternalResourceManager(ResourceManager externalResourceManager) {
+ _externalResourceManager = externalResourceManager;
+ }
+
+ private ResourceManager getResourceManager() {
+ if(_externalResourceManager != null) {
+ return _externalResourceManager;
+ }
+ return new ResourceManagerDefaultImpl();
+ }
+
+ private ExecutionContext createExecutionContext(
+ CheckFileWithContext checkFile, ResourceManager resourceManager) {
+ final Set<EPackage> allEPackages = new HashSet<EPackage>();
+ allEPackages.add(_ePackage);
+ for (String nsURI : checkFile.getImportedEPackageNsUris()) {
+ try {
+ EPackage importedEPackage = EPackage.Registry.INSTANCE
+ .getEPackage(nsURI);
+ if (importedEPackage != null) {
+ allEPackages.add(importedEPackage);
+ }
+ } catch (Exception exc) {
+ log.error(exc);
+ }
+ }
+ TypeSystemImpl typeSystem = new TypeSystemImpl();
+ typeSystem.registerMetaModel(new EmfMetaModel() {
+ private EPackage[] _allEPackages = allEPackages
+ .toArray(new EPackage[allEPackages.size()]);
+
+ @Override
+ protected EPackage[] allPackages() {
+ return _allEPackages;
+ }
+ });
+ ExecutionContext executionContext = new ExecutionContextImpl(
+ resourceManager, typeSystem, null);
+ return executionContext;
+ }
+
+ private boolean runOawCheck(DiagnosticChain diagnostics, List<?> allElements) {
+ boolean isValid = true;
+ for (CheckFileWithContext checkFile : _checkFiles) {
+ Issues issues = new IssuesImpl();
+ ResourceManager resourceManager = getResourceManager();
+ ExtensionFile parsedCheckFile = (ExtensionFile) resourceManager
+ .loadResource(checkFile.getFileName(),
+ CheckUtils.FILE_EXTENSION);
+ ExecutionContext executionContext = createExecutionContext(checkFile, resourceManager);
+ runOawCheck(parsedCheckFile, allElements, diagnostics,
+ executionContext);
+ isValid &= issues.hasErrors();
+ }
+ return isValid;
+ }
+
+ private Issues runOawCheck(ExtensionFile parsedCheckFile,
+ List<?> allElements, DiagnosticChain diagnostics,
+ ExecutionContext executionContext) {
+ Issues issues = new IssuesImpl();
+ parsedCheckFile.check(executionContext, allElements, issues, false);
+ addDiagnosticFromIssues(diagnostics, issues);
+ return issues;
+ }
+
+ private void addDiagnosticFromIssues(
+ DiagnosticChain allDiagnostics, Issues issues) {
+ MWEDiagnostic[] errors = issues.getErrors();
+ addDiagnostics(allDiagnostics, errors);
+
+ MWEDiagnostic[] warnings = issues.getWarnings();
+ addDiagnostics(allDiagnostics, warnings);
+ }
+
+ private void addDiagnostics(DiagnosticChain allDiagnostics,
+ MWEDiagnostic[] issues) {
+ for (MWEDiagnostic issue : issues) {
+ allDiagnostics.add(issue);
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/check/CheckFileWithContext.java b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/check/CheckFileWithContext.java
new file mode 100644
index 0000000..6868c7b
--- /dev/null
+++ b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/check/CheckFileWithContext.java
@@ -0,0 +1,37 @@
+package org.eclipse.xtend.typesystem.emf.check;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.xtend.check.CheckUtils;
+
+
+public class CheckFileWithContext {
+
+ private String fileName;
+
+ private List<String> importedEPackageNsUris = new ArrayList<String>();
+
+ public CheckFileWithContext(String checkFileName) {
+ this.fileName = normalizeFileName(checkFileName);
+ }
+
+ public String getFileName() {
+ return fileName;
+ }
+
+ public List<String> getImportedEPackageNsUris() {
+ return importedEPackageNsUris;
+ }
+
+ public void addImportedEPackageNsUri(String importedEPackageNsUri) {
+ importedEPackageNsUris.add(importedEPackageNsUri);
+ }
+
+ private String normalizeFileName(String checkFileName) {
+ if(checkFileName.toLowerCase().endsWith(CheckUtils.FILE_EXTENSION)) {
+ checkFileName = checkFileName.substring(0, checkFileName.length() - CheckUtils.FILE_EXTENSION.length() - 1);
+ }
+ return checkFileName;
+ }
+}
diff --git a/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/check/CheckRegistry.java b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/check/CheckRegistry.java
new file mode 100644
index 0000000..5b7df95
--- /dev/null
+++ b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/check/CheckRegistry.java
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * <copyright>
+ * Copyright (c) 2008 itemis AG and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * committers of openArchitectureWare - initial API and implementation
+ * </copyright>
+ *******************************************************************************/
+
+package org.eclipse.xtend.typesystem.emf.check;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EValidator;
+import org.eclipse.xtend.typesystem.internal.emf.XtendTypesytemEmfPlugin;
+
+/**
+ * Reads checks extensions, instantiates validators and registers them.
+ *
+ * @author Jan Köhnlein
+ */
+public class CheckRegistry {
+
+ private final Log log = LogFactory.getLog(getClass());
+
+ private static final String EXTENSION_POINT_ID = XtendTypesytemEmfPlugin.PLUGIN_ID + ".checks";
+ private static final String NS_URI_ATTR_ID = "nsURI";
+ private static final String CHECK_FILE_ATTR_ID = "checkFile";
+ private static final String CHECK_FILE_PATH_ATTR_ID = "path";
+ private static final String OVERRIDE_ATTR_ID = "override";
+ private static final String REFERENCED_META_MODEL = "referencedMetaModel";
+
+ private static CheckRegistry INSTANCE;
+
+ private CheckRegistry() {
+ registerExtensions();
+ }
+
+ public static CheckRegistry getInstance() {
+ if (INSTANCE == null) {
+ INSTANCE = new CheckRegistry();
+ }
+ return INSTANCE;
+ }
+
+ private void registerExtensions() {
+ try {
+ IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
+ IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint(EXTENSION_POINT_ID);
+ IConfigurationElement[] metaModels = extensionPoint.getConfigurationElements();
+ for (IConfigurationElement metaModel : metaModels) {
+ try {
+ String nsURI = metaModel.getAttribute(NS_URI_ATTR_ID);
+ EPackage ePackage = findEPackage(nsURI);
+ String override = metaModel.getAttribute(OVERRIDE_ATTR_ID);
+ CheckEValidatorAdapter oawValidator;
+ if ("true".equals(override)) {
+ oawValidator = new CheckEValidatorAdapter(ePackage);
+ }
+ else {
+ EValidator validator = EValidator.Registry.INSTANCE.getEValidator(ePackage);
+ if (validator instanceof CheckEValidatorAdapter)
+ oawValidator = (CheckEValidatorAdapter) validator;
+ else
+ oawValidator = new CheckEValidatorAdapter(ePackage, validator);
+ }
+ IConfigurationElement[] checkFiles = metaModel.getChildren(CHECK_FILE_ATTR_ID);
+ for (IConfigurationElement checkFile : checkFiles) {
+ try {
+ String checkFileName = checkFile.getAttribute(CHECK_FILE_PATH_ATTR_ID);
+ CheckFileWithContext registeredCheckFile = new CheckFileWithContext(checkFileName);
+ for (IConfigurationElement referencedMetaModel : checkFile
+ .getChildren(REFERENCED_META_MODEL)) {
+ String refNsURI = referencedMetaModel.getAttribute(NS_URI_ATTR_ID);
+ registeredCheckFile.addImportedEPackageNsUri(refNsURI);
+ }
+ oawValidator.addCheckFile(registeredCheckFile);
+ }
+ catch (Exception exc) {
+ log.error(exc);
+ }
+ }
+ EValidator.Registry.INSTANCE.put(ePackage, oawValidator);
+ }
+ catch (Exception exc) {
+ log.error(exc);
+ }
+ }
+ }
+ catch (Exception exc) {
+ log.error(exc);
+ }
+ }
+
+ private EPackage findEPackage(String nsURI) {
+ Object registeredEPackageDescriptor = EPackage.Registry.INSTANCE.get(nsURI);
+ if (registeredEPackageDescriptor instanceof EPackage) {
+ return (EPackage) registeredEPackageDescriptor;
+ }
+ else if (registeredEPackageDescriptor instanceof EPackage.Descriptor) {
+ return ((EPackage.Descriptor) registeredEPackageDescriptor).getEPackage();
+ }
+ throw new IllegalArgumentException("Wrong type in Ecore.Registry");
+ }
+}
diff --git a/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/internal/emf/XtendTypesytemEmfPlugin.java b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/internal/emf/XtendTypesytemEmfPlugin.java
new file mode 100644
index 0000000..a43b62c
--- /dev/null
+++ b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/internal/emf/XtendTypesytemEmfPlugin.java
@@ -0,0 +1,49 @@
+package org.eclipse.xtend.typesystem.internal.emf;
+
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.xtend.typesystem.emf.check.CheckRegistry;
+import org.osgi.framework.BundleContext;
+
+public class XtendTypesytemEmfPlugin extends Plugin {
+
+ // the shared instance
+ private static XtendTypesytemEmfPlugin plugin;
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.xtend.typesystem.emf";
+
+ public XtendTypesytemEmfPlugin() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ CheckRegistry.getInstance();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static XtendTypesytemEmfPlugin getDefault() {
+ return plugin;
+ }
+
+
+}
diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/ResourceManagerDefaultImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/ResourceManagerDefaultImpl.java
index e468ce7..a54a266 100644
--- a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/ResourceManagerDefaultImpl.java
+++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/ResourceManagerDefaultImpl.java
@@ -29,6 +29,7 @@ import org.eclipse.internal.xtend.util.internal.icu.CharsetDetector;
import org.eclipse.internal.xtend.util.internal.icu.CharsetMatch;
import org.eclipse.internal.xtend.xtend.XtendFile;
import org.eclipse.internal.xtend.xtend.XtendResourceParser;
+import org.eclipse.xtend.check.CheckUtils;
public class ResourceManagerDefaultImpl implements ResourceManager {
@@ -41,6 +42,7 @@ public class ResourceManagerDefaultImpl implements ResourceManager {
public ResourceManagerDefaultImpl() {
registeredParsers.put(XtendFile.FILE_EXTENSION,
new XtendResourceParser());
+ registeredParsers.put(CheckUtils.FILE_EXTENSION, new XtendResourceParser());
}
public Resource loadResource(final String fullyQualifiedName,