protected HighlightSeverity getSeverity(@NotNull RefElement element) { final PsiElement psiElement = element.getPointer().getContainingFile(); if (psiElement != null) { final GlobalInspectionContextImpl context = getContext(); final String shortName = getSeverityDelegateName(); final Tools tools = context.getTools().get(shortName); if (tools != null) { for (ScopeToolState state : tools.getTools()) { InspectionToolWrapper toolWrapper = state.getTool(); if (toolWrapper == getToolWrapper()) { return context .getCurrentProfile() .getErrorLevel(HighlightDisplayKey.find(shortName), psiElement) .getSeverity(); } } } final InspectionProfile profile = InspectionProjectProfileManager.getInstance(context.getProject()).getInspectionProfile(); final HighlightDisplayLevel level = profile.getErrorLevel(HighlightDisplayKey.find(shortName), psiElement); return level.getSeverity(); } return null; }
@NotNull @Override public FileStatus getElementStatus(final RefEntity element) { final GlobalInspectionContextImpl context = getContext(); if (!isDisposed() && context.getUIOptions().SHOW_DIFF_WITH_PREVIOUS_RUN) { if (myOldProblemElements != null) { final boolean old = RefUtil.contains(element, myOldProblemElements.keySet()); final boolean current = RefUtil.contains(element, getProblemElements().keySet()); return calcStatus(old, current); } } return FileStatus.NOT_CHANGED; }
private InspectionTool getTool(final RefEntity refEntity) { InspectionTool tool = getTool(); assert tool != null; final GlobalInspectionContextImpl manager = tool.getContext(); if (manager == null) return tool; if (refEntity instanceof RefElement) { PsiElement element = ((RefElement) refEntity).getElement(); if (element == null) return tool; final InspectionProfileWrapper profileWrapper = InspectionProjectProfileManagerImpl.getInstanceImpl(manager.getProject()) .getProfileWrapper(); if (profileWrapper == null) return tool; tool = profileWrapper.getInspectionTool(tool.getShortName(), element); } return tool; }
public FileStatus getProblemStatus(final CommonProblemDescriptor descriptor) { final GlobalInspectionContextImpl context = getContext(); if (context != null && context.getUIOptions().SHOW_DIFF_WITH_PREVIOUS_RUN) { if (myOldProblemElements != null) { final Set<CommonProblemDescriptor> allAvailable = new HashSet<CommonProblemDescriptor>(); for (CommonProblemDescriptor[] descriptors : myOldProblemElements.values()) { if (descriptors != null) { ContainerUtil.addAll(allAvailable, descriptors); } } final boolean old = contains(descriptor, allAvailable); final boolean current = contains(descriptor, getProblemToElements().keySet()); return calcStatus(old, current); } } return FileStatus.NOT_CHANGED; }
public boolean updateView(boolean strict) { if (!strict && !myGlobalInspectionContext.getUIOptions().FILTER_RESOLVED_ITEMS) { myTree.repaint(); return false; } clearTree(); boolean resultsFound = buildTree(); myTree.restoreExpansionAndSelection(); return resultsFound; }
private boolean buildTree() { InspectionProfile profile = myInspectionProfile; boolean isGroupedBySeverity = myGlobalInspectionContext.getUIOptions().GROUP_BY_SEVERITY; myGroups.clear(); final Map<String, Tools> tools = myGlobalInspectionContext.getTools(); boolean resultsFound = false; for (Tools currentTools : tools.values()) { InspectionToolWrapper defaultToolWrapper = currentTools.getDefaultState().getTool(); final HighlightDisplayKey key = HighlightDisplayKey.find(defaultToolWrapper.getShortName()); for (ScopeToolState state : myProvider.getTools(currentTools)) { InspectionToolWrapper toolWrapper = state.getTool(); if (myProvider.checkReportedProblems(myGlobalInspectionContext, toolWrapper)) { addTool( toolWrapper, ((InspectionProfileImpl) profile) .getErrorLevel(key, state.getScope(myProject), myProject), isGroupedBySeverity); resultsFound = true; } } } return resultsFound; }
@NotNull public InspectionNode addTool( @NotNull final InspectionToolWrapper toolWrapper, HighlightDisplayLevel errorLevel, boolean groupedBySeverity) { String groupName = toolWrapper.getGroupDisplayName().isEmpty() ? InspectionProfileEntry.GENERAL_GROUP_NAME : toolWrapper.getGroupDisplayName(); InspectionTreeNode parentNode = getToolParentNode(groupName, errorLevel, groupedBySeverity); InspectionNode toolNode = new InspectionNode(toolWrapper); boolean showStructure = myGlobalInspectionContext.getUIOptions().SHOW_STRUCTURE; myProvider.appendToolNodeContent( myGlobalInspectionContext, toolNode, parentNode, showStructure); InspectionToolPresentation presentation = myGlobalInspectionContext.getPresentation(toolWrapper); toolNode = presentation.createToolNode( myGlobalInspectionContext, toolNode, myProvider, parentNode, showStructure); ((DefaultInspectionToolPresentation) presentation).setToolNode(toolNode); registerActionShortcuts(presentation); return toolNode; }
@Override public boolean hasReportedProblems() { final GlobalInspectionContextImpl context = getContext(); if (!isDisposed() && context.getUIOptions().SHOW_ONLY_DIFF) { for (CommonProblemDescriptor descriptor : getProblemToElements().keySet()) { if (getProblemStatus(descriptor) != FileStatus.NOT_CHANGED) { return true; } } if (myOldProblemElements != null) { for (RefEntity entity : myOldProblemElements.keySet()) { if (getElementStatus(entity) != FileStatus.NOT_CHANGED) { return true; } } } return false; } if (!getProblemElements().isEmpty()) return true; return !isDisposed() && context.getUIOptions().SHOW_DIFF_WITH_PREVIOUS_RUN && myOldProblemElements != null && !myOldProblemElements.isEmpty(); }
private JComponent createLeftActionsToolbar() { final CommonActionsManager actionsManager = CommonActionsManager.getInstance(); DefaultActionGroup group = new DefaultActionGroup(); group.add(new RerunAction(this)); group.add(new CloseAction()); final TreeExpander treeExpander = new TreeExpander() { @Override public void expandAll() { TreeUtil.expandAll(myTree); } @Override public boolean canExpand() { return true; } @Override public void collapseAll() { TreeUtil.collapseAll(myTree, 0); } @Override public boolean canCollapse() { return true; } }; group.add(actionsManager.createExpandAllAction(treeExpander, myTree)); group.add(actionsManager.createCollapseAllAction(treeExpander, myTree)); group.add(actionsManager.createPrevOccurenceAction(getOccurenceNavigator())); group.add(actionsManager.createNextOccurenceAction(getOccurenceNavigator())); group.add(myGlobalInspectionContext.createToggleAutoscrollAction()); group.add(new ExportHTMLAction(this)); group.add(new ContextHelpAction(HELP_ID)); return createToolbar(group); }
private boolean isAutoScrollMode() { String activeToolWindowId = ToolWindowManager.getInstance(myProject).getActiveToolWindowId(); return myGlobalInspectionContext.getUIOptions().AUTOSCROLL_TO_SOURCE && (activeToolWindowId == null || activeToolWindowId.equals(ToolWindowId.INSPECTION)); }
@SuppressWarnings({"NonStaticInitializer"}) private JComponent createRightActionsToolbar() { myIncludeAction = new AnAction(InspectionsBundle.message("inspections.result.view.include.action.text")) { { registerCustomShortcutSet(CommonShortcuts.INSERT, myTree); } @Override public void actionPerformed(AnActionEvent e) { final TreePath[] paths = myTree.getSelectionPaths(); if (paths != null) { for (TreePath path : paths) { ((InspectionTreeNode) path.getLastPathComponent()).amnesty(); } } updateView(false); } @Override public void update(final AnActionEvent e) { final TreePath[] paths = myTree.getSelectionPaths(); e.getPresentation() .setEnabled( paths != null && paths.length > 0 && !myGlobalInspectionContext.getUIOptions().FILTER_RESOLVED_ITEMS); } }; myExcludeAction = new AnAction(InspectionsBundle.message("inspections.result.view.exclude.action.text")) { { registerCustomShortcutSet(CommonShortcuts.getDelete(), myTree); } @Override public void actionPerformed(final AnActionEvent e) { final TreePath[] paths = myTree.getSelectionPaths(); if (paths != null) { for (TreePath path : paths) { ((InspectionTreeNode) path.getLastPathComponent()).ignoreElement(); } } updateView(false); } @Override public void update(final AnActionEvent e) { final TreePath[] path = myTree.getSelectionPaths(); e.getPresentation().setEnabled(path != null && path.length > 0); } }; DefaultActionGroup specialGroup = new DefaultActionGroup(); specialGroup.add(myGlobalInspectionContext.getUIOptions().createGroupBySeverityAction(this)); specialGroup.add(myGlobalInspectionContext.getUIOptions().createGroupByDirectoryAction(this)); specialGroup.add( myGlobalInspectionContext.getUIOptions().createFilterResolvedItemsAction(this)); specialGroup.add( myGlobalInspectionContext.getUIOptions().createShowOutdatedProblemsAction(this)); specialGroup.add(myGlobalInspectionContext.getUIOptions().createShowDiffOnlyAction(this)); specialGroup.add(new EditSettingsAction()); specialGroup.add(new InvokeQuickFixAction(this)); specialGroup.add(new InspectionsOptionsToolbarAction(this)); return createToolbar(specialGroup); }
@Override public void addProblemElement( final RefEntity refElement, boolean filterSuppressed, @NotNull final CommonProblemDescriptor... descriptors) { if (refElement == null) return; if (descriptors.length == 0) return; if (filterSuppressed) { if (!isOutputPathSet() || !(myToolWrapper instanceof LocalInspectionToolWrapper)) { synchronized (lock) { Map<RefEntity, CommonProblemDescriptor[]> problemElements = getProblemElements(); CommonProblemDescriptor[] problems = problemElements.get(refElement); problems = problems == null ? descriptors : mergeDescriptors(problems, descriptors); problemElements.put(refElement, problems); } for (CommonProblemDescriptor description : descriptors) { getProblemToElements().put(description, refElement); collectQuickFixes(description.getFixes(), refElement); } } else { writeOutput(descriptors, refElement); } } else { // just need to collect problems for (CommonProblemDescriptor descriptor : descriptors) { getProblemToElements().put(descriptor, refElement); } } final GlobalInspectionContextImpl context = getContext(); if (myToolWrapper instanceof LocalInspectionToolWrapper) { final InspectionResultsView view = context.getView(); if (view == null || !(refElement instanceof RefElement)) { return; } UIUtil.invokeLaterIfNeeded( new Runnable() { @Override public void run() { if (!isDisposed()) { final InspectionNode toolNode; synchronized (myToolLock) { if (myToolNode == null) { final HighlightSeverity currentSeverity = getSeverity((RefElement) refElement); toolNode = view.addTool( myToolWrapper, HighlightDisplayLevel.find(currentSeverity), context.getUIOptions().GROUP_BY_SEVERITY); } else { toolNode = myToolNode; if (toolNode.isTooBigForOnlineRefresh()) { return; } } } final Map<RefEntity, CommonProblemDescriptor[]> problems = new HashMap<RefEntity, CommonProblemDescriptor[]>(); problems.put(refElement, descriptors); final Map<String, Set<RefEntity>> contents = new HashMap<String, Set<RefEntity>>(); final String groupName = refElement.getRefManager().getGroupName((RefElement) refElement); Set<RefEntity> content = contents.get(groupName); if (content == null) { content = new HashSet<RefEntity>(); contents.put(groupName, content); } content.add(refElement); view.getProvider() .appendToolNodeContent( context, toolNode, (InspectionTreeNode) toolNode.getParent(), context.getUIOptions().SHOW_STRUCTURE, contents, problems, (DefaultTreeModel) view.getTree().getModel()); context.addView(view); } } }); } }
@Override public boolean isOldProblemsIncluded() { final GlobalInspectionContextImpl context = getContext(); return context.getUIOptions().SHOW_DIFF_WITH_PREVIOUS_RUN && getOldContent() != null; }