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/Fame.java 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("benlock.fm"), 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) {
		res=resource;
		val basePackage = resource.allContents.filter(MainRule).next.fullyQualifiedName
		fsa.generateFile(basePackage.toString("/") + "/api/exception/InitFailedException.java", "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");
	    defaultOutput.setOutputDirectory("./src-gen");
	    defaultOutput.setOverrideExistingResources(true);
	    defaultOutput.setCreateOutputDirectory(true);
	    defaultOutput.setCleanUpDerivedResources(true);
	    defaultOutput.setSetDerivedProperty(true);

	    OutputConfiguration fameOutput = new OutputConfiguration(DEFAULT_OUTPUT_FAME);
	    onceOutput.setDescription("Java source folder");
	    onceOutput.setOutputDirectory("./src/main/java");
	    onceOutput.setOverrideExistingResources(true);
	    onceOutput.setCreateOutputDirectory(true);
	    onceOutput.setCleanUpDerivedResources(false);
	    onceOutput.setSetDerivedProperty(true);


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: 11892
Registered: July 2009
Senior Member
Hi,

what exactly is not working? what is your expectation?


Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Previous Topic:grammar modularization within one project
Next Topic:Error 404 with CORS enabled
Goto Forum:
  


Current Time: Sun Apr 22 12:58:36 GMT 2018

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

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