Replacer (@NotNull PsiSwitchBlock switchBlock) { if (!(switchBlock instanceof PsiSwitchExpression)) { return null; } Object returnStatement = switchBlock.getParent(); return returnStatement instanceof PsiReturnStatement ? new ReturningReplacer((PsiReturnStatement)returnStatement) : null; }