tsquery icon indicating copy to clipboard operation
tsquery copied to clipboard

(WIP) feat: Add `:scope` and `:root` selectors

Open run1t opened this issue 6 years ago • 2 comments

As said in #23 I thought the :root selector work. But after adding tests cases discussed with @petebacondarwin the implementation of :root from ESquery is not sufficient to cover the use cases defined below.

However I added the tests to cover the use cases.

Base example

function a() {
  function b() {
    return 'bar';
  }
  return 'foo';
};

Uses cases

:root

  • Assuming we are in the root of the example:
    • ✅ Executing this query :root > FunctionDeclaration should return the function a
  • Assuming we are in the BLOCK of the function a:
    • ✅ Executing this query :root > FunctionDeclaration should return the function a
    • ✅ Executing this query :root FunctionDeclaration should return the function a an function b

:scope

  • Assuming we are in the root of the example:
    • ✅ Executing this query :scope > FunctionDeclaration should return the function a
  • Assuming we are in the BLOCK of the function a:
    • ✅ Executing this query :scope > FunctionDeclaration should return the function b
    • ✅ Executing this query :scope FunctionDeclaration should return the function b

run1t avatar Nov 17 '18 12:11 run1t

Is this going to get merged in?

auser avatar Jul 30 '19 11:07 auser

Not until we get the upstream fix merged I'm afraid. I thought I did a review of the PR in the esquery repo, but it's vanished. I'll do it again and see if we can get @run1t's changes merged there.

phenomnomnominal avatar Jul 30 '19 18:07 phenomnomnominal