Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » AbstractDeclarativeFormatter 2.0 strange behaviour
AbstractDeclarativeFormatter 2.0 strange behaviour [message #661326] Thu, 24 March 2011 09:32 Go to next message
Mark Christiaens is currently offline Mark ChristiaensFriend
Messages: 63
Registered: October 2010
Member
I've been trying to implement a formatter in Xtext 2.0 but it's not behaving well. Some questions:

  • It's unclear to me what the precendence of FormattingConfig commands is. For example. Suppose I tell the formatter to put a newline after a ';' keyword. Suppose in addition I tell the formatter to not put a newline after a rule that ends with the ';' keyword. What will happen? Will a newline appear or not?
  • The AbstractDeclarativeFormatter implements some kind of default behavior that I can tweak with overriding configureFormatting. What is that behavior?
  • Is the formatting supposed to be "idempotent" i.e., if I reformat an already formatted file, I would expect that nothing happens. In my tests, additional new lines continue to appear each time I invoke the formatter.

Regards,
---
Mark Christiaens
Discover the Future of VHDL Design
Go to www.sigasi.com
Re: AbstractDeclarativeFormatter 2.0 strange behaviour [message #661377 is a reply to message #661326] Thu, 24 March 2011 12:57 Go to previous messageGo to next message
Mark Christiaens is currently offline Mark ChristiaensFriend
Messages: 63
Registered: October 2010
Member
In the mean time I was able to answer one of my questions. The reason why my formatter is not idempotent is that I've redefined the whitespace lexer rule of my grammar; it does not include the newline character. I guess that internally the formatter uses this rule to strip off all whitespace and was therefore leaving the newlines in place.
---
Mark Christiaens
Discover the Future of VHDL Design
Go to www.sigasi.com
Re: AbstractDeclarativeFormatter 2.0 strange behaviour [message #661822 is a reply to message #661326] Mon, 28 March 2011 06:48 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Mark,

yes, subsequent formatting of the very same input should yield unchanged
results. Everything else sounds like a bug to me. Regarding the
precedencies of formatting rules: I cannot provide any insight on this
at the moment, but will come back to that question later. The default
behavior of the declarative formatter is to insert a single space
between two tokens.

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

Am 24.03.11 10:32, schrieb Mark Christiaens:
> I've been trying to implement a formatter in Xtext 2.0 but it's not
> behaving well. Some questions:
>
> It's unclear to me what the precendence of FormattingConfig commands is.
> For example. Suppose I tell the formatter to put a newline after a ';'
> keyword. Suppose in addition I tell the formatter to not put a newline
> after a rule that ends with the ';' keyword. What will happen? Will a
> newline appear or not?
> The AbstractDeclarativeFormatter implements some kind of default
> behavior that I can tweak with overriding configureFormatting. What is
> that behavior?
> Is the formatting supposed to be "idempotent" i.e., if I reformat an
> already formatted file, I would expect that nothing happens. In my
> tests, additional new lines continue to appear each time I invoke the
> formatter.
> Regards,
> ---
> Mark Christiaens
> Discover the Future of VHDL Design
> Go to http://www.sigasi.com
Re: AbstractDeclarativeFormatter 2.0 strange behaviour [message #661916 is a reply to message #661822] Mon, 28 March 2011 14:05 Go to previous message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
I have also seen that formatting applied when none should have been.
Logged an issue with reproducible JUnit tests for the cases I found:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=340166

- henrik

On 3/28/11 8:48 AM, Sebastian Zarnekow wrote:
> Hi Mark,
>
> yes, subsequent formatting of the very same input should yield unchanged
> results. Everything else sounds like a bug to me. Regarding the
> precedencies of formatting rules: I cannot provide any insight on this
> at the moment, but will come back to that question later. The default
> behavior of the declarative formatter is to insert a single space
> between two tokens.
>
> Regards,
> Sebastian
Previous Topic:Problem with the editor
Next Topic:resolution of uriFragment failed
Goto Forum:
  


Current Time: Tue Apr 23 14:25:51 GMT 2024

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

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

Back to the top