Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext standalone generator output configuration
Xtext standalone generator output configuration [message #1771980] Sat, 02 September 2017 09:31 Go to next message
Vishal Desai is currently offline Vishal DesaiFriend
Messages: 1
Registered: September 2017
Junior Member
I've managed to implement a standalone generator with the tutorial on typefox named how-and-why-use-xtext-without-the-ide
What I cannot achieve is the output configuration.
In my generator, the output config values are used while creating and when I run the same with the standalone generator, it shows DEFAULT_OUTPUT_FAMEorg/eclipse/ when I print out the file name.
class FameGeneratorRunner {
	def static void main(String[] args) {
		val injector = new FameStandaloneSetup().createInjectorAndDoEMFRegistration();
		val resourceSet = injector.getInstance(XtextResourceSet);
		val resource = resourceSet.getResource(URI.createFileURI(""), true);
		val generator = injector.getInstance(FameGenerator);
		val fsa = new InMemoryFileSystemAccess();
		generator.doGenerate(resource, fsa);
		for (Entry<String, CharSequence> file : fsa.getTextFiles().entrySet()) {
		  println("Generated file path : "+file.getKey());
		  println("Generated file contents : "+file.getValue());

class FameGenerator implements IGenerator{
	@Inject extension IQualifiedNameProvider

	Resource res
	override doGenerate(Resource resource, IFileSystemAccess fsa) {
		val basePackage = resource.allContents.filter(MainRule).next.fullyQualifiedName
		fsa.generateFile(basePackage.toString("/") + "/api/exception/", "DEFAULT_OUTPUT_FAME", basePackage.compileInitFailedException)
		for (struct : resource.allContents.toIterable.filter(GlamourType)) {
			val glamour = struct.fullyQualifiedName.lastSegment.toFirstUpper
			fsa.generateFile(basePackage.toString("/") + "/" + glamour + 
			".java", "DEFAULT_OUTPUT_FAME", struct.compile)

public Set<OutputConfiguration> getOutputConfigurations() {
	    OutputConfiguration defaultOutput = new OutputConfiguration(IFileSystemAccess2.DEFAULT_OUTPUT);
	    defaultOutput.setDescription("Output Folder");

	    OutputConfiguration fameOutput = new OutputConfiguration(DEFAULT_OUTPUT_FAME);
	    onceOutput.setDescription("Java source folder");

Could some one please help me understand why everything works well whilst running via an Eclipse application but no file is generated via the standalone procedure. Is it because the IOutputConfiguration is a part of eclipse application process or something? Thank you in advance.
Re: Xtext standalone generator output configuration [message #1772111 is a reply to message #1771980] Tue, 05 September 2017 16:00 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14296
Registered: July 2009
Senior Member

what exactly is not working? what is your expectation?

Need professional support for Xtext, Xpand, EMF?
Go to:
Twitter : @chrdietrich
Blog :
Previous Topic:grammar modularization within one project
Next Topic:Error 404 with CORS enabled
Goto Forum:

Current Time: Wed Jul 06 23:40:52 GMT 2022

Powered by FUDForum. Page generated in 0.02131 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top