int (@NotNull Document document, int line, int tabSize, int offset) { offset = Math.min(offset, document.getLineEndOffset(line)); int lineStartOffset = document.getLineStartOffset(line); int relOffset = offset - lineStartOffset; if (columnCache == null) return relOffset; int cacheIndex = relOffset / CACHE_FREQUENCY; int startOffset = lineStartOffset + cacheIndex * CACHE_FREQUENCY; int startColumn = cacheIndex == 0 ? 0 : columnCache[cacheIndex - 1]; return calcColumn(document.getImmutableCharSequence(), startOffset, startColumn, offset, tabSize); }