Closed vmarkovtsev closed 5 years ago
I finally extracted them with //uast:Function/../../Name
but damn that was hard. Is there a better solution?
I suspect #366 and #367 saturate this issue, but assigning for triage in case I missed something.
@vmarkovtsev For functions, this query should work:
//uast:FunctionGroup/Nodes/uast:Alias/Name
or
//uast:FunctionGroup/*/uast:Alias/Name
This works, thanks. Is the first uast:Alias
node guaranteed to be the function name?
Yes, an Alias
will always be there. It's our way to bind a specific function declaration to a name. Anonymous functions won't have it, for example - they are just Function
without a FunctionGroup
.
I give up: I cannot compose the XPath to extract function names in Semantic mode.
I get all the functions by
//uast:FunctionGroup
, however, theName
node is inside theNodes
array and I don't know how to address it.//uast:FunctionGroup/*[1]
returns the position and//uast:FunctionGroup/*[2]
is already empty.//uast:FunctionGroup/descendant::uast:Identifier
returns all identifiers inside a function. I tried withchild
but failed. So the question is, how do I dig inside the immediate array ofNode
-s inside functions?