private void handleTokenBefore(ASTNode node, int tokenType, boolean spaceBefore, boolean spaceAfter) { if (spaceBefore || spaceAfter) { Token token = this.tm.firstTokenBefore(node, tokenType); handleToken(token, spaceBefore, spaceAfter); } }
private void handleTokenBefore(ASTNode node, int tokenType, boolean spaceBefore, boolean spaceAfter) { if (spaceBefore || spaceAfter) { Token token = this.tm.firstTokenBefore(node, tokenType); handleToken(token, spaceBefore, spaceAfter); } }
private void handleTokenBefore(ASTNode node, int tokenType, boolean spaceBefore, boolean spaceAfter) { if (spaceBefore || spaceAfter) { Token token = this.tm.firstTokenBefore(node, tokenType); handleToken(token, spaceBefore, spaceAfter); } }
@Override public boolean visit(TryStatement node) { if (node.getFinally() != null && this.options.insert_new_line_before_finally_in_try_statement) { this.tm.firstTokenBefore(node.getFinally(), TokenNamefinally).breakBefore(); } if (!node.resources().isEmpty()) { int lParen = this.tm.firstIndexIn(node, TokenNameLPAREN); int rParen = this.tm.firstIndexBefore(node.getBody(), TokenNameRPAREN); handleParenthesesPositions(lParen, rParen, this.options.parenthesis_positions_in_try_clause); } return true; }
@Override public boolean visit(TryStatement node) { if (node.getFinally() != null && this.options.insert_new_line_before_finally_in_try_statement) { this.tm.firstTokenBefore(node.getFinally(), TokenNamefinally).breakBefore(); } if (!node.resources().isEmpty()) { int lParen = this.tm.firstIndexIn(node, TokenNameLPAREN); int rParen = this.tm.firstIndexBefore(node.getBody(), TokenNameRPAREN); handleParenthesesPositions(lParen, rParen, this.options.parenthesis_positions_in_try_clause); } return true; }
@Override public boolean visit(TryStatement node) { if (node.getFinally() != null && this.options.insert_new_line_before_finally_in_try_statement) { this.tm.firstTokenBefore(node.getFinally(), TokenNamefinally).breakBefore(); } if (!node.resources().isEmpty()) { int lParen = this.tm.firstIndexIn(node, TokenNameLPAREN); int rParen = this.tm.firstIndexBefore(node.getBody(), TokenNameRPAREN); handleParenthesesPositions(lParen, rParen, this.options.parenthesis_positions_in_try_clause); } return true; }
private void handleInvocation(ASTNode invocationNode, ASTNode nodeBeforeOpeningParen, ASTNode nodeAfterClosingParen) { if (handleEmptyParens(nodeBeforeOpeningParen, this.options.insert_space_between_empty_parens_in_method_invocation)) { handleToken(nodeBeforeOpeningParen, TokenNameLPAREN, this.options.insert_space_before_opening_paren_in_method_invocation, false); } else { handleToken(nodeBeforeOpeningParen, TokenNameLPAREN, this.options.insert_space_before_opening_paren_in_method_invocation, this.options.insert_space_after_opening_paren_in_method_invocation); if (this.options.insert_space_before_closing_paren_in_method_invocation) { Token closingParen = nodeAfterClosingParen == null ? this.tm.lastTokenIn(invocationNode, TokenNameRPAREN) : this.tm.firstTokenBefore(nodeAfterClosingParen, TokenNameRPAREN); closingParen.spaceBefore(); } } }
private void handleInvocation(ASTNode invocationNode, ASTNode nodeBeforeOpeningParen, ASTNode nodeAfterClosingParen) { if (handleEmptyParens(nodeBeforeOpeningParen, this.options.insert_space_between_empty_parens_in_method_invocation)) { handleToken(nodeBeforeOpeningParen, TokenNameLPAREN, this.options.insert_space_before_opening_paren_in_method_invocation, false); } else { handleToken(nodeBeforeOpeningParen, TokenNameLPAREN, this.options.insert_space_before_opening_paren_in_method_invocation, this.options.insert_space_after_opening_paren_in_method_invocation); if (this.options.insert_space_before_closing_paren_in_method_invocation) { Token closingParen = nodeAfterClosingParen == null ? this.tm.lastTokenIn(invocationNode, TokenNameRPAREN) : this.tm.firstTokenBefore(nodeAfterClosingParen, TokenNameRPAREN); closingParen.spaceBefore(); } } }
private void handleInvocation(ASTNode invocationNode, ASTNode nodeBeforeOpeningParen, ASTNode nodeAfterClosingParen) { if (handleEmptyParens(nodeBeforeOpeningParen, this.options.insert_space_between_empty_parens_in_method_invocation)) { handleToken(nodeBeforeOpeningParen, TokenNameLPAREN, this.options.insert_space_before_opening_paren_in_method_invocation, false); } else { handleToken(nodeBeforeOpeningParen, TokenNameLPAREN, this.options.insert_space_before_opening_paren_in_method_invocation, this.options.insert_space_after_opening_paren_in_method_invocation); if (this.options.insert_space_before_closing_paren_in_method_invocation) { Token closingParen = nodeAfterClosingParen == null ? this.tm.lastTokenIn(invocationNode, TokenNameRPAREN) : this.tm.firstTokenBefore(nodeAfterClosingParen, TokenNameRPAREN); closingParen.spaceBefore(); } } }
@Override public boolean visit(AnnotationTypeDeclaration node) { handleBracedCode(node, node.getName(), this.options.brace_position_for_annotation_type_declaration, this.options.indent_body_declarations_compare_to_annotation_declaration_header); handleBodyDeclarations(node.bodyDeclarations()); if (node.getModifiers() == 0) this.tm.firstTokenBefore(node.getName(), TokenNameAT).breakBefore(); this.declarationModifierVisited = false; return true; }
@Override public boolean visit(AnnotationTypeDeclaration node) { handleBracedCode(node, node.getName(), this.options.brace_position_for_annotation_type_declaration, this.options.indent_body_declarations_compare_to_annotation_declaration_header, this.options.insert_new_line_in_empty_annotation_declaration); handleBodyDeclarations(node.bodyDeclarations()); if (node.getModifiers() == 0) this.tm.firstTokenBefore(node.getName(), TokenNameAT).breakBefore(); this.declarationModifierVisited = false; return true; }
@Override public boolean visit(AnnotationTypeDeclaration node) { handleBracedCode(node, node.getName(), this.options.brace_position_for_annotation_type_declaration, this.options.indent_body_declarations_compare_to_annotation_declaration_header, this.options.insert_new_line_in_empty_annotation_declaration); handleBodyDeclarations(node.bodyDeclarations()); if (node.getModifiers() == 0) this.tm.firstTokenBefore(node.getName(), TokenNameAT).breakBefore(); this.declarationModifierVisited = false; 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; }
@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(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; }
this.tm.firstTokenBefore(thrownExceptionTypes.get(0), TokenNamethrows).spaceBefore();
this.tm.firstTokenBefore(thrownExceptionTypes.get(0), TokenNamethrows).spaceBefore();