diff --git a/platform/lang-api/src/com/intellij/codeInspection/InspectionProfileEntry.java b/platform/lang-api/src/com/intellij/codeInspection/InspectionProfileEntry.java index 10fa441dedc4..e145a713225b 100644 --- a/platform/lang-api/src/com/intellij/codeInspection/InspectionProfileEntry.java +++ b/platform/lang-api/src/com/intellij/codeInspection/InspectionProfileEntry.java @@ -278,6 +278,14 @@ public abstract class InspectionProfileEntry { return true; } + /** + * @return short name of tool whose results will be used + */ + @Nullable + public String getMainToolId() { + return null; + } + @Nullable public String loadDescription() { final String description = getStaticDescription(); diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java index a81c867b3e40..7a7c661e3dcd 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java @@ -63,6 +63,7 @@ import com.intellij.util.containers.HashMap; import com.intellij.util.ui.UIUtil; import gnu.trove.THashMap; import gnu.trove.THashSet; +import gnu.trove.TObjectHashingStrategy; import org.jdom.Document; import org.jdom.Element; import org.jetbrains.annotations.NonNls; @@ -78,6 +79,17 @@ import java.util.Set; public class GlobalInspectionContextImpl extends UserDataHolderBase implements GlobalInspectionContext { private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.ex.GlobalInspectionContextImpl"); + private static final TObjectHashingStrategy TOOLS_HASHING_STRATEGY = new TObjectHashingStrategy() { + @Override + public int computeHashCode(ToolsImpl object) { + return object.getShortName().hashCode(); + } + + @Override + public boolean equals(ToolsImpl o1, ToolsImpl o2) { + return o1.getShortName().equals(o2.getShortName()); + } + }; private RefManager myRefManager; private final NotNullLazyValue myContentManager; @@ -142,12 +154,12 @@ public class GlobalInspectionContextImpl extends UserDataHolderBase implements G profile = InspectionProfileManager.getInstance().getProfile(managerEx.getCurrentProfile()); if (profile != null) return (InspectionProfile)profile; - final String[] avaliableProfileNames = inspectionProfileManager.getAvailableProfileNames(); - if (avaliableProfileNames == null || avaliableProfileNames.length == 0) { + final String[] availableProfileNames = inspectionProfileManager.getAvailableProfileNames(); + if (availableProfileNames == null || availableProfileNames.length == 0) { //can't be return null; } - profile = inspectionProfileManager.getProfile(avaliableProfileNames[0]); + profile = inspectionProfileManager.getProfile(availableProfileNames[0]); } return (InspectionProfile)profile; } @@ -702,7 +714,21 @@ public class GlobalInspectionContextImpl extends UserDataHolderBase implements G } protected List getUsedTools() { - return ((InspectionProfileImpl)getCurrentProfile()).getAllEnabledInspectionTools(myProject); + InspectionProfileImpl profile = (InspectionProfileImpl)getCurrentProfile(); + List tools = profile.getAllEnabledInspectionTools(myProject); + THashSet set = null; + for (ToolsImpl tool : tools) { + String id = tool.getTool().getMainToolId(); + if (id != null) { + InspectionProfileEntry mainTool = profile.getInspectionTool(id); + LOG.assertTrue(mainTool != null, "Can't find main tool: " + id); + if (set == null) { + set = new THashSet(tools, TOOLS_HASHING_STRATEGY); + } + set.add(new ToolsImpl(mainTool, mainTool.getDefaultLevel(), true)); + } + } + return set == null ? tools : new ArrayList(set); } private void classifyTool(List outGlobalTools,