void (Map<PsiMethodCallExpression, PsiMethod> oldResolves, final PsiMethod extracted, final PsiElement oldFragment) { final PsiCodeBlock body = extracted.getBody(); assert body != null; final JavaRecursiveElementVisitor visitor = new JavaRecursiveElementVisitor() { @Override public void visitMethodCallExpression(@NotNull PsiMethodCallExpression expression) { super.visitMethodCallExpression(expression); final PsiMethod target = expression.getCopyableUserData(RESOLVE_TARGET_KEY); if (target != null) { expression.putCopyableUserData(RESOLVE_TARGET_KEY, null); try { addCastsToEnsureResolveTarget(target, expression); } catch (IncorrectOperationException e) { LOG.error(e); } } } }; body.accept(visitor); oldFragment.accept(visitor); for (final Map.Entry<PsiMethodCallExpression, PsiMethod> entry : oldResolves.entrySet()) { try { addCastsToEnsureResolveTarget(entry.getValue(), entry.getKey()); } catch (IncorrectOperationException e) { LOG.error(e); } } }