use of net.sf.eclipsecs.core.config.configtypes.ProjectConfigurationType in project eclipse-cs by checkstyle.
the class ProjectConfigurationFactory method getLocalCheckConfigs.
@SuppressWarnings("unchecked")
private static List<ICheckConfiguration> getLocalCheckConfigs(Element root, IProject project) {
List<ICheckConfiguration> configurations = new ArrayList<>();
List<Element> configElements = root.elements(XMLTags.CHECK_CONFIG_TAG);
for (Element configEl : configElements) {
final String name = configEl.attributeValue(XMLTags.NAME_TAG);
final String description = configEl.attributeValue(XMLTags.DESCRIPTION_TAG);
String location = configEl.attributeValue(XMLTags.LOCATION_TAG);
String type = configEl.attributeValue(XMLTags.TYPE_TAG);
IConfigurationType configType = ConfigurationTypes.getByInternalName(type);
if (configType instanceof ProjectConfigurationType) {
// RFE 1420212
// treat config files relative to *THIS* project
IWorkspaceRoot workspaceRoot = project.getWorkspace().getRoot();
// test if the location contains the project name
if (workspaceRoot.findMember(location) == null) {
location = project.getFullPath().append(location).toString();
}
}
// get resolvable properties
List<ResolvableProperty> props = new ArrayList<>();
List<Element> propertiesElements = configEl.elements(XMLTags.PROPERTY_TAG);
for (Element propsEl : propertiesElements) {
ResolvableProperty prop = new ResolvableProperty(propsEl.attributeValue(XMLTags.NAME_TAG), propsEl.attributeValue(XMLTags.VALUE_TAG));
props.add(prop);
}
// get additional data
Map<String, String> additionalData = new HashMap<>();
List<Element> dataElements = configEl.elements(XMLTags.ADDITIONAL_DATA_TAG);
for (Element dataEl : dataElements) {
additionalData.put(dataEl.attributeValue(XMLTags.NAME_TAG), dataEl.attributeValue(XMLTags.VALUE_TAG));
}
ICheckConfiguration checkConfig = new CheckConfiguration(name, location, description, configType, false, props, additionalData);
configurations.add(checkConfig);
}
return configurations;
}
use of net.sf.eclipsecs.core.config.configtypes.ProjectConfigurationType in project eclipse-cs by checkstyle.
the class ProjectConfigurationWorkingCopy method writeLocalConfiguration.
/**
* Writes a local check configuration.
*
* @param checkConfig
* the local check configuration
* @param docRoot
* the root element of the project configuration
*/
private void writeLocalConfiguration(ICheckConfiguration checkConfig, Element docRoot) {
// configurations
if (checkConfig.getType() instanceof BuiltInConfigurationType || checkConfig.isGlobal()) {
return;
}
// RFE 1420212
String location = checkConfig.getLocation();
if (checkConfig.getType() instanceof ProjectConfigurationType) {
IProject project = mProjectConfig.getProject();
IWorkspaceRoot root = project.getWorkspace().getRoot();
IFile configFile = root.getFile(new Path(location));
IProject configFileProject = configFile.getProject();
// path part
if (project.equals(configFileProject)) {
location = configFile.getProjectRelativePath().toString();
}
}
Element configEl = docRoot.addElement(XMLTags.CHECK_CONFIG_TAG);
configEl.addAttribute(XMLTags.NAME_TAG, checkConfig.getName());
configEl.addAttribute(XMLTags.LOCATION_TAG, location);
configEl.addAttribute(XMLTags.TYPE_TAG, checkConfig.getType().getInternalName());
if (checkConfig.getDescription() != null) {
configEl.addAttribute(XMLTags.DESCRIPTION_TAG, checkConfig.getDescription());
}
// Write resolvable properties
for (ResolvableProperty prop : checkConfig.getResolvableProperties()) {
Element propEl = configEl.addElement(XMLTags.PROPERTY_TAG);
propEl.addAttribute(XMLTags.NAME_TAG, prop.getPropertyName());
propEl.addAttribute(XMLTags.VALUE_TAG, prop.getValue());
}
// Write additional data
for (Map.Entry<String, String> entry : checkConfig.getAdditionalData().entrySet()) {
Element addEl = configEl.addElement(XMLTags.ADDITIONAL_DATA_TAG);
addEl.addAttribute(XMLTags.NAME_TAG, entry.getKey());
addEl.addAttribute(XMLTags.VALUE_TAG, entry.getValue());
}
}
Aggregations