From 1c0fd1e718dc86eec433dbdab47a0f377b5a32c2 Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Mon, 21 May 2012 15:47:06 +0400 Subject: [PATCH 1/2] typo --- .../codeInspection/ex/GlobalInspectionContextImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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..9d35d08f35f8 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java @@ -142,12 +142,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; } From c57e93644c6e5f06b7c342a12114e4890f57fea8 Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Mon, 21 May 2012 16:26:06 +0400 Subject: [PATCH 2/2] force running "main" tools in global context --- .../InspectionProfileEntry.java | 8 ++++++ .../ex/GlobalInspectionContextImpl.java | 28 ++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) 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 9d35d08f35f8..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; @@ -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,