@eagleoutice/flowr-dev
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
43 lines • 2.18 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.DataflowQueryDefinition = void 0;
const dataflow_query_executor_1 = require("./dataflow-query-executor");
const ansi_1 = require("../../../util/text/ansi");
const time_1 = require("../../../util/text/time");
const joi_1 = __importDefault(require("joi"));
const df_helper_1 = require("../../../dataflow/graph/df-helper");
/** Above this many characters, the mermaid.live link is dropped from the REPL output (large graphs produce megabyte-sized base64 urls). */
const MaxMermaidUrlLength = 8000;
exports.DataflowQueryDefinition = {
title: 'Dataflow Query',
executor: dataflow_query_executor_1.executeDataflowQuery,
asciiSummarizer: (formatter, _analyzer, queryResults, result) => {
const out = queryResults;
result.push(`Query: ${(0, ansi_1.bold)('dataflow', formatter)} (${(0, time_1.printAsMs)(out['.meta'].timing, 0)})`);
const url = df_helper_1.Dataflow.visualize.mermaid.url(out.graph);
if (url.length <= MaxMermaidUrlLength) {
result.push(` ╰ [Dataflow Graph](${url})`);
}
else {
const vertices = Array.from(out.graph.vertices(true)).length;
const edges = Array.from(out.graph.edges()).length;
result.push(` ╰ Dataflow Graph too large to link (${vertices} vertices, ${edges} edges, url would be ${url.length} chars); use ':df#' for more detail.`);
}
return true;
},
schema: joi_1.default.object({
type: joi_1.default.string().valid('dataflow').required().description('The type of the query.'),
}).description('The dataflow query simply returns the dataflow graph, there is no need to pass it multiple times!'),
flattenInvolvedNodes: queryResults => {
const flattened = [];
const out = queryResults;
for (const id of out.graph.idMap?.keys() ?? []) {
flattened.push(id);
}
return flattened;
}
};
//# sourceMappingURL=dataflow-query-format.js.map