@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
package/queries/query.js CHANGED
@@ -53,7 +53,7 @@ exports.SupportedQueries = {
53
53
  'origin': origin_query_format_1.OriginQueryDefinition,
54
54
  'linter': linter_query_format_1.LinterQueryDefinition
55
55
  };
56
- function executeQueriesOfSameType(data, queries) {
56
+ async function executeQueriesOfSameType(data, queries) {
57
57
  (0, assert_1.guard)(queries.length > 0, 'At least one query must be provided');
58
58
  /* every query must have the same type */
59
59
  (0, assert_1.guard)(queries.every(q => q.type === queries[0].type), 'All queries must have the same type');
@@ -5,8 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.TreeSitterExecutor = exports.DEFAULT_TREE_SITTER_WASM_PATH = exports.DEFAULT_TREE_SITTER_R_WASM_PATH = void 0;
7
7
  const web_tree_sitter_1 = __importDefault(require("web-tree-sitter"));
8
- const fs_1 = __importDefault(require("fs"));
9
8
  const log_1 = require("../../../util/log");
9
+ const fs_1 = __importDefault(require("fs"));
10
10
  exports.DEFAULT_TREE_SITTER_R_WASM_PATH = './node_modules/@eagleoutice/tree-sitter-r/tree-sitter-r.wasm';
11
11
  exports.DEFAULT_TREE_SITTER_WASM_PATH = './node_modules/web-tree-sitter/tree-sitter.wasm';
12
12
  const wasmLog = log_1.log.getSubLogger({ name: 'tree-sitter-wasm' });
@@ -2,16 +2,24 @@ import { type RShell } from './shell';
2
2
  import type { AsyncOrSync } from 'ts-essentials';
3
3
  import { RShellExecutor } from './shell-executor';
4
4
  import type { NormalizedAst } from './lang-4.x/ast/model/processing/decorate';
5
+ import type { SupportedFormats } from '../util/formats/adapter-format';
5
6
  export declare const fileProtocol = "file://";
6
- export interface RParseRequestFromFile {
7
+ export interface ParseRequestAdditionalInfoBase {
8
+ type: SupportedFormats;
9
+ }
10
+ export interface RParseRequestFromFile<AdditionalInfo extends ParseRequestAdditionalInfoBase = ParseRequestAdditionalInfoBase> {
7
11
  readonly request: 'file';
8
12
  /**
9
13
  * The path to the file (an absolute path is probably best here).
10
14
  * See {@link RParseRequests} for multiple files.
11
15
  */
12
16
  readonly content: string;
17
+ /**
18
+ * Additional info from different file formates like .Rmd
19
+ */
20
+ readonly info?: AdditionalInfo;
13
21
  }
14
- export interface RParseRequestFromText {
22
+ export interface RParseRequestFromText<AdditionalInfo extends ParseRequestAdditionalInfoBase = ParseRequestAdditionalInfoBase> {
15
23
  readonly request: 'text';
16
24
  /**
17
25
  * Source code to parse (not a file path).
@@ -20,6 +28,10 @@ export interface RParseRequestFromText {
20
28
  * or concatenate their contents to pass them with this request.
21
29
  */
22
30
  readonly content: string;
31
+ /**
32
+ * Additional info from different file formates like .Rmd
33
+ */
34
+ readonly info?: AdditionalInfo;
23
35
  }
24
36
  /**
25
37
  * A provider for an {@link RParseRequests} that can be used, for example, to override source file parsing behavior in tests
@@ -34,6 +46,7 @@ export type RParseRequest = RParseRequestFromFile | RParseRequestFromText;
34
46
  * Several requests that can be passed along to {@link retrieveParseDataFromRCode}.
35
47
  */
36
48
  export type RParseRequests = RParseRequest | ReadonlyArray<RParseRequest>;
49
+ export declare function isParseRequest(request: unknown): request is RParseRequest;
37
50
  export declare function requestFromInput(input: `${typeof fileProtocol}${string}`): RParseRequestFromFile;
38
51
  export declare function requestFromInput(input: `${typeof fileProtocol}${string}`[]): RParseRequestFromFile[];
39
52
  export declare function requestFromInput(input: string): RParseRequestFromText;
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.fileProtocol = void 0;
7
+ exports.isParseRequest = isParseRequest;
7
8
  exports.requestFromInput = requestFromInput;
8
9
  exports.requestProviderFromFile = requestProviderFromFile;
9
10
  exports.requestProviderFromText = requestProviderFromText;
@@ -22,23 +23,32 @@ const decorate_1 = require("./lang-4.x/ast/model/processing/decorate");
22
23
  const type_1 = require("./lang-4.x/ast/model/type");
23
24
  const fs_1 = __importDefault(require("fs"));
24
25
  const path_1 = __importDefault(require("path"));
26
+ const adapter_1 = require("../util/formats/adapter");
25
27
  exports.fileProtocol = 'file://';
28
+ function isParseRequest(request) {
29
+ if (typeof request !== 'object' || request === null) {
30
+ return false;
31
+ }
32
+ return 'request' in request;
33
+ }
26
34
  /**
27
35
  * Creates a {@link RParseRequests} from a given input.
28
36
  * If your input starts with {@link fileProtocol}, it is assumed to be a file path and will be processed as such.
29
37
  * Giving an array, you can mix file paths and text content (again using the {@link fileProtocol}).
30
38
  *
31
39
  */
32
- function requestFromInput(input) {
40
+ function requestFromInput(input, fileTypeHint) {
33
41
  if (Array.isArray(input)) {
34
42
  return input.flatMap(requestFromInput);
35
43
  }
36
44
  const content = input;
37
45
  const file = content.startsWith(exports.fileProtocol);
38
- return {
39
- request: file ? 'file' : 'text',
40
- content: file ? content.slice(7) : content
41
- };
46
+ if (file) {
47
+ return (0, adapter_1.requestFromFile)(content.slice(7));
48
+ }
49
+ else {
50
+ return (0, adapter_1.requestFromText)(content, fileTypeHint);
51
+ }
42
52
  }
43
53
  function requestProviderFromFile() {
44
54
  return {
@@ -1,9 +1,7 @@
1
1
  import type { FlowrSearch, FlowrSearchLike, SearchOutput } from './flowr-search-builder';
2
- import type { FlowrSearchInput } from './flowr-search';
3
- import type { Pipeline } from '../core/steps/pipeline/pipeline';
4
- type GetSearchElements<S> = S extends FlowrSearch<infer _, infer _, infer _, infer Elements> ? Elements : never;
2
+ import type { FlowrAnalysisProvider } from '../project/flowr-analyzer';
3
+ export type GetSearchElements<S> = S extends FlowrSearch<infer _, infer _, infer _, infer Elements> ? Elements : never;
5
4
  /**
6
5
  * Run a search with the given search query and data.
7
6
  */
8
- export declare function runSearch<S extends FlowrSearchLike, P extends Pipeline>(search: S, data: FlowrSearchInput<P>): GetSearchElements<SearchOutput<S>>;
9
- export {};
7
+ export declare function runSearch<S extends FlowrSearchLike>(search: S, input: FlowrAnalysisProvider): Promise<GetSearchElements<SearchOutput<S>>>;
@@ -7,10 +7,12 @@ const search_transformer_1 = require("./search-executor/search-transformer");
7
7
  /**
8
8
  * Run a search with the given search query and data.
9
9
  */
10
- function runSearch(search, data) {
10
+ async function runSearch(search, input) {
11
11
  const s = (0, flowr_search_builder_1.getFlowrSearch)(search);
12
- return s.search.reduce((acc, transformer) => (0, search_transformer_1.getTransformer)(transformer.name)(data, acc, transformer.args),
13
- /* support multiple arguments may be abstracted away in search frontend */
14
- (0, search_generators_1.getGenerator)(s.generator.name)(data, s.generator.args));
12
+ let acc = await (0, search_generators_1.getGenerator)(s.generator.name)(input, s.generator.args);
13
+ for (const transformer of s.search) {
14
+ acc = await (0, search_transformer_1.getTransformer)(transformer.name)(input, acc, transformer.args);
15
+ }
16
+ return acc;
15
17
  }
16
18
  //# sourceMappingURL=flowr-search-executor.js.map
@@ -1,10 +1,10 @@
1
1
  import { RType } from '../r-bridge/lang-4.x/ast/model/type';
2
2
  import { VertexType } from '../dataflow/graph/vertex';
3
3
  import type { ParentInformation } from '../r-bridge/lang-4.x/ast/model/processing/decorate';
4
- import type { FlowrSearchElement, FlowrSearchInput } from './flowr-search';
4
+ import type { FlowrSearchElement } from './flowr-search';
5
5
  import type { Enrichment } from './search-executor/search-enrichers';
6
6
  import type { BuiltInMappingName } from '../dataflow/environments/built-in';
7
- import type { Pipeline } from '../core/steps/pipeline/pipeline';
7
+ import type { DataflowInformation } from '../dataflow/info';
8
8
  export type FlowrFilterName = keyof typeof FlowrFilters;
9
9
  interface FlowrFilterWithArgs<Filter extends FlowrFilterName, Args extends FlowrFilterArgs<Filter>> {
10
10
  name: Filter;
@@ -28,7 +28,9 @@ export declare enum FlowrFilter {
28
28
  */
29
29
  OriginKind = "origin-kind"
30
30
  }
31
- export type FlowrFilterFunction<T> = (e: FlowrSearchElement<ParentInformation>, args: T, data: FlowrSearchInput<Pipeline>) => boolean;
31
+ export type FlowrFilterFunction<T> = (e: FlowrSearchElement<ParentInformation>, args: T, data: {
32
+ dataflow: DataflowInformation;
33
+ }) => boolean;
32
34
  export declare const ValidFlowrFilters: Set<string>;
33
35
  export declare const ValidFlowrFiltersReverse: {
34
36
  [k: string]: string;
@@ -36,7 +38,9 @@ export declare const ValidFlowrFiltersReverse: {
36
38
  export declare const FlowrFilters: {
37
39
  readonly "drop-empty-arguments": (e: FlowrSearchElement<ParentInformation>, _args: never) => boolean;
38
40
  readonly "matches-enrichment": (e: FlowrSearchElement<ParentInformation>, args: MatchesEnrichmentArgs<Enrichment>) => boolean;
39
- readonly "origin-kind": (e: FlowrSearchElement<ParentInformation>, args: OriginKindArgs, data: FlowrSearchInput<Pipeline>) => boolean;
41
+ readonly "origin-kind": (e: FlowrSearchElement<ParentInformation>, args: OriginKindArgs, data: {
42
+ dataflow: DataflowInformation;
43
+ }) => boolean;
40
44
  };
41
45
  export type FlowrFilterArgs<F extends FlowrFilter> = typeof FlowrFilters[F] extends FlowrFilterFunction<infer Args> ? Args : never;
42
46
  export interface MatchesEnrichmentArgs<E extends Enrichment> {
@@ -48,7 +52,7 @@ export interface OriginKindArgs {
48
52
  matchType?: 'some' | 'every';
49
53
  keepNonFunctionCalls?: boolean;
50
54
  }
51
- export declare function testFunctionsIgnoringPackage(functions: string[]): RegExp;
55
+ export declare function testFunctionsIgnoringPackage(functions: readonly string[]): RegExp;
52
56
  type ValidFilterTypes<F extends FlowrFilter = FlowrFilter> = FlowrFilterName | FlowrFilterWithArgs<F, FlowrFilterArgs<F>> | RType | VertexType;
53
57
  /**
54
58
  * By default, we provide filter for every {@link RType} and {@link VertexType}.
@@ -102,7 +106,9 @@ export declare function isBinaryTree(tree: unknown): tree is {
102
106
  };
103
107
  interface FilterData {
104
108
  readonly element: FlowrSearchElement<ParentInformation>;
105
- readonly data: FlowrSearchInput<Pipeline>;
109
+ readonly data: {
110
+ dataflow: DataflowInformation;
111
+ };
106
112
  }
107
113
  export declare function evalFilter<Filter extends FlowrFilter>(filter: FlowrFilterExpression<Filter>, data: FilterData): boolean;
108
114
  export {};
@@ -156,7 +156,7 @@ const evalVisit = {
156
156
  xor: ({ left, right }, data) => evalTree(left, data) !== evalTree(right, data),
157
157
  not: ({ operand }, data) => !evalTree(operand, data),
158
158
  'r-type': ({ value }, { element }) => element.node.type === value,
159
- 'vertex-type': ({ value }, { data: { dataflow }, element }) => dataflow.graph.getVertex(element.node.info.id)?.tag === value,
159
+ 'vertex-type': ({ value }, { data, element }) => data.dataflow.graph.getVertex(element.node.info.id)?.tag === value,
160
160
  'special': ({ value }, { data, element }) => {
161
161
  const name = typeof value === 'string' ? value : value.name;
162
162
  const args = typeof value === 'string' ? undefined : value.args;
@@ -1,10 +1,7 @@
1
1
  import type { NoInfo, RNode } from '../r-bridge/lang-4.x/ast/model/model';
2
- import type { Pipeline, PipelineOutput, PipelineStepOutputWithName } from '../core/steps/pipeline/pipeline';
3
- import type { NormalizedAst } from '../r-bridge/lang-4.x/ast/model/processing/decorate';
4
2
  import type { NodeId } from '../r-bridge/lang-4.x/ast/model/processing/node-id';
5
- import type { DataflowInformation } from '../dataflow/info';
6
- import type { FlowrConfigOptions } from '../config';
7
- import type { Enrichment, EnrichmentSearchArguments, EnrichmentElementContent, EnrichmentSearchContent } from './search-executor/search-enrichers';
3
+ import type { Enrichment, EnrichmentElementContent, EnrichmentSearchArguments, EnrichmentSearchContent } from './search-executor/search-enrichers';
4
+ import type { FlowrAnalysisProvider } from '../project/flowr-analyzer';
8
5
  /**
9
6
  * Yes, for now we do technically not need a wrapper around the RNode, but this allows us to attach caches etc.
10
7
  * just for the respective search.
@@ -45,13 +42,6 @@ export interface FlowrSearchGetFilter extends Record<string, unknown> {
45
42
  */
46
43
  readonly id?: NodeId;
47
44
  }
48
- type MinimumInputForFlowrSearch<P extends Pipeline> = PipelineStepOutputWithName<P, 'normalize'> extends NormalizedAst ? (PipelineStepOutputWithName<P, 'dataflow'> extends DataflowInformation ? PipelineOutput<P> & {
49
- normalize: NormalizedAst;
50
- dataflow: DataflowInformation;
51
- config: FlowrConfigOptions;
52
- } : never) : never;
53
- /** we allow any pipeline, which provides us with a 'normalize' and 'dataflow' step */
54
- export type FlowrSearchInput<P extends Pipeline> = MinimumInputForFlowrSearch<P>;
55
45
  /** Intentionally, we abstract away from an array to avoid the use of conventional typescript operations */
56
46
  export declare class FlowrSearchElements<Info = NoInfo, Elements extends FlowrSearchElement<Info>[] = FlowrSearchElement<Info>[]> {
57
47
  private elements;
@@ -60,14 +50,13 @@ export declare class FlowrSearchElements<Info = NoInfo, Elements extends FlowrSe
60
50
  add(element: FlowrSearchElement<Info>): this;
61
51
  addAll(elements: FlowrSearchElement<Info>[]): this;
62
52
  getElements(): Readonly<Elements>;
63
- mutate<OutElements extends Elements>(mutator: (elements: Elements) => OutElements): this;
53
+ mutate<OutElements extends Elements>(mutator: (elements: Elements) => OutElements | Promise<OutElements>): this | Promise<this>;
64
54
  /**
65
55
  * Enriches this flowr search element collection with the given enrichment.
66
56
  * To retrieve enrichment content for a given enrichment type, use {@link enrichmentContent}.
67
57
  *
68
- * Please note that this function does not also enrich individual elements, which is done through {@link enrichElement}. Both functions are called in a consise manner in {@link FlowrSearchBuilder.with}, which is the preferred way to add enrichments to a search.
58
+ * Please note that this function does not also enrich individual elements, which is done through {@link enrichElement}. Both functions are called in a concise manner in {@link FlowrSearchBuilder.with}, which is the preferred way to add enrichments to a search.
69
59
  */
70
- enrich<E extends Enrichment>(data: FlowrSearchInput<Pipeline>, enrichment: E, args?: EnrichmentSearchArguments<E>): this;
60
+ enrich<E extends Enrichment>(data: FlowrAnalysisProvider, enrichment: E, args?: EnrichmentSearchArguments<E>): Promise<this>;
71
61
  enrichmentContent<E extends Enrichment>(enrichment: E): EnrichmentSearchContent<E>;
72
62
  }
73
- export {};
@@ -23,21 +23,30 @@ class FlowrSearchElements {
23
23
  return this.elements;
24
24
  }
25
25
  mutate(mutator) {
26
- this.elements = mutator(this.elements);
27
- return this;
26
+ const result = mutator(this.elements);
27
+ if (result instanceof Promise) {
28
+ return result.then(resolvedElements => {
29
+ this.elements = resolvedElements;
30
+ return this;
31
+ });
32
+ }
33
+ else {
34
+ this.elements = result;
35
+ return this;
36
+ }
28
37
  }
29
38
  /**
30
39
  * Enriches this flowr search element collection with the given enrichment.
31
40
  * To retrieve enrichment content for a given enrichment type, use {@link enrichmentContent}.
32
41
  *
33
- * Please note that this function does not also enrich individual elements, which is done through {@link enrichElement}. Both functions are called in a consise manner in {@link FlowrSearchBuilder.with}, which is the preferred way to add enrichments to a search.
42
+ * Please note that this function does not also enrich individual elements, which is done through {@link enrichElement}. Both functions are called in a concise manner in {@link FlowrSearchBuilder.with}, which is the preferred way to add enrichments to a search.
34
43
  */
35
- enrich(data, enrichment, args) {
44
+ async enrich(data, enrichment, args) {
36
45
  const enrichmentData = search_enrichers_1.Enrichments[enrichment];
37
46
  if (enrichmentData.enrichSearch !== undefined) {
38
47
  this.enrichments = {
39
48
  ...this.enrichments ?? {},
40
- [enrichment]: enrichmentData.enrichSearch(this, data, args, this.enrichments?.[enrichment])
49
+ [enrichment]: await enrichmentData.enrichSearch(this, data, args, this.enrichments?.[enrichment])
41
50
  };
42
51
  }
43
52
  return this;
@@ -1,20 +1,25 @@
1
- import type { FlowrSearchElement, FlowrSearchElements, 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';
1
+ import type { FlowrSearchElement, FlowrSearchElements } from '../flowr-search';
2
+ import type { NormalizedAst, ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
4
3
  import type { MergeableRecord } from '../../util/objects';
5
4
  import type { Identifier } from '../../dataflow/environments/identifier';
6
5
  import type { LinkToLastCall } from '../../queries/catalog/call-context-query/call-context-query-format';
7
6
  import { type NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
8
7
  import type { ControlFlowInformation } from '../../control-flow/control-flow-graph';
9
- import type { QueryResult, SynchronousQuery } from '../../queries/query';
8
+ import type { Query, QueryResult } from '../../queries/query';
10
9
  import type { CfgSimplificationPassName } from '../../control-flow/cfg-simplification';
11
- import type { AsyncOrSyncType } from 'ts-essentials';
10
+ import type { AsyncOrSync } from 'ts-essentials';
11
+ import type { FlowrAnalysisProvider } from '../../project/flowr-analyzer';
12
+ import type { DataflowInformation } from '../../dataflow/info';
12
13
  export interface EnrichmentData<ElementContent extends MergeableRecord, ElementArguments = undefined, SearchContent extends MergeableRecord = never, SearchArguments = ElementArguments> {
13
14
  /**
14
15
  * A function that is applied to each element of the search to enrich it with additional data.
15
16
  */
16
- readonly enrichElement?: (element: FlowrSearchElement<ParentInformation>, search: FlowrSearchElements<ParentInformation>, data: FlowrSearchInput<Pipeline>, args: ElementArguments | undefined, previousValue: ElementContent | undefined) => ElementContent;
17
- readonly enrichSearch?: (search: FlowrSearchElements<ParentInformation>, data: FlowrSearchInput<Pipeline>, args: SearchArguments | undefined, previousValue: SearchContent | undefined) => SearchContent;
17
+ readonly enrichElement?: (element: FlowrSearchElement<ParentInformation>, search: FlowrSearchElements<ParentInformation>, data: {
18
+ dataflow: DataflowInformation;
19
+ normalize: NormalizedAst;
20
+ cfg: ControlFlowInformation;
21
+ }, args: ElementArguments | undefined, previousValue: ElementContent | undefined) => AsyncOrSync<ElementContent>;
22
+ readonly enrichSearch?: (search: FlowrSearchElements<ParentInformation>, data: FlowrAnalysisProvider, args: SearchArguments | undefined, previousValue: SearchContent | undefined) => AsyncOrSync<SearchContent>;
18
23
  /**
19
24
  * The mapping function used by the {@link Mapper.Enrichment} mapper.
20
25
  */
@@ -76,11 +81,11 @@ export interface CfgInformationArguments extends MergeableRecord {
76
81
  }
77
82
  export interface QueryDataElementContent extends MergeableRecord {
78
83
  /** The name of the query that this element originated from. To get each query's data, see {@link QueryDataSearchContent}. */
79
- query: SynchronousQuery['type'];
84
+ query: Query['type'];
80
85
  }
81
86
  export interface QueryDataSearchContent extends MergeableRecord {
82
87
  queries: {
83
- [QueryType in SynchronousQuery['type']]: AsyncOrSyncType<QueryResult<QueryType>>;
88
+ [QueryType in Query['type']]: Awaited<QueryResult<QueryType>>;
84
89
  };
85
90
  }
86
91
  /**
@@ -89,49 +94,41 @@ export interface QueryDataSearchContent extends MergeableRecord {
89
94
  */
90
95
  export declare const Enrichments: {
91
96
  readonly "call-targets": {
92
- enrichElement: (e: FlowrSearchElement<ParentInformation>, _s: FlowrSearchElements<ParentInformation, 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>>> & {
93
- normalize: import("../../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
94
- dataflow: import("../../dataflow/info").DataflowInformation;
95
- config: import("../../config").FlowrConfigOptions;
97
+ enrichElement: (e: FlowrSearchElement<ParentInformation>, _s: FlowrSearchElements<ParentInformation, FlowrSearchElement<ParentInformation>[]>, data: {
98
+ dataflow: DataflowInformation;
99
+ normalize: NormalizedAst;
100
+ cfg: ControlFlowInformation;
96
101
  }, args: {
97
102
  onlyBuiltin?: boolean;
98
103
  } | undefined, prev: CallTargetsContent | undefined) => CallTargetsContent;
99
104
  mapper: ({ targets }: CallTargetsContent) => FlowrSearchElement<ParentInformation>[];
100
105
  };
101
106
  readonly "last-call": {
102
- enrichElement: (e: FlowrSearchElement<ParentInformation>, _s: FlowrSearchElements<ParentInformation, 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>>> & {
103
- normalize: import("../../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
104
- dataflow: import("../../dataflow/info").DataflowInformation;
105
- config: import("../../config").FlowrConfigOptions;
107
+ enrichElement: (e: FlowrSearchElement<ParentInformation>, _s: FlowrSearchElements<ParentInformation, FlowrSearchElement<ParentInformation>[]>, data: {
108
+ dataflow: DataflowInformation;
109
+ normalize: NormalizedAst;
110
+ cfg: ControlFlowInformation;
106
111
  }, args: Omit<LinkToLastCall<import("../../queries/catalog/call-context-query/call-context-query-format").CallNameTypes>, "type">[] | undefined, prev: LastCallContent | undefined) => LastCallContent;
107
112
  mapper: ({ linkedIds }: LastCallContent) => FlowrSearchElement<ParentInformation>[];
108
113
  };
109
114
  readonly "cfg-information": {
110
- enrichElement: (e: FlowrSearchElement<ParentInformation>, search: FlowrSearchElements<ParentInformation, 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>>> & {
111
- normalize: import("../../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
112
- dataflow: import("../../dataflow/info").DataflowInformation;
113
- config: import("../../config").FlowrConfigOptions;
115
+ enrichElement: (e: FlowrSearchElement<ParentInformation>, search: FlowrSearchElements<ParentInformation, FlowrSearchElement<ParentInformation>[]>, _data: {
116
+ dataflow: DataflowInformation;
117
+ normalize: NormalizedAst;
118
+ cfg: ControlFlowInformation;
114
119
  }, _args: CfgInformationArguments | undefined, prev: CfgInformationElementContent | undefined) => {
115
120
  isRoot: boolean;
116
121
  isReachable: boolean | undefined;
117
122
  };
118
- enrichSearch: (_search: FlowrSearchElements<ParentInformation, 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>>> & {
119
- normalize: import("../../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
120
- dataflow: import("../../dataflow/info").DataflowInformation;
121
- config: import("../../config").FlowrConfigOptions;
122
- }, args: CfgInformationArguments | undefined, prev: CfgInformationSearchContent | undefined) => CfgInformationSearchContent;
123
+ enrichSearch: (_search: FlowrSearchElements<ParentInformation, FlowrSearchElement<ParentInformation>[]>, data: FlowrAnalysisProvider, args: CfgInformationArguments | undefined, prev: CfgInformationSearchContent | undefined) => Promise<CfgInformationSearchContent>;
123
124
  };
124
125
  readonly "query-data": {
125
- enrichElement: (_e: FlowrSearchElement<ParentInformation>, _search: FlowrSearchElements<ParentInformation, 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>>> & {
126
- normalize: import("../../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
127
- dataflow: import("../../dataflow/info").DataflowInformation;
128
- config: import("../../config").FlowrConfigOptions;
126
+ enrichElement: (_e: FlowrSearchElement<ParentInformation>, _search: FlowrSearchElements<ParentInformation, FlowrSearchElement<ParentInformation>[]>, _data: {
127
+ dataflow: DataflowInformation;
128
+ normalize: NormalizedAst;
129
+ cfg: ControlFlowInformation;
129
130
  }, args: QueryDataElementContent | undefined, prev: QueryDataElementContent | undefined) => QueryDataElementContent;
130
- enrichSearch: (_search: FlowrSearchElements<ParentInformation, 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>>> & {
131
- normalize: import("../../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
132
- dataflow: import("../../dataflow/info").DataflowInformation;
133
- config: import("../../config").FlowrConfigOptions;
134
- }, args: QueryDataSearchContent | undefined, prev: QueryDataSearchContent | undefined) => Required<QueryDataSearchContent>;
131
+ enrichSearch: (_search: FlowrSearchElements<ParentInformation, FlowrSearchElement<ParentInformation>[]>, _data: FlowrAnalysisProvider, args: QueryDataSearchContent | undefined, prev: QueryDataSearchContent | undefined) => Required<QueryDataSearchContent>;
135
132
  };
136
133
  };
137
134
  /**
@@ -141,4 +138,8 @@ export declare const Enrichments: {
141
138
  * @param enrichment - The enrichment content, if present, else `undefined`.
142
139
  */
143
140
  export declare function enrichmentContent<E extends Enrichment>(e: FlowrSearchElement<ParentInformation>, enrichment: E): EnrichmentElementContent<E>;
144
- export declare function enrichElement<Element extends FlowrSearchElement<ParentInformation>, E extends Enrichment>(e: Element, s: FlowrSearchElements<ParentInformation>, data: FlowrSearchInput<Pipeline>, enrichment: E, args?: EnrichmentElementArguments<E>): Element;
141
+ export declare function enrichElement<Element extends FlowrSearchElement<ParentInformation>, E extends Enrichment>(e: Element, s: FlowrSearchElements<ParentInformation>, data: {
142
+ dataflow: DataflowInformation;
143
+ normalize: NormalizedAst;
144
+ cfg: ControlFlowInformation;
145
+ }, enrichment: E, args?: EnrichmentElementArguments<E>): Promise<Element>;
@@ -100,7 +100,7 @@ exports.Enrichments = {
100
100
  isReachable: searchContent.reachableNodes?.has(e.node.info.id)
101
101
  };
102
102
  },
103
- enrichSearch: (_search, data, args, prev) => {
103
+ enrichSearch: async (_search, data, args, prev) => {
104
104
  args = {
105
105
  forceRefresh: false,
106
106
  checkReachable: false,
@@ -113,7 +113,7 @@ exports.Enrichments = {
113
113
  }
114
114
  const content = {
115
115
  ...prev,
116
- cfg: (0, extract_cfg_1.extractCfg)(data.normalize, data.config, data.dataflow.graph, args.simplificationPasses),
116
+ cfg: await data.controlflow(args.simplificationPasses, true),
117
117
  };
118
118
  if (args.checkReachable) {
119
119
  content.reachableNodes = (0, cfg_simplification_1.cfgFindAllReachable)(content.cfg);
@@ -136,14 +136,14 @@ exports.Enrichments = {
136
136
  function enrichmentContent(e, enrichment) {
137
137
  return e?.enrichments?.[enrichment];
138
138
  }
139
- function enrichElement(e, s, data, enrichment, args) {
139
+ async function enrichElement(e, s, data, enrichment, args) {
140
140
  const enrichmentData = exports.Enrichments[enrichment];
141
141
  const prev = e?.enrichments;
142
142
  return {
143
143
  ...e,
144
144
  enrichments: {
145
145
  ...prev ?? {},
146
- [enrichment]: enrichmentData.enrichElement?.(e, s, data, args, prev?.[enrichment])
146
+ [enrichment]: await enrichmentData.enrichElement?.(e, s, data, args, prev?.[enrichment])
147
147
  }
148
148
  };
149
149
  }
@@ -1,10 +1,10 @@
1
- import type { FlowrSearchElement, FlowrSearchGeneratorNodeBase, FlowrSearchGetFilter, FlowrSearchInput } from '../flowr-search';
1
+ import type { FlowrSearchElement, FlowrSearchGeneratorNodeBase, FlowrSearchGetFilter } from '../flowr-search';
2
2
  import { FlowrSearchElements } from '../flowr-search';
3
- import type { Pipeline } from '../../core/steps/pipeline/pipeline';
4
3
  import type { TailTypesOrUndefined } from '../../util/collections/arrays';
5
4
  import type { ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
6
5
  import type { SlicingCriteria } from '../../slicing/criterion/parse';
7
- import type { SynchronousQuery } from '../../queries/query';
6
+ import type { Query } from '../../queries/query';
7
+ import type { FlowrAnalysisProvider } from '../../project/flowr-analyzer';
8
8
  /**
9
9
  * This is a union of all possible generator node types
10
10
  */
@@ -25,18 +25,18 @@ export declare const generators: {
25
25
  readonly from: typeof generateFrom;
26
26
  readonly 'from-query': typeof generateFromQuery;
27
27
  };
28
- declare function generateAll(data: FlowrSearchInput<Pipeline>): FlowrSearchElements<ParentInformation>;
29
- declare function generateGet(data: FlowrSearchInput<Pipeline>, { filter: { line, column, id, name, nameIsRegex } }: {
28
+ declare function generateAll(data: FlowrAnalysisProvider): Promise<FlowrSearchElements<ParentInformation>>;
29
+ declare function generateGet(input: FlowrAnalysisProvider, { filter: { line, column, id, name, nameIsRegex } }: {
30
30
  filter: FlowrSearchGetFilter;
31
- }): FlowrSearchElements<ParentInformation>;
32
- declare function generateFrom(data: FlowrSearchInput<Pipeline>, args: {
31
+ }): Promise<FlowrSearchElements<ParentInformation>>;
32
+ declare function generateFrom(_input: FlowrAnalysisProvider, args: {
33
33
  from: FlowrSearchElement<ParentInformation> | FlowrSearchElement<ParentInformation>[];
34
34
  }): FlowrSearchElements<ParentInformation>;
35
- declare function generateFromQuery(data: FlowrSearchInput<Pipeline>, args: {
36
- from: readonly SynchronousQuery[];
37
- }): FlowrSearchElements<ParentInformation, FlowrSearchElement<ParentInformation>[]>;
38
- declare function generateCriterion(data: FlowrSearchInput<Pipeline>, args: {
35
+ declare function generateFromQuery(input: FlowrAnalysisProvider, args: {
36
+ from: readonly Query[];
37
+ }): Promise<FlowrSearchElements<ParentInformation, FlowrSearchElement<ParentInformation>[]>>;
38
+ declare function generateCriterion(input: FlowrAnalysisProvider, args: {
39
39
  criterion: SlicingCriteria;
40
- }): FlowrSearchElements<ParentInformation>;
40
+ }): Promise<FlowrSearchElements<ParentInformation>>;
41
41
  export declare function getGenerator<Name extends GeneratorNames>(name: Name): typeof generators[Name];
42
42
  export {};
@@ -17,21 +17,23 @@ exports.generators = {
17
17
  from: generateFrom,
18
18
  'from-query': generateFromQuery
19
19
  };
20
- function generateAll(data) {
21
- return new flowr_search_1.FlowrSearchElements(getAllNodes(data)
20
+ async function generateAll(data) {
21
+ return new flowr_search_1.FlowrSearchElements((await getAllNodes(data))
22
22
  .map(node => ({ node })));
23
23
  }
24
- function getAllNodes(data) {
25
- return [...new Map([...data.normalize.idMap.values()].map(n => [n.info.id, n]))
24
+ async function getAllNodes(data) {
25
+ const normalize = await data.normalize();
26
+ return [...new Map([...normalize.idMap.values()].map(n => [n.info.id, n]))
26
27
  .values()];
27
28
  }
28
- function generateGet(data, { filter: { line, column, id, name, nameIsRegex } }) {
29
+ async function generateGet(input, { filter: { line, column, id, name, nameIsRegex } }) {
30
+ const normalize = await input.normalize();
29
31
  let potentials = (id ?
30
- [data.normalize.idMap.get(id)].filter(assert_1.isNotUndefined) :
31
- getAllNodes(data));
32
+ [normalize.idMap.get(id)].filter(assert_1.isNotUndefined) :
33
+ await getAllNodes(input));
32
34
  if (line && line < 0) {
33
- const maxLines = data.normalize.ast.info.fullRange?.[2] ??
34
- (id ? getAllNodes(data) : potentials).reduce((maxLine, { location }) => location && location[2] > maxLine ? location[2] : maxLine, 0);
35
+ const maxLines = normalize.ast.info.fullRange?.[2] ??
36
+ (id ? (await getAllNodes(input)) : potentials).reduce((maxLine, { location }) => location && location[2] > maxLine ? location[2] : maxLine, 0);
35
37
  line = maxLines + line + 1;
36
38
  }
37
39
  if (line && column) {
@@ -52,11 +54,11 @@ function generateGet(data, { filter: { line, column, id, name, nameIsRegex } })
52
54
  }
53
55
  return new flowr_search_1.FlowrSearchElements(potentials.map(node => ({ node })));
54
56
  }
55
- function generateFrom(data, args) {
57
+ function generateFrom(_input, args) {
56
58
  return new flowr_search_1.FlowrSearchElements(Array.isArray(args.from) ? args.from : [args.from]);
57
59
  }
58
- function generateFromQuery(data, args) {
59
- const result = (0, query_1.executeQueries)({ ast: data.normalize, dataflow: data.dataflow, config: data.config }, args.from);
60
+ async function generateFromQuery(input, args) {
61
+ const result = await (0, query_1.executeQueries)({ analyzer: input }, args.from);
60
62
  // collect involved nodes
61
63
  const nodesByQuery = new Map();
62
64
  for (const [query, content] of Object.entries(result)) {
@@ -66,19 +68,25 @@ function generateFromQuery(data, args) {
66
68
  const nodes = new Set();
67
69
  const queryDef = query_1.SupportedQueries[query];
68
70
  for (const node of queryDef.flattenInvolvedNodes(content, args.from)) {
69
- nodes.add({ node: data.normalize.idMap.get(node) });
71
+ nodes.add({ node: (await input.normalize()).idMap.get(node) });
70
72
  }
71
73
  nodesByQuery.set(query, nodes);
72
74
  }
73
75
  // enrich elements with query data
74
- const elements = new flowr_search_1.FlowrSearchElements([...nodesByQuery].flatMap(([_, nodes]) => [...nodes])).enrich(data, search_enrichers_1.Enrichment.QueryData, { queries: result });
75
- return elements.mutate(s => s.map(e => {
76
+ const normalize = await input.normalize();
77
+ const dataflow = await input.dataflow();
78
+ const cfg = await input.controlflow();
79
+ const elements = await new flowr_search_1.FlowrSearchElements([...nodesByQuery]
80
+ .flatMap(([_, nodes]) => [...nodes]))
81
+ .enrich(input, search_enrichers_1.Enrichment.QueryData, { queries: result });
82
+ return elements.mutate(s => Promise.all(s.map(async (e) => {
76
83
  const [query, _] = [...nodesByQuery].find(([_, nodes]) => nodes.has(e));
77
- return (0, search_enrichers_1.enrichElement)(e, elements, data, search_enrichers_1.Enrichment.QueryData, { query });
78
- }));
84
+ return await (0, search_enrichers_1.enrichElement)(e, elements, { normalize, dataflow, cfg }, search_enrichers_1.Enrichment.QueryData, { query });
85
+ })));
79
86
  }
80
- function generateCriterion(data, args) {
81
- return new flowr_search_1.FlowrSearchElements(args.criterion.map(c => ({ node: data.normalize.idMap.get((0, parse_1.slicingCriterionToId)(c, data.normalize.idMap)) })));
87
+ async function generateCriterion(input, args) {
88
+ const idMap = (await input.normalize()).idMap;
89
+ return new flowr_search_1.FlowrSearchElements(args.criterion.map(c => ({ node: idMap.get((0, parse_1.slicingCriterionToId)(c, idMap)) })));
82
90
  }
83
91
  function getGenerator(name) {
84
92
  if (!exports.generators[name]) {
@@ -1,19 +1,19 @@
1
- import type { FlowrSearchElement, FlowrSearchInput } from '../flowr-search';
1
+ import type { FlowrSearchElement } from '../flowr-search';
2
2
  import type { ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
3
3
  import type { Enrichment } from './search-enrichers';
4
4
  import type { MergeableRecord } from '../../util/objects';
5
- import type { Pipeline } from '../../core/steps/pipeline/pipeline';
5
+ import type { FlowrAnalysisProvider } from '../../project/flowr-analyzer';
6
6
  export declare enum Mapper {
7
7
  Enrichment = "enrichment"
8
8
  }
9
9
  export interface MapperData<Arguments extends string | MergeableRecord> {
10
- mapper: (e: FlowrSearchElement<ParentInformation>, data: FlowrSearchInput<Pipeline>, args: Arguments) => FlowrSearchElement<ParentInformation>[];
10
+ mapper: (e: FlowrSearchElement<ParentInformation>, data: FlowrAnalysisProvider, args: Arguments) => FlowrSearchElement<ParentInformation>[];
11
11
  }
12
12
  export type MapperArguments<M extends Mapper> = typeof Mappers[M] extends MapperData<infer Arguments> ? Arguments : never;
13
13
  declare const Mappers: {
14
14
  readonly enrichment: {
15
- mapper: (e: FlowrSearchElement<ParentInformation>, _data: FlowrSearchInput<Pipeline>, enrichment: Enrichment) => FlowrSearchElement<ParentInformation>[];
15
+ mapper: (e: FlowrSearchElement<ParentInformation>, _data: FlowrAnalysisProvider, enrichment: Enrichment) => FlowrSearchElement<ParentInformation>[];
16
16
  };
17
17
  };
18
- export declare function map<Element extends FlowrSearchElement<ParentInformation>, MapperType extends Mapper>(e: Element, data: FlowrSearchInput<Pipeline>, mapper: MapperType, args: MapperArguments<MapperType>): Element[];
18
+ export declare function map<Element extends FlowrSearchElement<ParentInformation>, MapperType extends Mapper>(e: Element, data: FlowrAnalysisProvider, mapper: MapperType, args: MapperArguments<MapperType>): Element[];
19
19
  export {};