Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [Xtext formatting] Ignore indentation in special cases and how to disable autowrap
[Xtext formatting] Ignore indentation in special cases and how to disable autowrap [message #730970] Thu, 29 September 2011 15:58 Go to next message
Michael Ernst is currently offline Michael ErnstFriend
Messages: 49
Registered: July 2010
Member
Hi,
I created a formatter for my language definition by inheriting from AbstractDeclarativeFormatter. In the default generated formatter the following pattern is used for selecting pairs for indentation:
for( Pair<Keyword, Keyword> pair : f.findKeywordPairs( "{", "}" ) )

Is there a way to filter the result because I use also the curly brackets for array initialization.

I fixed this by introducing a terminal rule for the curly brackets and define the behaviour for each bracket occurence but when doing so I have to define it this way:
c.setLinewrap().after( f.get...().getOPEN_CURLY_BRACKETTerminalRuleCall_5() );
c.setIndentationDecrement().before(...
c.setIndentationDecrement().before(...

Thats ok, but when I make changes in my grammer definition, it is possible that the numbers at end changes which leads to compile errors.
Is there a better way?

Another question is how to disable the autowrap functionality in a global scope. The documentation says that it can be overridden for local elements. Isn't there a global setting?

Kind regards
Michael
Re: [Xtext formatting] Ignore indentation in special cases and how to disable autowrap [message #730989 is a reply to message #730970] Thu, 29 September 2011 16:28 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

seems ok from my point. these compile errors are a feature and not a bug - consider having the same keyword more than once in a rule - and want to have different formatting rules. but afaik you dont need a own terminal rule

~Christian


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

[Updated on: Thu, 29 September 2011 16:50]

Report message to a moderator

Re: [Xtext formatting] Ignore indentation in special cases and how to disable autowrap [message #731000 is a reply to message #730989] Thu, 29 September 2011 16:50 Go to previous messageGo to next message
Michael Ernst is currently offline Michael ErnstFriend
Messages: 49
Registered: July 2010
Member
Hi,
as I already said it works great for me and only changes at the grammer could lead to compile errors and I hoped that there is a better way. Thanks for the reply.

Any ideas for the disabling of the autowrap functionaly?

Kind regards
Michael
Re: [Xtext formatting] Ignore indentation in special cases and how to disable autowrap [message #731004 is a reply to message #731000] Thu, 29 September 2011 16:58 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

what do you mean with autowrap? linewrapping

c.setNoLinewrap();
does dont work globally

what about c.setAutoLinewrap(Integer.MAX_VALUE)

~Christian


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

[Updated on: Thu, 29 September 2011 17:03]

Report message to a moderator

Re: [Xtext formatting] Ignore indentation in special cases and how to disable autowrap [message #731053 is a reply to message #731004] Thu, 29 September 2011 19:04 Go to previous message
Michael Ernst is currently offline Michael ErnstFriend
Messages: 49
Registered: July 2010
Member
OK, also a solution but it also wraps after a big amount of tokens. A complete disabling would be better.
BTW. I tried it with a negative value which kills my runtime workspace (doesn't react any more).

Kind regards
Michael
Previous Topic:View encompassing multiple files
Next Topic:Unique flags in generated ecore model file
Goto Forum:
  


Current Time: Tue Apr 23 16:03:10 GMT 2024

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

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

Back to the top