Declarative Code Formatter ignores configurations related with parser rules [message #774580] |
Wed, 04 January 2012 08:09 |
|
I made some language and everything was good at first.
And, I tried to remove statement separator ';'.
So I've face a lot of ambiguous problems and left-recursion problems.
After some dig,
I could eliminate problems by left-factoring and using Syntactic Predicates.
After that, (I can't sure)
Declarative Code Formatter began to work incorrectly.
It seems to ignore every format configuration related with Parser-rules.
for Instance, My root rule is:
Calc:
elements+=CalcElement*;
CalcElement:
(Add | Define);
...
and My format configuration code begins with:
CalcGrammarAccess ga = (CalcGrammarAccess) getGrammarAccess();
c.setLinewrap(1, 1, 2).after(ga.getCalcElementRule());
...
But formatting did not make line wraps after each CalcElement.
I tried several other rules and alternative rules, nothing worked.
Only configuration related with keyword rules worked likes how I expected.
What do I missing some picture?
[Updated on: Wed, 04 January 2012 08:10] Report message to a moderator
|
|
|
Re: Declarative Code Formatter ignores configurations related with parser rules [message #774602 is a reply to message #774580] |
Wed, 04 January 2012 09:16 |
|
I think only leaf parser-rules work correctly,
for instance:
A: B | C;
c.setLinewrap(1, 1, 2).after(ga.getARule()); // NOT WORK
c.setLinewrap(1, 1, 2).after(ga.getBRule()); // WORK
c.setLinewrap(1, 1, 2).after(ga.getCRule()); // WORK
Do I digging right place? If so, I consider it as a bug and I will make a manual formatter. I think it's easy because of I have still very powerful xtext parser.
PS.
Injection and lazy creation make debuging declarative formatter so crazy.
I tried make it real time debug-able but I couldn't. Any Idea?
And I think defining format configuration with Java Code makes no sense since it's called Declarative thing.
|
|
|
Powered by
FUDForum. Page generated in 0.02118 seconds