rust-analyzer / rowan

Apache License 2.0
697 stars 57 forks source link

Way to change node order #29

Closed Lapz closed 5 years ago

Lapz commented 5 years ago

It would be really useful if there was a way to change the root syntax kind for a node. The reason for this is because the language that I'm using has both grouping expressions i.e. (1+10) and tuple expressions. So when parsing a grouping expression which is actually a tuple expression it would be nice if the GreenNodeBuilder offered an API that could swap the current root node to something else.

matklad commented 5 years ago

You probably want checkpoint method: https://github.com/rust-analyzer/rowan/blob/a00ccb60ea99eccbc7f24d31ee83e925e0d8258d/src/green.rs#L185

In rust-analyzer, we handle this by in another way, by a filtering pre-pass that turns expr, expr, tuple events into tuple, expr, expr

Lapz commented 5 years ago

Thanks.