Merge remote-tracking branch 'origin/master'

This commit is contained in:
Dmitry Jemerov
2012-05-21 15:10:53 +02:00
2 changed files with 38 additions and 4 deletions
@@ -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();
@@ -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<ToolsImpl> TOOLS_HASHING_STRATEGY = new TObjectHashingStrategy<ToolsImpl>() {
@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<ContentManager> 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<ToolsImpl> getUsedTools() {
return ((InspectionProfileImpl)getCurrentProfile()).getAllEnabledInspectionTools(myProject);
InspectionProfileImpl profile = (InspectionProfileImpl)getCurrentProfile();
List<ToolsImpl> tools = profile.getAllEnabledInspectionTools(myProject);
THashSet<ToolsImpl> 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<ToolsImpl>(tools, TOOLS_HASHING_STRATEGY);
}
set.add(new ToolsImpl(mainTool, mainTool.getDefaultLevel(), true));
}
}
return set == null ? tools : new ArrayList<ToolsImpl>(set);
}
private void classifyTool(List<Tools> outGlobalTools,