@Override public boolean visit(CompilationUnit node) { List<ImportDeclaration> imports = node.imports(); if (!imports.isEmpty()) { this.importsStart = this.tm.firstIndexIn(imports.get(0), -1); this.importsEnd = this.tm.lastIndexIn(imports.get(imports.size() - 1), -1); } return true; }
@Override public boolean visit(CompilationUnit node) { List<ImportDeclaration> imports = node.imports(); if (!imports.isEmpty()) { this.importsStart = this.tm.firstIndexIn(imports.get(0), -1); this.importsEnd = this.tm.lastIndexIn(imports.get(imports.size() - 1), -1); } return true; }
@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(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(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; }
public int getIdentifierIndex(TokenManager tm) { if (this.accessExpression instanceof FieldAccess) return tm.firstIndexIn(((FieldAccess) this.accessExpression).getName(), TokenNameIdentifier); if (this.accessExpression instanceof QualifiedName) return tm.firstIndexIn(((QualifiedName) this.accessExpression).getName(), TokenNameIdentifier); if (this.accessExpression instanceof ThisExpression) return tm.lastIndexIn(this.accessExpression, TokenNamethis); if (this.accessExpression instanceof SuperFieldAccess) return tm.lastIndexIn(this.accessExpression, TokenNamesuper); throw new AssertionError(); } }
public int getIdentifierIndex(TokenManager tm) { if (this.accessExpression instanceof FieldAccess) return tm.firstIndexIn(((FieldAccess) this.accessExpression).getName(), TokenNameIdentifier); if (this.accessExpression instanceof QualifiedName) return tm.firstIndexIn(((QualifiedName) this.accessExpression).getName(), TokenNameIdentifier); if (this.accessExpression instanceof ThisExpression) return tm.lastIndexIn(this.accessExpression, TokenNamethis); if (this.accessExpression instanceof SuperFieldAccess) return tm.lastIndexIn(this.accessExpression, TokenNamesuper); throw new AssertionError(); } }
@Override public boolean visit(MethodInvocation node) { int lParen = this.tm.firstIndexAfter(node.getName(), TokenNameLPAREN); int rParen = this.tm.lastIndexIn(node, TokenNameRPAREN); handleParenthesesPositions(lParen, rParen, this.options.parenthesis_positions_in_method_invocation); return true; }
@Override public boolean visit(SuperMethodInvocation node) { int lParen = this.tm.firstIndexAfter(node.getName(), TokenNameLPAREN); int rParen = this.tm.lastIndexIn(node, TokenNameRPAREN); handleParenthesesPositions(lParen, rParen, this.options.parenthesis_positions_in_method_invocation); return true; }
@Override public boolean visit(SuperMethodInvocation node) { int lParen = this.tm.firstIndexAfter(node.getName(), TokenNameLPAREN); int rParen = this.tm.lastIndexIn(node, TokenNameRPAREN); handleParenthesesPositions(lParen, rParen, this.options.parenthesis_positions_in_method_invocation); return true; }
@Override public boolean visit(SuperMethodInvocation node) { int lParen = this.tm.firstIndexAfter(node.getName(), TokenNameLPAREN); int rParen = this.tm.lastIndexIn(node, TokenNameRPAREN); handleParenthesesPositions(lParen, rParen, this.options.parenthesis_positions_in_method_invocation); return true; }
@Override public boolean visit(MethodInvocation node) { int lParen = this.tm.firstIndexAfter(node.getName(), TokenNameLPAREN); int rParen = this.tm.lastIndexIn(node, TokenNameRPAREN); handleParenthesesPositions(lParen, rParen, this.options.parenthesis_positions_in_method_invocation); return true; }
private void handleLoopBody(Statement body) { if (body instanceof Block) return; if (body instanceof EmptyStatement && !this.options.put_empty_statement_on_new_line && !(body.getParent() instanceof IfStatement)) return; breakLineBefore(body); adjustEmptyLineAfter(this.tm.lastIndexIn(body, -1), -1); indent(body); }
private void handleLoopBody(Statement body) { if (body instanceof Block) return; if (body instanceof EmptyStatement && !this.options.put_empty_statement_on_new_line && !(body.getParent() instanceof IfStatement)) return; breakLineBefore(body); adjustEmptyLineAfter(this.tm.lastIndexIn(body, -1), -1); indent(body); }
@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; }
private void indent(ASTNode node) { int startIndex = this.tm.firstIndexIn(node, -1); while (startIndex > 0 && this.tm.get(startIndex - 1).isComment()) startIndex--; this.tm.get(startIndex).indent(); int lastIndex = this.tm.lastIndexIn(node, -1); if (lastIndex + 1 < this.tm.size()) this.tm.get(lastIndex + 1).unindent(); }
private void indent(ASTNode node) { int startIndex = this.tm.firstIndexIn(node, -1); while (startIndex > 0 && this.tm.get(startIndex - 1).isComment()) startIndex--; this.tm.get(startIndex).indent(); int lastIndex = this.tm.lastIndexIn(node, -1); if (lastIndex + 1 < this.tm.size()) this.tm.get(lastIndex + 1).unindent(); }