@eagleoutice/flowr 2.2.15 → 2.3.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 (255) hide show
  1. package/README.md +226 -6
  2. package/abstract-interpretation/data-frame/absint-info.d.ts +109 -0
  3. package/abstract-interpretation/data-frame/absint-info.js +31 -0
  4. package/abstract-interpretation/data-frame/absint-visitor.d.ts +59 -0
  5. package/abstract-interpretation/data-frame/absint-visitor.js +173 -0
  6. package/abstract-interpretation/data-frame/domain.d.ts +107 -0
  7. package/abstract-interpretation/data-frame/domain.js +315 -0
  8. package/abstract-interpretation/data-frame/mappers/access-mapper.d.ts +17 -0
  9. package/abstract-interpretation/data-frame/mappers/access-mapper.js +166 -0
  10. package/abstract-interpretation/data-frame/mappers/arguments.d.ts +117 -0
  11. package/abstract-interpretation/data-frame/mappers/arguments.js +188 -0
  12. package/abstract-interpretation/data-frame/mappers/assignment-mapper.d.ts +20 -0
  13. package/abstract-interpretation/data-frame/mappers/assignment-mapper.js +34 -0
  14. package/abstract-interpretation/data-frame/mappers/function-mapper.d.ts +261 -0
  15. package/abstract-interpretation/data-frame/mappers/function-mapper.js +1219 -0
  16. package/abstract-interpretation/data-frame/mappers/replacement-mapper.d.ts +12 -0
  17. package/abstract-interpretation/data-frame/mappers/replacement-mapper.js +206 -0
  18. package/abstract-interpretation/data-frame/resolve-args.d.ts +42 -0
  19. package/abstract-interpretation/data-frame/resolve-args.js +118 -0
  20. package/abstract-interpretation/data-frame/semantics.d.ts +213 -0
  21. package/abstract-interpretation/data-frame/semantics.js +366 -0
  22. package/abstract-interpretation/data-frame/shape-inference.d.ts +38 -0
  23. package/abstract-interpretation/data-frame/shape-inference.js +117 -0
  24. package/benchmark/slicer.d.ts +18 -2
  25. package/benchmark/slicer.js +143 -5
  26. package/benchmark/stats/print.js +123 -45
  27. package/benchmark/stats/size-of.d.ts +7 -0
  28. package/benchmark/stats/size-of.js +1 -0
  29. package/benchmark/stats/stats.d.ts +30 -1
  30. package/benchmark/stats/stats.js +4 -2
  31. package/benchmark/summarizer/data.d.ts +33 -2
  32. package/benchmark/summarizer/first-phase/input.js +5 -1
  33. package/benchmark/summarizer/first-phase/process.d.ts +2 -1
  34. package/benchmark/summarizer/first-phase/process.js +49 -3
  35. package/benchmark/summarizer/second-phase/process.js +101 -3
  36. package/cli/benchmark-app.d.ts +2 -0
  37. package/cli/benchmark-app.js +5 -1
  38. package/cli/benchmark-helper-app.d.ts +2 -0
  39. package/cli/benchmark-helper-app.js +13 -8
  40. package/cli/common/options.js +4 -0
  41. package/cli/export-quads-app.js +2 -1
  42. package/cli/flowr.js +58 -57
  43. package/cli/repl/commands/repl-cfg.js +13 -13
  44. package/cli/repl/commands/repl-commands.js +2 -2
  45. package/cli/repl/commands/repl-dataflow.js +10 -10
  46. package/cli/repl/commands/repl-execute.d.ts +2 -3
  47. package/cli/repl/commands/repl-execute.js +4 -4
  48. package/cli/repl/commands/repl-lineage.js +4 -4
  49. package/cli/repl/commands/repl-main.d.ts +12 -1
  50. package/cli/repl/commands/repl-normalize.js +6 -6
  51. package/cli/repl/commands/repl-parse.js +2 -2
  52. package/cli/repl/commands/repl-query.js +9 -9
  53. package/cli/repl/commands/repl-version.js +1 -1
  54. package/cli/repl/core.d.ts +5 -2
  55. package/cli/repl/core.js +10 -8
  56. package/cli/repl/server/connection.d.ts +3 -1
  57. package/cli/repl/server/connection.js +7 -5
  58. package/cli/repl/server/server.d.ts +3 -2
  59. package/cli/repl/server/server.js +4 -2
  60. package/cli/script-core/statistics-core.d.ts +2 -1
  61. package/cli/script-core/statistics-core.js +2 -2
  62. package/cli/script-core/statistics-helper-core.d.ts +2 -1
  63. package/cli/script-core/statistics-helper-core.js +5 -4
  64. package/cli/slicer-app.js +4 -2
  65. package/cli/statistics-app.js +2 -1
  66. package/cli/statistics-helper-app.js +2 -1
  67. package/config.d.ts +43 -10
  68. package/config.js +47 -43
  69. package/control-flow/cfg-dead-code.js +45 -2
  70. package/control-flow/cfg-simplification.d.ts +2 -0
  71. package/control-flow/control-flow-graph.d.ts +2 -0
  72. package/control-flow/control-flow-graph.js +8 -0
  73. package/control-flow/dfg-cfg-guided-visitor.d.ts +5 -3
  74. package/control-flow/dfg-cfg-guided-visitor.js +15 -4
  75. package/control-flow/extract-cfg.d.ts +4 -2
  76. package/control-flow/extract-cfg.js +4 -3
  77. package/control-flow/semantic-cfg-guided-visitor.d.ts +20 -2
  78. package/control-flow/semantic-cfg-guided-visitor.js +24 -4
  79. package/core/pipeline-executor.d.ts +4 -1
  80. package/core/pipeline-executor.js +6 -5
  81. package/core/steps/all/core/10-normalize.d.ts +2 -0
  82. package/core/steps/all/core/10-normalize.js +1 -1
  83. package/core/steps/all/core/11-normalize-tree-sitter.d.ts +2 -1
  84. package/core/steps/all/core/11-normalize-tree-sitter.js +2 -2
  85. package/core/steps/all/core/20-dataflow.d.ts +2 -1
  86. package/core/steps/all/core/20-dataflow.js +2 -2
  87. package/core/steps/all/static-slicing/00-slice.d.ts +2 -1
  88. package/core/steps/all/static-slicing/00-slice.js +2 -2
  89. package/core/steps/pipeline/default-pipelines.d.ts +32 -31
  90. package/core/steps/pipeline/default-pipelines.js +8 -8
  91. package/core/steps/pipeline-step.d.ts +2 -1
  92. package/dataflow/environments/built-in-config.d.ts +3 -3
  93. package/dataflow/environments/built-in.d.ts +11 -3
  94. package/dataflow/environments/built-in.js +5 -3
  95. package/dataflow/environments/default-builtin-config.js +4 -2
  96. package/dataflow/environments/define.d.ts +2 -1
  97. package/dataflow/environments/define.js +4 -5
  98. package/dataflow/environments/remove.d.ts +6 -0
  99. package/dataflow/environments/remove.js +29 -0
  100. package/dataflow/eval/resolve/alias-tracking.d.ts +7 -2
  101. package/dataflow/eval/resolve/alias-tracking.js +11 -8
  102. package/dataflow/eval/resolve/resolve-argument.d.ts +8 -0
  103. package/dataflow/eval/resolve/resolve-argument.js +118 -0
  104. package/dataflow/eval/resolve/resolve.d.ts +65 -18
  105. package/dataflow/eval/resolve/resolve.js +144 -48
  106. package/dataflow/eval/values/string/string-constants.d.ts +1 -1
  107. package/dataflow/eval/values/string/string-constants.js +7 -2
  108. package/dataflow/extractor.d.ts +2 -1
  109. package/dataflow/extractor.js +2 -1
  110. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +5 -6
  111. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +1 -1
  112. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +4 -2
  113. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +11 -11
  114. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +10 -11
  115. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +7 -2
  116. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +2 -3
  117. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +1 -1
  118. package/dataflow/internal/process/functions/call/built-in/built-in-list.js +2 -2
  119. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +2 -3
  120. package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +6 -3
  121. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +19 -15
  122. package/dataflow/internal/process/functions/call/built-in/built-in-vector.js +2 -2
  123. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +1 -1
  124. package/dataflow/internal/process/functions/call/common.js +1 -1
  125. package/dataflow/internal/process/functions/process-parameter.js +1 -1
  126. package/dataflow/origin/dfg-get-symbol-refs.d.ts +21 -0
  127. package/dataflow/origin/dfg-get-symbol-refs.js +50 -0
  128. package/dataflow/processor.d.ts +5 -0
  129. package/documentation/doc-util/doc-cfg.js +4 -3
  130. package/documentation/doc-util/doc-code.d.ts +1 -1
  131. package/documentation/doc-util/doc-dfg.js +3 -2
  132. package/documentation/doc-util/doc-functions.d.ts +24 -0
  133. package/documentation/doc-util/doc-functions.js +65 -0
  134. package/documentation/doc-util/doc-normalized-ast.js +3 -2
  135. package/documentation/doc-util/doc-print.d.ts +5 -0
  136. package/documentation/doc-util/doc-print.js +36 -0
  137. package/documentation/doc-util/doc-query.js +13 -2
  138. package/documentation/doc-util/doc-repl.js +2 -1
  139. package/documentation/doc-util/doc-search.js +3 -2
  140. package/documentation/doc-util/doc-types.d.ts +28 -6
  141. package/documentation/doc-util/doc-types.js +89 -45
  142. package/documentation/print-cfg-wiki.js +6 -7
  143. package/documentation/print-core-wiki.js +5 -5
  144. package/documentation/print-dataflow-graph-wiki.js +10 -10
  145. package/documentation/print-engines-wiki.js +1 -2
  146. package/documentation/print-faq-wiki.js +8 -2
  147. package/documentation/print-interface-wiki.js +12 -2
  148. package/documentation/print-linter-issue.d.ts +1 -0
  149. package/documentation/print-linter-issue.js +71 -0
  150. package/documentation/print-linter-wiki.js +223 -34
  151. package/documentation/print-linting-and-testing-wiki.js +2 -4
  152. package/documentation/print-normalized-ast-wiki.js +3 -3
  153. package/documentation/print-query-wiki.js +18 -2
  154. package/documentation/print-readme.js +24 -1
  155. package/documentation/print-search-wiki.js +1 -2
  156. package/linter/linter-executor.d.ts +3 -1
  157. package/linter/linter-executor.js +3 -2
  158. package/linter/linter-format.d.ts +67 -7
  159. package/linter/linter-format.js +12 -1
  160. package/linter/linter-rules.d.ts +178 -16
  161. package/linter/linter-rules.js +14 -4
  162. package/linter/linter-tags.d.ts +80 -0
  163. package/linter/linter-tags.js +85 -0
  164. package/linter/rules/absolute-path.d.ts +71 -0
  165. package/linter/rules/absolute-path.js +177 -0
  166. package/linter/rules/dataframe-access-validation.d.ts +53 -0
  167. package/linter/rules/dataframe-access-validation.js +116 -0
  168. package/linter/rules/deprecated-functions.d.ts +43 -0
  169. package/linter/rules/deprecated-functions.js +58 -0
  170. package/linter/rules/{2-file-path-validity.d.ts → file-path-validity.d.ts} +16 -6
  171. package/linter/rules/{2-file-path-validity.js → file-path-validity.js} +21 -13
  172. package/linter/rules/naming-convention.d.ts +71 -0
  173. package/linter/rules/naming-convention.js +168 -0
  174. package/linter/rules/seeded-randomness.d.ts +65 -0
  175. package/linter/rules/seeded-randomness.js +122 -0
  176. package/linter/rules/unused-definition.d.ts +41 -0
  177. package/linter/rules/unused-definition.js +105 -0
  178. package/package.json +5 -2
  179. package/queries/base-query-format.d.ts +2 -0
  180. package/queries/catalog/call-context-query/call-context-query-executor.d.ts +1 -1
  181. package/queries/catalog/call-context-query/call-context-query-executor.js +2 -2
  182. package/queries/catalog/cluster-query/cluster-query-format.d.ts +1 -1
  183. package/queries/catalog/config-query/config-query-executor.d.ts +1 -1
  184. package/queries/catalog/config-query/config-query-executor.js +2 -3
  185. package/queries/catalog/control-flow-query/control-flow-query-executor.d.ts +1 -1
  186. package/queries/catalog/control-flow-query/control-flow-query-executor.js +2 -2
  187. package/queries/catalog/control-flow-query/control-flow-query-format.d.ts +1 -1
  188. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.d.ts +1 -1
  189. package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +1 -1
  190. package/queries/catalog/dependencies-query/dependencies-query-executor.js +4 -116
  191. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +1 -1
  192. package/queries/catalog/df-shape-query/df-shape-query-executor.d.ts +3 -0
  193. package/queries/catalog/df-shape-query/df-shape-query-executor.js +46 -0
  194. package/queries/catalog/df-shape-query/df-shape-query-format.d.ts +72 -0
  195. package/queries/catalog/df-shape-query/df-shape-query-format.js +31 -0
  196. package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +1 -1
  197. package/queries/catalog/id-map-query/id-map-query-format.d.ts +1 -1
  198. package/queries/catalog/lineage-query/lineage-query-format.d.ts +1 -1
  199. package/queries/catalog/linter-query/linter-query-executor.d.ts +1 -1
  200. package/queries/catalog/linter-query/linter-query-executor.js +2 -2
  201. package/queries/catalog/linter-query/linter-query-format.d.ts +1 -1
  202. package/queries/catalog/linter-query/linter-query-format.js +16 -12
  203. package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +1 -1
  204. package/queries/catalog/origin-query/origin-query-format.d.ts +1 -1
  205. package/queries/catalog/project-query/project-query-format.d.ts +1 -1
  206. package/queries/catalog/resolve-value-query/resolve-value-query-executor.d.ts +1 -1
  207. package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +2 -2
  208. package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +1 -1
  209. package/queries/catalog/search-query/search-query-executor.d.ts +1 -1
  210. package/queries/catalog/search-query/search-query-executor.js +2 -2
  211. package/queries/catalog/search-query/search-query-format.d.ts +1 -1
  212. package/queries/catalog/static-slice-query/static-slice-query-executor.d.ts +1 -1
  213. package/queries/catalog/static-slice-query/static-slice-query-executor.js +2 -2
  214. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +1 -1
  215. package/queries/query.d.ts +76 -16
  216. package/queries/query.js +2 -0
  217. package/r-bridge/lang-4.x/ast/parser/json/parser.d.ts +2 -1
  218. package/r-bridge/lang-4.x/ast/parser/json/parser.js +4 -2
  219. package/r-bridge/lang-4.x/convert-values.js +2 -1
  220. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.d.ts +3 -1
  221. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +4 -4
  222. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.d.ts +1 -1
  223. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +7 -5
  224. package/r-bridge/shell.d.ts +3 -2
  225. package/r-bridge/shell.js +4 -5
  226. package/search/flowr-search-builder.d.ts +6 -2
  227. package/search/flowr-search-builder.js +7 -0
  228. package/search/flowr-search-filters.d.ts +32 -8
  229. package/search/flowr-search-filters.js +42 -15
  230. package/search/flowr-search.d.ts +4 -0
  231. package/search/search-executor/search-enrichers.d.ts +7 -3
  232. package/search/search-executor/search-enrichers.js +29 -20
  233. package/search/search-executor/search-generators.js +1 -1
  234. package/search/search-executor/search-transformer.d.ts +2 -0
  235. package/search/search-executor/search-transformer.js +10 -1
  236. package/slicing/static/static-slicer.d.ts +1 -1
  237. package/slicing/static/static-slicer.js +2 -3
  238. package/statistics/statistics.d.ts +3 -1
  239. package/statistics/statistics.js +5 -4
  240. package/util/containers.d.ts +12 -9
  241. package/util/containers.js +12 -9
  242. package/util/files.d.ts +8 -2
  243. package/util/files.js +22 -4
  244. package/util/objects.d.ts +5 -4
  245. package/util/r-value.d.ts +23 -0
  246. package/util/r-value.js +113 -0
  247. package/util/range.d.ts +5 -1
  248. package/util/range.js +11 -3
  249. package/util/text/strings.d.ts +6 -0
  250. package/util/text/strings.js +35 -0
  251. package/util/version.js +1 -1
  252. package/linter/rules/1-deprecated-functions.d.ts +0 -34
  253. package/linter/rules/1-deprecated-functions.js +0 -54
  254. package/util/cfg/cfg.d.ts +0 -0
  255. package/util/cfg/cfg.js +0 -2
@@ -55,7 +55,7 @@ export declare const SearchQueryDefinition: {
55
55
  }, input: {
56
56
  request?: import("../../../r-bridge/retriever").RParseRequests;
57
57
  parser?: import("../../../r-bridge/parser").Parser<import("../../../r-bridge/parser").KnownParserType>;
58
- }) => import("../../../dataflow/info").DataflowInformation;
58
+ }, config: import("../../../config").FlowrConfigOptions) => import("../../../dataflow/info").DataflowInformation;
59
59
  readonly requiredInput: {};
60
60
  readonly name: "dataflow";
61
61
  readonly description: "Construct the dataflow graph";
@@ -1,4 +1,4 @@
1
1
  import type { StaticSliceQuery, StaticSliceQueryResult } from './static-slice-query-format';
2
2
  import type { BasicQueryData } from '../../base-query-format';
3
3
  export declare function fingerPrintOfQuery(query: StaticSliceQuery): string;
4
- export declare function executeStaticSliceQuery({ dataflow: { graph }, ast }: BasicQueryData, queries: readonly StaticSliceQuery[]): StaticSliceQueryResult;
4
+ export declare function executeStaticSliceQuery({ dataflow: { graph }, ast, config }: BasicQueryData, queries: readonly StaticSliceQuery[]): StaticSliceQueryResult;
@@ -10,7 +10,7 @@ const log_1 = require("../../../util/log");
10
10
  function fingerPrintOfQuery(query) {
11
11
  return JSON.stringify(query);
12
12
  }
13
- function executeStaticSliceQuery({ dataflow: { graph }, ast }, queries) {
13
+ function executeStaticSliceQuery({ dataflow: { graph }, ast, config }, queries) {
14
14
  const start = Date.now();
15
15
  const results = {};
16
16
  for (const query of queries) {
@@ -20,7 +20,7 @@ function executeStaticSliceQuery({ dataflow: { graph }, ast }, queries) {
20
20
  }
21
21
  const { criteria, noReconstruction, noMagicComments } = query;
22
22
  const sliceStart = Date.now();
23
- const slice = (0, static_slicer_1.staticSlicing)(graph, ast, criteria);
23
+ const slice = (0, static_slicer_1.staticSlicing)(graph, ast, criteria, config.solver.slicer?.threshold);
24
24
  const sliceEnd = Date.now();
25
25
  if (noReconstruction) {
26
26
  results[key] = { slice: { ...slice, '.meta': { timing: sliceEnd - sliceStart } } };
@@ -67,7 +67,7 @@ export declare const StaticSliceQueryDefinition: {
67
67
  }, input: {
68
68
  request?: import("../../../r-bridge/retriever").RParseRequests;
69
69
  parser?: import("../../../r-bridge/parser").Parser<import("../../../r-bridge/parser").KnownParserType>;
70
- }) => import("../../../dataflow/info").DataflowInformation;
70
+ }, config: import("../../../config").FlowrConfigOptions) => import("../../../dataflow/info").DataflowInformation;
71
71
  readonly requiredInput: {};
72
72
  readonly name: "dataflow";
73
73
  readonly description: "Construct the dataflow graph";
@@ -24,7 +24,8 @@ import type { OriginQuery } from './catalog/origin-query/origin-query-format';
24
24
  import type { LinterQuery } from './catalog/linter-query/linter-query-format';
25
25
  import type { NodeId } from '../r-bridge/lang-4.x/ast/model/processing/node-id';
26
26
  import type { ControlFlowQuery } from './catalog/control-flow-query/control-flow-query-format';
27
- export type Query = CallContextQuery | ConfigQuery | SearchQuery | DataflowQuery | ControlFlowQuery | DataflowLensQuery | NormalizedAstQuery | IdMapQuery | DataflowClusterQuery | StaticSliceQuery | LineageQuery | DependenciesQuery | LocationMapQuery | HappensBeforeQuery | ResolveValueQuery | ProjectQuery | OriginQuery | LinterQuery;
27
+ import type { DfShapeQuery } from './catalog/df-shape-query/df-shape-query-format';
28
+ export type Query = CallContextQuery | ConfigQuery | SearchQuery | DataflowQuery | ControlFlowQuery | DataflowLensQuery | DfShapeQuery | NormalizedAstQuery | IdMapQuery | DataflowClusterQuery | StaticSliceQuery | LineageQuery | DependenciesQuery | LocationMapQuery | HappensBeforeQuery | ResolveValueQuery | ProjectQuery | OriginQuery | LinterQuery;
28
29
  export type QueryArgumentsWithType<QueryType extends BaseQueryFormat['type']> = Query & {
29
30
  type: QueryType;
30
31
  };
@@ -97,7 +98,7 @@ export declare const SupportedQueries: {
97
98
  }, input: {
98
99
  request?: import("../r-bridge/retriever").RParseRequests;
99
100
  parser?: import("../r-bridge/parser").Parser<import("../r-bridge/parser").KnownParserType>;
100
- }) => import("../dataflow/info").DataflowInformation;
101
+ }, config: import("../config").FlowrConfigOptions) => import("../dataflow/info").DataflowInformation;
101
102
  readonly requiredInput: {};
102
103
  readonly name: "dataflow";
103
104
  readonly description: "Construct the dataflow graph";
@@ -156,7 +157,7 @@ export declare const SupportedQueries: {
156
157
  }, input: {
157
158
  request?: import("../r-bridge/retriever").RParseRequests;
158
159
  parser?: import("../r-bridge/parser").Parser<import("../r-bridge/parser").KnownParserType>;
159
- }) => import("../dataflow/info").DataflowInformation;
160
+ }, config: import("../config").FlowrConfigOptions) => import("../dataflow/info").DataflowInformation;
160
161
  readonly requiredInput: {};
161
162
  readonly name: "dataflow";
162
163
  readonly description: "Construct the dataflow graph";
@@ -215,7 +216,66 @@ export declare const SupportedQueries: {
215
216
  }, input: {
216
217
  request?: import("../r-bridge/retriever").RParseRequests;
217
218
  parser?: import("../r-bridge/parser").Parser<import("../r-bridge/parser").KnownParserType>;
218
- }) => import("../dataflow/info").DataflowInformation;
219
+ }, config: import("../config").FlowrConfigOptions) => import("../dataflow/info").DataflowInformation;
220
+ readonly requiredInput: {};
221
+ readonly name: "dataflow";
222
+ readonly description: "Construct the dataflow graph";
223
+ readonly executed: import("../core/steps/pipeline-step").PipelineStepStage.OncePerFile;
224
+ readonly printer: {
225
+ readonly 0: typeof import("../core/print/print").internalPrinter;
226
+ readonly 2: typeof import("../core/print/dataflow-printer").dataflowGraphToJson;
227
+ readonly 5: typeof import("../core/print/dataflow-printer").dataflowGraphToQuads;
228
+ readonly 3: typeof import("../core/print/dataflow-printer").dataflowGraphToMermaid;
229
+ readonly 4: typeof import("../core/print/dataflow-printer").dataflowGraphToMermaidUrl;
230
+ };
231
+ readonly dependencies: readonly ["normalize"];
232
+ }>>, queryResults: BaseQueryResult, result: string[]) => true;
233
+ readonly schema: Joi.ObjectSchema<any>;
234
+ readonly flattenInvolvedNodes: () => never[];
235
+ };
236
+ readonly 'df-shape': {
237
+ readonly executor: typeof import("./catalog/df-shape-query/df-shape-query-executor").executeDfShapeQuery;
238
+ readonly asciiSummarizer: (formatter: OutputFormatter, _processed: PipelineOutput<import("../core/steps/pipeline/pipeline").Pipeline<{
239
+ readonly name: "parse";
240
+ readonly humanReadableName: "parse with R shell";
241
+ readonly description: "Parse the given R code into an AST";
242
+ readonly processor: (_results: unknown, input: Partial<import("../r-bridge/parser").ParseRequiredInput<string>>) => Promise<import("../r-bridge/parser").ParseStepOutput<string>>;
243
+ readonly executed: import("../core/steps/pipeline-step").PipelineStepStage.OncePerFile;
244
+ readonly printer: {
245
+ readonly 0: typeof import("../core/print/print").internalPrinter;
246
+ readonly 2: {
247
+ (value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string;
248
+ (value: any, replacer?: (number | string)[] | null, space?: string | number): string;
249
+ };
250
+ readonly 5: ({ parsed }: import("../r-bridge/parser").ParseStepOutput<string>, config: import("../util/quads").QuadSerializationConfiguration) => string;
251
+ };
252
+ readonly dependencies: readonly [];
253
+ readonly requiredInput: import("../r-bridge/parser").ParseRequiredInput<string>;
254
+ } | {
255
+ readonly name: "normalize";
256
+ readonly humanReadableName: "normalize";
257
+ readonly description: "Normalize the AST to flowR's AST";
258
+ readonly processor: (results: {
259
+ parse?: import("../r-bridge/parser").ParseStepOutput<string>;
260
+ }, input: Partial<import("../core/steps/all/core/10-normalize").NormalizeRequiredInput>) => import("../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../r-bridge/lang-4.x/ast/model/model").RNode<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>>;
261
+ readonly executed: import("../core/steps/pipeline-step").PipelineStepStage.OncePerFile;
262
+ readonly printer: {
263
+ readonly 0: typeof import("../core/print/print").internalPrinter;
264
+ readonly 2: typeof import("../core/print/normalize-printer").normalizedAstToJson;
265
+ readonly 5: typeof import("../core/print/normalize-printer").normalizedAstToQuads;
266
+ readonly 3: typeof import("../core/print/normalize-printer").printNormalizedAstToMermaid;
267
+ readonly 4: typeof import("../core/print/normalize-printer").printNormalizedAstToMermaidUrl;
268
+ };
269
+ readonly dependencies: readonly ["parse"];
270
+ readonly requiredInput: import("../core/steps/all/core/10-normalize").NormalizeRequiredInput;
271
+ } | {
272
+ readonly humanReadableName: "dataflow";
273
+ readonly processor: (results: {
274
+ normalize?: import("../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
275
+ }, input: {
276
+ request?: import("../r-bridge/retriever").RParseRequests;
277
+ parser?: import("../r-bridge/parser").Parser<import("../r-bridge/parser").KnownParserType>;
278
+ }, config: import("../config").FlowrConfigOptions) => import("../dataflow/info").DataflowInformation;
219
279
  readonly requiredInput: {};
220
280
  readonly name: "dataflow";
221
281
  readonly description: "Construct the dataflow graph";
@@ -274,7 +334,7 @@ export declare const SupportedQueries: {
274
334
  }, input: {
275
335
  request?: import("../r-bridge/retriever").RParseRequests;
276
336
  parser?: import("../r-bridge/parser").Parser<import("../r-bridge/parser").KnownParserType>;
277
- }) => import("../dataflow/info").DataflowInformation;
337
+ }, config: import("../config").FlowrConfigOptions) => import("../dataflow/info").DataflowInformation;
278
338
  readonly requiredInput: {};
279
339
  readonly name: "dataflow";
280
340
  readonly description: "Construct the dataflow graph";
@@ -333,7 +393,7 @@ export declare const SupportedQueries: {
333
393
  }, input: {
334
394
  request?: import("../r-bridge/retriever").RParseRequests;
335
395
  parser?: import("../r-bridge/parser").Parser<import("../r-bridge/parser").KnownParserType>;
336
- }) => import("../dataflow/info").DataflowInformation;
396
+ }, config: import("../config").FlowrConfigOptions) => import("../dataflow/info").DataflowInformation;
337
397
  readonly requiredInput: {};
338
398
  readonly name: "dataflow";
339
399
  readonly description: "Construct the dataflow graph";
@@ -392,7 +452,7 @@ export declare const SupportedQueries: {
392
452
  }, input: {
393
453
  request?: import("../r-bridge/retriever").RParseRequests;
394
454
  parser?: import("../r-bridge/parser").Parser<import("../r-bridge/parser").KnownParserType>;
395
- }) => import("../dataflow/info").DataflowInformation;
455
+ }, config: import("../config").FlowrConfigOptions) => import("../dataflow/info").DataflowInformation;
396
456
  readonly requiredInput: {};
397
457
  readonly name: "dataflow";
398
458
  readonly description: "Construct the dataflow graph";
@@ -451,7 +511,7 @@ export declare const SupportedQueries: {
451
511
  }, input: {
452
512
  request?: import("../r-bridge/retriever").RParseRequests;
453
513
  parser?: import("../r-bridge/parser").Parser<import("../r-bridge/parser").KnownParserType>;
454
- }) => import("../dataflow/info").DataflowInformation;
514
+ }, config: import("../config").FlowrConfigOptions) => import("../dataflow/info").DataflowInformation;
455
515
  readonly requiredInput: {};
456
516
  readonly name: "dataflow";
457
517
  readonly description: "Construct the dataflow graph";
@@ -510,7 +570,7 @@ export declare const SupportedQueries: {
510
570
  }, input: {
511
571
  request?: import("../r-bridge/retriever").RParseRequests;
512
572
  parser?: import("../r-bridge/parser").Parser<import("../r-bridge/parser").KnownParserType>;
513
- }) => import("../dataflow/info").DataflowInformation;
573
+ }, config: import("../config").FlowrConfigOptions) => import("../dataflow/info").DataflowInformation;
514
574
  readonly requiredInput: {};
515
575
  readonly name: "dataflow";
516
576
  readonly description: "Construct the dataflow graph";
@@ -569,7 +629,7 @@ export declare const SupportedQueries: {
569
629
  }, input: {
570
630
  request?: import("../r-bridge/retriever").RParseRequests;
571
631
  parser?: import("../r-bridge/parser").Parser<import("../r-bridge/parser").KnownParserType>;
572
- }) => import("../dataflow/info").DataflowInformation;
632
+ }, config: import("../config").FlowrConfigOptions) => import("../dataflow/info").DataflowInformation;
573
633
  readonly requiredInput: {};
574
634
  readonly name: "dataflow";
575
635
  readonly description: "Construct the dataflow graph";
@@ -634,7 +694,7 @@ export declare const SupportedQueries: {
634
694
  }, input: {
635
695
  request?: import("../r-bridge/retriever").RParseRequests;
636
696
  parser?: import("../r-bridge/parser").Parser<import("../r-bridge/parser").KnownParserType>;
637
- }) => import("../dataflow/info").DataflowInformation;
697
+ }, config: import("../config").FlowrConfigOptions) => import("../dataflow/info").DataflowInformation;
638
698
  readonly requiredInput: {};
639
699
  readonly name: "dataflow";
640
700
  readonly description: "Construct the dataflow graph";
@@ -693,7 +753,7 @@ export declare const SupportedQueries: {
693
753
  }, input: {
694
754
  request?: import("../r-bridge/retriever").RParseRequests;
695
755
  parser?: import("../r-bridge/parser").Parser<import("../r-bridge/parser").KnownParserType>;
696
- }) => import("../dataflow/info").DataflowInformation;
756
+ }, config: import("../config").FlowrConfigOptions) => import("../dataflow/info").DataflowInformation;
697
757
  readonly requiredInput: {};
698
758
  readonly name: "dataflow";
699
759
  readonly description: "Construct the dataflow graph";
@@ -752,7 +812,7 @@ export declare const SupportedQueries: {
752
812
  }, input: {
753
813
  request?: import("../r-bridge/retriever").RParseRequests;
754
814
  parser?: import("../r-bridge/parser").Parser<import("../r-bridge/parser").KnownParserType>;
755
- }) => import("../dataflow/info").DataflowInformation;
815
+ }, config: import("../config").FlowrConfigOptions) => import("../dataflow/info").DataflowInformation;
756
816
  readonly requiredInput: {};
757
817
  readonly name: "dataflow";
758
818
  readonly description: "Construct the dataflow graph";
@@ -811,7 +871,7 @@ export declare const SupportedQueries: {
811
871
  }, input: {
812
872
  request?: import("../r-bridge/retriever").RParseRequests;
813
873
  parser?: import("../r-bridge/parser").Parser<import("../r-bridge/parser").KnownParserType>;
814
- }) => import("../dataflow/info").DataflowInformation;
874
+ }, config: import("../config").FlowrConfigOptions) => import("../dataflow/info").DataflowInformation;
815
875
  readonly requiredInput: {};
816
876
  readonly name: "dataflow";
817
877
  readonly description: "Construct the dataflow graph";
@@ -870,7 +930,7 @@ export declare const SupportedQueries: {
870
930
  }, input: {
871
931
  request?: import("../r-bridge/retriever").RParseRequests;
872
932
  parser?: import("../r-bridge/parser").Parser<import("../r-bridge/parser").KnownParserType>;
873
- }) => import("../dataflow/info").DataflowInformation;
933
+ }, config: import("../config").FlowrConfigOptions) => import("../dataflow/info").DataflowInformation;
874
934
  readonly requiredInput: {};
875
935
  readonly name: "dataflow";
876
936
  readonly description: "Construct the dataflow graph";
@@ -929,7 +989,7 @@ export declare const SupportedQueries: {
929
989
  }, input: {
930
990
  request?: import("../r-bridge/retriever").RParseRequests;
931
991
  parser?: import("../r-bridge/parser").Parser<import("../r-bridge/parser").KnownParserType>;
932
- }) => import("../dataflow/info").DataflowInformation;
992
+ }, config: import("../config").FlowrConfigOptions) => import("../dataflow/info").DataflowInformation;
933
993
  readonly requiredInput: {};
934
994
  readonly name: "dataflow";
935
995
  readonly description: "Construct the dataflow graph";
package/queries/query.js CHANGED
@@ -31,12 +31,14 @@ const project_query_format_1 = require("./catalog/project-query/project-query-fo
31
31
  const origin_query_format_1 = require("./catalog/origin-query/origin-query-format");
32
32
  const linter_query_format_1 = require("./catalog/linter-query/linter-query-format");
33
33
  const control_flow_query_format_1 = require("./catalog/control-flow-query/control-flow-query-format");
34
+ const df_shape_query_format_1 = require("./catalog/df-shape-query/df-shape-query-format");
34
35
  exports.SupportedQueries = {
35
36
  'call-context': call_context_query_format_1.CallContextQueryDefinition,
36
37
  'config': config_query_format_1.ConfigQueryDefinition,
37
38
  'control-flow': control_flow_query_format_1.ControlFlowQueryDefinition,
38
39
  'dataflow': dataflow_query_format_1.DataflowQueryDefinition,
39
40
  'dataflow-lens': dataflow_lens_query_format_1.DataflowLensQueryDefinition,
41
+ 'df-shape': df_shape_query_format_1.DfShapeQueryDefinition,
40
42
  'id-map': id_map_query_format_1.IdMapQueryDefinition,
41
43
  'normalized-ast': normalized_ast_query_format_1.NormalizedAstQueryDefinition,
42
44
  'dataflow-cluster': cluster_query_format_1.ClusterQueryDefinition,
@@ -2,6 +2,7 @@ import type { IdGenerator, NormalizedAst } from '../../model/processing/decorate
2
2
  import type { NoInfo, RNode } from '../../model/model';
3
3
  import type { ParseStepOutputTS } from '../../../../../core/steps/all/core/01-parse-tree-sitter';
4
4
  import type { ParseStepOutput } from '../../../../parser';
5
+ import type { FlowrConfigOptions } from '../../../../../config';
5
6
  export declare const parseLog: import("tslog").Logger<import("tslog").ILogObj>;
6
7
  /**
7
8
  * Take the output as produced by the parse step and normalize the AST from the R parser.
@@ -18,4 +19,4 @@ export declare function normalizeButNotDecorated({ parsed }: ParseStepOutput<str
18
19
  /**
19
20
  * Tree-Sitter pendant to {@link normalize}.
20
21
  */
21
- export declare function normalizeTreeSitter({ parsed }: ParseStepOutputTS, getId?: IdGenerator<NoInfo>, file?: string): NormalizedAst;
22
+ export declare function normalizeTreeSitter({ parsed }: ParseStepOutputTS, getId: IdGenerator<NoInfo> | undefined, config: FlowrConfigOptions, file?: string): NormalizedAst;
@@ -9,6 +9,7 @@ const log_1 = require("../../../../../util/log");
9
9
  const decorate_1 = require("../../model/processing/decorate");
10
10
  const normalize_root_1 = require("../main/internal/structure/normalize-root");
11
11
  const tree_sitter_normalize_1 = require("../../../tree-sitter/tree-sitter-normalize");
12
+ const config_1 = require("../../../../../config");
12
13
  exports.parseLog = log_1.log.getSubLogger({ name: 'ast-parser' });
13
14
  /**
14
15
  * Take the output as produced by the parse step and normalize the AST from the R parser.
@@ -31,8 +32,9 @@ function normalizeButNotDecorated({ parsed }) {
31
32
  /**
32
33
  * Tree-Sitter pendant to {@link normalize}.
33
34
  */
34
- function normalizeTreeSitter({ parsed }, getId = (0, decorate_1.deterministicCountingIdGenerator)(0), file) {
35
- const result = (0, decorate_1.decorateAst)((0, tree_sitter_normalize_1.normalizeTreeSitterTreeToAst)(parsed), { getId, file });
35
+ function normalizeTreeSitter({ parsed }, getId = (0, decorate_1.deterministicCountingIdGenerator)(0), config, file) {
36
+ const lax = (0, config_1.getEngineConfig)(config, 'tree-sitter')?.lax;
37
+ const result = (0, decorate_1.decorateAst)((0, tree_sitter_normalize_1.normalizeTreeSitterTreeToAst)(parsed, lax), { getId, file });
36
38
  result.hasError = parsed.rootNode.hasError;
37
39
  return result;
38
40
  }
@@ -7,6 +7,7 @@ exports.boolean2ts = boolean2ts;
7
7
  exports.number2ts = number2ts;
8
8
  exports.string2ts = string2ts;
9
9
  exports.isNA = isNA;
10
+ const strings_1 = require("../../util/text/strings");
10
11
  class ValueConversionError extends Error {
11
12
  constructor(message) {
12
13
  super(message);
@@ -136,7 +137,7 @@ function string2ts(value) {
136
137
  const flags = value[1];
137
138
  if (flags === '"' || flags === '\'') {
138
139
  return {
139
- str: value.slice(2, -1),
140
+ str: (0, strings_1.dropRawStringSurround)(value.slice(2, -1)),
140
141
  quotes: flags,
141
142
  flag: 'raw'
142
143
  };
@@ -1,6 +1,7 @@
1
1
  import Parser from 'web-tree-sitter';
2
2
  import type { RParseRequest } from '../../retriever';
3
3
  import type { SyncParser } from '../../parser';
4
+ import type { TreeSitterEngineConfig } from '../../../config';
4
5
  export declare const DEFAULT_TREE_SITTER_R_WASM_PATH = "./node_modules/@eagleoutice/tree-sitter-r/tree-sitter-r.wasm";
5
6
  export declare const DEFAULT_TREE_SITTER_WASM_PATH = "./node_modules/web-tree-sitter/tree-sitter.wasm";
6
7
  /**
@@ -12,10 +13,11 @@ export declare class TreeSitterExecutor implements SyncParser<Parser.Tree> {
12
13
  private static language;
13
14
  /**
14
15
  * Initializes the underlying tree-sitter parser. This only needs to be called once globally.
16
+ * @param config - The configuration for the tree-sitter engine, which can include paths to the wasm files.
15
17
  * @param overrideWasmPath - The path to the tree-sitter-r wasm file, which takes precedence over the config and default paths if set.
16
18
  * @param overrideTreeSitterWasmPath - The path to the tree-sitter wasm file, which takes precedence over the config and default paths if set.
17
19
  */
18
- static initTreeSitter(overrideWasmPath?: string, overrideTreeSitterWasmPath?: string): Promise<void>;
20
+ static initTreeSitter(config?: TreeSitterEngineConfig, overrideWasmPath?: string, overrideTreeSitterWasmPath?: string): Promise<void>;
19
21
  constructor();
20
22
  rVersion(): Promise<string | 'unknown' | 'none'>;
21
23
  treeSitterVersion(): number;
@@ -6,7 +6,6 @@ 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
8
  const fs_1 = __importDefault(require("fs"));
9
- const config_1 = require("../../../config");
10
9
  const log_1 = require("../../../util/log");
11
10
  exports.DEFAULT_TREE_SITTER_R_WASM_PATH = './node_modules/@eagleoutice/tree-sitter-r/tree-sitter-r.wasm';
12
11
  exports.DEFAULT_TREE_SITTER_WASM_PATH = './node_modules/web-tree-sitter/tree-sitter.wasm';
@@ -20,11 +19,12 @@ class TreeSitterExecutor {
20
19
  static language;
21
20
  /**
22
21
  * Initializes the underlying tree-sitter parser. This only needs to be called once globally.
22
+ * @param config - The configuration for the tree-sitter engine, which can include paths to the wasm files.
23
23
  * @param overrideWasmPath - The path to the tree-sitter-r wasm file, which takes precedence over the config and default paths if set.
24
24
  * @param overrideTreeSitterWasmPath - The path to the tree-sitter wasm file, which takes precedence over the config and default paths if set.
25
25
  */
26
- static async initTreeSitter(overrideWasmPath, overrideTreeSitterWasmPath) {
27
- const treeSitterWasmPath = overrideTreeSitterWasmPath ?? (0, config_1.getEngineConfig)('tree-sitter')?.treeSitterWasmPath ?? exports.DEFAULT_TREE_SITTER_WASM_PATH;
26
+ static async initTreeSitter(config, overrideWasmPath, overrideTreeSitterWasmPath) {
27
+ const treeSitterWasmPath = overrideTreeSitterWasmPath ?? config?.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
30
  locateFile: treeSitterWasmPath ? (path, prefix) => {
@@ -38,7 +38,7 @@ class TreeSitterExecutor {
38
38
  print: (s) => wasmLog.debug(s),
39
39
  printErr: (s) => wasmLog.error(s)
40
40
  });
41
- const wasmPath = overrideWasmPath ?? (0, config_1.getEngineConfig)('tree-sitter')?.wasmPath ?? exports.DEFAULT_TREE_SITTER_R_WASM_PATH;
41
+ const wasmPath = overrideWasmPath ?? config?.wasmPath ?? exports.DEFAULT_TREE_SITTER_R_WASM_PATH;
42
42
  TreeSitterExecutor.language = await web_tree_sitter_1.default.Language.load(wasmPath);
43
43
  }
44
44
  constructor() {
@@ -3,6 +3,6 @@ import type { Tree } from 'web-tree-sitter';
3
3
  /**
4
4
  * @param tree - The tree to normalize
5
5
  */
6
- export declare function normalizeTreeSitterTreeToAst(tree: Tree): RExpressionList;
6
+ export declare function normalizeTreeSitterTreeToAst(tree: Tree, lax?: boolean): RExpressionList;
7
7
  export declare function makeTreeSitterLax(): void;
8
8
  export declare function makeTreeSitterStrict(): void;
@@ -12,13 +12,11 @@ const normalize_meta_1 = require("../ast/parser/main/normalize-meta");
12
12
  const arrays_1 = require("../../../util/collections/arrays");
13
13
  const r_function_call_1 = require("../ast/model/nodes/r-function-call");
14
14
  const strings_1 = require("../../../util/text/strings");
15
- const config_1 = require("../../../config");
16
15
  const log_1 = require("../../../util/log");
17
16
  /**
18
17
  * @param tree - The tree to normalize
19
18
  */
20
- function normalizeTreeSitterTreeToAst(tree) {
21
- const lax = (0, config_1.getEngineConfig)('tree-sitter')?.lax;
19
+ function normalizeTreeSitterTreeToAst(tree, lax) {
22
20
  if (lax) {
23
21
  makeTreeSitterLax();
24
22
  }
@@ -343,14 +341,18 @@ function convertTreeNode(node) {
343
341
  }
344
342
  case tree_sitter_types_1.TreeSitterType.FunctionDefinition: {
345
343
  const [name, paramsParens, body] = nonErrorChildren(node);
346
- const params = (0, arrays_1.splitArrayOn)(paramsParens.children.slice(1, -1), x => x.type === 'comma');
344
+ const [comments, noCommentRawParams] = splitComments(paramsParens.children.slice(1, -1));
345
+ const params = (0, arrays_1.splitArrayOn)(noCommentRawParams, x => x.type === 'comma');
347
346
  return {
348
347
  type: type_1.RType.FunctionDefinition,
349
348
  parameters: params.map(n => convertTreeNode(n[0])),
350
349
  body: (0, normalize_meta_1.ensureExpressionList)(convertTreeNode(body)),
351
350
  location: makeSourceRange(name),
352
351
  lexeme: name.text,
353
- ...defaultInfo
352
+ info: {
353
+ ...defaultInfo.info,
354
+ additionalTokens: comments.map(c => c[1]),
355
+ }
354
356
  };
355
357
  }
356
358
  case tree_sitter_types_1.TreeSitterType.String:
@@ -1,6 +1,7 @@
1
1
  import { type MergeableRecord } from '../util/objects';
2
2
  import type { SemVer } from 'semver';
3
3
  import type { AsyncOrSync } from 'ts-essentials';
4
+ import type { RShellEngineConfig } from '../config';
4
5
  import type { AsyncParser } from './parser';
5
6
  import type { RParseRequest } from './retriever';
6
7
  export type OutputStreamSelector = 'stdout' | 'stderr' | 'both';
@@ -68,7 +69,7 @@ export interface RShellOptions extends RShellSessionOptions {
68
69
  readonly sessionName: string;
69
70
  }
70
71
  export declare const DEFAULT_R_PATH: string;
71
- export declare function getDefaultRShellOptions(): RShellOptions;
72
+ export declare function getDefaultRShellOptions(config?: RShellEngineConfig): RShellOptions;
72
73
  /**
73
74
  * The `RShell` represents an interactive session with the R interpreter.
74
75
  * You can configure it by {@link RShellOptions}.
@@ -85,7 +86,7 @@ export declare class RShell implements AsyncParser<string> {
85
86
  private readonly log;
86
87
  private versionCache;
87
88
  private tempDirs;
88
- constructor(options?: Partial<RShellOptions>);
89
+ constructor(config?: RShellEngineConfig, options?: Partial<RShellOptions>);
89
90
  parse(request: RParseRequest): Promise<string>;
90
91
  private revive;
91
92
  /**
package/r-bridge/shell.js CHANGED
@@ -46,7 +46,6 @@ const preload_1 = __importDefault(require("semver/preload"));
46
46
  const os_1 = require("../util/os");
47
47
  const fs_1 = __importDefault(require("fs"));
48
48
  const init_1 = require("./init");
49
- const config_1 = require("../config");
50
49
  const convert_values_1 = require("./lang-4.x/convert-values");
51
50
  const retriever_1 = require("./retriever");
52
51
  exports.DEFAULT_OUTPUT_COLLECTOR_CONFIGURATION = {
@@ -62,10 +61,10 @@ exports.DEFAULT_OUTPUT_COLLECTOR_CONFIGURATION = {
62
61
  };
63
62
  exports.DEFAULT_R_PATH = (0, os_1.getPlatform)() === 'windows' ? 'R.exe' : 'R';
64
63
  let DEFAULT_R_SHELL_OPTIONS = undefined;
65
- function getDefaultRShellOptions() {
64
+ function getDefaultRShellOptions(config) {
66
65
  if (!DEFAULT_R_SHELL_OPTIONS) {
67
66
  DEFAULT_R_SHELL_OPTIONS = {
68
- pathToRExecutable: (0, config_1.getEngineConfig)('r-shell')?.rPath ?? exports.DEFAULT_R_PATH,
67
+ pathToRExecutable: config?.rPath ?? exports.DEFAULT_R_PATH,
69
68
  // -s is a short form of --no-echo (and the old version --slave), but this one works in R 3 and 4
70
69
  // (see https://github.com/wch/r-source/commit/f1ff49e74593341c74c20de9517f31a22c8bcb04)
71
70
  commandLineOptions: ['--vanilla', '--quiet', '--no-save', '-s'],
@@ -97,8 +96,8 @@ class RShell {
97
96
  versionCache = null;
98
97
  // should never be more than one, but let's be sure
99
98
  tempDirs = new Set();
100
- constructor(options) {
101
- this.options = { ...getDefaultRShellOptions(), ...options };
99
+ constructor(config, options) {
100
+ this.options = { ...getDefaultRShellOptions(config), ...options };
102
101
  this.log = log_1.log.getSubLogger({ name: this.options.sessionName });
103
102
  this.session = new RShellSession(this.options, this.log);
104
103
  this.revive();
@@ -1,6 +1,6 @@
1
1
  import type { NodeId } from '../r-bridge/lang-4.x/ast/model/processing/node-id';
2
2
  import type { FlowrSearchElement, FlowrSearchElementFromQuery, FlowrSearchElements, FlowrSearchGetFilter } from './flowr-search';
3
- import type { FlowrFilterExpression } from './flowr-search-filters';
3
+ import type { FlowrFilter, 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';
@@ -155,7 +155,7 @@ export declare class FlowrSearchBuilder<Generator extends GeneratorNames, Transf
155
155
  /**
156
156
  * only returns the elements that match the given filter.
157
157
  */
158
- filter(filter: FlowrFilterExpression): FlowrSearchBuilderOut<Generator, Transformers, Info, 'filter'>;
158
+ filter<Filter extends FlowrFilter>(filter: FlowrFilterExpression<Filter>): FlowrSearchBuilderOut<Generator, Transformers, Info, 'filter'>;
159
159
  /**
160
160
  * first either returns the first element of the search or nothing, if no elements are present.
161
161
  */
@@ -201,6 +201,10 @@ export declare class FlowrSearchBuilder<Generator extends GeneratorNames, Transf
201
201
  * merge combines the search results with those of another search.
202
202
  */
203
203
  merge<Generator2 extends GeneratorNames, Transformers2 extends TransformerNames[], OtherElementType extends FlowrSearchElements<Info, FlowrSearchElement<Info>[]>>(other: FlowrSearchBuilder<Generator2, Transformers2, Info, OtherElementType>): FlowrSearchBuilder<Generator, Transformers, Info>;
204
+ /**
205
+ * Removes duplicate elements based on the ids of the elements.
206
+ */
207
+ unique(): FlowrSearchBuilderOut<Generator, Transformers, Info, 'unique'>;
204
208
  /**
205
209
  * Construct the final search (this may happen automatically with most search handlers).
206
210
  *
@@ -195,6 +195,13 @@ class FlowrSearchBuilder {
195
195
  this.search.push({ type: 'transformer', name: 'merge', args: { generator: other.generator, search: other.search } });
196
196
  return this;
197
197
  }
198
+ /**
199
+ * Removes duplicate elements based on the ids of the elements.
200
+ */
201
+ unique() {
202
+ this.search.push({ type: 'transformer', name: 'unique', args: undefined });
203
+ return this;
204
+ }
198
205
  /**
199
206
  * Construct the final search (this may happen automatically with most search handlers).
200
207
  *
@@ -2,23 +2,47 @@ import { RType } from '../r-bridge/lang-4.x/ast/model/type';
2
2
  import type { VertexType } from '../dataflow/graph/vertex';
3
3
  import type { NormalizedAst, ParentInformation } from '../r-bridge/lang-4.x/ast/model/processing/decorate';
4
4
  import type { DataflowInformation } from '../dataflow/info';
5
- import type { RNode } from '../r-bridge/lang-4.x/ast/model/model';
5
+ import type { FlowrSearchElement } from './flowr-search';
6
+ import type { MergeableRecord } from '../util/objects';
7
+ import type { Enrichment } from './search-executor/search-enrichers';
6
8
  export type FlowrFilterName = keyof typeof FlowrFilters;
9
+ interface FlowrFilterWithArgs<Filter extends FlowrFilterName, Args extends FlowrFilterArgs<Filter>> {
10
+ name: Filter;
11
+ args: Args;
12
+ }
7
13
  export declare enum FlowrFilter {
8
- DropEmptyArguments = "drop-empty-arguments"
14
+ /**
15
+ * Drops search elements that represent empty arguments. Specifically, all nodes that are arguments and have an undefined name are skipped.
16
+ * This filter does not accept any arguments.
17
+ */
18
+ DropEmptyArguments = "drop-empty-arguments",
19
+ /**
20
+ * Only returns search elements whose enrichments' JSON representations match a given test regular expression.
21
+ * This filter accepts {@link MatchesEnrichmentArgs}, which includes the enrichment to match for, as well as the regular expression to test the enrichment's (non-pretty-printed) JSON representation for.
22
+ * To test for included function names in an enrichment like {@link Enrichment.CallTargets}, the helper function {@link testFunctionsIgnoringPackage} can be used.
23
+ */
24
+ MatchesEnrichment = "matches-enrichment"
9
25
  }
26
+ export type FlowrFilterFunction<T extends MergeableRecord> = (e: FlowrSearchElement<ParentInformation>, args: T) => boolean;
10
27
  export declare const ValidFlowrFilters: Set<string>;
11
28
  export declare const ValidFlowrFiltersReverse: {
12
29
  [k: string]: string;
13
30
  };
14
31
  export declare const FlowrFilters: {
15
- readonly "drop-empty-arguments": (n: RNode<ParentInformation>) => boolean;
32
+ readonly "drop-empty-arguments": (e: FlowrSearchElement<ParentInformation>, _args: never) => boolean;
33
+ readonly "matches-enrichment": (e: FlowrSearchElement<ParentInformation>, args: MatchesEnrichmentArgs<Enrichment>) => boolean;
16
34
  };
17
- type ValidFilterTypes = FlowrFilterName | RType | VertexType;
35
+ export type FlowrFilterArgs<F extends FlowrFilter> = typeof FlowrFilters[F] extends FlowrFilterFunction<infer Args> ? Args : never;
36
+ export interface MatchesEnrichmentArgs<E extends Enrichment> extends MergeableRecord {
37
+ enrichment: E;
38
+ test: RegExp;
39
+ }
40
+ export declare function testFunctionsIgnoringPackage(functions: string[]): RegExp;
41
+ type ValidFilterTypes<F extends FlowrFilter = FlowrFilter> = FlowrFilterName | FlowrFilterWithArgs<F, FlowrFilterArgs<F>> | RType | VertexType;
18
42
  /**
19
43
  * By default, we provide filter for every {@link RType} and {@link VertexType}.
20
44
  */
21
- export type FlowrFilterExpression = FlowrFilterCombinator | ValidFilterTypes;
45
+ export type FlowrFilterExpression<F extends FlowrFilter = FlowrFilter> = FlowrFilterCombinator | ValidFilterTypes<F>;
22
46
  interface BooleanBinaryNode<Composite> {
23
47
  readonly type: 'and' | 'or' | 'xor';
24
48
  readonly left: Composite;
@@ -38,7 +62,7 @@ type LeafVertexType = {
38
62
  };
39
63
  type LeafSpecial = {
40
64
  readonly type: 'special';
41
- readonly value: string;
65
+ readonly value: FlowrFilterName | FlowrFilterWithArgs<FlowrFilter, FlowrFilterArgs<FlowrFilter>>;
42
66
  };
43
67
  type Leaf = LeafRType | LeafVertexType | LeafSpecial;
44
68
  type BooleanNode = BooleanBinaryNode<BooleanNode> | BooleanUnaryNode<BooleanNode> | Leaf;
@@ -66,9 +90,9 @@ export declare function isBinaryTree(tree: unknown): tree is {
66
90
  tree: BooleanNode;
67
91
  };
68
92
  interface FilterData {
69
- readonly node: RNode<ParentInformation>;
93
+ readonly element: FlowrSearchElement<ParentInformation>;
70
94
  readonly normalize: NormalizedAst;
71
95
  readonly dataflow: DataflowInformation;
72
96
  }
73
- export declare function evalFilter(filter: FlowrFilterExpression, data: FilterData): boolean;
97
+ export declare function evalFilter<Filter extends FlowrFilter>(filter: FlowrFilterExpression<Filter>, data: FilterData): boolean;
74
98
  export {};