@eagleoutice/flowr 2.14.1 → 2.14.2

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 (413) hide show
  1. package/README.md +154 -87
  2. package/abstract-interpretation/absint-visitor.d.ts +91 -25
  3. package/abstract-interpretation/absint-visitor.js +235 -74
  4. package/abstract-interpretation/data-frame/mappers/access-mapper.d.ts +1 -1
  5. package/abstract-interpretation/data-frame/mappers/access-mapper.js +4 -4
  6. package/abstract-interpretation/data-frame/mappers/arguments.d.ts +1 -1
  7. package/abstract-interpretation/data-frame/mappers/arguments.js +1 -1
  8. package/abstract-interpretation/data-frame/mappers/function-mapper.js +107 -254
  9. package/abstract-interpretation/data-frame/mappers/replacement-mapper.js +5 -5
  10. package/abstract-interpretation/data-frame/resolve-args.d.ts +1 -1
  11. package/abstract-interpretation/data-frame/resolve-args.js +6 -4
  12. package/abstract-interpretation/data-frame/shape-inference.d.ts +4 -9
  13. package/abstract-interpretation/domains/bounded-set-domain.d.ts +1 -0
  14. package/abstract-interpretation/domains/bounded-set-domain.js +1 -0
  15. package/abstract-interpretation/domains/partial-product-domain.js +1 -1
  16. package/abstract-interpretation/domains/set-range-domain.d.ts +3 -2
  17. package/abstract-interpretation/domains/set-range-domain.js +3 -2
  18. package/abstract-interpretation/domains/set-upper-bound-domain.d.ts +3 -2
  19. package/abstract-interpretation/domains/set-upper-bound-domain.js +3 -2
  20. package/benchmark/calibration.d.ts +11 -6
  21. package/benchmark/calibration.js +19 -8
  22. package/benchmark/slicer.d.ts +7 -1
  23. package/benchmark/slicer.js +38 -34
  24. package/benchmark/stats/count-comments.d.ts +16 -0
  25. package/benchmark/stats/count-comments.js +30 -0
  26. package/benchmark/stats/print.js +2 -0
  27. package/benchmark/stats/size-of.d.ts +7 -3
  28. package/benchmark/stats/size-of.js +7 -3
  29. package/benchmark/stats/stats.d.ts +7 -0
  30. package/benchmark/summarizer/first-phase/process.js +2 -19
  31. package/benchmark/summarizer/second-phase/graph.js +13 -3
  32. package/benchmark/summarizer/second-phase/process.js +2 -0
  33. package/cli/repl/commands/repl-dataflow.js +70 -27
  34. package/cli/repl/core.d.ts +1 -1
  35. package/cli/repl/core.js +1 -1
  36. package/cli/repl/parser/slice-query-parser.js +2 -1
  37. package/cli/repl/server/connection.d.ts +4 -0
  38. package/cli/repl/server/connection.js +19 -16
  39. package/cli/repl/server/messages/message-analysis.d.ts +1 -1
  40. package/config.d.ts +6 -0
  41. package/config.js +8 -4
  42. package/control-flow/basic-cfg-guided-visitor.d.ts +7 -2
  43. package/control-flow/basic-cfg-guided-visitor.js +37 -24
  44. package/control-flow/cfg-dead-code.js +44 -33
  45. package/control-flow/cfg-properties.js +2 -2
  46. package/control-flow/cfg-simplification.js +6 -5
  47. package/control-flow/cfg-to-basic-blocks.js +11 -13
  48. package/control-flow/control-flow-graph.d.ts +179 -189
  49. package/control-flow/control-flow-graph.js +400 -263
  50. package/control-flow/dfg-cfg-guided-visitor.d.ts +21 -3
  51. package/control-flow/dfg-cfg-guided-visitor.js +17 -13
  52. package/control-flow/diff-cfg.js +6 -14
  53. package/control-flow/happens-before.js +5 -4
  54. package/control-flow/semantic-cfg-guided-visitor.d.ts +44 -101
  55. package/control-flow/semantic-cfg-guided-visitor.js +6 -26
  56. package/control-flow/simple-visitor.js +14 -15
  57. package/control-flow/syntax-cfg-guided-visitor.d.ts +2 -1
  58. package/control-flow/useless-loop.js +18 -14
  59. package/core/steps/all/core/20-dataflow.d.ts +1 -3
  60. package/core/steps/pipeline/default-pipelines.d.ts +141 -157
  61. package/dataflow/cluster.js +7 -0
  62. package/dataflow/environments/apply-kill.d.ts +6 -0
  63. package/dataflow/environments/apply-kill.js +63 -31
  64. package/dataflow/environments/built-in-props.d.ts +5 -1
  65. package/dataflow/environments/built-in-props.js +4 -0
  66. package/dataflow/environments/built-in.d.ts +6 -3
  67. package/dataflow/environments/built-in.js +8 -5
  68. package/dataflow/environments/clone.d.ts +3 -3
  69. package/dataflow/environments/clone.js +5 -5
  70. package/dataflow/environments/default-builtin-config.d.ts +112 -7
  71. package/dataflow/environments/default-builtin-config.js +82 -34
  72. package/dataflow/environments/environment.d.ts +5 -5
  73. package/dataflow/environments/environment.js +5 -5
  74. package/dataflow/environments/identifier.d.ts +11 -1
  75. package/dataflow/environments/identifier.js +4 -1
  76. package/dataflow/environments/resolve-by-name.d.ts +7 -0
  77. package/dataflow/environments/resolve-by-name.js +12 -0
  78. package/dataflow/environments/resolve-helper.d.ts +3 -1
  79. package/dataflow/environments/resolve-helper.js +2 -0
  80. package/dataflow/eval/resolve/alias-tracking.d.ts +2 -2
  81. package/dataflow/eval/resolve/alias-tracking.js +2 -2
  82. package/dataflow/eval/resolve/match-arguments.js +7 -5
  83. package/dataflow/eval/resolve/node-value.d.ts +3 -1
  84. package/dataflow/eval/resolve/node-value.js +12 -0
  85. package/dataflow/eval/resolve/resolve-argument.js +5 -4
  86. package/dataflow/eval/resolve/resolve-operators.js +9 -6
  87. package/dataflow/eval/resolve/resolve-strings.js +2 -2
  88. package/dataflow/eval/resolve/resolve-working-directory.js +4 -3
  89. package/dataflow/eval/resolve/resolve.js +3 -2
  90. package/dataflow/eval/values/general.js +8 -5
  91. package/dataflow/extractor.d.ts +1 -4
  92. package/dataflow/extractor.js +11 -10
  93. package/dataflow/fn/exceptions-of-function.d.ts +3 -1
  94. package/dataflow/fn/strict-function.js +7 -5
  95. package/dataflow/graph/call-graph.js +2 -2
  96. package/dataflow/graph/df-helper.d.ts +8 -1
  97. package/dataflow/graph/diff-dataflow-graph.d.ts +1 -1
  98. package/dataflow/graph/diff-dataflow-graph.js +19 -2
  99. package/dataflow/graph/edge.d.ts +38 -2
  100. package/dataflow/graph/edge.js +32 -2
  101. package/dataflow/graph/graph.d.ts +4 -3
  102. package/dataflow/graph/graph.js +6 -2
  103. package/dataflow/graph/match-args.d.ts +69 -0
  104. package/dataflow/graph/match-args.js +167 -0
  105. package/dataflow/info.d.ts +14 -0
  106. package/dataflow/internal/control-flow.d.ts +102 -0
  107. package/dataflow/internal/control-flow.js +200 -0
  108. package/dataflow/internal/linker.d.ts +6 -31
  109. package/dataflow/internal/linker.js +24 -81
  110. package/dataflow/internal/process/functions/call/argument/unpack-argument.d.ts +1 -1
  111. package/dataflow/internal/process/functions/call/argument/unpack-argument.js +3 -3
  112. package/dataflow/internal/process/functions/call/built-in/built-in-access.d.ts +2 -2
  113. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +9 -6
  114. package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +1 -1
  115. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +6 -4
  116. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +1 -10
  117. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +18 -37
  118. package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +1 -1
  119. package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +3 -3
  120. package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.d.ts +1 -1
  121. package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +11 -7
  122. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +6 -8
  123. package/dataflow/internal/process/functions/call/built-in/built-in-eval.d.ts +1 -1
  124. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +18 -14
  125. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +8 -1
  126. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +11 -0
  127. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +2 -1
  128. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +27 -20
  129. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +3 -2
  130. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.d.ts +1 -1
  131. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +35 -6
  132. package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +1 -1
  133. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +20 -17
  134. package/dataflow/internal/process/functions/call/built-in/built-in-list.d.ts +1 -1
  135. package/dataflow/internal/process/functions/call/built-in/built-in-list.js +6 -4
  136. package/dataflow/internal/process/functions/call/built-in/built-in-load.js +4 -3
  137. package/dataflow/internal/process/functions/call/built-in/built-in-local.js +8 -3
  138. package/dataflow/internal/process/functions/call/built-in/built-in-namespace-access.d.ts +2 -2
  139. package/dataflow/internal/process/functions/call/built-in/built-in-namespace-access.js +5 -5
  140. package/dataflow/internal/process/functions/call/built-in/built-in-new-env.d.ts +1 -1
  141. package/dataflow/internal/process/functions/call/built-in/built-in-new-env.js +5 -4
  142. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +7 -5
  143. package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.d.ts +1 -1
  144. package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.js +15 -13
  145. package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +2 -2
  146. package/dataflow/internal/process/functions/call/built-in/built-in-recall.js +2 -2
  147. package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.js +4 -3
  148. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.d.ts +1 -1
  149. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +26 -4
  150. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.d.ts +2 -2
  151. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +17 -4
  152. package/dataflow/internal/process/functions/call/built-in/built-in-rm.d.ts +2 -2
  153. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +71 -33
  154. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +6 -15
  155. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +12 -13
  156. package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +1 -1
  157. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +14 -11
  158. package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.js +15 -1
  159. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.d.ts +1 -1
  160. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +12 -8
  161. package/dataflow/internal/process/functions/call/built-in/built-in-stop-if-not.js +6 -5
  162. package/dataflow/internal/process/functions/call/built-in/built-in-string-template.d.ts +1 -1
  163. package/dataflow/internal/process/functions/call/built-in/built-in-string-template.js +5 -4
  164. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +2 -2
  165. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +45 -10
  166. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.d.ts +2 -2
  167. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +19 -3
  168. package/dataflow/internal/process/functions/call/built-in/built-in-with.js +6 -2
  169. package/dataflow/internal/process/functions/call/common.js +5 -6
  170. package/dataflow/internal/process/functions/call/deferred.js +2 -2
  171. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +12 -2
  172. package/dataflow/internal/process/functions/call/known-call-handling.js +23 -1
  173. package/dataflow/internal/process/functions/call/named-call-handling.js +2 -0
  174. package/dataflow/internal/process/functions/call/nse.d.ts +1 -1
  175. package/dataflow/internal/process/functions/call/nse.js +6 -1
  176. package/dataflow/internal/process/functions/call/quoted.js +2 -2
  177. package/dataflow/internal/process/functions/call/unnamed-call-handling.js +19 -6
  178. package/dataflow/internal/process/functions/process-argument.d.ts +1 -1
  179. package/dataflow/internal/process/functions/process-argument.js +12 -4
  180. package/dataflow/internal/process/functions/process-parameter.js +13 -0
  181. package/dataflow/internal/process/process-named-call.d.ts +2 -2
  182. package/dataflow/internal/process/process-named-call.js +9 -7
  183. package/documentation/data/server/doc-data-server-messages.js +4 -4
  184. package/documentation/doc-readme.js +45 -0
  185. package/documentation/doc-util/doc-cfg.d.ts +8 -7
  186. package/documentation/doc-util/doc-cfg.js +10 -10
  187. package/documentation/doc-util/doc-playground.d.ts +12 -0
  188. package/documentation/doc-util/doc-playground.js +21 -0
  189. package/documentation/doc-util/doc-query.d.ts +4 -1
  190. package/documentation/doc-util/doc-query.js +4 -2
  191. package/documentation/wiki-absint.d.ts +3 -4
  192. package/documentation/wiki-absint.js +12 -5
  193. package/documentation/wiki-analyzer.js +2 -2
  194. package/documentation/wiki-cfg.js +101 -106
  195. package/documentation/wiki-dataflow-graph.js +84 -53
  196. package/documentation/wiki-linter.js +15 -1
  197. package/documentation/wiki-linting-and-testing.js +1 -16
  198. package/documentation/wiki-mk/doc-maker.js +6 -4
  199. package/documentation/wiki-query.js +14 -4
  200. package/documentation/wiki-signature-database.js +28 -2
  201. package/linter/linter-fix.d.ts +16 -0
  202. package/linter/linter-fix.js +104 -0
  203. package/linter/linter-format.d.ts +18 -1
  204. package/linter/linter-format.js +31 -1
  205. package/linter/linter-output.js +46 -10
  206. package/linter/linter-rules.d.ts +40 -9
  207. package/linter/linter-rules.js +2 -0
  208. package/linter/rules/absolute-path.js +4 -2
  209. package/linter/rules/dataframe-access-validation.js +6 -7
  210. package/linter/rules/deprecated-functions.d.ts +107 -10
  211. package/linter/rules/deprecated-functions.js +309 -23
  212. package/linter/rules/file-path-validity.js +5 -4
  213. package/linter/rules/function-finder-util.d.ts +6 -0
  214. package/linter/rules/function-finder-util.js +21 -13
  215. package/linter/rules/naming-convention.js +1 -1
  216. package/linter/rules/network-functions.d.ts +2 -2
  217. package/linter/rules/stop-with-call-arg.js +2 -2
  218. package/linter/rules/unclosed-connection.js +2 -2
  219. package/linter/rules/undefined-symbol-util.js +6 -4
  220. package/linter/rules/undefined-symbol.js +2 -2
  221. package/linter/rules/unused-definition.js +8 -4
  222. package/linter/rules/unused-import.d.ts +60 -0
  223. package/linter/rules/unused-import.js +179 -0
  224. package/package.json +2 -2
  225. package/project/attached-packages.js +2 -1
  226. package/project/cache/flowr-analyzer-cache.d.ts +2 -5
  227. package/project/cache/flowr-analyzer-cache.js +4 -7
  228. package/project/cache/flowr-analyzer-controlflow-cache.d.ts +9 -8
  229. package/project/cache/flowr-analyzer-controlflow-cache.js +17 -34
  230. package/project/cache/flowr-cache.d.ts +9 -0
  231. package/project/cache/flowr-cache.js +19 -0
  232. package/project/context/flowr-analyzer-context.d.ts +7 -3
  233. package/project/context/flowr-analyzer-context.js +15 -9
  234. package/project/context/flowr-analyzer-dependencies-context.d.ts +24 -3
  235. package/project/context/flowr-analyzer-dependencies-context.js +9 -14
  236. package/project/context/flowr-analyzer-files-context.js +15 -17
  237. package/project/context/flowr-analyzer-meta-context.js +2 -12
  238. package/project/dependency-version-space.d.ts +0 -7
  239. package/project/dependency-version-space.js +8 -7
  240. package/project/flowr-analyzer.d.ts +4 -6
  241. package/project/flowr-analyzer.js +4 -5
  242. package/project/plugins/file-plugins/files/flowr-namespace-file.js +22 -34
  243. package/project/plugins/file-plugins/files/flowr-rda-file.d.ts +13 -13
  244. package/project/plugins/file-plugins/files/flowr-rda-file.js +131 -286
  245. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +1 -0
  246. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +1 -0
  247. package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.d.ts +2 -5
  248. package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.js +2 -8
  249. package/project/plugins/file-plugins/flowr-analyzer-file-plugin.d.ts +32 -0
  250. package/project/plugins/file-plugins/flowr-analyzer-file-plugin.js +43 -1
  251. package/project/plugins/file-plugins/flowr-analyzer-inst-file-plugin.d.ts +4 -12
  252. package/project/plugins/file-plugins/flowr-analyzer-inst-file-plugin.js +3 -16
  253. package/project/plugins/file-plugins/flowr-analyzer-license-file-plugin.d.ts +5 -8
  254. package/project/plugins/file-plugins/flowr-analyzer-license-file-plugin.js +4 -10
  255. package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.d.ts +3 -10
  256. package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.js +1 -13
  257. package/project/plugins/file-plugins/flowr-analyzer-namespace-files-plugin.d.ts +3 -6
  258. package/project/plugins/file-plugins/flowr-analyzer-namespace-files-plugin.js +2 -8
  259. package/project/plugins/file-plugins/flowr-analyzer-news-file-plugin.d.ts +2 -5
  260. package/project/plugins/file-plugins/flowr-analyzer-news-file-plugin.js +2 -8
  261. package/project/plugins/file-plugins/flowr-analyzer-rda-file-plugin.d.ts +2 -5
  262. package/project/plugins/file-plugins/flowr-analyzer-rda-file-plugin.js +2 -8
  263. package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.d.ts +3 -4
  264. package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.js +3 -6
  265. package/project/plugins/file-plugins/flowr-analyzer-test-file-plugin.d.ts +4 -12
  266. package/project/plugins/file-plugins/flowr-analyzer-test-file-plugin.js +3 -16
  267. package/project/plugins/file-plugins/flowr-analyzer-vignette-file-plugin.d.ts +4 -12
  268. package/project/plugins/file-plugins/flowr-analyzer-vignette-file-plugin.js +3 -16
  269. package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.d.ts +4 -12
  270. package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.js +3 -16
  271. package/project/plugins/file-plugins/notebooks/flowr-analyzer-jupyter-file-plugin.d.ts +2 -5
  272. package/project/plugins/file-plugins/notebooks/flowr-analyzer-jupyter-file-plugin.js +2 -8
  273. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmarkdown-file-plugin.d.ts +2 -6
  274. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmarkdown-file-plugin.js +1 -10
  275. package/project/plugins/file-plugins/notebooks/flowr-analyzer-sweave-file-plugin.d.ts +2 -5
  276. package/project/plugins/file-plugins/notebooks/flowr-analyzer-sweave-file-plugin.js +2 -8
  277. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-library-plugin.js +2 -1
  278. package/project/sigdb/build.d.ts +2 -2
  279. package/project/sigdb/decode.d.ts +0 -5
  280. package/project/sigdb/decode.js +0 -8
  281. package/project/sigdb/index-format.d.ts +4 -4
  282. package/project/sigdb/manifest.d.ts +2 -2
  283. package/project/sigdb/reader.d.ts +48 -13
  284. package/project/sigdb/reader.js +2 -1
  285. package/project/sigdb/schema.d.ts +3 -1
  286. package/project/sigdb/signature-db.d.ts +69 -0
  287. package/project/sigdb/signature-db.js +54 -0
  288. package/project/sigdb/signature-match.d.ts +10 -5
  289. package/project/sigdb/signature-match.js +13 -8
  290. package/queries/catalog/absint-query/absint-query-executor.js +1 -2
  291. package/queries/catalog/call-context-query/call-context-query-executor.js +2 -4
  292. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.d.ts +1 -1
  293. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +33 -6
  294. package/queries/catalog/control-flow-query/control-flow-query-executor.js +1 -2
  295. package/queries/catalog/dependencies-query/dependencies-query-executor.js +2 -2
  296. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +8 -7
  297. package/queries/catalog/dependencies-query/dependencies-query-format.js +22 -35
  298. package/queries/catalog/dependencies-query/function-info/library-functions.d.ts +13 -1
  299. package/queries/catalog/dependencies-query/function-info/library-functions.js +26 -22
  300. package/queries/catalog/dependencies-query/function-info/statistics-functions.d.ts +9 -0
  301. package/queries/catalog/dependencies-query/function-info/statistics-functions.js +19 -0
  302. package/queries/catalog/dependencies-query/implicit-echo.d.ts +13 -0
  303. package/queries/catalog/dependencies-query/implicit-echo.js +133 -0
  304. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +2 -2
  305. package/queries/catalog/happens-before-query/happens-before-query-executor.js +1 -2
  306. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.d.ts +2 -2
  307. package/queries/catalog/signature-query/signature-query-executor.js +4 -3
  308. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +1 -1
  309. package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.d.ts +1 -0
  310. package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.js +1 -0
  311. package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +1 -0
  312. package/r-bridge/lang-4.x/ast/model/nodes/r-access.js +1 -0
  313. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +4 -1
  314. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.js +5 -2
  315. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +1 -0
  316. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.js +1 -0
  317. package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +1 -0
  318. package/r-bridge/lang-4.x/ast/model/nodes/r-break.js +1 -0
  319. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +1 -0
  320. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.js +1 -0
  321. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +1 -0
  322. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.js +1 -0
  323. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +1 -0
  324. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.js +1 -0
  325. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +6 -4
  326. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +6 -4
  327. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +1 -0
  328. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.js +1 -0
  329. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +1 -0
  330. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.js +1 -0
  331. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +1 -0
  332. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.js +1 -0
  333. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +1 -0
  334. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.js +1 -0
  335. package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +1 -0
  336. package/r-bridge/lang-4.x/ast/model/nodes/r-next.js +1 -0
  337. package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +6 -0
  338. package/r-bridge/lang-4.x/ast/model/nodes/r-number.js +13 -0
  339. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +1 -0
  340. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.js +1 -0
  341. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +1 -0
  342. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.js +1 -0
  343. package/r-bridge/lang-4.x/ast/model/nodes/r-project.d.ts +1 -0
  344. package/r-bridge/lang-4.x/ast/model/nodes/r-project.js +1 -0
  345. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +1 -0
  346. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.js +1 -0
  347. package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +1 -0
  348. package/r-bridge/lang-4.x/ast/model/nodes/r-string.js +1 -0
  349. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +1 -0
  350. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.js +1 -0
  351. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +1 -0
  352. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.js +1 -0
  353. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +1 -0
  354. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.js +1 -0
  355. package/r-bridge/lang-4.x/ast/model/processing/decorate.js +2 -1
  356. package/r-bridge/lang-4.x/ast/model/processing/stateful-fold.d.ts +1 -1
  357. package/r-bridge/lang-4.x/ast/model/processing/stateful-fold.js +3 -2
  358. package/r-bridge/lang-4.x/ast/parser/main/internal/control/normalize-if-then-else.js +2 -1
  359. package/r-bridge/lang-4.x/ast/parser/main/internal/control/normalize-if-then.js +2 -1
  360. package/r-bridge/lang-4.x/ast/parser/main/internal/expression/normalize-expression.js +1 -1
  361. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-argument.js +2 -1
  362. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.d.ts +2 -2
  363. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.js +6 -3
  364. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-definition.js +2 -1
  365. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-parameter.js +2 -1
  366. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-for.js +5 -3
  367. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-repeat.js +2 -1
  368. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-while.js +2 -1
  369. package/r-bridge/lang-4.x/ast/parser/main/internal/normalize-access.js +2 -1
  370. package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-binary.js +5 -3
  371. package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-unary.js +2 -1
  372. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-expressions.d.ts +1 -1
  373. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-expressions.js +2 -1
  374. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-root.js +3 -1
  375. package/r-bridge/lang-4.x/ast/parser/main/normalize-meta.d.ts +1 -1
  376. package/r-bridge/lang-4.x/ast/parser/main/normalize-meta.js +2 -1
  377. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +5 -3
  378. package/reconstruct/inline/source-inline-map.js +3 -3
  379. package/reconstruct/reconstruct.js +6 -4
  380. package/search/flowr-search-builder.d.ts +8 -8
  381. package/search/flowr-search-builder.js +4 -4
  382. package/search/flowr-search-filters.d.ts +2 -2
  383. package/search/flowr-search-filters.js +3 -2
  384. package/search/search-executor/search-enrichers.d.ts +6 -4
  385. package/search/search-executor/search-enrichers.js +44 -5
  386. package/slicing/criterion/filters/all-variables.js +2 -1
  387. package/slicing/criterion/parse.js +8 -6
  388. package/slicing/static/slice-call.js +2 -2
  389. package/util/arg-matching.d.ts +3 -0
  390. package/util/arg-matching.js +12 -1
  391. package/util/collections/arrays.d.ts +0 -4
  392. package/util/collections/arrays.js +4 -26
  393. package/util/diff-graph.d.ts +1 -1
  394. package/util/diff-graph.js +17 -3
  395. package/util/diff.d.ts +6 -0
  396. package/util/mermaid/ast.d.ts +1 -1
  397. package/util/mermaid/ast.js +5 -4
  398. package/util/mermaid/cfg.js +130 -24
  399. package/util/mermaid/dfg.js +31 -10
  400. package/util/mermaid/mermaid.js +2 -0
  401. package/util/objects.d.ts +9 -0
  402. package/util/objects.js +12 -0
  403. package/util/prefix.d.ts +1 -1
  404. package/util/text/playground-link.d.ts +131 -0
  405. package/util/text/playground-link.js +214 -0
  406. package/util/text/strings.js +7 -3
  407. package/util/version.js +1 -1
  408. package/control-flow/cfg-builder.d.ts +0 -30
  409. package/control-flow/cfg-builder.js +0 -79
  410. package/control-flow/extract-cfg.d.ts +0 -36
  411. package/control-flow/extract-cfg.js +0 -693
  412. package/project/cfg-kind.d.ts +0 -21
  413. package/project/cfg-kind.js +0 -26
@@ -9,6 +9,8 @@ const auto_select_defaults_1 = require("../../reconstruct/auto-select/auto-selec
9
9
  const info_1 = require("./info");
10
10
  const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
11
11
  const mermaid_1 = require("./mermaid");
12
+ const r_function_definition_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
13
+ const convert_values_1 = require("../../r-bridge/lang-4.x/convert-values");
12
14
  exports.MermaidEntryPointDefaultMarkStyle = 'stroke:cyan,stroke-width:6.5px;';
13
15
  exports.MermaidExitPointDefaultMarkStyle = 'stroke:green,stroke-width:6.5px;';
14
16
  function getLexeme(n) {
@@ -18,28 +20,107 @@ function cfgOfNode(vert, normalizedVertex, id, content, output) {
18
20
  if (normalizedVertex && content !== undefined) {
19
21
  const start = control_flow_graph_1.CfgVertex.isExpression(vert) ? '([' : '[';
20
22
  const end = control_flow_graph_1.CfgVertex.isExpression(vert) ? '])' : ']';
21
- const name = `"\`${mermaid_1.Mermaid.escape(normalizedVertex.type)} (${id})${content ? '\n' + mermaid_1.Mermaid.escape(JSON.stringify(content)) : ''}${control_flow_graph_1.CfgVertex.getCallTargets(vert) ? '\n calls:' + mermaid_1.Mermaid.escape(JSON.stringify([...control_flow_graph_1.CfgVertex.getCallTargets(vert)])) : ''}\`"`;
23
+ /* the code is set in bold so it stands out from the type and id above it */
24
+ const code = content ? `\n**${mermaid_1.Mermaid.escape(content.replaceAll(/\s+/gu, ' '))}**` : '';
25
+ const calls = control_flow_graph_1.CfgVertex.getCallTargets(vert) ? '\n calls:' + mermaid_1.Mermaid.escape(JSON.stringify([...control_flow_graph_1.CfgVertex.getCallTargets(vert)])) : '';
26
+ const name = `"\`${mermaid_1.Mermaid.escape(normalizedVertex.type)} (${id})${code}${calls}\`"`;
22
27
  output += ` n${id}${start}${name}${end}\n`;
23
28
  }
24
29
  else {
25
- output += String(id).endsWith('-exit') ? ` n${id}((${id}))\n` : ` n${id}[[${id}]]\n`;
30
+ output += ` n${id}[[${id}]]\n`;
26
31
  }
27
32
  return output;
28
33
  }
29
34
  const getDirRegex = /flowchart\s+([A-Za-z]+)/;
35
+ /**
36
+ * The vertices that make up each function body, keyed by the definition that holds it.
37
+ * Nothing flows into such a region, so it is reachable only from the entry the definition points at.
38
+ */
39
+ function collectBodies(graph) {
40
+ const bodies = new Map();
41
+ for (const [id] of graph.vertices(false)) {
42
+ const children = graph.childrenOf(id);
43
+ if (children === undefined || children.length === 0) {
44
+ continue;
45
+ }
46
+ const body = new Set();
47
+ const stack = [...children];
48
+ while (stack.length > 0) {
49
+ const current = stack.pop();
50
+ if (body.has(current)) {
51
+ continue;
52
+ }
53
+ body.add(current);
54
+ for (const next of graph.successors(current)) {
55
+ stack.push(next);
56
+ }
57
+ }
58
+ bodies.set(id, [...body]);
59
+ }
60
+ return bodies;
61
+ }
62
+ /**
63
+ * The region a vertex belongs to: the function definition it is part of and whether it sits in its parameter list.
64
+ * A definition itself belongs to the region it is written in, not to the one it opens.
65
+ */
66
+ function regionOf(id, normalizedAst) {
67
+ let current = normalizedAst.idMap.get(id);
68
+ current = current?.info.parent === undefined ? undefined : normalizedAst.idMap.get(current.info.parent);
69
+ let inParameters = false;
70
+ while (current !== undefined) {
71
+ inParameters ||= current.info.role === "param" /* RoleInParent.FunctionDefinitionParameter */;
72
+ if (r_function_definition_1.RFunctionDefinition.is(current)) {
73
+ return `${current.info.id}-${inParameters ? 'parameters' : 'body'}`;
74
+ }
75
+ current = current.info.parent === undefined ? undefined : normalizedAst.idMap.get(current.info.parent);
76
+ }
77
+ return 'top-level';
78
+ }
79
+ /**
80
+ * The code a simplified basic block stands for.
81
+ * Its elements are reconstructed per region, so the parameters of a function do not end up looking like its body,
82
+ * and a run that reconstructs to nothing but braces is named by its vertices instead.
83
+ */
84
+ function blockCode(elems, normalizedAst) {
85
+ const runs = [];
86
+ let lastRegion = undefined;
87
+ for (const elem of elems) {
88
+ const region = regionOf(control_flow_graph_1.CfgVertex.getId(elem), normalizedAst);
89
+ if (region !== lastRegion) {
90
+ runs.push([]);
91
+ lastRegion = region;
92
+ }
93
+ runs[runs.length - 1].push(elem);
94
+ }
95
+ return runs.map(run => {
96
+ const code = (0, reconstruct_1.reconstructToCode)(normalizedAst, { nodes: new Set(run.map(control_flow_graph_1.CfgVertex.getId)) }, auto_select_defaults_1.doNotAutoSelect).code;
97
+ if (/[\p{L}\p{N}]/u.test(code)) {
98
+ return code;
99
+ }
100
+ /* nothing but braces means these vertices are where a structure is over, so we name them as the graph does */
101
+ return run.map(elem => `${normalizedAst.idMap.get(control_flow_graph_1.CfgVertex.getId(elem))?.type} (${control_flow_graph_1.CfgVertex.getId(elem)})`).join('\n');
102
+ }).join('\n');
103
+ }
104
+ /**
105
+ * Name the condition a branch is decided by, which is where the branch starts from.
106
+ * Within a basic block that is its last element, so an edge still tells what triggers it.
107
+ */
108
+ function conditionName(cfg, normalizedAst, from) {
109
+ const vertex = cfg.graph.getVertex(from);
110
+ const condition = control_flow_graph_1.CfgVertex.isBlock(vertex) ? control_flow_graph_1.CfgVertex.getId(control_flow_graph_1.CfgVertex.getBasicBlockElements(vertex).at(-1)) ?? from : from;
111
+ const lexeme = getLexeme(normalizedAst.idMap.get(condition));
112
+ return lexeme ? `${lexeme} (${condition})` : String(condition);
113
+ }
30
114
  function shouldIncludeNode(simplify, v, include) {
31
115
  if (simplify) {
32
116
  // Only basic blocks are shown, so include the BB, if at least one child is selected
33
117
  return control_flow_graph_1.CfgVertex.isBlock(v) && control_flow_graph_1.CfgVertex.getBasicBlockElements(v)
34
- .filter(elem => !control_flow_graph_1.CfgVertex.isMarker(elem))
35
118
  .some(elem => include.has(control_flow_graph_1.CfgVertex.getId(elem)));
36
119
  }
37
120
  else {
38
121
  // Basic blocks and vertices are shown, include the BB, if all children are highlighted
39
122
  return control_flow_graph_1.CfgVertex.isBlock(v)
40
- ? control_flow_graph_1.CfgVertex.getBasicBlockElements(v)
41
- .filter(elem => !control_flow_graph_1.CfgVertex.isMarker(elem))
42
- .every(elem => include.has(control_flow_graph_1.CfgVertex.getId(elem)))
123
+ ? control_flow_graph_1.CfgVertex.getBasicBlockElements(v).every(elem => include.has(control_flow_graph_1.CfgVertex.getId(elem)))
43
124
  : include.has(control_flow_graph_1.CfgVertex.getId(v));
44
125
  }
45
126
  }
@@ -47,7 +128,7 @@ function shouldIncludeNode(simplify, v, include) {
47
128
  * Convert the control flow graph to a mermaid string.
48
129
  * @see {@link MermaidCfgGraphPrinterInfo} for additional options.
49
130
  */
50
- function cfgToMermaid(cfg, normalizedAst, { prefix = 'flowchart BT\n', simplify = false, markStyle = info_1.MermaidDefaultMarkStyle, entryPointStyle = exports.MermaidEntryPointDefaultMarkStyle, exitPointStyle = exports.MermaidExitPointDefaultMarkStyle, includeOnlyIds, mark, includeBasicBlockLabel = true, basicBlockCharacterLimit = 100 } = {}) {
131
+ function cfgToMermaid(cfg, normalizedAst, { prefix = 'flowchart TD\n', simplify = false, markStyle = info_1.MermaidDefaultMarkStyle, entryPointStyle = exports.MermaidEntryPointDefaultMarkStyle, exitPointStyle = exports.MermaidExitPointDefaultMarkStyle, includeOnlyIds, mark, includeBasicBlockLabel = true, basicBlockCharacterLimit = 100 } = {}) {
51
132
  const hasBbandSimplify = simplify && cfg.graph.mayHaveBasicBlocks();
52
133
  let output = prefix;
53
134
  if (includeOnlyIds) {
@@ -62,16 +143,33 @@ function cfgToMermaid(cfg, normalizedAst, { prefix = 'flowchart BT\n', simplify
62
143
  completed.add(childId);
63
144
  }
64
145
  }
65
- // if we have a filter, we automatically add all vertices in the cfg that are *markers* for these ids and
66
- for (const [id, v] of cfg.graph.vertices()) {
67
- if (control_flow_graph_1.CfgVertex.isMarker(v) && completed.has(control_flow_graph_1.CfgVertex.unpackRootId(v))) {
68
- completed.add(id);
69
- }
70
- }
71
146
  includeOnlyIds = completed;
72
147
  }
73
148
  const dirIs = getDirRegex.exec(prefix)?.at(1) ?? 'LR';
74
149
  const diagramIncludedIds = new Set();
150
+ /* a function body runs when the function is called, so it is drawn as a region of its own instead of floating free */
151
+ const bodies = cfg.graph.mayHaveBasicBlocks() ? new Map() : collectBodies(cfg.graph);
152
+ const partOfBody = new Set(bodies.values().flatMap(body => body));
153
+ const emitBody = (defId) => {
154
+ const body = bodies.get(defId)?.filter(v => !includeOnlyIds || includeOnlyIds.has(v));
155
+ if (body === undefined || body.length === 0) {
156
+ return;
157
+ }
158
+ const definition = normalizedAst.idMap.get(defId);
159
+ output += ` subgraph n${defId}-body ["body of ${mermaid_1.Mermaid.escape(limitTo(getLexeme(definition) ?? String(defId), 40))}"]\n`;
160
+ output += ` direction ${dirIs}\n`;
161
+ for (const vertexId of body) {
162
+ const vertex = cfg.graph.getVertex(vertexId);
163
+ if (vertex === undefined || control_flow_graph_1.CfgVertex.isBlock(vertex)) {
164
+ continue;
165
+ }
166
+ const node = normalizedAst.idMap.get(vertexId);
167
+ output = cfgOfNode(vertex, node, vertexId, getLexeme(node), output);
168
+ diagramIncludedIds.add(vertexId);
169
+ emitBody(vertexId);
170
+ }
171
+ output += ' end\n';
172
+ };
75
173
  for (const [id, vertex] of cfg.graph.vertices(false)) {
76
174
  const normalizedVertex = normalizedAst?.idMap.get(id);
77
175
  const content = getLexeme(normalizedVertex);
@@ -81,9 +179,8 @@ function cfgToMermaid(cfg, normalizedAst, { prefix = 'flowchart BT\n', simplify
81
179
  if (includeOnlyIds && !elems.some(elem => includeOnlyIds.has(control_flow_graph_1.CfgVertex.getId(elem)))) {
82
180
  continue;
83
181
  }
84
- const ids = elems?.map(control_flow_graph_1.CfgVertex.getId) ?? [];
85
- const reconstruct = limitTo((0, reconstruct_1.reconstructToCode)(normalizedAst, { nodes: new Set(ids) }, auto_select_defaults_1.doNotAutoSelect).code, basicBlockCharacterLimit);
86
- const name = `"\`${includeBasicBlockLabel ? `Basic Block (${id})\n` : ''}${mermaid_1.Mermaid.escape(reconstruct)}\`"`;
182
+ const code = limitTo(blockCode(elems, normalizedAst), basicBlockCharacterLimit);
183
+ const name = `"\`${includeBasicBlockLabel ? `Basic Block (${id})\n` : ''}${mermaid_1.Mermaid.escape(code)}\`"`;
87
184
  output += ` n${id}[[${name}]]\n`;
88
185
  diagramIncludedIds.add(control_flow_graph_1.CfgVertex.getId(vertex));
89
186
  }
@@ -103,20 +200,21 @@ function cfgToMermaid(cfg, normalizedAst, { prefix = 'flowchart BT\n', simplify
103
200
  const eid = control_flow_graph_1.CfgVertex.getId(element);
104
201
  const childNormalizedVertex = normalizedAst?.idMap.get(eid);
105
202
  const childContent = getLexeme(childNormalizedVertex);
106
- output = cfgOfNode(vertex, childNormalizedVertex, eid, childContent, output);
203
+ output = cfgOfNode(element, childNormalizedVertex, eid, childContent, output);
107
204
  diagramIncludedIds.add(eid);
108
- // just to keep the order
205
+ /* everything in a block runs one after the other, which is what these arrows show */
109
206
  if (last) {
110
- output += ` ${last} -.-> n${eid}\n`;
207
+ output += ` ${last} --> n${eid}\n`;
111
208
  }
112
209
  last = `n${eid}`;
113
210
  }
114
211
  output += ' end\n';
115
212
  }
116
213
  }
117
- else if (!includeOnlyIds || includeOnlyIds.has(id)) {
214
+ else if ((!includeOnlyIds || includeOnlyIds.has(id)) && !partOfBody.has(id)) {
118
215
  output = cfgOfNode(vertex, normalizedVertex, id, content, output);
119
216
  diagramIncludedIds.add(id);
217
+ emitBody(id);
120
218
  }
121
219
  }
122
220
  for (const [from, targets] of cfg.graph.edges()) {
@@ -127,10 +225,18 @@ function cfgToMermaid(cfg, normalizedAst, { prefix = 'flowchart BT\n', simplify
127
225
  if (!diagramIncludedIds.has(to)) {
128
226
  continue;
129
227
  }
130
- const isCd = control_flow_graph_1.CfgEdge.isControlDependency(edge);
131
- const edgeType = isCd ? '-->' : '-.->';
132
- const edgeSuffix = isCd ? ` (${control_flow_graph_1.CfgEdge.unpackWhen(edge)})` : '';
133
- output += ` n${from} ${edgeType}|"${mermaid_1.Mermaid.escape(control_flow_graph_1.CfgEdge.typeToString(edge))}${edgeSuffix}"| n${to}\n`;
228
+ /* a branch is drawn dashed, so what always runs stands out from what only runs under a condition */
229
+ const isBranch = control_flow_graph_1.CfgEdge.isControlDependency(edge);
230
+ const arrow = isBranch ? '-.->' : '-->';
231
+ const label = isBranch ? `branch on ${conditionName(cfg, normalizedAst, from)} if ${control_flow_graph_1.CfgEdge.unpackWhen(edge) === convert_values_1.RTrue ? 'T' : 'F'}` : control_flow_graph_1.CfgEdge.typeToString(edge);
232
+ output += ` n${from} ${arrow}|"${mermaid_1.Mermaid.escape(label)}"| n${to}\n`;
233
+ }
234
+ }
235
+ for (const [defId] of bodies) {
236
+ const entry = cfg.graph.childrenOf(defId)?.[0];
237
+ /* no arrow head: the definition does not run its body, it only holds it */
238
+ if (entry !== undefined && diagramIncludedIds.has(defId) && diagramIncludedIds.has(entry)) {
239
+ output += ` n${defId} -. holds .- n${entry}\n`;
134
240
  }
135
241
  }
136
242
  for (const entryPoint of cfg.entryPoints) {
@@ -12,12 +12,12 @@ const identifier_1 = require("../../dataflow/environments/identifier");
12
12
  const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
13
13
  const edge_1 = require("../../dataflow/graph/edge");
14
14
  const vertex_1 = require("../../dataflow/graph/vertex");
15
- const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
16
15
  const info_1 = require("./info");
17
16
  const range_1 = require("../range");
18
17
  const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
19
18
  const info_2 = require("../../dataflow/info");
20
19
  const df_helper_1 = require("../../dataflow/graph/df-helper");
20
+ const r_expression_list_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-expression-list");
21
21
  function subflowToMermaid(nodeId, subflow, mermaid, idPrefix = '') {
22
22
  if (subflow === undefined) {
23
23
  return;
@@ -181,7 +181,7 @@ function vertexToMermaid(info, mermaid, id, idPrefix, mark, includeOnlyIds) {
181
181
  }
182
182
  }
183
183
  const node = mermaid.rootGraph.idMap?.get(info.id);
184
- const lexeme = node?.lexeme ?? (node?.type === type_1.RType.ExpressionList ? node?.grouping?.[0]?.lexeme : '') ?? '??';
184
+ const lexeme = node?.lexeme ?? (r_expression_list_1.RExpressionList.is(node) ? node?.grouping?.[0]?.lexeme : '') ?? '??';
185
185
  let display = lexeme;
186
186
  if (fCall && vertex_1.FunctionCallVertex.is(info)) {
187
187
  const q = identifier_1.Identifier.toQualified(df_helper_1.Dataflow.origin(mermaid.rootGraph, origId), info.name, mermaid.qualifyBaseR !== false);
@@ -201,7 +201,7 @@ function vertexToMermaid(info, mermaid, id, idPrefix, mark, includeOnlyIds) {
201
201
  const lnks = info.link?.origin ? ', links: ' + info.link.origin.map(o => mermaid_1.Mermaid.escapeId(o)).join(', ') : '';
202
202
  const source = vertex_1.VariableDefinitionVertex.is(info) ? info.source : undefined;
203
203
  const sources = source ? ', v: ' + source.map(s => mermaid_1.Mermaid.escapeId(s)).join(', ') : '';
204
- const n = node?.info.fullRange ?? node?.location ?? (node?.type === type_1.RType.ExpressionList ? node?.grouping?.[0].location : undefined);
204
+ const n = node?.info.fullRange ?? node?.location ?? (r_expression_list_1.RExpressionList.is(node) ? node?.grouping?.[0].location : undefined);
205
205
  mermaid.nodeLines.push(` ${idPrefix}${id}${open}"\`${escapedName}\n *${range_1.SourceRange.format(n)}* (**id: ${id}**${deps}${lnks}${sources})${fCall ? displayFunctionArgMapping(info.args) : '' + (vertex_1.FunctionDefinitionVertex.is(info) && info.mode && info.mode.length > 0 ? mermaid_1.Mermaid.escape(JSON.stringify(info.mode)) : '')}\`"${close}`);
206
206
  }
207
207
  if (mark?.has(id)) {
@@ -218,25 +218,35 @@ function vertexToMermaid(info, mermaid, id, idPrefix, mark, includeOnlyIds) {
218
218
  mermaid.nodeLines.push(' %% No edges found for ' + id);
219
219
  return;
220
220
  }
221
- const artificialCdEdges = (info.cds ?? []).map(x => [x.id, { types: new Set([x.when ? 'CD-True' : 'CD-False']), file: x.file }]);
222
221
  // eslint-disable-next-line prefer-const
223
- for (let [target, edge] of [...edges, ...artificialCdEdges]) {
222
+ for (let [target, edge] of edges) {
224
223
  if (includeOnlyIds && !includeOnlyIds.has(target)) {
225
224
  continue;
226
225
  }
227
226
  const originalTarget = target;
228
227
  target = mermaid_1.Mermaid.escapeId(target);
229
228
  const edgeTypes = typeof edge.types == 'number' ? new Set(edge_1.DfEdge.splitTypes(edge)) : edge.types;
229
+ const carriesControlFlow = edgeTypes.has(edge_1.EdgeType.FlowEdge) || edgeTypes.has(edge_1.EdgeType.ControlEdge);
230
+ /* an edge that carries dataflow as well stays a dataflow edge, it just says the control flow goes there too */
231
+ const onlyControlFlow = carriesControlFlow && ![...edgeTypes].some(t => typeof t === 'number' && (t & ~edge_1.ControlFlowEdgeTypes) !== 0);
232
+ if (mermaid.simplified && onlyControlFlow) {
233
+ /* a simplified view is about the dataflow, and the control flow is a graph of its own */
234
+ continue;
235
+ }
230
236
  const edgeId = encodeEdge(idPrefix + id, idPrefix + target, edgeTypes);
231
237
  if (!mermaid.presentEdges.has(edgeId)) {
232
238
  mermaid.presentEdges.add(edgeId);
233
- const style = node_id_1.NodeId.isBuiltIn(target) ? '-.->' : '-->';
234
- mermaid.edgeLines.push(` ${idPrefix}${id} ${style}|"${[...edgeTypes].map(e => typeof e === 'number' ? edge_1.DfEdge.typeToName(e) : e).join(', ')}${'file' in edge && edge.file ? `, from: ${mermaid_1.Mermaid.escape(String(edge.file))}` : ''}"| ${idPrefix}${target}`);
239
+ const style = node_id_1.NodeId.isBuiltIn(target) || onlyControlFlow ? '-.->' : '-->';
240
+ const names = [...edgeTypes].map(e => typeof e === 'number' ? edgeName(e) : e).join(', ');
241
+ const cd = edgeTypes.has(edge_1.EdgeType.ControlEdge) ? edge.cd : undefined;
242
+ const when = cd === undefined ? '' : ` (when: ${cd.when ?? 'any'})`;
243
+ const assumedFile = cd?.file ? `, from: ${mermaid_1.Mermaid.escape(cd.file)}` : '';
244
+ mermaid.edgeLines.push(` ${idPrefix}${id} ${style}|"${names}${when}${assumedFile}"| ${idPrefix}${target}`);
235
245
  if (mermaid.mark?.has(id + '->' + target)) {
236
246
  // who invented this syntax?!
237
247
  mermaid.edgeLines.push(` linkStyle ${mermaid.presentEdges.size - 1} ${mermaid.markStyle.edge}`);
238
248
  }
239
- if (edgeTypes.has('CD-True') || edgeTypes.has('CD-False')) {
249
+ if (onlyControlFlow) {
240
250
  mermaid.edgeLines.push(` linkStyle ${mermaid.presentEdges.size - 1} stroke:gray,color:gray;`);
241
251
  }
242
252
  if (node_id_1.NodeId.isBuiltIn(target)) {
@@ -250,8 +260,19 @@ function vertexToMermaid(info, mermaid, id, idPrefix, mark, includeOnlyIds) {
250
260
  }
251
261
  }
252
262
  }
263
+ /** control flow edges are drawn all over the graph, so they get a short name to save space */
264
+ function edgeName(type) {
265
+ switch (type) {
266
+ case edge_1.EdgeType.FlowEdge:
267
+ return 'flow';
268
+ case edge_1.EdgeType.ControlEdge:
269
+ return 'branch';
270
+ default:
271
+ return edge_1.DfEdge.typeToName(type);
272
+ }
273
+ }
253
274
  // make the passing of root ids more performant again
254
- function graphToMermaidGraph(rootIds, { simplified, graph, prefix = 'flowchart BT', idPrefix = '', includeEnvironments = !simplified, mark, rootGraph, presentEdges = new Set(), markStyle = info_1.MermaidDefaultMarkStyle, includeOnlyIds, qualifyBaseR = true }) {
275
+ function graphToMermaidGraph(rootIds, { simplified, graph, prefix = 'flowchart TD', idPrefix = '', includeEnvironments = !simplified, mark, rootGraph, presentEdges = new Set(), markStyle = info_1.MermaidDefaultMarkStyle, includeOnlyIds, qualifyBaseR = true }) {
255
276
  const mermaid = { nodeLines: prefix === null ? [] : [prefix], edgeLines: [], presentEdges, presentVertices: new Set(), mark, rootGraph: rootGraph ?? graph, includeEnvironments, markStyle, simplified, qualifyBaseR };
256
277
  for (const [id, info] of graph.vertices(true)) {
257
278
  if (rootIds.has(id)) {
@@ -265,7 +286,7 @@ function diffGraphsToMermaid(left, right, prefix) {
265
286
  // we add the prefix ourselves
266
287
  const { string: leftGraph, mermaid } = exports.DataflowMermaid.convert({ graph: left.graph, prefix: '', idPrefix: `l-${left.label}`, includeEnvironments: true, mark: left.mark });
267
288
  const { string: rightGraph } = exports.DataflowMermaid.convert({ graph: right.graph, prefix: '', idPrefix: `r-${right.label}`, includeEnvironments: true, mark: right.mark, presentEdges: mermaid.presentEdges });
268
- return `${prefix}flowchart BT\nsubgraph "${left.label}"\n${leftGraph}\nend\nsubgraph "${right.label}"\n${rightGraph}\nend`;
289
+ return `${prefix}flowchart TD\nsubgraph "${left.label}"\n${leftGraph}\nend\nsubgraph "${right.label}"\n${rightGraph}\nend`;
269
290
  }
270
291
  /**
271
292
  * Converts two dataflow graphs to a mermaid url that visualizes their differences.
@@ -68,6 +68,8 @@ exports.Mermaid = {
68
68
  */
69
69
  escapeId(text) {
70
70
  text = String(text).replace(/[^a-zA-Z0-9:\-./]/g, '_');
71
+ /* a dash before a dash or a dot reads as the start of a link, e.g. the id of `$<-.grouped_df` would cut the line in two */
72
+ text = text.replace(/-(?=[-.])/g, '_');
71
73
  return text.replace(/(^|[:\-./])([a-zA-Z0-9_]+)/g, (_m, sep, tok) => sep + (exports.Mermaid.reservedIds.has(tok) ? tok + '_' : tok));
72
74
  },
73
75
  /**
package/util/objects.d.ts CHANGED
@@ -70,4 +70,13 @@ export declare function getOnPath(obj: unknown, path: string): unknown;
70
70
  * @see {@link getOnPath} for the counterpart that reads such a path
71
71
  */
72
72
  export declare function setOnPath(obj: object, path: string, value: unknown): void;
73
+ /**
74
+ * The members of an enum as name-value pairs.
75
+ * A numeric enum maps its values back to their names as well, which this leaves out.
76
+ * @example
77
+ * ```ts
78
+ * enumMembers(CfgVertexType) // [['Statement', 1], ['Expression', 2], ['Block', 3]]
79
+ * ```
80
+ */
81
+ export declare function enumMembers<T extends object>(enumObject: T): [name: string, value: T[keyof T]][];
73
82
  export {};
package/util/objects.js CHANGED
@@ -9,6 +9,7 @@ exports.deepClonePreserveUnclonable = deepClonePreserveUnclonable;
9
9
  exports.looselyCompareObjects = looselyCompareObjects;
10
10
  exports.getOnPath = getOnPath;
11
11
  exports.setOnPath = setOnPath;
12
+ exports.enumMembers = enumMembers;
12
13
  const assert_1 = require("./assert");
13
14
  const json_1 = require("./json");
14
15
  const log_1 = require("./log");
@@ -242,4 +243,15 @@ function setOnPath(obj, path, value) {
242
243
  }
243
244
  at[segments[segments.length - 1]] = value;
244
245
  }
246
+ /**
247
+ * The members of an enum as name-value pairs.
248
+ * A numeric enum maps its values back to their names as well, which this leaves out.
249
+ * @example
250
+ * ```ts
251
+ * enumMembers(CfgVertexType) // [['Statement', 1], ['Expression', 2], ['Block', 3]]
252
+ * ```
253
+ */
254
+ function enumMembers(enumObject) {
255
+ return Object.entries(enumObject).filter(([name]) => Number.isNaN(Number(name)));
256
+ }
245
257
  //# sourceMappingURL=objects.js.map
package/util/prefix.d.ts CHANGED
@@ -13,4 +13,4 @@
13
13
  * findByPrefixIfUnique('', [ 'hello', 'hell' ]) // => undefined (empty prefix)
14
14
  * ```
15
15
  */
16
- export declare function findByPrefixIfUnique(prefix: string, keys: readonly string[] | MapIterator<string>): string | undefined;
16
+ export declare function findByPrefixIfUnique(prefix: string, keys: Iterable<string>): string | undefined;
@@ -0,0 +1,131 @@
1
+ /** the parts of the page a mark can point at, rather than a place in the script */
2
+ export declare enum PlaygroundBox {
3
+ /** the program slice the page built for the criterion the cursor sits on */
4
+ Slice = "slice",
5
+ /** flowR's own repl, which a mark of this name opens as it marks it */
6
+ Repl = "repl",
7
+ /** what the dependency query found */
8
+ Deps = "deps",
9
+ /** what the linter found */
10
+ Lints = "lints"
11
+ }
12
+ /**
13
+ * What a link can point at, written the way flowR names a place in a script:
14
+ *
15
+ * - `12` is the whole line, `12-15` the lines from 12 to 15
16
+ * - `12@sum` is the name `sum` on line 12, `12:5` whatever starts at that column
17
+ * - `lint:<rule>` is everything a linting rule reported, `lint:<rule>@12` its finding on that line
18
+ * - `dep:<kind>` is what the dependency query found of that kind, `dep:<kind>@12` the one on that line
19
+ * - a {@link PlaygroundBox} is one of the boxes of the page itself
20
+ * @see {@link PlaygroundMark.isValid} to check one, {@link PlaygroundMark.compress} to shorten a list
21
+ */
22
+ export type PlaygroundMark = `${number}` | `${number}-${number}` | `${number}:${number}` | `${number}@${string}` | `lint:${string}` | `dep:${string}` | PlaygroundBox;
23
+ /**
24
+ * The helper object associated with {@link PlaygroundMark}, which makes it easy to check a mark and to
25
+ * keep a list of them as short as a link should be.
26
+ */
27
+ export declare const PlaygroundMark: {
28
+ name: string;
29
+ /**
30
+ * Checks whether a value has a valid mark syntax. This does not check whether the mark points at
31
+ * anything: a line past the end of the script is valid and simply marks nothing.
32
+ */
33
+ isValid(this: void, mark: unknown): mark is PlaygroundMark;
34
+ /**
35
+ * The same marks, as short as they go: without repetition, without what another mark already covers,
36
+ * and with runs of plain lines written as ranges. A link is read by people as well as by the page,
37
+ * so this shortens rather than packs.
38
+ */
39
+ compress(this: void, marks: readonly PlaygroundMark[]): PlaygroundMark[];
40
+ /** the inverse of {@link PlaygroundMark.compress}: every range back to the lines it stands for */
41
+ expand(this: void, marks: readonly string[]): PlaygroundMark[];
42
+ };
43
+ /** everything a link can say about the page it opens; whatever is left out the page fills in itself */
44
+ export interface PlaygroundLinkParts {
45
+ /** the script the page opens with; left out, the page keeps its own sample */
46
+ readonly code?: string;
47
+ /** what the page marks when it opens, and what alt-click toggles from there on */
48
+ readonly marks?: readonly PlaygroundMark[];
49
+ /** the boxes that open folded away, for whatever the example is not about */
50
+ readonly collapsed?: readonly PlaygroundBox[];
51
+ /** where the cursor lands, as a slicing criterion (`12@sum`, `12:5`) or a bare line */
52
+ readonly at?: string;
53
+ /** slice forward from the criterion rather than backward */
54
+ readonly forward?: boolean;
55
+ /** the lines outside the slice step back, as the `dim the rest` box does on the page */
56
+ readonly dim?: boolean;
57
+ /** the repl is open, rather than folded away under the panes */
58
+ readonly replOpen?: boolean;
59
+ /** the whole slice is shown, rather than as much of it as the window has room for */
60
+ readonly wholeSlice?: boolean;
61
+ /** the configuration keys that differ from the defaults, as `a.b.c=<json>` */
62
+ readonly config?: readonly string[];
63
+ /** how wide the code pane is, in percent, and how tall the repl is, in pixels */
64
+ readonly split?: number;
65
+ readonly repl?: number;
66
+ /** another deployment of the page, for a local build or a fork */
67
+ readonly base?: string;
68
+ }
69
+ /**
70
+ * Everything about flowR's playground that is not the page itself: what a link to it carries, and how
71
+ * one is written. The page reads back exactly what {@link Playground.link} writes.
72
+ * @example
73
+ * ```ts
74
+ * Playground.link({ code: 'x <- 1\nprint(x)', at: '2@x', marks: ['2@x'] });
75
+ * ```
76
+ */
77
+ export declare const Playground: {
78
+ name: string;
79
+ /** where the page these links point at is served from */
80
+ BaseRef: string;
81
+ /** what a link can point at */
82
+ Mark: {
83
+ name: string;
84
+ /**
85
+ * Checks whether a value has a valid mark syntax. This does not check whether the mark points at
86
+ * anything: a line past the end of the script is valid and simply marks nothing.
87
+ */
88
+ isValid(this: void, mark: unknown): mark is PlaygroundMark;
89
+ /**
90
+ * The same marks, as short as they go: without repetition, without what another mark already covers,
91
+ * and with runs of plain lines written as ranges. A link is read by people as well as by the page,
92
+ * so this shortens rather than packs.
93
+ */
94
+ compress(this: void, marks: readonly PlaygroundMark[]): PlaygroundMark[];
95
+ /** the inverse of {@link PlaygroundMark.compress}: every range back to the lines it stands for */
96
+ expand(this: void, marks: readonly string[]): PlaygroundMark[];
97
+ };
98
+ /** the boxes of the page a mark can point at */
99
+ Box: typeof PlaygroundBox;
100
+ /**
101
+ * The link that opens the playground on exactly this: a script, what it points at, where its cursor
102
+ * sits, and how the page is laid out.
103
+ */
104
+ link(this: void, parts: PlaygroundLinkParts): string;
105
+ /**
106
+ * A fragment is not a query, so `,`, `:`, and the braces a configuration carries stand in it as they
107
+ * are and only what would end it, split it, or read back as something else has to be escaped. `<` and
108
+ * `>` go together: both are excluded from a URI, and a bare one of either ends the autolink a chat
109
+ * client or a markdown reader made of the address. A link is also made not to end on punctuation,
110
+ * because that is where a chat client stops reading it.
111
+ */
112
+ hash(this: void, fields: readonly (readonly [string, string])[]): string;
113
+ /**
114
+ * Where a criterion points in the given code, as the `<line>:<column>` the page opens the cursor on.
115
+ * `12@sum` is the name `sum` in line 12, `12:5` that column, `12` the first name on the line.
116
+ */
117
+ positionOf(this: void, code: string, criterion: string): string | undefined;
118
+ /**
119
+ * The same script with what is nobody's business taken out: the directories a path names, addresses,
120
+ * and whatever a name like `token` or `password` was set to. This is what makes a script safe enough
121
+ * to travel in a bug report, and it is best-effort: it is not a guarantee that nothing private is left.
122
+ */
123
+ sanitize(this: void, code: string): string;
124
+ /**
125
+ * The link a bug report carries, or `undefined` when the script is too long to travel in one. What
126
+ * {@link Playground.sanitize} takes out never enters the link.
127
+ */
128
+ reportLink(this: void, code: string, parts?: Omit<PlaygroundLinkParts, "code">): string | undefined;
129
+ /** where a name stands in a line, as a name rather than as a substring of a longer one */
130
+ nameIndexIn(this: void, text: string, name: string): number | undefined;
131
+ };