use of com.intellij.codeInspection.reference.RefFile in project intellij-community by JetBrains.
the class InspectionResultsViewComparator method compareEntities.
private static int compareEntities(final RefEntity entity1, final RefEntity entity2) {
if (entity1 instanceof RefElement && entity2 instanceof RefElement) {
final SmartPsiElementPointer p1 = ((RefElement) entity1).getPointer();
final SmartPsiElementPointer p2 = ((RefElement) entity2).getPointer();
if (p1 != null && p2 != null) {
final VirtualFile file1 = p1.getVirtualFile();
final VirtualFile file2 = p2.getVirtualFile();
if (file1 != null && Comparing.equal(file1, file2) && file1.isValid()) {
final int positionComparing = PsiUtilCore.compareElementsByPosition(((RefElement) entity1).getElement(), ((RefElement) entity2).getElement());
if (positionComparing != 0) {
return positionComparing;
}
}
}
}
if (entity1 instanceof RefFile && entity2 instanceof RefFile) {
final VirtualFile file1 = ((RefFile) entity1).getPointer().getVirtualFile();
final VirtualFile file2 = ((RefFile) entity2).getPointer().getVirtualFile();
if (file1 != null && file2 != null) {
if (file1.equals(file2))
return 0;
final int cmp = compareEntitiesByName(entity1, entity2);
if (cmp != 0)
return cmp;
return file1.hashCode() - file2.hashCode();
}
}
if (entity1 != null && entity2 != null) {
return compareEntitiesByName(entity1, entity2);
}
if (entity1 != null)
return -1;
return entity2 != null ? 1 : 0;
}
Aggregations