@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.
Files changed (131) hide show
  1. package/README.md +2 -1
  2. package/cli/repl/commands/repl-parse.js +7 -16
  3. package/cli/repl/commands/repl-query.d.ts +0 -5
  4. package/cli/repl/commands/repl-query.js +2 -73
  5. package/core/print/parse-printer.js +1 -22
  6. package/core/steps/pipeline/default-pipelines.d.ts +64 -0
  7. package/core/steps/pipeline/default-pipelines.js +2 -1
  8. package/dataflow/cluster.d.ts +20 -0
  9. package/dataflow/cluster.js +46 -0
  10. package/dataflow/graph/edge.d.ts +2 -3
  11. package/dataflow/graph/graph.d.ts +1 -1
  12. package/documentation/data/server/doc-data-server-messages.d.ts +1 -1
  13. package/documentation/data/server/doc-data-server-messages.js +16 -5
  14. package/documentation/doc-util/doc-code.d.ts +1 -0
  15. package/documentation/doc-util/doc-code.js +9 -0
  16. package/documentation/doc-util/doc-dfg.d.ts +1 -0
  17. package/documentation/doc-util/doc-dfg.js +5 -4
  18. package/documentation/doc-util/doc-normalized-ast.js +2 -2
  19. package/documentation/doc-util/doc-query.d.ts +5 -1
  20. package/documentation/doc-util/doc-query.js +154 -9
  21. package/documentation/doc-util/doc-server-message.js +3 -5
  22. package/documentation/doc-util/doc-types.js +19 -11
  23. package/documentation/print-dataflow-graph-wiki.js +10 -1
  24. package/documentation/print-interface-wiki.js +1 -1
  25. package/documentation/print-normalized-ast-wiki.js +2 -2
  26. package/documentation/print-query-wiki.js +196 -37
  27. package/package.json +3 -2
  28. package/queries/{call-context-query → catalog/call-context-query}/call-context-query-executor.d.ts +4 -3
  29. package/queries/{call-context-query → catalog/call-context-query}/call-context-query-executor.js +22 -16
  30. package/queries/{call-context-query → catalog/call-context-query}/call-context-query-format.d.ts +6 -2
  31. package/queries/catalog/cluster-query/cluster-query-executor.d.ts +3 -0
  32. package/queries/catalog/cluster-query/cluster-query-executor.js +19 -0
  33. package/queries/catalog/cluster-query/cluster-query-format.d.ts +12 -0
  34. package/queries/catalog/cluster-query/cluster-query-format.js +3 -0
  35. package/queries/catalog/dataflow-query/dataflow-query-executor.d.ts +3 -0
  36. package/queries/catalog/dataflow-query/dataflow-query-executor.js +17 -0
  37. package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +12 -0
  38. package/queries/catalog/dataflow-query/dataflow-query-format.js +3 -0
  39. package/queries/catalog/id-map-query/id-map-query-executor.d.ts +3 -0
  40. package/queries/catalog/id-map-query/id-map-query-executor.js +17 -0
  41. package/queries/catalog/id-map-query/id-map-query-format.d.ts +8 -0
  42. package/{r-bridge/lang-4.x/ast/parser/xml/normalizer-data.js → queries/catalog/id-map-query/id-map-query-format.js} +1 -1
  43. package/queries/catalog/lineage-query/lineage-query-executor.d.ts +3 -0
  44. package/queries/catalog/lineage-query/lineage-query-executor.js +22 -0
  45. package/queries/catalog/lineage-query/lineage-query-format.d.ts +14 -0
  46. package/queries/catalog/lineage-query/lineage-query-format.js +3 -0
  47. package/queries/catalog/normalized-ast-query/normalized-ast-query-executor.d.ts +3 -0
  48. package/queries/catalog/normalized-ast-query/normalized-ast-query-executor.js +17 -0
  49. package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +11 -0
  50. package/queries/catalog/normalized-ast-query/normalized-ast-query-format.js +3 -0
  51. package/queries/catalog/static-slice-query/static-slice-query-executor.d.ts +4 -0
  52. package/queries/catalog/static-slice-query/static-slice-query-executor.js +40 -0
  53. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +24 -0
  54. package/queries/catalog/static-slice-query/static-slice-query-format.js +3 -0
  55. package/queries/query-schema.d.ts +6 -0
  56. package/queries/query-schema.js +26 -3
  57. package/queries/query.d.ts +22 -4
  58. package/queries/query.js +14 -2
  59. package/r-bridge/lang-4.x/ast/parser/json/format.d.ts +37 -13
  60. package/r-bridge/lang-4.x/ast/parser/json/format.js +59 -6
  61. package/r-bridge/lang-4.x/ast/parser/json/parser.d.ts +0 -3
  62. package/r-bridge/lang-4.x/ast/parser/json/parser.js +2 -40
  63. package/r-bridge/lang-4.x/ast/parser/main/internal/control/normalize-if-then-else.d.ts +15 -0
  64. package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/control/normalize-if-then-else.js +5 -8
  65. package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/control/normalize-if-then.d.ts +7 -7
  66. package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/control/normalize-if-then.js +11 -12
  67. package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/expression/normalize-expression.d.ts +3 -3
  68. package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/expression/normalize-expression.js +4 -7
  69. package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/functions/normalize-argument.d.ts +2 -2
  70. package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/functions/normalize-argument.js +3 -3
  71. package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/functions/normalize-call.d.ts +3 -3
  72. package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/functions/normalize-call.js +6 -9
  73. package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/functions/normalize-definition.d.ts +3 -3
  74. package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/functions/normalize-definition.js +1 -3
  75. package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/functions/normalize-parameter.d.ts +2 -2
  76. package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/functions/normalize-parameter.js +6 -5
  77. package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/loops/normalize-break.d.ts +2 -2
  78. package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/loops/normalize-for.d.ts +2 -2
  79. package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/loops/normalize-for.js +5 -6
  80. package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/loops/normalize-next.d.ts +2 -2
  81. package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/loops/normalize-repeat.d.ts +2 -2
  82. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-while.d.ts +4 -0
  83. package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/loops/normalize-while.js +4 -4
  84. package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/normalize-access.d.ts +3 -3
  85. package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/normalize-access.js +1 -2
  86. package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/operators/normalize-binary.d.ts +2 -2
  87. package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/operators/normalize-binary.js +2 -2
  88. package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/operators/normalize-unary.d.ts +2 -2
  89. package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/other/normalize-comment.d.ts +3 -3
  90. package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/other/normalize-comment.js +1 -1
  91. package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/other/normalize-line-directive.d.ts +3 -3
  92. package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/other/normalize-line-directive.js +1 -1
  93. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-delimiter.d.ts +3 -0
  94. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-expressions.d.ts +10 -0
  95. package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/structure/normalize-root.d.ts +2 -2
  96. package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/structure/normalize-root.js +3 -4
  97. package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/structure/normalize-single-node.d.ts +2 -2
  98. package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/structure/normalize-single-node.js +2 -2
  99. package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/values/normalize-number.d.ts +3 -3
  100. package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/values/normalize-number.js +1 -1
  101. package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/values/normalize-string.d.ts +3 -3
  102. package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/values/normalize-string.js +1 -1
  103. package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/values/normalize-symbol.d.ts +3 -3
  104. package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/values/normalize-symbol.js +1 -3
  105. package/r-bridge/lang-4.x/ast/parser/main/normalize-meta.d.ts +41 -0
  106. package/r-bridge/lang-4.x/ast/parser/main/normalize-meta.js +85 -0
  107. package/r-bridge/lang-4.x/ast/parser/{xml → main}/normalizer-data.d.ts +10 -4
  108. package/r-bridge/lang-4.x/ast/parser/main/normalizer-data.js +14 -0
  109. package/slicing/criterion/parse.d.ts +1 -1
  110. package/statistics/summarizer/post-process/clusterer.d.ts +1 -1
  111. package/util/ansi.js +9 -2
  112. package/util/time.d.ts +4 -0
  113. package/util/time.js +8 -0
  114. package/util/version.js +1 -1
  115. package/documentation/doc-util/doc-ms.d.ts +0 -1
  116. package/documentation/doc-util/doc-ms.js +0 -8
  117. package/r-bridge/lang-4.x/ast/parser/xml/input-format.d.ts +0 -39
  118. package/r-bridge/lang-4.x/ast/parser/xml/input-format.js +0 -38
  119. package/r-bridge/lang-4.x/ast/parser/xml/internal/control/normalize-if-then-else.d.ts +0 -15
  120. package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/normalize-while.d.ts +0 -4
  121. package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/normalize-delimiter.d.ts +0 -3
  122. package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/normalize-expressions.d.ts +0 -10
  123. package/r-bridge/lang-4.x/ast/parser/xml/normalize-meta.d.ts +0 -47
  124. package/r-bridge/lang-4.x/ast/parser/xml/normalize-meta.js +0 -110
  125. /package/queries/{call-context-query → catalog/call-context-query}/call-context-query-format.js +0 -0
  126. /package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/loops/normalize-break.js +0 -0
  127. /package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/loops/normalize-next.js +0 -0
  128. /package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/loops/normalize-repeat.js +0 -0
  129. /package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/operators/normalize-unary.js +0 -0
  130. /package/r-bridge/lang-4.x/ast/parser/{xml → main}/internal/structure/normalize-delimiter.js +0 -0
  131. /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>&#92;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, doc_ms_1.printAsMs)(duration)}_ (including parsing and normalization and the query) within the generation environment.
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
- ${(0, repl_query_1.asciiSummaryOfQueryResult)(ansi_1.markdownFormatter, duration, results, analysis)}
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
- \`\`\`json
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
- ${msgPrettyPrint.length > 5_000 ? '_As the message is pretty long, we inhibit pretty printing and syntax highlighting:_' : ''}
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, doc_ms_1.printAsMs)(end - start)} (including time required to validate the messages, start, and stop the internal mock server).
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.replace(/^\/\*\*?/, '').replace(/\*\/$/, '').replace(/^\s*\*/, '').trim();
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
- if (['Pick', 'Partial', 'Required', 'Readonly', 'Omit'].map(s => nodeLexeme.startsWith(s))) {
73
- return args;
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 (options.inlineTypes?.includes(baseType)) {
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.getText(program.getSourceFile(node.node.getSourceFile().fileName));
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.documentAllMessages)();
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)&nbsp;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, doc_ms_1.printAsMs)(elapsed)}._
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')}),