@eagleoutice/flowr 2.10.9 → 2.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (417) hide show
  1. package/README.md +116 -38
  2. package/abstract-interpretation/absint-visitor.js +6 -3
  3. package/abstract-interpretation/domains/abstract-domain.d.ts +1 -1
  4. package/abstract-interpretation/domains/bounded-set-domain.d.ts +1 -1
  5. package/abstract-interpretation/domains/bounded-set-domain.js +1 -1
  6. package/abstract-interpretation/domains/interval-domain.d.ts +1 -1
  7. package/abstract-interpretation/domains/interval-domain.js +1 -1
  8. package/abstract-interpretation/domains/lattice.d.ts +1 -1
  9. package/abstract-interpretation/domains/partial-product-domain.d.ts +1 -1
  10. package/abstract-interpretation/domains/partial-product-domain.js +2 -2
  11. package/abstract-interpretation/domains/set-range-domain.d.ts +1 -1
  12. package/abstract-interpretation/domains/set-range-domain.js +1 -1
  13. package/abstract-interpretation/domains/set-upper-bound-domain.d.ts +1 -1
  14. package/abstract-interpretation/domains/set-upper-bound-domain.js +1 -1
  15. package/abstract-interpretation/domains/singleton-domain.d.ts +1 -1
  16. package/abstract-interpretation/domains/singleton-domain.js +1 -1
  17. package/abstract-interpretation/domains/state-abstract-domain.d.ts +1 -1
  18. package/abstract-interpretation/domains/state-abstract-domain.js +2 -2
  19. package/abstract-interpretation/unsupported-functions.d.ts +3 -2
  20. package/abstract-interpretation/unsupported-functions.js +38 -28
  21. package/cli/benchmark-app.js +2 -1
  22. package/cli/common/options.d.ts +2 -108
  23. package/cli/common/options.js +3 -27
  24. package/cli/common/script.js +3 -2
  25. package/cli/common/scripts-info.d.ts +2 -123
  26. package/cli/common/scripts-info.js +0 -17
  27. package/cli/flowr-main-options.d.ts +5 -0
  28. package/cli/flowr-main-options.js +10 -0
  29. package/cli/flowr.js +48 -11
  30. package/cli/repl/commands/repl-cfg.js +9 -9
  31. package/cli/repl/commands/repl-commands.js +5 -0
  32. package/cli/repl/commands/repl-dataflow.js +31 -24
  33. package/cli/repl/commands/repl-main.d.ts +6 -0
  34. package/cli/repl/commands/repl-normalize.js +15 -12
  35. package/cli/repl/commands/repl-parse.js +1 -1
  36. package/cli/repl/commands/repl-query.js +4 -5
  37. package/cli/repl/commands/repl-quit.js +2 -1
  38. package/cli/repl/core.d.ts +11 -0
  39. package/cli/repl/core.js +101 -3
  40. package/cli/repl/execute.js +3 -2
  41. package/cli/repl/parser/slice-query-parser.d.ts +16 -0
  42. package/cli/repl/parser/slice-query-parser.js +52 -0
  43. package/cli/repl/print-version.d.ts +3 -1
  44. package/cli/repl/print-version.js +21 -2
  45. package/cli/repl/server/connection.d.ts +3 -0
  46. package/cli/repl/server/connection.js +65 -31
  47. package/cli/repl/server/messages/message-analysis.d.ts +10 -0
  48. package/cli/repl/server/messages/message-analysis.js +6 -2
  49. package/cli/repl/server/messages/message-slice.d.ts +1 -1
  50. package/cli/script-core/summarizer-core.js +13 -32
  51. package/cli/wiki.d.ts +3 -1
  52. package/cli/wiki.js +6 -1
  53. package/config.d.ts +22 -10
  54. package/config.js +33 -7
  55. package/control-flow/diff-cfg.d.ts +1 -1
  56. package/control-flow/diff-cfg.js +1 -1
  57. package/control-flow/semantic-cfg-guided-visitor.js +2 -0
  58. package/control-flow/simple-visitor.js +6 -5
  59. package/control-flow/useless-loop.js +2 -2
  60. package/core/print/dataflow-printer.d.ts +2 -2
  61. package/core/print/dataflow-printer.js +2 -2
  62. package/core/steps/all/static-slicing/00-slice.js +1 -1
  63. package/data/pkgdb/pkgdb-latest.json.br +0 -0
  64. package/data/pkgdb/pkgdb-tiny.json.br +0 -0
  65. package/dataflow/environments/append.d.ts +2 -2
  66. package/dataflow/environments/append.js +4 -10
  67. package/dataflow/environments/apply-kill.d.ts +21 -0
  68. package/dataflow/environments/apply-kill.js +155 -0
  69. package/dataflow/environments/built-in-proc-name.d.ts +4 -0
  70. package/dataflow/environments/built-in-proc-name.js +4 -0
  71. package/dataflow/environments/built-in.d.ts +4 -0
  72. package/dataflow/environments/built-in.js +4 -0
  73. package/dataflow/environments/default-builtin-config.d.ts +183 -67
  74. package/dataflow/environments/default-builtin-config.js +358 -147
  75. package/dataflow/environments/environment.d.ts +49 -31
  76. package/dataflow/environments/environment.js +144 -25
  77. package/dataflow/environments/identifier.d.ts +65 -2
  78. package/dataflow/environments/identifier.js +37 -2
  79. package/dataflow/environments/overwrite.js +2 -10
  80. package/dataflow/environments/reference-to-maybe.d.ts +2 -0
  81. package/dataflow/environments/reference-to-maybe.js +56 -11
  82. package/dataflow/environments/resolve-by-name.d.ts +1 -1
  83. package/dataflow/environments/resolve-by-name.js +23 -9
  84. package/dataflow/environments/scoping.d.ts +9 -2
  85. package/dataflow/environments/scoping.js +15 -2
  86. package/dataflow/eval/values/general.js +4 -0
  87. package/dataflow/extractor.js +35 -4
  88. package/dataflow/graph/df-helper.d.ts +14 -0
  89. package/dataflow/graph/df-helper.js +41 -0
  90. package/dataflow/graph/graph.d.ts +4 -1
  91. package/dataflow/graph/graph.js +6 -2
  92. package/dataflow/info.d.ts +27 -1
  93. package/dataflow/internal/linker.d.ts +5 -1
  94. package/dataflow/internal/linker.js +34 -9
  95. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +7 -5
  96. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +19 -0
  97. package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +1 -8
  98. package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +7 -13
  99. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +9 -48
  100. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +30 -47
  101. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +17 -0
  102. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +7 -2
  103. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +2 -2
  104. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +61 -1
  105. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +9 -0
  106. package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +37 -3
  107. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +391 -21
  108. package/dataflow/internal/process/functions/call/built-in/built-in-namespace-access.d.ts +13 -0
  109. package/dataflow/internal/process/functions/call/built-in/built-in-namespace-access.js +58 -0
  110. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +1 -1
  111. package/dataflow/internal/process/functions/call/built-in/built-in-rm.d.ts +3 -2
  112. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +132 -25
  113. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +9 -10
  114. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.d.ts +25 -0
  115. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +94 -0
  116. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +11 -4
  117. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +30 -0
  118. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +279 -0
  119. package/dataflow/internal/process/functions/call/known-call-handling.js +4 -3
  120. package/dataflow/internal/process/functions/call/named-call-handling.d.ts +1 -1
  121. package/dataflow/internal/process/functions/call/named-call-handling.js +23 -0
  122. package/dataflow/origin/dfg-get-origin.d.ts +1 -1
  123. package/dataflow/origin/dfg-get-origin.js +1 -1
  124. package/dataflow/processor.d.ts +6 -0
  125. package/documentation/data/faq/faqs.d.ts +2 -1
  126. package/documentation/data/faq/faqs.js +78 -57
  127. package/documentation/data/interface/doc-writing-code.js +4 -80
  128. package/documentation/data/server/doc-data-server-messages.d.ts +2 -1
  129. package/documentation/data/server/doc-data-server-messages.js +15 -7
  130. package/documentation/doc-readme.js +15 -15
  131. package/documentation/doc-util/doc-cfg.d.ts +3 -1
  132. package/documentation/doc-util/doc-cfg.js +3 -3
  133. package/documentation/doc-util/doc-dfg.d.ts +3 -1
  134. package/documentation/doc-util/doc-dfg.js +3 -3
  135. package/documentation/doc-util/doc-files.d.ts +3 -1
  136. package/documentation/doc-util/doc-files.js +9 -6
  137. package/documentation/doc-util/doc-normalized-ast.d.ts +3 -1
  138. package/documentation/doc-util/doc-normalized-ast.js +2 -2
  139. package/documentation/doc-util/doc-query.d.ts +2 -1
  140. package/documentation/doc-util/doc-query.js +2 -2
  141. package/documentation/doc-util/doc-repl.js +1 -0
  142. package/documentation/doc-util/doc-structure.js +1 -2
  143. package/documentation/doc-util/doc-types.d.ts +6 -6
  144. package/documentation/doc-util/doc-types.js +11 -9
  145. package/documentation/issue-linting-rule.js +1 -2
  146. package/documentation/wiki-analyzer.js +9 -9
  147. package/documentation/wiki-cfg.js +40 -41
  148. package/documentation/wiki-core.js +121 -32
  149. package/documentation/wiki-create-linting-rules.d.ts +6 -0
  150. package/documentation/wiki-create-linting-rules.js +95 -0
  151. package/documentation/wiki-dataflow-graph.js +112 -77
  152. package/documentation/wiki-engine.js +1 -2
  153. package/documentation/wiki-faq.d.ts +2 -1
  154. package/documentation/wiki-faq.js +4 -4
  155. package/documentation/wiki-interface.js +22 -8
  156. package/documentation/wiki-linter.d.ts +1 -1
  157. package/documentation/wiki-linter.js +16 -6
  158. package/documentation/wiki-linting-and-testing.js +2 -2
  159. package/documentation/wiki-mk/doc-context.d.ts +3 -3
  160. package/documentation/wiki-mk/doc-maker.d.ts +2 -0
  161. package/documentation/wiki-mk/doc-maker.js +7 -1
  162. package/documentation/wiki-normalized-ast.js +5 -5
  163. package/documentation/wiki-onboarding.d.ts +2 -1
  164. package/documentation/wiki-onboarding.js +5 -5
  165. package/documentation/wiki-overview.js +4 -17
  166. package/documentation/wiki-package-database.d.ts +9 -0
  167. package/documentation/wiki-package-database.js +63 -0
  168. package/documentation/wiki-query.js +86 -84
  169. package/documentation/wiki-search.js +4 -5
  170. package/documentation/wiki-setup.js +6 -7
  171. package/gas.d.ts +74 -0
  172. package/gas.js +18 -0
  173. package/linter/linter-executor.js +2 -8
  174. package/linter/linter-format.d.ts +4 -11
  175. package/linter/linter-rules.d.ts +111 -86
  176. package/linter/linter-rules.js +9 -1
  177. package/linter/rules/absolute-path.d.ts +2 -7
  178. package/linter/rules/absolute-path.js +8 -5
  179. package/linter/rules/dataframe-access-validation.d.ts +1 -6
  180. package/linter/rules/dataframe-access-validation.js +8 -6
  181. package/linter/rules/dead-code.d.ts +2 -11
  182. package/linter/rules/dead-code.js +16 -11
  183. package/linter/rules/deprecated-functions.d.ts +3 -3
  184. package/linter/rules/file-path-validity.d.ts +1 -6
  185. package/linter/rules/file-path-validity.js +5 -5
  186. package/linter/rules/function-finder-util.d.ts +7 -11
  187. package/linter/rules/function-finder-util.js +9 -6
  188. package/linter/rules/naming-convention.d.ts +2 -7
  189. package/linter/rules/naming-convention.js +3 -2
  190. package/linter/rules/network-functions.d.ts +2 -7
  191. package/linter/rules/network-functions.js +14 -12
  192. package/linter/rules/no-leaked-credentials.d.ts +36 -0
  193. package/linter/rules/no-leaked-credentials.js +75 -0
  194. package/linter/rules/problematic-inputs.d.ts +1 -8
  195. package/linter/rules/problematic-inputs.js +5 -4
  196. package/linter/rules/roxygen-arguments.d.ts +2 -7
  197. package/linter/rules/roxygen-arguments.js +13 -20
  198. package/linter/rules/seeded-randomness.d.ts +2 -7
  199. package/linter/rules/seeded-randomness.js +7 -4
  200. package/linter/rules/software-has-license.d.ts +31 -0
  201. package/linter/rules/software-has-license.js +46 -0
  202. package/linter/rules/software-has-tests.d.ts +38 -0
  203. package/linter/rules/software-has-tests.js +48 -0
  204. package/linter/rules/stop-with-call-arg.d.ts +2 -7
  205. package/linter/rules/stop-with-call-arg.js +3 -2
  206. package/linter/rules/undefined-symbol.d.ts +39 -0
  207. package/linter/rules/undefined-symbol.js +80 -0
  208. package/linter/rules/unused-definition.d.ts +3 -8
  209. package/linter/rules/unused-definition.js +7 -5
  210. package/linter/rules/useless-loop.d.ts +2 -7
  211. package/linter/rules/useless-loop.js +5 -2
  212. package/package.json +5 -5
  213. package/project/cache/flowr-analyzer-cache.d.ts +2 -0
  214. package/project/cache/flowr-analyzer-cache.js +9 -1
  215. package/project/context/flowr-analyzer-context.d.ts +13 -14
  216. package/project/context/flowr-analyzer-context.js +4 -0
  217. package/project/context/flowr-analyzer-dependencies-context.d.ts +16 -8
  218. package/project/context/flowr-analyzer-dependencies-context.js +36 -4
  219. package/project/context/flowr-analyzer-environment-context.d.ts +2 -4
  220. package/project/context/flowr-analyzer-environment-context.js +3 -4
  221. package/project/context/flowr-analyzer-files-context.d.ts +13 -0
  222. package/project/context/flowr-analyzer-files-context.js +12 -2
  223. package/project/context/flowr-analyzer-gas-context.d.ts +28 -0
  224. package/project/context/flowr-analyzer-gas-context.js +101 -0
  225. package/project/context/flowr-file.d.ts +2 -0
  226. package/project/context/flowr-file.js +2 -0
  227. package/project/flowr-analyzer-builder.js +3 -0
  228. package/project/flowr-analyzer.d.ts +2 -1
  229. package/project/flowr-analyzer.js +3 -1
  230. package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +13 -15
  231. package/project/plugins/file-plugins/files/flowr-namespace-file.js +36 -13
  232. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +13 -7
  233. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +56 -11
  234. package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.d.ts +27 -0
  235. package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.js +41 -0
  236. package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.d.ts +1 -1
  237. package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.js +2 -2
  238. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.d.ts +2 -1
  239. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.js +5 -5
  240. package/project/plugins/flowr-analyzer-plugin.d.ts +15 -8
  241. package/project/plugins/flowr-analyzer-plugin.js +14 -7
  242. package/project/plugins/gas-plugins/flowr-analyzer-gas-plugin.d.ts +19 -0
  243. package/project/plugins/gas-plugins/flowr-analyzer-gas-plugin.js +35 -0
  244. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.d.ts +18 -0
  245. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +62 -0
  246. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin.d.ts +63 -0
  247. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin.js +174 -0
  248. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.d.ts +10 -0
  249. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.js +6 -0
  250. package/project/plugins/package-version-plugins/package.d.ts +3 -0
  251. package/project/plugins/package-version-plugins/package.js +12 -0
  252. package/project/plugins/package-version-plugins/pkgdb.d.ts +133 -0
  253. package/project/plugins/package-version-plugins/pkgdb.js +370 -0
  254. package/project/plugins/plugin-registry.d.ts +5 -1
  255. package/project/plugins/plugin-registry.js +10 -1
  256. package/project/plugins/project-discovery/flowr-analyzer-gitignore-project-discovery-plugin.d.ts +22 -0
  257. package/project/plugins/project-discovery/flowr-analyzer-gitignore-project-discovery-plugin.js +47 -0
  258. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +1 -1
  259. package/queries/catalog/call-context-query/call-context-query-executor.js +62 -8
  260. package/queries/catalog/call-context-query/call-context-query-format.d.ts +4 -2
  261. package/queries/catalog/call-context-query/call-context-query-format.js +1 -0
  262. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +8 -0
  263. package/queries/catalog/dependencies-query/dependencies-query-executor.js +31 -3
  264. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +3 -1
  265. package/queries/catalog/dependencies-query/dependencies-query-format.js +3 -2
  266. package/queries/catalog/dependencies-query/function-info/function-info.d.ts +1 -1
  267. package/queries/catalog/dependencies-query/function-info/other-path-functions.d.ts +2 -0
  268. package/queries/catalog/dependencies-query/function-info/other-path-functions.js +27 -0
  269. package/queries/catalog/dependencies-query/function-info/read-functions.js +5 -4
  270. package/queries/catalog/dependencies-query/function-info/test-functions.d.ts +2 -0
  271. package/queries/catalog/dependencies-query/function-info/test-functions.js +18 -177
  272. package/queries/catalog/dependencies-query/function-info/visualize-functions.js +3 -1
  273. package/queries/catalog/df-shape-query/df-shape-query-format.js +1 -1
  274. package/queries/catalog/dice-query/dice-query-executor.d.ts +8 -0
  275. package/queries/catalog/dice-query/dice-query-executor.js +52 -0
  276. package/queries/catalog/dice-query/dice-query-format.d.ts +53 -0
  277. package/queries/catalog/dice-query/dice-query-format.js +102 -0
  278. package/queries/catalog/happens-before-query/happens-before-query-executor.js +2 -2
  279. package/queries/catalog/input-sources-query/input-sources-query-format.d.ts +2 -0
  280. package/queries/catalog/input-sources-query/input-sources-query-format.js +1 -0
  281. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.d.ts +2 -0
  282. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +1 -0
  283. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +2 -0
  284. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +1 -0
  285. package/queries/catalog/linter-query/linter-query-executor.js +8 -0
  286. package/queries/catalog/location-map-query/location-map-query-format.d.ts +2 -0
  287. package/queries/catalog/location-map-query/location-map-query-format.js +1 -0
  288. package/queries/catalog/origin-query/origin-query-format.d.ts +2 -0
  289. package/queries/catalog/origin-query/origin-query-format.js +1 -0
  290. package/queries/catalog/provenance-query/provenance-query-format.d.ts +2 -0
  291. package/queries/catalog/provenance-query/provenance-query-format.js +1 -0
  292. package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +2 -0
  293. package/queries/catalog/resolve-value-query/resolve-value-query-format.js +1 -0
  294. package/queries/catalog/static-slice-query/static-slice-query-executor.js +1 -1
  295. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +2 -0
  296. package/queries/catalog/static-slice-query/static-slice-query-format.js +1 -0
  297. package/queries/query.d.ts +18 -1
  298. package/queries/query.js +3 -1
  299. package/r-bridge/data/data.d.ts +7 -2
  300. package/r-bridge/data/data.js +8 -2
  301. package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +0 -1
  302. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-number.d.ts +1 -1
  303. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-number.js +1 -1
  304. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-string.d.ts +1 -1
  305. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-string.js +1 -1
  306. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +13 -4
  307. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +55 -44
  308. package/r-bridge/parser.js +2 -9
  309. package/r-bridge/shell.d.ts +8 -1
  310. package/r-bridge/shell.js +26 -7
  311. package/search/flowr-search-builder.d.ts +2 -2
  312. package/search/flowr-search-builder.js +1 -1
  313. package/search/flowr-search-filters.d.ts +30 -9
  314. package/search/flowr-search-filters.js +26 -21
  315. package/search/search-executor/search-enrichers.d.ts +601 -1
  316. package/search/search-executor/search-enrichers.js +30 -6
  317. package/slicing/static/static-slicer.d.ts +39 -11
  318. package/slicing/static/static-slicer.js +44 -14
  319. package/util/collections/queue.d.ts +16 -0
  320. package/util/collections/queue.js +38 -0
  321. package/util/log.d.ts +1 -1
  322. package/util/log.js +1 -1
  323. package/util/mermaid/dfg.d.ts +2 -2
  324. package/util/mermaid/dfg.js +2 -2
  325. package/util/mermaid/mermaid.d.ts +4 -0
  326. package/util/mermaid/mermaid.js +8 -1
  327. package/util/objects.d.ts +9 -0
  328. package/util/objects.js +54 -0
  329. package/util/proc.d.ts +6 -0
  330. package/util/proc.js +20 -0
  331. package/util/version.js +10 -2
  332. package/cli/common/features.d.ts +0 -9
  333. package/cli/common/features.js +0 -35
  334. package/cli/script-core/statistics-core.d.ts +0 -6
  335. package/cli/script-core/statistics-core.js +0 -103
  336. package/cli/script-core/statistics-helper-core.d.ts +0 -6
  337. package/cli/script-core/statistics-helper-core.js +0 -85
  338. package/cli/statistics-app.d.ts +0 -11
  339. package/cli/statistics-app.js +0 -16
  340. package/cli/statistics-helper-app.d.ts +0 -11
  341. package/cli/statistics-helper-app.js +0 -14
  342. package/statistics/features/common-syntax-probability.d.ts +0 -38
  343. package/statistics/features/common-syntax-probability.js +0 -169
  344. package/statistics/features/feature.d.ts +0 -179
  345. package/statistics/features/feature.js +0 -38
  346. package/statistics/features/post-processing.d.ts +0 -18
  347. package/statistics/features/post-processing.js +0 -26
  348. package/statistics/features/supported/assignments/assignments.d.ts +0 -12
  349. package/statistics/features/supported/assignments/assignments.js +0 -56
  350. package/statistics/features/supported/assignments/post-process.d.ts +0 -6
  351. package/statistics/features/supported/assignments/post-process.js +0 -126
  352. package/statistics/features/supported/comments/comments.d.ts +0 -18
  353. package/statistics/features/supported/comments/comments.js +0 -143
  354. package/statistics/features/supported/comments/post-process.d.ts +0 -6
  355. package/statistics/features/supported/comments/post-process.js +0 -51
  356. package/statistics/features/supported/control-flow/control-flow.d.ts +0 -17
  357. package/statistics/features/supported/control-flow/control-flow.js +0 -69
  358. package/statistics/features/supported/control-flow/post-process.d.ts +0 -6
  359. package/statistics/features/supported/control-flow/post-process.js +0 -66
  360. package/statistics/features/supported/data-access/data-access.d.ts +0 -15
  361. package/statistics/features/supported/data-access/data-access.js +0 -122
  362. package/statistics/features/supported/data-access/post-process.d.ts +0 -6
  363. package/statistics/features/supported/data-access/post-process.js +0 -108
  364. package/statistics/features/supported/defined-functions/defined-functions.d.ts +0 -34
  365. package/statistics/features/supported/defined-functions/defined-functions.js +0 -145
  366. package/statistics/features/supported/defined-functions/post-process.d.ts +0 -6
  367. package/statistics/features/supported/defined-functions/post-process.js +0 -168
  368. package/statistics/features/supported/expression-list/post-process.d.ts +0 -6
  369. package/statistics/features/supported/expression-list/post-process.js +0 -45
  370. package/statistics/features/supported/expression-list/statistics-expression-list.d.ts +0 -9
  371. package/statistics/features/supported/expression-list/statistics-expression-list.js +0 -37
  372. package/statistics/features/supported/loops/loops.d.ts +0 -20
  373. package/statistics/features/supported/loops/loops.js +0 -81
  374. package/statistics/features/supported/loops/post-process.d.ts +0 -6
  375. package/statistics/features/supported/loops/post-process.js +0 -73
  376. package/statistics/features/supported/used-functions/post-process.d.ts +0 -6
  377. package/statistics/features/supported/used-functions/post-process.js +0 -176
  378. package/statistics/features/supported/used-functions/used-functions.d.ts +0 -24
  379. package/statistics/features/supported/used-functions/used-functions.js +0 -99
  380. package/statistics/features/supported/used-packages/post-process.d.ts +0 -6
  381. package/statistics/features/supported/used-packages/post-process.js +0 -122
  382. package/statistics/features/supported/used-packages/used-packages.d.ts +0 -16
  383. package/statistics/features/supported/used-packages/used-packages.js +0 -140
  384. package/statistics/features/supported/values/post-process.d.ts +0 -6
  385. package/statistics/features/supported/values/post-process.js +0 -73
  386. package/statistics/features/supported/values/values.d.ts +0 -14
  387. package/statistics/features/supported/values/values.js +0 -111
  388. package/statistics/features/supported/variables/post-process.d.ts +0 -15
  389. package/statistics/features/supported/variables/post-process.js +0 -126
  390. package/statistics/features/supported/variables/variables.d.ts +0 -15
  391. package/statistics/features/supported/variables/variables.js +0 -62
  392. package/statistics/meta-statistics.d.ts +0 -32
  393. package/statistics/meta-statistics.js +0 -16
  394. package/statistics/output/file-provider.d.ts +0 -36
  395. package/statistics/output/file-provider.js +0 -96
  396. package/statistics/output/print-stats.d.ts +0 -29
  397. package/statistics/output/print-stats.js +0 -81
  398. package/statistics/output/statistics-file.d.ts +0 -36
  399. package/statistics/output/statistics-file.js +0 -68
  400. package/statistics/statistics.d.ts +0 -29
  401. package/statistics/statistics.js +0 -108
  402. package/statistics/summarizer/auto-detect.d.ts +0 -5
  403. package/statistics/summarizer/auto-detect.js +0 -34
  404. package/statistics/summarizer/first-phase/process.d.ts +0 -6
  405. package/statistics/summarizer/first-phase/process.js +0 -81
  406. package/statistics/summarizer/post-process/clusterer.d.ts +0 -25
  407. package/statistics/summarizer/post-process/clusterer.js +0 -40
  408. package/statistics/summarizer/post-process/file-based-count.d.ts +0 -16
  409. package/statistics/summarizer/post-process/file-based-count.js +0 -47
  410. package/statistics/summarizer/post-process/histogram.d.ts +0 -57
  411. package/statistics/summarizer/post-process/histogram.js +0 -126
  412. package/statistics/summarizer/post-process/post-process-output.d.ts +0 -14
  413. package/statistics/summarizer/post-process/post-process-output.js +0 -102
  414. package/statistics/summarizer/second-phase/process.d.ts +0 -15
  415. package/statistics/summarizer/second-phase/process.js +0 -118
  416. package/statistics/summarizer/summarizer.d.ts +0 -34
  417. package/statistics/summarizer/summarizer.js +0 -141
@@ -34,7 +34,6 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.controlflowBbStarCommand = exports.controlflowBbCommand = exports.controlflowStarCommand = exports.controlflowCommand = void 0;
37
- const retriever_1 = require("../../../r-bridge/retriever");
38
37
  const cfg_1 = require("../../../util/mermaid/cfg");
39
38
  const ansi_1 = require("../../../util/text/ansi");
40
39
  const cfg_simplification_1 = require("../../../control-flow/cfg-simplification");
@@ -47,16 +46,17 @@ async function produceAndPrintCfg(analyzer, output, simplifications, cfgConverte
47
46
  const normalizedAst = await analyzer.normalize();
48
47
  const mermaid = cfgConverter(cfg, normalizedAst);
49
48
  output.stdout(mermaid);
50
- try {
51
- const clipboard = await Promise.resolve().then(() => __importStar(require('clipboardy')));
52
- clipboard.default.writeSync(mermaid);
53
- output.stdout(formatInfo(output, 'mermaid code'));
54
- }
55
- catch { /* do nothing this is a service thing */
49
+ if (output.allowClipboard !== false) {
50
+ try {
51
+ const clipboard = await Promise.resolve().then(() => __importStar(require('clipboardy')));
52
+ clipboard.default.writeSync(mermaid);
53
+ output.stdout(formatInfo(output, 'mermaid code'));
54
+ }
55
+ catch { /* do nothing this is a service thing */ }
56
56
  }
57
57
  }
58
58
  exports.controlflowCommand = {
59
- description: `Get mermaid code for the control-flow graph of R code, start with '${retriever_1.fileProtocol}' to indicate a file`,
59
+ description: 'Get mermaid code for the control-flow graph of R code',
60
60
  isCodeCommand: true,
61
61
  usageExample: ':controlflow',
62
62
  aliases: ['cfg', 'cf'],
@@ -78,7 +78,7 @@ exports.controlflowStarCommand = {
78
78
  }
79
79
  };
80
80
  exports.controlflowBbCommand = {
81
- description: `Get mermaid code for the control-flow graph with basic blocks, start with '${retriever_1.fileProtocol}' to indicate a file`,
81
+ description: 'Get mermaid code for the control-flow graph with basic blocks',
82
82
  isCodeCommand: true,
83
83
  usageExample: ':controlflowbb',
84
84
  aliases: ['cfgb', 'cfb'],
@@ -65,6 +65,11 @@ Furthermore, you can directly call the following scripts which accept arguments.
65
65
  ${Array.from(Object.entries(getReplCommands())).filter(([, { script }]) => script).map(([command, { description }]) => ` ${(0, ansi_1.bold)(padCmd(':' + command), output.formatter)}${description}`).sort().join('\n')}
66
66
 
67
67
  You can combine commands by separating them with a semicolon ${(0, ansi_1.bold)(';', output.formatter)}.
68
+
69
+ Commands that accept a file path support two path prefixes:
70
+ ${(0, ansi_1.bold)('file://<path>', output.formatter)} run the command once on the given file or folder
71
+ ${(0, ansi_1.bold)('watch://<path>', output.formatter)} re-run the command whenever the file (or any file in the folder) changes
72
+ Press Ctrl+C or enter any other command to leave watch mode.
68
73
  `);
69
74
  }
70
75
  };
@@ -34,7 +34,6 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.dataflowSimpleStarCommand = exports.dataflowSimplifiedCommand = exports.dataflowSilentCommand = exports.dataflowAsciiCommand = exports.dataflowStarCommand = exports.dataflowCommand = void 0;
37
- const retriever_1 = require("../../../r-bridge/retriever");
38
37
  const ansi_1 = require("../../../util/text/ansi");
39
38
  const core_1 = require("../core");
40
39
  const vertex_1 = require("../../../dataflow/graph/vertex");
@@ -44,7 +43,7 @@ function formatInfo(out, type, meta) {
44
43
  return out.formatter.format(`Copied ${type} to clipboard (dataflow: ${meta['.meta'].timing + 'ms'}).`, { color: 7 /* Colors.White */, effect: ansi_1.ColorEffect.Foreground, style: 3 /* FontStyles.Italic */ });
45
44
  }
46
45
  exports.dataflowCommand = {
47
- description: `Get mermaid code for the dataflow graph, start with '${retriever_1.fileProtocol}' to indicate a file`,
46
+ description: 'Get mermaid code for the dataflow graph',
48
47
  isCodeCommand: true,
49
48
  usageExample: ':dataflow',
50
49
  aliases: ['d', 'df'],
@@ -54,12 +53,14 @@ exports.dataflowCommand = {
54
53
  const result = await analyzer.dataflow();
55
54
  const mermaid = df_helper_1.Dataflow.visualize.mermaid.convert({ graph: result.graph, includeEnvironments: false }).string;
56
55
  output.stdout(mermaid);
57
- try {
58
- const clipboard = await Promise.resolve().then(() => __importStar(require('clipboardy')));
59
- clipboard.default.writeSync(mermaid);
60
- output.stdout(formatInfo(output, 'mermaid code', result));
61
- }
62
- catch { /* do nothing this is a service thing */
56
+ if (output.allowClipboard !== false) {
57
+ try {
58
+ const clipboard = await Promise.resolve().then(() => __importStar(require('clipboardy')));
59
+ clipboard.default.writeSync(mermaid);
60
+ output.stdout(formatInfo(output, 'mermaid code', result));
61
+ }
62
+ catch { /* do nothing this is a service thing */
63
+ }
63
64
  }
64
65
  }
65
66
  };
@@ -74,12 +75,14 @@ exports.dataflowStarCommand = {
74
75
  const result = await analyzer.dataflow();
75
76
  const mermaid = df_helper_1.Dataflow.visualize.mermaid.url(result.graph, false);
76
77
  output.stdout(mermaid);
77
- try {
78
- const clipboard = await Promise.resolve().then(() => __importStar(require('clipboardy')));
79
- clipboard.default.writeSync(mermaid);
80
- output.stdout(formatInfo(output, 'mermaid url', result));
78
+ if (output.allowClipboard !== false) {
79
+ try {
80
+ const clipboard = await Promise.resolve().then(() => __importStar(require('clipboardy')));
81
+ clipboard.default.writeSync(mermaid);
82
+ output.stdout(formatInfo(output, 'mermaid url', result));
83
+ }
84
+ catch { /* do nothing this is a service thing */ }
81
85
  }
82
- catch { /* do nothing this is a service thing */ }
83
86
  }
84
87
  };
85
88
  exports.dataflowAsciiCommand = {
@@ -118,7 +121,7 @@ exports.dataflowSilentCommand = {
118
121
  }
119
122
  };
120
123
  exports.dataflowSimplifiedCommand = {
121
- description: `Get mermaid code for the simplified dataflow graph, start with '${retriever_1.fileProtocol}' to indicate a file`,
124
+ description: 'Get mermaid code for the simplified dataflow graph',
122
125
  isCodeCommand: true,
123
126
  usageExample: ':dataflowsimple',
124
127
  aliases: ['ds', 'dfs'],
@@ -128,12 +131,14 @@ exports.dataflowSimplifiedCommand = {
128
131
  const result = await analyzer.dataflow();
129
132
  const mermaid = df_helper_1.Dataflow.visualize.mermaid.convert({ graph: result.graph, includeEnvironments: false, simplified: true }).string;
130
133
  output.stdout(mermaid);
131
- try {
132
- const clipboard = await Promise.resolve().then(() => __importStar(require('clipboardy')));
133
- clipboard.default.writeSync(mermaid);
134
- output.stdout(formatInfo(output, 'mermaid code', result));
134
+ if (output.allowClipboard !== false) {
135
+ try {
136
+ const clipboard = await Promise.resolve().then(() => __importStar(require('clipboardy')));
137
+ clipboard.default.writeSync(mermaid);
138
+ output.stdout(formatInfo(output, 'mermaid code', result));
139
+ }
140
+ catch { /* do nothing this is a service thing */ }
135
141
  }
136
- catch { /* do nothing this is a service thing */ }
137
142
  }
138
143
  };
139
144
  exports.dataflowSimpleStarCommand = {
@@ -147,12 +152,14 @@ exports.dataflowSimpleStarCommand = {
147
152
  const result = await analyzer.dataflow();
148
153
  const mermaid = df_helper_1.Dataflow.visualize.mermaid.url(result.graph, false, undefined, true);
149
154
  output.stdout(mermaid);
150
- try {
151
- const clipboard = await Promise.resolve().then(() => __importStar(require('clipboardy')));
152
- clipboard.default.writeSync(mermaid);
153
- output.stdout(formatInfo(output, 'mermaid url', result));
155
+ if (output.allowClipboard !== false) {
156
+ try {
157
+ const clipboard = await Promise.resolve().then(() => __importStar(require('clipboardy')));
158
+ clipboard.default.writeSync(mermaid);
159
+ output.stdout(formatInfo(output, 'mermaid url', result));
160
+ }
161
+ catch { /* do nothing this is a service thing */ }
154
162
  }
155
- catch { /* do nothing this is a service thing */ }
156
163
  }
157
164
  };
158
165
  //# sourceMappingURL=repl-dataflow.js.map
@@ -11,6 +11,12 @@ export interface ReplOutput {
11
11
  formatter: OutputFormatter;
12
12
  stdout(msg: string): void;
13
13
  stderr(msg: string): void;
14
+ /**
15
+ * When `false`, REPL commands must skip clipboard operations and must not emit
16
+ * "Copied to clipboard" messages. Defaults to `true` (clipboard allowed).
17
+ * Set to `false` in non-interactive contexts such as wiki generation or tests.
18
+ */
19
+ allowClipboard?: boolean;
14
20
  }
15
21
  /**
16
22
  * Default repl output that redirects everything to the stdout and stderror channels (linked to `console`).
@@ -34,7 +34,6 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.normalizeHashCommand = exports.normalizeStarCommand = exports.normalizeCommand = void 0;
37
- const retriever_1 = require("../../../r-bridge/retriever");
38
37
  const ast_1 = require("../../../util/mermaid/ast");
39
38
  const ansi_1 = require("../../../util/text/ansi");
40
39
  const core_1 = require("../core");
@@ -44,7 +43,7 @@ function formatInfo(out, type, meta) {
44
43
  return out.formatter.format(`Copied ${type} to clipboard (normalize: ${meta['.meta'].timing + 'ms'}).`, { color: 7 /* Colors.White */, effect: ansi_1.ColorEffect.Foreground, style: 3 /* FontStyles.Italic */ });
45
44
  }
46
45
  exports.normalizeCommand = {
47
- description: `Get mermaid code for the normalized AST of R code, start with '${retriever_1.fileProtocol}' to indicate a file`,
46
+ description: 'Get mermaid code for the normalized AST of R code',
48
47
  isCodeCommand: true,
49
48
  usageExample: ':normalize',
50
49
  aliases: ['n'],
@@ -54,12 +53,14 @@ exports.normalizeCommand = {
54
53
  const result = await analyzer.normalize();
55
54
  const mermaid = (0, ast_1.normalizedAstToMermaid)(result.ast);
56
55
  output.stdout(mermaid);
57
- try {
58
- const clipboard = await Promise.resolve().then(() => __importStar(require('clipboardy')));
59
- clipboard.default.writeSync(mermaid);
60
- output.stdout(formatInfo(output, 'mermaid url', result));
56
+ if (output.allowClipboard !== false) {
57
+ try {
58
+ const clipboard = await Promise.resolve().then(() => __importStar(require('clipboardy')));
59
+ clipboard.default.writeSync(mermaid);
60
+ output.stdout(formatInfo(output, 'mermaid url', result));
61
+ }
62
+ catch { /* do nothing this is a service thing */ }
61
63
  }
62
- catch { /* do nothing this is a service thing */ }
63
64
  }
64
65
  };
65
66
  exports.normalizeStarCommand = {
@@ -73,12 +74,14 @@ exports.normalizeStarCommand = {
73
74
  const result = await analyzer.normalize();
74
75
  const mermaid = (0, ast_1.normalizedAstToMermaidUrl)(result.ast);
75
76
  output.stdout(mermaid);
76
- try {
77
- const clipboard = await Promise.resolve().then(() => __importStar(require('clipboardy')));
78
- clipboard.default.writeSync(mermaid);
79
- output.stdout(formatInfo(output, 'mermaid url', result));
77
+ if (output.allowClipboard !== false) {
78
+ try {
79
+ const clipboard = await Promise.resolve().then(() => __importStar(require('clipboardy')));
80
+ clipboard.default.writeSync(mermaid);
81
+ output.stdout(formatInfo(output, 'mermaid url', result));
82
+ }
83
+ catch { /* do nothing this is a service thing */ }
80
84
  }
81
- catch { /* do nothing this is a service thing */ }
82
85
  }
83
86
  };
84
87
  exports.normalizeHashCommand = {
@@ -126,7 +126,7 @@ function depthListToTextTree(list, f) {
126
126
  return result;
127
127
  }
128
128
  exports.parseCommand = {
129
- description: `Prints ASCII Art of the parsed, unmodified AST, start with '${retriever_1.fileProtocol}' to indicate a file`,
129
+ description: 'Prints ASCII Art of the parsed, unmodified AST',
130
130
  isCodeCommand: true,
131
131
  usageExample: ':parse',
132
132
  aliases: ['p'],
@@ -3,15 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.queryStarCommand = exports.queryCommand = void 0;
4
4
  const ansi_1 = require("../../../util/text/ansi");
5
5
  const query_1 = require("../../../queries/query");
6
- const retriever_1 = require("../../../r-bridge/retriever");
7
6
  const query_print_1 = require("../../../queries/query-print");
8
7
  const json_1 = require("../../../util/json");
9
8
  const args_1 = require("../../../util/text/args");
9
+ const record_1 = require("../../../util/record");
10
10
  function printHelp(output) {
11
11
  output.stderr(`Format: ${(0, ansi_1.italic)(':query <query> <code>', output.formatter)}`);
12
12
  output.stdout('Queries starting with \'@<type>\' are interpreted as a query of the given type.');
13
13
  output.stdout(`With this, ${(0, ansi_1.bold)(':query @config', output.formatter)} prints the result of the config query.`);
14
- output.stdout(`If you want to run the linter on a project use:\n ${(0, ansi_1.bold)(':query @linter file://<path>', output.formatter)}.`);
14
+ output.stdout(`If you want to run the linter on a project use:\n ${(0, ansi_1.bold)(':query @linter file://<path>', output.formatter)} (or ${(0, ansi_1.bold)('watch://<path>', output.formatter)} to re-run on changes).`);
15
15
  output.stdout((0, ansi_1.ansiInfo)('Otherwise, you can also directly pass the query json. Then, the query is an array of query objects to represent multiple queries.'));
16
16
  output.stdout((0, ansi_1.ansiInfo)('The example') + (0, ansi_1.italic)(String.raw `:query "[{\"type\": \"call-context\", \"callName\": \"mean\" }]" mean(1:10)`, output.formatter, { color: 7 /* Colors.White */, effect: ansi_1.ColorEffect.Foreground }) + (0, ansi_1.ansiInfo)('would return the call context of the mean function.'));
17
17
  output.stdout('Please have a look at the wiki for more info: https://github.com/flowr-analysis/flowr/wiki/Query-API');
@@ -98,7 +98,7 @@ function parseArgs(line) {
98
98
  };
99
99
  }
100
100
  exports.queryCommand = {
101
- description: `Query the given R code, start with '${retriever_1.fileProtocol}' to indicate a file. The query is to be a valid query in json format (use 'help' to get more information).`,
101
+ description: 'Query the given R code (use \'help\' for more information)',
102
102
  isCodeCommand: true,
103
103
  usageExample: ':query "<query>" <code>',
104
104
  aliases: [],
@@ -123,8 +123,7 @@ exports.queryStarCommand = {
123
123
  fn: async ({ output, analyzer, remainingArgs }) => {
124
124
  const results = await processQueryArgs(output, analyzer, remainingArgs);
125
125
  if (results) {
126
- const json = Object.fromEntries(Object.entries(results.query)
127
- .map(([query, queryResults]) => [query, query_1.SupportedQueries[query]?.jsonFormatter?.(queryResults) ?? queryResults]));
126
+ const json = record_1.Record.map(results.query, ([query, queryResults]) => [query, query_1.SupportedQueries[query]?.jsonFormatter?.(queryResults) ?? queryResults]);
128
127
  output.stdout(JSON.stringify(json, json_1.jsonReplacer));
129
128
  }
130
129
  }
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.quitCommand = void 0;
4
4
  const log_1 = require("../../../util/log");
5
+ const proc_1 = require("../../../util/proc");
5
6
  exports.quitCommand = {
6
7
  description: 'End the repl',
7
8
  isCodeCommand: false,
@@ -10,7 +11,7 @@ exports.quitCommand = {
10
11
  script: false,
11
12
  fn: () => {
12
13
  log_1.log.info('bye');
13
- process.exit(0);
14
+ (0, proc_1.exitSafe)(0);
14
15
  }
15
16
  };
16
17
  //# sourceMappingURL=repl-quit.js.map
@@ -1,4 +1,5 @@
1
1
  import * as readline from 'readline';
2
+ import fs from 'fs';
2
3
  import { type ReplOutput } from './commands/repl-main';
3
4
  import type { MergeableRecord } from '../../util/objects';
4
5
  import type { FlowrConfig } from '../../config';
@@ -30,6 +31,16 @@ export declare function handleString(code: string): {
30
31
  rCode: string | undefined;
31
32
  remaining: never[];
32
33
  };
34
+ /** Path prefix that activates watch mode; use instead of {@link fileProtocol} to re-run on every file change. */
35
+ export declare const watchProtocol = "watch://";
36
+ /** Convert a statement containing {@link watchProtocol} into one using {@link fileProtocol} so it can be executed. */
37
+ export declare function toFileStatement(statement: string): string;
38
+ /** Return the watch path from the first `watch://<path>` token in `statement`, or `undefined` if none is present. */
39
+ export declare function extractWatchPath(statement: string): string | undefined;
40
+ /** Stop the active watcher. Pass `notify = false` when silently switching to a new watch target. */
41
+ export declare function stopWatching(output: ReplOutput, notify?: boolean): void;
42
+ /** `watchImpl` is injectable so tests can pass a fake `fs.watch`. */
43
+ export declare function startWatching(watchPath: string, output: ReplOutput, onFire: () => void, watchImpl?: typeof fs.watch): fs.FSWatcher;
33
44
  /**
34
45
  * This function interprets the given `expr` as a REPL command (see {@link repl} for more on the semantics).
35
46
  * @param analyzer - The flowR analyzer to use.
package/cli/repl/core.js CHANGED
@@ -36,9 +36,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
36
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.watchProtocol = void 0;
39
40
  exports.replCompleter = replCompleter;
40
41
  exports.makeDefaultReplReadline = makeDefaultReplReadline;
41
42
  exports.handleString = handleString;
43
+ exports.toFileStatement = toFileStatement;
44
+ exports.extractWatchPath = extractWatchPath;
45
+ exports.stopWatching = stopWatching;
46
+ exports.startWatching = startWatching;
42
47
  exports.replProcessAnswer = replProcessAnswer;
43
48
  exports.repl = repl;
44
49
  exports.loadReplHistory = loadReplHistory;
@@ -62,6 +67,7 @@ const log_1 = require("../../util/log");
62
67
  const query_1 = require("../../queries/query");
63
68
  const strings_1 = require("../../util/text/strings");
64
69
  const instrument_dataflow_count_1 = require("../../dataflow/instrument/instrument-dataflow-count");
70
+ const proc_1 = require("../../util/proc");
65
71
  let _replCompleterKeywords = undefined;
66
72
  function replCompleterKeywords() {
67
73
  if (_replCompleterKeywords === undefined) {
@@ -98,8 +104,8 @@ function replCompleter(line, config) {
98
104
  completions = completions.concat(queryCompletions);
99
105
  }
100
106
  else {
101
- // autocomplete command arguments (specifically, autocomplete the file:// protocol)
102
107
  completions.push(retriever_1.fileProtocol);
108
+ completions.push(exports.watchProtocol);
103
109
  }
104
110
  return [completions.filter(a => a.startsWith(currentArg)), currentArg];
105
111
  }
@@ -145,7 +151,46 @@ function handleString(code) {
145
151
  remaining: []
146
152
  };
147
153
  }
148
- async function replProcessStatement(output, statement, analyzer, allowRSessionAccess) {
154
+ /** Path prefix that activates watch mode; use instead of {@link fileProtocol} to re-run on every file change. */
155
+ exports.watchProtocol = 'watch://';
156
+ /** Convert a statement containing {@link watchProtocol} into one using {@link fileProtocol} so it can be executed. */
157
+ function toFileStatement(statement) {
158
+ return statement.replaceAll(exports.watchProtocol, retriever_1.fileProtocol);
159
+ }
160
+ /** Return the watch path from the first `watch://<path>` token in `statement`, or `undefined` if none is present. */
161
+ function extractWatchPath(statement) {
162
+ return /watch:\/\/(\S+)/.exec(statement)?.[1];
163
+ }
164
+ let activeWatcher;
165
+ /** Stop the active watcher. Pass `notify = false` when silently switching to a new watch target. */
166
+ function stopWatching(output, notify = true) {
167
+ if (activeWatcher !== undefined) {
168
+ try {
169
+ activeWatcher.close();
170
+ }
171
+ catch { /* already closed */ }
172
+ activeWatcher = undefined;
173
+ if (notify) {
174
+ output.stdout('Watch mode stopped.');
175
+ }
176
+ }
177
+ }
178
+ /** `watchImpl` is injectable so tests can pass a fake `fs.watch`. */
179
+ function startWatching(watchPath, output, onFire, watchImpl = fs_1.default.watch) {
180
+ const faint = (s) => output.formatter.format(s, { style: 2 /* FontStyles.Faint */ });
181
+ const isDir = fs_1.default.existsSync(watchPath) && fs_1.default.statSync(watchPath).isDirectory();
182
+ let debounce;
183
+ const watcher = watchImpl(watchPath, { recursive: isDir }, () => {
184
+ clearTimeout(debounce);
185
+ debounce = setTimeout(() => {
186
+ output.stdout(faint(`\nChange detected in '${watchPath}', re-running...`));
187
+ onFire();
188
+ }, 50);
189
+ });
190
+ output.stdout(faint(`Watching ${isDir ? 'folder' : 'file'} '${watchPath}'. Press Ctrl+C or enter another command to stop.`));
191
+ return watcher;
192
+ }
193
+ async function executeStatement(output, statement, analyzer, allowRSessionAccess) {
149
194
  const time = Date.now();
150
195
  const heatMap = new Map();
151
196
  if (analyzer.inspectContext().config.repl.dfProcessorHeat) {
@@ -224,6 +269,31 @@ async function replProcessStatement(output, statement, analyzer, allowRSessionAc
224
269
  }
225
270
  }
226
271
  }
272
+ async function replProcessStatement(output, statement, analyzer, allowRSessionAccess) {
273
+ stopWatching(output, !statement.includes(exports.watchProtocol));
274
+ if (statement.includes(exports.watchProtocol)) {
275
+ const watchPath = extractWatchPath(statement);
276
+ const effective = toFileStatement(statement);
277
+ await executeStatement(output, effective, analyzer, allowRSessionAccess);
278
+ if (watchPath) {
279
+ try {
280
+ activeWatcher = startWatching(watchPath, output, () => {
281
+ void executeStatement(output, effective, analyzer, allowRSessionAccess);
282
+ });
283
+ activeWatcher.unref();
284
+ activeWatcher.on('error', (err) => {
285
+ output.stderr(`Watch error for '${watchPath}': ${err.message}`);
286
+ stopWatching(output, false);
287
+ });
288
+ }
289
+ catch (e) {
290
+ output.stderr(`Cannot watch '${watchPath}': ${e.message}`);
291
+ }
292
+ }
293
+ return;
294
+ }
295
+ await executeStatement(output, statement, analyzer, allowRSessionAccess);
296
+ }
227
297
  /**
228
298
  * This function interprets the given `expr` as a REPL command (see {@link repl} for more on the semantics).
229
299
  * @param analyzer - The flowR analyzer to use.
@@ -251,11 +321,39 @@ async function repl({ analyzer, rl = readline.createInterface(makeDefaultReplRea
251
321
  if (historyFile) {
252
322
  rl.on('history', h => fs_1.default.writeFileSync(historyFile, h.join('\n'), { encoding: 'utf-8' }));
253
323
  }
324
+ let sigintCount = 0;
325
+ rl.on('SIGINT', () => {
326
+ process.stdout.write('\n');
327
+ if (activeWatcher !== undefined) {
328
+ stopWatching(output);
329
+ rl.setPrompt((0, prompt_1.prompt)());
330
+ sigintCount = 0;
331
+ }
332
+ else {
333
+ sigintCount++;
334
+ if (sigintCount >= 2) {
335
+ stopWatching(output, false);
336
+ (0, proc_1.exitSafe)(0);
337
+ }
338
+ else {
339
+ output.stdout('(Press Ctrl+C again or type :quit to exit)');
340
+ setTimeout(() => {
341
+ sigintCount = 0;
342
+ }, 2000).unref();
343
+ }
344
+ }
345
+ rl.prompt();
346
+ });
347
+ rl.on('close', () => {
348
+ stopWatching(output, false);
349
+ (0, proc_1.exitSafe)(0);
350
+ });
254
351
  // the incredible repl :D, we kill it with ':quit'
255
352
  // noinspection InfiniteLoopJS
256
353
  while (true) {
257
354
  await new Promise((resolve, reject) => {
258
- rl.question((0, prompt_1.prompt)(), answer => {
355
+ rl.question(activeWatcher !== undefined ? '' : (0, prompt_1.prompt)(), answer => {
356
+ sigintCount = 0;
259
357
  rl.pause();
260
358
  replProcessAnswer(analyzer, output, answer, allowRSessionAccess).then(() => {
261
359
  rl.resume();
@@ -9,6 +9,7 @@ const child_process_1 = __importDefault(require("child_process"));
9
9
  const readline_1 = __importDefault(require("readline"));
10
10
  const assert_1 = require("../../util/assert");
11
11
  const log_1 = require("../../util/log");
12
+ const proc_1 = require("../../util/proc");
12
13
  /**
13
14
  * Simply captures the output of the script executed by {@link waitOnScript}.
14
15
  * @param stdio - The standard io tuple provided by {@link waitOnScript}
@@ -54,14 +55,14 @@ async function waitOnScript(module, args, io, exitOnError = false) {
54
55
  if (code) {
55
56
  console.error(`Script ${module} exited with code ${String(code)} and signal ${JSON.stringify(signal)}`);
56
57
  if (exitOnError) {
57
- process.exit(code);
58
+ (0, proc_1.exitSafe)(code);
58
59
  }
59
60
  }
60
61
  });
61
62
  child.on('error', err => {
62
63
  console.error(`Script ${module} signaled error ${JSON.stringify(err)}`);
63
64
  if (exitOnError) {
64
- process.exit(1);
65
+ (0, proc_1.exitSafe)(1);
65
66
  }
66
67
  });
67
68
  await new Promise((resolve, reject) => child.on('exit', code => {
@@ -1,5 +1,7 @@
1
1
  import type { SlicingCriterion, SlicingCriteria } from '../../../slicing/criterion/parse';
2
2
  import { SliceDirection } from '../../../util/slice-direction';
3
+ import type { CommandCompletions } from '../core';
4
+ import type { FlowrConfig } from '../../../config';
3
5
  /**
4
6
  * Checks whether the given argument represents a slicing direction with an `f` suffix.
5
7
  */
@@ -12,3 +14,17 @@ export declare function sliceCriterionParser(argument: string | undefined): Slic
12
14
  * Parses multiple slicing criteria from the given argument.
13
15
  */
14
16
  export declare function sliceCriteriaParser(argument: string | undefined): SlicingCriteria | undefined;
17
+ /**
18
+ * Tab-completer for query arguments of the form `(line@var;line@var;...)`.
19
+ * Guides the user step by step: `(` then digits then `@` then variable then `)`.
20
+ */
21
+ export declare function criteriaQueryCompleter(line: readonly string[], startingNewArg: boolean, _config: FlowrConfig): CommandCompletions;
22
+ /**
23
+ * Parses a dice argument of the form `(from1;from2->to1;to2)`.
24
+ * Returns `{ from, to }` on success, or `undefined` if the argument is malformed.
25
+ * Each side is a semicolon-separated list of slicing criteria; a single criterion needs no semicolon.
26
+ */
27
+ export declare function diceCriteriaParser(argument: string | undefined): {
28
+ from: SlicingCriteria;
29
+ to: SlicingCriteria;
30
+ } | undefined;
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.sliceDirectionParser = sliceDirectionParser;
4
4
  exports.sliceCriterionParser = sliceCriterionParser;
5
5
  exports.sliceCriteriaParser = sliceCriteriaParser;
6
+ exports.criteriaQueryCompleter = criteriaQueryCompleter;
7
+ exports.diceCriteriaParser = diceCriteriaParser;
6
8
  const slice_direction_1 = require("../../../util/slice-direction");
7
9
  /**
8
10
  * Checks whether the given argument represents a slicing direction with an `f` suffix.
@@ -31,4 +33,54 @@ function sliceCriteriaParser(argument) {
31
33
  return criteria;
32
34
  }
33
35
  }
36
+ /** Last partial criterion fragment after the most recent `;` or after `(`. */
37
+ function lastCriterionFragment(arg) {
38
+ return arg.slice(Math.max(arg.indexOf('(') + 1, arg.lastIndexOf(';') + 1));
39
+ }
40
+ /**
41
+ * Tab-completer for query arguments of the form `(line@var;line@var;...)`.
42
+ * Guides the user step by step: `(` then digits then `@` then variable then `)`.
43
+ */
44
+ function criteriaQueryCompleter(line, startingNewArg, _config) {
45
+ if (line.length === 0) {
46
+ return { completions: ['('] };
47
+ }
48
+ if (startingNewArg || line.length !== 1) {
49
+ return { completions: [] };
50
+ }
51
+ const arg = line[0];
52
+ if (arg.endsWith(')') || arg.endsWith(')f')) {
53
+ return { completions: [] };
54
+ }
55
+ const fragment = lastCriterionFragment(arg);
56
+ if (/^\d+$/.test(fragment)) {
57
+ return { completions: [`${arg}@`], argumentPart: arg };
58
+ }
59
+ if (/^\d+@\w+$/.test(fragment)) {
60
+ return { completions: [`${arg})`], argumentPart: arg };
61
+ }
62
+ return { completions: [] };
63
+ }
64
+ /**
65
+ * Parses a dice argument of the form `(from1;from2->to1;to2)`.
66
+ * Returns `{ from, to }` on success, or `undefined` if the argument is malformed.
67
+ * Each side is a semicolon-separated list of slicing criteria; a single criterion needs no semicolon.
68
+ */
69
+ function diceCriteriaParser(argument) {
70
+ if (!argument?.startsWith('(') || !argument.includes(')')) {
71
+ return undefined;
72
+ }
73
+ const endBracket = argument.indexOf(')');
74
+ const inner = argument.slice(1, endBracket);
75
+ const arrowIdx = inner.indexOf('->');
76
+ if (arrowIdx < 0) {
77
+ return undefined;
78
+ }
79
+ const from = inner.slice(0, arrowIdx).split(';').filter(s => s.length > 0);
80
+ const to = inner.slice(arrowIdx + 2).split(';').filter(s => s.length > 0);
81
+ if (from.length === 0 || to.length === 0) {
82
+ return undefined;
83
+ }
84
+ return { from, to };
85
+ }
34
86
  //# sourceMappingURL=slice-query-parser.js.map
@@ -1,6 +1,8 @@
1
1
  import type { KnownParser } from '../../r-bridge/parser';
2
+ /** a short `, package database: <scope> <date>` suffix for the bundled database, or empty if none */
3
+ export declare function pkgDbReplSuffix(): string;
2
4
  /**
3
- * Returns a version string for the REPL including flowR and R version.
5
+ * Returns a version string for the REPL including flowR, R, and the package database in use.
4
6
  */
5
7
  export declare function versionReplString(parser: KnownParser): Promise<string>;
6
8
  /**
@@ -1,16 +1,35 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pkgDbReplSuffix = pkgDbReplSuffix;
3
4
  exports.versionReplString = versionReplString;
4
5
  exports.printVersionRepl = printVersionRepl;
5
6
  const version_1 = require("../../util/version");
7
+ const pkgdb_1 = require("../../project/plugins/package-version-plugins/pkgdb");
8
+ /** a short `, package database: <scope> <date>` suffix for the bundled database, or empty if none */
9
+ function pkgDbReplSuffix() {
10
+ try {
11
+ if (typeof process !== 'undefined' && process.env?.FLOWR_DISABLE_DEFAULT_PKGDB) {
12
+ return '';
13
+ }
14
+ const path = (0, pkgdb_1.defaultPkgDbPath)();
15
+ if (path === undefined) {
16
+ return '';
17
+ }
18
+ const db = pkgdb_1.PkgDatabase.fromFileSync(path);
19
+ return `, pkg-db: ${db.scope}/${db.content.date}`;
20
+ }
21
+ catch {
22
+ return '';
23
+ }
24
+ }
6
25
  /**
7
- * Returns a version string for the REPL including flowR and R version.
26
+ * Returns a version string for the REPL including flowR, R, and the package database in use.
8
27
  */
9
28
  async function versionReplString(parser) {
10
29
  const version = await (0, version_1.retrieveVersionInformation)(parser);
11
30
  const rVersion = version.r === 'none' ? '' : version.r === 'unknown' ? ', R version unknown' : `, R v${version.r}`;
12
31
  const treeSitterVer = parser.name === 'tree-sitter' ? `, R grammar v${parser.treeSitterVersion()}` : '';
13
- return `flowR repl using flowR v${version.flowr}${rVersion}${treeSitterVer} (${version.engine} engine)`;
32
+ return `flowR repl v${version.flowr}${rVersion}${treeSitterVer} (${version.engine} engine${pkgDbReplSuffix()})`;
14
33
  }
15
34
  /**
16
35
  * Prints the version information for the REPL including flowR and R version.
@@ -21,8 +21,11 @@ export declare class FlowRServerConnection {
21
21
  private readonly fileMap;
22
22
  constructor(socket: Socket, name: string, parser: KnownParser, allowRSessionAccess: boolean, config: FlowrConfig);
23
23
  private currentMessageBuffer;
24
+ private requestQueue;
24
25
  private handleData;
26
+ private dispatch;
25
27
  private handleFileAnalysisRequest;
28
+ private invalidateTokens;
26
29
  private sendFileAnalysisResponse;
27
30
  private createAnalyzerForRequest;
28
31
  private handleSliceRequest;