From 7ee3b8fdba1811296f0f8075f8a42c67b2b26312 Mon Sep 17 00:00:00 2001
From: Sebastian Zarnekow
Date: Wed, 3 Aug 2011 11:39:30 +0200
Subject: [genmodel] First shot at indexing genmodels
To be discussed:
Do we want / need to index GenStructuralFeatures?
Do we need a hash value in the user data of GenClasses to detect changes of their content?---
.../.classpath | 7 ++
org.eclipse.emf.codegen.ecore.xtext.tests/.project | 28 +++++
.../.settings/org.eclipse.jdt.core.prefs | 7 ++
.../META-INF/MANIFEST.MF | 12 ++
.../about.html | 28 +++++
.../build.properties | 5 +
.../plugin.properties | 2 +
.../GenmodelResourceDescriptionManagerTest.java | 132 +++++++++++++++++++++
org.eclipse.emf.codegen.ecore.xtext.ui/.classpath | 7 ++
org.eclipse.emf.codegen.ecore.xtext.ui/.project | 28 +++++
.../.settings/org.eclipse.jdt.core.prefs | 7 ++
.../META-INF/MANIFEST.MF | 15 +++
org.eclipse.emf.codegen.ecore.xtext.ui/about.html | 28 +++++
.../build.properties | 6 +
.../plugin.properties | 2 +
org.eclipse.emf.codegen.ecore.xtext.ui/plugin.xml | 12 ++
.../emf/codegen/ecore/xtext/ui/Activator.java | 80 +++++++++++++
.../ecore/xtext/ui/ExecutableExtensionFactory.java | 27 +++++
.../ecore/xtext/ui/GenmodelEditorOpener.java | 31 +++++
.../codegen/ecore/xtext/ui/GenmodelUiModule.java | 26 ++++
org.eclipse.emf.codegen.ecore.xtext/.classpath | 7 ++
org.eclipse.emf.codegen.ecore.xtext/.gitignore | 1 +
org.eclipse.emf.codegen.ecore.xtext/.project | 28 +++++
.../.settings/org.eclipse.jdt.core.prefs | 7 ++
.../META-INF/MANIFEST.MF | 13 ++
org.eclipse.emf.codegen.ecore.xtext/about.html | 28 +++++
.../build.properties | 5 +
.../plugin.properties | 2 +
.../ecore/xtext/GenmodelQualifiedNameProvider.java | 43 +++++++
.../xtext/GenmodelResourceDescriptionStrategy.java | 35 ++++++
.../codegen/ecore/xtext/GenmodelRuntimeModule.java | 40 +++++++
.../emf/codegen/ecore/xtext/GenmodelSupport.java | 45 +++++++
org.eclipse.emf.ecore.xcore.ui/.gitignore | 1 +
org.eclipse.emf.ecore.xcore.ui/about.html | 28 +++++
org.eclipse.emf.ecore.xcore.ui/plugin.properties | 2 +
35 files changed, 775 insertions(+)
create mode 100644 org.eclipse.emf.codegen.ecore.xtext.tests/.classpath
create mode 100644 org.eclipse.emf.codegen.ecore.xtext.tests/.project
create mode 100644 org.eclipse.emf.codegen.ecore.xtext.tests/.settings/org.eclipse.jdt.core.prefs
create mode 100644 org.eclipse.emf.codegen.ecore.xtext.tests/META-INF/MANIFEST.MF
create mode 100644 org.eclipse.emf.codegen.ecore.xtext.tests/about.html
create mode 100644 org.eclipse.emf.codegen.ecore.xtext.tests/build.properties
create mode 100644 org.eclipse.emf.codegen.ecore.xtext.tests/plugin.properties
create mode 100644 org.eclipse.emf.codegen.ecore.xtext.tests/src/org/eclipse/emf/codegen/ecore/xtext/GenmodelResourceDescriptionManagerTest.java
create mode 100644 org.eclipse.emf.codegen.ecore.xtext.ui/.classpath
create mode 100644 org.eclipse.emf.codegen.ecore.xtext.ui/.project
create mode 100644 org.eclipse.emf.codegen.ecore.xtext.ui/.settings/org.eclipse.jdt.core.prefs
create mode 100644 org.eclipse.emf.codegen.ecore.xtext.ui/META-INF/MANIFEST.MF
create mode 100644 org.eclipse.emf.codegen.ecore.xtext.ui/about.html
create mode 100644 org.eclipse.emf.codegen.ecore.xtext.ui/build.properties
create mode 100644 org.eclipse.emf.codegen.ecore.xtext.ui/plugin.properties
create mode 100644 org.eclipse.emf.codegen.ecore.xtext.ui/plugin.xml
create mode 100644 org.eclipse.emf.codegen.ecore.xtext.ui/src/org/eclipse/emf/codegen/ecore/xtext/ui/Activator.java
create mode 100644 org.eclipse.emf.codegen.ecore.xtext.ui/src/org/eclipse/emf/codegen/ecore/xtext/ui/ExecutableExtensionFactory.java
create mode 100644 org.eclipse.emf.codegen.ecore.xtext.ui/src/org/eclipse/emf/codegen/ecore/xtext/ui/GenmodelEditorOpener.java
create mode 100644 org.eclipse.emf.codegen.ecore.xtext.ui/src/org/eclipse/emf/codegen/ecore/xtext/ui/GenmodelUiModule.java
create mode 100644 org.eclipse.emf.codegen.ecore.xtext/.classpath
create mode 100644 org.eclipse.emf.codegen.ecore.xtext/.gitignore
create mode 100644 org.eclipse.emf.codegen.ecore.xtext/.project
create mode 100644 org.eclipse.emf.codegen.ecore.xtext/.settings/org.eclipse.jdt.core.prefs
create mode 100644 org.eclipse.emf.codegen.ecore.xtext/META-INF/MANIFEST.MF
create mode 100644 org.eclipse.emf.codegen.ecore.xtext/about.html
create mode 100644 org.eclipse.emf.codegen.ecore.xtext/build.properties
create mode 100644 org.eclipse.emf.codegen.ecore.xtext/plugin.properties
create mode 100644 org.eclipse.emf.codegen.ecore.xtext/src/org/eclipse/emf/codegen/ecore/xtext/GenmodelQualifiedNameProvider.java
create mode 100644 org.eclipse.emf.codegen.ecore.xtext/src/org/eclipse/emf/codegen/ecore/xtext/GenmodelResourceDescriptionStrategy.java
create mode 100644 org.eclipse.emf.codegen.ecore.xtext/src/org/eclipse/emf/codegen/ecore/xtext/GenmodelRuntimeModule.java
create mode 100644 org.eclipse.emf.codegen.ecore.xtext/src/org/eclipse/emf/codegen/ecore/xtext/GenmodelSupport.java
create mode 100644 org.eclipse.emf.ecore.xcore.ui/.gitignore
create mode 100644 org.eclipse.emf.ecore.xcore.ui/about.html
create mode 100644 org.eclipse.emf.ecore.xcore.ui/plugin.properties
diff --git a/org.eclipse.emf.codegen.ecore.xtext.tests/.classpath b/org.eclipse.emf.codegen.ecore.xtext.tests/.classpath
new file mode 100644
index 000000000..1fa3e6803
--- /dev/null
+++ b/org.eclipse.emf.codegen.ecore.xtext.tests/.classpath
@@ -0,0 +1,7 @@
+
+
June 15, 2010
+The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available +at http://www.eclipse.org/legal/epl-v10.html. +For purposes of the EPL, "Program" will mean the Content.
+ +If you did not receive this Content directly from the Eclipse Foundation, the Content is +being redistributed by another party ("Redistributor") and different terms and conditions may +apply to your use of any object code in the Content. Check the Redistributor's license that was +provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise +indicated below, the terms and conditions of the EPL still apply to any source code in the Content +and such source code may be obtained at http://www.eclipse.org.
+ + + \ No newline at end of file diff --git a/org.eclipse.emf.codegen.ecore.xtext.tests/build.properties b/org.eclipse.emf.codegen.ecore.xtext.tests/build.properties new file mode 100644 index 000000000..39c1bfa03 --- /dev/null +++ b/org.eclipse.emf.codegen.ecore.xtext.tests/build.properties @@ -0,0 +1,5 @@ +source.. = src/ +bin.includes = META-INF/,\ + .,\ + about.html,\ + plugin.properties diff --git a/org.eclipse.emf.codegen.ecore.xtext.tests/plugin.properties b/org.eclipse.emf.codegen.ecore.xtext.tests/plugin.properties new file mode 100644 index 000000000..d089281fb --- /dev/null +++ b/org.eclipse.emf.codegen.ecore.xtext.tests/plugin.properties @@ -0,0 +1,2 @@ +pluginName = EMF CodeGen Ecore Xtext Integration Tests +providerName = Eclipse Modeling Project \ No newline at end of file diff --git a/org.eclipse.emf.codegen.ecore.xtext.tests/src/org/eclipse/emf/codegen/ecore/xtext/GenmodelResourceDescriptionManagerTest.java b/org.eclipse.emf.codegen.ecore.xtext.tests/src/org/eclipse/emf/codegen/ecore/xtext/GenmodelResourceDescriptionManagerTest.java new file mode 100644 index 000000000..6a7760bd1 --- /dev/null +++ b/org.eclipse.emf.codegen.ecore.xtext.tests/src/org/eclipse/emf/codegen/ecore/xtext/GenmodelResourceDescriptionManagerTest.java @@ -0,0 +1,132 @@ +/******************************************************************************* + * Copyright (c) 2009 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.emf.codegen.ecore.xtext; + +import java.util.Collections; +import java.util.Map; + +import junit.framework.TestCase; + +import org.eclipse.emf.codegen.ecore.genmodel.GenClass; +import org.eclipse.emf.codegen.ecore.genmodel.GenModel; +import org.eclipse.emf.codegen.ecore.genmodel.GenModelFactory; +import org.eclipse.emf.codegen.ecore.genmodel.GenModelPackage; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EcoreFactory; +import org.eclipse.emf.ecore.EcorePackage; +import org.eclipse.emf.ecore.plugin.EcorePlugin; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; +import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl; +import org.eclipse.xtext.naming.IQualifiedNameConverter; +import org.eclipse.xtext.naming.QualifiedName; +import org.eclipse.xtext.resource.IEObjectDescription; +import org.eclipse.xtext.resource.IResourceDescription; +import org.eclipse.xtext.resource.generic.GenericResourceDescriptionManager; + +import com.google.common.collect.Maps; +import com.google.inject.Guice; +import com.google.inject.Injector; + +/** + * @author Sven Efftinge - Initial contribution and API + * @author Jan Koehnlein + */ +public class GenmodelResourceDescriptionManagerTest extends TestCase { + + private GenericResourceDescriptionManager testMe; + + private IQualifiedNameConverter converter; + + private Resource ecoreGenModel; + + @Override + protected void setUp() throws Exception { + super.setUp(); + Injector injector = Guice.createInjector(new GenmodelRuntimeModule()); + testMe = injector.getInstance(GenericResourceDescriptionManager.class); + converter = injector.getInstance(IQualifiedNameConverter.class); + URI genmodelURI = EcorePlugin.getEPackageNsURIToGenModelLocationMap().get(EcorePackage.eINSTANCE.getNsURI()); + ecoreGenModel = new ResourceSetImpl().getResource(genmodelURI, true); + assertNotNull(ecoreGenModel); + } + + @Override + protected void tearDown() throws Exception { + testMe = null; + converter = null; + ecoreGenModel = null; + super.tearDown(); + } + + public void testEcoreGenmodel() throws Exception { + MapJune 15, 2010
+The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available +at http://www.eclipse.org/legal/epl-v10.html. +For purposes of the EPL, "Program" will mean the Content.
+ +If you did not receive this Content directly from the Eclipse Foundation, the Content is +being redistributed by another party ("Redistributor") and different terms and conditions may +apply to your use of any object code in the Content. Check the Redistributor's license that was +provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise +indicated below, the terms and conditions of the EPL still apply to any source code in the Content +and such source code may be obtained at http://www.eclipse.org.
+ + + \ No newline at end of file diff --git a/org.eclipse.emf.codegen.ecore.xtext.ui/build.properties b/org.eclipse.emf.codegen.ecore.xtext.ui/build.properties new file mode 100644 index 000000000..ff1f844c8 --- /dev/null +++ b/org.eclipse.emf.codegen.ecore.xtext.ui/build.properties @@ -0,0 +1,6 @@ +source.. = src/ +bin.includes = META-INF/,\ + .,\ + plugin.xml,\ + plugin.properties,\ + about.html diff --git a/org.eclipse.emf.codegen.ecore.xtext.ui/plugin.properties b/org.eclipse.emf.codegen.ecore.xtext.ui/plugin.properties new file mode 100644 index 000000000..1d44cf4fe --- /dev/null +++ b/org.eclipse.emf.codegen.ecore.xtext.ui/plugin.properties @@ -0,0 +1,2 @@ +pluginName = Xtext Ecore Ui Support +providerName = Eclipse Modeling Project \ No newline at end of file diff --git a/org.eclipse.emf.codegen.ecore.xtext.ui/plugin.xml b/org.eclipse.emf.codegen.ecore.xtext.ui/plugin.xml new file mode 100644 index 000000000..1222ca016 --- /dev/null +++ b/org.eclipse.emf.codegen.ecore.xtext.ui/plugin.xml @@ -0,0 +1,12 @@ + + +June 15, 2010
+The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available +at http://www.eclipse.org/legal/epl-v10.html. +For purposes of the EPL, "Program" will mean the Content.
+ +If you did not receive this Content directly from the Eclipse Foundation, the Content is +being redistributed by another party ("Redistributor") and different terms and conditions may +apply to your use of any object code in the Content. Check the Redistributor's license that was +provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise +indicated below, the terms and conditions of the EPL still apply to any source code in the Content +and such source code may be obtained at http://www.eclipse.org.
+ + + \ No newline at end of file diff --git a/org.eclipse.emf.codegen.ecore.xtext/build.properties b/org.eclipse.emf.codegen.ecore.xtext/build.properties new file mode 100644 index 000000000..8020d8bd4 --- /dev/null +++ b/org.eclipse.emf.codegen.ecore.xtext/build.properties @@ -0,0 +1,5 @@ +source.. = src/ +bin.includes = META-INF/,\ + .,\ + plugin.properties,\ + about.html diff --git a/org.eclipse.emf.codegen.ecore.xtext/plugin.properties b/org.eclipse.emf.codegen.ecore.xtext/plugin.properties new file mode 100644 index 000000000..4bd96f2bd --- /dev/null +++ b/org.eclipse.emf.codegen.ecore.xtext/plugin.properties @@ -0,0 +1,2 @@ +pluginName = EMF CodeGen Ecore Xtext Integration +providerName = Eclipse Modeling Project \ No newline at end of file diff --git a/org.eclipse.emf.codegen.ecore.xtext/src/org/eclipse/emf/codegen/ecore/xtext/GenmodelQualifiedNameProvider.java b/org.eclipse.emf.codegen.ecore.xtext/src/org/eclipse/emf/codegen/ecore/xtext/GenmodelQualifiedNameProvider.java new file mode 100644 index 000000000..c716e144d --- /dev/null +++ b/org.eclipse.emf.codegen.ecore.xtext/src/org/eclipse/emf/codegen/ecore/xtext/GenmodelQualifiedNameProvider.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2011 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.emf.codegen.ecore.xtext; + +import org.eclipse.emf.codegen.ecore.genmodel.GenClassifier; +import org.eclipse.emf.codegen.ecore.genmodel.GenPackage; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.xtext.naming.IQualifiedNameConverter; +import org.eclipse.xtext.naming.IQualifiedNameProvider; +import org.eclipse.xtext.naming.QualifiedName; + +import com.google.inject.Inject; + +/** + * @author Sebastian Zarnekow - Initial contribution and API + */ +public class GenmodelQualifiedNameProvider extends IQualifiedNameProvider.AbstractImpl { + + @Inject + private IQualifiedNameConverter qualifiedNameConverter; + + public QualifiedName getFullyQualifiedName(final EObject obj) { + if (obj instanceof GenPackage) { + String packageName = ((GenPackage) obj).getQualifiedPackageName(); + return qualifiedNameConverter.toQualifiedName(packageName); + + } else if (obj instanceof GenClassifier) { + GenClassifier classifier = (GenClassifier) obj; + GenPackage genPackage = classifier.getGenPackage(); + String packageName = genPackage.getQualifiedPackageName(); + String classifierName = classifier.getName(); + return qualifiedNameConverter.toQualifiedName(packageName).append(classifierName); + } + return null; + } + + +} diff --git a/org.eclipse.emf.codegen.ecore.xtext/src/org/eclipse/emf/codegen/ecore/xtext/GenmodelResourceDescriptionStrategy.java b/org.eclipse.emf.codegen.ecore.xtext/src/org/eclipse/emf/codegen/ecore/xtext/GenmodelResourceDescriptionStrategy.java new file mode 100644 index 000000000..12897be0a --- /dev/null +++ b/org.eclipse.emf.codegen.ecore.xtext/src/org/eclipse/emf/codegen/ecore/xtext/GenmodelResourceDescriptionStrategy.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2011 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.emf.codegen.ecore.xtext; + +import org.eclipse.emf.codegen.ecore.genmodel.GenClassifier; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.xtext.resource.IEObjectDescription; +import org.eclipse.xtext.resource.impl.DefaultResourceDescriptionStrategy; +import org.eclipse.xtext.util.IAcceptor; + +import com.google.inject.Singleton; + +/** + * @author Sebastian Zarnekow - Initial contribution and API + * + * TODO: We should probably add some hashed user data over all information that + * impacts the code generation in order to be properly notify clients about these changes + */ +@Singleton +public class GenmodelResourceDescriptionStrategy extends DefaultResourceDescriptionStrategy { + + @Override + public boolean createEObjectDescriptions(EObject eObject, IAcceptor+ * component = org.eclipse.emf.codegen.ecore.xtext.GenmodelSupport{} + *+ * + * If you want to provide a different guice guiceModule than the default one ({@link GenmodelRuntimeModule}) in order to + * change any implementation classes, you can make use of the property guiceModule. E.g. : + * + *
+ * component = org.eclipse.emf.codegen.ecore.xtext.GenmodelSupport{ + * guiceModule = my.special.CustomizedGenmodelRuntimeModule {} + * } + *+ * + * @author Sven Efftinge - Initial contribution and API + */ +public class GenmodelSupport extends AbstractGenericResourceSupport { + + @Override + protected Module createGuiceModule() { + return new GenmodelRuntimeModule(); + } + +} diff --git a/org.eclipse.emf.ecore.xcore.ui/.gitignore b/org.eclipse.emf.ecore.xcore.ui/.gitignore new file mode 100644 index 000000000..ba077a403 --- /dev/null +++ b/org.eclipse.emf.ecore.xcore.ui/.gitignore @@ -0,0 +1 @@ +bin diff --git a/org.eclipse.emf.ecore.xcore.ui/about.html b/org.eclipse.emf.ecore.xcore.ui/about.html new file mode 100644 index 000000000..68e17ab9e --- /dev/null +++ b/org.eclipse.emf.ecore.xcore.ui/about.html @@ -0,0 +1,28 @@ + + + + +
June 15, 2010
+The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available +at http://www.eclipse.org/legal/epl-v10.html. +For purposes of the EPL, "Program" will mean the Content.
+ +If you did not receive this Content directly from the Eclipse Foundation, the Content is +being redistributed by another party ("Redistributor") and different terms and conditions may +apply to your use of any object code in the Content. Check the Redistributor's license that was +provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise +indicated below, the terms and conditions of the EPL still apply to any source code in the Content +and such source code may be obtained at http://www.eclipse.org.
+ + + \ No newline at end of file diff --git a/org.eclipse.emf.ecore.xcore.ui/plugin.properties b/org.eclipse.emf.ecore.xcore.ui/plugin.properties new file mode 100644 index 000000000..023d5be53 --- /dev/null +++ b/org.eclipse.emf.ecore.xcore.ui/plugin.properties @@ -0,0 +1,2 @@ +pluginName = EMF CodeGen Ecore Xtext UI Integration +providerName = Eclipse Modeling Project \ No newline at end of file -- cgit v1.2.3