Class LeftCurlyCheck

    • Method Detail

      • setOption

        public void setOption​(String optionStr)
        Setter to specify the policy on placement of a left curly brace ('{').
        Parameters:
        optionStr - string to decode option from
        Throws:
        IllegalArgumentException - if unable to decode
        Since:
        3.0
      • setIgnoreEnums

        public void setIgnoreEnums​(boolean ignoreEnums)
        Setter to allow to ignore enums when left curly brace policy is EOL.
        Parameters:
        ignoreEnums - check's option for ignoring enums.
        Since:
        6.9
      • 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:
        TokenTypes
      • getBraceFromSwitchMember

        @Nullable
        private static DetailAST getBraceFromSwitchMember​(DetailAST ast)
        Gets the brace of a switch statement/ expression member.
        Parameters:
        ast - DetailAST.
        Returns:
        DetailAST if the first child is TokenTypes.SLIST, null otherwise.
      • getBraceAsFirstChild

        @Nullable
        private static DetailAST getBraceAsFirstChild​(DetailAST ast)
        Gets a SLIST if it is the first child of the AST.
        Parameters:
        ast - DetailAST.
        Returns:
        DetailAST if the first child is TokenTypes.SLIST, null otherwise.
      • skipModifierAnnotations

        private static DetailAST skipModifierAnnotations​(DetailAST ast)
        Skip all TokenTypes.ANNOTATIONs to the first non-annotation.
        Parameters:
        ast - DetailAST.
        Returns:
        DetailAST.
      • findLastAnnotation

        private static DetailAST findLastAnnotation​(DetailAST modifiers)
        Find the last token of type TokenTypes.ANNOTATION under the given set of modifiers.
        Parameters:
        modifiers - DetailAST.
        Returns:
        DetailAST or null if there are no annotations.
      • verifyBrace

        private void verifyBrace​(DetailAST brace,
                                 DetailAST startToken)
        Verifies that a specified left curly brace is placed correctly according to policy.
        Parameters:
        brace - token for left curly brace
        startToken - token for start of expression
      • validateEol

        private void validateEol​(DetailAST brace,
                                 String braceLine)
        Validate EOL case.
        Parameters:
        brace - brace AST
        braceLine - line content
      • validateNewLinePosition

        private void validateNewLinePosition​(DetailAST brace,
                                             DetailAST startToken,
                                             String braceLine)
        Validate token on new Line position.
        Parameters:
        brace - brace AST
        startToken - start Token
        braceLine - content of line with Brace
      • hasLineBreakAfter

        private boolean hasLineBreakAfter​(DetailAST leftCurly)
        Checks if left curly has line break after.
        Parameters:
        leftCurly - Left curly token.
        Returns:
        True, left curly has line break after.