forked from phoedos/pmd
Fix pmd-core compil
This commit is contained in:
@ -9,7 +9,6 @@ import static net.sourceforge.pmd.util.CollectionUtil.listOf;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Writer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
@ -29,9 +28,11 @@ import net.sourceforge.pmd.cli.PMDCommandLineInterface;
|
||||
import net.sourceforge.pmd.cli.PmdParametersParseResult;
|
||||
import net.sourceforge.pmd.cli.internal.CliMessages;
|
||||
import net.sourceforge.pmd.internal.Slf4jSimpleConfiguration;
|
||||
import net.sourceforge.pmd.lang.document.TextFile;
|
||||
import net.sourceforge.pmd.renderers.Renderer;
|
||||
import net.sourceforge.pmd.reporting.ReportStats;
|
||||
import net.sourceforge.pmd.reporting.ReportStatsListener;
|
||||
import net.sourceforge.pmd.util.CollectionUtil;
|
||||
import net.sourceforge.pmd.util.datasource.DataSource;
|
||||
import net.sourceforge.pmd.util.log.MessageReporter;
|
||||
import net.sourceforge.pmd.util.log.internal.SimpleMessageReporter;
|
||||
@ -137,9 +138,9 @@ public final class PMD {
|
||||
pmd.addRenderers(renderers);
|
||||
@SuppressWarnings("PMD.CloseResource")
|
||||
GlobalReportBuilderListener reportBuilder = new GlobalReportBuilderListener();
|
||||
List<DataSource> sortedFiles = new ArrayList<>(files);
|
||||
sortedFiles.sort(Comparator.comparing(ds -> ds.getNiceFileName(false, "")));
|
||||
pmd.performAnalysisImpl(listOf(reportBuilder), sortedFiles);
|
||||
List<TextFile> textFiles = CollectionUtil.map(files, ds -> TextFile.dataSourceCompat(ds, configuration));
|
||||
textFiles.sort(Comparator.comparing(TextFile::getPathId));
|
||||
pmd.performAnalysisImpl(listOf(reportBuilder), textFiles);
|
||||
return reportBuilder.getResult();
|
||||
}
|
||||
}
|
||||
|
@ -16,11 +16,11 @@ import java.util.function.Consumer;
|
||||
|
||||
import net.sourceforge.pmd.annotation.DeprecatedUntil700;
|
||||
import net.sourceforge.pmd.annotation.InternalApi;
|
||||
import net.sourceforge.pmd.lang.document.TextFile;
|
||||
import net.sourceforge.pmd.renderers.AbstractAccumulatingRenderer;
|
||||
import net.sourceforge.pmd.reporting.FileAnalysisListener;
|
||||
import net.sourceforge.pmd.reporting.GlobalAnalysisListener;
|
||||
import net.sourceforge.pmd.util.BaseResultProducingCloseable;
|
||||
import net.sourceforge.pmd.lang.document.TextFile;
|
||||
|
||||
/**
|
||||
* A {@link Report} collects all informations during a PMD execution. This
|
||||
|
@ -25,9 +25,9 @@ import net.sourceforge.pmd.annotation.InternalApi;
|
||||
import net.sourceforge.pmd.cache.ChecksumAware;
|
||||
import net.sourceforge.pmd.internal.util.PredicateUtil;
|
||||
import net.sourceforge.pmd.lang.LanguageVersion;
|
||||
import net.sourceforge.pmd.lang.document.TextFile;
|
||||
import net.sourceforge.pmd.lang.rule.RuleReference;
|
||||
import net.sourceforge.pmd.lang.rule.XPathRule;
|
||||
import net.sourceforge.pmd.lang.document.TextFile;
|
||||
|
||||
/**
|
||||
* This class represents a collection of rules along with some optional filter
|
||||
|
@ -17,9 +17,9 @@ import net.sourceforge.pmd.benchmark.TimeTracker;
|
||||
import net.sourceforge.pmd.benchmark.TimedOperation;
|
||||
import net.sourceforge.pmd.benchmark.TimedOperationCategory;
|
||||
import net.sourceforge.pmd.lang.ast.RootNode;
|
||||
import net.sourceforge.pmd.lang.document.TextFile;
|
||||
import net.sourceforge.pmd.lang.rule.internal.RuleApplicator;
|
||||
import net.sourceforge.pmd.reporting.FileAnalysisListener;
|
||||
import net.sourceforge.pmd.lang.document.TextFile;
|
||||
|
||||
/**
|
||||
* Grouping of Rules per Language in a RuleSet.
|
||||
|
@ -28,11 +28,11 @@ import org.apache.tools.ant.types.Parameter;
|
||||
|
||||
import net.sourceforge.pmd.Report;
|
||||
import net.sourceforge.pmd.annotation.InternalApi;
|
||||
import net.sourceforge.pmd.lang.document.TextFile;
|
||||
import net.sourceforge.pmd.renderers.Renderer;
|
||||
import net.sourceforge.pmd.renderers.RendererFactory;
|
||||
import net.sourceforge.pmd.reporting.FileAnalysisListener;
|
||||
import net.sourceforge.pmd.reporting.GlobalAnalysisListener;
|
||||
import net.sourceforge.pmd.lang.document.TextFile;
|
||||
|
||||
@InternalApi
|
||||
public class Formatter {
|
||||
|
@ -8,7 +8,6 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
import org.apache.tools.ant.AntClassLoader;
|
||||
import org.apache.tools.ant.BuildException;
|
||||
@ -32,13 +31,13 @@ import net.sourceforge.pmd.internal.Slf4jSimpleConfiguration;
|
||||
import net.sourceforge.pmd.lang.Language;
|
||||
import net.sourceforge.pmd.lang.LanguageRegistry;
|
||||
import net.sourceforge.pmd.lang.LanguageVersion;
|
||||
import net.sourceforge.pmd.lang.document.TextFile;
|
||||
import net.sourceforge.pmd.reporting.FileAnalysisListener;
|
||||
import net.sourceforge.pmd.reporting.GlobalAnalysisListener;
|
||||
import net.sourceforge.pmd.reporting.ReportStats;
|
||||
import net.sourceforge.pmd.reporting.ReportStatsListener;
|
||||
import net.sourceforge.pmd.util.ClasspathClassLoader;
|
||||
import net.sourceforge.pmd.util.IOUtil;
|
||||
import net.sourceforge.pmd.util.datasource.DataSource;
|
||||
|
||||
public class PMDTaskImpl {
|
||||
|
||||
@ -105,9 +104,6 @@ public class PMDTaskImpl {
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("PMD.CloseResource") final List<String> reportShortNamesPaths = new ArrayList<>();
|
||||
StringJoiner fullInputPath = new StringJoiner(",");
|
||||
|
||||
List<String> ruleSetPaths = expandRuleSetPaths(configuration.getRuleSetPaths());
|
||||
// don't let PmdAnalysis.create create rulesets itself.
|
||||
configuration.setRuleSets(Collections.emptyList());
|
||||
@ -120,20 +116,17 @@ public class PMDTaskImpl {
|
||||
|
||||
for (FileSet fileset : filesets) {
|
||||
DirectoryScanner ds = fileset.getDirectoryScanner(project);
|
||||
if (configuration.isReportShortNames()) {
|
||||
pmd.files().relativizeWith(ds.getBasedir().getPath());
|
||||
}
|
||||
for (String srcFile : ds.getIncludedFiles()) {
|
||||
pmd.files().addFile(ds.getBasedir().toPath().resolve(srcFile));
|
||||
}
|
||||
|
||||
final String commonInputPath = ds.getBasedir().getPath();
|
||||
fullInputPath.add(commonInputPath);
|
||||
if (configuration.isReportShortNames()) {
|
||||
reportShortNamesPaths.add(commonInputPath);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("PMD.CloseResource")
|
||||
ReportStatsListener reportStatsListener = new ReportStatsListener();
|
||||
pmd.addListener(getListener(reportStatsListener, reportShortNamesPaths, fullInputPath.toString()));
|
||||
pmd.addListener(getListener(reportStatsListener));
|
||||
|
||||
pmd.performAnalysis();
|
||||
stats = reportStatsListener.getResult();
|
||||
@ -163,16 +156,14 @@ public class PMDTaskImpl {
|
||||
return paths;
|
||||
}
|
||||
|
||||
private @NonNull GlobalAnalysisListener getListener(ReportStatsListener reportSizeListener,
|
||||
List<String> reportShortNamesPaths,
|
||||
String inputPaths) {
|
||||
private @NonNull GlobalAnalysisListener getListener(ReportStatsListener reportSizeListener) {
|
||||
List<GlobalAnalysisListener> renderers = new ArrayList<>(formatters.size() + 1);
|
||||
try {
|
||||
renderers.add(makeLogListener(inputPaths));
|
||||
renderers.add(makeLogListener());
|
||||
renderers.add(reportSizeListener);
|
||||
for (Formatter formatter : formatters) {
|
||||
project.log("Sending a report to " + formatter, Project.MSG_VERBOSE);
|
||||
renderers.add(formatter.newListener(project, reportShortNamesPaths));
|
||||
renderers.add(formatter.newListener(project));
|
||||
}
|
||||
return GlobalAnalysisListener.tee(renderers);
|
||||
} catch (Exception e) {
|
||||
@ -185,12 +176,12 @@ public class PMDTaskImpl {
|
||||
}
|
||||
}
|
||||
|
||||
private GlobalAnalysisListener makeLogListener(String commonInputPath) {
|
||||
private GlobalAnalysisListener makeLogListener() {
|
||||
return new GlobalAnalysisListener() {
|
||||
|
||||
@Override
|
||||
public FileAnalysisListener startFileAnalysis(DataSource dataSource) {
|
||||
String name = dataSource.getNiceFileName(false, commonInputPath);
|
||||
public FileAnalysisListener startFileAnalysis(TextFile dataSource) {
|
||||
String name = dataSource.getDisplayName();
|
||||
project.log("Processing file " + name, Project.MSG_VERBOSE);
|
||||
return FileAnalysisListener.noop();
|
||||
}
|
||||
|
@ -80,8 +80,8 @@ public abstract class AbstractAnalysisCache implements AnalysisCache {
|
||||
if (result) {
|
||||
LOG.debug("Incremental Analysis cache HIT");
|
||||
} else {
|
||||
LOG.debug("Incremental Analysis cache MISS - {}" ,analysisResult != null ? "file changed"
|
||||
: "no previous result found");
|
||||
LOG.debug("Incremental Analysis cache MISS - {}",
|
||||
analysisResult != null ? "file changed" : "no previous result found");
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -10,9 +10,8 @@ import java.util.List;
|
||||
import net.sourceforge.pmd.RuleSets;
|
||||
import net.sourceforge.pmd.RuleViolation;
|
||||
import net.sourceforge.pmd.annotation.InternalApi;
|
||||
import net.sourceforge.pmd.reporting.FileAnalysisListener;
|
||||
import net.sourceforge.pmd.lang.document.TextDocument;
|
||||
import net.sourceforge.pmd.lang.document.TextFile;
|
||||
import net.sourceforge.pmd.reporting.FileAnalysisListener;
|
||||
|
||||
/**
|
||||
* A NOOP analysis cache. Easier / safer than null-checking.
|
||||
@ -49,7 +48,7 @@ public class NoopAnalysisCache implements AnalysisCache {
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileAnalysisListener startFileAnalysis(TextFile filename) {
|
||||
public FileAnalysisListener startFileAnalysis(TextDocument filename) {
|
||||
return FileAnalysisListener.noop();
|
||||
}
|
||||
|
||||
|
@ -20,11 +20,10 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import net.sourceforge.pmd.PMD;
|
||||
import net.sourceforge.pmd.PMDVersion;
|
||||
import net.sourceforge.pmd.cli.internal.CliMessages;
|
||||
|
@ -90,7 +90,6 @@ public final class FileCollectionUtil {
|
||||
public static void collectFiles(FileCollector collector, List<String> filePaths) {
|
||||
for (String rootLocation : filePaths) {
|
||||
try {
|
||||
collector.relativizeWith(rootLocation);
|
||||
addRoot(collector, rootLocation);
|
||||
} catch (IOException e) {
|
||||
collector.getReporter().errorEx("Error collecting " + rootLocation, e);
|
||||
|
@ -17,6 +17,10 @@ import net.sourceforge.pmd.annotation.DeprecatedUntil700;
|
||||
import net.sourceforge.pmd.lang.LanguageVersion;
|
||||
import net.sourceforge.pmd.lang.ast.NodeStream.DescendantNodeStream;
|
||||
import net.sourceforge.pmd.lang.ast.internal.StreamImpl;
|
||||
import net.sourceforge.pmd.lang.document.FileLocation;
|
||||
import net.sourceforge.pmd.lang.document.Reportable;
|
||||
import net.sourceforge.pmd.lang.document.TextDocument;
|
||||
import net.sourceforge.pmd.lang.document.TextRegion;
|
||||
import net.sourceforge.pmd.lang.rule.xpath.Attribute;
|
||||
import net.sourceforge.pmd.lang.rule.xpath.NoAttribute;
|
||||
import net.sourceforge.pmd.lang.rule.xpath.XPathVersion;
|
||||
@ -26,10 +30,6 @@ import net.sourceforge.pmd.lang.rule.xpath.internal.DeprecatedAttrLogger;
|
||||
import net.sourceforge.pmd.lang.rule.xpath.internal.SaxonXPathRuleQuery;
|
||||
import net.sourceforge.pmd.util.DataMap;
|
||||
import net.sourceforge.pmd.util.DataMap.DataKey;
|
||||
import net.sourceforge.pmd.lang.document.FileLocation;
|
||||
import net.sourceforge.pmd.lang.document.Reportable;
|
||||
import net.sourceforge.pmd.lang.document.TextDocument;
|
||||
import net.sourceforge.pmd.lang.document.TextRegion;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -13,8 +13,8 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import net.sourceforge.pmd.lang.ast.impl.javacc.JavaccToken;
|
||||
import net.sourceforge.pmd.lang.ast.impl.javacc.JavaccTokenDocument;
|
||||
import net.sourceforge.pmd.util.StringUtil;
|
||||
import net.sourceforge.pmd.lang.document.FileLocation;
|
||||
import net.sourceforge.pmd.util.StringUtil;
|
||||
|
||||
public class ParseException extends FileAnalysisException {
|
||||
|
||||
|
@ -10,11 +10,11 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import net.sourceforge.pmd.PMDConfiguration;
|
||||
import net.sourceforge.pmd.lang.LanguageVersion;
|
||||
import net.sourceforge.pmd.lang.document.TextDocument;
|
||||
import net.sourceforge.pmd.properties.AbstractPropertySource;
|
||||
import net.sourceforge.pmd.properties.PropertyDescriptor;
|
||||
import net.sourceforge.pmd.properties.PropertyFactory;
|
||||
import net.sourceforge.pmd.properties.PropertySource;
|
||||
import net.sourceforge.pmd.lang.document.TextDocument;
|
||||
|
||||
/**
|
||||
* Produces an AST from a source file. Instances of this interface must
|
||||
|
@ -74,7 +74,7 @@ public interface SemanticErrorReporter {
|
||||
private boolean hasError = false;
|
||||
|
||||
private String locPrefix(Node loc) {
|
||||
return "at " + loc.getAstInfo().getFileName() + " :" + loc.getBeginLine() + ":" + loc.getBeginColumn() + ": ";
|
||||
return "at " + loc.getReportLocation() + ": ";
|
||||
}
|
||||
|
||||
private String makeMessage(Node location, String message, Object[] args) {
|
||||
|
@ -4,8 +4,8 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.ast;
|
||||
|
||||
import net.sourceforge.pmd.lang.rule.xpath.NoAttribute;
|
||||
import net.sourceforge.pmd.lang.document.TextRegion;
|
||||
import net.sourceforge.pmd.lang.rule.xpath.NoAttribute;
|
||||
|
||||
/**
|
||||
* Refinement of {@link Node} for nodes that can provide the underlying
|
||||
|
@ -12,10 +12,10 @@ import org.antlr.v4.runtime.tree.TerminalNode;
|
||||
|
||||
import net.sourceforge.pmd.lang.ast.impl.GenericNode;
|
||||
import net.sourceforge.pmd.lang.ast.impl.antlr4.BaseAntlrNode.AntlrToPmdParseTreeAdapter;
|
||||
import net.sourceforge.pmd.util.DataMap;
|
||||
import net.sourceforge.pmd.util.DataMap.DataKey;
|
||||
import net.sourceforge.pmd.lang.document.FileLocation;
|
||||
import net.sourceforge.pmd.lang.document.TextRegion;
|
||||
import net.sourceforge.pmd.util.DataMap;
|
||||
import net.sourceforge.pmd.util.DataMap.DataKey;
|
||||
|
||||
/**
|
||||
* Base class for an antlr node. This implements the PMD interfaces only,
|
||||
|
@ -143,7 +143,9 @@ public final class FileCollector implements AutoCloseable {
|
||||
}
|
||||
LanguageVersion languageVersion = discoverLanguage(file.toString());
|
||||
if (languageVersion != null) {
|
||||
addFileImpl(new NioTextFile(file, charset, languageVersion, getDisplayName(file)));
|
||||
addFileImpl(TextFile.builderForPath(file, charset, languageVersion)
|
||||
.withDisplayName(getDisplayName(file))
|
||||
.build());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -198,7 +200,7 @@ public final class FileCollector implements AutoCloseable {
|
||||
|
||||
LanguageVersion version = discoverLanguage(pathId);
|
||||
if (version != null) {
|
||||
addFileImpl(new StringTextFile(sourceContents, pathId, pathId, version));
|
||||
addFileImpl(TextFile.builderForCharSeq(sourceContents, pathId, version).build());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -25,11 +25,10 @@ class NioTextFile extends BaseCloseable implements TextFile {
|
||||
|
||||
private final Path path;
|
||||
private final Charset charset;
|
||||
private final @Nullable ReferenceCountedCloseable fs;
|
||||
private final LanguageVersion languageVersion;
|
||||
private final @Nullable String displayName;
|
||||
|
||||
NioTextFile(Path path, Charset charset, LanguageVersion languageVersion, @Nullable String displayName, @Nullable ReferenceCountedCloseable fs) {
|
||||
NioTextFile(Path path, Charset charset, LanguageVersion languageVersion, @Nullable String displayName) {
|
||||
AssertionUtil.requireParamNotNull("path", path);
|
||||
AssertionUtil.requireParamNotNull("charset", charset);
|
||||
AssertionUtil.requireParamNotNull("language version", languageVersion);
|
||||
@ -38,10 +37,6 @@ class NioTextFile extends BaseCloseable implements TextFile {
|
||||
this.path = path;
|
||||
this.charset = charset;
|
||||
this.languageVersion = languageVersion;
|
||||
this.fs = fs;
|
||||
if (fs != null) {
|
||||
fs.addDependent();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -93,9 +88,25 @@ class NioTextFile extends BaseCloseable implements TextFile {
|
||||
|
||||
@Override
|
||||
protected void doClose() throws IOException {
|
||||
if (fs != null) {
|
||||
fs.closeDependent();
|
||||
// nothing to do.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
@SuppressWarnings("PMD.CloseResource")
|
||||
NioTextFile that = (NioTextFile) o;
|
||||
return path.equals(that.path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return path.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -22,10 +22,10 @@ import net.sourceforge.pmd.annotation.DeprecatedUntil700;
|
||||
import net.sourceforge.pmd.cpd.SourceCode;
|
||||
import net.sourceforge.pmd.internal.util.BaseCloseable;
|
||||
import net.sourceforge.pmd.lang.LanguageVersion;
|
||||
import net.sourceforge.pmd.util.datasource.DataSource;
|
||||
import net.sourceforge.pmd.lang.document.TextFileBuilder.ForCharSeq;
|
||||
import net.sourceforge.pmd.lang.document.TextFileBuilder.ForNio;
|
||||
import net.sourceforge.pmd.lang.document.TextFileBuilder.ForReader;
|
||||
import net.sourceforge.pmd.util.datasource.DataSource;
|
||||
|
||||
/**
|
||||
* Represents some location containing character data. Despite the name,
|
||||
@ -245,6 +245,7 @@ public interface TextFile extends Closeable {
|
||||
|
||||
@Override
|
||||
public TextFileContent readContents() throws IOException {
|
||||
ensureOpen();
|
||||
try (InputStream is = ds.getInputStream();
|
||||
Reader reader = new BufferedReader(new InputStreamReader(is, config.getSourceEncoding()))) {
|
||||
String contents = IOUtils.toString(reader);
|
||||
|
@ -30,7 +30,6 @@ public abstract class TextFileBuilder {
|
||||
|
||||
private final Path path;
|
||||
private final Charset charset;
|
||||
private @Nullable ReferenceCountedCloseable fs;
|
||||
|
||||
ForNio(LanguageVersion languageVersion, Path path, Charset charset) {
|
||||
super(languageVersion);
|
||||
@ -38,15 +37,9 @@ public abstract class TextFileBuilder {
|
||||
this.charset = AssertionUtil.requireParamNotNull("charset", charset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextFileBuilder belongingTo(@Nullable ReferenceCountedCloseable fs) {
|
||||
this.fs = fs;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextFile build() {
|
||||
return new NioTextFile(path, charset, languageVersion, displayName, fs);
|
||||
return new NioTextFile(path, charset, languageVersion, displayName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -98,23 +91,6 @@ public abstract class TextFileBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a closeable that must be closed after the new file is closed itself.
|
||||
* This is used to close zip archives after all the textfiles within them
|
||||
* are closed. In this case, the reference counted closeable tracks a ZipFileSystem.
|
||||
* If null, then the new text file doesn't have a dependency. This
|
||||
* is also a noop unless the file was build with {@link TextFile#forPath(Path, Charset, LanguageVersion) forPath}.
|
||||
*
|
||||
* <p>Note at most one of those is expected. The last one wins.
|
||||
*
|
||||
* @param fs A closeable for the filesystem
|
||||
*
|
||||
* @return This builder
|
||||
*/
|
||||
public TextFileBuilder belongingTo(@Nullable ReferenceCountedCloseable fs) {
|
||||
return this; // noop
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns the new text file.
|
||||
*/
|
||||
|
@ -8,9 +8,9 @@ import net.sourceforge.pmd.Rule;
|
||||
import net.sourceforge.pmd.RuleViolation;
|
||||
import net.sourceforge.pmd.annotation.InternalApi;
|
||||
import net.sourceforge.pmd.internal.util.AssertionUtil;
|
||||
import net.sourceforge.pmd.properties.PropertyDescriptor;
|
||||
import net.sourceforge.pmd.lang.document.FileLocation;
|
||||
import net.sourceforge.pmd.lang.document.Reportable;
|
||||
import net.sourceforge.pmd.properties.PropertyDescriptor;
|
||||
|
||||
/**
|
||||
* @deprecated This is internal. Clients should exclusively use {@link RuleViolation}.
|
||||
|
@ -102,7 +102,7 @@ public class RuleApplicator {
|
||||
listener.onError(new ProcessingError(e, node.getTextDocument().getDisplayName()));
|
||||
|
||||
// fixme - maybe duplicated logging
|
||||
LOG.warn("Exception applying rule {} on file {}, continuing with next rule", rule.getName(), node.getAstInfo().getFileName(), e);
|
||||
LOG.warn("Exception applying rule {} on file {}, continuing with next rule", rule.getName(), node.getTextDocument().getPathId(), e);
|
||||
String nodeToString = StringUtil.elide(node.toString(), 600, " ... (truncated)");
|
||||
LOG.warn("Exception occurred on node {}", nodeToString);
|
||||
}
|
||||
|
@ -12,8 +12,8 @@ import net.sourceforge.pmd.PMDConfiguration;
|
||||
import net.sourceforge.pmd.RuleSet;
|
||||
import net.sourceforge.pmd.RuleSets;
|
||||
import net.sourceforge.pmd.annotation.InternalApi;
|
||||
import net.sourceforge.pmd.reporting.GlobalAnalysisListener;
|
||||
import net.sourceforge.pmd.lang.document.TextFile;
|
||||
import net.sourceforge.pmd.reporting.GlobalAnalysisListener;
|
||||
|
||||
/**
|
||||
* This is internal API!
|
||||
|
@ -8,8 +8,8 @@ import java.util.List;
|
||||
|
||||
import net.sourceforge.pmd.PMDConfiguration;
|
||||
import net.sourceforge.pmd.RuleSets;
|
||||
import net.sourceforge.pmd.reporting.GlobalAnalysisListener;
|
||||
import net.sourceforge.pmd.lang.document.TextFile;
|
||||
import net.sourceforge.pmd.reporting.GlobalAnalysisListener;
|
||||
|
||||
/**
|
||||
* @author Romain Pelisse <belaran@gmail.com>
|
||||
|
@ -11,8 +11,8 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
import net.sourceforge.pmd.PMDConfiguration;
|
||||
import net.sourceforge.pmd.RuleSets;
|
||||
import net.sourceforge.pmd.reporting.GlobalAnalysisListener;
|
||||
import net.sourceforge.pmd.lang.document.TextFile;
|
||||
import net.sourceforge.pmd.reporting.GlobalAnalysisListener;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -14,9 +14,9 @@ import net.sourceforge.pmd.annotation.InternalApi;
|
||||
import net.sourceforge.pmd.benchmark.TimeTracker;
|
||||
import net.sourceforge.pmd.benchmark.TimedOperation;
|
||||
import net.sourceforge.pmd.benchmark.TimedOperationCategory;
|
||||
import net.sourceforge.pmd.lang.document.TextFile;
|
||||
import net.sourceforge.pmd.reporting.FileAnalysisListener;
|
||||
import net.sourceforge.pmd.reporting.GlobalAnalysisListener;
|
||||
import net.sourceforge.pmd.lang.document.TextFile;
|
||||
|
||||
/**
|
||||
* Abstract base class for {@link Renderer} implementations which only produce
|
||||
|
@ -18,11 +18,11 @@ import net.sourceforge.pmd.annotation.Experimental;
|
||||
import net.sourceforge.pmd.benchmark.TimeTracker;
|
||||
import net.sourceforge.pmd.benchmark.TimedOperation;
|
||||
import net.sourceforge.pmd.benchmark.TimedOperationCategory;
|
||||
import net.sourceforge.pmd.lang.document.TextFile;
|
||||
import net.sourceforge.pmd.properties.PropertyDescriptor;
|
||||
import net.sourceforge.pmd.properties.PropertySource;
|
||||
import net.sourceforge.pmd.reporting.FileAnalysisListener;
|
||||
import net.sourceforge.pmd.reporting.GlobalAnalysisListener;
|
||||
import net.sourceforge.pmd.lang.document.TextFile;
|
||||
|
||||
/**
|
||||
* This is an interface for rendering a Report. When a Renderer is being
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
package net.sourceforge.pmd.reporting;
|
||||
|
||||
import net.sourceforge.pmd.util.datasource.DataSource;
|
||||
import net.sourceforge.pmd.lang.document.TextFile;
|
||||
|
||||
/**
|
||||
* @author Clément Fournier
|
||||
@ -18,7 +18,7 @@ final class NoopAnalysisListener implements GlobalAnalysisListener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileAnalysisListener startFileAnalysis(DataSource file) {
|
||||
public FileAnalysisListener startFileAnalysis(TextFile file) {
|
||||
return FileAnalysisListener.noop();
|
||||
}
|
||||
|
||||
|
@ -8,8 +8,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import net.sourceforge.pmd.Report.ProcessingError;
|
||||
import net.sourceforge.pmd.RuleViolation;
|
||||
import net.sourceforge.pmd.lang.document.TextFile;
|
||||
import net.sourceforge.pmd.util.BaseResultProducingCloseable;
|
||||
import net.sourceforge.pmd.util.datasource.DataSource;
|
||||
|
||||
/**
|
||||
* Collects summarized info about a PMD run.
|
||||
@ -22,7 +22,7 @@ public final class ReportStatsListener extends BaseResultProducingCloseable<Repo
|
||||
private final AtomicInteger numViolations = new AtomicInteger(0);
|
||||
|
||||
@Override
|
||||
public FileAnalysisListener startFileAnalysis(DataSource file) {
|
||||
public FileAnalysisListener startFileAnalysis(TextFile file) {
|
||||
return new FileAnalysisListener() {
|
||||
// this object does not need thread-safety so we avoid using atomics,
|
||||
// except during the merge.
|
||||
|
@ -121,6 +121,7 @@ public final class FileUtil {
|
||||
public static List<String> readFilelistEntries(Path filelist) throws IOException {
|
||||
return Files.readAllLines(filelist).stream()
|
||||
.flatMap(it -> Arrays.stream(it.split(",")))
|
||||
.map(String::trim)
|
||||
.filter(StringUtils::isNotBlank)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user