/** * Gets token text with characters escaped as HTML entities where necessary. * @param tokenIndex index of the token to get. */ public String toString(int tokenIndex) { return toString(get(tokenIndex)); }
/** * Gets token text with characters escaped as HTML entities where necessary. * @param tokenIndex index of the token to get. */ public String toString(int tokenIndex) { return toString(get(tokenIndex)); }
/** * Gets token text with characters escaped as HTML entities where necessary. * @param tokenIndex index of the token to get. */ public String toString(int tokenIndex) { return toString(get(tokenIndex)); }
/** * @return true if the comment contains on/off tag and should not be formatted */ private boolean handleFormatOnOffTags(Token commentToken) { if (!this.options.use_tags) return false; String commentString = this.tm.toString(commentToken); int offIndex = this.formatDisableTag != null ? commentString.lastIndexOf(this.formatDisableTag) : -1; int onIndex = this.formatEnableTag != null ? commentString.lastIndexOf(this.formatEnableTag) : -1; if (this.lastFormatOffComment == null) { if (offIndex > onIndex) this.lastFormatOffComment = commentToken; } else { if (onIndex > offIndex) { this.tm.addDisableFormatTokenPair(this.lastFormatOffComment, commentToken); this.lastFormatOffComment = null; } } return offIndex >= 0 || onIndex >= 0; }
/** * @return true if the comment contains on/off tag and should not be formatted */ private boolean handleFormatOnOffTags(Token commentToken) { if (!this.options.use_tags) return false; String commentString = this.tm.toString(commentToken); int offIndex = this.formatDisableTag != null ? commentString.lastIndexOf(this.formatDisableTag) : -1; int onIndex = this.formatEnableTag != null ? commentString.lastIndexOf(this.formatEnableTag) : -1; if (this.lastFormatOffComment == null) { if (offIndex > onIndex) this.lastFormatOffComment = commentToken; } else { if (onIndex > offIndex) { this.tm.addDisableFormatTokenPair(this.lastFormatOffComment, commentToken); this.lastFormatOffComment = null; } } return offIndex >= 0 || onIndex >= 0; }
/** * @return true if the comment contains on/off tag and should not be formatted */ private boolean handleFormatOnOffTags(Token commentToken) { if (!this.options.use_tags) return false; String commentString = this.tm.toString(commentToken); int offIndex = this.formatDisableTag != null ? commentString.lastIndexOf(this.formatDisableTag) : -1; int onIndex = this.formatEnableTag != null ? commentString.lastIndexOf(this.formatEnableTag) : -1; if (this.lastFormatOffComment == null) { if (offIndex > onIndex) this.lastFormatOffComment = commentToken; } else { if (onIndex > offIndex) { this.tm.addDisableFormatTokenPair(this.lastFormatOffComment, commentToken); this.lastFormatOffComment = null; } } return offIndex >= 0 || onIndex >= 0; }
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); } }
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 void endVisit(TagElement node) { String tagName = node.getTagName(); if (tagName == null || tagName.length() <= 1) handleHtml(node); if (TagElement.TAG_SEE.equals(tagName)) handleStringLiterals(this.tm.toString(node), node.getStartPosition()); }
@Override public void endVisit(TagElement node) { String tagName = node.getTagName(); if (tagName == null || tagName.length() <= 1) handleHtml(node); if (TagElement.TAG_SEE.equals(tagName)) handleStringLiterals(this.tm.toString(node), node.getStartPosition()); }
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); } }
private void handleCompilerTags(Token commentToken, int commentIndex) { final String commentText = this.tm.toString(commentToken); final List<Token> structure = commentToken.getInternalStructure(); if (commentText.startsWith("//$FALL-THROUGH$") //$NON-NLS-1$ || commentText.startsWith("//$IDENTITY-COMPARISON$")) { //$NON-NLS-1$ structure.get(1).clearSpaceBefore(); } if (commentText.contains("//$IDENTITY-COMPARISON$")) { //$NON-NLS-1$ // make sure the whole line is not broken Token token = commentToken; for (int i = commentIndex; i > 0; i--) { Token left = this.tm.get(i - 1); if (this.tm.countLineBreaksBetween(left, token) > 0) break; token.clearLineBreaksBefore(); left.clearLineBreaksAfter(); token.setWrapPolicy(WrapPolicy.DISABLE_WRAP); token = left; } } }
private void handleCompilerTags(Token commentToken, int commentIndex) { final String commentText = this.tm.toString(commentToken); final List<Token> structure = commentToken.getInternalStructure(); if (commentText.startsWith("//$FALL-THROUGH$") //$NON-NLS-1$ || commentText.startsWith("//$IDENTITY-COMPARISON$")) { //$NON-NLS-1$ structure.get(1).clearSpaceBefore(); } if (commentText.contains("//$IDENTITY-COMPARISON$")) { //$NON-NLS-1$ // make sure the whole line is not broken Token token = commentToken; for (int i = commentIndex; i > 0; i--) { Token left = this.tm.get(i - 1); if (this.tm.countLineBreaksBetween(left, token) > 0) break; token.clearLineBreaksBefore(); left.clearLineBreaksAfter(); token.setWrapPolicy(WrapPolicy.DISABLE_WRAP); token = left; } } }
private void handleCompilerTags(Token commentToken, int commentIndex) { final String commentText = this.tm.toString(commentToken); final List<Token> structure = commentToken.getInternalStructure(); if (commentText.startsWith("//$FALL-THROUGH$") //$NON-NLS-1$ || commentText.startsWith("//$IDENTITY-COMPARISON$")) { //$NON-NLS-1$ structure.get(1).clearSpaceBefore(); } if (commentText.contains("//$IDENTITY-COMPARISON$")) { //$NON-NLS-1$ // make sure the whole line is not broken Token token = commentToken; for (int i = commentIndex; i > 0; i--) { Token left = this.tm.get(i - 1); if (this.tm.countLineBreaksBetween(left, token) > 0) break; token.clearLineBreaksBefore(); left.clearLineBreaksAfter(); token.setWrapPolicy(WrapPolicy.DISABLE_WRAP); token = left; } } }
@Override public boolean visit(PostfixExpression node) { if (this.options.insert_space_before_postfix_operator || this.options.insert_space_after_postfix_operator) { String operator = node.getOperator().toString(); int i = this.tm.firstIndexAfter(node.getOperand(), -1); while (!operator.equals(this.tm.toString(i))) { i++; } handleToken(this.tm.get(i), this.options.insert_space_before_postfix_operator, this.options.insert_space_after_postfix_operator); } return true; }
@Override public boolean visit(PostfixExpression node) { if (this.options.insert_space_before_postfix_operator || this.options.insert_space_after_postfix_operator) { String operator = node.getOperator().toString(); int i = this.tm.firstIndexAfter(node.getOperand(), -1); while (!operator.equals(this.tm.toString(i))) { i++; } handleToken(this.tm.get(i), this.options.insert_space_before_postfix_operator, this.options.insert_space_after_postfix_operator); } return true; }
@Override public boolean visit(PostfixExpression node) { if (this.options.insert_space_before_postfix_operator || this.options.insert_space_after_postfix_operator) { String operator = node.getOperator().toString(); int i = this.tm.firstIndexAfter(node.getOperand(), -1); while (!operator.equals(this.tm.toString(i))) { i++; } handleToken(this.tm.get(i), this.options.insert_space_before_postfix_operator, this.options.insert_space_after_postfix_operator); } return true; }
@Override public boolean visit(Assignment node) { int rightSideIndex = this.tm.firstIndexIn(node.getRightHandSide(), -1); if (this.tm.get(rightSideIndex).getLineBreaksBefore() > 0) return true; // must be an array initializer in new line because of brace_position_for_array_initializer int operatorIndex = this.tm.firstIndexBefore(node.getRightHandSide(), -1); while (this.tm.get(operatorIndex).isComment()) operatorIndex--; assert node.getOperator().toString().equals(this.tm.toString(operatorIndex)); this.wrapIndexes.add(this.options.wrap_before_assignment_operator ? operatorIndex : rightSideIndex); this.secondaryWrapIndexes.add(this.options.wrap_before_assignment_operator ? rightSideIndex : operatorIndex); this.wrapParentIndex = operatorIndex - 1; this.wrapGroupEnd = this.tm.lastIndexIn(node.getRightHandSide(), -1); handleWrap(this.options.alignment_for_assignment); return true; }
@Override public boolean visit(Assignment node) { int rightSideIndex = this.tm.firstIndexIn(node.getRightHandSide(), -1); if (this.tm.get(rightSideIndex).getLineBreaksBefore() > 0) return true; // must be an array initializer in new line because of brace_position_for_array_initializer int operatorIndex = this.tm.firstIndexBefore(node.getRightHandSide(), -1); while (this.tm.get(operatorIndex).isComment()) operatorIndex--; assert node.getOperator().toString().equals(this.tm.toString(operatorIndex)); this.wrapIndexes.add(this.options.wrap_before_assignment_operator ? operatorIndex : rightSideIndex); this.secondaryWrapIndexes.add(this.options.wrap_before_assignment_operator ? rightSideIndex : operatorIndex); this.wrapParentIndex = operatorIndex - 1; this.wrapGroupEnd = this.tm.lastIndexIn(node.getRightHandSide(), -1); handleWrap(this.options.alignment_for_assignment); return true; }
@Override public boolean visit(Assignment node) { int rightSideIndex = this.tm.firstIndexIn(node.getRightHandSide(), -1); if (this.tm.get(rightSideIndex).getLineBreaksBefore() > 0) return true; // must be an array initializer in new line because of brace_position_for_array_initializer int operatorIndex = this.tm.firstIndexBefore(node.getRightHandSide(), -1); while (this.tm.get(operatorIndex).isComment()) operatorIndex--; assert node.getOperator().toString().equals(this.tm.toString(operatorIndex)); this.wrapIndexes.add(this.options.wrap_before_assignment_operator ? operatorIndex : rightSideIndex); this.secondaryWrapIndexes.add(this.options.wrap_before_assignment_operator ? rightSideIndex : operatorIndex); this.wrapParentIndex = operatorIndex - 1; this.wrapGroupEnd = this.tm.lastIndexIn(node.getRightHandSide(), -1); handleWrap(this.options.alignment_for_assignment); return true; }