Class UnnecessarySemicolonInEnumerationCheck

All Implemented Interfaces:
Configurable, Contextualizable

Checks if unnecessary semicolon is in enum definitions. Semicolon is not needed if enum body contains only enum constants.
Since:
8.22
  • Field Details

  • Constructor Details

  • Method Details

    • getDefaultTokens

      public int[] getDefaultTokens()
      Description copied from class: AbstractCheck
      Returns the default token a check is interested in. Only used if the configuration for a check does not define the tokens.
      Specified by:
      getDefaultTokens in class AbstractCheck
      Returns:
      the default tokens
      See Also:
    • getAcceptableTokens

      public int[] getAcceptableTokens()
      Description copied from class: AbstractCheck
      The configurable token set. Used to protect Checks against malicious users who specify an unacceptable token set in the configuration file. The default implementation returns the check's default tokens.
      Specified by:
      getAcceptableTokens in class AbstractCheck
      Returns:
      the token set this check is designed for.
      See Also:
    • getRequiredTokens

      public int[] getRequiredTokens()
      Description copied from class: AbstractCheck
      The tokens that this check must be registered for.
      Specified by:
      getRequiredTokens in class AbstractCheck
      Returns:
      the token set this must be registered for.
      See Also:
    • visitToken

      public void visitToken(DetailAST ast)
      Description copied from class: AbstractCheck
      Called to process a token.
      Overrides:
      visitToken in class AbstractCheck
      Parameters:
      ast - the token to process
    • hasMembersAfterConstants

      private static boolean hasMembersAfterConstants(DetailAST enumBlock)
      Checks if enum body contains any member (method, constructor, field, etc.) in addition to enum constants and semicolons.
      Parameters:
      enumBlock - the enum body to check
      Returns:
      true if enum body has members, false if it only has constants and semicolons.
    • isPrecededBySemi

      private static boolean isPrecededBySemi(DetailAST ast)
      Checks if semicolon is immediately preceded by another semicolon, making it a redundant duplicate.
      Parameters:
      ast - semicolon to check
      Returns:
      true if previous sibling is also a semicolon, false otherwise.