@eagleoutice/flowr 2.9.13 → 2.9.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. package/README.md +22 -10
  2. package/abstract-interpretation/absint-visitor.d.ts +1 -1
  3. package/abstract-interpretation/absint-visitor.js +20 -20
  4. package/abstract-interpretation/data-frame/mappers/replacement-mapper.js +2 -2
  5. package/benchmark/slicer.d.ts +1 -1
  6. package/benchmark/slicer.js +7 -5
  7. package/cli/repl/commands/repl-dataflow.js +5 -5
  8. package/cli/repl/parser/slice-query-parser.d.ts +1 -1
  9. package/cli/repl/parser/slice-query-parser.js +2 -2
  10. package/cli/repl/server/connection.js +2 -2
  11. package/cli/repl/server/messages/message-slice.d.ts +1 -1
  12. package/cli/repl/server/messages/message-slice.js +2 -2
  13. package/config.d.ts +8 -8
  14. package/control-flow/extract-cfg.js +2 -2
  15. package/control-flow/semantic-cfg-guided-visitor.d.ts +1 -1
  16. package/control-flow/semantic-cfg-guided-visitor.js +43 -43
  17. package/control-flow/useless-loop.d.ts +1 -1
  18. package/control-flow/useless-loop.js +3 -3
  19. package/core/print/dataflow-printer.d.ts +0 -14
  20. package/core/print/dataflow-printer.js +0 -21
  21. package/core/steps/all/core/20-dataflow.d.ts +3 -3
  22. package/core/steps/all/core/20-dataflow.js +3 -2
  23. package/core/steps/all/static-slicing/00-slice.d.ts +2 -5
  24. package/core/steps/all/static-slicing/00-slice.js +6 -8
  25. package/core/steps/pipeline/default-pipelines.d.ts +89 -89
  26. package/dataflow/environments/built-in-proc-name.d.ts +83 -0
  27. package/dataflow/environments/built-in-proc-name.js +88 -0
  28. package/dataflow/environments/built-in.d.ts +1 -83
  29. package/dataflow/environments/built-in.js +37 -120
  30. package/dataflow/environments/default-builtin-config.d.ts +1 -1
  31. package/dataflow/environments/default-builtin-config.js +75 -75
  32. package/dataflow/environments/identifier.d.ts +1 -0
  33. package/dataflow/environments/identifier.js +1 -0
  34. package/dataflow/eval/resolve/resolve.js +2 -2
  35. package/dataflow/fn/exceptions-of-function.d.ts +1 -1
  36. package/dataflow/fn/exceptions-of-function.js +2 -2
  37. package/dataflow/graph/call-graph.d.ts +49 -19
  38. package/dataflow/graph/call-graph.js +117 -114
  39. package/dataflow/graph/dataflowgraph-builder.d.ts +1 -1
  40. package/dataflow/graph/dataflowgraph-builder.js +2 -2
  41. package/dataflow/graph/df-helper.d.ts +132 -0
  42. package/dataflow/graph/df-helper.js +131 -0
  43. package/dataflow/graph/diff-dataflow-graph.d.ts +5 -10
  44. package/dataflow/graph/diff-dataflow-graph.js +3 -28
  45. package/dataflow/graph/edge.d.ts +1 -0
  46. package/dataflow/graph/edge.js +1 -0
  47. package/dataflow/graph/graph-helper.d.ts +55 -0
  48. package/dataflow/graph/graph-helper.js +105 -0
  49. package/dataflow/graph/graph.d.ts +6 -1
  50. package/dataflow/graph/graph.js +6 -1
  51. package/dataflow/graph/vertex.d.ts +1 -1
  52. package/dataflow/info.d.ts +14 -4
  53. package/dataflow/info.js +28 -16
  54. package/dataflow/internal/linker.d.ts +14 -10
  55. package/dataflow/internal/linker.js +29 -32
  56. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +5 -5
  57. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +4 -4
  58. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +7 -6
  59. package/dataflow/internal/process/functions/call/built-in/built-in-eval.d.ts +1 -1
  60. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +3 -3
  61. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +2 -2
  62. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +2 -2
  63. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +4 -4
  64. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +2 -2
  65. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +3 -3
  66. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +2 -2
  67. package/dataflow/internal/process/functions/call/built-in/built-in-list.js +2 -2
  68. package/dataflow/internal/process/functions/call/built-in/built-in-local.d.ts +1 -1
  69. package/dataflow/internal/process/functions/call/built-in/built-in-local.js +5 -5
  70. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +2 -2
  71. package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +2 -2
  72. package/dataflow/internal/process/functions/call/built-in/built-in-recall.js +2 -2
  73. package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.js +5 -5
  74. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +2 -2
  75. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.d.ts +1 -1
  76. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +5 -4
  77. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +2 -2
  78. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-dispatch.js +3 -3
  79. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +3 -3
  80. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -1
  81. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +7 -7
  82. package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +1 -1
  83. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +3 -3
  84. package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.js +3 -3
  85. package/dataflow/internal/process/functions/call/built-in/built-in-stop-if-not.js +2 -2
  86. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +6 -9
  87. package/dataflow/internal/process/functions/call/built-in/built-in-vector.js +2 -2
  88. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +2 -2
  89. package/dataflow/internal/process/functions/call/known-call-handling.js +2 -2
  90. package/dataflow/internal/process/functions/call/named-call-handling.d.ts +1 -1
  91. package/dataflow/internal/process/functions/call/named-call-handling.js +1 -1
  92. package/dataflow/internal/process/functions/call/unnamed-call-handling.js +2 -2
  93. package/dataflow/internal/process/process-uninteresting-leaf.d.ts +1 -1
  94. package/dataflow/internal/process/process-uninteresting-leaf.js +1 -1
  95. package/dataflow/origin/dfg-get-origin.d.ts +1 -1
  96. package/dataflow/origin/dfg-get-symbol-refs.js +6 -6
  97. package/documentation/doc-util/doc-dfg.d.ts +3 -0
  98. package/documentation/doc-util/doc-dfg.js +5 -7
  99. package/documentation/doc-util/doc-normalized-ast.d.ts +0 -6
  100. package/documentation/doc-util/doc-normalized-ast.js +0 -23
  101. package/documentation/doc-util/doc-structure.js +3 -3
  102. package/documentation/doc-util/doc-types.js +3 -3
  103. package/documentation/wiki-core.js +5 -4
  104. package/documentation/wiki-dataflow-graph.js +14 -12
  105. package/documentation/wiki-interface.js +3 -3
  106. package/documentation/wiki-linter.js +1 -0
  107. package/documentation/wiki-normalized-ast.js +5 -4
  108. package/documentation/wiki-query.js +28 -3
  109. package/linter/linter-rules.d.ts +24 -1
  110. package/linter/linter-rules.js +3 -1
  111. package/linter/rules/seeded-randomness.js +2 -2
  112. package/linter/rules/stop-with-call-arg.d.ts +35 -0
  113. package/linter/rules/stop-with-call-arg.js +72 -0
  114. package/linter/rules/useless-loop.d.ts +1 -1
  115. package/package.json +1 -1
  116. package/project/cache/flowr-analyzer-cache.d.ts +1 -1
  117. package/project/cache/flowr-analyzer-cache.js +1 -1
  118. package/project/flowr-analyzer-builder.d.ts +3 -0
  119. package/project/flowr-analyzer.d.ts +1 -1
  120. package/queries/catalog/call-context-query/identify-link-to-nested-call-relation.js +2 -2
  121. package/queries/catalog/call-graph-query/call-graph-query-format.d.ts +1 -1
  122. package/queries/catalog/call-graph-query/call-graph-query-format.js +2 -2
  123. package/queries/catalog/cluster-query/cluster-query-format.js +2 -2
  124. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.js +2 -2
  125. package/queries/catalog/dataflow-query/dataflow-query-format.js +2 -2
  126. package/queries/catalog/df-shape-query/df-shape-query-executor.js +1 -2
  127. package/queries/catalog/does-call-query/does-call-query-executor.js +2 -2
  128. package/queries/catalog/happens-before-query/happens-before-query-executor.js +2 -2
  129. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.d.ts +1 -1
  130. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.js +1 -1
  131. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +3 -3
  132. package/queries/catalog/location-map-query/location-map-query-executor.js +2 -2
  133. package/queries/catalog/origin-query/origin-query-executor.d.ts +1 -1
  134. package/queries/catalog/origin-query/origin-query-executor.js +3 -3
  135. package/queries/catalog/provenance-query/provenance-query-executor.d.ts +9 -0
  136. package/queries/catalog/provenance-query/provenance-query-executor.js +37 -0
  137. package/queries/catalog/provenance-query/provenance-query-format.d.ts +35 -0
  138. package/queries/catalog/provenance-query/provenance-query-format.js +62 -0
  139. package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +2 -2
  140. package/queries/catalog/search-query/search-query-format.js +1 -1
  141. package/queries/catalog/static-slice-query/static-slice-query-executor.js +4 -2
  142. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +2 -2
  143. package/queries/catalog/static-slice-query/static-slice-query-format.js +3 -3
  144. package/queries/query.d.ts +9 -1
  145. package/queries/query.js +2 -0
  146. package/r-bridge/lang-4.x/ast/model/model.d.ts +6 -0
  147. package/r-bridge/lang-4.x/ast/model/model.js +7 -1
  148. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +8 -1
  149. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.js +13 -0
  150. package/search/flowr-search-filters.d.ts +1 -1
  151. package/search/flowr-search-printer.js +3 -3
  152. package/search/search-executor/search-enrichers.js +2 -2
  153. package/search/search-executor/search-generators.js +1 -1
  154. package/slicing/criterion/parse.d.ts +40 -16
  155. package/slicing/criterion/parse.js +67 -63
  156. package/slicing/static/slicer-types.d.ts +2 -3
  157. package/slicing/static/static-slicer.d.ts +3 -4
  158. package/slicing/static/static-slicer.js +9 -12
  159. package/util/diff.d.ts +2 -2
  160. package/util/mermaid/ast.js +4 -4
  161. package/util/mermaid/cfg.js +5 -5
  162. package/util/mermaid/dfg.d.ts +33 -18
  163. package/util/mermaid/dfg.js +46 -31
  164. package/util/mermaid/mermaid.d.ts +57 -12
  165. package/util/mermaid/mermaid.js +74 -67
  166. package/util/range.d.ts +8 -0
  167. package/util/range.js +13 -1
  168. package/util/slice-direction.d.ts +7 -0
  169. package/util/slice-direction.js +12 -0
  170. package/util/version.js +1 -1
  171. package/dataflow/graph/invert-dfg.d.ts +0 -6
  172. package/dataflow/graph/invert-dfg.js +0 -20
  173. package/dataflow/graph/resolve-graph.d.ts +0 -8
  174. package/dataflow/graph/resolve-graph.js +0 -59
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DataflowMermaid = void 0;
3
4
  exports.mermaidNodeBrackets = mermaidNodeBrackets;
4
5
  exports.printIdentifier = printIdentifier;
5
- exports.graphToMermaid = graphToMermaid;
6
- exports.graphToMermaidUrl = graphToMermaidUrl;
7
6
  exports.diffGraphsToMermaid = diffGraphsToMermaid;
8
7
  exports.diffGraphsToMermaidUrl = diffGraphsToMermaidUrl;
9
8
  const mermaid_1 = require("./mermaid");
@@ -17,18 +16,19 @@ const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
17
16
  const info_1 = require("./info");
18
17
  const range_1 = require("../range");
19
18
  const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
19
+ const info_2 = require("../../dataflow/info");
20
20
  function subflowToMermaid(nodeId, subflow, mermaid, idPrefix = '') {
21
21
  if (subflow === undefined) {
22
22
  return;
23
23
  }
24
- const subflowId = (0, mermaid_1.escapeId)(`${idPrefix}flow-${nodeId}`);
24
+ const subflowId = mermaid_1.Mermaid.escapeId(`${idPrefix}flow-${nodeId}`);
25
25
  if (mermaid.simplified) {
26
26
  // get parent
27
27
  const idMap = mermaid.rootGraph.idMap;
28
28
  const node = idMap?.get(nodeId);
29
29
  const nodeLexeme = model_1.RNode.lexeme(node) ?? 'function';
30
30
  const location = node?.location?.[0] ? ` (L. ${node?.location?.[0]})` : '';
31
- mermaid.nodeLines.push(`\nsubgraph "${subflowId}" ["${(0, mermaid_1.escapeMarkdown)(nodeLexeme)}${location}"]`);
31
+ mermaid.nodeLines.push(`\nsubgraph "${subflowId}" ["${mermaid_1.Mermaid.escape(nodeLexeme)}${location}"]`);
32
32
  }
33
33
  else {
34
34
  mermaid.nodeLines.push(`\nsubgraph "${subflowId}" [function ${nodeId}]`);
@@ -83,7 +83,7 @@ function printArg(arg) {
83
83
  function displayFunctionArgMapping(argMapping) {
84
84
  const result = [];
85
85
  for (const arg of argMapping) {
86
- result.push((0, mermaid_1.escapeMarkdown)(printArg(arg)));
86
+ result.push(mermaid_1.Mermaid.escape(printArg(arg)));
87
87
  }
88
88
  return result.length === 0 ? '' : `\n (${result.join(', ')})`;
89
89
  }
@@ -139,7 +139,7 @@ function vertexToMermaid(info, mermaid, id, idPrefix, mark, includeOnlyIds) {
139
139
  const fCall = info.tag === vertex_1.VertexType.FunctionCall;
140
140
  const { open, close } = mermaidNodeBrackets(info.tag);
141
141
  const origId = id;
142
- id = (0, mermaid_1.escapeId)(id);
142
+ id = mermaid_1.Mermaid.escapeId(id);
143
143
  if (info.environment && mermaid.includeEnvironments) {
144
144
  if (info.environment.level > 0 || info.environment.current.memory.size !== 0) {
145
145
  mermaid.nodeLines.push(` %% Environment of ${id} [level: ${info.environment.level}]:`, printEnvironmentToLines(info.environment.current).map(x => ` %% ${x}`).join('\n'));
@@ -149,15 +149,15 @@ function vertexToMermaid(info, mermaid, id, idPrefix, mark, includeOnlyIds) {
149
149
  const lexeme = node?.lexeme ?? (node?.type === type_1.RType.ExpressionList ? node?.grouping?.[0]?.lexeme : '') ?? '??';
150
150
  if (mermaid.simplified) {
151
151
  const location = node?.location?.[0] ? ` (L. ${node?.location?.[0]})` : '';
152
- const escapedName = '**' + (0, mermaid_1.escapeMarkdown)(node ? `${lexeme}` : '??') + '**' + location + (node ? `\n*${node.type}*` : '');
152
+ const escapedName = '**' + mermaid_1.Mermaid.escape(node ? `${lexeme}` : '??') + '**' + location + (node ? `\n*${node.type}*` : '');
153
153
  mermaid.nodeLines.push(` ${idPrefix}${id}${open}"\`${escapedName}\`"${close}`);
154
154
  }
155
155
  else {
156
- const escapedName = (0, mermaid_1.escapeMarkdown)(node ? `[${node.type}] ${lexeme}` : '??');
156
+ const escapedName = mermaid_1.Mermaid.escape(node ? `[${node.type}] ${lexeme}` : '??');
157
157
  const deps = info.cds ? ', :may:' + info.cds.map(c => c.id + (c.when ? '+' : '-')).join(',') : '';
158
158
  const lnks = info.link?.origin ? ', :links:' + info.link.origin.join(',') : '';
159
159
  const n = node?.info.fullRange ?? node?.location ?? (node?.type === type_1.RType.ExpressionList ? node?.grouping?.[0].location : undefined);
160
- mermaid.nodeLines.push(` ${idPrefix}${id}${open}"\`${escapedName}${escapedName.length > 10 ? '\n ' : ' '}(${id}${deps}${lnks})\n *${range_1.SourceRange.format(n)}*${fCall ? displayFunctionArgMapping(info.args) : '' + (info.tag === vertex_1.VertexType.FunctionDefinition && info.mode && info.mode.length > 0 ? (0, mermaid_1.escapeMarkdown)(JSON.stringify(info.mode)) : '')}\`"${close}`);
160
+ mermaid.nodeLines.push(` ${idPrefix}${id}${open}"\`${escapedName}${escapedName.length > 10 ? '\n ' : ' '}(${id}${deps}${lnks})\n *${range_1.SourceRange.format(n)}*${fCall ? displayFunctionArgMapping(info.args) : '' + (info.tag === vertex_1.VertexType.FunctionDefinition && info.mode && info.mode.length > 0 ? mermaid_1.Mermaid.escape(JSON.stringify(info.mode)) : '')}\`"${close}`);
161
161
  }
162
162
  if (mark?.has(id)) {
163
163
  mermaid.nodeLines.push(` style ${idPrefix}${id} ${mermaid.markStyle.vertex} `);
@@ -180,7 +180,7 @@ function vertexToMermaid(info, mermaid, id, idPrefix, mark, includeOnlyIds) {
180
180
  continue;
181
181
  }
182
182
  const originalTarget = target;
183
- target = (0, mermaid_1.escapeId)(target);
183
+ target = mermaid_1.Mermaid.escapeId(target);
184
184
  const edgeTypes = typeof edge.types == 'number' ? new Set(edge_1.DfEdge.splitTypes(edge)) : edge.types;
185
185
  const edgeId = encodeEdge(idPrefix + id, idPrefix + target, edgeTypes);
186
186
  if (!mermaid.presentEdges.has(edgeId)) {
@@ -197,7 +197,7 @@ function vertexToMermaid(info, mermaid, id, idPrefix, mark, includeOnlyIds) {
197
197
  if (node_id_1.NodeId.isBuiltIn(target)) {
198
198
  mermaid.edgeLines.push(` linkStyle ${mermaid.presentEdges.size - 1} stroke:gray;`);
199
199
  if (!mermaid.presentVertices.has(target)) {
200
- mermaid.nodeLines.push(` ${idPrefix}${target}["\`Built-In:\n${(0, mermaid_1.escapeMarkdown)(String(originalTarget).replace('built-in:', ''))}\`"]`);
200
+ mermaid.nodeLines.push(` ${idPrefix}${target}["\`Built-In:\n${mermaid_1.Mermaid.escape(String(originalTarget).replace('built-in:', ''))}\`"]`);
201
201
  mermaid.nodeLines.push(` style ${idPrefix}${target} stroke:gray,fill:gray,stroke-width:2px,opacity:.8;`);
202
202
  mermaid.presentVertices.add(target);
203
203
  }
@@ -215,34 +215,49 @@ function graphToMermaidGraph(rootIds, { simplified, graph, prefix = 'flowchart B
215
215
  }
216
216
  return mermaid;
217
217
  }
218
- /**
219
- * Converts a dataflow graph to mermaid graph code that visualizes the graph.
220
- */
221
- function graphToMermaid(config) {
222
- const mermaid = graphToMermaidGraph(config.includeOnlyIds ? config.includeOnlyIds : config.graph.rootIds(), config);
223
- return { string: `${mermaid.nodeLines.join('\n')}\n${mermaid.edgeLines.join('\n')}`, mermaid };
224
- }
225
- /**
226
- * Converts a dataflow graph to a mermaid url that visualizes the graph.
227
- * @param graph - The graph to convert
228
- * @param includeEnvironments - Whether to include the environments in the mermaid graph code
229
- * @param mark - Special nodes to mark (e.g., those included in the slice)
230
- * @param simplified - Whether to simplify the graph
231
- */
232
- function graphToMermaidUrl(graph, includeEnvironments, mark, simplified = false) {
233
- return (0, mermaid_1.mermaidCodeToUrl)(graphToMermaid({ graph, includeEnvironments, mark, simplified }).string);
234
- }
235
218
  /** uses same id map but ensures, it is different from the rhs so that mermaid can work with that */
236
219
  function diffGraphsToMermaid(left, right, prefix) {
237
220
  // we add the prefix ourselves
238
- const { string: leftGraph, mermaid } = graphToMermaid({ graph: left.graph, prefix: '', idPrefix: `l-${left.label}`, includeEnvironments: true, mark: left.mark });
239
- const { string: rightGraph } = graphToMermaid({ graph: right.graph, prefix: '', idPrefix: `r-${right.label}`, includeEnvironments: true, mark: right.mark, presentEdges: mermaid.presentEdges });
221
+ const { string: leftGraph, mermaid } = exports.DataflowMermaid.convert({ graph: left.graph, prefix: '', idPrefix: `l-${left.label}`, includeEnvironments: true, mark: left.mark });
222
+ const { string: rightGraph } = exports.DataflowMermaid.convert({ graph: right.graph, prefix: '', idPrefix: `r-${right.label}`, includeEnvironments: true, mark: right.mark, presentEdges: mermaid.presentEdges });
240
223
  return `${prefix}flowchart BT\nsubgraph "${left.label}"\n${leftGraph}\nend\nsubgraph "${right.label}"\n${rightGraph}\nend`;
241
224
  }
242
225
  /**
243
226
  * Converts two dataflow graphs to a mermaid url that visualizes their differences.
244
227
  */
245
228
  function diffGraphsToMermaidUrl(left, right, prefix) {
246
- return (0, mermaid_1.mermaidCodeToUrl)(diffGraphsToMermaid(left, right, prefix));
229
+ return mermaid_1.Mermaid.codeToUrl(diffGraphsToMermaid(left, right, prefix));
247
230
  }
231
+ /**
232
+ * The helper object for all things regarding the mermaid based visualization of dataflow graphs!
233
+ */
234
+ exports.DataflowMermaid = {
235
+ name: 'DataflowMermaid',
236
+ /**
237
+ * Converts a dataflow graph to mermaid graph code that visualizes the graph.
238
+ * @see {@link DataflowMermaid.url} - render the given graph to a url to mermaid.live
239
+ */
240
+ convert(config) {
241
+ const mermaid = graphToMermaidGraph(config.includeOnlyIds ?? config.graph.rootIds(), config);
242
+ return { string: `${mermaid.nodeLines.join('\n')}\n${mermaid.edgeLines.join('\n')}`, mermaid };
243
+ },
244
+ /**
245
+ * This is a simplified version of {@link DataflowMermaid.convertToMermaid}
246
+ */
247
+ raw(graph, includeEnvironments, mark, simplified = false) {
248
+ graph = info_2.DataflowInformation.is(graph) ? graph.graph : graph;
249
+ return exports.DataflowMermaid.convert({ graph, includeEnvironments, mark, simplified }).string;
250
+ },
251
+ /**
252
+ * Converts a dataflow graph to a mermaid url that visualizes the graph.
253
+ * This is basically a combination of {@link DataflowMermaid.mermaidRaw} and {@link Mermaid.codeToUrl}.
254
+ * @param graph - the dataflow graph to render
255
+ * @param includeEnvironments - whether to include the environment content in the output
256
+ * @param mark - which vertices to highlight in the visualization
257
+ * @param simplified - whether to show a simplified use of the graph with fewer details on the vertices and edges
258
+ */
259
+ url(graph, includeEnvironments, mark, simplified = false) {
260
+ return mermaid_1.Mermaid.codeToUrl(exports.DataflowMermaid.raw(graph, includeEnvironments, mark, simplified));
261
+ }
262
+ };
248
263
  //# sourceMappingURL=dfg.js.map
@@ -1,14 +1,59 @@
1
1
  /**
2
- * Escapes markdown special characters in a string.
2
+ * Global mermaid helper object with useful functions.
3
3
  */
4
- export declare function escapeMarkdown(text: string): string;
5
- /**
6
- * Escapes a string or number to be used as a mermaid node id.
7
- */
8
- export declare function escapeId(text: string | number): string;
9
- /**
10
- * Converts mermaid code (potentially produced by {@link graphToMermaid}) to an url that presents the graph in the mermaid editor.
11
- * @param code - code to convert
12
- * @param edit - if true, the url will point to the editor, otherwise it will point to the viewer
13
- */
14
- export declare function mermaidCodeToUrl(code: string, edit?: boolean): string;
4
+ export declare const Mermaid: {
5
+ readonly name: "Mermaid";
6
+ /**
7
+ * Replacements applied by escape functions!
8
+ */
9
+ readonly replacements: {
10
+ readonly '\\n': "\n";
11
+ readonly '`': "#96;";
12
+ readonly '[': "#91;";
13
+ readonly ']': "#93;";
14
+ readonly '<': "#60;";
15
+ readonly '>': "#62;";
16
+ readonly '*': "#42;";
17
+ readonly '+': "#43;";
18
+ readonly '-': "#45;";
19
+ readonly '"': "#34;";
20
+ readonly '\\': "#92;";
21
+ readonly _: "#95;";
22
+ readonly '{': "#123;";
23
+ readonly '}': "#125;";
24
+ readonly '&': "#38;";
25
+ readonly '\'': "#39;";
26
+ readonly ':': "#58;";
27
+ readonly '\u2228': "#8744;";
28
+ readonly '\u2227': "#8743;";
29
+ readonly '\u00AC': "#172;";
30
+ readonly '\u2192': "#8594;";
31
+ readonly '\u2194': "#8596;";
32
+ readonly '\u21D2': "#8658;";
33
+ readonly '\u21D4': "#8660;";
34
+ readonly '\u2200': "#8704;";
35
+ readonly '\u2203': "#8707;";
36
+ readonly '\u2208': "#8712;";
37
+ readonly '\u2209': "#8713;";
38
+ readonly '\u220B': "#8715;";
39
+ readonly '\u220C': "#8716;";
40
+ readonly '\u2229': "#8745;";
41
+ readonly '\u222A': "#8746;";
42
+ readonly '\u222B': "#8747;";
43
+ readonly '\u2295': "#8853;";
44
+ };
45
+ /**
46
+ * Escapes markdown special characters in a string.
47
+ */
48
+ readonly escape: (this: void, text: string) => string;
49
+ /**
50
+ * Escapes a string or number to be used as a mermaid node id.
51
+ */
52
+ readonly escapeId: (this: void, text: string | number) => string;
53
+ /**
54
+ * Converts mermaid code (potentially produced by {@link DataflowMermaid.convert}) to an url that presents the graph in the mermaid editor.
55
+ * @param code - code to convert
56
+ * @param edit - if true, the url will point to the editor, otherwise it will point to the viewer
57
+ */
58
+ readonly codeToUrl: (this: void, code: string, edit?: boolean) => string;
59
+ };
@@ -1,73 +1,80 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.escapeMarkdown = escapeMarkdown;
4
- exports.escapeId = escapeId;
5
- exports.mermaidCodeToUrl = mermaidCodeToUrl;
6
- const replacements = {
7
- // keep newlines
8
- '\\n': '\n',
9
- '`': '#96;',
10
- '[': '#91;',
11
- ']': '#93;',
12
- '<': '#60;',
13
- '>': '#62;',
14
- '*': '#42;',
15
- '+': '#43;',
16
- '-': '#45;',
17
- '"': '#34;',
18
- '\\': '#92;',
19
- '_': '#95;',
20
- '{': '#123;',
21
- '}': '#125;',
22
- '&': '#38;',
23
- '\'': '#39;',
24
- ':': '#58;',
25
- '∨': '#8744;',
26
- '∧': '#8743;',
27
- '¬': '#172;',
28
- '→': '#8594;',
29
- '↔': '#8596;',
30
- '⇒': '#8658;',
31
- '⇔': '#8660;',
32
- '∀': '#8704;',
33
- '∃': '#8707;',
34
- '∈': '#8712;',
35
- '∉': '#8713;',
36
- '∋': '#8715;',
37
- '∌': '#8716;',
38
- '∩': '#8745;',
39
- '∪': '#8746;',
40
- '∫': '#8747;',
41
- '⊕': '#8853;',
42
- };
43
- /**
44
- * Escapes markdown special characters in a string.
45
- */
46
- function escapeMarkdown(text) {
47
- for (const [key, value] of Object.entries(replacements)) {
48
- text = text.replaceAll(key, value);
49
- }
50
- return text;
51
- }
3
+ exports.Mermaid = void 0;
52
4
  /**
53
- * Escapes a string or number to be used as a mermaid node id.
5
+ * Global mermaid helper object with useful functions.
54
6
  */
55
- function escapeId(text) {
56
- text = String(text).replace(/[^a-zA-Z0-9:-]/g, '_');
57
- return text;
58
- }
59
- /**
60
- * Converts mermaid code (potentially produced by {@link graphToMermaid}) to an url that presents the graph in the mermaid editor.
61
- * @param code - code to convert
62
- * @param edit - if true, the url will point to the editor, otherwise it will point to the viewer
63
- */
64
- function mermaidCodeToUrl(code, edit = false) {
65
- const obj = {
66
- code,
67
- mermaid: {
68
- autoSync: true
7
+ exports.Mermaid = {
8
+ name: 'Mermaid',
9
+ /**
10
+ * Replacements applied by escape functions!
11
+ */
12
+ replacements: {
13
+ // keep newlines
14
+ '\\n': '\n',
15
+ '`': '#96;',
16
+ '[': '#91;',
17
+ ']': '#93;',
18
+ '<': '#60;',
19
+ '>': '#62;',
20
+ '*': '#42;',
21
+ '+': '#43;',
22
+ '-': '#45;',
23
+ '"': '#34;',
24
+ '\\': '#92;',
25
+ '_': '#95;',
26
+ '{': '#123;',
27
+ '}': '#125;',
28
+ '&': '#38;',
29
+ '\'': '#39;',
30
+ ':': '#58;',
31
+ '∨': '#8744;',
32
+ '∧': '#8743;',
33
+ '¬': '#172;',
34
+ '→': '#8594;',
35
+ '↔': '#8596;',
36
+ '⇒': '#8658;',
37
+ '⇔': '#8660;',
38
+ '∀': '#8704;',
39
+ '∃': '#8707;',
40
+ '∈': '#8712;',
41
+ '∉': '#8713;',
42
+ '∋': '#8715;',
43
+ '∌': '#8716;',
44
+ '∩': '#8745;',
45
+ '∪': '#8746;',
46
+ '∫': '#8747;',
47
+ '⊕': '#8853;',
48
+ },
49
+ /**
50
+ * Escapes markdown special characters in a string.
51
+ */
52
+ escape(text) {
53
+ for (const [key, value] of Object.entries(exports.Mermaid.replacements)) {
54
+ text = text.replaceAll(key, value);
69
55
  }
70
- };
71
- return `https://mermaid.live/${edit ? 'edit' : 'view'}#base64:${Buffer.from(JSON.stringify(obj)).toString('base64')}`;
72
- }
56
+ return text;
57
+ },
58
+ /**
59
+ * Escapes a string or number to be used as a mermaid node id.
60
+ */
61
+ escapeId(text) {
62
+ text = String(text).replace(/[^a-zA-Z0-9:-]/g, '_');
63
+ return text;
64
+ },
65
+ /**
66
+ * Converts mermaid code (potentially produced by {@link DataflowMermaid.convert}) to an url that presents the graph in the mermaid editor.
67
+ * @param code - code to convert
68
+ * @param edit - if true, the url will point to the editor, otherwise it will point to the viewer
69
+ */
70
+ codeToUrl(code, edit = false) {
71
+ const obj = {
72
+ code,
73
+ mermaid: {
74
+ autoSync: true
75
+ }
76
+ };
77
+ return `https://mermaid.live/${edit ? 'edit' : 'view'}#base64:${Buffer.from(JSON.stringify(obj)).toString('base64')}`;
78
+ }
79
+ };
73
80
  //# sourceMappingURL=mermaid.js.map
package/util/range.d.ts CHANGED
@@ -31,6 +31,14 @@ export declare const SourcePosition: {
31
31
  * returns an invalid source position
32
32
  */
33
33
  readonly invalid: (this: void) => SourcePosition;
34
+ /**
35
+ * Returns the line of a source position
36
+ */
37
+ readonly getLine: (this: void, pos: SourcePosition) => number;
38
+ /**
39
+ * Returns the column of a source position
40
+ */
41
+ readonly getColumn: (this: void, pos: SourcePosition) => number;
34
42
  };
35
43
  /**
36
44
  * **Please note** that for multi-file projects we also have a {@link SourceLocation|source location} type that includes the file name.
package/util/range.js CHANGED
@@ -31,7 +31,19 @@ exports.SourcePosition = {
31
31
  */
32
32
  invalid() {
33
33
  return [-1, -1];
34
- }
34
+ },
35
+ /**
36
+ * Returns the line of a source position
37
+ */
38
+ getLine(pos) {
39
+ return pos[0];
40
+ },
41
+ /**
42
+ * Returns the column of a source position
43
+ */
44
+ getColumn(pos) {
45
+ return pos[1];
46
+ },
35
47
  };
36
48
  /**
37
49
  * Utility functions for {@link SourceRange|source ranges}.
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The direction to slice a program.
3
+ */
4
+ export declare enum SliceDirection {
5
+ Backward = "backward",
6
+ Forward = "forward"
7
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SliceDirection = void 0;
4
+ /**
5
+ * The direction to slice a program.
6
+ */
7
+ var SliceDirection;
8
+ (function (SliceDirection) {
9
+ SliceDirection["Backward"] = "backward";
10
+ SliceDirection["Forward"] = "forward";
11
+ })(SliceDirection || (exports.SliceDirection = SliceDirection = {}));
12
+ //# sourceMappingURL=slice-direction.js.map
package/util/version.js CHANGED
@@ -6,7 +6,7 @@ exports.printVersionInformation = printVersionInformation;
6
6
  const semver_1 = require("semver");
7
7
  const assert_1 = require("./assert");
8
8
  // this is automatically replaced with the current version by release-it
9
- const version = '2.9.13';
9
+ const version = '2.9.14';
10
10
  /**
11
11
  * Retrieves the current flowR version as a new {@link SemVer} object.
12
12
  */
@@ -1,6 +0,0 @@
1
- import { DataflowGraph } from './graph';
2
- import type { REnvironmentInformation } from '../environments/environment';
3
- /**
4
- * Inverts the given dataflow graph by reversing all edges.
5
- */
6
- export declare function invertDfg(graph: DataflowGraph, cleanEnv: REnvironmentInformation): DataflowGraph;
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.invertDfg = invertDfg;
4
- const graph_1 = require("./graph");
5
- /**
6
- * Inverts the given dataflow graph by reversing all edges.
7
- */
8
- function invertDfg(graph, cleanEnv) {
9
- const invertedGraph = new graph_1.DataflowGraph(graph.idMap);
10
- for (const [, v] of graph.vertices(true)) {
11
- invertedGraph.addVertex(v, cleanEnv);
12
- }
13
- for (const [from, targets] of graph.edges()) {
14
- for (const [to, { types }] of targets) {
15
- invertedGraph.addEdge(to, from, types);
16
- }
17
- }
18
- return invertedGraph;
19
- }
20
- //# sourceMappingURL=invert-dfg.js.map
@@ -1,8 +0,0 @@
1
- import { DataflowGraph } from './graph';
2
- import { type AstIdMap } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
3
- import type { ReadOnlyFlowrAnalyzerContext } from '../../project/context/flowr-analyzer-context';
4
- /**
5
- * Resolves the dataflow graph ids from slicing criterion form to ids.
6
- * This returns a **new** graph with the resolved ids.
7
- */
8
- export declare function resolveDataflowGraph(graph: DataflowGraph, ctx: ReadOnlyFlowrAnalyzerContext, idMap?: AstIdMap): DataflowGraph;
@@ -1,59 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveDataflowGraph = resolveDataflowGraph;
4
- const graph_1 = require("./graph");
5
- const assert_1 = require("../../util/assert");
6
- const parse_1 = require("../../slicing/criterion/parse");
7
- const edge_1 = require("./edge");
8
- /**
9
- * Resolves the dataflow graph ids from slicing criterion form to ids.
10
- * This returns a **new** graph with the resolved ids.
11
- */
12
- function resolveDataflowGraph(graph, ctx, idMap) {
13
- const resolveMap = idMap ?? graph.idMap;
14
- (0, assert_1.guard)(resolveMap !== undefined, 'idMap must be provided to resolve the graph');
15
- const cache = new Map();
16
- const resolve = (id) => {
17
- const cached = cache.get(id);
18
- if (cached !== undefined) {
19
- return cached;
20
- }
21
- let resolved;
22
- try {
23
- resolved = (0, parse_1.slicingCriterionToId)(id, resolveMap);
24
- }
25
- catch {
26
- /* just keep it :D */
27
- resolved = id;
28
- }
29
- cache.set(id, resolved);
30
- return resolved;
31
- };
32
- const resultGraph = new graph_1.DataflowGraph(resolveMap);
33
- const roots = graph.rootIds();
34
- /* recreate vertices */
35
- for (const [id, vertex] of graph.vertices(true)) {
36
- resultGraph.addVertex({
37
- ...vertex,
38
- id: resolve(id)
39
- }, ctx.env.makeCleanEnv(), roots.has(id));
40
- }
41
- /* recreate edges */
42
- for (const [from, targets] of graph.edges()) {
43
- for (const [to, info] of targets) {
44
- for (const type of edge_1.DfEdge.splitTypes(info)) {
45
- resultGraph.addEdge(resolve(from), resolve(to), type);
46
- }
47
- }
48
- }
49
- for (const unknown of graph.unknownSideEffects) {
50
- if (typeof unknown === 'object') {
51
- resultGraph.markIdForUnknownSideEffects(resolve(unknown.id), unknown.linkTo);
52
- }
53
- else {
54
- resultGraph.markIdForUnknownSideEffects(resolve(unknown));
55
- }
56
- }
57
- return resultGraph;
58
- }
59
- //# sourceMappingURL=resolve-graph.js.map