Skip to content
This repository has been archived by the owner on Feb 4, 2025. It is now read-only.

Consider making path to node readily available in Model #72

Closed
davidmorgan opened this issue Sep 26, 2024 · 0 comments
Closed

Consider making path to node readily available in Model #72

davidmorgan opened this issue Sep 26, 2024 · 0 comments

Comments

@davidmorgan
Copy link
Contributor

Per this comment

https://github.com/dart-lang/macros/pull/68/files#r1759229776

it's really convenient for some use cases if a node in the model knows its own location. For example, that would mean a field in a class knows how it can be referred to from anywhere.

One option would be to change the schema to make that information explicit in the model.

But I wonder if we can cheat. When we instantiate a Map from a JsonBufferBuilder, it's always either the root map or it's in the context of another Map or List lookup. A Map is just a pointer into JsonBufferBuilder, I wonder if we could add also a pointer to the parent, and so provide a fast Model.pathTo(node) that uses the parent pointers to compute the path from root to the node.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

1 participant