@eagleoutice/flowr 2.2.14 → 2.2.16

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 (245) hide show
  1. package/README.md +210 -6
  2. package/benchmark/slicer.d.ts +3 -1
  3. package/benchmark/slicer.js +8 -5
  4. package/benchmark/summarizer/first-phase/process.d.ts +2 -1
  5. package/benchmark/summarizer/first-phase/process.js +2 -2
  6. package/cli/benchmark-app.d.ts +1 -0
  7. package/cli/benchmark-app.js +4 -1
  8. package/cli/benchmark-helper-app.d.ts +1 -0
  9. package/cli/benchmark-helper-app.js +7 -8
  10. package/cli/common/options.js +2 -0
  11. package/cli/export-quads-app.js +2 -1
  12. package/cli/flowr.js +58 -57
  13. package/cli/repl/commands/repl-cfg.js +13 -13
  14. package/cli/repl/commands/repl-commands.js +3 -3
  15. package/cli/repl/commands/repl-dataflow.js +10 -10
  16. package/cli/repl/commands/repl-execute.d.ts +2 -3
  17. package/cli/repl/commands/repl-execute.js +5 -4
  18. package/cli/repl/commands/repl-lineage.js +4 -4
  19. package/cli/repl/commands/repl-main.d.ts +12 -1
  20. package/cli/repl/commands/repl-normalize.js +6 -6
  21. package/cli/repl/commands/repl-parse.js +2 -2
  22. package/cli/repl/commands/repl-query.js +9 -9
  23. package/cli/repl/commands/repl-version.js +1 -1
  24. package/cli/repl/core.d.ts +5 -2
  25. package/cli/repl/core.js +10 -8
  26. package/cli/repl/server/connection.d.ts +3 -1
  27. package/cli/repl/server/connection.js +7 -5
  28. package/cli/repl/server/server.d.ts +3 -2
  29. package/cli/repl/server/server.js +4 -2
  30. package/cli/script-core/statistics-core.d.ts +2 -1
  31. package/cli/script-core/statistics-core.js +2 -2
  32. package/cli/script-core/statistics-helper-core.d.ts +2 -1
  33. package/cli/script-core/statistics-helper-core.js +5 -4
  34. package/cli/slicer-app.js +4 -2
  35. package/cli/statistics-app.js +2 -1
  36. package/cli/statistics-helper-app.js +2 -1
  37. package/config.d.ts +12 -10
  38. package/config.js +27 -43
  39. package/control-flow/basic-cfg-guided-visitor.d.ts +3 -3
  40. package/control-flow/cfg-dead-code.d.ts +4 -0
  41. package/control-flow/cfg-dead-code.js +124 -0
  42. package/control-flow/cfg-simplification.d.ts +19 -6
  43. package/control-flow/cfg-simplification.js +23 -19
  44. package/control-flow/control-flow-graph.d.ts +3 -1
  45. package/control-flow/control-flow-graph.js +5 -0
  46. package/control-flow/dfg-cfg-guided-visitor.d.ts +9 -7
  47. package/control-flow/dfg-cfg-guided-visitor.js +16 -5
  48. package/control-flow/extract-cfg.d.ts +4 -2
  49. package/control-flow/extract-cfg.js +63 -59
  50. package/control-flow/semantic-cfg-guided-visitor.d.ts +36 -9
  51. package/control-flow/semantic-cfg-guided-visitor.js +73 -20
  52. package/control-flow/simple-visitor.d.ts +4 -0
  53. package/control-flow/simple-visitor.js +14 -0
  54. package/control-flow/syntax-cfg-guided-visitor.d.ts +2 -2
  55. package/core/pipeline-executor.d.ts +4 -1
  56. package/core/pipeline-executor.js +6 -5
  57. package/core/steps/all/core/10-normalize.d.ts +2 -0
  58. package/core/steps/all/core/10-normalize.js +1 -1
  59. package/core/steps/all/core/11-normalize-tree-sitter.d.ts +2 -1
  60. package/core/steps/all/core/11-normalize-tree-sitter.js +2 -2
  61. package/core/steps/all/core/20-dataflow.d.ts +2 -1
  62. package/core/steps/all/core/20-dataflow.js +2 -2
  63. package/core/steps/all/static-slicing/00-slice.d.ts +2 -1
  64. package/core/steps/all/static-slicing/00-slice.js +2 -2
  65. package/core/steps/pipeline/default-pipelines.d.ts +32 -31
  66. package/core/steps/pipeline/default-pipelines.js +8 -8
  67. package/core/steps/pipeline-step.d.ts +2 -1
  68. package/dataflow/environments/built-in-config.d.ts +4 -3
  69. package/dataflow/environments/built-in.d.ts +16 -1
  70. package/dataflow/environments/built-in.js +11 -5
  71. package/dataflow/environments/default-builtin-config.js +5 -3
  72. package/dataflow/environments/define.d.ts +2 -1
  73. package/dataflow/environments/define.js +4 -5
  74. package/dataflow/environments/remove.d.ts +6 -0
  75. package/dataflow/environments/remove.js +29 -0
  76. package/dataflow/environments/resolve-by-name.d.ts +0 -36
  77. package/dataflow/environments/resolve-by-name.js +0 -240
  78. package/dataflow/eval/resolve/alias-tracking.d.ts +92 -0
  79. package/dataflow/eval/resolve/alias-tracking.js +352 -0
  80. package/dataflow/eval/resolve/resolve-argument.d.ts +8 -0
  81. package/dataflow/eval/resolve/resolve-argument.js +118 -0
  82. package/dataflow/eval/resolve/resolve.d.ts +37 -0
  83. package/dataflow/eval/resolve/resolve.js +95 -0
  84. package/dataflow/eval/values/general.d.ts +27 -0
  85. package/dataflow/eval/values/general.js +73 -0
  86. package/dataflow/eval/values/intervals/interval-constants.d.ts +4 -0
  87. package/dataflow/eval/values/intervals/interval-constants.js +27 -0
  88. package/dataflow/eval/values/logical/logical-constants.d.ts +7 -0
  89. package/dataflow/eval/values/logical/logical-constants.js +31 -0
  90. package/dataflow/eval/values/r-value.d.ts +58 -0
  91. package/dataflow/eval/values/r-value.js +90 -0
  92. package/dataflow/eval/values/scalar/scalar-consatnts.d.ts +15 -0
  93. package/dataflow/eval/values/scalar/scalar-consatnts.js +35 -0
  94. package/dataflow/eval/values/sets/set-constants.d.ts +7 -0
  95. package/dataflow/eval/values/sets/set-constants.js +34 -0
  96. package/dataflow/eval/values/string/string-constants.d.ts +8 -0
  97. package/dataflow/eval/values/string/string-constants.js +45 -0
  98. package/dataflow/eval/values/vectors/vector-constants.d.ts +14 -0
  99. package/dataflow/eval/values/vectors/vector-constants.js +35 -0
  100. package/dataflow/extractor.d.ts +2 -1
  101. package/dataflow/extractor.js +2 -1
  102. package/dataflow/graph/unknown-replacement.d.ts +11 -0
  103. package/dataflow/graph/unknown-replacement.js +12 -0
  104. package/dataflow/graph/unknown-side-effect.d.ts +7 -0
  105. package/dataflow/graph/unknown-side-effect.js +13 -0
  106. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +5 -6
  107. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +8 -5
  108. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +4 -2
  109. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +15 -13
  110. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +20 -18
  111. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +7 -2
  112. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +2 -3
  113. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +5 -4
  114. package/dataflow/internal/process/functions/call/built-in/built-in-list.js +2 -2
  115. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +11 -5
  116. package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +5 -3
  117. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +26 -29
  118. package/dataflow/internal/process/functions/call/built-in/built-in-vector.js +2 -2
  119. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +23 -0
  120. package/dataflow/internal/process/functions/call/common.js +1 -1
  121. package/dataflow/internal/process/functions/call/known-call-handling.js +2 -1
  122. package/dataflow/internal/process/functions/process-parameter.js +1 -1
  123. package/dataflow/origin/dfg-get-symbol-refs.d.ts +21 -0
  124. package/dataflow/origin/dfg-get-symbol-refs.js +50 -0
  125. package/dataflow/processor.d.ts +5 -0
  126. package/documentation/doc-util/doc-cfg.js +4 -3
  127. package/documentation/doc-util/doc-code.d.ts +1 -1
  128. package/documentation/doc-util/doc-dfg.js +3 -2
  129. package/documentation/doc-util/doc-functions.d.ts +24 -0
  130. package/documentation/doc-util/doc-functions.js +65 -0
  131. package/documentation/doc-util/doc-normalized-ast.js +3 -2
  132. package/documentation/doc-util/doc-print.d.ts +5 -0
  133. package/documentation/doc-util/doc-print.js +36 -0
  134. package/documentation/doc-util/doc-query.d.ts +6 -3
  135. package/documentation/doc-util/doc-query.js +6 -3
  136. package/documentation/doc-util/doc-repl.js +2 -1
  137. package/documentation/doc-util/doc-search.js +3 -2
  138. package/documentation/doc-util/doc-types.d.ts +28 -6
  139. package/documentation/doc-util/doc-types.js +89 -45
  140. package/documentation/print-cfg-wiki.js +10 -11
  141. package/documentation/print-core-wiki.js +5 -5
  142. package/documentation/print-dataflow-graph-wiki.js +14 -13
  143. package/documentation/print-engines-wiki.js +2 -3
  144. package/documentation/print-faq-wiki.js +8 -2
  145. package/documentation/print-interface-wiki.js +1 -2
  146. package/documentation/print-linter-issue.d.ts +1 -0
  147. package/documentation/print-linter-issue.js +71 -0
  148. package/documentation/print-linter-wiki.js +219 -34
  149. package/documentation/print-linting-and-testing-wiki.js +2 -4
  150. package/documentation/print-normalized-ast-wiki.js +3 -3
  151. package/documentation/print-query-wiki.js +81 -2
  152. package/documentation/print-readme.js +24 -1
  153. package/documentation/print-search-wiki.js +1 -2
  154. package/linter/linter-executor.d.ts +3 -1
  155. package/linter/linter-executor.js +3 -2
  156. package/linter/linter-format.d.ts +67 -7
  157. package/linter/linter-format.js +12 -1
  158. package/linter/linter-rules.d.ts +155 -16
  159. package/linter/linter-rules.js +12 -4
  160. package/linter/linter-tags.d.ts +80 -0
  161. package/linter/linter-tags.js +85 -0
  162. package/linter/rules/absolute-path.d.ts +71 -0
  163. package/linter/rules/absolute-path.js +177 -0
  164. package/linter/rules/deprecated-functions.d.ts +43 -0
  165. package/linter/rules/deprecated-functions.js +58 -0
  166. package/linter/rules/{2-file-path-validity.d.ts → file-path-validity.d.ts} +16 -6
  167. package/linter/rules/{2-file-path-validity.js → file-path-validity.js} +21 -13
  168. package/linter/rules/naming-convention.d.ts +71 -0
  169. package/linter/rules/naming-convention.js +164 -0
  170. package/linter/rules/seeded-randomness.d.ts +65 -0
  171. package/linter/rules/seeded-randomness.js +122 -0
  172. package/linter/rules/unused-definition.d.ts +41 -0
  173. package/linter/rules/unused-definition.js +105 -0
  174. package/package.json +4 -1
  175. package/queries/base-query-format.d.ts +2 -0
  176. package/queries/catalog/call-context-query/call-context-query-executor.d.ts +1 -1
  177. package/queries/catalog/call-context-query/call-context-query-executor.js +2 -2
  178. package/queries/catalog/cluster-query/cluster-query-format.d.ts +1 -1
  179. package/queries/catalog/config-query/config-query-executor.d.ts +1 -1
  180. package/queries/catalog/config-query/config-query-executor.js +2 -3
  181. package/queries/catalog/control-flow-query/control-flow-query-executor.d.ts +3 -0
  182. package/queries/catalog/control-flow-query/control-flow-query-executor.js +20 -0
  183. package/queries/catalog/control-flow-query/control-flow-query-format.d.ts +81 -0
  184. package/queries/catalog/control-flow-query/control-flow-query-format.js +34 -0
  185. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.d.ts +1 -1
  186. package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +1 -1
  187. package/queries/catalog/dependencies-query/dependencies-query-executor.js +4 -115
  188. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +1 -1
  189. package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +1 -1
  190. package/queries/catalog/id-map-query/id-map-query-format.d.ts +1 -1
  191. package/queries/catalog/lineage-query/lineage-query-format.d.ts +1 -1
  192. package/queries/catalog/linter-query/linter-query-executor.d.ts +1 -1
  193. package/queries/catalog/linter-query/linter-query-executor.js +2 -2
  194. package/queries/catalog/linter-query/linter-query-format.d.ts +1 -1
  195. package/queries/catalog/linter-query/linter-query-format.js +17 -12
  196. package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +1 -1
  197. package/queries/catalog/origin-query/origin-query-format.d.ts +1 -1
  198. package/queries/catalog/project-query/project-query-format.d.ts +1 -1
  199. package/queries/catalog/resolve-value-query/resolve-value-query-executor.d.ts +1 -1
  200. package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +4 -4
  201. package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +3 -2
  202. package/queries/catalog/resolve-value-query/resolve-value-query-format.js +2 -22
  203. package/queries/catalog/search-query/search-query-executor.d.ts +1 -1
  204. package/queries/catalog/search-query/search-query-executor.js +2 -2
  205. package/queries/catalog/search-query/search-query-format.d.ts +1 -1
  206. package/queries/catalog/static-slice-query/static-slice-query-executor.d.ts +1 -1
  207. package/queries/catalog/static-slice-query/static-slice-query-executor.js +2 -2
  208. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +1 -1
  209. package/queries/query.d.ts +75 -15
  210. package/queries/query.js +2 -0
  211. package/r-bridge/lang-4.x/ast/parser/json/parser.d.ts +2 -1
  212. package/r-bridge/lang-4.x/ast/parser/json/parser.js +4 -2
  213. package/r-bridge/lang-4.x/convert-values.js +2 -1
  214. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.d.ts +3 -1
  215. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +4 -4
  216. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.d.ts +1 -1
  217. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +18 -9
  218. package/r-bridge/shell.d.ts +3 -2
  219. package/r-bridge/shell.js +4 -5
  220. package/search/flowr-search-builder.d.ts +6 -2
  221. package/search/flowr-search-builder.js +7 -0
  222. package/search/flowr-search-filters.d.ts +32 -8
  223. package/search/flowr-search-filters.js +42 -15
  224. package/search/flowr-search.d.ts +4 -0
  225. package/search/search-executor/search-enrichers.d.ts +7 -3
  226. package/search/search-executor/search-enrichers.js +32 -20
  227. package/search/search-executor/search-generators.js +1 -1
  228. package/search/search-executor/search-transformer.d.ts +2 -0
  229. package/search/search-executor/search-transformer.js +10 -1
  230. package/slicing/criterion/parse.d.ts +8 -0
  231. package/slicing/criterion/parse.js +20 -0
  232. package/slicing/static/static-slicer.d.ts +1 -1
  233. package/slicing/static/static-slicer.js +2 -3
  234. package/statistics/statistics.d.ts +3 -1
  235. package/statistics/statistics.js +5 -4
  236. package/util/containers.d.ts +12 -9
  237. package/util/containers.js +12 -9
  238. package/util/objects.d.ts +5 -4
  239. package/util/range.d.ts +5 -1
  240. package/util/range.js +11 -3
  241. package/util/text/strings.d.ts +6 -0
  242. package/util/text/strings.js +35 -0
  243. package/util/version.js +1 -1
  244. package/linter/rules/1-deprecated-functions.d.ts +0 -34
  245. package/linter/rules/1-deprecated-functions.js +0 -54
@@ -23,7 +23,8 @@ import type { ProjectQuery } from './catalog/project-query/project-query-format'
23
23
  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
- export type Query = CallContextQuery | ConfigQuery | SearchQuery | DataflowQuery | DataflowLensQuery | NormalizedAstQuery | IdMapQuery | DataflowClusterQuery | StaticSliceQuery | LineageQuery | DependenciesQuery | LocationMapQuery | HappensBeforeQuery | ResolveValueQuery | ProjectQuery | OriginQuery | LinterQuery;
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
28
  export type QueryArgumentsWithType<QueryType extends BaseQueryFormat['type']> = Query & {
28
29
  type: QueryType;
29
30
  };
@@ -54,6 +55,65 @@ export declare const SupportedQueries: {
54
55
  readonly schema: Joi.ObjectSchema<any>;
55
56
  readonly flattenInvolvedNodes: () => never[];
56
57
  };
58
+ readonly 'control-flow': {
59
+ readonly executor: typeof import("./catalog/control-flow-query/control-flow-query-executor").executeControlFlowQuery;
60
+ readonly asciiSummarizer: (formatter: OutputFormatter, processed: PipelineOutput<import("../core/steps/pipeline/pipeline").Pipeline<{
61
+ readonly name: "parse";
62
+ readonly humanReadableName: "parse with R shell";
63
+ readonly description: "Parse the given R code into an AST";
64
+ readonly processor: (_results: unknown, input: Partial<import("../r-bridge/parser").ParseRequiredInput<string>>) => Promise<import("../r-bridge/parser").ParseStepOutput<string>>;
65
+ readonly executed: import("../core/steps/pipeline-step").PipelineStepStage.OncePerFile;
66
+ readonly printer: {
67
+ readonly 0: typeof import("../core/print/print").internalPrinter;
68
+ readonly 2: {
69
+ (value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string;
70
+ (value: any, replacer?: (number | string)[] | null, space?: string | number): string;
71
+ };
72
+ readonly 5: ({ parsed }: import("../r-bridge/parser").ParseStepOutput<string>, config: import("../util/quads").QuadSerializationConfiguration) => string;
73
+ };
74
+ readonly dependencies: readonly [];
75
+ readonly requiredInput: import("../r-bridge/parser").ParseRequiredInput<string>;
76
+ } | {
77
+ readonly name: "normalize";
78
+ readonly humanReadableName: "normalize";
79
+ readonly description: "Normalize the AST to flowR's AST";
80
+ readonly processor: (results: {
81
+ parse?: import("../r-bridge/parser").ParseStepOutput<string>;
82
+ }, 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>>;
83
+ readonly executed: import("../core/steps/pipeline-step").PipelineStepStage.OncePerFile;
84
+ readonly printer: {
85
+ readonly 0: typeof import("../core/print/print").internalPrinter;
86
+ readonly 2: typeof import("../core/print/normalize-printer").normalizedAstToJson;
87
+ readonly 5: typeof import("../core/print/normalize-printer").normalizedAstToQuads;
88
+ readonly 3: typeof import("../core/print/normalize-printer").printNormalizedAstToMermaid;
89
+ readonly 4: typeof import("../core/print/normalize-printer").printNormalizedAstToMermaidUrl;
90
+ };
91
+ readonly dependencies: readonly ["parse"];
92
+ readonly requiredInput: import("../core/steps/all/core/10-normalize").NormalizeRequiredInput;
93
+ } | {
94
+ readonly humanReadableName: "dataflow";
95
+ readonly processor: (results: {
96
+ normalize?: import("../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
97
+ }, input: {
98
+ request?: import("../r-bridge/retriever").RParseRequests;
99
+ parser?: import("../r-bridge/parser").Parser<import("../r-bridge/parser").KnownParserType>;
100
+ }, config: import("../config").FlowrConfigOptions) => import("../dataflow/info").DataflowInformation;
101
+ readonly requiredInput: {};
102
+ readonly name: "dataflow";
103
+ readonly description: "Construct the dataflow graph";
104
+ readonly executed: import("../core/steps/pipeline-step").PipelineStepStage.OncePerFile;
105
+ readonly printer: {
106
+ readonly 0: typeof import("../core/print/print").internalPrinter;
107
+ readonly 2: typeof import("../core/print/dataflow-printer").dataflowGraphToJson;
108
+ readonly 5: typeof import("../core/print/dataflow-printer").dataflowGraphToQuads;
109
+ readonly 3: typeof import("../core/print/dataflow-printer").dataflowGraphToMermaid;
110
+ readonly 4: typeof import("../core/print/dataflow-printer").dataflowGraphToMermaidUrl;
111
+ };
112
+ readonly dependencies: readonly ["normalize"];
113
+ }>>, queryResults: BaseQueryResult, result: string[]) => true;
114
+ readonly schema: Joi.ObjectSchema<any>;
115
+ readonly flattenInvolvedNodes: (queryResults: BaseQueryResult) => NodeId[];
116
+ };
57
117
  readonly dataflow: {
58
118
  readonly executor: typeof import("./catalog/dataflow-query/dataflow-query-executor").executeDataflowQuery;
59
119
  readonly asciiSummarizer: (formatter: OutputFormatter, _processed: PipelineOutput<import("../core/steps/pipeline/pipeline").Pipeline<{
@@ -96,7 +156,7 @@ export declare const SupportedQueries: {
96
156
  }, input: {
97
157
  request?: import("../r-bridge/retriever").RParseRequests;
98
158
  parser?: import("../r-bridge/parser").Parser<import("../r-bridge/parser").KnownParserType>;
99
- }) => import("../dataflow/info").DataflowInformation;
159
+ }, config: import("../config").FlowrConfigOptions) => import("../dataflow/info").DataflowInformation;
100
160
  readonly requiredInput: {};
101
161
  readonly name: "dataflow";
102
162
  readonly description: "Construct the dataflow graph";
@@ -155,7 +215,7 @@ export declare const SupportedQueries: {
155
215
  }, input: {
156
216
  request?: import("../r-bridge/retriever").RParseRequests;
157
217
  parser?: import("../r-bridge/parser").Parser<import("../r-bridge/parser").KnownParserType>;
158
- }) => import("../dataflow/info").DataflowInformation;
218
+ }, config: import("../config").FlowrConfigOptions) => import("../dataflow/info").DataflowInformation;
159
219
  readonly requiredInput: {};
160
220
  readonly name: "dataflow";
161
221
  readonly description: "Construct the dataflow graph";
@@ -214,7 +274,7 @@ export declare const SupportedQueries: {
214
274
  }, input: {
215
275
  request?: import("../r-bridge/retriever").RParseRequests;
216
276
  parser?: import("../r-bridge/parser").Parser<import("../r-bridge/parser").KnownParserType>;
217
- }) => import("../dataflow/info").DataflowInformation;
277
+ }, config: import("../config").FlowrConfigOptions) => import("../dataflow/info").DataflowInformation;
218
278
  readonly requiredInput: {};
219
279
  readonly name: "dataflow";
220
280
  readonly description: "Construct the dataflow graph";
@@ -273,7 +333,7 @@ export declare const SupportedQueries: {
273
333
  }, input: {
274
334
  request?: import("../r-bridge/retriever").RParseRequests;
275
335
  parser?: import("../r-bridge/parser").Parser<import("../r-bridge/parser").KnownParserType>;
276
- }) => import("../dataflow/info").DataflowInformation;
336
+ }, config: import("../config").FlowrConfigOptions) => import("../dataflow/info").DataflowInformation;
277
337
  readonly requiredInput: {};
278
338
  readonly name: "dataflow";
279
339
  readonly description: "Construct the dataflow graph";
@@ -332,7 +392,7 @@ export declare const SupportedQueries: {
332
392
  }, input: {
333
393
  request?: import("../r-bridge/retriever").RParseRequests;
334
394
  parser?: import("../r-bridge/parser").Parser<import("../r-bridge/parser").KnownParserType>;
335
- }) => import("../dataflow/info").DataflowInformation;
395
+ }, config: import("../config").FlowrConfigOptions) => import("../dataflow/info").DataflowInformation;
336
396
  readonly requiredInput: {};
337
397
  readonly name: "dataflow";
338
398
  readonly description: "Construct the dataflow graph";
@@ -391,7 +451,7 @@ export declare const SupportedQueries: {
391
451
  }, input: {
392
452
  request?: import("../r-bridge/retriever").RParseRequests;
393
453
  parser?: import("../r-bridge/parser").Parser<import("../r-bridge/parser").KnownParserType>;
394
- }) => import("../dataflow/info").DataflowInformation;
454
+ }, config: import("../config").FlowrConfigOptions) => import("../dataflow/info").DataflowInformation;
395
455
  readonly requiredInput: {};
396
456
  readonly name: "dataflow";
397
457
  readonly description: "Construct the dataflow graph";
@@ -450,7 +510,7 @@ export declare const SupportedQueries: {
450
510
  }, input: {
451
511
  request?: import("../r-bridge/retriever").RParseRequests;
452
512
  parser?: import("../r-bridge/parser").Parser<import("../r-bridge/parser").KnownParserType>;
453
- }) => import("../dataflow/info").DataflowInformation;
513
+ }, config: import("../config").FlowrConfigOptions) => import("../dataflow/info").DataflowInformation;
454
514
  readonly requiredInput: {};
455
515
  readonly name: "dataflow";
456
516
  readonly description: "Construct the dataflow graph";
@@ -509,7 +569,7 @@ export declare const SupportedQueries: {
509
569
  }, input: {
510
570
  request?: import("../r-bridge/retriever").RParseRequests;
511
571
  parser?: import("../r-bridge/parser").Parser<import("../r-bridge/parser").KnownParserType>;
512
- }) => import("../dataflow/info").DataflowInformation;
572
+ }, config: import("../config").FlowrConfigOptions) => import("../dataflow/info").DataflowInformation;
513
573
  readonly requiredInput: {};
514
574
  readonly name: "dataflow";
515
575
  readonly description: "Construct the dataflow graph";
@@ -574,7 +634,7 @@ export declare const SupportedQueries: {
574
634
  }, input: {
575
635
  request?: import("../r-bridge/retriever").RParseRequests;
576
636
  parser?: import("../r-bridge/parser").Parser<import("../r-bridge/parser").KnownParserType>;
577
- }) => import("../dataflow/info").DataflowInformation;
637
+ }, config: import("../config").FlowrConfigOptions) => import("../dataflow/info").DataflowInformation;
578
638
  readonly requiredInput: {};
579
639
  readonly name: "dataflow";
580
640
  readonly description: "Construct the dataflow graph";
@@ -633,7 +693,7 @@ export declare const SupportedQueries: {
633
693
  }, input: {
634
694
  request?: import("../r-bridge/retriever").RParseRequests;
635
695
  parser?: import("../r-bridge/parser").Parser<import("../r-bridge/parser").KnownParserType>;
636
- }) => import("../dataflow/info").DataflowInformation;
696
+ }, config: import("../config").FlowrConfigOptions) => import("../dataflow/info").DataflowInformation;
637
697
  readonly requiredInput: {};
638
698
  readonly name: "dataflow";
639
699
  readonly description: "Construct the dataflow graph";
@@ -692,7 +752,7 @@ export declare const SupportedQueries: {
692
752
  }, input: {
693
753
  request?: import("../r-bridge/retriever").RParseRequests;
694
754
  parser?: import("../r-bridge/parser").Parser<import("../r-bridge/parser").KnownParserType>;
695
- }) => import("../dataflow/info").DataflowInformation;
755
+ }, config: import("../config").FlowrConfigOptions) => import("../dataflow/info").DataflowInformation;
696
756
  readonly requiredInput: {};
697
757
  readonly name: "dataflow";
698
758
  readonly description: "Construct the dataflow graph";
@@ -751,7 +811,7 @@ export declare const SupportedQueries: {
751
811
  }, input: {
752
812
  request?: import("../r-bridge/retriever").RParseRequests;
753
813
  parser?: import("../r-bridge/parser").Parser<import("../r-bridge/parser").KnownParserType>;
754
- }) => import("../dataflow/info").DataflowInformation;
814
+ }, config: import("../config").FlowrConfigOptions) => import("../dataflow/info").DataflowInformation;
755
815
  readonly requiredInput: {};
756
816
  readonly name: "dataflow";
757
817
  readonly description: "Construct the dataflow graph";
@@ -810,7 +870,7 @@ export declare const SupportedQueries: {
810
870
  }, input: {
811
871
  request?: import("../r-bridge/retriever").RParseRequests;
812
872
  parser?: import("../r-bridge/parser").Parser<import("../r-bridge/parser").KnownParserType>;
813
- }) => import("../dataflow/info").DataflowInformation;
873
+ }, config: import("../config").FlowrConfigOptions) => import("../dataflow/info").DataflowInformation;
814
874
  readonly requiredInput: {};
815
875
  readonly name: "dataflow";
816
876
  readonly description: "Construct the dataflow graph";
@@ -869,7 +929,7 @@ export declare const SupportedQueries: {
869
929
  }, input: {
870
930
  request?: import("../r-bridge/retriever").RParseRequests;
871
931
  parser?: import("../r-bridge/parser").Parser<import("../r-bridge/parser").KnownParserType>;
872
- }) => import("../dataflow/info").DataflowInformation;
932
+ }, config: import("../config").FlowrConfigOptions) => import("../dataflow/info").DataflowInformation;
873
933
  readonly requiredInput: {};
874
934
  readonly name: "dataflow";
875
935
  readonly description: "Construct the dataflow graph";
package/queries/query.js CHANGED
@@ -30,9 +30,11 @@ const dataflow_lens_query_format_1 = require("./catalog/dataflow-lens-query/data
30
30
  const project_query_format_1 = require("./catalog/project-query/project-query-format");
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
+ const control_flow_query_format_1 = require("./catalog/control-flow-query/control-flow-query-format");
33
34
  exports.SupportedQueries = {
34
35
  'call-context': call_context_query_format_1.CallContextQueryDefinition,
35
36
  'config': config_query_format_1.ConfigQueryDefinition,
37
+ 'control-flow': control_flow_query_format_1.ControlFlowQueryDefinition,
36
38
  'dataflow': dataflow_query_format_1.DataflowQueryDefinition,
37
39
  'dataflow-lens': dataflow_lens_query_format_1.DataflowLensQueryDefinition,
38
40
  'id-map': id_map_query_format_1.IdMapQueryDefinition,
@@ -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
  }
@@ -293,13 +291,20 @@ function convertTreeNode(node) {
293
291
  ...defaultInfo
294
292
  };
295
293
  }
296
- const args = (0, arrays_1.splitArrayOn)(nonErrorChildren(argsParentheses).slice(1, -1), x => x.type === 'comma');
294
+ const rawArgs = nonErrorChildren(argsParentheses);
295
+ const [comments, noCommentrawArgs] = splitComments(rawArgs);
296
+ const args = (0, arrays_1.splitArrayOn)(noCommentrawArgs.slice(1, -1), x => x.type === 'comma');
297
297
  const funcRange = makeSourceRange(func);
298
+ const mappedArgs = args.map(n => n.length == 0 ? r_function_call_1.EmptyArgument : convertTreeNode(n[0]));
298
299
  const call = {
299
- arguments: args.map(n => n.length == 0 ? r_function_call_1.EmptyArgument : convertTreeNode(n[0])),
300
+ arguments: mappedArgs,
300
301
  location: funcRange,
301
302
  lexeme: func.text,
302
- ...defaultInfo
303
+ ...defaultInfo,
304
+ info: {
305
+ ...defaultInfo.info,
306
+ additionalTokens: comments.map(c => c[1]),
307
+ }
303
308
  };
304
309
  if (func.type === tree_sitter_types_1.TreeSitterType.Identifier || func.type === tree_sitter_types_1.TreeSitterType.String || func.type === tree_sitter_types_1.TreeSitterType.NamespaceOperator || func.type === tree_sitter_types_1.TreeSitterType.Return) {
305
310
  let funcNode = convertTreeNode(func);
@@ -336,14 +341,18 @@ function convertTreeNode(node) {
336
341
  }
337
342
  case tree_sitter_types_1.TreeSitterType.FunctionDefinition: {
338
343
  const [name, paramsParens, body] = nonErrorChildren(node);
339
- 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');
340
346
  return {
341
347
  type: type_1.RType.FunctionDefinition,
342
348
  parameters: params.map(n => convertTreeNode(n[0])),
343
349
  body: (0, normalize_meta_1.ensureExpressionList)(convertTreeNode(body)),
344
350
  location: makeSourceRange(name),
345
351
  lexeme: name.text,
346
- ...defaultInfo
352
+ info: {
353
+ ...defaultInfo.info,
354
+ additionalTokens: comments.map(c => c[1]),
355
+ }
347
356
  };
348
357
  }
349
358
  case tree_sitter_types_1.TreeSitterType.String:
@@ -491,7 +500,7 @@ function convertTreeNode(node) {
491
500
  const nameRange = makeSourceRange(nameNode);
492
501
  return {
493
502
  type: type_1.RType.Argument,
494
- name: name,
503
+ name,
495
504
  value: valueNode ? convertTreeNode(valueNode) : undefined,
496
505
  location: nameRange,
497
506
  lexeme: nameNode.text,
@@ -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 {};