Package net.sourceforge.pmd.cpd.impl
Class BaseTokenFilter<T extends GenericToken<T>>
- java.lang.Object
-
- net.sourceforge.pmd.cpd.impl.BaseTokenFilter<T>
-
- All Implemented Interfaces:
TokenManager<T>
- Direct Known Subclasses:
AntlrTokenFilter
,JavaCCTokenFilter
public class BaseTokenFilter<T extends GenericToken<T>> extends Object implements TokenManager<T>
A generic filter for PMD token managers that allows to use comments to enable / disable analysis of parts of the stream
-
-
Constructor Summary
Constructors Constructor Description BaseTokenFilter(TokenManager<T> tokenManager)
Creates a new BaseTokenFilter
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
analyzeToken(T currentToken)
Extension point for subclasses to analyze all tokens (before filtering) and update internal status to decide on custom discard rules.protected void
analyzeTokens(T currentToken, Iterable<T> remainingTokens)
Extension point for subclasses to analyze all tokens (before filtering) and update internal status to decide on custom discard rules.T
getNextToken()
protected boolean
isLanguageSpecificDiscarding()
Extension point for subclasses to indicate tokens are to be filtered.protected boolean
shouldStopProcessing(T currentToken)
Extension point for subclasses to indicate when to stop filtering tokens.
-
-
-
Constructor Detail
-
BaseTokenFilter
public BaseTokenFilter(TokenManager<T> tokenManager)
Creates a new BaseTokenFilter- Parameters:
tokenManager
- The token manager from which to retrieve tokens to be filtered
-
-
Method Detail
-
getNextToken
public final T getNextToken()
- Specified by:
getNextToken
in interfaceTokenManager<T extends GenericToken<T>>
-
analyzeToken
protected void analyzeToken(T currentToken)
Extension point for subclasses to analyze all tokens (before filtering) and update internal status to decide on custom discard rules.- Parameters:
currentToken
- The token to be analyzed- See Also:
isLanguageSpecificDiscarding()
-
analyzeTokens
protected void analyzeTokens(T currentToken, Iterable<T> remainingTokens)
Extension point for subclasses to analyze all tokens (before filtering) and update internal status to decide on custom discard rules.- Parameters:
currentToken
- The token to be analyzedremainingTokens
- All upcoming tokens- See Also:
isLanguageSpecificDiscarding()
-
isLanguageSpecificDiscarding
protected boolean isLanguageSpecificDiscarding()
Extension point for subclasses to indicate tokens are to be filtered.- Returns:
- True if tokens should be filtered, false otherwise
-
shouldStopProcessing
protected boolean shouldStopProcessing(T currentToken)
Extension point for subclasses to indicate when to stop filtering tokens.- Parameters:
currentToken
- The token to be analyzed- Returns:
- True if the token filter has finished consuming all tokens, false otherwise
-
-