Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Invoking Code Beautifiers with mwe2
Invoking Code Beautifiers with mwe2 [message #532775] Tue, 11 May 2010 08:26 Go to next message
Stefan Missing name is currently offline Stefan Missing nameFriend
Messages: 13
Registered: May 2010
Junior Member
Hi,

I recently switched from working with Xtext 0.7.2 to the latest milestone release M7. In the stable release and using mwe I can invoke the beautifier from within the org.eclipse.xpand2.Generator component just fine:

<beautifier class="org.fornax.utilities.formatter.xml.XmlFormatter"/>


The syntax, obviously, has changed in mwe2 and since my search for any examples on using beautifiers with mwe2 failed to yield anything helpful, the best I could come up with was

component = org.eclipse.xpand2.Generator {
		metaModel = org.eclipse.xtend.typesystem.emf.EmfRegistryMetaModel {}
		expand = "templates::ScxMain::main FOREACH model"
		outlet = {
			path = targetDir
		}
		fileEncoding = fileEncoding 
		beautifier = org.fornax.utilities.formatter.xml.XmlFormatter		
}	


The keyword "beautifier" is not marked as an error (so i assume it is correct), however, the specified XmlFormatter is. The formatter should be correctly added to the build path and thus referencable from within the project (same set-up as the working 0.7.2 project).
The provided error message says it's not:

Couldn't resolve reference to Referrable 'org.fornax.utilities.formatter.xml.XmlFormatter'


How do I invoke the code formatter correctly?

Thanks and best regards
Stefan

Re: Invoking Code Beautifiers with mwe2 [message #532783 is a reply to message #532775] Tue, 11 May 2010 08:38 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Stefan,

there is a syntax error in the workflow. You have to use braces behind
class references. Otherwise they are interpreted as local variables
(Referable).

beautifier = org.fornax.utilities.formatter.xml.XmlFormatter {}

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

Am 11.05.10 10:26, schrieb Stefan:
> Hi,
>
> I recently switched from working with Xtext 0.7.2 to the latest
> milestone release M7. In the stable release and using mwe I can invoke
> the beautifier from within the org.eclipse.xpand2.Generator component
> just fine:
>
> <beautifier class="org.fornax.utilities.formatter.xml.XmlFormatter"/>
>
> The syntax, obviously, has changed in mwe2 and since my search for any
> examples on using beautifiers with mwe2 failed to yield anything
> helpful, the best I could come up with was
>
> component = org.eclipse.xpand2.Generator {
> metaModel = org.eclipse.xtend.typesystem.emf.EmfRegistryMetaModel {}
> expand = "templates::ScxMain::main FOREACH model"
> outlet = {
> path = targetDir
> }
> fileEncoding = fileEncoding beautifier =
> org.fornax.utilities.formatter.xml.XmlFormatter
> }
>
> The keyword "beautifier" is not marked as an error (so i assume it is
> correct), however, the specified XmlFormatter is. The formatter should
> be correctly added to the build path and thus referencable from within
> the project (same set-up as the working 0.7.2 project).
> The provided error message says it's not:
>
> Couldn't resolve reference to Referrable
> 'org.fornax.utilities.formatter.xml.XmlFormatter'
>
> How do I invoke the code formatter correctly?
>
> Thanks and best regards
> Stefan
>
>
Re: Invoking Code Beautifiers with mwe2 [message #532785 is a reply to message #532783] Tue, 11 May 2010 08:53 Go to previous messageGo to next message
Stefan Missing name is currently offline Stefan Missing nameFriend
Messages: 13
Registered: May 2010
Junior Member
Hi Sebastian,

thank you for the fast response. Unfortunately, if I add the braces, I get another error:

A value of type ' org.fornax.utilities.formatter.xml.XmlFormatter' can not be assigned to the feature setBeautifier


The same error arises when I try the JavaBeautifier delivered with Xtext instead, so it shouldn't be due to some incompatible implementation of the fornax formatter.

Regards
Stefan
Re: Invoking Code Beautifiers with mwe2 [message #532803 is a reply to message #532785] Tue, 11 May 2010 09:31 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Stefan,

you are stumbling accross
https://bugs.eclipse.org/bugs/show_bug.cgi?id=310429

As setBeautifier(List) is not compatible to an XmlFormatter, you have to
register it as a post processor. Sorry for that.

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

Am 11.05.10 10:53, schrieb Stefan:
> Hi Sebastian,
>
> thank you for the fast response. Unfortunately, if I add the braces, I
> get another error:
>
> A value of type ' org.fornax.utilities.formatter.xml.XmlFormatter' can
> not be assigned to the feature setBeautifier
>
> The same error arises when I try the JavaBeautifier delivered with Xtext
> instead, so it shouldn't be due to some incompatible implementation of
> the fornax formatter.
>
> Regards
> Stefan
Re: Invoking Code Beautifiers with mwe2 [message #532819 is a reply to message #532803] Tue, 11 May 2010 10:02 Go to previous messageGo to next message
Stefan Missing name is currently offline Stefan Missing nameFriend
Messages: 13
Registered: May 2010
Junior Member
Hi Sebastian,

thank you again. The inevitable question now is: How do I register the beautifier as a postprocessor? The Xtext User Guide tells me i can implement my own postprocessor in "<MyDsl>PostProcessor.ext", but this looks more like model processing than actual file processing to me. How, if at all, can I invoke the beautifier from within this Extend file?

Additionally, mwe does seem to have a postprocessor attribute, but trying to use it like
postprocessor = org.fornax.utilities.formatter.xml.XmlFormatter {}

only gets me
Couldn't resolve reference to JvmFeature 'postprocessor'


Regards Stefan
Re: Invoking Code Beautifiers with mwe2 [message #532834 is a reply to message #532819] Tue, 11 May 2010 11:01 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hello Stefan,

have you configured the postprocessor within the outlet? e.g.

	component = org.eclipse.xpand2.Generator {
		metaModel = org.eclipse.xtend.typesystem.emf.EmfRegistryMetaModel {}
		expand = "templates::Template::main FOREACH model"
		outlet = {
			path = targetDir
			postprocessor = org.eclipse.xpand2.output.XmlBeautifier {}
		}
		fileEncoding = fileEncoding
	}


~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
icon14.gif  Re: Invoking Code Beautifiers with mwe2 [message #532844 is a reply to message #532834] Tue, 11 May 2010 11:10 Go to previous message
Stefan Missing name is currently offline Stefan Missing nameFriend
Messages: 13
Registered: May 2010
Junior Member
Hi Christian,

no, I did not ... should have seen this myself.
The workflow is now running and the beautifier beautifying. Thanks a lot to both of you!

Regards
Stefan
Previous Topic:problems with the generated Parser (in M7)
Next Topic:classpath-URLs in generated ecore file
Goto Forum:
  


Current Time: Fri Apr 19 20:45:15 GMT 2024

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

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

Back to the top