Closed t9md closed 6 years ago
I am also curious how closest treat unnamed node since I want to skip unnamed function node if I don't I get function keyword instead of the node which contains whole function body.
Yeah, this is exactly the problem. I think that the current implementation is misinterpreting the string function
to mean the unnamed "function" node. closest
should only look for named nodes, since unnamed nodes can never have children.
I want to get
function
SyntaxNode by usingclosest
. But, in the example below, it returns nothing. I could get function body by the manual way. I am also curious howclosest
treat unnamed node since I want to skip unnamedfunction
node if I don't I getfunction
keyword instead of the node which contains whole function body.Reproduce
Open atom-editor and enable tree-sitter and place cursor at
foo
in method: Can get method node byclosest
(OK).bar
in function: Can NOT get function node byclosest
(NG).code to repro
getClosestFunction()
by placing cursor atfoo
andbar
.closest
fail butclosestManual
success when the cursor is atbar
.