inspection view: make problems with different in-element ranges different
authorDmitry Batkovich <dmitry.batkovich@jetbrains.com>
Thu, 6 Oct 2016 16:11:20 +0000 (19:11 +0300)
committerDmitry Batkovich <dmitry.batkovich@jetbrains.com>
Thu, 6 Oct 2016 16:12:35 +0000 (19:12 +0300)
platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsViewComparator.java

index cb85ba7ae7025494b22a6228ac6e98537a0a78c7..3758a78aa7771c765e196406c5331cb8182bb01c 100644 (file)
@@ -32,6 +32,7 @@ import com.intellij.codeInspection.reference.RefEntity;
 import com.intellij.codeInspection.reference.RefFile;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.util.Comparing;
+import com.intellij.openapi.util.TextRange;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.profile.codeInspection.ui.inspectionsTree.InspectionsConfigTreeComparator;
@@ -107,8 +108,18 @@ public class InspectionResultsViewComparator implements Comparator {
         if (diff != 0) {
           return diff;
         }
-        return PsiUtilCore.compareElementsByPosition(((ProblemDescriptor)descriptor2).getEndElement(),
+        diff = PsiUtilCore.compareElementsByPosition(((ProblemDescriptor)descriptor2).getEndElement(),
                                                      ((ProblemDescriptor)descriptor1).getEndElement());
+        if (diff != 0) return diff;
+
+        final TextRange range1 = ((ProblemDescriptor)descriptor1).getTextRangeInElement();
+        final TextRange range2 = ((ProblemDescriptor)descriptor2).getTextRangeInElement();
+        if (range1 != null && range2 != null) {
+          diff = range1.getStartOffset() - range2.getStartOffset();
+          if (diff != 0) return diff;
+          diff = range1.getEndOffset() - range2.getEndOffset();
+          if (diff != 0) return diff;
+        }
       }
       if (descriptor1 != null && descriptor2 != null) {
         return descriptor1.getDescriptionTemplate().compareToIgnoreCase(descriptor2.getDescriptionTemplate());