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
    Creates a new BaseTokenFilter
  • Method Summary

    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.
    final T
     
    protected boolean
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BaseTokenFilter

      public BaseTokenFilter(TokenManager<T> tokenManager)
      Creates a new BaseTokenFilter
      Parameters:
      tokenManager - The token manager from which to retrieve tokens to be filtered
  • Method Details

    • getNextToken

      public final T getNextToken()
      Specified by:
      getNextToken in interface TokenManager<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:
    • 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 analyzed
      remainingTokens - All upcoming tokens
      See Also:
    • 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