wasm: Add matchLimit option to query methods
This exposes the new configurable match limits for query cursors.
This commit is contained in:
parent
1f6eac555c
commit
ad3907c2a6
3 changed files with 37 additions and 7 deletions
|
|
@ -953,9 +953,17 @@ class Query {
|
|||
this[0] = 0;
|
||||
}
|
||||
|
||||
matches(node, startPosition, endPosition) {
|
||||
matches(node, startPosition, endPosition, options) {
|
||||
if (!startPosition) startPosition = ZERO_POINT;
|
||||
if (!endPosition) endPosition = ZERO_POINT;
|
||||
if (!options) options = {};
|
||||
|
||||
let matchLimit = options.matchLimit;
|
||||
if (typeof matchLimit === 'undefined') {
|
||||
matchLimit = 0;
|
||||
} else if (typeof matchLimit !== 'number') {
|
||||
throw new Error('Arguments must be numbers');
|
||||
}
|
||||
|
||||
marshalNode(node);
|
||||
|
||||
|
|
@ -965,7 +973,8 @@ class Query {
|
|||
startPosition.row,
|
||||
startPosition.column,
|
||||
endPosition.row,
|
||||
endPosition.column
|
||||
endPosition.column,
|
||||
matchLimit
|
||||
);
|
||||
|
||||
const rawCount = getValue(TRANSFER_BUFFER, 'i32');
|
||||
|
|
@ -1000,9 +1009,17 @@ class Query {
|
|||
return result;
|
||||
}
|
||||
|
||||
captures(node, startPosition, endPosition) {
|
||||
captures(node, startPosition, endPosition, options) {
|
||||
if (!startPosition) startPosition = ZERO_POINT;
|
||||
if (!endPosition) endPosition = ZERO_POINT;
|
||||
if (!options) options = {};
|
||||
|
||||
let matchLimit = options.matchLimit;
|
||||
if (typeof matchLimit === 'undefined') {
|
||||
matchLimit = 0;
|
||||
} else if (typeof matchLimit !== 'number') {
|
||||
throw new Error('Arguments must be numbers');
|
||||
}
|
||||
|
||||
marshalNode(node);
|
||||
|
||||
|
|
@ -1012,7 +1029,8 @@ class Query {
|
|||
startPosition.row,
|
||||
startPosition.column,
|
||||
endPosition.row,
|
||||
endPosition.column
|
||||
endPosition.column,
|
||||
matchLimit
|
||||
);
|
||||
|
||||
const count = getValue(TRANSFER_BUFFER, 'i32');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue