}
};
+ @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;
}
* 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();
}
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());
}