Search in sources :

Example 1 with MultiPropertyResolver

use of net.sf.eclipsecs.core.config.configtypes.MultiPropertyResolver in project eclipse-cs by checkstyle.

the class CheckConfigurationTester method getUnresolvedProperties.

/**
 * Tests a configuration if there are unresolved properties.
 *
 * @return the list of unresolved properties as ResolvableProperty values.
 * @throws CheckstylePluginException
 *           most likely the configuration file could not be found
 */
public List<ResolvableProperty> getUnresolvedProperties() throws CheckstylePluginException {
    CheckstyleConfigurationFile configFile = mCheckConfiguration.getCheckstyleConfiguration();
    PropertyResolver resolver = configFile.getPropertyResolver();
    // context
    if (mContextProject != null && resolver instanceof IContextAware) {
        ((IContextAware) resolver).setProjectContext(mContextProject);
    }
    MissingPropertyCollector collector = new MissingPropertyCollector();
    if (resolver instanceof MultiPropertyResolver) {
        ((MultiPropertyResolver) resolver).addPropertyResolver(collector);
    } else {
        MultiPropertyResolver multiResolver = new MultiPropertyResolver();
        multiResolver.addPropertyResolver(resolver);
        multiResolver.addPropertyResolver(collector);
        resolver = multiResolver;
    }
    InputSource in = null;
    try {
        in = configFile.getCheckConfigFileInputSource();
        ConfigurationLoader.loadConfiguration(in, resolver, false);
    } catch (CheckstyleException e) {
        CheckstylePluginException.rethrow(e);
    } finally {
        Closeables.closeQuietly(in.getByteStream());
    }
    return collector.getUnresolvedProperties();
}
Also used : InputSource(org.xml.sax.InputSource) CheckstyleException(com.puppycrawl.tools.checkstyle.api.CheckstyleException) PropertyResolver(com.puppycrawl.tools.checkstyle.PropertyResolver) MultiPropertyResolver(net.sf.eclipsecs.core.config.configtypes.MultiPropertyResolver) MultiPropertyResolver(net.sf.eclipsecs.core.config.configtypes.MultiPropertyResolver) IContextAware(net.sf.eclipsecs.core.config.configtypes.IContextAware)

Aggregations

PropertyResolver (com.puppycrawl.tools.checkstyle.PropertyResolver)1 CheckstyleException (com.puppycrawl.tools.checkstyle.api.CheckstyleException)1 IContextAware (net.sf.eclipsecs.core.config.configtypes.IContextAware)1 MultiPropertyResolver (net.sf.eclipsecs.core.config.configtypes.MultiPropertyResolver)1 InputSource (org.xml.sax.InputSource)1