InspectionDescriptionNotFound inspection is tuned to avoid the dummy inspections

This commit is contained in:
Alexander Kirillin
2012-04-13 15:32:15 +04:00
parent e89a479486
commit b30c2bf87b
4 changed files with 12 additions and 9 deletions
@@ -18,13 +18,13 @@ package com.intellij.codeInspection;
import org.jetbrains.annotations.NotNull;
/**
* This class is for the inspections that are gathered by another inspection,
* This interface is for the inspections that are gathered by another inspection,
* but should be shown under this inspection in the inspections result view.
* This inspection is identified by the problem group, which is stored in the Annotation, HighlightInfo and ProblemDescriptor classes.
*/
public abstract class LocalDummyInspectionTool extends LocalInspectionTool {
public interface DummyInspectionTool {
@NotNull
public abstract String getProblemGroup();
String getProblemGroup();
public abstract boolean shouldBeShownInInspectionProfile();
boolean shouldBeShownInInspectionProfile();
}
@@ -18,8 +18,8 @@ package com.intellij.codeInspection.ex;
import com.intellij.codeHighlighting.HighlightDisplayLevel;
import com.intellij.codeInsight.daemon.HighlightDisplayKey;
import com.intellij.codeInspection.DummyInspectionTool;
import com.intellij.codeInspection.InspectionProfileEntry;
import com.intellij.codeInspection.LocalDummyInspectionTool;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.psi.search.scope.packageSet.NamedScope;
@@ -62,8 +62,8 @@ public class Descriptor {
if (tool instanceof InspectionToolWrapper) {
InspectionProfileEntry inspection = ((InspectionToolWrapper)tool).getTool();
if (inspection instanceof LocalDummyInspectionTool) {
myShouldBeShown = ((LocalDummyInspectionTool)inspection).shouldBeShownInInspectionProfile();
if (inspection instanceof DummyInspectionTool) {
myShouldBeShown = ((DummyInspectionTool)inspection).shouldBeShownInInspectionProfile();
}
}
}
@@ -636,12 +636,12 @@ public class GlobalInspectionContextImpl extends UserDataHolderBase implements G
InspectionToolWrapper toolWrapper = (InspectionToolWrapper)profileEntry;
InspectionProfileEntry inspectionTool = toolWrapper.getTool();
if (inspectionTool instanceof LocalDummyInspectionTool) {
if (inspectionTool instanceof DummyInspectionTool) {
if (toolWrappers == null) {
toolWrappers = new HashMap<String, DescriptorProviderInspection>();
}
toolWrappers.put(((LocalDummyInspectionTool)inspectionTool).getProblemGroup(), toolWrapper);
toolWrappers.put(((DummyInspectionTool)inspectionTool).getProblemGroup(), toolWrapper);
}
}
}
@@ -40,6 +40,7 @@ import java.util.List;
*/
public class InspectionDescriptionNotFoundInspection extends DevKitInspectionBase{
@NonNls static final String INSPECTION_PROFILE_ENTRY = InspectionProfileEntry.class.getName();
@NonNls static final String DUMMY_INSPECTION_TOOL = DummyInspectionTool.class.getName();
@NonNls private static final String INSPECTION_DESCRIPTIONS = "inspectionDescriptions";
@Override
@@ -51,8 +52,10 @@ public class InspectionDescriptionNotFoundInspection extends DevKitInspectionBas
if (nameIdentifier == null || module == null || !PsiUtil.isInstantiatable(aClass)) return null;
final PsiClass base = JavaPsiFacade.getInstance(project).findClass(INSPECTION_PROFILE_ENTRY, GlobalSearchScope.allScope(project));
final PsiClass dummy = JavaPsiFacade.getInstance(project).findClass(DUMMY_INSPECTION_TOOL, GlobalSearchScope.allScope(project));
if (base == null || ! aClass.isInheritor(base, true) || isPathMethodsAreOverridden(aClass)) return null;
if (dummy == null || aClass.isInheritor(dummy, true)) return null;
PsiMethod method = findNearestMethod("getShortName", aClass);
if (method != null && method.getContainingClass().getQualifiedName().equals(INSPECTION_PROFILE_ENTRY)) {