@eagleoutice/flowr 2.2.12 → 2.2.14

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 (282) hide show
  1. package/README.md +82 -20
  2. package/benchmark/slicer.js +2 -2
  3. package/benchmark/summarizer/first-phase/input.js +1 -1
  4. package/benchmark/summarizer/first-phase/process.js +3 -3
  5. package/benchmark/summarizer/second-phase/process.js +1 -1
  6. package/benchmark/summarizer/summarizer.js +1 -1
  7. package/cli/common/options.js +4 -4
  8. package/cli/common/script.js +1 -1
  9. package/cli/flowr.js +1 -1
  10. package/cli/repl/commands/repl-cfg.d.ts +2 -0
  11. package/cli/repl/commands/repl-cfg.js +38 -24
  12. package/cli/repl/commands/repl-commands.js +4 -2
  13. package/cli/repl/commands/repl-dataflow.js +3 -3
  14. package/cli/repl/commands/repl-execute.js +1 -1
  15. package/cli/repl/commands/repl-main.d.ts +1 -1
  16. package/cli/repl/commands/repl-main.js +1 -1
  17. package/cli/repl/commands/repl-normalize.js +1 -1
  18. package/cli/repl/commands/repl-query.js +2 -2
  19. package/cli/repl/core.js +1 -1
  20. package/cli/repl/prompt.js +1 -1
  21. package/cli/repl/server/connection.js +4 -4
  22. package/cli/repl/server/messages/message-analysis.d.ts +1 -1
  23. package/cli/script-core/statistics-core.js +1 -1
  24. package/cli/script-core/statistics-helper-core.js +4 -4
  25. package/config.d.ts +47 -24
  26. package/config.js +3 -3
  27. package/control-flow/basic-cfg-guided-visitor.d.ts +39 -0
  28. package/control-flow/basic-cfg-guided-visitor.js +114 -0
  29. package/control-flow/cfg-properties.d.ts +26 -0
  30. package/control-flow/cfg-properties.js +100 -0
  31. package/control-flow/cfg-simplification.d.ts +18 -0
  32. package/control-flow/cfg-simplification.js +55 -0
  33. package/control-flow/cfg-to-basic-blocks.d.ts +5 -0
  34. package/control-flow/cfg-to-basic-blocks.js +81 -0
  35. package/control-flow/control-flow-graph.d.ts +247 -0
  36. package/control-flow/control-flow-graph.js +290 -0
  37. package/control-flow/dfg-cfg-guided-visitor.d.ts +32 -0
  38. package/control-flow/dfg-cfg-guided-visitor.js +71 -0
  39. package/control-flow/diff-cfg.d.ts +11 -0
  40. package/control-flow/diff-cfg.js +161 -0
  41. package/control-flow/extract-cfg.d.ts +30 -0
  42. package/control-flow/extract-cfg.js +475 -0
  43. package/control-flow/happens-before.d.ts +7 -0
  44. package/{util/cfg → control-flow}/happens-before.js +3 -3
  45. package/control-flow/semantic-cfg-guided-visitor.d.ts +452 -0
  46. package/control-flow/semantic-cfg-guided-visitor.js +492 -0
  47. package/control-flow/simple-visitor.d.ts +25 -0
  48. package/control-flow/simple-visitor.js +80 -0
  49. package/control-flow/syntax-cfg-guided-visitor.d.ts +128 -0
  50. package/control-flow/syntax-cfg-guided-visitor.js +166 -0
  51. package/core/print/print.d.ts +1 -1
  52. package/core/print/slice-diff-ansi.js +1 -1
  53. package/core/steps/pipeline/create-pipeline.js +1 -1
  54. package/dataflow/environments/built-in-config.js +9 -6
  55. package/dataflow/environments/built-in.d.ts +8 -4
  56. package/dataflow/environments/built-in.js +47 -5
  57. package/dataflow/environments/default-builtin-config.d.ts +2 -0
  58. package/dataflow/environments/default-builtin-config.js +81 -14
  59. package/dataflow/environments/resolve-by-name.js +15 -4
  60. package/dataflow/extractor.js +2 -2
  61. package/dataflow/graph/dataflowgraph-builder.d.ts +3 -1
  62. package/dataflow/graph/dataflowgraph-builder.js +4 -2
  63. package/dataflow/graph/diff-dataflow-graph.d.ts +16 -0
  64. package/dataflow/graph/{diff.js → diff-dataflow-graph.js} +30 -56
  65. package/dataflow/graph/graph.d.ts +11 -3
  66. package/dataflow/graph/graph.js +27 -12
  67. package/dataflow/graph/vertex.d.ts +17 -2
  68. package/dataflow/internal/linker.d.ts +3 -2
  69. package/dataflow/internal/linker.js +33 -24
  70. package/dataflow/internal/process/functions/call/argument/unpack-argument.d.ts +1 -1
  71. package/dataflow/internal/process/functions/call/argument/unpack-argument.js +1 -1
  72. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +12 -9
  73. package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +1 -1
  74. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +84 -16
  75. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +23 -16
  76. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +5 -5
  77. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +9 -4
  78. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +3 -2
  79. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +15 -4
  80. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +4 -3
  81. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +4 -3
  82. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +4 -3
  83. package/dataflow/internal/process/functions/call/built-in/built-in-list.js +1 -1
  84. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +1 -1
  85. package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +9 -7
  86. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +3 -2
  87. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.d.ts +1 -0
  88. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +19 -4
  89. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +2 -2
  90. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +19 -4
  91. package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.js +4 -3
  92. package/dataflow/internal/process/functions/call/built-in/built-in-vector.js +3 -3
  93. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +3 -3
  94. package/dataflow/internal/process/functions/call/common.d.ts +4 -1
  95. package/dataflow/internal/process/functions/call/common.js +5 -3
  96. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +3 -2
  97. package/dataflow/internal/process/functions/call/known-call-handling.js +2 -1
  98. package/dataflow/internal/process/functions/call/named-call-handling.js +1 -1
  99. package/dataflow/internal/process/functions/call/unnamed-call-handling.d.ts +1 -0
  100. package/dataflow/internal/process/functions/call/unnamed-call-handling.js +6 -4
  101. package/dataflow/internal/process/process-named-call.d.ts +1 -1
  102. package/dataflow/internal/process/process-named-call.js +5 -5
  103. package/dataflow/origin/dfg-get-origin.d.ts +82 -0
  104. package/dataflow/origin/dfg-get-origin.js +116 -0
  105. package/documentation/doc-util/doc-cfg.d.ts +13 -6
  106. package/documentation/doc-util/doc-cfg.js +20 -15
  107. package/documentation/doc-util/doc-cli-option.js +4 -2
  108. package/documentation/doc-util/doc-dfg.js +3 -3
  109. package/documentation/doc-util/doc-escape.d.ts +7 -0
  110. package/documentation/doc-util/doc-escape.js +19 -0
  111. package/documentation/doc-util/doc-files.d.ts +1 -0
  112. package/documentation/doc-util/doc-files.js +2 -1
  113. package/documentation/doc-util/doc-normalized-ast.js +3 -3
  114. package/documentation/doc-util/doc-query.js +2 -2
  115. package/documentation/doc-util/doc-repl.js +1 -1
  116. package/documentation/doc-util/doc-search.js +1 -1
  117. package/documentation/doc-util/doc-server-message.js +2 -2
  118. package/documentation/doc-util/doc-structure.d.ts +1 -0
  119. package/documentation/doc-util/doc-structure.js +5 -0
  120. package/documentation/doc-util/doc-types.d.ts +7 -1
  121. package/documentation/doc-util/doc-types.js +13 -2
  122. package/documentation/print-capabilities-markdown.js +27 -1
  123. package/documentation/print-cfg-wiki.js +508 -20
  124. package/documentation/print-dataflow-graph-wiki.js +180 -25
  125. package/documentation/print-engines-wiki.js +1 -1
  126. package/documentation/print-faq-wiki.d.ts +1 -0
  127. package/documentation/print-faq-wiki.js +75 -0
  128. package/documentation/print-interface-wiki.js +1 -1
  129. package/documentation/print-linter-wiki.d.ts +1 -0
  130. package/documentation/print-linter-wiki.js +76 -0
  131. package/documentation/print-linting-and-testing-wiki.js +52 -36
  132. package/documentation/print-normalized-ast-wiki.js +1 -1
  133. package/documentation/print-onboarding-wiki.d.ts +1 -0
  134. package/documentation/print-onboarding-wiki.js +42 -0
  135. package/documentation/print-query-wiki.js +21 -1
  136. package/documentation/print-readme.js +10 -3
  137. package/linter/linter-executor.d.ts +9 -0
  138. package/linter/linter-executor.js +26 -0
  139. package/linter/linter-format.d.ts +65 -0
  140. package/linter/linter-format.js +9 -0
  141. package/linter/linter-rules.d.ts +42 -0
  142. package/linter/linter-rules.js +14 -0
  143. package/linter/rules/1-deprecated-functions.d.ts +34 -0
  144. package/linter/rules/1-deprecated-functions.js +54 -0
  145. package/linter/rules/2-file-path-validity.d.ts +48 -0
  146. package/linter/rules/2-file-path-validity.js +93 -0
  147. package/package.json +10 -6
  148. package/queries/catalog/call-context-query/call-context-query-executor.js +5 -5
  149. package/queries/catalog/call-context-query/call-context-query-format.d.ts +3 -3
  150. package/queries/catalog/call-context-query/call-context-query-format.js +7 -3
  151. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.d.ts +2 -2
  152. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +24 -21
  153. package/queries/catalog/cluster-query/cluster-query-format.d.ts +3 -1
  154. package/queries/catalog/cluster-query/cluster-query-format.js +6 -2
  155. package/queries/catalog/config-query/config-query-format.d.ts +2 -1
  156. package/queries/catalog/config-query/config-query-format.js +4 -3
  157. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.d.ts +2 -1
  158. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.js +4 -3
  159. package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +3 -1
  160. package/queries/catalog/dataflow-query/dataflow-query-format.js +11 -3
  161. package/queries/catalog/dependencies-query/dependencies-query-executor.js +4 -2
  162. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +2 -1
  163. package/queries/catalog/dependencies-query/dependencies-query-format.js +12 -3
  164. package/queries/catalog/happens-before-query/happens-before-query-executor.d.ts +1 -1
  165. package/queries/catalog/happens-before-query/happens-before-query-executor.js +4 -4
  166. package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +2 -1
  167. package/queries/catalog/happens-before-query/happens-before-query-format.js +4 -3
  168. package/queries/catalog/id-map-query/id-map-query-format.d.ts +2 -1
  169. package/queries/catalog/id-map-query/id-map-query-format.js +4 -3
  170. package/queries/catalog/lineage-query/lineage-query-format.d.ts +2 -1
  171. package/queries/catalog/lineage-query/lineage-query-format.js +7 -3
  172. package/queries/catalog/linter-query/linter-query-executor.d.ts +3 -0
  173. package/queries/catalog/linter-query/linter-query-executor.js +28 -0
  174. package/queries/catalog/linter-query/linter-query-format.d.ts +80 -0
  175. package/queries/catalog/linter-query/linter-query-format.js +43 -0
  176. package/queries/catalog/location-map-query/location-map-query-format.d.ts +2 -1
  177. package/queries/catalog/location-map-query/location-map-query-format.js +4 -3
  178. package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +2 -1
  179. package/queries/catalog/normalized-ast-query/normalized-ast-query-format.js +4 -3
  180. package/queries/catalog/origin-query/origin-query-executor.d.ts +5 -0
  181. package/queries/catalog/origin-query/origin-query-executor.js +33 -0
  182. package/queries/catalog/origin-query/origin-query-format.d.ts +73 -0
  183. package/queries/catalog/origin-query/origin-query-format.js +31 -0
  184. package/queries/catalog/project-query/project-query-executor.js +1 -1
  185. package/queries/catalog/project-query/project-query-format.d.ts +2 -1
  186. package/queries/catalog/project-query/project-query-format.js +4 -3
  187. package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +2 -1
  188. package/queries/catalog/resolve-value-query/resolve-value-query-format.js +4 -3
  189. package/queries/catalog/search-query/search-query-format.d.ts +2 -1
  190. package/queries/catalog/search-query/search-query-format.js +7 -3
  191. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +3 -1
  192. package/queries/catalog/static-slice-query/static-slice-query-format.js +11 -3
  193. package/queries/query-print.d.ts +1 -1
  194. package/queries/query-print.js +4 -4
  195. package/queries/query.d.ts +143 -2
  196. package/queries/query.js +5 -1
  197. package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +3 -2
  198. package/r-bridge/lang-4.x/ast/model/nodes/r-number.js +5 -0
  199. package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +3 -2
  200. package/r-bridge/lang-4.x/ast/model/nodes/r-string.js +5 -0
  201. package/r-bridge/lang-4.x/ast/model/processing/decorate.d.ts +1 -1
  202. package/r-bridge/lang-4.x/ast/model/processing/decorate.js +1 -1
  203. package/r-bridge/lang-4.x/ast/model/processing/fold.js +3 -1
  204. package/r-bridge/lang-4.x/ast/model/processing/stateful-fold.d.ts +1 -1
  205. package/r-bridge/lang-4.x/ast/parser/main/internal/expression/normalize-expression.js +1 -1
  206. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-argument.js +1 -1
  207. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.js +1 -1
  208. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-definition.js +1 -1
  209. package/r-bridge/lang-4.x/ast/parser/main/internal/normalize-access.js +1 -1
  210. package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-binary.js +1 -1
  211. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-root.js +1 -1
  212. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-symbol.js +1 -1
  213. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.d.ts +2 -2
  214. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +4 -4
  215. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +26 -8
  216. package/r-bridge/retriever.js +2 -2
  217. package/search/flowr-search-builder.d.ts +31 -2
  218. package/search/flowr-search-builder.js +30 -0
  219. package/search/flowr-search.d.ts +7 -1
  220. package/search/search-executor/search-enrichers.d.ts +73 -0
  221. package/search/search-executor/search-enrichers.js +98 -0
  222. package/search/search-executor/search-generators.d.ts +7 -2
  223. package/search/search-executor/search-generators.js +21 -1
  224. package/search/search-executor/search-mappers.d.ts +19 -0
  225. package/search/search-executor/search-mappers.js +21 -0
  226. package/search/search-executor/search-transformer.d.ts +13 -1
  227. package/search/search-executor/search-transformer.js +11 -1
  228. package/slicing/criterion/collect-all.js +1 -1
  229. package/slicing/static/slice-call.js +13 -3
  230. package/statistics/features/supported/assignments/post-process.js +1 -1
  231. package/statistics/features/supported/defined-functions/post-process.js +2 -2
  232. package/statistics/features/supported/used-functions/post-process.js +1 -1
  233. package/statistics/features/supported/used-packages/post-process.js +2 -2
  234. package/statistics/features/supported/values/post-process.js +2 -2
  235. package/statistics/output/print-stats.js +2 -2
  236. package/statistics/summarizer/post-process/clusterer.d.ts +1 -1
  237. package/statistics/summarizer/post-process/clusterer.js +1 -1
  238. package/statistics/summarizer/post-process/histogram.js +3 -3
  239. package/statistics/summarizer/post-process/post-process-output.js +3 -3
  240. package/statistics/summarizer/second-phase/process.js +2 -2
  241. package/statistics/summarizer/summarizer.js +2 -2
  242. package/util/assert.js +36 -1
  243. package/util/cfg/cfg.d.ts +0 -80
  244. package/util/cfg/cfg.js +0 -549
  245. package/util/{arrays.d.ts → collections/arrays.d.ts} +1 -1
  246. package/util/{arrays.js → collections/arrays.js} +3 -3
  247. package/util/collections/set.js +17 -0
  248. package/util/diff-graph.d.ts +47 -0
  249. package/util/diff-graph.js +61 -0
  250. package/util/diff.d.ts +6 -6
  251. package/util/diff.js +1 -1
  252. package/util/mermaid/cfg.d.ts +9 -2
  253. package/util/mermaid/cfg.js +64 -12
  254. package/util/mermaid/dfg.d.ts +2 -1
  255. package/util/mermaid/dfg.js +26 -10
  256. package/util/mermaid/mermaid.d.ts +2 -0
  257. package/util/mermaid/mermaid.js +6 -0
  258. package/util/quads.js +1 -1
  259. package/util/schema.d.ts +1 -1
  260. package/util/schema.js +1 -1
  261. package/util/summarizer.js +1 -1
  262. package/util/{text.js → text/text.js} +1 -1
  263. package/util/{time.js → text/time.js} +1 -1
  264. package/util/version.js +1 -1
  265. package/dataflow/graph/diff.d.ts +0 -36
  266. package/util/cfg/happens-before.d.ts +0 -7
  267. package/util/cfg/visitor.d.ts +0 -9
  268. package/util/cfg/visitor.js +0 -30
  269. package/util/set.js +0 -31
  270. /package/util/{bimap.d.ts → collections/bimap.d.ts} +0 -0
  271. /package/util/{bimap.js → collections/bimap.js} +0 -0
  272. /package/util/{defaultmap.d.ts → collections/defaultmap.d.ts} +0 -0
  273. /package/util/{defaultmap.js → collections/defaultmap.js} +0 -0
  274. /package/util/{set.d.ts → collections/set.d.ts} +0 -0
  275. /package/util/{ansi.d.ts → text/ansi.d.ts} +0 -0
  276. /package/util/{ansi.js → text/ansi.js} +0 -0
  277. /package/util/{args.d.ts → text/args.d.ts} +0 -0
  278. /package/util/{args.js → text/args.js} +0 -0
  279. /package/util/{strings.d.ts → text/strings.d.ts} +0 -0
  280. /package/util/{strings.js → text/strings.js} +0 -0
  281. /package/util/{text.d.ts → text/text.d.ts} +0 -0
  282. /package/util/{time.d.ts → text/time.d.ts} +0 -0
@@ -1,8 +1,8 @@
1
1
  import Parser from 'web-tree-sitter';
2
2
  import type { RParseRequest } from '../../retriever';
3
3
  import type { SyncParser } from '../../parser';
4
- export declare const DEFAULT_TREE_SITTER_R_WASM_PATH: string;
5
- export declare const DEFAULT_TREE_SITTER_WASM_PATH: string;
4
+ export declare const DEFAULT_TREE_SITTER_R_WASM_PATH = "./node_modules/@eagleoutice/tree-sitter-r/tree-sitter-r.wasm";
5
+ export declare const DEFAULT_TREE_SITTER_WASM_PATH = "./node_modules/web-tree-sitter/tree-sitter.wasm";
6
6
  /**
7
7
  * Synchronous and (way) faster alternative to the {@link RShell} using tree-sitter.
8
8
  */
@@ -8,8 +8,8 @@ const web_tree_sitter_1 = __importDefault(require("web-tree-sitter"));
8
8
  const fs_1 = __importDefault(require("fs"));
9
9
  const config_1 = require("../../../config");
10
10
  const log_1 = require("../../../util/log");
11
- exports.DEFAULT_TREE_SITTER_R_WASM_PATH = `${__dirname}/tree-sitter-r.wasm`;
12
- exports.DEFAULT_TREE_SITTER_WASM_PATH = `${__dirname}/tree-sitter.wasm`;
11
+ exports.DEFAULT_TREE_SITTER_R_WASM_PATH = './node_modules/@eagleoutice/tree-sitter-r/tree-sitter-r.wasm';
12
+ exports.DEFAULT_TREE_SITTER_WASM_PATH = './node_modules/web-tree-sitter/tree-sitter.wasm';
13
13
  const wasmLog = log_1.log.getSubLogger({ name: 'tree-sitter-wasm' });
14
14
  /**
15
15
  * Synchronous and (way) faster alternative to the {@link RShell} using tree-sitter.
@@ -27,13 +27,13 @@ class TreeSitterExecutor {
27
27
  const treeSitterWasmPath = overrideTreeSitterWasmPath ?? (0, config_1.getEngineConfig)('tree-sitter')?.treeSitterWasmPath ?? exports.DEFAULT_TREE_SITTER_WASM_PATH;
28
28
  // noinspection JSUnusedGlobalSymbols - this is used by emscripten, see https://emscripten.org/docs/api_reference/module.html
29
29
  await web_tree_sitter_1.default.init({
30
- locateFile: (path, prefix) => {
30
+ locateFile: treeSitterWasmPath ? (path, prefix) => {
31
31
  // allow setting a custom path for the tree sitter wasm file
32
32
  if (path.endsWith('tree-sitter.wasm')) {
33
33
  return treeSitterWasmPath;
34
34
  }
35
35
  return prefix + path;
36
- },
36
+ } : undefined,
37
37
  onAbort: (s) => wasmLog.error(`Tree-sitter wasm aborted: ${s}`),
38
38
  print: (s) => wasmLog.debug(s),
39
39
  printErr: (s) => wasmLog.error(s)
@@ -9,9 +9,9 @@ const type_1 = require("../ast/model/type");
9
9
  const retriever_1 = require("../../retriever");
10
10
  const convert_values_1 = require("../convert-values");
11
11
  const normalize_meta_1 = require("../ast/parser/main/normalize-meta");
12
- const arrays_1 = require("../../../util/arrays");
12
+ const arrays_1 = require("../../../util/collections/arrays");
13
13
  const r_function_call_1 = require("../ast/model/nodes/r-function-call");
14
- const strings_1 = require("../../../util/strings");
14
+ const strings_1 = require("../../../util/text/strings");
15
15
  const config_1 = require("../../../config");
16
16
  const log_1 = require("../../../util/log");
17
17
  /**
@@ -511,17 +511,35 @@ function convertTreeNode(node) {
511
511
  lexeme: node.text,
512
512
  ...defaultInfo
513
513
  };
514
+ case tree_sitter_types_1.TreeSitterType.Error:
515
+ return {
516
+ type: type_1.RType.ExpressionList,
517
+ location: undefined,
518
+ lexeme: undefined,
519
+ children: [],
520
+ grouping: undefined,
521
+ info: defaultInfo
522
+ };
514
523
  default:
515
524
  throw new normalizer_data_1.ParseError(`unexpected node type ${node.type} at ${JSON.stringify(range)}`);
516
525
  }
517
526
  }
518
527
  function makeSourceRange(node) {
519
- return [
520
- // tree-sitter is 0-based but we want 1-based
521
- node.startPosition.row + 1, node.startPosition.column + 1,
522
- // tree-sitter's end position is one off from ours, so we don't add 1 here
523
- node.endPosition.row + 1, node.endPosition.column
524
- ];
528
+ if (node.startPosition && node.endPosition) {
529
+ return [
530
+ // tree-sitter is 0-based but we want 1-based
531
+ node.startPosition.row + 1, node.startPosition.column + 1,
532
+ // tree-sitter's end position is one off from ours, so we don't add 1 here
533
+ node.endPosition.row + 1, node.endPosition.column
534
+ ];
535
+ }
536
+ else {
537
+ return [
538
+ (node.startPosition?.row ?? -2) + 1, (node.startPosition?.column ?? -2) + 1,
539
+ // tree-sitter's end position is one off from ours, so we don't add 1 here
540
+ (node.endPosition?.row ?? -2) + 1, node.endPosition?.column ?? -1
541
+ ];
542
+ }
525
543
  }
526
544
  function splitComments(nodes) {
527
545
  const comments = [];
@@ -12,7 +12,7 @@ exports.retrieveParseDataFromRCode = retrieveParseDataFromRCode;
12
12
  exports.retrieveNormalizedAstFromRCode = retrieveNormalizedAstFromRCode;
13
13
  exports.removeRQuotes = removeRQuotes;
14
14
  exports.retrieveNumberOfRTokensOfLastParse = retrieveNumberOfRTokensOfLastParse;
15
- const strings_1 = require("../util/strings");
15
+ const strings_1 = require("../util/text/strings");
16
16
  const assert_1 = require("../util/assert");
17
17
  const shell_executor_1 = require("./shell-executor");
18
18
  const parser_1 = require("./lang-4.x/ast/parser/json/parser");
@@ -72,7 +72,7 @@ function requestProviderFromText(text) {
72
72
  if (ignoreCase) {
73
73
  return Object.keys(text).find(p => p.toLowerCase() === path.toLowerCase());
74
74
  }
75
- return text[path] ? path : undefined;
75
+ return text[path] !== undefined ? path : undefined;
76
76
  },
77
77
  createRequest(path) {
78
78
  return {
@@ -1,10 +1,14 @@
1
1
  import type { NodeId } from '../r-bridge/lang-4.x/ast/model/processing/node-id';
2
- import type { FlowrSearchElement, FlowrSearchElements, FlowrSearchGetFilter } from './flowr-search';
2
+ import type { FlowrSearchElement, FlowrSearchElementFromQuery, FlowrSearchElements, FlowrSearchGetFilter } from './flowr-search';
3
3
  import type { FlowrFilterExpression } from './flowr-search-filters';
4
4
  import type { FlowrSearchGeneratorNode, GeneratorNames } from './search-executor/search-generators';
5
5
  import type { FlowrSearchTransformerNode, GetOutputOfTransformer, TransformerNames } from './search-executor/search-transformer';
6
6
  import type { SlicingCriteria } from '../slicing/criterion/parse';
7
7
  import type { ParentInformation } from '../r-bridge/lang-4.x/ast/model/processing/decorate';
8
+ import type { Enrichment, EnrichmentArguments } from './search-executor/search-enrichers';
9
+ import type { MapperArguments } from './search-executor/search-mappers';
10
+ import { Mapper } from './search-executor/search-mappers';
11
+ import type { Query } from '../queries/query';
8
12
  type FlowrCriteriaReturn<C extends SlicingCriteria> = FlowrSearchElements<ParentInformation, C extends [] ? never : C extends [infer _] ? [
9
13
  FlowrSearchElement<ParentInformation>
10
14
  ] : FlowrSearchElement<ParentInformation>[]>;
@@ -19,6 +23,12 @@ export declare const FlowrSearchGenerator: {
19
23
  * see {@link FlowrSearchGenerator.criterion} for a serializable alternative (passing the ids with `$id`).
20
24
  */
21
25
  readonly from: (from: FlowrSearchElement<ParentInformation> | FlowrSearchElement<ParentInformation>[]) => FlowrSearchBuilder<"from">;
26
+ /**
27
+ * Initializes a new search query based on the results of the given JSON query or queries.
28
+ * Internally, the {@link SupportedQuery#flattenInvolvedNodes} function is used to flatten the resulting nodes of the query.
29
+ * Please note that, due to the fact that not every query involves dataflow nodes, the search may not contain any elements at all for certain queries.
30
+ */
31
+ readonly fromQuery: (...from: readonly Query[]) => FlowrSearchBuilder<"from-query", [], ParentInformation, FlowrSearchElements<ParentInformation, FlowrSearchElementFromQuery<ParentInformation>[]>>;
22
32
  /**
23
33
  * Returns all elements (nodes/dataflow vertices) from the given data.
24
34
  */
@@ -71,6 +81,12 @@ export declare const Q: {
71
81
  * see {@link FlowrSearchGenerator.criterion} for a serializable alternative (passing the ids with `$id`).
72
82
  */
73
83
  readonly from: (from: FlowrSearchElement<ParentInformation> | FlowrSearchElement<ParentInformation>[]) => FlowrSearchBuilder<"from">;
84
+ /**
85
+ * Initializes a new search query based on the results of the given JSON query or queries.
86
+ * Internally, the {@link SupportedQuery#flattenInvolvedNodes} function is used to flatten the resulting nodes of the query.
87
+ * Please note that, due to the fact that not every query involves dataflow nodes, the search may not contain any elements at all for certain queries.
88
+ */
89
+ readonly fromQuery: (...from: readonly Query[]) => FlowrSearchBuilder<"from-query", [], ParentInformation, FlowrSearchElements<ParentInformation, FlowrSearchElementFromQuery<ParentInformation>[]>>;
74
90
  /**
75
91
  * Returns all elements (nodes/dataflow vertices) from the given data.
76
92
  */
@@ -168,6 +184,19 @@ export declare class FlowrSearchBuilder<Generator extends GeneratorNames, Transf
168
184
  * select returns only the elements at the given indices.
169
185
  */
170
186
  select<Select extends number[]>(...select: Select): FlowrSearchBuilderOut<Generator, Transformers, Info, 'select'>;
187
+ /**
188
+ * Adds the given enrichment to each element of the search.
189
+ * Added enrichments can later be retrieved using the {@link enrichmentContent} function.
190
+ */
191
+ with<ConcreteEnrichment extends Enrichment>(enrichment: ConcreteEnrichment, args?: EnrichmentArguments<ConcreteEnrichment>): FlowrSearchBuilderOut<Generator, Transformers, Info, 'with'>;
192
+ /**
193
+ * Maps the elements of the search to new values using the given mapper function.
194
+ */
195
+ map<MapperType extends Mapper>(mapper: MapperType, args: MapperArguments<MapperType>): FlowrSearchBuilderOut<Generator, Transformers, Info, 'map'>;
196
+ /**
197
+ * A convenience function that combines {@link with} and the {@link Mapper.Enrichment} mapper to immediately add an enrichment and then map to its value(s).
198
+ */
199
+ get<ConcreteEnrichment extends Enrichment>(enrichment: ConcreteEnrichment, args?: EnrichmentArguments<ConcreteEnrichment>): FlowrSearchBuilderOut<Generator, Transformers, Info, 'with' | 'map'>;
171
200
  /**
172
201
  * merge combines the search results with those of another search.
173
202
  */
@@ -183,7 +212,7 @@ export declare class FlowrSearchBuilder<Generator extends GeneratorNames, Transf
183
212
  * This type summarizes all types that can be used in places in which the API expects you to provide a search query.
184
213
  * @see {@link FlowrSearch}
185
214
  */
186
- export type FlowrSearchLike = FlowrSearch | FlowrSearchBuilderType;
215
+ export type FlowrSearchLike<Info = ParentInformation, Generator extends GeneratorNames = GeneratorNames, Transformers extends TransformerNames[] = TransformerNames[], ElementType = FlowrSearchElements<Info, FlowrSearchElement<Info>[]>> = FlowrSearch<Info, Generator, Transformers, ElementType> | FlowrSearchBuilderType<Generator, Transformers, Info, ElementType>;
187
216
  export type SearchOutput<Search> = Search extends FlowrSearch ? Search : Search extends FlowrSearchBuilderType<infer Generator, infer Transformers, infer Info, infer Elements> ? FlowrSearch<Info, Generator, Transformers, Elements> : never;
188
217
  /**
189
218
  * Freezes any accepted {@link FlowrSearchLike} into a {@link FlowrSearch}.
@@ -4,6 +4,7 @@ exports.FlowrSearchBuilder = exports.Q = exports.FlowrSearchGenerator = void 0;
4
4
  exports.getFlowrSearch = getFlowrSearch;
5
5
  const search_optimizer_1 = require("./search-optimizer/search-optimizer");
6
6
  const assert_1 = require("../util/assert");
7
+ const search_mappers_1 = require("./search-executor/search-mappers");
7
8
  /**
8
9
  * This object holds all the methods to generate search queries.
9
10
  * For compatibility, please use the {@link Q} identifier object to access these methods.
@@ -17,6 +18,14 @@ exports.FlowrSearchGenerator = {
17
18
  from(from) {
18
19
  return new FlowrSearchBuilder({ type: 'generator', name: 'from', args: { from } });
19
20
  },
21
+ /**
22
+ * Initializes a new search query based on the results of the given JSON query or queries.
23
+ * Internally, the {@link SupportedQuery#flattenInvolvedNodes} function is used to flatten the resulting nodes of the query.
24
+ * Please note that, due to the fact that not every query involves dataflow nodes, the search may not contain any elements at all for certain queries.
25
+ */
26
+ fromQuery(...from) {
27
+ return new FlowrSearchBuilder({ type: 'generator', name: 'from-query', args: { from } });
28
+ },
20
29
  /**
21
30
  * Returns all elements (nodes/dataflow vertices) from the given data.
22
31
  */
@@ -158,6 +167,27 @@ class FlowrSearchBuilder {
158
167
  this.search.push({ type: 'transformer', name: 'select', args: { select } });
159
168
  return this;
160
169
  }
170
+ /**
171
+ * Adds the given enrichment to each element of the search.
172
+ * Added enrichments can later be retrieved using the {@link enrichmentContent} function.
173
+ */
174
+ with(enrichment, args) {
175
+ this.search.push({ type: 'transformer', name: 'with', args: { info: enrichment, args: args } });
176
+ return this;
177
+ }
178
+ /**
179
+ * Maps the elements of the search to new values using the given mapper function.
180
+ */
181
+ map(mapper, args) {
182
+ this.search.push({ type: 'transformer', name: 'map', args: { mapper: mapper, args: args } });
183
+ return this;
184
+ }
185
+ /**
186
+ * A convenience function that combines {@link with} and the {@link Mapper.Enrichment} mapper to immediately add an enrichment and then map to its value(s).
187
+ */
188
+ get(enrichment, args) {
189
+ return this.with(enrichment, args).map(search_mappers_1.Mapper.Enrichment, enrichment);
190
+ }
161
191
  /**
162
192
  * merge combines the search results with those of another search.
163
193
  */
@@ -3,6 +3,8 @@ import type { Pipeline, PipelineOutput, PipelineStepOutputWithName } from '../co
3
3
  import type { NormalizedAst } from '../r-bridge/lang-4.x/ast/model/processing/decorate';
4
4
  import type { NodeId } from '../r-bridge/lang-4.x/ast/model/processing/node-id';
5
5
  import type { DataflowInformation } from '../dataflow/info';
6
+ import type { BaseQueryResult } from '../queries/base-query-format';
7
+ import type { Query } from '../queries/query';
6
8
  /**
7
9
  * Yes, for now we do technically not need a wrapper around the RNode, but this allows us to attach caches etc.
8
10
  * just for the respective search.
@@ -10,6 +12,10 @@ import type { DataflowInformation } from '../dataflow/info';
10
12
  export interface FlowrSearchElement<Info> {
11
13
  readonly node: RNode<Info>;
12
14
  }
15
+ export interface FlowrSearchElementFromQuery<Info> extends FlowrSearchElement<Info> {
16
+ readonly query: Query['type'];
17
+ readonly queryResult: BaseQueryResult;
18
+ }
13
19
  export interface FlowrSearchNodeBase<Type extends string, Name extends string, Args extends Record<string, unknown> | undefined> {
14
20
  readonly type: Type;
15
21
  readonly name: Name;
@@ -52,7 +58,7 @@ export declare class FlowrSearchElements<Info = NoInfo, Elements extends FlowrSe
52
58
  constructor(elements?: Elements);
53
59
  add(element: FlowrSearchElement<Info>): this;
54
60
  addAll(elements: FlowrSearchElement<Info>[]): this;
55
- getElements(): readonly FlowrSearchElement<Info>[];
61
+ getElements(): Readonly<Elements>;
56
62
  mutate<OutElements extends Elements>(mutator: (elements: Elements) => OutElements): this;
57
63
  }
58
64
  export {};
@@ -0,0 +1,73 @@
1
+ import type { FlowrSearchElement, FlowrSearchInput } from '../flowr-search';
2
+ import type { ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
3
+ import type { Pipeline } from '../../core/steps/pipeline/pipeline';
4
+ import type { MergeableRecord } from '../../util/objects';
5
+ import type { Identifier } from '../../dataflow/environments/identifier';
6
+ import type { LinkToLastCall } from '../../queries/catalog/call-context-query/call-context-query-format';
7
+ /**
8
+ * A {@link FlowrSearchElement} that is enriched with a set of enrichments through {@link FlowrSearchBuilder.with}.
9
+ * Enrichments can be retrieved easily from an element through {@link enrichmentContent}.
10
+ */
11
+ export interface EnrichedFlowrSearchElement<Info> extends FlowrSearchElement<Info> {
12
+ enrichments: {
13
+ [E in Enrichment]?: EnrichmentContent<E>;
14
+ };
15
+ }
16
+ export interface EnrichmentData<EnrichmentContent extends MergeableRecord, EnrichmentArguments = undefined> {
17
+ /**
18
+ * A function that is applied to each element of the search to enrich it with additional data.
19
+ */
20
+ readonly enrich: (e: FlowrSearchElement<ParentInformation>, data: FlowrSearchInput<Pipeline>, args: EnrichmentArguments | undefined) => EnrichmentContent;
21
+ /**
22
+ * The mapping function used by the {@link Mapper.Enrichment} mapper.
23
+ */
24
+ readonly mapper: (c: EnrichmentContent) => FlowrSearchElement<ParentInformation>[];
25
+ }
26
+ export type EnrichmentContent<E extends Enrichment> = typeof Enrichments[E] extends EnrichmentData<infer Content, infer _Args> ? Content : never;
27
+ export type EnrichmentArguments<E extends Enrichment> = typeof Enrichments[E] extends EnrichmentData<infer _Content, infer Args> ? Args : never;
28
+ /**
29
+ * An enumeration that stores the names of the available enrichments that can be applied to a set of search elements.
30
+ * See {@link FlowrSearchBuilder.with} for more information on how to apply enrichments.
31
+ */
32
+ export declare enum Enrichment {
33
+ CallTargets = "call-targets",
34
+ LastCall = "last-call"
35
+ }
36
+ export interface CallTargetsContent extends MergeableRecord {
37
+ /**
38
+ * The call targets of the function call.
39
+ * For identifier call targets, the identifier is the name of the library function being called.
40
+ */
41
+ targets: (FlowrSearchElement<ParentInformation> | Identifier)[];
42
+ }
43
+ export interface LastCallContent extends MergeableRecord {
44
+ linkedIds: FlowrSearchElement<ParentInformation>[];
45
+ }
46
+ /**
47
+ * The registry of enrichments that are currently supported by the search.
48
+ * See {@link FlowrSearchBuilder.with} for more information on how to apply enrichments.
49
+ */
50
+ export declare const Enrichments: {
51
+ readonly "call-targets": {
52
+ enrich: (e: FlowrSearchElement<ParentInformation>, data: import("../../core/steps/pipeline/pipeline").PipelineOutput<Pipeline<import("../../core/steps/pipeline-step").IPipelineStep<import("../../core/steps/pipeline-step").PipelineStepName, (...args: any[]) => any>>> & {
53
+ normalize: import("../../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
54
+ dataflow: import("../../dataflow/info").DataflowInformation;
55
+ }) => CallTargetsContent;
56
+ mapper: ({ targets }: CallTargetsContent) => FlowrSearchElement<ParentInformation>[];
57
+ };
58
+ readonly "last-call": {
59
+ enrich: (e: FlowrSearchElement<ParentInformation>, data: import("../../core/steps/pipeline/pipeline").PipelineOutput<Pipeline<import("../../core/steps/pipeline-step").IPipelineStep<import("../../core/steps/pipeline-step").PipelineStepName, (...args: any[]) => any>>> & {
60
+ normalize: import("../../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
61
+ dataflow: import("../../dataflow/info").DataflowInformation;
62
+ }, args: Omit<LinkToLastCall<string | RegExp>, "type">[] | undefined) => LastCallContent;
63
+ mapper: ({ linkedIds }: LastCallContent) => FlowrSearchElement<ParentInformation>[];
64
+ };
65
+ };
66
+ /**
67
+ * Returns the content of the given enrichment type from a {@link FlowrSearchElement}.
68
+ * If the search element is not enriched with the given enrichment, `undefined` is returned.
69
+ * @param e - The search element whose enrichment content should be retrieved.
70
+ * @param enrichment - The enrichment content, if present, else `undefined`.
71
+ */
72
+ export declare function enrichmentContent<E extends Enrichment>(e: FlowrSearchElement<ParentInformation>, enrichment: E): EnrichmentContent<E>;
73
+ export declare function enrich<ElementIn extends FlowrSearchElement<ParentInformation>, ElementOut extends ElementIn & EnrichedFlowrSearchElement<ParentInformation>, ConcreteEnrichment extends Enrichment>(e: ElementIn, data: FlowrSearchInput<Pipeline>, enrichment: ConcreteEnrichment, args?: EnrichmentArguments<ConcreteEnrichment>): ElementOut;
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Enrichments = exports.Enrichment = void 0;
4
+ exports.enrichmentContent = enrichmentContent;
5
+ exports.enrich = enrich;
6
+ const vertex_1 = require("../../dataflow/graph/vertex");
7
+ const log_1 = require("../../util/log");
8
+ const identify_link_to_last_call_relation_1 = require("../../queries/catalog/call-context-query/identify-link-to-last-call-relation");
9
+ const assert_1 = require("../../util/assert");
10
+ const extract_cfg_1 = require("../../control-flow/extract-cfg");
11
+ const dfg_get_origin_1 = require("../../dataflow/origin/dfg-get-origin");
12
+ /**
13
+ * An enumeration that stores the names of the available enrichments that can be applied to a set of search elements.
14
+ * See {@link FlowrSearchBuilder.with} for more information on how to apply enrichments.
15
+ */
16
+ var Enrichment;
17
+ (function (Enrichment) {
18
+ Enrichment["CallTargets"] = "call-targets";
19
+ Enrichment["LastCall"] = "last-call";
20
+ })(Enrichment || (exports.Enrichment = Enrichment = {}));
21
+ /**
22
+ * The registry of enrichments that are currently supported by the search.
23
+ * See {@link FlowrSearchBuilder.with} for more information on how to apply enrichments.
24
+ */
25
+ exports.Enrichments = {
26
+ [Enrichment.CallTargets]: {
27
+ enrich: (e, data) => {
28
+ // we don't resolve aliases here yet!
29
+ const content = { targets: [] };
30
+ const callVertex = data.dataflow.graph.getVertex(e.node.info.id);
31
+ if (callVertex?.tag === vertex_1.VertexType.FunctionCall) {
32
+ const origins = (0, dfg_get_origin_1.getOriginInDfg)(data.dataflow.graph, callVertex.id);
33
+ if (!origins || origins.length === 0) {
34
+ log_1.log.warn(`No origin found for call vertex ${callVertex.id}, cannot resolve call targets.`);
35
+ return content;
36
+ }
37
+ // find call targets in user code (which have ids!)
38
+ content.targets = content.targets.concat(origins.map(o => {
39
+ switch (o.type) {
40
+ case 2 /* OriginType.FunctionCallOrigin */:
41
+ return {
42
+ node: data.normalize.idMap.get(o.id),
43
+ };
44
+ case 3 /* OriginType.BuiltInFunctionOrigin */:
45
+ return o.fn.name;
46
+ default:
47
+ return undefined;
48
+ }
49
+ }).filter(assert_1.isNotUndefined));
50
+ }
51
+ return content;
52
+ },
53
+ // as built-in call target enrichments are not nodes, we don't return them as part of the mapper!
54
+ mapper: ({ targets }) => targets.map(t => t).filter(t => t.node !== undefined)
55
+ },
56
+ [Enrichment.LastCall]: {
57
+ enrich: (e, data, args) => {
58
+ (0, assert_1.guard)(args && args.length, `${Enrichment.LastCall} enrichment requires at least one argument`);
59
+ const content = { linkedIds: [] };
60
+ const vertex = data.dataflow.graph.get(e.node.info.id);
61
+ if (vertex !== undefined && vertex[0].tag === vertex_1.VertexType.FunctionCall) {
62
+ const cfg = (0, extract_cfg_1.extractSimpleCfg)(data.normalize);
63
+ for (const arg of args) {
64
+ const lastCalls = (0, identify_link_to_last_call_relation_1.identifyLinkToLastCallRelation)(vertex[0].id, cfg.graph, data.dataflow.graph, {
65
+ ...arg,
66
+ callName: new RegExp(arg.callName),
67
+ type: 'link-to-last-call',
68
+ });
69
+ for (const lastCall of lastCalls) {
70
+ content.linkedIds.push({ node: data.normalize.idMap.get(lastCall) });
71
+ }
72
+ }
73
+ }
74
+ return content;
75
+ },
76
+ mapper: ({ linkedIds }) => linkedIds
77
+ },
78
+ };
79
+ /**
80
+ * Returns the content of the given enrichment type from a {@link FlowrSearchElement}.
81
+ * If the search element is not enriched with the given enrichment, `undefined` is returned.
82
+ * @param e - The search element whose enrichment content should be retrieved.
83
+ * @param enrichment - The enrichment content, if present, else `undefined`.
84
+ */
85
+ function enrichmentContent(e, enrichment) {
86
+ return e?.enrichments?.[enrichment];
87
+ }
88
+ function enrich(e, data, enrichment, args) {
89
+ const enrichmentData = exports.Enrichments[enrichment];
90
+ return {
91
+ ...e,
92
+ enrichments: {
93
+ ...e?.enrichments ?? {},
94
+ [enrichment]: enrichmentData.enrich(e, data, args)
95
+ }
96
+ };
97
+ }
98
+ //# sourceMappingURL=search-enrichers.js.map
@@ -1,9 +1,10 @@
1
- import type { FlowrSearchElement, FlowrSearchGeneratorNodeBase, FlowrSearchGetFilter, FlowrSearchInput } from '../flowr-search';
1
+ import type { FlowrSearchElement, FlowrSearchElementFromQuery, FlowrSearchGeneratorNodeBase, FlowrSearchGetFilter, FlowrSearchInput } from '../flowr-search';
2
2
  import { FlowrSearchElements } from '../flowr-search';
3
3
  import type { Pipeline } from '../../core/steps/pipeline/pipeline';
4
- import type { TailTypesOrUndefined } from '../../util/arrays';
4
+ import type { TailTypesOrUndefined } from '../../util/collections/arrays';
5
5
  import type { ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
6
6
  import type { SlicingCriteria } from '../../slicing/criterion/parse';
7
+ import type { Query } from '../../queries/query';
7
8
  /**
8
9
  * This is a union of all possible generator node types
9
10
  */
@@ -22,6 +23,7 @@ export declare const generators: {
22
23
  readonly get: typeof generateGet;
23
24
  readonly criterion: typeof generateCriterion;
24
25
  readonly from: typeof generateFrom;
26
+ readonly 'from-query': typeof generateFromQuery;
25
27
  };
26
28
  declare function generateAll(data: FlowrSearchInput<Pipeline>): FlowrSearchElements<ParentInformation>;
27
29
  declare function generateGet(data: FlowrSearchInput<Pipeline>, { filter: { line, column, id, name, nameIsRegex } }: {
@@ -30,6 +32,9 @@ declare function generateGet(data: FlowrSearchInput<Pipeline>, { filter: { line,
30
32
  declare function generateFrom(data: FlowrSearchInput<Pipeline>, args: {
31
33
  from: FlowrSearchElement<ParentInformation> | FlowrSearchElement<ParentInformation>[];
32
34
  }): FlowrSearchElements<ParentInformation>;
35
+ declare function generateFromQuery(data: FlowrSearchInput<Pipeline>, args: {
36
+ from: readonly Query[];
37
+ }): FlowrSearchElements<ParentInformation, FlowrSearchElementFromQuery<ParentInformation>[]>;
33
38
  declare function generateCriterion(data: FlowrSearchInput<Pipeline>, args: {
34
39
  criterion: SlicingCriteria;
35
40
  }): FlowrSearchElements<ParentInformation>;
@@ -5,6 +5,7 @@ exports.getGenerator = getGenerator;
5
5
  const flowr_search_1 = require("../flowr-search");
6
6
  const parse_1 = require("../../slicing/criterion/parse");
7
7
  const assert_1 = require("../../util/assert");
8
+ const query_1 = require("../../queries/query");
8
9
  /**
9
10
  * All supported generators!
10
11
  */
@@ -12,7 +13,8 @@ exports.generators = {
12
13
  all: generateAll,
13
14
  get: generateGet,
14
15
  criterion: generateCriterion,
15
- from: generateFrom
16
+ from: generateFrom,
17
+ 'from-query': generateFromQuery
16
18
  };
17
19
  function generateAll(data) {
18
20
  return new flowr_search_1.FlowrSearchElements(getAllNodes(data)
@@ -52,6 +54,24 @@ function generateGet(data, { filter: { line, column, id, name, nameIsRegex } })
52
54
  function generateFrom(data, args) {
53
55
  return new flowr_search_1.FlowrSearchElements(Array.isArray(args.from) ? args.from : [args.from]);
54
56
  }
57
+ function generateFromQuery(data, args) {
58
+ const nodes = new Set();
59
+ const result = (0, query_1.executeQueries)({ ast: data.normalize, dataflow: data.dataflow }, args.from);
60
+ for (const [query, content] of Object.entries(result)) {
61
+ if (query === '.meta') {
62
+ continue;
63
+ }
64
+ const queryDef = query_1.SupportedQueries[query];
65
+ for (const node of queryDef.flattenInvolvedNodes(content)) {
66
+ nodes.add({
67
+ node: data.normalize.idMap.get(node),
68
+ query: query,
69
+ queryResult: content
70
+ });
71
+ }
72
+ }
73
+ return new flowr_search_1.FlowrSearchElements([...nodes]);
74
+ }
55
75
  function generateCriterion(data, args) {
56
76
  return new flowr_search_1.FlowrSearchElements(args.criterion.map(c => ({ node: data.normalize.idMap.get((0, parse_1.slicingCriterionToId)(c, data.normalize.idMap)) })));
57
77
  }
@@ -0,0 +1,19 @@
1
+ import type { FlowrSearchElement, FlowrSearchInput } from '../flowr-search';
2
+ import type { ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
3
+ import type { Enrichment } from './search-enrichers';
4
+ import type { MergeableRecord } from '../../util/objects';
5
+ import type { Pipeline } from '../../core/steps/pipeline/pipeline';
6
+ export declare enum Mapper {
7
+ Enrichment = "enrichment"
8
+ }
9
+ export interface MapperData<Arguments extends string | MergeableRecord> {
10
+ mapper: (e: FlowrSearchElement<ParentInformation>, data: FlowrSearchInput<Pipeline>, args: Arguments) => FlowrSearchElement<ParentInformation>[];
11
+ }
12
+ export type MapperArguments<M extends Mapper> = typeof Mappers[M] extends MapperData<infer Arguments> ? Arguments : never;
13
+ declare const Mappers: {
14
+ readonly enrichment: {
15
+ mapper: (e: FlowrSearchElement<ParentInformation>, _data: FlowrSearchInput<Pipeline>, enrichment: Enrichment) => FlowrSearchElement<ParentInformation>[];
16
+ };
17
+ };
18
+ export declare function map<Element extends FlowrSearchElement<ParentInformation>, MapperType extends Mapper>(e: Element, data: FlowrSearchInput<Pipeline>, mapper: MapperType, args: MapperArguments<MapperType>): Element[];
19
+ export {};
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Mapper = void 0;
4
+ exports.map = map;
5
+ const search_enrichers_1 = require("./search-enrichers");
6
+ var Mapper;
7
+ (function (Mapper) {
8
+ Mapper["Enrichment"] = "enrichment";
9
+ })(Mapper || (exports.Mapper = Mapper = {}));
10
+ const Mappers = {
11
+ [Mapper.Enrichment]: {
12
+ mapper: (e, _data, enrichment) => {
13
+ const data = (0, search_enrichers_1.enrichmentContent)(e, enrichment);
14
+ return data !== undefined ? search_enrichers_1.Enrichments[enrichment].mapper(data) : [];
15
+ }
16
+ }
17
+ };
18
+ function map(e, data, mapper, args) {
19
+ return Mappers[mapper].mapper(e, data, args);
20
+ }
21
+ //# sourceMappingURL=search-mappers.js.map
@@ -1,9 +1,11 @@
1
1
  import type { FlowrSearchElement, FlowrSearchElements, FlowrSearchInput, FlowrSearchTransformerNodeBase } from '../flowr-search';
2
2
  import type { Pipeline } from '../../core/steps/pipeline/pipeline';
3
- import type { LastOfArray, Tail2TypesOrUndefined, TailOfArray } from '../../util/arrays';
3
+ import type { LastOfArray, Tail2TypesOrUndefined, TailOfArray } from '../../util/collections/arrays';
4
4
  import type { FlowrFilterExpression } from '../flowr-search-filters';
5
5
  import type { FlowrSearchGeneratorNode } from './search-generators';
6
6
  import type { ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
7
+ import type { EnrichedFlowrSearchElement, Enrichment, EnrichmentArguments } from './search-enrichers';
8
+ import type { Mapper, MapperArguments } from './search-mappers';
7
9
  /**
8
10
  * This is a union of all possible transformer node types
9
11
  */
@@ -28,6 +30,8 @@ export declare const transformers: {
28
30
  readonly filter: typeof getFilter;
29
31
  readonly merge: typeof getMerge;
30
32
  readonly select: typeof getSelect;
33
+ readonly with: typeof getWith;
34
+ readonly map: typeof getMap;
31
35
  };
32
36
  export declare function getTransformer<Name extends TransformerNames>(name: Name): typeof transformers[Name];
33
37
  /** If we already have no more elements, cascade will not add any but keep the empty elements, otherwise it will now be NewElements */
@@ -50,6 +54,14 @@ declare function getSkip<Elements extends FlowrSearchElement<ParentInformation>[
50
54
  declare function getFilter<Elements extends FlowrSearchElement<ParentInformation>[], FSE extends FlowrSearchElements<ParentInformation, Elements>>(data: FlowrSearchInput<Pipeline>, elements: FSE, { filter }: {
51
55
  filter: FlowrFilterExpression;
52
56
  }): CascadeEmpty<Elements, Elements | []>;
57
+ declare function getWith<Elements extends FlowrSearchElement<ParentInformation>[], FSE extends FlowrSearchElements<ParentInformation, Elements>>(data: FlowrSearchInput<Pipeline>, elements: FSE, { info, args }: {
58
+ info: Enrichment;
59
+ args?: EnrichmentArguments<Enrichment>;
60
+ }): FlowrSearchElements<ParentInformation, EnrichedFlowrSearchElement<ParentInformation>[]>;
61
+ declare function getMap<Elements extends FlowrSearchElement<ParentInformation>[], FSE extends FlowrSearchElements<ParentInformation, Elements>>(data: FlowrSearchInput<Pipeline>, elements: FSE, { mapper, args }: {
62
+ mapper: Mapper;
63
+ args: MapperArguments<Mapper>;
64
+ }): FlowrSearchElements<ParentInformation, Elements>;
53
65
  declare function getMerge<Elements extends FlowrSearchElement<ParentInformation>[], FSE extends FlowrSearchElements<ParentInformation, Elements>>(data: FlowrSearchInput<Pipeline>, elements: FSE, other: {
54
66
  search: unknown[];
55
67
  generator: FlowrSearchGeneratorNode;
@@ -5,6 +5,8 @@ exports.getTransformer = getTransformer;
5
5
  const flowr_search_filters_1 = require("../flowr-search-filters");
6
6
  const flowr_search_executor_1 = require("../flowr-search-executor");
7
7
  const assert_1 = require("../../util/assert");
8
+ const search_enrichers_1 = require("./search-enrichers");
9
+ const search_mappers_1 = require("./search-mappers");
8
10
  /**
9
11
  * All supported generators!
10
12
  */
@@ -17,7 +19,9 @@ exports.transformers = {
17
19
  skip: getSkip,
18
20
  filter: getFilter,
19
21
  merge: getMerge,
20
- select: getSelect
22
+ select: getSelect,
23
+ with: getWith,
24
+ map: getMap
21
25
  };
22
26
  function getTransformer(name) {
23
27
  if (!exports.transformers[name]) {
@@ -90,6 +94,12 @@ function getSkip(data, elements, { count }) {
90
94
  function getFilter(data, elements, { filter }) {
91
95
  return elements.mutate(e => e.filter(({ node }) => (0, flowr_search_filters_1.evalFilter)(filter, { node, normalize: data.normalize, dataflow: data.dataflow })));
92
96
  }
97
+ function getWith(data, elements, { info, args }) {
98
+ return elements.mutate(elements => elements.map(e => (0, search_enrichers_1.enrich)(e, data, info, args)));
99
+ }
100
+ function getMap(data, elements, { mapper, args }) {
101
+ return elements.mutate(elements => elements.flatMap(e => (0, search_mappers_1.map)(e, data, mapper, args)));
102
+ }
93
103
  function getMerge(
94
104
  /* search has to be unknown because it is a recursive type */
95
105
  data, elements, other) {
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.collectAllSlicingCriteria = collectAllSlicingCriteria;
4
4
  const assert_1 = require("../../util/assert");
5
- const arrays_1 = require("../../util/arrays");
5
+ const arrays_1 = require("../../util/collections/arrays");
6
6
  const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
7
7
  /**
8
8
  * Will create all possible slicing criteria for the given ast, based on the {@link SlicingCriteriaFilter}.