TextRange (@NotNull GrExpression expression, PsiElement context) { GrParenthesizedExpression result = (GrParenthesizedExpression) GroovyPsiElementFactory.getInstance(expression.getProject()).createExpressionFromText("(a)", context); replaceToOldExpression(result.getOperand(), expression); result = (GrParenthesizedExpression) expression.replaceWithExpression(result, true); return new TextRange(result.getTextRange().getEndOffset(), result.getTextRange().getEndOffset()); }