Package ch.usi.si.seart.treesitter
Class Tree
- java.lang.Object
-
- ch.usi.si.seart.treesitter.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 containsNodeinstances that indicate the structure of the source code.- Since:
- 1.0.0
- Author:
- Tommy MacWilliam, Ozren Dabić
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Treeclone()Clone this tree, creating a separate, independent instance.voidclose()Delete the external resource, freeing all the memory that it used.voidedit(@NotNull InputEdit edit)Edit the syntax tree to keep it in sync with source code that has been edited.booleanequals(Object obj)NodegetRootNode()Get the topmostNodeof the syntax tree.inthashCode()booleanisNull()Checks whether the memory address associated with this external resource isnullptr.@NotNull Iterator<Node>iterator()Returns an iterator over the entire syntax tree, starting from the root.-
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
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 topmostNodeof 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:
iteratorin interfaceIterable<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 isnullptr.- Returns:
trueif the memory address is 0, otherwisefalse
-
close
public void close()
Delete the external resource, freeing all the memory that it used.- Specified by:
closein interfaceAutoCloseable
-
-