private void handleToken(Token token, boolean spaceBefore, boolean spaceAfter) { if (spaceBefore) token.spaceBefore(); if (spaceAfter) token.spaceAfter(); }
private void handleToken(Token token, boolean spaceBefore, boolean spaceAfter) { if (spaceBefore) token.spaceBefore(); if (spaceAfter) token.spaceAfter(); }
private void handleToken(Token token, boolean spaceBefore, boolean spaceAfter) { if (spaceBefore) token.spaceBefore(); if (spaceAfter) token.spaceAfter(); }
@Override public boolean visit(ThrowStatement node) { int returnTokenIndex = this.tm.firstIndexIn(node, TokenNamethrow); if (this.tm.get(returnTokenIndex + 1).tokenType != TokenNameLPAREN || this.options.insert_space_before_parenthesized_expression_in_throw) { this.tm.get(returnTokenIndex).spaceAfter(); } return true; }
private boolean handleEmptyBrackets(ASTNode nodeContainingBrackets, boolean insertSpace) { int openingIndex = this.tm.firstIndexIn(nodeContainingBrackets, TokenNameLBRACKET); if (this.tm.get(openingIndex + 1).tokenType == TokenNameRBRACKET) { if (insertSpace) this.tm.get(openingIndex).spaceAfter(); return true; } return false; }
private boolean handleEmptyBrackets(ASTNode nodeContainingBrackets, boolean insertSpace) { int openingIndex = this.tm.firstIndexIn(nodeContainingBrackets, TokenNameLBRACKET); if (this.tm.get(openingIndex + 1).tokenType == TokenNameRBRACKET) { if (insertSpace) this.tm.get(openingIndex).spaceAfter(); return true; } return false; }
@Override public boolean visit(ThrowStatement node) { int returnTokenIndex = this.tm.firstIndexIn(node, TokenNamethrow); if (this.tm.get(returnTokenIndex + 1).tokenType != TokenNameLPAREN || this.options.insert_space_before_parenthesized_expression_in_throw) { this.tm.get(returnTokenIndex).spaceAfter(); } return true; }
private boolean handleEmptyBrackets(ASTNode nodeContainingBrackets, boolean insertSpace) { int openingIndex = this.tm.firstIndexIn(nodeContainingBrackets, TokenNameLBRACKET); if (this.tm.get(openingIndex + 1).tokenType == TokenNameRBRACKET) { if (insertSpace) this.tm.get(openingIndex).spaceAfter(); return true; } return false; }
@Override public boolean visit(ThrowStatement node) { int returnTokenIndex = this.tm.firstIndexIn(node, TokenNamethrow); if (this.tm.get(returnTokenIndex + 1).tokenType != TokenNameLPAREN || this.options.insert_space_before_parenthesized_expression_in_throw) { this.tm.get(returnTokenIndex).spaceAfter(); } return true; }
@Override public boolean visit(ReturnStatement node) { if (node.getExpression() != null) { int returnTokenIndex = this.tm.firstIndexIn(node, TokenNamereturn); if (!(node.getExpression() instanceof ParenthesizedExpression) || this.options.insert_space_before_parenthesized_expression_in_return) { this.tm.get(returnTokenIndex).spaceAfter(); } } return true; }
@Override public boolean visit(ReturnStatement node) { if (node.getExpression() != null) { int returnTokenIndex = this.tm.firstIndexIn(node, TokenNamereturn); if (!(node.getExpression() instanceof ParenthesizedExpression) || this.options.insert_space_before_parenthesized_expression_in_return) { this.tm.get(returnTokenIndex).spaceAfter(); } } return true; }
private boolean handleEmptyParens(ASTNode nodeBeforeParens, boolean insertSpace) { int openingIndex = this.tm.findIndex(nodeBeforeParens.getStartPosition(), TokenNameLPAREN, true); if (this.tm.get(openingIndex + 1).tokenType == TokenNameRPAREN) { if (insertSpace) this.tm.get(openingIndex).spaceAfter(); return true; } return false; }
@Override public boolean visit(AssertStatement node) { this.tm.firstTokenIn(node, TokenNameassert).spaceAfter(); if (node.getMessage() != null) { handleTokenBefore(node.getMessage(), TokenNameCOLON, this.options.insert_space_before_colon_in_assert, this.options.insert_space_after_colon_in_assert); } return true; }
@Override public boolean visit(AssertStatement node) { this.tm.firstTokenIn(node, TokenNameassert).spaceAfter(); if (node.getMessage() != null) { handleTokenBefore(node.getMessage(), TokenNameCOLON, this.options.insert_space_before_colon_in_assert, this.options.insert_space_after_colon_in_assert); } return true; }
private boolean handleEmptyParens(ASTNode nodeBeforeParens, boolean insertSpace) { int openingIndex = this.tm.findIndex(nodeBeforeParens.getStartPosition(), TokenNameLPAREN, true); if (this.tm.get(openingIndex + 1).tokenType == TokenNameRPAREN) { if (insertSpace) this.tm.get(openingIndex).spaceAfter(); return true; } return false; }
@Override public boolean visit(AssertStatement node) { this.tm.firstTokenIn(node, TokenNameassert).spaceAfter(); if (node.getMessage() != null) { handleTokenBefore(node.getMessage(), TokenNameCOLON, this.options.insert_space_before_colon_in_assert, this.options.insert_space_after_colon_in_assert); } return true; }
@Override public boolean visit(ReturnStatement node) { if (node.getExpression() != null) { int returnTokenIndex = this.tm.firstIndexIn(node, TokenNamereturn); if (!(node.getExpression() instanceof ParenthesizedExpression) || this.options.insert_space_before_parenthesized_expression_in_return) { this.tm.get(returnTokenIndex).spaceAfter(); } } return true; }
private boolean handleEmptyParens(ASTNode nodeBeforeParens, boolean insertSpace) { int openingIndex = this.tm.findIndex(nodeBeforeParens.getStartPosition(), TokenNameLPAREN, true); if (this.tm.get(openingIndex + 1).tokenType == TokenNameRPAREN) { if (insertSpace) this.tm.get(openingIndex).spaceAfter(); return true; } return false; }
@Override public boolean visit(Block node) { handleSemicolon(node.statements()); ASTNode parent = node.getParent(); if (parent.getLength() == 0) return true; // this is a fake block created by parsing in statements mode if (parent instanceof MethodDeclaration) return true; // spaces handled in #visit(MethodDeclaration) handleToken(node, TokenNameLBRACE, this.options.insert_space_before_opening_brace_in_block, false); if (this.options.insert_space_after_closing_brace_in_block && (parent instanceof Statement || parent instanceof CatchClause)) { int closeBraceIndex = this.tm.lastIndexIn(node, TokenNameRBRACE); this.tm.get(closeBraceIndex).spaceAfter(); } return true; }
private void splitToken(Token token, int tokenIndex, int splitPosition) { assert splitPosition > token.originalStart && splitPosition <= token.originalEnd; Token part1 = new Token(token.originalStart, splitPosition - 1, token.tokenType); Token part2 = new Token(splitPosition, token.originalEnd, token.tokenType); if (token.isSpaceBefore()) part1.spaceBefore(); part1.putLineBreaksBefore(token.getLineBreaksBefore()); if (token.isSpaceAfter()) part2.spaceAfter(); part2.putLineBreaksAfter(token.getLineBreaksAfter()); part1.setIndent(token.getIndent()); part2.setIndent(token.getIndent()); part1.setWrapPolicy(token.getWrapPolicy()); this.commentStructure.set(tokenIndex, part1); this.commentStructure.add(tokenIndex + 1, part2); }