Formatting multiple parser rules within curly brackets [message #1786093] |
Wed, 25 April 2018 08:58  |
Eclipse User |
|
|
|
I have the following grammar simplified:
Match:
'match'
'{'
target=Target
subject=Subject
action=Action
matcher=Matcher
'}';
Target:
'target' '=' value=STRING;
Subject:
'subject' '=' value=STRING]
Action:
'action' '=' value=STRING;
Matcher:
'contextMatcher' '=' value=ID;
My formatted text should look something like this:
match {
target = ".*"
subject = "foo"
action = ".*"
contextMatcher = MATCH_ALWAYS
}
But right now it looks like this (Only the first parser rule is being indented):
match {
target = ".*"
subject = "foo"
action = ".*"
contextMatcher = MATCH_ALWAYS
}
I tried the following in my formatter but it didn't work:
def dispatch void format(Match match, extension IFormattableDocument document) {
match.regionFor.keyword('match').append[oneSpace]
match.regionFor.keyword(matchAccess.leftCurlyBracketKeyword_1).append[newLine]
match.regionFor.keyword(matchAccess.rightCurlyBracketKeyword_6).prepend[newLine]
interior(match.regionFor.keyword(matchAccess.leftCurlyBracketKeyword_1),match.regionFor.keyword(matchAccess.rightCurlyBracketKeyword_6))[indent]
}
Does anyone have an idea what I can do?
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05507 seconds