boolean (PsiElement element, @NotNull ActionContext context) { TextRange selection = context.selection(); Document document = element.getContainingFile().getViewProvider().getDocument(); if (!selection.isEmpty()) { final int start = selection.getStartOffset(); final int end = selection.getEndOffset(); if (start < 0 || end < 0 || start > end || end > document.getTextLength()) { return false; } final String text = document.getCharsSequence().subSequence(start, end).toString(); return indexOfUnicodeEscape(text, 1) >= 0; } else { final int lineNumber = document.getLineNumber(context.offset()); int lineStart = document.getLineStartOffset(lineNumber); final String line = document.getText(new TextRange(lineStart, document.getLineEndOffset(lineNumber))); final int column = context.offset() - lineStart; final int index = indexOfUnicodeEscape(line, column); return index >= 0 && column >= index; } }