Class AstRoot

    • Constructor Detail

      • AstRoot

        public AstRoot()
      • AstRoot

        public AstRoot​(int pos)
    • Method Detail

      • getComments

        public SortedSet<Comment> getComments()
        Returns comment set
        Returns:
        comment set, sorted by start position. Can be null.
      • setComments

        public void setComments​(SortedSet<Comment> comments)
        Sets comment list, and updates the parent of each entry to point to this node. Replaces any existing comments.
        Parameters:
        comments - comment list. can be null.
      • addComment

        public void addComment​(Comment comment)
        Add a comment to the comment set.
        Parameters:
        comment - the comment node.
        Throws:
        IllegalArgumentException - if comment is null
      • setInStrictMode

        public void setInStrictMode​(boolean inStrictMode)
      • isInStrictMode

        public boolean isInStrictMode()
      • visitComments

        public void visitComments​(NodeVisitor visitor)
        Visits the comment nodes in the order they appear in the source code. The comments are not visited by the ScriptNode.visit(org.mozilla.javascript.ast.NodeVisitor) function - you must use this function to visit them.
        Parameters:
        visitor - the callback object. It is passed each comment node. The return value is ignored.
      • toSource

        public String toSource​(int depth)
        Description copied from class: AstNode
        Emits source code for this node. Callee is responsible for calling this function recursively on children, incrementing indent as appropriate.

        Note: if the parser was in error-recovery mode, some AST nodes may have null children that are expected to be non-null when no errors are present. In this situation, the behavior of the toSource method is undefined: toSource implementations may assume that the AST node is error-free, since it is intended to be invoked only at runtime after a successful parse.

        Overrides:
        toSource in class Scope
        Parameters:
        depth - the current recursion depth, typically beginning at 0 when called on the root node.
      • debugPrint

        public String debugPrint()
        A debug-printer that includes comments (at the end).
        Overrides:
        debugPrint in class AstNode
        Returns:
        a very verbose indented printout of the tree. The format of each line is: abs-pos name position length [identifier]
      • checkParentLinks

        public void checkParentLinks()
        Debugging function to check that the parser has set the parent link for every node in the tree.
        Throws:
        IllegalStateException - if a parent link is missing