From d60c6f163deac02e2765f0e53197dafc16f2b2ec Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Mon, 20 Jan 2025 14:26:53 -0500 Subject: [PATCH] refactor(web)!: rename `pattern` to `patternIndex` in `QueryMatch` This aligns with other bindings --- lib/binding_web/src/query.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/binding_web/src/query.ts b/lib/binding_web/src/query.ts index e4cc0160..6beb1617 100644 --- a/lib/binding_web/src/query.ts +++ b/lib/binding_web/src/query.ts @@ -106,9 +106,12 @@ export interface QueryCapture { /** A match of a {@link Query} to a particular set of {@link Node}s. */ export interface QueryMatch { - /** The index of the pattern that matched. */ + /** @deprecated Use `patternIndex` instead, this will be removed in 0.26. */ pattern: number; + /** The index of the pattern that matched. */ + patternIndex: number; + /** The captures associated with the match. */ captures: QueryCapture[]; @@ -298,7 +301,7 @@ export class Query { let filteredCount = 0; let address = startAddress; for (let i = 0; i < rawCount; i++) { - const pattern = C.getValue(address, 'i32'); + const patternIndex = C.getValue(address, 'i32'); address += SIZE_OF_INT; const captureCount = C.getValue(address, 'i32'); address += SIZE_OF_INT; @@ -306,13 +309,13 @@ export class Query { const captures = new Array(captureCount); address = unmarshalCaptures(this, node.tree, address, captures); - if (this.textPredicates[pattern].every((p) => p(captures))) { - result[filteredCount] = { pattern, captures }; - const setProperties = this.setProperties[pattern]; + if (this.textPredicates[patternIndex].every((p) => p(captures))) { + result[filteredCount] = { pattern: patternIndex, patternIndex, captures }; + const setProperties = this.setProperties[patternIndex]; result[filteredCount].setProperties = setProperties; - const assertedProperties = this.assertedProperties[pattern]; + const assertedProperties = this.assertedProperties[patternIndex]; result[filteredCount].assertedProperties = assertedProperties; - const refutedProperties = this.refutedProperties[pattern]; + const refutedProperties = this.refutedProperties[patternIndex]; result[filteredCount].refutedProperties = refutedProperties; filteredCount++; }