bblfsh / sdk

Babelfish driver SDK
GNU General Public License v3.0
23 stars 27 forks source link

Add parent field into UAST Node in clients. #252

Open zurk opened 6 years ago

zurk commented 6 years ago

Sometimes it is important to keep it on hands.

If there is no such field you need to store all parents while performing some complicated UAST traversing.

juanjux commented 6 years ago

It's an interesting request. We approved adding an "structural parent" to some nodes, that would link them with the "high level structure" (function, class, etc) where they belong, even if they're several levels below. Anyway we're in the middle of a complete rewrite of the SDK and the annotations but after that is completed we could evaluate this and how to do it.

zurk commented 6 years ago

ok, it can wait, I have workarounds.

dennwc commented 6 years ago

@zurk As a retrospective, have you used the SDK or Go/Python client?

juanjux commented 6 years ago

I definitely used the "@internalRole" selector in the implementation of many SonarSource checks, which is not exactly the same, but I can imagine getting the parent node could be useful. But just as a side note, with XPath you can get the parent of the node with the query "/parent::*"

dennwc commented 6 years ago

Yes, this is why I'm trying to figure where exactly the parent field can be helpful. Probably the native client data structures.

zurk commented 6 years ago

@dennwc I use Python client. I need this field in some complex traversing scenarios. For example, if I need to find the shortest path between two leaves. So it is not about XPath queries, more about class property like node.parent

zurk commented 5 years ago

@dennwc any updates? Maybe this issue should be moved to python client?