Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Problem Enabling/Disabling Codan checkers programmatically (Bug?)

Hi Martin,
 Thanks for your reply. I tried your idea but it doesn't work for me. What I did was to create a plugin_customization.ini file with the command:

org.eclipse.ui.workbench/PLUGINS_NOT_ACTIVATED_ON_STARTUP=org.eclipse.cdt.codan.ui;

...and then add:

 -pluginCustomization plugin_customization.ini

to the eclipse.ini file. I must be doing something wrong. Could you please explain in detail?

After all though,  I would prefer to do it programmatically as I do because I would like more control over enabling/disabling problem checkers either individually or globally. Note that the first part of my method disables all problem checkers whilst keeping all default severities. So it would be easy to turn CODAN on and off whilst using default values. We could easily go further and also save current enable/severity settings so that CODAN could be switched on or off with one switch conserving current settings. This would fulfil your initial request in:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=374749

The only problem is that when entering a new workspace, before CODAN preferences can be set programmatically, it is necessary to go into:

Windows -> C/C++ -> Code Analysis

and click on the "Apply" or "Ok" button at least one time.

Is there no way get around this? A way of doing what the "Apply" or "Ok" buttons do programmatically?

Thanks again,

Antony


On 05/04/2013 14:38, Oberhuber, Martin wrote:

Hi Anthony,

 

Instead of enabling/disabling each checker separately, what we have done in our product is disable the "autostart" of Codan as a whole:

 

                Preferences > General > Startup : Plugins not enabled on startup : CODAN

 

We do it by putting this into our plugin_customization.ini :

 

org.eclipse.ui.workbench/PLUGINS_NOT_ACTIVATED_ON_STARTUP=org.eclipse.equinox.p2.ui.sdk.scheduler;org.eclipse.update.scheduler; org.eclipse.cdt.scripting;org.eclipse.dltk.ui;org.eclipse.php.debug.daemon;org.eclipse.cdt.codan.ui.cxx;org.tigris.subversion.subclipse.tools.usage;

 

This works nicely in NEW workspaces; the only problem is that if user has an EXISTING workspace where the respective PLUGINS_NOT_ACTIVATED_ON_STARTUP has been set in the workspace preferences while Codan was not yet installed (in an earlier release), the new plugin_customization.ini is not picked up.

 

https://bugs.eclipse.org/bugs/show_bug.cgi?id=374749

 

Another disadvantage is that once user does Right-click > Validate on a project, CODAN is enabled (and remains enabled). But since that is an explicit request to turn on validation, it could also be seen as an advantage. Another advantage of our approach is that IF a user DOES want to use codan, it is a single switch to change and not all of them.

 

The best solution would be fixing the bug mentioned above, ie introducing a global CODAN on/off switch in addition to all the individual checker switches.

Implementing this shouldn't be rocket science...

Contributions welcome :)

 

Thanks,

Martin

--

Martin Oberhuber, SMTS / Product Architect – Development Tools, Wind River

direct +43.662.457915.85  fax +43.662.457915.6

 

-----Original Message-----
From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Antony Burton
Sent: Wednesday, April 03, 2013 5:32 PM
To: CDT General developers list.
Subject: [cdt-dev] Problem Enabling/Disabling Codan checkers programmatically (Bug?)

 

Hi,

   We are working on a plugin which creates a  C project for ARM processors and would like to avoid users having to delve into preferences. So we have used the following code to modify default code analysis preferences:

 

/************** enable/disable code analysis checkers that we need or don't need... ****************************************/

 

             IEclipsePreferences codanp = CodanCorePlugin.getDefault().getStorePreferences();

             // get pproblem checker keys

             String[] keys = null;

             try {

                 keys = codanp.keys();

             } catch (org.osgi.service.prefs.BackingStoreException e) {

                 // TODO Auto-generated catch block

                 e.printStackTrace();

             }

 

             // first disable all problem checkers...

             for (int i=0; i<keys.length; i++) {

                 String res = codanp.get(keys[i], "");

                 if (!res.substring(0,1).equals("-")) {

                     res = "-"+res;

                 }

                 if (res.equals("-Error") || res.equals("-Warning") ||

res.equals("-Info")) {

                         codanp.put(keys[i], res);

                 }

             }

 

             // now enable the checkers we need with either warning or error...

 

codanp.put("org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem",

"Warning");

             codanp.put("org.eclipse.cdt.codan.checkers.noreturn", "Error");

             codanp.put("org.eclipse.cdt.codan.checkers.errnoreturn",

"Error");

codanp.put("org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem",

"Warning");

codanp.put("org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem",

"Warning");

codanp.put("org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem",

"Warning");

             //...

**************************************************************************************************************************************/

 

This worked fine up until I tried it in a fresh workspace, in which case the instruction:

 

IEclipsePreferences codanp =

CodanCorePlugin.getDefault().getStorePreferences();

 

returns a value which provides no keys.

 

In order to get it to work I must go into code analysis preferences and click on the "Apply" or "Ok" button.

 

Is this a bug or have I forgotten something? Is there a work around to get it to work in a new workspace?

 

Thanks in advance,

 

Regards,

 

Antony

_______________________________________________

cdt-dev mailing list

cdt-dev@xxxxxxxxxxx

https://dev.eclipse.org/mailman/listinfo/cdt-dev



_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev


Back to the top