void (PsiJavaCodeReferenceElement reference, PsiMember target) { final PsiManager manager = reference.getManager(); final Project project = manager.getProject(); final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project); final PsiElementFactory factory = psiFacade.getElementFactory(); final PsiClass aClass = target.getContainingClass(); if (aClass == null) { return; } CommentTracker tracker = new CommentTracker(); final String qualifiedName = aClass.getQualifiedName(); final String text = tracker.text(reference); final String referenceText = qualifiedName + '.' + text; if (reference instanceof PsiReferenceExpression) { final PsiElement insertedElement = tracker.replaceAndRestoreComments(reference, referenceText); JavaCodeStyleManager.getInstance(project).shortenClassReferences(insertedElement); } else { final PsiJavaCodeReferenceElement referenceElement = factory.createReferenceElementByFQClassName(referenceText, reference.getResolveScope()); final PsiElement insertedElement = tracker.replaceAndRestoreComments(reference, referenceElement); JavaCodeStyleManager.getInstance(project).shortenClassReferences(insertedElement); } }