private void bufferIndent(Token token, int index) { int indent = token.getIndent(); if (getCurrent() != null && getCurrent() != token) indent += getCurrent().getEmptyLineIndentAdjustment(); int spaces = 0; if (this.options.use_tabs_only_for_leading_indentations && this.options.tab_char != DefaultCodeFormatterOptions.SPACE) { WrapPolicy wrapPolicy = token.getWrapPolicy(); boolean isWrappedBlockComment = this.childBuilder != null && this.childBuilder.parentTokenIndex == index; if (isWrappedBlockComment) { Token lineStart = this.tm.get(this.tm.findFirstTokenInLine(index)); spaces = token.getIndent() - lineStart.getIndent(); token = lineStart; wrapPolicy = token.getWrapPolicy(); } while (wrapPolicy != null) { Token parentLineStart = this.tm.get(this.tm.findFirstTokenInLine(wrapPolicy.wrapParentIndex)); if (wrapPolicy.wrapMode != WrapMode.BLOCK_INDENT) spaces += token.getIndent() - parentLineStart.getIndent(); token = parentLineStart; wrapPolicy = token.getWrapPolicy(); } } appendIndentationString(this.buffer, this.options.tab_char, this.options.tab_size, indent - spaces, spaces); }
private void bufferIndent(Token token, int index) { int indent = token.getIndent(); if (getCurrent() != null && getCurrent() != token) indent += getCurrent().getEmptyLineIndentAdjustment(); int spaces = 0; if (this.options.use_tabs_only_for_leading_indentations && this.options.tab_char != DefaultCodeFormatterOptions.SPACE) { WrapPolicy wrapPolicy = token.getWrapPolicy(); boolean isWrappedBlockComment = this.childBuilder != null && this.childBuilder.parentTokenIndex == index; if (isWrappedBlockComment) { Token lineStart = this.tm.get(this.tm.findFirstTokenInLine(index)); spaces = token.getIndent() - lineStart.getIndent(); token = lineStart; wrapPolicy = token.getWrapPolicy(); } while (wrapPolicy != null) { Token parentLineStart = this.tm.get(this.tm.findFirstTokenInLine(wrapPolicy.wrapParentIndex)); if (wrapPolicy.wrapMode != WrapMode.FORCED) spaces += token.getIndent() - parentLineStart.getIndent(); token = parentLineStart; wrapPolicy = token.getWrapPolicy(); } } appendIndentationString(this.buffer, this.options.tab_char, this.options.tab_size, indent - spaces, spaces); }
private void bufferIndent(Token token, int index) { int indent = token.getIndent(); if (getCurrent() != null && getCurrent() != token) indent += getCurrent().getEmptyLineIndentAdjustment(); int spaces = 0; if (this.options.use_tabs_only_for_leading_indentations && this.options.tab_char != DefaultCodeFormatterOptions.SPACE) { WrapPolicy wrapPolicy = token.getWrapPolicy(); boolean isWrappedBlockComment = this.childBuilder != null && this.childBuilder.parentTokenIndex == index; if (isWrappedBlockComment) { Token lineStart = this.tm.get(this.tm.findFirstTokenInLine(index)); spaces = token.getIndent() - lineStart.getIndent(); token = lineStart; wrapPolicy = token.getWrapPolicy(); } while (wrapPolicy != null) { Token parentLineStart = this.tm.get(this.tm.findFirstTokenInLine(wrapPolicy.wrapParentIndex)); if (wrapPolicy.wrapMode != WrapMode.BLOCK_INDENT) spaces += token.getIndent() - parentLineStart.getIndent(); token = parentLineStart; if (wrapPolicy == token.getWrapPolicy()) { assert wrapPolicy == WrapPolicy.FORCE_FIRST_COLUMN || wrapPolicy == WrapPolicy.DISABLE_WRAP; break; } wrapPolicy = token.getWrapPolicy(); } } appendIndentationString(this.buffer, this.options.tab_char, this.options.tab_size, indent - spaces, spaces); }