Package net.sourceforge.pmd.cache
Class AbstractAnalysisCache
- java.lang.Object
-
- net.sourceforge.pmd.cache.AbstractAnalysisCache
-
- All Implemented Interfaces:
AnalysisCache
- Direct Known Subclasses:
FileAnalysisCache
@Deprecated @InternalApi public abstract class AbstractAnalysisCache extends Object implements AnalysisCache
Deprecated.This is internal API, will be hidden with 7.0.0Abstract implementation of the analysis cache. Handles all operations, except for persistence.
-
-
Field Summary
Fields Modifier and Type Field Description protected long
auxClassPathChecksum
Deprecated.protected long
executionClassPathChecksum
Deprecated.protected ConcurrentMap<FileId,AnalysisResult>
fileResultsCache
Deprecated.protected static net.sourceforge.pmd.cache.internal.ClasspathFingerprinter
FINGERPRINTER
Deprecated.protected static org.slf4j.Logger
LOG
Deprecated.protected String
pmdVersion
Deprecated.protected CachedRuleMapper
ruleMapper
Deprecated.protected long
rulesetChecksum
Deprecated.protected ConcurrentMap<FileId,AnalysisResult>
updatedResultsCache
Deprecated.
-
Constructor Summary
Constructors Constructor Description AbstractAnalysisCache()
Deprecated.Creates a new empty cache
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
analysisFailed(TextDocument sourceFile)
Deprecated.Notifies the cache that analysis of the given file has failed and should not be cached.protected abstract boolean
cacheExists()
Deprecated.Returns true if the cache exists.void
checkValidity(RuleSets ruleSets, ClassLoader auxclassPathClassLoader, Collection<? extends TextFile> files)
Deprecated.Checks if the cache is valid for the configured rulesets and class loader.List<RuleViolation>
getCachedViolations(TextDocument sourceFile)
Deprecated.Retrieves cached violations for the given file.boolean
isUpToDate(TextDocument document)
Deprecated.Checks if a given file is up to date in the cache and can be skipped from analysis.FileAnalysisListener
startFileAnalysis(TextDocument file)
Deprecated.Returns a listener that will be used like inGlobalAnalysisListener.startFileAnalysis(TextFile)
.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.sourceforge.pmd.cache.AnalysisCache
persist
-
-
-
-
Field Detail
-
LOG
protected static final org.slf4j.Logger LOG
Deprecated.
-
FINGERPRINTER
protected static final net.sourceforge.pmd.cache.internal.ClasspathFingerprinter FINGERPRINTER
Deprecated.
-
pmdVersion
protected final String pmdVersion
Deprecated.
-
fileResultsCache
protected final ConcurrentMap<FileId,AnalysisResult> fileResultsCache
Deprecated.
-
updatedResultsCache
protected final ConcurrentMap<FileId,AnalysisResult> updatedResultsCache
Deprecated.
-
ruleMapper
protected final CachedRuleMapper ruleMapper
Deprecated.
-
rulesetChecksum
protected long rulesetChecksum
Deprecated.
-
auxClassPathChecksum
protected long auxClassPathChecksum
Deprecated.
-
executionClassPathChecksum
protected long executionClassPathChecksum
Deprecated.
-
-
Method Detail
-
isUpToDate
public boolean isUpToDate(TextDocument document)
Deprecated.Description copied from interface:AnalysisCache
Checks if a given file is up to date in the cache and can be skipped from analysis. Regardless of the return value of this method, each call adds the parameter to the updated cache, which allowsFileAnalysisListener.onRuleViolation(RuleViolation)
to add a rule violation to the file. TODO is this really best behaviour? This side-effects seems counter-intuitive.- Specified by:
isUpToDate
in interfaceAnalysisCache
- Parameters:
document
- The file to check in the cache- Returns:
- True if the cache is a hit, false otherwise
-
getCachedViolations
public List<RuleViolation> getCachedViolations(TextDocument sourceFile)
Deprecated.Description copied from interface:AnalysisCache
Retrieves cached violations for the given file. Make sure to callAnalysisCache.isUpToDate(TextDocument)
first.- Specified by:
getCachedViolations
in interfaceAnalysisCache
- Parameters:
sourceFile
- The file to check in the cache- Returns:
- The list of cached violations.
-
analysisFailed
public void analysisFailed(TextDocument sourceFile)
Deprecated.Description copied from interface:AnalysisCache
Notifies the cache that analysis of the given file has failed and should not be cached.- Specified by:
analysisFailed
in interfaceAnalysisCache
- Parameters:
sourceFile
- The file whose analysis failed
-
cacheExists
protected abstract boolean cacheExists()
Deprecated.Returns true if the cache exists. If so, normal cache validity checks will be performed. Otherwise, the cache is necessarily invalid (e.g. on a first run).
-
checkValidity
public void checkValidity(RuleSets ruleSets, ClassLoader auxclassPathClassLoader, Collection<? extends TextFile> files)
Deprecated.Description copied from interface:AnalysisCache
Checks if the cache is valid for the configured rulesets and class loader. If the provided rulesets and classpath don't match those of the cache, the cache is invalidated. This needs to be called before analysis, as it conditions the good behaviour ofAnalysisCache.isUpToDate(TextDocument)
.- Specified by:
checkValidity
in interfaceAnalysisCache
- Parameters:
ruleSets
- The rulesets configured for this analysis.auxclassPathClassLoader
- The class loader for auxclasspath configured for this analysis.files
- Set of files in the current analysis. File records in the cache are matched to the file IDs of these files.
-
startFileAnalysis
public FileAnalysisListener startFileAnalysis(TextDocument file)
Deprecated.Description copied from interface:AnalysisCache
Returns a listener that will be used like inGlobalAnalysisListener.startFileAnalysis(TextFile)
. This should record violations, and callAnalysisCache.analysisFailed(TextDocument)
upon error.- Specified by:
startFileAnalysis
in interfaceAnalysisCache
-
-