@Override public boolean visit(WhileStatement node) { handleLoopBody(node.getBody()); int lParen = this.tm.firstIndexIn(node, TokenNameLPAREN); int rParen = this.tm.firstIndexAfter(node.getExpression(), TokenNameRPAREN); handleParenthesesPositions(lParen, rParen, this.options.parenthesis_positions_in_if_while_statement); return true; }
@Override public boolean visit(WhileStatement node) { handleLoopBody(node.getBody()); int lParen = this.tm.firstIndexIn(node, TokenNameLPAREN); int rParen = this.tm.firstIndexAfter(node.getExpression(), TokenNameRPAREN); handleParenthesesPositions(lParen, rParen, this.options.parenthesis_positions_in_if_while_statement); return true; }
@Override public boolean visit(EnhancedForStatement node) { if (!this.options.keep_simple_for_body_on_same_line) handleLoopBody(node.getBody()); int lParen = this.tm.firstIndexIn(node, TokenNameLPAREN); int rParen = this.tm.firstIndexBefore(node.getBody(), TokenNameRPAREN); handleParenthesesPositions(lParen, rParen, this.options.parenthesis_positions_in_for_statement); return true; }
@Override public boolean visit(WhileStatement node) { if (!this.options.keep_simple_while_body_on_same_line) handleLoopBody(node.getBody()); int lParen = this.tm.firstIndexIn(node, TokenNameLPAREN); int rParen = this.tm.firstIndexAfter(node.getExpression(), TokenNameRPAREN); handleParenthesesPositions(lParen, rParen, this.options.parenthesis_positions_in_if_while_statement); return true; }
@Override public boolean visit(ForStatement node) { if (!this.options.keep_simple_for_body_on_same_line) handleLoopBody(node.getBody()); int lParen = this.tm.firstIndexIn(node, TokenNameLPAREN); int rParen = this.tm.firstIndexBefore(node.getBody(), TokenNameRPAREN); handleParenthesesPositions(lParen, rParen, this.options.parenthesis_positions_in_for_statement); return true; }
@Override public boolean visit(ForStatement node) { handleLoopBody(node.getBody()); int lParen = this.tm.firstIndexIn(node, TokenNameLPAREN); int rParen = this.tm.firstIndexBefore(node.getBody(), TokenNameRPAREN); handleParenthesesPositions(lParen, rParen, this.options.parenthesis_positions_in_for_statement); return true; }
@Override public boolean visit(EnhancedForStatement node) { handleLoopBody(node.getBody()); int lParen = this.tm.firstIndexIn(node, TokenNameLPAREN); int rParen = this.tm.firstIndexBefore(node.getBody(), TokenNameRPAREN); handleParenthesesPositions(lParen, rParen, this.options.parenthesis_positions_in_for_statement); return true; }
@Override public boolean visit(EnhancedForStatement node) { handleLoopBody(node.getBody()); int lParen = this.tm.firstIndexIn(node, TokenNameLPAREN); int rParen = this.tm.firstIndexBefore(node.getBody(), TokenNameRPAREN); handleParenthesesPositions(lParen, rParen, this.options.parenthesis_positions_in_for_statement); return true; }
@Override public boolean visit(ForStatement node) { handleLoopBody(node.getBody()); int lParen = this.tm.firstIndexIn(node, TokenNameLPAREN); int rParen = this.tm.firstIndexBefore(node.getBody(), TokenNameRPAREN); handleParenthesesPositions(lParen, rParen, this.options.parenthesis_positions_in_for_statement); return true; }
@Override public boolean visit(IfStatement node) { Statement elseNode = node.getElseStatement(); Statement thenNode = node.getThenStatement(); if (elseNode != null) { if (this.options.insert_new_line_before_else_in_if_statement || !(thenNode instanceof Block)) this.tm.firstTokenBefore(elseNode, TokenNameelse).breakBefore(); boolean keepElseOnSameLine = (this.options.keep_else_statement_on_same_line) || (this.options.compact_else_if && (elseNode instanceof IfStatement)); if (!keepElseOnSameLine) handleLoopBody(elseNode); } boolean keepThenOnSameLine = this.options.keep_then_statement_on_same_line || (this.options.keep_simple_if_on_one_line && elseNode == null); if (!keepThenOnSameLine) handleLoopBody(thenNode); int lParen = this.tm.firstIndexIn(node, TokenNameLPAREN); int rParen = this.tm.firstIndexAfter(node.getExpression(), TokenNameRPAREN); handleParenthesesPositions(lParen, rParen, this.options.parenthesis_positions_in_if_while_statement); return true; }
@Override public boolean visit(IfStatement node) { Statement elseNode = node.getElseStatement(); Statement thenNode = node.getThenStatement(); if (elseNode != null) { if (this.options.insert_new_line_before_else_in_if_statement || !(thenNode instanceof Block)) this.tm.firstTokenBefore(elseNode, TokenNameelse).breakBefore(); boolean keepElseOnSameLine = (this.options.keep_else_statement_on_same_line) || (this.options.compact_else_if && (elseNode instanceof IfStatement)); if (!keepElseOnSameLine) handleLoopBody(elseNode); } boolean keepThenOnSameLine = this.options.keep_then_statement_on_same_line || (this.options.keep_simple_if_on_one_line && elseNode == null); if (!keepThenOnSameLine) handleLoopBody(thenNode); int lParen = this.tm.firstIndexIn(node, TokenNameLPAREN); int rParen = this.tm.firstIndexAfter(node.getExpression(), TokenNameRPAREN); handleParenthesesPositions(lParen, rParen, this.options.parenthesis_positions_in_if_while_statement); return true; }
@Override public boolean visit(IfStatement node) { Statement elseNode = node.getElseStatement(); Statement thenNode = node.getThenStatement(); if (elseNode != null) { if (this.options.insert_new_line_before_else_in_if_statement || !(thenNode instanceof Block)) this.tm.firstTokenBefore(elseNode, TokenNameelse).breakBefore(); boolean keepElseOnSameLine = (this.options.keep_else_statement_on_same_line) || (this.options.compact_else_if && (elseNode instanceof IfStatement)); if (!keepElseOnSameLine) handleLoopBody(elseNode); } boolean keepThenOnSameLine = this.options.keep_then_statement_on_same_line || (this.options.keep_simple_if_on_one_line && elseNode == null); if (!keepThenOnSameLine) handleLoopBody(thenNode); int lParen = this.tm.firstIndexIn(node, TokenNameLPAREN); int rParen = this.tm.firstIndexAfter(node.getExpression(), TokenNameRPAREN); handleParenthesesPositions(lParen, rParen, this.options.parenthesis_positions_in_if_while_statement); return true; }
@Override public boolean visit(DoStatement node) { Statement body = node.getBody(); handleLoopBody(body); if (this.options.insert_new_line_before_while_in_do_statement || (!(body instanceof Block) && !(body instanceof EmptyStatement))) { Token whileToken = this.tm.firstTokenBefore(node.getExpression(), TokenNamewhile); whileToken.breakBefore(); } int lParen = this.tm.firstIndexBefore(node.getExpression(), TokenNameLPAREN); int rParen = this.tm.firstIndexAfter(node.getExpression(), TokenNameRPAREN); handleParenthesesPositions(lParen, rParen, this.options.parenthesis_positions_in_if_while_statement); return true; }
@Override public boolean visit(DoStatement node) { Statement body = node.getBody(); handleLoopBody(body); if (this.options.insert_new_line_before_while_in_do_statement || (!(body instanceof Block) && !(body instanceof EmptyStatement))) { Token whileToken = this.tm.firstTokenBefore(node.getExpression(), TokenNamewhile); whileToken.breakBefore(); } int lParen = this.tm.firstIndexBefore(node.getExpression(), TokenNameLPAREN); int rParen = this.tm.firstIndexAfter(node.getExpression(), TokenNameRPAREN); handleParenthesesPositions(lParen, rParen, this.options.parenthesis_positions_in_if_while_statement); return true; }
@Override public boolean visit(DoStatement node) { Statement body = node.getBody(); boolean sameLine = this.options.keep_simple_do_while_body_on_same_line; if (!sameLine) handleLoopBody(body); if (this.options.insert_new_line_before_while_in_do_statement || (!(body instanceof Block) && !(body instanceof EmptyStatement) && !sameLine)) { Token whileToken = this.tm.firstTokenBefore(node.getExpression(), TokenNamewhile); whileToken.breakBefore(); } int lParen = this.tm.firstIndexBefore(node.getExpression(), TokenNameLPAREN); int rParen = this.tm.firstIndexAfter(node.getExpression(), TokenNameRPAREN); handleParenthesesPositions(lParen, rParen, this.options.parenthesis_positions_in_if_while_statement); return true; }