boolean (@Nullable PsiElement context) { context = PsiUtil.skipParenthesizedExprUp(context); if (context instanceof PsiTypeCastExpression) { return true; } while (true) { context = PsiUtil.skipParenthesizedExprUp(context); if (isAssignmentOrInvocationContext(context)) { return true; } if (context instanceof PsiConditionalExpression) { context = context.getParent(); continue; } if (context instanceof PsiYieldStatement) { PsiSwitchExpression switchExpression = ((PsiYieldStatement)context).findEnclosingExpression(); if (switchExpression != null) { context = switchExpression.getParent(); continue; } } if (context instanceof PsiExpressionStatement) { PsiElement parent = context.getParent(); if (parent instanceof PsiSwitchLabeledRuleStatement) { PsiSwitchBlock switchBlock = ((PsiSwitchLabeledRuleStatement)parent).getEnclosingSwitchBlock(); if (switchBlock != null) { context = switchBlock.getParent(); continue; } } } return false; } }