inspection toolwindow: offline inspection result action resolves packages/classes...
authorDmitry Batkovich <dmitry.batkovich@jetbrains.com>
Thu, 16 Jun 2016 13:21:12 +0000 (16:21 +0300)
committerDmitry Batkovich <dmitry.batkovich@jetbrains.com>
Thu, 16 Jun 2016 13:21:41 +0000 (16:21 +0300)
15 files changed:
java/java-tests/testData/inspection/offline/project/src/Test.java
java/java-tests/testData/inspection/offline/project/src/Test2.java [new file with mode: 0644]
java/java-tests/testData/inspection/offline/res/EqualsWithItself.xml [new file with mode: 0644]
java/java-tests/testSrc/com/intellij/codeInspection/OfflineInspectionResultViewTest.java
platform/analysis-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextBase.java
platform/analysis-impl/src/com/intellij/codeInspection/reference/SmartRefElementPointerImpl.java
platform/lang-api/src/com/intellij/codeInspection/offline/OfflineProblemDescriptor.java
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/offlineViewer/OfflineRefElementNode.java [deleted file]
platform/lang-impl/src/com/intellij/codeInspection/offlineViewer/OfflineViewParseUtil.java
platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsViewComparator.java
platform/lang-impl/src/com/intellij/codeInspection/ui/ProblemDescriptionNode.java
platform/platform-resources-en/src/messages/InspectionsBundle.properties

index 94e0c00069f65584c82078adcbb6887918f07fae..63a9bd4730a20be33c3db8229f08d07c13482028 100644 (file)
@@ -49,4 +49,8 @@ public class Test {
       long d = 5;
       int a = 0;
   }
       long d = 5;
       int a = 0;
   }
+
+  void m() {
+    "".equals("");
+  }
 }
 }
diff --git a/java/java-tests/testData/inspection/offline/project/src/Test2.java b/java/java-tests/testData/inspection/offline/project/src/Test2.java
new file mode 100644 (file)
index 0000000..0ef1884
--- /dev/null
@@ -0,0 +1,11 @@
+public class Test2 {
+
+  void m123() {
+
+
+    "".equals("");
+
+
+  }
+
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/inspection/offline/res/EqualsWithItself.xml b/java/java-tests/testData/inspection/offline/res/EqualsWithItself.xml
new file mode 100644 (file)
index 0000000..2fd5dac
--- /dev/null
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<problems>
+  <problem>
+    <file>file://$PROJECT_DIR$/src/Test.java</file>
+    <line>54</line>
+    <module>test</module>
+    <package>&lt;default&gt;</package>
+    <entry_point TYPE="method" FQNAME="Test void m()" />
+    <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'equals()' called on itself</problem_class>
+    <description>Identical qualifier and argument to &lt;code&gt;equals()&lt;/code&gt; call</description>
+  </problem>
+  <problem>
+    <file>file://$PROJECT_DIR$/src/Test2.java</file>
+    <line>6</line>
+    <module>test</module>
+    <package>&lt;default&gt;</package>
+    <entry_point TYPE="method" FQNAME="Test2 void m123()" />
+    <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'equals()' called on itself</problem_class>
+    <description>Identical qualifier and argument to &lt;code&gt;equals()&lt;/code&gt; call</description>
+  </problem>
+</problems>
+
index 234a3fa32136102361dae1f81cde25fab88e5a99..36604631f1c8b69f3fa56719a607aa337791ddd9 100644 (file)
@@ -24,15 +24,14 @@ import com.intellij.codeInsight.daemon.HighlightDisplayKey;
 import com.intellij.codeInspection.actions.ViewOfflineResultsAction;
 import com.intellij.codeInspection.defUse.DefUseInspection;
 import com.intellij.codeInspection.defUse.DefUseInspectionBase;
 import com.intellij.codeInspection.actions.ViewOfflineResultsAction;
 import com.intellij.codeInspection.defUse.DefUseInspection;
 import com.intellij.codeInspection.defUse.DefUseInspectionBase;
-import com.intellij.codeInspection.ex.InspectionProfileImpl;
-import com.intellij.codeInspection.ex.InspectionToolWrapper;
-import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
-import com.intellij.codeInspection.ex.ToolsImpl;
+import com.intellij.codeInspection.ex.*;
 import com.intellij.codeInspection.offline.OfflineProblemDescriptor;
 import com.intellij.codeInspection.offline.OfflineProblemDescriptor;
+import com.intellij.codeInspection.offlineViewer.OfflineProblemDescriptorNode;
 import com.intellij.codeInspection.offlineViewer.OfflineViewParseUtil;
 import com.intellij.codeInspection.ui.InspectionResultsView;
 import com.intellij.codeInspection.ui.InspectionTree;
 import com.intellij.codeInspection.ui.InspectionTreeNode;
 import com.intellij.codeInspection.offlineViewer.OfflineViewParseUtil;
 import com.intellij.codeInspection.ui.InspectionResultsView;
 import com.intellij.codeInspection.ui.InspectionTree;
 import com.intellij.codeInspection.ui.InspectionTreeNode;
+import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.application.ex.PathManagerEx;
 import com.intellij.openapi.util.Comparing;
 import com.intellij.openapi.util.Disposer;
 import com.intellij.openapi.application.ex.PathManagerEx;
 import com.intellij.openapi.util.Comparing;
 import com.intellij.openapi.util.Disposer;
@@ -40,7 +39,10 @@ import com.intellij.openapi.util.io.FileUtil;
 import com.intellij.psi.PsiElement;
 import com.intellij.testFramework.PlatformTestUtil;
 import com.intellij.testFramework.TestSourceBasedTestCase;
 import com.intellij.psi.PsiElement;
 import com.intellij.testFramework.PlatformTestUtil;
 import com.intellij.testFramework.TestSourceBasedTestCase;
+import com.intellij.util.containers.ContainerUtil;
 import com.intellij.util.ui.tree.TreeUtil;
 import com.intellij.util.ui.tree.TreeUtil;
+import com.siyeh.ig.bugs.EqualsWithItselfInspection;
+import gnu.trove.THashMap;
 import org.jetbrains.annotations.NotNull;
 
 import java.io.File;
 import org.jetbrains.annotations.NotNull;
 
 import java.io.File;
@@ -51,7 +53,8 @@ import java.util.Set;
 
 public class OfflineInspectionResultViewTest extends TestSourceBasedTestCase {
   private InspectionResultsView myView;
 
 public class OfflineInspectionResultViewTest extends TestSourceBasedTestCase {
   private InspectionResultsView myView;
-  private LocalInspectionToolWrapper myToolWrapper;
+  private LocalInspectionToolWrapper myUnusedToolWrapper;
+  private LocalInspectionToolWrapper myDataFlowToolWrapper;
 
   private static String varMessage(String name) {
     return InspectionsBundle.message("inspection.unused.assignment.problem.descriptor1", "'" + name + "'");
 
   private static String varMessage(String name) {
     return InspectionsBundle.message("inspection.unused.assignment.problem.descriptor1", "'" + name + "'");
@@ -66,8 +69,7 @@ public class OfflineInspectionResultViewTest extends TestSourceBasedTestCase {
       HighlightDisplayKey.register(DefUseInspectionBase.SHORT_NAME);
     }
 
       HighlightDisplayKey.register(DefUseInspectionBase.SHORT_NAME);
     }
 
-    myToolWrapper = new LocalInspectionToolWrapper(new DefUseInspection());
-    myView = ViewOfflineResultsAction.showOfflineView(getProject(), parse(), new InspectionProfileImpl("test") {
+    final InspectionProfileImpl profile = new InspectionProfileImpl("test") {
       @Override
       public boolean isToolEnabled(final HighlightDisplayKey key, PsiElement element) {
         return Comparing.strEqual(key.toString(), DefUseInspectionBase.SHORT_NAME);
       @Override
       public boolean isToolEnabled(final HighlightDisplayKey key, PsiElement element) {
         return Comparing.strEqual(key.toString(), DefUseInspectionBase.SHORT_NAME);
@@ -76,7 +78,7 @@ public class OfflineInspectionResultViewTest extends TestSourceBasedTestCase {
       @Override
       @NotNull
       public InspectionToolWrapper[] getInspectionTools(PsiElement element) {
       @Override
       @NotNull
       public InspectionToolWrapper[] getInspectionTools(PsiElement element) {
-        return new InspectionToolWrapper[]{myToolWrapper};
+        return new InspectionToolWrapper[]{myUnusedToolWrapper};
       }
 
       @Override
       }
 
       @Override
@@ -86,7 +88,7 @@ public class OfflineInspectionResultViewTest extends TestSourceBasedTestCase {
           @Override
           @NotNull
           public InspectionToolWrapper[] getInspectionTools(PsiElement element) {
           @Override
           @NotNull
           public InspectionToolWrapper[] getInspectionTools(PsiElement element) {
-            return new InspectionToolWrapper[]{myToolWrapper};
+            return new InspectionToolWrapper[]{myUnusedToolWrapper};
           }
 
           @Override
           }
 
           @Override
@@ -95,11 +97,19 @@ public class OfflineInspectionResultViewTest extends TestSourceBasedTestCase {
           }
         };
       }
           }
         };
       }
-    }, "");
-    myView.getGlobalInspectionContext().getTools().put(
-      myToolWrapper.getShortName(), new ToolsImpl(myToolWrapper, myToolWrapper.getDefaultLevel(), true));
-    myToolWrapper.initialize(myView.getGlobalInspectionContext());
-  }
+    };
+
+    myView = ViewOfflineResultsAction.showOfflineView(getProject(), parse(), profile, "");
+    myUnusedToolWrapper = new LocalInspectionToolWrapper(new DefUseInspection());
+    myDataFlowToolWrapper = new LocalInspectionToolWrapper(new EqualsWithItselfInspection());
+
+    final Map<String, Tools> tools = myView.getGlobalInspectionContext().getTools();
+    for (LocalInspectionToolWrapper tool : ContainerUtil.ar(myUnusedToolWrapper, myDataFlowToolWrapper)) {
+      profile.addTool(getProject(), tool, new THashMap<>());
+      tools.put(tool.getShortName(), new ToolsImpl(tool, tool.getDefaultLevel(), true));
+      tool.initialize(myView.getGlobalInspectionContext());
+    }
+}
 
   private Map<String, Map<String, Set<OfflineProblemDescriptor>>> parse() throws IOException {
     final String moduleName = getModule().getName();
 
   private Map<String, Map<String, Set<OfflineProblemDescriptor>>> parse() throws IOException {
     final String moduleName = getModule().getName();
@@ -125,22 +135,33 @@ public class OfflineInspectionResultViewTest extends TestSourceBasedTestCase {
   protected void tearDown() throws Exception {
     Disposer.dispose(myView);
     myView = null;
   protected void tearDown() throws Exception {
     Disposer.dispose(myView);
     myView = null;
-    myToolWrapper = null;
+    myUnusedToolWrapper = null;
+    myDataFlowToolWrapper = null;
     super.tearDown();
   }
 
     super.tearDown();
   }
 
-  public void testOfflineView() throws Exception {
+  public void testOfflineWithInvalid() throws Exception {
+    ApplicationManager.getApplication().runWriteAction(() -> getJavaFacade().findClass("Test2").getContainingFile().delete());
     myView.getGlobalInspectionContext().getUIOptions().SHOW_STRUCTURE = true;
     InspectionTree tree = updateTree();
     TreeUtil.expandAll(tree);
     myView.getGlobalInspectionContext().getUIOptions().SHOW_STRUCTURE = true;
     InspectionTree tree = updateTree();
     TreeUtil.expandAll(tree);
-    PlatformTestUtil.assertTreeEqual(tree, "-" + getProject() + "\n"
-                                           + " -Probable bugs\n"
-                                           + "  -" + myToolWrapper + "\n"
+    PlatformTestUtil.assertTreeEqual(tree, "-" + getProject() + "\n" +
+                                           " -Probable bugs\n" +
+                                           "  -" + myDataFlowToolWrapper + "\n" +
+                                           "   -Module: 'testOfflineWithInvalid'\n" +
+                                           "    -<default>\n" +
+                                           "     -Test\n" +
+                                           "      -m()\n" +
+                                           "       Identical qualifier and argument to 'equals()' call\n" +
+                                           "      Identical qualifier and argument to <code>equals()</code> call\n"
+                                           + "  -" + myUnusedToolWrapper + "\n"
                                            + "   -" + getModule().toString() + "\n"
                                            + "    -<default>\n"
                                            + "     -Test\n"
                                            + "      -foo()\n"
                                            + "       " + varMessage("j") + "\n"
                                            + "   -" + getModule().toString() + "\n"
                                            + "    -<default>\n"
                                            + "     -Test\n"
                                            + "      -foo()\n"
                                            + "       " + varMessage("j") + "\n"
+                                           + "      -main(String[])\n"
+                                           + "       " + varMessage("test") + "\n"
                                            + "      -f()\n"
                                            + "       -D\n"
                                            + "        -b()\n"
                                            + "      -f()\n"
                                            + "       -D\n"
                                            + "        -b()\n"
@@ -150,21 +171,63 @@ public class OfflineInspectionResultViewTest extends TestSourceBasedTestCase {
                                            + "           " + varMessage("i") + "\n"
                                            + "      -ff()\n"
                                            + "       " + varMessage("d") + "\n"
                                            + "           " + varMessage("i") + "\n"
                                            + "      -ff()\n"
                                            + "       " + varMessage("d") + "\n"
-                                           + "       " + varMessage("a") + "\n"
+                                           + "       " + varMessage("a") + "\n");
+    tree.setSelectionRow(7);
+    final OfflineProblemDescriptorNode node =
+      (OfflineProblemDescriptorNode)tree.getSelectionModel().getSelectionPath().getLastPathComponent();
+    assertFalse(node.isValid());
+  }
+
+  public void testOfflineView() throws Exception {
+    myView.getGlobalInspectionContext().getUIOptions().SHOW_STRUCTURE = true;
+    InspectionTree tree = updateTree();
+    TreeUtil.expandAll(tree);
+    PlatformTestUtil.assertTreeEqual(tree, "-" + getProject() + "\n" +
+                                           " -Probable bugs\n" +
+                                           "  -" + myDataFlowToolWrapper + "\n" +
+                                           "   -Module: 'testOfflineView'\n" +
+                                           "    -<default>\n" +
+                                           "     -Test\n" +
+                                           "      -m()\n" +
+                                           "       Identical qualifier and argument to 'equals()' call\n" +
+                                           "     -Test2\n" +
+                                           "      -m123()\n" +
+                                           "       Identical qualifier and argument to 'equals()' call\n"
+                                           + "  -" + myUnusedToolWrapper + "\n"
+                                           + "   -" + getModule().toString() + "\n"
+                                           + "    -<default>\n"
+                                           + "     -Test\n"
+                                           + "      -foo()\n"
+                                           + "       " + varMessage("j") + "\n"
                                            + "      -main(String[])\n"
                                            + "      -main(String[])\n"
-                                           + "       " + varMessage("test") + "\n");
-    myView.getGlobalInspectionContext().getUIOptions().SHOW_STRUCTURE = false;
+                                           + "       " + varMessage("test") + "\n"
+                                           + "      -f()\n"
+                                           + "       -D\n"
+                                           + "        -b()\n"
+                                           + "         " + varMessage("r") + "\n"
+                                           + "         -anonymous (java.lang.Runnable)\n"
+                                           + "          -run()\n"
+                                           + "           " + varMessage("i") + "\n"
+                                           + "      -ff()\n"
+                                           + "       " + varMessage("d") + "\n"
+                                           + "       " + varMessage("a") + "\n");
+                                     myView.getGlobalInspectionContext().getUIOptions().SHOW_STRUCTURE = false;
     tree = updateTree();
     PlatformTestUtil.assertTreeEqual(tree, "-" + getProject() + "\n"
                                            + " -Probable bugs\n"
     tree = updateTree();
     PlatformTestUtil.assertTreeEqual(tree, "-" + getProject() + "\n"
                                            + " -Probable bugs\n"
-                                           + "  -" + myToolWrapper + "\n"
+                                           + "  -" + myDataFlowToolWrapper + "\n" +
+                                           "   -Test\n" +
+                                           "    Identical qualifier and argument to 'equals()' call\n" +
+                                           "   -Test2\n" +
+                                           "    Identical qualifier and argument to 'equals()' call\n"
+                                           + "  -" + myUnusedToolWrapper + "\n"
                                            + "   -Test\n"
                                            + "    " + varMessage("j") + "\n"
                                            + "   -Test\n"
                                            + "    " + varMessage("j") + "\n"
+                                           + "    " + varMessage("test") + "\n"
                                            + "    " + varMessage("r") + "\n"
                                            + "    " + varMessage("i") + "\n"
                                            + "    " + varMessage("d") + "\n"
                                            + "    " + varMessage("r") + "\n"
                                            + "    " + varMessage("i") + "\n"
                                            + "    " + varMessage("d") + "\n"
-                                           + "    " + varMessage("a") + "\n"
-                                           + "    " + varMessage("test") + "\n");
+                                           + "    " + varMessage("a") + "\n");
     TreeUtil.selectFirstNode(tree);
     final InspectionTreeNode root = (InspectionTreeNode)tree.getLastSelectedPathComponent();
     root.excludeElement(myView.getExcludedManager());
     TreeUtil.selectFirstNode(tree);
     final InspectionTreeNode root = (InspectionTreeNode)tree.getLastSelectedPathComponent();
     root.excludeElement(myView.getExcludedManager());
@@ -182,14 +245,19 @@ public class OfflineInspectionResultViewTest extends TestSourceBasedTestCase {
     tree = updateTree();
     PlatformTestUtil.assertTreeEqual(tree, "-" + getProject() + "\n"
                                            + " -Probable bugs\n"
     tree = updateTree();
     PlatformTestUtil.assertTreeEqual(tree, "-" + getProject() + "\n"
                                            + " -Probable bugs\n"
-                                           + "  -" + myToolWrapper + "\n"
+                                           + "  -" + myDataFlowToolWrapper + "\n" +
+                                           "   -Test\n" +
+                                           "    Identical qualifier and argument to 'equals()' call\n" +
+                                           "   -Test2\n" +
+                                           "    Identical qualifier and argument to 'equals()' call\n"
+                                           + "  -" + myUnusedToolWrapper + "\n"
                                            + "   -Test\n"
                                            + "    " + varMessage("j") + "\n"
                                            + "   -Test\n"
                                            + "    " + varMessage("j") + "\n"
+                                           + "    " + varMessage("test") + "\n"
                                            + "    " + varMessage("r") + "\n"
                                            + "    " + varMessage("i") + "\n"
                                            + "    " + varMessage("d") + "\n"
                                            + "    " + varMessage("r") + "\n"
                                            + "    " + varMessage("i") + "\n"
                                            + "    " + varMessage("d") + "\n"
-                                           + "    " + varMessage("a") + "\n"
-                                           + "    " + varMessage("test") + "\n");
+                                           + "    " + varMessage("a") + "\n");
   }
 
   private InspectionTree updateTree() {
   }
 
   private InspectionTree updateTree() {
index a53fb7de796329a1a5d4dfa3c6505175b39b28c9..fb5d76fa046a416c35fb47691c377c8273cbd2f4 100644 (file)
@@ -39,7 +39,6 @@ import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
 import com.intellij.psi.*;
 import com.intellij.psi.search.LocalSearchScope;
 import com.intellij.psi.search.scope.packageSet.NamedScope;
 import com.intellij.psi.*;
 import com.intellij.psi.search.LocalSearchScope;
 import com.intellij.psi.search.scope.packageSet.NamedScope;
-import com.intellij.util.Function;
 import com.intellij.util.containers.ContainerUtil;
 import com.intellij.util.containers.HashMap;
 import gnu.trove.THashMap;
 import com.intellij.util.containers.ContainerUtil;
 import com.intellij.util.containers.HashMap;
 import gnu.trove.THashMap;
index 06a0baf4487a19a3abadc7e3a9be2d7818df7df8..8e145ec4d7c72d5d86a47a985f2bdb154a256ac5 100644 (file)
@@ -85,12 +85,6 @@ public class SmartRefElementPointerImpl implements SmartRefElementPointer {
     Element element = new Element(ENTRY_POINT);
     element.setAttribute(TYPE_ATTR, myType);
     element.setAttribute(FQNAME_ATTR, getFQName());
     Element element = new Element(ENTRY_POINT);
     element.setAttribute(TYPE_ATTR, myType);
     element.setAttribute(FQNAME_ATTR, getFQName());
-    /*if (myRefElement != null) {
-      final RefEntity entity = myRefElement.getOwner();
-      if (entity != null) {
-        new SmartRefElementPointerImpl(entity, myIsPersistent).writeExternal(element);
-      }
-    }*/
     parentNode.addContent(element);
   }
 
     parentNode.addContent(element);
   }
 
index 428d7251b19db189cd6f53d2fe2d6fb0aadb0809..e172c5bca1241a0ae748b00c7c43b95e6610f6a6 100644 (file)
 package com.intellij.codeInspection.offline;
 
 import com.intellij.codeInspection.reference.RefElement;
 package com.intellij.codeInspection.offline;
 
 import com.intellij.codeInspection.reference.RefElement;
-import com.intellij.codeInspection.reference.RefManager;
 import com.intellij.codeInspection.reference.RefEntity;
 import com.intellij.codeInspection.reference.RefEntity;
-import com.intellij.openapi.application.Application;
+import com.intellij.codeInspection.reference.RefManager;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.psi.PsiDocumentManager;
 import com.intellij.psi.PsiElement;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.psi.PsiDocumentManager;
 import com.intellij.psi.PsiElement;
-import com.intellij.util.ArrayUtil;
 import com.intellij.util.ui.UIUtil;
 import org.jetbrains.annotations.Nullable;
 
 import com.intellij.util.ui.UIUtil;
 import org.jetbrains.annotations.Nullable;
 
@@ -41,8 +39,6 @@ public class OfflineProblemDescriptor {
   public List<String> myHints;
   public int myProblemIndex;
   public int myLine;
   public List<String> myHints;
   public int myProblemIndex;
   public int myLine;
-  public String[] myParentType;
-  public String[] myParentFQName;
   public String myModuleName;
 
   public String getType() {
   public String myModuleName;
 
   public String getType() {
@@ -93,22 +89,6 @@ public class OfflineProblemDescriptor {
     myLine = line;
   }
 
     myLine = line;
   }
 
-  public String[] getParentType() {
-    return myParentType;
-  }
-
-  public void setParentType(final String[] parentType) {
-    myParentType = parentType;
-  }
-
-  public String[] getParentFQName() {
-    return myParentFQName;
-  }
-
-  public void setParentFQName(final String[] parentFQName) {
-    myParentFQName = parentFQName;
-  }
-
   @Nullable
   public RefEntity getRefElement(final RefManager refManager) {
     final RefEntity refElement = refManager.getReference(myType, myFQName);
   @Nullable
   public RefEntity getRefElement(final RefManager refManager) {
     final RefEntity refElement = refManager.getReference(myType, myFQName);
@@ -121,23 +101,6 @@ public class OfflineProblemDescriptor {
     return refElement;
   }
 
     return refElement;
   }
 
-  @Nullable
-  public OfflineProblemDescriptor getOwner() {
-    if (myParentType != null && myParentFQName != null) {
-      final OfflineProblemDescriptor descriptor = new OfflineProblemDescriptor();
-      descriptor.setLine(myLine);
-      descriptor.setFQName(myParentFQName[0]);
-      descriptor.setType(myParentType[0]);
-      if (myParentType.length > 1 && myParentFQName.length > 1) {
-        descriptor.setParentType(ArrayUtil.remove(myParentType, 0));
-        descriptor.setParentFQName(ArrayUtil.remove(myParentFQName, 0));
-      }
-      return descriptor;
-    }
-    return null;
-  }
-
-
   public boolean equals(final Object o) {
     if (this == o) return true;
     if (o == null || getClass() != o.getClass()) return false;
   public boolean equals(final Object o) {
     if (this == o) return true;
     if (o == null || getClass() != o.getClass()) return false;
@@ -150,8 +113,6 @@ public class OfflineProblemDescriptor {
     if (myFQName != null ? !myFQName.equals(that.myFQName) : that.myFQName != null) return false;
     if (myHints != null ? !myHints.equals(that.myHints) : that.myHints != null) return false;
     if (myModuleName != null ? !myModuleName.equals(that.myModuleName) : that.myModuleName != null) return false;
     if (myFQName != null ? !myFQName.equals(that.myFQName) : that.myFQName != null) return false;
     if (myHints != null ? !myHints.equals(that.myHints) : that.myHints != null) return false;
     if (myModuleName != null ? !myModuleName.equals(that.myModuleName) : that.myModuleName != null) return false;
-    if (!Arrays.equals(myParentFQName, that.myParentFQName)) return false;
-    if (!Arrays.equals(myParentType, that.myParentType)) return false;
     if (myType != null ? !myType.equals(that.myType) : that.myType != null) return false;
 
     return true;
     if (myType != null ? !myType.equals(that.myType) : that.myType != null) return false;
 
     return true;
@@ -165,8 +126,6 @@ public class OfflineProblemDescriptor {
     result = 31 * result + (myHints != null ? myHints.hashCode() : 0);
     result = 31 * result + myProblemIndex;
     result = 31 * result + myLine;
     result = 31 * result + (myHints != null ? myHints.hashCode() : 0);
     result = 31 * result + myProblemIndex;
     result = 31 * result + myLine;
-    result = 31 * result + (myParentType != null ? Arrays.hashCode(myParentType) : 0);
-    result = 31 * result + (myParentFQName != null ? Arrays.hashCode(myParentFQName) : 0);
     result = 31 * result + (myModuleName != null ? myModuleName.hashCode() : 0);
     return result;
   }
     result = 31 * result + (myModuleName != null ? myModuleName.hashCode() : 0);
     return result;
   }
index 475b9a2068f4d9f2a98635f2deb1ff63071e4545..50b1d8d9b6bb66a64c32aa0494a720a38629b3cd 100644 (file)
@@ -22,13 +22,16 @@ package com.intellij.codeInspection.ex;
 
 import com.intellij.codeInspection.CommonProblemDescriptor;
 import com.intellij.codeInspection.QuickFix;
 
 import com.intellij.codeInspection.CommonProblemDescriptor;
 import com.intellij.codeInspection.QuickFix;
-import com.intellij.codeInspection.offlineViewer.OfflineRefElementNode;
+import com.intellij.codeInspection.reference.RefDirectory;
+import com.intellij.codeInspection.reference.RefElement;
 import com.intellij.codeInspection.reference.RefEntity;
 import com.intellij.codeInspection.reference.RefEntity;
+import com.intellij.codeInspection.reference.RefModule;
 import com.intellij.codeInspection.ui.*;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.module.Module;
 import com.intellij.openapi.module.ModuleManager;
 import com.intellij.openapi.project.Project;
 import com.intellij.codeInspection.ui.*;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.module.Module;
 import com.intellij.openapi.module.ModuleManager;
 import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Comparing;
 import com.intellij.openapi.util.Ref;
 import com.intellij.util.Function;
 import com.intellij.util.containers.MultiMap;
 import com.intellij.openapi.util.Ref;
 import com.intellij.util.Function;
 import com.intellij.util.containers.MultiMap;
@@ -49,22 +52,54 @@ public abstract class InspectionRVContentProvider {
     myProject = project;
   }
 
     myProject = project;
   }
 
-  protected interface UserObjectContainer<T> {
+  protected static class RefEntityContainer<Descriptor> {
+    private final Descriptor[] myDescriptors;
     @Nullable
     @Nullable
-    UserObjectContainer<T> getOwner();
+    private final RefEntity myEntity;
 
 
-    @NotNull
-    RefElementNode createNode(@NotNull InspectionToolPresentation presentation);
+    public RefEntityContainer(@Nullable RefEntity entity, Descriptor[] descriptors) {
+      myEntity = entity;
+      myDescriptors = descriptors;
+    }
+
+    @Nullable
+    public RefEntityContainer<Descriptor> getOwner() {
+      if (myEntity == null) return null;
+      final RefEntity entity = myEntity.getOwner();
+      return entity instanceof RefElement && !(entity instanceof RefDirectory)
+             ? new RefEntityContainer<Descriptor>(entity, myDescriptors)
+             : null;
+    }
 
     @NotNull
 
     @NotNull
-    T getUserObject();
+    public RefElementNode createNode(@NotNull InspectionToolPresentation presentation) {
+      return new RefElementNode(myEntity, presentation);
+    }
+
+    @Nullable
+    public RefEntity getRefEntity() {
+      return myEntity;
+    }
 
     @Nullable
 
     @Nullable
-    String getModule();
+    public String getModule() {
+      final RefModule refModule = myEntity instanceof RefElement
+                                  ? ((RefElement)myEntity).getModule()
+                                  : myEntity instanceof RefModule ? (RefModule)myEntity : null;
+      return refModule != null ? refModule.getName() : null;
+    }
 
 
-    boolean areEqual(final T o1, final T o2);
+    boolean areEqual(final @NotNull RefEntity o1, final @NotNull RefEntity o2) {
+      return Comparing.equal(o1, o2);
+    }
 
 
-    boolean supportStructure();
+    boolean supportStructure() {
+      return myEntity == null || myEntity instanceof RefElement && !(myEntity instanceof RefDirectory); //do not show structure for refModule and refPackage
+    }
+
+    public Descriptor[] getDescriptors() {
+      return myDescriptors;
+    }
   }
 
   public abstract boolean checkReportedProblems(@NotNull GlobalInspectionContextImpl context, @NotNull InspectionToolWrapper toolWrapper);
   }
 
   public abstract boolean checkReportedProblems(@NotNull GlobalInspectionContextImpl context, @NotNull InspectionToolWrapper toolWrapper);
@@ -121,7 +156,7 @@ public abstract class InspectionRVContentProvider {
 
   protected abstract void appendDescriptor(@NotNull GlobalInspectionContextImpl context,
                                            @NotNull InspectionToolWrapper toolWrapper,
 
   protected abstract void appendDescriptor(@NotNull GlobalInspectionContextImpl context,
                                            @NotNull InspectionToolWrapper toolWrapper,
-                                           @NotNull UserObjectContainer container,
+                                           @NotNull RefEntityContainer container,
                                            @NotNull InspectionTreeNode pNode,
                                            final boolean canPackageRepeat);
 
                                            @NotNull InspectionTreeNode pNode,
                                            final boolean canPackageRepeat);
 
@@ -133,16 +168,16 @@ public abstract class InspectionRVContentProvider {
                                @NotNull Map<String, Set<T>> packageContents,
                                final boolean canPackageRepeat,
                                @NotNull InspectionToolWrapper toolWrapper,
                                @NotNull Map<String, Set<T>> packageContents,
                                final boolean canPackageRepeat,
                                @NotNull InspectionToolWrapper toolWrapper,
-                               @NotNull Function<T, UserObjectContainer<T>> computeContainer,
+                               @NotNull Function<T, RefEntityContainer<?>> computeContainer,
                                final boolean showStructure,
                                final UnaryOperator<InspectionTreeNode> createdNodesConsumer) {
     final Map<String, Map<String, InspectionPackageNode>> module2PackageMap = new HashMap<String, Map<String, InspectionPackageNode>>();
     boolean supportStructure = showStructure;
                                final boolean showStructure,
                                final UnaryOperator<InspectionTreeNode> createdNodesConsumer) {
     final Map<String, Map<String, InspectionPackageNode>> module2PackageMap = new HashMap<String, Map<String, InspectionPackageNode>>();
     boolean supportStructure = showStructure;
-    final MultiMap<InspectionPackageNode, UserObjectContainer<T>> packageDescriptors = new MultiMap<>();
+    final MultiMap<InspectionPackageNode, RefEntityContainer<?>> packageDescriptors = new MultiMap<>();
     for (String packageName : packageContents.keySet()) {
       final Set<T> elements = packageContents.get(packageName);
       for (T userObject : elements) {
     for (String packageName : packageContents.keySet()) {
       final Set<T> elements = packageContents.get(packageName);
       for (T userObject : elements) {
-        final UserObjectContainer<T> container = computeContainer.fun(userObject);
+        final RefEntityContainer container = computeContainer.fun(userObject);
         supportStructure &= container.supportStructure();
         final String moduleName = showStructure ? container.getModule() : null;
         Map<String, InspectionPackageNode> packageNodes = module2PackageMap.get(moduleName);
         supportStructure &= container.supportStructure();
         final String moduleName = showStructure ? container.getModule() : null;
         Map<String, InspectionPackageNode> packageNodes = module2PackageMap.get(moduleName);
@@ -181,7 +216,7 @@ public abstract class InspectionRVContentProvider {
           else {
             for (InspectionPackageNode packageNode : packageNodes.values()) {
               createdNodesConsumer.apply(packageNode);
           else {
             for (InspectionPackageNode packageNode : packageNodes.values()) {
               createdNodesConsumer.apply(packageNode);
-              for (UserObjectContainer<T> container : packageDescriptors.get(packageNode)) {
+              for (RefEntityContainer<?> container : packageDescriptors.get(packageNode)) {
                 appendDescriptor(context, toolWrapper, container, packageNode, canPackageRepeat);
               }
             }
                 appendDescriptor(context, toolWrapper, container, packageNode, canPackageRepeat);
               }
             }
@@ -192,14 +227,14 @@ public abstract class InspectionRVContentProvider {
         }
         for (InspectionPackageNode packageNode : packageNodes.values()) {
           if (packageNode.getPackageName() != null) {
         }
         for (InspectionPackageNode packageNode : packageNodes.values()) {
           if (packageNode.getPackageName() != null) {
-            Collection<UserObjectContainer<T>> objectContainers = packageDescriptors.get(packageNode);
+            Collection<RefEntityContainer<?>> objectContainers = packageDescriptors.get(packageNode);
             packageNode = (InspectionPackageNode)merge(packageNode, moduleNode, true);
             packageNode = (InspectionPackageNode)merge(packageNode, moduleNode, true);
-            for (UserObjectContainer<T> container : objectContainers) {
+            for (RefEntityContainer<?> container : objectContainers) {
               appendDescriptor(context, toolWrapper, container, packageNode, canPackageRepeat);
             }
           }
           else {
               appendDescriptor(context, toolWrapper, container, packageNode, canPackageRepeat);
             }
           }
           else {
-            for (UserObjectContainer<T> container : packageDescriptors.get(packageNode)) {
+            for (RefEntityContainer<?> container : packageDescriptors.get(packageNode)) {
               appendDescriptor(context, toolWrapper, container, moduleNode, canPackageRepeat);
             }
           }
               appendDescriptor(context, toolWrapper, container, moduleNode, canPackageRepeat);
             }
           }
@@ -209,7 +244,7 @@ public abstract class InspectionRVContentProvider {
     else {
       for (Map<String, InspectionPackageNode> packageNodes : module2PackageMap.values()) {
         for (InspectionPackageNode pNode : packageNodes.values()) {
     else {
       for (Map<String, InspectionPackageNode> packageNodes : module2PackageMap.values()) {
         for (InspectionPackageNode pNode : packageNodes.values()) {
-          for (UserObjectContainer<T> container : packageDescriptors.get(pNode)) {
+          for (RefEntityContainer<?> container : packageDescriptors.get(pNode)) {
             appendDescriptor(context, toolWrapper, container, pNode, canPackageRepeat);
           }
           final int count = pNode.getChildCount();
             appendDescriptor(context, toolWrapper, container, pNode, canPackageRepeat);
           }
           final int count = pNode.getChildCount();
@@ -270,7 +305,7 @@ public abstract class InspectionRVContentProvider {
   }
 
   @NotNull
   }
 
   @NotNull
-  protected static RefElementNode addNodeToParent(@NotNull UserObjectContainer container,
+  protected static RefElementNode addNodeToParent(@NotNull RefEntityContainer container,
                                                   @NotNull InspectionToolPresentation presentation,
                                                   final InspectionTreeNode parentNode) {
     final RefElementNode nodeToBeAdded = container.createNode(presentation);
                                                   @NotNull InspectionToolPresentation presentation,
                                                   final InspectionTreeNode parentNode) {
     final RefElementNode nodeToBeAdded = container.createNode(presentation);
@@ -279,16 +314,16 @@ public abstract class InspectionRVContentProvider {
     final Ref<RefElementNode> result = new Ref<RefElementNode>();
     while (true) {
       final RefElementNode currentNode = firstLevel.get() ? nodeToBeAdded : container.createNode(presentation);
     final Ref<RefElementNode> result = new Ref<RefElementNode>();
     while (true) {
       final RefElementNode currentNode = firstLevel.get() ? nodeToBeAdded : container.createNode(presentation);
-      final UserObjectContainer finalContainer = container;
+      final RefEntityContainer finalContainer = container;
       final RefElementNode finalPrevNode = prevNode;
       TreeUtil.traverseDepth(parentNode, new TreeUtil.Traverse() {
         @Override
         public boolean accept(Object node) {
           if (node instanceof RefElementNode) {
             final RefElementNode refElementNode = (RefElementNode)node;
       final RefElementNode finalPrevNode = prevNode;
       TreeUtil.traverseDepth(parentNode, new TreeUtil.Traverse() {
         @Override
         public boolean accept(Object node) {
           if (node instanceof RefElementNode) {
             final RefElementNode refElementNode = (RefElementNode)node;
-            final Object userObject = finalContainer.getUserObject();
-            final Object object = node instanceof OfflineRefElementNode ? ((OfflineRefElementNode) refElementNode).getOfflineDescriptor() : refElementNode.getUserObject();
-            if ((object == null || userObject.getClass().equals(object.getClass())) && finalContainer.areEqual(object, userObject)) {
+            final RefEntity userObject = finalContainer.getRefEntity();
+            final RefEntity object = refElementNode.getElement();
+            if (userObject == null || object == null || (userObject.getClass().equals(object.getClass())) && finalContainer.areEqual(object, userObject)) {
               if (firstLevel.get()) {
                 result.set(refElementNode);
                 return false;
               if (firstLevel.get()) {
                 result.set(refElementNode);
                 return false;
@@ -308,7 +343,7 @@ public abstract class InspectionRVContentProvider {
       if (!firstLevel.get()) {
         currentNode.insertByOrder(prevNode, false);
       }
       if (!firstLevel.get()) {
         currentNode.insertByOrder(prevNode, false);
       }
-      final UserObjectContainer owner = container.getOwner();
+      final RefEntityContainer owner = container.getOwner();
       if (owner == null) {
         parentNode.insertByOrder(currentNode, false);
         return nodeToBeAdded;
       if (owner == null) {
         parentNode.insertByOrder(currentNode, false);
         return nodeToBeAdded;
index 34c51e635c5bf4af6ac96a2382fb33b6332a6e22..a823c3961fca279cc9114263e3d54b4cbc0bf181 100644 (file)
@@ -24,7 +24,6 @@ import com.intellij.codeInspection.CommonProblemDescriptor;
 import com.intellij.codeInspection.reference.*;
 import com.intellij.codeInspection.ui.*;
 import com.intellij.openapi.project.Project;
 import com.intellij.codeInspection.reference.*;
 import com.intellij.codeInspection.ui.*;
 import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.Comparing;
 import com.intellij.openapi.util.TextRange;
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.search.LocalSearchScope;
 import com.intellij.openapi.util.TextRange;
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.search.LocalSearchScope;
@@ -107,7 +106,7 @@ public class InspectionRVContentProviderImpl extends InspectionRVContentProvider
               contents,
               false,
               toolWrapper,
               contents,
               false,
               toolWrapper,
-              refElement -> new RefElementContainer(refElement, problems.get(refElement)),
+              refElement -> new RefEntityContainer<CommonProblemDescriptor>(refElement, problems.get(refElement)),
               showStructure,
               node -> merge(node, mergedToolNode, true));
     return mergedToolNode;
               showStructure,
               node -> merge(node, mergedToolNode, true));
     return mergedToolNode;
@@ -116,13 +115,12 @@ public class InspectionRVContentProviderImpl extends InspectionRVContentProvider
   @Override
   protected void appendDescriptor(@NotNull GlobalInspectionContextImpl context,
                                   @NotNull final InspectionToolWrapper toolWrapper,
   @Override
   protected void appendDescriptor(@NotNull GlobalInspectionContextImpl context,
                                   @NotNull final InspectionToolWrapper toolWrapper,
-                                  @NotNull final UserObjectContainer container,
+                                  @NotNull final RefEntityContainer container,
                                   @NotNull final InspectionTreeNode pNode,
                                   final boolean canPackageRepeat) {
                                   @NotNull final InspectionTreeNode pNode,
                                   final boolean canPackageRepeat) {
-    final RefElementContainer refElementDescriptor = (RefElementContainer)container;
-    final RefEntity refElement = refElementDescriptor.getUserObject();
+    final RefEntity refElement = container.getRefEntity();
     InspectionToolPresentation presentation = context.getPresentation(toolWrapper);
     InspectionToolPresentation presentation = context.getPresentation(toolWrapper);
-    final CommonProblemDescriptor[] problems = refElementDescriptor.getProblemDescriptors();
+    final CommonProblemDescriptor[] problems = ((RefEntityContainer<CommonProblemDescriptor>)container).getDescriptors();
     if (problems != null) {
         final RefElementNode elemNode = addNodeToParent(container, presentation, pNode);
         for (CommonProblemDescriptor problem : problems) {
     if (problems != null) {
         final RefElementNode elemNode = addNodeToParent(container, presentation, pNode);
         for (CommonProblemDescriptor problem : problems) {
@@ -144,60 +142,4 @@ public class InspectionRVContentProviderImpl extends InspectionRVContentProvider
       addNodeToParent(container, presentation, pNode);
     }
   }
       addNodeToParent(container, presentation, pNode);
     }
   }
-
-  private static class RefElementContainer implements UserObjectContainer<RefEntity> {
-    @NotNull
-    private final RefEntity myElement;
-    private final CommonProblemDescriptor[] myDescriptors;
-
-    public RefElementContainer(@NotNull RefEntity element, CommonProblemDescriptor[] descriptors) {
-      myElement = element;
-      myDescriptors = descriptors;
-    }
-
-    @Override
-    @Nullable
-    public RefElementContainer getOwner() {
-      final RefEntity entity = myElement.getOwner();
-      if (entity instanceof RefElement && !(entity instanceof RefDirectory)) {
-        return new RefElementContainer(entity, myDescriptors);
-      }
-      return null;
-    }
-
-    @NotNull
-    @Override
-    public RefElementNode createNode(@NotNull InspectionToolPresentation presentation) {
-      return new RefElementNode(myElement, presentation);
-    }
-
-    @Override
-    @NotNull
-    public RefEntity getUserObject() {
-      return myElement;
-    }
-
-    @Override
-    @Nullable
-    public String getModule() {
-      final RefModule refModule = myElement instanceof RefElement
-                                  ? ((RefElement)myElement).getModule()
-                                  : myElement instanceof RefModule ? (RefModule)myElement : null;
-      return refModule != null ? refModule.getName() : null;
-    }
-
-    @Override
-    public boolean areEqual(final RefEntity o1, final RefEntity o2) {
-      return Comparing.equal(o1, o2);
-    }
-
-    @Override
-    public boolean supportStructure() {
-      return myElement instanceof RefElement && !(myElement instanceof RefDirectory); //do not show structure for refModule and refPackage
-    }
-
-    public CommonProblemDescriptor[] getProblemDescriptors() {
-      return myDescriptors;
-    }
-  }
 }
 }
index ec4b7952e8b5c975aa60b4dc3be05c7be173f60a..ccc1944b0cbf7536b57fbd7159b563d35f346f3a 100644 (file)
@@ -25,7 +25,6 @@ import com.intellij.codeInspection.ex.*;
 import com.intellij.codeInspection.offline.OfflineProblemDescriptor;
 import com.intellij.codeInspection.reference.RefElement;
 import com.intellij.codeInspection.reference.RefEntity;
 import com.intellij.codeInspection.offline.OfflineProblemDescriptor;
 import com.intellij.codeInspection.reference.RefElement;
 import com.intellij.codeInspection.reference.RefEntity;
-import com.intellij.codeInspection.reference.SmartRefElementPointer;
 import com.intellij.codeInspection.ui.*;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Comparing;
 import com.intellij.codeInspection.ui.*;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Comparing;
@@ -114,7 +113,17 @@ public class OfflineInspectionRVContentProvider extends InspectionRVContentProvi
     final Map<String, Set<OfflineProblemDescriptor>> filteredContent = getFilteredContent(context, toolWrapper);
     if (filteredContent != null && !filteredContent.values().isEmpty()) {
       parentNode.insertByOrder(toolNode, false);
     final Map<String, Set<OfflineProblemDescriptor>> filteredContent = getFilteredContent(context, toolWrapper);
     if (filteredContent != null && !filteredContent.values().isEmpty()) {
       parentNode.insertByOrder(toolNode, false);
-      buildTree(context, filteredContent, false, toolWrapper, OfflineProblemDescriptorContainer::new, showStructure,
+      buildTree(context, filteredContent, false, toolWrapper, descriptor -> {
+                  final RefEntity element = descriptor.getRefElement(context.getRefManager());
+                  return new RefEntityContainer<OfflineProblemDescriptor>(element, new OfflineProblemDescriptor[] {descriptor}) {
+                    @Nullable
+                    @Override
+                    public String getModule() {
+                      final String module = super.getModule();
+                      return module == null ? descriptor.getModuleName() : module;
+                    }
+                  };
+                }, showStructure,
                 (newChild) -> {
                   toolNode.insertByOrder(newChild, false);
                   return newChild;
                 (newChild) -> {
                   toolNode.insertByOrder(newChild, false);
                   return newChild;
@@ -164,73 +173,16 @@ public class OfflineInspectionRVContentProvider extends InspectionRVContentProvi
   @Override
   protected void appendDescriptor(@NotNull GlobalInspectionContextImpl context,
                                   @NotNull final InspectionToolWrapper toolWrapper,
   @Override
   protected void appendDescriptor(@NotNull GlobalInspectionContextImpl context,
                                   @NotNull final InspectionToolWrapper toolWrapper,
-                                  @NotNull final UserObjectContainer container,
+                                  @NotNull final RefEntityContainer container,
                                   @NotNull final InspectionTreeNode packageNode,
                                   final boolean canPackageRepeat) {
     InspectionToolPresentation presentation = context.getPresentation(toolWrapper);
     final RefElementNode elemNode = addNodeToParent(container, presentation, packageNode);
     if (toolWrapper instanceof LocalInspectionToolWrapper) {
                                   @NotNull final InspectionTreeNode packageNode,
                                   final boolean canPackageRepeat) {
     InspectionToolPresentation presentation = context.getPresentation(toolWrapper);
     final RefElementNode elemNode = addNodeToParent(container, presentation, packageNode);
     if (toolWrapper instanceof LocalInspectionToolWrapper) {
-      final OfflineProblemDescriptorNode child =
-        OfflineProblemDescriptorNode.create(((OfflineProblemDescriptorContainer)container).getUserObject(),
-                                            (LocalInspectionToolWrapper)toolWrapper, presentation);
-      elemNode.insertByOrder(child, true);
-    }
-  }
-
-
-  private static class OfflineProblemDescriptorContainer implements UserObjectContainer<OfflineProblemDescriptor> {
-    @NotNull
-    private final OfflineProblemDescriptor myDescriptor;
-
-    public OfflineProblemDescriptorContainer(@NotNull OfflineProblemDescriptor descriptor) {
-      myDescriptor = descriptor;
-    }
-
-    @Override
-    @Nullable
-    public OfflineProblemDescriptorContainer getOwner() {
-      final OfflineProblemDescriptor descriptor = myDescriptor.getOwner();
-      if (descriptor != null) {
-        final OfflineProblemDescriptorContainer container = new OfflineProblemDescriptorContainer(descriptor);
-        return container.supportStructure() ? container : null;
-      }
-      return null;
-    }
-
-    @NotNull
-    @Override
-    public RefElementNode createNode(@NotNull InspectionToolPresentation presentation) {
-      return new OfflineRefElementNode(myDescriptor, presentation);
-    }
-
-    @Override
-    @NotNull
-    public OfflineProblemDescriptor getUserObject() {
-      return myDescriptor;
-    }
-
-    @Override
-    public String getModule() {
-      return myDescriptor.getModuleName();
-    }
-
-    @Override
-    public boolean areEqual(final OfflineProblemDescriptor o1, final OfflineProblemDescriptor o2) {
-      if (o1 == null || o2 == null) {
-        return o1 == o2;
+      for (OfflineProblemDescriptor descriptor : ((RefEntityContainer<OfflineProblemDescriptor>)container).getDescriptors()) {
+        final OfflineProblemDescriptorNode child = OfflineProblemDescriptorNode.create(descriptor, (LocalInspectionToolWrapper)toolWrapper, presentation);
+        elemNode.insertByOrder(child, true);
       }
       }
-
-      if (!Comparing.strEqual(o1.getFQName(), o2.getFQName())) return false;
-      if (!Comparing.strEqual(o1.getType(), o2.getType())) return false;
-
-      return true;
-    }
-
-    @Override
-    public boolean supportStructure() {
-      return !Comparing.strEqual(myDescriptor.getType(), SmartRefElementPointer.MODULE) &&
-             !Comparing.strEqual(myDescriptor.getType(), "package") &&
-             !Comparing.strEqual(myDescriptor.getType(), SmartRefElementPointer.PROJECT);
     }
   }
 }
     }
   }
 }
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/offlineViewer/OfflineRefElementNode.java b/platform/lang-impl/src/com/intellij/codeInspection/offlineViewer/OfflineRefElementNode.java
deleted file mode 100644 (file)
index e55584b..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2000-2009 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- * User: anna
- * Date: 05-Jan-2007
- */
-package com.intellij.codeInspection.offlineViewer;
-
-import com.intellij.codeInspection.offline.OfflineProblemDescriptor;
-import com.intellij.codeInspection.reference.RefEntity;
-import com.intellij.codeInspection.ui.InspectionToolPresentation;
-import com.intellij.codeInspection.ui.RefElementNode;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-public class OfflineRefElementNode extends RefElementNode {
-  @NotNull
-  private OfflineProblemDescriptor myOfflineDescriptor;
-
-  public OfflineRefElementNode(@NotNull OfflineProblemDescriptor descriptor, @NotNull InspectionToolPresentation presentation) {
-    super(descriptor.getRefElement(presentation.getContext().getRefManager()), presentation);
-    myOfflineDescriptor = descriptor;
-  }
-
-  @Override
-  @Nullable
-  public RefEntity getElement() {
-    return (RefEntity)getUserObject();
-  }
-
-  @NotNull
-  public OfflineProblemDescriptor getOfflineDescriptor() {
-    return myOfflineDescriptor;
-  }
-}
\ No newline at end of file
index 12e2f9f8f40325eb25351c88f47b7940d34cfc3a..b1bd3e5593a23855e33f538d95343439eef55ea0 100644 (file)
@@ -23,7 +23,6 @@ package com.intellij.codeInspection.offlineViewer;
 import com.intellij.codeInspection.InspectionApplication;
 import com.intellij.codeInspection.offline.OfflineProblemDescriptor;
 import com.intellij.codeInspection.reference.SmartRefElementPointerImpl;
 import com.intellij.codeInspection.InspectionApplication;
 import com.intellij.codeInspection.offline.OfflineProblemDescriptor;
 import com.intellij.codeInspection.reference.SmartRefElementPointerImpl;
-import com.intellij.util.ArrayUtil;
 import com.thoughtworks.xstream.io.xml.XppReader;
 import gnu.trove.THashMap;
 import gnu.trove.THashSet;
 import com.thoughtworks.xstream.io.xml.XppReader;
 import gnu.trove.THashMap;
 import gnu.trove.THashSet;
@@ -69,27 +68,6 @@ public class OfflineViewParseUtil {
             int idx = fqName2IdxMap.get(fqName);
             descriptor.setProblemIndex(idx);
             fqName2IdxMap.put(fqName, idx + 1);
             int idx = fqName2IdxMap.get(fqName);
             descriptor.setProblemIndex(idx);
             fqName2IdxMap.put(fqName, idx + 1);
-
-            final List<String> parentTypes = new ArrayList<String>();
-            final List<String> parentNames = new ArrayList<String>();
-            int deep = 0;
-            while (true) {
-              if (reader.hasMoreChildren()) {
-                reader.moveDown();
-                parentTypes.add(reader.getAttribute(SmartRefElementPointerImpl.TYPE_ATTR));
-                parentNames.add(reader.getAttribute(SmartRefElementPointerImpl.FQNAME_ATTR));                
-                deep ++;
-              } else {
-                while (deep-- > 0) {
-                  reader.moveUp();
-                }
-                break;
-              }
-            }
-            if (!parentTypes.isEmpty() && !parentNames.isEmpty()) {
-              descriptor.setParentType(ArrayUtil.toStringArray(parentTypes));
-              descriptor.setParentFQName(ArrayUtil.toStringArray(parentNames));
-            }
           }
           if (DESCRIPTION.equals(reader.getNodeName())) {
             descriptor.setDescription(reader.getValue());
           }
           if (DESCRIPTION.equals(reader.getNodeName())) {
             descriptor.setDescription(reader.getValue());
index 9167d41f83208321e0e9a89f74202fecb7b153c3..06b0efb87738d103a0e15b437402edd129c2bc96 100644 (file)
@@ -27,8 +27,6 @@ package com.intellij.codeInspection.ui;
 import com.intellij.codeInsight.daemon.impl.SeverityRegistrar;
 import com.intellij.codeInspection.CommonProblemDescriptor;
 import com.intellij.codeInspection.ProblemDescriptor;
 import com.intellij.codeInsight.daemon.impl.SeverityRegistrar;
 import com.intellij.codeInspection.CommonProblemDescriptor;
 import com.intellij.codeInspection.ProblemDescriptor;
-import com.intellij.codeInspection.offline.OfflineProblemDescriptor;
-import com.intellij.codeInspection.offlineViewer.OfflineRefElementNode;
 import com.intellij.codeInspection.reference.RefElement;
 import com.intellij.codeInspection.reference.RefEntity;
 import com.intellij.codeInspection.reference.RefFile;
 import com.intellij.codeInspection.reference.RefElement;
 import com.intellij.codeInspection.reference.RefEntity;
 import com.intellij.codeInspection.reference.RefFile;
@@ -88,18 +86,6 @@ public class InspectionResultsViewComparator implements Comparator {
     if (node1 instanceof InspectionPackageNode) return -1;
     if (node2 instanceof InspectionPackageNode) return 1;
 
     if (node1 instanceof InspectionPackageNode) return -1;
     if (node2 instanceof InspectionPackageNode) return 1;
 
-    if (node1 instanceof OfflineRefElementNode && node2 instanceof OfflineRefElementNode) {
-      final Object userObject1 = ((OfflineRefElementNode)node1).getOfflineDescriptor();
-      final Object userObject2 = ((OfflineRefElementNode)node2).getOfflineDescriptor();
-      final OfflineProblemDescriptor descriptor1 = (OfflineProblemDescriptor)userObject1;
-      final OfflineProblemDescriptor descriptor2 = (OfflineProblemDescriptor)userObject2;
-      final int res = descriptor1.getFQName().compareToIgnoreCase(descriptor2.getFQName());
-      if (res != 0) {
-        return res;
-      }
-      return descriptor1.getLine() - descriptor2.getLine();
-    }
-
     if (node1 instanceof RefElementNode && node2 instanceof RefElementNode){   //sort by filename and inside file by start offset
       return compareEntities(((RefElementNode)node1).getElement(), ((RefElementNode)node2).getElement());
     }
     if (node1 instanceof RefElementNode && node2 instanceof RefElementNode){   //sort by filename and inside file by start offset
       return compareEntities(((RefElementNode)node1).getElement(), ((RefElementNode)node2).getElement());
     }
index 6b242dacef18c167257156734d2331aa33dd2de8..951869147ffc098c0e11fb58a9ad815a3edc4054 100644 (file)
@@ -25,7 +25,6 @@ import com.intellij.codeInspection.ex.InspectionProfileImpl;
 import com.intellij.codeInspection.ex.InspectionToolWrapper;
 import com.intellij.codeInspection.reference.RefElement;
 import com.intellij.codeInspection.reference.RefEntity;
 import com.intellij.codeInspection.ex.InspectionToolWrapper;
 import com.intellij.codeInspection.reference.RefElement;
 import com.intellij.codeInspection.reference.RefEntity;
-import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.vcs.FileStatus;
 import com.intellij.psi.PsiElement;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.vcs.FileStatus;
 import com.intellij.psi.PsiElement;
@@ -116,7 +115,7 @@ public class ProblemDescriptionNode extends SuppressableInspectionTreeNode {
   @Override
   protected boolean calculateIsValid() {
     if (myDescriptor == null) return false;
   @Override
   protected boolean calculateIsValid() {
     if (myDescriptor == null) return false;
-    if (myElement instanceof RefElement && !myElement.isValid()) return false;
+    if (myElement == null || myElement instanceof RefElement && !myElement.isValid()) return false;
     if (myDescriptor instanceof ProblemDescriptor) {
       final PsiElement psiElement = ((ProblemDescriptor)myDescriptor).getPsiElement();
       return psiElement != null && psiElement.isValid();
     if (myDescriptor instanceof ProblemDescriptor) {
       final PsiElement psiElement = ((ProblemDescriptor)myDescriptor).getPsiElement();
       return psiElement != null && psiElement.isValid();
index caa0be333848d04d568d58233fb05e7430d1c40e..7aaf3afb58e0b034f6f9e9a6d5d8f5f824eeb5e7 100644 (file)
@@ -215,7 +215,7 @@ inspection.suspicious.collections.method.calls.display.name=Suspicious collectio
 inspection.suspicious.collections.method.calls.problem.descriptor=''{0}'' may not contain objects of type ''{1}''
 inspection.suspicious.collections.method.calls.problem.descriptor1=Suspicious call to ''{0}''
 
 inspection.suspicious.collections.method.calls.problem.descriptor=''{0}'' may not contain objects of type ''{1}''
 inspection.suspicious.collections.method.calls.problem.descriptor1=Suspicious call to ''{0}''
 
-inspection.reference.invalid=invalid
+inspection.reference.invalid=element no longer exists
 inspection.reference.default.package=default package
 inspection.reference.implicit.constructor.name=implicit constructor of {0}
 inspection.reference.noname=noname
 inspection.reference.default.package=default package
 inspection.reference.implicit.constructor.name=implicit constructor of {0}
 inspection.reference.noname=noname