Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Configure postprocessor for xtext2 generator in the MWE2 workflow?
Configure postprocessor for xtext2 generator in the MWE2 workflow? [message #719456] Sat, 27 August 2011 09:18 Go to next message
Matthijs  is currently offline Matthijs Friend
Messages: 11
Registered: August 2011
Junior Member
How to configure a postprocessor for xtext2 generators in the MWE2 workflow?

With Xpand it was possible to configure a postprocessor in the MWE2 workflow. The component org.eclipse.xpand2.Generator provided a property "outlet.postprocessor". This property could be set to e.g. org.eclipse.xpand2.output.JavaBeautifier {}

How to do this with the new generator for xtext2. The component org.eclipse.xtext.generator.GeneratorComponent provides an outlet property but there does not seem to be a postprocessor property.

Regards
Matthijs
Re: Configure postprocessor for xtext2 generator in the MWE2 workflow? [message #719458 is a reply to message #719456] Sat, 27 August 2011 09:45 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

i guess you are takling about a postprocessor for Xtend2 (not Xtext 2). this is currrently not possible, you have to build something yourself.
feel free to file an enhancement request.

maybe adding it here https://bugs.eclipse.org/bugs/show_bug.cgi?id=353463

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Sat, 27 August 2011 09:51]

Report message to a moderator

(no subject) [message #719460 is a reply to message #719456] Sat, 27 August 2011 09:51 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Matthijs,

the generator itself is only the abstraction that finally writes to
disk. If you want to modify the contents, you should customize the
IGenerator for your language. Otherwise you'd end up with different
results depending on whether your create in Eclipse or from a workflow.

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com


On 27.08.11 11:18, Matthijs wrote:
> How to configure a postprocessor for xtext2 generators in the MWE2
> workflow?
>
> With Xpand it was possible to configure a postprocessor in the MWE2
> workflow. The component org.eclipse.xpand2.Generator provided a property
> "outlet.postprocessor". This property could be set to e.g.
> org.eclipse.xpand2.output.JavaBeautifier {}
>
> How to do this with the new generator for xtext2. The component
> org.eclipse.xtext.generator.GeneratorComponent provides an outlet
> property but there does not seem to be a postprocessor property.
> Regards
> Matthijs
Re: (no subject) [message #719498 is a reply to message #719460] Sat, 27 August 2011 14:04 Go to previous message
Matthijs  is currently offline Matthijs Friend
Messages: 11
Registered: August 2011
Junior Member
Hi

Thanks for the advice. Indeed the formatter can easily be called from the IGenerator.

I have created a little class 'Beautifier' to make it easy to call the xpand formatters. See code snippet below. Now I can easily call the formatter from the IGenerator, before the code is given to IFileSystemAccess for saving. It is easy to do the same for other postprocessors, including the hybridlabs beautifier.

Dependencies to org.eclipse.jdt.core,org.eclipse.jface.text,org.eclipse.xpand must be added to META-INF.

Regards
Matthijs


@Singleton
public class Beautifier {

@Inject
JavaBeautifier javaBeautifier;

/**
* Format code with PostProcessor (XPand style).
*/
public CharSequence format(String fileName, CharSequence code) {

// create fileHandle with dummy outlet.
File file = new File(fileName);
FileHandle fileHandle = new FileHandleImpl(new Outlet(), file);
fileHandle.setBuffer(code);

// call postProcessor for formatting the code.
javaBeautifier.beforeWriteAndClose(fileHandle);

// return formatted results.
return fileHandle.getBuffer();

}
}
Previous Topic:Exporting deployable plug-ins using ant scripts
Next Topic:View AST of my grammar
Goto Forum:
  


Current Time: Thu Apr 25 03:33:59 GMT 2024

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

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

Back to the top