@eagleoutice/flowr 2.1.1 → 2.1.3
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 +2 -1
- package/cli/repl/commands/repl-parse.js +7 -16
- package/cli/repl/commands/repl-query.d.ts +0 -5
- package/cli/repl/commands/repl-query.js +2 -73
- package/core/print/parse-printer.js +1 -22
- package/core/steps/pipeline/default-pipelines.d.ts +64 -0
- package/core/steps/pipeline/default-pipelines.js +2 -1
- package/dataflow/cluster.d.ts +20 -0
- package/dataflow/cluster.js +46 -0
- package/dataflow/graph/edge.d.ts +2 -3
- package/dataflow/graph/graph.d.ts +1 -1
- package/documentation/data/server/doc-data-server-messages.d.ts +1 -1
- package/documentation/data/server/doc-data-server-messages.js +16 -5
- package/documentation/doc-util/doc-code.d.ts +1 -0
- package/documentation/doc-util/doc-code.js +9 -0
- package/documentation/doc-util/doc-dfg.d.ts +1 -0
- package/documentation/doc-util/doc-dfg.js +5 -4
- package/documentation/doc-util/doc-normalized-ast.js +2 -2
- package/documentation/doc-util/doc-query.d.ts +5 -1
- package/documentation/doc-util/doc-query.js +154 -9
- package/documentation/doc-util/doc-server-message.js +3 -5
- package/documentation/doc-util/doc-types.js +19 -11
- package/documentation/print-dataflow-graph-wiki.js +10 -1
- package/documentation/print-interface-wiki.js +1 -1
- package/documentation/print-normalized-ast-wiki.js +2 -2
- package/documentation/print-query-wiki.js +196 -37
- package/package.json +3 -2
- package/queries/{call-context-query → catalog/call-context-query}/call-context-query-executor.d.ts +4 -3
- package/queries/{call-context-query → catalog/call-context-query}/call-context-query-executor.js +22 -16
- package/queries/{call-context-query → catalog/call-context-query}/call-context-query-format.d.ts +6 -2
- package/queries/catalog/cluster-query/cluster-query-executor.d.ts +3 -0
- package/queries/catalog/cluster-query/cluster-query-executor.js +19 -0
- package/queries/catalog/cluster-query/cluster-query-format.d.ts +12 -0
- package/queries/catalog/cluster-query/cluster-query-format.js +3 -0
- package/queries/catalog/dataflow-query/dataflow-query-executor.d.ts +3 -0
- package/queries/catalog/dataflow-query/dataflow-query-executor.js +17 -0
- package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +12 -0
- package/queries/catalog/dataflow-query/dataflow-query-format.js +3 -0
- package/queries/catalog/id-map-query/id-map-query-executor.d.ts +3 -0
- package/queries/catalog/id-map-query/id-map-query-executor.js +17 -0
- package/queries/catalog/id-map-query/id-map-query-format.d.ts +8 -0
- package/{r-bridge/lang-4.x/ast/parser/xml/normalizer-data.js → queries/catalog/id-map-query/id-map-query-format.js} +1 -1
- package/queries/catalog/lineage-query/lineage-query-executor.d.ts +3 -0
- package/queries/catalog/lineage-query/lineage-query-executor.js +22 -0
- package/queries/catalog/lineage-query/lineage-query-format.d.ts +14 -0
- package/queries/catalog/lineage-query/lineage-query-format.js +3 -0
- package/queries/catalog/normalized-ast-query/normalized-ast-query-executor.d.ts +3 -0
- package/queries/catalog/normalized-ast-query/normalized-ast-query-executor.js +17 -0
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +11 -0
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.js +3 -0
- package/queries/catalog/static-slice-query/static-slice-query-executor.d.ts +4 -0
- package/queries/catalog/static-slice-query/static-slice-query-executor.js +40 -0
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +24 -0
- package/queries/catalog/static-slice-query/static-slice-query-format.js +3 -0
- package/queries/query-schema.d.ts +6 -0
- package/queries/query-schema.js +26 -3
- package/queries/query.d.ts +22 -4
- package/queries/query.js +14 -2
- package/r-bridge/lang-4.x/ast/parser/json/format.d.ts +37 -13
- package/r-bridge/lang-4.x/ast/parser/json/format.js +59 -6
- package/r-bridge/lang-4.x/ast/parser/json/parser.d.ts +0 -3
- package/r-bridge/lang-4.x/ast/parser/json/parser.js +2 -40
- package/r-bridge/lang-4.x/ast/parser/main/internal/control/normalize-if-then-else.d.ts +15 -0
- package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/control/normalize-if-then-else.js +5 -8
- package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/control/normalize-if-then.d.ts +7 -7
- package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/control/normalize-if-then.js +11 -12
- package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/expression/normalize-expression.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/expression/normalize-expression.js +4 -7
- package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/functions/normalize-argument.d.ts +2 -2
- package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/functions/normalize-argument.js +3 -3
- package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/functions/normalize-call.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/functions/normalize-call.js +6 -9
- package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/functions/normalize-definition.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/functions/normalize-definition.js +1 -3
- package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/functions/normalize-parameter.d.ts +2 -2
- package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/functions/normalize-parameter.js +6 -5
- package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/loops/normalize-break.d.ts +2 -2
- package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/loops/normalize-for.d.ts +2 -2
- package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/loops/normalize-for.js +5 -6
- package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/loops/normalize-next.d.ts +2 -2
- package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/loops/normalize-repeat.d.ts +2 -2
- package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-while.d.ts +4 -0
- package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/loops/normalize-while.js +4 -4
- package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/normalize-access.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/normalize-access.js +1 -2
- package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/operators/normalize-binary.d.ts +2 -2
- package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/operators/normalize-binary.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/operators/normalize-unary.d.ts +2 -2
- package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/other/normalize-comment.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/other/normalize-comment.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/other/normalize-line-directive.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/other/normalize-line-directive.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-delimiter.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-expressions.d.ts +10 -0
- package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/structure/normalize-root.d.ts +2 -2
- package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/structure/normalize-root.js +3 -4
- package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/structure/normalize-single-node.d.ts +2 -2
- package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/structure/normalize-single-node.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/values/normalize-number.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/values/normalize-number.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/values/normalize-string.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/values/normalize-string.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/values/normalize-symbol.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/values/normalize-symbol.js +1 -3
- package/r-bridge/lang-4.x/ast/parser/main/normalize-meta.d.ts +41 -0
- package/r-bridge/lang-4.x/ast/parser/main/normalize-meta.js +85 -0
- package/r-bridge/lang-4.x/ast/parser/{xml → main}/normalizer-data.d.ts +10 -4
- package/r-bridge/lang-4.x/ast/parser/main/normalizer-data.js +14 -0
- package/slicing/criterion/parse.d.ts +1 -1
- package/statistics/summarizer/post-process/clusterer.d.ts +1 -1
- package/util/ansi.js +9 -2
- package/util/time.d.ts +4 -0
- package/util/time.js +8 -0
- package/util/version.js +1 -1
- package/documentation/doc-util/doc-ms.d.ts +0 -1
- package/documentation/doc-util/doc-ms.js +0 -8
- package/r-bridge/lang-4.x/ast/parser/xml/input-format.d.ts +0 -39
- package/r-bridge/lang-4.x/ast/parser/xml/input-format.js +0 -38
- package/r-bridge/lang-4.x/ast/parser/xml/internal/control/normalize-if-then-else.d.ts +0 -15
- package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/normalize-while.d.ts +0 -4
- package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/normalize-delimiter.d.ts +0 -3
- package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/normalize-expressions.d.ts +0 -10
- package/r-bridge/lang-4.x/ast/parser/xml/normalize-meta.d.ts +0 -47
- package/r-bridge/lang-4.x/ast/parser/xml/normalize-meta.js +0 -110
- /package/queries/{call-context-query → catalog/call-context-query}/call-context-query-format.js +0 -0
- /package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/loops/normalize-break.js +0 -0
- /package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/loops/normalize-next.js +0 -0
- /package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/loops/normalize-repeat.js +0 -0
- /package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/operators/normalize-unary.js +0 -0
- /package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/structure/normalize-delimiter.js +0 -0
- /package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/structure/normalize-expressions.js +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RegisteredQueries = void 0;
|
|
4
|
+
exports.asciiSummaryOfQueryResult = asciiSummaryOfQueryResult;
|
|
4
5
|
exports.showQuery = showQuery;
|
|
5
6
|
exports.registerQueryDocumentation = registerQueryDocumentation;
|
|
6
7
|
exports.tocForQueryType = tocForQueryType;
|
|
@@ -9,12 +10,159 @@ const query_1 = require("../../queries/query");
|
|
|
9
10
|
const pipeline_executor_1 = require("../../core/pipeline-executor");
|
|
10
11
|
const default_pipelines_1 = require("../../core/steps/pipeline/default-pipelines");
|
|
11
12
|
const retriever_1 = require("../../r-bridge/retriever");
|
|
12
|
-
const doc_ms_1 = require("./doc-ms");
|
|
13
13
|
const json_1 = require("../../util/json");
|
|
14
14
|
const ansi_1 = require("../../util/ansi");
|
|
15
|
-
const repl_query_1 = require("../../cli/repl/commands/repl-query");
|
|
16
15
|
const doc_files_1 = require("./doc-files");
|
|
17
16
|
const doc_dfg_1 = require("./doc-dfg");
|
|
17
|
+
const doc_code_1 = require("./doc-code");
|
|
18
|
+
const time_1 = require("../../util/time");
|
|
19
|
+
const built_in_1 = require("../../dataflow/environments/built-in");
|
|
20
|
+
const dfg_1 = require("../../util/mermaid/dfg");
|
|
21
|
+
const ast_1 = require("../../util/mermaid/ast");
|
|
22
|
+
const doc_hover_over_1 = require("./doc-hover-over");
|
|
23
|
+
function nodeString(id, formatter, processed) {
|
|
24
|
+
if (id === built_in_1.BuiltIn) {
|
|
25
|
+
return (0, ansi_1.italic)('built-in', formatter);
|
|
26
|
+
}
|
|
27
|
+
const node = processed.normalize.idMap.get(id);
|
|
28
|
+
if (node === undefined) {
|
|
29
|
+
return `UNKNOWN: ${id}`;
|
|
30
|
+
}
|
|
31
|
+
return `${(0, ansi_1.italic)('`' + (node.lexeme ?? node.info.fullLexeme ?? 'UNKNOWN') + '`', formatter)} (L.${node.location?.[0]})`;
|
|
32
|
+
}
|
|
33
|
+
function asciiCallContextSubHit(formatter, results, processed) {
|
|
34
|
+
const result = [];
|
|
35
|
+
for (const { id, calls = [], linkedIds = [], aliasRoots = [] } of results) {
|
|
36
|
+
const node = processed.normalize.idMap.get(id);
|
|
37
|
+
if (node === undefined) {
|
|
38
|
+
result.push(` ${(0, ansi_1.bold)('UNKNOWN: ' + JSON.stringify({ calls, linkedIds }))}`);
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
let line = nodeString(id, formatter, processed);
|
|
42
|
+
if (calls.length > 0) {
|
|
43
|
+
line += ` with ${calls.length} call${calls.length > 1 ? 's' : ''} (${calls.map(c => nodeString(c, formatter, processed)).join(', ')})`;
|
|
44
|
+
}
|
|
45
|
+
if (linkedIds.length > 0) {
|
|
46
|
+
line += ` with ${linkedIds.length} link${linkedIds.length > 1 ? 's' : ''} (${linkedIds.map(c => nodeString(c, formatter, processed)).join(', ')})`;
|
|
47
|
+
}
|
|
48
|
+
if (aliasRoots.length > 0) {
|
|
49
|
+
line += ` with ${aliasRoots.length} alias root${aliasRoots.length > 1 ? 's' : ''} (${aliasRoots.map(c => nodeString(c, formatter, processed)).join(', ')})`;
|
|
50
|
+
}
|
|
51
|
+
result.push(line);
|
|
52
|
+
}
|
|
53
|
+
return result.join(', ');
|
|
54
|
+
}
|
|
55
|
+
function asciiCallContext(formatter, results, processed) {
|
|
56
|
+
/* traverse over 'kinds' and within them 'subkinds' */
|
|
57
|
+
const result = [];
|
|
58
|
+
for (const [kind, { subkinds }] of Object.entries(results['kinds'])) {
|
|
59
|
+
result.push(` ╰ ${(0, ansi_1.bold)(kind, formatter)}`);
|
|
60
|
+
for (const [subkind, values] of Object.entries(subkinds)) {
|
|
61
|
+
result.push(` ╰ ${(0, ansi_1.bold)(subkind, formatter)}: ${asciiCallContextSubHit(formatter, values, processed)}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return result.join('\n');
|
|
65
|
+
}
|
|
66
|
+
function summarizeIdsIfTooLong(ids) {
|
|
67
|
+
const naive = ids.join(', ');
|
|
68
|
+
if (naive.length <= 20) {
|
|
69
|
+
return naive;
|
|
70
|
+
}
|
|
71
|
+
let acc = '';
|
|
72
|
+
let i = 0;
|
|
73
|
+
while (acc.length <= 20) {
|
|
74
|
+
acc += ids[i++] + ', ';
|
|
75
|
+
}
|
|
76
|
+
if (i < ids.length) {
|
|
77
|
+
acc += '... (see JSON below)';
|
|
78
|
+
}
|
|
79
|
+
return (0, doc_hover_over_1.textWithTooltip)(acc, JSON.stringify(ids));
|
|
80
|
+
}
|
|
81
|
+
function asciiSummaryOfQueryResult(formatter, totalInMs, results, processed) {
|
|
82
|
+
const result = [];
|
|
83
|
+
for (const [query, queryResults] of Object.entries(results)) {
|
|
84
|
+
if (query === '.meta') {
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
if (query === 'call-context') {
|
|
88
|
+
const out = queryResults;
|
|
89
|
+
result.push(`Query: ${(0, ansi_1.bold)(query, formatter)} (${(0, time_1.printAsMs)(out['.meta'].timing, 0)})`);
|
|
90
|
+
result.push(asciiCallContext(formatter, out, processed));
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
else if (query === 'dataflow') {
|
|
94
|
+
const out = queryResults;
|
|
95
|
+
result.push(`Query: ${(0, ansi_1.bold)(query, formatter)} (${(0, time_1.printAsMs)(out['.meta'].timing, 0)})`);
|
|
96
|
+
result.push(` ╰ [Dataflow Graph](${(0, dfg_1.graphToMermaidUrl)(out.graph)})`);
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
else if (query === 'id-map') {
|
|
100
|
+
const out = queryResults;
|
|
101
|
+
result.push(`Query: ${(0, ansi_1.bold)(query, formatter)} (${(0, time_1.printAsMs)(out['.meta'].timing, 0)})`);
|
|
102
|
+
result.push(` ╰ Id List: {${summarizeIdsIfTooLong([...out.idMap.keys()])}}`);
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
else if (query === 'normalized-ast') {
|
|
106
|
+
const out = queryResults;
|
|
107
|
+
result.push(`Query: ${(0, ansi_1.bold)(query, formatter)} (${(0, time_1.printAsMs)(out['.meta'].timing, 0)})`);
|
|
108
|
+
result.push(` ╰ [Normalized AST](${(0, ast_1.normalizedAstToMermaidUrl)(out.normalized.ast)})`);
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
else if (query === 'static-slice') {
|
|
112
|
+
const out = queryResults;
|
|
113
|
+
result.push(`Query: ${(0, ansi_1.bold)(query, formatter)} (${(0, time_1.printAsMs)(out['.meta'].timing, 0)})`);
|
|
114
|
+
for (const [fingerprint, obj] of Object.entries(out.results)) {
|
|
115
|
+
const { criteria, noMagicComments, noReconstruction } = JSON.parse(fingerprint);
|
|
116
|
+
const addons = [];
|
|
117
|
+
if (noReconstruction) {
|
|
118
|
+
addons.push('no reconstruction');
|
|
119
|
+
}
|
|
120
|
+
if (noMagicComments) {
|
|
121
|
+
addons.push('no magic comments');
|
|
122
|
+
}
|
|
123
|
+
result.push(` ╰ Slice for {${criteria.join(', ')}} ${addons.join(', ')}`);
|
|
124
|
+
if ('reconstruct' in obj) {
|
|
125
|
+
result.push(' ╰ Code (newline as <code>\n</code>): <code>' + obj.reconstruct.code.split('\n').join('\\n') + '</code>');
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
result.push(` ╰ Id List: {${summarizeIdsIfTooLong([...obj.slice.result])}}`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
else if (query === 'dataflow-cluster') {
|
|
134
|
+
const out = queryResults;
|
|
135
|
+
result.push(`Query: ${(0, ansi_1.bold)(query, formatter)} (${out['.meta'].timing.toFixed(0)}ms)`);
|
|
136
|
+
result.push(` ╰ Found ${out.clusters.length} cluster${out.clusters.length === 1 ? '' : 's'}`);
|
|
137
|
+
for (const cluster of out.clusters) {
|
|
138
|
+
const unknownSideEffects = cluster.hasUnknownSideEffects ? '(has unknown side effect)' : '';
|
|
139
|
+
result.push(` ╰ ${unknownSideEffects} {${summarizeIdsIfTooLong(cluster.members)}} ([marked](${(0, dfg_1.graphToMermaidUrl)(processed.dataflow.graph, false, new Set(cluster.members))}))`);
|
|
140
|
+
}
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
else if (query === 'lineage') {
|
|
144
|
+
const out = queryResults;
|
|
145
|
+
result.push(`Query: ${(0, ansi_1.bold)(query, formatter)} (${(0, time_1.printAsMs)(out['.meta'].timing, 0)})`);
|
|
146
|
+
for (const [criteria, lineage] of Object.entries(out.lineages)) {
|
|
147
|
+
result.push(` ╰ ${criteria}: {${summarizeIdsIfTooLong([...lineage])}}`);
|
|
148
|
+
}
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
result.push(`Query: ${(0, ansi_1.bold)(query, formatter)}`);
|
|
152
|
+
let timing = -1;
|
|
153
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
154
|
+
for (const [key, value] of Object.entries(queryResults)) {
|
|
155
|
+
if (key === '.meta') {
|
|
156
|
+
timing = value.timing;
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
result.push(` ╰ ${key}: ${JSON.stringify(value)}`);
|
|
160
|
+
}
|
|
161
|
+
result.push(` - Took ${(0, time_1.printAsMs)(timing, 0)}`);
|
|
162
|
+
}
|
|
163
|
+
result.push((0, ansi_1.italic)(`All queries together required ≈${(0, time_1.printAsMs)(results['.meta'].timing, 0)} (1ms accuracy, total ${(0, time_1.printAsMs)(totalInMs, 0)})`, formatter));
|
|
164
|
+
return formatter.format(result.join('\n'));
|
|
165
|
+
}
|
|
18
166
|
async function showQuery(shell, code, queries, { showCode, collapseResult } = {}) {
|
|
19
167
|
const now = performance.now();
|
|
20
168
|
const analysis = await new pipeline_executor_1.PipelineExecutor(default_pipelines_1.DEFAULT_DATAFLOW_PIPELINE, {
|
|
@@ -24,9 +172,8 @@ async function showQuery(shell, code, queries, { showCode, collapseResult } = {}
|
|
|
24
172
|
const results = (0, query_1.executeQueries)({ graph: analysis.dataflow.graph, ast: analysis.normalize }, queries);
|
|
25
173
|
const duration = performance.now() - now;
|
|
26
174
|
const metaInfo = `
|
|
27
|
-
The analysis required _${(0,
|
|
175
|
+
The analysis required _${(0, time_1.printAsMs)(duration)}_ (including parsing and normalization and the query) within the generation environment.
|
|
28
176
|
`.trim();
|
|
29
|
-
const resultAsString = JSON.stringify(results, json_1.jsonReplacer, 2);
|
|
30
177
|
return `
|
|
31
178
|
|
|
32
179
|
\`\`\`json
|
|
@@ -37,7 +184,7 @@ ${collapseResult ? ' <details> <summary style="color:gray">Show Results</summary
|
|
|
37
184
|
|
|
38
185
|
_Results (prettified and summarized):_
|
|
39
186
|
|
|
40
|
-
${
|
|
187
|
+
${asciiSummaryOfQueryResult(ansi_1.markdownFormatter, duration, results, analysis)}
|
|
41
188
|
|
|
42
189
|
<details> <summary style="color:gray">Show Detailed Results as Json</summary>
|
|
43
190
|
|
|
@@ -46,9 +193,7 @@ ${metaInfo}
|
|
|
46
193
|
In general, the JSON contains the Ids of the nodes in question as they are present in the normalized AST or the dataflow graph of flowR.
|
|
47
194
|
Please consult the [Interface](${doc_files_1.FlowrWikiBaseRef}/Interface) wiki page for more information on how to get those.
|
|
48
195
|
|
|
49
|
-
|
|
50
|
-
${resultAsString}
|
|
51
|
-
\`\`\`
|
|
196
|
+
${(0, doc_code_1.jsonWithLimit)(results)}
|
|
52
197
|
|
|
53
198
|
</details>
|
|
54
199
|
|
|
@@ -79,7 +224,7 @@ function linkify(name) {
|
|
|
79
224
|
return name.toLowerCase().replace(/ /g, '-');
|
|
80
225
|
}
|
|
81
226
|
function tocForQueryType(type) {
|
|
82
|
-
const queries = exports.RegisteredQueries[type];
|
|
227
|
+
const queries = [...exports.RegisteredQueries[type].entries()].sort(([, { name: a }], [, { name: b }]) => a.localeCompare(b));
|
|
83
228
|
const result = [];
|
|
84
229
|
for (const [id, { name, shortDescription }] of queries) {
|
|
85
230
|
result.push(`1. [${name}](#${linkify(name)}) (\`${id}\`):\\\n ${shortDescription}`);
|
|
@@ -9,8 +9,8 @@ const schema_1 = require("../../util/schema");
|
|
|
9
9
|
const ansi_1 = require("../../util/ansi");
|
|
10
10
|
const net_1 = require("../../../test/functionality/_helper/net");
|
|
11
11
|
const doc_code_1 = require("./doc-code");
|
|
12
|
-
const doc_ms_1 = require("./doc-ms");
|
|
13
12
|
const assert_1 = require("../../util/assert");
|
|
13
|
+
const time_1 = require("../../util/time");
|
|
14
14
|
const messages = [];
|
|
15
15
|
function documentServerMessage(description) {
|
|
16
16
|
messages.push(description);
|
|
@@ -29,7 +29,6 @@ async function inServerContext(shell, fn) {
|
|
|
29
29
|
}
|
|
30
30
|
function explainMsg(msg, type, desc = '', open = false) {
|
|
31
31
|
const bold = open ? s => `<b>${s}</b>` : s => s;
|
|
32
|
-
const msgPrettyPrint = JSON.stringify(msg, null, 2);
|
|
33
32
|
return `
|
|
34
33
|
<li> ${bold('<code>' + msg.type + `</code> (${type})`)}
|
|
35
34
|
<details${open ? ' open' : ''}>
|
|
@@ -38,8 +37,7 @@ function explainMsg(msg, type, desc = '', open = false) {
|
|
|
38
37
|
|
|
39
38
|
${desc}
|
|
40
39
|
|
|
41
|
-
${
|
|
42
|
-
${(0, doc_code_1.codeBlock)(msgPrettyPrint.length > 5_000 ? 'text' : 'json', msgPrettyPrint.length > 5_000 ? JSON.stringify(msg) : msgPrettyPrint)}
|
|
40
|
+
${(0, doc_code_1.jsonWithLimit)(msg)}
|
|
43
41
|
|
|
44
42
|
</details>
|
|
45
43
|
</li>
|
|
@@ -102,7 +100,7 @@ The following lists all messages that were sent and received in case you want to
|
|
|
102
100
|
|
|
103
101
|
${explainPingPong(messages, response)}
|
|
104
102
|
|
|
105
|
-
The complete round-trip took ${(0,
|
|
103
|
+
The complete round-trip took ${(0, time_1.printAsMs)(end - start)} (including time required to validate the messages, start, and stop the internal mock server).
|
|
106
104
|
|
|
107
105
|
</details>
|
|
108
106
|
`;
|
|
@@ -37,14 +37,19 @@ function dropGenericsFromType(type) {
|
|
|
37
37
|
return type;
|
|
38
38
|
}
|
|
39
39
|
function removeCommentSymbols(comment) {
|
|
40
|
-
return comment
|
|
40
|
+
return comment
|
|
41
|
+
// remove '/** \n * \n */...
|
|
42
|
+
.replace(/^\/\*\*?/gm, '').replace(/^\s*\*\s*/gm, '').replace(/\*\/$/gm, '').replace(/^\s*\*/gm, '')
|
|
43
|
+
/* replace {@key foo|bar} with `bar` and {@key foo} with `foo` */
|
|
44
|
+
.replace(/\{@[a-zA-Z]+ ([^}]+\|)?(?<name>[^}]+)}/gm, '<code>$<name></code>')
|
|
45
|
+
.trim();
|
|
41
46
|
}
|
|
42
47
|
function getTextualComments(node) {
|
|
43
48
|
const comments = typescript_1.default.getJSDocCommentsAndTags(node);
|
|
44
49
|
const out = [];
|
|
45
50
|
for (const { comment } of comments) {
|
|
46
51
|
if (typeof comment === 'string') {
|
|
47
|
-
out.push(comment);
|
|
52
|
+
out.push(removeCommentSymbols(comment));
|
|
48
53
|
}
|
|
49
54
|
else if (comment !== undefined) {
|
|
50
55
|
for (const c of comment) {
|
|
@@ -62,6 +67,7 @@ function getType(node, typeChecker) {
|
|
|
62
67
|
const tryDirect = typeChecker.getTypeAtLocation(node);
|
|
63
68
|
return tryDirect ? typeChecker.typeToString(tryDirect) : 'unknown';
|
|
64
69
|
}
|
|
70
|
+
const defaultSkip = ['Pick', 'Partial', 'Required', 'Readonly', 'Omit', 'DeepPartial', 'DeepReadonly', 'DeepWritable', 'StrictOmit'];
|
|
65
71
|
function followTypeReference(type, sourceFile) {
|
|
66
72
|
const node = type.typeName;
|
|
67
73
|
if (typescript_1.default.isQualifiedName(node)) {
|
|
@@ -69,10 +75,11 @@ function followTypeReference(type, sourceFile) {
|
|
|
69
75
|
}
|
|
70
76
|
const args = type.typeArguments?.map(arg => arg.getText(sourceFile)) ?? [];
|
|
71
77
|
const nodeLexeme = node.getText(sourceFile) ?? '';
|
|
72
|
-
|
|
73
|
-
|
|
78
|
+
const baseLexeme = type.getText(sourceFile) ?? '';
|
|
79
|
+
if (defaultSkip.map(s => nodeLexeme.startsWith(s))) {
|
|
80
|
+
return [baseLexeme, ...args];
|
|
74
81
|
}
|
|
75
|
-
return [nodeLexeme, ...args];
|
|
82
|
+
return [nodeLexeme, baseLexeme, ...args];
|
|
76
83
|
}
|
|
77
84
|
function collectHierarchyInformation(sourceFiles, options) {
|
|
78
85
|
const hierarchyList = [];
|
|
@@ -112,7 +119,7 @@ function collectHierarchyInformation(sourceFiles, options) {
|
|
|
112
119
|
.map(dropGenericsFromType);
|
|
113
120
|
}
|
|
114
121
|
else if (typescript_1.default.isTypeReferenceNode(node.type)) {
|
|
115
|
-
baseTypes = [...followTypeReference(node.type, sourceFile)];
|
|
122
|
+
baseTypes = [...followTypeReference(node.type, sourceFile)].map(dropGenericsFromType);
|
|
116
123
|
}
|
|
117
124
|
const generics = node.typeParameters?.map(param => param.getText(sourceFile) ?? '') ?? [];
|
|
118
125
|
hierarchyList.push({
|
|
@@ -129,7 +136,7 @@ function collectHierarchyInformation(sourceFiles, options) {
|
|
|
129
136
|
else if (typescript_1.default.isEnumDeclaration(node)) {
|
|
130
137
|
const enumName = node.name?.getText(sourceFile) ?? '';
|
|
131
138
|
hierarchyList.push({
|
|
132
|
-
name: enumName,
|
|
139
|
+
name: dropGenericsFromType(enumName),
|
|
133
140
|
node,
|
|
134
141
|
kind: 'enum',
|
|
135
142
|
extends: [],
|
|
@@ -178,9 +185,10 @@ function generateMermaidClassDiagram(hierarchyList, rootName, options, visited =
|
|
|
178
185
|
}
|
|
179
186
|
}
|
|
180
187
|
collect.nodeLines.push(`click ${node.name} href "${getTypePathLink(node)}" "${(0, mermaid_1.escapeMarkdown)(node.comments?.join('; ').replace(/\n/g, ' ') ?? '')}"`);
|
|
188
|
+
const inline = [...options.inlineTypes ?? [], ...defaultSkip];
|
|
181
189
|
if (node.extends.length > 0) {
|
|
182
190
|
for (const baseType of node.extends) {
|
|
183
|
-
if (
|
|
191
|
+
if (inline.includes(baseType)) {
|
|
184
192
|
const info = hierarchyList.find(h => h.name === baseType);
|
|
185
193
|
for (const property of info?.properties ?? []) {
|
|
186
194
|
if (!writtenProperties.has(property)) {
|
|
@@ -191,10 +199,10 @@ function generateMermaidClassDiagram(hierarchyList, rootName, options, visited =
|
|
|
191
199
|
}
|
|
192
200
|
else {
|
|
193
201
|
if (node.kind === 'type' || hierarchyList.find(h => h.name === baseType)?.kind === 'type') {
|
|
194
|
-
collect.edgeLines.push(`${baseType} .. ${node.name}`);
|
|
202
|
+
collect.edgeLines.push(`${dropGenericsFromType(baseType)} .. ${node.name}`);
|
|
195
203
|
}
|
|
196
204
|
else {
|
|
197
|
-
collect.edgeLines.push(`${baseType} <|-- ${node.name}`);
|
|
205
|
+
collect.edgeLines.push(`${dropGenericsFromType(baseType)} <|-- ${node.name}`);
|
|
198
206
|
}
|
|
199
207
|
const { nodeLines, edgeLines } = generateMermaidClassDiagram(hierarchyList, baseType, options, visited);
|
|
200
208
|
collect.nodeLines.push(...nodeLines);
|
|
@@ -243,7 +251,7 @@ function implSnippet(node, program, nesting = 0) {
|
|
|
243
251
|
const bold = node.kind === 'interface' || node.kind === 'enum' ? '**' : '';
|
|
244
252
|
const sep = node.comments ? ' \n' : '\n';
|
|
245
253
|
let text = node.comments?.join('\n') ?? '';
|
|
246
|
-
const code = node.node.
|
|
254
|
+
const code = node.node.getFullText(program.getSourceFile(node.node.getSourceFile().fileName));
|
|
247
255
|
text += `\n<details><summary style="color:gray">Defined at <a href="${getTypePathLink(node)}">${getTypePathLink(node, '.')}</a></summary>\n\n${(0, doc_code_1.codeBlock)('ts', code)}\n\n</details>\n`;
|
|
248
256
|
return `${indent} * ${bold}[${node.name}](${getTypePathLink(node)})${bold} ${sep}${indent} ${text.replaceAll('\t', ' ').split(/\n/g).join(`\n${indent} `)}`;
|
|
249
257
|
}
|
|
@@ -615,6 +615,13 @@ What to do if you encounter this vertex?
|
|
|
615
615
|
|
|
616
616
|
This depends on your analysis. To handle many real-world sources correctly you are probably fine with just ignoring it.
|
|
617
617
|
Yet, you may choose to follow these references for other queries. For now, _flowR's_ support for non-standard evaluation is limited.
|
|
618
|
+
|
|
619
|
+
Besides the obvious quotation there are other cases in which _flowR_ may choose to create a ${linkEdgeName(edge_1.EdgeType.NonStandardEvaluation)} edge, there are
|
|
620
|
+
some that may appear to be counter-intuitive. For example, a for-loop body, as in the following example.
|
|
621
|
+
|
|
622
|
+
${(0, doc_structure_1.details)('Example: For-Loop Body', await (0, doc_dfg_1.printDfGraphForCode)(shell, 'for(i in v) b', { mark: new Set([2, '4->2']) }))}
|
|
623
|
+
${(0, doc_structure_1.details)('Example: While-Loop Body', await (0, doc_dfg_1.printDfGraphForCode)(shell, 'while(TRUE) b', { mark: new Set([1, '3->1']) }))}
|
|
624
|
+
|
|
618
625
|
`
|
|
619
626
|
})}
|
|
620
627
|
`,
|
|
@@ -674,7 +681,9 @@ Additionally, you may be interested in the set of [Unknown Side Effects](#unknow
|
|
|
674
681
|
> [!TIP]
|
|
675
682
|
> If you want to investigate the dataflow graph,
|
|
676
683
|
> you can either use the [Visual Studio Code extension](${doc_files_1.FlowrGithubBaseRef}/vscode-flowr) or the ${(0, doc_cli_option_1.getReplCommand)('dataflow*')}
|
|
677
|
-
> command in the REPL (see the [Interface wiki page](${doc_files_1.FlowrWikiBaseRef}/Interface) for more information).
|
|
684
|
+
> command in the REPL (see the [Interface wiki page](${doc_files_1.FlowrWikiBaseRef}/Interface) for more information). When using _flowR_ as a library, you may use the functions in ${(0, doc_files_1.getFilePathMd)('../util/mermaid/dfg.ts')}.
|
|
685
|
+
>
|
|
686
|
+
> If you receive a dataflow graph in its serialized form (e.g., by talking to a [_flowR_ server](${doc_files_1.FlowrWikiBaseRef}/Interface)), you can use \`${graph_1.DataflowGraph.name}::${graph_1.DataflowGraph.fromJson.name}\` to retrieve the graph from the JSON representation.
|
|
678
687
|
|
|
679
688
|
${await (0, doc_dfg_1.printDfGraphForCode)(shell, 'x <- 3\ny <- x + 1\ny')}
|
|
680
689
|
|
|
@@ -19,7 +19,7 @@ const flowr_main_options_1 = require("../cli/flowr-main-options");
|
|
|
19
19
|
const doc_issue_1 = require("./doc-util/doc-issue");
|
|
20
20
|
const pipeline_executor_1 = require("../core/pipeline-executor");
|
|
21
21
|
async function explainServer(shell) {
|
|
22
|
-
(0, doc_data_server_messages_1.
|
|
22
|
+
(0, doc_data_server_messages_1.documentAllServerMessages)();
|
|
23
23
|
return `
|
|
24
24
|
As explained in the [Overview](${doc_files_1.FlowrWikiBaseRef}/Overview), you can simply run the [TCP](https://de.wikipedia.org/wiki/Transmission_Control_Protocol) server by adding the ${(0, doc_cli_option_1.getCliLongOptionOf)('flowr', 'server', true)} flag (and, due to the interactive mode, exit with the conventional <kbd>CTRL</kbd>+<kbd>C</kbd>).
|
|
25
25
|
Currently, every connection is handled by the same underlying \`${shell_1.RShell.name}\` - so the server is not designed to handle many clients at a time.
|
|
@@ -11,8 +11,8 @@ const doc_normalized_ast_1 = require("./doc-util/doc-normalized-ast");
|
|
|
11
11
|
const doc_types_1 = require("./doc-util/doc-types");
|
|
12
12
|
const path_1 = __importDefault(require("path"));
|
|
13
13
|
const doc_files_1 = require("./doc-util/doc-files");
|
|
14
|
-
const doc_ms_1 = require("./doc-util/doc-ms");
|
|
15
14
|
const doc_cli_option_1 = require("./doc-util/doc-cli-option");
|
|
15
|
+
const time_1 = require("../util/time");
|
|
16
16
|
async function getText(shell) {
|
|
17
17
|
const rversion = (await shell.usedRVersion())?.format() ?? 'unknown';
|
|
18
18
|
const now = performance.now();
|
|
@@ -67,7 +67,7 @@ Grayed-out parts are used for structuring the AST, grouping together related nod
|
|
|
67
67
|
|
|
68
68
|
${(0, doc_code_1.codeBlock)('mermaid', types.text)}
|
|
69
69
|
|
|
70
|
-
_The generation of the class diagram required ${(0,
|
|
70
|
+
_The generation of the class diagram required ${(0, time_1.printAsMs)(elapsed)}._
|
|
71
71
|
</details>
|
|
72
72
|
|
|
73
73
|
Node types are controlled by the \`${'RType'}\` enum (see ${(0, doc_files_1.getFilePathMd)('../r-bridge/lang-4.x/ast/model/type.ts')}),
|