Class BaseTokenFilter<T extends GenericToken>
- java.lang.Object
-
- net.sourceforge.pmd.cpd.token.internal.BaseTokenFilter<T>
-
- All Implemented Interfaces:
TokenFilter
- Direct Known Subclasses:
AntlrTokenFilter
,JavaCCTokenFilter
public abstract class BaseTokenFilter<T extends GenericToken> extends java.lang.Object implements TokenFilter
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 tokenManager)
Creates a new BaseTokenFilter
-
Method Summary
All Methods Instance Methods Abstract 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.T
getNextToken()
Retrieves the next token to pass the filterprotected boolean
isLanguageSpecificDiscarding()
Extension point for subclasses to indicate tokens are to be filtered.protected abstract boolean
shouldStopProcessing(T currentToken)
Extension point for subclasses to indicate when to stop filtering tokens.
-
-
-
Constructor Detail
-
BaseTokenFilter
public BaseTokenFilter(TokenManager 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()
Description copied from interface:TokenFilter
Retrieves the next token to pass the filter- Specified by:
getNextToken
in interfaceTokenFilter
- Returns:
- The next token to pass the filter, or null if the end of the stream was reached
-
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()
-
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 abstract 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
-
-