private void noSubstituteWrapping(int from, int to) { int commentStart = this.ctm.get(0).originalStart; assert commentStart <= from && from <= to && to <= this.ctm.get(this.ctm.size() - 1).originalEnd; Arrays.fill(this.allowSubstituteWrapping, from - commentStart, to - commentStart + 1, false); }
private void noSubstituteWrapping(int from, int to) { int commentStart = this.ctm.get(0).originalStart; assert commentStart <= from && from <= to && to <= this.ctm.get(this.ctm.size() - 1).originalEnd; Arrays.fill(this.allowSubstituteWrapping, from - commentStart, to - commentStart + 1, false); }
private void noSubstituteWrapping(int from, int to) { int commentStart = this.ctm.get(0).originalStart; assert commentStart <= from && from <= to && to <= this.ctm.get(this.ctm.size() - 1).originalEnd; Arrays.fill(this.allowSubstituteWrapping, from - commentStart, to - commentStart + 1, false); }
public void finishUp() { if (this.lastFormatOffComment != null) this.tm.addDisableFormatTokenPair(this.lastFormatOffComment, this.tm.get(this.tm.size() - 1)); } }
public void finishUp() { if (this.lastFormatOffComment != null) this.tm.addDisableFormatTokenPair(this.lastFormatOffComment, this.tm.get(this.tm.size() - 1)); } }
public void finishUp() { if (this.lastFormatOffComment != null) this.tm.addDisableFormatTokenPair(this.lastFormatOffComment, this.tm.get(this.tm.size() - 1)); } }
private void handleBracePosition(Token openBraceToken, int closeBraceIndex, String bracePosition) { if (bracePosition.equals(DefaultCodeFormatterConstants.NEXT_LINE)) { openBraceToken.breakBefore(); } else if (bracePosition.equals(DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED)) { openBraceToken.breakBefore(); openBraceToken.indent(); if (closeBraceIndex + 1 < this.tm.size()) this.tm.get(closeBraceIndex + 1).unindent(); } else if (bracePosition.equals(DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP)) { openBraceToken.setNextLineOnWrap(); } }
private void handleBracePosition(Token openBraceToken, int closeBraceIndex, String bracePosition) { if (bracePosition.equals(DefaultCodeFormatterConstants.NEXT_LINE)) { openBraceToken.breakBefore(); } else if (bracePosition.equals(DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED)) { openBraceToken.breakBefore(); openBraceToken.indent(); if (closeBraceIndex + 1 < this.tm.size()) this.tm.get(closeBraceIndex + 1).unindent(); } else if (bracePosition.equals(DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP)) { openBraceToken.setNextLineOnWrap(); } }
private void handleBracePosition(Token openBraceToken, int closeBraceIndex, String bracePosition) { if (bracePosition.equals(DefaultCodeFormatterConstants.NEXT_LINE)) { openBraceToken.breakBefore(); } else if (bracePosition.equals(DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED)) { openBraceToken.breakBefore(); openBraceToken.indent(); if (closeBraceIndex + 1 < this.tm.size()) this.tm.get(closeBraceIndex + 1).unindent(); } else if (bracePosition.equals(DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP)) { openBraceToken.setNextLineOnWrap(); } }
public void executeWraps() { int index = 0; while (index < this.tm.size()) { Token token = this.tm.get(index); while (true) { try { int currentIndent = getWrapIndent(token); this.wrapSearchResults.clear(); index = applyWraps(index, currentIndent); break; } catch (WrapRestartThrowable e) { handleTopPriorityWraps(e); } } this.wrapSearchResults.clear(); this.usedTopPriorityWraps.clear(); } this.tm.traverse(0, new NLSTagHandler()); }
private void adjustEmptyLineAfter(int tokenIndex, int indentationAdjustment) { if (tokenIndex + 1 >= this.tm.size()) return; Token token = this.tm.get(tokenIndex); Token next = this.tm.get(tokenIndex + 1); if (this.tm.countLineBreaksBetween(token, next) < 2 || !this.options.indent_empty_lines) return; next.setEmptyLineIndentAdjustment(indentationAdjustment * this.options.indentation_size); }
private void adjustEmptyLineAfter(int tokenIndex, int indentationAdjustment) { if (tokenIndex + 1 >= this.tm.size()) return; Token token = this.tm.get(tokenIndex); Token next = this.tm.get(tokenIndex + 1); if (this.tm.countLineBreaksBetween(token, next) < 2 || !this.options.indent_empty_lines) return; next.setEmptyLineIndentAdjustment(indentationAdjustment * this.options.indentation_size); }
private void adjustEmptyLineAfter(int tokenIndex, int indentationAdjustment) { if (tokenIndex + 1 >= this.tm.size()) return; Token token = this.tm.get(tokenIndex); Token next = this.tm.get(tokenIndex + 1); if (this.tm.countLineBreaksBetween(token, next) < 2 || !this.options.indent_empty_lines) return; next.setEmptyLineIndentAdjustment(indentationAdjustment * this.options.indentation_size); }
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(); }
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 cleanupHTMLElement(int openingTagIndex, int closingTagIndex, boolean formattedCode) { Token previous = this.ctm.get(openingTagIndex); int indent = previous.getIndent(); for (int i = openingTagIndex + 1; i < closingTagIndex; i++) { Token token = this.ctm.get(i); token.setToEscape(true); if (formattedCode && (token.getLineBreaksBefore() > 0 || previous.getLineBreaksAfter() > 0)) token.setAlign(indent); previous = token; } for (int i = closingTagIndex; i < this.ctm.size(); i++) { Token token = this.ctm.get(i); if (token.getIndent() == 0) break; token.setIndent(indent); previous = token; } }
private void cleanupHTMLElement(int openingTagIndex, int closingTagIndex, boolean formattedCode) { Token previous = this.ctm.get(openingTagIndex); int indent = previous.getIndent(); for (int i = openingTagIndex + 1; i < closingTagIndex; i++) { Token token = this.ctm.get(i); token.setToEscape(true); if (formattedCode && (token.getLineBreaksBefore() > 0 || previous.getLineBreaksAfter() > 0)) token.setAlign(indent); previous = token; } for (int i = closingTagIndex; i < this.ctm.size(); i++) { Token token = this.ctm.get(i); if (token.getIndent() == 0) break; token.setIndent(indent); previous = token; } }
private void cleanupHTMLElement(int openingTagIndex, int closingTagIndex, boolean formattedCode) { Token previous = this.ctm.get(openingTagIndex); int indent = previous.getIndent(); for (int i = openingTagIndex + 1; i < closingTagIndex; i++) { Token token = this.ctm.get(i); token.setToEscape(true); if (formattedCode && (token.getLineBreaksBefore() > 0 || previous.getLineBreaksAfter() > 0)) token.setAlign(indent); previous = token; } for (int i = closingTagIndex; i < this.ctm.size(); i++) { Token token = this.ctm.get(i); if (token.getIndent() == 0) break; token.setIndent(indent); previous = token; } }
private void handleFormatCodeTag(int startPos, int endPos, boolean isOpeningTag) { if (!this.options.comment_format_source) { handleNoFormatTag(startPos, endPos, isOpeningTag); return; } // add empty lines before opening and after closing token handleSeparateLineTag(startPos, endPos); if (isOpeningTag) { int startIndex = tokenStartingAt(startPos); if (startIndex > 1) this.ctm.get(startIndex).putLineBreaksBefore(2); if (this.formatCodeTagOpenEnd < 0) this.formatCodeTagOpenEnd = endPos; } else if (this.formatCodeTagOpenEnd >= 0) { int endTagIndex = tokenEndingAt(endPos); if (endTagIndex < this.ctm.size() - 2) this.ctm.get(endTagIndex).putLineBreaksAfter(2); formatCode(startPos, endPos); this.formatCodeTagOpenEnd = -1; this.lastFormatCodeClosingTagIndex = this.ctm.findIndex(startPos, -1, true); } }