diff --git a/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/AbstractGeneratorFragment2.xtend b/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/AbstractGeneratorFragment2.xtend index cfee33634..2e3e79a42 100644 --- a/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/AbstractGeneratorFragment2.xtend +++ b/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/AbstractGeneratorFragment2.xtend @@ -15,7 +15,7 @@ import org.eclipse.xtext.Grammar abstract class AbstractGeneratorFragment2 implements IGeneratorFragment2 { @Accessors(PROTECTED_GETTER) - @Inject IXtextProjectConfig projectConfig + @Inject XtextProjectConfig projectConfig @Accessors(PROTECTED_GETTER) @Inject ILanguageConfig language diff --git a/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/DefaultGeneratorModule.xtend b/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/DefaultGeneratorModule.xtend index 3e937be13..313b145bf 100644 --- a/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/DefaultGeneratorModule.xtend +++ b/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/DefaultGeneratorModule.xtend @@ -27,7 +27,7 @@ class DefaultGeneratorModule extends AbstractGenericModule { } def void configureXtextProjectConfig(Binder binder) { - binder.bind(IXtextProjectConfig).toInstance(project) + binder.bind(XtextProjectConfig).toInstance(project) } def void configureCodeConfig(Binder binder) { diff --git a/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/IXtextProjectConfig.java b/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/IXtextProjectConfig.java deleted file mode 100644 index 424ff7031..000000000 --- a/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/IXtextProjectConfig.java +++ /dev/null @@ -1,102 +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.xtext.generator; - -import org.eclipse.xtext.xtext.generator.model.IXtextGeneratorFileSystemAccess; -import org.eclipse.xtext.xtext.generator.IGuiceAwareGeneratorComponent; -import org.eclipse.xtext.xtext.generator.model.ManifestAccess; -import org.eclipse.xtext.xtext.generator.model.PluginXmlAccess; - -/** - * Inject an instance of this interface in order to generate code in a generator fragment. - * - *
This file has been generated with {@link org.eclipse.xtext.xtext.generator.internal.ProjectConfigGenerator}.
- */ -public interface IXtextProjectConfig extends IGuiceAwareGeneratorComponent { - - IXtextGeneratorFileSystemAccess getRuntimeModelGen(); - - String getRuntimeProjectName(); - IXtextGeneratorFileSystemAccess getRuntimeRoot(); - IXtextGeneratorFileSystemAccess getRuntimeMetaInf(); - IXtextGeneratorFileSystemAccess getRuntimeSrc(); - IXtextGeneratorFileSystemAccess getRuntimeSrcGen(); - ManifestAccess getRuntimeManifest(); - PluginXmlAccess getRuntimePluginXml(); - - String getRuntimeTestProjectName(); - IXtextGeneratorFileSystemAccess getRuntimeTestRoot(); - IXtextGeneratorFileSystemAccess getRuntimeTestMetaInf(); - IXtextGeneratorFileSystemAccess getRuntimeTestSrc(); - IXtextGeneratorFileSystemAccess getRuntimeTestSrcGen(); - ManifestAccess getRuntimeTestManifest(); - PluginXmlAccess getRuntimeTestPluginXml(); - - String getGenericIdeProjectName(); - IXtextGeneratorFileSystemAccess getGenericIdeRoot(); - IXtextGeneratorFileSystemAccess getGenericIdeMetaInf(); - IXtextGeneratorFileSystemAccess getGenericIdeSrc(); - IXtextGeneratorFileSystemAccess getGenericIdeSrcGen(); - ManifestAccess getGenericIdeManifest(); - PluginXmlAccess getGenericIdePluginXml(); - - String getGenericIdeTestProjectName(); - IXtextGeneratorFileSystemAccess getGenericIdeTestRoot(); - IXtextGeneratorFileSystemAccess getGenericIdeTestMetaInf(); - IXtextGeneratorFileSystemAccess getGenericIdeTestSrc(); - IXtextGeneratorFileSystemAccess getGenericIdeTestSrcGen(); - ManifestAccess getGenericIdeTestManifest(); - PluginXmlAccess getGenericIdeTestPluginXml(); - - String getEclipsePluginProjectName(); - IXtextGeneratorFileSystemAccess getEclipsePluginRoot(); - IXtextGeneratorFileSystemAccess getEclipsePluginMetaInf(); - IXtextGeneratorFileSystemAccess getEclipsePluginSrc(); - IXtextGeneratorFileSystemAccess getEclipsePluginSrcGen(); - ManifestAccess getEclipsePluginManifest(); - PluginXmlAccess getEclipsePluginPluginXml(); - - String getEclipsePluginTestProjectName(); - IXtextGeneratorFileSystemAccess getEclipsePluginTestRoot(); - IXtextGeneratorFileSystemAccess getEclipsePluginTestMetaInf(); - IXtextGeneratorFileSystemAccess getEclipsePluginTestSrc(); - IXtextGeneratorFileSystemAccess getEclipsePluginTestSrcGen(); - ManifestAccess getEclipsePluginTestManifest(); - PluginXmlAccess getEclipsePluginTestPluginXml(); - - String getIdeaPluginProjectName(); - IXtextGeneratorFileSystemAccess getIdeaPluginRoot(); - IXtextGeneratorFileSystemAccess getIdeaPluginMetaInf(); - IXtextGeneratorFileSystemAccess getIdeaPluginSrc(); - IXtextGeneratorFileSystemAccess getIdeaPluginSrcGen(); - ManifestAccess getIdeaPluginManifest(); - - String getIdeaPluginTestProjectName(); - IXtextGeneratorFileSystemAccess getIdeaPluginTestRoot(); - IXtextGeneratorFileSystemAccess getIdeaPluginTestMetaInf(); - IXtextGeneratorFileSystemAccess getIdeaPluginTestSrc(); - IXtextGeneratorFileSystemAccess getIdeaPluginTestSrcGen(); - ManifestAccess getIdeaPluginTestManifest(); - - String getWebProjectName(); - IXtextGeneratorFileSystemAccess getWebRoot(); - IXtextGeneratorFileSystemAccess getWebMetaInf(); - IXtextGeneratorFileSystemAccess getWebSrc(); - IXtextGeneratorFileSystemAccess getWebSrcGen(); - ManifestAccess getWebManifest(); - - String getWebTestProjectName(); - IXtextGeneratorFileSystemAccess getWebTestRoot(); - IXtextGeneratorFileSystemAccess getWebTestMetaInf(); - IXtextGeneratorFileSystemAccess getWebTestSrc(); - IXtextGeneratorFileSystemAccess getWebTestSrcGen(); - ManifestAccess getWebTestManifest(); - - IXtextGeneratorFileSystemAccess getWebApp(); - -} diff --git a/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/ImplicitFragment.xtend b/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/ImplicitFragment.xtend index 6365709bf..0ab2ef56b 100644 --- a/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/ImplicitFragment.xtend +++ b/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/ImplicitFragment.xtend @@ -19,26 +19,24 @@ import static extension org.eclipse.xtext.xtext.generator.model.TypeReference.* package class ImplicitFragment extends AbstractGeneratorFragment2 { - @Inject IXtextProjectConfig projectConfig - @Inject extension XbaseUsageDetector @Inject extension XtextGeneratorNaming naming override generate() { - if (projectConfig.runtimeManifest !== null) { - projectConfig.runtimeManifest.requiredBundles.addAll(#[ + if (projectConfig.runtime.manifest !== null) { + projectConfig.runtime.manifest.requiredBundles.addAll(#[ 'org.eclipse.xtext', 'org.eclipse.xtext.util', 'org.eclipse.xtend.lib' ]) - projectConfig.runtimeManifest.importedPackages.add('org.apache.log4j') + projectConfig.runtime.manifest.importedPackages.add('org.apache.log4j') } - if (projectConfig.eclipsePluginManifest !== null) { - projectConfig.eclipsePluginManifest.requiredBundles.addAll(#[ + if (projectConfig.eclipsePlugin.manifest !== null) { + projectConfig.eclipsePlugin.manifest.requiredBundles.addAll(#[ 'org.eclipse.xtext.ui', 'org.eclipse.xtext.ui.shared', 'org.eclipse.ui.editors', 'org.eclipse.ui', 'org.eclipse.xtend.lib' ]) } - if (projectConfig.eclipsePluginPluginXml !== null) { - projectConfig.eclipsePluginPluginXml.entries += grammar.implicitPluginXmlEnties + if (projectConfig.eclipsePlugin.pluginXml !== null) { + projectConfig.eclipsePlugin.pluginXml.entries += grammar.implicitPluginXmlEnties } val StringConcatenationClient expression = '''«'org.eclipse.xtext.ui.shared.Access'.typeRef».getJavaProjectsState()''' diff --git a/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/NewWizardConfig.xtend b/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/NewWizardConfig.xtend new file mode 100644 index 000000000..1b4e46769 --- /dev/null +++ b/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/NewWizardConfig.xtend @@ -0,0 +1,113 @@ +/******************************************************************************* + * 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.xtext.generator + +import org.eclipse.emf.mwe2.runtime.Mandatory +import org.eclipse.xtend.lib.annotations.Accessors +import org.eclipse.xtext.xtext.generator.model.ManifestAccess +import org.eclipse.xtext.xtext.generator.model.PluginXmlAccess + +@Accessors +class WizardConfig extends XtextProjectConfig { + + boolean mavenLayout + boolean createEclipseMetaData + String rootPath + String baseName + + @Mandatory + def setBaseName(String baseName) { + this.baseName = baseName + } + + @Mandatory + def setRootPath(String rootPath) { + this.rootPath = rootPath + } + + override checkConfiguration(Issues issues) { + super.checkConfiguration(issues) + if (rootPath === null) + issues.addError("The property 'rootPath' must be set", this) + if (baseName === null) + issues.addError("The property 'baseName' must be set", this) + } + + override setDefaults() { + super.setDefaults + enabledProjects.forEach [ + if (name === null) + name = computeName + if (root === null) + root = computeRoot + if (metaInf === null) + metaInf = computeMetaInf + if (src === null) + src = computeSrc + if (srcGen === null) + srcGen = computeSrcGen + if (it instanceof BundleProjectConfig) { + if (createEclipseMetaData) { + if (manifest === null) + manifest = new ManifestAccess + if (pluginXml === null) + pluginXml = new PluginXmlAccess + } + } + if (it instanceof RuntimeProjectConfig) { + if (ecoreModel === null) + ecoreModel = computeEcoreModel + } + if (it instanceof WebProjectConfig) { + if (assets === null) + assets = computeAssets + } + ] + } + + protected def computeName(SubProjectConfig project) { + switch project { + case runtime: baseName + case runtimeTest: baseName + '.tests' + case genericIde: baseName + '.ide' + case eclipsePlugin: baseName + '.ui' + case eclipsePluginTest: baseName + '.ui.tests' + case ideaPlugin: baseName + '.idea' + case web: baseName + '.web' + } + } + + protected def computeRoot(SubProjectConfig project) { + rootPath + '/' + project.name + } + + protected def computeSrc(SubProjectConfig project) { + project.root.path + '/' + if(mavenLayout) 'src/' + project.computeSourceSet + '/java' else 'src' + } + + protected def computeSrcGen(SubProjectConfig project) { + project.root.path + '/' + if(mavenLayout) 'src/' + project.computeSourceSet + '/xtext-gen' else 'src-gen' + } + + protected def computeMetaInf(SubProjectConfig project) { + project.root.path + '/' + if(mavenLayout) 'src/' + project.computeSourceSet + '/resources/META-INF' else 'META-INF' + } + + protected def computeEcoreModel(RuntimeProjectConfig project) { + project.root.path + '/' + if(mavenLayout) 'src/' + project.computeSourceSet + '/ecore/generated' else 'model/generated' + } + + protected def computeAssets(WebProjectConfig project) { + project.root.path + '/' + if(mavenLayout) 'src/' + project.computeSourceSet + '/webapp' else 'WebRoot' + } + + protected def computeSourceSet(SubProjectConfig project) { + if(testProjects.contains(project)) 'test' else 'main' + } + +} \ No newline at end of file diff --git a/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/NewXtextProjectConfig.xtend b/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/NewXtextProjectConfig.xtend new file mode 100644 index 000000000..58b51cbd1 --- /dev/null +++ b/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/NewXtextProjectConfig.xtend @@ -0,0 +1,69 @@ +/******************************************************************************* + * 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.xtext.generator + +import com.google.inject.Injector +import java.util.List +import org.eclipse.xtend.lib.annotations.Accessors + +@Accessors +class XtextProjectConfig implements IGuiceAwareGeneratorComponent { + RuntimeProjectConfig runtime = new RuntimeProjectConfig + BundleProjectConfig runtimeTest = new BundleProjectConfig + BundleProjectConfig genericIde = new BundleProjectConfig + BundleProjectConfig eclipsePlugin = new BundleProjectConfig + BundleProjectConfig eclipsePluginTest = new BundleProjectConfig + SubProjectConfig ideaPlugin = new SubProjectConfig + WebProjectConfig web = new WebProjectConfig + + def void checkConfiguration(Issues issues) { + enabledProjects.forEach[checkConfiguration(issues)] + } + + def List extends SubProjectConfig> getAllProjects() { + val allProjects = newArrayList + allProjects += #[ + runtime, + runtimeTest, + genericIde, + eclipsePlugin, + eclipsePluginTest, + ideaPlugin, + web + ] + allProjects + } + + def List extends SubProjectConfig> getTestProjects() { + val testProjects = newArrayList + testProjects += #[ + runtimeTest, + eclipsePluginTest + ] + testProjects + } + + def List extends SubProjectConfig> getEnabledProjects() { + val enabledProjects = newArrayList + enabledProjects += allProjects.filter[enabled] + enabledProjects + } + + override initialize(Injector injector) { + setDefaults + injector.injectMembers(this) + enabledProjects.forEach[initialize(injector)] + } + + def setDefaults() { + runtime.enabled = true + if (#[eclipsePlugin, ideaPlugin, web].exists[enabled]) + genericIde.enabled = true + } + +} \ No newline at end of file diff --git a/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/SubProjectConfig.xtend b/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/SubProjectConfig.xtend new file mode 100644 index 000000000..95ef45abe --- /dev/null +++ b/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/SubProjectConfig.xtend @@ -0,0 +1,123 @@ +/******************************************************************************* + * 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.xtext.generator + +import com.google.common.base.CharMatcher +import com.google.inject.Injector +import org.eclipse.xtend.lib.annotations.Accessors +import org.eclipse.xtext.xtext.generator.model.IXtextGeneratorFileSystemAccess +import org.eclipse.xtext.xtext.generator.model.ManifestAccess +import org.eclipse.xtext.xtext.generator.model.PluginXmlAccess +import org.eclipse.xtext.xtext.generator.model.XtextGeneratorFileSystemAccess + + +class SubProjectConfig implements IGuiceAwareGeneratorComponent { + @Accessors + boolean enabled + @Accessors + String name + @Accessors(PUBLIC_GETTER) + IXtextGeneratorFileSystemAccess root + @Accessors(PUBLIC_GETTER) + IXtextGeneratorFileSystemAccess metaInf + @Accessors(PUBLIC_GETTER) + IXtextGeneratorFileSystemAccess src + @Accessors(PUBLIC_GETTER) + IXtextGeneratorFileSystemAccess srcGen + + def void setRoot(String path) { + root = new XtextGeneratorFileSystemAccess(path, true) + } + + def void setMetaInf(String path) { + metaInf = new XtextGeneratorFileSystemAccess(path, true) + } + + def void setSrc(String path) { + src = new XtextGeneratorFileSystemAccess(path, false) + } + + def void setSrcGen(String path) { + srcGen = new XtextGeneratorFileSystemAccess(path, true) + } + + def void checkConfiguration(Issues issues) { + } + + override initialize(Injector injector) { + injector.injectMembers(this) + root?.initialize(injector) + metaInf?.initialize(injector) + src?.initialize(injector) + srcGen?.initialize(injector) + } + +} + +@Accessors +class BundleProjectConfig extends SubProjectConfig { + ManifestAccess manifest + PluginXmlAccess pluginXml + + override initialize(Injector injector) { + super.initialize(injector) + manifest?.initialize(injector) + pluginXml?.initialize(injector) + } + + override checkConfiguration(Issues issues) { + super.checkConfiguration(issues) + if (manifest !== null && metaInf === null) { + issues.addError("The 'metaInf' outlet must be configured for projects with a manifest", this) + } + if (pluginXml !== null && root === null) { + issues.addError("The 'root' outlet must be configured for projects with a plugin.xml", this) + } + } + +} + +class RuntimeProjectConfig extends BundleProjectConfig { + @Accessors(PUBLIC_GETTER) + IXtextGeneratorFileSystemAccess ecoreModel + + def void setEcoreModel(String path) { + ecoreModel = new XtextGeneratorFileSystemAccess(path, true) + } + + /** + * Returns the root-relative path of the folder where the generated .ecore and .genmodel can be found. + * The path is delimited by and ends with '/' + */ + def String getEcoreModelFolder() { + val ecoreModelFolder = ecoreModel.path.replace(root.path, "").replace('\\', '/') + val slashes = CharMatcher.is('/') + slashes.trimFrom(ecoreModelFolder) + "/" + } + + override initialize(Injector injector) { + super.initialize(injector) + ecoreModel?.initialize(injector) + } + +} + +class WebProjectConfig extends SubProjectConfig { + @Accessors(PUBLIC_GETTER) + IXtextGeneratorFileSystemAccess assets + + def void setAssets(String path) { + assets = new XtextGeneratorFileSystemAccess(path, true) + } + + override initialize(Injector injector) { + super.initialize(injector) + assets?.initialize(injector) + } + +} \ No newline at end of file diff --git a/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/WizardConfig.xtend b/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/WizardConfig.xtend deleted file mode 100644 index 5503be42e..000000000 --- a/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/WizardConfig.xtend +++ /dev/null @@ -1,194 +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.xtext.generator - -import com.google.inject.Injector -import org.eclipse.emf.mwe2.runtime.Mandatory -import org.eclipse.xtend.lib.annotations.Accessors -import org.eclipse.xtext.xtext.generator.model.ManifestAccess -import org.eclipse.xtext.xtext.generator.model.PluginXmlAccess - -@Accessors -class WizardConfig extends XtextProjectConfig { - - boolean eclipseEditor = true - - boolean ideaEditor = false - - boolean webSupport = false - - boolean genericIdeSupport = false - - boolean testingSupport = false - - boolean mavenLayout = false - - String rootPath - - String baseName - - @Mandatory - def setBaseName(String baseName) { - this.baseName = baseName - } - - @Mandatory - def setRootPath(String rootPath) { - this.rootPath = rootPath - } - - override checkConfiguration(Issues issues) { - super.checkConfiguration(issues) - if (rootPath == null) { - issues.addError('The property \'rootPath\' must be set.', this) - return - } - if (baseName == null) { - issues.addError('The property \'baseName\' must be set.', this) - return - } - val runtimeBase = runtimeRoot?.path - if (!Character.isJavaIdentifierPart(runtimeBase.charAt(runtimeBase.length - 1))) - issues.addError('The runtime root path must end with a valid package name.', this) - if ((ideaEditor || webSupport) && !genericIdeSupport) - issues.addError('Generic IDE support must be enabled when the IDEA or web editors are enabled.', this) - } - - override initialize(Injector injector) { - var src = 'src' - var testSrc = src - var srcGen = 'src-gen' - var testSrcGen = srcGen - var metaInf = 'META-INF' - var modelGen = 'model/generated' - var srcWeb = 'WebRoot' - if (mavenLayout) { - src = 'src/main/java' - testSrc = 'src/test/java' - srcGen = 'src/main/xtext-gen' - testSrcGen = 'src/test/xtext-gen' - metaInf = 'src/main/resources/META-INF' - modelGen = 'src/main/model-gen' - srcWeb = 'src/main/webapp' - } - - if (runtimeProjectName=== null) - runtimeProjectName = baseName - if (runtimeRoot === null) - runtimeRoot = rootPath + '/' + runtimeProjectName - if (runtimeMetaInf === null) - runtimeMetaInf = runtimeRoot.path + '/' + metaInf - if (runtimeSrc === null) - runtimeSrc = runtimeRoot.path + '/' + src - if (runtimeSrcGen === null) - runtimeSrcGen = runtimeRoot.path + '/' + srcGen - if (runtimeManifest === null) - runtimeManifest = injector.getInstance(ManifestAccess) - if (runtimePluginXml === null) - runtimePluginXml = injector.getInstance(PluginXmlAccess) - if (runtimeModelGen === null) - runtimeModelGen = runtimeRoot.path + '/' + modelGen - - if (testingSupport) { - if (runtimeTestProjectName=== null) - if(mavenLayout) { - runtimeTestProjectName = runtimeProjectName - } else { - runtimeTestProjectName = runtimeProjectName + ".tests" - } - if (runtimeTestRoot === null) - runtimeTestRoot = rootPath + '/' + runtimeTestProjectName - if (runtimeTestMetaInf=== null) - runtimeTestMetaInf = runtimeTestRoot.path + '/' + metaInf - if (runtimeTestSrc === null) - runtimeTestSrc = runtimeTestRoot.path + '/' + testSrc - if (runtimeTestSrcGen === null) - runtimeTestSrcGen = runtimeTestRoot.path + '/' + testSrcGen - if (runtimeTestManifest === null) - runtimeTestManifest = injector.getInstance(ManifestAccess) - } - - if (eclipseEditor) { - if (eclipsePluginProjectName=== null) - eclipsePluginProjectName = baseName + '.ui' - if (eclipsePluginRoot === null) - eclipsePluginRoot = rootPath + '/' + eclipsePluginProjectName - if (eclipsePluginMetaInf === null) - eclipsePluginMetaInf = eclipsePluginRoot.path + '/' + metaInf - if (eclipsePluginSrc === null) - eclipsePluginSrc = eclipsePluginRoot.path + '/' + src - if (eclipsePluginSrcGen === null) - eclipsePluginSrcGen = eclipsePluginRoot.path + '/' + srcGen - if (eclipsePluginManifest === null) - eclipsePluginManifest = injector.getInstance(ManifestAccess) - if (eclipsePluginPluginXml === null) - eclipsePluginPluginXml = injector.getInstance(PluginXmlAccess) - - if (testingSupport) { - if (eclipsePluginTestProjectName=== null) - eclipsePluginTestProjectName = eclipsePluginProjectName + '.tests' - if (eclipsePluginTestRoot === null) - eclipsePluginTestRoot = rootPath + '/' + eclipsePluginTestProjectName - if (eclipsePluginTestRoot === null) - eclipsePluginTestRoot = eclipsePluginRoot.path + '.tests' - if (eclipsePluginTestMetaInf === null) - eclipsePluginTestMetaInf = eclipsePluginTestRoot.path + '/' + metaInf - if (eclipsePluginTestSrc === null) - eclipsePluginTestSrc = eclipsePluginTestRoot.path + '/' + testSrc - if (eclipsePluginTestSrcGen === null) - eclipsePluginTestSrcGen = eclipsePluginTestRoot.path + '/' + testSrcGen - if (eclipsePluginTestManifest === null) - eclipsePluginTestManifest = injector.getInstance(ManifestAccess) - } - } - - if (ideaEditor) { - if (ideaPluginProjectName=== null) - ideaPluginProjectName = baseName + '.idea' - if (ideaPluginRoot === null) - ideaPluginRoot = rootPath + '/' + ideaPluginProjectName - if (ideaPluginSrc === null) - ideaPluginSrc = ideaPluginRoot.path + '/' + src - if (ideaPluginSrcGen === null) - ideaPluginSrcGen = ideaPluginRoot.path + '/' + srcGen - if (ideaPluginMetaInf === null) - ideaPluginMetaInf = ideaPluginRoot.path + '/' + metaInf - } - - if (webSupport) { - if (webProjectName=== null) - webProjectName = baseName + '.web' - if (webRoot === null) - webRoot = rootPath + '/' + webProjectName - if (webSrc === null) - webSrc = webRoot.path + '/' + src - if (webSrcGen === null) - webSrcGen = webRoot.path + '/' + srcGen - if (webApp === null) - webApp = webRoot.path + '/' + srcWeb - } - - if (genericIdeSupport) { - if (genericIdeProjectName=== null) - genericIdeProjectName = baseName + '.ide' - if (genericIdeRoot === null) - genericIdeRoot = rootPath + '/' + genericIdeProjectName - if (genericIdeMetaInf === null) - genericIdeMetaInf = genericIdeRoot.path + '/' + metaInf - if (genericIdeSrc === null) - genericIdeSrc = genericIdeRoot.path + '/' + src - if (genericIdeSrcGen === null) - genericIdeSrcGen = genericIdeRoot.path + '/' + srcGen - if (genericIdeManifest === null) - genericIdeManifest = injector.getInstance(ManifestAccess) - } - - super.initialize(injector) - } - -} \ No newline at end of file diff --git a/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/XtextDirectoryCleaner.xtend b/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/XtextDirectoryCleaner.xtend index ae6ea810d..41ce5119d 100644 --- a/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/XtextDirectoryCleaner.xtend +++ b/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/XtextDirectoryCleaner.xtend @@ -15,7 +15,7 @@ import org.eclipse.xtend.lib.annotations.Accessors import java.io.File class XtextDirectoryCleaner implements IGuiceAwareGeneratorComponent { - @Inject IXtextProjectConfig config + @Inject XtextProjectConfig config @Accessors(PUBLIC_SETTER) boolean enabled = true @@ -38,19 +38,7 @@ class XtextDirectoryCleaner implements IGuiceAwareGeneratorComponent { return; val directories = newArrayList - directories += #[ - config.runtimeModelGen, - config.runtimeSrcGen, - config.runtimeTestSrcGen, - config.genericIdeSrcGen, - config.genericIdeTestSrcGen, - config.eclipsePluginSrcGen, - config.eclipsePluginTestSrcGen, - config.ideaPluginSrcGen, - config.ideaPluginTestSrcGen, - config.webSrcGen, - config.webTestSrcGen - ].filterNull.map[path].filter[new File(it).isDirectory] + directories += (config.enabledProjects.map[srcGen] + #[config.runtime.ecoreModel]).filterNull.map[path].filter[new File(it).isDirectory] directories += extraDirectories val delegate = new DirectoryCleaner diff --git a/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/XtextGenerator.xtend b/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/XtextGenerator.xtend index 4e0eac2af..4de0aa260 100644 --- a/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/XtextGenerator.xtend +++ b/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/XtextGenerator.xtend @@ -58,7 +58,7 @@ class XtextGenerator extends AbstractWorkflowComponent2 { Injector injector - @Inject IXtextProjectConfig projectConfig + @Inject XtextProjectConfig projectConfig @Inject XtextGeneratorTemplates templates @@ -136,40 +136,30 @@ class XtextGenerator extends AbstractWorkflowComponent2 { } protected def generateSetups(ILanguageConfig language) { - templates.createRuntimeGenSetup(language).writeTo(projectConfig.runtimeSrcGen) - templates.createRuntimeSetup(language).writeTo(projectConfig.runtimeSrc) - templates.createWebSetup(language).writeTo(projectConfig.webSrc) + templates.createRuntimeGenSetup(language).writeTo(projectConfig.runtime.srcGen) + templates.createRuntimeSetup(language).writeTo(projectConfig.runtime.src) + templates.createWebSetup(language).writeTo(projectConfig.web.src) } protected def generateModules(ILanguageConfig language) { - templates.createRuntimeGenModule(language).writeTo(projectConfig.runtimeSrcGen) - templates.createRuntimeModule(language).writeTo(projectConfig.runtimeSrc) - templates.createEclipsePluginGenModule(language).writeTo(projectConfig.eclipsePluginSrcGen) - templates.createEclipsePluginModule(language).writeTo(projectConfig.eclipsePluginSrc) - templates.createIdeaGenModule(language).writeTo(projectConfig.ideaPluginSrcGen) - templates.createIdeaModule(language).writeTo(projectConfig.ideaPluginSrc) - templates.createWebGenModule(language).writeTo(projectConfig.webSrcGen) - templates.createWebModule(language).writeTo(projectConfig.webSrc) + templates.createRuntimeGenModule(language).writeTo(projectConfig.runtime.srcGen) + templates.createRuntimeModule(language).writeTo(projectConfig.runtime.src) + templates.createEclipsePluginGenModule(language).writeTo(projectConfig.eclipsePlugin.srcGen) + templates.createEclipsePluginModule(language).writeTo(projectConfig.eclipsePlugin.src) + templates.createIdeaGenModule(language).writeTo(projectConfig.ideaPlugin.srcGen) + templates.createIdeaModule(language).writeTo(projectConfig.ideaPlugin.src) + templates.createWebGenModule(language).writeTo(projectConfig.web.srcGen) + templates.createWebModule(language).writeTo(projectConfig.web.src) } protected def generateExecutableExtensionFactory(ILanguageConfig language) { - if (projectConfig.eclipsePluginSrcGen !== null) - templates.createEclipsePluginExecutableExtensionFactory(language, languageConfigs.head).writeTo(projectConfig.eclipsePluginSrcGen) + if (projectConfig.eclipsePlugin.srcGen !== null) + templates.createEclipsePluginExecutableExtensionFactory(language, languageConfigs.head).writeTo(projectConfig.eclipsePlugin.srcGen) } protected def generateManifests() { - val manifests = newLinkedList( - Tuples.create(projectConfig.runtimeManifest, projectConfig.runtimeMetaInf, projectConfig.runtimeProjectName), - Tuples.create(projectConfig.runtimeTestManifest, projectConfig.runtimeTestMetaInf, projectConfig.runtimeTestProjectName), - Tuples.create(projectConfig.genericIdeManifest, projectConfig.genericIdeMetaInf, projectConfig.genericIdeProjectName), - Tuples.create(projectConfig.genericIdeTestManifest, projectConfig.genericIdeTestMetaInf, projectConfig.genericIdeTestProjectName), - Tuples.create(projectConfig.eclipsePluginManifest, projectConfig.eclipsePluginMetaInf, projectConfig.eclipsePluginProjectName), - Tuples.create(projectConfig.eclipsePluginTestManifest, projectConfig.eclipsePluginTestMetaInf, projectConfig.eclipsePluginTestProjectName), - Tuples.create(projectConfig.ideaPluginManifest, projectConfig.ideaPluginMetaInf, projectConfig.ideaPluginProjectName), - Tuples.create(projectConfig.ideaPluginTestManifest, projectConfig.ideaPluginTestMetaInf, projectConfig.ideaPluginTestProjectName), - Tuples.create(projectConfig.webManifest, projectConfig.webMetaInf, projectConfig.webProjectName), - Tuples.create(projectConfig.webTestManifest, projectConfig.webTestMetaInf, projectConfig.webTestProjectName) - ) + val manifests = projectConfig.enabledProjects.filter(BundleProjectConfig) + .map[Tuples.create(manifest, metaInf, name)].toList // Filter null values and merge duplicate entries val uri2Manifest = Maps.This file has been generated with {@link org.eclipse.xtext.xtext.generator.internal.ProjectConfigGenerator}.
- */ -public class XtextProjectConfig implements IXtextProjectConfig { - - private IXtextGeneratorFileSystemAccess runtimeModelGen; - private String runtimeProjectName; - private IXtextGeneratorFileSystemAccess runtimeRoot; - private IXtextGeneratorFileSystemAccess runtimeMetaInf; - private IXtextGeneratorFileSystemAccess runtimeSrc; - private IXtextGeneratorFileSystemAccess runtimeSrcGen; - private ManifestAccess runtimeManifest; - private PluginXmlAccess runtimePluginXml; - private String runtimeTestProjectName; - private IXtextGeneratorFileSystemAccess runtimeTestRoot; - private IXtextGeneratorFileSystemAccess runtimeTestMetaInf; - private IXtextGeneratorFileSystemAccess runtimeTestSrc; - private IXtextGeneratorFileSystemAccess runtimeTestSrcGen; - private ManifestAccess runtimeTestManifest; - private PluginXmlAccess runtimeTestPluginXml; - private String genericIdeProjectName; - private IXtextGeneratorFileSystemAccess genericIdeRoot; - private IXtextGeneratorFileSystemAccess genericIdeMetaInf; - private IXtextGeneratorFileSystemAccess genericIdeSrc; - private IXtextGeneratorFileSystemAccess genericIdeSrcGen; - private ManifestAccess genericIdeManifest; - private PluginXmlAccess genericIdePluginXml; - private String genericIdeTestProjectName; - private IXtextGeneratorFileSystemAccess genericIdeTestRoot; - private IXtextGeneratorFileSystemAccess genericIdeTestMetaInf; - private IXtextGeneratorFileSystemAccess genericIdeTestSrc; - private IXtextGeneratorFileSystemAccess genericIdeTestSrcGen; - private ManifestAccess genericIdeTestManifest; - private PluginXmlAccess genericIdeTestPluginXml; - private String eclipsePluginProjectName; - private IXtextGeneratorFileSystemAccess eclipsePluginRoot; - private IXtextGeneratorFileSystemAccess eclipsePluginMetaInf; - private IXtextGeneratorFileSystemAccess eclipsePluginSrc; - private IXtextGeneratorFileSystemAccess eclipsePluginSrcGen; - private ManifestAccess eclipsePluginManifest; - private PluginXmlAccess eclipsePluginPluginXml; - private String eclipsePluginTestProjectName; - private IXtextGeneratorFileSystemAccess eclipsePluginTestRoot; - private IXtextGeneratorFileSystemAccess eclipsePluginTestMetaInf; - private IXtextGeneratorFileSystemAccess eclipsePluginTestSrc; - private IXtextGeneratorFileSystemAccess eclipsePluginTestSrcGen; - private ManifestAccess eclipsePluginTestManifest; - private PluginXmlAccess eclipsePluginTestPluginXml; - private String ideaPluginProjectName; - private IXtextGeneratorFileSystemAccess ideaPluginRoot; - private IXtextGeneratorFileSystemAccess ideaPluginMetaInf; - private IXtextGeneratorFileSystemAccess ideaPluginSrc; - private IXtextGeneratorFileSystemAccess ideaPluginSrcGen; - private ManifestAccess ideaPluginManifest; - private String ideaPluginTestProjectName; - private IXtextGeneratorFileSystemAccess ideaPluginTestRoot; - private IXtextGeneratorFileSystemAccess ideaPluginTestMetaInf; - private IXtextGeneratorFileSystemAccess ideaPluginTestSrc; - private IXtextGeneratorFileSystemAccess ideaPluginTestSrcGen; - private ManifestAccess ideaPluginTestManifest; - private String webProjectName; - private IXtextGeneratorFileSystemAccess webRoot; - private IXtextGeneratorFileSystemAccess webMetaInf; - private IXtextGeneratorFileSystemAccess webSrc; - private IXtextGeneratorFileSystemAccess webSrcGen; - private ManifestAccess webManifest; - private String webTestProjectName; - private IXtextGeneratorFileSystemAccess webTestRoot; - private IXtextGeneratorFileSystemAccess webTestMetaInf; - private IXtextGeneratorFileSystemAccess webTestSrc; - private IXtextGeneratorFileSystemAccess webTestSrcGen; - private ManifestAccess webTestManifest; - private IXtextGeneratorFileSystemAccess webApp; - - public void checkConfiguration(Issues issues) { - if (runtimeSrc == null) { - issues.addError("The property 'runtimeSrc' must be set.", this); - } - if (runtimeSrcGen == null) { - issues.addError("The property 'runtimeSrcGen' must be set.", this); - } - if (runtimeManifest != null && runtimeMetaInf == null) { - issues.addError("The property 'runtimeMetaInf' must be set when 'runtimeManifest' is set."); - } - if (runtimePluginXml != null && runtimeRoot == null) { - issues.addError("The property 'runtimeRoot' must be set when 'runtimePluginXml' is set."); - } - if (runtimeTestManifest != null && runtimeTestMetaInf == null) { - issues.addError("The property 'runtimeTestMetaInf' must be set when 'runtimeTestManifest' is set."); - } - if (runtimeTestPluginXml != null && runtimeTestRoot == null) { - issues.addError("The property 'runtimeTestRoot' must be set when 'runtimeTestPluginXml' is set."); - } - if (genericIdeManifest != null && genericIdeMetaInf == null) { - issues.addError("The property 'genericIdeMetaInf' must be set when 'genericIdeManifest' is set."); - } - if (genericIdePluginXml != null && genericIdeRoot == null) { - issues.addError("The property 'genericIdeRoot' must be set when 'genericIdePluginXml' is set."); - } - if (genericIdeTestManifest != null && genericIdeTestMetaInf == null) { - issues.addError("The property 'genericIdeTestMetaInf' must be set when 'genericIdeTestManifest' is set."); - } - if (genericIdeTestPluginXml != null && genericIdeTestRoot == null) { - issues.addError("The property 'genericIdeTestRoot' must be set when 'genericIdeTestPluginXml' is set."); - } - if (eclipsePluginManifest != null && eclipsePluginMetaInf == null) { - issues.addError("The property 'eclipsePluginMetaInf' must be set when 'eclipsePluginManifest' is set."); - } - if (eclipsePluginPluginXml != null && eclipsePluginRoot == null) { - issues.addError("The property 'eclipsePluginRoot' must be set when 'eclipsePluginPluginXml' is set."); - } - if (eclipsePluginTestManifest != null && eclipsePluginTestMetaInf == null) { - issues.addError("The property 'eclipsePluginTestMetaInf' must be set when 'eclipsePluginTestManifest' is set."); - } - if (eclipsePluginTestPluginXml != null && eclipsePluginTestRoot == null) { - issues.addError("The property 'eclipsePluginTestRoot' must be set when 'eclipsePluginTestPluginXml' is set."); - } - if (ideaPluginManifest != null && ideaPluginMetaInf == null) { - issues.addError("The property 'ideaPluginMetaInf' must be set when 'ideaPluginManifest' is set."); - } - if (ideaPluginTestManifest != null && ideaPluginTestMetaInf == null) { - issues.addError("The property 'ideaPluginTestMetaInf' must be set when 'ideaPluginTestManifest' is set."); - } - if (webManifest != null && webMetaInf == null) { - issues.addError("The property 'webMetaInf' must be set when 'webManifest' is set."); - } - if (webTestManifest != null && webTestMetaInf == null) { - issues.addError("The property 'webTestMetaInf' must be set when 'webTestManifest' is set."); - } - } - - @Override - public void initialize(Injector injector) { - injector.injectMembers(this); - if (runtimeModelGen != null) { - runtimeModelGen.initialize(injector); - } - - // Initialize runtime configuration - if (runtimeRoot != null) { - runtimeRoot.initialize(injector); - } - if (runtimeMetaInf != null) { - runtimeMetaInf.initialize(injector); - } - if (runtimeSrc != null) { - runtimeSrc.initialize(injector); - } - if (runtimeSrcGen != null) { - runtimeSrcGen.initialize(injector); - } - - // Initialize runtimeTest configuration - if (runtimeTestRoot != null) { - runtimeTestRoot.initialize(injector); - } - if (runtimeTestMetaInf != null) { - runtimeTestMetaInf.initialize(injector); - } - if (runtimeTestSrc != null) { - runtimeTestSrc.initialize(injector); - } - if (runtimeTestSrcGen != null) { - runtimeTestSrcGen.initialize(injector); - } - - // Initialize genericIde configuration - if (genericIdeRoot != null) { - genericIdeRoot.initialize(injector); - } - if (genericIdeMetaInf != null) { - genericIdeMetaInf.initialize(injector); - } - if (genericIdeSrc != null) { - genericIdeSrc.initialize(injector); - } - if (genericIdeSrcGen != null) { - genericIdeSrcGen.initialize(injector); - } - - // Initialize genericIdeTest configuration - if (genericIdeTestRoot != null) { - genericIdeTestRoot.initialize(injector); - } - if (genericIdeTestMetaInf != null) { - genericIdeTestMetaInf.initialize(injector); - } - if (genericIdeTestSrc != null) { - genericIdeTestSrc.initialize(injector); - } - if (genericIdeTestSrcGen != null) { - genericIdeTestSrcGen.initialize(injector); - } - - // Initialize eclipsePlugin configuration - if (eclipsePluginRoot != null) { - eclipsePluginRoot.initialize(injector); - } - if (eclipsePluginMetaInf != null) { - eclipsePluginMetaInf.initialize(injector); - } - if (eclipsePluginSrc != null) { - eclipsePluginSrc.initialize(injector); - } - if (eclipsePluginSrcGen != null) { - eclipsePluginSrcGen.initialize(injector); - } - - // Initialize eclipsePluginTest configuration - if (eclipsePluginTestRoot != null) { - eclipsePluginTestRoot.initialize(injector); - } - if (eclipsePluginTestMetaInf != null) { - eclipsePluginTestMetaInf.initialize(injector); - } - if (eclipsePluginTestSrc != null) { - eclipsePluginTestSrc.initialize(injector); - } - if (eclipsePluginTestSrcGen != null) { - eclipsePluginTestSrcGen.initialize(injector); - } - - // Initialize ideaPlugin configuration - if (ideaPluginRoot != null) { - ideaPluginRoot.initialize(injector); - } - if (ideaPluginMetaInf != null) { - ideaPluginMetaInf.initialize(injector); - } - if (ideaPluginSrc != null) { - ideaPluginSrc.initialize(injector); - } - if (ideaPluginSrcGen != null) { - ideaPluginSrcGen.initialize(injector); - } - - // Initialize ideaPluginTest configuration - if (ideaPluginTestRoot != null) { - ideaPluginTestRoot.initialize(injector); - } - if (ideaPluginTestMetaInf != null) { - ideaPluginTestMetaInf.initialize(injector); - } - if (ideaPluginTestSrc != null) { - ideaPluginTestSrc.initialize(injector); - } - if (ideaPluginTestSrcGen != null) { - ideaPluginTestSrcGen.initialize(injector); - } - - // Initialize web configuration - if (webRoot != null) { - webRoot.initialize(injector); - } - if (webMetaInf != null) { - webMetaInf.initialize(injector); - } - if (webSrc != null) { - webSrc.initialize(injector); - } - if (webSrcGen != null) { - webSrcGen.initialize(injector); - } - - // Initialize webTest configuration - if (webTestRoot != null) { - webTestRoot.initialize(injector); - } - if (webTestMetaInf != null) { - webTestMetaInf.initialize(injector); - } - if (webTestSrc != null) { - webTestSrc.initialize(injector); - } - if (webTestSrcGen != null) { - webTestSrcGen.initialize(injector); - } - - if (webApp != null) { - webApp.initialize(injector); - } - } - - @Override - public IXtextGeneratorFileSystemAccess getRuntimeModelGen() { - return runtimeModelGen; - } - - public void setRuntimeModelGen(String path) { - this.runtimeModelGen = new XtextGeneratorFileSystemAccess(path, true); - } - - @Override - public String getRuntimeProjectName() { - return runtimeProjectName; - } - - public void setRuntimeProjectName(String projectName) { - this.runtimeProjectName = projectName; - } - - @Override - public IXtextGeneratorFileSystemAccess getRuntimeRoot() { - return runtimeRoot; - } - - public void setRuntimeRoot(String path) { - this.runtimeRoot = new XtextGeneratorFileSystemAccess(path, true); - } - - @Override - public IXtextGeneratorFileSystemAccess getRuntimeMetaInf() { - return runtimeMetaInf; - } - - public void setRuntimeMetaInf(String path) { - this.runtimeMetaInf = new XtextGeneratorFileSystemAccess(path, true); - } - - @Override - public IXtextGeneratorFileSystemAccess getRuntimeSrc() { - return runtimeSrc; - } - - public void setRuntimeSrc(String path) { - this.runtimeSrc = new XtextGeneratorFileSystemAccess(path, false); - } - - @Override - public IXtextGeneratorFileSystemAccess getRuntimeSrcGen() { - return runtimeSrcGen; - } - - public void setRuntimeSrcGen(String path) { - this.runtimeSrcGen = new XtextGeneratorFileSystemAccess(path, true); - } - - @Override - public ManifestAccess getRuntimeManifest() { - return runtimeManifest; - } - - public void setRuntimeManifest(ManifestAccess manifest) { - this.runtimeManifest = manifest; - } - - @Override - public PluginXmlAccess getRuntimePluginXml() { - return runtimePluginXml; - } - - public void setRuntimePluginXml(PluginXmlAccess pluginXml) { - this.runtimePluginXml = pluginXml; - } - - @Override - public String getRuntimeTestProjectName() { - return runtimeTestProjectName; - } - - public void setRuntimeTestProjectName(String projectName) { - this.runtimeTestProjectName = projectName; - } - - @Override - public IXtextGeneratorFileSystemAccess getRuntimeTestRoot() { - return runtimeTestRoot; - } - - public void setRuntimeTestRoot(String path) { - this.runtimeTestRoot = new XtextGeneratorFileSystemAccess(path, true); - } - - @Override - public IXtextGeneratorFileSystemAccess getRuntimeTestMetaInf() { - return runtimeTestMetaInf; - } - - public void setRuntimeTestMetaInf(String path) { - this.runtimeTestMetaInf = new XtextGeneratorFileSystemAccess(path, true); - } - - @Override - public IXtextGeneratorFileSystemAccess getRuntimeTestSrc() { - return runtimeTestSrc; - } - - public void setRuntimeTestSrc(String path) { - this.runtimeTestSrc = new XtextGeneratorFileSystemAccess(path, false); - } - - @Override - public IXtextGeneratorFileSystemAccess getRuntimeTestSrcGen() { - return runtimeTestSrcGen; - } - - public void setRuntimeTestSrcGen(String path) { - this.runtimeTestSrcGen = new XtextGeneratorFileSystemAccess(path, true); - } - - @Override - public ManifestAccess getRuntimeTestManifest() { - return runtimeTestManifest; - } - - public void setRuntimeTestManifest(ManifestAccess manifest) { - this.runtimeTestManifest = manifest; - } - - @Override - public PluginXmlAccess getRuntimeTestPluginXml() { - return runtimeTestPluginXml; - } - - public void setRuntimeTestPluginXml(PluginXmlAccess pluginXml) { - this.runtimeTestPluginXml = pluginXml; - } - - @Override - public String getGenericIdeProjectName() { - return genericIdeProjectName; - } - - public void setGenericIdeProjectName(String projectName) { - this.genericIdeProjectName = projectName; - } - - @Override - public IXtextGeneratorFileSystemAccess getGenericIdeRoot() { - return genericIdeRoot; - } - - public void setGenericIdeRoot(String path) { - this.genericIdeRoot = new XtextGeneratorFileSystemAccess(path, true); - } - - @Override - public IXtextGeneratorFileSystemAccess getGenericIdeMetaInf() { - return genericIdeMetaInf; - } - - public void setGenericIdeMetaInf(String path) { - this.genericIdeMetaInf = new XtextGeneratorFileSystemAccess(path, true); - } - - @Override - public IXtextGeneratorFileSystemAccess getGenericIdeSrc() { - return genericIdeSrc; - } - - public void setGenericIdeSrc(String path) { - this.genericIdeSrc = new XtextGeneratorFileSystemAccess(path, false); - } - - @Override - public IXtextGeneratorFileSystemAccess getGenericIdeSrcGen() { - return genericIdeSrcGen; - } - - public void setGenericIdeSrcGen(String path) { - this.genericIdeSrcGen = new XtextGeneratorFileSystemAccess(path, true); - } - - @Override - public ManifestAccess getGenericIdeManifest() { - return genericIdeManifest; - } - - public void setGenericIdeManifest(ManifestAccess manifest) { - this.genericIdeManifest = manifest; - } - - @Override - public PluginXmlAccess getGenericIdePluginXml() { - return genericIdePluginXml; - } - - public void setGenericIdePluginXml(PluginXmlAccess pluginXml) { - this.genericIdePluginXml = pluginXml; - } - - @Override - public String getGenericIdeTestProjectName() { - return genericIdeTestProjectName; - } - - public void setGenericIdeTestProjectName(String projectName) { - this.genericIdeTestProjectName = projectName; - } - - @Override - public IXtextGeneratorFileSystemAccess getGenericIdeTestRoot() { - return genericIdeTestRoot; - } - - public void setGenericIdeTestRoot(String path) { - this.genericIdeTestRoot = new XtextGeneratorFileSystemAccess(path, true); - } - - @Override - public IXtextGeneratorFileSystemAccess getGenericIdeTestMetaInf() { - return genericIdeTestMetaInf; - } - - public void setGenericIdeTestMetaInf(String path) { - this.genericIdeTestMetaInf = new XtextGeneratorFileSystemAccess(path, true); - } - - @Override - public IXtextGeneratorFileSystemAccess getGenericIdeTestSrc() { - return genericIdeTestSrc; - } - - public void setGenericIdeTestSrc(String path) { - this.genericIdeTestSrc = new XtextGeneratorFileSystemAccess(path, false); - } - - @Override - public IXtextGeneratorFileSystemAccess getGenericIdeTestSrcGen() { - return genericIdeTestSrcGen; - } - - public void setGenericIdeTestSrcGen(String path) { - this.genericIdeTestSrcGen = new XtextGeneratorFileSystemAccess(path, true); - } - - @Override - public ManifestAccess getGenericIdeTestManifest() { - return genericIdeTestManifest; - } - - public void setGenericIdeTestManifest(ManifestAccess manifest) { - this.genericIdeTestManifest = manifest; - } - - @Override - public PluginXmlAccess getGenericIdeTestPluginXml() { - return genericIdeTestPluginXml; - } - - public void setGenericIdeTestPluginXml(PluginXmlAccess pluginXml) { - this.genericIdeTestPluginXml = pluginXml; - } - - @Override - public String getEclipsePluginProjectName() { - return eclipsePluginProjectName; - } - - public void setEclipsePluginProjectName(String projectName) { - this.eclipsePluginProjectName = projectName; - } - - @Override - public IXtextGeneratorFileSystemAccess getEclipsePluginRoot() { - return eclipsePluginRoot; - } - - public void setEclipsePluginRoot(String path) { - this.eclipsePluginRoot = new XtextGeneratorFileSystemAccess(path, true); - } - - @Override - public IXtextGeneratorFileSystemAccess getEclipsePluginMetaInf() { - return eclipsePluginMetaInf; - } - - public void setEclipsePluginMetaInf(String path) { - this.eclipsePluginMetaInf = new XtextGeneratorFileSystemAccess(path, true); - } - - @Override - public IXtextGeneratorFileSystemAccess getEclipsePluginSrc() { - return eclipsePluginSrc; - } - - public void setEclipsePluginSrc(String path) { - this.eclipsePluginSrc = new XtextGeneratorFileSystemAccess(path, false); - } - - @Override - public IXtextGeneratorFileSystemAccess getEclipsePluginSrcGen() { - return eclipsePluginSrcGen; - } - - public void setEclipsePluginSrcGen(String path) { - this.eclipsePluginSrcGen = new XtextGeneratorFileSystemAccess(path, true); - } - - @Override - public ManifestAccess getEclipsePluginManifest() { - return eclipsePluginManifest; - } - - public void setEclipsePluginManifest(ManifestAccess manifest) { - this.eclipsePluginManifest = manifest; - } - - @Override - public PluginXmlAccess getEclipsePluginPluginXml() { - return eclipsePluginPluginXml; - } - - public void setEclipsePluginPluginXml(PluginXmlAccess pluginXml) { - this.eclipsePluginPluginXml = pluginXml; - } - - @Override - public String getEclipsePluginTestProjectName() { - return eclipsePluginTestProjectName; - } - - public void setEclipsePluginTestProjectName(String projectName) { - this.eclipsePluginTestProjectName = projectName; - } - - @Override - public IXtextGeneratorFileSystemAccess getEclipsePluginTestRoot() { - return eclipsePluginTestRoot; - } - - public void setEclipsePluginTestRoot(String path) { - this.eclipsePluginTestRoot = new XtextGeneratorFileSystemAccess(path, true); - } - - @Override - public IXtextGeneratorFileSystemAccess getEclipsePluginTestMetaInf() { - return eclipsePluginTestMetaInf; - } - - public void setEclipsePluginTestMetaInf(String path) { - this.eclipsePluginTestMetaInf = new XtextGeneratorFileSystemAccess(path, true); - } - - @Override - public IXtextGeneratorFileSystemAccess getEclipsePluginTestSrc() { - return eclipsePluginTestSrc; - } - - public void setEclipsePluginTestSrc(String path) { - this.eclipsePluginTestSrc = new XtextGeneratorFileSystemAccess(path, false); - } - - @Override - public IXtextGeneratorFileSystemAccess getEclipsePluginTestSrcGen() { - return eclipsePluginTestSrcGen; - } - - public void setEclipsePluginTestSrcGen(String path) { - this.eclipsePluginTestSrcGen = new XtextGeneratorFileSystemAccess(path, true); - } - - @Override - public ManifestAccess getEclipsePluginTestManifest() { - return eclipsePluginTestManifest; - } - - public void setEclipsePluginTestManifest(ManifestAccess manifest) { - this.eclipsePluginTestManifest = manifest; - } - - @Override - public PluginXmlAccess getEclipsePluginTestPluginXml() { - return eclipsePluginTestPluginXml; - } - - public void setEclipsePluginTestPluginXml(PluginXmlAccess pluginXml) { - this.eclipsePluginTestPluginXml = pluginXml; - } - - @Override - public String getIdeaPluginProjectName() { - return ideaPluginProjectName; - } - - public void setIdeaPluginProjectName(String projectName) { - this.ideaPluginProjectName = projectName; - } - - @Override - public IXtextGeneratorFileSystemAccess getIdeaPluginRoot() { - return ideaPluginRoot; - } - - public void setIdeaPluginRoot(String path) { - this.ideaPluginRoot = new XtextGeneratorFileSystemAccess(path, true); - } - - @Override - public IXtextGeneratorFileSystemAccess getIdeaPluginMetaInf() { - return ideaPluginMetaInf; - } - - public void setIdeaPluginMetaInf(String path) { - this.ideaPluginMetaInf = new XtextGeneratorFileSystemAccess(path, true); - } - - @Override - public IXtextGeneratorFileSystemAccess getIdeaPluginSrc() { - return ideaPluginSrc; - } - - public void setIdeaPluginSrc(String path) { - this.ideaPluginSrc = new XtextGeneratorFileSystemAccess(path, false); - } - - @Override - public IXtextGeneratorFileSystemAccess getIdeaPluginSrcGen() { - return ideaPluginSrcGen; - } - - public void setIdeaPluginSrcGen(String path) { - this.ideaPluginSrcGen = new XtextGeneratorFileSystemAccess(path, true); - } - - @Override - public ManifestAccess getIdeaPluginManifest() { - return ideaPluginManifest; - } - - public void setIdeaPluginManifest(ManifestAccess manifest) { - this.ideaPluginManifest = manifest; - } - - @Override - public String getIdeaPluginTestProjectName() { - return ideaPluginTestProjectName; - } - - public void setIdeaPluginTestProjectName(String projectName) { - this.ideaPluginTestProjectName = projectName; - } - - @Override - public IXtextGeneratorFileSystemAccess getIdeaPluginTestRoot() { - return ideaPluginTestRoot; - } - - public void setIdeaPluginTestRoot(String path) { - this.ideaPluginTestRoot = new XtextGeneratorFileSystemAccess(path, true); - } - - @Override - public IXtextGeneratorFileSystemAccess getIdeaPluginTestMetaInf() { - return ideaPluginTestMetaInf; - } - - public void setIdeaPluginTestMetaInf(String path) { - this.ideaPluginTestMetaInf = new XtextGeneratorFileSystemAccess(path, true); - } - - @Override - public IXtextGeneratorFileSystemAccess getIdeaPluginTestSrc() { - return ideaPluginTestSrc; - } - - public void setIdeaPluginTestSrc(String path) { - this.ideaPluginTestSrc = new XtextGeneratorFileSystemAccess(path, false); - } - - @Override - public IXtextGeneratorFileSystemAccess getIdeaPluginTestSrcGen() { - return ideaPluginTestSrcGen; - } - - public void setIdeaPluginTestSrcGen(String path) { - this.ideaPluginTestSrcGen = new XtextGeneratorFileSystemAccess(path, true); - } - - @Override - public ManifestAccess getIdeaPluginTestManifest() { - return ideaPluginTestManifest; - } - - public void setIdeaPluginTestManifest(ManifestAccess manifest) { - this.ideaPluginTestManifest = manifest; - } - - @Override - public String getWebProjectName() { - return webProjectName; - } - - public void setWebProjectName(String projectName) { - this.webProjectName = projectName; - } - - @Override - public IXtextGeneratorFileSystemAccess getWebRoot() { - return webRoot; - } - - public void setWebRoot(String path) { - this.webRoot = new XtextGeneratorFileSystemAccess(path, true); - } - - @Override - public IXtextGeneratorFileSystemAccess getWebMetaInf() { - return webMetaInf; - } - - public void setWebMetaInf(String path) { - this.webMetaInf = new XtextGeneratorFileSystemAccess(path, true); - } - - @Override - public IXtextGeneratorFileSystemAccess getWebSrc() { - return webSrc; - } - - public void setWebSrc(String path) { - this.webSrc = new XtextGeneratorFileSystemAccess(path, false); - } - - @Override - public IXtextGeneratorFileSystemAccess getWebSrcGen() { - return webSrcGen; - } - - public void setWebSrcGen(String path) { - this.webSrcGen = new XtextGeneratorFileSystemAccess(path, true); - } - - @Override - public ManifestAccess getWebManifest() { - return webManifest; - } - - public void setWebManifest(ManifestAccess manifest) { - this.webManifest = manifest; - } - - @Override - public String getWebTestProjectName() { - return webTestProjectName; - } - - public void setWebTestProjectName(String projectName) { - this.webTestProjectName = projectName; - } - - @Override - public IXtextGeneratorFileSystemAccess getWebTestRoot() { - return webTestRoot; - } - - public void setWebTestRoot(String path) { - this.webTestRoot = new XtextGeneratorFileSystemAccess(path, true); - } - - @Override - public IXtextGeneratorFileSystemAccess getWebTestMetaInf() { - return webTestMetaInf; - } - - public void setWebTestMetaInf(String path) { - this.webTestMetaInf = new XtextGeneratorFileSystemAccess(path, true); - } - - @Override - public IXtextGeneratorFileSystemAccess getWebTestSrc() { - return webTestSrc; - } - - public void setWebTestSrc(String path) { - this.webTestSrc = new XtextGeneratorFileSystemAccess(path, false); - } - - @Override - public IXtextGeneratorFileSystemAccess getWebTestSrcGen() { - return webTestSrcGen; - } - - public void setWebTestSrcGen(String path) { - this.webTestSrcGen = new XtextGeneratorFileSystemAccess(path, true); - } - - @Override - public ManifestAccess getWebTestManifest() { - return webTestManifest; - } - - public void setWebTestManifest(ManifestAccess manifest) { - this.webTestManifest = manifest; - } - - @Override - public IXtextGeneratorFileSystemAccess getWebApp() { - return webApp; - } - - public void setWebApp(String path) { - this.webApp = new XtextGeneratorFileSystemAccess(path, true); - } -} diff --git a/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/builder/BuilderIntegrationFragment2.xtend b/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/builder/BuilderIntegrationFragment2.xtend index 99a723247..02547cc2a 100644 --- a/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/builder/BuilderIntegrationFragment2.xtend +++ b/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/builder/BuilderIntegrationFragment2.xtend @@ -27,8 +27,8 @@ class BuilderIntegrationFragment2 extends AbstractGeneratorFragment2 { addRuntimeGuiceBindings addEclipsePluginGuiceBindings - if (projectConfig.eclipsePluginManifest !== null) { - projectConfig.eclipsePluginManifest.requiredBundles.addAll(#[ + if (projectConfig.eclipsePlugin.manifest !== null) { + projectConfig.eclipsePlugin.manifest.requiredBundles.addAll(#[ 'org.eclipse.xtext.builder', 'org.eclipse.xtext.ui' ]) } diff --git a/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/ecore/EMFGeneratorFragment2.xtend b/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/ecore/EMFGeneratorFragment2.xtend index db2fdeb3e..3cf64e08d 100644 --- a/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/ecore/EMFGeneratorFragment2.xtend +++ b/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/ecore/EMFGeneratorFragment2.xtend @@ -200,7 +200,7 @@ class EMFGeneratorFragment2 extends AbstractGeneratorFragment2 { } protected def String getJavaModelDirectory() { - javaModelDirectory ?: projectConfig.runtimeSrcGen.path + javaModelDirectory ?: projectConfig.runtime.srcGen.path } protected def String getModelName(Grammar grammar) { @@ -215,7 +215,7 @@ class EMFGeneratorFragment2 extends AbstractGeneratorFragment2 { } protected def String getEcoreFilePath(Grammar grammar) { - projectConfig.runtimeModelGen.path + '/' + grammar.modelName + '.ecore' + projectConfig.runtime.ecoreModel.path + '/' + grammar.modelName + '.ecore' } protected def URI getEcoreFileUri(Grammar grammar) { @@ -223,7 +223,7 @@ class EMFGeneratorFragment2 extends AbstractGeneratorFragment2 { } protected def String getGenModelPath(Grammar grammar) { - genModel ?: projectConfig.runtimeModelGen.path + '/' + grammar.modelName + '.genmodel' + genModel ?: projectConfig.runtime.ecoreModel.path + '/' + grammar.modelName + '.genmodel' } protected def URI getGenModelUri(Grammar grammar) { @@ -231,7 +231,7 @@ class EMFGeneratorFragment2 extends AbstractGeneratorFragment2 { } protected def String getRelativePath(String pathInRoot) { - val projectRoot = projectConfig.runtimeRoot.path + val projectRoot = projectConfig.runtime.root.path if (pathInRoot.startsWith(projectRoot)) pathInRoot.substring(projectRoot.length + 1) else @@ -258,17 +258,17 @@ class EMFGeneratorFragment2 extends AbstractGeneratorFragment2 { protected def String getModelPluginID() { modelPluginID ?: { - val path = projectConfig.runtimeRoot.path + val path = projectConfig.runtime.root.path path.substring(path.lastIndexOf('/') + 1) } } protected def String getEditDirectory() { - editDirectory ?: projectConfig.runtimeRoot.path + '.edit/src' + editDirectory ?: projectConfig.runtime.root.path + '.edit/src' } protected def String getEditorDirectory() { - editorDirectory ?: projectConfig.runtimeRoot.path + '.editor/src' + editorDirectory ?: projectConfig.runtime.root.path + '.editor/src' } protected def String getEditPluginID() { @@ -346,8 +346,8 @@ class EMFGeneratorFragment2 extends AbstractGeneratorFragment2 { } protected def void addProjectContributions(Grammar grammar, ListThis file has been generated with {@link «ProjectConfigGenerator.name»}.
- */ - public interface «INTERFACE_NAME.substring(INTERFACE_NAME.lastIndexOf('.') + 1)» extends IGuiceAwareGeneratorComponent { - - IXtextGeneratorFileSystemAccess getRuntimeModelGen(); - - «FOR p : PROJECTS» - String get«p.toFirstUpper»ProjectName(); - IXtextGeneratorFileSystemAccess get«p.toFirstUpper»Root(); - IXtextGeneratorFileSystemAccess get«p.toFirstUpper»MetaInf(); - IXtextGeneratorFileSystemAccess get«p.toFirstUpper»Src(); - IXtextGeneratorFileSystemAccess get«p.toFirstUpper»SrcGen(); - ManifestAccess get«p.toFirstUpper»Manifest(); - «IF p.hasPluginXml» - PluginXmlAccess get«p.toFirstUpper»PluginXml(); - «ENDIF» - - «ENDFOR» - IXtextGeneratorFileSystemAccess getWebApp(); - - } - ''' - - def generateImpl() ''' - /******************************************************************************* - * 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 «IMPL_NAME.substring(0, IMPL_NAME.lastIndexOf('.'))»; - - import com.google.inject.Injector; - import org.eclipse.xtext.xtext.generator.model.IXtextGeneratorFileSystemAccess; - import org.eclipse.xtext.xtext.generator.model.XtextGeneratorFileSystemAccess; - import org.eclipse.xtext.xtext.generator.model.ManifestAccess; - import org.eclipse.xtext.xtext.generator.model.PluginXmlAccess; - - /** - * Use this class to configure output paths in the XtextGenerator. - * - *This file has been generated with {@link «ProjectConfigGenerator.name»}.
- */ - public class «IMPL_NAME.substring(IMPL_NAME.lastIndexOf('.') + 1)» implements «INTERFACE_NAME.substring(INTERFACE_NAME.lastIndexOf('.') + 1)» { - - private IXtextGeneratorFileSystemAccess runtimeModelGen; - «FOR p : PROJECTS» - private String «p»ProjectName; - private IXtextGeneratorFileSystemAccess «p»Root; - private IXtextGeneratorFileSystemAccess «p»MetaInf; - private IXtextGeneratorFileSystemAccess «p»Src; - private IXtextGeneratorFileSystemAccess «p»SrcGen; - private ManifestAccess «p»Manifest; - «IF p.hasPluginXml» - private PluginXmlAccess «p»PluginXml; - «ENDIF» - «ENDFOR» - private IXtextGeneratorFileSystemAccess webApp; - - public void checkConfiguration(Issues issues) { - if («PROJECTS.head»Src == null) { - issues.addError("The property '«PROJECTS.head»Src' must be set.", this); - } - if («PROJECTS.head»SrcGen == null) { - issues.addError("The property '«PROJECTS.head»SrcGen' must be set.", this); - } - «FOR p : PROJECTS» - if («p»Manifest != null && «p»MetaInf == null) { - issues.addError("The property '«p»MetaInf' must be set when '«p»Manifest' is set."); - } - «IF p.hasPluginXml» - if («p»PluginXml != null && «p»Root == null) { - issues.addError("The property '«p»Root' must be set when '«p»PluginXml' is set."); - } - «ENDIF» - «ENDFOR» - } - - @Override - public void initialize(Injector injector) { - injector.injectMembers(this); - if (runtimeModelGen != null) { - runtimeModelGen.initialize(injector); - } - «FOR p : PROJECTS» - - // Initialize «p» configuration - if («p»Root != null) { - «p»Root.initialize(injector); - } - if («p»MetaInf != null) { - «p»MetaInf.initialize(injector); - } - if («p»Src != null) { - «p»Src.initialize(injector); - } - if («p»SrcGen != null) { - «p»SrcGen.initialize(injector); - } - «ENDFOR» - - if (webApp != null) { - webApp.initialize(injector); - } - } - - @Override - public IXtextGeneratorFileSystemAccess getRuntimeModelGen() { - return runtimeModelGen; - } - - public void setRuntimeModelGen(String path) { - this.runtimeModelGen = new XtextGeneratorFileSystemAccess(path, true); - } - - «FOR p : PROJECTS» - @Override - public String get«p.toFirstUpper»ProjectName() { - return «p»ProjectName; - } - - public void set«p.toFirstUpper»ProjectName(String projectName) { - this.«p»ProjectName = projectName; - } - - @Override - public IXtextGeneratorFileSystemAccess get«p.toFirstUpper»Root() { - return «p»Root; - } - - public void set«p.toFirstUpper»Root(String path) { - this.«p»Root = new XtextGeneratorFileSystemAccess(path, true); - } - - @Override - public IXtextGeneratorFileSystemAccess get«p.toFirstUpper»MetaInf() { - return «p»MetaInf; - } - - public void set«p.toFirstUpper»MetaInf(String path) { - this.«p»MetaInf = new XtextGeneratorFileSystemAccess(path, true); - } - - @Override - public IXtextGeneratorFileSystemAccess get«p.toFirstUpper»Src() { - return «p»Src; - } - - public void set«p.toFirstUpper»Src(String path) { - this.«p»Src = new XtextGeneratorFileSystemAccess(path, false); - } - - @Override - public IXtextGeneratorFileSystemAccess get«p.toFirstUpper»SrcGen() { - return «p»SrcGen; - } - - public void set«p.toFirstUpper»SrcGen(String path) { - this.«p»SrcGen = new XtextGeneratorFileSystemAccess(path, true); - } - - @Override - public ManifestAccess get«p.toFirstUpper»Manifest() { - return «p»Manifest; - } - - public void set«p.toFirstUpper»Manifest(ManifestAccess manifest) { - this.«p»Manifest = manifest; - } - - «IF p.hasPluginXml» - @Override - public PluginXmlAccess get«p.toFirstUpper»PluginXml() { - return «p»PluginXml; - } - - public void set«p.toFirstUpper»PluginXml(PluginXmlAccess pluginXml) { - this.«p»PluginXml = pluginXml; - } - - «ENDIF» - «ENDFOR» - @Override - public IXtextGeneratorFileSystemAccess getWebApp() { - return webApp; - } - - public void setWebApp(String path) { - this.webApp = new XtextGeneratorFileSystemAccess(path, true); - } - } - ''' - -} \ No newline at end of file diff --git a/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/junit/Junit4Fragment2.xtend b/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/junit/Junit4Fragment2.xtend index 800093d10..177a5c50a 100644 --- a/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/junit/Junit4Fragment2.xtend +++ b/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/junit/Junit4Fragment2.xtend @@ -2,7 +2,6 @@ package org.eclipse.xtext.xtext.generator.junit import org.eclipse.xtext.xtext.generator.AbstractGeneratorFragment2 import com.google.inject.Inject -import org.eclipse.xtext.xtext.generator.IXtextProjectConfig import org.eclipse.xtext.xtext.generator.XtextGeneratorNaming import org.eclipse.xtext.xtext.generator.model.JavaFileAccess import org.eclipse.xtext.xtext.generator.model.FileAccessFactory @@ -12,13 +11,12 @@ import static extension org.eclipse.xtext.GrammarUtil.* import org.eclipse.xtext.xtext.generator.util.GenModelUtil2 class Junit4Fragment2 extends AbstractGeneratorFragment2 { - @Inject IXtextProjectConfig projectConfig @Inject extension XtextGeneratorNaming @Inject FileAccessFactory fileAccessFactory override generate() { - if (projectConfig.runtimeTestManifest != null) { - projectConfig.runtimeTestManifest => [ + if (projectConfig.runtimeTest.manifest != null) { + projectConfig.runtimeTest.manifest => [ requiredBundles.addAll( "org.eclipse.xtext.junit4", "org.eclipse.xtext.xbase.lib" @@ -26,8 +24,8 @@ class Junit4Fragment2 extends AbstractGeneratorFragment2 { exportedPackages.add(grammar.runtimeTestBasePackage) ] } - if (projectConfig.eclipsePluginTestManifest != null) { - projectConfig.eclipsePluginTestManifest => [ + if (projectConfig.eclipsePluginTest.manifest != null) { + projectConfig.eclipsePluginTest.manifest => [ requiredBundles.addAll( "org.eclipse.core.runtime", "org.eclipse.ui.workbench;resolution:=optional" @@ -35,13 +33,13 @@ class Junit4Fragment2 extends AbstractGeneratorFragment2 { exportedPackages.add(grammar.eclipsePluginTestBasePackage) ] } - if (projectConfig.eclipsePluginManifest != null) { - projectConfig.eclipsePluginManifest.exportedPackages.add(grammar.eclipsePluginActivator.packageName) + if (projectConfig.eclipsePlugin.manifest != null) { + projectConfig.eclipsePlugin.manifest.exportedPackages.add(grammar.eclipsePluginActivator.packageName) } #[ - projectConfig.runtimeTestManifest, - projectConfig.eclipsePluginTestManifest + projectConfig.runtimeTest.manifest, + projectConfig.eclipsePluginTest.manifest ].filterNull.forEach [ importedPackages.addAll( "org.junit;version=\"4.5.0\"", @@ -53,9 +51,9 @@ class Junit4Fragment2 extends AbstractGeneratorFragment2 { "org.hamcrest.core" ) ] - generateInjectorProvider.writeTo(projectConfig.runtimeTestSrcGen) - generateExampleRuntimeTest.writeTo(projectConfig.runtimeTestSrc) - generateUiInjectorProvider.writeTo(projectConfig.eclipsePluginTestSrcGen) + generateInjectorProvider.writeTo(projectConfig.runtimeTest.srcGen) + generateExampleRuntimeTest.writeTo(projectConfig.runtimeTest.src) + generateUiInjectorProvider.writeTo(projectConfig.eclipsePluginTest.srcGen) } def JavaFileAccess generateExampleRuntimeTest() { diff --git a/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/model/ManifestAccess.xtend b/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/model/ManifestAccess.xtend index b20da15a3..70a9dd0c0 100644 --- a/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/model/ManifestAccess.xtend +++ b/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/model/ManifestAccess.xtend @@ -15,10 +15,12 @@ import org.eclipse.xtend2.lib.StringConcatenationClient import org.eclipse.xtext.generator.IFileSystemAccess2 import org.eclipse.xtext.util.MergeableManifest import org.eclipse.xtext.util.internal.Log +import org.eclipse.xtext.xtext.generator.IGuiceAwareGeneratorComponent +import com.google.inject.Injector @Log @Accessors -class ManifestAccess extends TextFileAccess { +class ManifestAccess extends TextFileAccess implements IGuiceAwareGeneratorComponent { String bundleName @@ -129,4 +131,8 @@ class ManifestAccess extends TextFileAccess { } } + override initialize(Injector injector) { + injector.injectMembers(this) + } + } diff --git a/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/model/PluginXmlAccess.xtend b/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/model/PluginXmlAccess.xtend index e45a48487..eeb20a46a 100644 --- a/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/model/PluginXmlAccess.xtend +++ b/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/model/PluginXmlAccess.xtend @@ -14,10 +14,12 @@ import org.eclipse.xtext.generator.IFileSystemAccess2 import org.eclipse.xtext.util.internal.Log import org.eclipse.xtext.xtext.generator.CodeConfig import com.google.inject.Inject +import org.eclipse.xtext.xtext.generator.IGuiceAwareGeneratorComponent +import com.google.inject.Injector @Log @Accessors -class PluginXmlAccess extends TextFileAccess { +class PluginXmlAccess extends TextFileAccess implements IGuiceAwareGeneratorComponent { @Inject CodeConfig codeConfig @@ -57,4 +59,8 @@ class PluginXmlAccess extends TextFileAccess { } } + override initialize(Injector injector) { + injector.injectMembers(this) + } + } \ No newline at end of file diff --git a/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/scoping/ImportNamespacesScopingFragment2.xtend b/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/scoping/ImportNamespacesScopingFragment2.xtend index 6d6f56426..7b657ea57 100644 --- a/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/scoping/ImportNamespacesScopingFragment2.xtend +++ b/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/scoping/ImportNamespacesScopingFragment2.xtend @@ -72,10 +72,10 @@ class ImportNamespacesScopingFragment2 extends AbstractGeneratorFragment2 { else generateJavaScopeProvider() - if (projectConfig.runtimeManifest !== null) { - projectConfig.runtimeManifest.exportedPackages += grammar.scopeProviderClass.packageName + if (projectConfig.runtime.manifest !== null) { + projectConfig.runtime.manifest.exportedPackages += grammar.scopeProviderClass.packageName if (codeConfig.preferXtendStubs) - projectConfig.runtimeManifest.requiredBundles += 'org.eclipse.xtext.xbase.lib' + projectConfig.runtime.manifest.requiredBundles += 'org.eclipse.xtext.xbase.lib' } } } @@ -109,7 +109,7 @@ class ImportNamespacesScopingFragment2 extends AbstractGeneratorFragment2 { public class «grammar.scopeProviderClass.simpleName» extends «grammar.scopeProviderSuperClass» { } - ''').writeTo(projectConfig.runtimeSrc) + ''').writeTo(projectConfig.runtime.src) } protected def generateXtendScopeProvider() { @@ -123,7 +123,7 @@ class ImportNamespacesScopingFragment2 extends AbstractGeneratorFragment2 { class «grammar.scopeProviderClass.simpleName» extends «grammar.scopeProviderSuperClass» { } - ''').writeTo(projectConfig.runtimeSrc) + ''').writeTo(projectConfig.runtime.src) } } \ No newline at end of file diff --git a/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/types/TypesGeneratorFragment2.xtend b/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/types/TypesGeneratorFragment2.xtend index d35eabc53..fb45be132 100644 --- a/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/types/TypesGeneratorFragment2.xtend +++ b/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/types/TypesGeneratorFragment2.xtend @@ -29,21 +29,21 @@ class TypesGeneratorFragment2 extends AbstractGeneratorFragment2 { .contributeTo(language.eclipsePluginGenModule) language.eclipsePluginGenModule.superClass = 'org.eclipse.xtext.common.types.ui.DefaultCommonTypesUiModule'.typeRef - if (projectConfig.runtimeManifest !== null) { - projectConfig.runtimeManifest.requiredBundles.addAll( + if (projectConfig.runtime.manifest !== null) { + projectConfig.runtime.manifest.requiredBundles.addAll( 'org.eclipse.xtext.common.types', 'org.objectweb.asm;bundle-version="[5.0.1,6.0.0)";resolution:=optional' ) } - if (projectConfig.runtimeTestManifest !== null) { - projectConfig.runtimeTestManifest.requiredBundles.add( + if (projectConfig.runtimeTest.manifest !== null) { + projectConfig.runtimeTest.manifest.requiredBundles.add( 'org.objectweb.asm;bundle-version="[5.0.1,6.0.0)";resolution:=optional' ) } - if (projectConfig.eclipsePluginManifest !== null) { - projectConfig.eclipsePluginManifest.requiredBundles.add( + if (projectConfig.eclipsePlugin.manifest !== null) { + projectConfig.eclipsePlugin.manifest.requiredBundles.add( 'org.eclipse.xtext.common.types.ui' ) } diff --git a/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/ui/outline/OutlineTreeProviderFragment2.xtend b/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/ui/outline/OutlineTreeProviderFragment2.xtend index 8cb24ed8f..3fa7f3fc0 100644 --- a/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/ui/outline/OutlineTreeProviderFragment2.xtend +++ b/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/ui/outline/OutlineTreeProviderFragment2.xtend @@ -38,15 +38,15 @@ class OutlineTreeProviderFragment2 extends AbstractGeneratorFragment2 { } override generate() { - if (projectConfig.eclipsePluginManifest != null) { - projectConfig.eclipsePluginManifest.requiredBundles += "org.eclipse.xtext.ui" + if (projectConfig.eclipsePlugin.manifest != null) { + projectConfig.eclipsePlugin.manifest.requiredBundles += "org.eclipse.xtext.ui" } if (!generateStub) { return; } - if (projectConfig.eclipsePluginSrc !== null) { + if (projectConfig.eclipsePlugin.src !== null) { if (codeConfig.preferXtendStubs) { generateXtendOutlineTreeProvider } else { @@ -73,7 +73,7 @@ class OutlineTreeProviderFragment2 extends AbstractGeneratorFragment2 { "org.eclipse.xtext.ui.editor.outline.impl.DefaultOutlineTreeProvider".typeRef» { } - ''').writeTo(projectConfig.eclipsePluginSrc) + ''').writeTo(projectConfig.eclipsePlugin.src) } def protected generateXtendOutlineTreeProvider() { @@ -87,5 +87,5 @@ class OutlineTreeProviderFragment2 extends AbstractGeneratorFragment2 { "org.eclipse.xtext.ui.editor.outline.impl.DefaultOutlineTreeProvider".typeRef» { } - ''').writeTo(projectConfig.eclipsePluginSrc) + ''').writeTo(projectConfig.eclipsePlugin.src) }} \ No newline at end of file diff --git a/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/validation/ValidatorFragment2.xtend b/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/validation/ValidatorFragment2.xtend index 85374e870..baf0161cb 100644 --- a/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/validation/ValidatorFragment2.xtend +++ b/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/validation/ValidatorFragment2.xtend @@ -88,10 +88,10 @@ class ValidatorFragment2 extends AbstractGeneratorFragment2 { } generateAbstractValidator() - if (projectConfig.runtimeManifest !== null) - projectConfig.runtimeManifest.exportedPackages += grammar.validatorClass.packageName + if (projectConfig.runtime.manifest !== null) + projectConfig.runtime.manifest.exportedPackages += grammar.validatorClass.packageName - if (projectConfig.eclipsePluginPluginXml !== null) + if (projectConfig.eclipsePlugin.pluginXml !== null) contributeEclipsePluginExtensions() } @@ -118,7 +118,7 @@ class ValidatorFragment2 extends AbstractGeneratorFragment2 { // } } - ''').writeTo(projectConfig.runtimeSrc) + ''').writeTo(projectConfig.runtime.src) } protected def generateJavaValidatorStub() { @@ -140,7 +140,7 @@ class ValidatorFragment2 extends AbstractGeneratorFragment2 { // } } - ''').writeTo(projectConfig.runtimeSrc) + ''').writeTo(projectConfig.runtime.src) } protected def generateAbstractValidator() { @@ -165,7 +165,7 @@ class ValidatorFragment2 extends AbstractGeneratorFragment2 { } ''' - javaFile.writeTo(projectConfig.runtimeSrcGen) + javaFile.writeTo(projectConfig.runtime.srcGen) } protected def getGeneratedPackagesToValidate() { @@ -184,7 +184,7 @@ class ValidatorFragment2 extends AbstractGeneratorFragment2 { protected def contributeEclipsePluginExtensions() { val simpleName = getSimpleName(grammar) - projectConfig.eclipsePluginPluginXml.entries += ''' + projectConfig.eclipsePlugin.pluginXml.entries += '''