Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Custom Formatter - minimising impact when grammar changes?
Custom Formatter - minimising impact when grammar changes? [message #799962] Thu, 16 February 2012 14:07 Go to next message
Scott Finnie is currently offline Scott FinnieFriend
Messages: 94
Registered: October 2011
Member
I have a simple custom formatter implemented for linewrap and indenting. For example,

c.setLinewrap().after( f.getClassAccess().getLeftCurlyBracketKeyword_3());


However: it's very sensitive to changes in the grammar. For example, if I add a new construct to the 'Class' rule, the method called above changes to:

getLeftCurlyBracketKeyword_4()


It's only the suffix that changes, but it breaks the formatter. Fixing it isn't difficult but is a bit of a nuisance. So I wondered if there's a way around it?

As a matter of interest, any reason why the _<x> suffix is there anyway? If it wasn't there this problem wouldn't occur...

thx.
Re: Custom Formatter - minimising impact when grammar changes? [message #800022 is a reply to message #799962] Thu, 16 February 2012 15:34 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi,

the suffix is used to make the names unique and to avoid silent breakage
of accesses. Consider the following example:

Rule:
'{' A '}’ | B '{' C '}'
;

Which one would be getLeftCurlyBracketKeyword() ?

You can workaround this issue by introducing own delegates thus every
suffixed method is only called by exactly one handwritten utility.

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

Am 16.02.12 15:07, schrieb sfinnie Mising name:
> I have a simple custom formatter implemented for linewrap and indenting.
> For example,
>
>
> c.setLinewrap().after( f.getClassAccess().getLeftCurlyBracketKeyword_3());
>
>
> However: it's very sensitive to changes in the grammar. For example, if
> I add a new construct to the 'Class' rule, the method called above
> changes to:
>
>
> getLeftCurlyBracketKeyword_4()
>
>
> It's only the suffix that changes, but it breaks the formatter. Fixing
> it isn't difficult but is a bit of a nuisance. So I wondered if there's
> a way around it?
>
> As a matter of interest, any reason why the _<x> suffix is there anyway?
> If it wasn't there this problem wouldn't occur...
>
> thx.
Re: Custom Formatter - minimising impact when grammar changes? [message #800079 is a reply to message #800022] Thu, 16 February 2012 17:00 Go to previous message
Scott Finnie is currently offline Scott FinnieFriend
Messages: 94
Registered: October 2011
Member
Thanks Sebastian.
Previous Topic:Standalone compilation of xbase based grammar
Next Topic:Check eContainer for equality
Goto Forum:
  


Current Time: Thu Apr 25 12:07:13 GMT 2024

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

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

Back to the top