make *Access classes customizable

This commit is contained in:
Stefan Oehme 2015-10-09 11:16:35 +02:00
parent 9a195a4ca8
commit 0b0566a38a
3 changed files with 82 additions and 21 deletions

View file

@ -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) {

View file

@ -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) {

View file

@ -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)
}
}