GrStatement (@NotNull PsiMethod method, @NotNull GrMethodCall methodCall) { String replacementStatement = getReplacementStatement(method, methodCall); if (replacementStatement == null) return null; GrExpression[] arguments = methodCall.getArgumentList().getExpressionArguments(); GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(method.getProject()); GrAssertStatement statement = (GrAssertStatement)factory.createStatementFromText(replacementStatement); final Map<GrExpression, GrExpression> replaceMap = new HashMap<>(); statement.acceptChildren(new GroovyRecursiveElementVisitor() { @Override public void visitExpression(@NotNull GrExpression expression) { Matcher matcher = Holder.PATTERN.matcher(expression.getText()); if (matcher.matches()) { int index = Integer.parseInt(matcher.group(1)); replaceMap.put(expression, arguments[index]); } else { super.visitExpression(expression); } } }); for (Map.Entry<GrExpression, GrExpression> entry : replaceMap.entrySet()) { entry.getKey().replaceWithExpression(entry.getValue(), true); } return statement; }