Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Formatting ML_Comment inside a indentation block ?
Formatting ML_Comment inside a indentation block ? [message #917958] Thu, 20 September 2012 15:44 Go to next message
Cristiano Gavião is currently offline Cristiano GaviãoFriend
Messages: 279
Registered: July 2009
Senior Member
Hi,

I'm using the following code to format a document:
		c.setLinewrap(0, 1, 2).before(gac.getSL_COMMENTRule());
		c.setLinewrap(0, 1, 2).before(gac.getML_COMMENTRule());
		c.setLinewrap(0, 1, 1).after(gac.getML_COMMENTRule());



The problem that I'm facing is that only the first line of the multiline comment is being formatted when there is a indentation (see in test result below).

Could someone point me what can I do to indent all the commented lines?

org.junit.ComparisonFailure: expected:<...partment."
	}

	/**
[	* The roles
	]*/
	role id financia...> but was:<...partment."
	}

	/**
[* The roles
]*/
	role id financia...>
	at org.junit.Assert.assertEquals(Assert.java:125)



thanks,

Cristiano
Re: Formatting ML_Comment inside a indentation block ? [message #918250 is a reply to message #917958] Thu, 20 September 2012 22:02 Go to previous message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
Afaik, the current formatter is not capable of dealing with that, and it
is difficult (as in "you don't want to do that") to extend.

If you are a bit adventurous you could use the formatter I developed for
cloudsmith / geppetto @ github - it is not a direct replacement as the
rules are expressed using CSS style rules and/or via "semantic methods".
One of the things I spent a lot of time on is its comment formatter.

The geppetto formatter is generic but is not (currently) packaged as a
separate consumable plugin. (It also requires overriding and tweaking
some aspects of the serializer) - hence the "adventurous" warning.
Geppetto itself uses it, so there is a live example.

Your other option is probably to do a second pass of formatting, finding
all comments, extracting them from their "container", and perform
formatting using the context they are found in. (It quickly gets complex
if you want to deal with things like "should comment be moved of
folded", "aligning sequences of SL comments", etc.

Maybe someone else has done something smart that can be reused.

Regards
- henrik

On 2012-20-09 17:44, Cristiano Gaviao wrote:
> Hi,
>
> I'm using the following code to format a document:
>
> c.setLinewrap(0, 1, 2).before(gac.getSL_COMMENTRule());
> c.setLinewrap(0, 1, 2).before(gac.getML_COMMENTRule());
> c.setLinewrap(0, 1, 1).after(gac.getML_COMMENTRule());
>
>
>
> The problem that I'm facing is that only the first line of the multiline
> comment is being formatted when there is a indentation (see in test
> result below).
>
> Could someone point me what can I do to indent all the commented lines?
>
>
> org.junit.ComparisonFailure: expected:<...partment."
> }
>
> /**
> [ * The roles
> ]*/
> role id financia...> but was:<...partment."
> }
>
> /**
> [* The roles
> ]*/
> role id financia...>
> at org.junit.Assert.assertEquals(Assert.java:125)
>
>
>
> thanks,
>
> Cristiano
>
Previous Topic:Large Files slows the Editor
Next Topic:Modify text in XtextEditor
Goto Forum:
  


Current Time: Fri Apr 26 13:20:07 GMT 2024

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

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

Back to the top