inspection toolwindow: insert problem nodes with permission of duplication according...
authorDmitry Batkovich <dmitry.batkovich@jetbrains.com>
Fri, 27 May 2016 11:31:24 +0000 (14:31 +0300)
committerDmitry Batkovich <dmitry.batkovich@jetbrains.com>
Fri, 27 May 2016 17:16:05 +0000 (20:16 +0300)
platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionRVContentProvider.java
platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionRVContentProviderImpl.java
platform/lang-impl/src/com/intellij/codeInspection/offlineViewer/OfflineInspectionRVContentProvider.java
platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java
platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionTreeNode.java

index cc6b9a7df15240865d77268bb90cf60d83c7ef17..671a7bbdd45624c8ceac304465b52cc19f697161 100644 (file)
@@ -187,7 +187,7 @@ public abstract class InspectionRVContentProvider {
         }
         for (InspectionPackageNode packageNode : packageNodes.values()) {
           if (packageNode.getPackageName() != null) {
-            moduleNode.insertByOrder(packageNode);
+            moduleNode.insertByOrder(packageNode, false);
             for (UserObjectContainer<T> container : packageDescriptors.get(packageNode)) {
               appendDescriptor(context, toolWrapper, container, packageNode, canPackageRepeat);
             }
@@ -289,7 +289,7 @@ public abstract class InspectionRVContentProvider {
                 return false;
               }
               else {
-                refElementNode.insertByOrder(finalPrevNode);
+                refElementNode.insertByOrder(finalPrevNode, false);
                 result.set(nodeToBeAdded);
                 return false;
               }
@@ -301,11 +301,11 @@ public abstract class InspectionRVContentProvider {
       if(!result.isNull()) return result.get();
 
       if (!firstLevel.get()) {
-        currentNode.insertByOrder(prevNode);
+        currentNode.insertByOrder(prevNode, false);
       }
       final UserObjectContainer owner = container.getOwner();
       if (owner == null) {
-        parentNode.insertByOrder(currentNode);
+        parentNode.insertByOrder(currentNode, false);
         return nodeToBeAdded;
       }
       container = owner;
@@ -349,7 +349,7 @@ public abstract class InspectionRVContentProvider {
         }
       }
     }
-    parent.insertByOrder(child);
+    parent.insertByOrder(child, false);
   }
 
   private static void processDepth(final InspectionTreeNode child, final InspectionTreeNode current) {
index dde1c52293db5965af151626af69cff97fc8c36f..2368a2fb1cc23266b934741103ed7cf5bf736077 100644 (file)
@@ -125,7 +125,7 @@ public class InspectionRVContentProviderImpl extends InspectionRVContentProvider
         final RefElementNode elemNode = addNodeToParent(container, presentation, pNode);
         for (CommonProblemDescriptor problem : problems) {
           assert problem != null;
-          elemNode.insertByOrder(new ProblemDescriptionNode(refElement, problem, toolWrapper,presentation));
+          elemNode.insertByOrder(new ProblemDescriptionNode(refElement, problem, toolWrapper,presentation), true);
           if (problems.length == 1) {
             elemNode.setProblem(problems[0]);
           }
index fe7b23bc0a11bd52cd031f6b2d68eb731bceb6d4..c62e5913bac499fefee67cfd30d5ef0cd62bd59d 100644 (file)
@@ -171,7 +171,7 @@ public class OfflineInspectionRVContentProvider extends InspectionRVContentProvi
       final OfflineProblemDescriptorNode child =
         OfflineProblemDescriptorNode.create(((OfflineProblemDescriptorContainer)container).getUserObject(),
                                             (LocalInspectionToolWrapper)toolWrapper, presentation);
-      elemNode.insertByOrder(child);
+      elemNode.insertByOrder(child, true);
     }
   }
 
index b13a34aeec38f76b14e016eb370ea63100892013..4b52ba781eef247fbaaad198b31e9353fd52622f 100644 (file)
@@ -745,7 +745,7 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren
       }
       group = ConcurrencyUtil.cacheOrGet(map, groupName, new InspectionGroupNode(groupName, groupPath));
       if (!myDisposed) {
-        getRelativeRootNode(groupedBySeverity, errorLevel).insertByOrder(group);
+        getRelativeRootNode(groupedBySeverity, errorLevel).insertByOrder(group, false);
       }
     }
     return group;
@@ -760,7 +760,7 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren
         severityGroupNode = ConcurrencyUtil.cacheOrGet(mySeverityGroupNodes, level, newNode);
         if (severityGroupNode == newNode) {
           InspectionTreeNode root = myTree.getRoot();
-          root.insertByOrder(severityGroupNode);
+          root.insertByOrder(severityGroupNode, false);
         }
       }
       return severityGroupNode;
index 98b1dded76a42aa1e52393e2928040105ddda914..ab130e12a6a9c70c64aced569992b8006bd25f00 100644 (file)
@@ -100,15 +100,15 @@ public abstract class InspectionTreeNode extends DefaultMutableTreeNode {
     }
   }
 
-  public void insertByOrder(InspectionTreeNode child) {
-    if (getIndex(child) != -1) {
+  public void insertByOrder(InspectionTreeNode child, boolean allowDuplication) {
+    if (!allowDuplication && getIndex(child) != -1) {
       return;
     }
     final int i = TreeUtil.indexedBinarySearch(this, child, InspectionResultsViewComparator.getInstance());
-    if (i >= 0){
+    if (!allowDuplication && i >= 0){
       return;
     }
-    insert(child, -i -1);
+    insert(child, Math.abs(i + 1));
   }
 
   @Override