List<TextRange> (@NotNull PsiElement e, @NotNull CharSequence editorText, int cursorOffset, @NotNull Editor editor) { TextRange range = e.getTextRange(); char prevLeftChar = ' '; for (int left = Math.min(cursorOffset, editor.getDocument().getTextLength() - 1); left >= range.getStartOffset(); left--) { char leftChar = editorText.charAt(left); if (leftChar == '}') return Collections.emptyList(); if (leftChar == '$' && prevLeftChar == '{') { for (int right = cursorOffset; right < range.getEndOffset(); right++) { char rightChar = editorText.charAt(right); if (rightChar == '{') return Collections.emptyList(); if (rightChar == '}') { return Arrays.asList(new TextRange(left + 2, right), new TextRange(left, right + 1)); } } } prevLeftChar = leftChar; } return Collections.emptyList(); }