last = last.getPrevSibling();
}
if (first == null || last == null || first == last && last instanceof PsiWhiteSpace) return null;
PsiElement parent = element.getParent();
PsiElement target = parent instanceof BnfQuantified || parent instanceof BnfPredicate? parent : element;
return Collections.singletonList(target.replace(BnfElementFactory.createExpressionFromText(
editor.getProject(), element.getContainingFile().getText().substring(first.getTextRange().getStartOffset(), last.getTextRange().getEndOffset()))));
}
@Nullable
private static PsiElement findTargetElement(Editor editor, PsiFile file) {