-
Notifications
You must be signed in to change notification settings - Fork 195
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
refactor: replace all Range
with TSNode
as much as possible
#674
base: main
Are you sure you want to change the base?
Conversation
@clason we could continue our discussion in #672 (comment) here. |
Pretty much, except I think there was a discussion to keep the predicate definition (although now unneeded) for backwards compatibility with user queries |
Also I haven't done a thorough review, but is this a fully safe change? Sometimes metadata.range is needed over node:range() because the latter doesn't account for range changes from something like #offset! |
This is what I am concerned about most too. I think we can handle the problem with |
I think we always have to check the metadata; the question is just when (do we precompute that or not); that is the same as for any other query. The difference here is that the original code uses the "metadata" ranges as primary objects, which could come from nodes or from So the signs are starting to point to a full breaking rewrite on |
Honestly, it is a rather complicated situation. It uses ranges from So If
Indeed. At least #612 must be merged before we move on. |
Brief summary, three sources of range:
The first two sources could be handled if we use |
In our queries. Experience has taught me the hard way that user configs (and third-party plugins) can be full of all kinds of stuff... |
Since the However, one point I want to discuss is whether, if |
Well, that's not the right way of looking at this. Right now, TL;DR: We can and should do this, but it's absolutely not a "lol"ing matter. |
Yes, that might be a joke that isn't funny, queries could not be synced between two branches after that. But if we are certain about making this change, we could first remove |
That would also get quick feedback on outside use of
Yes, that is the main design decision we need to make. And I agree that given the current information, this looks possible and desirable. Personally, I think |
f14de22
to
d675d10
Compare
@clason Could you please take a look at e83e3eb? Previously, we were using |
Looks good to me; if this is incorrect, it should fail pretty badly (easy to manually test with one of the quantified captures here). @ribru17 ? |
Oh, I realized there is indeed an issue with this change regarding quantified captures. My previous manual tests were too simple, sorry about that. Quantified captures don’t combine multiple nodes into a single node; instead, they match these nodes separately while keeping them within the same pattern. Therefore, we need to use |
The
Range
type should only be used internally. To leverage more upstream API, we should convert it into aTSNode
as much as possible.