@eagleoutice/flowr 2.15.10 → 2.16.0

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 (181) hide show
  1. package/README.md +23 -26
  2. package/abstract-interpretation/data-frame/arguments.js +11 -7
  3. package/control-flow/happens-before.d.ts +5 -0
  4. package/control-flow/happens-before.js +48 -34
  5. package/control-flow/useless-loop.d.ts +1 -1
  6. package/control-flow/useless-loop.js +29 -42
  7. package/dataflow/environments/built-in-props.d.ts +9 -0
  8. package/dataflow/environments/built-in-props.js +25 -19
  9. package/dataflow/environments/built-in.d.ts +2 -2
  10. package/dataflow/environments/built-in.js +41 -77
  11. package/dataflow/environments/default-builtin-config.d.ts +181 -29
  12. package/dataflow/environments/default-builtin-config.js +38 -24
  13. package/dataflow/environments/environment.d.ts +6 -4
  14. package/dataflow/environments/environment.js +54 -121
  15. package/dataflow/environments/identifier.d.ts +4 -2
  16. package/dataflow/environments/identifier.js +23 -69
  17. package/dataflow/environments/reference-to-maybe.d.ts +9 -0
  18. package/dataflow/environments/reference-to-maybe.js +23 -51
  19. package/dataflow/environments/resolve-by-name.js +37 -76
  20. package/dataflow/eval/resolve/resolve-argument.d.ts +3 -1
  21. package/dataflow/eval/resolve/resolve-argument.js +61 -64
  22. package/dataflow/eval/resolve/resolve-working-directory.d.ts +8 -2
  23. package/dataflow/eval/resolve/resolve-working-directory.js +12 -20
  24. package/dataflow/eval/resolve/resolve.d.ts +4 -0
  25. package/dataflow/eval/resolve/resolve.js +23 -14
  26. package/dataflow/extractor.js +176 -59
  27. package/dataflow/fn/class-declaration.d.ts +8 -2
  28. package/dataflow/fn/class-declaration.js +96 -97
  29. package/dataflow/fn/exceptions-of-function.js +68 -37
  30. package/dataflow/fn/frame-reflection.d.ts +12 -4
  31. package/dataflow/fn/frame-reflection.js +51 -41
  32. package/dataflow/fn/function-props.js +15 -33
  33. package/dataflow/fn/function-semantics.d.ts +11 -3
  34. package/dataflow/fn/function-semantics.js +6 -0
  35. package/dataflow/fn/higher-order-function.js +13 -17
  36. package/dataflow/fn/strict-function.d.ts +13 -0
  37. package/dataflow/fn/strict-function.js +285 -122
  38. package/dataflow/graph/call-graph.d.ts +7 -6
  39. package/dataflow/graph/call-graph.js +35 -46
  40. package/dataflow/graph/graph.d.ts +6 -1
  41. package/dataflow/graph/graph.js +57 -66
  42. package/dataflow/info.d.ts +8 -1
  43. package/dataflow/info.js +24 -30
  44. package/dataflow/internal/control-flow.d.ts +31 -4
  45. package/dataflow/internal/control-flow.js +61 -39
  46. package/dataflow/internal/linker.d.ts +15 -9
  47. package/dataflow/internal/linker.js +253 -241
  48. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +80 -14
  49. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +446 -78
  50. package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +3 -1
  51. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +51 -48
  52. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +2 -2
  53. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +119 -185
  54. package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +7 -9
  55. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.d.ts +1 -1
  56. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +122 -147
  57. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +55 -25
  58. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +289 -251
  59. package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +1 -1
  60. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +30 -32
  61. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +68 -67
  62. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +72 -126
  63. package/dataflow/internal/process/functions/call/built-in/built-in-local.d.ts +1 -3
  64. package/dataflow/internal/process/functions/call/built-in/built-in-local.js +10 -10
  65. package/dataflow/internal/process/functions/call/built-in/built-in-quote.d.ts +4 -4
  66. package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +9 -35
  67. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +8 -3
  68. package/dataflow/internal/process/functions/call/built-in/built-in-s-four.d.ts +1 -1
  69. package/dataflow/internal/process/functions/call/built-in/built-in-s-four.js +12 -28
  70. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +1 -1
  71. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +40 -118
  72. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -3
  73. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +16 -24
  74. package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +2 -0
  75. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +93 -102
  76. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +7 -3
  77. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +173 -114
  78. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.d.ts +1 -3
  79. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +22 -27
  80. package/dataflow/internal/process/functions/call/built-in/built-in-with.d.ts +1 -1
  81. package/dataflow/internal/process/functions/call/built-in/built-in-with.js +34 -9
  82. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +1 -1
  83. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +119 -93
  84. package/dataflow/internal/process/functions/call/common.d.ts +1 -3
  85. package/dataflow/internal/process/functions/call/common.js +36 -76
  86. package/dataflow/internal/process/functions/call/deferred.d.ts +6 -2
  87. package/dataflow/internal/process/functions/call/deferred.js +54 -57
  88. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +4 -2
  89. package/dataflow/internal/process/functions/call/known-call-handling.js +65 -68
  90. package/dataflow/internal/process/functions/call/named-call-handling.d.ts +3 -5
  91. package/dataflow/internal/process/functions/call/named-call-handling.js +35 -21
  92. package/dataflow/internal/process/functions/call/quoted.d.ts +2 -0
  93. package/dataflow/internal/process/functions/call/quoted.js +162 -172
  94. package/dataflow/internal/process/functions/call/unnamed-call-handling.js +17 -38
  95. package/dataflow/internal/process/functions/process-parameter.js +25 -32
  96. package/dataflow/internal/process/process-symbol.js +3 -6
  97. package/dataflow/internal/program-order.d.ts +26 -0
  98. package/dataflow/internal/program-order.js +49 -0
  99. package/documentation/wiki-setup.js +23 -0
  100. package/linter/linter-rules.d.ts +17 -8
  101. package/linter/rules/absolute-path.js +63 -87
  102. package/linter/rules/file-path-validity.d.ts +4 -2
  103. package/linter/rules/file-path-validity.js +114 -80
  104. package/linter/rules/namespace-access.js +21 -33
  105. package/linter/rules/naming-convention.d.ts +1 -1
  106. package/linter/rules/naming-convention.js +60 -48
  107. package/linter/rules/network-functions.js +11 -7
  108. package/linter/rules/no-leaked-credentials.js +15 -18
  109. package/linter/rules/problematic-inputs.d.ts +2 -1
  110. package/linter/rules/problematic-inputs.js +39 -59
  111. package/linter/rules/roxygen-arguments.d.ts +9 -4
  112. package/linter/rules/roxygen-arguments.js +29 -48
  113. package/linter/rules/seeded-randomness.d.ts +7 -4
  114. package/linter/rules/seeded-randomness.js +128 -89
  115. package/linter/rules/stop-with-call-arg.d.ts +4 -2
  116. package/linter/rules/stop-with-call-arg.js +25 -22
  117. package/linter/rules/unclosed-connection.js +31 -24
  118. package/linter/rules/undefined-symbol.d.ts +4 -6
  119. package/linter/rules/undefined-symbol.js +58 -75
  120. package/linter/rules/unescaped-arguments.js +18 -44
  121. package/linter/rules/unused-definition.d.ts +6 -0
  122. package/linter/rules/unused-definition.js +105 -145
  123. package/linter/rules/unused-import.d.ts +3 -0
  124. package/linter/rules/unused-import.js +25 -43
  125. package/package.json +5 -2
  126. package/project/flowr-analyzer.js +6 -2
  127. package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +2 -2
  128. package/project/plugins/file-plugins/files/flowr-jupyter-file.js +8 -12
  129. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +7 -5
  130. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +34 -56
  131. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +16 -41
  132. package/queries/base-query-format.js +1 -2
  133. package/queries/catalog/absint-query/absint-query-format.js +1 -1
  134. package/queries/catalog/dataflow-query/dataflow-query-executor.js +2 -2
  135. package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +2 -0
  136. package/queries/catalog/dataflow-query/dataflow-query-format.js +4 -7
  137. package/queries/catalog/dependencies-query/dependencies-query-executor.js +50 -114
  138. package/queries/catalog/dependencies-query/function-info/library-functions.d.ts +5 -9
  139. package/queries/catalog/dependencies-query/function-info/library-functions.js +6 -0
  140. package/queries/catalog/dependencies-query/function-info/read-functions.js +1 -1
  141. package/queries/catalog/dependencies-query/function-info/write-functions.js +7 -3
  142. package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +4 -4
  143. package/queries/catalog/input-sources-query/simple-input-classifier.js +192 -301
  144. package/r-bridge/lang-4.x/ast/model/model.d.ts +3 -1
  145. package/r-bridge/lang-4.x/ast/model/model.js +19 -43
  146. package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +1 -0
  147. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +3 -0
  148. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.js +5 -12
  149. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +1 -0
  150. package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +1 -0
  151. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +1 -0
  152. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +1 -0
  153. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +1 -0
  154. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +1 -0
  155. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +1 -0
  156. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +1 -0
  157. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +1 -0
  158. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +1 -0
  159. package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +1 -0
  160. package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +1 -0
  161. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +1 -0
  162. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +1 -0
  163. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +1 -0
  164. package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +1 -0
  165. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +1 -0
  166. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +1 -0
  167. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +1 -0
  168. package/r-bridge/roxygen2/roxygen-parse.js +28 -42
  169. package/r-bridge/shell.js +6 -0
  170. package/search/search-executor/search-enrichers.js +25 -37
  171. package/slicing/static/slice-call.d.ts +4 -3
  172. package/slicing/static/slice-call.js +56 -88
  173. package/slicing/static/static-slicer.js +115 -79
  174. package/slicing/static/visiting-queue.d.ts +4 -6
  175. package/slicing/static/visiting-queue.js +9 -13
  176. package/util/proc.js +2 -1
  177. package/util/r-base-packages.d.ts +2 -0
  178. package/util/r-base-packages.js +23 -13
  179. package/util/text/playground-link.d.ts +12 -3
  180. package/util/text/playground-link.js +18 -27
  181. package/util/version.js +4 -10
@@ -7,17 +7,17 @@ import type { FlowrAnalyzerContext } from '../../../context/flowr-analyzer-conte
7
7
  * Finally, it provides access to the single cells, and all cells fused together as one R file.
8
8
  */
9
9
  export declare class FlowrRMarkdownFile extends FlowrFile {
10
- private data?;
11
- private mergedCode?;
12
10
  private readonly wrapped;
13
11
  private readonly context;
12
+ private data?;
13
+ private mergedCode?;
14
14
  private readonly included;
15
15
  /**
16
16
  * Prefer the static {@link FlowrRMarkdownFile.from} method
17
- * @param file - the file to load as R Markdown
18
- * @param ctx - the analyzer context the chunks are read with
17
+ * @param wrapped - the file to load as R Markdown
18
+ * @param context - the analyzer context the chunks are read with
19
19
  */
20
- constructor(file: FlowrFileProvider<string>, ctx: FlowrAnalyzerContext);
20
+ constructor(wrapped: FlowrFileProvider<string>, context: FlowrAnalyzerContext);
21
21
  /**
22
22
  * Gets the parsed R Markdown information
23
23
  */
@@ -74,6 +74,8 @@ export declare function globalChunkOptions(frontmatter: object): CodeBlockOption
74
74
  * @returns Rmd Info
75
75
  */
76
76
  export declare function parseRMarkdownFile(raw: string): RmdInfo;
77
+ /** The info string of an R chunk, `{r}` or `{r label, eval = FALSE}`; the `[\s,]` keeps `{rust}` out */
78
+ export declare const RTagRegex: RegExp;
77
79
  /**
78
80
  * Checks whether a CommonMark node is an R code block
79
81
  */
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FlowrRMarkdownFile = void 0;
3
+ exports.RTagRegex = exports.FlowrRMarkdownFile = void 0;
4
4
  exports.isExecutableCell = isExecutableCell;
5
5
  exports.continuesAfterError = continuesAfterError;
6
6
  exports.globalChunkOptions = globalChunkOptions;
@@ -19,20 +19,20 @@ const built_in_source_1 = require("../../../../dataflow/internal/process/functio
19
19
  * Finally, it provides access to the single cells, and all cells fused together as one R file.
20
20
  */
21
21
  class FlowrRMarkdownFile extends flowr_file_1.FlowrFile {
22
- data;
23
- mergedCode;
24
22
  wrapped;
25
23
  context;
24
+ data;
25
+ mergedCode;
26
26
  included = [];
27
27
  /**
28
28
  * Prefer the static {@link FlowrRMarkdownFile.from} method
29
- * @param file - the file to load as R Markdown
30
- * @param ctx - the analyzer context the chunks are read with
29
+ * @param wrapped - the file to load as R Markdown
30
+ * @param context - the analyzer context the chunks are read with
31
31
  */
32
- constructor(file, ctx) {
33
- super(file.path(), file.roles ? [...file.roles, flowr_file_1.FileRole.Source] : [flowr_file_1.FileRole.Source]);
34
- this.wrapped = file;
35
- this.context = ctx;
32
+ constructor(wrapped, context) {
33
+ super(wrapped.path(), wrapped.roles ? [...wrapped.roles, flowr_file_1.FileRole.Source] : [flowr_file_1.FileRole.Source]);
34
+ this.wrapped = wrapped;
35
+ this.context = context;
36
36
  }
37
37
  /**
38
38
  * Gets the parsed R Markdown information
@@ -68,10 +68,7 @@ class FlowrRMarkdownFile extends flowr_file_1.FlowrFile {
68
68
  (0, assert_1.guard)(this.data !== undefined);
69
69
  for (const block of this.data.blocks) {
70
70
  const childOpt = block.options.get('child');
71
- if (childOpt === undefined) {
72
- continue;
73
- }
74
- const childPath = (0, built_in_source_1.findSource)(this.context.config.solver.resolveSource, childOpt, {
71
+ const childPath = childOpt === undefined ? undefined : (0, built_in_source_1.findSource)(this.context.config.solver.resolveSource, childOpt, {
75
72
  ctx: this.context,
76
73
  referenceChain: [this.path()]
77
74
  });
@@ -138,8 +135,12 @@ function wrapErrorTolerant(code) {
138
135
  */
139
136
  function globalChunkOptions(frontmatter) {
140
137
  const knitr = frontmatter.knitr;
138
+ return scalarOptions([frontmatter.execute, knitr?.opts_chunk]);
139
+ }
140
+ /** The scalar entries of the given yaml objects as options, later ones overriding earlier ones. */
141
+ function scalarOptions(sources) {
141
142
  const options = new Map();
142
- for (const source of [frontmatter.execute, knitr?.opts_chunk]) {
143
+ for (const source of sources) {
143
144
  if (typeof source !== 'object' || source === null) {
144
145
  continue;
145
146
  }
@@ -183,20 +184,14 @@ function parseFrontmatter(raw) {
183
184
  * @returns Rmd Info
184
185
  */
185
186
  function parseRMarkdownFile(raw) {
186
- // Read and Parse Markdown
187
- const parser = new commonmark_1.Parser();
188
- const ast = parser.parse(raw);
189
- // Parse Frontmatter
190
187
  let frontmatter;
191
188
  try {
192
189
  frontmatter = parseFrontmatter(raw);
193
190
  }
194
191
  catch (e) {
195
192
  log_1.log.warn(`Failed to parse frontmatter of Rmd file, ignoring it. Error was: ${JSON.stringify(e)}`);
196
- frontmatter = undefined;
197
193
  }
198
- // Parse Codeblocks
199
- const walker = ast.walker();
194
+ const walker = new commonmark_1.Parser().parse(raw).walker();
200
195
  const blocks = [];
201
196
  let e;
202
197
  while ((e = walker.next())) {
@@ -206,48 +201,42 @@ function parseRMarkdownFile(raw) {
206
201
  }
207
202
  const options = parseCodeBlockOptions(node.info, node.literal);
208
203
  const engineOpt = options.get('engine');
209
- if (engineOpt !== undefined && engineOpt.trim().toLowerCase() !== 'r') {
210
- continue;
204
+ if (engineOpt === undefined || engineOpt.trim().toLowerCase() === 'r') {
205
+ blocks.push({
206
+ code: node.literal,
207
+ options,
208
+ header: node.info,
209
+ startpos: { line: node.sourcepos[0][0] + 1, col: 0 }
210
+ });
211
211
  }
212
- blocks.push({
213
- code: node.literal,
214
- options: options,
215
- header: node.info,
216
- startpos: { line: node.sourcepos[0][0] + 1, col: 0 }
217
- });
218
212
  }
219
213
  blocks.push(...parseIncludeShortcodes(raw));
220
214
  blocks.sort((a, b) => a.startpos.line - b.startpos.line);
221
215
  return {
222
- blocks: blocks,
216
+ blocks,
223
217
  options: typeof frontmatter === 'object' && frontmatter !== null ? frontmatter : {}
224
218
  };
225
219
  }
226
220
  const IncludeShortcodeRegex = /{{<\s*include\s+["']?(.+?)["']?\s*>}}/;
227
221
  /** Collects quarto's `{{< include other.qmd >}}` as blocks carrying a `child`, resolved like knitr's option */
228
222
  function parseIncludeShortcodes(raw) {
229
- const blocks = [];
230
- const lines = raw.split(LineRegex);
231
- for (let i = 0; i < lines.length; i++) {
232
- const match = IncludeShortcodeRegex.exec(lines[i]);
233
- if (match) {
234
- blocks.push({
223
+ return raw.split(LineRegex).flatMap((line, i) => {
224
+ const match = IncludeShortcodeRegex.exec(line);
225
+ return match ? [{
235
226
  code: '',
236
227
  options: new Map([['child', match[1]]]),
237
228
  header: '',
238
229
  startpos: { line: i + 1, col: 0 }
239
- });
240
- }
241
- }
242
- return blocks;
230
+ }] : [];
231
+ });
243
232
  }
244
- // We need the [\s,] part, otherwise {rust} would also match
245
- const RTagRegex = /{[rR](?:[\s,][^}]*)?}/;
233
+ /** The info string of an R chunk, `{r}` or `{r label, eval = FALSE}`; the `[\s,]` keeps `{rust}` out */
234
+ exports.RTagRegex = /{[rR](?:[\s,][^}]*)?}/;
246
235
  /**
247
236
  * Checks whether a CommonMark node is an R code block
248
237
  */
249
238
  function isRCodeBlock(node) {
250
- return node.type === 'code_block' && node.literal !== null && node.info !== null && RTagRegex.test(node.info);
239
+ return node.type === 'code_block' && node.literal !== null && node.info !== null && exports.RTagRegex.test(node.info);
251
240
  }
252
241
  const LineRegex = /\r\n|\r|\n/;
253
242
  function countNewlines(str) {
@@ -269,7 +258,6 @@ function restoreBlocksWithoutMd(blocks, totalLines) {
269
258
  output += block.code;
270
259
  line += countNewlines(block.code);
271
260
  }
272
- // Add remainder of file
273
261
  goToLine(totalLines + 1);
274
262
  return output;
275
263
  }
@@ -289,11 +277,7 @@ function parseCodeBlockOptions(header, content) {
289
277
  // keep the indentation, yaml block scalars rely on it
290
278
  cellLines.push(line.trim().slice(2).replace(/^ /, ''));
291
279
  }
292
- const options = parseOptionString(headerOpts);
293
- for (const [key, value] of parseCellOptions(cellLines)) {
294
- options.set(key, value);
295
- }
296
- return options;
280
+ return new Map([...parseOptionString(headerOpts), ...parseCellOptions(cellLines)]);
297
281
  }
298
282
  /** Parses knitr's `key=value` option syntax as used in the chunk header */
299
283
  function parseOptionString(opts) {
@@ -314,13 +298,7 @@ function parseCellOptions(lines) {
314
298
  const parsed = parseFrontmatter(`---\n${lines.join('\n')}\n---\n`);
315
299
  // a bare scalar is knitr's `key=value` syntax, not yaml
316
300
  if (typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed) && Object.keys(parsed).length > 0) {
317
- const options = new Map();
318
- for (const [key, value] of Object.entries(parsed)) {
319
- if (value !== null && typeof value !== 'object') {
320
- options.set(key, String(value));
321
- }
322
- }
323
- return options;
301
+ return scalarOptions([parsed]);
324
302
  }
325
303
  }
326
304
  catch (e) {
@@ -57,22 +57,15 @@ const defaultmap_1 = require("../../../util/collections/defaultmap");
57
57
  const arrays_1 = require("../../../util/collections/arrays");
58
58
  /** the plugin's instance name (pass to `unregisterPlugins` to disable the default sigdb resolver) */
59
59
  exports.SigDbPluginName = 'flowr-analyzer-package-versions-sigdb-plugin';
60
- /** map a resolved source's compressed extension to a codec name for display (`undefined` extension is a plain file) */
61
- function codecNameOf(ext) {
62
- switch (ext) {
63
- case '.zst': return 'zstd';
64
- case '.br': return 'brotli';
65
- case '.gz': return 'gzip';
66
- default: return 'plain';
67
- }
68
- }
60
+ /** a resolved source's compressed extension as a codec name for display, a file without one is `plain` */
61
+ const CodecNames = { '.zst': 'zstd', '.br': 'brotli', '.gz': 'gzip' };
69
62
  /** the codec name of a manifest's resolved shard + dict sources, or `mixed` when they do not all agree */
70
63
  function manifestFormat(set) {
71
64
  const paths = [
72
65
  ...set.manifest.shards.map(s => s.path),
73
66
  ...(set.manifest.dicts?.map(d => d.path) ?? [])
74
67
  ];
75
- const codecs = (0, arrays_1.uniqueArray)(paths.map(p => codecNameOf((0, codec_1.compressedExtOf)((0, decompress_1.resolveSource)(set.baseDir, p)))));
68
+ const codecs = (0, arrays_1.uniqueArray)(paths.map(p => CodecNames[(0, codec_1.compressedExtOf)((0, decompress_1.resolveSource)(set.baseDir, p)) ?? ''] ?? 'plain'));
76
69
  return codecs.length === 1 ? codecs[0] : 'mixed';
77
70
  }
78
71
  /** describe one loaded source for `:version` / diagnostics: a single bundle, a sharded set, or an in-memory source */
@@ -285,16 +278,7 @@ class FlowrAnalyzerPackageVersionsSigDbPlugin extends flowr_analyzer_package_ver
285
278
  /* the historical bundle is not asked: a name is hinted so a `library()` can be added for it, and a package
286
279
  only that bundle carries is one nothing can attach today */
287
280
  const sources = this.loadSources().filter(s => describeLoadedDatabase(s).scope !== 'history');
288
- const seen = new Set();
289
- const owners = [];
290
- for (const src of sources) {
291
- for (const pkg of exportOwners(src, name)) {
292
- if (!seen.has(pkg) && !this.isSelfPackage(pkg)) {
293
- seen.add(pkg);
294
- owners.push(pkg);
295
- }
296
- }
297
- }
281
+ const owners = (0, arrays_1.uniqueArray)(sources.flatMap(src => exportOwners(src, name))).filter(pkg => !this.isSelfPackage(pkg));
298
282
  // each source's list is already sorted; a merge of several needs one more pass to be globally ordered
299
283
  if (owners.length > 1 && sources.length > 1) {
300
284
  /* the comparator runs O(n log n) times, so each package is counted once up front */
@@ -395,12 +379,8 @@ class FlowrAnalyzerPackageVersionsSigDbPlugin extends flowr_analyzer_package_ver
395
379
  return undefined;
396
380
  }
397
381
  const target = this.analyzerCtx?.resolvedRVersion ?? (0, config_1.resolveAssumedRVersion)(undefined);
398
- let chosen; // versions are ascending; keep the newest core release <= target
399
- for (const v of versions) {
400
- if (r_version_1.RVersion.compare(v.str, target) <= 0) {
401
- chosen = v;
402
- }
403
- }
382
+ // versions are ascending; keep the newest core release <= target
383
+ let chosen = versions.findLast(v => r_version_1.RVersion.compare(v.str, target) <= 0);
404
384
  if (chosen === undefined) {
405
385
  // the assumed R version is older than the earliest recorded core release: fall back to the closest one
406
386
  chosen = versions[0];
@@ -481,24 +461,17 @@ class FlowrAnalyzerPackageVersionsSigDbPlugin extends flowr_analyzer_package_ver
481
461
  if (info && (range === undefined || r_version_1.RRange.satisfies(info.version, range))) {
482
462
  return info;
483
463
  }
484
- if (range !== undefined) {
485
- const versions = this.availableVersions(src, name);
486
- for (let i = versions.length - 1; i >= 0; i--) {
487
- if (r_version_1.RRange.satisfies(versions[i], range)) {
488
- return src.lookup(name, versions[i]);
489
- }
490
- }
464
+ if (range === undefined) {
465
+ return undefined;
491
466
  }
492
- return undefined;
467
+ const satisfying = this.availableVersions(src, name).findLast(version => r_version_1.RRange.satisfies(version, range));
468
+ return satisfying === undefined ? undefined : src.lookup(name, satisfying);
493
469
  }
494
470
  /** Lowest stored version satisfying the constraint (using the store's actual R-form version strings). */
495
471
  oldestSatisfying(src, name, range) {
496
- for (const version of this.availableVersions(src, name)) { // ascending
497
- if (range === undefined || r_version_1.RRange.satisfies(version, range)) {
498
- return src.lookup(name, version);
499
- }
500
- }
501
- return undefined;
472
+ // versions are ascending, so the first satisfying one is the oldest
473
+ const satisfying = this.availableVersions(src, name).find(version => range === undefined || r_version_1.RRange.satisfies(version, range));
474
+ return satisfying === undefined ? undefined : src.lookup(name, satisfying);
502
475
  }
503
476
  /**
504
477
  * The versions the source can answer for a package (dated releases, base-R core releases, and the latest),
@@ -509,7 +482,9 @@ class FlowrAnalyzerPackageVersionsSigDbPlugin extends flowr_analyzer_package_ver
509
482
  }
510
483
  /** build the resolved {@link Package} (namespace + version) from a source's export view */
511
484
  toResolvedPackage(name, info) {
512
- const exported = info.exported.slice();
485
+ /* what the configuration states for the package is part of its interface, even where the database misses it */
486
+ const stated = this.analyzerCtx?.env.statedFor(name);
487
+ const exported = stated === undefined ? info.exported.slice() : (0, arrays_1.uniqueArray)([...info.exported, ...[...stated.keys()].map(String)]);
513
488
  const namespaceInfo = {
514
489
  exportedSymbols: exported,
515
490
  exportedFunctions: [],
@@ -18,13 +18,12 @@ function filterLineParser(type) {
18
18
  function singleCriterionLineParser(type, label, extra) {
19
19
  return function (output, line, _config) {
20
20
  const criterion = (0, slice_query_parser_1.sliceCriteriaParser)(line[0]);
21
- const fields = extra?.(line);
22
21
  if (!criterion || criterion.length !== 1) {
23
22
  output.stderr(output.formatter.format(`Invalid ${label} query format, a single slicing criterion must be given in the form "(criterion1)"`, { color: 1 /* Colors.Red */, effect: ansi_1.ColorEffect.Foreground, style: 1 /* FontStyles.Bold */ }));
24
23
  return { query: [] };
25
24
  }
26
25
  return {
27
- query: [{ type, criterion: criterion[0], ...fields }],
26
+ query: [{ type, criterion: criterion[0], ...extra?.(line) }],
28
27
  rCode: (0, slice_query_parser_1.queryLineCode)(line)
29
28
  };
30
29
  };
@@ -45,7 +45,7 @@ function absintQueryCompleter(line, startingNewArg, _config) {
45
45
  return { completions: [] };
46
46
  }
47
47
  function absintQueryLineParser(output, line, _config) {
48
- const type = line[0].toLowerCase();
48
+ const type = (line[0] ?? '').toLowerCase();
49
49
  if (!record_1.Record.has(exports.AbsintQueryInferences, type)) {
50
50
  output.stderr(output.formatter.format(`Invalid inference type "${type}", must be one of ${record_1.Record.keys(exports.AbsintQueryInferences).map(type => `"${type}"`).join(', ')}`, { color: 1 /* Colors.Red */, effect: ansi_1.ColorEffect.Foreground, style: 1 /* FontStyles.Bold */ }));
51
51
  return { query: [] };
@@ -10,12 +10,12 @@ async function executeDataflowQuery({ analyzer }, queries) {
10
10
  log_1.log.warn('Dataflow query expects only up to one query, but got', queries.length);
11
11
  }
12
12
  const startTime = Date.now();
13
- const graph = (await analyzer.dataflow()).graph;
13
+ const { graph } = await analyzer.dataflow();
14
14
  return {
15
15
  '.meta': {
16
16
  timing: Date.now() - startTime
17
17
  },
18
- graph
18
+ graph: queries.every(q => q.environments === false) ? graph.withoutEnvironments() : graph
19
19
  };
20
20
  }
21
21
  //# sourceMappingURL=dataflow-query-executor.js.map
@@ -8,6 +8,8 @@ import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/nod
8
8
  */
9
9
  export interface DataflowQuery extends BaseQueryFormat {
10
10
  readonly type: 'dataflow';
11
+ /** Whether to include the environments of the vertices and function definitions (default), see {@link DataflowGraph#withoutEnvironments}. */
12
+ readonly environments?: boolean;
11
13
  }
12
14
  export interface DataflowQueryResult extends BaseQueryResult {
13
15
  /** Please be aware that this is the graph in its JSON representation, use {@link DataflowGraph#fromJson} if the result is serialized */
@@ -22,7 +22,7 @@ exports.DataflowQueryDefinition = {
22
22
  result.push(` ╰ [Dataflow Graph](${url})`);
23
23
  }
24
24
  else {
25
- const vertices = Array.from(out.graph.vertices(true)).length;
25
+ const vertices = out.graph.vertices(true).toArray().length;
26
26
  const edges = Array.from(out.graph.edges()).length;
27
27
  result.push(` ╰ Dataflow Graph too large to link (${vertices} vertices, ${edges} edges, url would be ${url.length} chars); use ':df#' for more detail.`);
28
28
  }
@@ -30,14 +30,11 @@ exports.DataflowQueryDefinition = {
30
30
  },
31
31
  schema: joi_1.default.object({
32
32
  type: joi_1.default.string().valid('dataflow').required().description('The type of the query.'),
33
+ environments: joi_1.default.boolean().optional().description('Whether to include the environments of the vertices and function definitions (default: true). They make up most of the answer, so leave them out if only the graph itself is of interest.'),
33
34
  }).description('The dataflow query simply returns the dataflow graph, there is no need to pass it multiple times!'),
34
- flattenInvolvedNodes: queryResults => {
35
- const flattened = [];
35
+ flattenInvolvedNodes: (queryResults) => {
36
36
  const out = queryResults;
37
- for (const id of out.graph.idMap?.keys() ?? []) {
38
- flattened.push(id);
39
- }
40
- return flattened;
37
+ return [...out.graph.idMap?.keys() ?? []];
41
38
  }
42
39
  };
43
40
  //# sourceMappingURL=dataflow-query-format.js.map