do not check suppressions if inspection language is not applicable

This commit is contained in:
Dmitry Avdeev
2013-07-24 12:34:56 +04:00
parent 670f5c518e
commit a7be42377d
3 changed files with 24 additions and 2 deletions
@@ -19,6 +19,7 @@ import com.intellij.codeHighlighting.HighlightDisplayLevel;
import com.intellij.codeInspection.GlobalInspectionContext;
import com.intellij.codeInspection.InspectionEP;
import com.intellij.codeInspection.InspectionProfileEntry;
import com.intellij.lang.Language;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
@@ -85,6 +86,10 @@ public abstract class InspectionToolWrapper<T extends InspectionProfileEntry, E
return myTool != null;
}
/**
* @see #applyToDialects()
* @see #isApplicable(com.intellij.lang.Language)
*/
@Nullable
public String getLanguage() {
return myEP == null ? null : myEP.language;
@@ -94,6 +99,11 @@ public abstract class InspectionToolWrapper<T extends InspectionProfileEntry, E
return myEP != null && myEP.applyToDialects;
}
public boolean isApplicable(@NotNull Language language) {
String langId = getLanguage();
return langId == null || language.getID().equals(langId) || applyToDialects() && language.isKindOf(langId);
}
@NotNull
public String getShortName() {
return myEP != null ? myEP.getShortName() : getTool().getShortName();
@@ -198,6 +198,15 @@ public abstract class Language extends UserDataHolderBase {
return false;
}
public final boolean isKindOf(String anotherLanguageId) {
Language l = this;
while (l != null) {
if (l.getID().equals(anotherLanguageId)) return true;
l = l.getBaseLanguage();
}
return false;
}
public List<Language> getDialects() {
return myDialects;
}
@@ -729,6 +729,7 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass
List<LocalInspectionToolWrapper> enabled = new ArrayList<LocalInspectionToolWrapper>();
final InspectionToolWrapper[] toolWrappers = profile.getInspectionTools(element);
InspectionProfileWrapper.checkInspectionsDuplicates(toolWrappers);
Language language = myFile.getLanguage();
for (InspectionToolWrapper toolWrapper : toolWrappers) {
if (!profile.isToolEnabled(HighlightDisplayKey.find(toolWrapper.getShortName()), element)) continue;
LocalInspectionToolWrapper wrapper = null;
@@ -736,8 +737,10 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass
wrapper = (LocalInspectionToolWrapper)toolWrapper;
}
if (wrapper == null) continue;
if (myIgnoreSuppressed && InspectionManagerEx.inspectionResultSuppressed(myFile, wrapper.getTool())) {
continue;
if (myIgnoreSuppressed) {
if (wrapper.isApplicable(language) && InspectionManagerEx.inspectionResultSuppressed(myFile, wrapper.getTool())) {
continue;
}
}
enabled.add(wrapper);
}