private int normalizedAlign(int desiredAlign) { if (this.options.align_with_spaces) return desiredAlign; return this.tm.toIndent(desiredAlign, false); } }
/** * @return index of the last token in line */ public int analyzeLine(int startIndex, int indent) { Token startToken = WrapExecutor.this.tm.get(startIndex); this.counter = WrapExecutor.this.tm.toIndent(indent, startToken.isWrappable()); this.lineIndent = indent; this.firstPotentialWrap = -1; this.extraLines = 0; this.extraLinesPerComment.clear(); this.topPriorityGroupStarts.clear(); this.currentTopPriorityGroupEnd = -1; this.isNLSTagInLine = false; return WrapExecutor.this.tm.traverse(startIndex, this); }
/** * @return index of the last token in line */ public int analyzeLine(int startIndex, int indent) { Token startToken = WrapExecutor.this.tm.get(startIndex); assert startToken.getLineBreaksBefore() > 0; this.counter = WrapExecutor.this.tm.toIndent(indent, startToken.isWrappable()); this.lineIndent = indent; this.firstPotentialWrap = -1; this.activeTopPriorityWrap = -1; this.minStructureDepth = Integer.MAX_VALUE; this.extraLines = 0; this.isNextLineWrapped = false; this.extraLinesPerComment.clear(); this.topPriorityGroupStarts.clear(); this.currentTopPriorityGroupEnd = -1; this.isNLSTagInLine = false; int lastIndex = WrapExecutor.this.tm.traverse(startIndex, this); return lastIndex + (this.isNextLineWrapped ? 1 : 0); }
/** * @return index of the last token in line */ public int analyzeLine(int startIndex, int indent) { Token startToken = WrapExecutor.this.tm.get(startIndex); assert startToken.getLineBreaksBefore() > 0; this.counter = WrapExecutor.this.tm.toIndent(indent, startToken.isWrappable()); this.lineIndent = indent; this.firstPotentialWrap = -1; this.activeTopPriorityWrap = -1; this.minStructureDepth = Integer.MAX_VALUE; this.extraLines = 0; this.isNextLineWrapped = false; this.extraLinesPerComment.clear(); this.topPriorityGroupStarts.clear(); this.currentTopPriorityGroupEnd = -1; this.isNLSTagInLine = false; int lastIndex = WrapExecutor.this.tm.traverse(startIndex, this); return lastIndex + (this.isNextLineWrapped ? 1 : 0); }
if (getLineBreaksBefore() > 0) { if (this.parent == null) currentPositionInLine = this.tm.toIndent(token.getIndent(), token.getWrapPolicy() != null); } else { currentPositionInLine = this.tm.getPositionInLine(index - 1);
public int getPositionInLine(int tokenIndex) { Token token = get(tokenIndex); // find the first token in line and calculate position of given token int firstTokenIndex = token.getLineBreaksBefore() > 0 ? tokenIndex : findFirstTokenInLine(tokenIndex); Token firstToken = get(firstTokenIndex); int startingPosition = toIndent(firstToken.getIndent(), firstToken.getWrapPolicy() != null); this.positionInLineCounter.value = tokenIndex; this.positionInLineCounter.counter = startingPosition; traverse(firstTokenIndex, this.positionInLineCounter); return Math.max(this.positionInLineCounter.counter, token.getAlign()); }
return startPosition + this.tm.getLength(commentToken, startPosition); commentToken.setIndent(this.tm.toIndent(startPosition, true)); this.lineStartPosition = commentToken.getIndent(); this.simulation = simulate;
this.lineCounter = 1; this.counter = startPosition; commentToken.setIndent(this.tm.toIndent(startPosition, true)); this.lineStartPosition = commentToken.getIndent(); this.lineLimit = getLineLimit(startPosition);
this.lineCounter = 1; this.counter = startPosition; commentToken.setIndent(this.tm.toIndent(startPosition, true)); this.lineStartPosition = commentToken.getIndent(); this.lineLimit = getLineLimit(startPosition);
public int getPositionInLine(int tokenIndex) { Token token = get(tokenIndex); if (token.getAlign() > 0) return get(tokenIndex).getAlign(); // find the first token in line and calculate position of given token int firstTokenIndex = token.getLineBreaksBefore() > 0 ? tokenIndex : findFirstTokenInLine(tokenIndex); Token firstToken = get(firstTokenIndex); int startingPosition = toIndent(firstToken.getIndent(), firstToken.getWrapPolicy() != null); if (firstTokenIndex == tokenIndex) return startingPosition; this.positionInLineCounter.value = tokenIndex; this.positionInLineCounter.counter = startingPosition; traverse(firstTokenIndex, this.positionInLineCounter); return this.positionInLineCounter.counter; }
int getWrapIndent(Token token) { WrapPolicy policy = token.getWrapPolicy(); if (policy == null) return token.getIndent(); if (policy == WrapPolicy.FORCE_FIRST_COLUMN) return 0; Token wrapParent = this.tm.get(policy.wrapParentIndex); int wrapIndent = wrapParent.getIndent(); if (policy.indentOnColumn) { wrapIndent = this.tm.getPositionInLine(policy.wrapParentIndex); wrapIndent += this.tm.getLength(wrapParent, wrapIndent); if (wrapParent.isSpaceAfter() || this.tm.get(policy.wrapParentIndex + 1).isSpaceBefore()) wrapIndent++; } wrapIndent += policy.extraIndent; return this.tm.toIndent(wrapIndent, true); } }
public int getPositionInLine(int tokenIndex) { Token token = get(tokenIndex); if (token.getAlign() > 0) return get(tokenIndex).getAlign(); // find the first token in line and calculate position of given token int firstTokenIndex = token.getLineBreaksBefore() > 0 ? tokenIndex : findFirstTokenInLine(tokenIndex); Token firstToken = get(firstTokenIndex); int startingPosition = toIndent(firstToken.getIndent(), firstToken.getWrapPolicy() != null); if (firstTokenIndex == tokenIndex) return startingPosition; this.positionInLineCounter.value = tokenIndex; this.positionInLineCounter.counter = startingPosition; traverse(firstTokenIndex, this.positionInLineCounter); return this.positionInLineCounter.counter; }
positionCounter.findMaxPosition(firstIndexInLine, lastIndex)); maxCommentAlign = this.tm.toIndent(maxCommentAlign, false);
int getWrapIndent(Token token) { WrapPolicy policy = token.getWrapPolicy(); if (policy == null) return token.getIndent(); if (policy == WrapPolicy.FORCE_FIRST_COLUMN) return 0; Token wrapParent = this.tm.get(policy.wrapParentIndex); int wrapIndent = wrapParent.getIndent(); if (policy.indentOnColumn) { wrapIndent = this.tm.getPositionInLine(policy.wrapParentIndex); wrapIndent += this.tm.getLength(wrapParent, wrapIndent); Token next = this.tm.get(policy.wrapParentIndex + 1); if (wrapParent.isSpaceAfter() || (next.isSpaceBefore() && !next.isComment())) wrapIndent++; } wrapIndent += policy.extraIndent; return this.tm.toIndent(wrapIndent, true); } }
positionCounter.findMaxPosition(firstIndexInLine, lastIndex)); maxCommentAlign = this.tm.toIndent(maxCommentAlign, false);
int getWrapIndent(Token token) { WrapPolicy policy = token.getWrapPolicy(); if (policy == null) return token.getIndent(); if (this.options.never_indent_line_comments_on_first_column && token.tokenType == TokenNameCOMMENT_LINE && token.getIndent() == 0) return 0; if (this.options.never_indent_block_comments_on_first_column && token.tokenType == TokenNameCOMMENT_BLOCK && token.getIndent() == 0) return 0; Token wrapParent = this.tm.get(policy.wrapParentIndex); int wrapIndent = wrapParent.getIndent(); if (policy.indentOnColumn) { wrapIndent = this.tm.getPositionInLine(policy.wrapParentIndex); wrapIndent += this.tm.getLength(wrapParent, wrapIndent); if (wrapParent.isSpaceAfter() || this.tm.get(policy.wrapParentIndex + 1).isSpaceBefore()) wrapIndent++; } wrapIndent += policy.extraIndent; return this.tm.toIndent(wrapIndent, true); } }
@Override public boolean visit(Javadoc node) { this.noFormatTagOpenStart = -1; this.formatCodeTagOpenEnd = -1; this.lastFormatCodeClosingTagIndex = -1; this.firstTagToken = null; this.ctm = null; int commentIndex = this.tm.firstIndexIn(node, TokenNameCOMMENT_JAVADOC); Token commentToken = this.tm.get(commentIndex); if (node.getParent() == null) { // not a proper javadoc, treat as block comment handleWhitespaceAround(commentIndex); } if (commentIndex < this.tm.size() - 1) commentToken.breakAfter(); if (handleFormatOnOffTags(commentToken)) return false; boolean isHeader = this.tm.isInHeader(commentIndex); boolean formattingEnabled = (this.options.comment_format_javadoc_comment && !isHeader) || (this.options.comment_format_header && isHeader); if (!formattingEnabled || !tokenizeMultilineComment(commentToken)) { commentToken.setInternalStructure(commentToLines(commentToken, -1)); return false; } this.commentStructure = commentToken.getInternalStructure(); this.commentIndent = this.tm.toIndent(commentToken.getIndent(), true); this.ctm = new TokenManager(commentToken.getInternalStructure(), this.tm); return true; }
@Override public boolean visit(Javadoc node) { this.noFormatTagOpenStart = -1; this.formatCodeTagOpenEnd = -1; this.lastFormatCodeClosingTagIndex = -1; this.firstTagToken = null; this.ctm = null; int commentIndex = this.tm.firstIndexIn(node, TokenNameCOMMENT_JAVADOC); Token commentToken = this.tm.get(commentIndex); if (node.getParent() == null) { // not a proper javadoc, treat as block comment handleWhitespaceAround(commentIndex); } if (commentIndex < this.tm.size() - 1) commentToken.breakAfter(); if (handleFormatOnOffTags(commentToken)) return false; boolean isHeader = this.tm.isInHeader(commentIndex); boolean formattingEnabled = (this.options.comment_format_javadoc_comment && !isHeader) || (this.options.comment_format_header && isHeader); if (!formattingEnabled || !tokenizeMultilineComment(commentToken)) { commentToken.setInternalStructure(commentToLines(commentToken, -1)); return false; } this.commentStructure = commentToken.getInternalStructure(); this.commentIndent = this.tm.toIndent(commentToken.getIndent(), true); this.ctm = new TokenManager(commentToken.getInternalStructure(), this.tm); return true; }
@Override public boolean visit(Javadoc node) { this.noFormatTagOpenStart = -1; this.formatCodeTagOpenEnd = -1; this.lastFormatCodeClosingTagIndex = -1; this.firstTagToken = null; this.ctm = null; int commentIndex = this.tm.firstIndexIn(node, TokenNameCOMMENT_JAVADOC); Token commentToken = this.tm.get(commentIndex); if (node.getParent() == null) { // not a proper javadoc, treat as block comment handleWhitespaceAround(commentIndex); } if (commentIndex < this.tm.size() - 1) commentToken.breakAfter(); if (handleFormatOnOffTags(commentToken)) return false; boolean isHeader = this.tm.isInHeader(commentIndex); boolean formattingEnabled = (this.options.comment_format_javadoc_comment && !isHeader) || (this.options.comment_format_header && isHeader); if (!formattingEnabled || !tokenizeMultilineComment(commentToken)) { commentToken.setInternalStructure(commentToLines(commentToken, -1)); return false; } this.commentStructure = commentToken.getInternalStructure(); this.commentIndent = this.tm.toIndent(commentToken.getIndent(), true); this.ctm = new TokenManager(commentToken.getInternalStructure(), this.tm); handleJavadocTagAlignment(node); return true; }