UNPKG

@eagleoutice/flowr

Version:

Static Dataflow Analyzer and Program Slicer for the R Programming Language

49 lines 1.69 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.executeFileQuery = executeFileQuery; /** * Executes the given files queries using the provided analyzer. */ function executeFileQuery({ analyzer }, queries) { const start = Date.now(); analyzer.inspectContext().resolvePreAnalysis(); const base = analyzer.inspectContext().files.getAllFiles(); let files = []; const foundFingerprints = new Set(); for (const query of queries) { if (query.matchesPathRegex === undefined && query.roles === undefined) { files = base.map(l => ({ roles: l.roles, content: l.content(), path: l.path() })); break; } const pathRegex = query.matchesPathRegex ? new RegExp(query.matchesPathRegex) : undefined; for (const file of base) { const fingerprint = `${file.roles?.join(':')}:::${file.path()}`; if (foundFingerprints.has(fingerprint)) { continue; } if (pathRegex && !pathRegex.test(file.path())) { continue; } if ((query.roles?.length ?? 0) > 0 && !query.roles?.every(r => file.roles?.includes(r))) { continue; } foundFingerprints.add(fingerprint); files.push({ roles: file.roles, content: file.content(), path: file.path() }); } } return Promise.resolve({ '.meta': { timing: Date.now() - start }, files }); } //# sourceMappingURL=files-query-executor.js.map