esquery
esquery copied to clipboard
Reimplement subject indicators using :has selectors
Current subject indicator implementation is very buggy, see e.g. #60. This rewrites queries that include subject indicators so that :has
selectors are used instead.
So e.g. the AST for:
!* :expression
...is transformed into the equivalent of:
*:has(:expression)
...right after parsing.
Also adds support for :root
, :scope
, and relative selectors; improves the implementation of :has
. E.g. this now works:
:has( > Identifier)
Oh and this also fixes #25, obviously.
I'd love to see this in TSQuery, and we're depending on ESQuery for the parsing. We could clone this PR and move it into our repo, but would prefer to see this happen this side if possible!
This PR introduces :root
and :scope
selectors but adds no tests for them. Please add tests for :root
and :scope
.
@michaelficarra any chance of progressing this now that tests have been added?
Could we progress this? The documentation links suggest that :has( > Identifier)
works, but it doesn't, and this PR fixes that.
@michaelficarra Hi, can you give us some insight on when someone can take a look at this PR ? Thanks
Hey @run1t, I now have review powers in this repo, and a bit of time to try to get this through. Are you still keen to move it forward? If so I'll properly check out the changes.
Hi @phenomnomnominal , Yes I am ! It would be very nice :)
Not sure why my review didn't come through about a month ago, I musn't have hit the final button. Either way @run1t, care to check out my review and respond? I'll admit I'm not massively familiar with the changes.
Hi, Sorry that I wasn’t able to respond. I had a lot to do in the last month, I sure be able to check that next week :) It’s been a long time since I made the changes so I have to go back in the code ^^’
Hi, any progress here, is this blocked on something?
We are missing relative selectors (e.g. :has( > Identifier)
) in ESLint and believe this would fix that.
Anything we can help with? Thanks.
@tosmolka The PR author hasn't addressed @phenomnomnominal's review comments. And it looks like this PR needs a rebase. If you'd like to open another PR with these commits, rebase them, and address the comments, we can do another review and possibly merge.