Class Tree

  • All Implemented Interfaces:
    AutoCloseable, Cloneable, Iterable<Node>

    public class Tree
    extends Object
    implements Iterable<Node>, Cloneable
    A Tree represents the syntax tree of an entire source code file. It contains Node instances that indicate the structure of the source code.
    Since:
    1.0.0
    Author:
    Tommy MacWilliam, Ozren Dabić
    • Method Detail

      • edit

        public void edit​(@NotNull
                         @NotNull InputEdit edit)
        Edit the syntax tree to keep it in sync with source code that has been edited.
        Parameters:
        edit - changes made to the source code in terms of both byte offsets and row/column coordinates
      • getRootNode

        public Node getRootNode()
        Get the topmost Node of the syntax tree.
        Returns:
        the root node of the syntax tree
      • iterator

        @NotNull
        public @NotNull Iterator<Node> iterator()
        Returns an iterator over the entire syntax tree, starting from the root.
        Specified by:
        iterator in interface Iterable<Node>
        Returns:
        an iterator over syntax tree nodes
        See Also:
        Node.iterator()
      • clone

        public Tree clone()
        Clone this tree, creating a separate, independent instance.
        Returns:
        a clone of this instance
        Since:
        1.6.0
      • isNull

        public final boolean isNull()
        Checks whether the memory address associated with this external resource is nullptr.
        Returns:
        true if the memory address is 0, otherwise false
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • close

        public void close()
        Delete the external resource, freeing all the memory that it used.
        Specified by:
        close in interface AutoCloseable