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);
}
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);
}
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();
}
}
}
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()));
}
}
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()));
}
Aggregations