diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsViewComparator.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsViewComparator.java index a06afdf762ec..cb85ba7ae702 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsViewComparator.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsViewComparator.java @@ -38,6 +38,7 @@ import com.intellij.profile.codeInspection.ui.inspectionsTree.InspectionsConfigT import com.intellij.psi.PsiElement; import com.intellij.psi.PsiNamedElement; import com.intellij.psi.PsiQualifiedNamedElement; +import com.intellij.psi.SmartPsiElementPointer; import com.intellij.psi.util.PsiUtilCore; import java.util.Comparator; @@ -159,12 +160,16 @@ public class InspectionResultsViewComparator implements Comparator { private static int compareEntities(final RefEntity entity1, final RefEntity entity2) { if (entity1 instanceof RefElement && entity2 instanceof RefElement) { - final VirtualFile file1 = ((RefElement)entity1).getPointer().getVirtualFile(); - final VirtualFile file2 = ((RefElement)entity2).getPointer().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; + 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; + } } } }