Handle is?, is-not?, and set! predicate functions in queries
This commit is contained in:
parent
b15e90bd26
commit
27149902f8
4 changed files with 256 additions and 142 deletions
|
|
@ -202,16 +202,18 @@ describe("Query", () => {
|
|||
tree = parser.parse(`a(b.c);`);
|
||||
query = JavaScript.query(`
|
||||
((call_expression (identifier) @func)
|
||||
(set! foo bar)
|
||||
(set! baz quux))
|
||||
(set! foo)
|
||||
(set! bar baz))
|
||||
|
||||
(property_identifier) @prop
|
||||
((property_identifier) @prop
|
||||
(is? foo)
|
||||
(is-not? bar baz))
|
||||
`);
|
||||
|
||||
const captures = query.captures(tree.rootNode);
|
||||
assert.deepEqual(formatCaptures(captures), [
|
||||
{name: 'func', text: 'a', properties: {foo: 'bar', baz: 'quux'}},
|
||||
{name: 'prop', text: 'c'},
|
||||
{name: 'func', text: 'a', setProperties: {foo: null, bar: 'baz'}},
|
||||
{name: 'prop', text: 'c', assertedProperties: {foo: null}, refutedProperties: {bar: 'baz'}},
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue