void (@NotNull PsiElement element, @NotNull ActionContext context, @NotNull ModPsiUpdater updater) { final GrIfStatement ifStatement = (GrIfStatement)element.getParent(); final PsiElement thenBranch = skipBlock(ifStatement.getThenBranch()); final PsiElement elseBranch = skipBlock(ifStatement.getElseBranch()); Project project = context.project(); if (thenBranch instanceof GrAssignmentExpression thenAssign && elseBranch instanceof GrAssignmentExpression elseAssign) { final GrAssignmentExpression assignment = (GrAssignmentExpression)GroovyPsiElementFactory.getInstance( project).createStatementFromText("a = b ? c : d"); assignment.getLValue().replaceWithExpression(thenAssign.getLValue(), true); final GrConditionalExpression conditional = (GrConditionalExpression)assignment.getRValue(); replaceConditional(conditional, ifStatement.getCondition(), thenAssign.getRValue(), elseAssign.getRValue()); ifStatement.replaceWithStatement(assignment); } if (thenBranch instanceof GrReturnStatement thenReturn && elseBranch instanceof GrReturnStatement elseReturn) { final GrReturnStatement returnSt = (GrReturnStatement)GroovyPsiElementFactory.getInstance(project).createStatementFromText("return a ? b : c"); final GrConditionalExpression conditional = (GrConditionalExpression)returnSt.getReturnValue(); replaceConditional(conditional, ifStatement.getCondition(), thenReturn.getReturnValue(), elseReturn.getReturnValue()); ifStatement.replaceWithStatement(returnSt); } }