Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] Running external tools with error parsing "org.eclipse.cdt.core.ErrorParser"

Hello everybody,
In my plugins I need to provide the ability to run several external tools on our C++ projects. They all analyze the code and return some information on stdout.

First, I added them all individually as CDT build configurations. That worked fine, the output showed in the console and could be analyzed by a CDT error parser (extension point="org.eclipse.cdt.core.ErrorParser") . But it had a major disadvantage: The .cproject file grew huge, and the list of build configurations became quite cluttered. Logically these tools didn't belong there at all, these are no "builds", no new resources are generated.

So I added a new context menu for projects, from the actions I start the external tools like this (stripped down code):

ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
       ILaunchConfigurationType programType = manager
.getLaunchConfigurationType(IExternalToolConstants.ID_PROGRAM_LAUNCH_CONFIGURATION_TYPE);
       ILaunchConfiguration cfg;
       try {
           cfg = programType.newInstance(null, title);
           ILaunchConfigurationWorkingCopy wc = cfg.getWorkingCopy();
           wc.setAttribute(IExternalToolConstants.ATTR_LOCATION,
                   "${eclipse_home}/wrap/tool.cmd");
           wc.setAttribute(IExternalToolConstants.ATTR_WORKING_DIRECTORY,
                   workingdir);
           wc.setAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, cmd
                   + " " + params);
           cfg = wc.doSave();
           cfg.launch(ILaunchManager.RUN_MODE, null, false, true);
           cfg.delete();
       } catch (CoreException e) {
         ...

This works, but I have no possibility to add an error parser, which is what I need.
Is there a "canonical" way of achieving what I want:
Launching an external tool with some parameters, and feeding the output both to a console view AND to a CDT error parser?
Any hints?
Thanks in advance
 Achim


Back to the top