WEB-20613 'Run Inspection by name' doesn't found ESLint appcode/146.1275 clion/146.1276 dbe/146.1272 idea/146.1273 phpstorm/146.1274 pycharm/146.1277 pycharm/146.1280 rubymine/146.1278 webstorm/146.1282
authorSergey Simonchik <sergey.simonchik@jetbrains.com>
Thu, 14 Apr 2016 21:31:17 +0000 (00:31 +0300)
committerSergey Simonchik <sergey.simonchik@jetbrains.com>
Thu, 14 Apr 2016 21:31:17 +0000 (00:31 +0300)
platform/analysis-impl/src/com/intellij/codeInspection/ex/LocalInspectionToolWrapper.java
platform/analysis-impl/src/com/intellij/codeInspection/ex/PairedUnfairLocalInspectionTool.java
platform/lang-impl/src/com/intellij/codeInspection/actions/GotoInspectionModel.java

index fe1072db1585f8684f88b084d1101bb953d6b01d..21564c250ab17f8749826b604661a3c981925950 100644 (file)
@@ -93,18 +93,26 @@ public class LocalInspectionToolWrapper extends InspectionToolWrapper<LocalInspe
     }
   };
 
+  @Nullable
   public static InspectionToolWrapper findTool2RunInBatch(@NotNull Project project, @Nullable PsiElement element, @NotNull String name) {
     final InspectionProfile inspectionProfile = InspectionProjectProfileManager.getInstance(project).getInspectionProfile();
     final InspectionToolWrapper toolWrapper = element == null
                                            ? inspectionProfile.getInspectionTool(name, project)
                                            : inspectionProfile.getInspectionTool(name, element);
+    return findTool2RunInBatch(project, element, inspectionProfile, toolWrapper);
+  }
+
+  @Nullable
+  public static InspectionToolWrapper findTool2RunInBatch(@NotNull Project project,
+                                                          @Nullable PsiElement element,
+                                                          @NotNull InspectionProfile inspectionProfile,
+                                                          @Nullable InspectionToolWrapper toolWrapper) {
     if (toolWrapper instanceof LocalInspectionToolWrapper && ((LocalInspectionToolWrapper)toolWrapper).isUnfair()) {
-      final LocalInspectionTool inspectionTool = ((LocalInspectionToolWrapper)toolWrapper).getTool();
+      LocalInspectionTool inspectionTool = ((LocalInspectionToolWrapper)toolWrapper).getTool();
       if (inspectionTool instanceof PairedUnfairLocalInspectionTool) {
-        final String oppositeShortName = ((PairedUnfairLocalInspectionTool)inspectionTool).getInspectionForBatchShortName();
-        return element == null
-                         ? inspectionProfile.getInspectionTool(oppositeShortName, project)
-                         : inspectionProfile.getInspectionTool(oppositeShortName, element);
+        String oppositeShortName = ((PairedUnfairLocalInspectionTool)inspectionTool).getInspectionForBatchShortName();
+        return element == null ? inspectionProfile.getInspectionTool(oppositeShortName, project)
+                               : inspectionProfile.getInspectionTool(oppositeShortName, element);
       }
       return null;
     }
index cead9aeaaa03511dd746fd25c05a87e2a1873777..0509673de8971533b9441ddbf29fdc8bf0b16204 100644 (file)
@@ -22,6 +22,12 @@ import org.jetbrains.annotations.NotNull;
  * Date: 4/17/13
  */
 public interface PairedUnfairLocalInspectionTool extends UnfairLocalInspectionTool {
+  /**
+   * @return {@link com.intellij.codeInspection.LocalInspectionTool#getShortName()} of
+   *         a tool to be run instead of this tool in batch mode.
+   *         The returned value can be a short name of this inspection tool, in this case
+   *         this unfair tool will be run in batch mode.
+   */
   @NotNull
   String getInspectionForBatchShortName();
 }
index 202a3df16717f3863418660461f6218ad8c99e83..34d750955d06987c0e9da156f85e88d4b43b0d58 100644 (file)
@@ -44,12 +44,11 @@ public class GotoInspectionModel extends SimpleChooseByNameModel {
     super(project, IdeBundle.message("prompt.goto.inspection.enter.name"), "goto.inspection.help.id");
     final InspectionProfileImpl rootProfile = (InspectionProfileImpl)InspectionProfileManager.getInstance().getRootProfile();
     for (ScopeToolState state : rootProfile.getAllTools(project)) {
-      InspectionToolWrapper tool = state.getTool();
-      if (tool instanceof LocalInspectionToolWrapper && ((LocalInspectionToolWrapper)tool).isUnfair()) {
-        continue;
+      InspectionToolWrapper tool = LocalInspectionToolWrapper.findTool2RunInBatch(project, null, rootProfile, state.getTool());
+      if (tool != null) {
+        String name = tool.getDisplayName() + " " + StringUtil.join(tool.getGroupPath(), " ");
+        myToolNames.put(name, tool);
       }
-      final String name = tool.getDisplayName() + " " + StringUtil.join(tool.getGroupPath(), " ");
-      myToolNames.put(name, tool);
     }
     myNames = ArrayUtil.toStringArray(myToolNames.keySet());
   }