-
Notifications
You must be signed in to change notification settings - Fork 27
Non semantically mapped properties on semantic objects #361
Comments
The same is need and will be handled by 4 in bblfsh/javascript-driver#57 |
@bzz yes, for what I'm seeing, it'll happen on almost all drivers. For the Python driver I'm fixing some node-specific mappings but resorting to 1) + adding an issue for the ones that can be on almost every node until we've a better solution. |
For now, I propose to drop those fields explicitly with a A bit more on why I think dumping fields to the You may ask how it's different from having external nodes wrapping semantic nodes. The best way to describe it is that by design, each semantic node = a UAST role in the old SDK. Adding @juanjux May rightfully argue that we already use external nodes to dump unknown properties in some cases. That's true, but it's not because of the issues with the design, nor schema. It's an issue with a DSL implementation - there are no helpers to do this in a clean way right now, so we either group unknown properties to a separate external node, or write custom transforms that solves it properly. So from my perspective, we need a bit more helpers in SDK that will allow to move nodes cleanly. This is indeed urgent, but C# is a priority, so I'll look into it right after I finish the current work on annotations. |
The problem:
Sometimes (or almost always) native objects that have a semantic mapping have more properties than the ones we have in our schema. What to do with them? This is more evident with the latest SDK update that produces and error when you silently drop any field on the semantic mapping.
Possible solutions:
Drop them explicitly.
Pros: trivial to implement. User could still have access in the non semantic UAST.
Cons: It's ugly to lose information in the semantic UAST.
Add an
extra
or similar field onGenNode
where these properties can be loaded.Pros: easy to implement.
Cons: turns the semantic objects into "schema-less" at least regarding the contents of the
extra
field.Add an SDK feature to get a list of strings and create a group where these properties are together with the semantic node. Then call that on the
Normalize
transform. It's similar to 2), but with the properties one level above instead of into the semantic object. This is similar to what the C# and Python driver do (in different ways) to keep comments.Pros: easy to implement (on the drivers, unsure about the SDK feature itself).
Cons: more noisy semantic UAST. Adds groups without real semantic meaning. Have to implement feature in the SDK. More boilerplate for the driver programmer. Won't always work for all drivers (the C# driver for example sometimes maps the comments inside properties instead of a parent group).
Continue writing custom transforms for each driver like the C# and Python driver do.
Pros: will work for each driver.
Cont: Very cumbersome to write and maintain, ugly, fails the DRY principle since most will be similar but not equal.
Other solutions...?
This is semi-urgent since the latest SDK made mandatory to map these fields.
The text was updated successfully, but these errors were encountered: