Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Using declarative formatter with Assignment objects(Unable to decrement indentation after assignments)
Using declarative formatter with Assignment objects [message #783746] Thu, 26 January 2012 11:19 Go to next message
John J. Camilleri is currently offline John J. CamilleriFriend
Messages: 33
Registered: November 2011
Location: Göteborg
Member
In my grammar I have a rule like so:
Exp : k=ID '->' v=ID

I want to implement my formatter to achieve the following:
aaa ->
  bbb
ccc ->
  ddd
eee ->
  fff

Since there is no keyword after the second ID, in my formatter I tried something like the following:
c.setLinewrap().before(f.getExpRule());
Assignment k = f.getExpAccess().getVAssignment_0_2();
c.setLinewrap().before(k);
c.setIndentationIncrement().before(k);
c.setLinewrap().after(k);
c.setIndentationDecrement().after(k);

While the "before" rules seem to work fine, the "after" rules do not seem to work on Assignment objects. Thus my indentation is never decremented and I end up with the following:
aaa ->
  bbb
  ccc ->
    ddd
    eee ->
      fff

How can I achieve this when there is no keyword and the end of the Exp rule for me to apply after() to?

[Updated on: Thu, 26 January 2012 12:28]

Report message to a moderator

Re: Using declarative formatter with Assignment objects [message #783769 is a reply to message #783746] Thu, 26 January 2012 12:27 Go to previous messageGo to next message
John J. Camilleri is currently offline John J. CamilleriFriend
Messages: 33
Registered: November 2011
Location: Göteborg
Member
I have filed a bug here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=369795
But please advise if this is not actually a bug, and if there some workaround for this behaviour.
Re: Using declarative formatter with Assignment objects [message #783780 is a reply to message #783769] Thu, 26 January 2012 12:54 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi John,

you may want to try to define #after for the rulecall in the assignment.

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

Am 26.01.12 13:27, schrieb John J. Camilleri:
> I have filed a bug here:
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=369795
> But please advise if this is not actually a bug, and if there some
> workaround for this behaviour.
Re: Using declarative formatter with Assignment objects [message #783788 is a reply to message #783780] Thu, 26 January 2012 13:11 Go to previous message
John J. Camilleri is currently offline John J. CamilleriFriend
Messages: 33
Registered: November 2011
Location: Göteborg
Member
Thanks for your reply, but I'm not sure exactly what you mean.
If you are suggesting something like the following:
c.setIndentationDecrement().after( f.getIDRule() );

then this is not suitable, because the decreasing of the indentation only applies when ID appears after the -> in the example rule above.
In other words, I don't want to define the formatting for all ID rule calls.
Does anyone have any suggestions for how to handle this?

[Updated on: Mon, 30 January 2012 08:40]

Report message to a moderator

Previous Topic:How to handle two different scoping providers?
Next Topic:How to set an arbitrary value to a property in particular alternative?
Goto Forum:
  


Current Time: Thu Apr 25 02:12:33 GMT 2024

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

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

Back to the top