|
Re: hidden whitespaces and formatting [message #915567 is a reply to message #915517] |
Mon, 17 September 2012 10:45  |
Eclipse User |
|
|
|
I know how I deal with this in the formatter used by Geppetto - but it
is a new/different formatter. There I make a distinction between
explicit and implied white space and allow the implementor to treat an
explicit whitespace as if it was implied. It is otherwise difficult to
handle non-breaking spaces that are part of the grammar.
Don't remember if a similar concepts is available in the old/current
formatter.
The formatter I wrote for cloudsmith / geppetto is generic, so if you do
not find another solution, you may want to try using it instead (it is
not a plug-and-play replacement though as rules are expressed a
different way).
Regards
- henrik
On 2012-17-09 14:55, Christoph Caks wrote:
> Hi,
>
> i'm trying to add formatting to my grammer and stumbled upon the
> following issue:
>
> when a rule does not hide whitespaces "Fuu hidden():" the formatter
> autmatically duplicates the whitespaces within the rule.
>
> here is a simple example:
>
> the grammer
>
> grammar example.WSFun with org.eclipse.xtext.common.Terminals
>
> generate wSFun "<url stripped, because the forum wont' allow links>"
>
> Model:
> lines+=(WSLine|NoWSLine)+
> ;
>
> WSLine returns Line:
> {WSLine} 'ws' 'A' 'B' ';'
> ;
>
> NoWSLine returns Line hidden():
> {NoWSLine} 'nows' WS+ 'A' WS+ 'B' WS* ';'
> ;
>
> the formatter:
>
> protected void configureFormatting(FormattingConfig c) {
> for (Keyword k : getGrammarAccess().findKeywords(";")) {
> c.setLinewrap().after(k);
> c.setNoSpace().before(k);
> }
> }
>
>
> formatting the WSLine works perfectly fine, but formatting the NoWSLine
> leads to the issue.
>
> before calling format:
> ws A B;nows A B;
>
> after the first call to format:
> ws A B;
> nows A B;
>
> after the second call to format:
> ws A B;
> nows A B;
>
> i used Xtext SDK 2.3.0.v201206120633
> org.eclipse.xtext.sdk.feature.group Eclipse Modeling Project
>
>
> is there a way to work around this?
> I need the whitespaces in my language, so using hidden(WS) is no
> solution for me :/
>
> greetings Christoph
|
|
|
Powered by
FUDForum. Page generated in 0.03331 seconds