Class AstRoot

    • Constructor Detail

      • AstRoot

        public AstRoot()
      • AstRoot

        public AstRoot​(int pos)
    • Method Detail

      • getComments

        public SortedSet<Comment> getComments()
        Returns comment set
        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.
        comments - comment list. can be null.
      • addComment

        public void addComment​(Comment comment)
        Add a comment to the comment set.
        comment - the comment node.
        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.
        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.

        toSource in class Scope
        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).
        debugPrint in class AstNode
        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.
        IllegalStateException - if a parent link is missing