I can't get StringTemplate to indent
-
27-06-2021 - |
Question
I have the following StringTemplate group
group RPInstr;
before(firstStat) ::= <<
<{<[beforeEnteringInstr(),firstStat]; anchor, separator="\n">}; anchor>
>>
beforeEnteringInstr() ::= "before();"
I am trying to make the first statement of a method to align with the instrumentation code ("before();"). However, what I am getting right now is something like this:
public int method() {
before();
System.out.println("testing");
System.out.println("testing again");
}
What is the proper way to indent before(); and the next statement so I get the following?
public int method() {
before();
System.out.println("testing");
System.out.println("testing again");
}
Thanks in advance.
PS: the options that I am using in my grammar are the following
options {output=template; rewrite=true; backtrack=true; memoize=true;}
Solution
the expr in before(firstStat) is not indented. No reason for ST to indent then.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow