use of net.sf.eclipsecs.core.config.CheckstyleConfigurationFile in project eclipse-cs by checkstyle.
the class CheckerFactory method getAdditionalData.
/**
* Determines the additional data for a given configuration file.
*
* @param config
* the check configuration
* @param project
* the project to create the checker for
* @return the checker for the given configuration file
* @throws CheckstylePluginException
* the configuration could not be read
*/
public static ConfigurationReader.AdditionalConfigData getAdditionalData(ICheckConfiguration config, IProject project) throws CheckstylePluginException {
String cacheKey = getCacheKey(config, project);
AdditionalConfigData additionalData = sAdditionalDataMap.get(cacheKey);
// no cache hit - create the additional data
if (additionalData == null) {
CheckstyleConfigurationFile configFileData = config.getCheckstyleConfiguration();
InputSource in = null;
try {
in = configFileData.getCheckConfigFileInputSource();
additionalData = ConfigurationReader.getAdditionalConfigData(in);
} finally {
Closeables.closeQuietly(in.getByteStream());
}
sAdditionalDataMap.put(cacheKey, additionalData);
}
return additionalData;
}
use of net.sf.eclipsecs.core.config.CheckstyleConfigurationFile in project eclipse-cs by checkstyle.
the class TransformCheckstyleRulesJob method runInWorkspace.
/**
* {@inheritDoc}
*/
@Override
public IStatus runInWorkspace(final IProgressMonitor arg0) throws CoreException {
try {
final IProjectConfiguration conf = ProjectConfigurationFactory.getConfiguration(mProject);
final List<Configuration> rules = new ArrayList<Configuration>();
// collect rules from all configured filesets
for (FileSet fs : conf.getFileSets()) {
ICheckConfiguration checkConfig = fs.getCheckConfig();
CheckstyleConfigurationFile configFile = checkConfig.getCheckstyleConfiguration();
PropertyResolver resolver = configFile.getPropertyResolver();
// context
if (resolver instanceof IContextAware) {
((IContextAware) resolver).setProjectContext(mProject);
}
InputSource in = null;
try {
in = configFile.getCheckConfigFileInputSource();
Configuration configuration = ConfigurationLoader.loadConfiguration(in, resolver, true);
// flatten the nested configuration tree into a list
recurseConfiguration(configuration, rules);
} finally {
Closeables.closeQuietly(in.getByteStream());
}
}
if (rules.isEmpty()) {
return Status.CANCEL_STATUS;
}
final CheckstyleTransformer transformer = new CheckstyleTransformer(mProject, rules);
transformer.transformRules();
} catch (CheckstyleException e) {
Status status = new Status(IStatus.ERROR, CheckstylePlugin.PLUGIN_ID, IStatus.ERROR, e.getMessage(), e);
throw new CoreException(status);
} catch (CheckstylePluginException e) {
Status status = new Status(IStatus.ERROR, CheckstylePlugin.PLUGIN_ID, IStatus.ERROR, e.getMessage(), e);
throw new CoreException(status);
}
return Status.OK_STATUS;
}
Aggregations