void (@NotNull PsiElement element) { if (!(element instanceof PsiReferenceList referenceList)) { return; } final PsiClassType[] types = referenceList.getReferencedTypes(); final PsiClass commonSuperClass = findCommonSuperClass(types); if (commonSuperClass == null) { return; } final PsiElementFactory factory = JavaPsiFacade.getElementFactory(element.getProject()); final PsiJavaCodeReferenceElement referenceElement = factory.createClassReferenceElement(commonSuperClass); final PsiReferenceList newReferenceList = factory.createReferenceList(new PsiJavaCodeReferenceElement[]{referenceElement}); new CommentTracker().replaceAndRestoreComments(referenceList, newReferenceList); }