void (@NotNull PsiJavaCodeReferenceElement referenceElement, @NotNull ModPsiUpdater updater) { final PsiFile file = referenceElement.getContainingFile(); final PsiElement target = referenceElement.resolve(); if (!(target instanceof PsiClass aClass)) { return; } final String qualifiedName = aClass.getQualifiedName(); if (qualifiedName == null || !ImportUtils.nameCanBeImported(qualifiedName, referenceElement)) { return; } ImportUtils.addImportIfNeeded(aClass, referenceElement); final String fullyQualifiedText = referenceElement.getText(); final QualificationRemover qualificationRemover = new QualificationRemover(fullyQualifiedText); file.accept(qualificationRemover); qualificationRemover.getShortenedElements().forEach(element -> { if (element.isValid()) { updater.highlight(element); } }); }