Class DetailAstImpl

  • All Implemented Interfaces:
    DetailAST

    public final class DetailAstImpl
    extends java.lang.Object
    implements DetailAST
    The implementation of DetailAST. This should only be directly used to create custom AST nodes and in 'JavaAstVisitor.java'.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.BitSet branchTokenTypes
      All token types in this branch.
      private int childCount
      Number of children.
      private int columnNo
      The column number.
      private DetailAstImpl firstChild
      First child of this DetailAST.
      private java.util.List<org.antlr.v4.runtime.Token> hiddenAfter
      All tokens on COMMENTS channel to the right of the current token up to the next token on the DEFAULT_TOKEN_CHANNEL.
      private java.util.List<org.antlr.v4.runtime.Token> hiddenBefore
      All tokens on COMMENTS channel to the left of the current token up to the preceding token on the DEFAULT_TOKEN_CHANNEL.
      private int lineNo
      The line number.
      private DetailAstImpl nextSibling
      First sibling of this DetailAST.
      private static int NOT_INITIALIZED
      Constant to indicate if not calculated the child count.
      private DetailAstImpl parent
      The parent token.
      private DetailAstImpl previousSibling
      Previous sibling.
      private java.lang.String text
      Text of this DetailAST.
      private int type
      The type of this DetailAST.
    • Constructor Summary

      Constructors 
      Constructor Description
      DetailAstImpl()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addChild​(DetailAST child)
      Adds a new child to the current AST.
      void addNextSibling​(DetailAST ast)
      Add next sibling, pushes other siblings back.
      void addPreviousSibling​(DetailAST ast)
      Add previous sibling.
      boolean branchContains​(int tokenType)
      Checks if this branch of the parse tree contains a token of the provided type.
      private void clearBranchTokenTypes()
      Clears branchTokenTypes cache for all parents of the current DetailAST instance, and the child count for the current DetailAST instance.
      private static void clearChildCountCache​(DetailAstImpl ast)
      Clears the child count for the ast instance.
      private static int findColumnNo​(DetailAST ast)
      Finds column number in the first non-comment node.
      DetailAST findFirstToken​(int tokenType)
      Returns the first child token that makes a specified type.
      private static int findLineNo​(DetailAST ast)
      Finds line number in the first non-comment node.
      private java.util.BitSet getBranchTokenTypes()
      Returns token type with branch.
      int getChildCount()
      Returns the number of child nodes one level below this node.
      int getChildCount​(int tokenType)
      Returns the number of direct child tokens that have the specified type.
      int getColumnNo()
      Gets column number.
      DetailAstImpl getFirstChild()
      Get the first child of this AST.
      java.util.List<org.antlr.v4.runtime.Token> getHiddenAfter()
      Get list tokens on COMMENTS channel to the right of the current token up to the next token on the DEFAULT_TOKEN_CHANNEL.
      java.util.List<org.antlr.v4.runtime.Token> getHiddenBefore()
      Get list of tokens on COMMENTS channel to the left of the current token up to the preceding token on the DEFAULT_TOKEN_CHANNEL.
      DetailAST getLastChild()
      Gets the last child node.
      int getLineNo()
      Gets line number.
      DetailAstImpl getNextSibling()
      Get the next sibling in line after this one.
      int getNumberOfChildren()
      Get number of children of this AST.
      DetailAST getParent()
      Returns the parent token.
      DetailAST getPreviousSibling()
      Returns the previous sibling or null if no such sibling exists.
      java.lang.String getText()
      Gets the text of this AST.
      int getType()
      Gets the type of this AST.
      boolean hasChildren()
      Returns whether this AST has any children.
      void initialize​(int tokenType, java.lang.String tokenText)
      Initializes this DetailAstImpl.
      void initialize​(org.antlr.v4.runtime.Token token)
      Initializes this DetailAstImpl.
      void removeChildren()
      Removes all children of this AST.
      void setColumnNo​(int columnNo)
      Set column number.
      void setFirstChild​(DetailAST firstChild)
      Sets the first child of this AST.
      void setHiddenAfter​(java.util.List<org.antlr.v4.runtime.Token> hiddenAfter)
      Sets the hiddenAfter token field.
      void setHiddenBefore​(java.util.List<org.antlr.v4.runtime.Token> hiddenBefore)
      Sets the hiddenBefore token field.
      void setLineNo​(int lineNo)
      Set line number.
      void setNextSibling​(DetailAST nextSibling)
      Sets the next sibling of this AST.
      private void setParent​(DetailAstImpl parent)
      Set the parent token.
      void setText​(java.lang.String text)
      Sets the text for this DetailAstImpl.
      void setType​(int type)
      Sets the type of this AST.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • lineNo

        private int lineNo
        The line number.
      • columnNo

        private int columnNo
        The column number.
      • childCount

        private int childCount
        Number of children.
      • text

        private java.lang.String text
        Text of this DetailAST.
      • type

        private int type
        The type of this DetailAST.
      • hiddenBefore

        private java.util.List<org.antlr.v4.runtime.Token> hiddenBefore
        All tokens on COMMENTS channel to the left of the current token up to the preceding token on the DEFAULT_TOKEN_CHANNEL.
      • hiddenAfter

        private java.util.List<org.antlr.v4.runtime.Token> hiddenAfter
        All tokens on COMMENTS channel to the right of the current token up to the next token on the DEFAULT_TOKEN_CHANNEL.
      • branchTokenTypes

        private java.util.BitSet branchTokenTypes
        All token types in this branch. Token 'x' (where x is an int) is in this branch if branchTokenTypes.get(x) is true.
    • Method Detail

      • initialize

        public void initialize​(int tokenType,
                               java.lang.String tokenText)
        Initializes this DetailAstImpl.
        Parameters:
        tokenType - the type of this DetailAstImpl
        tokenText - the text of this DetailAstImpl
      • initialize

        public void initialize​(org.antlr.v4.runtime.Token token)
        Initializes this DetailAstImpl.
        Parameters:
        token - the token to generate this DetailAstImpl from
      • addNextSibling

        public void addNextSibling​(DetailAST ast)
        Add next sibling, pushes other siblings back.
        Parameters:
        ast - DetailAST object.
      • addChild

        public void addChild​(DetailAST child)
        Adds a new child to the current AST.
        Parameters:
        child - to DetailAST to add as child
      • getChildCount

        public int getChildCount()
        Description copied from interface: DetailAST
        Returns the number of child nodes one level below this node. That is, does not recurse down the tree.
        Specified by:
        getChildCount in interface DetailAST
        Returns:
        the number of child nodes
      • getChildCount

        public int getChildCount​(int tokenType)
        Description copied from interface: DetailAST
        Returns the number of direct child tokens that have the specified type.
        Specified by:
        getChildCount in interface DetailAST
        Parameters:
        tokenType - the token type to match
        Returns:
        the number of matching token
      • setParent

        private void setParent​(DetailAstImpl parent)
        Set the parent token.
        Parameters:
        parent - the parent token
      • getText

        public java.lang.String getText()
        Description copied from interface: DetailAST
        Gets the text of this AST.
        Specified by:
        getText in interface DetailAST
        Returns:
        the text.
      • setText

        public void setText​(java.lang.String text)
        Sets the text for this DetailAstImpl.
        Parameters:
        text - the text field of this DetailAstImpl
      • getType

        public int getType()
        Description copied from interface: DetailAST
        Gets the type of this AST.
        Specified by:
        getType in interface DetailAST
        Returns:
        the type.
      • setType

        public void setType​(int type)
        Sets the type of this AST.
        Parameters:
        type - the token type of this DetailAstImpl
      • setLineNo

        public void setLineNo​(int lineNo)
        Set line number.
        Parameters:
        lineNo - line number.
      • setColumnNo

        public void setColumnNo​(int columnNo)
        Set column number.
        Parameters:
        columnNo - column number.
      • findColumnNo

        private static int findColumnNo​(DetailAST ast)
        Finds column number in the first non-comment node.
        Parameters:
        ast - DetailAST node.
        Returns:
        Column number if non-comment node exists, -1 otherwise.
      • findLineNo

        private static int findLineNo​(DetailAST ast)
        Finds line number in the first non-comment node.
        Parameters:
        ast - DetailAST node.
        Returns:
        Line number if non-comment node exists, -1 otherwise.
      • getBranchTokenTypes

        private java.util.BitSet getBranchTokenTypes()
        Returns token type with branch.
        Returns:
        the token types that occur in the branch as a sorted set.
      • branchContains

        public boolean branchContains​(int tokenType)
        Description copied from interface: DetailAST
        Checks if this branch of the parse tree contains a token of the provided type.
        Specified by:
        branchContains in interface DetailAST
        Parameters:
        tokenType - a TokenType
        Returns:
        true if and only if this branch (including this node) contains a token of type type.
      • findFirstToken

        public DetailAST findFirstToken​(int tokenType)
        Description copied from interface: DetailAST
        Returns the first child token that makes a specified type.
        Specified by:
        findFirstToken in interface DetailAST
        Parameters:
        tokenType - the token type to match
        Returns:
        the matching token, or null if no match
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • hasChildren

        public boolean hasChildren()
        Description copied from interface: DetailAST
        Returns whether this AST has any children.
        Specified by:
        hasChildren in interface DetailAST
        Returns:
        true if this AST has any children.
      • clearChildCountCache

        private static void clearChildCountCache​(DetailAstImpl ast)
        Clears the child count for the ast instance.
        Parameters:
        ast - The ast to clear.
      • clearBranchTokenTypes

        private void clearBranchTokenTypes()
        Clears branchTokenTypes cache for all parents of the current DetailAST instance, and the child count for the current DetailAST instance.
      • setNextSibling

        public void setNextSibling​(DetailAST nextSibling)
        Sets the next sibling of this AST.
        Parameters:
        nextSibling - the DetailAST to set as sibling
      • setFirstChild

        public void setFirstChild​(DetailAST firstChild)
        Sets the first child of this AST.
        Parameters:
        firstChild - the DetailAST to set as first child
      • removeChildren

        public void removeChildren()
        Removes all children of this AST.
      • getHiddenBefore

        public java.util.List<org.antlr.v4.runtime.Token> getHiddenBefore()
        Get list of tokens on COMMENTS channel to the left of the current token up to the preceding token on the DEFAULT_TOKEN_CHANNEL.
        Returns:
        list of comment tokens
      • getHiddenAfter

        public java.util.List<org.antlr.v4.runtime.Token> getHiddenAfter()
        Get list tokens on COMMENTS channel to the right of the current token up to the next token on the DEFAULT_TOKEN_CHANNEL.
        Returns:
        list of comment tokens
      • setHiddenBefore

        public void setHiddenBefore​(java.util.List<org.antlr.v4.runtime.Token> hiddenBefore)
        Sets the hiddenBefore token field.
        Parameters:
        hiddenBefore - comment token preceding this DetailAstImpl
      • setHiddenAfter

        public void setHiddenAfter​(java.util.List<org.antlr.v4.runtime.Token> hiddenAfter)
        Sets the hiddenAfter token field.
        Parameters:
        hiddenAfter - comment token following this DetailAstImpl