@Override public boolean enter(RuleSetNode ruleSet) { if (_compress) { // Check if the inner scope contains nodes ScopeNode scope = NodeTreeUtils.getFirstChild(ruleSet, ScopeNode.class); return !scope.getChildren().isEmpty(); } return super.enter(ruleSet); }
@Override public boolean enter(ScopeNode node) { if (node.getParent() != null && node.isBracketsDisplayed()) { print('{'); List<Node> children = node.getChildren(); if (children.isEmpty()) { // do nothing } else { addIndent(); } } return super.enter(node); }
@Override public boolean exit(ScopeNode node) { if (node.getParent() != null && node.isBracketsDisplayed()) { List<Node> children = node.getChildren(); if (children.isEmpty()) { // do nothing } else { removeIndent(); } deleteIndent().print('}'); // Some editors and version control systems don't like extremely long lines, so add // line breaks every so often when compressing. if (_compress && _sb.length() - _lastCompressedLineBreak > COMPRESSED_LINE_BREAK_POSITION) { printLine(); _lastCompressedLineBreak = _sb.length(); } } return super.exit(node); }