Search in sources :

Example 1 with BeforeExecutionFileFilter

use of com.puppycrawl.tools.checkstyle.api.BeforeExecutionFileFilter in project checkstyle by checkstyle.

the class Checker method setupChild.

/**
 * {@inheritDoc} Creates child module.
 *
 * @noinspection ChainOfInstanceofChecks
 */
@Override
protected void setupChild(Configuration childConf) throws CheckstyleException {
    final String name = childConf.getName();
    final Object child;
    try {
        child = moduleFactory.createModule(name);
        if (child instanceof AutomaticBean) {
            final AutomaticBean bean = (AutomaticBean) child;
            bean.contextualize(childContext);
            bean.configure(childConf);
        }
    } catch (final CheckstyleException ex) {
        throw new CheckstyleException("cannot initialize module " + name + " - " + ex.getMessage(), ex);
    }
    if (child instanceof FileSetCheck) {
        final FileSetCheck fsc = (FileSetCheck) child;
        fsc.init();
        addFileSetCheck(fsc);
    } else if (child instanceof BeforeExecutionFileFilter) {
        final BeforeExecutionFileFilter filter = (BeforeExecutionFileFilter) child;
        addBeforeExecutionFileFilter(filter);
    } else if (child instanceof Filter) {
        final Filter filter = (Filter) child;
        addFilter(filter);
    } else if (child instanceof AuditListener) {
        final AuditListener listener = (AuditListener) child;
        addListener(listener);
    } else {
        throw new CheckstyleException(name + " is not allowed as a child in Checker");
    }
}
Also used : FileSetCheck(com.puppycrawl.tools.checkstyle.api.FileSetCheck) BeforeExecutionFileFilter(com.puppycrawl.tools.checkstyle.api.BeforeExecutionFileFilter) Filter(com.puppycrawl.tools.checkstyle.api.Filter) BeforeExecutionFileFilter(com.puppycrawl.tools.checkstyle.api.BeforeExecutionFileFilter) CheckstyleException(com.puppycrawl.tools.checkstyle.api.CheckstyleException) AuditListener(com.puppycrawl.tools.checkstyle.api.AuditListener) AutomaticBean(com.puppycrawl.tools.checkstyle.api.AutomaticBean)

Aggregations

AuditListener (com.puppycrawl.tools.checkstyle.api.AuditListener)1 AutomaticBean (com.puppycrawl.tools.checkstyle.api.AutomaticBean)1 BeforeExecutionFileFilter (com.puppycrawl.tools.checkstyle.api.BeforeExecutionFileFilter)1 CheckstyleException (com.puppycrawl.tools.checkstyle.api.CheckstyleException)1 FileSetCheck (com.puppycrawl.tools.checkstyle.api.FileSetCheck)1 Filter (com.puppycrawl.tools.checkstyle.api.Filter)1