void (@NotNull Project project, @NotNull PsiElement startElement, @NotNull ModPsiUpdater updater) { final PsiIdentifier name = (PsiIdentifier)startElement; final PsiJavaCodeReferenceElement reference = (PsiJavaCodeReferenceElement)name.getParent(); final PsiClass aClass = (PsiClass)reference.resolve(); if (aClass == null) { return; } final PsiClass containingClass = aClass.getContainingClass(); if (containingClass == null) { return; } final PsiElementFactory factory = JavaPsiFacade.getElementFactory(reference.getProject()); final PsiJavaCodeReferenceElement newReferenceElement; if (reference instanceof PsiReferenceExpression) { newReferenceElement = factory.createReferenceExpression(containingClass); } else { newReferenceElement = factory.createClassReferenceElement(containingClass); } final PsiElement qualifier = reference.getQualifier(); if (qualifier == null) { return; } qualifier.replace(newReferenceElement); }