Replacer (@NotNull PsiSwitchBlock switchBlock) { if (!(switchBlock instanceof PsiSwitchExpression)) return null; PsiAssignmentExpression assignment = tryCast(switchBlock.getParent(), PsiAssignmentExpression.class); if (assignment == null || !(assignment.getLExpression() instanceof PsiReferenceExpression)) return null; return new AssignmentReplacer(assignment); }