Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » disabling cdt code analysis programmatically(disabling cdt code analysis programmatically)
disabling cdt code analysis programmatically [message #916889] Wed, 19 September 2012 15:51 Go to next message
tony burton is currently offline tony burtonFriend
Messages: 26
Registered: April 2012
Location: France
Junior Member
Hi,
I would like to disable cdt code analysis programmatically and, after lots of research and stepping through code, I have found the following:

           CodanPreferencesLoader codanPreferencesLoader = new
                      CodanPreferencesLoader(CodanRuntime.getInstance().
                      getCheckersRegistry().getDefaultProfile());
		
		IProblem[] probs = codanPreferencesLoader.getProblems();
		for (int i = 0; i < probs.length; i++) {
			String id = probs[i].getId();
			((IProblemWorkingCopy) probs[i]).setEnabled(false);
		}


which seems to work, but when I open the preference page, the values are unchanged.

Could someone please point me in the right direction,

Thanks in advance,

Antony
Re: disabling cdt code analysis programmatically [message #917942 is a reply to message #916889] Thu, 20 September 2012 15:25 Go to previous messageGo to next message
tony burton is currently offline tony burtonFriend
Messages: 26
Registered: April 2012
Location: France
Junior Member
OK, I've realized I was barking up the wrong treeEditor! Now I think I should be doing something like this:

// enable auto save...
IPreferenceStore iwp = 	IDEWorkbenchPlugin.getDefault().getPreferenceStore();
boolean val4 = iwp.getBoolean("SAVE_ALL_BEFORE_BUILD");
iwp.putValue("SAVE_ALL_BEFORE_BUILD", "true");


...which works well for this preference. I found the "SAVE_ALL_BEFORE_BUILD" by steping through the code. In the method get of the class ImmutableMap in org.eclipse.core.internal.preferences, there is an array called keyTable with strings corresponding to the various preferences of the preferenceStore concerned.

But I am unable to find the boolean value of preferences for the code analysis page. I would ideally like to find the id to the boolean which switches off all of the problem checkers (Potential Programming Problems) but search as I might, I cannot.

In the CodanCorePlugin keyTable I can find the individual problem checkers such as "Assignment To Itself" but when I do:

IEclipsePreferences codanp = CodanCorePlugin.getDefault().getStorePreferences();
String val3 = codanp.get("org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem", "");


...it returns the property for this checker (info, error or warning). What is the id for the enable button?

So now I'm getting a little stuck and any help would be greatly appreciated!

Thanks,

Antony
Re: disabling cdt code analysis programmatically [message #929388 is a reply to message #917942] Mon, 01 October 2012 12:15 Go to previous messageGo to next message
tony burton is currently offline tony burtonFriend
Messages: 26
Registered: April 2012
Location: France
Junior Member
It's been almost 2 weeks now since I posted this question. Could someone please give me a pointer, even if it's a link to somewhere I can get an answer,

Thanks,

Antony
Re: disabling cdt code analysis programmatically [message #929890 is a reply to message #929388] Mon, 01 October 2012 21:31 Go to previous messageGo to next message
Yevgeny Shifrin is currently offline Yevgeny ShifrinFriend
Messages: 208
Registered: July 2009
Senior Member
Hi,

I would suggest posting your question on CDT mailing list (https://dev.eclipse.org/mailman/listinfo/cdt-dev). This forum is more for CDT users, CDT mailing list is for CDT developers.

Thanks,
Yevgeny
Re: disabling cdt code analysis programmatically [message #930353 is a reply to message #929890] Tue, 02 October 2012 08:30 Go to previous messageGo to next message
tony burton is currently offline tony burtonFriend
Messages: 26
Registered: April 2012
Location: France
Junior Member
Hi Yevgeny,
Thanks for the info!

Antony
Re: disabling cdt code analysis programmatically [message #1012530 is a reply to message #930353] Thu, 21 February 2013 18:34 Go to previous messageGo to next message
NINGAREDDY MODASE is currently offline NINGAREDDY MODASEFriend
Messages: 2
Registered: February 2013
Junior Member
There is way we can enable/disable cdt code analysis settings programmatically


I have used it and it works fine for me.

E.g.

IEclipsePreferences codanp = CodanCorePlugin.getDefault() .getStorePreferences();
codanp.put("org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem","-Error"); // To disable we have to pass -Error
// To enable we have to pass Error

I have attached the file which contains preferances id'd and their default values

Note: You have to add the dependency 'org.eclipse.cdt.codan.core' in your plugin for controlling preferances settings...

Hope this will help..
Re: disabling cdt code analysis programmatically [message #1012532 is a reply to message #917942] Thu, 21 February 2013 18:39 Go to previous messageGo to next message
NINGAREDDY MODASE is currently offline NINGAREDDY MODASEFriend
Messages: 2
Registered: February 2013
Junior Member

Please see the following link. I have replied it.

http://www.eclipse.org/forums/index.php/r/reply_to/930353/


IEclipsePreferences codanp = CodanCorePlugin.getDefault() .getStorePreferences();
codanp.put("org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem","-Error"); // To disable we have to pass -Error
// To enable we have to pass Error
Re: disabling cdt code analysis programmatically [message #1012922 is a reply to message #930353] Fri, 22 February 2013 13:13 Go to previous messageGo to next message
tony burton is currently offline tony burtonFriend
Messages: 26
Registered: April 2012
Location: France
Junior Member
Thank you so much NINGAREDDY! I had found a temporary solution which was to set all problem checkers to 'INFO':

// no code analysis (for the time being I am changing all the problem properties to info (no errors or warnings)...
String[] keys = null;
IEclipsePreferences codanp = CodanCorePlugin.getDefault().getStorePreferences();
try {
  keys = codanp.keys();
} catch (org.osgi.service.prefs.BackingStoreException e) {
  e.printStackTrace();
}
			
for (int i=0; i<keys.length; i++) {
 if (!keys[i].contains("params"))
	codanp.put(keys[i], "Info");
}


But I never found that I should put '-' in front to deselect them,

Thanks again,

Antony
Re: disabling cdt code analysis programmatically [message #1012988 is a reply to message #1012922] Fri, 22 February 2013 15:17 Go to previous messageGo to next message
tony burton is currently offline tony burtonFriend
Messages: 26
Registered: April 2012
Location: France
Junior Member
...just another thing that could be of help. In order to disable the problem checkers but keep their default values (Error, Warning or Info), one can do as follows:

IEclipsePreferences codanp = CodanCorePlugin.getDefault().getStorePreferences();
String[] keys = null;

keys = codanp.keys();

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);
	}
}
Re: disabling cdt code analysis programmatically [message #1032816 is a reply to message #1012532] Wed, 03 April 2013 13:19 Go to previous message
tony burton is currently offline tony burtonFriend
Messages: 26
Registered: April 2012
Location: France
Junior Member
Hi again!

I have a new problem, up until now, disabling code analysis worked fine, but when I tried using it in a fresh workspace, it didn't work anymore. In order for it to work, one must go into code analysis preferences and press the "Apply" button. So it seems something must be initialized. Have you or anyone any ideas please,

Thanks,

Antony
Previous Topic:Jni application error Javaw.exe -Application error?
Next Topic:CDT Disassembly View
Goto Forum:
  


Current Time: Sat Apr 20 10:02:33 GMT 2024

Powered by FUDForum. Page generated in 0.03948 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top