@eagleoutice/flowr
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
46 lines • 1.72 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.AbstractFlowrAnalyzerContext = void 0;
const assert_1 = require("../../util/assert");
/**
* Abstract class representing the context, a context may be modified and enriched by plugins (see {@link FlowrAnalyzerPlugin}).
*
* Please use the specialized contexts like {@link FlowrAnalyzerFilesContext} or {@link FlowrAnalyzerLoadingOrderContext} to work with flowR and
* in general, use the {@link FlowrAnalyzerContext} to access the full project context.
*/
class AbstractFlowrAnalyzerContext {
/**
* The plugins registered for this context. These build the foundation for {@link applyPlugins}.
*/
plugins;
/**
* The linked full project context, allowing plugins to modify and access it.
*/
ctx;
/**
* Creates a new context with the given project context, a default plugin (to be used when no other is registered)
*/
constructor(ctx, defaultPlugin, plugins) {
this.plugins = [...plugins ?? [], defaultPlugin];
this.ctx = ctx;
}
/**
* Run all registered plugins on the given args, please be aware that if they are async, it is up to you to
* await them.
*/
applyPlugins(args) {
const res = [];
for (const plugin of this.plugins) {
res.push(plugin.processor(this.ctx, args));
}
return res.filter(assert_1.isNotUndefined);
}
/**
* Returns the project context this sub-context is attached to
*/
getAttachedContext() {
return this.ctx;
}
}
exports.AbstractFlowrAnalyzerContext = AbstractFlowrAnalyzerContext;
//# sourceMappingURL=abstract-flowr-analyzer-context.js.map