boolean (PsiElement position) { PsiElement prev = PsiTreeUtil.prevVisibleLeaf(position); if (prev == null) return false; PsiElement expr = PsiTreeUtil.getParentOfType(prev, PsiExpression.class); if (expr != null && expr.getTextRange().getEndOffset() == prev.getTextRange().getEndOffset() && PsiTreeUtil.getParentOfType(expr, PsiAnnotation.class) == null) { return true; } if (position instanceof PsiIdentifier && position.getParent() instanceof PsiLocalVariable) { PsiType type = ((PsiLocalVariable)position.getParent()).getType(); if (type instanceof PsiClassType && ((PsiClassType)type).resolve() == null) { PsiElement grandParent = position.getParent().getParent(); return !(grandParent instanceof PsiDeclarationStatement) || !(grandParent.getParent() instanceof PsiForStatement) || ((PsiForStatement)grandParent.getParent()).getInitialization() != grandParent; } } return false; }