void (PsiClass innerClass) { SearchScope scope = myAnonOrLocalClass.getUseScope(); Collection<PsiReference> refs = ReferencesSearch.search(myAnonOrLocalClass, scope).findAll(); myAnonOrLocalClass.delete(); for (PsiReference reference : refs) { if (reference.getElement().isValid()) { reference.bindToElement(innerClass); } } }