Search in sources :

Example 1 with LocationContext

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

the class PMDPropertyPageModelTransformer method toDomainModel.

/**
 * Transforms a rule set view model to a rule set domain model.
 */
public static RuleSetModel toDomainModel(final RuleSetViewModel viewModel) {
    final String name = viewModel.getName();
    final String path = viewModel.getLocation();
    final LocationContext context = CONTEXT_TYPE_MAP.inverse().get(viewModel.getType());
    return new RuleSetModel(name, new Location(path, context));
}
Also used : RuleSetModel(ch.acanda.eclipse.pmd.domain.RuleSetModel) LocationContext(ch.acanda.eclipse.pmd.domain.LocationContext) Location(ch.acanda.eclipse.pmd.domain.Location)

Example 2 with LocationContext

use of ch.acanda.eclipse.pmd.domain.LocationContext 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 3 with LocationContext

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

the class AddRuleSetConfigurationModel method getAbsoluteLocation.

private Optional<Path> getAbsoluteLocation() {
    final LocationContext locationContext;
    if (isWorkspaceTypeSelected) {
        locationContext = LocationContext.WORKSPACE;
    } else if (isProjectTypeSelected) {
        locationContext = LocationContext.PROJECT;
    } else if (isFileSystemTypeSelected) {
        locationContext = LocationContext.FILE_SYSTEM;
    } else {
        throw new IllegalStateException("Unknown location type");
    }
    final Optional<String> resolvedLocation = LocationResolver.resolveIfExists(new Location(location, locationContext), project);
    if (resolvedLocation.isPresent()) {
        return Optional.of(Paths.get(resolvedLocation.get()));
    }
    return Optional.absent();
}
Also used : LocationContext(ch.acanda.eclipse.pmd.domain.LocationContext) Location(ch.acanda.eclipse.pmd.domain.Location)

Aggregations

Location (ch.acanda.eclipse.pmd.domain.Location)3 LocationContext (ch.acanda.eclipse.pmd.domain.LocationContext)3 RuleSetModel (ch.acanda.eclipse.pmd.domain.RuleSetModel)2