A way to reach the parent node(s) or root node from a given Prism::Node
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 35/100
Rechercherichtung
Start by reading the linked Ruby issue note and the discussion here to understand the proposed Prism::Node#root or Prism::Node#parse_result API and the concern about keeping the whole tree alive. Then inspect how nodes retain Prism::Source and how Prism.parse constructs its result. Done means the API choice and memory tradeoff are resolved; the issue does not specify an implementation or tests.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
This is from https://bugs.ruby-lang.org/issues/22520#note-5, for #syntax_tree.
It can be necessary to get the parent node(s) or even the root node, from a given Prism::Node.
One idea would be to have Prism::Node#root or Prism::Node#parse_result, which would work through the existing @source ivar of every node holding a Prism::Source.
So then we'd store the root node or the ParseResult inside the Source, and we could then provide Prism::Node#root or Prism::Node#parse_result.
There is one downside, this means holding on to any node (even leaves) would keep the whole tree alive.
(Currently every node holds the source, so the entire source code, but does not hold on parent nodes)
If that's a concern, this could be controlled via a keyword argument of Prism.parse (opt-in or opt-out).
I'm happy to make a PR for this but I wanted to first see what others think of this idea, and whether they prefer Prism::Node#root or Prism::Node#parse_result, or some other solution.
(Feel free to convert this to a GitHub discussion if you prefer)
- Vorherrschende Sprache
- C
- Sterne
- 1k
- Forks
- 206
- Ø Merge
- 1 T. 1 Std.
- Gemergte PRs (30 T.)
- 71
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus ruby/prism
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 25/100
Maintainer antworten meist innerhalb von 1 Tag
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
Polprzewodnikowy/N64FlashcartMenu#486 · 3 Kommentare ·
-
[raygui] update to 5.0Offencategory:port-update
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 64/100
Maintainer antworten meist innerhalb von 2 Tagen
-
crash
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 64/100
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 83/100
tree-sitter/tree-sitter-c#338 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100