Formatting issue with comma-separated lists [message #655171] |
Fri, 18 February 2011 14:38 |
Jose Carlos Messages: 5 Registered: February 2011 |
Junior Member |
|
|
Hi all,
I'm testing the formatting capability offered in xtext, but I've found the following issue and I can't guess if it's a bug or something i'm missing. My grammar is someting like:
Root : model+=MyModel* ;
MyModel : head=Head "[" ( body=Body )? "]";
Head : name+=Tag ( ',' name+=Tag )* ;
Tag : name+=TagImpl+;
TagImpl : name=ID;
Body : name+=BodyImpl+;
BodyImpl : name=ID "=" (value=ID)? ";" ;
So I have a head and a body, and the head is made up from a comma-separated list of "Tag" objects, which are a list of TagImpl objects.
My formatting code is:
c.setLinewrap().after ( g.getMyModelAccess().getLeftSquareBracketKeyword_1() );
c.setIndentationIncrement().after ( g.getMyModelAccess().getLeftSquareBracketKeyword_1() );
c.setLinewrap().before ( g.getMyModelAccess().getRightSquareBracketKeyword_3() );
c.setIndentationDecrement().before ( g.getMyModelAccess().getRightSquareBracketKeyword_3() );
c.setLinewrap().after ( g.getMyModelAccess().getRightSquareBracketKeyword_3() );
So I expect linewraps before/after "[" / "]", and indentation on the body. An example:
one , two three [
four = five ;
]
six seven [
eight = nine ;
]
The problem is that I get:
one , two three [
four = five ;
] six seven [
eight = nine ;
]
which is incorrect. There's no line wrap after the first "]" sign. I also tried to do the formatting by using the Pair<Keyword,Keyword> code from grammar.findKeywordPairs(...), but the result is also wrong. The funny thing is, when I remove the comma between "one" and "two" the code is formatted correctly and the line wrap comes up; the problem always happens when I am using a comma-separated list.
Regards
|
|
|
Re: Formatting issue with comma-separated lists [message #655326 is a reply to message #655171] |
Sat, 19 February 2011 12:19 |
Sebastian Zarnekow Messages: 3118 Registered: July 2009 |
Senior Member |
|
|
Hi Jose,
this one should be fixed in the upcoming 1.0.2 service release. Please
open a ticket if the problem persists with the latest version installed.
Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Am 18.02.11 15:38, schrieb Jose Carlos:
> Hi all,
>
> I'm testing the formatting capability offered in xtext, but I've found
> the following issue and I can't guess if it's a bug or something i'm
> missing. My grammar is someting like:
>
>
> Root : model+=MyModel* ;
> MyModel : head=Head "[" ( body=Body )? "]";
> Head : name+=Tag ( ',' name+=Tag )* ;
> Tag : name+=TagImpl+;
> TagImpl : name=ID;
> Body : name+=BodyImpl+;
> BodyImpl : name=ID "=" (value=ID)? ";" ;
>
>
> So I have a head and a body, and the head is made up from a
> comma-separated list of "Tag" objects, which are a list of TagImpl objects.
>
> My formatting code is:
>
>
> c.setLinewrap().after (
> g.getMyModelAccess().getLeftSquareBracketKeyword_1() );
> c.setIndentationIncrement().after (
> g.getMyModelAccess().getLeftSquareBracketKeyword_1() );
>
> c.setLinewrap().before (
> g.getMyModelAccess().getRightSquareBracketKeyword_3() );
> c.setIndentationDecrement().before (
> g.getMyModelAccess().getRightSquareBracketKeyword_3() );
> c.setLinewrap().after (
> g.getMyModelAccess().getRightSquareBracketKeyword_3() );
>
>
> So I expect linewraps before/after "[" / "]", and indentation on the
> body. An example:
>
>
> one , two three [
> four = five ;
> ]
> six seven [
> eight = nine ;
> ]
>
>
> The problem is that I get:
>
>
> one , two three [
> four = five ;
> ] six seven [
> eight = nine ;
> ]
>
>
> which is incorrect. There's no line wrap after the first "]" sign. I
> also tried to do the formatting by using the Pair<Keyword,Keyword> code
> from grammar.findKeywordPairs(...), but the result is also wrong. The
> funny thing is, when I remove the comma between "one" and "two" the code
> is formatted correctly and the line wrap comes up; the problem always
> happens when I am using a comma-separated list.
>
> Regards
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04085 seconds