Reimplement subject indicators using :has selectors#61
Reimplement subject indicators using :has selectors#61jupenur wants to merge 7 commits intoestools:masterfrom
Conversation
|
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 |
|
@michaelficarra any chance of progressing this now that tests have been added? |
|
Could we progress this? The documentation links suggest that |
|
@michaelficarra Hi, can you give us some insight on when someone can take a look at this PR ? |
|
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 , |
| /* | ||
| * Clones a selector AST | ||
| */ | ||
| function clone(selector) { |
There was a problem hiding this comment.
This whole chunk from here down seems to exist purely to translate the old query syntax into the new. Is that necessary? Is the alternative just a breaking change? I think I'd prefer the latter instead of making the PR huge.
| "nested descendant subject": function () { | ||
| var matches = esquery(nestedFunctions, "!:function :function AssignmentExpression"); | ||
| assert.contains([ nestedFunctions.body[0] ], matches); | ||
| assert.isSame(1, matches.length); |
There was a problem hiding this comment.
Seems like we need more than one new test to cover the changes here?
| @@ -33,13 +33,27 @@ selectors = s:selector ss:(_ "," _ selector)* { | |||
| return [s].concat(ss.map(function (s) { return s[3]; })); | |||
There was a problem hiding this comment.
If we get rid of the old syntax entirely and break the selector API, can some of the grammar be removed?
|
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, |
|
Hi, any progress here, is this blocked on something? We are missing relative selectors (e.g. 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. |
Current subject indicator implementation is very buggy, see e.g. #60. This rewrites queries that include subject indicators so that
:hasselectors are used instead.So e.g. the AST for:
...is transformed into the equivalent of:
...right after parsing.
Also adds support for
:root,:scope, and relative selectors; improves the implementation of:has. E.g. this now works: