Xtext Formatter change configuration dynamically [message #799003] |
Wed, 15 February 2012 10:19 |
Tobi Miller Messages: 12 Registered: January 2012 |
Junior Member |
|
|
Hello,
I'm developing with Xtext and I must say, I really like it. But I have a little problem with the formatter. I extended the AbstractDeclarativeFormatter and everything works great except one "little" thing:
In my grammar I have defined some rules for code blocks that look like this:
VARIABLES
{
TYPE_X short_name "value"
TYPE_Y very__long__name "value"
...
}
OBJECT
{
ATT_LENGTH "value"
ATT_DESCRIPTION "value"
}
What I want to implement in the formatter is that the "value" parts in the VARIABLE block will be aligned in one column (like the "value" parts in the OBJECT blocks). For the "value" parts in the OBJECT blocks it works with inserting a default amount of spaces through myFormattingConfig.setSpace(...).before(...); because I know the length of the longest word before the "value" parts. Is it even possible to determine the length of the longest word (here: very__long__name) in the formatter and insert spaces? And of course I have to do this in each OBJECT block and every new block has another longest name...
After formatting it should look this way:
{
TYPE_X short_name "value"
TYPE_Y very__long__name "value"
...
}
(I know, I try to implement relly bad "elastic tabstops" but that would be enough for my purposes.)
Thanks in advance!
[Updated on: Wed, 15 February 2012 10:26] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02125 seconds