@eagleoutice/flowr-dev
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
38 lines • 1.6 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.executeConfigQuery = executeConfigQuery;
const log_1 = require("../../../util/log");
const config_query_format_1 = require("./config-query-format");
const assert_1 = require("../../../util/assert");
/**
* Executes the given configuration queries using the provided analyzer.
*/
function executeConfigQuery({ analyzer }, queries) {
if (queries.some(q => q.reset)) {
analyzer.resetConfig();
}
const updates = queries.map(q => q.update).filter(assert_1.isNotUndefined);
if (updates.length > 1) {
log_1.log.warn('Config query usually expects only up to one update, but got', updates.length);
}
// validate here too (not only in the repl parser), so a programmatic / JSON-API update cannot merge an unknown
// key or a wrong-typed value; the update then lands via `updateConfig`, which invalidates the analysis cache
for (const update of updates) {
const err = (0, config_query_format_1.validateConfigUpdate)(update);
if (err !== undefined) {
log_1.log.warn(`ignoring invalid config update: ${err}`);
continue;
}
analyzer.updateConfig(update);
}
const specialization = analyzer.inspectContext().configSpecialization();
return Promise.resolve({
'.meta': {
/* there is no sense in measuring a get */
timing: 0
},
config: analyzer.flowrConfig,
...(specialization ? { specialization } : {})
});
}
//# sourceMappingURL=config-query-executor.js.map