esquery icon indicating copy to clipboard operation
esquery copied to clipboard

Reimplement subject indicators using :has selectors

Open jupenur opened this issue 7 years ago • 12 comments

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)

jupenur avatar Aug 22 '17 18:08 jupenur

Oh and this also fixes #25, obviously.

jupenur avatar Aug 23 '17 10:08 jupenur

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!

phenomnomnominal avatar Jul 17 '18 23:07 phenomnomnominal

This PR introduces :root and :scope selectors but adds no tests for them. Please add tests for :root and :scope.

michaelficarra avatar Jul 18 '18 00:07 michaelficarra

@michaelficarra any chance of progressing this now that tests have been added?

phenomnomnominal avatar Dec 03 '18 23:12 phenomnomnominal

Could we progress this? The documentation links suggest that :has( > Identifier) works, but it doesn't, and this PR fixes that.

RoystonS avatar Mar 14 '19 08:03 RoystonS

@michaelficarra Hi, can you give us some insight on when someone can take a look at this PR ? Thanks

run1t avatar Apr 10 '19 09:04 run1t

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.

phenomnomnominal avatar Jul 01 '19 06:07 phenomnomnominal

Hi @phenomnomnominal , Yes I am ! It would be very nice :)

run1t avatar Jul 01 '19 07:07 run1t

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.

phenomnomnominal avatar Jul 30 '19 18:07 phenomnomnominal

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 ^^’

run1t avatar Jul 30 '19 18:07 run1t

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 avatar Aug 17 '20 15:08 tosmolka

@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.

michaelficarra avatar Aug 19 '20 01:08 michaelficarra