void (final PsiElement element, final PsiMethod oldConstructor, final PsiExpression[] instanceCreationArguments) { Map<PsiReferenceExpression, PsiExpression> replacement = new LinkedHashMap<>(); element.accept(new JavaRecursiveElementWalkingVisitor() { @Override public void visitReferenceExpression(@NotNull PsiReferenceExpression expression) { super.visitReferenceExpression(expression); PsiElement resolved = expression.resolve(); if (resolved instanceof PsiParameter && element.getManager().areElementsEquivalent(((PsiParameter)resolved).getDeclarationScope(), oldConstructor)) { int parameterIndex = oldConstructor.getParameterList().getParameterIndex((PsiParameter)resolved); if (parameterIndex >= 0) { replacement.put(expression, instanceCreationArguments[parameterIndex]); } } } }); for (Map.Entry<PsiReferenceExpression, PsiExpression> entry : replacement.entrySet()) { try { entry.getKey().replace(entry.getValue()); } catch (IncorrectOperationException e) { LOG.error(e); } } }