boolean (PsiElement position) { if (psiElement() .withSuperParent(2, PsiConditionalExpression.class) .andNot(psiElement().insideStarting(psiElement(PsiConditionalExpression.class))) .accepts(position)) { return false; } if (isEndOfBlock(position) && PsiTreeUtil.getParentOfType(position, PsiCodeBlock.class, true, PsiMember.class) != null) { return !isForLoopMachinery(position); } if (psiElement().withParents(PsiReferenceExpression.class, PsiExpressionStatement.class, PsiIfStatement.class).andNot( psiElement().afterLeaf(".")).accepts(position)) { PsiElement stmt = position.getParent().getParent(); PsiIfStatement ifStatement = (PsiIfStatement)stmt.getParent(); return ifStatement.getElseBranch() == stmt || ifStatement.getThenBranch() == stmt; } return false; }