@eagleoutice/flowr 2.16.6 → 2.16.8

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 (321) hide show
  1. package/README.md +21 -15
  2. package/abstract-interpretation/data-frame/dataframe-semantics.d.ts +2 -0
  3. package/abstract-interpretation/data-frame/dataframe-semantics.js +3 -1
  4. package/abstract-interpretation/data-frame/resolve-args.d.ts +1 -7
  5. package/abstract-interpretation/data-frame/resolve-args.js +2 -11
  6. package/cli/repl/commands/repl-cfg.js +5 -19
  7. package/cli/repl/commands/repl-code-command.d.ts +10 -0
  8. package/cli/repl/commands/repl-code-command.js +18 -0
  9. package/cli/repl/commands/repl-dataflow.js +34 -59
  10. package/cli/repl/commands/repl-normalize.js +24 -41
  11. package/cli/repl/commands/repl-query.js +10 -17
  12. package/config.js +3 -3
  13. package/control-flow/cfg-dead-code.js +15 -2
  14. package/control-flow/useless-loop.js +1 -2
  15. package/data/r-base-packages.generated.d.ts +1 -1
  16. package/data/r-base-packages.generated.js +3 -3
  17. package/dataflow/environments/ambient-state-name.d.ts +80 -0
  18. package/dataflow/environments/ambient-state-name.js +113 -0
  19. package/dataflow/environments/built-in-eval-name.d.ts +3 -1
  20. package/dataflow/environments/built-in-eval-name.js +2 -0
  21. package/dataflow/environments/built-in-props.d.ts +27 -7
  22. package/dataflow/environments/built-in-props.js +59 -44
  23. package/dataflow/environments/built-in.d.ts +5 -2
  24. package/dataflow/environments/built-in.js +22 -5
  25. package/dataflow/environments/default-builtin-config.d.ts +538 -14
  26. package/dataflow/environments/default-builtin-config.js +189 -123
  27. package/dataflow/environments/environment.d.ts +7 -1
  28. package/dataflow/environments/environment.js +19 -1
  29. package/dataflow/environments/identifier.d.ts +12 -1
  30. package/dataflow/environments/reference-to-maybe.js +1 -6
  31. package/dataflow/eval/resolve/alias-tracking.d.ts +13 -3
  32. package/dataflow/eval/resolve/alias-tracking.js +66 -37
  33. package/dataflow/eval/resolve/resolve-argument.d.ts +4 -2
  34. package/dataflow/eval/resolve/resolve-argument.js +23 -11
  35. package/dataflow/eval/resolve/resolve.d.ts +5 -0
  36. package/dataflow/eval/resolve/resolve.js +25 -3
  37. package/dataflow/eval/values/r-value.d.ts +4 -2
  38. package/dataflow/eval/values/r-value.js +3 -1
  39. package/dataflow/eval/values/string/string-constants.d.ts +7 -1
  40. package/dataflow/eval/values/string/string-constants.js +38 -36
  41. package/dataflow/extractor.js +105 -2
  42. package/dataflow/fn/argument-roles.js +22 -8
  43. package/dataflow/fn/function-semantics.d.ts +3 -2
  44. package/dataflow/fn/strict-function.js +13 -2
  45. package/dataflow/graph/dataflowgraph-builder.d.ts +4 -4
  46. package/dataflow/graph/df-helper.d.ts +14 -1
  47. package/dataflow/graph/df-helper.js +37 -4
  48. package/dataflow/graph/graph.d.ts +6 -0
  49. package/dataflow/graph/graph.js +9 -10
  50. package/dataflow/graph/vertex.d.ts +1 -1
  51. package/dataflow/hooks.d.ts +1 -1
  52. package/dataflow/info.d.ts +3 -3
  53. package/dataflow/internal/linker.d.ts +4 -1
  54. package/dataflow/internal/linker.js +12 -8
  55. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.d.ts +41 -0
  56. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.js +88 -0
  57. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +21 -46
  58. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +125 -158
  59. package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +6 -1
  60. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +35 -9
  61. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +10 -1
  62. package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +4 -1
  63. package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +6 -1
  64. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +1 -1
  65. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +3 -2
  66. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +7 -0
  67. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +21 -12
  68. package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +1 -1
  69. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +8 -1
  70. package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +4 -1
  71. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +5 -0
  72. package/dataflow/internal/process/functions/call/built-in/built-in-local.js +5 -2
  73. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +11 -12
  74. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -1
  75. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +6 -0
  76. package/dataflow/internal/process/functions/call/built-in/built-in-string-template.js +1 -1
  77. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +7 -0
  78. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +43 -7
  79. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +11 -0
  80. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +29 -4
  81. package/dataflow/internal/process/functions/call/common.js +3 -4
  82. package/dataflow/internal/process/functions/call/deferred.d.ts +3 -2
  83. package/dataflow/internal/process/functions/call/deferred.js +17 -9
  84. package/dataflow/internal/process/functions/call/quoted.js +1 -1
  85. package/dataflow/processor.d.ts +1 -1
  86. package/documentation/doc-capabilities.js +3 -2
  87. package/documentation/doc-readme.js +1 -2
  88. package/documentation/doc-util/doc-dfg.js +2 -2
  89. package/documentation/doc-util/doc-query.d.ts +3 -1
  90. package/documentation/doc-util/doc-query.js +4 -4
  91. package/documentation/wiki-create-linting-rules.js +1 -1
  92. package/documentation/wiki-linter.js +16 -206
  93. package/documentation/wiki-linting-and-testing.js +31 -64
  94. package/documentation/wiki-query.js +41 -0
  95. package/index.d.ts +1 -0
  96. package/index.js +5 -1
  97. package/linter/linter-format.d.ts +6 -0
  98. package/linter/linter-format.js +10 -0
  99. package/linter/linter-rules.d.ts +155 -103
  100. package/linter/linter-rules.js +2 -0
  101. package/linter/linter-util.d.ts +23 -0
  102. package/linter/linter-util.js +58 -0
  103. package/linter/rules/absolute-path.d.ts +2 -2
  104. package/linter/rules/absolute-path.js +1 -4
  105. package/linter/rules/cmd-check/bogus-return.d.ts +2 -2
  106. package/linter/rules/cmd-check/bogus-return.js +3 -7
  107. package/linter/rules/cmd-check/call-arguments.d.ts +2 -2
  108. package/linter/rules/cmd-check/class-string-comparison.d.ts +2 -2
  109. package/linter/rules/cmd-check/class-string-comparison.js +3 -7
  110. package/linter/rules/cmd-check/cmd-check-util.d.ts +8 -9
  111. package/linter/rules/cmd-check/cmd-check-util.js +14 -26
  112. package/linter/rules/cmd-check/compiled-code.d.ts +8 -3
  113. package/linter/rules/cmd-check/compiled-code.js +3 -13
  114. package/linter/rules/cmd-check/dependency-declaration.d.ts +2 -2
  115. package/linter/rules/cmd-check/dependency-declaration.js +6 -7
  116. package/linter/rules/cmd-check/description-metadata.d.ts +4 -4
  117. package/linter/rules/cmd-check/documentation-mismatch.d.ts +2 -2
  118. package/linter/rules/cmd-check/documentation-mismatch.js +4 -11
  119. package/linter/rules/cmd-check/file-checks.d.ts +19 -6
  120. package/linter/rules/cmd-check/file-checks.js +13 -5
  121. package/linter/rules/cmd-check/foreign-function-calls.d.ts +2 -2
  122. package/linter/rules/cmd-check/global-environment-modification.d.ts +2 -2
  123. package/linter/rules/cmd-check/global-environment-modification.js +3 -2
  124. package/linter/rules/cmd-check/namespace-tampering.d.ts +2 -2
  125. package/linter/rules/cmd-check/namespace-tampering.js +9 -9
  126. package/linter/rules/cmd-check/non-ascii-code.d.ts +2 -2
  127. package/linter/rules/cmd-check/package-data.d.ts +11 -5
  128. package/linter/rules/cmd-check/package-data.js +5 -12
  129. package/linter/rules/cmd-check/package-files.js +4 -10
  130. package/linter/rules/cmd-check/package-hooks.d.ts +2 -2
  131. package/linter/rules/cmd-check/package-hooks.js +10 -8
  132. package/linter/rules/cmd-check/package-metafiles.d.ts +8 -3
  133. package/linter/rules/cmd-check/package-metafiles.js +3 -12
  134. package/linter/rules/cmd-check/package-runtime.d.ts +18 -5
  135. package/linter/rules/cmd-check/package-runtime.js +64 -20
  136. package/linter/rules/cmd-check/package-structure.d.ts +11 -5
  137. package/linter/rules/cmd-check/package-structure.js +4 -12
  138. package/linter/rules/cmd-check/rd-files.d.ts +8 -3
  139. package/linter/rules/cmd-check/rd-files.js +4 -14
  140. package/linter/rules/cmd-check/s-three-method-consistency.d.ts +2 -2
  141. package/linter/rules/cmd-check/s-three-method-consistency.js +3 -4
  142. package/linter/rules/cmd-check/true-false-abbreviation.d.ts +2 -2
  143. package/linter/rules/dataframe-access-validation.d.ts +2 -2
  144. package/linter/rules/dataframe-access-validation.js +5 -8
  145. package/linter/rules/dead-code.d.ts +5 -4
  146. package/linter/rules/dead-code.js +25 -14
  147. package/linter/rules/deprecated-functions.d.ts +3 -3
  148. package/linter/rules/deprecated-functions.js +16 -23
  149. package/linter/rules/file-path-validity.d.ts +2 -2
  150. package/linter/rules/file-path-validity.js +3 -6
  151. package/linter/rules/function-finder-util.d.ts +3 -3
  152. package/linter/rules/function-finder-util.js +7 -14
  153. package/linter/rules/namespace-access.d.ts +2 -2
  154. package/linter/rules/namespace-access.js +6 -9
  155. package/linter/rules/naming-convention.d.ts +2 -2
  156. package/linter/rules/naming-convention.js +1 -4
  157. package/linter/rules/network-functions.d.ts +3 -3
  158. package/linter/rules/no-leaked-credentials.d.ts +2 -2
  159. package/linter/rules/no-leaked-credentials.js +1 -4
  160. package/linter/rules/overwritten-file.d.ts +38 -0
  161. package/linter/rules/overwritten-file.js +102 -0
  162. package/linter/rules/problematic-inputs.d.ts +16 -6
  163. package/linter/rules/problematic-inputs.js +78 -34
  164. package/linter/rules/roxygen-arguments.d.ts +2 -2
  165. package/linter/rules/roxygen-arguments.js +1 -4
  166. package/linter/rules/seeded-randomness.d.ts +3 -3
  167. package/linter/rules/seeded-randomness.js +6 -23
  168. package/linter/rules/software-has-license.d.ts +2 -2
  169. package/linter/rules/software-has-license.js +1 -4
  170. package/linter/rules/software-has-tests.d.ts +2 -2
  171. package/linter/rules/software-has-tests.js +1 -4
  172. package/linter/rules/stop-with-call-arg.d.ts +2 -2
  173. package/linter/rules/stop-with-call-arg.js +4 -11
  174. package/linter/rules/syntactically-valid.d.ts +4 -2
  175. package/linter/rules/syntactically-valid.js +29 -10
  176. package/linter/rules/unclosed-connection.d.ts +2 -2
  177. package/linter/rules/unclosed-connection.js +1 -4
  178. package/linter/rules/undefined-symbol.d.ts +2 -2
  179. package/linter/rules/undefined-symbol.js +25 -22
  180. package/linter/rules/unescaped-arguments.d.ts +2 -2
  181. package/linter/rules/unescaped-arguments.js +1 -4
  182. package/linter/rules/unused-definition.d.ts +2 -2
  183. package/linter/rules/unused-definition.js +37 -25
  184. package/linter/rules/unused-import.d.ts +2 -2
  185. package/linter/rules/unused-import.js +9 -14
  186. package/linter/rules/useless-loop.d.ts +7 -6
  187. package/linter/rules/useless-loop.js +4 -8
  188. package/package.json +5 -3
  189. package/project/cache/flowr-analyzer-cache.d.ts +2 -0
  190. package/project/cache/flowr-analyzer-cache.js +15 -11
  191. package/project/context/flowr-analyzer-files-context.d.ts +3 -0
  192. package/project/context/flowr-analyzer-files-context.js +6 -0
  193. package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +6 -1
  194. package/project/plugins/file-plugins/files/flowr-jupyter-file.js +35 -0
  195. package/project/plugins/file-plugins/files/flowr-namespace-file.js +2 -1
  196. package/project/plugins/file-plugins/files/flowr-rsession-file.d.ts +26 -0
  197. package/project/plugins/file-plugins/files/flowr-rsession-file.js +44 -0
  198. package/project/plugins/file-plugins/files/r-session.d.ts +20 -0
  199. package/project/plugins/file-plugins/files/r-session.js +58 -0
  200. package/project/plugins/file-plugins/files/recorded-runs.d.ts +18 -0
  201. package/project/plugins/file-plugins/files/recorded-runs.js +8 -0
  202. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rsession-file-plugin.d.ts +20 -0
  203. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rsession-file-plugin.js +28 -0
  204. package/project/plugins/plugin-registry.d.ts +2 -1
  205. package/project/plugins/plugin-registry.js +2 -0
  206. package/project/sigdb/spec-query.d.ts +73 -0
  207. package/project/sigdb/spec-query.js +339 -0
  208. package/queries/base-query-format.d.ts +1 -1
  209. package/queries/base-query-format.js +2 -2
  210. package/queries/catalog/absint-query/absint-query-executor.js +3 -6
  211. package/queries/catalog/call-context-query/call-context-query-executor.d.ts +1 -0
  212. package/queries/catalog/call-context-query/call-context-query-executor.js +113 -73
  213. package/queries/catalog/call-graph-query/call-graph-query-executor.js +2 -3
  214. package/queries/catalog/cluster-query/cluster-query-executor.js +2 -3
  215. package/queries/catalog/config-query/config-query-format.d.ts +0 -1
  216. package/queries/catalog/config-query/config-query-format.js +1 -2
  217. package/queries/catalog/control-flow-query/control-flow-query-executor.js +2 -3
  218. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.js +2 -4
  219. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.d.ts +0 -1
  220. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.js +1 -2
  221. package/queries/catalog/dataflow-query/dataflow-query-executor.js +2 -3
  222. package/queries/catalog/dependencies-query/dependencies-query-executor.d.ts +7 -0
  223. package/queries/catalog/dependencies-query/dependencies-query-executor.js +72 -42
  224. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +24 -6
  225. package/queries/catalog/dependencies-query/dependencies-query-format.js +108 -3
  226. package/queries/catalog/dependencies-query/function-info/function-info.d.ts +6 -1
  227. package/queries/catalog/dependencies-query/function-info/read-functions.js +6 -6
  228. package/queries/catalog/dependencies-query/function-info/write-functions.js +13 -7
  229. package/queries/catalog/dependencies-query/implicit-echo.js +21 -7
  230. package/queries/catalog/dice-query/dice-query-executor.js +2 -3
  231. package/queries/catalog/does-call-query/does-call-query-executor.js +2 -3
  232. package/queries/catalog/files-query/files-query-executor.js +2 -3
  233. package/queries/catalog/function-info-query/function-info-query-executor.js +2 -1
  234. package/queries/catalog/function-info-query/function-info-query-format.d.ts +0 -2
  235. package/queries/catalog/function-info-query/function-info-query-format.js +1 -2
  236. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +3 -2
  237. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +0 -2
  238. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +1 -2
  239. package/queries/catalog/happens-before-query/happens-before-query-executor.js +2 -3
  240. package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +0 -1
  241. package/queries/catalog/happens-before-query/happens-before-query-format.js +1 -2
  242. package/queries/catalog/id-map-query/id-map-query-executor.js +2 -3
  243. package/queries/catalog/id-map-query/id-map-query-format.d.ts +0 -1
  244. package/queries/catalog/id-map-query/id-map-query-format.js +1 -2
  245. package/queries/catalog/input-sources-query/input-sources-query-executor.js +3 -4
  246. package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +2 -1
  247. package/queries/catalog/input-sources-query/simple-input-classifier.js +60 -13
  248. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.js +2 -3
  249. package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-executor.js +2 -3
  250. package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.js +2 -1
  251. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.d.ts +3 -2
  252. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +1 -7
  253. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +6 -9
  254. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +8 -33
  255. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.d.ts +3 -2
  256. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.js +1 -7
  257. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.d.ts +6 -7
  258. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.js +8 -31
  259. package/queries/catalog/linter-query/linter-query-executor.js +2 -3
  260. package/queries/catalog/location-map-query/location-map-query-executor.js +2 -3
  261. package/queries/catalog/location-map-query/location-map-query-format.d.ts +0 -1
  262. package/queries/catalog/location-map-query/location-map-query-format.js +1 -2
  263. package/queries/catalog/normalized-ast-query/normalized-ast-query-executor.js +2 -3
  264. package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +0 -1
  265. package/queries/catalog/normalized-ast-query/normalized-ast-query-format.js +1 -2
  266. package/queries/catalog/origin-query/origin-query-executor.d.ts +0 -5
  267. package/queries/catalog/origin-query/origin-query-executor.js +3 -11
  268. package/queries/catalog/project-query/project-query-executor.js +23 -7
  269. package/queries/catalog/project-query/project-query-format.d.ts +5 -0
  270. package/queries/catalog/project-query/project-query-format.js +20 -2
  271. package/queries/catalog/provenance-query/provenance-query-executor.js +2 -3
  272. package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +2 -3
  273. package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +0 -1
  274. package/queries/catalog/resolve-value-query/resolve-value-query-format.js +1 -2
  275. package/queries/catalog/search-query/search-query-executor.js +2 -3
  276. package/queries/catalog/signature-query/signature-query-executor.js +39 -0
  277. package/queries/catalog/signature-query/signature-query-format.d.ts +7 -1
  278. package/queries/catalog/signature-query/signature-query-format.js +15 -1
  279. package/queries/catalog/signature-query/signature-query-render.js +2 -1
  280. package/queries/catalog/static-slice-query/static-slice-query-executor.js +2 -3
  281. package/queries/query-function-property.d.ts +28 -0
  282. package/queries/query-function-property.js +48 -0
  283. package/queries/query-meta.d.ts +3 -0
  284. package/queries/query-meta.js +8 -0
  285. package/queries/query.d.ts +13 -18
  286. package/r-bridge/lang-4.x/ast/model/processing/decorate.d.ts +2 -2
  287. package/r-bridge/lang-4.x/ast/model/processing/decorate.js +4 -3
  288. package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +6 -0
  289. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +9 -0
  290. package/r-bridge/lang-4.x/ast/model/syntax-version.d.ts +8 -0
  291. package/r-bridge/lang-4.x/ast/model/syntax-version.js +49 -0
  292. package/r-bridge/lang-4.x/ast/model/type.d.ts +2 -0
  293. package/r-bridge/lang-4.x/ast/model/type.js +3 -0
  294. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-parameter.js +4 -1
  295. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-single-node.js +1 -0
  296. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +1 -1
  297. package/reconstruct/reconstruct.js +35 -1
  298. package/search/search-executor/search-generators.js +1 -1
  299. package/slicing/static/fingerprint.js +7 -3
  300. package/slicing/static/static-slicer.js +6 -0
  301. package/util/assert.js +2 -2
  302. package/util/collections/arrays.d.ts +4 -0
  303. package/util/collections/arrays.js +11 -0
  304. package/util/collections/defaultmap.d.ts +5 -1
  305. package/util/collections/defaultmap.js +6 -1
  306. package/util/files.js +26 -5
  307. package/util/flowr-version.d.ts +10 -0
  308. package/util/flowr-version.js +20 -0
  309. package/util/glob.js +6 -4
  310. package/util/r-regex.d.ts +6 -0
  311. package/util/r-regex.js +17 -0
  312. package/util/text/args.d.ts +5 -0
  313. package/util/text/args.js +28 -22
  314. package/util/text/name-rank.d.ts +2 -0
  315. package/util/text/name-rank.js +3 -1
  316. package/util/text/regex.d.ts +10 -0
  317. package/util/text/regex.js +29 -0
  318. package/util/version.d.ts +1 -6
  319. package/util/version.js +6 -14
  320. package/documentation/doc-util/doc-functions.d.ts +0 -24
  321. package/documentation/doc-util/doc-functions.js +0 -65
@@ -10,9 +10,14 @@ const flowr_search_builder_1 = require("../../search/flowr-search-builder");
10
10
  const range_1 = require("../../util/range");
11
11
  const linter_tags_1 = require("../linter-tags");
12
12
  const vertex_1 = require("../../dataflow/graph/vertex");
13
+ const graph_1 = require("../../dataflow/graph/graph");
14
+ const r_symbol_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
13
15
  const edge_1 = require("../../dataflow/graph/edge");
14
16
  const flowr_search_filters_1 = require("../../search/flowr-search-filters");
15
17
  const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
18
+ const assert_1 = require("../../util/assert");
19
+ const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
20
+ const built_in_proc_name_1 = require("../../dataflow/environments/built-in-proc-name");
16
21
  const flowr_file_1 = require("../../project/context/flowr-file");
17
22
  const flowr_namespace_file_1 = require("../../project/plugins/file-plugins/files/flowr-namespace-file");
18
23
  const identifier_1 = require("../../dataflow/environments/identifier");
@@ -107,8 +112,8 @@ function isConsideredUsed(lexeme, config, pkg, called, ctx) {
107
112
  return isS3MethodName(name, ctx, called, pkg.s3Generics) || (config.excludeExportedDefinitions && pkg.exported.has(name));
108
113
  }
109
114
  const InterestingEdgesVariable = edge_1.EdgeType.Reads | edge_1.EdgeType.Calls | edge_1.EdgeType.DefinesOnCall;
110
- /* include read as this could print the function definition */
111
- const InterestingEdgesFunction = edge_1.EdgeType.Reads | edge_1.EdgeType.Calls;
115
+ /* a read may print the definition, and a call handing it back unchanged, like `(` in `f <- (function() 1)`, passes it on */
116
+ const InterestingEdgesFunction = edge_1.EdgeType.Reads | edge_1.EdgeType.Calls | edge_1.EdgeType.Returns;
112
117
  const InterestingEdgesTargets = edge_1.EdgeType.SideEffectOnCall;
113
118
  /**
114
119
  * Whether the node names a parameter of a function whose signature something outside the code fixes: a package
@@ -140,25 +145,32 @@ function hasContractedSignature(node, ast, config, pkg, called, ctx) {
140
145
  * so says nothing; the same property on a call within it, as `assign` states, is an effect of its own.
141
146
  */
142
147
  function doesMoreThanCompute(id, df, binds) {
143
- if (!vertex_1.DfgVertex.isFunctionCall(df.graph.getVertex(id))) {
148
+ const vertex = df.graph.getVertex(id);
149
+ if (!vertex_1.DfgVertex.isFunctionCall(vertex)) {
144
150
  return false;
145
151
  }
146
- /* what a call that binds the very name in question does to that name is not what keeps it alive */
147
- const worthKeeping = id === binds ? { props: built_in_props_1.ImpureProps.props & ~built_in_props_1.CallProp.Scope, tags: built_in_props_1.ImpureProps.tags } : built_in_props_1.ImpureProps;
148
- return function_semantics_1.FunctionSemantics.call.props.hasAny((0, query_fn_props_1.callFnProps)(id, df), worthKeeping);
152
+ /* two properties do not count: the `Scope` effect of the assignment being removed, which is the binding itself, and
153
+ the `MayPure` of `do.call(f, args)` with a known `f`, as `f` is checked on its own as part of the value */
154
+ const ignored = (id === binds ? built_in_props_1.CallProp.Scope : 0) | (runsOnlyKnownFunctions(vertex, df) ? built_in_props_1.CallProp.MayPure : 0);
155
+ return function_semantics_1.FunctionSemantics.call.props.hasAny((0, query_fn_props_1.callFnProps)(id, df), { props: built_in_props_1.ImpureProps.props & ~ignored, tags: built_in_props_1.ImpureProps.tags });
149
156
  }
150
- function getAssignmentPeer(node, ast) {
157
+ /** whether the functions handed to a call like `do.call(f, args)` are all known, see {@link Dataflow.callsOnlyKnownFunctions} */
158
+ function runsOnlyKnownFunctions(vertex, { graph, environment }) {
159
+ const handed = vertex.args.map(graph_1.FunctionArgument.getReference)
160
+ .filter(r => r !== undefined && r_symbol_1.RSymbol.is(graph.idMap?.get(r)) && vertex_1.DfgVertex.isFunctionCall(graph.getVertex(r)));
161
+ return handed.length > 0 && handed.every(h => df_helper_1.Dataflow.callsOnlyKnownFunctions(h, graph, environment));
162
+ }
163
+ function getAssignmentPeer(node, ast, dfg) {
151
164
  const parent = model_1.RNode.directParent(node, ast.idMap);
152
- if (!r_binary_op_1.RBinaryOp.is(parent)) {
153
- return undefined;
154
- }
155
- if (parent.lhs.info.id === node.info.id) {
156
- return { statement: parent, value: parent.rhs };
165
+ if (r_binary_op_1.RBinaryOp.is(parent)) {
166
+ return parent.lhs.info.id === node.info.id ? { statement: parent, value: parent.rhs }
167
+ : parent.rhs.info.id === node.info.id ? { statement: parent, value: parent.lhs } : undefined;
157
168
  }
158
- if (parent.rhs.info.id === node.info.id) {
159
- return { statement: parent, value: parent.lhs };
160
- }
161
- return undefined;
169
+ /* `assign("x", 1)` assigns like `x <- 1`: the first argument names the target, the second is the value */
170
+ const call = r_argument_1.RArgument.is(parent) ? model_1.RNode.directParent(parent, ast.idMap) : undefined;
171
+ const definition = dfg.getVertex(node.info.id);
172
+ const value = vertex_1.DfgVertex.isVariableDefinition(definition) && definition.source?.length === 1 ? ast.idMap.get(definition.source[0]) : undefined;
173
+ return r_function_call_1.RFunctionCall.is(call) && value !== undefined && vertex_1.DfgVertex.hasOrigin(dfg.getVertex(call.info.id), built_in_proc_name_1.BuiltInProcName.Assignment) ? { statement: call, value } : undefined;
162
174
  }
163
175
  function yieldsFunctionValue(node, ast, dfg) {
164
176
  const path = new Set([node.info.id]);
@@ -185,7 +197,10 @@ function isStandaloneStatement(node, ast) {
185
197
  /** Whether the definition's value has obligations, like side effects, so the definition cannot be removed. */
186
198
  function hasImportantArgs(definedBys, df, binds) {
187
199
  const dfg = df.graph;
188
- return definedBys.some(d => dfg.unknownSideEffects.has(d) || doesMoreThanCompute(d, df, binds)
200
+ /* removing `u <- (runif(1))` removes the `runif` call too, which changes the random seed; calls in a function body defined there do not run */
201
+ const values = definedBys.filter(d => d !== binds).map(d => dfg.idMap?.get(d)).filter(assert_1.isNotUndefined);
202
+ const runs = model_1.RNode.collectAllIdsWithStop(values, r_function_definition_1.RFunctionDefinition.is).union(new Set(definedBys));
203
+ return runs.values().some(d => dfg.unknownSideEffects.has(d) || doesMoreThanCompute(d, df, binds)
189
204
  || dfg.edgesTo(d).values().some(edge => edge_1.DfEdge.includesType(edge, InterestingEdgesTargets))
190
205
  || dfg.edgesFrom(d).entries().some(([target, edge]) => edge_1.DfEdge.includesType(edge, InterestingEdgesTargets) || dfg.unknownSideEffects.has(target)));
191
206
  }
@@ -198,10 +213,10 @@ function quickFixForUnused(variable, df, ast) {
198
213
  return undefined;
199
214
  }
200
215
  const definedBys = df_helper_1.Dataflow.targetsOf(dfg, variable.info.id, edge_1.EdgeType.DefinedBy);
201
- if (hasImportantArgs(definedBys, df, variable.info.parent)) {
216
+ const assignment = getAssignmentPeer(variable, ast, dfg);
217
+ if (hasImportantArgs(definedBys, df, assignment?.statement.info.id ?? variable.info.parent)) {
202
218
  return undefined;
203
219
  }
204
- const assignment = getAssignmentPeer(variable, ast);
205
220
  const totalRangeToRemove = range_1.SourceLocation.merge([
206
221
  ...definedBys.map(d => range_1.SourceLocation.fromNode(ast.idMap.get(d))),
207
222
  range_1.SourceLocation.fromNode(assignment?.value),
@@ -211,7 +226,7 @@ function quickFixForUnused(variable, df, ast) {
211
226
  /* a fix that names no place cannot be carried out, so none is offered */
212
227
  return undefined;
213
228
  }
214
- const description = `Remove unused definition of \`${variable.lexeme}\``;
229
+ const description = `Remove unused definition of \`${node_id_1.NodeId.recoverBareName(variable.info.id, ast.idMap)}\``;
215
230
  const statement = assignment?.statement ?? variable;
216
231
  if (isStandaloneStatement(statement, ast)) {
217
232
  return yieldsFunctionValue(statement, ast, dfg) ? undefined : [{ type: 'remove', loc: totalRangeToRemove, description }];
@@ -308,7 +323,7 @@ exports.UNUSED_DEFINITION = {
308
323
  }
309
324
  return [{
310
325
  certainty: linter_format_1.LintingResultCertainty.Uncertain,
311
- variableName: node.lexeme,
326
+ variableName: node_id_1.NodeId.recoverBareName(node.info.id, normalize.idMap),
312
327
  involvedId: node.info.id,
313
328
  loc: range_1.SourceLocation.fromNode(node) ?? range_1.SourceLocation.invalid(),
314
329
  quickFix: quickFixForUnused(node, dataflow, normalize)
@@ -317,10 +332,7 @@ exports.UNUSED_DEFINITION = {
317
332
  '.meta': metadata
318
333
  };
319
334
  },
320
- prettyPrint: {
321
- [linter_format_1.LintingPrettyPrintContext.Query]: result => `Definition of \`${result.variableName}\` at ${range_1.SourceLocation.format(result.loc)}`,
322
- [linter_format_1.LintingPrettyPrintContext.Full]: result => `Definition of \`${result.variableName}\` at ${range_1.SourceLocation.format(result.loc)} is unused`
323
- },
335
+ prettyPrint: (0, linter_format_1.prettyPrint)(result => `Definition of \`${result.variableName}\` at ${range_1.SourceLocation.format(result.loc)}`, result => `Definition of \`${result.variableName}\` at ${range_1.SourceLocation.format(result.loc)} is unused`),
324
336
  info: {
325
337
  name: 'Unused Definitions',
326
338
  description: 'Finds definitions that are never used.',
@@ -48,8 +48,8 @@ export declare const UNUSED_IMPORT: {
48
48
  '.meta': UnusedImportMetadata;
49
49
  }>;
50
50
  readonly prettyPrint: {
51
- readonly query: (result: UnusedImportResult) => string;
52
- readonly full: (result: UnusedImportResult) => string;
51
+ readonly query: (r: UnusedImportResult, metadata: unknown) => string;
52
+ readonly full: (r: UnusedImportResult, metadata: unknown) => string;
53
53
  };
54
54
  readonly info: {
55
55
  readonly name: "Unused Import";
@@ -42,18 +42,16 @@ function isReadFrom(graph, id) {
42
42
  */
43
43
  function unusedPackages(attachments, graph, src) {
44
44
  const pending = new Set(attachments.map(a => a.name));
45
- const unbound = new Set();
46
- for (const [id, qualified] of df_helper_1.Dataflow.qualifyAll(graph)) {
45
+ for (const [, qualified] of df_helper_1.Dataflow.qualifyAll(graph)) {
47
46
  const namespace = qualified === undefined ? undefined : identifier_1.Identifier.getNamespace(qualified);
48
- if (namespace !== undefined) {
49
- pending.delete(namespace);
50
- if (pending.size === 0) {
51
- return pending;
52
- }
53
- continue;
47
+ if (namespace !== undefined && pending.delete(namespace) && pending.size === 0) {
48
+ return pending;
54
49
  }
55
- const vertex = graph.getVertex(id);
56
- if (vertex_1.DfgVertex.isFunctionCall(vertex) && isUnbound(graph, id)) {
50
+ }
51
+ /* a call or a read of a name the code binds nowhere, like `percent` in `scale_y_continuous(labels = percent)` */
52
+ const unbound = new Set();
53
+ for (const [id, vertex] of graph.vertices(true)) {
54
+ if (vertex_1.DfgVertex.isFunctionCall(vertex) && identifier_1.Identifier.getNamespace(vertex.name) === undefined && isUnbound(graph, id)) {
57
55
  unbound.add(identifier_1.Identifier.getName(vertex.name));
58
56
  }
59
57
  else if (vertex_1.DfgVertex.isUse(vertex) && isUnbound(graph, id)) {
@@ -153,10 +151,7 @@ exports.UNUSED_IMPORT = {
153
151
  metadata.totalUnused = results.length;
154
152
  return { results, '.meta': metadata };
155
153
  },
156
- prettyPrint: {
157
- [linter_format_1.LintingPrettyPrintContext.Query]: result => `Import of ${result.package} at ${range_1.SourceLocation.format(result.loc)}`,
158
- [linter_format_1.LintingPrettyPrintContext.Full]: result => `Import of ${result.package} at ${range_1.SourceLocation.format(result.loc)} is unused (checked v${result.version}).`
159
- },
154
+ prettyPrint: (0, linter_format_1.prettyPrint)(result => `Import of ${result.package} at ${range_1.SourceLocation.format(result.loc)}`, result => `Import of ${result.package} at ${range_1.SourceLocation.format(result.loc)} is unused (checked v${result.version}).`),
160
155
  info: {
161
156
  name: 'Unused Import',
162
157
  tags: [linter_tags_1.LintingRuleTag.Smell, linter_tags_1.LintingRuleTag.Readability, linter_tags_1.LintingRuleTag.QuickFix],
@@ -1,5 +1,6 @@
1
1
  import type { MergeableRecord } from '../../util/objects';
2
- import { type LintingResult, LintingResultCertainty, LintingRuleCertainty } from '../linter-format';
2
+ import { SourceLocation } from '../../util/range';
3
+ import { type LintingResult, LintingRuleCertainty } from '../linter-format';
3
4
  import { LintingRuleTag } from '../linter-tags';
4
5
  import type { BuiltInProcName } from '../../dataflow/environments/built-in-proc-name';
5
6
  export interface UselessLoopResult extends LintingResult {
@@ -16,18 +17,18 @@ export declare const USELESS_LOOP: {
16
17
  readonly createSearch: () => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter"], import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, Promise<import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, [] | import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>>;
17
18
  readonly processSearchResult: (elements: import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>, useLessLoopConfig: UselessLoopConfig, data: import("../..").ReadonlyFlowrAnalysisProvider<import("../..").KnownParser>) => Promise<{
18
19
  results: {
19
- certainty: LintingResultCertainty.Certain;
20
20
  name: string;
21
- loc: [startLine: number, startColumn: number, endLine: number, endColumn: number, f?: string | undefined];
22
- involvedId: import("../..").NodeId;
21
+ certainty: import("../linter-format").LintingResultCertainty;
22
+ loc: SourceLocation;
23
+ involvedId: import("../..").NodeId | import("../..").NodeId[] | undefined;
23
24
  }[];
24
25
  '.meta': {
25
26
  numOfUselessLoops: number;
26
27
  };
27
28
  }>;
28
29
  readonly prettyPrint: {
29
- readonly query: (result: UselessLoopResult) => string;
30
- readonly full: (result: UselessLoopResult) => string;
30
+ readonly query: (r: UselessLoopResult, metadata: unknown) => string;
31
+ readonly full: (r: UselessLoopResult, metadata: unknown) => string;
31
32
  };
32
33
  readonly info: {
33
34
  readonly name: "Useless Loops";
@@ -5,6 +5,7 @@ const useless_loop_1 = require("../../control-flow/useless-loop");
5
5
  const vertex_1 = require("../../dataflow/graph/vertex");
6
6
  const flowr_search_builder_1 = require("../../search/flowr-search-builder");
7
7
  const range_1 = require("../../util/range");
8
+ const linter_util_1 = require("../linter-util");
8
9
  const linter_format_1 = require("../linter-format");
9
10
  const linter_tags_1 = require("../linter-tags");
10
11
  exports.USELESS_LOOP = {
@@ -20,10 +21,8 @@ exports.USELESS_LOOP = {
20
21
  && vertex.origin !== 'unnamed'
21
22
  && useLessLoopConfig.loopyFunctions.has(vertex.origin[0]);
22
23
  }).filter(loop => (0, useless_loop_1.onlyLoopsOnce)(loop.node.info.id, dataflow.graph, cfg, normalize, data.inspectContext())).map(res => ({
23
- certainty: linter_format_1.LintingResultCertainty.Certain,
24
- name: res.node.lexeme,
25
- loc: range_1.SourceLocation.fromNode(res.node) ?? range_1.SourceLocation.invalid(),
26
- involvedId: res.node.info.id
24
+ ...(0, linter_util_1.at)(res.node),
25
+ name: res.node.lexeme
27
26
  }));
28
27
  return {
29
28
  results: results,
@@ -32,10 +31,7 @@ exports.USELESS_LOOP = {
32
31
  }
33
32
  };
34
33
  },
35
- prettyPrint: {
36
- [linter_format_1.LintingPrettyPrintContext.Query]: result => `${result.name}-loop at ${range_1.SourceLocation.format(result.loc)} only loops once`,
37
- [linter_format_1.LintingPrettyPrintContext.Full]: result => `${result.name}-loop at ${range_1.SourceLocation.format(result.loc)} only loops once`
38
- },
34
+ prettyPrint: (0, linter_format_1.prettyPrint)(result => `${result.name}-loop at ${range_1.SourceLocation.format(result.loc)} only loops once`),
39
35
  info: {
40
36
  name: 'Useless Loops',
41
37
  description: 'Finds loops that iterate only once.',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eagleoutice/flowr",
3
- "version": "2.16.6",
3
+ "version": "2.16.8",
4
4
  "description": "Static Dataflow Analyzer and Program Slicer for the R Programming Language",
5
5
  "engines": {
6
6
  "node": ">=22"
@@ -29,6 +29,9 @@
29
29
  "lodash.isequal": "npm:fast-deep-equal@^3.1.3",
30
30
  "get-uri": {
31
31
  "basic-ftp": "6.2.3"
32
+ },
33
+ "release-it": {
34
+ "undici": "^7.30.1"
32
35
  }
33
36
  },
34
37
  "dependencies": {
@@ -41,13 +44,12 @@
41
44
  "joi": "^18.0.1",
42
45
  "js-yaml": "^4.3.2",
43
46
  "lz-string": "^1.5.0",
44
- "n-readlines": "^3.4.1",
45
47
  "object-hash": "^3.0.0",
46
48
  "object-sizeof": "^2.6.5",
47
49
  "semver": "^7.7.4",
48
50
  "smol-toml": "^1.7.0",
49
51
  "tmp": "^0.2.3",
50
- "ts-essentials": "^10.1.1",
52
+ "ts-essentials": "~10.1.1",
51
53
  "tslog": "^4.10.2",
52
54
  "web-tree-sitter": "^0.24.7",
53
55
  "ws": "^8.18.0"
@@ -22,6 +22,8 @@ export type AnalyzerCacheType<Parser extends KnownParser> = Parser extends TreeS
22
22
  export declare class FlowrAnalyzerCache<Parser extends KnownParser> extends FlowrCache<AnalyzerCacheType<Parser>> {
23
23
  private args;
24
24
  private pipeline;
25
+ /** the steps of the tape run so far, which the next caller waits for */
26
+ private running;
25
27
  private controlFlowCache;
26
28
  private callGraphCache;
27
29
  protected constructor(args: FlowrAnalyzerCacheOptions<Parser>);
@@ -17,6 +17,8 @@ function isTreeSitterParse(parse) {
17
17
  class FlowrAnalyzerCache extends flowr_cache_1.FlowrCache {
18
18
  args;
19
19
  pipeline = undefined;
20
+ /** the steps of the tape run so far, which the next caller waits for */
21
+ running = Promise.resolve();
20
22
  controlFlowCache = undefined;
21
23
  callGraphCache = undefined;
22
24
  constructor(args) {
@@ -67,11 +69,16 @@ class FlowrAnalyzerCache extends flowr_cache_1.FlowrCache {
67
69
  }
68
70
  async runTapeUntil(force, until) {
69
71
  (0, assert_1.guard)(this.args.context.files.hasRequests(), 'At least one request must be set to run the analysis pipeline');
70
- if (force) {
71
- this.reset();
72
- }
73
- /* the contingent belongs to the analysis, so stepping the tape starts one of its own */
74
- return this.args.context.gas.withGas(undefined, () => this.stepTapeUntil(until));
72
+ /* one tape: a second caller, as `analyzer.normalize()` while `analyzer.dataflow()` still runs, waits for the steps before */
73
+ const run = this.running.then(() => {
74
+ if (force) {
75
+ this.reset();
76
+ }
77
+ /* the contingent belongs to the analysis, so stepping the tape starts one of its own */
78
+ return this.args.context.gas.withGas(undefined, () => this.stepTapeUntil(until));
79
+ });
80
+ this.running = run.catch(() => undefined);
81
+ return run;
75
82
  }
76
83
  async stepTapeUntil(until) {
77
84
  let g;
@@ -97,8 +104,7 @@ class FlowrAnalyzerCache extends flowr_cache_1.FlowrCache {
97
104
  * @see {@link FlowrAnalyzerCache#peekParse} - to get the parse output if already available without triggering a new parse.
98
105
  */
99
106
  async parse(force) {
100
- const d = this.get();
101
- return this.runTapeUntil(force, () => d.parse);
107
+ return this.runTapeUntil(force, () => this.get().parse);
102
108
  }
103
109
  /**
104
110
  * Get the parse output for the request if already available, otherwise return `undefined`.
@@ -114,8 +120,7 @@ class FlowrAnalyzerCache extends flowr_cache_1.FlowrCache {
114
120
  * @see {@link FlowrAnalyzerCache#peekNormalize} - to get the normalized AST if already available without triggering a new normalization.
115
121
  */
116
122
  async normalize(force) {
117
- const d = this.get();
118
- return this.runTapeUntil(force, () => d.normalize);
123
+ return this.runTapeUntil(force, () => this.get().normalize);
119
124
  }
120
125
  /**
121
126
  * Get the normalized abstract syntax tree for the request if already available, otherwise return `undefined`.
@@ -131,8 +136,7 @@ class FlowrAnalyzerCache extends flowr_cache_1.FlowrCache {
131
136
  * @see {@link FlowrAnalyzerCache#peekDataflow} - to get the dataflow graph if already available without triggering a new computation.
132
137
  */
133
138
  async dataflow(force) {
134
- const d = this.get();
135
- return this.runTapeUntil(force, () => d.dataflow);
139
+ return this.runTapeUntil(force, () => this.get().dataflow);
136
140
  }
137
141
  /**
138
142
  * Get the dataflow graph for the request if already available, otherwise return `undefined`.
@@ -1,4 +1,5 @@
1
1
  import { AbstractFlowrAnalyzerContext } from './abstract-flowr-analyzer-context';
2
+ import { type RecordedRun } from '../plugins/file-plugins/files/recorded-runs';
2
3
  import type { RParseRequestFromText, RParseRequest, RParseRequestFromFile } from '../../r-bridge/retriever';
3
4
  import type { FlowrAnalyzerLoadingOrderContext, ReadOnlyFlowrAnalyzerLoadingOrderContext } from './flowr-analyzer-loading-order-context';
4
5
  import { FlowrAnalyzerProjectDiscoveryPlugin } from '../plugins/project-discovery/flowr-analyzer-project-discovery-plugin';
@@ -252,6 +253,8 @@ export declare class FlowrAnalyzerFilesContext extends AbstractFlowrAnalyzerCont
252
253
  getFilesByRole<Role extends FileRole>(role: Role): RoleBasedFiles[Role];
253
254
  getAllFiles(): FlowrFileProvider[];
254
255
  getFileByPath(path: string): FlowrFileProvider | undefined;
256
+ /** the runs a notebook or transcript recorded with their output, `undefined` if the file is not found or records none */
257
+ recordedRuns(path: string): readonly RecordedRun[] | undefined;
255
258
  getFileCount(): number;
256
259
  hasRequests(): boolean;
257
260
  }
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.FlowrAnalyzerFilesContext = void 0;
7
7
  const abstract_flowr_analyzer_context_1 = require("./abstract-flowr-analyzer-context");
8
+ const recorded_runs_1 = require("../plugins/file-plugins/files/recorded-runs");
8
9
  const retriever_1 = require("../../r-bridge/retriever");
9
10
  const assert_1 = require("../../util/assert");
10
11
  const flowr_analyzer_project_discovery_plugin_1 = require("../plugins/project-discovery/flowr-analyzer-project-discovery-plugin");
@@ -433,6 +434,11 @@ class FlowrAnalyzerFilesContext extends abstract_flowr_analyzer_context_1.Abstra
433
434
  getFileByPath(path) {
434
435
  return this.files.get(files_1.RPath.of(path)) ?? this.inlineFiles.find(f => f.path() === path);
435
436
  }
437
+ /** the runs a notebook or transcript recorded with their output, `undefined` if the file is not found or records none */
438
+ recordedRuns(path) {
439
+ const file = this.getFileByPath(path);
440
+ return (0, recorded_runs_1.recordsRuns)(file) ? file.recorded() : undefined;
441
+ }
436
442
  getFileCount() {
437
443
  return this.files.size + this.inlineFiles.length;
438
444
  }
@@ -1,10 +1,11 @@
1
1
  import type { FlowrFileProvider } from '../../../context/flowr-file';
2
2
  import { FileRole, FlowrFile } from '../../../context/flowr-file';
3
+ import type { RecordedRun, RecordsRuns } from './recorded-runs';
3
4
  /**
4
5
  * This decorates a text file and parses its contents as a Jupyter file.
5
6
  * Finnaly, it provides access to the single cells, and all cells fused together as one R file.
6
7
  */
7
- export declare class FlowrJupyterFile extends FlowrFile {
8
+ export declare class FlowrJupyterFile extends FlowrFile implements RecordsRuns {
8
9
  private readonly wrapped;
9
10
  /**
10
11
  * Prefer the static {@link FlowrJupyterFile.from} method
@@ -13,6 +14,8 @@ export declare class FlowrJupyterFile extends FlowrFile {
13
14
  constructor(wrapped: FlowrFileProvider<string>);
14
15
  /** The text of the document itself, as its content is only the code it holds. */
15
16
  rawText(): string;
17
+ /** The code cells with the output the notebook recorded for each. */
18
+ recorded(): RecordedRun[];
16
19
  /**
17
20
  * Loads and parses the content of the wrapped file.
18
21
  * @returns RmdInfo
@@ -25,3 +28,5 @@ export declare class FlowrJupyterFile extends FlowrFile {
25
28
  */
26
29
  static from(file: FlowrFileProvider<string> | FlowrJupyterFile, role?: FileRole): FlowrJupyterFile;
27
30
  }
31
+ /** the code cells of a notebook with the output recorded for each */
32
+ export declare function jupyterRecordedRuns(json: string): RecordedRun[];
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FlowrJupyterFile = void 0;
4
+ exports.jupyterRecordedRuns = jupyterRecordedRuns;
4
5
  const flowr_file_1 = require("../../../context/flowr-file");
5
6
  /**
6
7
  * This decorates a text file and parses its contents as a Jupyter file.
@@ -20,6 +21,10 @@ class FlowrJupyterFile extends flowr_file_1.FlowrFile {
20
21
  rawText() {
21
22
  return this.wrapped.content().toString();
22
23
  }
24
+ /** The code cells with the output the notebook recorded for each. */
25
+ recorded() {
26
+ return jupyterRecordedRuns(this.rawText());
27
+ }
23
28
  /**
24
29
  * Loads and parses the content of the wrapped file.
25
30
  * @returns RmdInfo
@@ -40,6 +45,36 @@ class FlowrJupyterFile extends flowr_file_1.FlowrFile {
40
45
  }
41
46
  }
42
47
  exports.FlowrJupyterFile = FlowrJupyterFile;
48
+ /** the code cells of a notebook with the output recorded for each */
49
+ function jupyterRecordedRuns(json) {
50
+ let cells;
51
+ try {
52
+ cells = JSON.parse(json).cells;
53
+ }
54
+ catch {
55
+ return [];
56
+ }
57
+ return !Array.isArray(cells) ? [] : cells.flatMap(cell => cell.cell_type === 'code'
58
+ ? [{ code: joined(cell.source ?? ''), output: outputText(cell.outputs ?? []).trim(), plots: plotCount(cell.outputs ?? []), images: imagesOf(cell.outputs ?? []) }] : []);
59
+ }
60
+ const joined = (text) => typeof text === 'string' ? text : text.join('');
61
+ /** the images the outputs hold, which are the plots */
62
+ const plotCount = (outputs) => outputs.filter(o => Object.keys(o.data ?? {}).some(type => type.startsWith('image/'))).length;
63
+ /** the plots of a cell as data URLs, for the formats a browser shows */
64
+ const imagesOf = (outputs) => outputs.flatMap(o => ['image/png', 'image/jpeg', 'image/gif'].flatMap(type => {
65
+ const data = o.data?.[type];
66
+ return data === undefined ? [] : [`data:${type};base64,${joined(data).replace(/\s/g, '')}`];
67
+ }));
68
+ /** what a cell printed: streams and the plain text of results, and the error a run ended in */
69
+ function outputText(outputs) {
70
+ return outputs.map(o => {
71
+ switch (o.output_type) {
72
+ case 'stream': return joined(o.text);
73
+ case 'error': return `Error: ${o.evalue}`;
74
+ default: return joined((o.data?.['text/plain']) ?? '');
75
+ }
76
+ }).join('\n');
77
+ }
43
78
  function loadJupyter(content) {
44
79
  return JSON.parse(content).cells.map(cell => {
45
80
  const source = typeof cell.source === 'object' ? cell.source.join('') : cell.source;
@@ -7,6 +7,7 @@ exports.getExportedNames = getExportedNames;
7
7
  exports.getCallables = getCallables;
8
8
  exports.setCallable = setCallable;
9
9
  const r_string_1 = require("../../../../r-bridge/lang-4.x/ast/model/nodes/r-string");
10
+ const string_constants_1 = require("../../../../dataflow/eval/values/string/string-constants");
10
11
  const flowr_file_1 = require("../../../context/flowr-file");
11
12
  const resolve_args_1 = require("../../../../abstract-interpretation/data-frame/resolve-args");
12
13
  const fold_1 = require("../../../../r-bridge/lang-4.x/ast/model/processing/fold");
@@ -93,7 +94,7 @@ function isExportedInInfo(name, nsInfo) {
93
94
  }
94
95
  }
95
96
  for (const pattern of nsInfo.exportedPatterns) {
96
- const regex = (0, r_regex_1.parseRRegexPattern)(pattern);
97
+ const regex = (0, r_regex_1.parseRRegexPattern)((0, string_constants_1.unescapeRString)(pattern) ?? pattern);
97
98
  if (regex.test(name)) {
98
99
  return true;
99
100
  }
@@ -0,0 +1,26 @@
1
+ import type { FlowrFileProvider } from '../../../context/flowr-file';
2
+ import { FileRole, FlowrFile } from '../../../context/flowr-file';
3
+ import type { RecordedRun, RecordsRuns } from './recorded-runs';
4
+ /**
5
+ * This decorates a text file and reads it as a transcript of an R console (`.Rout`, `.Rout.save`):
6
+ * the code is the commands behind their prompts, and everything else is kept as a comment, so every line stays where it was.
7
+ */
8
+ export declare class FlowrRSessionFile extends FlowrFile implements RecordsRuns {
9
+ private readonly wrapped;
10
+ /**
11
+ * Prefer the static {@link FlowrRSessionFile.from} method
12
+ * @param wrapped - the file to load as a transcript
13
+ */
14
+ constructor(wrapped: FlowrFileProvider<string>);
15
+ /** The text of the transcript itself, as its content is only the code it holds. */
16
+ rawText(): string;
17
+ /** The commands with the output the transcript recorded for each. */
18
+ recorded(): RecordedRun[];
19
+ protected loadContent(): string;
20
+ /**
21
+ * Lifts a file to a {@link FlowrRSessionFile}, reusing it if already one and assigning roles.
22
+ * @param file - The file to lift or return if already a transcript
23
+ * @param role - An optional role to assign to the file
24
+ */
25
+ static from(file: FlowrFileProvider<string> | FlowrRSessionFile, role?: FileRole): FlowrRSessionFile;
26
+ }
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FlowrRSessionFile = void 0;
4
+ const flowr_file_1 = require("../../../context/flowr-file");
5
+ const r_session_1 = require("./r-session");
6
+ /**
7
+ * This decorates a text file and reads it as a transcript of an R console (`.Rout`, `.Rout.save`):
8
+ * the code is the commands behind their prompts, and everything else is kept as a comment, so every line stays where it was.
9
+ */
10
+ class FlowrRSessionFile extends flowr_file_1.FlowrFile {
11
+ wrapped;
12
+ /**
13
+ * Prefer the static {@link FlowrRSessionFile.from} method
14
+ * @param wrapped - the file to load as a transcript
15
+ */
16
+ constructor(wrapped) {
17
+ super(wrapped.path(), wrapped.roles ? [...wrapped.roles, flowr_file_1.FileRole.Source] : [flowr_file_1.FileRole.Source]);
18
+ this.wrapped = wrapped;
19
+ }
20
+ /** The text of the transcript itself, as its content is only the code it holds. */
21
+ rawText() {
22
+ return this.wrapped.content().toString();
23
+ }
24
+ /** The commands with the output the transcript recorded for each. */
25
+ recorded() {
26
+ return (0, r_session_1.recordedRuns)(this.rawText());
27
+ }
28
+ loadContent() {
29
+ return (0, r_session_1.sessionAsScript)(this.rawText());
30
+ }
31
+ /**
32
+ * Lifts a file to a {@link FlowrRSessionFile}, reusing it if already one and assigning roles.
33
+ * @param file - The file to lift or return if already a transcript
34
+ * @param role - An optional role to assign to the file
35
+ */
36
+ static from(file, role) {
37
+ if (role) {
38
+ file.assignRole(role);
39
+ }
40
+ return file instanceof FlowrRSessionFile ? file : new FlowrRSessionFile(file);
41
+ }
42
+ }
43
+ exports.FlowrRSessionFile = FlowrRSessionFile;
44
+ //# sourceMappingURL=flowr-rsession-file.js.map
@@ -0,0 +1,20 @@
1
+ /** R console transcripts: `> ` input lines, `+ ` continuations, and recorded output in between */
2
+ import type { RecordedRun } from './recorded-runs';
3
+ export interface SessionSegment {
4
+ readonly kind: 'input' | 'output';
5
+ readonly lines: readonly string[];
6
+ /** 1-based line of the first line */
7
+ readonly firstLine: number;
8
+ }
9
+ /** the width of `> ` and `+ `, which the code of a line starts behind */
10
+ export declare const PromptWidth = 2;
11
+ /** whether a file is a console transcript, by its name or by its first non-blank line starting with a prompt */
12
+ export declare function isRSession(name: string, text: string): boolean;
13
+ /** the transcript as runs of input (a command with its continuations) and output; blank lines are output */
14
+ export declare function parseRSession(text: string): SessionSegment[];
15
+ /** the code of an input line, behind its prompt */
16
+ export declare const codeOfInput: (line: string) => string;
17
+ /** the script flowR reads: prompts blanked to the same width, output as comments, every line where it was */
18
+ export declare function sessionAsScript(text: string): string;
19
+ /** the commands of a transcript with the output recorded below each */
20
+ export declare function recordedRuns(text: string): RecordedRun[];