You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 8, 2020. It is now read-only.
Repository navigation
This repository was archived by the owner on Mar 8, 2020. It is now read-only.
@zurk It doesn't show the internalRole field of these nodes. I'm quite sure they are different. It's probably a name and an alias fields (package-local name).
@zurk Yes, but I'm talking about a different field :) internal_type in UAST v1 corresponds to a @type field in v2, so yes, you will have two Identifiers there. But there is an InternalRole property in v1 which corresponds to a field name (or predicate) in v2. This field should have two different values in your example. So there are two different identifiers - one for the external import name and the second one for the internal name (alias for current file/package). Or at least this is what I assume, looking at the sample.
But in case that @dpordomingo described, we can remove these duplicates from the tree safely. But for the case with names vs aliases, removing one of them will cause half of the UAST queries to break.
The correct solution will require adding support for DAGs in SDK that I was advocating from the very beginning. This will happen later during v2 cycle, or even in v3.
Activity
dpordomingo commentedon Sep 17, 2018
For comment blocks, the same comment can be returned three times, not only two
zurk commentedon Sep 28, 2018
I confirm that for drivers
v1.2.0andv2.2.0And it happens not only for comments.This JS code produses next UAST tree:
dennwc commentedon Sep 28, 2018
@zurk It doesn't show the
internalRolefield of these nodes. I'm quite sure they are different. It's probably anameand analiasfields (package-local name).zurk commentedon Sep 28, 2018
oh, I just mixed, and column
Internal Rolecorresponds tonode.internal_typefield. So, internal types are the same or we have a bug in theredennwc commentedon Sep 28, 2018
@zurk Yes, but I'm talking about a different field :)
internal_typein UAST v1 corresponds to a@typefield in v2, so yes, you will have twoIdentifiers there. But there is anInternalRoleproperty in v1 which corresponds to a field name (or predicate) in v2. This field should have two different values in your example. So there are two different identifiers - one for the external import name and the second one for the internal name (alias for current file/package). Or at least this is what I assume, looking at the sample.But in case that @dpordomingo described, we can remove these duplicates from the tree safely. But for the case with names vs aliases, removing one of them will cause half of the UAST queries to break.
The correct solution will require adding support for DAGs in SDK that I was advocating from the very beginning. This will happen later during v2 cycle, or even in v3.
zurk commentedon Sep 28, 2018
yeah, now I get it. If in
Internal RoleI usenode.properties["internalRole"]I getbefore it was
node.internal_typeon this place. UAST even more complicated than I think.bzz commentedon Nov 29, 2018
This seems still to be the case: the query to the same file
//*/uast:Commentresults in entities for me:{"@pos":{"@type":"uast:Positions","end":{"@type":"uast:Position","col":22,"line":1,"offset":21},"start":{"@type":"uast:Position","col":8,"line":1,"offset":7}},"@type":"uast:Comment","Block":false,"Prefix":"","Suffix":"","Tab":"","Text":"comment here"} {"@pos":{"@type":"uast:Positions","end":{"@type":"uast:Position","col":20,"line":2,"offset":41},"start":{"@type":"uast:Position","col":1,"line":2,"offset":22}},"@type":"uast:Comment","Block":true,"Prefix":" ","Suffix":" ","Tab":"","Text":"block comment"} {"@pos":{"@type":"uast:Positions","end":{"@type":"uast:Position","col":22,"line":1,"offset":21},"start":{"@type":"uast:Position","col":8,"line":1,"offset":7}},"@type":"uast:Comment","Block":false,"Prefix":"","Suffix":"","Tab":"","Text":"comment here"} {"@pos":{"@type":"uast:Positions","end":{"@type":"uast:Position","col":20,"line":2,"offset":41},"start":{"@type":"uast:Position","col":1,"line":2,"offset":22}},"@type":"uast:Comment","Block":true,"Prefix":" ","Suffix":" ","Tab":"","Text":"block comment"}query.go4
@dennwc do you know what is the reason? This seems like a 2 identical copies to me
dennwc commentedon Nov 29, 2018
@bzz This is exactly the problem I talked about when reffering to DAGs. There are two pointers to the same comment node in the native AST.