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 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


Back to the top