use of net.sourceforge.pmd.eclipse.runtime.preferences.IPreferencesManager in project pmd-eclipse-plugin by pmd.
the class PreferencesManagerImplTest method storeAndLoadInactiveRules.
/**
* See bug https://sourceforge.net/p/pmd/bugs/1184/
*
* Inactive rules were not stored / loaded
*/
@Test
public void storeAndLoadInactiveRules() {
String ruleName = "LocalVariableCouldBeFinal";
IPreferencesManager manager = PMDPlugin.getDefault().getPreferencesManager();
IPreferences preferences = manager.loadPreferences();
preferences.isActive(ruleName, false);
manager.storePreferences(preferences);
Assert.assertFalse(preferences.getActiveRuleNames().contains(ruleName));
preferences = manager.reloadPreferences();
Assert.assertFalse(preferences.getActiveRuleNames().contains(ruleName));
}
use of net.sourceforge.pmd.eclipse.runtime.preferences.IPreferencesManager in project pmd-eclipse-plugin by pmd.
the class ProjectPropertiesModelTest method testProjectRuleSet.
/**
* A brand new project should be affected the Plugin ruleset in the global ruleset.
*/
@Test
public void testProjectRuleSet() throws PropertiesException {
final IProjectPropertiesManager mgr = PMDPlugin.getDefault().getPropertiesManager();
final IProjectProperties model = mgr.loadProjectProperties(this.testProject);
final IPreferencesManager pmgr = PMDPlugin.getDefault().getPreferencesManager();
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
PrintStream out = new PrintStream(byteStream);
Assert.assertTrue("A new project is not created with the default plugin ruleset", EclipseUtils.assertRuleSetEquals(model.getProjectRuleSet().getRules(), pmgr.getRuleSet().getRules(), out));
}
use of net.sourceforge.pmd.eclipse.runtime.preferences.IPreferencesManager in project pmd-eclipse-plugin by pmd.
the class ProjectPropertiesModelTest method testProjectRuleSet2.
/**
* When rules are removed from the plugin preferences, these rules should also be removed from the project euh...
* ben en fait non. annulé.
*/
@Test
@Ignore("implementation is not finished - maybe the behavior would even be wrong")
public void testProjectRuleSet2() throws PropertiesException, RuleSetNotFoundException, CoreException {
// First ensure that the plugin initial ruleset is equal to the project
// // ruleset IProjectPropertiesManager
final IProjectPropertiesManager mgr = PMDPlugin.getDefault().getPropertiesManager();
final IProjectProperties model = mgr.loadProjectProperties(this.testProject);
RuleSet projectRuleSet = model.getProjectRuleSet();
Assert.assertEquals("The project ruleset is not equal to the plugin ruleset", this.initialPluginRuleSet.getRules(), projectRuleSet.getRules());
final RuleSetFactory factory = new RuleSetFactory();
// use the best practices ruleset because it should be included in the
// plugin ruleset.
final RuleSet bestPracticesRuleSet = factory.createRuleSet("category/java/bestpractices.xml");
IPreferencesManager pmgr = PMDPlugin.getDefault().getPreferencesManager();
pmgr.setRuleSet(bestPracticesRuleSet);
projectRuleSet = model.getProjectRuleSet();
dumpRuleSet(bestPracticesRuleSet);
dumpRuleSet(projectRuleSet);
Assert.assertEquals("The project ruleset is not equal to the plugin ruleset", bestPracticesRuleSet.getRules(), projectRuleSet.getRules());
}
use of net.sourceforge.pmd.eclipse.runtime.preferences.IPreferencesManager in project pmd-eclipse-plugin by pmd.
the class FilterPreferencesPage method performOk.
/**
* @return boolean
* @see org.eclipse.jface.preference.IPreferencePage#performOk()
*/
@Override
public boolean performOk() {
IPreferencesManager ipMgr = plugin.getPreferencesManager();
RuleSet ruleSet = ipMgr.getRuleSet();
ruleSet = RuleSetUtil.setExcludePatterns(ruleSet, tableFilters(false));
ruleSet = RuleSetUtil.setIncludePatterns(ruleSet, tableFilters(true));
ipMgr.setRuleSet(ruleSet);
Set<FilterHolder> filters = currentCheckedFilters();
preferences.activeExclusionPatterns(patternsIn(filters, false));
preferences.activeInclusionPatterns(patternsIn(filters, true));
preferences.sync();
if (isModified()) {
rebuildProjects();
}
return super.performOk();
}
use of net.sourceforge.pmd.eclipse.runtime.preferences.IPreferencesManager in project pmd-eclipse-plugin by pmd.
the class PriorityDescriptorCache method storeInPreferences.
public void storeInPreferences() {
IPreferencesManager mgr = preferencesManager();
IPreferences prefs = mgr.loadPreferences();
for (Map.Entry<RulePriority, PriorityDescriptor> entry : uiDescriptorsByPriority.entrySet()) {
prefs.setPriorityDescriptor(entry.getKey(), entry.getValue());
}
mgr.storePreferences(prefs);
}
Aggregations