File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
main/java/io/github/treesitter/jtreesitter
test/java/io/github/treesitter/jtreesitter Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -234,6 +234,24 @@ public Optional<Node> getNamedChild(@Unsigned int index) throws IndexOutOfBounds
234234 return optional (ts_node_named_child (arena , self , index ));
235235 }
236236
237+ /**
238+ * Get the node's first child that contains or starts after the given byte offset.
239+ *
240+ * @since 0.25.0
241+ */
242+ public Optional <Node > getFirstChildForByte (@ Unsigned int byte_offset ) {
243+ return optional (ts_node_first_child_for_byte (arena , self , byte_offset ));
244+ }
245+
246+ /**
247+ * Get the node's first <em>named</em> child that contains or starts after the given byte offset.
248+ *
249+ * @since 0.25.0
250+ */
251+ public Optional <Node > getFirstNamedChildForByte (@ Unsigned int byte_offset ) {
252+ return optional (ts_node_first_named_child_for_byte (arena , self , byte_offset ));
253+ }
254+
237255 /**
238256 * Get the node's first child with the given field ID, if any.
239257 *
Original file line number Diff line number Diff line change @@ -171,6 +171,18 @@ void getNamedChild() {
171171 assertEquals ("class_declaration" , child .getGrammarType ());
172172 }
173173
174+ @ Test
175+ void getFirstChildForByte () {
176+ var child = node .getFirstChildForByte (15 ).orElseThrow ();
177+ assertEquals ("line_comment" , child .getGrammarType ());
178+ }
179+
180+ @ Test
181+ void getFirstNamedChildForByte () {
182+ var child = node .getFirstNamedChildForByte (15 ).orElseThrow ();
183+ assertEquals ("line_comment" , child .getGrammarType ());
184+ }
185+
174186 @ Test
175187 void getChildByFieldId () {
176188 var child = node .getChild (0 ).orElseThrow ();
You can’t perform that action at this time.
0 commit comments