Skip to content

Conversation

@ribru17
Copy link
Member

@ribru17 ribru17 commented Apr 9, 2025

This commit provides access to the child_with_descendant node function, allowing for more efficient searches for, e.g., nodes containing certain ancestors


#[inline]
pub fn child_with_descendant(&self, descendant: Self) -> Option<Self> {
self.inner.child_with_descendant(descendant.inner).map(Into::into)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question, what's the version of tree-sitter has this method?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v0.24.0, though before that a similar method called child_containing_descendant existed (deprecated in 0.24, removed in 0.25)

@HerringtonDarkholme
Copy link
Member

I read relevant info here neovim/neovim#28512 and neovim/neovim#30516
and source https://github.com/tree-sitter/tree-sitter/blob/b3410731929d57d2eb8e20dbfae90ef3deb234b5/lib/src/node.c#L560

amzing perf improvement!

@HerringtonDarkholme HerringtonDarkholme merged commit caffcd5 into ast-grep:main Apr 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants