I have the following grammar:
Department:
'Department:' name = ID
'Company:' companyName = STRING
'Persons:' persons += Person+
;
Person:
firstName = STRING
':'
surname = STRING
':'
address = STRING
;
And I would like to have formatting like this:
Department: Department1
Company: "Company1"
Persons:
"Person1FirstName" : "Person1LastName" : "Person1Address"
"Person2FirstName" : "Person2LastName" : "Person2Address"
But when I implement the formatter code for the Person type I cannot seem to be able to use indent twice since the white space formatting gets merged instead of getting concatinated.
class TestsFormatter extends AbstractFormatter2
{
def dispatch void format(Department department, extension IFormattableDocument document)
{
department.interior[indent]
department.regionFor.keyword("Department:").prepend[setNewLines(2)]
department.regionFor.keyword("Department:").append[oneSpace]
department.regionFor.keyword("Company:").prepend[newLine]
department.regionFor.keyword("Company:").append[oneSpace]
department.regionFor.keyword("Persons:").prepend[newLine]
for (Person person : department.persons)
{
person.format
}
}
def dispatch void format(Person person, extension IFormattableDocument document)
{
person.prepend[indent]
person.prepend[indent]
}
}
I found out that there is an example with "increaseIndentation"/"decreaseIndentation" in the documentation of AbstractFormatter2. But when I try to use them, they cannot be resolved.