Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cursor/Node API suggestions #583

Closed
DrakeEvans opened this issue Aug 30, 2023 · 2 comments · Fixed by #666
Closed

Cursor/Node API suggestions #583

DrakeEvans opened this issue Aug 30, 2023 · 2 comments · Fixed by #666
Assignees

Comments

@DrakeEvans
Copy link

DrakeEvans commented Aug 30, 2023

Hi I have been using the current version for some tooling and wanted to suggest some API additions.

On RuleNode and TokenNode, it would be nice to be able to create a cursor
Given some TokenNode of kind Identifier, I would like to find the definition in the larger parse tree
Given some RuleNode, I would like a reconstruct() function which generates the original syntax from the children tokens
Given some RuleNode, find children with a predicate or matching a kind

@AntonyBlakey
Copy link
Contributor

AntonyBlakey commented Sep 6, 2023

On RuleNode and TokenNode, it would be nice to be able to create a cursor

Will do

Given some TokenNode of kind Identifier, I would like to find the definition in the larger parse tree

This is binding analysis, which is coming

Given some RuleNode, I would like a reconstruct() function which generates the original syntax from the children tokens

Will do.

Given some RuleNode, find children with a predicate or matching a kind

some_rule_node::cursor().find_matching(...);

some_rule_node::cursor().find_rule_matching(...);
some_rule_node::cursor().find_rule_with_kind(kind);

some_rule_node::cursor().find_token_matching(...);
some_rule_node::cursor().find_token_with_kind(kind);

which only requires the addition of RuleNode::cursor()

@Xanewok
Copy link
Contributor

Xanewok commented Nov 20, 2023

About this point

On RuleNode and TokenNode, it would be nice to be able to create a cursor

Could you tell me if you're dealing with Rc-wrapped enum variants or bare RuleNode/TokenNode?

github-merge-queue bot pushed a commit that referenced this issue Nov 22, 2023
Closes #583
Ref #628 for the modified cursor/offset API

Changes are best reviewed commit-by-commit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: No status
Development

Successfully merging a pull request may close this issue.

3 participants