A way to reach the parent node(s) or root node from a given Prism::Node
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 5/5
- Tempo estimado
- Mais de uma semana
- Facilidade para iniciantes
- 35/100
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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)
- Linguagem predominante
- C
- Estrelas
- 1k
- Forks
- 206
- Merge médio
- 1d 1h
- PRs com merge (30d)
- 71
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de ruby/prism
-
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 35/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 25/100
Mantenedores costumam responder em até 1 dia
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
Polprzewodnikowy/N64FlashcartMenu#486 · 3 comentários ·
-
[raygui] update to 5.0Abertacategory:port-update
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 64/100
Mantenedores costumam responder em até 2 dias
-
crash
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 64/100
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 83/100
tree-sitter/tree-sitter-c#338 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100