query: Handle #not-match? in rust, wasm bindings

This commit is contained in:
Max Brunsfeld 2020-07-24 10:49:20 -07:00
parent 32099050d6
commit 1ae5cbc851
4 changed files with 25 additions and 7 deletions

View file

@ -784,6 +784,8 @@ class Language {
}
break;
case 'not-match?':
isPositive = false;
case 'match?':
if (steps.length !== 3) throw new Error(
`Wrong number of arguments to \`#match?\` predicate. Expected 2, got ${steps.length - 1}.`
@ -798,7 +800,7 @@ class Language {
const regex = new RegExp(steps[2].value);
textPredicates[i].push(function(captures) {
for (const c of captures) {
if (c.name === captureName) return regex.test(c.node.text);
if (c.name === captureName) return regex.test(c.node.text) === isPositive;
}
return false;
});