refactor(treesitter): deprecate for_each_child #25118

The name for_each_child is misleading and caused bugs.
After #25111, #25115, there are no more usages of `for_each_child` in Nvim.

In the future if we want to restore this functionality we can consider a
generalized vim.traverse(node, key, visitor) function.
This commit is contained in:
LW
2023-09-14 03:36:16 -07:00
committed by GitHub
parent a4743487b7
commit 9fc321c976
4 changed files with 8 additions and 9 deletions

View File

@@ -451,11 +451,14 @@ function LanguageTree:parse(range)
return self._trees
end
---@deprecated Misleading name. Use `LanguageTree:children()` (non-recursive) instead,
--- add recursion yourself if needed.
--- Invokes the callback for each |LanguageTree| and its children recursively
---
---@param fn fun(tree: LanguageTree, lang: string)
---@param include_self boolean|nil Whether to include the invoking tree in the results
function LanguageTree:for_each_child(fn, include_self)
vim.deprecate('LanguageTree:for_each_child()', 'LanguageTree:children()', '0.11')
if include_self then
fn(self, self._lang)
end