int (@NotNull Document document, int lineNumber) { int lineStart = document.getLineStartOffset(lineNumber); int lineEnd = document.getLineEndOffset(lineNumber); int result = findFirstNonSpaceOffsetInRange(document.getCharsSequence(), lineStart, lineEnd); return result >= 0 ? result : lineEnd; }