Class FullIdent


  • public final class FullIdent
    extends Object
    Represents a full identifier, including dots, with associated position information.

    Identifiers such as java.util.HashMap are spread across multiple AST nodes in the syntax tree (three IDENT nodes, two DOT nodes). A FullIdent represents the whole String (excluding any intermediate whitespace), which is often easier to work with in Checks.

    See Also:
    TokenTypes.DOT, TokenTypes.IDENT
    • Field Detail

      • elements

        private final List<String> elements
        The list holding subsequent elements of identifier.
      • detailAst

        private DetailAST detailAst
        The topmost and leftmost AST of the full identifier.
    • Constructor Detail

      • FullIdent

        private FullIdent()
        Hide default constructor.
    • Method Detail

      • createFullIdentBelow

        public static FullIdent createFullIdentBelow​(DetailAST ast)
        Creates a new FullIdent starting from the child of the specified node.
        Parameters:
        ast - the parent node from where to start from
        Returns:
        a FullIdent value
      • createFullIdent

        public static FullIdent createFullIdent​(DetailAST ast)
        Creates a new FullIdent starting from the specified node.
        Parameters:
        ast - the node to start from
        Returns:
        a FullIdent value
      • extractFullIdent

        private static void extractFullIdent​(FullIdent full,
                                             DetailAST ast)
        Recursively extract a FullIdent.
        Parameters:
        full - the FullIdent to add to
        ast - the node to recurse from
      • isArrayTypeDeclaration

        private static boolean isArrayTypeDeclaration​(DetailAST arrayDeclarator)
        Checks an `ARRAY_DECLARATOR` ast to verify that it is not an array initialization, i.e. 'new int [2][2]'. We do this by making sure that no 'EXPR' token exists in this branch.
        Parameters:
        arrayDeclarator - the first ARRAY_DECLARATOR token in the ast
        Returns:
        true if ast is an array type declaration
      • appendBrackets

        private static void appendBrackets​(FullIdent full,
                                           DetailAST ast)
        Appends the brackets of an array type to a FullIdent.
        Parameters:
        full - the FullIdent to append brackets to
        ast - the type ast we are building a FullIdent for
      • getText

        public String getText()
        Gets the text.
        Returns:
        the text
      • getDetailAst

        public DetailAST getDetailAst()
        Gets the topmost leftmost DetailAST for this FullIdent.
        Returns:
        the topmost leftmost ast
      • getLineNo

        public int getLineNo()
        Gets the line number.
        Returns:
        the line number
      • getColumnNo

        public int getColumnNo()
        Gets the column number.
        Returns:
        the column number
      • append

        private void append​(String text)
        Append the specified text.
        Parameters:
        text - the text to append
      • append

        private void append​(DetailAST ast)
        Append the specified token and also recalibrate the first line and column.
        Parameters:
        ast - the token to append