WhiteSpaceInfo (@NotNull CharSequence text, int startOffset, int endOffset, int startColumn, int tabSize) { assert startOffset <= endOffset; int spaces = 0; int indentSpaces = 0; int lineFeeds = 0; int column = startColumn; for (int i = startOffset; i < endOffset; i++) { switch (text.charAt(i)) { case LINE_FEED -> { lineFeeds++; spaces = 0; indentSpaces = 0; column = 0; } case '\t' -> { int change = tabSize - (column % tabSize); indentSpaces += change; column += change; } default -> { spaces++; column++; } } } return new WhiteSpaceInfo(lineFeeds, indentSpaces, spaces); }