Search in sources :

Example 1 with InspectionResultsView

use of com.intellij.codeInspection.ui.InspectionResultsView in project intellij-community by JetBrains.

the class EditSettingsAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final InspectionResultsView view = getView(e);
    InspectionProfileImpl inspectionProfile = view.getCurrentProfile();
    if (view.isSingleInspectionRun()) {
        InspectionToolWrapper tool = ObjectUtils.notNull(inspectionProfile.getInspectionTool(ObjectUtils.notNull(inspectionProfile.getSingleTool()), view.getProject()));
        JComponent panel = tool.getTool().createOptionsPanel();
        if (panel != null) {
            final DialogBuilder builder = new DialogBuilder().title(InspectionsBundle.message("inspection.tool.window.inspection.dialog.title", tool.getDisplayName())).centerPanel(panel);
            builder.removeAllActions();
            builder.addOkAction();
            if (view.isRerunAvailable()) {
                builder.addActionDescriptor(new DialogBuilder.DialogActionDescriptor(InspectionsBundle.message("inspection.action.rerun"), 'R') {

                    @Override
                    protected Action createAction(DialogWrapper dialogWrapper) {
                        return new AbstractAction() {

                            @Override
                            public void actionPerformed(ActionEvent e) {
                                view.rerun();
                                dialogWrapper.close(DialogWrapper.OK_EXIT_CODE);
                            }
                        };
                    }
                });
            }
            builder.show();
        } else {
            Messages.showInfoMessage(view.getProject(), InspectionsBundle.message("inspection.tool.window.dialog.no.options", tool.getDisplayName()), InspectionsBundle.message("inspection.tool.window.dialog.title"));
        }
    } else {
        final InspectionToolWrapper toolWrapper = view.getTree().getSelectedToolWrapper(false);
        if (toolWrapper != null) {
            //do not search for dead code entry point tool
            final HighlightDisplayKey key = HighlightDisplayKey.find(toolWrapper.getShortName());
            if (key != null) {
                if (new EditInspectionToolsSettingsAction(key).editToolSettings(view.getProject(), inspectionProfile)) {
                    view.updateCurrentProfile();
                }
                return;
            }
        }
        final String[] path = view.getTree().getSelectedGroupPath();
        if (EditInspectionToolsSettingsAction.editSettings(view.getProject(), inspectionProfile, (c) -> {
            if (path != null) {
                c.selectInspectionGroup(path);
            }
        })) {
            view.updateCurrentProfile();
        }
    }
}
Also used : InspectionProfileImpl(com.intellij.codeInspection.ex.InspectionProfileImpl) EditInspectionToolsSettingsAction(com.intellij.codeInspection.ex.EditInspectionToolsSettingsAction) ActionEvent(java.awt.event.ActionEvent) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) HighlightDisplayKey(com.intellij.codeInsight.daemon.HighlightDisplayKey) InspectionResultsView(com.intellij.codeInspection.ui.InspectionResultsView) DialogWrapper(com.intellij.openapi.ui.DialogWrapper) EditInspectionToolsSettingsAction(com.intellij.codeInspection.ex.EditInspectionToolsSettingsAction) DialogBuilder(com.intellij.openapi.ui.DialogBuilder) InspectionToolWrapper(com.intellij.codeInspection.ex.InspectionToolWrapper)

Example 2 with InspectionResultsView

use of com.intellij.codeInspection.ui.InspectionResultsView in project intellij-community by JetBrains.

the class InspectionViewActionBase method update.

@Override
public final void update(AnActionEvent e) {
    final InspectionResultsView view = getView(e);
    final boolean enabled = view != null && isEnabled(view, e);
    final Presentation presentation = e.getPresentation();
    presentation.setEnabled(enabled);
}
Also used : InspectionResultsView(com.intellij.codeInspection.ui.InspectionResultsView) Presentation(com.intellij.openapi.actionSystem.Presentation)

Example 3 with InspectionResultsView

use of com.intellij.codeInspection.ui.InspectionResultsView in project intellij-community by JetBrains.

the class KeyAwareInspectionViewAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final InspectionResultsView view = getView(e);
    final HighlightDisplayKey key = HighlightDisplayKey.find(view.getTree().getSelectedToolWrapper(true).getShortName());
    actionPerformed(view, key);
}
Also used : HighlightDisplayKey(com.intellij.codeInsight.daemon.HighlightDisplayKey) InspectionResultsView(com.intellij.codeInspection.ui.InspectionResultsView)

Example 4 with InspectionResultsView

use of com.intellij.codeInspection.ui.InspectionResultsView in project intellij-community by JetBrains.

the class SuppressActionWrapper method getChildren.

@Override
@NotNull
public AnAction[] getChildren(@Nullable final AnActionEvent e) {
    final InspectionResultsView view = getView(e);
    if (view == null)
        return AnAction.EMPTY_ARRAY;
    final InspectionToolWrapper wrapper = view.getTree().getSelectedToolWrapper(true);
    if (wrapper == null)
        return AnAction.EMPTY_ARRAY;
    final Set<SuppressIntentionAction> suppressActions = view.getSuppressActions(wrapper);
    if (suppressActions.isEmpty())
        return AnAction.EMPTY_ARRAY;
    final AnAction[] actions = new AnAction[suppressActions.size() + 1];
    int i = 0;
    for (SuppressIntentionAction action : suppressActions) {
        actions[i++] = new SuppressTreeAction(action);
    }
    actions[suppressActions.size()] = Separator.getInstance();
    Arrays.sort(actions, new Comparator<AnAction>() {

        @Override
        public int compare(AnAction a1, AnAction a2) {
            return getWeight(a1) - getWeight(a2);
        }

        public int getWeight(AnAction a) {
            return a instanceof Separator ? 0 : ((SuppressTreeAction) a).isSuppressAll() ? 1 : -1;
        }
    });
    return actions;
}
Also used : SuppressIntentionAction(com.intellij.codeInspection.SuppressIntentionAction) InspectionResultsView(com.intellij.codeInspection.ui.InspectionResultsView) InspectionToolWrapper(com.intellij.codeInspection.ex.InspectionToolWrapper) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with InspectionResultsView

use of com.intellij.codeInspection.ui.InspectionResultsView in project intellij-community by JetBrains.

the class QuickFixAction method actionPerformed.

@Override
public void actionPerformed(final AnActionEvent e) {
    final InspectionResultsView view = getInvoker(e);
    final InspectionTree tree = view.getTree();
    try {
        Ref<CommonProblemDescriptor[]> descriptors = Ref.create();
        Set<VirtualFile> readOnlyFiles = new THashSet<>();
        if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> ReadAction.run(() -> {
            final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
            indicator.setText("Checking problem descriptors...");
            descriptors.set(tree.getSelectedDescriptors(true, readOnlyFiles, false, false));
        }), InspectionsBundle.message("preparing.for.apply.fix"), true, e.getProject())) {
            return;
        }
        if (isProblemDescriptorsAcceptable() && descriptors.get().length > 0) {
            doApplyFix(view.getProject(), descriptors.get(), readOnlyFiles, tree.getContext());
        } else {
            doApplyFix(getSelectedElements(view), view);
        }
    } finally {
        view.setApplyingFix(false);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) InspectionResultsView(com.intellij.codeInspection.ui.InspectionResultsView) THashSet(gnu.trove.THashSet) InspectionTree(com.intellij.codeInspection.ui.InspectionTree)

Aggregations

InspectionResultsView (com.intellij.codeInspection.ui.InspectionResultsView)10 InspectionToolWrapper (com.intellij.codeInspection.ex.InspectionToolWrapper)3 NotNull (org.jetbrains.annotations.NotNull)3 HighlightDisplayKey (com.intellij.codeInsight.daemon.HighlightDisplayKey)2 InspectionTree (com.intellij.codeInspection.ui.InspectionTree)2 AnalysisScope (com.intellij.analysis.AnalysisScope)1 SuppressIntentionAction (com.intellij.codeInspection.SuppressIntentionAction)1 EditInspectionToolsSettingsAction (com.intellij.codeInspection.ex.EditInspectionToolsSettingsAction)1 GlobalInspectionContextImpl (com.intellij.codeInspection.ex.GlobalInspectionContextImpl)1 InspectionManagerEx (com.intellij.codeInspection.ex.InspectionManagerEx)1 InspectionProfileImpl (com.intellij.codeInspection.ex.InspectionProfileImpl)1 QuickFixAction (com.intellij.codeInspection.ex.QuickFixAction)1 OfflineInspectionRVContentProvider (com.intellij.codeInspection.offlineViewer.OfflineInspectionRVContentProvider)1 RefManagerImpl (com.intellij.codeInspection.reference.RefManagerImpl)1 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 Presentation (com.intellij.openapi.actionSystem.Presentation)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 DialogBuilder (com.intellij.openapi.ui.DialogBuilder)1 DialogWrapper (com.intellij.openapi.ui.DialogWrapper)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1