running test inspections by language + inspection language fixes
authorDmitry Avdeev <Dmitry.Avdeev@jetbrains.com>
Wed, 28 Dec 2011 12:58:55 +0000 (16:58 +0400)
committerDmitry Avdeev <Dmitry.Avdeev@jetbrains.com>
Wed, 28 Dec 2011 13:43:10 +0000 (17:43 +0400)
platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionToolWrapper.java
platform/lang-impl/src/com/intellij/codeInspection/ex/LocalInspectionToolWrapper.java
platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java
resources/src/META-INF/IdeaPlugin.xml

index 4123e2f6736b6b316609f5dac419eba4c93adcfb..2a9609e47a9a4752ec26a1dc9ba1e07b8594d80d 100644 (file)
@@ -40,12 +40,16 @@ public abstract class InspectionToolWrapper<T extends InspectionProfileEntry, E
   protected final E myEP;
 
   protected InspectionToolWrapper(E ep) {
-    myEP = ep;
+    this(null, ep);
   }
 
   protected InspectionToolWrapper(T tool) {
+    this(tool, null);
+  }
+
+  protected InspectionToolWrapper(@Nullable T tool, @Nullable E ep) {
+    myEP = ep;
     myTool = tool;
-    myEP = null;
   }
 
   @NotNull
index 2910606bbda7689657d888c76a12f5ad1b9dec50..df2853233e7b4c8b235e889b0fe7d4c597a2a5bb 100644 (file)
@@ -51,6 +51,10 @@ public final class LocalInspectionToolWrapper extends InspectionToolWrapper<Loca
     super(ep);
   }
 
+  public LocalInspectionToolWrapper(@Nullable LocalInspectionTool tool, @Nullable LocalInspectionEP ep) {
+    super(tool, ep);
+  }
+
   public void processFile(PsiFile file, final boolean filterSuppressed, final InspectionManager manager) {
     processFile(file, filterSuppressed, manager, false);
   }
index 10dc319a7e465e9d7e7a1df9fce563843ac1d863..f30c4362fd6b243a3e84d957bb9dfee1f0309b1a 100644 (file)
@@ -68,6 +68,7 @@ import com.intellij.openapi.editor.markup.GutterIconRenderer;
 import com.intellij.openapi.editor.markup.RangeHighlighter;
 import com.intellij.openapi.extensions.ExtensionPoint;
 import com.intellij.openapi.extensions.ExtensionPointName;
+import com.intellij.openapi.extensions.Extensions;
 import com.intellij.openapi.extensions.ExtensionsArea;
 import com.intellij.openapi.fileEditor.*;
 import com.intellij.openapi.fileEditor.impl.text.TextEditorProvider;
@@ -152,6 +153,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
   @NonNls private static final String XXX = "XXX";
   private final FileTreeAccessFilter myJavaFilesFilter = new FileTreeAccessFilter();
   private boolean myAllowDirt;
+  private final Map<String, LocalInspectionEP> myExtensions = new HashMap<String, LocalInspectionEP>();
 
   public CodeInsightTestFixtureImpl(IdeaProjectTestFixture projectFixture, TempDirTestFixture tempDirTestFixture) {
     myProjectFixture = projectFixture;
@@ -1024,6 +1026,10 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
     DaemonCodeAnalyzerSettings.getInstance().setImportHintEnabled(false);
     ensureIndexesUpToDate(getProject());
     ((StartupManagerImpl)StartupManagerEx.getInstanceEx(getProject())).runPostStartupActivities();
+    LocalInspectionEP[] extensions = Extensions.getExtensions(LocalInspectionEP.LOCAL_INSPECTION);
+    for (LocalInspectionEP extension : extensions) {
+      myExtensions.put(extension.shortName, extension);
+    }
   }
 
   @Override
@@ -1057,9 +1063,15 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
       HighlightDisplayKey.register(shortName, tool.getDisplayName(), id);
     }
     myAvailableTools.put(shortName, tool);
-    myAvailableLocalTools.put(shortName, tool instanceof LocalInspectionTool ?
-                                         new LocalInspectionToolWrapper((LocalInspectionTool)tool) :
-                                         (InspectionTool)tool);
+    InspectionTool inspectionTool;
+    if (tool instanceof LocalInspectionTool) {
+      LocalInspectionEP ep = myExtensions.get(tool.getShortName());
+      inspectionTool = new LocalInspectionToolWrapper((LocalInspectionTool)tool, ep);
+    }
+    else {
+      inspectionTool = (InspectionTool)tool;
+    }
+    myAvailableLocalTools.put(shortName, inspectionTool);
   }
 
   private void configureInspections(final InspectionProfileEntry[] tools) {
index cb291100c94c14979b7395cfb6e91d553a53091d..67cf4dc7faa9bc6fb6c7da896c8b1f7b885558b9 100644 (file)
     <localInspection language="JAVA" suppressId="deprecation" shortName="Deprecation" displayName="Deprecated API usage" groupName=""
                      enabledByDefault="true" level="WARNING"
                      implementationClass="com.intellij.codeInspection.deprecation.DeprecationInspection"/>
-    <localInspection language="JAVA" shortName="DeprecatedClassUsageInspection" displayName="Deprecated API usage in XML" groupName="XML"
+    <localInspection language="XML" shortName="DeprecatedClassUsageInspection" displayName="Deprecated API usage in XML" groupName="XML"
                      enabledByDefault="true" level="WARNING" implementationClass="com.intellij.util.xml.DeprecatedClassUsageInspection"/>
     <localInspection language="JAVA" shortName="EqualsAndHashcode" bundle="messages.InspectionsBundle" key="inspection.equals.hashcode.display.name"
                      groupName="" enabledByDefault="false" level="WARNING"