boolean () { if (isCodeFragmentType(getTreeParent().getElementType()) || getParent() instanceof PsiAnnotation) { return false; } PsiElement superParent = getParent(); while (superParent != null) { if (superParent instanceof PsiCodeBlock || superParent instanceof PsiLocalVariable) { return true; } if (superParent instanceof PsiClass || superParent instanceof PsiCatchSection) { return false; } superParent = superParent.getParent(); } return false; }