[generator] Added language and code configuration objects, added adapter for old fragments

Signed-off-by: Miro Spönemann <miro.spoenemann@itemis.de>
This commit is contained in:
Miro Spönemann 2015-06-30 16:39:46 +02:00
parent 12670508e9
commit 4d00a50d2f
16 changed files with 820 additions and 221 deletions

View file

@ -23,3 +23,5 @@ Require-Bundle: org.eclipse.xtext;x-installation:=greedy,
Import-Package: com.ibm.icu.text;version="4.0.0",
org.apache.commons.logging;version="1.0.4";resolution:=optional;x-installation:=greedy,
org.apache.log4j;version="1.2.15"
Export-Package: org.eclipse.xtext.xtext.generator,
org.eclipse.xtext.xtext.generator.model

View file

@ -0,0 +1,34 @@
/*******************************************************************************
* 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.Inject
import com.google.inject.Injector
import java.util.List
/**
* A composite generator fragment delegates to its contained fragments.
*/
class CompositeGeneratorFragment2 implements IGeneratorFragment2 {
@Inject Injector injector
val List<IGeneratorFragment2> fragments = newArrayList
def void addFragment(IGeneratorFragment2 fragment) {
this.fragments.add(fragment)
}
override generate() {
for (fragment : fragments) {
injector.injectMembers(fragment)
fragment.generate()
}
}
}

View file

@ -0,0 +1,27 @@
/*******************************************************************************
* 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.Binder
import org.eclipse.emf.ecore.resource.ResourceSet
import org.eclipse.xtext.parser.EclipseProjectPropertiesEncodingProvider
import org.eclipse.xtext.parser.IEncodingProvider
import org.eclipse.xtext.resource.XtextResourceSet
import org.eclipse.xtext.service.AbstractGenericModule
class DefaultGeneratorModule extends AbstractGenericModule {
def configureResourceSet(Binder binder) {
binder.bind(ResourceSet).toInstance(new XtextResourceSet)
}
def Class<? extends IEncodingProvider> bindIEncodingProvider() {
EclipseProjectPropertiesEncodingProvider
}
}

View file

@ -12,4 +12,6 @@ package org.eclipse.xtext.xtext.generator
*/
interface IGeneratorFragment2 {
def void generate()
}

View file

@ -0,0 +1,208 @@
/*******************************************************************************
* 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.Joiner
import com.google.common.collect.Lists
import com.google.inject.Inject
import com.google.inject.Provider
import java.util.Collections
import java.util.HashMap
import java.util.List
import org.eclipse.emf.common.util.Diagnostic
import org.eclipse.emf.common.util.DiagnosticChain
import org.eclipse.emf.common.util.URI
import org.eclipse.emf.common.util.WrappedException
import org.eclipse.emf.ecore.EValidator
import org.eclipse.emf.ecore.resource.Resource
import org.eclipse.emf.ecore.resource.ResourceSet
import org.eclipse.emf.ecore.util.EcoreUtil
import org.eclipse.xtend.lib.annotations.Accessors
import org.eclipse.xtext.Grammar
import org.eclipse.xtext.GrammarUtil
import org.eclipse.xtext.ReferencedMetamodel
import org.eclipse.xtext.XtextPackage
import org.eclipse.xtext.ecore.EcoreSupportStandaloneSetup
import org.eclipse.xtext.nodemodel.util.NodeModelUtils
import org.eclipse.xtext.resource.IResourceServiceProvider
import org.eclipse.xtext.resource.XtextResource
import org.eclipse.xtext.resource.impl.ResourceDescriptionsData
import org.eclipse.xtext.util.internal.Log
@Log
class LanguageConfig2 extends CompositeGeneratorFragment2 {
@Inject Provider<ResourceSet> resourceSetProvider
@Accessors
String uri
@Accessors(PUBLIC_GETTER)
Grammar grammar
@Accessors(PUBLIC_GETTER)
List<String> fileExtensions
@Accessors
val List<String> loadedResources = newArrayList
def void setFileExtensions(String fileExtensions) {
this.fileExtensions = fileExtensions.trim.split("\\s*,\\s*").toList
}
def void addLoadedResource(String uri) {
this.loadedResources.add(uri)
}
def void initialize() {
val rs = resourceSetProvider.get()
for (String loadedResource : loadedResources) {
val loadedResourceUri = URI.createURI(loadedResource)
switch (loadedResourceUri.fileExtension) {
case 'genmodel': {
val resourceServiceProvider = IResourceServiceProvider.Registry.INSTANCE.getResourceServiceProvider(loadedResourceUri)
if (resourceServiceProvider === null) {
try {
val genModelSupport = Class.forName('org.eclipse.emf.codegen.ecore.xtext.GenModelSupport')
val instance = genModelSupport.newInstance()
genModelSupport.getDeclaredMethod('createInjectorAndDoEMFRegistration').invoke(instance)
} catch (ClassNotFoundException e) {
LOG.error("Couldn't initialize GenModel support. Is it on the classpath?")
LOG.debug(e.getMessage(), e)
} catch (Exception e) {
LOG.error("Couldn't initialize GenModel support.", e)
}
}
}
case 'ecore': {
val resourceServiceProvider = IResourceServiceProvider.Registry.INSTANCE.getResourceServiceProvider(loadedResourceUri)
if (resourceServiceProvider === null) {
EcoreSupportStandaloneSetup.setup()
}
}
case 'xcore': {
val resourceServiceProvider = IResourceServiceProvider.Registry.INSTANCE.getResourceServiceProvider(loadedResourceUri)
if (resourceServiceProvider === null) {
try {
val xcore = Class.forName('org.eclipse.emf.ecore.xcore.XcoreStandaloneSetup')
xcore.getDeclaredMethod('doSetup', #[]).invoke(null)
} catch (ClassNotFoundException e) {
LOG.error("Couldn't initialize Xcore support. Is it on the classpath?")
LOG.debug(e.getMessage(), e)
} catch (Exception e) {
LOG.error("Couldn't initialize Xcore support.", e)
}
}
val xcoreLangURI = URI.createPlatformResourceURI('/org.eclipse.emf.ecore.xcore.lib/model/XcoreLang.xcore', true)
try {
rs.getResource(xcoreLangURI, true)
} catch (WrappedException e) {
LOG.error("Could not load XcoreLang.xcore.", e)
val brokenResource = rs.getResource(xcoreLangURI, false)
rs.resources.remove(brokenResource)
}
}
}
rs.getResource(loadedResourceUri, true)
}
if (!rs.resources.isEmpty) {
installIndex(rs)
for (var i = 0, var size = rs.resources.size; i < size; i++) {
val res = rs.resources.get(i)
if (res.getContents().isEmpty())
LOG.error("Error loading '" + res.getURI() + "'")
else if (!res.getErrors().isEmpty())
LOG.error("Error loading '" + res.getURI() + "':\n" + Joiner.on('\n').join(res.getErrors()))
}
EcoreUtil.resolveAll(rs)
}
val resource = rs.getResource(URI.createURI(uri), true) as XtextResource
if (resource.contents.isEmpty) {
throw new IllegalArgumentException("Couldn't load grammar for '" + uri + "'.")
}
if (!resource.errors.isEmpty) {
LOG.error(resource.errors)
throw new IllegalStateException("Problem parsing '" + uri + "':\n" + Joiner.on('\n').join(resource.getErrors()))
}
val grammar = resource.getContents().get(0) as Grammar
validateGrammar(grammar)
this.grammar = grammar
}
private def void installIndex(ResourceSet resourceSet) {
val index = new ResourceDescriptionsData(Collections.emptyList)
val resources = Lists.newArrayList(resourceSet.resources)
for (resource : resources) {
index(resource, resource.URI, index)
}
ResourceDescriptionsData.ResourceSetAdapter.installResourceDescriptionsData(resourceSet, index)
}
private def void index(Resource resource, URI uri, ResourceDescriptionsData index) {
val serviceProvider = IResourceServiceProvider.Registry.INSTANCE.getResourceServiceProvider(uri)
if (serviceProvider != null) {
val resourceDescription = serviceProvider.resourceDescriptionManager.getResourceDescription(resource)
if (resourceDescription != null) {
index.addDescription(uri, resourceDescription)
}
}
}
protected def void validateGrammar(Grammar grammar) {
validateAllImports(grammar)
val validator = EValidator.Registry.INSTANCE.getEValidator(XtextPackage.eINSTANCE)
if (validator !== null) {
val chain = new DiagnosticChain() {
override add(Diagnostic diagnostic) {
if (diagnostic.severity == Diagnostic.ERROR) {
if (diagnostic.exception == null)
throw new IllegalStateException(diagnostic.message)
else
throw new IllegalStateException(diagnostic.message, diagnostic.exception)
}
}
override addAll(Diagnostic diagnostic) {
add(diagnostic)
}
override merge(Diagnostic diagnostic) {
throw new UnsupportedOperationException
}
}
validator.validate(grammar, chain, null)
val iterator = grammar.eAllContents
while (iterator.hasNext) {
validator.validate(iterator.next, chain, new HashMap);
}
}
}
protected def void validateAllImports(Grammar grammar) {
for (amd : GrammarUtil.allMetamodelDeclarations(grammar)) {
if (amd instanceof ReferencedMetamodel)
validateReferencedMetamodel(amd)
}
}
protected def void validateReferencedMetamodel(ReferencedMetamodel ref) {
if (ref.EPackage != null && !ref.EPackage.eIsProxy) {
return
}
val eref = XtextPackage.Literals.ABSTRACT_METAMODEL_DECLARATION__EPACKAGE
val nodes = NodeModelUtils.findNodesForFeature(ref, eref)
val refName = if (nodes.empty) '(unknown)' else NodeModelUtils.getTokenText(nodes.get(0))
val grammarName = GrammarUtil.getGrammar(ref).name
val msg = "The EPackage " + refName + " in grammar " + grammarName + " could not be found. "
+ "You might want to register that EPackage in your workflow file."
throw new IllegalStateException(msg)
}
}

View file

@ -7,20 +7,20 @@
*******************************************************************************/
package org.eclipse.xtext.xtext.generator
import java.io.IOException
import java.io.InputStream
import java.net.URL
import java.text.SimpleDateFormat
import java.util.Date
import com.google.inject.Guice
import com.google.inject.Injector
import com.google.inject.Module
import java.util.List
import java.util.jar.Manifest
import org.eclipse.emf.common.EMFPlugin
import org.eclipse.emf.mwe.core.WorkflowContext
import org.eclipse.emf.mwe.core.issues.Issues
import org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent2
import org.eclipse.emf.mwe.core.monitor.ProgressMonitor
import org.eclipse.xtend.lib.annotations.Accessors
import org.eclipse.xtext.XtextStandaloneSetup
import org.eclipse.xtext.util.Modules2
import org.eclipse.xtext.xtext.generator.model.CodeConfig
import org.eclipse.xtext.xtext.generator.model.IXtextProjectConfig
import org.eclipse.xtext.xtext.generator.model.XtextProjectConfig
/**
* The Xtext language infrastructure generator. Can be configured with {@link IGeneratorFragment}
@ -29,100 +29,118 @@ import org.eclipse.xtext.XtextStandaloneSetup
* <p><b>NOTE: This is a reimplementation of org.eclipse.xtext.generator.Generator</b></p>
*/
class XtextGenerator extends AbstractWorkflowComponent2 {
static val FILE_HEADER_VAR_TIME = '${time}'
static val FILE_HEADER_VAR_DATE = '${date}'
static val FILE_HEADER_VAR_YEAR = '${year}'
static val FILE_HEADER_VAR_USER = '${user}'
static val FILE_HEADER_VAR_VERSION = '${version}'
@Accessors
String encoding = System.getProperty('file.encoding')
XtextProjectConfig projectConfig
@Accessors
String fileHeader = "/*\n * generated by Xtext\n */"
CodeConfig codeConfig
val List<IClassAnnotation> classAnnotations = newArrayList
val List<Module> modules = newArrayList
val List<LanguageConfig2> languageConfigs = newArrayList
new() {
new XtextStandaloneSetup().createInjectorAndDoEMFRegistration()
}
protected override invokeInternal(WorkflowContext ctx, ProgressMonitor monitor, Issues issues) {
/**
* Add a language configuration to be included in the code generation process.
*/
def void addLanguage(LanguageConfig2 language) {
this.languageConfigs.add(language)
}
/**
* Class annotations are used configure specific Java annotations to be added to each generated class.
* Add Guice modules to customize the behavior of the generator.
*/
def void addClassAnnotation(IClassAnnotation annotation) {
this.classAnnotations.add(annotation)
def void addModule(Module module) {
this.modules.add(module)
}
protected def getTransformedFileHeader() {
var result = fileHeader
if (result != null) {
if (result.contains(FILE_HEADER_VAR_TIME)) {
val dateFormat = new SimpleDateFormat('HH:mm:ss')
val time = dateFormat.format(new Date)
result = result.replace(FILE_HEADER_VAR_TIME, time)
}
if (result.contains(FILE_HEADER_VAR_DATE)) {
val dateFormat = new SimpleDateFormat('MMM d, yyyy')
val date = dateFormat.format(new Date)
result = result.replace(FILE_HEADER_VAR_DATE, date)
}
if (result.contains(FILE_HEADER_VAR_YEAR)) {
val dateFormat = new SimpleDateFormat('yyyy')
val year = dateFormat.format(new Date)
result = result.replace(FILE_HEADER_VAR_YEAR, year)
}
if (result.contains(FILE_HEADER_VAR_USER)) {
val user = System.getProperty("user.name")
if (user != null) {
result = result.replace(FILE_HEADER_VAR_USER, user)
}
}
if (result.contains(FILE_HEADER_VAR_VERSION)) {
val version = getVersion()
if (version != null) {
result = result.replace(FILE_HEADER_VAR_VERSION, version)
}
}
protected override invokeInternal(WorkflowContext ctx, ProgressMonitor monitor, Issues issues) {
var IXtextProjectConfig project = projectConfig
for (language : languageConfigs) {
val injector = language.createInjector()
language.generate()
if (project === null)
project = injector.getInstance(IXtextProjectConfig)
}
return result
}
/**
* Read the exact version from the Manifest of the plugin.
*/
private def getVersion() {
var InputStream is
try {
val url = new URL(Plugin.INSTANCE.baseURL + 'META-INF/MANIFEST.MF')
is = url.openStream()
val manifest = new Manifest(is)
return manifest.getMainAttributes().getValue('Bundle-Version')
} catch (Exception e) {
return null;
} finally {
if (is != null) {
try { is.close() }
catch (IOException e) {}
}
if (project !== null) {
project.generateManifests()
project.generatePluginXmls()
project.generateModules()
}
}
/**
* Only needed to determine the Manifest file and its version of this plugin in standalone mode.
*/
private static class Plugin extends EMFPlugin {
public static final Plugin INSTANCE = new Plugin
private new() {
super(#[]);
protected def generateManifests(IXtextProjectConfig project) {
project.runtimeManifest?.generate()
project.runtimeTestManifest?.generate()
project.genericIdeManifest?.generate()
project.genericIdeTestManifest?.generate()
project.eclipsePluginManifest?.generate()
project.eclipsePluginTestManifest?.generate()
project.ideaPluginManifest?.generate()
project.ideaPluginTestManifest?.generate()
project.webManifest?.generate()
project.webTestManifest?.generate()
}
protected def generatePluginXmls(IXtextProjectConfig project) {
project.runtimePluginXml?.generate()
project.runtimeTestPluginXml?.generate()
project.genericIdePluginXml?.generate()
project.genericIdeTestPluginXml?.generate()
project.eclipsePluginPluginXml?.generate()
project.eclipsePluginTestPluginXml?.generate()
project.ideaPluginPluginXml?.generate()
project.ideaPluginTestPluginXml?.generate()
project.webPluginXml?.generate()
project.webTestPluginXml?.generate()
}
protected def generateModules(IXtextProjectConfig project) {
project.runtimeModule?.generate()
project.runtimeTestModule?.generate()
project.genericIdeModule?.generate()
project.genericIdeTestModule?.generate()
project.eclipsePluginModule?.generate()
project.eclipsePluginTestModule?.generate()
project.ideaPluginModule?.generate()
project.ideaPluginTestModule?.generate()
project.webModule?.generate()
project.webTestModule?.generate()
}
protected def Injector createInjector(LanguageConfig2 languageConfig) {
val guiceConfig = <Module>newArrayList(new DefaultGeneratorModule)
guiceConfig.addAll(modules)
guiceConfig.add([
bind(LanguageConfig2).toInstance(languageConfig)
])
if (projectConfig !== null) {
guiceConfig.add([
bind(IXtextProjectConfig).toInstance(projectConfig)
])
}
override getPluginResourceLocator() {
if (codeConfig !== null) {
guiceConfig.add([
bind(CodeConfig).toInstance(codeConfig)
])
}
val injector = Guice.createInjector(Modules2.mixin(guiceConfig))
injector.injectMembers(languageConfig)
languageConfig.initialize()
if (projectConfig !== null) {
injector.injectMembers(projectConfig)
projectConfig.initialize()
}
if (codeConfig !== null) {
injector.injectMembers(codeConfig)
codeConfig.initialize()
}
return injector
}
}

View file

@ -12,6 +12,9 @@ import java.util.ArrayList
import java.io.FileWriter
import java.io.File
/**
* A utility class for generating XtextProjectConfig. Not intended to be used outside of this project.
*/
class ProjectConfigGenerator {
static val INTERFACE_NAME = 'org.eclipse.xtext.xtext.generator.model.IXtextProjectConfig'
@ -56,6 +59,11 @@ class ProjectConfigGenerator {
import org.eclipse.xtext.xtext.generator.model.ModuleAccess;
import org.eclipse.xtext.xtext.generator.model.PluginXmlAccess;
/**
* Inject an instance of this interface in order to generate code in a generator fragment.
*
* <p>This file has been generated with {@link «ProjectConfigGenerator.name»}.</p>
*/
public interface «INTERFACE_NAME.substring(INTERFACE_NAME.lastIndexOf('.') + 1)» {
«FOR p : PROJECTS»
@ -90,38 +98,51 @@ class ProjectConfigGenerator {
import org.eclipse.xtext.xtext.generator.model.ModuleAccess;
import org.eclipse.xtext.xtext.generator.model.PluginXmlAccess;
/**
* Use this class to configure output paths in the XtextGenerator.
*
* <p>This file has been generated with {@link «ProjectConfigGenerator.name»}.</p>
*/
public class «IMPL_NAME.substring(IMPL_NAME.lastIndexOf('.') + 1)» implements «INTERFACE_NAME.substring(INTERFACE_NAME.lastIndexOf('.') + 1)» {
@Inject private IEncodingProvider encodingProvider;
«FOR p : PROJECTS»
private FileSystemAccess «p»SrcAccess;
private FileSystemAccess «p»SrcGenAccess;
private String «p»SrcPath;
private String «p»SrcGenPath;
private ManifestAccess «p»ManifestAccess;
private PluginXmlAccess «p»PluginXmlAccess;
private ModuleAccess «p»ModuleAccess;
«ENDFOR»
private FileSystemAccess orionJsGenAccess;
private FileSystemAccess aceJsGenAccess;
private String orionJsGenPath;
private String aceJsGenPath;
public void initialize() {
}
«FOR p : PROJECTS»
@Override
public IFileSystemAccess2 get«p.toFirstUpper»Src() {
return «p»SrcAccess;
if («p»SrcPath != null)
return new FileSystemAccess(«p»SrcPath, encodingProvider);
else
return null;
}
public void set«p.toFirstUpper»Src(String path) {
«p»SrcAccess = new FileSystemAccess(path, encodingProvider);
this.«p»SrcPath = path;
}
@Override
public IFileSystemAccess2 get«p.toFirstUpper»SrcGen() {
return «p»SrcGenAccess;
if («p»SrcGenPath != null)
return new FileSystemAccess(«p»SrcGenPath, encodingProvider);
else
return null;
}
public void set«p.toFirstUpper»SrcGen(String path) {
«p»SrcGenAccess = new FileSystemAccess(path, encodingProvider);
«p»ModuleAccess = new ModuleAccess(«p»SrcGenAccess);
this.«p»SrcGenPath = path;
}
@Override
@ -129,8 +150,8 @@ class ProjectConfigGenerator {
return «p»ManifestAccess;
}
public void set«p.toFirstUpper»Manifest(String path) {
«p»ManifestAccess = new ManifestAccess(path);
public void set«p.toFirstUpper»Manifest(ManifestAccess manifest) {
this.«p»ManifestAccess = manifest;
}
@Override
@ -138,32 +159,41 @@ class ProjectConfigGenerator {
return «p»PluginXmlAccess;
}
public void set«p.toFirstUpper»PluginXml(String path) {
«p»PluginXmlAccess = new PluginXmlAccess(path);
public void set«p.toFirstUpper»PluginXml(PluginXmlAccess pluginXml) {
this.«p»PluginXmlAccess = pluginXml;
}
@Override
public ModuleAccess get«p.toFirstUpper»Module() {
if («p»ModuleAccess == null) {
«p»ModuleAccess = new ModuleAccess(get«p.toFirstUpper»SrcGen());
}
return «p»ModuleAccess;
}
«ENDFOR»
@Override
public IFileSystemAccess2 getOrionJsGen() {
return orionJsGenAccess;
if (orionJsGenPath != null)
return new FileSystemAccess(orionJsGenPath, encodingProvider);
else
return null;
}
public void setOrionJsGen(String path) {
orionJsGenAccess = new FileSystemAccess(path, encodingProvider);
this.orionJsGenPath = path;
}
@Override
public IFileSystemAccess2 getAceJsGen() {
return aceJsGenAccess;
if (aceJsGenPath != null)
return new FileSystemAccess(aceJsGenPath, encodingProvider);
else
return null;
}
public void setAceJsGen(String path) {
aceJsGenAccess = new FileSystemAccess(path, encodingProvider);
this.aceJsGenPath = path;
}
}

View file

@ -0,0 +1,154 @@
/*******************************************************************************
* 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.model
import java.io.IOException
import java.io.InputStream
import java.net.URL
import java.text.SimpleDateFormat
import java.util.Date
import java.util.List
import java.util.jar.Manifest
import org.eclipse.emf.common.EMFPlugin
import org.eclipse.xtend.lib.annotations.Accessors
import org.eclipse.xtext.util.Strings
/**
* Configuration object for generated code.
*/
class CodeConfig {
static val FILE_HEADER_VAR_TIME = '${time}'
static val FILE_HEADER_VAR_DATE = '${date}'
static val FILE_HEADER_VAR_YEAR = '${year}'
static val FILE_HEADER_VAR_USER = '${user}'
static val FILE_HEADER_VAR_VERSION = '${version}'
@Accessors
String lineDelimiter
@Accessors(PUBLIC_GETTER)
String fileHeader
String fileHeaderTemplate = "/*\n * generated by Xtext\n */"
val List<IClassAnnotation> classAnnotations = newArrayList
/**
* Configure a template for file headers. The template can contain variables:
* <ul>
* <li><code>${time}</code> - the current time of the day (hour:minute:second)</li>
* <li><code>${date}</code> - the current date (month day, year)</li>
* <li><code>${year}</code> - the current year</li>
* <li><code>${user}</code> - the content of the 'user.name' system property</li>
* <li><code>${version}</code> - the generator plug-in version</li>
* </ul>
*/
def void setFileHeader(String fileHeaderTemplate) {
this.fileHeaderTemplate = fileHeaderTemplate
}
/**
* Class annotations are used to configure specific Java annotations to be added to each generated class.
*/
def void addClassAnnotation(IClassAnnotation annotation) {
this.classAnnotations.add(annotation)
}
def initialize() {
var fileHeader = fileHeaderTemplate
if (fileHeader != null) {
if (fileHeader.contains(FILE_HEADER_VAR_TIME)) {
val dateFormat = new SimpleDateFormat('HH:mm:ss')
val time = dateFormat.format(new Date)
fileHeader = fileHeader.replace(FILE_HEADER_VAR_TIME, time)
}
if (fileHeader.contains(FILE_HEADER_VAR_DATE)) {
val dateFormat = new SimpleDateFormat('MMM d, yyyy')
val date = dateFormat.format(new Date)
fileHeader = fileHeader.replace(FILE_HEADER_VAR_DATE, date)
}
if (fileHeader.contains(FILE_HEADER_VAR_YEAR)) {
val dateFormat = new SimpleDateFormat('yyyy')
val year = dateFormat.format(new Date)
fileHeader = fileHeader.replace(FILE_HEADER_VAR_YEAR, year)
}
if (fileHeader.contains(FILE_HEADER_VAR_USER)) {
val user = System.getProperty("user.name")
if (user != null) {
fileHeader = fileHeader.replace(FILE_HEADER_VAR_USER, user)
}
}
if (fileHeader.contains(FILE_HEADER_VAR_VERSION)) {
val version = getVersion()
if (version != null) {
fileHeader = fileHeader.replace(FILE_HEADER_VAR_VERSION, version)
}
}
}
this.fileHeader = fileHeader
}
/**
* Read the exact version from the Manifest of the plugin.
*/
private def getVersion() {
var InputStream is
try {
val url = new URL(Plugin.INSTANCE.baseURL + 'META-INF/MANIFEST.MF')
is = url.openStream()
val manifest = new Manifest(is)
return manifest.getMainAttributes().getValue('Bundle-Version')
} catch (Exception e) {
return null;
} finally {
if (is != null) {
try { is.close() }
catch (IOException e) {}
}
}
}
/**
* Only needed to determine the Manifest file and its version of this plugin in standalone mode.
*/
private static class Plugin extends EMFPlugin {
public static final Plugin INSTANCE = new Plugin
private new() {
super(#[]);
}
override getPluginResourceLocator() {
}
}
def String getClassAnnotationsAsString() {
if (classAnnotations.isEmpty) {
return null
}
val stringBuilder = new StringBuilder
for (annotation : classAnnotations) {
stringBuilder.append(annotation.toString).append(Strings.newLine)
}
return stringBuilder.toString
}
def String getAnnotationImportsAsString() {
if (classAnnotations.isEmpty) {
return null
}
val stringBuilder = new StringBuilder
for (annotation : classAnnotations) {
val importString = annotation.annotationImport
if (!Strings.isEmpty(importString)) {
stringBuilder.append('import ').append(importString).append(';').append(Strings.newLine)
}
}
return stringBuilder.toString
}
}

View file

@ -13,17 +13,22 @@ import java.io.FileInputStream
import java.io.InputStream
import java.nio.charset.Charset
import org.eclipse.emf.common.util.URI
import org.eclipse.xtend.lib.annotations.Accessors
import org.eclipse.xtext.generator.IFileSystemAccess2
import org.eclipse.xtext.parser.IEncodingProvider
import org.eclipse.xtext.util.RuntimeIOException
class FileSystemAccess implements IFileSystemAccess2 {
@Accessors
val String path
val URI baseUri
val IEncodingProvider encodingProvider
new(String basePath, IEncodingProvider encodingProvider) {
this.baseUri = URI.createPlatformResourceURI(basePath, true)
new(String path, IEncodingProvider encodingProvider) {
this.path = path
this.baseUri = URI.createPlatformResourceURI(path, true)
this.encodingProvider = encodingProvider
}

View file

@ -5,12 +5,13 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
package org.eclipse.xtext.xtext.generator
package org.eclipse.xtext.xtext.generator.model
import java.text.SimpleDateFormat
import java.util.Date
import org.eclipse.xtend.lib.annotations.Accessors
import org.eclipse.xtext.util.Strings
import org.eclipse.xtext.xtext.generator.XtextGenerator
/**
* A class annotation configuration for the <code>@Generated</code> annotation.

View file

@ -5,7 +5,7 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
package org.eclipse.xtext.xtext.generator
package org.eclipse.xtext.xtext.generator.model
/**
* Class annotations can be added to the {@link XtextGenerator} workflow component in order

View file

@ -12,6 +12,11 @@ import org.eclipse.xtext.xtext.generator.model.ManifestAccess;
import org.eclipse.xtext.xtext.generator.model.ModuleAccess;
import org.eclipse.xtext.xtext.generator.model.PluginXmlAccess;
/**
* Inject an instance of this interface in order to generate code in a generator fragment.
*
* <p>This file has been generated with {@link org.eclipse.xtext.xtext.generator.internal.ProjectConfigGenerator}.</p>
*/
public interface IXtextProjectConfig {
IFileSystemAccess2 getRuntimeSrc();

View file

@ -7,9 +7,17 @@
*******************************************************************************/
package org.eclipse.xtext.xtext.generator.model
import org.eclipse.xtend.lib.annotations.Accessors
class ManifestAccess {
new(String path) {
@Accessors
String path
@Accessors
boolean merge
def void generate() {
}

View file

@ -7,9 +7,15 @@
*******************************************************************************/
package org.eclipse.xtext.xtext.generator.model
import org.eclipse.xtext.generator.IFileSystemAccess2
class ModuleAccess {
new(FileSystemAccess outlet) {
new(IFileSystemAccess2 outlet) {
}
def void generate() {
}

View file

@ -7,9 +7,14 @@
*******************************************************************************/
package org.eclipse.xtext.xtext.generator.model
import org.eclipse.xtend.lib.annotations.Accessors
class PluginXmlAccess {
new(String path) {
@Accessors
String path
def void generate() {
}

View file

@ -15,80 +15,93 @@ import org.eclipse.xtext.xtext.generator.model.ManifestAccess;
import org.eclipse.xtext.xtext.generator.model.ModuleAccess;
import org.eclipse.xtext.xtext.generator.model.PluginXmlAccess;
/**
* Use this class to configure output paths in the XtextGenerator.
*
* <p>This file has been generated with {@link org.eclipse.xtext.xtext.generator.internal.ProjectConfigGenerator}.</p>
*/
public class XtextProjectConfig implements IXtextProjectConfig {
@Inject private IEncodingProvider encodingProvider;
private FileSystemAccess runtimeSrcAccess;
private FileSystemAccess runtimeSrcGenAccess;
private String runtimeSrcPath;
private String runtimeSrcGenPath;
private ManifestAccess runtimeManifestAccess;
private PluginXmlAccess runtimePluginXmlAccess;
private ModuleAccess runtimeModuleAccess;
private FileSystemAccess runtimeTestSrcAccess;
private FileSystemAccess runtimeTestSrcGenAccess;
private String runtimeTestSrcPath;
private String runtimeTestSrcGenPath;
private ManifestAccess runtimeTestManifestAccess;
private PluginXmlAccess runtimeTestPluginXmlAccess;
private ModuleAccess runtimeTestModuleAccess;
private FileSystemAccess genericIdeSrcAccess;
private FileSystemAccess genericIdeSrcGenAccess;
private String genericIdeSrcPath;
private String genericIdeSrcGenPath;
private ManifestAccess genericIdeManifestAccess;
private PluginXmlAccess genericIdePluginXmlAccess;
private ModuleAccess genericIdeModuleAccess;
private FileSystemAccess genericIdeTestSrcAccess;
private FileSystemAccess genericIdeTestSrcGenAccess;
private String genericIdeTestSrcPath;
private String genericIdeTestSrcGenPath;
private ManifestAccess genericIdeTestManifestAccess;
private PluginXmlAccess genericIdeTestPluginXmlAccess;
private ModuleAccess genericIdeTestModuleAccess;
private FileSystemAccess eclipsePluginSrcAccess;
private FileSystemAccess eclipsePluginSrcGenAccess;
private String eclipsePluginSrcPath;
private String eclipsePluginSrcGenPath;
private ManifestAccess eclipsePluginManifestAccess;
private PluginXmlAccess eclipsePluginPluginXmlAccess;
private ModuleAccess eclipsePluginModuleAccess;
private FileSystemAccess eclipsePluginTestSrcAccess;
private FileSystemAccess eclipsePluginTestSrcGenAccess;
private String eclipsePluginTestSrcPath;
private String eclipsePluginTestSrcGenPath;
private ManifestAccess eclipsePluginTestManifestAccess;
private PluginXmlAccess eclipsePluginTestPluginXmlAccess;
private ModuleAccess eclipsePluginTestModuleAccess;
private FileSystemAccess ideaPluginSrcAccess;
private FileSystemAccess ideaPluginSrcGenAccess;
private String ideaPluginSrcPath;
private String ideaPluginSrcGenPath;
private ManifestAccess ideaPluginManifestAccess;
private PluginXmlAccess ideaPluginPluginXmlAccess;
private ModuleAccess ideaPluginModuleAccess;
private FileSystemAccess ideaPluginTestSrcAccess;
private FileSystemAccess ideaPluginTestSrcGenAccess;
private String ideaPluginTestSrcPath;
private String ideaPluginTestSrcGenPath;
private ManifestAccess ideaPluginTestManifestAccess;
private PluginXmlAccess ideaPluginTestPluginXmlAccess;
private ModuleAccess ideaPluginTestModuleAccess;
private FileSystemAccess webSrcAccess;
private FileSystemAccess webSrcGenAccess;
private String webSrcPath;
private String webSrcGenPath;
private ManifestAccess webManifestAccess;
private PluginXmlAccess webPluginXmlAccess;
private ModuleAccess webModuleAccess;
private FileSystemAccess webTestSrcAccess;
private FileSystemAccess webTestSrcGenAccess;
private String webTestSrcPath;
private String webTestSrcGenPath;
private ManifestAccess webTestManifestAccess;
private PluginXmlAccess webTestPluginXmlAccess;
private ModuleAccess webTestModuleAccess;
private FileSystemAccess orionJsGenAccess;
private FileSystemAccess aceJsGenAccess;
private String orionJsGenPath;
private String aceJsGenPath;
public void initialize() {
}
@Override
public IFileSystemAccess2 getRuntimeSrc() {
return runtimeSrcAccess;
if (runtimeSrcPath != null)
return new FileSystemAccess(runtimeSrcPath, encodingProvider);
else
return null;
}
public void setRuntimeSrc(String path) {
runtimeSrcAccess = new FileSystemAccess(path, encodingProvider);
this.runtimeSrcPath = path;
}
@Override
public IFileSystemAccess2 getRuntimeSrcGen() {
return runtimeSrcGenAccess;
if (runtimeSrcGenPath != null)
return new FileSystemAccess(runtimeSrcGenPath, encodingProvider);
else
return null;
}
public void setRuntimeSrcGen(String path) {
runtimeSrcGenAccess = new FileSystemAccess(path, encodingProvider);
runtimeModuleAccess = new ModuleAccess(runtimeSrcGenAccess);
this.runtimeSrcGenPath = path;
}
@Override
@ -96,8 +109,8 @@ public class XtextProjectConfig implements IXtextProjectConfig {
return runtimeManifestAccess;
}
public void setRuntimeManifest(String path) {
runtimeManifestAccess = new ManifestAccess(path);
public void setRuntimeManifest(ManifestAccess manifest) {
this.runtimeManifestAccess = manifest;
}
@Override
@ -105,32 +118,40 @@ public class XtextProjectConfig implements IXtextProjectConfig {
return runtimePluginXmlAccess;
}
public void setRuntimePluginXml(String path) {
runtimePluginXmlAccess = new PluginXmlAccess(path);
public void setRuntimePluginXml(PluginXmlAccess pluginXml) {
this.runtimePluginXmlAccess = pluginXml;
}
@Override
public ModuleAccess getRuntimeModule() {
if (runtimeModuleAccess == null) {
runtimeModuleAccess = new ModuleAccess(getRuntimeSrcGen());
}
return runtimeModuleAccess;
}
@Override
public IFileSystemAccess2 getRuntimeTestSrc() {
return runtimeTestSrcAccess;
if (runtimeTestSrcPath != null)
return new FileSystemAccess(runtimeTestSrcPath, encodingProvider);
else
return null;
}
public void setRuntimeTestSrc(String path) {
runtimeTestSrcAccess = new FileSystemAccess(path, encodingProvider);
this.runtimeTestSrcPath = path;
}
@Override
public IFileSystemAccess2 getRuntimeTestSrcGen() {
return runtimeTestSrcGenAccess;
if (runtimeTestSrcGenPath != null)
return new FileSystemAccess(runtimeTestSrcGenPath, encodingProvider);
else
return null;
}
public void setRuntimeTestSrcGen(String path) {
runtimeTestSrcGenAccess = new FileSystemAccess(path, encodingProvider);
runtimeTestModuleAccess = new ModuleAccess(runtimeTestSrcGenAccess);
this.runtimeTestSrcGenPath = path;
}
@Override
@ -138,8 +159,8 @@ public class XtextProjectConfig implements IXtextProjectConfig {
return runtimeTestManifestAccess;
}
public void setRuntimeTestManifest(String path) {
runtimeTestManifestAccess = new ManifestAccess(path);
public void setRuntimeTestManifest(ManifestAccess manifest) {
this.runtimeTestManifestAccess = manifest;
}
@Override
@ -147,32 +168,40 @@ public class XtextProjectConfig implements IXtextProjectConfig {
return runtimeTestPluginXmlAccess;
}
public void setRuntimeTestPluginXml(String path) {
runtimeTestPluginXmlAccess = new PluginXmlAccess(path);
public void setRuntimeTestPluginXml(PluginXmlAccess pluginXml) {
this.runtimeTestPluginXmlAccess = pluginXml;
}
@Override
public ModuleAccess getRuntimeTestModule() {
if (runtimeTestModuleAccess == null) {
runtimeTestModuleAccess = new ModuleAccess(getRuntimeTestSrcGen());
}
return runtimeTestModuleAccess;
}
@Override
public IFileSystemAccess2 getGenericIdeSrc() {
return genericIdeSrcAccess;
if (genericIdeSrcPath != null)
return new FileSystemAccess(genericIdeSrcPath, encodingProvider);
else
return null;
}
public void setGenericIdeSrc(String path) {
genericIdeSrcAccess = new FileSystemAccess(path, encodingProvider);
this.genericIdeSrcPath = path;
}
@Override
public IFileSystemAccess2 getGenericIdeSrcGen() {
return genericIdeSrcGenAccess;
if (genericIdeSrcGenPath != null)
return new FileSystemAccess(genericIdeSrcGenPath, encodingProvider);
else
return null;
}
public void setGenericIdeSrcGen(String path) {
genericIdeSrcGenAccess = new FileSystemAccess(path, encodingProvider);
genericIdeModuleAccess = new ModuleAccess(genericIdeSrcGenAccess);
this.genericIdeSrcGenPath = path;
}
@Override
@ -180,8 +209,8 @@ public class XtextProjectConfig implements IXtextProjectConfig {
return genericIdeManifestAccess;
}
public void setGenericIdeManifest(String path) {
genericIdeManifestAccess = new ManifestAccess(path);
public void setGenericIdeManifest(ManifestAccess manifest) {
this.genericIdeManifestAccess = manifest;
}
@Override
@ -189,32 +218,40 @@ public class XtextProjectConfig implements IXtextProjectConfig {
return genericIdePluginXmlAccess;
}
public void setGenericIdePluginXml(String path) {
genericIdePluginXmlAccess = new PluginXmlAccess(path);
public void setGenericIdePluginXml(PluginXmlAccess pluginXml) {
this.genericIdePluginXmlAccess = pluginXml;
}
@Override
public ModuleAccess getGenericIdeModule() {
if (genericIdeModuleAccess == null) {
genericIdeModuleAccess = new ModuleAccess(getGenericIdeSrcGen());
}
return genericIdeModuleAccess;
}
@Override
public IFileSystemAccess2 getGenericIdeTestSrc() {
return genericIdeTestSrcAccess;
if (genericIdeTestSrcPath != null)
return new FileSystemAccess(genericIdeTestSrcPath, encodingProvider);
else
return null;
}
public void setGenericIdeTestSrc(String path) {
genericIdeTestSrcAccess = new FileSystemAccess(path, encodingProvider);
this.genericIdeTestSrcPath = path;
}
@Override
public IFileSystemAccess2 getGenericIdeTestSrcGen() {
return genericIdeTestSrcGenAccess;
if (genericIdeTestSrcGenPath != null)
return new FileSystemAccess(genericIdeTestSrcGenPath, encodingProvider);
else
return null;
}
public void setGenericIdeTestSrcGen(String path) {
genericIdeTestSrcGenAccess = new FileSystemAccess(path, encodingProvider);
genericIdeTestModuleAccess = new ModuleAccess(genericIdeTestSrcGenAccess);
this.genericIdeTestSrcGenPath = path;
}
@Override
@ -222,8 +259,8 @@ public class XtextProjectConfig implements IXtextProjectConfig {
return genericIdeTestManifestAccess;
}
public void setGenericIdeTestManifest(String path) {
genericIdeTestManifestAccess = new ManifestAccess(path);
public void setGenericIdeTestManifest(ManifestAccess manifest) {
this.genericIdeTestManifestAccess = manifest;
}
@Override
@ -231,32 +268,40 @@ public class XtextProjectConfig implements IXtextProjectConfig {
return genericIdeTestPluginXmlAccess;
}
public void setGenericIdeTestPluginXml(String path) {
genericIdeTestPluginXmlAccess = new PluginXmlAccess(path);
public void setGenericIdeTestPluginXml(PluginXmlAccess pluginXml) {
this.genericIdeTestPluginXmlAccess = pluginXml;
}
@Override
public ModuleAccess getGenericIdeTestModule() {
if (genericIdeTestModuleAccess == null) {
genericIdeTestModuleAccess = new ModuleAccess(getGenericIdeTestSrcGen());
}
return genericIdeTestModuleAccess;
}
@Override
public IFileSystemAccess2 getEclipsePluginSrc() {
return eclipsePluginSrcAccess;
if (eclipsePluginSrcPath != null)
return new FileSystemAccess(eclipsePluginSrcPath, encodingProvider);
else
return null;
}
public void setEclipsePluginSrc(String path) {
eclipsePluginSrcAccess = new FileSystemAccess(path, encodingProvider);
this.eclipsePluginSrcPath = path;
}
@Override
public IFileSystemAccess2 getEclipsePluginSrcGen() {
return eclipsePluginSrcGenAccess;
if (eclipsePluginSrcGenPath != null)
return new FileSystemAccess(eclipsePluginSrcGenPath, encodingProvider);
else
return null;
}
public void setEclipsePluginSrcGen(String path) {
eclipsePluginSrcGenAccess = new FileSystemAccess(path, encodingProvider);
eclipsePluginModuleAccess = new ModuleAccess(eclipsePluginSrcGenAccess);
this.eclipsePluginSrcGenPath = path;
}
@Override
@ -264,8 +309,8 @@ public class XtextProjectConfig implements IXtextProjectConfig {
return eclipsePluginManifestAccess;
}
public void setEclipsePluginManifest(String path) {
eclipsePluginManifestAccess = new ManifestAccess(path);
public void setEclipsePluginManifest(ManifestAccess manifest) {
this.eclipsePluginManifestAccess = manifest;
}
@Override
@ -273,32 +318,40 @@ public class XtextProjectConfig implements IXtextProjectConfig {
return eclipsePluginPluginXmlAccess;
}
public void setEclipsePluginPluginXml(String path) {
eclipsePluginPluginXmlAccess = new PluginXmlAccess(path);
public void setEclipsePluginPluginXml(PluginXmlAccess pluginXml) {
this.eclipsePluginPluginXmlAccess = pluginXml;
}
@Override
public ModuleAccess getEclipsePluginModule() {
if (eclipsePluginModuleAccess == null) {
eclipsePluginModuleAccess = new ModuleAccess(getEclipsePluginSrcGen());
}
return eclipsePluginModuleAccess;
}
@Override
public IFileSystemAccess2 getEclipsePluginTestSrc() {
return eclipsePluginTestSrcAccess;
if (eclipsePluginTestSrcPath != null)
return new FileSystemAccess(eclipsePluginTestSrcPath, encodingProvider);
else
return null;
}
public void setEclipsePluginTestSrc(String path) {
eclipsePluginTestSrcAccess = new FileSystemAccess(path, encodingProvider);
this.eclipsePluginTestSrcPath = path;
}
@Override
public IFileSystemAccess2 getEclipsePluginTestSrcGen() {
return eclipsePluginTestSrcGenAccess;
if (eclipsePluginTestSrcGenPath != null)
return new FileSystemAccess(eclipsePluginTestSrcGenPath, encodingProvider);
else
return null;
}
public void setEclipsePluginTestSrcGen(String path) {
eclipsePluginTestSrcGenAccess = new FileSystemAccess(path, encodingProvider);
eclipsePluginTestModuleAccess = new ModuleAccess(eclipsePluginTestSrcGenAccess);
this.eclipsePluginTestSrcGenPath = path;
}
@Override
@ -306,8 +359,8 @@ public class XtextProjectConfig implements IXtextProjectConfig {
return eclipsePluginTestManifestAccess;
}
public void setEclipsePluginTestManifest(String path) {
eclipsePluginTestManifestAccess = new ManifestAccess(path);
public void setEclipsePluginTestManifest(ManifestAccess manifest) {
this.eclipsePluginTestManifestAccess = manifest;
}
@Override
@ -315,32 +368,40 @@ public class XtextProjectConfig implements IXtextProjectConfig {
return eclipsePluginTestPluginXmlAccess;
}
public void setEclipsePluginTestPluginXml(String path) {
eclipsePluginTestPluginXmlAccess = new PluginXmlAccess(path);
public void setEclipsePluginTestPluginXml(PluginXmlAccess pluginXml) {
this.eclipsePluginTestPluginXmlAccess = pluginXml;
}
@Override
public ModuleAccess getEclipsePluginTestModule() {
if (eclipsePluginTestModuleAccess == null) {
eclipsePluginTestModuleAccess = new ModuleAccess(getEclipsePluginTestSrcGen());
}
return eclipsePluginTestModuleAccess;
}
@Override
public IFileSystemAccess2 getIdeaPluginSrc() {
return ideaPluginSrcAccess;
if (ideaPluginSrcPath != null)
return new FileSystemAccess(ideaPluginSrcPath, encodingProvider);
else
return null;
}
public void setIdeaPluginSrc(String path) {
ideaPluginSrcAccess = new FileSystemAccess(path, encodingProvider);
this.ideaPluginSrcPath = path;
}
@Override
public IFileSystemAccess2 getIdeaPluginSrcGen() {
return ideaPluginSrcGenAccess;
if (ideaPluginSrcGenPath != null)
return new FileSystemAccess(ideaPluginSrcGenPath, encodingProvider);
else
return null;
}
public void setIdeaPluginSrcGen(String path) {
ideaPluginSrcGenAccess = new FileSystemAccess(path, encodingProvider);
ideaPluginModuleAccess = new ModuleAccess(ideaPluginSrcGenAccess);
this.ideaPluginSrcGenPath = path;
}
@Override
@ -348,8 +409,8 @@ public class XtextProjectConfig implements IXtextProjectConfig {
return ideaPluginManifestAccess;
}
public void setIdeaPluginManifest(String path) {
ideaPluginManifestAccess = new ManifestAccess(path);
public void setIdeaPluginManifest(ManifestAccess manifest) {
this.ideaPluginManifestAccess = manifest;
}
@Override
@ -357,32 +418,40 @@ public class XtextProjectConfig implements IXtextProjectConfig {
return ideaPluginPluginXmlAccess;
}
public void setIdeaPluginPluginXml(String path) {
ideaPluginPluginXmlAccess = new PluginXmlAccess(path);
public void setIdeaPluginPluginXml(PluginXmlAccess pluginXml) {
this.ideaPluginPluginXmlAccess = pluginXml;
}
@Override
public ModuleAccess getIdeaPluginModule() {
if (ideaPluginModuleAccess == null) {
ideaPluginModuleAccess = new ModuleAccess(getIdeaPluginSrcGen());
}
return ideaPluginModuleAccess;
}
@Override
public IFileSystemAccess2 getIdeaPluginTestSrc() {
return ideaPluginTestSrcAccess;
if (ideaPluginTestSrcPath != null)
return new FileSystemAccess(ideaPluginTestSrcPath, encodingProvider);
else
return null;
}
public void setIdeaPluginTestSrc(String path) {
ideaPluginTestSrcAccess = new FileSystemAccess(path, encodingProvider);
this.ideaPluginTestSrcPath = path;
}
@Override
public IFileSystemAccess2 getIdeaPluginTestSrcGen() {
return ideaPluginTestSrcGenAccess;
if (ideaPluginTestSrcGenPath != null)
return new FileSystemAccess(ideaPluginTestSrcGenPath, encodingProvider);
else
return null;
}
public void setIdeaPluginTestSrcGen(String path) {
ideaPluginTestSrcGenAccess = new FileSystemAccess(path, encodingProvider);
ideaPluginTestModuleAccess = new ModuleAccess(ideaPluginTestSrcGenAccess);
this.ideaPluginTestSrcGenPath = path;
}
@Override
@ -390,8 +459,8 @@ public class XtextProjectConfig implements IXtextProjectConfig {
return ideaPluginTestManifestAccess;
}
public void setIdeaPluginTestManifest(String path) {
ideaPluginTestManifestAccess = new ManifestAccess(path);
public void setIdeaPluginTestManifest(ManifestAccess manifest) {
this.ideaPluginTestManifestAccess = manifest;
}
@Override
@ -399,32 +468,40 @@ public class XtextProjectConfig implements IXtextProjectConfig {
return ideaPluginTestPluginXmlAccess;
}
public void setIdeaPluginTestPluginXml(String path) {
ideaPluginTestPluginXmlAccess = new PluginXmlAccess(path);
public void setIdeaPluginTestPluginXml(PluginXmlAccess pluginXml) {
this.ideaPluginTestPluginXmlAccess = pluginXml;
}
@Override
public ModuleAccess getIdeaPluginTestModule() {
if (ideaPluginTestModuleAccess == null) {
ideaPluginTestModuleAccess = new ModuleAccess(getIdeaPluginTestSrcGen());
}
return ideaPluginTestModuleAccess;
}
@Override
public IFileSystemAccess2 getWebSrc() {
return webSrcAccess;
if (webSrcPath != null)
return new FileSystemAccess(webSrcPath, encodingProvider);
else
return null;
}
public void setWebSrc(String path) {
webSrcAccess = new FileSystemAccess(path, encodingProvider);
this.webSrcPath = path;
}
@Override
public IFileSystemAccess2 getWebSrcGen() {
return webSrcGenAccess;
if (webSrcGenPath != null)
return new FileSystemAccess(webSrcGenPath, encodingProvider);
else
return null;
}
public void setWebSrcGen(String path) {
webSrcGenAccess = new FileSystemAccess(path, encodingProvider);
webModuleAccess = new ModuleAccess(webSrcGenAccess);
this.webSrcGenPath = path;
}
@Override
@ -432,8 +509,8 @@ public class XtextProjectConfig implements IXtextProjectConfig {
return webManifestAccess;
}
public void setWebManifest(String path) {
webManifestAccess = new ManifestAccess(path);
public void setWebManifest(ManifestAccess manifest) {
this.webManifestAccess = manifest;
}
@Override
@ -441,32 +518,40 @@ public class XtextProjectConfig implements IXtextProjectConfig {
return webPluginXmlAccess;
}
public void setWebPluginXml(String path) {
webPluginXmlAccess = new PluginXmlAccess(path);
public void setWebPluginXml(PluginXmlAccess pluginXml) {
this.webPluginXmlAccess = pluginXml;
}
@Override
public ModuleAccess getWebModule() {
if (webModuleAccess == null) {
webModuleAccess = new ModuleAccess(getWebSrcGen());
}
return webModuleAccess;
}
@Override
public IFileSystemAccess2 getWebTestSrc() {
return webTestSrcAccess;
if (webTestSrcPath != null)
return new FileSystemAccess(webTestSrcPath, encodingProvider);
else
return null;
}
public void setWebTestSrc(String path) {
webTestSrcAccess = new FileSystemAccess(path, encodingProvider);
this.webTestSrcPath = path;
}
@Override
public IFileSystemAccess2 getWebTestSrcGen() {
return webTestSrcGenAccess;
if (webTestSrcGenPath != null)
return new FileSystemAccess(webTestSrcGenPath, encodingProvider);
else
return null;
}
public void setWebTestSrcGen(String path) {
webTestSrcGenAccess = new FileSystemAccess(path, encodingProvider);
webTestModuleAccess = new ModuleAccess(webTestSrcGenAccess);
this.webTestSrcGenPath = path;
}
@Override
@ -474,8 +559,8 @@ public class XtextProjectConfig implements IXtextProjectConfig {
return webTestManifestAccess;
}
public void setWebTestManifest(String path) {
webTestManifestAccess = new ManifestAccess(path);
public void setWebTestManifest(ManifestAccess manifest) {
this.webTestManifestAccess = manifest;
}
@Override
@ -483,31 +568,40 @@ public class XtextProjectConfig implements IXtextProjectConfig {
return webTestPluginXmlAccess;
}
public void setWebTestPluginXml(String path) {
webTestPluginXmlAccess = new PluginXmlAccess(path);
public void setWebTestPluginXml(PluginXmlAccess pluginXml) {
this.webTestPluginXmlAccess = pluginXml;
}
@Override
public ModuleAccess getWebTestModule() {
if (webTestModuleAccess == null) {
webTestModuleAccess = new ModuleAccess(getWebTestSrcGen());
}
return webTestModuleAccess;
}
@Override
public IFileSystemAccess2 getOrionJsGen() {
return orionJsGenAccess;
if (orionJsGenPath != null)
return new FileSystemAccess(orionJsGenPath, encodingProvider);
else
return null;
}
public void setOrionJsGen(String path) {
orionJsGenAccess = new FileSystemAccess(path, encodingProvider);
this.orionJsGenPath = path;
}
@Override
public IFileSystemAccess2 getAceJsGen() {
return aceJsGenAccess;
if (aceJsGenPath != null)
return new FileSystemAccess(aceJsGenPath, encodingProvider);
else
return null;
}
public void setAceJsGen(String path) {
aceJsGenAccess = new FileSystemAccess(path, encodingProvider);
this.aceJsGenPath = path;
}
}