Search in sources :

Example 6 with RuleSetModel

use of ch.acanda.eclipse.pmd.domain.RuleSetModel in project eclipse-pmd by acanda.

the class PMDPropertyPageController method init.

public void init(final IProject project) {
    this.project = project;
    final WorkspaceModel workspaceModel = PMDPlugin.getDefault().getWorkspaceModel();
    projectModel = workspaceModel.getOrCreateProject(project.getName());
    model.setInitialState(projectModel.isPMDEnabled(), projectModel.getRuleSets(), project);
    final ImmutableSortedSet.Builder<RuleSetModel> ruleSetBuilder = ImmutableSortedSet.orderedBy(ProjectModel.RULE_SET_COMPARATOR);
    for (final ProjectModel projectModel : workspaceModel.getProjects()) {
        ruleSetBuilder.addAll(projectModel.getRuleSets());
    }
    model.setRuleSets(ImmutableList.copyOf(toViewModels(ruleSetBuilder.build(), project)));
    reset();
}
Also used : WorkspaceModel(ch.acanda.eclipse.pmd.domain.WorkspaceModel) RuleSetModel(ch.acanda.eclipse.pmd.domain.RuleSetModel) ImmutableSortedSet(com.google.common.collect.ImmutableSortedSet) ProjectModel(ch.acanda.eclipse.pmd.domain.ProjectModel)

Example 7 with RuleSetModel

use of ch.acanda.eclipse.pmd.domain.RuleSetModel in project eclipse-pmd by acanda.

the class ProjectConfigurationContentHandler method createRuleSet.

private RuleSetModel createRuleSet(final Attributes attributes) {
    final LocationContext context = getContext(attributes.getValue(ATTRIBUTE_NAME_REFCONTEXT));
    final Location location = new Location(attributes.getValue(ATTRIBUTE_NAME_REF), context);
    return new RuleSetModel(attributes.getValue(ATTRIBUTE_NAME_NAME), location);
}
Also used : RuleSetModel(ch.acanda.eclipse.pmd.domain.RuleSetModel) LocationContext(ch.acanda.eclipse.pmd.domain.LocationContext) Location(ch.acanda.eclipse.pmd.domain.Location)

Example 8 with RuleSetModel

use of ch.acanda.eclipse.pmd.domain.RuleSetModel in project eclipse-pmd by acanda.

the class ProjectModelSerializerTest method assertRuleSetModel.

private void assertRuleSetModel(final ProjectModel projectModel, final LocationContext context, final String name, final String path) {
    final RuleSetModel remoteRuleSet = extractRuleSetModel(projectModel, context);
    assertEquals("Name of the " + context + " rule set", name, remoteRuleSet.getName());
    assertEquals("Path of the " + context + " rule set", path, remoteRuleSet.getLocation().getPath());
}
Also used : RuleSetModel(ch.acanda.eclipse.pmd.domain.RuleSetModel)

Example 9 with RuleSetModel

use of ch.acanda.eclipse.pmd.domain.RuleSetModel in project eclipse-pmd by acanda.

the class RuleSetsCacheTest method secondGetLoadsWhenProjectRuleSetsWereChanged.

/**
 * Verifies that the second cache access loads the rule sets if the project model's rule sets have been changed
 * after the first access.
 */
@Test
public void secondGetLoadsWhenProjectRuleSetsWereChanged() throws Exception {
    final WorkspaceModel workspaceModel = getWorkspaceModel();
    final RuleSetsCache cache = new RuleSetsCache(getCacheLoaderMock(), workspaceModel);
    cache.getRuleSets(PROJECT_NAME_1);
    final RuleSetModel ruleSetModel = new RuleSetModel("abc", new Location("path", LocationContext.WORKSPACE));
    workspaceModel.getOrCreateProject(PROJECT_NAME_1).setRuleSets(Arrays.asList(ruleSetModel));
    final RuleSets actualRuleSets = cache.getRuleSets(PROJECT_NAME_1);
    assertSame("Second cache access should reload rule sets", RULE_SETS_FOO_2, actualRuleSets);
}
Also used : WorkspaceModel(ch.acanda.eclipse.pmd.domain.WorkspaceModel) RuleSetModel(ch.acanda.eclipse.pmd.domain.RuleSetModel) RuleSets(net.sourceforge.pmd.RuleSets) Location(ch.acanda.eclipse.pmd.domain.Location) Test(org.junit.Test)

Aggregations

RuleSetModel (ch.acanda.eclipse.pmd.domain.RuleSetModel)9 Location (ch.acanda.eclipse.pmd.domain.Location)5 ProjectModel (ch.acanda.eclipse.pmd.domain.ProjectModel)4 WorkspaceModel (ch.acanda.eclipse.pmd.domain.WorkspaceModel)3 RuleSets (net.sourceforge.pmd.RuleSets)3 LocationContext (ch.acanda.eclipse.pmd.domain.LocationContext)2 Test (org.junit.Test)2 FileChangedListener (ch.acanda.eclipse.pmd.file.FileChangedListener)1 Subscription (ch.acanda.eclipse.pmd.file.Subscription)1 ImmutableSortedSet (com.google.common.collect.ImmutableSortedSet)1 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 RuleSetFactory (net.sourceforge.pmd.RuleSetFactory)1 RuleSetNotFoundException (net.sourceforge.pmd.RuleSetNotFoundException)1 RuleSetReferenceId (net.sourceforge.pmd.RuleSetReferenceId)1 IProject (org.eclipse.core.resources.IProject)1