-
Notifications
You must be signed in to change notification settings - Fork 57
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
Add the ability to make a SyntaxNode which is offset by a certain amount from the source code #73
Comments
One possible way of kludging an offset together with the current API is to just put an extra green node in front with the desired offset length. Ofc, that requires a string of that length to back it, so it's not a great solution. It in theory wouldn't be a difficult change to at a base offset to the syntax tree. In theory, "just:"
That should be all that's necessary to add a root offset to the syntax tree. That also should make it possible to "reroot" syntax trees, pulling out a subtree so the rest can potentially be reclaimed, though I don't know how useful that'd be in practice. |
I briefly asked @matklad about this over zulip, he brought up a great point.
Which makes a ton of sense, only syntax nodes should carry an offset. This change should not affect green nodes at all |
That's why the plan I outline is just adding an offset to the root of the syntax tree; it doesn't touch the green tree. |
Hello, i have been using rowan in my own project, it works absolutely great. However, when parsing something like a markdown file, i run into issues with text ranges because it assumes the root node starts at the start of the source. Which means i need to offset every single node, token, or element's range i make. It would be great if i could make a syntax node and tell rowan the range is actually offset by a certain amount, i tried to implement this myself but i ran into a good amount of issues, including:
raw_range
internal methodText would stay the same, as the green node will still have the right text, only text range of parent and children would be affected.
The text was updated successfully, but these errors were encountered: