List<TextRange> (final PsiElement e, final CharSequence editorText, final int cursorOffset) { int start = cursorOffset; while (start > 0 && editorText.charAt(start - 1) != '\n' && editorText.charAt(start - 1) != '\r') start--; int end = cursorOffset; while (end < editorText.length() && editorText.charAt(end) != '\n' && editorText.charAt(end) != '\r') end++; final TextRange range = new TextRange(start, end); if (!e.getParent().getTextRange().contains(range)) return null; List<TextRange> result = new ArrayList<>(); result.add(range); return result; }