private @Nullable PsiReference chooseReference() {
    if (myReferences.isEmpty()) return null;

    ContainerUtil.sort(myReferences, (o1, o2) -> {
      final int byPriority = Double.compare(getPriority(o2), getPriority(o1));
      if (byPriority != 0) return byPriority;

      final int bySoftness = Boolean.compare(o2.isSoft(), o1.isSoft());
      if (bySoftness != 0) return bySoftness;

      return Boolean.compare(o2 instanceof FileReference, o1 instanceof FileReference);  // by ref type
    });

    return myReferences.get(0);
  }
private @Nullable PsiReference chooseReference()