query: Handle #not-match? in rust, wasm bindings
This commit is contained in:
parent
32099050d6
commit
1ae5cbc851
4 changed files with 25 additions and 7 deletions
|
|
@ -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;
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue