rawsql-ts
Version:
[beta]High-performance SQL parser and AST analyzer written in TypeScript. Provides fast parsing and advanced transformation capabilities.
37 lines • 1.22 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.ParameterCollector = void 0;
const ValueComponent_1 = require("../models/ValueComponent");
/**
* Utility class to collect all ParameterExpression nodes from an AST.
*/
class ParameterCollector {
/**
* Recursively collect all ParameterExpression nodes from AST.
* @param node AST root
* @returns ParameterExpression[]
*/
static collect(node) {
const result = [];
function walk(n) {
if (!n || typeof n !== 'object')
return;
if (n.constructor && n.constructor.kind === ValueComponent_1.ParameterExpression.kind) {
result.push(n);
}
for (const key of Object.keys(n)) {
const v = n[key];
if (Array.isArray(v)) {
v.forEach(walk);
}
else if (v && typeof v === 'object' && v.constructor && v.constructor.kind) {
walk(v);
}
}
}
walk(node);
return result;
}
}
exports.ParameterCollector = ParameterCollector;
//# sourceMappingURL=ParameterCollector.js.map
;