void (@NotNull final GrExpression element, @NotNull final Project project, @NotNull final Editor editor) { final List<GrLiteral> literals = collectOperands(element, new ArrayList<>()); if (literals.isEmpty()) return; final StringBuilder buffer = prepareNewLiteralText(literals); CommandProcessor.getInstance().executeCommand(project, () -> ApplicationManager.getApplication().runWriteAction(() -> { try { final int offset = editor.getCaretModel().getOffset(); final TextRange range = element.getTextRange(); int shift; if (editor.getSelectionModel().hasSelection()) { shift = 0; } else if (range.getStartOffset() == offset) { shift = 0; } else if (range.getEndOffset() == offset + 1) { shift = -2; } else { shift = 2; } final GrExpression newLiteral = GroovyPsiElementFactory.getInstance(project).createExpressionFromText(buffer.toString()); element.replaceWithExpression(newLiteral, true); if (shift != 0) { editor.getCaretModel().moveToOffset(editor.getCaretModel().getOffset() + shift); } } catch (IncorrectOperationException e) { LOG.error(e); } }), getText(), null); }