TextRange (@NotNull Editor editor) { int offset = editor.getCaretModel().getOffset(); int line = editor.getDocument().getLineNumber(offset); int start = editor.getDocument().getLineStartOffset(line); int end = editor.getDocument().getLineEndOffset(line); return new TextRange(start, end); }