use of com.puppycrawl.tools.checkstyle.api.FileSetCheck in project checkstyle by checkstyle.
the class Checker method process.
@Override
public int process(List<File> files) throws CheckstyleException {
if (cacheFile != null) {
cacheFile.putExternalResources(getExternalResourceLocations());
}
// Prepare to start
fireAuditStarted();
for (final FileSetCheck fsc : fileSetChecks) {
fsc.beginProcessing(charset);
}
final List<File> targetFiles = files.stream().filter(file -> CommonUtil.matchesFileExtension(file, fileExtensions)).collect(Collectors.toList());
processFiles(targetFiles);
// Finish up
// It may also log!!!
fileSetChecks.forEach(FileSetCheck::finishProcessing);
// It may also log!!!
fileSetChecks.forEach(FileSetCheck::destroy);
final int errorCount = counter.getCount();
fireAuditFinished();
return errorCount;
}
use of com.puppycrawl.tools.checkstyle.api.FileSetCheck 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");
}
}
Aggregations