@eagleoutice/flowr 2.16.2 → 2.16.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 (445) hide show
  1. package/README.md +10 -10
  2. package/abstract-interpretation/data-frame/arguments.js +4 -3
  3. package/abstract-interpretation/data-frame/dataframe-semantics.js +1 -2
  4. package/abstract-interpretation/data-frame/semantics.d.ts +2 -2
  5. package/abstract-interpretation/data-frame/semantics.js +2 -6
  6. package/benchmark/slicer.js +1 -3
  7. package/benchmark/summarizer/first-phase/input.js +1 -12
  8. package/benchmark/summarizer/second-phase/process.d.ts +7 -0
  9. package/benchmark/summarizer/second-phase/process.js +15 -12
  10. package/cli/repl/commands/repl-cfg.js +18 -49
  11. package/cli/repl/commands/repl-clipboard.d.ts +2 -0
  12. package/cli/repl/commands/repl-clipboard.js +5 -0
  13. package/cli/repl/commands/repl-commands.js +2 -2
  14. package/cli/repl/commands/repl-dataflow.js +21 -55
  15. package/cli/repl/commands/repl-normalize.js +15 -28
  16. package/cli/repl/commands/repl-parse.js +2 -2
  17. package/cli/repl/commands/repl-query.js +10 -10
  18. package/cli/repl/commands/repl-signature.js +4 -4
  19. package/cli/repl/server/connection.d.ts +1 -0
  20. package/cli/repl/server/connection.js +8 -30
  21. package/cli/repl/server/messages/message-analysis.js +1 -1
  22. package/config.d.ts +6 -0
  23. package/config.js +7 -4
  24. package/control-flow/cfg-dead-code.js +5 -14
  25. package/control-flow/cfg-to-basic-blocks.js +1 -6
  26. package/control-flow/control-flow-graph.d.ts +2 -16
  27. package/control-flow/control-flow-graph.js +8 -66
  28. package/control-flow/diff-cfg.js +10 -23
  29. package/control-flow/semantic-cfg-guided-visitor.js +5 -11
  30. package/control-flow/simple-visitor.js +2 -2
  31. package/core/steps/pipeline/default-pipelines.d.ts +138 -138
  32. package/data/r-base-packages.generated.js +0 -1
  33. package/data/r-base-primitives.generated.js +0 -1
  34. package/data/r-s3-generics.generated.d.ts +5 -0
  35. package/data/r-s3-generics.generated.js +103 -0
  36. package/dataflow/cluster.js +2 -1
  37. package/dataflow/environments/append.d.ts +1 -0
  38. package/dataflow/environments/built-in-props.d.ts +10 -0
  39. package/dataflow/environments/built-in-props.js +25 -1
  40. package/dataflow/environments/built-in.js +15 -9
  41. package/dataflow/environments/clone.d.ts +1 -0
  42. package/dataflow/environments/clone.js +1 -0
  43. package/dataflow/environments/default-builtin-config.d.ts +188 -14
  44. package/dataflow/environments/default-builtin-config.js +125 -65
  45. package/dataflow/environments/define.d.ts +1 -0
  46. package/dataflow/environments/define.js +1 -0
  47. package/dataflow/environments/environment.d.ts +27 -0
  48. package/dataflow/environments/environment.js +37 -16
  49. package/dataflow/environments/frame-memory.d.ts +9 -1
  50. package/dataflow/environments/frame-memory.js +12 -1
  51. package/dataflow/environments/identifier.d.ts +0 -2
  52. package/dataflow/environments/identifier.js +5 -7
  53. package/dataflow/environments/overwrite.js +1 -0
  54. package/dataflow/environments/query-fn-props.js +2 -3
  55. package/dataflow/environments/scoping.d.ts +3 -0
  56. package/dataflow/environments/scoping.js +3 -0
  57. package/dataflow/eval/resolve/alias-tracking.js +3 -3
  58. package/dataflow/eval/resolve/resolve-argument.d.ts +7 -3
  59. package/dataflow/eval/resolve/resolve-argument.js +16 -11
  60. package/dataflow/eval/resolve/resolve-numbers.js +5 -2
  61. package/dataflow/eval/resolve/resolve-strings.d.ts +1 -1
  62. package/dataflow/eval/resolve/resolve-working-directory.js +2 -2
  63. package/dataflow/eval/resolve/resolve.js +1 -2
  64. package/dataflow/eval/values/intervals/interval-constants.js +1 -6
  65. package/dataflow/eval/values/r-value.js +1 -6
  66. package/dataflow/extractor.js +17 -17
  67. package/dataflow/fn/argument-roles.js +15 -15
  68. package/dataflow/fn/class-declaration.js +7 -7
  69. package/dataflow/fn/frame-reflection.d.ts +1 -23
  70. package/dataflow/fn/frame-reflection.js +8 -95
  71. package/dataflow/fn/function-props.d.ts +0 -3
  72. package/dataflow/fn/function-props.js +9 -11
  73. package/dataflow/fn/function-semantics.d.ts +1 -0
  74. package/dataflow/fn/strict-function.js +15 -14
  75. package/dataflow/graph/call-graph.d.ts +8 -0
  76. package/dataflow/graph/call-graph.js +40 -25
  77. package/dataflow/graph/dataflowgraph-builder.d.ts +0 -60
  78. package/dataflow/graph/dataflowgraph-builder.js +15 -135
  79. package/dataflow/graph/df-helper.d.ts +56 -4
  80. package/dataflow/graph/df-helper.js +116 -1
  81. package/dataflow/graph/diff-dataflow-graph.js +13 -15
  82. package/dataflow/graph/graph-helper.d.ts +20 -0
  83. package/dataflow/graph/graph-helper.js +18 -0
  84. package/dataflow/graph/graph.js +3 -8
  85. package/dataflow/graph/match-args.d.ts +1 -1
  86. package/dataflow/graph/match-args.js +3 -3
  87. package/dataflow/internal/linker.d.ts +4 -10
  88. package/dataflow/internal/linker.js +21 -29
  89. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +2 -8
  90. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +5 -2
  91. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +39 -22
  92. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +19 -21
  93. package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +3 -7
  94. package/dataflow/internal/process/functions/call/built-in/built-in-env-contents.js +6 -11
  95. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +6 -8
  96. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +14 -13
  97. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +27 -13
  98. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +6 -8
  99. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +33 -35
  100. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +3 -5
  101. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +6 -7
  102. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +12 -5
  103. package/dataflow/internal/process/functions/call/built-in/built-in-list.js +3 -4
  104. package/dataflow/internal/process/functions/call/built-in/built-in-load.js +7 -8
  105. package/dataflow/internal/process/functions/call/built-in/built-in-local.js +5 -6
  106. package/dataflow/internal/process/functions/call/built-in/built-in-new-env.js +3 -4
  107. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +2 -3
  108. package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.js +5 -7
  109. package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +6 -5
  110. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +1 -2
  111. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +5 -6
  112. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +4 -4
  113. package/dataflow/internal/process/functions/call/built-in/built-in-s-four.js +7 -7
  114. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +1 -2
  115. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +2 -3
  116. package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +1 -1
  117. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +5 -7
  118. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.d.ts +1 -1
  119. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +4 -5
  120. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +8 -9
  121. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +4 -5
  122. package/dataflow/internal/process/functions/call/built-in/built-in-with.js +3 -3
  123. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +36 -38
  124. package/dataflow/internal/process/functions/call/common.d.ts +3 -1
  125. package/dataflow/internal/process/functions/call/common.js +6 -7
  126. package/dataflow/internal/process/functions/call/deferred.js +8 -8
  127. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +11 -4
  128. package/dataflow/internal/process/functions/call/known-call-handling.js +11 -7
  129. package/dataflow/internal/process/functions/call/named-call-handling.js +4 -3
  130. package/dataflow/internal/process/functions/call/nse.js +4 -4
  131. package/dataflow/internal/process/functions/call/quoted.js +16 -14
  132. package/dataflow/internal/process/functions/call/unnamed-call-handling.js +2 -2
  133. package/dataflow/internal/process/functions/process-parameter.js +2 -2
  134. package/dataflow/internal/process/process-named-call.js +1 -1
  135. package/dataflow/origin/dfg-get-origin.js +2 -2
  136. package/dataflow/origin/dfg-get-symbol-refs.d.ts +1 -0
  137. package/dataflow/origin/dfg-get-symbol-refs.js +3 -8
  138. package/documentation/data/faq/wiki-faq-store.js +2 -2
  139. package/documentation/doc-capabilities.js +2 -1
  140. package/documentation/doc-util/doc-functions.js +2 -2
  141. package/documentation/doc-util/doc-repl.js +4 -4
  142. package/documentation/doc-util/doc-types.js +2 -2
  143. package/documentation/wiki-absint.js +2 -1
  144. package/documentation/wiki-cfg.js +2 -1
  145. package/documentation/wiki-create-linting-rules.js +1 -1
  146. package/documentation/wiki-dataflow-graph.js +6 -6
  147. package/documentation/wiki-interface.js +3 -2
  148. package/documentation/wiki-linter.js +54 -4
  149. package/documentation/wiki-mk/doc-maker.js +1 -2
  150. package/documentation/wiki-query.js +25 -0
  151. package/documentation/wiki-search.js +2 -1
  152. package/documentation/wiki-signature-database.js +0 -2
  153. package/linter/linter-executor.js +4 -0
  154. package/linter/linter-rules.d.ts +518 -1
  155. package/linter/linter-rules.js +39 -1
  156. package/linter/linter-tags.d.ts +6 -0
  157. package/linter/linter-tags.js +6 -0
  158. package/linter/rules/absolute-path.js +4 -3
  159. package/linter/rules/cmd-check/bogus-return.d.ts +29 -0
  160. package/linter/rules/cmd-check/bogus-return.js +63 -0
  161. package/linter/rules/cmd-check/call-arguments.d.ts +63 -0
  162. package/linter/rules/cmd-check/call-arguments.js +211 -0
  163. package/linter/rules/cmd-check/class-string-comparison.d.ts +48 -0
  164. package/linter/rules/cmd-check/class-string-comparison.js +135 -0
  165. package/linter/rules/cmd-check/cmd-check-util.d.ts +67 -0
  166. package/linter/rules/cmd-check/cmd-check-util.js +169 -0
  167. package/linter/rules/cmd-check/compiled-code.d.ts +86 -0
  168. package/linter/rules/cmd-check/compiled-code.js +350 -0
  169. package/linter/rules/cmd-check/conformance.d.ts +47 -0
  170. package/linter/rules/cmd-check/conformance.js +166 -0
  171. package/linter/rules/cmd-check/dependency-declaration.d.ts +95 -0
  172. package/linter/rules/cmd-check/dependency-declaration.js +299 -0
  173. package/linter/rules/cmd-check/description-metadata.d.ts +63 -0
  174. package/linter/rules/cmd-check/description-metadata.js +393 -0
  175. package/linter/rules/cmd-check/documentation-mismatch.d.ts +54 -0
  176. package/linter/rules/cmd-check/documentation-mismatch.js +407 -0
  177. package/linter/rules/cmd-check/file-checks.d.ts +29 -0
  178. package/linter/rules/cmd-check/file-checks.js +34 -0
  179. package/linter/rules/cmd-check/foreign-function-calls.d.ts +54 -0
  180. package/linter/rules/cmd-check/foreign-function-calls.js +115 -0
  181. package/linter/rules/cmd-check/global-environment-modification.d.ts +61 -0
  182. package/linter/rules/cmd-check/global-environment-modification.js +237 -0
  183. package/linter/rules/cmd-check/namespace-tampering.d.ts +52 -0
  184. package/linter/rules/cmd-check/namespace-tampering.js +162 -0
  185. package/linter/rules/cmd-check/non-ascii-code.d.ts +51 -0
  186. package/linter/rules/cmd-check/non-ascii-code.js +112 -0
  187. package/linter/rules/cmd-check/package-code.d.ts +30 -0
  188. package/linter/rules/cmd-check/package-code.js +141 -0
  189. package/linter/rules/cmd-check/package-data.d.ts +49 -0
  190. package/linter/rules/cmd-check/package-data.js +181 -0
  191. package/linter/rules/cmd-check/package-files.d.ts +41 -0
  192. package/linter/rules/cmd-check/package-files.js +157 -0
  193. package/linter/rules/cmd-check/package-hooks.d.ts +57 -0
  194. package/linter/rules/cmd-check/package-hooks.js +165 -0
  195. package/linter/rules/cmd-check/package-metafiles.d.ts +49 -0
  196. package/linter/rules/cmd-check/package-metafiles.js +292 -0
  197. package/linter/rules/cmd-check/package-runtime.d.ts +67 -0
  198. package/linter/rules/cmd-check/package-runtime.js +284 -0
  199. package/linter/rules/cmd-check/package-structure.d.ts +85 -0
  200. package/linter/rules/cmd-check/package-structure.js +320 -0
  201. package/linter/rules/cmd-check/rd-files.d.ts +67 -0
  202. package/linter/rules/cmd-check/rd-files.js +621 -0
  203. package/linter/rules/cmd-check/s-three-method-consistency.d.ts +72 -0
  204. package/linter/rules/cmd-check/s-three-method-consistency.js +206 -0
  205. package/linter/rules/cmd-check/true-false-abbreviation.d.ts +45 -0
  206. package/linter/rules/cmd-check/true-false-abbreviation.js +121 -0
  207. package/linter/rules/deprecated-functions.js +4 -4
  208. package/linter/rules/naming-convention.d.ts +1 -1
  209. package/linter/rules/naming-convention.js +13 -14
  210. package/linter/rules/no-leaked-credentials.js +4 -4
  211. package/linter/rules/problematic-inputs.js +2 -1
  212. package/linter/rules/seeded-randomness.js +5 -5
  213. package/linter/rules/software-has-license.d.ts +1 -1
  214. package/linter/rules/software-has-license.js +1 -1
  215. package/linter/rules/unclosed-connection.js +3 -3
  216. package/linter/rules/undefined-symbol-util.js +16 -32
  217. package/linter/rules/undefined-symbol.d.ts +2 -0
  218. package/linter/rules/undefined-symbol.js +33 -3
  219. package/linter/rules/unescaped-arguments.js +10 -9
  220. package/linter/rules/unused-definition.js +13 -19
  221. package/package.json +1 -1
  222. package/project/cache/flowr-analyzer-cache.js +1 -1
  223. package/project/context/flowr-analyzer-context.js +1 -1
  224. package/project/context/flowr-analyzer-environment-context.d.ts +1 -1
  225. package/project/context/flowr-analyzer-files-context.d.ts +6 -0
  226. package/project/context/flowr-analyzer-files-context.js +3 -0
  227. package/project/context/flowr-analyzer-incremental-analysis-context.d.ts +0 -2
  228. package/project/context/flowr-analyzer-incremental-analysis-context.js +0 -4
  229. package/project/context/flowr-file.d.ts +4 -0
  230. package/project/context/flowr-file.js +4 -0
  231. package/project/flowr-analyzer-builder.js +1 -1
  232. package/project/plugins/file-plugins/files/flowr-description-file.js +2 -2
  233. package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +2 -0
  234. package/project/plugins/file-plugins/files/flowr-jupyter-file.js +4 -0
  235. package/project/plugins/file-plugins/files/flowr-manifest-files.d.ts +2 -0
  236. package/project/plugins/file-plugins/files/flowr-manifest-files.js +11 -14
  237. package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +3 -0
  238. package/project/plugins/file-plugins/files/flowr-namespace-file.js +25 -15
  239. package/project/plugins/file-plugins/files/flowr-rd-file.d.ts +44 -0
  240. package/project/plugins/file-plugins/files/flowr-rd-file.js +130 -61
  241. package/project/plugins/file-plugins/files/flowr-rda-file.d.ts +0 -1
  242. package/project/plugins/file-plugins/files/flowr-rda-file.js +4 -16
  243. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +2 -0
  244. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +4 -0
  245. package/project/plugins/file-plugins/files/flowr-sweave-file.d.ts +2 -0
  246. package/project/plugins/file-plugins/files/flowr-sweave-file.js +4 -0
  247. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.d.ts +0 -1
  248. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.js +1 -5
  249. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.d.ts +2 -0
  250. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +2 -0
  251. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-session-info-plugin.js +3 -7
  252. package/project/sigdb/build.js +16 -30
  253. package/project/sigdb/dict.d.ts +4 -6
  254. package/project/sigdb/dict.js +125 -31
  255. package/project/sigdb/reader.js +2 -18
  256. package/project/sigdb/sigdb-download.js +14 -23
  257. package/queries/base-query-format.d.ts +2 -0
  258. package/queries/base-query-format.js +10 -2
  259. package/queries/catalog/absint-query/absint-query-format.d.ts +1 -1
  260. package/queries/catalog/absint-query/absint-query-format.js +5 -7
  261. package/queries/catalog/call-context-query/call-context-query-executor.js +24 -32
  262. package/queries/catalog/call-context-query/call-context-query-format.d.ts +1 -1
  263. package/queries/catalog/call-context-query/call-context-query-format.js +1 -3
  264. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +2 -4
  265. package/queries/catalog/call-context-query/identify-link-to-nested-call-relation.js +1 -4
  266. package/queries/catalog/call-graph-query/call-graph-query-format.js +2 -3
  267. package/queries/catalog/config-query/config-query-format.js +3 -3
  268. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.js +2 -3
  269. package/queries/catalog/dataflow-query/dataflow-query-format.js +2 -3
  270. package/queries/catalog/dependencies-query/data-flow.d.ts +43 -0
  271. package/queries/catalog/dependencies-query/data-flow.js +173 -0
  272. package/queries/catalog/dependencies-query/dependencies-query-executor.d.ts +18 -0
  273. package/queries/catalog/dependencies-query/dependencies-query-executor.js +108 -12
  274. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +17 -1
  275. package/queries/catalog/dependencies-query/dependencies-query-format.js +14 -11
  276. package/queries/catalog/dependencies-query/function-info/derived-functions.js +2 -1
  277. package/queries/catalog/dependencies-query/function-info/function-info.d.ts +2 -0
  278. package/queries/catalog/dependencies-query/function-info/library-functions.js +13 -13
  279. package/queries/catalog/dependencies-query/function-info/read-functions.js +1 -1
  280. package/queries/catalog/dependencies-query/function-info/remote-functions.js +3 -3
  281. package/queries/catalog/dependencies-query/function-info/source-functions.js +2 -2
  282. package/queries/catalog/dependencies-query/function-info/test-functions.js +8 -8
  283. package/queries/catalog/dependencies-query/function-info/transform-functions.d.ts +8 -0
  284. package/queries/catalog/dependencies-query/function-info/transform-functions.js +17 -0
  285. package/queries/catalog/dependencies-query/function-info/write-functions.js +4 -0
  286. package/queries/catalog/dependencies-query/implicit-echo.d.ts +5 -3
  287. package/queries/catalog/dependencies-query/implicit-echo.js +33 -34
  288. package/queries/catalog/dependencies-query/link-devices.d.ts +3 -2
  289. package/queries/catalog/dependencies-query/link-devices.js +9 -6
  290. package/queries/catalog/dependencies-query/plot-description.d.ts +10 -0
  291. package/queries/catalog/dependencies-query/plot-description.js +119 -0
  292. package/queries/catalog/dependencies-query/plot-objects.d.ts +13 -0
  293. package/queries/catalog/dependencies-query/plot-objects.js +61 -0
  294. package/queries/catalog/dice-query/dice-query-format.d.ts +2 -2
  295. package/queries/catalog/dice-query/dice-query-format.js +3 -40
  296. package/queries/catalog/does-call-query/does-call-query-format.d.ts +1 -1
  297. package/queries/catalog/does-call-query/does-call-query-format.js +2 -2
  298. package/queries/catalog/function-info-query/function-info-query-format.js +2 -2
  299. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +2 -1
  300. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +2 -2
  301. package/queries/catalog/happens-before-query/happens-before-query-format.js +2 -2
  302. package/queries/catalog/id-map-query/id-map-query-format.js +1 -3
  303. package/queries/catalog/input-sources-query/input-sources-query-executor.js +2 -2
  304. package/queries/catalog/input-sources-query/input-sources-query-format.js +2 -3
  305. package/queries/catalog/input-sources-query/simple-input-classifier.js +28 -29
  306. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +4 -7
  307. package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-executor.js +1 -1
  308. package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.js +3 -2
  309. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.js +2 -2
  310. package/queries/catalog/linter-query/linter-query-executor.js +10 -3
  311. package/queries/catalog/linter-query/linter-query-format.d.ts +4 -1
  312. package/queries/catalog/linter-query/linter-query-format.js +32 -21
  313. package/queries/catalog/location-map-query/location-map-query-format.d.ts +1 -1
  314. package/queries/catalog/location-map-query/location-map-query-format.js +1 -3
  315. package/queries/catalog/normalized-ast-query/normalized-ast-query-format.js +2 -3
  316. package/queries/catalog/origin-query/origin-query-executor.d.ts +1 -1
  317. package/queries/catalog/origin-query/origin-query-executor.js +3 -3
  318. package/queries/catalog/origin-query/origin-query-format.d.ts +1 -1
  319. package/queries/catalog/origin-query/origin-query-format.js +4 -5
  320. package/queries/catalog/project-query/project-query-format.js +2 -2
  321. package/queries/catalog/provenance-query/provenance-query-format.js +2 -3
  322. package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +1 -1
  323. package/queries/catalog/resolve-value-query/resolve-value-query-format.js +4 -4
  324. package/queries/catalog/search-query/search-query-format.js +1 -3
  325. package/queries/catalog/signature-query/signature-query-executor.js +3 -3
  326. package/queries/catalog/signature-query/signature-query-format.js +2 -2
  327. package/queries/catalog/slice-query-options.d.ts +16 -0
  328. package/queries/catalog/slice-query-options.js +28 -0
  329. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +2 -2
  330. package/queries/catalog/static-slice-query/static-slice-query-format.js +3 -42
  331. package/queries/query-print.d.ts +4 -0
  332. package/queries/query-print.js +17 -1
  333. package/queries/query.d.ts +3 -3
  334. package/queries/query.js +3 -4
  335. package/r-bridge/lang-4.x/ast/model/model.d.ts +27 -3
  336. package/r-bridge/lang-4.x/ast/model/model.js +28 -1
  337. package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.d.ts +1 -0
  338. package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.js +1 -0
  339. package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +2 -0
  340. package/r-bridge/lang-4.x/ast/model/nodes/r-access.js +1 -0
  341. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +20 -1
  342. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.js +25 -1
  343. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +2 -0
  344. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.js +1 -0
  345. package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +2 -0
  346. package/r-bridge/lang-4.x/ast/model/nodes/r-break.js +1 -0
  347. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +2 -0
  348. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.js +1 -0
  349. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +2 -0
  350. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.js +1 -0
  351. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +2 -0
  352. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.js +1 -0
  353. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +18 -2
  354. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +15 -6
  355. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +2 -0
  356. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.js +1 -0
  357. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +2 -0
  358. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.js +1 -0
  359. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +2 -0
  360. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.js +1 -0
  361. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +2 -0
  362. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.js +1 -0
  363. package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +2 -0
  364. package/r-bridge/lang-4.x/ast/model/nodes/r-next.js +1 -0
  365. package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +2 -0
  366. package/r-bridge/lang-4.x/ast/model/nodes/r-number.js +1 -0
  367. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +2 -0
  368. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.js +1 -0
  369. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +2 -0
  370. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.js +1 -0
  371. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +2 -0
  372. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.js +1 -0
  373. package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +17 -0
  374. package/r-bridge/lang-4.x/ast/model/nodes/r-string.js +20 -0
  375. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +2 -0
  376. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.js +1 -0
  377. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +2 -0
  378. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.js +1 -0
  379. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +2 -0
  380. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.js +1 -0
  381. package/r-bridge/lang-4.x/ast/model/operators.js +0 -2
  382. package/r-bridge/lang-4.x/ast/model/processing/decorate.js +1 -6
  383. package/r-bridge/lang-4.x/ast/model/processing/fold.js +1 -6
  384. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +4 -3
  385. package/r-bridge/lang-4.x/ast/parser/json/format.js +2 -2
  386. package/r-bridge/lang-4.x/ast/parser/main/internal/control/normalize-if-then.js +1 -5
  387. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-argument.js +2 -2
  388. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.js +4 -20
  389. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-definition.js +1 -5
  390. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-next.js +1 -5
  391. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-repeat.js +1 -5
  392. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-while.js +2 -9
  393. package/r-bridge/lang-4.x/ast/parser/main/internal/normalize-access.js +1 -5
  394. package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-binary.js +2 -10
  395. package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-unary.js +2 -11
  396. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-expressions.js +3 -11
  397. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-number.js +1 -5
  398. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-string.js +1 -5
  399. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-symbol.js +1 -5
  400. package/r-bridge/lang-4.x/ast/parser/main/normalize-meta.d.ts +6 -1
  401. package/r-bridge/lang-4.x/ast/parser/main/normalize-meta.js +7 -0
  402. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.d.ts +0 -10
  403. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +30 -82
  404. package/r-bridge/retriever.d.ts +0 -4
  405. package/r-bridge/retriever.js +0 -13
  406. package/r-bridge/roxygen2/documentation-provider.js +3 -7
  407. package/r-bridge/shell.js +3 -8
  408. package/reconstruct/auto-select/magic-comments.js +8 -7
  409. package/reconstruct/inline/source-inline-map.d.ts +3 -0
  410. package/reconstruct/inline/source-inline-map.js +8 -7
  411. package/reconstruct/reconstruct.d.ts +1 -1
  412. package/reconstruct/reconstruct.js +33 -109
  413. package/search/flowr-search-printer.js +4 -15
  414. package/search/search-executor/search-generators.js +1 -1
  415. package/slicing/criterion/filters/all-variables.js +1 -2
  416. package/slicing/static/fingerprint.js +11 -2
  417. package/slicing/static/slice-call.d.ts +2 -8
  418. package/slicing/static/slice-call.js +8 -18
  419. package/slicing/static/static-slicer.js +81 -6
  420. package/util/collections/arrays.js +1 -1
  421. package/util/collections/set.js +1 -1
  422. package/util/diff-graph.d.ts +4 -0
  423. package/util/diff-graph.js +12 -0
  424. package/util/files.js +2 -6
  425. package/util/json.js +1 -15
  426. package/util/mermaid/cfg.js +10 -17
  427. package/util/mermaid/dfg.js +6 -8
  428. package/util/objects.d.ts +1 -1
  429. package/util/quads.js +4 -13
  430. package/util/r-author.js +5 -5
  431. package/util/range.d.ts +9 -0
  432. package/util/range.js +11 -0
  433. package/util/schema.js +3 -3
  434. package/util/simple-df/dfg-view.js +2 -1
  435. package/util/text/ansi.js +1 -2
  436. package/util/text/playground-link.js +2 -1
  437. package/util/text/r-highlight.js +2 -1
  438. package/util/text/strings.d.ts +2 -0
  439. package/util/text/strings.js +5 -0
  440. package/util/text/time.js +1 -2
  441. package/util/version.js +4 -3
  442. package/dataflow/fn/recursive-function.d.ts +0 -6
  443. package/dataflow/fn/recursive-function.js +0 -32
  444. package/dataflow/internal/process/functions/call/argument/unpack-argument.d.ts +0 -16
  445. package/dataflow/internal/process/functions/call/argument/unpack-argument.js +0 -27
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.DependenciesQueryDefinition = exports.defaultDependencyCategories = exports.DefaultDependencyCategoryNames = exports.Attached = exports.Constant = exports.Unknown = void 0;
7
7
  exports.getAllCategories = getAllCategories;
8
8
  exports.getAllCategoryNames = getAllCategoryNames;
9
+ const query_print_1 = require("../../query-print");
9
10
  const ansi_1 = require("../../../util/text/ansi");
10
- const time_1 = require("../../../util/text/time");
11
11
  const joi_1 = __importDefault(require("joi"));
12
12
  const dependencies_query_executor_1 = require("./dependencies-query-executor");
13
13
  const library_functions_1 = require("./function-info/library-functions");
@@ -16,6 +16,7 @@ const remote_functions_1 = require("./function-info/remote-functions");
16
16
  const read_functions_1 = require("./function-info/read-functions");
17
17
  const write_functions_1 = require("./function-info/write-functions");
18
18
  const visualize_functions_1 = require("./function-info/visualize-functions");
19
+ const transform_functions_1 = require("./function-info/transform-functions");
19
20
  const statistics_functions_1 = require("./function-info/statistics-functions");
20
21
  const test_functions_1 = require("./function-info/test-functions");
21
22
  const identifier_1 = require("../../../dataflow/environments/identifier");
@@ -24,6 +25,7 @@ const model_1 = require("../../../r-bridge/lang-4.x/ast/model/model");
24
25
  const objects_1 = require("../../../util/objects");
25
26
  const r_symbol_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
26
27
  const implicit_echo_1 = require("./implicit-echo");
28
+ const arrays_1 = require("../../../util/collections/arrays");
27
29
  /** The value could not be resolved, e.g. a path assembled at runtime. Such a dependency may be missing or fetchable. */
28
30
  exports.Unknown = 'unknown';
29
31
  /** The value resolved, but to data given inline rather than to a path (`matrix(0, 2, 2)`, `data.frame(a = 1)`). */
@@ -31,7 +33,7 @@ exports.Constant = 'constant';
31
33
  /** {@link DependencyInfo#functionName} for an assumed base package: nothing in the code names it, so there is no call to report as `functionName`. */
32
34
  exports.Attached = '<attached>';
33
35
  /** the built-in categories; what each searches for is derived per configuration, see {@link defaultDependencyCategories} */
34
- exports.DefaultDependencyCategoryNames = ['library', 'remote', 'source', 'read', 'write', 'visualize', 'test', 'statistics'];
36
+ exports.DefaultDependencyCategoryNames = ['library', 'remote', 'source', 'read', 'write', 'visualize', 'transform', 'test', 'statistics'];
35
37
  /**
36
38
  * The categories flowR searches for by default. The functions of the categories flowR derives from its
37
39
  * built-ins follow the ones the analyzer registered, so a configured built-in is searched for and a dropped
@@ -100,18 +102,20 @@ const dependencyCategoriesOf = (env) => ({
100
102
  return;
101
103
  }
102
104
  const [ast, dataflow] = await Promise.all([data.analyzer.normalize(), data.analyzer.dataflow()]);
103
- /* a call another category reports belongs to that category, except for a statistical test: what it
104
- is asked for is the statistic it prints, so a top-level one is an output like any other */
105
- const accountedFor = new Set(Object.entries(queryResults?.kinds ?? {})
106
- .filter(([kind]) => kind !== 'statistics')
107
- .flatMap(([, k]) => Object.values(k.subkinds).flat()).map(r => r.id));
108
- (0, implicit_echo_1.collectImplicitEchoes)(ast, dataflow, accountedFor, result);
105
+ /* a call reported as an output already is not repeated, any other still prints a visible result */
106
+ const accountedFor = new Set(Object.values(queryResults?.kinds['write']?.subkinds ?? {}).flat().map(r => r.id));
107
+ const invisible = Object.values((0, exports.defaultDependencyCategories)(data.analyzer.inspectContext())).flatMap(c => c.functions.filter(f => f.invisible));
108
+ (0, implicit_echo_1.collectImplicitEchoes)(ast, dataflow, accountedFor, invisible, result);
109
109
  }
110
110
  },
111
111
  'visualize': {
112
112
  queryDisplayName: 'Visualizations',
113
113
  functions: visualize_functions_1.VisualizeFunctions
114
114
  },
115
+ 'transform': {
116
+ queryDisplayName: 'Data Transformations',
117
+ functions: (0, transform_functions_1.transformFunctions)(env.builtInIndex)
118
+ },
115
119
  'test': {
116
120
  queryDisplayName: 'Tests',
117
121
  functions: test_functions_1.TestFunctions
@@ -165,8 +169,7 @@ function getAllCategories(queries, ctx) {
165
169
  }
166
170
  /** every category a set of queries reports on, which is what the results are keyed by; no built-in has to be read for that */
167
171
  function getAllCategoryNames(queries) {
168
- return [...new Set([...exports.DefaultDependencyCategoryNames,
169
- ...queries.flatMap(query => Object.keys(query.additionalCategories ?? {}))])];
172
+ return (0, arrays_1.uniqueArrayMerge)(exports.DefaultDependencyCategoryNames, queries.flatMap(query => Object.keys(query.additionalCategories ?? {})));
170
173
  }
171
174
  const functionInfoSchema = joi_1.default.array().items(joi_1.default.object({
172
175
  name: joi_1.default.string().required().description('The name of the library function.'),
@@ -179,7 +182,7 @@ exports.DependenciesQueryDefinition = {
179
182
  executor: dependencies_query_executor_1.executeDependenciesQuery,
180
183
  asciiSummarizer: (formatter, analyzer, queryResults, result, queries) => {
181
184
  const out = queryResults;
182
- result.push(`Query: ${(0, ansi_1.bold)('dependencies', formatter)} (${(0, time_1.printAsMs)(out['.meta'].timing, 0)})`);
185
+ result.push((0, query_print_1.queryHeader)('dependencies', formatter, out['.meta'].timing));
183
186
  for (const [category, value] of Object.entries(getAllCategories(queries, analyzer.inspectContext()))) {
184
187
  printResultSection(value.queryDisplayName ?? category, out[category] ?? [], result, formatter);
185
188
  }
@@ -42,7 +42,8 @@ function functionInfosFromProps(props, except, definitions) {
42
42
  const name = identifier_1.Identifier.getName(id);
43
43
  const pkg = identifier_1.Identifier.getNamespace(id);
44
44
  if (!takenEverywhere.has(name) && !taken.has(pkg === undefined ? name : `${pkg}::${name}`)) {
45
- found.push({ package: pkg, name, argIdx, argName: info.sig[argIdx][0], resolveValue: true });
45
+ found.push({ package: pkg, name, argIdx, argName: info.sig[argIdx][0], resolveValue: true,
46
+ ...function_semantics_1.FunctionSemantics.call.props.hasAny(info, [built_in_props_1.CallProp.Invisible]) ? { invisible: true } : {} });
46
47
  }
47
48
  }
48
49
  }
@@ -34,4 +34,6 @@ export interface FunctionInfo extends FunctionArgInfo {
34
34
  additionalArgs?: Record<string, FunctionArgInfo>;
35
35
  /** string replacements to apply to resolved values, e.g. `{ '': 'stdin' }` */
36
36
  stringReplacements?: Record<string, string>;
37
+ /** the call hands back its result invisibly, so a top-level one prints nothing, even with its package not loaded */
38
+ invisible?: true;
37
39
  }
@@ -13,20 +13,20 @@ exports.LibraryFunctions = [
13
13
  /* what is attached here is a list or a data frame, never a package */
14
14
  { package: 'base', name: 'attach', argIdx: 0, argName: 'what', resolveValue: true, attaches: false },
15
15
  { package: 'base', name: 'use', argIdx: 0, argName: 'package', resolveValue: 'library', attaches: true },
16
- { package: 'groundhog', name: 'groundhog.library', argIdx: 0, argName: 'pkg', resolveValue: true, attaches: true },
17
- { package: 'pacman', name: 'p_load', argIdx: 'unnamed', resolveValue: 'library', attaches: true },
18
- { package: 'pacman', name: 'p_load_gh', argIdx: 'unnamed', resolveValue: 'library', attaches: true },
19
- { package: 'pacman', name: 'p_load_current_gh', argIdx: 'unnamed', resolveValue: 'library', attaches: true },
20
- { package: 'xfun', name: 'pkg_attach', argIdx: 'unnamed', resolveValue: true, attaches: true },
21
- { package: 'xfun', name: 'pkg_attach2', argIdx: 'unnamed', resolveValue: true, attaches: true },
22
- { package: 'needs', name: 'needs', argIdx: 'unnamed', resolveValue: 'library', attaches: true },
23
- { package: 'modules', name: 'import', argIdx: 0, argName: 'from', resolveValue: 'library', attaches: true },
24
- { package: 'easypackages', name: 'from_import', argIdx: 0, argName: 'package', resolveValue: true, attaches: true },
25
- { package: 'easypackages', name: 'libraries', argIdx: 'unnamed', resolveValue: true, attaches: true },
26
- { package: 'librarian', name: 'shelf', argIdx: 'unnamed', resolveValue: true, attaches: true },
27
- { package: 'devtools', name: 'load_all', argIdx: 0, argName: 'path', resolveValue: true, defaultValue: '.', attaches: true },
16
+ { package: 'groundhog', name: 'groundhog.library', argIdx: 0, argName: 'pkg', resolveValue: true, attaches: true, invisible: true },
17
+ { package: 'pacman', name: 'p_load', argIdx: 'unnamed', resolveValue: 'library', attaches: true, invisible: true },
18
+ { package: 'pacman', name: 'p_load_gh', argIdx: 'unnamed', resolveValue: 'library', attaches: true, invisible: true },
19
+ { package: 'pacman', name: 'p_load_current_gh', argIdx: 'unnamed', resolveValue: 'library', attaches: true, invisible: true },
20
+ { package: 'xfun', name: 'pkg_attach', argIdx: 'unnamed', resolveValue: true, attaches: true, invisible: true },
21
+ { package: 'xfun', name: 'pkg_attach2', argIdx: 'unnamed', resolveValue: true, attaches: true, invisible: true },
22
+ { package: 'needs', name: 'needs', argIdx: 'unnamed', resolveValue: 'library', attaches: true, invisible: true },
23
+ { package: 'modules', name: 'import', argIdx: 0, argName: 'from', resolveValue: 'library', attaches: true, invisible: true },
24
+ { package: 'easypackages', name: 'from_import', argIdx: 0, argName: 'package', resolveValue: true, attaches: true, invisible: true },
25
+ { package: 'easypackages', name: 'libraries', argIdx: 'unnamed', resolveValue: true, attaches: true, invisible: true },
26
+ { package: 'librarian', name: 'shelf', argIdx: 'unnamed', resolveValue: true, attaches: true, invisible: true },
27
+ { package: 'devtools', name: 'load_all', argIdx: 0, argName: 'path', resolveValue: true, defaultValue: '.', attaches: true, invisible: true },
28
28
  /* the code of a package is loaded into its namespace, and nothing is put on the search path */
29
- { package: 'pkgload', name: 'load_code', argIdx: 0, argName: 'path', resolveValue: true, defaultValue: '.', attaches: false },
29
+ { package: 'pkgload', name: 'load_code', argIdx: 0, argName: 'path', resolveValue: true, defaultValue: '.', attaches: false, invisible: true },
30
30
  { package: 'import', name: 'from', argIdx: 0, argName: 'package', resolveValue: true, attaches: true },
31
31
  /* a hook that runs when the package is loaded by someone else, which loads nothing itself */
32
32
  { package: 'rlang', name: 'on_package_load', argIdx: 0, argName: 'pkg', resolveValue: true, attaches: false }
@@ -40,7 +40,7 @@ const ReadFunctionsWithMore = [
40
40
  { package: 'rpolars', name: 'pl_scan_ndjson', argIdx: 0, argName: 'source', resolveValue: true, ignoreIf: 'arg-missing' },
41
41
  { package: 'rpolars', name: 'pl_scan_parquet', argIdx: 0, argName: 'source', resolveValue: true, ignoreIf: 'arg-missing' },
42
42
  { package: 'compiler', name: 'loadcmp', argIdx: 0, argName: 'file', resolveValue: true },
43
- { package: 'compiler', name: 'cmpfile', argIdx: 0, argName: 'infile', resolveValue: true },
43
+ { package: 'compiler', name: 'cmpfile', argIdx: 0, argName: 'infile', resolveValue: true, invisible: true },
44
44
  { package: 'yaml', name: 'read_yaml', argIdx: 0, argName: 'file', resolveValue: true, ignoreIf: 'arg-set', additionalArgs: { argSet: { argName: 'text' } } },
45
45
  { package: 'shinyjs', name: 'extendShinyjs', argIdx: 0, argName: 'script', resolveValue: true, ignoreIf: 'arg-missing' }
46
46
  ];
@@ -17,9 +17,9 @@ exports.RemoteFunctions = [
17
17
  { name: 'install_svn', argIdx: 0, argName: 'url', resolveValue: true },
18
18
  { name: 'install_url', argIdx: 0, argName: 'url', resolveValue: true },
19
19
  { name: 'install_bioc', argIdx: 0, argName: 'repo', resolveValue: true },
20
- { package: 'pak', name: 'pkg_install', argIdx: 0, argName: 'pkg', resolveValue: true },
21
- { package: 'pak', name: 'pak', argIdx: 0, argName: 'pkg', resolveValue: true },
22
- { package: 'renv', name: 'install', argIdx: 0, argName: 'packages', resolveValue: true }
20
+ { package: 'pak', name: 'pkg_install', argIdx: 0, argName: 'pkg', resolveValue: true, invisible: true },
21
+ { package: 'pak', name: 'pak', argIdx: 0, argName: 'pkg', resolveValue: true, invisible: true },
22
+ { package: 'renv', name: 'install', argIdx: 0, argName: 'packages', resolveValue: true, invisible: true }
23
23
  ];
24
24
  /** `github::`, `bioc::`, ... prefixes of a `pak` reference, and the `.git` a clone url ends in */
25
25
  const RemotePrefix = /^[a-z]+::/;
@@ -5,7 +5,7 @@ exports.SourceFunctions = void 0;
5
5
  exports.SourceFunctions = [
6
6
  { package: 'base', name: 'source', argIdx: 0, argName: 'file', resolveValue: true, stringReplacements: { '': 'stdin' } },
7
7
  { package: 'base', name: 'sys.source', argIdx: 0, argName: 'file', resolveValue: true },
8
- { package: 'devtools', name: 'source_url', argIdx: 0, argName: 'url', resolveValue: true },
9
- { package: 'devtools', name: 'source_gist', argIdx: 0, argName: 'id', resolveValue: true }
8
+ { package: 'devtools', name: 'source_url', argIdx: 0, argName: 'url', resolveValue: true, invisible: true },
9
+ { package: 'devtools', name: 'source_gist', argIdx: 0, argName: 'id', resolveValue: true, invisible: true }
10
10
  ];
11
11
  //# sourceMappingURL=source-functions.js.map
@@ -41,19 +41,19 @@ const ContextFunctions = {
41
41
  callName: new RegExp('^(context)$')
42
42
  };
43
43
  exports.TestFunctions = [
44
- { package: 'testthat', name: 'test_that', argName: 'desc', argIdx: 0, resolveValue: true, linkTo: [exports.ExpectFunctions, ContextFunctions] },
45
- { package: 'testthat', name: 'describe', argName: 'description', argIdx: 0, resolveValue: true, linkTo: [exports.ExpectFunctions, ContextFunctions] },
46
- { package: 'testthat', name: 'it', argName: 'description', argIdx: 0, resolveValue: true, linkTo: [exports.ExpectFunctions, ContextFunctions] },
47
- { package: 'testthat', name: 'test_file' },
48
- { package: 'testthat', name: 'test_dir' },
49
- { package: 'testthat', name: 'test_package' },
44
+ { package: 'testthat', name: 'test_that', argName: 'desc', argIdx: 0, resolveValue: true, linkTo: [exports.ExpectFunctions, ContextFunctions], invisible: true },
45
+ { package: 'testthat', name: 'describe', argName: 'description', argIdx: 0, resolveValue: true, linkTo: [exports.ExpectFunctions, ContextFunctions], invisible: true },
46
+ { package: 'testthat', name: 'it', argName: 'description', argIdx: 0, resolveValue: true, linkTo: [exports.ExpectFunctions, ContextFunctions], invisible: true },
47
+ { package: 'testthat', name: 'test_file', invisible: true },
48
+ { package: 'testthat', name: 'test_dir', invisible: true },
49
+ { package: 'testthat', name: 'test_package', invisible: true },
50
50
  { package: 'tinytest', name: 'run_test_dir' },
51
51
  { package: 'tinytest', name: 'run_test_file' },
52
52
  { package: 'tinytest', name: 'test_all' },
53
53
  { package: 'tinytest', name: 'test_package' },
54
- { package: 'testit', name: 'test_pkg' },
54
+ { package: 'testit', name: 'test_pkg', invisible: true },
55
55
  { package: 'RUnit', name: 'runTestSuite' },
56
56
  { package: 'RUnit', name: 'runTestFile' },
57
- { package: 'RUnit', name: 'defineTestSuite' },
57
+ { package: 'RUnit', name: 'defineTestSuite', invisible: true },
58
58
  ];
59
59
  //# sourceMappingURL=test-functions.js.map
@@ -0,0 +1,8 @@
1
+ import type { FunctionInfo } from './function-info';
2
+ import type { BuiltInIndex } from '../../../../dataflow/environments/query-fn-props';
3
+ /**
4
+ * The calls that reshape, filter, join or aggregate data, read back from the {@link SemanticCallTag.Transforms}
5
+ * built-ins. Every one of them names its package, so `filter` only counts when it resolves to dplyr and never
6
+ * for the time-series `stats::filter`. Label a built-in `Transforms` and it shows up here.
7
+ */
8
+ export declare function transformFunctions(index: BuiltInIndex): FunctionInfo[];
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.transformFunctions = transformFunctions;
4
+ const identifier_1 = require("../../../../dataflow/environments/identifier");
5
+ const built_in_props_1 = require("../../../../dataflow/environments/built-in-props");
6
+ /**
7
+ * The calls that reshape, filter, join or aggregate data, read back from the {@link SemanticCallTag.Transforms}
8
+ * built-ins. Every one of them names its package, so `filter` only counts when it resolves to dplyr and never
9
+ * for the time-series `stats::filter`. Label a built-in `Transforms` and it shows up here.
10
+ */
11
+ function transformFunctions(index) {
12
+ return index.with(built_in_props_1.SemanticCallTag.Transforms).map(call => ({
13
+ name: identifier_1.Identifier.getName(call),
14
+ package: identifier_1.Identifier.getNamespace(call)
15
+ }));
16
+ }
17
+ //# sourceMappingURL=transform-functions.js.map
@@ -7,6 +7,7 @@ const function_info_1 = require("./function-info");
7
7
  const built_in_props_1 = require("../../../../dataflow/environments/built-in-props");
8
8
  const derived_functions_1 = require("./derived-functions");
9
9
  const other_path_functions_1 = require("./other-path-functions");
10
+ const default_builtin_config_1 = require("../../../../dataflow/environments/default-builtin-config");
10
11
  const read_functions_1 = require("./read-functions");
11
12
  const OutputRedirects = [
12
13
  { type: 'link-to-last-call', callName: 'sink', attachLinkInfo: { argIdx: 0, argName: 'file', when: function_info_1.DependencyInfoLinkConstraint.IfUnknown, resolveValue: true } }
@@ -14,6 +15,8 @@ const OutputRedirects = [
14
15
  const WriteFunctionsWithMore = [
15
16
  { package: 'base', name: 'save.image', argIdx: 0, argName: 'file', resolveValue: true, defaultValue: '.RData' },
16
17
  { package: 'utils', name: 'write.csv', argIdx: 1, argName: 'file', resolveValue: true },
18
+ /* without a `plot`, it saves `last_plot()` */
19
+ { package: 'ggplot2', name: 'ggsave', argIdx: 0, argName: 'filename', resolveValue: true, linkTo: [default_builtin_config_1.LinkToLastGgPlot] },
17
20
  {
18
21
  package: 'base',
19
22
  name: 'try',
@@ -29,6 +32,7 @@ const WriteFunctionsWithMore = [
29
32
  },
30
33
  // write functions that don't have argIndex are assumed to write to stdout
31
34
  { package: 'base', name: 'print', linkTo: OutputRedirects, resolveValue: false },
35
+ { package: 'graphics', name: 'stem', linkTo: OutputRedirects, resolveValue: false },
32
36
  { package: 'base', name: 'cat', linkTo: OutputRedirects, argName: 'file', resolveValue: true },
33
37
  { package: 'base', name: 'message', linkTo: OutputRedirects, resolveValue: false },
34
38
  { package: 'base', name: 'warning', linkTo: OutputRedirects, resolveValue: false },
@@ -2,12 +2,14 @@ import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/nod
2
2
  import type { NormalizedAst } from '../../../r-bridge/lang-4.x/ast/model/processing/decorate';
3
3
  import type { DataflowInformation } from '../../../dataflow/info';
4
4
  import type { DependencyInfo } from './dependencies-query-format';
5
+ import type { FunctionInfo } from './function-info/function-info';
5
6
  /**
6
7
  * Collects what the top level of the analyzed code prints on its own (as {@link DependencyInfo#implicit}
7
8
  * outputs), given that it is echoed at all
8
9
  * (`project.assumeImplicitEcho`). A statement is only an output if its value is visible: an assignment, a loop,
9
10
  * and every {@link CallProp.Invisible} call hand back their result invisibly, while a bare symbol, a constant,
10
- * or an ordinary call reaches stdout. Calls another category already reports (a plot, a write, an assertion)
11
- * are left to it.
11
+ * or an ordinary call reaches stdout, unless it is one of the `invisible` dependency functions (which hold even for a
12
+ * package that is not loaded). Calls already reported as outputs are not repeated, and a printed plot draws instead
13
+ * (a lone ggplot component is no plot and is printed).
12
14
  */
13
- export declare function collectImplicitEchoes(ast: NormalizedAst, dataflow: DataflowInformation, accountedFor: ReadonlySet<NodeId>, result: DependencyInfo[]): void;
15
+ export declare function collectImplicitEchoes(ast: NormalizedAst, dataflow: DataflowInformation, accountedFor: ReadonlySet<NodeId>, invisible: readonly FunctionInfo[], result: DependencyInfo[]): void;
@@ -10,14 +10,14 @@ const r_function_call_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-
10
10
  const r_argument_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
11
11
  const r_comment_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-comment");
12
12
  const r_line_directive_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-line-directive");
13
- const vertex_1 = require("../../../dataflow/graph/vertex");
14
- const edge_1 = require("../../../dataflow/graph/edge");
15
13
  const df_helper_1 = require("../../../dataflow/graph/df-helper");
16
14
  const query_fn_props_1 = require("../../../dataflow/environments/query-fn-props");
17
15
  const built_in_props_1 = require("../../../dataflow/environments/built-in-props");
16
+ const built_in_ambient_state_1 = require("../../../dataflow/internal/process/functions/call/built-in/built-in-ambient-state");
17
+ const plot_objects_1 = require("./plot-objects");
18
18
  const test_functions_1 = require("./function-info/test-functions");
19
19
  /** the node whose value R echoes for a statement, `undefined` if the statement yields nothing visible */
20
- function echoedValue(node, dataflow) {
20
+ function echoedValue(node, dataflow, invisible) {
21
21
  switch (node?.type) {
22
22
  /* the loops hand back an invisible NULL, and the jumps never hand back anything at all */
23
23
  case undefined:
@@ -30,22 +30,22 @@ function echoedValue(node, dataflow) {
30
30
  case type_1.RType.LineDirective:
31
31
  return undefined;
32
32
  case type_1.RType.FunctionCall: {
33
- if (callName(node, dataflow) === undefined) {
33
+ if (callName(node, dataflow, invisible) === undefined) {
34
34
  return undefined;
35
35
  }
36
- const handedOn = aliased(node, dataflow);
37
- return handedOn === undefined ? node : echoedValue(handedOn, dataflow);
36
+ const handedOn = aliased(node, dataflow, invisible);
37
+ return handedOn === undefined ? node : echoedValue(handedOn, dataflow, invisible);
38
38
  }
39
39
  /* a block hands on the value of its last statement, a `( )` group that of what it holds, visibly:
40
40
  which is what makes `(x <- 1)` print what it assigned */
41
41
  case type_1.RType.ExpressionList:
42
42
  return grouped(node) ? lastStatement(node) ?? node
43
- : echoedValue(lastStatement(node), dataflow) ?? (node.children.length === 0 ? node : undefined);
43
+ : echoedValue(lastStatement(node), dataflow, invisible) ?? (node.children.length === 0 ? node : undefined);
44
44
  case type_1.RType.Pipe:
45
- return echoedValue(node.rhs, dataflow);
45
+ return echoedValue(node.rhs, dataflow, invisible);
46
46
  /* whichever branch runs decides; without an `else` a false condition yields an invisible NULL */
47
47
  case type_1.RType.IfThenElse:
48
- return echoedValue(node.then, dataflow) ?? echoedValue(node.otherwise, dataflow);
48
+ return echoedValue(node.then, dataflow, invisible) ?? echoedValue(node.otherwise, dataflow, invisible);
49
49
  case type_1.RType.BinaryOp:
50
50
  return r_binary_op_1.RBinaryOp.getOperatorInfo(node)?.usedAs === 'assignment' ? undefined : node;
51
51
  /* a symbol, a constant, an access, a unary operator, or a function definition is printed as it stands */
@@ -61,8 +61,8 @@ function grouped(node) {
61
61
  * The call whose result this one hands back unchanged, as its {@link ArgProp.Alias} argument states: a pipe
62
62
  * is visible exactly when the call it feeds is. `undefined` when the call answers for itself.
63
63
  */
64
- function aliased(node, dataflow) {
65
- const name = callName(node, dataflow);
64
+ function aliased(node, dataflow, invisible) {
65
+ const name = callName(node, dataflow, invisible);
66
66
  const at = name === undefined ? -1 : (0, query_fn_props_1.queryFnProps)(name, { environment: dataflow.environment })?.sig
67
67
  ?.findIndex(([, p]) => (p & built_in_props_1.ArgProp.Alias) !== 0) ?? -1;
68
68
  const arg = at < 0 ? undefined : node.arguments[at];
@@ -80,37 +80,35 @@ function lastStatement(node) {
80
80
  }
81
81
  return undefined;
82
82
  }
83
- /** the name the call goes by, with its package when it has one */
84
- function qualifiedName(node, dataflow) {
85
- const vertex = dataflow.graph.getVertex(node.info.id);
86
- return vertex_1.DfgVertex.isFunctionCall(vertex)
87
- ? df_helper_1.Dataflow.qualify(node.info.id, dataflow.graph, false) ?? vertex.name : undefined;
88
- }
89
- function callName(node, dataflow, seen = new Set()) {
90
- const name = qualifiedName(node, dataflow);
83
+ function callName(node, dataflow, invisible, seen = new Set()) {
84
+ const name = (0, plot_objects_1.callIdentifierOf)(node, dataflow);
91
85
  if (name === undefined) {
92
86
  return undefined;
93
87
  }
94
88
  const props = (0, query_fn_props_1.queryFnProps)(name, { environment: dataflow.environment });
95
- return function_semantics_1.FunctionSemantics.call.props.hasAny(props, [built_in_props_1.CallProp.Invisible, built_in_props_1.SemanticCallTag.Graphics]) || test_functions_1.ExpectFunctionNames.test(identifier_1.Identifier.getName(name))
96
- || (props === undefined && returnsInvisibly(node.info.id, dataflow, seen)) ? undefined : name;
89
+ /* a setter hands back the previous state invisibly, but queried, the state is what it returns */
90
+ const hidden = function_semantics_1.FunctionSemantics.call.props.hasAny(props, [built_in_props_1.CallProp.Invisible]) && !(0, built_in_ambient_state_1.callOnlyQueries)(name, node.arguments, dataflow.environment);
91
+ return hidden || test_functions_1.ExpectFunctionNames.test(identifier_1.Identifier.getName(name)) || isInvisible(name, invisible)
92
+ || (props === undefined && calleesReturnInvisibly(node.info.id, dataflow, invisible, seen)) ? undefined : name;
93
+ }
94
+ /** whether the call is to one of the functions stated to return invisibly, unless its package says it is another one */
95
+ function isInvisible(name, invisible) {
96
+ const fn = identifier_1.Identifier.getName(name);
97
+ const ns = identifier_1.Identifier.getNamespace(name);
98
+ return invisible.some(f => f.name === fn && (f.package === undefined || ns === undefined || f.package === ns));
97
99
  }
98
- function returnsInvisibly(id, dataflow, seen) {
100
+ function calleesReturnInvisibly(id, dataflow, invisible, seen) {
99
101
  const idMap = dataflow.graph.idMap;
100
102
  if (idMap === undefined || seen.has(id)) {
101
103
  return false;
102
104
  }
103
105
  seen.add(id);
104
106
  let callee = false;
105
- for (const [target, edge] of dataflow.graph.edgesFrom(id)) {
106
- const definition = edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Calls) ? dataflow.graph.getVertex(target) : undefined;
107
- if (!vertex_1.DfgVertex.isFunctionDefinition(definition)) {
108
- continue;
109
- }
107
+ for (const definition of df_helper_1.Dataflow.calleesOf(dataflow.graph, id)) {
110
108
  callee = true;
111
109
  for (const exit of definition.exitPoints) {
112
110
  const last = idMap.get(exit.nodeId);
113
- if (!r_function_call_1.RFunctionCall.is(last) || callName(last, dataflow, seen) !== undefined) {
111
+ if (!r_function_call_1.RFunctionCall.is(last) || callName(last, dataflow, invisible, seen) !== undefined) {
114
112
  return false;
115
113
  }
116
114
  }
@@ -121,7 +119,7 @@ function returnsInvisibly(id, dataflow, seen) {
121
119
  function echoName(node, dataflow) {
122
120
  switch (node.type) {
123
121
  case type_1.RType.FunctionCall:
124
- return qualifiedName(node, dataflow) ?? '';
122
+ return (0, plot_objects_1.callIdentifierOf)(node, dataflow) ?? '';
125
123
  case type_1.RType.BinaryOp:
126
124
  case type_1.RType.UnaryOp:
127
125
  case type_1.RType.Access:
@@ -139,14 +137,15 @@ function echoName(node, dataflow) {
139
137
  * outputs), given that it is echoed at all
140
138
  * (`project.assumeImplicitEcho`). A statement is only an output if its value is visible: an assignment, a loop,
141
139
  * and every {@link CallProp.Invisible} call hand back their result invisibly, while a bare symbol, a constant,
142
- * or an ordinary call reaches stdout. Calls another category already reports (a plot, a write, an assertion)
143
- * are left to it.
140
+ * or an ordinary call reaches stdout, unless it is one of the `invisible` dependency functions (which hold even for a
141
+ * package that is not loaded). Calls already reported as outputs are not repeated, and a printed plot draws instead
142
+ * (a lone ggplot component is no plot and is printed).
144
143
  */
145
- function collectImplicitEchoes(ast, dataflow, accountedFor, result) {
144
+ function collectImplicitEchoes(ast, dataflow, accountedFor, invisible, result) {
146
145
  for (const file of ast.ast.files) {
147
146
  for (const statement of file.root.children) {
148
- const echoed = echoedValue(statement, dataflow);
149
- if (echoed === undefined || accountedFor.has(echoed.info.id)) {
147
+ const echoed = echoedValue(statement, dataflow, invisible);
148
+ if (echoed === undefined || accountedFor.has(echoed.info.id) || (0, plot_objects_1.isPlot)(echoed, dataflow)) {
150
149
  continue;
151
150
  }
152
151
  result.push({ nodeId: echoed.info.id, functionName: echoName(echoed, dataflow), value: 'stdout', implicit: true });
@@ -1,6 +1,7 @@
1
1
  import type { DependencyInfo } from './dependencies-query-format';
2
2
  import type { NormalizedAst } from '../../../r-bridge/lang-4.x/ast/model/processing/decorate';
3
3
  import type { DataflowInformation } from '../../../dataflow/info';
4
+ import type { ReadOnlyFlowrAnalyzerContext } from '../../../project/context/flowr-analyzer-context';
4
5
  /**
5
6
  * Names the file each visualization lands in, and the statements that build it.
6
7
  *
@@ -10,7 +11,7 @@ import type { DataflowInformation } from '../../../dataflow/info';
10
11
  * {@link DependencyInfo#parts}: the addons drawn onto it, plus the device opener and closer around it.
11
12
  * Closing a device ends the plot, so an addon after it builds whatever device is open then, not this file.
12
13
  *
13
- * Openers are the `write` entries that draw ({@link SemanticCallTag.Graphics}), closers the calls that end a device
14
+ * Openers are the `write` entries that draw ({@link SemanticCallTag.Graphics}), other than what a call prints, closers the calls that end a device
14
15
  * ({@link SemanticCallTag.Closes}), and the order is the one the source states.
15
16
  */
16
- export declare function linkPlotsToDevices(written: readonly DependencyInfo[], plots: DependencyInfo[], dataflow: DataflowInformation, ast: NormalizedAst): void;
17
+ export declare function linkPlotsToDevices(written: readonly DependencyInfo[], plots: DependencyInfo[], dataflow: DataflowInformation, ast: NormalizedAst, ctx: ReadOnlyFlowrAnalyzerContext): void;
@@ -5,6 +5,7 @@ const function_semantics_1 = require("../../../dataflow/fn/function-semantics");
5
5
  const query_fn_props_1 = require("../../../dataflow/environments/query-fn-props");
6
6
  const built_in_props_1 = require("../../../dataflow/environments/built-in-props");
7
7
  const vertex_1 = require("../../../dataflow/graph/vertex");
8
+ const identifier_1 = require("../../../dataflow/environments/identifier");
8
9
  const range_1 = require("../../../util/range");
9
10
  function callHas(id, dataflow, props) {
10
11
  return function_semantics_1.FunctionSemantics.call.props.hasAny((0, query_fn_props_1.callFnProps)(id, dataflow), props);
@@ -18,15 +19,17 @@ function callHas(id, dataflow, props) {
18
19
  * {@link DependencyInfo#parts}: the addons drawn onto it, plus the device opener and closer around it.
19
20
  * Closing a device ends the plot, so an addon after it builds whatever device is open then, not this file.
20
21
  *
21
- * Openers are the `write` entries that draw ({@link SemanticCallTag.Graphics}), closers the calls that end a device
22
+ * Openers are the `write` entries that draw ({@link SemanticCallTag.Graphics}), other than what a call prints, closers the calls that end a device
22
23
  * ({@link SemanticCallTag.Closes}), and the order is the one the source states.
23
24
  */
24
- function linkPlotsToDevices(written, plots, dataflow, ast) {
25
+ function linkPlotsToDevices(written, plots, dataflow, ast, ctx) {
26
+ /* only a call of a name some built-in closing a device goes by can close one, which spares asking every call */
27
+ const closers = new Set(ctx.env.builtInIndex.with(built_in_props_1.SemanticCallTag.Closes).map(n => identifier_1.Identifier.getName(n)));
25
28
  const opened = new Map(written
26
- .filter(w => w.nodeId !== undefined && w.value !== undefined && callHas(w.nodeId, dataflow, built_in_props_1.SemanticCallTag.Graphics))
29
+ .filter(w => w.nodeId !== undefined && w.value !== undefined && !w.implicit && callHas(w.nodeId, dataflow, built_in_props_1.SemanticCallTag.Graphics))
27
30
  .map(w => [w.nodeId, w.value]));
28
- const closed = new Set(dataflow.graph.vertexIdsOfType(vertex_1.VertexType.FunctionCall)
29
- .filter(id => callHas(id, dataflow, built_in_props_1.SemanticCallTag.Closes)));
31
+ const closed = new Set(dataflow.graph.verticesOfType(vertex_1.VertexType.FunctionCall)
32
+ .filter(([id, call]) => closers.has(identifier_1.Identifier.getName(call.name)) && callHas(id, dataflow, built_in_props_1.SemanticCallTag.Closes)).map(([id]) => id));
30
33
  const plotAt = new Map();
31
34
  const linkOf = new Map();
32
35
  plots.forEach(({ nodeId, linkedIds }, at) => {
@@ -70,7 +73,7 @@ function linkPlotsToDevices(written, plots, dataflow, ast) {
70
73
  if (device !== undefined) {
71
74
  device.plots.push(id);
72
75
  around.set(id, [device.opener]);
73
- plots[plot] = { ...plots[plot], value: device.file };
76
+ plots[plot] = { ...plots[plot], value: device.file, savedTo: device.file };
74
77
  }
75
78
  const window = device?.opener;
76
79
  const linked = linkOf.get(id);
@@ -0,0 +1,10 @@
1
+ import { type DependencyInfo } from './dependencies-query-format';
2
+ import type { ReadOnlyFlowrAnalyzerContext } from '../../../project/context/flowr-analyzer-context';
3
+ import type { QueryRun } from './dependencies-query-executor';
4
+ /**
5
+ * Describes the plots (the visualizations nothing is linked to): the `title` their `ggtitle`, `labs(title = )` or
6
+ * `main =` states, and the file `ggsave` writes them to (the one of the `plot` it is given, else the last plot it is
7
+ * linked to, as ggplot's `last_plot()`). A plot drawn on a graphics device that writes to a file is described by {@link linkPlotsToDevices}.
8
+ * The title of the last statement stating one wins.
9
+ */
10
+ export declare function describePlots(written: readonly DependencyInfo[], plots: DependencyInfo[], run: QueryRun, ctx: ReadOnlyFlowrAnalyzerContext): void;
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.describePlots = describePlots;
4
+ const dependencies_query_format_1 = require("./dependencies-query-format");
5
+ const vertex_1 = require("../../../dataflow/graph/vertex");
6
+ const edge_1 = require("../../../dataflow/graph/edge");
7
+ const identifier_1 = require("../../../dataflow/environments/identifier");
8
+ const resolve_argument_1 = require("../../../dataflow/eval/resolve/resolve-argument");
9
+ const range_1 = require("../../../util/range");
10
+ const data_flow_1 = require("./data-flow");
11
+ const built_in_props_1 = require("../../../dataflow/environments/built-in-props");
12
+ /** where a call states the title of the plot it draws onto; every other call is asked for `main` */
13
+ const TitleArguments = {
14
+ ggtitle: { argIdx: 0, argName: 'label' },
15
+ labs: { argName: 'title' }
16
+ };
17
+ const DefaultTitleArgument = { argName: 'main' };
18
+ function isResolved(value) {
19
+ return value !== undefined && value !== dependencies_query_format_1.Unknown && value !== dependencies_query_format_1.Constant;
20
+ }
21
+ function titleOf(call, { dataflow, config, formals }, ctx) {
22
+ /* a call handed nothing states no title */
23
+ if (call.args.length === 0) {
24
+ return undefined;
25
+ }
26
+ const { argIdx, argName } = TitleArguments[identifier_1.Identifier.getName(call.name)] ?? DefaultTitleArgument;
27
+ const values = (0, resolve_argument_1.getArgumentStringValue)(config.solver.variables, dataflow.graph, call, argIdx, argName, true, ctx, formals(call));
28
+ return values?.values().flatMap(v => [...v]).find(isResolved);
29
+ }
30
+ /** the plot roots (by id) the value `start` is built from, looking through variables and the calls handing a value on */
31
+ function rootsReaching({ dataflow, normalize: ast, memo }, start, roots) {
32
+ const dfg = dataflow.graph;
33
+ const found = new Set();
34
+ const seen = new Set();
35
+ const todo = [start];
36
+ for (let id = todo.pop(); id !== undefined; id = todo.pop()) {
37
+ if (seen.has(id)) {
38
+ continue;
39
+ }
40
+ seen.add(id);
41
+ const vertex = dfg.getVertex(id);
42
+ if (roots.has(id)) {
43
+ found.add(id);
44
+ }
45
+ else if (vertex_1.DfgVertex.isUse(vertex)) {
46
+ todo.push(...dfg.edgesFrom(id).entries().filter(([, e]) => edge_1.DfEdge.includesType(e, edge_1.EdgeType.Reads)).map(([to]) => to));
47
+ }
48
+ else if (vertex_1.DfgVertex.isVariableDefinition(vertex)) {
49
+ todo.push(...dfg.edgesFrom(id).entries().filter(([, e]) => edge_1.DfEdge.includesType(e, edge_1.EdgeType.DefinedBy)).map(([to]) => to));
50
+ }
51
+ else if (vertex_1.DfgVertex.isFunctionCall(vertex)) {
52
+ todo.push(...(0, data_flow_1.handedOn)(dataflow, ast, vertex, memo));
53
+ }
54
+ }
55
+ return [...found];
56
+ }
57
+ /**
58
+ * Describes the plots (the visualizations nothing is linked to): the `title` their `ggtitle`, `labs(title = )` or
59
+ * `main =` states, and the file `ggsave` writes them to (the one of the `plot` it is given, else the last plot it is
60
+ * linked to, as ggplot's `last_plot()`). A plot drawn on a graphics device that writes to a file is described by {@link linkPlotsToDevices}.
61
+ * The title of the last statement stating one wins.
62
+ */
63
+ function describePlots(written, plots, run, ctx) {
64
+ const { dataflow, normalize: ast } = run;
65
+ const dfg = dataflow.graph;
66
+ const located = (id) => ast.idMap.get(id)?.location;
67
+ const bySource = (a, b) => {
68
+ const [from, to] = [located(a), located(b)];
69
+ return from && to ? range_1.SourceRange.compare(from, to) : 0;
70
+ };
71
+ const roots = new Map();
72
+ plots.forEach(({ nodeId, linkedIds }, at) => {
73
+ if (nodeId !== undefined && !linkedIds?.length) {
74
+ roots.set(nodeId, at);
75
+ }
76
+ });
77
+ if (roots.size === 0) {
78
+ return;
79
+ }
80
+ const parts = new Map([...roots.keys()].map(root => [root, [root]]));
81
+ for (const { nodeId, linkedIds } of plots) {
82
+ for (const root of linkedIds ?? []) {
83
+ if (nodeId !== undefined) {
84
+ parts.get(root)?.push(nodeId);
85
+ }
86
+ }
87
+ }
88
+ for (const [root, ids] of parts) {
89
+ /* the last statement stating a title wins, so the search starts there */
90
+ let title;
91
+ for (const id of ids.sort(bySource).reverse()) {
92
+ const call = dfg.getVertex(id);
93
+ title = vertex_1.DfgVertex.isFunctionCall(call) ? titleOf(call, run, ctx) : undefined;
94
+ if (title !== undefined) {
95
+ break;
96
+ }
97
+ }
98
+ if (title !== undefined) {
99
+ const at = roots.get(root);
100
+ plots[at] = { ...plots[at], title };
101
+ }
102
+ }
103
+ const rootIds = new Set(roots.keys());
104
+ /* an addon names the plot it builds, a root itself */
105
+ const rootsOf = (id) => rootIds.has(id) ? [id] : plots.find(p => p.nodeId === id)?.linkedIds ?? [];
106
+ for (const { nodeId, functionName, value, linkedIds } of written) {
107
+ const call = nodeId === undefined ? undefined : dfg.getVertex(nodeId);
108
+ if (!isResolved(value) || !vertex_1.DfgVertex.isFunctionCall(call) || identifier_1.Identifier.getName(functionName) !== 'ggsave') {
109
+ continue;
110
+ }
111
+ const plot = (0, data_flow_1.argumentRoles)(dataflow, call, run.memo).filter(([, roles]) => (roles & built_in_props_1.ArgProp.Value) !== 0).map(([arg]) => arg);
112
+ const saved = plot.length > 0 ? plot.flatMap(p => rootsReaching(run, p, rootIds)) : (linkedIds ?? []).flatMap(rootsOf);
113
+ for (const root of saved) {
114
+ const at = roots.get(root);
115
+ plots[at] = { ...plots[at], savedTo: value };
116
+ }
117
+ }
118
+ }
119
+ //# sourceMappingURL=plot-description.js.map