void (@NotNull PsiField @NotNull [] allFields, PsiClass implementingClass, Project project, PsiClass iface, PsiFile file, @NotNull ModPsiUpdater updater) { Map<PsiReferenceExpression, PsiClass> replacements = findReplacements(allFields, implementingClass, updater); PsiClassType classType = JavaPsiFacade.getInstance(project).getElementFactory().createType(iface); IntentionAction fix = QuickFixFactory.getInstance().createExtendsListFix(updater.getWritable(implementingClass), classType, false); fix.invoke(project, null, file); final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project); replacements.forEach((referenceExpression, containingClass) -> { final PsiReferenceExpression qualified = (PsiReferenceExpression) elementFactory.createExpressionFromText("xxx." + referenceExpression.getText(), referenceExpression); final PsiReferenceExpression newReference = (PsiReferenceExpression)referenceExpression.replace(qualified); final PsiReferenceExpression qualifier = (PsiReferenceExpression)newReference.getQualifierExpression(); assert qualifier != null : DebugUtil.psiToString(newReference, true); qualifier.bindToElement(containingClass); }); }