Thanks Alena for providing the code for modification of the Codan settings. There is one little issue yet for Marco. The
CheckerRegistry works as kind of cache. As far as I can see the settings in updateProfile are only temporary. If you restart CDT or even just create a new project the settings in the CheckerRegistry are lost. That’s ok for the test infrastructure, but does
not work for a persistent workspace. Codan stores the profiles in the preference page. I guess there is no infrastructure to do the from outside, right? So the way to go will be to do it manually with a ScopedPreferenceStrore and the CodanPreferencesLoader,
right?
Regards
Thomas
From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx]
On Behalf Of Alena Laskavaia
Sent: Donnerstag, 16. Juli 2015 15:31
To: CDT General developers list. <cdt-dev@xxxxxxxxxxx>
Subject: 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.
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
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?
_______________________________________________
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
|