Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext Formatter change configuration dynamically
Xtext Formatter change configuration dynamically [message #799003] Wed, 15 February 2012 10:19 Go to next message
Tobi Miller is currently offline Tobi MillerFriend
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

Re: Xtext Formatter change configuration dynamically [message #799046 is a reply to message #799003] Wed, 15 February 2012 11:24 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

Hi Tobi,

short answer: the declarative formatter is not capable of column layouts.

Regards,
~Karsten


Need professional support for Xtext, EMF, Eclipse IDE?
Go to: http://devhub.karakun.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
Re: Xtext Formatter change configuration dynamically [message #799067 is a reply to message #799046] Wed, 15 February 2012 12:03 Go to previous message
Tobi Miller is currently offline Tobi MillerFriend
Messages: 12
Registered: January 2012
Junior Member
I was already frightened about such an answer... Is there any other formatter interface in Xtext I could implement? Or do I have to build one from scratch?

EDIT: Ok, found out that I could implement IFormatter. But can't I access the node model from my existing formatter and add some spaces?

[Updated on: Wed, 15 February 2012 12:40]

Report message to a moderator

Previous Topic:allow anythin in a block?
Next Topic:JvmModelInferrer and super-constructor
Goto Forum:
  


Current Time: Sat Apr 20 01:56:04 GMT 2024

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

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

Back to the top