WEB-20613 'Run Inspection by name' doesn't found ESLint

This commit is contained in:
Sergey Simonchik
2016-04-15 00:31:17 +03:00
parent d410cbe871
commit 9b23fd9c69
3 changed files with 23 additions and 10 deletions
@@ -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;
}
@@ -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();
}
@@ -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());
}