Search in sources :

Example 1 with ReaderDataSource

use of net.sourceforge.pmd.util.datasource.ReaderDataSource in project Gargoyle by callakrsos.

the class DoPMD method internalGetApplicableFiles.

private List<DataSource> internalGetApplicableFiles(GargoylePMDConfiguration configuration, Set<Language> languages) {
    List<DataSource> files = new ArrayList<>();
    LanguageFilenameFilter fileSelector = new LanguageFilenameFilter(languages);
    if (null != configuration.getInputPaths()) {
        files.addAll(FileUtil.collectFiles(configuration.getInputPaths(), fileSelector));
    }
    if (null != configuration.getSourceText()) {
        String filePaths = "SourceBase";
        if (null != configuration.getSourceFileName()) {
            filePaths = configuration.getSourceFileName();
        }
        filePaths = filePaths.replaceAll("\\r?\\n", ",");
        filePaths = filePaths.replaceAll(",+", ",");
        String sourceText = configuration.getSourceText();
        try {
            Reader reader = new StringReader(sourceText);
            files.addAll(Arrays.asList(new ReaderDataSource(reader, filePaths)));
        } catch (Exception e) {
            LOGGER.error(ValueUtil.toString(e));
        }
    }
    return files;
}
Also used : ReaderDataSource(net.sourceforge.pmd.util.datasource.ReaderDataSource) ArrayList(java.util.ArrayList) StringReader(java.io.StringReader) Reader(java.io.Reader) StringReader(java.io.StringReader) LanguageFilenameFilter(net.sourceforge.pmd.lang.LanguageFilenameFilter) IOException(java.io.IOException) DataSource(net.sourceforge.pmd.util.datasource.DataSource) ReaderDataSource(net.sourceforge.pmd.util.datasource.ReaderDataSource)

Aggregations

IOException (java.io.IOException)1 Reader (java.io.Reader)1 StringReader (java.io.StringReader)1 ArrayList (java.util.ArrayList)1 LanguageFilenameFilter (net.sourceforge.pmd.lang.LanguageFilenameFilter)1 DataSource (net.sourceforge.pmd.util.datasource.DataSource)1 ReaderDataSource (net.sourceforge.pmd.util.datasource.ReaderDataSource)1