private void handleModuleStatement(List<Name> names, int joiningTokenType) { if (names.isEmpty()) return; int joiningTokenIndex = this.tm.firstIndexBefore(names.get(0), joiningTokenType); this.wrapParentIndex = this.tm.firstIndexBefore(names.get(0), TokenNameIdentifier); this.wrapIndexes.add(joiningTokenIndex); prepareElementsList(names, TokenNameCOMMA, -1); handleWrap(this.options.alignment_for_module_statements, PREFERRED); }
private void handleModuleStatement(List<Name> names, int joiningTokenType) { if (names.isEmpty()) return; int joiningTokenIndex = this.tm.firstIndexBefore(names.get(0), joiningTokenType); this.wrapParentIndex = this.tm.firstIndexBefore(names.get(0), TokenNameIdentifier); this.wrapIndexes.add(joiningTokenIndex); prepareElementsList(names, TokenNameCOMMA, -1); handleWrap(this.options.alignment_for_module_statements, PREFERRED); }
private void handleOperator(String operator, ASTNode nodeAfter, boolean spaceBefore, boolean spaceAfter) { if (spaceBefore || spaceAfter) { int i = this.tm.firstIndexBefore(nodeAfter, -1); while (!operator.equals(this.tm.toString(i))) { i--; } handleToken(this.tm.get(i), spaceBefore, spaceAfter); } }
@Override public boolean visit(SuperConstructorInvocation node) { int lParen = node.arguments().isEmpty() ? this.tm.lastIndexIn(node, TokenNameLPAREN) : this.tm.firstIndexBefore((ASTNode) node.arguments().get(0), TokenNameLPAREN); int rParen = this.tm.lastIndexIn(node, TokenNameRPAREN); handleParenthesesPositions(lParen, rParen, this.options.parenthesis_positions_in_method_invocation); return true; }
@Override public boolean visit(ConstructorInvocation node) { int lParen = node.arguments().isEmpty() ? this.tm.lastIndexIn(node, TokenNameLPAREN) : this.tm.firstIndexBefore((ASTNode) node.arguments().get(0), TokenNameLPAREN); int rParen = this.tm.lastIndexIn(node, TokenNameRPAREN); handleParenthesesPositions(lParen, rParen, this.options.parenthesis_positions_in_method_invocation); return true; }
@Override public boolean visit(ConstructorInvocation node) { int lParen = node.arguments().isEmpty() ? this.tm.lastIndexIn(node, TokenNameLPAREN) : this.tm.firstIndexBefore((ASTNode) node.arguments().get(0), TokenNameLPAREN); int rParen = this.tm.lastIndexIn(node, TokenNameRPAREN); handleParenthesesPositions(lParen, rParen, this.options.parenthesis_positions_in_method_invocation); return true; }
@Override public boolean visit(CatchClause node) { if (this.options.insert_new_line_before_catch_in_try_statement) breakLineBefore(node); int lParen = this.tm.firstIndexIn(node, TokenNameLPAREN); int rParen = this.tm.firstIndexBefore(node.getBody(), TokenNameRPAREN); handleParenthesesPositions(lParen, rParen, this.options.parenthesis_positions_in_catch_clause); return true; }
@Override public boolean visit(LambdaExpression node) { int lParen = this.tm.firstIndexIn(node, -1); if (this.tm.get(lParen).tokenType == TokenNameLPAREN) { int rParen = this.tm.firstIndexBefore(node.getBody(), TokenNameRPAREN); handleParenthesesPositions(lParen, rParen, this.options.parenthesis_positions_in_lambda_declaration); } return true; }
@Override public boolean visit(LambdaExpression node) { int lParen = this.tm.firstIndexIn(node, -1); if (this.tm.get(lParen).tokenType == TokenNameLPAREN) { int rParen = this.tm.firstIndexBefore(node.getBody(), TokenNameRPAREN); handleParenthesesPositions(lParen, rParen, this.options.parenthesis_positions_in_lambda_declaration); } 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(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(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(ClassInstanceCreation node) { int lParen = this.tm.firstIndexAfter(node.getType(), TokenNameLPAREN); int rParen = node.getAnonymousClassDeclaration() == null ? this.tm.lastIndexIn(node, TokenNameRPAREN) : this.tm.firstIndexBefore(node.getAnonymousClassDeclaration(), TokenNameRPAREN); handleParenthesesPositions(lParen, rParen, this.options.parenthesis_positions_in_method_invocation); return true; }
@Override public boolean visit(ClassInstanceCreation node) { int lParen = this.tm.firstIndexAfter(node.getType(), TokenNameLPAREN); int rParen = node.getAnonymousClassDeclaration() == null ? this.tm.lastIndexIn(node, TokenNameRPAREN) : this.tm.firstIndexBefore(node.getAnonymousClassDeclaration(), TokenNameRPAREN); handleParenthesesPositions(lParen, rParen, this.options.parenthesis_positions_in_method_invocation); return true; }
@Override public boolean visit(ClassInstanceCreation node) { int lParen = this.tm.firstIndexAfter(node.getType(), TokenNameLPAREN); int rParen = node.getAnonymousClassDeclaration() == null ? this.tm.lastIndexIn(node, TokenNameRPAREN) : this.tm.firstIndexBefore(node.getAnonymousClassDeclaration(), TokenNameRPAREN); handleParenthesesPositions(lParen, rParen, this.options.parenthesis_positions_in_method_invocation); return true; }
@Override public boolean visit(EnumConstantDeclaration node) { this.declarationModifierVisited = false; int lParen = this.tm.firstIndexAfter(node.getName(), -1); while (this.tm.get(lParen).isComment()) lParen++; if (this.tm.get(lParen).tokenType == TokenNameLPAREN) { int rParen = node.getAnonymousClassDeclaration() == null ? this.tm.lastIndexIn(node, TokenNameRPAREN) : this.tm.firstIndexBefore(node.getAnonymousClassDeclaration(), TokenNameRPAREN); handleParenthesesPositions(lParen, rParen, this.options.parenthesis_positions_in_enum_constant_declaration); } return true; }