boolean (PsiExpression expr) { PsiType type = expr.getType(); if (type instanceof PsiPrimitiveType) return false; if (!expr.isPhysical()) return false; if (expr.getParent() instanceof PsiExpressionStatement) return false; PsiElement parent = PsiTreeUtil.getParentOfType(expr, PsiExpressionStatement.class); if (parent == null) return false; final PsiElement element = parent.getParent(); if (!(element instanceof PsiCodeBlock) && !(FileTypeUtils.isInServerPageFile(element) && element instanceof PsiFile)) return false; return true; }