void (@NotNull PsiElement element, @NotNull ActionContext context, @NotNull ModPsiUpdater updater) { String quote = element.getText().substring(0, 1); StringBuilder buffer = new StringBuilder(); buffer.append(quote); GrExpression old; if (element instanceof GrLiteralImpl) { appendSimpleStringValue(element, buffer, quote); old = (GrExpression)element; } else { final GrStringImpl gstring = (GrStringImpl)element; for (GroovyPsiElement child : gstring.getAllContentParts()) { if (child instanceof GrStringContent) { appendSimpleStringValue(child, buffer, "\""); } else if (child instanceof GrStringInjection) { buffer.append(child.getText()); } } old = gstring; } buffer.append(quote); try { final int offset = context.offset(); final TextRange range = old.getTextRange(); int shift; if (range.getStartOffset() == offset) { shift = 0; } else if (range.getStartOffset() == offset - 1) { shift = -1; } else if (range.getEndOffset() == offset) { shift = -4; } else if (range.getEndOffset() == offset + 1) { shift = -3; } else { shift = -2; } final GrExpression newLiteral = GroovyPsiElementFactory.getInstance(context.project()).createExpressionFromText(buffer.toString()); old.replaceWithExpression(newLiteral, true); if (shift != 0) { updater.moveTo(offset + shift); } } catch (IncorrectOperationException e) { LOG.error(e); } }