@eagleoutice/flowr 2.9.13 → 2.10.1
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.
- package/README.md +52 -28
- package/abstract-interpretation/absint-visitor.d.ts +1 -1
- package/abstract-interpretation/absint-visitor.js +20 -20
- package/abstract-interpretation/data-frame/mappers/replacement-mapper.js +2 -2
- package/benchmark/slicer.d.ts +1 -1
- package/benchmark/slicer.js +7 -5
- package/benchmark/stats/stats.d.ts +2 -2
- package/cli/repl/commands/repl-dataflow.js +5 -5
- package/cli/repl/parser/slice-query-parser.d.ts +3 -3
- package/cli/repl/parser/slice-query-parser.js +2 -2
- package/cli/repl/server/connection.js +2 -2
- package/cli/repl/server/messages/message-slice.d.ts +1 -1
- package/cli/repl/server/messages/message-slice.js +2 -2
- package/config.d.ts +12 -8
- package/config.js +5 -3
- package/control-flow/extract-cfg.js +2 -2
- package/control-flow/semantic-cfg-guided-visitor.d.ts +1 -1
- package/control-flow/semantic-cfg-guided-visitor.js +43 -43
- package/control-flow/useless-loop.d.ts +1 -1
- package/control-flow/useless-loop.js +3 -3
- package/core/print/dataflow-printer.d.ts +0 -14
- package/core/print/dataflow-printer.js +0 -21
- package/core/steps/all/core/20-dataflow.d.ts +3 -3
- package/core/steps/all/core/20-dataflow.js +3 -2
- package/core/steps/all/static-slicing/00-slice.d.ts +2 -5
- package/core/steps/all/static-slicing/00-slice.js +6 -8
- package/core/steps/pipeline/default-pipelines.d.ts +89 -89
- package/dataflow/environments/built-in-proc-name.d.ts +83 -0
- package/dataflow/environments/built-in-proc-name.js +88 -0
- package/dataflow/environments/built-in.d.ts +1 -83
- package/dataflow/environments/built-in.js +37 -120
- package/dataflow/environments/default-builtin-config.d.ts +1 -1
- package/dataflow/environments/default-builtin-config.js +75 -75
- package/dataflow/environments/identifier.d.ts +5 -0
- package/dataflow/environments/identifier.js +18 -0
- package/dataflow/eval/resolve/resolve.js +2 -2
- package/dataflow/fn/exceptions-of-function.d.ts +1 -1
- package/dataflow/fn/exceptions-of-function.js +2 -2
- package/dataflow/graph/call-graph.d.ts +46 -19
- package/dataflow/graph/call-graph.js +95 -114
- package/dataflow/graph/dataflowgraph-builder.d.ts +1 -1
- package/dataflow/graph/dataflowgraph-builder.js +2 -2
- package/dataflow/graph/df-helper.d.ts +133 -0
- package/dataflow/graph/df-helper.js +138 -0
- package/dataflow/graph/diff-dataflow-graph.d.ts +5 -10
- package/dataflow/graph/diff-dataflow-graph.js +3 -28
- package/dataflow/graph/edge.d.ts +1 -0
- package/dataflow/graph/edge.js +1 -0
- package/dataflow/graph/graph-helper.d.ts +60 -0
- package/dataflow/graph/graph-helper.js +128 -0
- package/dataflow/graph/graph.d.ts +19 -3
- package/dataflow/graph/graph.js +32 -5
- package/dataflow/graph/vertex.d.ts +3 -1
- package/dataflow/info.d.ts +14 -4
- package/dataflow/info.js +28 -16
- package/dataflow/internal/linker.d.ts +14 -10
- package/dataflow/internal/linker.js +29 -32
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +5 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +5 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +8 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +6 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-list.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-local.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-local.js +5 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-recall.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.js +5 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +5 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-dispatch.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +7 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-stop-if-not.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +6 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-vector.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +2 -2
- package/dataflow/internal/process/functions/call/common.js +2 -1
- package/dataflow/internal/process/functions/call/known-call-handling.js +2 -2
- package/dataflow/internal/process/functions/call/named-call-handling.d.ts +1 -1
- package/dataflow/internal/process/functions/call/named-call-handling.js +1 -1
- package/dataflow/internal/process/functions/call/unnamed-call-handling.js +2 -2
- package/dataflow/internal/process/functions/process-parameter.js +1 -1
- package/dataflow/internal/process/process-uninteresting-leaf.d.ts +1 -1
- package/dataflow/internal/process/process-uninteresting-leaf.js +1 -1
- package/dataflow/origin/dfg-get-origin.d.ts +1 -1
- package/dataflow/origin/dfg-get-symbol-refs.js +6 -6
- package/documentation/doc-readme.js +2 -1
- package/documentation/doc-util/doc-dfg.d.ts +3 -0
- package/documentation/doc-util/doc-dfg.js +5 -7
- package/documentation/doc-util/doc-normalized-ast.d.ts +0 -6
- package/documentation/doc-util/doc-normalized-ast.js +0 -23
- package/documentation/doc-util/doc-structure.js +3 -3
- package/documentation/doc-util/doc-types.js +3 -3
- package/documentation/wiki-core.js +5 -4
- package/documentation/wiki-dataflow-graph.js +14 -12
- package/documentation/wiki-interface.js +3 -3
- package/documentation/wiki-linter.js +6 -0
- package/documentation/wiki-normalized-ast.js +5 -4
- package/documentation/wiki-query.js +28 -3
- package/linter/linter-rules.d.ts +49 -1
- package/linter/linter-rules.js +5 -1
- package/linter/rules/problematic-eval.d.ts +44 -0
- package/linter/rules/problematic-eval.js +83 -0
- package/linter/rules/seeded-randomness.js +2 -2
- package/linter/rules/stop-with-call-arg.d.ts +35 -0
- package/linter/rules/stop-with-call-arg.js +72 -0
- package/linter/rules/useless-loop.d.ts +1 -1
- package/package.json +7 -7
- package/project/cache/flowr-analyzer-cache.d.ts +1 -1
- package/project/cache/flowr-analyzer-cache.js +1 -1
- package/project/flowr-analyzer-builder.d.ts +3 -0
- package/project/flowr-analyzer.d.ts +1 -1
- package/queries/catalog/call-context-query/identify-link-to-nested-call-relation.js +2 -2
- package/queries/catalog/call-graph-query/call-graph-query-format.d.ts +1 -1
- package/queries/catalog/call-graph-query/call-graph-query-format.js +2 -2
- package/queries/catalog/cluster-query/cluster-query-format.js +2 -2
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.js +2 -2
- package/queries/catalog/dataflow-query/dataflow-query-format.js +2 -2
- package/queries/catalog/df-shape-query/df-shape-query-executor.js +1 -2
- package/queries/catalog/df-shape-query/df-shape-query-format.d.ts +3 -3
- package/queries/catalog/does-call-query/does-call-query-executor.js +2 -2
- package/queries/catalog/does-call-query/does-call-query-format.d.ts +2 -2
- package/queries/catalog/happens-before-query/happens-before-query-executor.js +2 -2
- package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +3 -3
- package/queries/catalog/input-sources-query/input-sources-query-executor.d.ts +6 -0
- package/queries/catalog/input-sources-query/input-sources-query-executor.js +66 -0
- package/queries/catalog/input-sources-query/input-sources-query-format.d.ts +36 -0
- package/queries/catalog/input-sources-query/input-sources-query-format.js +63 -0
- package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +90 -0
- package/queries/catalog/input-sources-query/simple-input-classifier.js +308 -0
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.d.ts +2 -2
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.js +1 -1
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.d.ts +2 -2
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +3 -3
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +2 -2
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.d.ts +2 -2
- package/queries/catalog/location-map-query/location-map-query-executor.js +2 -2
- package/queries/catalog/location-map-query/location-map-query-format.d.ts +2 -2
- package/queries/catalog/origin-query/origin-query-executor.d.ts +2 -2
- package/queries/catalog/origin-query/origin-query-executor.js +3 -3
- package/queries/catalog/origin-query/origin-query-format.d.ts +3 -3
- package/queries/catalog/provenance-query/provenance-query-executor.d.ts +6 -0
- package/queries/catalog/provenance-query/provenance-query-executor.js +34 -0
- package/queries/catalog/provenance-query/provenance-query-format.d.ts +35 -0
- package/queries/catalog/provenance-query/provenance-query-format.js +62 -0
- package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +2 -2
- package/queries/catalog/search-query/search-query-format.js +1 -1
- package/queries/catalog/static-slice-query/static-slice-query-executor.js +4 -2
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +2 -2
- package/queries/catalog/static-slice-query/static-slice-query-format.js +3 -3
- package/queries/query.d.ts +17 -1
- package/queries/query.js +4 -0
- package/r-bridge/lang-4.x/ast/model/model.d.ts +9 -0
- package/r-bridge/lang-4.x/ast/model/model.js +10 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +16 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.js +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +16 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.js +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +16 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.js +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +15 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-break.js +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +15 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.js +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +16 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.js +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +16 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.js +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +16 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +29 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.js +29 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +16 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.js +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +16 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.js +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +16 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-logical.js +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +16 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-next.js +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +16 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-number.js +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +16 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.js +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +16 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.js +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +16 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.js +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +16 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.js +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +16 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.js +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +16 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.js +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +16 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.js +2 -0
- package/search/flowr-search-filters.d.ts +1 -1
- package/search/flowr-search-printer.js +3 -3
- package/search/search-executor/search-enrichers.js +2 -2
- package/search/search-executor/search-generators.js +1 -1
- package/slicing/criterion/parse.d.ts +43 -18
- package/slicing/criterion/parse.js +68 -63
- package/slicing/static/slicer-types.d.ts +2 -3
- package/slicing/static/static-slicer.d.ts +3 -4
- package/slicing/static/static-slicer.js +32 -12
- package/util/collections/arrays.d.ts +4 -0
- package/util/collections/arrays.js +7 -0
- package/util/diff.d.ts +2 -2
- package/util/mermaid/ast.js +4 -4
- package/util/mermaid/cfg.js +5 -5
- package/util/mermaid/dfg.d.ts +33 -18
- package/util/mermaid/dfg.js +47 -31
- package/util/mermaid/mermaid.d.ts +57 -12
- package/util/mermaid/mermaid.js +74 -67
- package/util/range.d.ts +8 -0
- package/util/range.js +13 -1
- package/util/slice-direction.d.ts +7 -0
- package/util/slice-direction.js +12 -0
- package/util/version.js +1 -1
- package/dataflow/graph/invert-dfg.d.ts +0 -6
- package/dataflow/graph/invert-dfg.js +0 -20
- package/dataflow/graph/resolve-graph.d.ts +0 -8
- package/dataflow/graph/resolve-graph.js +0 -59
|
@@ -92,6 +92,10 @@ export declare function equidistantSampling<T>(list: readonly T[], sampleCount:
|
|
|
92
92
|
export declare function cartesianProduct<T>(...arrays: T[][]): T[][];
|
|
93
93
|
/** merge two arrays, removing duplicates */
|
|
94
94
|
export declare function uniqueArrayMerge<T>(left: readonly T[], right: readonly T[]): T[];
|
|
95
|
+
/**
|
|
96
|
+
* Returns a duplicate-free array.
|
|
97
|
+
*/
|
|
98
|
+
export declare function uniqueArray<T>(a: Iterable<T>): T[];
|
|
95
99
|
/**
|
|
96
100
|
* Groups the elements of the given array by the key returned by the given key function.
|
|
97
101
|
*/
|
|
@@ -11,6 +11,7 @@ exports.arrayEqual = arrayEqual;
|
|
|
11
11
|
exports.equidistantSampling = equidistantSampling;
|
|
12
12
|
exports.cartesianProduct = cartesianProduct;
|
|
13
13
|
exports.uniqueArrayMerge = uniqueArrayMerge;
|
|
14
|
+
exports.uniqueArray = uniqueArray;
|
|
14
15
|
exports.arraysGroupBy = arraysGroupBy;
|
|
15
16
|
const assert_1 = require("../assert");
|
|
16
17
|
/**
|
|
@@ -227,6 +228,12 @@ function uniqueArrayMerge(left, right) {
|
|
|
227
228
|
}
|
|
228
229
|
return Array.from(result);
|
|
229
230
|
}
|
|
231
|
+
/**
|
|
232
|
+
* Returns a duplicate-free array.
|
|
233
|
+
*/
|
|
234
|
+
function uniqueArray(a) {
|
|
235
|
+
return Array.from(new Set(a));
|
|
236
|
+
}
|
|
230
237
|
/**
|
|
231
238
|
* Groups the elements of the given array by the key returned by the given key function.
|
|
232
239
|
*/
|
package/util/diff.d.ts
CHANGED
|
@@ -42,12 +42,12 @@ export interface GenericDifferenceInformation<Report extends WriteableDifference
|
|
|
42
42
|
}
|
|
43
43
|
export interface GenericDiffConfiguration {
|
|
44
44
|
/**
|
|
45
|
-
* The left graph may contain more vertices and or edges than the right graph.
|
|
45
|
+
* The left/first graph may contain more vertices and or edges than the right/second graph.
|
|
46
46
|
* However, those which are the same (based on their ids) have to be equal
|
|
47
47
|
*/
|
|
48
48
|
readonly rightIsSubgraph?: boolean;
|
|
49
49
|
/**
|
|
50
|
-
* Similar to {@link rightIsSubgraph}, but for the left graph.
|
|
50
|
+
* Similar to {@link rightIsSubgraph}, but for the left/first graph.
|
|
51
51
|
*/
|
|
52
52
|
readonly leftIsSubgraph?: boolean;
|
|
53
53
|
}
|
package/util/mermaid/ast.js
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalizedAstToMermaid = normalizedAstToMermaid;
|
|
4
4
|
exports.normalizedAstToMermaidUrl = normalizedAstToMermaidUrl;
|
|
5
|
-
const mermaid_1 = require("./mermaid");
|
|
6
5
|
const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
|
|
7
6
|
const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
8
7
|
const flowr_file_1 = require("../../project/context/flowr-file");
|
|
9
8
|
const info_1 = require("./info");
|
|
10
9
|
const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
|
|
10
|
+
const mermaid_1 = require("./mermaid");
|
|
11
11
|
function identifyMermaidDirection(prefix) {
|
|
12
12
|
const directionMatch = prefix.match(/flowchart (TD|LR|RL|BT)/);
|
|
13
13
|
if (directionMatch) {
|
|
@@ -25,7 +25,7 @@ function normalizedAstToMermaid(ast, { prefix = 'flowchart TD\n', markStyle = in
|
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
27
|
const name = `${n.type} (${n.info.id})\\n${n.lexeme ?? ' '}`;
|
|
28
|
-
output += ` n${n.info.id}(["${
|
|
28
|
+
output += ` n${n.info.id}(["${mermaid_1.Mermaid.escape(name)}"])\n`;
|
|
29
29
|
if (mark?.has(n.info.id)) {
|
|
30
30
|
output += ` style n${n.info.id} ${markStyle.vertex}\n`;
|
|
31
31
|
}
|
|
@@ -57,7 +57,7 @@ function normalizedAstToMermaid(ast, { prefix = 'flowchart TD\n', markStyle = in
|
|
|
57
57
|
// add a subgraph for each file
|
|
58
58
|
if (ast.files.length !== 1 || (f.filePath && f.filePath !== flowr_file_1.FlowrFile.INLINE_PATH)) {
|
|
59
59
|
const direction = identifyMermaidDirection(prefix);
|
|
60
|
-
output += ` subgraph "File: ${
|
|
60
|
+
output += ` subgraph "File: ${mermaid_1.Mermaid.escape(f.filePath ?? flowr_file_1.FlowrFile.INLINE_PATH)}" direction ${direction}\n`;
|
|
61
61
|
showAst(f.root);
|
|
62
62
|
output += ' end\n';
|
|
63
63
|
}
|
|
@@ -75,6 +75,6 @@ function normalizedAstToMermaid(ast, { prefix = 'flowchart TD\n', markStyle = in
|
|
|
75
75
|
* Use mermaid to visualize the normalized AST.
|
|
76
76
|
*/
|
|
77
77
|
function normalizedAstToMermaidUrl(ast, info) {
|
|
78
|
-
return
|
|
78
|
+
return mermaid_1.Mermaid.codeToUrl(normalizedAstToMermaid(ast, info ?? {}));
|
|
79
79
|
}
|
|
80
80
|
//# sourceMappingURL=ast.js.map
|
package/util/mermaid/cfg.js
CHANGED
|
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.MermaidExitPointDefaultMarkStyle = exports.MermaidEntryPointDefaultMarkStyle = void 0;
|
|
4
4
|
exports.cfgToMermaid = cfgToMermaid;
|
|
5
5
|
exports.cfgToMermaidUrl = cfgToMermaidUrl;
|
|
6
|
-
const mermaid_1 = require("./mermaid");
|
|
7
6
|
const control_flow_graph_1 = require("../../control-flow/control-flow-graph");
|
|
8
7
|
const reconstruct_1 = require("../../reconstruct/reconstruct");
|
|
9
8
|
const auto_select_defaults_1 = require("../../reconstruct/auto-select/auto-select-defaults");
|
|
10
9
|
const info_1 = require("./info");
|
|
11
10
|
const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
|
|
11
|
+
const mermaid_1 = require("./mermaid");
|
|
12
12
|
exports.MermaidEntryPointDefaultMarkStyle = 'stroke:cyan,stroke-width:6.5px;';
|
|
13
13
|
exports.MermaidExitPointDefaultMarkStyle = 'stroke:green,stroke-width:6.5px;';
|
|
14
14
|
function getLexeme(n) {
|
|
@@ -18,7 +18,7 @@ function cfgOfNode(vert, normalizedVertex, id, content, output) {
|
|
|
18
18
|
if (normalizedVertex && content !== undefined) {
|
|
19
19
|
const start = control_flow_graph_1.CfgVertex.isExpression(vert) ? '([' : '[';
|
|
20
20
|
const end = control_flow_graph_1.CfgVertex.isExpression(vert) ? '])' : ']';
|
|
21
|
-
const name = `"\`${
|
|
21
|
+
const name = `"\`${mermaid_1.Mermaid.escape(normalizedVertex.type)} (${id})${content ? '\n' + mermaid_1.Mermaid.escape(JSON.stringify(content)) : ''}${control_flow_graph_1.CfgVertex.getCallTargets(vert) ? '\n calls:' + mermaid_1.Mermaid.escape(JSON.stringify([...control_flow_graph_1.CfgVertex.getCallTargets(vert)])) : ''}\`"`;
|
|
22
22
|
output += ` n${id}${start}${name}${end}\n`;
|
|
23
23
|
}
|
|
24
24
|
else {
|
|
@@ -83,7 +83,7 @@ function cfgToMermaid(cfg, normalizedAst, { prefix = 'flowchart BT\n', simplify
|
|
|
83
83
|
}
|
|
84
84
|
const ids = elems?.map(control_flow_graph_1.CfgVertex.getId) ?? [];
|
|
85
85
|
const reconstruct = limitTo((0, reconstruct_1.reconstructToCode)(normalizedAst, { nodes: new Set(ids) }, auto_select_defaults_1.doNotAutoSelect).code, basicBlockCharacterLimit);
|
|
86
|
-
const name = `"\`${includeBasicBlockLabel ? `Basic Block (${id})\n` : ''}${
|
|
86
|
+
const name = `"\`${includeBasicBlockLabel ? `Basic Block (${id})\n` : ''}${mermaid_1.Mermaid.escape(reconstruct)}\`"`;
|
|
87
87
|
output += ` n${id}[[${name}]]\n`;
|
|
88
88
|
diagramIncludedIds.add(control_flow_graph_1.CfgVertex.getId(vertex));
|
|
89
89
|
}
|
|
@@ -130,7 +130,7 @@ function cfgToMermaid(cfg, normalizedAst, { prefix = 'flowchart BT\n', simplify
|
|
|
130
130
|
const isCd = control_flow_graph_1.CfgEdge.isControlDependency(edge);
|
|
131
131
|
const edgeType = isCd ? '-->' : '-.->';
|
|
132
132
|
const edgeSuffix = isCd ? ` (${control_flow_graph_1.CfgEdge.unpackWhen(edge)})` : '';
|
|
133
|
-
output += ` n${from} ${edgeType}|"${
|
|
133
|
+
output += ` n${from} ${edgeType}|"${mermaid_1.Mermaid.escape(control_flow_graph_1.CfgEdge.typeToString(edge))}${edgeSuffix}"| n${to}\n`;
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
for (const entryPoint of cfg.entryPoints) {
|
|
@@ -156,7 +156,7 @@ function cfgToMermaid(cfg, normalizedAst, { prefix = 'flowchart BT\n', simplify
|
|
|
156
156
|
* Use mermaid to visualize the normalized AST.
|
|
157
157
|
*/
|
|
158
158
|
function cfgToMermaidUrl(cfg, normalizedAst, info) {
|
|
159
|
-
return
|
|
159
|
+
return mermaid_1.Mermaid.codeToUrl(cfgToMermaid(cfg, normalizedAst, info ?? {}));
|
|
160
160
|
}
|
|
161
161
|
/**
|
|
162
162
|
* Limits a string to n chars, after which the remainder will be replaced with ...
|
package/util/mermaid/dfg.d.ts
CHANGED
|
@@ -3,7 +3,11 @@ import { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
|
3
3
|
import { type IdentifierDefinition } from '../../dataflow/environments/identifier';
|
|
4
4
|
import { type DataflowGraphVertexInfo } from '../../dataflow/graph/vertex';
|
|
5
5
|
import { type MermaidMarkdownMark, type MermaidMarkStyle } from './info';
|
|
6
|
-
|
|
6
|
+
import { DataflowInformation } from '../../dataflow/info';
|
|
7
|
+
/**
|
|
8
|
+
* Internal representation of a mermaid graph in flowR
|
|
9
|
+
*/
|
|
10
|
+
export interface MermaidGraph {
|
|
7
11
|
nodeLines: string[];
|
|
8
12
|
edgeLines: string[];
|
|
9
13
|
includeEnvironments: boolean;
|
|
@@ -27,7 +31,7 @@ export declare function mermaidNodeBrackets(tag: DataflowGraphVertexInfo['tag'])
|
|
|
27
31
|
* Prints an identifier definition in a human-readable format.
|
|
28
32
|
*/
|
|
29
33
|
export declare function printIdentifier(id: IdentifierDefinition): string;
|
|
30
|
-
interface MermaidGraphConfiguration {
|
|
34
|
+
export interface MermaidGraphConfiguration {
|
|
31
35
|
graph: DataflowGraph;
|
|
32
36
|
prefix?: string | null;
|
|
33
37
|
idPrefix?: string;
|
|
@@ -39,21 +43,6 @@ interface MermaidGraphConfiguration {
|
|
|
39
43
|
simplified?: boolean;
|
|
40
44
|
includeOnlyIds?: ReadonlySet<NodeId>;
|
|
41
45
|
}
|
|
42
|
-
/**
|
|
43
|
-
* Converts a dataflow graph to mermaid graph code that visualizes the graph.
|
|
44
|
-
*/
|
|
45
|
-
export declare function graphToMermaid(config: MermaidGraphConfiguration): {
|
|
46
|
-
string: string;
|
|
47
|
-
mermaid: MermaidGraph;
|
|
48
|
-
};
|
|
49
|
-
/**
|
|
50
|
-
* Converts a dataflow graph to a mermaid url that visualizes the graph.
|
|
51
|
-
* @param graph - The graph to convert
|
|
52
|
-
* @param includeEnvironments - Whether to include the environments in the mermaid graph code
|
|
53
|
-
* @param mark - Special nodes to mark (e.g., those included in the slice)
|
|
54
|
-
* @param simplified - Whether to simplify the graph
|
|
55
|
-
*/
|
|
56
|
-
export declare function graphToMermaidUrl(graph: DataflowGraph, includeEnvironments?: boolean, mark?: ReadonlySet<NodeId>, simplified?: boolean): string;
|
|
57
46
|
export interface LabeledDiffGraph {
|
|
58
47
|
label: string;
|
|
59
48
|
graph: DataflowGraph;
|
|
@@ -65,4 +54,30 @@ export declare function diffGraphsToMermaid(left: LabeledDiffGraph, right: Label
|
|
|
65
54
|
* Converts two dataflow graphs to a mermaid url that visualizes their differences.
|
|
66
55
|
*/
|
|
67
56
|
export declare function diffGraphsToMermaidUrl(left: LabeledDiffGraph, right: LabeledDiffGraph, prefix: string): string;
|
|
68
|
-
|
|
57
|
+
/**
|
|
58
|
+
* The helper object for all things regarding the mermaid based visualization of dataflow graphs!
|
|
59
|
+
*/
|
|
60
|
+
export declare const DataflowMermaid: {
|
|
61
|
+
readonly name: "DataflowMermaid";
|
|
62
|
+
/**
|
|
63
|
+
* Converts a dataflow graph to mermaid graph code that visualizes the graph.
|
|
64
|
+
* @see {@link DataflowMermaid.url} - render the given graph to a url to mermaid.live
|
|
65
|
+
*/
|
|
66
|
+
readonly convert: (this: void, config: MermaidGraphConfiguration) => {
|
|
67
|
+
string: string;
|
|
68
|
+
mermaid: MermaidGraph;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* This is a simplified version of {@link DataflowMermaid.convertToMermaid}
|
|
72
|
+
*/
|
|
73
|
+
readonly raw: (this: void, graph: DataflowGraph | DataflowInformation, includeEnvironments?: boolean, mark?: ReadonlySet<NodeId>, simplified?: boolean) => string;
|
|
74
|
+
/**
|
|
75
|
+
* Converts a dataflow graph to a mermaid url that visualizes the graph.
|
|
76
|
+
* This is basically a combination of {@link DataflowMermaid.mermaidRaw} and {@link Mermaid.codeToUrl}.
|
|
77
|
+
* @param graph - the dataflow graph to render
|
|
78
|
+
* @param includeEnvironments - whether to include the environment content in the output
|
|
79
|
+
* @param mark - which vertices to highlight in the visualization
|
|
80
|
+
* @param simplified - whether to show a simplified use of the graph with fewer details on the vertices and edges
|
|
81
|
+
*/
|
|
82
|
+
readonly url: (this: void, graph: DataflowGraph | DataflowInformation, includeEnvironments?: boolean, mark?: ReadonlySet<NodeId>, simplified?: boolean) => string;
|
|
83
|
+
};
|
package/util/mermaid/dfg.js
CHANGED
|
@@ -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 =
|
|
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}" ["${
|
|
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(
|
|
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 =
|
|
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,16 @@ 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 = '**' +
|
|
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 =
|
|
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
|
+
const sources = info.source ? ', sources: ' + JSON.stringify(info.source) : '';
|
|
159
160
|
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 ?
|
|
161
|
+
mermaid.nodeLines.push(` ${idPrefix}${id}${open}"\`${escapedName}${escapedName.length > 10 ? '\n ' : ' '}(${id}${deps}${lnks}${sources})\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
162
|
}
|
|
162
163
|
if (mark?.has(id)) {
|
|
163
164
|
mermaid.nodeLines.push(` style ${idPrefix}${id} ${mermaid.markStyle.vertex} `);
|
|
@@ -180,7 +181,7 @@ function vertexToMermaid(info, mermaid, id, idPrefix, mark, includeOnlyIds) {
|
|
|
180
181
|
continue;
|
|
181
182
|
}
|
|
182
183
|
const originalTarget = target;
|
|
183
|
-
target =
|
|
184
|
+
target = mermaid_1.Mermaid.escapeId(target);
|
|
184
185
|
const edgeTypes = typeof edge.types == 'number' ? new Set(edge_1.DfEdge.splitTypes(edge)) : edge.types;
|
|
185
186
|
const edgeId = encodeEdge(idPrefix + id, idPrefix + target, edgeTypes);
|
|
186
187
|
if (!mermaid.presentEdges.has(edgeId)) {
|
|
@@ -197,7 +198,7 @@ function vertexToMermaid(info, mermaid, id, idPrefix, mark, includeOnlyIds) {
|
|
|
197
198
|
if (node_id_1.NodeId.isBuiltIn(target)) {
|
|
198
199
|
mermaid.edgeLines.push(` linkStyle ${mermaid.presentEdges.size - 1} stroke:gray;`);
|
|
199
200
|
if (!mermaid.presentVertices.has(target)) {
|
|
200
|
-
mermaid.nodeLines.push(` ${idPrefix}${target}["\`Built-In:\n${
|
|
201
|
+
mermaid.nodeLines.push(` ${idPrefix}${target}["\`Built-In:\n${mermaid_1.Mermaid.escape(String(originalTarget).replace('built-in:', ''))}\`"]`);
|
|
201
202
|
mermaid.nodeLines.push(` style ${idPrefix}${target} stroke:gray,fill:gray,stroke-width:2px,opacity:.8;`);
|
|
202
203
|
mermaid.presentVertices.add(target);
|
|
203
204
|
}
|
|
@@ -215,34 +216,49 @@ function graphToMermaidGraph(rootIds, { simplified, graph, prefix = 'flowchart B
|
|
|
215
216
|
}
|
|
216
217
|
return mermaid;
|
|
217
218
|
}
|
|
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
219
|
/** uses same id map but ensures, it is different from the rhs so that mermaid can work with that */
|
|
236
220
|
function diffGraphsToMermaid(left, right, prefix) {
|
|
237
221
|
// we add the prefix ourselves
|
|
238
|
-
const { string: leftGraph, mermaid } =
|
|
239
|
-
const { string: rightGraph } =
|
|
222
|
+
const { string: leftGraph, mermaid } = exports.DataflowMermaid.convert({ graph: left.graph, prefix: '', idPrefix: `l-${left.label}`, includeEnvironments: true, mark: left.mark });
|
|
223
|
+
const { string: rightGraph } = exports.DataflowMermaid.convert({ graph: right.graph, prefix: '', idPrefix: `r-${right.label}`, includeEnvironments: true, mark: right.mark, presentEdges: mermaid.presentEdges });
|
|
240
224
|
return `${prefix}flowchart BT\nsubgraph "${left.label}"\n${leftGraph}\nend\nsubgraph "${right.label}"\n${rightGraph}\nend`;
|
|
241
225
|
}
|
|
242
226
|
/**
|
|
243
227
|
* Converts two dataflow graphs to a mermaid url that visualizes their differences.
|
|
244
228
|
*/
|
|
245
229
|
function diffGraphsToMermaidUrl(left, right, prefix) {
|
|
246
|
-
return
|
|
230
|
+
return mermaid_1.Mermaid.codeToUrl(diffGraphsToMermaid(left, right, prefix));
|
|
247
231
|
}
|
|
232
|
+
/**
|
|
233
|
+
* The helper object for all things regarding the mermaid based visualization of dataflow graphs!
|
|
234
|
+
*/
|
|
235
|
+
exports.DataflowMermaid = {
|
|
236
|
+
name: 'DataflowMermaid',
|
|
237
|
+
/**
|
|
238
|
+
* Converts a dataflow graph to mermaid graph code that visualizes the graph.
|
|
239
|
+
* @see {@link DataflowMermaid.url} - render the given graph to a url to mermaid.live
|
|
240
|
+
*/
|
|
241
|
+
convert(config) {
|
|
242
|
+
const mermaid = graphToMermaidGraph(config.includeOnlyIds ?? config.graph.rootIds(), config);
|
|
243
|
+
return { string: `${mermaid.nodeLines.join('\n')}\n${mermaid.edgeLines.join('\n')}`, mermaid };
|
|
244
|
+
},
|
|
245
|
+
/**
|
|
246
|
+
* This is a simplified version of {@link DataflowMermaid.convertToMermaid}
|
|
247
|
+
*/
|
|
248
|
+
raw(graph, includeEnvironments, mark, simplified = false) {
|
|
249
|
+
graph = info_2.DataflowInformation.is(graph) ? graph.graph : graph;
|
|
250
|
+
return exports.DataflowMermaid.convert({ graph, includeEnvironments, mark, simplified }).string;
|
|
251
|
+
},
|
|
252
|
+
/**
|
|
253
|
+
* Converts a dataflow graph to a mermaid url that visualizes the graph.
|
|
254
|
+
* This is basically a combination of {@link DataflowMermaid.mermaidRaw} and {@link Mermaid.codeToUrl}.
|
|
255
|
+
* @param graph - the dataflow graph to render
|
|
256
|
+
* @param includeEnvironments - whether to include the environment content in the output
|
|
257
|
+
* @param mark - which vertices to highlight in the visualization
|
|
258
|
+
* @param simplified - whether to show a simplified use of the graph with fewer details on the vertices and edges
|
|
259
|
+
*/
|
|
260
|
+
url(graph, includeEnvironments, mark, simplified = false) {
|
|
261
|
+
return mermaid_1.Mermaid.codeToUrl(exports.DataflowMermaid.raw(graph, includeEnvironments, mark, simplified));
|
|
262
|
+
}
|
|
263
|
+
};
|
|
248
264
|
//# sourceMappingURL=dfg.js.map
|
|
@@ -1,14 +1,59 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Global mermaid helper object with useful functions.
|
|
3
3
|
*/
|
|
4
|
-
export declare
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
+
};
|
package/util/mermaid/mermaid.js
CHANGED
|
@@ -1,73 +1,80 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
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
|
-
*
|
|
5
|
+
* Global mermaid helper object with useful functions.
|
|
54
6
|
*/
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
-
|
|
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,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
|