void (@NotNull final Map<PsiElement, PsiElement> oldToNewElementsMapping) { for (final PsiElement newClass : oldToNewElementsMapping.values()) { if (newClass.getLanguage() != JavaLanguage.INSTANCE) continue; newClass.accept(new JavaRecursiveElementVisitor() { @Override public void visitReferenceElement(final @NotNull PsiJavaCodeReferenceElement reference) { PsiElement element = reference.resolve(); if (element instanceof PsiClass) { for (PsiElement oldClass : oldToNewElementsMapping.keySet()) { if (PsiTreeUtil.isAncestor(oldClass, element, false)) { PsiClass newInnerClass = findMatchingClass((PsiClass)oldClass, (PsiClass)oldToNewElementsMapping.get(oldClass), (PsiClass)element); try { reference.bindToElement(newInnerClass); return; } catch (IncorrectOperationException ex) { LOG.error(ex); } } } } super.visitReferenceElement(reference); } }); } }