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`.
This commit is contained in:
Riley Bruins
2024-10-02 10:34:14 -07:00
committed by Christian Clason
parent c4762b3097
commit 267c7525f7
9 changed files with 96 additions and 18 deletions

View File

@@ -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