diff options
Diffstat (limited to 'platform/lang-impl/src/com/intellij/codeInspection/actions/GotoInspectionModel.java')
-rw-r--r-- | platform/lang-impl/src/com/intellij/codeInspection/actions/GotoInspectionModel.java | 55 |
1 files changed, 16 insertions, 39 deletions
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/actions/GotoInspectionModel.java b/platform/lang-impl/src/com/intellij/codeInspection/actions/GotoInspectionModel.java index 4c6efc2b7897..ddcce12a9236 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/actions/GotoInspectionModel.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/actions/GotoInspectionModel.java @@ -22,13 +22,11 @@ import com.intellij.codeInspection.ex.ScopeToolState; import com.intellij.ide.IdeBundle; import com.intellij.ide.util.gotoByName.SimpleChooseByNameModel; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.profile.codeInspection.InspectionProfileManager; -import com.intellij.util.ArrayUtil; -import com.intellij.util.containers.MultiMap; import javax.swing.*; import java.util.HashMap; -import java.util.HashSet; import java.util.Map; import java.util.Set; @@ -36,11 +34,10 @@ import java.util.Set; * @author Konstantin Bulenkov */ public class GotoInspectionModel extends SimpleChooseByNameModel { - private final MultiMap<String, InspectionToolWrapper> myToolNames = MultiMap.createSmartList(); - private final Map<String, Set<InspectionToolWrapper>> myGroupNames = new HashMap<String, Set<InspectionToolWrapper>>(); - private final Map<String, InspectionToolWrapper> myToolShortNames = new HashMap<String, InspectionToolWrapper>(); + private static final InspectionToolWrapper[] EMPTY_WRAPPERS_ARRAY = new InspectionToolWrapper[0]; + private final Map<String, InspectionToolWrapper> myToolNames = new HashMap<String, InspectionToolWrapper>(); private final String[] myNames; - private final ListCellRenderer myListCellRenderer = new InspectionListCellRenderer(); + private final InspectionListCellRenderer myListCellRenderer = new InspectionListCellRenderer(); public GotoInspectionModel(Project project) { @@ -48,28 +45,14 @@ public class GotoInspectionModel extends SimpleChooseByNameModel { final InspectionProfileImpl rootProfile = (InspectionProfileImpl)InspectionProfileManager.getInstance().getRootProfile(); for (ScopeToolState state : rootProfile.getAllTools(project)) { InspectionToolWrapper tool = state.getTool(); - InspectionToolWrapper workingTool = tool; - if (tool instanceof LocalInspectionToolWrapper) { - workingTool = LocalInspectionToolWrapper.findTool2RunInBatch(project, null, tool.getShortName()); - if (workingTool == null) { - continue; - } + if (tool instanceof LocalInspectionToolWrapper && ((LocalInspectionToolWrapper)tool).isUnfair()) { + continue; } - myToolNames.putValue(tool.getDisplayName(), workingTool); - final String groupName = tool.getGroupDisplayName(); - Set<InspectionToolWrapper> toolsInGroup = myGroupNames.get(groupName); - if (toolsInGroup == null) { - toolsInGroup = new HashSet<InspectionToolWrapper>(); - myGroupNames.put(groupName, toolsInGroup); - } - toolsInGroup.add(workingTool); - myToolShortNames.put(tool.getShortName(), workingTool); + final String name = tool.getDisplayName() + " " + StringUtil.join(tool.getGroupPath(), " "); + myToolNames.put(name, tool); } - - final Set<String> nameIds = new HashSet<String>(); - nameIds.addAll(myToolNames.keySet()); - nameIds.addAll(myGroupNames.keySet()); - myNames = ArrayUtil.toStringArray(nameIds); + final Set<String> strings = myToolNames.keySet(); + myNames = strings.toArray(new String[strings.size()]); } @Override @@ -83,25 +66,19 @@ public class GotoInspectionModel extends SimpleChooseByNameModel { } @Override - public Object[] getElementsByName(final String id, final String pattern) { - final Set<InspectionToolWrapper> result = new HashSet<InspectionToolWrapper>(); - result.addAll(myToolNames.get(id)); - InspectionToolWrapper e = myToolShortNames.get(id); - if (e != null) { - result.add(e); - } - final Set<InspectionToolWrapper> entries = myGroupNames.get(id); - if (entries != null) { - result.addAll(entries); + public Object[] getElementsByName(final String name, final String pattern) { + final InspectionToolWrapper tool = myToolNames.get(name); + if (tool == null) { + return EMPTY_WRAPPERS_ARRAY; } - return result.toArray(new InspectionToolWrapper[result.size()]); + return new InspectionToolWrapper[] {tool}; } @Override public String getElementName(final Object element) { if (element instanceof InspectionToolWrapper) { InspectionToolWrapper entry = (InspectionToolWrapper)element; - return entry.getDisplayName() + " " + entry.getGroupDisplayName(); + return entry.getDisplayName() + " " + StringUtil.join(entry.getGroupPath(), " "); } return null; } |