Search in sources :

Example 6 with InspectionToolWrapper

use of com.intellij.codeInspection.ex.InspectionToolWrapper in project intellij-plugins by JetBrains.

the class GlobalFlexHighlightingTest method testAvailability.

public void testAvailability() throws Exception {
    boolean foundSyntaxCheckInspection = false;
    boolean foundAnnotatorInspection = false;
    List<InspectionToolWrapper> tools = InspectionToolRegistrar.getInstance().createTools();
    for (InspectionToolWrapper tool : tools) {
        String shortName = tool.getShortName();
        foundAnnotatorInspection |= shortName.equals("Annotator");
        foundSyntaxCheckInspection |= shortName.equals("SyntaxError");
    }
    assertTrue("Should have global syntax inspection provided", foundSyntaxCheckInspection);
    assertTrue("Should have global annotator inspection provided", foundAnnotatorInspection);
}
Also used : InspectionToolWrapper(com.intellij.codeInspection.ex.InspectionToolWrapper)

Example 7 with InspectionToolWrapper

use of com.intellij.codeInspection.ex.InspectionToolWrapper in project intellij-community by JetBrains.

the class EditCleanupProfileIntentionAction method invoke.

@Override
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
    final ProjectInspectionProfileManager profileManager = ProjectInspectionProfileManager.getInstance(project);
    final ProjectInspectionToolsConfigurable configurable = new ProjectInspectionToolsConfigurable(profileManager) {

        @Override
        protected boolean acceptTool(InspectionToolWrapper entry) {
            return super.acceptTool(entry) && entry.isCleanupTool();
        }

        @Override
        public String getDisplayName() {
            return CodeCleanupAction.CODE_CLEANUP_INSPECTIONS_DISPLAY_NAME;
        }
    };
    ShowSettingsUtil.getInstance().editConfigurable(project, configurable);
}
Also used : ProjectInspectionToolsConfigurable(com.intellij.profile.codeInspection.ui.ProjectInspectionToolsConfigurable) ProjectInspectionProfileManager(com.intellij.profile.codeInspection.ProjectInspectionProfileManager) InspectionToolWrapper(com.intellij.codeInspection.ex.InspectionToolWrapper)

Example 8 with InspectionToolWrapper

use of com.intellij.codeInspection.ex.InspectionToolWrapper 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 9 with InspectionToolWrapper

use of com.intellij.codeInspection.ex.InspectionToolWrapper in project intellij-community by JetBrains.

the class ExportHTMLAction method dump2xml.

private void dump2xml(final String outputDirectoryName) {
    try {
        final File outputDir = new File(outputDirectoryName);
        if (!outputDir.exists() && !outputDir.mkdirs()) {
            throw new IOException("Cannot create \'" + outputDir + "\'");
        }
        final InspectionTreeNode root = myView.getTree().getRoot();
        final IOException[] ex = new IOException[1];
        final Set<InspectionToolWrapper> visitedWrappers = new THashSet<>();
        TreeUtil.traverse(root, node -> {
            if (node instanceof InspectionNode) {
                InspectionNode toolNode = (InspectionNode) node;
                Element problems = new Element(PROBLEMS);
                InspectionToolWrapper toolWrapper = toolNode.getToolWrapper();
                if (!visitedWrappers.add(toolWrapper))
                    return true;
                final Set<InspectionToolWrapper> toolWrappers = getWorkedTools(toolNode);
                for (InspectionToolWrapper wrapper : toolWrappers) {
                    InspectionToolPresentation presentation = myView.getGlobalInspectionContext().getPresentation(wrapper);
                    final ExcludedInspectionTreeNodesManager excludedManager = myView.getExcludedManager();
                    if (!toolNode.isExcluded(excludedManager)) {
                        presentation.exportResults(problems, e -> excludedManager.containsRefEntity(e, toolWrapper), excludedManager::containsProblemDescriptor);
                    }
                }
                PathMacroManager.getInstance(myView.getProject()).collapsePaths(problems);
                try {
                    if (problems.getContentSize() != 0) {
                        JDOMUtil.writeDocument(new Document(problems), outputDirectoryName + File.separator + toolWrapper.getShortName() + InspectionApplication.XML_EXTENSION, CodeStyleSettingsManager.getSettings(null).getLineSeparator());
                    }
                } catch (IOException e) {
                    ex[0] = e;
                }
            }
            return true;
        });
        if (ex[0] != null) {
            throw ex[0];
        }
        final Element element = new Element(InspectionApplication.INSPECTIONS_NODE);
        final String profileName = myView.getCurrentProfileName();
        if (profileName != null) {
            element.setAttribute(InspectionApplication.PROFILE, profileName);
        }
        JDOMUtil.write(element, new File(outputDirectoryName, InspectionApplication.DESCRIPTIONS + InspectionApplication.XML_EXTENSION), CodeStyleSettingsManager.getSettings(null).getLineSeparator());
    } catch (IOException e) {
        ApplicationManager.getApplication().invokeLater(() -> Messages.showErrorDialog(myView, e.getMessage()));
    }
}
Also used : Element(org.jdom.Element) IOException(java.io.IOException) Document(org.jdom.Document) THashSet(gnu.trove.THashSet) File(java.io.File) InspectionToolWrapper(com.intellij.codeInspection.ex.InspectionToolWrapper)

Example 10 with InspectionToolWrapper

use of com.intellij.codeInspection.ex.InspectionToolWrapper in project intellij-community by JetBrains.

the class InvokeQuickFixAction method update.

@Override
public void update(AnActionEvent e) {
    final Presentation presentation = e.getPresentation();
    InspectionToolWrapper toolWrapper = myView.getTree().getSelectedToolWrapper(true);
    final InspectionRVContentProvider provider = myView.getProvider();
    if (toolWrapper == null || cantApplyFixes(myView)) {
        presentation.setEnabled(false);
        return;
    }
    presentation.setEnabled(provider.hasQuickFixes(myView.getTree()));
}
Also used : InspectionToolWrapper(com.intellij.codeInspection.ex.InspectionToolWrapper) InspectionRVContentProvider(com.intellij.codeInspection.ex.InspectionRVContentProvider)

Aggregations

InspectionToolWrapper (com.intellij.codeInspection.ex.InspectionToolWrapper)34 NotNull (org.jetbrains.annotations.NotNull)10 InspectionProfile (com.intellij.codeInspection.InspectionProfile)7 LocalInspectionToolWrapper (com.intellij.codeInspection.ex.LocalInspectionToolWrapper)6 File (java.io.File)6 Project (com.intellij.openapi.project.Project)5 InspectionProfileImpl (com.intellij.codeInspection.ex.InspectionProfileImpl)4 HighlightDisplayKey (com.intellij.codeInsight.daemon.HighlightDisplayKey)3 TextRange (com.intellij.openapi.util.TextRange)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 PsiFile (com.intellij.psi.PsiFile)3 Element (org.jdom.Element)3 AnalysisScope (com.intellij.analysis.AnalysisScope)2 HighlightDisplayLevel (com.intellij.codeHighlighting.HighlightDisplayLevel)2 IntentionAction (com.intellij.codeInsight.intention.IntentionAction)2 IntentionManager (com.intellij.codeInsight.intention.IntentionManager)2 IntentionHintComponent (com.intellij.codeInsight.intention.impl.IntentionHintComponent)2 GlobalInspectionToolWrapper (com.intellij.codeInspection.ex.GlobalInspectionToolWrapper)2 InspectionManagerEx (com.intellij.codeInspection.ex.InspectionManagerEx)2 InspectionResultsView (com.intellij.codeInspection.ui.InspectionResultsView)2