InspectionToolWrapper everywhere

This commit is contained in:
Dmitry Avdeev
2012-02-10 12:27:46 +04:00
parent fb2f3d257b
commit 6d024064c5
10 changed files with 123 additions and 92 deletions
@@ -20,9 +20,7 @@ import com.intellij.codeInsight.completion.scope.CompletionElement;
import com.intellij.codeInsight.completion.scope.JavaCompletionProcessor;
import com.intellij.codeInsight.lookup.*;
import com.intellij.codeInspection.InspectionProfile;
import com.intellij.codeInspection.InspectionProfileEntry;
import com.intellij.codeInspection.SuppressionUtil;
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
import com.intellij.codeInspection.javaDoc.JavaDocLocalInspection;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.CaretModel;
@@ -135,8 +133,8 @@ public class JavaDocCompletionContributor extends CompletionContributor {
InspectionProfile inspectionProfile =
InspectionProjectProfileManager.getInstance(position.getProject()).getInspectionProfile();
final InspectionProfileEntry inspectionTool = inspectionProfile.getInspectionTool(JavaDocLocalInspection.SHORT_NAME, position);
JavaDocLocalInspection inspection = (JavaDocLocalInspection)((LocalInspectionToolWrapper)inspectionTool).getTool();
JavaDocLocalInspection inspection =
(JavaDocLocalInspection)inspectionProfile.getUnwrappedTool(JavaDocLocalInspection.SHORT_NAME, position);
final StringTokenizer tokenizer = new StringTokenizer(inspection.myAdditionalJavadocTags, ", ");
while (tokenizer.hasMoreTokens()) {
ret.add(tokenizer.nextToken());
@@ -31,12 +31,9 @@ import com.intellij.codeInsight.intention.EmptyIntentionAction;
import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.codeInsight.intention.IntentionManager;
import com.intellij.codeInspection.InspectionProfile;
import com.intellij.codeInspection.InspectionProfileEntry;
import com.intellij.codeInspection.InspectionsBundle;
import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection;
import com.intellij.codeInspection.ex.GlobalInspectionToolWrapper;
import com.intellij.codeInspection.ex.InspectionManagerEx;
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
import com.intellij.codeInspection.reference.UnusedDeclarationFixProvider;
import com.intellij.codeInspection.unusedImport.UnusedImportLocalInspection;
import com.intellij.codeInspection.unusedParameters.UnusedParametersInspection;
@@ -230,17 +227,14 @@ public class PostHighlightingPass extends TextEditorHighlightingPass {
boolean unusedSymbolEnabled = profile.isToolEnabled(myUnusedSymbolKey, myFile);
HighlightDisplayKey unusedImportKey = HighlightDisplayKey.find(UnusedImportLocalInspection.SHORT_NAME);
boolean unusedImportEnabled = profile.isToolEnabled(unusedImportKey, myFile);
LocalInspectionToolWrapper unusedSymbolTool = (LocalInspectionToolWrapper)profile.getInspectionTool(UnusedSymbolLocalInspection.SHORT_NAME,
myFile);
myUnusedSymbolInspection = unusedSymbolTool == null ? null : (UnusedSymbolLocalInspection)unusedSymbolTool.getTool();
myUnusedSymbolInspection = (UnusedSymbolLocalInspection)profile.getUnwrappedTool(UnusedSymbolLocalInspection.SHORT_NAME, myFile);
LOG.assertTrue(ApplicationManager.getApplication().isUnitTestMode() || myUnusedSymbolInspection != null);
myDeadCodeKey = HighlightDisplayKey.find(UnusedDeclarationInspection.SHORT_NAME);
myDeadCodeInspection = (UnusedDeclarationInspection)profile.getInspectionTool(UnusedDeclarationInspection.SHORT_NAME, myFile);
myDeadCodeInspection = (UnusedDeclarationInspection)profile.getUnwrappedTool(UnusedDeclarationInspection.SHORT_NAME, myFile);
myDeadCodeEnabled = profile.isToolEnabled(myDeadCodeKey, myFile);
final InspectionProfileEntry inspectionTool = profile.getInspectionTool(UnusedParametersInspection.SHORT_NAME, myFile);
myUnusedParametersInspection = inspectionTool != null ? (UnusedParametersInspection)((GlobalInspectionToolWrapper)inspectionTool).getTool() : null;
myUnusedParametersInspection = (UnusedParametersInspection)profile.getUnwrappedTool(UnusedParametersInspection.SHORT_NAME, myFile);
LOG.assertTrue(ApplicationManager.getApplication().isUnitTestMode() || myUnusedParametersInspection != null);
if (unusedImportEnabled && JspPsiUtil.isInJspFile(myFile)) {
final JspFile jspFile = JspPsiUtil.getJspFile(myFile);
@@ -32,9 +32,12 @@ public interface InspectionProfile extends Profile {
HighlightDisplayLevel getErrorLevel(@NotNull HighlightDisplayKey inspectionToolKey, PsiElement element);
InspectionProfileEntry getInspectionTool(@NotNull String shortName, @NotNull PsiElement element);
/** Returns (unwrapped) inspection */
InspectionProfileEntry getUnwrappedTool(@NotNull String shortName, @NotNull PsiElement element);
@Nullable
@Deprecated
InspectionProfileEntry getInspectionTool(@NotNull String shortName);
@@ -29,6 +29,15 @@ public class GlobalInspectionToolWrapper extends InspectionToolWrapper<GlobalIns
super(ep);
}
public GlobalInspectionToolWrapper(InspectionEP ep, GlobalInspectionTool tool) {
super(ep, tool);
}
@Override
public InspectionToolWrapper<GlobalInspectionTool, InspectionEP> createCopy(InspectionToolWrapper<GlobalInspectionTool, InspectionEP> from) {
return new GlobalInspectionToolWrapper(from.myEP, from.myTool);
}
public void initialize(@NotNull GlobalInspectionContextImpl context) {
super.initialize(context);
final RefGraphAnnotator annotator = getTool().getAnnotator(getRefManager());
@@ -297,11 +297,20 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
}
}
@Nullable
public InspectionProfileEntry getInspectionTool(@NotNull String shortName, @NotNull PsiElement element) {
final Tools toolList = getTools(shortName);
return toolList != null ? toolList.getInspectionTool(element) : null;
}
@Nullable
@Override
public InspectionProfileEntry getUnwrappedTool(@NotNull String shortName, @NotNull PsiElement element) {
InspectionProfileEntry tool = getInspectionTool(shortName, element);
return tool instanceof InspectionToolWrapper ? ((InspectionToolWrapper)tool).getTool() : tool;
}
@Nullable
public InspectionProfileEntry getInspectionTool(@NotNull String shortName) {
final ToolsImpl tools = getTools(shortName);
return tools != null? tools.getTool() : null;
@@ -442,7 +451,7 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
myBaseProfile.initInspectionTools(project);
}
final List<InspectionTool> tools;
final List<InspectionToolWrapper> tools;
try {
tools = myRegistrar.createTools();
}
@@ -507,13 +516,13 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
for (ToolsImpl toolList : profile.myTools.values()) {
final ToolsImpl tools = myTools.get(toolList.getShortName());
final ScopeToolState defaultState = toolList.getDefaultState();
tools.setDefaultState(copyToolSettings((InspectionTool)defaultState.getTool()), defaultState.isEnabled(), defaultState.getLevel());
tools.setDefaultState(copyToolSettings((InspectionToolWrapper)defaultState.getTool()), defaultState.isEnabled(), defaultState.getLevel());
tools.removeAllScopes();
tools.setEnabled(toolList.isEnabled());
final List<ScopeToolState> nonDefaultToolStates = toolList.getNonDefaultTools();
if (nonDefaultToolStates != null) {
for (ScopeToolState state : nonDefaultToolStates) {
final InspectionTool inspectionTool = copyToolSettings((InspectionTool)state.getTool());
final InspectionTool inspectionTool = copyToolSettings((InspectionToolWrapper)state.getTool());
final NamedScope scope = project != null ? state.getScope(project) : state.getScope();
if (scope != null) {
tools.addTool(scope, inspectionTool, state.isEnabled(), state.getLevel());
@@ -534,12 +543,12 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
private InspectionTool copyToolSettings(InspectionTool tool)
private InspectionTool copyToolSettings(InspectionToolWrapper tool)
throws WriteExternalException, InvalidDataException {
@NonNls String tempRoot = "config";
Element config = new Element(tempRoot);
tool.writeSettings(config);
final InspectionTool inspectionTool = myRegistrar.createInspectionTool(tool.getShortName(), tool);
final InspectionTool inspectionTool = tool.createCopy(tool);
inspectionTool.readSettings(config);
return inspectionTool;
}
@@ -669,7 +678,7 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
final HighlightDisplayKey key = HighlightDisplayKey.find(entry.getShortName());
try {
getTools(entry.getShortName())
.addTool(scope, copyToolSettings((InspectionTool)entry), inspectionProfile.isToolEnabled(key), inspectionProfile.getErrorLevel(key, (NamedScope)null));
.addTool(scope, copyToolSettings((InspectionToolWrapper)entry), inspectionProfile.isToolEnabled(key), inspectionProfile.getErrorLevel(key, (NamedScope)null));
}
catch (Exception e) {
LOG.error(e);
@@ -18,6 +18,7 @@ package com.intellij.codeInspection.ex;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.intellij.analysis.AnalysisScope;
import com.intellij.codeInspection.*;
import com.intellij.ide.ui.search.SearchableOptionsRegistrar;
import com.intellij.notification.Notification;
@@ -33,7 +34,6 @@ import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.util.Factory;
import com.intellij.profile.codeInspection.ui.InspectionToolsConfigurable;
import com.intellij.util.ArrayUtil;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import gnu.trove.THashSet;
import org.jetbrains.annotations.NonNls;
@@ -53,8 +53,7 @@ import java.util.regex.Pattern;
public class InspectionToolRegistrar {
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.ex.InspectionToolRegistrar");
private final ArrayList<Factory<InspectionTool>> myInspectionToolFactories = new ArrayList<Factory<InspectionTool>>();
private final ArrayList<Function<String, InspectionTool>> myToolsProviders = new ArrayList<Function<String, InspectionTool>>();
private final ArrayList<Factory<InspectionToolWrapper>> myInspectionToolFactories = new ArrayList<Factory<InspectionToolWrapper>>();
private final AtomicBoolean myToolsAreInitialized = new AtomicBoolean(false);
private final AtomicBoolean myInspectionComponentsLoaded = new AtomicBoolean(false);
@@ -76,40 +75,40 @@ public class InspectionToolRegistrar {
ContainerUtil.addAll(providers, Extensions.getExtensions(InspectionToolProvider.EXTENSION_POINT_NAME));
registerTools(providers.toArray(new InspectionToolProvider[providers.size()]));
for (final LocalInspectionEP ep : Extensions.getExtensions(LocalInspectionEP.LOCAL_INSPECTION)) {
myInspectionToolFactories.add(new Factory<InspectionTool>() {
myInspectionToolFactories.add(new Factory<InspectionToolWrapper>() {
@Override
public InspectionTool create() {
public InspectionToolWrapper create() {
return new LocalInspectionToolWrapper(ep);
}
});
}
for (final InspectionEP ep : Extensions.getExtensions(InspectionEP.GLOBAL_INSPECTION)) {
myInspectionToolFactories.add(new Factory<InspectionTool>() {
myInspectionToolFactories.add(new Factory<InspectionToolWrapper>() {
@Override
public InspectionTool create() {
public InspectionToolWrapper create() {
return new GlobalInspectionToolWrapper(ep);
}
});
}
for (final InspectionEP ep : Extensions.getExtensions(SPECIAL_TOOL)) {
myInspectionToolFactories.add(new Factory<InspectionTool>() {
myInspectionToolFactories.add(new Factory<InspectionToolWrapper>() {
@Override
public InspectionTool create() {
return (InspectionTool)ep.instantiateTool();
public InspectionToolWrapper create() {
return new CommonInspectionToolWrapper(ep);
}
});
}
for (InspectionToolsFactory factory : Extensions.getExtensions(InspectionToolsFactory.EXTENSION_POINT_NAME)) {
for (final InspectionProfileEntry profileEntry : factory.createTools()) {
myInspectionToolFactories.add(new Factory<InspectionTool>() {
public InspectionTool create() {
myInspectionToolFactories.add(new Factory<InspectionToolWrapper>() {
public InspectionToolWrapper create() {
if (profileEntry instanceof LocalInspectionTool) {
return new LocalInspectionToolWrapper((LocalInspectionTool)profileEntry);
}
else if (profileEntry instanceof GlobalInspectionTool) {
return new GlobalInspectionToolWrapper((GlobalInspectionTool)profileEntry);
}
return (InspectionTool)profileEntry;
return new CommonInspectionToolWrapper((InspectionTool)profileEntry);
}
});
}
@@ -122,7 +121,7 @@ public class InspectionToolRegistrar {
// System.out.println("***** " + provider.getClass().getName());
Class[] classes = provider.getInspectionClasses();
for (Class aClass : classes) {
Factory<InspectionTool> factory = registerInspectionTool(aClass, true);
Factory<InspectionToolWrapper> factory = registerInspectionTool(aClass, true);
// printExtension(aClass, factory.create());
}
}
@@ -170,83 +169,59 @@ public class InspectionToolRegistrar {
}
*/
private Factory<InspectionTool> registerInspectionTool(final Class aClass, boolean store) {
private Factory<InspectionToolWrapper> registerInspectionTool(final Class aClass, boolean store) {
if (LocalInspectionTool.class.isAssignableFrom(aClass)) {
return registerLocalInspection(aClass, store);
} else if (GlobalInspectionTool.class.isAssignableFrom(aClass)){
return registerGlobalInspection(aClass, store);
} else {
ensureInitialized();
return registerInspectionToolFactory(new Factory<InspectionTool>() {
public InspectionTool create() {
return (InspectionTool)instantiateTool(aClass);
return registerInspectionToolFactory(new Factory<InspectionToolWrapper>() {
public InspectionToolWrapper create() {
return new CommonInspectionToolWrapper((InspectionTool)instantiateTool(aClass));
}
}, store);
}
}
public InspectionTool createInspectionTool(String shortName, final InspectionProfileEntry profileEntry) {
for (Function<String, InspectionTool> toolsProvider : myToolsProviders) {
final InspectionTool inspectionTool = toolsProvider.fun(shortName);
if (inspectionTool != null) return inspectionTool;
}
final Class<? extends InspectionProfileEntry> inspectionToolClass;
if (profileEntry instanceof InspectionToolWrapper) {
inspectionToolClass = ((InspectionToolWrapper)profileEntry).getTool().getClass();
}
else {
inspectionToolClass = profileEntry.getClass();
}
return registerInspectionTool(inspectionToolClass, false).create();
}
public static InspectionToolRegistrar getInstance() {
return ServiceManager.getService(InspectionToolRegistrar.class);
}
public Factory<InspectionTool> registerInspectionToolFactory(Factory<InspectionTool> factory) {
return registerInspectionToolFactory(factory, true);
}
/**
* make sure that it is not too late
*/
public Factory<InspectionTool> registerInspectionToolFactory(Factory<InspectionTool> factory, boolean store) {
public Factory<InspectionToolWrapper> registerInspectionToolFactory(Factory<InspectionToolWrapper> factory, boolean store) {
if (store) {
myInspectionToolFactories.add(factory);
}
return factory;
}
public Function<String, InspectionTool> registerInspectionToolProvider(Function<String, InspectionTool> provider) {
myToolsProviders.add(provider);
return provider;
}
private Factory<InspectionTool> registerLocalInspection(final Class toolClass, boolean store) {
return registerInspectionToolFactory(new Factory<InspectionTool>() {
public InspectionTool create() {
private Factory<InspectionToolWrapper> registerLocalInspection(final Class toolClass, boolean store) {
return registerInspectionToolFactory(new Factory<InspectionToolWrapper>() {
public InspectionToolWrapper create() {
return new LocalInspectionToolWrapper((LocalInspectionTool)instantiateTool(toolClass));
}
}, store);
}
private Factory<InspectionTool> registerGlobalInspection(final Class aClass, boolean store) {
return registerInspectionToolFactory(new Factory<InspectionTool>() {
public InspectionTool create() {
private Factory<InspectionToolWrapper> registerGlobalInspection(final Class aClass, boolean store) {
return registerInspectionToolFactory(new Factory<InspectionToolWrapper>() {
public InspectionToolWrapper create() {
return new GlobalInspectionToolWrapper((GlobalInspectionTool) instantiateTool(aClass));
}
}, store);
}
public List<InspectionTool> createTools() {
public List<InspectionToolWrapper> createTools() {
ensureInitialized();
final List<InspectionTool> tools = Lists.newArrayListWithCapacity(myInspectionToolFactories.size());
final Set<Factory<InspectionTool>> broken = Sets.newHashSet();
for (final Factory<InspectionTool> factory : myInspectionToolFactories) {
final List<InspectionToolWrapper> tools = Lists.newArrayListWithCapacity(myInspectionToolFactories.size());
final Set<Factory<InspectionToolWrapper>> broken = Sets.newHashSet();
for (final Factory<InspectionToolWrapper> factory : myInspectionToolFactories) {
ProgressManager.checkCanceled();
final InspectionTool toolWrapper = factory.create();
final InspectionToolWrapper toolWrapper = factory.create();
if (toolWrapper != null && checkTool(toolWrapper)) {
tools.add(toolWrapper);
}
@@ -259,7 +234,7 @@ public class InspectionToolRegistrar {
return tools;
}
private static Object instantiateTool(Class<?> toolClass) {
static Object instantiateTool(Class<?> toolClass) {
try {
Constructor<?> constructor = toolClass.getDeclaredConstructor(ArrayUtil.EMPTY_CLASS_ARRAY);
constructor.setAccessible(true);
@@ -288,7 +263,7 @@ public class InspectionToolRegistrar {
app.executeOnPooledThread(new Runnable(){
public void run() {
List<InspectionTool> tools = createTools();
List<InspectionToolWrapper> tools = createTools();
for (InspectionTool tool : tools) {
processText(tool.getDisplayName().toLowerCase(), tool);
@@ -341,4 +316,33 @@ public class InspectionToolRegistrar {
});
}
private static class CommonInspectionToolWrapper extends InspectionToolWrapper<InspectionTool, InspectionEP> {
public CommonInspectionToolWrapper(InspectionEP ep) {
super(ep);
}
private CommonInspectionToolWrapper(InspectionTool tool) {
super(tool);
}
private CommonInspectionToolWrapper(InspectionEP ep, InspectionTool tool) {
super(ep, tool);
}
@Override
public CommonInspectionToolWrapper createCopy(InspectionToolWrapper<InspectionTool, InspectionEP> from) {
return new CommonInspectionToolWrapper(from.myEP, from.myTool);
}
@Override
public void runInspection(@NotNull AnalysisScope scope, @NotNull InspectionManager manager) {
getTool().runInspection(scope, manager);
}
@NotNull
@Override
public JobDescriptor[] getJobDescriptors(GlobalInspectionContext globalInspectionContext) {
return getTool().getJobDescriptors(globalInspectionContext);
}
}
}
@@ -27,6 +27,7 @@ import com.intellij.openapi.util.WriteExternalException;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
import javax.swing.*;
import java.net.URL;
@@ -36,22 +37,32 @@ import java.net.URL;
* Date: 9/28/11
*/
public abstract class InspectionToolWrapper<T extends InspectionProfileEntry, E extends InspectionEP> extends DescriptorProviderInspection {
private T myTool;
protected T myTool;
protected final E myEP;
protected InspectionToolWrapper(E ep) {
this(null, ep);
myTool = null;
myEP = ep;
}
protected InspectionToolWrapper(T tool) {
this(tool, null);
myTool = tool;
myEP = null;
}
@TestOnly
protected InspectionToolWrapper(@Nullable T tool, @Nullable E ep) {
myEP = ep;
myTool = tool;
}
protected InspectionToolWrapper(E ep, T tool) {
myEP = ep;
myTool = tool == null ? null : (T)InspectionToolRegistrar.instantiateTool(tool.getClass());
}
public abstract InspectionToolWrapper<T, E> createCopy(InspectionToolWrapper<T, E> from);
@NotNull
public T getTool() {
if (myTool == null) {
@@ -33,6 +33,7 @@ import com.intellij.util.containers.HashSet;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
import javax.swing.tree.DefaultTreeModel;
import java.util.*;
@@ -51,10 +52,20 @@ public final class LocalInspectionToolWrapper extends InspectionToolWrapper<Loca
super(ep);
}
@TestOnly
public LocalInspectionToolWrapper(@Nullable LocalInspectionTool tool, @Nullable LocalInspectionEP ep) {
super(tool, ep);
}
public LocalInspectionToolWrapper(LocalInspectionEP ep, LocalInspectionTool tool) {
super(ep, tool);
}
@Override
public InspectionToolWrapper<LocalInspectionTool, LocalInspectionEP> createCopy(InspectionToolWrapper<LocalInspectionTool, LocalInspectionEP> from) {
return new LocalInspectionToolWrapper(from.myEP, from.myTool);
}
public void processFile(PsiFile file, final boolean filterSuppressed, final InspectionManager manager) {
processFile(file, filterSuppressed, manager, false);
}
@@ -21,7 +21,6 @@
package com.intellij.codeInspection.ex;
import com.intellij.codeHighlighting.HighlightDisplayLevel;
import com.intellij.codeInspection.InspectionProfile;
import com.intellij.codeInspection.InspectionProfileEntry;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Comparing;
@@ -135,7 +134,7 @@ public class ToolsImpl implements Tools {
myDefaultState.getTool().writeSettings(inspectionElement);
}
public void readExternal(Element toolElement, InspectionProfile profile) throws InvalidDataException {
public void readExternal(Element toolElement, InspectionProfileImpl profile) throws InvalidDataException {
final String levelName = toolElement.getAttributeValue(InspectionProfileImpl.LEVEL_TAG);
final ProfileManager profileManager = profile.getProfileManager();
HighlightDisplayLevel level =
@@ -150,7 +149,7 @@ public class ToolsImpl implements Tools {
final String enabledTool = toolElement.getAttributeValue(ENABLED_TAG);
myDefaultState.setEnabled(enabledTool != null ? Boolean.parseBoolean(enabledTool) : isEnabled);
final InspectionProfileEntry tool = myDefaultState.getTool();
final InspectionToolWrapper tool = (InspectionToolWrapper)myDefaultState.getTool();
tool.readSettings(toolElement);
final List children = toolElement.getChildren(InspectionProfileImpl.SCOPE);
if (!children.isEmpty()) {
@@ -165,8 +164,7 @@ public class ToolsImpl implements Tools {
}
final String errorLevel = scopeElement.getAttributeValue(InspectionProfileImpl.LEVEL_TAG);
final String enabledInScope = scopeElement.getAttributeValue(InspectionProfileImpl.ENABLED_TAG);
final InspectionProfileEntry copyTool =
((InspectionProfileImpl)profile).myRegistrar.createInspectionTool(myShortName, tool);
final InspectionProfileEntry copyTool = tool.createCopy(tool);
copyTool.readSettings(scopeElement);
HighlightDisplayLevel scopeLevel = errorLevel != null ?
HighlightDisplayLevel.find(((SeverityProvider)profileManager).getOwnSeverityRegistrar().getSeverity(errorLevel)) : null;
@@ -4,7 +4,6 @@ import com.android.tools.lint.detector.api.Issue;
import com.intellij.codeHighlighting.HighlightDisplayLevel;
import com.intellij.codeInsight.daemon.HighlightDisplayKey;
import com.intellij.codeInspection.InspectionProfile;
import com.intellij.codeInspection.ex.InspectionToolWrapper;
import com.intellij.openapi.util.Pair;
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
import com.intellij.psi.PsiElement;
@@ -43,13 +42,8 @@ class AndroidLintUtil {
return null;
}
final InspectionToolWrapper toolWrapper =
(InspectionToolWrapper)profile.getInspectionTool(inspectionShortName, context);
if (toolWrapper == null) {
return null;
}
final AndroidLintInspectionBase inspection = (AndroidLintInspectionBase)toolWrapper.getTool();
final AndroidLintInspectionBase inspection = (AndroidLintInspectionBase)profile.getUnwrappedTool(inspectionShortName, context);
if (inspection == null) return null;
final HighlightDisplayLevel errorLevel = profile.getErrorLevel(key, context);
return new Pair<AndroidLintInspectionBase, HighlightDisplayLevel>(inspection,
errorLevel != null ? errorLevel : HighlightDisplayLevel.WARNING);