diff options
author | Riley Bruins <ribru17@hotmail.com> | 2025-03-20 14:57:58 -0700 |
---|---|---|
committer | Christian Clason <ch.clason+github@icloud.com> | 2025-03-21 09:01:47 +0100 |
commit | fa85543e3b6d4ff4643b460096dda315f145ef89 (patch) | |
tree | cda277b3476a3bfe8937df3ba81243bf5cc8e8fc | |
parent | 175c09bd660d0cea62288e74cea925a9b15bee55 (diff) | |
download | rneovim-fa85543e3b6d4ff4643b460096dda315f145ef89.tar.gz rneovim-fa85543e3b6d4ff4643b460096dda315f145ef89.tar.bz2 rneovim-fa85543e3b6d4ff4643b460096dda315f145ef89.zip |
docs(treesitter): document TSNode:named_children()
This commit also gives an internal documentation description for
`TSNode:__has_ancestor()`.
-rw-r--r-- | runtime/doc/treesitter.txt | 6 | ||||
-rw-r--r-- | runtime/lua/vim/treesitter/_meta/tsnode.lua | 11 |
2 files changed, 15 insertions, 2 deletions
diff --git a/runtime/doc/treesitter.txt b/runtime/doc/treesitter.txt index 6c98d46778..3d246601b9 100644 --- a/runtime/doc/treesitter.txt +++ b/runtime/doc/treesitter.txt @@ -804,6 +804,12 @@ TSNode:named_child_count() *TSNode:named_child_count()* Return: ~ (`integer`) +TSNode:named_children() *TSNode:named_children()* + Returns a list of the node's named children. + + Return: ~ + (`TSNode[]`) + *TSNode:named_descendant_for_range()* TSNode:named_descendant_for_range({start_row}, {start_col}, {end_row}, {end_col}) diff --git a/runtime/lua/vim/treesitter/_meta/tsnode.lua b/runtime/lua/vim/treesitter/_meta/tsnode.lua index 2f9d7f214a..de4b71c697 100644 --- a/runtime/lua/vim/treesitter/_meta/tsnode.lua +++ b/runtime/lua/vim/treesitter/_meta/tsnode.lua @@ -10,8 +10,6 @@ error('Cannot require a meta file') ---@nodoc ---@class TSNode: userdata ----@field named_children fun(self: TSNode): TSNode[] ----@field __has_ancestor fun(self: TSNode, node_types: string[]): boolean local TSNode = {} -- luacheck: no unused --- Get the node's immediate parent. @@ -62,6 +60,15 @@ function TSNode:child(index) end --- @return integer function TSNode:named_child_count() end +--- Returns a list of the node's named children. +--- @return TSNode[] +function TSNode:named_children() end + +--- Check if the node has any of the given node types as its ancestor. +--- @param node_types string[] +--- @return boolean +function TSNode:__has_ancestor(node_types) end + --- Get the node's named child at the given {index}, where zero represents the --- first named child. --- @param index integer |