Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] disabling/enabling cdt code analysis programmatically

Hi,
I hope I'm writing to the right place for an answer to this - I already posted it on the cdt forum but, after getting no answer for 2 weeks, I asked and someone suggested I post here.

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.

After more searching I realized I was probably barking up the wrong treeEditor :-) and tried 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 stepping 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) or to each problem checker, 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 in advance and sorry if I'm on the wrong mailing list,

Antony




Back to the top