protected void markup(IDomNode node, final boolean breakAndAlign, final int clusterWidth) {
Iterator<IDomNode> itor = node.treeIterator();
Map<IDomNode, Integer> operatorNodes = Maps.newHashMap();
IntegerCluster cluster = new IntegerCluster(clusterWidth);
// With a little help From the grammar:
// DefinitionArgumentList returns pp::DefinitionArgumentList : {pp::DefinitionArgumentList}
// '('
// (arguments += DefinitionArgument (',' arguments += DefinitionArgument)*)? ','?
// ')'
// ;
//
// DefinitionArgument returns pp::DefinitionArgument
// : argName = UNION_VARIABLE_OR_NAME ((op = '=' | op = '=>') value = AssignmentExpression)?
// ;
final DefinitionArgumentListElements access = grammarAccess.getDefinitionArgumentListAccess();
while(itor.hasNext()) {
IDomNode n = itor.next();
EObject ge = n.getGrammarElement();
if(ge == access.getLeftParenthesisKeyword_1()) {
IDomNode nextLeaf = DomModelUtils.nextLeaf(n);
if(DomModelUtils.isWhitespace(nextLeaf))
if(breakAndAlign)
nextLeaf.getStyles().add(StyleSet.withStyles(styles.oneLineBreak(), styles.indent()));
else
nextLeaf.getStyles().add(StyleSet.withStyles(styles.indent()));
}
else if(ge == access.getRightParenthesisKeyword_4()) {
IDomNode prevLeaf = DomModelUtils.previousLeaf(n);
if(DomModelUtils.isWhitespace(prevLeaf))
prevLeaf.getStyles().add(StyleSet.withStyles(styles.dedent()));
}
else if(breakAndAlign) {
if(ge == access.getCommaKeyword_2_1_0()) {
IDomNode nextLeaf = DomModelUtils.nextLeaf(n);
if(DomModelUtils.isWhitespace(nextLeaf))
nextLeaf.getStyles().add(StyleSet.withStyles(styles.oneLineBreak()));
}
// Break on endcomma does not look good - here is how it would be done though...
// else if(ge == grammarAccess.getDefinitionArgumentListAccess().getEndCommaParserRuleCall_3()) {
// IDomNode spaceAfterEndComma = DomModelUtils.nextLeaf(DomModelUtils.firstTokenWithText(n));
// if(DomModelUtils.isWhitespace(spaceAfterEndComma))
// spaceAfterEndComma.getStyles().add(StyleSet.withStyles(styles.oneLineBreak()));
//
// }
else if(ge == grammarAccess.getDefinitionArgumentAccess().getOpEqualsSignGreaterThanSignKeyword_1_0_1_0() ||
ge == grammarAccess.getDefinitionArgumentAccess().getOpEqualsSignKeyword_1_0_0_0()) {
EObject semantic = n.getParent().getSemanticObject();
if(semantic != null && semantic instanceof DefinitionArgument) {
DefinitionArgument da = (DefinitionArgument) semantic;
int length = da.getArgName() == null
? 0
: da.getArgName().length();
operatorNodes.put(n, length);
cluster.add(length);
}
}
}
}
if(breakAndAlign)