MCPcopy Create free account
hub / github.com/CodeGraphContext/CodeGraphContext / parsePattern

Function parsePattern

website/public/wasm/web-tree-sitter.js:3525–3565  ·  view source on GitHub ↗
(index, stepType, stepValueId, captureNames, stringValues, steps, textPredicates, predicates, setProperties, assertedProperties, refutedProperties)

Source from the content-addressed store, hash-verified

3523}
3524__name(parseSetDirective, "parseSetDirective");
3525function parsePattern(index, stepType, stepValueId, captureNames, stringValues, steps, textPredicates, predicates, setProperties, assertedProperties, refutedProperties) {
3526 if (stepType === PREDICATE_STEP_TYPE_CAPTURE) {
3527 const name2 = captureNames[stepValueId];
3528 steps.push({ type: "capture", name: name2 });
3529 } else if (stepType === PREDICATE_STEP_TYPE_STRING) {
3530 steps.push({ type: "string", value: stringValues[stepValueId] });
3531 } else if (steps.length > 0) {
3532 if (steps[0].type !== "string") {
3533 throw new Error("Predicates must begin with a literal value");
3534 }
3535 const operator = steps[0].value;
3536 switch (operator) {
3537 case "any-not-eq?":
3538 case "not-eq?":
3539 case "any-eq?":
3540 case "eq?":
3541 parseAnyPredicate(steps, index, operator, textPredicates);
3542 break;
3543 case "any-not-match?":
3544 case "not-match?":
3545 case "any-match?":
3546 case "match?":
3547 parseMatchPredicate(steps, index, operator, textPredicates);
3548 break;
3549 case "not-any-of?":
3550 case "any-of?":
3551 parseAnyOfPredicate(steps, index, operator, textPredicates);
3552 break;
3553 case "is?":
3554 case "is-not?":
3555 parseIsPredicate(steps, index, operator, assertedProperties, refutedProperties);
3556 break;
3557 case "set!":
3558 parseSetDirective(steps, index, setProperties);
3559 break;
3560 default:
3561 predicates[index].push({ operator, operands: steps.slice(1) });
3562 }
3563 steps.length = 0;
3564 }
3565}
3566__name(parsePattern, "parsePattern");
3567var Query = class {
3568 static {

Callers 1

constructorMethod · 0.85

Calls 6

parseAnyPredicateFunction · 0.85
parseMatchPredicateFunction · 0.85
parseAnyOfPredicateFunction · 0.85
parseIsPredicateFunction · 0.85
parseSetDirectiveFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected