userData = Maps.newHashMapWithExpectedSize(1);
+ userData.put(NS_URI_INDEX_ENTRY, Boolean.toString(isNsURI));
+ IEObjectDescription description = EObjectDescription.create(qualifiedName, eObject, userData);
+ acceptor.accept(description);
+ return true;
+ }
+ } catch (Exception exc) {
+ LOG.error(exc.getMessage(), exc);
+ }
+ return false;
+ }
+
+}
diff --git a/org.eclipse.xtext.tests/src/org/eclipse/xtext/tests/ecore/EcoreRuntimeModule.java b/org.eclipse.xtext.tests/src/org/eclipse/xtext/tests/ecore/EcoreRuntimeModule.java
new file mode 100644
index 000000000..a5b8e312a
--- /dev/null
+++ b/org.eclipse.xtext.tests/src/org/eclipse/xtext/tests/ecore/EcoreRuntimeModule.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.xtext.tests.ecore;
+
+import org.eclipse.xtext.naming.IQualifiedNameProvider;
+import org.eclipse.xtext.resource.IDefaultResourceDescriptionStrategy;
+import org.eclipse.xtext.resource.generic.AbstractGenericResourceRuntimeModule;
+
+/**
+ * Default Guice bindings for managing Ecore resources in the context of Xtext.
+ *
+ * @author Jan Koehnlein - Initial contribution and API
+ */
+public class EcoreRuntimeModule extends AbstractGenericResourceRuntimeModule {
+
+ @Override
+ protected String getLanguageName() {
+ return "org.eclipse.emf.ecore.presentation.EcoreEditorID";
+ }
+
+ @Override
+ protected String getFileExtensions() {
+ return "ecore";
+ }
+
+ public Class extends IDefaultResourceDescriptionStrategy> bindIDefaultResourceDescriptionStrategy() {
+ return EcoreResourceDescriptionStrategy.class;
+ }
+
+ @Override
+ public Class extends IQualifiedNameProvider> bindIQualifiedNameProvider() {
+ return EcoreQualifiedNameProvider.class;
+ }
+
+}
diff --git a/org.eclipse.xtext.tests/src/org/eclipse/xtext/tests/ecore/EcoreSupport.java b/org.eclipse.xtext.tests/src/org/eclipse/xtext/tests/ecore/EcoreSupport.java
new file mode 100644
index 000000000..96fac0bc5
--- /dev/null
+++ b/org.eclipse.xtext.tests/src/org/eclipse/xtext/tests/ecore/EcoreSupport.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.xtext.tests.ecore;
+
+import org.eclipse.xtext.ISetup;
+import org.eclipse.xtext.resource.generic.AbstractGenericResourceSupport;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.Module;
+
+/**
+ *
+ * This class is intended to be used from an MWE workflow.
+ *
+ * It instantiates and registers the Ecore support for Xtext, which allows for referencing ecore models from any Xtext
+ * language.
+ *
+ * Usage:
+ *
+ *
+ * component = org.eclipse.xtext.ecore.EcoreSupport{}
+ *
+ *
+ * If you want to provide a different guice guiceModule than the default one ({@link EcoreRuntimeModule}) in order to
+ * change any implementation classes, you can make use of the property guiceModule. E.g. :
+ *
+ *
+ * component = org.eclipse.xtext.ecore.EcoreSupport{
+ * guiceModule = my.special.CustomizedEcoreRuntimeModule {}
+ * }
+ *
+ *
+ * @author Sven Efftinge - Initial contribution and API
+ */
+public class EcoreSupport extends AbstractGenericResourceSupport implements ISetup {
+
+ @Override
+ protected Module createGuiceModule() {
+ return new EcoreRuntimeModule();
+ }
+
+ /**
+ * @since 2.5
+ */
+ @Override
+ public Injector createInjectorAndDoEMFRegistration() {
+ Injector injector = Guice.createInjector(getGuiceModule());
+ injector.injectMembers(this);
+ registerInRegistry(false);
+ return injector;
+ }
+
+}
diff --git a/org.eclipse.xtext.tests/src/org/eclipse/xtext/tests/ecore/EcoreSupportStandaloneSetup.java b/org.eclipse.xtext.tests/src/org/eclipse/xtext/tests/ecore/EcoreSupportStandaloneSetup.java
new file mode 100644
index 000000000..5e43297dd
--- /dev/null
+++ b/org.eclipse.xtext.tests/src/org/eclipse/xtext/tests/ecore/EcoreSupportStandaloneSetup.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * 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.xtext.tests.ecore;
+
+/**
+ * Can be used to cause a side effect in workflow. As soon as this bean
+ * is instantiated in a workflow, the {@link org.eclipse.xtext.resource.IResourceServiceProvider services}
+ * for {@code *.ecore} files are registered. Existing services will not be replaced.
+ * @author Sebastian Zarnekow - Initial contribution and API
+ */
+public class EcoreSupportStandaloneSetup {
+
+ public static void setup() {
+ new EcoreSupportStandaloneSetup();
+ }
+
+ public EcoreSupportStandaloneSetup() {
+ new EcoreSupport().registerServices(false);
+ }
+
+}
diff --git a/org.eclipse.xtext.tests/src/org/eclipse/xtext/tests/ecore/NsURIQualifiedNameProvider.java b/org.eclipse.xtext.tests/src/org/eclipse/xtext/tests/ecore/NsURIQualifiedNameProvider.java
new file mode 100644
index 000000000..e09785403
--- /dev/null
+++ b/org.eclipse.xtext.tests/src/org/eclipse/xtext/tests/ecore/NsURIQualifiedNameProvider.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * 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.xtext.tests.ecore;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+
+/**
+ * @author Jan Koehnlein - Initial contribution and API
+ */
+public class NsURIQualifiedNameProvider extends EcoreQualifiedNameProvider {
+
+ @Override
+ protected String name(EPackage ePackage) {
+ return ePackage.getNsURI();
+ }
+
+ @Override
+ protected String getCacheKey() {
+ return "nsURIfqn";
+ }
+
+ @Override
+ protected boolean isRecurseParent(EObject obj) {
+ return !(obj instanceof EPackage) && super.isRecurseParent(obj);
+ }
+}
diff --git a/org.eclipse.xtext.tests/src/org/eclipse/xtext/validation/GenerateValidationLanguages.mwe2 b/org.eclipse.xtext.tests/src/org/eclipse/xtext/validation/GenerateValidationLanguages.mwe2
index 6200ae254..6716ca879 100644
--- a/org.eclipse.xtext.tests/src/org/eclipse/xtext/validation/GenerateValidationLanguages.mwe2
+++ b/org.eclipse.xtext.tests/src/org/eclipse/xtext/validation/GenerateValidationLanguages.mwe2
@@ -10,15 +10,12 @@ module org.eclipse.xtext.validation.GenerateValidationLanguages
import org.eclipse.emf.mwe2.runtime.workflow.Workflow
import org.eclipse.emf.mwe.utils.*
import org.eclipse.xtext.*
-import org.eclipse.xtext.generator.*
+import org.eclipse.xtext.xtext.generator.*
var projectName = "org.eclipse.xtext.tests"
var runtimeProject = "../${projectName}"
var lineDelimiter = '\n'
-//var generateDotDiagram = true
-//var graphvizCommand = "/opt/local/bin/dot -o %1.pdf -v -T pdf"
-
Workflow {
bean = StandaloneSetup {
platformUri = "${runtimeProject}/.."
@@ -28,13 +25,23 @@ Workflow {
directory = "${runtimeProject}/src-gen/org/eclipse/xtext/validation"
}
- component = Generator auto-inject {
- mergeManifest = false
- pathRtProject = runtimeProject
- projectNameRt = projectName
+ component = XtextGenerator {
+ cleaner = {
+ enabled = false
+ }
+ configuration = {
+ project = model.project.StandardProjectConfig {
+ baseName = projectName
+ rootPath = ".."
+ }
+ code = {
+ lineDelimiter = lineDelimiter
+ preferXtendStubs = false
+ }
+ }
language = {
- uri = "classpath:/org/eclipse/xtext/validation/ConcreteSyntaxValidationTestLanguage.xtext"
+ grammarUri = "classpath:/org/eclipse/xtext/validation/ConcreteSyntaxValidationTestLanguage.xtext"
fragment = @TestLanguagesFragments auto-inject {}
}
}
diff --git a/org.eclipse.xtext.tests/src/org/eclipse/xtext/xtext/ecoreInference/GenerateEcoreInferenceTestLanguages.mwe2 b/org.eclipse.xtext.tests/src/org/eclipse/xtext/xtext/ecoreInference/GenerateEcoreInferenceTestLanguages.mwe2
index 8534b2e95..704d3e092 100644
--- a/org.eclipse.xtext.tests/src/org/eclipse/xtext/xtext/ecoreInference/GenerateEcoreInferenceTestLanguages.mwe2
+++ b/org.eclipse.xtext.tests/src/org/eclipse/xtext/xtext/ecoreInference/GenerateEcoreInferenceTestLanguages.mwe2
@@ -10,7 +10,7 @@ module org.eclipse.xtext.xtext.ecoreInference.GenerateEcoreInferenceTestLanguage
import org.eclipse.emf.mwe2.runtime.workflow.Workflow
import org.eclipse.emf.mwe.utils.*
import org.eclipse.xtext.*
-import org.eclipse.xtext.generator.*
+import org.eclipse.xtext.xtext.generator.*
var projectName = "org.eclipse.xtext.tests"
var runtimeProject = "../${projectName}"
@@ -25,16 +25,27 @@ Workflow {
directory = "${runtimeProject}/src-gen/org/eclipse/xtext/xtext/ecoreInference"
}
- component = Generator auto-inject {
- pathRtProject = runtimeProject
- projectNameRt = projectName
+ component = XtextGenerator {
+ cleaner = {
+ enabled = false
+ }
+ configuration = {
+ project = model.project.StandardProjectConfig {
+ baseName = projectName
+ rootPath = ".."
+ }
+ code = {
+ lineDelimiter = lineDelimiter
+ preferXtendStubs = false
+ }
+ }
language = {
- uri = "classpath:/org/eclipse/xtext/xtext/ecoreInference/MultiValueFeatureTestLanguage.xtext"
+ grammarUri = "classpath:/org/eclipse/xtext/xtext/ecoreInference/MultiValueFeatureTestLanguage.xtext"
fragment = @TestLanguagesFragments {}
}
language = {
- uri = "classpath:/org/eclipse/xtext/xtext/ecoreInference/UnassignedRuleCallTestLanguage.xtext"
+ grammarUri = "classpath:/org/eclipse/xtext/xtext/ecoreInference/UnassignedRuleCallTestLanguage.xtext"
fragment = @TestLanguagesFragments {}
}
}
diff --git a/org.eclipse.xtext.tests/xtend-gen/org/eclipse/xtext/TestProjectConfig.java b/org.eclipse.xtext.tests/xtend-gen/org/eclipse/xtext/TestProjectConfig.java
deleted file mode 100644
index 0a71fb00c..000000000
--- a/org.eclipse.xtext.tests/xtend-gen/org/eclipse/xtext/TestProjectConfig.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * Copyright (c) 2015 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.xtext;
-
-import org.eclipse.xtext.xtext.generator.model.project.StandardProjectConfig;
-import org.eclipse.xtext.xtext.generator.model.project.SubProjectConfig;
-
-/**
- * @author Christian Schneider - Initial contribution and API
- */
-@SuppressWarnings("all")
-public class TestProjectConfig extends StandardProjectConfig {
- /**
- * Put the 'srcGen' classes generated for those test languages that are migrated
- * to the new generator infrastructure into a separate source folder!
- */
- @Override
- protected String computeSrcGen(final SubProjectConfig project) {
- String _computeSrcGen = super.computeSrcGen(project);
- return (_computeSrcGen + "2");
- }
-}
diff --git a/org.eclipse.xtext.tests/xtend-gen/org/eclipse/xtext/tests/TestsEMFGeneratorFragment.java b/org.eclipse.xtext.tests/xtend-gen/org/eclipse/xtext/tests/TestsEMFGeneratorFragment.java
new file mode 100644
index 000000000..b097f37bb
--- /dev/null
+++ b/org.eclipse.xtext.tests/xtend-gen/org/eclipse/xtext/tests/TestsEMFGeneratorFragment.java
@@ -0,0 +1,81 @@
+/**
+ * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) 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.xtext.tests;
+
+import org.eclipse.xtend.lib.annotations.AccessorType;
+import org.eclipse.xtend.lib.annotations.Accessors;
+import org.eclipse.xtext.Grammar;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+import org.eclipse.xtext.xtext.generator.ecore.EMFGeneratorFragment2;
+
+/**
+ * @author spoenemann - Initial contribution and API
+ */
+@SuppressWarnings("all")
+public class TestsEMFGeneratorFragment extends EMFGeneratorFragment2 {
+ @Accessors(AccessorType.PUBLIC_SETTER)
+ private String ecoreModel;
+
+ private String genModel;
+
+ @Override
+ public void setGenModel(final String genModel) {
+ this.genModel = genModel;
+ super.setGenModel(genModel);
+ }
+
+ @Override
+ protected String getEcoreFilePath(final Grammar grammar) {
+ String _xifexpression = null;
+ boolean _isNullOrEmpty = StringExtensions.isNullOrEmpty(this.ecoreModel);
+ boolean _not = (!_isNullOrEmpty);
+ if (_not) {
+ _xifexpression = this.ecoreModel;
+ } else {
+ String _javaModelDirectory = this.getJavaModelDirectory();
+ String _plus = (_javaModelDirectory + "/");
+ String _name = grammar.getName();
+ String _name_1 = grammar.getName();
+ int _lastIndexOf = _name_1.lastIndexOf(".");
+ String _substring = _name.substring(0, _lastIndexOf);
+ String _replace = _substring.replace(".", "/");
+ String _plus_1 = (_plus + _replace);
+ String _modelName = this.getModelName(grammar);
+ String _plus_2 = (_plus_1 + _modelName);
+ _xifexpression = (_plus_2 + ".ecore");
+ }
+ return _xifexpression;
+ }
+
+ @Override
+ protected String getGenModelPath(final Grammar grammar) {
+ String _xifexpression = null;
+ boolean _isNullOrEmpty = StringExtensions.isNullOrEmpty(this.genModel);
+ boolean _not = (!_isNullOrEmpty);
+ if (_not) {
+ _xifexpression = this.genModel;
+ } else {
+ String _javaModelDirectory = this.getJavaModelDirectory();
+ String _plus = (_javaModelDirectory + "/");
+ String _name = grammar.getName();
+ String _name_1 = grammar.getName();
+ int _lastIndexOf = _name_1.lastIndexOf(".");
+ String _substring = _name.substring(0, _lastIndexOf);
+ String _replace = _substring.replace(".", "/");
+ String _plus_1 = (_plus + _replace);
+ String _modelName = this.getModelName(grammar);
+ String _plus_2 = (_plus_1 + _modelName);
+ _xifexpression = (_plus_2 + ".genmodel");
+ }
+ return _xifexpression;
+ }
+
+ public void setEcoreModel(final String ecoreModel) {
+ this.ecoreModel = ecoreModel;
+ }
+}