Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Enable/disable Codan checkers programatically for a project

You use preferences for project scope.

This is the code from cdt codan tests that enables checkes (modified by me for your purposes)

    protected void enableProblems(String... ids) {
        IProblemProfile profile = "">        IProblem[] problems = profile.getProblems();
        for (int i = 0; i < problems.length; i++) {
            IProblem p = problems[i];
            boolean enabled = false;
            for (int j = 0; j < ids.length; j++) {
                String pid = ids[j];
                if (p.getId().equals(pid)) {
                    enabled = true;
                    break;
                }
            }
            ((CodanProblem) p).setEnabled(enabled);
        }
        CodanRuntime.getInstance().getCheckersRegistry().updateProfile(project, profile); // then set for the project
    }


On Wed, Jul 15, 2015 at 9:30 AM, Marco Syfrig <marco.syfrig@xxxxxxxxx> wrote:
Thanks but this does not work for my purpose unfortunately. As I understand it the plugin_customization.ini is for workspace preferences and loaded only when starting Eclipse. I need to enable/disable them for a project and without a restart.

I’ve developed a plug-in that adds a new wizard page when creating a C++ project where you can select the C++ version/dialect you want for the project. The plug-in then sets project’s compiler flag property and for the discovery provider (this already works). Now I want to offer the user to also select some other actions like enabling/disabling some Codan checkers that seem useful for the selected C++ version. E.g. that {} should be used for initialization for C++11 and later which is contributed by a plug-in. So I need to change the checker’s status as soon as the project is created without a restart.

On Wed, Jul 15, 2015 at 3:20 PM Derek Morris <dmsubs@xxxxxxxxxxxxx> wrote:
I have done it by using plugin_customization.in and adding lines like this:

org.eclipse.cdt.codan.core/org.eclipse.cdt.codan.checkers.errnoreturn=-Warning

On 15 Jul 2015, at 14:15, Marco Syfrig <marco.syfrig@xxxxxxxxx> wrote:

Hi

I want to enable/disable Codan checkers for a project programmatically. Is there a way to do this besides setting project properties and working with strings?

My current solution is to add a ‚-‘ to e.g. org.eclipse.cdt.codan.internal.checkers.InvalidArguments=Error (new: „-Error“). Is there a better way to do this? I’ve found http://dev.eclipse.org/mhonarc/lists/cdt-dev/msg25727.html but this guy also used the string manipulation and wanted to achieve something else.

It seems like I need a CodanProblem and call setEnabled on it and save it somehow. However there are only two methods in the Codan plug-ins that return a CodanProblem instance and I cannot access them. Does the Codan Framework offer a method to enable/disable a checker for a project by its checker id?

Thanks,
Marco
_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/cdt-dev

_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/cdt-dev

_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/cdt-dev


Back to the top