@eagleoutice/flowr 2.5.0 → 2.6.1

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 (254) hide show
  1. package/README.md +46 -35
  2. package/abstract-interpretation/data-frame/absint-visitor.d.ts +1 -1
  3. package/abstract-interpretation/data-frame/absint-visitor.js +1 -1
  4. package/cli/flowr.js +11 -33
  5. package/cli/repl/commands/repl-cfg.d.ts +5 -5
  6. package/cli/repl/commands/repl-cfg.js +21 -22
  7. package/cli/repl/commands/repl-commands.d.ts +3 -3
  8. package/cli/repl/commands/repl-commands.js +2 -0
  9. package/cli/repl/commands/repl-dataflow.d.ts +5 -5
  10. package/cli/repl/commands/repl-dataflow.js +27 -30
  11. package/cli/repl/commands/repl-execute.d.ts +1 -1
  12. package/cli/repl/commands/repl-execute.js +8 -7
  13. package/cli/repl/commands/repl-lineage.d.ts +2 -2
  14. package/cli/repl/commands/repl-lineage.js +11 -11
  15. package/cli/repl/commands/repl-main.d.ts +35 -7
  16. package/cli/repl/commands/repl-normalize.d.ts +3 -3
  17. package/cli/repl/commands/repl-normalize.js +15 -19
  18. package/cli/repl/commands/repl-parse.d.ts +2 -2
  19. package/cli/repl/commands/repl-parse.js +14 -8
  20. package/cli/repl/commands/repl-query.d.ts +3 -3
  21. package/cli/repl/commands/repl-query.js +29 -19
  22. package/cli/repl/commands/repl-quit.js +1 -0
  23. package/cli/repl/commands/repl-version.d.ts +1 -16
  24. package/cli/repl/commands/repl-version.js +2 -18
  25. package/cli/repl/core.d.ts +12 -9
  26. package/cli/repl/core.js +26 -12
  27. package/cli/repl/print-version.js +2 -2
  28. package/cli/repl/server/connection.d.ts +7 -3
  29. package/cli/repl/server/connection.js +46 -50
  30. package/cli/repl/server/messages/message-hello.d.ts +1 -1
  31. package/cli/repl/server/messages/message-slice.d.ts +1 -1
  32. package/cli/repl/server/server.js +2 -2
  33. package/cli/slicer-app.js +1 -1
  34. package/config.d.ts +1 -1
  35. package/config.js +4 -1
  36. package/control-flow/extract-cfg.d.ts +1 -1
  37. package/control-flow/extract-cfg.js +1 -1
  38. package/core/pipeline-executor.d.ts +5 -0
  39. package/core/pipeline-executor.js +5 -0
  40. package/core/steps/all/core/20-dataflow.d.ts +3 -1
  41. package/core/steps/pipeline/create-pipeline.js +1 -1
  42. package/core/steps/pipeline/default-pipelines.d.ts +24 -8
  43. package/core/steps/pipeline/default-pipelines.js +4 -1
  44. package/dataflow/environments/default-builtin-config.js +8 -0
  45. package/dataflow/eval/resolve/alias-tracking.js +2 -0
  46. package/dataflow/eval/resolve/resolve.js +3 -0
  47. package/dataflow/eval/values/r-value.d.ts +4 -1
  48. package/dataflow/eval/values/r-value.js +2 -0
  49. package/dataflow/extractor.d.ts +4 -1
  50. package/dataflow/extractor.js +7 -5
  51. package/dataflow/fn/higher-order-function.d.ts +9 -0
  52. package/dataflow/fn/higher-order-function.js +75 -0
  53. package/dataflow/graph/dataflowgraph-builder.d.ts +11 -12
  54. package/dataflow/graph/dataflowgraph-builder.js +6 -6
  55. package/documentation/doc-util/doc-query.d.ts +3 -6
  56. package/documentation/doc-util/doc-query.js +5 -17
  57. package/documentation/doc-util/doc-repl.js +5 -2
  58. package/documentation/doc-util/doc-search.js +7 -10
  59. package/documentation/doc-util/doc-structure.d.ts +4 -0
  60. package/documentation/doc-util/doc-structure.js +28 -0
  61. package/documentation/doc-util/doc-types.d.ts +5 -1
  62. package/documentation/doc-util/doc-types.js +29 -3
  63. package/documentation/print-analyzer-wiki.d.ts +1 -0
  64. package/documentation/print-analyzer-wiki.js +137 -0
  65. package/documentation/print-core-wiki.d.ts +2 -1
  66. package/documentation/print-core-wiki.js +58 -4
  67. package/documentation/print-dataflow-graph-wiki.js +16 -23
  68. package/documentation/print-interface-wiki.js +18 -1
  69. package/documentation/print-linter-wiki.js +5 -1
  70. package/documentation/print-normalized-ast-wiki.js +6 -8
  71. package/documentation/print-query-wiki.js +20 -0
  72. package/documentation/print-readme.js +1 -1
  73. package/engines.d.ts +9 -0
  74. package/engines.js +38 -0
  75. package/linter/linter-executor.d.ts +2 -8
  76. package/linter/linter-executor.js +9 -4
  77. package/linter/linter-format.d.ts +8 -9
  78. package/linter/linter-rules.d.ts +57 -15
  79. package/linter/linter-rules.js +2 -0
  80. package/linter/rules/absolute-path.d.ts +1 -0
  81. package/linter/rules/dataframe-access-validation.d.ts +4 -3
  82. package/linter/rules/dataframe-access-validation.js +7 -4
  83. package/linter/rules/dead-code.d.ts +2 -1
  84. package/linter/rules/deprecated-functions.d.ts +15 -28
  85. package/linter/rules/deprecated-functions.js +5 -43
  86. package/linter/rules/file-path-validity.d.ts +2 -1
  87. package/linter/rules/file-path-validity.js +1 -1
  88. package/linter/rules/function-finder-util.d.ts +51 -0
  89. package/linter/rules/function-finder-util.js +77 -0
  90. package/linter/rules/naming-convention.d.ts +2 -1
  91. package/linter/rules/network-functions.d.ts +40 -0
  92. package/linter/rules/network-functions.js +24 -0
  93. package/linter/rules/seeded-randomness.d.ts +2 -1
  94. package/linter/rules/unused-definition.d.ts +2 -1
  95. package/linter/rules/useless-loop.d.ts +3 -2
  96. package/linter/rules/useless-loop.js +4 -6
  97. package/package.json +2 -1
  98. package/project/cache/flowr-analyzer-cache.d.ts +94 -0
  99. package/project/cache/flowr-analyzer-cache.js +164 -0
  100. package/project/cache/flowr-cache.d.ts +28 -0
  101. package/project/cache/flowr-cache.js +49 -0
  102. package/project/cfg-kind.d.ts +17 -0
  103. package/project/cfg-kind.js +22 -0
  104. package/project/context/abstract-flowr-analyzer-context.d.ts +39 -0
  105. package/project/context/abstract-flowr-analyzer-context.js +46 -0
  106. package/project/context/flowr-analyzer-context.d.ts +54 -0
  107. package/project/context/flowr-analyzer-context.js +58 -0
  108. package/project/context/flowr-analyzer-dependencies-context.d.ts +39 -0
  109. package/project/context/flowr-analyzer-dependencies-context.js +43 -0
  110. package/project/context/flowr-analyzer-files-context.d.ts +87 -0
  111. package/project/context/flowr-analyzer-files-context.js +134 -0
  112. package/project/context/flowr-analyzer-loading-order-context.d.ts +77 -0
  113. package/project/context/flowr-analyzer-loading-order-context.js +96 -0
  114. package/project/context/flowr-file.d.ts +89 -0
  115. package/project/context/flowr-file.js +78 -0
  116. package/project/flowr-analyzer-builder.d.ts +106 -0
  117. package/project/flowr-analyzer-builder.js +197 -0
  118. package/project/flowr-analyzer.d.ts +126 -0
  119. package/project/flowr-analyzer.js +88 -0
  120. package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.d.ts +17 -0
  121. package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.js +28 -0
  122. package/project/plugins/file-plugins/flowr-analyzer-file-plugin.d.ts +21 -0
  123. package/project/plugins/file-plugins/flowr-analyzer-file-plugin.js +34 -0
  124. package/project/plugins/file-plugins/flowr-description-file.d.ts +24 -0
  125. package/project/plugins/file-plugins/flowr-description-file.js +38 -0
  126. package/project/plugins/flowr-analyzer-plugin.d.ts +90 -0
  127. package/project/plugins/flowr-analyzer-plugin.js +82 -0
  128. package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-description-file-plugin.d.ts +14 -0
  129. package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-description-file-plugin.js +56 -0
  130. package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-plugin.d.ts +13 -0
  131. package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-plugin.js +33 -0
  132. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.d.ts +14 -0
  133. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.js +41 -0
  134. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.d.ts +10 -0
  135. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.js +29 -0
  136. package/project/plugins/package-version-plugins/package.d.ts +15 -0
  137. package/project/plugins/package-version-plugins/package.js +56 -0
  138. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.d.ts +15 -0
  139. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +44 -0
  140. package/queries/base-query-format.d.ts +2 -8
  141. package/queries/catalog/call-context-query/call-context-query-executor.d.ts +1 -1
  142. package/queries/catalog/call-context-query/call-context-query-executor.js +21 -13
  143. package/queries/catalog/call-context-query/call-context-query-format.d.ts +2 -3
  144. package/queries/catalog/call-context-query/call-context-query-format.js +2 -2
  145. package/queries/catalog/cluster-query/cluster-query-executor.d.ts +1 -1
  146. package/queries/catalog/cluster-query/cluster-query-executor.js +2 -2
  147. package/queries/catalog/cluster-query/cluster-query-format.d.ts +1 -54
  148. package/queries/catalog/cluster-query/cluster-query-format.js +2 -2
  149. package/queries/catalog/config-query/config-query-executor.d.ts +1 -1
  150. package/queries/catalog/config-query/config-query-executor.js +5 -5
  151. package/queries/catalog/config-query/config-query-format.d.ts +1 -1
  152. package/queries/catalog/config-query/config-query-format.js +1 -1
  153. package/queries/catalog/control-flow-query/control-flow-query-executor.d.ts +1 -1
  154. package/queries/catalog/control-flow-query/control-flow-query-executor.js +3 -3
  155. package/queries/catalog/control-flow-query/control-flow-query-format.d.ts +1 -54
  156. package/queries/catalog/control-flow-query/control-flow-query-format.js +2 -2
  157. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.d.ts +1 -1
  158. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.js +2 -2
  159. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.d.ts +1 -54
  160. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.js +1 -1
  161. package/queries/catalog/dataflow-query/dataflow-query-executor.d.ts +1 -1
  162. package/queries/catalog/dataflow-query/dataflow-query-executor.js +2 -2
  163. package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +1 -54
  164. package/queries/catalog/dataflow-query/dataflow-query-format.js +1 -1
  165. package/queries/catalog/dependencies-query/dependencies-query-executor.d.ts +1 -1
  166. package/queries/catalog/dependencies-query/dependencies-query-executor.js +19 -12
  167. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +7 -56
  168. package/queries/catalog/dependencies-query/dependencies-query-format.js +7 -4
  169. package/queries/catalog/df-shape-query/df-shape-query-executor.d.ts +1 -1
  170. package/queries/catalog/df-shape-query/df-shape-query-executor.js +4 -4
  171. package/queries/catalog/df-shape-query/df-shape-query-format.d.ts +1 -54
  172. package/queries/catalog/df-shape-query/df-shape-query-format.js +1 -1
  173. package/queries/catalog/happens-before-query/happens-before-query-executor.d.ts +1 -1
  174. package/queries/catalog/happens-before-query/happens-before-query-executor.js +2 -1
  175. package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +1 -54
  176. package/queries/catalog/happens-before-query/happens-before-query-format.js +1 -1
  177. package/queries/catalog/id-map-query/id-map-query-executor.d.ts +1 -1
  178. package/queries/catalog/id-map-query/id-map-query-executor.js +2 -2
  179. package/queries/catalog/id-map-query/id-map-query-format.d.ts +1 -54
  180. package/queries/catalog/id-map-query/id-map-query-format.js +2 -2
  181. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.d.ts +3 -0
  182. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +45 -0
  183. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +22 -0
  184. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +32 -0
  185. package/queries/catalog/lineage-query/lineage-query-executor.d.ts +1 -1
  186. package/queries/catalog/lineage-query/lineage-query-executor.js +2 -2
  187. package/queries/catalog/lineage-query/lineage-query-format.d.ts +1 -54
  188. package/queries/catalog/lineage-query/lineage-query-format.js +1 -1
  189. package/queries/catalog/linter-query/linter-query-executor.d.ts +1 -1
  190. package/queries/catalog/linter-query/linter-query-executor.js +2 -3
  191. package/queries/catalog/linter-query/linter-query-format.d.ts +1 -54
  192. package/queries/catalog/linter-query/linter-query-format.js +1 -1
  193. package/queries/catalog/location-map-query/location-map-query-executor.d.ts +1 -1
  194. package/queries/catalog/location-map-query/location-map-query-executor.js +3 -2
  195. package/queries/catalog/location-map-query/location-map-query-format.d.ts +1 -1
  196. package/queries/catalog/location-map-query/location-map-query-format.js +1 -1
  197. package/queries/catalog/normalized-ast-query/normalized-ast-query-executor.d.ts +1 -1
  198. package/queries/catalog/normalized-ast-query/normalized-ast-query-executor.js +2 -2
  199. package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +1 -54
  200. package/queries/catalog/normalized-ast-query/normalized-ast-query-format.js +1 -1
  201. package/queries/catalog/origin-query/origin-query-executor.d.ts +2 -2
  202. package/queries/catalog/origin-query/origin-query-executor.js +3 -3
  203. package/queries/catalog/origin-query/origin-query-format.d.ts +1 -54
  204. package/queries/catalog/origin-query/origin-query-format.js +1 -1
  205. package/queries/catalog/project-query/project-query-executor.d.ts +1 -1
  206. package/queries/catalog/project-query/project-query-executor.js +2 -2
  207. package/queries/catalog/project-query/project-query-format.d.ts +1 -54
  208. package/queries/catalog/project-query/project-query-format.js +1 -1
  209. package/queries/catalog/resolve-value-query/resolve-value-query-executor.d.ts +1 -1
  210. package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +4 -2
  211. package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +1 -54
  212. package/queries/catalog/resolve-value-query/resolve-value-query-format.js +1 -1
  213. package/queries/catalog/search-query/search-query-executor.d.ts +1 -1
  214. package/queries/catalog/search-query/search-query-executor.js +3 -3
  215. package/queries/catalog/search-query/search-query-format.d.ts +1 -54
  216. package/queries/catalog/search-query/search-query-format.js +1 -1
  217. package/queries/catalog/static-slice-query/static-slice-query-executor.d.ts +1 -1
  218. package/queries/catalog/static-slice-query/static-slice-query-executor.js +3 -3
  219. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +1 -54
  220. package/queries/catalog/static-slice-query/static-slice-query-format.js +1 -1
  221. package/queries/query-print.d.ts +4 -4
  222. package/queries/query-print.js +12 -12
  223. package/queries/query.d.ts +37 -885
  224. package/queries/query.js +3 -1
  225. package/r-bridge/parser.d.ts +7 -0
  226. package/r-bridge/retriever.d.ts +6 -5
  227. package/r-bridge/retriever.js +9 -5
  228. package/search/flowr-search-executor.d.ts +3 -5
  229. package/search/flowr-search-executor.js +6 -4
  230. package/search/flowr-search-filters.d.ts +12 -6
  231. package/search/flowr-search-filters.js +1 -1
  232. package/search/flowr-search.d.ts +5 -16
  233. package/search/flowr-search.js +14 -5
  234. package/search/search-executor/search-enrichers.d.ts +37 -36
  235. package/search/search-executor/search-enrichers.js +5 -4
  236. package/search/search-executor/search-generators.d.ts +12 -12
  237. package/search/search-executor/search-generators.js +27 -19
  238. package/search/search-executor/search-mappers.d.ts +5 -5
  239. package/search/search-executor/search-transformer.d.ts +17 -17
  240. package/search/search-executor/search-transformer.js +14 -7
  241. package/util/collections/arrays.d.ts +1 -0
  242. package/util/collections/arrays.js +15 -0
  243. package/util/collections/objectmap.d.ts +17 -0
  244. package/util/collections/objectmap.js +28 -0
  245. package/util/containers.d.ts +0 -1
  246. package/util/containers.js +0 -1
  247. package/util/files.d.ts +17 -0
  248. package/util/files.js +65 -0
  249. package/util/formats/adapter.d.ts +4 -2
  250. package/util/formats/adapter.js +11 -4
  251. package/util/r-value.d.ts +1 -1
  252. package/util/r-value.js +2 -0
  253. package/util/version.d.ts +17 -0
  254. package/util/version.js +28 -1
@@ -3,22 +3,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.executeCommand = void 0;
4
4
  exports.tryExecuteRShellCommand = tryExecuteRShellCommand;
5
5
  const ansi_1 = require("../../../util/text/ansi");
6
- const shell_1 = require("../../../r-bridge/shell");
7
- async function tryExecuteRShellCommand({ output, parser, allowRSessionAccess, remainingLine }) {
6
+ async function tryExecuteRShellCommand({ output, analyzer, allowRSessionAccess, remainingLine }) {
7
+ const parserInfo = await analyzer.parserInformation();
8
8
  if (!allowRSessionAccess) {
9
9
  output.stderr(`${output.formatter.format('You are not allowed to execute arbitrary R code.', { style: 1 /* FontStyles.Bold */, color: 1 /* Colors.Red */, effect: ansi_1.ColorEffect.Foreground })}
10
- If you want to do so, please restart flowR with the ${output.formatter.format('--r-session-access', { style: 1 /* FontStyles.Bold */ })} flag${parser.name !== 'r-shell' ? '. Additionally, please enable the r-shell engine, e.g., with ' + output.formatter.format('--default-engine r-shell', { style: 1 /* FontStyles.Bold */ }) : ''}. Please be careful of the security implications of this action. When running flowR with npm, you have to use an extra ${output.formatter.format('--', { style: 1 /* FontStyles.Bold */ })} to separate flowR from npm arguments.`);
10
+ If you want to do so, please restart flowR with the ${output.formatter.format('--r-session-access', { style: 1 /* FontStyles.Bold */ })} flag${parserInfo.name !== 'r-shell' ? '. Additionally, please enable the r-shell engine, e.g., with ' + output.formatter.format('--default-engine r-shell', { style: 1 /* FontStyles.Bold */ }) : ''}. Please be careful of the security implications of this action. When running flowR with npm, you have to use an extra ${output.formatter.format('--', { style: 1 /* FontStyles.Bold */ })} to separate flowR from npm arguments.`);
11
11
  }
12
- else if (parser instanceof shell_1.RShell) {
13
- await executeRShellCommand(output, parser, remainingLine);
12
+ else if (parserInfo.name === 'r-shell') {
13
+ await executeRShellCommand(output, analyzer, remainingLine);
14
14
  }
15
15
  else {
16
16
  output.stderr(`Executing arbitrary R code is only possible when using the r-shell engine as the default engine. Enable it using the configuration file or the ${output.formatter.format('--default-engine r-shell', { style: 1 /* FontStyles.Bold */ })} command line option. When running flowR with npm, you have to use an extra ${output.formatter.format('--', { style: 1 /* FontStyles.Bold */ })} to separate flowR from npm arguments.`);
17
17
  }
18
18
  }
19
- async function executeRShellCommand(output, shell, statement) {
19
+ async function executeRShellCommand(output, analyzer, statement) {
20
20
  try {
21
- const result = await shell.sendCommandWithOutput(statement, {
21
+ const result = await analyzer.sendCommandWithOutput(statement, {
22
22
  from: 'both',
23
23
  automaticallyTrimOutput: true
24
24
  });
@@ -30,6 +30,7 @@ async function executeRShellCommand(output, shell, statement) {
30
30
  }
31
31
  exports.executeCommand = {
32
32
  description: 'Execute the given code as R code (essentially similar to using now command). This requires the `--r-session-access` flag to be set and requires the r-shell engine.',
33
+ isCodeCommand: false,
33
34
  usageExample: ':execute',
34
35
  aliases: ['e', 'r'],
35
36
  script: false,
@@ -1,4 +1,4 @@
1
- import type { ReplCommand } from './repl-main';
1
+ import type { ReplCodeCommand } from './repl-main';
2
2
  import type { SingleSlicingCriterion } from '../../../slicing/criterion/parse';
3
3
  import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
4
4
  import type { DataflowGraph } from '../../../dataflow/graph/graph';
@@ -12,4 +12,4 @@ import type { AstIdMap } from '../../../r-bridge/lang-4.x/ast/model/processing/d
12
12
  * @returns The lineage of the node represented as a set of node ids
13
13
  */
14
14
  export declare function getLineage(criterion: SingleSlicingCriterion, graph: DataflowGraph, idMap?: AstIdMap): Set<NodeId>;
15
- export declare const lineageCommand: ReplCommand;
15
+ export declare const lineageCommand: ReplCodeCommand;
@@ -2,19 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.lineageCommand = void 0;
4
4
  exports.getLineage = getLineage;
5
- const default_pipelines_1 = require("../../../core/steps/pipeline/default-pipelines");
6
- const retriever_1 = require("../../../r-bridge/retriever");
7
5
  const parse_1 = require("../../../slicing/criterion/parse");
8
6
  const edge_1 = require("../../../dataflow/graph/edge");
9
7
  const assert_1 = require("../../../util/assert");
10
8
  function splitAt(str, idx) {
11
9
  return [str.slice(0, idx), str.slice(idx)];
12
10
  }
13
- async function getDfg(config, parser, remainingLine) {
14
- return await (0, default_pipelines_1.createDataflowPipeline)(parser, {
15
- request: (0, retriever_1.requestFromInput)(remainingLine.trim())
16
- }, config).allRemainingSteps();
17
- }
18
11
  function filterRelevantEdges(edge) {
19
12
  return (0, edge_1.edgeIncludesType)(edge_1.EdgeType.DefinedBy | edge_1.EdgeType.DefinedByOnCall | edge_1.EdgeType.Returns | edge_1.EdgeType.Reads, edge.types);
20
13
  }
@@ -53,13 +46,20 @@ function getLineage(criterion, graph, idMap) {
53
46
  }
54
47
  exports.lineageCommand = {
55
48
  description: 'Get the lineage of an R object',
49
+ isCodeCommand: true,
56
50
  usageExample: ':lineage',
57
51
  aliases: ['lin'],
58
52
  script: false,
59
- fn: async ({ output, parser, remainingLine, config }) => {
60
- const [criterion, rest] = splitAt(remainingLine, remainingLine.indexOf(' '));
61
- const { dataflow: dfg } = await getDfg(config, parser, rest);
62
- const lineageIds = getLineage(criterion, dfg.graph);
53
+ argsParser: (args) => {
54
+ const [criterion, rest] = splitAt(args, args.indexOf(' '));
55
+ const code = rest.trim();
56
+ return {
57
+ input: code.startsWith('"') ? JSON.parse(code) : code,
58
+ remaining: [criterion]
59
+ };
60
+ },
61
+ fn: async ({ output, analyzer, remainingArgs }) => {
62
+ const lineageIds = getLineage(remainingArgs[0], (await analyzer.dataflow()).graph);
63
63
  output.stdout([...lineageIds].join('\n'));
64
64
  }
65
65
  };
@@ -1,6 +1,5 @@
1
1
  import type { OutputFormatter } from '../../../util/text/ansi';
2
- import type { KnownParser } from '../../../r-bridge/parser';
3
- import type { FlowrConfigOptions } from '../../../config';
2
+ import type { FlowrAnalysisProvider } from '../../../project/flowr-analyzer';
4
3
  /**
5
4
  * Defines the main interface for output of the repl.
6
5
  * This allows us to redirect it (e.g., in the case of a server connection or tests).
@@ -20,20 +19,28 @@ export interface ReplOutput {
20
19
  */
21
20
  export declare const standardReplOutput: ReplOutput;
22
21
  /**
23
- * Information passed to each repl command function
22
+ * Information passed to each {@link ReplCommand#fn}.
24
23
  */
25
24
  export interface ReplCommandInformation {
26
25
  output: ReplOutput;
27
- parser: KnownParser;
28
- remainingLine: string;
29
26
  allowRSessionAccess: boolean;
30
- config: FlowrConfigOptions;
27
+ analyzer: FlowrAnalysisProvider;
28
+ remainingLine: string;
29
+ }
30
+ /**
31
+ * Information passed to each {@link ReplCodeCommand#fn}.
32
+ * The {@link analyzer} has the {@link RParseRequest}.
33
+ */
34
+ export interface ReplCodeCommandInformation {
35
+ output: ReplOutput;
36
+ analyzer: FlowrAnalysisProvider;
37
+ remainingArgs: string[];
31
38
  }
32
39
  /**
33
40
  * Content of a single command in the repl.
34
41
  * The command may execute an external script or simply call *flowR* functions.
35
42
  */
36
- export interface ReplCommand {
43
+ export interface ReplBaseCommand {
37
44
  /** Aliases of the command (without the leading colon), every alias must be unique (this is checked at runtime) */
38
45
  aliases: string[];
39
46
  /** A human-readable description of what the command does */
@@ -42,9 +49,30 @@ export interface ReplCommand {
42
49
  script: boolean;
43
50
  /** Example of how to use the command, for example `:slicer --help` */
44
51
  usageExample: string;
52
+ }
53
+ export interface ReplCommand extends ReplBaseCommand {
54
+ isCodeCommand: false;
45
55
  /**
46
56
  * Function to execute when the command is invoked, it must not write to the command line but instead use the output handler.
47
57
  * Furthermore, it has to obey the formatter defined in the {@link ReplOutput}.
48
58
  */
49
59
  fn: (info: ReplCommandInformation) => Promise<void> | void;
50
60
  }
61
+ /**
62
+ * Repl command that uses the {@link FlowrAnalyzer}
63
+ */
64
+ export interface ReplCodeCommand extends ReplBaseCommand {
65
+ isCodeCommand: true;
66
+ /**
67
+ * Function to execute when the command is invoked, it must not write to the command line but instead use the output handler.
68
+ * Furthermore, it has to obey the formatter defined in the {@link ReplOutput}.
69
+ */
70
+ fn: (info: ReplCodeCommandInformation) => Promise<void> | void;
71
+ /**
72
+ * Argument parser function which handles the input given after the repl command
73
+ */
74
+ argsParser: (remainingLine: string) => {
75
+ input: string | undefined;
76
+ remaining: string[];
77
+ };
78
+ }
@@ -1,3 +1,3 @@
1
- import type { ReplCommand } from './repl-main';
2
- export declare const normalizeCommand: ReplCommand;
3
- export declare const normalizeStarCommand: ReplCommand;
1
+ import type { ReplCodeCommand } from './repl-main';
2
+ export declare const normalizeCommand: ReplCodeCommand;
3
+ export declare const normalizeStarCommand: ReplCodeCommand;
@@ -34,51 +34,47 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.normalizeStarCommand = exports.normalizeCommand = void 0;
37
- const default_pipelines_1 = require("../../../core/steps/pipeline/default-pipelines");
38
37
  const retriever_1 = require("../../../r-bridge/retriever");
39
38
  const ast_1 = require("../../../util/mermaid/ast");
40
39
  const ansi_1 = require("../../../util/text/ansi");
41
- async function normalize(parser, remainingLine, config) {
42
- return await (0, default_pipelines_1.createNormalizePipeline)(parser, {
43
- request: (0, retriever_1.requestFromInput)(remainingLine.trim())
44
- }, config).allRemainingSteps();
45
- }
46
- function handleString(code) {
47
- return code.startsWith('"') ? JSON.parse(code) : code;
48
- }
49
- function formatInfo(out, type, timing) {
50
- return out.formatter.format(`Copied ${type} to clipboard (normalize: ${timing}ms).`, { color: 7 /* Colors.White */, effect: ansi_1.ColorEffect.Foreground, style: 3 /* FontStyles.Italic */ });
40
+ const core_1 = require("../core");
41
+ function formatInfo(out, type, meta) {
42
+ 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 */ });
51
43
  }
52
44
  exports.normalizeCommand = {
53
45
  description: `Get mermaid code for the normalized AST of R code, start with '${retriever_1.fileProtocol}' to indicate a file`,
46
+ isCodeCommand: true,
54
47
  usageExample: ':normalize',
55
48
  aliases: ['n'],
56
49
  script: false,
57
- fn: async ({ output, parser, remainingLine, config }) => {
58
- const result = await normalize(parser, handleString(remainingLine), config);
59
- const mermaid = (0, ast_1.normalizedAstToMermaid)(result.normalize.ast);
50
+ argsParser: (args) => (0, core_1.handleString)(args),
51
+ fn: async ({ output, analyzer }) => {
52
+ const result = await analyzer.normalize();
53
+ const mermaid = (0, ast_1.normalizedAstToMermaid)(result.ast);
60
54
  output.stdout(mermaid);
61
55
  try {
62
56
  const clipboard = await Promise.resolve().then(() => __importStar(require('clipboardy')));
63
57
  clipboard.default.writeSync(mermaid);
64
- output.stdout(formatInfo(output, 'mermaid url', result.normalize['.meta'].timing));
58
+ output.stdout(formatInfo(output, 'mermaid url', result));
65
59
  }
66
60
  catch { /* do nothing this is a service thing */ }
67
61
  }
68
62
  };
69
63
  exports.normalizeStarCommand = {
70
64
  description: 'Returns the URL to mermaid.live',
65
+ isCodeCommand: true,
71
66
  usageExample: ':normalize*',
72
67
  aliases: ['n*'],
73
68
  script: false,
74
- fn: async ({ output, parser, remainingLine, config }) => {
75
- const result = await normalize(parser, handleString(remainingLine), config);
76
- const mermaid = (0, ast_1.normalizedAstToMermaidUrl)(result.normalize.ast);
69
+ argsParser: (args) => (0, core_1.handleString)(args),
70
+ fn: async ({ output, analyzer }) => {
71
+ const result = await analyzer.normalize();
72
+ const mermaid = (0, ast_1.normalizedAstToMermaidUrl)(result.ast);
77
73
  output.stdout(mermaid);
78
74
  try {
79
75
  const clipboard = await Promise.resolve().then(() => __importStar(require('clipboardy')));
80
76
  clipboard.default.writeSync(mermaid);
81
- output.stdout(formatInfo(output, 'mermaid url', result.normalize['.meta'].timing));
77
+ output.stdout(formatInfo(output, 'mermaid url', result));
82
78
  }
83
79
  catch { /* do nothing this is a service thing */ }
84
80
  }
@@ -1,2 +1,2 @@
1
- import type { ReplCommand } from './repl-main';
2
- export declare const parseCommand: ReplCommand;
1
+ import type { ReplCodeCommand } from './repl-main';
2
+ export declare const parseCommand: ReplCodeCommand;
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseCommand = void 0;
4
4
  const format_1 = require("../../../r-bridge/lang-4.x/ast/parser/json/format");
5
5
  const normalize_meta_1 = require("../../../r-bridge/lang-4.x/ast/parser/main/normalize-meta");
6
- const default_pipelines_1 = require("../../../core/steps/pipeline/default-pipelines");
7
6
  const retriever_1 = require("../../../r-bridge/retriever");
8
7
  function toDepthMap(entry) {
9
8
  const visit = [{ depth: 0, node: entry }];
@@ -127,20 +126,27 @@ function depthListToTextTree(list, f) {
127
126
  }
128
127
  exports.parseCommand = {
129
128
  description: `Prints ASCII Art of the parsed, unmodified AST, start with '${retriever_1.fileProtocol}' to indicate a file`,
129
+ isCodeCommand: true,
130
130
  usageExample: ':parse',
131
131
  aliases: ['p'],
132
132
  script: false,
133
- fn: async ({ output, parser, remainingLine, config }) => {
134
- const result = await (0, default_pipelines_1.createParsePipeline)(parser, {
135
- request: (0, retriever_1.requestFromInput)((0, retriever_1.removeRQuotes)(remainingLine.trim()))
136
- }, config).allRemainingSteps();
137
- if (parser.name === 'r-shell') {
138
- const object = (0, format_1.convertPreparedParsedData)((0, format_1.prepareParsedData)(result.parse.parsed));
133
+ argsParser: (line) => {
134
+ return {
135
+ // Threat the whole input line as R code
136
+ input: (0, retriever_1.removeRQuotes)(line.trim()),
137
+ remaining: []
138
+ };
139
+ },
140
+ fn: async ({ output, analyzer }) => {
141
+ const result = await analyzer.parse();
142
+ const parserInfo = await analyzer.parserInformation();
143
+ if (parserInfo.name === 'r-shell') {
144
+ const object = (0, format_1.convertPreparedParsedData)((0, format_1.prepareParsedData)(result.parsed));
139
145
  output.stdout(depthListToTextTree(toDepthMap(object), output.formatter));
140
146
  }
141
147
  else {
142
148
  // print the tree-sitter ast
143
- output.stdout(depthListToTextTree(treeSitterToDepthList(result.parse.parsed.rootNode), output.formatter));
149
+ output.stdout(depthListToTextTree(treeSitterToDepthList(result.parsed.rootNode), output.formatter));
144
150
  }
145
151
  }
146
152
  };
@@ -1,3 +1,3 @@
1
- import type { ReplCommand } from './repl-main';
2
- export declare const queryCommand: ReplCommand;
3
- export declare const queryStarCommand: ReplCommand;
1
+ import type { ReplCodeCommand } from './repl-main';
2
+ export declare const queryCommand: ReplCodeCommand;
3
+ export declare const queryStarCommand: ReplCodeCommand;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.queryStarCommand = exports.queryCommand = void 0;
4
- const default_pipelines_1 = require("../../../core/steps/pipeline/default-pipelines");
5
4
  const retriever_1 = require("../../../r-bridge/retriever");
6
5
  const args_1 = require("../../../util/text/args");
7
6
  const ansi_1 = require("../../../util/text/ansi");
@@ -9,11 +8,6 @@ const schema_1 = require("../../../util/schema");
9
8
  const query_1 = require("../../../queries/query");
10
9
  const json_1 = require("../../../util/json");
11
10
  const query_print_1 = require("../../../queries/query-print");
12
- async function getDataflow(config, parser, remainingLine) {
13
- return await (0, default_pipelines_1.createDataflowPipeline)(parser, {
14
- request: (0, retriever_1.requestFromInput)(remainingLine.trim())
15
- }, config).allRemainingSteps();
16
- }
17
11
  function printHelp(output) {
18
12
  output.stderr(`Format: ${(0, ansi_1.italic)(':query "<query>" <code>', output.formatter)}`);
19
13
  output.stdout('The query is an array of query objects to represent multiple queries. Each query object may have the following properties:');
@@ -24,9 +18,8 @@ function printHelp(output) {
24
18
  output.stdout('Similarly, \'@<type>\' is interpreted as a query of the given type.');
25
19
  output.stdout(`With this, ${(0, ansi_1.italic)(':query @config', output.formatter)} prints the result of the config query.`);
26
20
  }
27
- async function processQueryArgs(line, parser, output, config) {
28
- const args = (0, args_1.splitAtEscapeSensitive)(line);
29
- const query = args.shift();
21
+ async function processQueryArgs(output, analyzer, remainingArgs) {
22
+ const query = remainingArgs.shift();
30
23
  if (!query) {
31
24
  output.stderr('No query provided, use \':query help\' to get more information.');
32
25
  return;
@@ -35,12 +28,12 @@ async function processQueryArgs(line, parser, output, config) {
35
28
  printHelp(output);
36
29
  return;
37
30
  }
38
- let parsedQuery = [];
31
+ let parsedQuery;
39
32
  if (query.startsWith('@')) {
40
33
  const queryName = query.slice(1);
41
34
  const queryObj = query_1.SupportedQueries[queryName];
42
35
  if (queryObj?.fromLine) {
43
- const q = queryObj.fromLine(args, config);
36
+ const q = queryObj.fromLine(remainingArgs, analyzer.flowrConfig);
44
37
  parsedQuery = q ? (Array.isArray(q) ? q : [q]) : [];
45
38
  }
46
39
  else {
@@ -65,34 +58,51 @@ async function processQueryArgs(line, parser, output, config) {
65
58
  else {
66
59
  parsedQuery = [{ type: 'call-context', callName: query }];
67
60
  }
68
- const processed = await getDataflow(config, parser, args.join(' '));
69
61
  return {
62
+ query: await (0, query_1.executeQueries)({
63
+ analyzer,
64
+ }, parsedQuery),
70
65
  parsedQuery,
71
- query: await Promise.resolve((0, query_1.executeQueries)({ dataflow: processed.dataflow, ast: processed.normalize, config }, parsedQuery)),
72
- processed
66
+ analyzer
67
+ };
68
+ }
69
+ /**
70
+ * Function for splitting the input line.
71
+ * The first token is the query command.
72
+ * The rest of the line is treated as input code.
73
+ */
74
+ function parseArgs(line) {
75
+ const args = (0, args_1.splitAtEscapeSensitive)(line);
76
+ return {
77
+ input: args[1].trim() === 'help' ? '' : args.slice(1).join(' ').trim(),
78
+ remaining: args
73
79
  };
74
80
  }
75
81
  exports.queryCommand = {
76
82
  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).`,
83
+ isCodeCommand: true,
77
84
  usageExample: ':query "<query>" <code>',
78
85
  aliases: [],
79
86
  script: false,
80
- fn: async ({ output, parser, remainingLine, config }) => {
87
+ argsParser: parseArgs,
88
+ fn: async ({ output, analyzer, remainingArgs }) => {
81
89
  const totalStart = Date.now();
82
- const results = await processQueryArgs(remainingLine, parser, output, config);
90
+ const results = await processQueryArgs(output, analyzer, remainingArgs);
83
91
  const totalEnd = Date.now();
84
92
  if (results) {
85
- output.stdout((0, query_print_1.asciiSummaryOfQueryResult)(ansi_1.ansiFormatter, totalEnd - totalStart, results.query, results.processed, results.parsedQuery));
93
+ output.stdout(await (0, query_print_1.asciiSummaryOfQueryResult)(ansi_1.ansiFormatter, totalEnd - totalStart, results.query, results.analyzer, results.parsedQuery));
86
94
  }
87
95
  }
88
96
  };
89
97
  exports.queryStarCommand = {
90
98
  description: 'Similar to query, but returns the output in json format.',
99
+ isCodeCommand: true,
91
100
  usageExample: ':query* <query> <code>',
92
101
  aliases: [],
93
102
  script: false,
94
- fn: async ({ output, parser, remainingLine, config }) => {
95
- const results = await processQueryArgs(remainingLine, parser, output, config);
103
+ argsParser: parseArgs,
104
+ fn: async ({ output, analyzer, remainingArgs }) => {
105
+ const results = await processQueryArgs(output, analyzer, remainingArgs);
96
106
  if (results) {
97
107
  output.stdout(JSON.stringify(results.query, json_1.jsonReplacer));
98
108
  }
@@ -4,6 +4,7 @@ exports.quitCommand = void 0;
4
4
  const log_1 = require("../../../util/log");
5
5
  exports.quitCommand = {
6
6
  description: 'End the repl',
7
+ isCodeCommand: false,
7
8
  aliases: ['q', 'exit'],
8
9
  usageExample: ':quit',
9
10
  script: false,
@@ -1,17 +1,2 @@
1
- import type { ReplCommand, ReplOutput } from './repl-main';
2
- import type { KnownParser } from '../../../r-bridge/parser';
3
- type Version = `${number}.${number}.${number}`;
4
- /**
5
- * Describes the version of flowR and the used R interpreter.
6
- */
7
- export interface VersionInformation {
8
- /** The version of flowR */
9
- flowr: Version;
10
- /** The version of R identified by the underlying {@link RShell} */
11
- r: Version | 'unknown' | 'none';
12
- engine: string;
13
- }
14
- export declare function retrieveVersionInformation(parser: KnownParser): Promise<VersionInformation>;
15
- export declare function printVersionInformation(output: ReplOutput, parser: KnownParser): Promise<void>;
1
+ import type { ReplCommand } from './repl-main';
16
2
  export declare const versionCommand: ReplCommand;
17
- export {};
@@ -1,29 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.versionCommand = void 0;
4
- exports.retrieveVersionInformation = retrieveVersionInformation;
5
- exports.printVersionInformation = printVersionInformation;
6
4
  const version_1 = require("../../../util/version");
7
- const assert_1 = require("../../../util/assert");
8
- const versionRegex = /^\d+\.\d+\.\d+/m;
9
- async function retrieveVersionInformation(parser) {
10
- const flowr = (0, version_1.flowrVersion)().toString();
11
- const r = await parser.rVersion();
12
- (0, assert_1.guard)(versionRegex.test(flowr), `flowR version ${flowr} does not match the expected format!`);
13
- (0, assert_1.guard)(r === 'unknown' || r === 'none' || versionRegex.test(r), `R version ${r} does not match the expected format!`);
14
- return { flowr: flowr, r: r, engine: parser.name };
15
- }
16
- async function printVersionInformation(output, parser) {
17
- const { flowr, r, engine } = await retrieveVersionInformation(parser);
18
- output.stdout(`Engine: ${engine}`);
19
- output.stdout(` flowR: ${flowr}`);
20
- output.stdout(` R: ${r}`);
21
- }
22
5
  exports.versionCommand = {
23
6
  description: 'Prints the version of flowR as well as the current version of R',
7
+ isCodeCommand: false,
24
8
  aliases: [],
25
9
  usageExample: ':version',
26
10
  script: false,
27
- fn: ({ output, parser }) => printVersionInformation(output, parser)
11
+ fn: ({ output, analyzer }) => (0, version_1.printVersionInformation)(output, analyzer)
28
12
  };
29
13
  //# sourceMappingURL=repl-version.js.map
@@ -1,33 +1,37 @@
1
1
  import * as readline from 'readline';
2
2
  import type { ReplOutput } from './commands/repl-main';
3
3
  import type { MergeableRecord } from '../../util/objects';
4
- import type { KnownParser } from '../../r-bridge/parser';
5
4
  import type { FlowrConfigOptions } from '../../config';
5
+ import type { FlowrAnalyzer } from '../../project/flowr-analyzer';
6
6
  /**
7
7
  * Used by the repl to provide automatic completions for a given (partial) input line
8
8
  */
9
9
  export declare function replCompleter(line: string, config: FlowrConfigOptions): [string[], string];
10
10
  export declare function makeDefaultReplReadline(config: FlowrConfigOptions): readline.ReadLineOptions;
11
+ export declare function handleString(code: string): {
12
+ input: string | undefined;
13
+ remaining: never[];
14
+ };
11
15
  /**
12
16
  * This function interprets the given `expr` as a REPL command (see {@link repl} for more on the semantics).
13
17
  *
14
- * @param config - flowr Config
18
+ * @param analyzer - The flowR analyzer to use.
15
19
  * @param output - Defines two methods that every function in the repl uses to output its data.
16
20
  * @param expr - The expression to process.
17
- * @param parser - The {@link RShell} or {@link TreeSitterExecutor} to use (see {@link repl}).
18
21
  * @param allowRSessionAccess - If true, allows the execution of arbitrary R code.
19
22
  */
20
- export declare function replProcessAnswer(config: FlowrConfigOptions, output: ReplOutput, expr: string, parser: KnownParser, allowRSessionAccess: boolean): Promise<void>;
23
+ export declare function replProcessAnswer(analyzer: FlowrAnalyzer, output: ReplOutput, expr: string, allowRSessionAccess: boolean): Promise<void>;
21
24
  /**
22
25
  * Options for the {@link repl} function.
23
26
  */
24
27
  export interface FlowrReplOptions extends MergeableRecord {
25
- /** The shell to use, if you do not pass one it will automatically create a new one with the `revive` option set to 'always'. */
26
- readonly parser?: KnownParser;
28
+ /**
29
+ * The flowR analyzer to use.
30
+ */
31
+ readonly analyzer: FlowrAnalyzer;
27
32
  /**
28
33
  * A potentially customized readline interface to be used for the repl to *read* from the user, we write the output with the {@link ReplOutput | `output` } interface.
29
34
  * If you want to provide a custom one but use the same `completer`, refer to {@link replCompleter}.
30
- * For the default arguments, see {@link DEFAULT_REPL_READLINE_CONFIGURATION}.
31
35
  */
32
36
  readonly rl?: readline.Interface;
33
37
  /** Defines two methods that every function in the repl uses to output its data. */
@@ -45,10 +49,9 @@ export interface FlowrReplOptions extends MergeableRecord {
45
49
  * - Starting with anything else, indicating default R code to be directly executed. If you kill the underlying shell, that is on you! </li>
46
50
  *
47
51
  * @param options - The options for the repl. See {@link FlowrReplOptions} for more information.
48
- * @param config - The flowr config
49
52
  *
50
53
  * For the execution, this function makes use of {@link replProcessAnswer}.
51
54
  *
52
55
  */
53
- export declare function repl(config: FlowrConfigOptions, { parser, rl, output, historyFile, allowRSessionAccess }: FlowrReplOptions): Promise<void>;
56
+ export declare function repl({ analyzer, rl, output, historyFile, allowRSessionAccess }: FlowrReplOptions): Promise<void>;
54
57
  export declare function loadReplHistory(historyFile: string): string[] | undefined;
package/cli/repl/core.js CHANGED
@@ -38,6 +38,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.replCompleter = replCompleter;
40
40
  exports.makeDefaultReplReadline = makeDefaultReplReadline;
41
+ exports.handleString = handleString;
41
42
  exports.replProcessAnswer = replProcessAnswer;
42
43
  exports.repl = repl;
43
44
  exports.loadReplHistory = loadReplHistory;
@@ -57,9 +58,7 @@ const repl_commands_1 = require("./commands/repl-commands");
57
58
  const scripts_info_1 = require("../common/scripts-info");
58
59
  const retriever_1 = require("../../r-bridge/retriever");
59
60
  const repl_main_1 = require("./commands/repl-main");
60
- const shell_1 = require("../../r-bridge/shell");
61
61
  const log_1 = require("../../util/log");
62
- const config_1 = require("../../config");
63
62
  const query_1 = require("../../queries/query");
64
63
  let _replCompleterKeywords = undefined;
65
64
  function replCompleterKeywords() {
@@ -129,14 +128,31 @@ function makeDefaultReplReadline(config) {
129
128
  completer: (c) => replCompleter(c, config)
130
129
  };
131
130
  }
132
- async function replProcessStatement(output, statement, parser, allowRSessionAccess, config) {
131
+ function handleString(code) {
132
+ return {
133
+ input: code.length == 0 ? undefined : code.startsWith('"') ? JSON.parse(code) : code,
134
+ remaining: []
135
+ };
136
+ }
137
+ async function replProcessStatement(output, statement, analyzer, allowRSessionAccess) {
133
138
  if (statement.startsWith(':')) {
134
139
  const command = statement.slice(1).split(' ')[0].toLowerCase();
135
140
  const processor = (0, repl_commands_1.getCommand)(command);
136
141
  const bold = (s) => output.formatter.format(s, { style: 1 /* FontStyles.Bold */ });
137
142
  if (processor) {
138
143
  try {
139
- await processor.fn({ output, parser, remainingLine: statement.slice(command.length + 2).trim(), allowRSessionAccess, config });
144
+ const remainingLine = statement.slice(command.length + 2).trim();
145
+ if (processor.isCodeCommand) {
146
+ const args = processor.argsParser(remainingLine);
147
+ if (args.input) {
148
+ analyzer.reset();
149
+ analyzer.context().addRequest((0, retriever_1.requestFromInput)(args.input));
150
+ }
151
+ await processor.fn({ output, analyzer, remainingArgs: args.remaining });
152
+ }
153
+ else {
154
+ await processor.fn({ output, analyzer, remainingLine, allowRSessionAccess });
155
+ }
140
156
  }
141
157
  catch (e) {
142
158
  output.stdout(`${bold(`Failed to execute command ${command}`)}: ${e?.message}. Using the ${bold('--verbose')} flag on startup may provide additional information.\n`);
@@ -150,22 +166,21 @@ async function replProcessStatement(output, statement, parser, allowRSessionAcce
150
166
  }
151
167
  }
152
168
  else {
153
- await (0, repl_execute_1.tryExecuteRShellCommand)({ output, parser, remainingLine: statement, allowRSessionAccess, config });
169
+ await (0, repl_execute_1.tryExecuteRShellCommand)({ output, analyzer, remainingLine: statement, allowRSessionAccess });
154
170
  }
155
171
  }
156
172
  /**
157
173
  * This function interprets the given `expr` as a REPL command (see {@link repl} for more on the semantics).
158
174
  *
159
- * @param config - flowr Config
175
+ * @param analyzer - The flowR analyzer to use.
160
176
  * @param output - Defines two methods that every function in the repl uses to output its data.
161
177
  * @param expr - The expression to process.
162
- * @param parser - The {@link RShell} or {@link TreeSitterExecutor} to use (see {@link repl}).
163
178
  * @param allowRSessionAccess - If true, allows the execution of arbitrary R code.
164
179
  */
165
- async function replProcessAnswer(config, output, expr, parser, allowRSessionAccess) {
180
+ async function replProcessAnswer(analyzer, output, expr, allowRSessionAccess) {
166
181
  const statements = (0, args_1.splitAtEscapeSensitive)(expr, false, ';');
167
182
  for (const statement of statements) {
168
- await replProcessStatement(output, statement, parser, allowRSessionAccess, config);
183
+ await replProcessStatement(output, statement, analyzer, allowRSessionAccess);
169
184
  }
170
185
  }
171
186
  /**
@@ -176,12 +191,11 @@ async function replProcessAnswer(config, output, expr, parser, allowRSessionAcce
176
191
  * - Starting with anything else, indicating default R code to be directly executed. If you kill the underlying shell, that is on you! </li>
177
192
  *
178
193
  * @param options - The options for the repl. See {@link FlowrReplOptions} for more information.
179
- * @param config - The flowr config
180
194
  *
181
195
  * For the execution, this function makes use of {@link replProcessAnswer}.
182
196
  *
183
197
  */
184
- async function repl(config, { parser = new shell_1.RShell((0, config_1.getEngineConfig)(config, 'r-shell'), { revive: 2 /* RShellReviveOptions.Always */ }), rl = readline.createInterface(makeDefaultReplReadline(config)), output = repl_main_1.standardReplOutput, historyFile = defaultHistoryFile, allowRSessionAccess = false }) {
198
+ async function repl({ analyzer, rl = readline.createInterface(makeDefaultReplReadline(analyzer.flowrConfig)), output = repl_main_1.standardReplOutput, historyFile = defaultHistoryFile, allowRSessionAccess = false }) {
185
199
  if (historyFile) {
186
200
  rl.on('history', h => fs_1.default.writeFileSync(historyFile, h.join('\n'), { encoding: 'utf-8' }));
187
201
  }
@@ -190,7 +204,7 @@ async function repl(config, { parser = new shell_1.RShell((0, config_1.getEngine
190
204
  await new Promise((resolve, reject) => {
191
205
  rl.question((0, prompt_1.prompt)(), answer => {
192
206
  rl.pause();
193
- replProcessAnswer(config, output, answer, parser, allowRSessionAccess).then(() => {
207
+ replProcessAnswer(analyzer, output, answer, allowRSessionAccess).then(() => {
194
208
  rl.resume();
195
209
  resolve();
196
210
  }).catch(reject);