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));
}
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);
}
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();
}
Aggregations