private void handleSeparateLineTag(int startPos, int endPos) { int openingTagIndex = tokenStartingAt(startPos); if (openingTagIndex > 1 && this.lastFormatCodeClosingTagIndex == openingTagIndex - 1) { Token token = this.ctm.get(openingTagIndex - 1); assert token.getLineBreaksAfter() == 2; token.clearLineBreaksAfter(); token.breakAfter(); } handleBreakBeforeTag(startPos, endPos, true); handleBreakAfterTag(startPos, endPos); }
@Override public void endVisit(Javadoc node) { if (this.ctm == null) return; if (this.options.comment_insert_empty_line_before_root_tags && this.firstTagToken != null && this.ctm.indexOf(this.firstTagToken) > 1) { this.firstTagToken.putLineBreaksBefore(2); } addSubstituteWraps(); }
public void processComment(Token commentToken) { assert commentToken.isComment(); if (commentToken.tokenType == TokenNameCOMMENT_LINE) { handleSingleLineComment(commentToken, this.tm.indexOf(commentToken)); } else { handleMultiLineComment(commentToken, this.tm.indexOf(commentToken)); } }
private void handleBreakBeforeTag(int start, int end, boolean isOpeningTag) { int firstPartIndex = tokenStartingAt(start); int lastPartIndex = tokenEndingAt(end); Token firstPartToken = this.ctm.get(firstPartIndex); firstPartToken.setWrapPolicy(null); if (isOpeningTag) { firstPartToken.breakBefore(); this.ctm.get(lastPartIndex + 1).clearSpaceBefore(); } else { firstPartToken.clearSpaceBefore(); } }
private boolean isActiveTopPriorityWrap(int index, WrapPolicy wrapPolicy) { if (this.activeTopPriorityWrap >= 0) return false; for (int i = index - 1; i > wrapPolicy.wrapParentIndex; i--) { Token token = WrapExecutor.this.tm.get(i); if (token.isWrappable() && token.getWrapPolicy().wrapParentIndex == wrapPolicy.wrapParentIndex && (token.getLineBreaksBefore() > 0 || WrapExecutor.this.tm.get(i - 1).getLineBreaksAfter() > 0)) { return true; } } return false; }
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 traverseInternalStructure(Token token, int index) { List<Token> structure = token.getInternalStructure(); this.tm = new TokenManager(structure, this.parent.tm); this.counter = token.originalStart; this.sourceLimit = token.originalEnd + 1; this.parentTokenIndex = index; traverse(structure, 0); }
@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 int tokenStartingAt(int start) { int tokenIndex = this.ctm.findIndex(start, -1, false); Token token = this.ctm.get(tokenIndex); if (token.originalStart == start) return tokenIndex; assert start > token.originalStart && start <= token.originalEnd; splitToken(token, tokenIndex, start); return tokenIndex + 1; }
@Override public boolean visit(LabeledStatement node) { if (this.options.insert_new_line_after_label) this.tm.firstTokenIn(node, TokenNameCOLON).breakAfter(); return true; }
private void handleSeparateLineTag(int startPos, int endPos) { int openingTagIndex = tokenStartingAt(startPos); if (openingTagIndex > 1 && this.lastFormatCodeClosingTagIndex == openingTagIndex - 1) { Token token = this.ctm.get(openingTagIndex - 1); assert token.getLineBreaksAfter() == 2; token.clearLineBreaksAfter(); token.breakAfter(); } handleBreakBeforeTag(startPos, endPos, true); handleBreakAfterTag(startPos, endPos); }
private void handleBreakBeforeTag(int start, int end, boolean isOpeningTag) { int firstPartIndex = tokenStartingAt(start); int lastPartIndex = tokenEndingAt(end); Token firstPartToken = this.ctm.get(firstPartIndex); firstPartToken.setWrapPolicy(null); if (isOpeningTag) { firstPartToken.breakBefore(); this.ctm.get(lastPartIndex + 1).clearSpaceBefore(); } else { firstPartToken.clearSpaceBefore(); } }
public void processComment(Token commentToken) { assert commentToken.isComment(); if (commentToken.tokenType == TokenNameCOMMENT_LINE) { handleSingleLineComment(commentToken, this.tm.indexOf(commentToken)); } else { handleMultiLineComment(commentToken, this.tm.indexOf(commentToken)); } }
@Override public void endVisit(Javadoc node) { if (this.ctm == null) return; if (this.options.comment_insert_empty_line_before_root_tags && this.firstTagToken != null && this.ctm.indexOf(this.firstTagToken) > 1) { this.firstTagToken.putLineBreaksBefore(2); } addSubstituteWraps(); }
private void traverseInternalStructure(Token token, int index) { List<Token> structure = token.getInternalStructure(); this.tm = new TokenManager(structure, this.parent.tm); this.counter = token.originalStart; this.sourceLimit = token.originalEnd + 1; this.parentTokenIndex = index; traverse(structure, 0); }
private void handleSeparateLineTag(int startPos, int endPos) { int openingTagIndex = tokenStartingAt(startPos); if (openingTagIndex > 1 && this.lastFormatCodeClosingTagIndex == openingTagIndex - 1) { Token token = this.ctm.get(openingTagIndex - 1); assert token.getLineBreaksAfter() == 2; token.clearLineBreaksAfter(); token.breakAfter(); } handleBreakBeforeTag(startPos, endPos, true); handleBreakAfterTag(startPos, endPos); }
private void handleBreakBeforeTag(int start, int end, boolean isOpeningTag) { int firstPartIndex = tokenStartingAt(start); int lastPartIndex = tokenEndingAt(end); Token firstPartToken = this.ctm.get(firstPartIndex); firstPartToken.setWrapPolicy(null); if (isOpeningTag) { firstPartToken.breakBefore(); this.ctm.get(lastPartIndex + 1).clearSpaceBefore(); } else { firstPartToken.clearSpaceBefore(); } }
public void processComment(Token commentToken) { assert commentToken.isComment(); if (commentToken.tokenType == TokenNameCOMMENT_LINE) { handleSingleLineComment(commentToken, this.tm.indexOf(commentToken)); } else { handleMultiLineComment(commentToken, this.tm.indexOf(commentToken)); } }
@Override public void endVisit(Javadoc node) { if (this.ctm == null) return; if (this.options.comment_insert_empty_line_before_root_tags && this.firstTagToken != null && this.ctm.indexOf(this.firstTagToken) > 1) { this.firstTagToken.putLineBreaksBefore(2); } addSubstituteWraps(); }
private void traverseInternalStructure(Token token, int index) { List<Token> structure = token.getInternalStructure(); this.tm = new TokenManager(structure, this.parent.tm); this.counter = token.originalStart; this.sourceLimit = token.originalEnd + 1; this.parentTokenIndex = index; traverse(structure, 0); }