Skip to main content



      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 05:18 Go to next message
Eclipse UserFriend
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 05:45 Go to previous messageGo to next message
Eclipse UserFriend
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

[Updated on: Sat, 27 August 2011 05:51] by Moderator

(no subject) [message #719460 is a reply to message #719456] Sat, 27 August 2011 05:51 Go to previous messageGo to next message
Eclipse UserFriend
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 10:04 Go to previous message
Eclipse UserFriend
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: Sun Jul 06 09:13:39 EDT 2025

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

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

Back to the top