@eagleoutice/flowr 2.4.8 → 2.6.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 (234) hide show
  1. package/README.md +66 -45
  2. package/benchmark/slicer.js +1 -1
  3. package/benchmark/summarizer/second-phase/graph.js +2 -2
  4. package/cli/flowr.js +3 -29
  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.js +1 -0
  12. package/cli/repl/commands/repl-lineage.js +1 -0
  13. package/cli/repl/commands/repl-main.d.ts +34 -3
  14. package/cli/repl/commands/repl-normalize.d.ts +3 -3
  15. package/cli/repl/commands/repl-normalize.js +15 -19
  16. package/cli/repl/commands/repl-parse.d.ts +2 -2
  17. package/cli/repl/commands/repl-parse.js +13 -8
  18. package/cli/repl/commands/repl-query.d.ts +3 -3
  19. package/cli/repl/commands/repl-query.js +29 -19
  20. package/cli/repl/commands/repl-quit.js +1 -0
  21. package/cli/repl/commands/repl-version.js +1 -0
  22. package/cli/repl/core.d.ts +4 -1
  23. package/cli/repl/core.js +21 -1
  24. package/cli/repl/server/connection.d.ts +7 -3
  25. package/cli/repl/server/connection.js +40 -48
  26. package/cli/repl/server/messages/message-slice.d.ts +1 -1
  27. package/cli/slicer-app.js +8 -3
  28. package/config.d.ts +1 -1
  29. package/config.js +4 -1
  30. package/control-flow/extract-cfg.d.ts +1 -1
  31. package/control-flow/extract-cfg.js +1 -1
  32. package/core/pipeline-executor.d.ts +5 -0
  33. package/core/pipeline-executor.js +5 -0
  34. package/core/steps/pipeline/create-pipeline.js +1 -1
  35. package/core/steps/pipeline/default-pipelines.d.ts +42 -42
  36. package/core/steps/pipeline/default-pipelines.js +4 -1
  37. package/dataflow/graph/dataflowgraph-builder.d.ts +11 -12
  38. package/dataflow/graph/dataflowgraph-builder.js +6 -6
  39. package/documentation/doc-util/doc-query.d.ts +3 -6
  40. package/documentation/doc-util/doc-query.js +5 -17
  41. package/documentation/doc-util/doc-search.js +7 -10
  42. package/documentation/doc-util/doc-structure.d.ts +4 -0
  43. package/documentation/doc-util/doc-structure.js +28 -0
  44. package/documentation/doc-util/doc-types.d.ts +5 -1
  45. package/documentation/doc-util/doc-types.js +29 -3
  46. package/documentation/print-analyzer-wiki.d.ts +1 -0
  47. package/documentation/print-analyzer-wiki.js +137 -0
  48. package/documentation/print-core-wiki.d.ts +2 -1
  49. package/documentation/print-core-wiki.js +58 -4
  50. package/documentation/print-dataflow-graph-wiki.js +15 -22
  51. package/documentation/print-interface-wiki.js +18 -1
  52. package/documentation/print-linter-wiki.js +5 -1
  53. package/documentation/print-linting-and-testing-wiki.js +4 -0
  54. package/documentation/print-normalized-ast-wiki.js +6 -8
  55. package/documentation/print-readme.js +6 -0
  56. package/engines.d.ts +9 -0
  57. package/engines.js +38 -0
  58. package/linter/linter-executor.d.ts +2 -8
  59. package/linter/linter-executor.js +9 -4
  60. package/linter/linter-format.d.ts +8 -9
  61. package/linter/linter-rules.d.ts +57 -15
  62. package/linter/linter-rules.js +2 -0
  63. package/linter/rules/absolute-path.d.ts +1 -0
  64. package/linter/rules/dataframe-access-validation.d.ts +4 -3
  65. package/linter/rules/dataframe-access-validation.js +7 -4
  66. package/linter/rules/dead-code.d.ts +2 -1
  67. package/linter/rules/deprecated-functions.d.ts +15 -28
  68. package/linter/rules/deprecated-functions.js +5 -43
  69. package/linter/rules/file-path-validity.d.ts +2 -1
  70. package/linter/rules/file-path-validity.js +1 -1
  71. package/linter/rules/function-finder-util.d.ts +51 -0
  72. package/linter/rules/function-finder-util.js +77 -0
  73. package/linter/rules/naming-convention.d.ts +2 -1
  74. package/linter/rules/network-functions.d.ts +40 -0
  75. package/linter/rules/network-functions.js +24 -0
  76. package/linter/rules/seeded-randomness.d.ts +2 -1
  77. package/linter/rules/unused-definition.d.ts +2 -1
  78. package/linter/rules/useless-loop.d.ts +3 -2
  79. package/linter/rules/useless-loop.js +4 -6
  80. package/package.json +5 -1
  81. package/project/cache/flowr-analyzer-cache.d.ts +93 -0
  82. package/project/cache/flowr-analyzer-cache.js +156 -0
  83. package/project/cache/flowr-cache.d.ts +28 -0
  84. package/project/cache/flowr-cache.js +49 -0
  85. package/project/context/abstract-flowr-analyzer-context.d.ts +35 -0
  86. package/project/context/abstract-flowr-analyzer-context.js +46 -0
  87. package/project/context/flowr-analyzer-context.d.ts +48 -0
  88. package/project/context/flowr-analyzer-context.js +47 -0
  89. package/project/context/flowr-analyzer-dependencies-context.d.ts +38 -0
  90. package/project/context/flowr-analyzer-dependencies-context.js +39 -0
  91. package/project/context/flowr-analyzer-files-context.d.ts +86 -0
  92. package/project/context/flowr-analyzer-files-context.js +130 -0
  93. package/project/context/flowr-analyzer-loading-order-context.d.ts +76 -0
  94. package/project/context/flowr-analyzer-loading-order-context.js +90 -0
  95. package/project/context/flowr-file.d.ts +89 -0
  96. package/project/context/flowr-file.js +78 -0
  97. package/project/flowr-analyzer-builder.d.ts +106 -0
  98. package/project/flowr-analyzer-builder.js +197 -0
  99. package/project/flowr-analyzer.d.ts +125 -0
  100. package/project/flowr-analyzer.js +81 -0
  101. package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.d.ts +17 -0
  102. package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.js +28 -0
  103. package/project/plugins/file-plugins/flowr-analyzer-file-plugin.d.ts +21 -0
  104. package/project/plugins/file-plugins/flowr-analyzer-file-plugin.js +34 -0
  105. package/project/plugins/file-plugins/flowr-description-file.d.ts +24 -0
  106. package/project/plugins/file-plugins/flowr-description-file.js +38 -0
  107. package/project/plugins/flowr-analyzer-plugin.d.ts +90 -0
  108. package/project/plugins/flowr-analyzer-plugin.js +82 -0
  109. package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-description-file-plugin.d.ts +14 -0
  110. package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-description-file-plugin.js +56 -0
  111. package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-plugin.d.ts +13 -0
  112. package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-plugin.js +33 -0
  113. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.d.ts +14 -0
  114. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.js +41 -0
  115. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.d.ts +10 -0
  116. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.js +29 -0
  117. package/project/plugins/package-version-plugins/package.d.ts +15 -0
  118. package/project/plugins/package-version-plugins/package.js +56 -0
  119. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.d.ts +15 -0
  120. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +44 -0
  121. package/queries/base-query-format.d.ts +2 -8
  122. package/queries/catalog/call-context-query/call-context-query-executor.d.ts +1 -1
  123. package/queries/catalog/call-context-query/call-context-query-executor.js +20 -13
  124. package/queries/catalog/call-context-query/call-context-query-format.d.ts +2 -3
  125. package/queries/catalog/call-context-query/call-context-query-format.js +2 -2
  126. package/queries/catalog/cluster-query/cluster-query-executor.d.ts +1 -1
  127. package/queries/catalog/cluster-query/cluster-query-executor.js +2 -2
  128. package/queries/catalog/cluster-query/cluster-query-format.d.ts +1 -54
  129. package/queries/catalog/cluster-query/cluster-query-format.js +2 -2
  130. package/queries/catalog/config-query/config-query-executor.d.ts +1 -1
  131. package/queries/catalog/config-query/config-query-executor.js +5 -5
  132. package/queries/catalog/config-query/config-query-format.d.ts +1 -1
  133. package/queries/catalog/config-query/config-query-format.js +1 -1
  134. package/queries/catalog/control-flow-query/control-flow-query-executor.d.ts +1 -1
  135. package/queries/catalog/control-flow-query/control-flow-query-executor.js +2 -3
  136. package/queries/catalog/control-flow-query/control-flow-query-format.d.ts +1 -54
  137. package/queries/catalog/control-flow-query/control-flow-query-format.js +2 -2
  138. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.d.ts +1 -1
  139. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.js +2 -2
  140. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.d.ts +1 -54
  141. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.js +1 -1
  142. package/queries/catalog/dataflow-query/dataflow-query-executor.d.ts +1 -1
  143. package/queries/catalog/dataflow-query/dataflow-query-executor.js +2 -2
  144. package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +1 -54
  145. package/queries/catalog/dataflow-query/dataflow-query-format.js +1 -1
  146. package/queries/catalog/dependencies-query/dependencies-query-executor.d.ts +1 -1
  147. package/queries/catalog/dependencies-query/dependencies-query-executor.js +19 -12
  148. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +7 -56
  149. package/queries/catalog/dependencies-query/dependencies-query-format.js +7 -4
  150. package/queries/catalog/df-shape-query/df-shape-query-executor.d.ts +1 -1
  151. package/queries/catalog/df-shape-query/df-shape-query-executor.js +4 -4
  152. package/queries/catalog/df-shape-query/df-shape-query-format.d.ts +1 -54
  153. package/queries/catalog/df-shape-query/df-shape-query-format.js +1 -1
  154. package/queries/catalog/happens-before-query/happens-before-query-executor.d.ts +1 -1
  155. package/queries/catalog/happens-before-query/happens-before-query-executor.js +2 -1
  156. package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +1 -54
  157. package/queries/catalog/happens-before-query/happens-before-query-format.js +1 -1
  158. package/queries/catalog/id-map-query/id-map-query-executor.d.ts +1 -1
  159. package/queries/catalog/id-map-query/id-map-query-executor.js +2 -2
  160. package/queries/catalog/id-map-query/id-map-query-format.d.ts +1 -54
  161. package/queries/catalog/id-map-query/id-map-query-format.js +2 -2
  162. package/queries/catalog/lineage-query/lineage-query-executor.d.ts +1 -1
  163. package/queries/catalog/lineage-query/lineage-query-executor.js +2 -2
  164. package/queries/catalog/lineage-query/lineage-query-format.d.ts +1 -54
  165. package/queries/catalog/lineage-query/lineage-query-format.js +1 -1
  166. package/queries/catalog/linter-query/linter-query-executor.d.ts +1 -1
  167. package/queries/catalog/linter-query/linter-query-executor.js +2 -3
  168. package/queries/catalog/linter-query/linter-query-format.d.ts +1 -54
  169. package/queries/catalog/linter-query/linter-query-format.js +1 -1
  170. package/queries/catalog/location-map-query/location-map-query-executor.d.ts +1 -1
  171. package/queries/catalog/location-map-query/location-map-query-executor.js +3 -2
  172. package/queries/catalog/location-map-query/location-map-query-format.d.ts +1 -1
  173. package/queries/catalog/location-map-query/location-map-query-format.js +1 -1
  174. package/queries/catalog/normalized-ast-query/normalized-ast-query-executor.d.ts +1 -1
  175. package/queries/catalog/normalized-ast-query/normalized-ast-query-executor.js +2 -2
  176. package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +1 -54
  177. package/queries/catalog/normalized-ast-query/normalized-ast-query-format.js +1 -1
  178. package/queries/catalog/origin-query/origin-query-executor.d.ts +2 -2
  179. package/queries/catalog/origin-query/origin-query-executor.js +3 -3
  180. package/queries/catalog/origin-query/origin-query-format.d.ts +1 -54
  181. package/queries/catalog/origin-query/origin-query-format.js +1 -1
  182. package/queries/catalog/project-query/project-query-executor.d.ts +1 -1
  183. package/queries/catalog/project-query/project-query-executor.js +2 -2
  184. package/queries/catalog/project-query/project-query-format.d.ts +1 -54
  185. package/queries/catalog/project-query/project-query-format.js +1 -1
  186. package/queries/catalog/resolve-value-query/resolve-value-query-executor.d.ts +1 -1
  187. package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +4 -2
  188. package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +1 -54
  189. package/queries/catalog/resolve-value-query/resolve-value-query-format.js +1 -1
  190. package/queries/catalog/search-query/search-query-executor.d.ts +1 -1
  191. package/queries/catalog/search-query/search-query-executor.js +3 -3
  192. package/queries/catalog/search-query/search-query-format.d.ts +1 -54
  193. package/queries/catalog/search-query/search-query-format.js +1 -1
  194. package/queries/catalog/static-slice-query/static-slice-query-executor.d.ts +1 -1
  195. package/queries/catalog/static-slice-query/static-slice-query-executor.js +3 -3
  196. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +1 -54
  197. package/queries/catalog/static-slice-query/static-slice-query-format.js +1 -1
  198. package/queries/query-print.d.ts +4 -4
  199. package/queries/query-print.js +12 -12
  200. package/queries/query.d.ts +29 -885
  201. package/queries/query.js +1 -1
  202. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +1 -1
  203. package/r-bridge/retriever.d.ts +15 -2
  204. package/r-bridge/retriever.js +15 -5
  205. package/search/flowr-search-executor.d.ts +3 -5
  206. package/search/flowr-search-executor.js +6 -4
  207. package/search/flowr-search-filters.d.ts +12 -6
  208. package/search/flowr-search-filters.js +1 -1
  209. package/search/flowr-search.d.ts +5 -16
  210. package/search/flowr-search.js +14 -5
  211. package/search/search-executor/search-enrichers.d.ts +37 -36
  212. package/search/search-executor/search-enrichers.js +4 -4
  213. package/search/search-executor/search-generators.d.ts +12 -12
  214. package/search/search-executor/search-generators.js +27 -19
  215. package/search/search-executor/search-mappers.d.ts +5 -5
  216. package/search/search-executor/search-transformer.d.ts +17 -17
  217. package/search/search-executor/search-transformer.js +14 -7
  218. package/util/collections/arrays.d.ts +1 -0
  219. package/util/collections/arrays.js +15 -0
  220. package/util/collections/objectmap.d.ts +17 -0
  221. package/util/collections/objectmap.js +28 -0
  222. package/util/containers.d.ts +0 -1
  223. package/util/containers.js +0 -1
  224. package/util/files.d.ts +17 -0
  225. package/util/files.js +65 -0
  226. package/util/formats/adapter-format.d.ts +6 -0
  227. package/util/formats/adapter-format.js +3 -0
  228. package/util/formats/adapter.d.ts +18 -0
  229. package/util/formats/adapter.js +49 -0
  230. package/util/formats/adapters/r-adapter.d.ts +4 -0
  231. package/util/formats/adapters/r-adapter.js +7 -0
  232. package/util/formats/adapters/rmd-adapter.d.ts +26 -0
  233. package/util/formats/adapters/rmd-adapter.js +91 -0
  234. package/util/version.js +1 -1
@@ -34,88 +34,85 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.dataflowSimpleStarCommand = exports.dataflowSimplifiedCommand = exports.dataflowStarCommand = exports.dataflowCommand = 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 dfg_1 = require("../../../util/mermaid/dfg");
40
39
  const ansi_1 = require("../../../util/text/ansi");
41
- /**
42
- * Obtain the dataflow graph using a known parser (such as the {@link RShell} or {@link TreeSitterExecutor}).
43
- */
44
- async function replGetDataflow(config, parser, code) {
45
- return await (0, default_pipelines_1.createDataflowPipeline)(parser, {
46
- request: (0, retriever_1.requestFromInput)(code.trim())
47
- }, config).allRemainingSteps();
48
- }
49
- function handleString(code) {
50
- return code.startsWith('"') ? JSON.parse(code) : code;
51
- }
52
- function formatInfo(out, type, timing) {
53
- return out.formatter.format(`Copied ${type} to clipboard (dataflow: ${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 (dataflow: ${meta['.meta'].timing + 'ms'}).`, { color: 7 /* Colors.White */, effect: ansi_1.ColorEffect.Foreground, style: 3 /* FontStyles.Italic */ });
54
43
  }
55
44
  exports.dataflowCommand = {
56
45
  description: `Get mermaid code for the dataflow graph, start with '${retriever_1.fileProtocol}' to indicate a file`,
46
+ usesAnalyzer: true,
57
47
  usageExample: ':dataflow',
58
48
  aliases: ['d', 'df'],
59
49
  script: false,
60
- fn: async ({ output, parser, remainingLine, config }) => {
61
- const result = await replGetDataflow(config, parser, handleString(remainingLine));
62
- const mermaid = (0, dfg_1.graphToMermaid)({ graph: result.dataflow.graph, includeEnvironments: false }).string;
50
+ argsParser: (args) => (0, core_1.handleString)(args),
51
+ fn: async ({ output, analyzer }) => {
52
+ const result = await analyzer.dataflow();
53
+ const mermaid = (0, dfg_1.graphToMermaid)({ graph: result.graph, includeEnvironments: false }).string;
63
54
  output.stdout(mermaid);
64
55
  try {
65
56
  const clipboard = await Promise.resolve().then(() => __importStar(require('clipboardy')));
66
57
  clipboard.default.writeSync(mermaid);
67
- output.stdout(formatInfo(output, 'mermaid code', result.dataflow['.meta'].timing));
58
+ output.stdout(formatInfo(output, 'mermaid code', result));
68
59
  }
69
60
  catch { /* do nothing this is a service thing */ }
70
61
  }
71
62
  };
72
63
  exports.dataflowStarCommand = {
73
64
  description: 'Returns the URL to mermaid.live',
65
+ usesAnalyzer: true,
74
66
  usageExample: ':dataflow*',
75
67
  aliases: ['d*', 'df*'],
76
68
  script: false,
77
- fn: async ({ output, parser, remainingLine, config }) => {
78
- const result = await replGetDataflow(config, parser, handleString(remainingLine));
79
- const mermaid = (0, dfg_1.graphToMermaidUrl)(result.dataflow.graph, false);
69
+ argsParser: (args) => (0, core_1.handleString)(args),
70
+ fn: async ({ output, analyzer }) => {
71
+ const result = await analyzer.dataflow();
72
+ const mermaid = (0, dfg_1.graphToMermaidUrl)(result.graph, false);
80
73
  output.stdout(mermaid);
81
74
  try {
82
75
  const clipboard = await Promise.resolve().then(() => __importStar(require('clipboardy')));
83
76
  clipboard.default.writeSync(mermaid);
84
- output.stdout(formatInfo(output, 'mermaid url', result.dataflow['.meta'].timing));
77
+ output.stdout(formatInfo(output, 'mermaid url', result));
85
78
  }
86
79
  catch { /* do nothing this is a service thing */ }
87
80
  }
88
81
  };
89
82
  exports.dataflowSimplifiedCommand = {
90
83
  description: `Get mermaid code for the simplified dataflow graph, start with '${retriever_1.fileProtocol}' to indicate a file`,
84
+ usesAnalyzer: true,
91
85
  usageExample: ':dataflowsimple',
92
86
  aliases: ['ds', 'dfs'],
93
87
  script: false,
94
- fn: async ({ output, parser, remainingLine, config }) => {
95
- const result = await replGetDataflow(config, parser, handleString(remainingLine));
96
- const mermaid = (0, dfg_1.graphToMermaid)({ graph: result.dataflow.graph, includeEnvironments: false, simplified: true }).string;
88
+ argsParser: (args) => (0, core_1.handleString)(args),
89
+ fn: async ({ output, analyzer }) => {
90
+ const result = await analyzer.dataflow();
91
+ const mermaid = (0, dfg_1.graphToMermaid)({ graph: result.graph, includeEnvironments: false, simplified: true }).string;
97
92
  output.stdout(mermaid);
98
93
  try {
99
94
  const clipboard = await Promise.resolve().then(() => __importStar(require('clipboardy')));
100
95
  clipboard.default.writeSync(mermaid);
101
- output.stdout(formatInfo(output, 'mermaid code', result.dataflow['.meta'].timing));
96
+ output.stdout(formatInfo(output, 'mermaid code', result));
102
97
  }
103
98
  catch { /* do nothing this is a service thing */ }
104
99
  }
105
100
  };
106
101
  exports.dataflowSimpleStarCommand = {
107
102
  description: 'Returns the URL to mermaid.live',
103
+ usesAnalyzer: true,
108
104
  usageExample: ':dataflowsimple*',
109
105
  aliases: ['ds*', 'dfs*'],
110
106
  script: false,
111
- fn: async ({ output, parser, remainingLine, config }) => {
112
- const result = await replGetDataflow(config, parser, handleString(remainingLine));
113
- const mermaid = (0, dfg_1.graphToMermaidUrl)(result.dataflow.graph, false, undefined, true);
107
+ argsParser: (args) => (0, core_1.handleString)(args),
108
+ fn: async ({ output, analyzer }) => {
109
+ const result = await analyzer.dataflow();
110
+ const mermaid = (0, dfg_1.graphToMermaidUrl)(result.graph, false, undefined, true);
114
111
  output.stdout(mermaid);
115
112
  try {
116
113
  const clipboard = await Promise.resolve().then(() => __importStar(require('clipboardy')));
117
114
  clipboard.default.writeSync(mermaid);
118
- output.stdout(formatInfo(output, 'mermaid url', result.dataflow['.meta'].timing));
115
+ output.stdout(formatInfo(output, 'mermaid url', result));
119
116
  }
120
117
  catch { /* do nothing this is a service thing */ }
121
118
  }
@@ -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
+ usesAnalyzer: false,
33
34
  usageExample: ':execute',
34
35
  aliases: ['e', 'r'],
35
36
  script: false,
@@ -53,6 +53,7 @@ function getLineage(criterion, graph, idMap) {
53
53
  }
54
54
  exports.lineageCommand = {
55
55
  description: 'Get the lineage of an R object',
56
+ usesAnalyzer: false,
56
57
  usageExample: ':lineage',
57
58
  aliases: ['lin'],
58
59
  script: false,
@@ -1,6 +1,7 @@
1
1
  import type { OutputFormatter } from '../../../util/text/ansi';
2
2
  import type { KnownParser } from '../../../r-bridge/parser';
3
3
  import type { FlowrConfigOptions } from '../../../config';
4
+ import type { FlowrAnalysisProvider } from '../../../project/flowr-analyzer';
4
5
  /**
5
6
  * Defines the main interface for output of the repl.
6
7
  * This allows us to redirect it (e.g., in the case of a server connection or tests).
@@ -20,20 +21,29 @@ export interface ReplOutput {
20
21
  */
21
22
  export declare const standardReplOutput: ReplOutput;
22
23
  /**
23
- * Information passed to each repl command function
24
+ * Information passed to each {@link ReplCommand#fn}.
24
25
  */
25
26
  export interface ReplCommandInformation {
26
27
  output: ReplOutput;
28
+ allowRSessionAccess: boolean;
27
29
  parser: KnownParser;
28
30
  remainingLine: string;
29
- allowRSessionAccess: boolean;
30
31
  config: FlowrConfigOptions;
31
32
  }
33
+ /**
34
+ * Information passed to each {@link ReplCodeCommand#fn}.
35
+ * The {@link analyzer} has the {@link RParseRequest}.
36
+ */
37
+ export interface ReplCodeCommandInformation {
38
+ output: ReplOutput;
39
+ analyzer: FlowrAnalysisProvider;
40
+ remainingArgs: string[];
41
+ }
32
42
  /**
33
43
  * Content of a single command in the repl.
34
44
  * The command may execute an external script or simply call *flowR* functions.
35
45
  */
36
- export interface ReplCommand {
46
+ export interface ReplBaseCommand {
37
47
  /** Aliases of the command (without the leading colon), every alias must be unique (this is checked at runtime) */
38
48
  aliases: string[];
39
49
  /** A human-readable description of what the command does */
@@ -42,9 +52,30 @@ export interface ReplCommand {
42
52
  script: boolean;
43
53
  /** Example of how to use the command, for example `:slicer --help` */
44
54
  usageExample: string;
55
+ }
56
+ export interface ReplCommand extends ReplBaseCommand {
57
+ usesAnalyzer: false;
45
58
  /**
46
59
  * Function to execute when the command is invoked, it must not write to the command line but instead use the output handler.
47
60
  * Furthermore, it has to obey the formatter defined in the {@link ReplOutput}.
48
61
  */
49
62
  fn: (info: ReplCommandInformation) => Promise<void> | void;
50
63
  }
64
+ /**
65
+ * Repl command that uses the {@link FlowrAnalyzer}
66
+ */
67
+ export interface ReplCodeCommand extends ReplBaseCommand {
68
+ usesAnalyzer: true;
69
+ /**
70
+ * Function to execute when the command is invoked, it must not write to the command line but instead use the output handler.
71
+ * Furthermore, it has to obey the formatter defined in the {@link ReplOutput}.
72
+ */
73
+ fn: (info: ReplCodeCommandInformation) => Promise<void> | void;
74
+ /**
75
+ * Argument parser function which handles the input given after the repl command
76
+ */
77
+ argsParser: (remainingLine: string) => {
78
+ input: string;
79
+ remaining: string[];
80
+ };
81
+ }
@@ -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
+ usesAnalyzer: 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
+ usesAnalyzer: 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,26 @@ 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
+ usesAnalyzer: 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
+ if (analyzer.parserName() === 'r-shell') {
143
+ const object = (0, format_1.convertPreparedParsedData)((0, format_1.prepareParsedData)(result.parsed));
139
144
  output.stdout(depthListToTextTree(toDepthMap(object), output.formatter));
140
145
  }
141
146
  else {
142
147
  // print the tree-sitter ast
143
- output.stdout(depthListToTextTree(treeSitterToDepthList(result.parse.parsed.rootNode), output.formatter));
148
+ output.stdout(depthListToTextTree(treeSitterToDepthList(result.parsed.rootNode), output.formatter));
144
149
  }
145
150
  }
146
151
  };
@@ -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.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
+ usesAnalyzer: 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
+ usesAnalyzer: 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
+ usesAnalyzer: false,
7
8
  aliases: ['q', 'exit'],
8
9
  usageExample: ':quit',
9
10
  script: false,
@@ -21,6 +21,7 @@ async function printVersionInformation(output, parser) {
21
21
  }
22
22
  exports.versionCommand = {
23
23
  description: 'Prints the version of flowR as well as the current version of R',
24
+ usesAnalyzer: false,
24
25
  aliases: [],
25
26
  usageExample: ':version',
26
27
  script: false,
@@ -8,6 +8,10 @@ import type { FlowrConfigOptions } from '../../config';
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;
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
  *
@@ -27,7 +31,6 @@ export interface FlowrReplOptions extends MergeableRecord {
27
31
  /**
28
32
  * 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
33
  * 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
34
  */
32
35
  readonly rl?: readline.Interface;
33
36
  /** Defines two methods that every function in the repl uses to output its data. */
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;
@@ -61,6 +62,7 @@ const shell_1 = require("../../r-bridge/shell");
61
62
  const log_1 = require("../../util/log");
62
63
  const config_1 = require("../../config");
63
64
  const query_1 = require("../../queries/query");
65
+ const flowr_analyzer_builder_1 = require("../../project/flowr-analyzer-builder");
64
66
  let _replCompleterKeywords = undefined;
65
67
  function replCompleterKeywords() {
66
68
  if (_replCompleterKeywords === undefined) {
@@ -129,6 +131,12 @@ function makeDefaultReplReadline(config) {
129
131
  completer: (c) => replCompleter(c, config)
130
132
  };
131
133
  }
134
+ function handleString(code) {
135
+ return {
136
+ input: code.startsWith('"') ? JSON.parse(code) : code,
137
+ remaining: []
138
+ };
139
+ }
132
140
  async function replProcessStatement(output, statement, parser, allowRSessionAccess, config) {
133
141
  if (statement.startsWith(':')) {
134
142
  const command = statement.slice(1).split(' ')[0].toLowerCase();
@@ -136,7 +144,19 @@ async function replProcessStatement(output, statement, parser, allowRSessionAcce
136
144
  const bold = (s) => output.formatter.format(s, { style: 1 /* FontStyles.Bold */ });
137
145
  if (processor) {
138
146
  try {
139
- await processor.fn({ output, parser, remainingLine: statement.slice(command.length + 2).trim(), allowRSessionAccess, config });
147
+ const remainingLine = statement.slice(command.length + 2).trim();
148
+ if (processor.usesAnalyzer) {
149
+ const args = processor.argsParser(remainingLine);
150
+ const request = (0, retriever_1.requestFromInput)(args.input);
151
+ const analyzer = await new flowr_analyzer_builder_1.FlowrAnalyzerBuilder(request)
152
+ .setConfig(config)
153
+ .setParser(parser)
154
+ .build();
155
+ await processor.fn({ output, analyzer, remainingArgs: args.remaining });
156
+ }
157
+ else {
158
+ await processor.fn({ output, parser, remainingLine, allowRSessionAccess, config });
159
+ }
140
160
  }
141
161
  catch (e) {
142
162
  output.stdout(`${bold(`Failed to execute command ${command}`)}: ${e?.message}. Using the ${bold('--verbose')} flag on startup may provide additional information.\n`);
@@ -1,9 +1,13 @@
1
1
  import type { Socket } from './net';
2
+ import type { TREE_SITTER_DATAFLOW_PIPELINE } from '../../../core/steps/pipeline/default-pipelines';
2
3
  import { DEFAULT_SLICING_PIPELINE } from '../../../core/steps/pipeline/default-pipelines';
3
4
  import type { PipelineOutput } from '../../../core/steps/pipeline/pipeline';
4
5
  import type { DeepPartial } from 'ts-essentials';
5
- import type { KnownParser } from '../../../r-bridge/parser';
6
+ import type { KnownParser, ParseStepOutput } from '../../../r-bridge/parser';
6
7
  import type { FlowrConfigOptions } from '../../../config';
8
+ import type { NormalizedAst } from '../../../r-bridge/lang-4.x/ast/model/processing/decorate';
9
+ import type { DataflowInformation } from '../../../dataflow/info';
10
+ import type { Tree } from 'web-tree-sitter';
7
11
  /**
8
12
  * Each connection handles a single client, answering to its requests.
9
13
  * There is no need to construct this class manually, {@link FlowRServer} will do it for you.
@@ -21,10 +25,10 @@ export declare class FlowRServerConnection {
21
25
  private handleData;
22
26
  private handleFileAnalysisRequest;
23
27
  private sendFileAnalysisResponse;
24
- private createPipelineExecutorForRequest;
28
+ private createAnalyzerForRequest;
25
29
  private handleSliceRequest;
26
30
  private handleRepl;
27
31
  private handleLineageRequest;
28
32
  private handleQueryRequest;
29
33
  }
30
- export declare function sanitizeAnalysisResults(results: Partial<PipelineOutput<typeof DEFAULT_SLICING_PIPELINE>>): DeepPartial<PipelineOutput<typeof DEFAULT_SLICING_PIPELINE>>;
34
+ export declare function sanitizeAnalysisResults(parse: ParseStepOutput<string | Tree>, normalize: NormalizedAst, dataflow: DataflowInformation): DeepPartial<PipelineOutput<typeof DEFAULT_SLICING_PIPELINE | typeof TREE_SITTER_DATAFLOW_PIPELINE>>;