TextRange (@NotNull ASTNode node) { if (node.getElementType() == TokenType.ERROR_ELEMENT) { return node.getTextRange(); } final ASTNode prevLeaf = FormatterUtil.getPreviousLeaf(node, TokenType.WHITE_SPACE); if (prevLeaf == null || prevLeaf.getElementType() != TokenType.ERROR_ELEMENT) { return node.getTextRange(); } final TextRange range = doGetRangeAffectingIndent(prevLeaf); if (range == null) { return node.getTextRange(); } else { return new TextRange(range.getStartOffset(), node.getTextRange().getEndOffset()); } }