int (final Object o1, final Object o2) { PsiElement element1 = getPsiElement(o1); PsiElement element2 = getPsiElement(o2); if (element1 == null) return element2 == null ? 0 : 1; if (element2 == null) return -1; if (myContext != null && myContextModule != null) { final ProximityLocation location = new ProximityLocation(myContext, myContextModule); StatisticsInfo info1 = StatisticsManager.serialize(STATISTICS_KEY, element1, location); StatisticsInfo info2 = StatisticsManager.serialize(STATISTICS_KEY, element2, location); if (info1 != null && info2 != null) { StatisticsManager statisticsManager = StatisticsManager.getInstance(); int count1 = statisticsManager.getLastUseRecency(info1); int count2 = statisticsManager.getLastUseRecency(info2); if (count1 != count2) { return count1 < count2 ? -1 : 1; } } } final WeighingComparable<PsiElement, ProximityLocation> proximity1 = myProximities.get(element1); final WeighingComparable<PsiElement, ProximityLocation> proximity2 = myProximities.get(element2); if (proximity1 == null || proximity2 == null) { return 0; } return -proximity1.compareTo(proximity2); }