public static void shortenReference(PsiFile file, int offset) throws IncorrectOperationException {
    Project project = file.getProject();
    PsiDocumentManager manager = PsiDocumentManager.getInstance(project);
    Document document = manager.getDocument(file);
    if (document == null) {
      PsiUtilCore.ensureValid(file);
      LOG.error("No document for " + file);
      return;
    }

    manager.commitDocument(document);
    PsiReference ref = file.findReferenceAt(offset);
    if (ref != null) {
      JavaCodeStyleManager.getInstance(project).shortenClassReferences(ref.getElement());
      PsiDocumentManager.getInstance(project).doPostponedOperationsAndUnblockDocument(document);
    }
  }
public static void shortenReference(PsiFile file, int offset)