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 index 95ef45abe..9677daacb 100644 --- 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 @@ -13,10 +13,10 @@ 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(PUBLIC_GETTER, PACKAGE_SETTER) + XtextProjectConfig owner @Accessors boolean enabled @Accessors @@ -29,21 +29,21 @@ class SubProjectConfig implements IGuiceAwareGeneratorComponent { IXtextGeneratorFileSystemAccess src @Accessors(PUBLIC_GETTER) IXtextGeneratorFileSystemAccess srcGen - + def void setRoot(String path) { - root = new XtextGeneratorFileSystemAccess(path, true) + root = owner.newFileSystemAccess(path, true) } def void setMetaInf(String path) { - metaInf = new XtextGeneratorFileSystemAccess(path, true) + metaInf = owner.newFileSystemAccess(path, true) } def void setSrc(String path) { - src = new XtextGeneratorFileSystemAccess(path, false) + src = owner.newFileSystemAccess(path, false) } def void setSrcGen(String path) { - srcGen = new XtextGeneratorFileSystemAccess(path, true) + srcGen = owner.newFileSystemAccess(path, true) } def void checkConfiguration(Issues issues) { @@ -59,6 +59,8 @@ class SubProjectConfig implements IGuiceAwareGeneratorComponent { } + + @Accessors class BundleProjectConfig extends SubProjectConfig { ManifestAccess manifest @@ -82,12 +84,13 @@ class BundleProjectConfig extends SubProjectConfig { } + class RuntimeProjectConfig extends BundleProjectConfig { @Accessors(PUBLIC_GETTER) IXtextGeneratorFileSystemAccess ecoreModel def void setEcoreModel(String path) { - ecoreModel = new XtextGeneratorFileSystemAccess(path, true) + ecoreModel = owner.newFileSystemAccess(path, true) } /** @@ -112,7 +115,7 @@ class WebProjectConfig extends SubProjectConfig { IXtextGeneratorFileSystemAccess assets def void setAssets(String path) { - assets = new XtextGeneratorFileSystemAccess(path, true) + assets = owner.newFileSystemAccess(path, true) } override initialize(Injector injector) { 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 index 1b4e46769..0bed425d6 100644 --- 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 @@ -9,8 +9,6 @@ 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 { @@ -54,9 +52,9 @@ class WizardConfig extends XtextProjectConfig { if (it instanceof BundleProjectConfig) { if (createEclipseMetaData) { if (manifest === null) - manifest = new ManifestAccess + manifest = newManifestAccess if (pluginXml === null) - pluginXml = new PluginXmlAccess + pluginXml = newPluginXmlAccess } } if (it instanceof RuntimeProjectConfig) { diff --git a/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/XtextProjectConfig.xtend b/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/XtextProjectConfig.xtend index 58b51cbd1..c5cb66d4c 100644 --- a/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/XtextProjectConfig.xtend +++ b/plugins/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/XtextProjectConfig.xtend @@ -10,16 +10,64 @@ package org.eclipse.xtext.xtext.generator import com.google.inject.Injector import java.util.List import org.eclipse.xtend.lib.annotations.Accessors +import org.eclipse.xtext.xtext.generator.model.ManifestAccess +import org.eclipse.xtext.xtext.generator.model.PluginXmlAccess +import org.eclipse.xtext.xtext.generator.model.XtextGeneratorFileSystemAccess -@Accessors +@Accessors(PUBLIC_GETTER) 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 + RuntimeProjectConfig runtime + BundleProjectConfig runtimeTest + BundleProjectConfig genericIde + BundleProjectConfig eclipsePlugin + BundleProjectConfig eclipsePluginTest + SubProjectConfig ideaPlugin + WebProjectConfig web + + new() { + setRuntime(new RuntimeProjectConfig) + setRuntimeTest(new BundleProjectConfig) + setGenericIde(new BundleProjectConfig) + setEclipsePlugin(new BundleProjectConfig) + setEclipsePluginTest(new BundleProjectConfig) + setIdeaPlugin(new SubProjectConfig) + setWeb(new WebProjectConfig) + } + + def void setRuntime(RuntimeProjectConfig config) { + this.runtime = config + config.owner = this + } + + def void setRuntimeTest(BundleProjectConfig config) { + this.runtimeTest = config + config.owner = this + } + + def void setGenericIde(BundleProjectConfig config) { + this.genericIde = config + config.owner = this + } + + def void setEclipsePlugin(BundleProjectConfig config) { + this.eclipsePlugin = config + config.owner = this + } + + def void setEclipsePluginTest(BundleProjectConfig config) { + this.eclipsePluginTest = config + config.owner = this + } + + def void setIdeaPlugin(SubProjectConfig config) { + this.ideaPlugin = config + config.owner = this + } + + def void setWeb(WebProjectConfig config) { + this.web = config + config.owner = this + } def void checkConfiguration(Issues issues) { enabledProjects.forEach[checkConfiguration(issues)] @@ -65,5 +113,17 @@ class XtextProjectConfig implements IGuiceAwareGeneratorComponent { if (#[eclipsePlugin, ideaPlugin, web].exists[enabled]) genericIde.enabled = true } + + protected def newManifestAccess() { + new ManifestAccess + } + + protected def newPluginXmlAccess() { + new PluginXmlAccess + } + + protected def newFileSystemAccess(String path, boolean overWrite) { + new XtextGeneratorFileSystemAccess(path, overWrite) + } } \ No newline at end of file