void (@NotNull PsiElement element, @NotNull ActionContext context, @NotNull ModPsiUpdater updater) { final PsiElement parent = element.getParent(); if (!(parent instanceof GrIfStatement)) return; final GrIfStatement ifStatement = GroovyRefactoringUtil.addBlockIntoParent((GrIfStatement)parent); assert ifStatement.getParent() instanceof GrStatementOwner; final PsiElement statementOwner = ifStatement.getParent(); final GrStatement branch = ifStatement.getElseBranch(); if (branch == null) return; if (branch instanceof GrBlockStatement) { final GrOpenBlock block = ((GrBlockStatement)branch).getBlock(); final PsiElement first = inferFirst(block.getLBrace()); final PsiElement last = inferLast(block.getRBrace()); if (!Objects.equals(first, block.getRBrace()) && !Objects.equals(last, block.getLBrace())) { // else block is not empty statementOwner.addRangeAfter(first, last, ifStatement); } } else { statementOwner.addAfter(branch, ifStatement); } branch.delete(); updater.moveTo(ifStatement.getTextRange().getEndOffset()); }