boolean (@NotNull PsiElement element, PsiElement context) { if (!(element instanceof PsiExpression)) return false; if (context == null) return false; try { PsiElementFactory.getInstance(element.getProject()).createExpressionFromText(element.getText(), element); } catch (IncorrectOperationException e) { return false; } return true; }