@eagleoutice/flowr 2.14.1 → 2.14.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (419) hide show
  1. package/README.md +142 -87
  2. package/abstract-interpretation/absint-visitor.d.ts +132 -25
  3. package/abstract-interpretation/absint-visitor.js +459 -99
  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 +21 -8
  41. package/config.js +12 -5
  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 -3
  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 +114 -3
  71. package/dataflow/environments/default-builtin-config.js +137 -35
  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 +3 -3
  81. package/dataflow/eval/resolve/alias-tracking.js +3 -3
  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 +15 -6
  106. package/dataflow/info.js +0 -17
  107. package/dataflow/internal/control-flow.d.ts +114 -0
  108. package/dataflow/internal/control-flow.js +224 -0
  109. package/dataflow/internal/linker.d.ts +6 -31
  110. package/dataflow/internal/linker.js +24 -81
  111. package/dataflow/internal/process/functions/call/argument/unpack-argument.d.ts +1 -1
  112. package/dataflow/internal/process/functions/call/argument/unpack-argument.js +3 -3
  113. package/dataflow/internal/process/functions/call/built-in/built-in-access.d.ts +2 -2
  114. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +9 -6
  115. package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +1 -1
  116. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +6 -4
  117. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +1 -10
  118. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +18 -37
  119. package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +1 -1
  120. package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +3 -3
  121. package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.d.ts +1 -1
  122. package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +11 -7
  123. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +6 -8
  124. package/dataflow/internal/process/functions/call/built-in/built-in-eval.d.ts +1 -1
  125. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +18 -14
  126. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +18 -2
  127. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +12 -1
  128. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +2 -1
  129. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +38 -30
  130. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +3 -2
  131. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.d.ts +1 -1
  132. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +36 -8
  133. package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +1 -1
  134. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +20 -17
  135. package/dataflow/internal/process/functions/call/built-in/built-in-list.d.ts +1 -1
  136. package/dataflow/internal/process/functions/call/built-in/built-in-list.js +6 -4
  137. package/dataflow/internal/process/functions/call/built-in/built-in-load.js +4 -3
  138. package/dataflow/internal/process/functions/call/built-in/built-in-local.js +9 -4
  139. package/dataflow/internal/process/functions/call/built-in/built-in-namespace-access.d.ts +2 -2
  140. package/dataflow/internal/process/functions/call/built-in/built-in-namespace-access.js +5 -5
  141. package/dataflow/internal/process/functions/call/built-in/built-in-new-env.d.ts +1 -1
  142. package/dataflow/internal/process/functions/call/built-in/built-in-new-env.js +5 -4
  143. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +7 -5
  144. package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.d.ts +1 -1
  145. package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.js +15 -13
  146. package/dataflow/internal/process/functions/call/built-in/built-in-quote.d.ts +1 -1
  147. package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +11 -2
  148. package/dataflow/internal/process/functions/call/built-in/built-in-recall.js +2 -2
  149. package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.js +4 -3
  150. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.d.ts +1 -1
  151. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +26 -4
  152. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.d.ts +2 -2
  153. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +17 -4
  154. package/dataflow/internal/process/functions/call/built-in/built-in-rm.d.ts +2 -2
  155. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +71 -33
  156. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +6 -15
  157. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +13 -14
  158. package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +1 -1
  159. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +14 -11
  160. package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.js +15 -1
  161. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.d.ts +1 -1
  162. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +12 -8
  163. package/dataflow/internal/process/functions/call/built-in/built-in-stop-if-not.js +6 -5
  164. package/dataflow/internal/process/functions/call/built-in/built-in-string-template.d.ts +1 -1
  165. package/dataflow/internal/process/functions/call/built-in/built-in-string-template.js +5 -4
  166. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +2 -2
  167. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +50 -10
  168. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.d.ts +2 -2
  169. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +20 -4
  170. package/dataflow/internal/process/functions/call/built-in/built-in-with.js +6 -2
  171. package/dataflow/internal/process/functions/call/common.js +5 -6
  172. package/dataflow/internal/process/functions/call/deferred.js +2 -2
  173. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +12 -2
  174. package/dataflow/internal/process/functions/call/known-call-handling.js +41 -15
  175. package/dataflow/internal/process/functions/call/named-call-handling.js +2 -0
  176. package/dataflow/internal/process/functions/call/nse.d.ts +1 -1
  177. package/dataflow/internal/process/functions/call/nse.js +6 -1
  178. package/dataflow/internal/process/functions/call/quoted.js +2 -2
  179. package/dataflow/internal/process/functions/call/unnamed-call-handling.js +19 -6
  180. package/dataflow/internal/process/functions/process-argument.d.ts +1 -1
  181. package/dataflow/internal/process/functions/process-argument.js +12 -4
  182. package/dataflow/internal/process/functions/process-parameter.js +13 -0
  183. package/dataflow/internal/process/process-named-call.d.ts +2 -2
  184. package/dataflow/internal/process/process-named-call.js +9 -7
  185. package/documentation/data/server/doc-data-server-messages.js +4 -4
  186. package/documentation/doc-readme.js +33 -0
  187. package/documentation/doc-util/doc-cfg.d.ts +8 -7
  188. package/documentation/doc-util/doc-cfg.js +10 -10
  189. package/documentation/doc-util/doc-playground.d.ts +12 -0
  190. package/documentation/doc-util/doc-playground.js +21 -0
  191. package/documentation/doc-util/doc-query.d.ts +4 -1
  192. package/documentation/doc-util/doc-query.js +4 -2
  193. package/documentation/wiki-absint.d.ts +3 -4
  194. package/documentation/wiki-absint.js +17 -5
  195. package/documentation/wiki-analyzer.js +2 -2
  196. package/documentation/wiki-cfg.js +101 -106
  197. package/documentation/wiki-dataflow-graph.js +84 -53
  198. package/documentation/wiki-interface.js +1 -0
  199. package/documentation/wiki-linter.js +15 -1
  200. package/documentation/wiki-linting-and-testing.js +1 -16
  201. package/documentation/wiki-mk/doc-maker.js +6 -4
  202. package/documentation/wiki-query.js +14 -4
  203. package/documentation/wiki-signature-database.js +28 -2
  204. package/linter/linter-fix.d.ts +16 -0
  205. package/linter/linter-fix.js +104 -0
  206. package/linter/linter-format.d.ts +18 -1
  207. package/linter/linter-format.js +31 -1
  208. package/linter/linter-output.js +46 -10
  209. package/linter/linter-rules.d.ts +40 -9
  210. package/linter/linter-rules.js +2 -0
  211. package/linter/rules/absolute-path.js +4 -2
  212. package/linter/rules/dataframe-access-validation.js +6 -7
  213. package/linter/rules/deprecated-functions.d.ts +107 -10
  214. package/linter/rules/deprecated-functions.js +311 -23
  215. package/linter/rules/file-path-validity.js +5 -4
  216. package/linter/rules/function-finder-util.d.ts +6 -0
  217. package/linter/rules/function-finder-util.js +21 -13
  218. package/linter/rules/naming-convention.js +1 -1
  219. package/linter/rules/network-functions.d.ts +2 -2
  220. package/linter/rules/stop-with-call-arg.js +2 -2
  221. package/linter/rules/unclosed-connection.js +2 -2
  222. package/linter/rules/undefined-symbol-util.js +6 -4
  223. package/linter/rules/undefined-symbol.js +2 -2
  224. package/linter/rules/unused-definition.js +8 -4
  225. package/linter/rules/unused-import.d.ts +60 -0
  226. package/linter/rules/unused-import.js +179 -0
  227. package/package.json +2 -2
  228. package/project/attached-packages.js +2 -1
  229. package/project/cache/flowr-analyzer-cache.d.ts +2 -5
  230. package/project/cache/flowr-analyzer-cache.js +4 -7
  231. package/project/cache/flowr-analyzer-controlflow-cache.d.ts +9 -8
  232. package/project/cache/flowr-analyzer-controlflow-cache.js +17 -34
  233. package/project/cache/flowr-cache.d.ts +9 -0
  234. package/project/cache/flowr-cache.js +19 -0
  235. package/project/context/flowr-analyzer-context.d.ts +7 -3
  236. package/project/context/flowr-analyzer-context.js +15 -9
  237. package/project/context/flowr-analyzer-dependencies-context.d.ts +24 -3
  238. package/project/context/flowr-analyzer-dependencies-context.js +9 -14
  239. package/project/context/flowr-analyzer-files-context.js +15 -17
  240. package/project/context/flowr-analyzer-meta-context.js +2 -12
  241. package/project/dependency-version-space.d.ts +1 -7
  242. package/project/dependency-version-space.js +9 -8
  243. package/project/flowr-analyzer-builder.d.ts +4 -4
  244. package/project/flowr-analyzer.d.ts +4 -6
  245. package/project/flowr-analyzer.js +4 -5
  246. package/project/plugins/file-plugins/files/flowr-namespace-file.js +22 -34
  247. package/project/plugins/file-plugins/files/flowr-rda-file.d.ts +13 -13
  248. package/project/plugins/file-plugins/files/flowr-rda-file.js +131 -286
  249. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +1 -0
  250. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +1 -0
  251. package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.d.ts +2 -5
  252. package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.js +2 -8
  253. package/project/plugins/file-plugins/flowr-analyzer-file-plugin.d.ts +32 -0
  254. package/project/plugins/file-plugins/flowr-analyzer-file-plugin.js +43 -1
  255. package/project/plugins/file-plugins/flowr-analyzer-inst-file-plugin.d.ts +4 -12
  256. package/project/plugins/file-plugins/flowr-analyzer-inst-file-plugin.js +3 -16
  257. package/project/plugins/file-plugins/flowr-analyzer-license-file-plugin.d.ts +5 -8
  258. package/project/plugins/file-plugins/flowr-analyzer-license-file-plugin.js +4 -10
  259. package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.d.ts +3 -10
  260. package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.js +1 -13
  261. package/project/plugins/file-plugins/flowr-analyzer-namespace-files-plugin.d.ts +3 -6
  262. package/project/plugins/file-plugins/flowr-analyzer-namespace-files-plugin.js +2 -8
  263. package/project/plugins/file-plugins/flowr-analyzer-news-file-plugin.d.ts +2 -5
  264. package/project/plugins/file-plugins/flowr-analyzer-news-file-plugin.js +2 -8
  265. package/project/plugins/file-plugins/flowr-analyzer-rda-file-plugin.d.ts +2 -5
  266. package/project/plugins/file-plugins/flowr-analyzer-rda-file-plugin.js +2 -8
  267. package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.d.ts +3 -4
  268. package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.js +3 -6
  269. package/project/plugins/file-plugins/flowr-analyzer-test-file-plugin.d.ts +4 -12
  270. package/project/plugins/file-plugins/flowr-analyzer-test-file-plugin.js +3 -16
  271. package/project/plugins/file-plugins/flowr-analyzer-vignette-file-plugin.d.ts +4 -12
  272. package/project/plugins/file-plugins/flowr-analyzer-vignette-file-plugin.js +3 -16
  273. package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.d.ts +4 -12
  274. package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.js +3 -16
  275. package/project/plugins/file-plugins/notebooks/flowr-analyzer-jupyter-file-plugin.d.ts +2 -5
  276. package/project/plugins/file-plugins/notebooks/flowr-analyzer-jupyter-file-plugin.js +2 -8
  277. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmarkdown-file-plugin.d.ts +2 -6
  278. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmarkdown-file-plugin.js +1 -10
  279. package/project/plugins/file-plugins/notebooks/flowr-analyzer-sweave-file-plugin.d.ts +2 -5
  280. package/project/plugins/file-plugins/notebooks/flowr-analyzer-sweave-file-plugin.js +2 -8
  281. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-library-plugin.js +2 -1
  282. package/project/sigdb/build.d.ts +2 -2
  283. package/project/sigdb/decode.d.ts +0 -5
  284. package/project/sigdb/decode.js +0 -8
  285. package/project/sigdb/index-format.d.ts +4 -4
  286. package/project/sigdb/manifest.d.ts +2 -2
  287. package/project/sigdb/reader.d.ts +54 -13
  288. package/project/sigdb/reader.js +4 -3
  289. package/project/sigdb/schema.d.ts +3 -1
  290. package/project/sigdb/signature-db.d.ts +69 -0
  291. package/project/sigdb/signature-db.js +54 -0
  292. package/project/sigdb/signature-match.d.ts +10 -5
  293. package/project/sigdb/signature-match.js +13 -8
  294. package/queries/catalog/absint-query/absint-query-executor.js +1 -2
  295. package/queries/catalog/call-context-query/call-context-query-executor.js +2 -4
  296. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.d.ts +1 -1
  297. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +33 -6
  298. package/queries/catalog/control-flow-query/control-flow-query-executor.js +1 -2
  299. package/queries/catalog/dependencies-query/dependencies-query-executor.js +2 -2
  300. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +8 -7
  301. package/queries/catalog/dependencies-query/dependencies-query-format.js +22 -35
  302. package/queries/catalog/dependencies-query/function-info/library-functions.d.ts +13 -1
  303. package/queries/catalog/dependencies-query/function-info/library-functions.js +26 -22
  304. package/queries/catalog/dependencies-query/function-info/statistics-functions.d.ts +9 -0
  305. package/queries/catalog/dependencies-query/function-info/statistics-functions.js +19 -0
  306. package/queries/catalog/dependencies-query/implicit-echo.d.ts +13 -0
  307. package/queries/catalog/dependencies-query/implicit-echo.js +133 -0
  308. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +2 -2
  309. package/queries/catalog/happens-before-query/happens-before-query-executor.js +1 -2
  310. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.d.ts +2 -2
  311. package/queries/catalog/signature-query/signature-query-executor.js +4 -3
  312. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +1 -1
  313. package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.d.ts +1 -0
  314. package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.js +1 -0
  315. package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +1 -0
  316. package/r-bridge/lang-4.x/ast/model/nodes/r-access.js +1 -0
  317. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +4 -1
  318. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.js +5 -2
  319. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +1 -0
  320. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.js +1 -0
  321. package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +1 -0
  322. package/r-bridge/lang-4.x/ast/model/nodes/r-break.js +1 -0
  323. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +1 -0
  324. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.js +1 -0
  325. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +1 -0
  326. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.js +1 -0
  327. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +1 -0
  328. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.js +1 -0
  329. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +6 -4
  330. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +6 -4
  331. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +1 -0
  332. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.js +1 -0
  333. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +1 -0
  334. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.js +1 -0
  335. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +1 -0
  336. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.js +1 -0
  337. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +1 -0
  338. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.js +1 -0
  339. package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +1 -0
  340. package/r-bridge/lang-4.x/ast/model/nodes/r-next.js +1 -0
  341. package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +6 -0
  342. package/r-bridge/lang-4.x/ast/model/nodes/r-number.js +13 -0
  343. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +8 -0
  344. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.js +8 -0
  345. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +1 -0
  346. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.js +1 -0
  347. package/r-bridge/lang-4.x/ast/model/nodes/r-project.d.ts +1 -0
  348. package/r-bridge/lang-4.x/ast/model/nodes/r-project.js +1 -0
  349. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +1 -0
  350. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.js +1 -0
  351. package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +1 -0
  352. package/r-bridge/lang-4.x/ast/model/nodes/r-string.js +1 -0
  353. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +1 -0
  354. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.js +1 -0
  355. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +1 -0
  356. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.js +1 -0
  357. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +1 -0
  358. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.js +1 -0
  359. package/r-bridge/lang-4.x/ast/model/processing/decorate.js +2 -1
  360. package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +5 -1
  361. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +0 -5
  362. package/r-bridge/lang-4.x/ast/model/processing/stateful-fold.d.ts +1 -1
  363. package/r-bridge/lang-4.x/ast/model/processing/stateful-fold.js +3 -2
  364. package/r-bridge/lang-4.x/ast/parser/main/internal/control/normalize-if-then-else.js +2 -1
  365. package/r-bridge/lang-4.x/ast/parser/main/internal/control/normalize-if-then.js +2 -1
  366. package/r-bridge/lang-4.x/ast/parser/main/internal/expression/normalize-expression.js +1 -1
  367. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-argument.js +2 -1
  368. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.d.ts +2 -2
  369. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.js +6 -3
  370. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-definition.js +2 -1
  371. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-parameter.js +2 -1
  372. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-for.js +5 -3
  373. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-repeat.js +2 -1
  374. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-while.js +2 -1
  375. package/r-bridge/lang-4.x/ast/parser/main/internal/normalize-access.js +2 -1
  376. package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-binary.js +5 -3
  377. package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-unary.js +2 -1
  378. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-expressions.d.ts +1 -1
  379. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-expressions.js +2 -1
  380. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-root.js +3 -1
  381. package/r-bridge/lang-4.x/ast/parser/main/normalize-meta.d.ts +1 -1
  382. package/r-bridge/lang-4.x/ast/parser/main/normalize-meta.js +2 -1
  383. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +5 -3
  384. package/reconstruct/inline/source-inline-map.js +3 -3
  385. package/reconstruct/reconstruct.js +6 -4
  386. package/search/flowr-search-builder.d.ts +8 -8
  387. package/search/flowr-search-builder.js +4 -4
  388. package/search/flowr-search-filters.d.ts +2 -2
  389. package/search/flowr-search-filters.js +3 -2
  390. package/search/search-executor/search-enrichers.d.ts +6 -0
  391. package/search/search-executor/search-enrichers.js +44 -5
  392. package/slicing/criterion/filters/all-variables.js +2 -1
  393. package/slicing/criterion/parse.js +8 -6
  394. package/slicing/static/slice-call.js +2 -2
  395. package/util/arg-matching.d.ts +3 -0
  396. package/util/arg-matching.js +12 -1
  397. package/util/collections/arrays.d.ts +0 -4
  398. package/util/collections/arrays.js +4 -26
  399. package/util/diff-graph.d.ts +1 -1
  400. package/util/diff-graph.js +17 -3
  401. package/util/diff.d.ts +6 -0
  402. package/util/mermaid/ast.d.ts +1 -1
  403. package/util/mermaid/ast.js +5 -4
  404. package/util/mermaid/cfg.js +130 -24
  405. package/util/mermaid/dfg.js +31 -10
  406. package/util/mermaid/mermaid.js +2 -0
  407. package/util/objects.d.ts +24 -4
  408. package/util/objects.js +12 -0
  409. package/util/prefix.d.ts +1 -1
  410. package/util/text/playground-link.d.ts +131 -0
  411. package/util/text/playground-link.js +214 -0
  412. package/util/text/strings.js +7 -3
  413. package/util/version.js +1 -1
  414. package/control-flow/cfg-builder.d.ts +0 -30
  415. package/control-flow/cfg-builder.js +0 -79
  416. package/control-flow/extract-cfg.d.ts +0 -36
  417. package/control-flow/extract-cfg.js +0 -693
  418. package/project/cfg-kind.d.ts +0 -21
  419. package/project/cfg-kind.js +0 -26
@@ -12,7 +12,6 @@ const flowr_search_filters_1 = require("../../search/flowr-search-filters");
12
12
  const flowr_file_1 = require("../../project/context/flowr-file");
13
13
  const flowr_namespace_file_1 = require("../../project/plugins/file-plugins/files/flowr-namespace-file");
14
14
  const identifier_1 = require("../../dataflow/environments/identifier");
15
- const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
16
15
  const retriever_1 = require("../../r-bridge/retriever");
17
16
  const query_fn_props_1 = require("../../dataflow/environments/query-fn-props");
18
17
  const built_in_props_1 = require("../../dataflow/environments/built-in-props");
@@ -20,6 +19,7 @@ const default_builtin_config_1 = require("../../dataflow/environments/default-bu
20
19
  const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
21
20
  const r_function_definition_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
22
21
  const graph_1 = require("../../dataflow/graph/graph");
22
+ const r_parameter_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-parameter");
23
23
  /**
24
24
  * The dots parameter is a special parameter and must never be reported as an unused definition.
25
25
  */
@@ -167,9 +167,13 @@ function buildQuickFix(variable, dfg, ast) {
167
167
  return vertex ? range_1.SourceLocation.fromNode(vertex) : undefined;
168
168
  }),
169
169
  variable.info.fullRange ?? variable.location]);
170
+ if (totalRangeToRemove === undefined) {
171
+ /* a fix that names no place cannot be carried out, so none is offered */
172
+ return undefined;
173
+ }
170
174
  return [{
171
175
  type: 'remove',
172
- loc: totalRangeToRemove ?? range_1.SourceLocation.invalid(),
176
+ loc: totalRangeToRemove,
173
177
  description: `Remove unused definition of \`${variable.lexeme}\``
174
178
  }];
175
179
  }
@@ -195,10 +199,10 @@ function isWithinPromise(node, idMap) {
195
199
  if (parent === undefined) {
196
200
  return false;
197
201
  }
198
- if (parent.type === type_1.RType.Parameter && parent.defaultValue?.info.id === child.info.id) {
202
+ if (r_parameter_1.RParameter.is(parent) && parent.defaultValue?.info.id === child.info.id) {
199
203
  return true;
200
204
  }
201
- if (parent.type === type_1.RType.FunctionCall && parent.named && identifier_1.Identifier.getName(parent.functionName.content) === 'delayedAssign') {
205
+ if (r_function_call_1.RFunctionCall.isNamed(parent) && identifier_1.Identifier.getName(parent.functionName.content) === 'delayedAssign') {
202
206
  return true;
203
207
  }
204
208
  child = parent;
@@ -0,0 +1,60 @@
1
+ import { type LintingResult, LintingResultCertainty, LintingRuleCertainty, type LintQuickFix } from '../linter-format';
2
+ import type { MergeableRecord } from '../../util/objects';
3
+ import { LintingRuleTag } from '../linter-tags';
4
+ import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
5
+ import type { ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
6
+ export interface UnusedImportResult extends LintingResult {
7
+ /** the package the flagged call attaches */
8
+ readonly package: string;
9
+ /** the version whose exports the finding was checked against, as the signature database resolved it */
10
+ readonly version: string;
11
+ }
12
+ export interface UnusedImportConfig extends MergeableRecord {
13
+ /** packages that do their work on load and hence should never be reported, however unused they look */
14
+ whitelist: string[];
15
+ }
16
+ export interface UnusedImportMetadata extends MergeableRecord {
17
+ /** attaching calls the rule looked at */
18
+ totalConsidered: number;
19
+ /** skipped because the database could not resolve the package the call names */
20
+ totalUnresolved: number;
21
+ /** skipped because one call attaches several packages at once */
22
+ totalMultiPackage: number;
23
+ /** the attaches reported as unused */
24
+ totalUnused: number;
25
+ }
26
+ /**
27
+ * Flags packages that are attached but never used, so dropping the `library`/`require` call would leave the code running
28
+ * just the same. A package counts as used as soon as any call resolves into it or anything reads one of its exports.
29
+ *
30
+ * Needs a signature database to know what a package exports; without one the rule reports nothing. Packages the database
31
+ * does not know, packages whose namespace loads with side effects, and those in the
32
+ * {@link UnusedImportConfig#whitelist|whitelist} are skipped. Every step errs towards keeping an import.
33
+ */
34
+ export declare const UNUSED_IMPORT: {
35
+ readonly createSearch: () => import("../../search/flowr-search-builder").FlowrSearchBuilder<"from-query", [], ParentInformation, import("../../search/flowr-search").FlowrSearchElements<ParentInformation, import("../../search/flowr-search").FlowrSearchElement<ParentInformation>[]>>;
36
+ readonly processSearchResult: (elements: import("../../search/flowr-search").FlowrSearchElements<ParentInformation, import("../../search/flowr-search").FlowrSearchElement<ParentInformation>[]>, config: UnusedImportConfig, data: import("../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider<import("../../r-bridge/parser").KnownParser>) => Promise<{
37
+ results: {
38
+ certainty: LintingResultCertainty;
39
+ involvedId: NodeId;
40
+ loc: [startLine: number, startColumn: number, endLine: number, endColumn: number, f?: string | undefined];
41
+ package: string;
42
+ version: string;
43
+ quickFix: LintQuickFix[] | undefined;
44
+ }[];
45
+ '.meta': UnusedImportMetadata;
46
+ }>;
47
+ readonly prettyPrint: {
48
+ readonly query: (result: UnusedImportResult) => string;
49
+ readonly full: (result: UnusedImportResult) => string;
50
+ };
51
+ readonly info: {
52
+ readonly name: "Unused Import";
53
+ readonly tags: readonly [LintingRuleTag.Smell, LintingRuleTag.Readability, LintingRuleTag.QuickFix];
54
+ readonly certainty: LintingRuleCertainty.BestEffort;
55
+ readonly description: "Highlights packages that are attached but never used, so the code runs just the same without them. Requires a signature database, and packages that only do their work on load should be whitelisted in the configuration.";
56
+ readonly defaultConfig: {
57
+ readonly whitelist: readonly [];
58
+ };
59
+ };
60
+ };
@@ -0,0 +1,179 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UNUSED_IMPORT = void 0;
4
+ const linter_format_1 = require("../linter-format");
5
+ const range_1 = require("../../util/range");
6
+ const flowr_search_builder_1 = require("../../search/flowr-search-builder");
7
+ const linter_tags_1 = require("../linter-tags");
8
+ const df_helper_1 = require("../../dataflow/graph/df-helper");
9
+ const graph_1 = require("../../dataflow/graph/graph");
10
+ const edge_1 = require("../../dataflow/graph/edge");
11
+ const vertex_1 = require("../../dataflow/graph/vertex");
12
+ const identifier_1 = require("../../dataflow/environments/identifier");
13
+ const search_enrichers_1 = require("../../search/search-executor/search-enrichers");
14
+ const dependencies_query_format_1 = require("../../queries/catalog/dependencies-query/dependencies-query-format");
15
+ const library_functions_1 = require("../../queries/catalog/dependencies-query/function-info/library-functions");
16
+ const r_expression_list_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-expression-list");
17
+ /**
18
+ * Whether the loader a `library`-category finding came from attaches the package, taken from the one place that
19
+ * says so. A call this does not know attaches nothing either: `pkg::fn` is reported as a loader of `pkg` and is no
20
+ * import of its own, and neither is whatever else may come to be reported here. Matching ignores the loader's own
21
+ * namespace, so `base::require` is caught just as well as a bare `require`.
22
+ */
23
+ function attachesPackage(info) {
24
+ return library_functions_1.LibraryFunctions.some(loader => loader.attaches && identifier_1.Identifier.matches(loader.name, info.functionName));
25
+ }
26
+ /** whether the call reaches no definition of the analyzed code itself */
27
+ function isUnbound(graph, id) {
28
+ const origins = df_helper_1.Dataflow.origin(graph, id);
29
+ return origins === undefined || origins.every(o => o.type === 3 /* OriginType.BuiltInFunctionOrigin */);
30
+ }
31
+ /** whether removing the call would empty a slot the syntax requires, as in an unbraced `if(c) library(x)` */
32
+ function removalWouldBreakSyntax(node, idMap) {
33
+ const parent = node.info.parent === undefined ? undefined : idMap.get(node.info.parent);
34
+ return r_expression_list_1.RExpressionList.isImplicit(parent) && parent.children.length === 1 && parent.info.role !== "root" /* RoleInParent.Root */;
35
+ }
36
+ /** whether anything reads out of the attach itself */
37
+ function isReadFrom(graph, id) {
38
+ for (const edge of (graph.ingoingEdges(id) ?? graph_1.NoEdges).values()) {
39
+ if (edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Reads)) {
40
+ return true;
41
+ }
42
+ }
43
+ return false;
44
+ }
45
+ /**
46
+ * Which of the `attachments` the program never makes use of. A call that resolves names its package outright;
47
+ * one that does not bind yet (a call in a function body) keeps every attached package exporting its name.
48
+ */
49
+ function unusedPackages(attachments, graph) {
50
+ const pending = new Set(attachments.map(a => a.name));
51
+ const unbound = new Set();
52
+ for (const [id, qualified] of df_helper_1.Dataflow.qualifyAll(graph)) {
53
+ const namespace = qualified === undefined ? undefined : identifier_1.Identifier.getNamespace(qualified);
54
+ if (namespace !== undefined) {
55
+ pending.delete(namespace);
56
+ if (pending.size === 0) {
57
+ return pending;
58
+ }
59
+ continue;
60
+ }
61
+ const vertex = graph.getVertex(id);
62
+ if (vertex_1.FunctionCallVertex.is(vertex) && isUnbound(graph, id)) {
63
+ unbound.add(identifier_1.Identifier.getName(vertex.name));
64
+ }
65
+ }
66
+ for (const { name, callable } of attachments) {
67
+ if (!pending.has(name)) {
68
+ continue;
69
+ }
70
+ for (const call of unbound) {
71
+ if (callable.has(call)) {
72
+ pending.delete(name);
73
+ break;
74
+ }
75
+ }
76
+ }
77
+ return pending;
78
+ }
79
+ /**
80
+ * Flags packages that are attached but never used, so dropping the `library`/`require` call would leave the code running
81
+ * just the same. A package counts as used as soon as any call resolves into it or anything reads one of its exports.
82
+ *
83
+ * Needs a signature database to know what a package exports; without one the rule reports nothing. Packages the database
84
+ * does not know, packages whose namespace loads with side effects, and those in the
85
+ * {@link UnusedImportConfig#whitelist|whitelist} are skipped. Every step errs towards keeping an import.
86
+ */
87
+ exports.UNUSED_IMPORT = {
88
+ createSearch: () => flowr_search_builder_1.Q.fromQuery({ type: 'dependencies', enabledCategories: ['library'] }),
89
+ processSearchResult: async (elements, config, data) => {
90
+ const metadata = { totalConsidered: 0, totalUnresolved: 0, totalMultiPackage: 0, totalUnused: 0 };
91
+ const deps = data.inspectContext().deps;
92
+ if (!deps.hasSignatureDatabase()) {
93
+ return { results: [], '.meta': metadata };
94
+ }
95
+ const whitelist = new Set(config.whitelist);
96
+ // one call may name more than one package, so the query can report it several times under the same id
97
+ const attachedBy = new Map();
98
+ for (const info of elements.enrichmentContent(search_enrichers_1.Enrichment.QueryData).queries['dependencies'].library) {
99
+ const known = attachedBy.get(info.nodeId);
100
+ if (known === undefined) {
101
+ attachedBy.set(info.nodeId, [info]);
102
+ }
103
+ else {
104
+ known.push(info);
105
+ }
106
+ }
107
+ const attachments = [];
108
+ const seen = new Set();
109
+ for (const { node } of elements.getElements()) {
110
+ const infos = attachedBy.get(node.info.id);
111
+ if (infos === undefined || seen.has(node.info.id) || !attachesPackage(infos[0])) {
112
+ continue;
113
+ }
114
+ seen.add(node.info.id);
115
+ metadata.totalConsidered++;
116
+ if (infos.length > 1) {
117
+ // a dynamic attach, e.g. `for(p in pkgs) library(p, character.only = TRUE)`; naming one of them would be a guess
118
+ metadata.totalMultiPackage++;
119
+ continue;
120
+ }
121
+ const name = infos[0].value;
122
+ if (name === undefined || name === dependencies_query_format_1.Unknown) {
123
+ metadata.totalUnresolved++;
124
+ continue;
125
+ }
126
+ if (whitelist.has(name)) {
127
+ continue;
128
+ }
129
+ const pkg = deps.getDependency(name);
130
+ const loc = range_1.SourceLocation.fromNode(node);
131
+ if (pkg?.resolvedVersion === undefined || loc === undefined) {
132
+ metadata.totalUnresolved++;
133
+ continue;
134
+ }
135
+ if (pkg.namespaceInfo?.loadsWithSideEffects) {
136
+ continue;
137
+ }
138
+ attachments.push({
139
+ id: node.info.id,
140
+ node,
141
+ loc,
142
+ name,
143
+ version: pkg.resolvedVersion,
144
+ callable: new Set(pkg.namespaceInfo?.callable)
145
+ });
146
+ }
147
+ if (attachments.length === 0) {
148
+ return { results: [], '.meta': metadata };
149
+ }
150
+ const { graph } = await data.dataflow();
151
+ const idMap = (await data.normalize()).idMap;
152
+ const unused = unusedPackages(attachments, graph);
153
+ const results = attachments.filter(({ id, name }) => unused.has(name) && !isReadFrom(graph, id)).map(({ id, node, loc, name, version }) => ({
154
+ certainty: linter_format_1.LintingResultCertainty.Uncertain,
155
+ involvedId: id,
156
+ loc,
157
+ package: name,
158
+ version,
159
+ quickFix: removalWouldBreakSyntax(node, idMap) ? undefined
160
+ : [{ type: 'remove', description: `Remove the unused import of ${name}`, loc }]
161
+ }));
162
+ metadata.totalUnused = results.length;
163
+ return { results, '.meta': metadata };
164
+ },
165
+ prettyPrint: {
166
+ [linter_format_1.LintingPrettyPrintContext.Query]: result => `Import of ${result.package} at ${range_1.SourceLocation.format(result.loc)}`,
167
+ [linter_format_1.LintingPrettyPrintContext.Full]: result => `Import of ${result.package} at ${range_1.SourceLocation.format(result.loc)} is unused (checked v${result.version}).`
168
+ },
169
+ info: {
170
+ name: 'Unused Import',
171
+ tags: [linter_tags_1.LintingRuleTag.Smell, linter_tags_1.LintingRuleTag.Readability, linter_tags_1.LintingRuleTag.QuickFix],
172
+ certainty: linter_format_1.LintingRuleCertainty.BestEffort,
173
+ description: 'Highlights packages that are attached but never used, so the code runs just the same without them. Requires a signature database, and packages that only do their work on load should be whitelisted in the configuration.',
174
+ defaultConfig: {
175
+ whitelist: []
176
+ }
177
+ }
178
+ };
179
+ //# sourceMappingURL=unused-import.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eagleoutice/flowr",
3
- "version": "2.14.1",
3
+ "version": "2.14.3",
4
4
  "description": "Static Dataflow Analyzer and Program Slicer for the R Programming Language",
5
5
  "engines": {
6
6
  "node": ">=22"
@@ -186,7 +186,7 @@
186
186
  "@codemirror/legacy-modes": "^6.5.3",
187
187
  "@commitlint/cli": "^20.5.0",
188
188
  "@commitlint/config-angular": "^20.5.0",
189
- "@eagleoutice/eslint-config-flowr": "^2.1.1",
189
+ "@eagleoutice/eslint-config-flowr": "^2.1.3",
190
190
  "@j-ulrich/release-it-regex-bumper": "^5.6.0",
191
191
  "@types/command-line-args": "^5.2.3",
192
192
  "@types/command-line-usage": "^5.0.4",
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MetaPackageCores = void 0;
4
4
  exports.attachedAlongside = attachedAlongside;
5
+ const arrays_1 = require("../util/collections/arrays");
5
6
  /**
6
7
  * Packages that attach further packages from their `.onAttach` hook, which no package metadata records: their core
7
8
  * set sits in `Imports`, indistinguishable from the packages they merely use. Whoever loads one of them gets the
@@ -25,6 +26,6 @@ function attachedAlongside(pack, sources, version) {
25
26
  .flatMap(src => src.dependencies(pack, version) ?? [])
26
27
  .filter(d => d.type === 0 /* DepType.Depends */ && d.name !== 'R')
27
28
  .map(d => d.name);
28
- return [...new Set([...depends, ...exports.MetaPackageCores.get(pack) ?? []])];
29
+ return (0, arrays_1.uniqueArray)([...depends, ...exports.MetaPackageCores.get(pack) ?? []]);
29
30
  }
30
31
  //# sourceMappingURL=attached-packages.js.map
@@ -7,7 +7,6 @@ import type { TreeSitterExecutor } from '../../r-bridge/lang-4.x/tree-sitter/tre
7
7
  import type { PipelineOutput } from '../../core/steps/pipeline/pipeline';
8
8
  import type { CfgSimplificationPassName } from '../../control-flow/cfg-simplification';
9
9
  import type { ControlFlowInformation } from '../../control-flow/control-flow-graph';
10
- import type { CfgKind } from '../cfg-kind';
11
10
  import type { FlowrAnalyzerContext } from '../context/flowr-analyzer-context';
12
11
  import { CallGraph } from '../../dataflow/graph/call-graph';
13
12
  interface FlowrAnalyzerCacheOptions<Parser extends KnownParser> {
@@ -75,17 +74,15 @@ export declare class FlowrAnalyzerCache<Parser extends KnownParser> extends Flow
75
74
  /**
76
75
  * Get the control flow graph (CFG) for the request, computing if necessary.
77
76
  * @param force - Do not use the cache, instead force new analyses.
78
- * @param kind - The kind of CFG that is requested.
79
77
  * @param simplifications - Simplification passes to be applied to the CFG.
80
78
  */
81
- controlflow(force: boolean | undefined, kind: CfgKind, simplifications?: readonly CfgSimplificationPassName[]): Promise<ControlFlowInformation>;
79
+ controlflow(force: boolean | undefined, simplifications?: readonly CfgSimplificationPassName[]): Promise<ControlFlowInformation>;
82
80
  /**
83
81
  * Get the control flow graph (CFG) for the request if already available, otherwise return `undefined`.
84
- * @param kind - The kind of CFG that is requested.
85
82
  * @param simplifications - Simplification passes to be applied to the CFG.
86
83
  * @see {@link FlowrAnalyzerCache#controlflow} - to get the control flow graph, computing if necessary.
87
84
  */
88
- peekControlflow(kind: CfgKind, simplifications: readonly CfgSimplificationPassName[] | undefined): ControlFlowInformation | undefined;
85
+ peekControlflow(simplifications: readonly CfgSimplificationPassName[] | undefined): ControlFlowInformation | undefined;
89
86
  /**
90
87
  * Get the call graph for the request, computing if necessary.
91
88
  * @param force - Do not use the cache, instead force new analyses.
@@ -145,26 +145,23 @@ class FlowrAnalyzerCache extends flowr_cache_1.FlowrCache {
145
145
  /**
146
146
  * Get the control flow graph (CFG) for the request, computing if necessary.
147
147
  * @param force - Do not use the cache, instead force new analyses.
148
- * @param kind - The kind of CFG that is requested.
149
148
  * @param simplifications - Simplification passes to be applied to the CFG.
150
149
  */
151
- async controlflow(force, kind, simplifications) {
150
+ async controlflow(force, simplifications) {
152
151
  const cfgInfo = {
153
152
  ctx: this.args.context,
154
- cfgQuick: this.peekDataflow()?.cfgQuick,
155
153
  ast: async () => await this.normalize(),
156
154
  dfg: async () => await this.dataflow()
157
155
  };
158
- return this.controlFlowCache.get(force, kind, cfgInfo, simplifications);
156
+ return this.controlFlowCache.get(force, cfgInfo, simplifications);
159
157
  }
160
158
  /**
161
159
  * Get the control flow graph (CFG) for the request if already available, otherwise return `undefined`.
162
- * @param kind - The kind of CFG that is requested.
163
160
  * @param simplifications - Simplification passes to be applied to the CFG.
164
161
  * @see {@link FlowrAnalyzerCache#controlflow} - to get the control flow graph, computing if necessary.
165
162
  */
166
- peekControlflow(kind, simplifications) {
167
- return this.controlFlowCache.peek(kind, simplifications);
163
+ peekControlflow(simplifications) {
164
+ return this.controlFlowCache.peek(simplifications);
168
165
  }
169
166
  /**
170
167
  * Get the call graph for the request, computing if necessary.
@@ -1,23 +1,24 @@
1
1
  import type { CfgSimplificationPassName } from '../../control-flow/cfg-simplification';
2
- import { CfgKind } from '../cfg-kind';
3
2
  import type { ControlFlowInformation } from '../../control-flow/control-flow-graph';
4
3
  import type { NormalizedAst } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
5
4
  import type { DataflowInformation } from '../../dataflow/info';
6
5
  import type { FlowrAnalyzerContext } from '../context/flowr-analyzer-context';
7
6
  interface CfgInfo {
8
7
  ctx: FlowrAnalyzerContext;
9
- cfgQuick: ControlFlowInformation | undefined;
10
8
  dfg: () => Promise<DataflowInformation>;
11
9
  ast: () => Promise<NormalizedAst>;
12
10
  }
11
+ /**
12
+ * Caches the control flow graph of a request.
13
+ *
14
+ * The control flow graph is a view on the dataflow graph (see {@link ControlFlowGraph}), so what is
15
+ * cached here is not the analysis but the simplification passes applied on top of it: the projection itself
16
+ * is lazy and costs nothing until something walks it.
17
+ */
13
18
  export declare class FlowrAnalyzerControlFlowCache {
14
19
  private readonly cache;
15
- peek(kind: CfgKind, simplifications: readonly CfgSimplificationPassName[] | undefined): ControlFlowInformation | undefined;
16
- get(force: boolean | undefined, kind: CfgKind, cfgCacheInfo: CfgInfo, simplifications?: readonly CfgSimplificationPassName[]): Promise<ControlFlowInformation>;
17
- /**
18
- * Create and cache the base CFG without simplifications.
19
- */
20
- private createAndCacheBaseCfg;
20
+ peek(simplifications: readonly CfgSimplificationPassName[] | undefined): ControlFlowInformation | undefined;
21
+ get(force: boolean | undefined, cfgCacheInfo: CfgInfo, simplifications?: readonly CfgSimplificationPassName[]): Promise<ControlFlowInformation>;
21
22
  /**
22
23
  * Try to get a cached CFG with some of the requested simplifications already applied.
23
24
  * Matches the longest prefix of simplifications available.
@@ -3,63 +3,46 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FlowrAnalyzerControlFlowCache = void 0;
4
4
  const objectmap_1 = require("../../util/collections/objectmap");
5
5
  const cfg_simplification_1 = require("../../control-flow/cfg-simplification");
6
- const cfg_kind_1 = require("../cfg-kind");
7
- const assert_1 = require("../../util/assert");
8
- const extract_cfg_1 = require("../../control-flow/extract-cfg");
6
+ const control_flow_graph_1 = require("../../control-flow/control-flow-graph");
7
+ /**
8
+ * Caches the control flow graph of a request.
9
+ *
10
+ * The control flow graph is a view on the dataflow graph (see {@link ControlFlowGraph}), so what is
11
+ * cached here is not the analysis but the simplification passes applied on top of it: the projection itself
12
+ * is lazy and costs nothing until something walks it.
13
+ */
9
14
  class FlowrAnalyzerControlFlowCache {
10
15
  cache = new objectmap_1.ObjectMap();
11
- peek(kind, simplifications) {
12
- return this.cache.get([simplifications ?? [], kind]);
16
+ peek(simplifications) {
17
+ return this.cache.get([simplifications ?? []]);
13
18
  }
14
- async get(force, kind, cfgCacheInfo, simplifications) {
15
- (0, assert_1.guard)(kind === cfg_kind_1.CfgKind.Quick ? simplifications === undefined : true, 'Cannot apply simplifications to quick CFG');
19
+ async get(force, cfgCacheInfo, simplifications) {
16
20
  simplifications ??= [];
17
21
  const orderedSimplifications = this.normalizeSimplificationOrder(simplifications);
18
22
  const cached = force ?
19
23
  { cfg: undefined, missingSimplifications: orderedSimplifications }
20
- : this.tryGetCachedCfg(orderedSimplifications, kind);
24
+ : this.tryGetCachedCfg(orderedSimplifications);
21
25
  let cfg = cached.cfg;
22
26
  if (!cfg) {
23
- cfg = await this.createAndCacheBaseCfg(kind, cfgCacheInfo);
27
+ cfg = (0, control_flow_graph_1.extractCfg)(await cfgCacheInfo.dfg());
28
+ this.cache.set([[]], cfg);
24
29
  }
25
30
  if (cached.missingSimplifications.length > 0) {
26
31
  const cfgPassInfo = { dfg: (await cfgCacheInfo.dfg()).graph, ctx: cfgCacheInfo.ctx, ast: await cfgCacheInfo.ast() };
27
32
  cfg = (0, cfg_simplification_1.simplifyControlFlowInformation)(cfg, cfgPassInfo, cached.missingSimplifications);
28
33
  }
29
- this.cache.set([orderedSimplifications, kind], cfg);
34
+ this.cache.set([orderedSimplifications], cfg);
30
35
  return cfg;
31
36
  }
32
- /**
33
- * Create and cache the base CFG without simplifications.
34
- */
35
- async createAndCacheBaseCfg(kind, { cfgQuick, dfg, ctx, ast }) {
36
- let result;
37
- switch (kind) {
38
- case cfg_kind_1.CfgKind.WithDataflow:
39
- result = (0, extract_cfg_1.extractCfg)(await ast(), ctx, (await dfg()).graph);
40
- break;
41
- case cfg_kind_1.CfgKind.NoDataflow:
42
- result = (0, extract_cfg_1.extractCfg)(await ast(), ctx);
43
- break;
44
- case cfg_kind_1.CfgKind.NoFunctionDefs:
45
- result = (0, extract_cfg_1.extractCfg)(await ast(), ctx, undefined, undefined, true);
46
- break;
47
- case cfg_kind_1.CfgKind.Quick:
48
- result = cfgQuick ?? (0, extract_cfg_1.extractCfgQuick)(await ast());
49
- break;
50
- }
51
- this.cache.set([[], kind], result);
52
- return result;
53
- }
54
37
  /**
55
38
  * Try to get a cached CFG with some of the requested simplifications already applied.
56
39
  * Matches the longest prefix of simplifications available.
57
40
  * @returns The cached CFG and the missing simplifications to be applied, or `undefined` if no cached CFG is available.
58
41
  */
59
- tryGetCachedCfg(simplifications, kind) {
42
+ tryGetCachedCfg(simplifications) {
60
43
  for (let prefixLen = simplifications.length; prefixLen >= 0; prefixLen--) {
61
44
  const prefix = simplifications.slice(0, prefixLen);
62
- const cached = this.cache.get([prefix, kind]);
45
+ const cached = this.cache.get([prefix]);
63
46
  if (cached !== undefined) {
64
47
  return {
65
48
  cfg: cached,
@@ -34,6 +34,15 @@ export type InvalidationEventHandler<Content extends StringableContent = Stringa
34
34
  export interface InvalidationEventReceiver<Content extends StringableContent = StringableContent> {
35
35
  receive: InvalidationEventHandler<Content>;
36
36
  }
37
+ /**
38
+ * The {@link InvalidationEventReceiver.receive} of every context that only caches project-wide state: a full
39
+ * invalidation drops it, a single changed file leaves it valid.
40
+ * @param target - The receiver whose state is dropped.
41
+ * @param event - The invalidation to handle.
42
+ */
43
+ export declare function resetOnFullInvalidation(target: {
44
+ reset(): void;
45
+ }, event: InvalidationEvent): void;
37
46
  /**
38
47
  * Central class for caching analysis results in FlowR.
39
48
  */
@@ -1,7 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FlowrCache = void 0;
4
+ exports.resetOnFullInvalidation = resetOnFullInvalidation;
4
5
  const assert_1 = require("../../util/assert");
6
+ /**
7
+ * The {@link InvalidationEventReceiver.receive} of every context that only caches project-wide state: a full
8
+ * invalidation drops it, a single changed file leaves it valid.
9
+ * @param target - The receiver whose state is dropped.
10
+ * @param event - The invalidation to handle.
11
+ */
12
+ function resetOnFullInvalidation(target, event) {
13
+ const type = event.type;
14
+ switch (type) {
15
+ case "full" /* InvalidationEventType.Full */:
16
+ target.reset();
17
+ break;
18
+ case "single-file-invalidate" /* InvalidationEventType.SingleFileInvalidate */:
19
+ break;
20
+ default:
21
+ (0, assert_1.assertUnreachable)(type);
22
+ }
23
+ }
5
24
  /**
6
25
  * Central class for caching analysis results in FlowR.
7
26
  */
@@ -77,8 +77,8 @@ export declare const enum RVersionOrigin {
77
77
  * Besides these, this layer only orchestrates the different steps and layers, providing a collection of convenience methods.
78
78
  * In general, you do not have to worry about these details, as the {@link FlowrAnalyzerBuilder} and {@link FlowrAnalyzer} take care of them.
79
79
  *
80
- * To inspect, e.g., the loading order, you can do so via {@link files.loadingOrder.getLoadingOrder}. To get information on a specific library, use
81
- * {@link deps.getDependency}.
80
+ * To inspect, e.g., the loading order, you can do so via {@link ReadOnlyFlowrAnalyzerLoadingOrderContext#getLoadingOrder|files.loadingOrder.getLoadingOrder}.
81
+ * To get information on a specific library, use {@link ReadOnlyFlowrAnalyzerDependenciesContext#getDependency|deps.getDependency}.
82
82
  * If you are just interested in inspecting the context, you can use {@link ReadOnlyFlowrAnalyzerContext} instead (e.g., via {@link inspect}).
83
83
  */
84
84
  export declare class FlowrAnalyzerContext implements ReadOnlyFlowrAnalyzerContext, InvalidationEventReceiver {
@@ -130,7 +130,11 @@ export declare class FlowrAnalyzerContext implements ReadOnlyFlowrAnalyzerContex
130
130
  } | undefined;
131
131
  /** {@link projectKind}, resolved with {@link baseConfig}, as classifying the project reads the config again */
132
132
  private kindToSpecializeFor;
133
- constructor(config: FlowrConfig, plugins: ReadonlyMap<PluginType, readonly FlowrAnalyzerPlugin[]>);
133
+ /**
134
+ * @param config - The configuration to analyze with.
135
+ * @param plugins - The plugins to run, either already grouped by their {@link PluginType} or as a plain list.
136
+ */
137
+ constructor(config: FlowrConfig, plugins?: ReadonlyMap<PluginType, readonly FlowrAnalyzerPlugin[]> | readonly FlowrAnalyzerPlugin[]);
134
138
  /**
135
139
  * Provides the analyzer associated with this context, if any.
136
140
  * This is usually set when the context is used within an analyzer instance.
@@ -25,8 +25,8 @@ const flowr_analyzer_gas_context_1 = require("./flowr-analyzer-gas-context");
25
25
  * Besides these, this layer only orchestrates the different steps and layers, providing a collection of convenience methods.
26
26
  * In general, you do not have to worry about these details, as the {@link FlowrAnalyzerBuilder} and {@link FlowrAnalyzer} take care of them.
27
27
  *
28
- * To inspect, e.g., the loading order, you can do so via {@link files.loadingOrder.getLoadingOrder}. To get information on a specific library, use
29
- * {@link deps.getDependency}.
28
+ * To inspect, e.g., the loading order, you can do so via {@link ReadOnlyFlowrAnalyzerLoadingOrderContext#getLoadingOrder|files.loadingOrder.getLoadingOrder}.
29
+ * To get information on a specific library, use {@link ReadOnlyFlowrAnalyzerDependenciesContext#getDependency|deps.getDependency}.
30
30
  * If you are just interested in inspecting the context, you can use {@link ReadOnlyFlowrAnalyzerContext} instead (e.g., via {@link inspect}).
31
31
  */
32
32
  class FlowrAnalyzerContext {
@@ -141,18 +141,24 @@ class FlowrAnalyzerContext {
141
141
  this._classifying = false;
142
142
  }
143
143
  }
144
- constructor(config, plugins) {
144
+ /**
145
+ * @param config - The configuration to analyze with.
146
+ * @param plugins - The plugins to run, either already grouped by their {@link PluginType} or as a plain list.
147
+ */
148
+ constructor(config, plugins = []) {
149
+ const byType = Array.isArray(plugins) ? (0, arrays_1.arraysGroupBy)(plugins, p => p.type)
150
+ : plugins;
145
151
  this.baseConfig = config;
146
152
  this._config = config;
147
- const loadingOrder = new flowr_analyzer_loading_order_context_1.FlowrAnalyzerLoadingOrderContext(this, plugins.get(flowr_analyzer_plugin_1.PluginType.LoadingOrder));
148
- this.files = new flowr_analyzer_files_context_1.FlowrAnalyzerFilesContext(this, loadingOrder, (plugins.get(flowr_analyzer_plugin_1.PluginType.ProjectDiscovery) ?? []), (plugins.get(flowr_analyzer_plugin_1.PluginType.FileLoad) ?? []));
153
+ const loadingOrder = new flowr_analyzer_loading_order_context_1.FlowrAnalyzerLoadingOrderContext(this, byType.get(flowr_analyzer_plugin_1.PluginType.LoadingOrder));
154
+ this.files = new flowr_analyzer_files_context_1.FlowrAnalyzerFilesContext(this, loadingOrder, (byType.get(flowr_analyzer_plugin_1.PluginType.ProjectDiscovery) ?? []), (byType.get(flowr_analyzer_plugin_1.PluginType.FileLoad) ?? []));
149
155
  this.env = new flowr_analyzer_environment_context_1.FlowrAnalyzerEnvironmentContext(this);
150
156
  this.inc = new flowr_analyzer_incremental_analysis_context_1.FlowrAnalyzerIncrementalAnalysisContext(this);
151
157
  const functions = new flowr_analyzer_functions_context_1.FlowrAnalyzerFunctionsContext(this);
152
- this.deps = new flowr_analyzer_dependencies_context_1.FlowrAnalyzerDependenciesContext(functions, (plugins.get(flowr_analyzer_plugin_1.PluginType.DependencyIdentification) ?? []));
158
+ this.deps = new flowr_analyzer_dependencies_context_1.FlowrAnalyzerDependenciesContext(functions, (byType.get(flowr_analyzer_plugin_1.PluginType.DependencyIdentification) ?? []));
153
159
  // the plugins contributing the metadata are the ones the dependency context runs on demand
154
160
  this.meta = new flowr_analyzer_meta_context_1.FlowrAnalyzerMetaContext(() => this.deps.ensureStaticsLoaded());
155
- this.gas = new flowr_analyzer_gas_context_1.FlowrAnalyzerGasContext(this, config.gas, (plugins.get(flowr_analyzer_plugin_1.PluginType.Gas) ?? []));
161
+ this.gas = new flowr_analyzer_gas_context_1.FlowrAnalyzerGasContext(this, config.gas, (byType.get(flowr_analyzer_plugin_1.PluginType.Gas) ?? []));
156
162
  }
157
163
  /**
158
164
  * Provides the analyzer associated with this context, if any.
@@ -249,7 +255,7 @@ exports.FlowrAnalyzerContext = FlowrAnalyzerContext;
249
255
  * @see {@link contextFromSources} - to create a context from source code strings directly.
250
256
  */
251
257
  function contextFromInput(input, config = config_1.FlowrConfig.default(), plugins) {
252
- const context = new FlowrAnalyzerContext(config, (0, arrays_1.arraysGroupBy)(plugins ?? [], (p) => p.type));
258
+ const context = new FlowrAnalyzerContext(config, plugins);
253
259
  if (typeof input === 'string' || Array.isArray(input) && input.every(i => typeof i === 'string')) {
254
260
  const requests = (0, retriever_1.requestFromInput)(input);
255
261
  context.addRequests(Array.isArray(requests) ? requests : [requests]);
@@ -269,7 +275,7 @@ function contextFromInput(input, config = config_1.FlowrConfig.default(), plugin
269
275
  * @see {@link FlowrInlineTextFile} - to create inline text files for the sources.
270
276
  */
271
277
  function contextFromSources(sources, config = config_1.FlowrConfig.default(), plugins) {
272
- const context = new FlowrAnalyzerContext(config, (0, arrays_1.arraysGroupBy)(plugins ?? [], (p) => p.type));
278
+ const context = new FlowrAnalyzerContext(config, plugins);
273
279
  for (const [p, c] of Object.entries(sources)) {
274
280
  context.addFile(new flowr_file_1.FlowrInlineTextFile(p, c));
275
281
  }