Package ch.usi.si.seart.treesitter
Class OffsetTreeCursor
- java.lang.Object
-
- ch.usi.si.seart.treesitter.TreeCursor
-
- ch.usi.si.seart.treesitter.OffsetTreeCursor
-
- All Implemented Interfaces:
AutoCloseable
public class OffsetTreeCursor extends TreeCursor
Specialization ofTreeCursorthat applies a positional offset to visited nodes. Retrieving nodes by eithergetCurrentNode()orgetCurrentTreeCursorNode()applies the offset to a copy of the original node, meaning that the tree is not mutated during traversal.So what exactly is the purpose of this cursor? Imagine a scenario in which we need to print out the node positions of a source code file that begins with
nblank lines. Rather than modifying the original file, we can just use this cursor with a positional offset ofnew Position(-n, 0). Likewise, when printing node positions of an indented function, thenspaces of indentation can be negated with a positional offset ofnew Position(0, -n). Row and column offsets can be combined with various positive and negative arrangements.- Since:
- 1.2.0
- Author:
- Ozren Dabić
-
-
Constructor Summary
Constructors Constructor Description OffsetTreeCursor(Node node, Point offset)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)NodegetCurrentNode()TreeCursorNodegetCurrentTreeCursorNode()inthashCode()booleanisNull()-
Methods inherited from class ch.usi.si.seart.treesitter.TreeCursor
close, getCurrentFieldName, gotoFirstChild, gotoNextSibling, gotoParent, preorderTraversal, toString
-
-
-
-
Method Detail
-
getCurrentNode
public Node getCurrentNode()
- Overrides:
getCurrentNodein classTreeCursor- Returns:
- The tree cursor's current node
-
getCurrentTreeCursorNode
public TreeCursorNode getCurrentTreeCursorNode()
- Overrides:
getCurrentTreeCursorNodein classTreeCursor- Returns:
- The tree cursor's current node
-
isNull
public final boolean isNull()
-
-