Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Formatting issue with comma-separated lists
Formatting issue with comma-separated lists [message #655171] Fri, 18 February 2011 14:38 Go to next message
Jose Carlos is currently offline Jose CarlosFriend
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 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
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
Re: Formatting issue with comma-separated lists [message #655363 is a reply to message #655326] Sat, 19 February 2011 22:40 Go to previous messageGo to next message
Jose Carlos is currently offline Jose CarlosFriend
Messages: 5
Registered: February 2011
Junior Member
Thank you Sebastian. I'm sure it'll be fixed :) You guys are doing a great work!

Regards,
José Carlos
Re: Formatting issue with comma-separated lists [message #657273 is a reply to message #655363] Wed, 02 March 2011 10:04 Go to previous message
Jose Carlos is currently offline Jose CarlosFriend
Messages: 5
Registered: February 2011
Junior Member
I've tested in Xtext 1.0.2 and is still wrong so I've opened this bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=338637
Previous Topic:EclipseCon tutorial on Enriching your models with OCL
Next Topic:[SOLVED] Question about global scopes and import statements
Goto Forum:
  


Current Time: Fri Sep 20 03:13:01 GMT 2024

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

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

Back to the top