@eagleoutice/flowr-dev
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
33 lines • 1.75 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.FlowrAnalyzerLoadingOrderIncludedFilesPlugin = void 0;
const semver_1 = require("semver");
const flowr_analyzer_loading_order_plugin_1 = require("./flowr-analyzer-loading-order-plugin");
const flowr_rmarkdown_file_1 = require("../file-plugins/files/flowr-rmarkdown-file");
/**
* Drops the files an R Markdown document splices into itself ({@link FlowrRMarkdownFile#includedFiles})
* from the loading order, as the including document already carries their content.
*
* This refines the orders the other loading-order plugins produced, so register it after them.
*/
class FlowrAnalyzerLoadingOrderIncludedFilesPlugin extends flowr_analyzer_loading_order_plugin_1.FlowrAnalyzerLoadingOrderPlugin {
name = 'flowr-analyzer-loading-order-included-files-plugin';
description = 'Drops files that another document includes from the loading order.';
version = new semver_1.SemVer('0.1.0');
process(ctx) {
const files = ctx.files.loadingOrder.getUnorderedRequests()
.filter((r) => r.request === 'file');
const included = new Set();
for (const request of files) {
const file = ctx.files.resolveFile(request.content);
if (file instanceof flowr_rmarkdown_file_1.FlowrRMarkdownFile) {
for (const path of file.includedFiles) {
included.add(path);
}
}
}
ctx.files.loadingOrder.removeFromOrder(files.filter(r => included.has(r.content)));
}
}
exports.FlowrAnalyzerLoadingOrderIncludedFilesPlugin = FlowrAnalyzerLoadingOrderIncludedFilesPlugin;
//# sourceMappingURL=flowr-analyzer-loading-order-included-files-plugin.js.map