aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/treesitter
diff options
context:
space:
mode:
authorRiley Bruins <ribru17@hotmail.com>2024-10-02 10:34:14 -0700
committerChristian Clason <c.clason@uni-graz.at>2024-10-11 17:29:45 +0200
commit267c7525f738cdd6024c39da758e885c026ffaaa (patch)
tree869fcb5fa87b4f9b2c4f0a0295498c5ed2883b73 /runtime/lua/vim/treesitter
parentc4762b309714897615607f135aab9d7bcc763c4f (diff)
downloadrneovim-267c7525f738cdd6024c39da758e885c026ffaaa.tar.gz
rneovim-267c7525f738cdd6024c39da758e885c026ffaaa.tar.bz2
rneovim-267c7525f738cdd6024c39da758e885c026ffaaa.zip
feat(treesitter): introduce child_with_descendant()
This commit also marks `child_containing_descendant()` as deprecated (per upstream's documentation), and uses `child_with_descendant()` in its place. Minimum required tree-sitter version will now be `0.24`.
Diffstat (limited to 'runtime/lua/vim/treesitter')
-rw-r--r--runtime/lua/vim/treesitter/_meta/tsnode.lua18
1 files changed, 17 insertions, 1 deletions
diff --git a/runtime/lua/vim/treesitter/_meta/tsnode.lua b/runtime/lua/vim/treesitter/_meta/tsnode.lua
index acc9f8d24e..d982b6a505 100644
--- a/runtime/lua/vim/treesitter/_meta/tsnode.lua
+++ b/runtime/lua/vim/treesitter/_meta/tsnode.lua
@@ -15,7 +15,7 @@ error('Cannot require a meta file')
local TSNode = {} -- luacheck: no unused
--- Get the node's immediate parent.
---- Prefer |TSNode:child_containing_descendant()|
+--- Prefer |TSNode:child_with_descendant()|
--- for iterating over the node's ancestors.
--- @return TSNode?
function TSNode:parent() end
@@ -71,8 +71,24 @@ function TSNode:named_child(index) end
--- Get the node's child that contains {descendant}.
--- @param descendant TSNode
--- @return TSNode?
+--- @deprecated
function TSNode:child_containing_descendant(descendant) end
+--- Get the node's child that contains {descendant} (includes {descendant}).
+---
+--- For example, with the following node hierarchy:
+---
+--- ```
+--- a -> b -> c
+---
+--- a:child_with_descendant(c) == b
+--- a:child_with_descendant(b) == b
+--- a:child_with_descendant(a) == nil
+--- ```
+--- @param descendant TSNode
+--- @return TSNode?
+function TSNode:child_with_descendant(descendant) end
+
--- Get the node's start position. Return three values: the row, column and
--- total byte count (all zero-based).
--- @return integer, integer, integer