@eagleoutice/flowr 2.6.3 → 2.7.2

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 (276) hide show
  1. package/README.md +22 -22
  2. package/abstract-interpretation/absint-visitor.d.ts +160 -0
  3. package/abstract-interpretation/absint-visitor.js +279 -0
  4. package/abstract-interpretation/data-frame/dataframe-domain.d.ts +4 -7
  5. package/abstract-interpretation/data-frame/dataframe-domain.js +26 -16
  6. package/abstract-interpretation/data-frame/mappers/access-mapper.d.ts +6 -4
  7. package/abstract-interpretation/data-frame/mappers/access-mapper.js +11 -14
  8. package/abstract-interpretation/data-frame/mappers/arguments.d.ts +10 -9
  9. package/abstract-interpretation/data-frame/mappers/arguments.js +8 -5
  10. package/abstract-interpretation/data-frame/mappers/function-mapper.d.ts +18 -18
  11. package/abstract-interpretation/data-frame/mappers/function-mapper.js +53 -58
  12. package/abstract-interpretation/data-frame/mappers/replacement-mapper.d.ts +7 -5
  13. package/abstract-interpretation/data-frame/mappers/replacement-mapper.js +26 -29
  14. package/abstract-interpretation/data-frame/semantics.js +48 -44
  15. package/abstract-interpretation/data-frame/shape-inference.d.ts +52 -28
  16. package/abstract-interpretation/data-frame/shape-inference.js +67 -90
  17. package/abstract-interpretation/domains/abstract-domain.d.ts +1 -0
  18. package/abstract-interpretation/domains/abstract-domain.js +3 -2
  19. package/abstract-interpretation/domains/bounded-set-domain.d.ts +2 -2
  20. package/abstract-interpretation/domains/bounded-set-domain.js +1 -1
  21. package/abstract-interpretation/domains/interval-domain.d.ts +4 -4
  22. package/abstract-interpretation/domains/interval-domain.js +3 -6
  23. package/abstract-interpretation/domains/lattice.d.ts +2 -0
  24. package/abstract-interpretation/domains/lattice.js +3 -1
  25. package/abstract-interpretation/domains/positive-interval-domain.d.ts +1 -1
  26. package/abstract-interpretation/domains/positive-interval-domain.js +1 -1
  27. package/abstract-interpretation/domains/satisfiable-domain.d.ts +2 -2
  28. package/abstract-interpretation/domains/satisfiable-domain.js +2 -2
  29. package/abstract-interpretation/domains/set-range-domain.d.ts +104 -0
  30. package/abstract-interpretation/domains/set-range-domain.js +406 -0
  31. package/abstract-interpretation/domains/set-upper-bound-domain.d.ts +2 -2
  32. package/abstract-interpretation/domains/set-upper-bound-domain.js +2 -2
  33. package/abstract-interpretation/domains/singleton-domain.d.ts +2 -2
  34. package/abstract-interpretation/domains/singleton-domain.js +2 -2
  35. package/benchmark/slicer.d.ts +2 -1
  36. package/benchmark/slicer.js +50 -29
  37. package/benchmark/stats/print.js +8 -5
  38. package/benchmark/stats/stats.d.ts +3 -2
  39. package/benchmark/summarizer/data.d.ts +11 -8
  40. package/benchmark/summarizer/first-phase/process.js +11 -8
  41. package/benchmark/summarizer/second-phase/process.js +24 -18
  42. package/cli/common/options.d.ts +431 -8
  43. package/cli/common/options.js +1 -1
  44. package/cli/common/scripts-info.d.ts +431 -7
  45. package/cli/flowr-main-options.d.ts +102 -2
  46. package/cli/flowr.d.ts +102 -2
  47. package/cli/repl/commands/repl-commands.d.ts +25 -0
  48. package/cli/repl/commands/repl-query.js +17 -5
  49. package/cli/wiki.d.ts +13 -0
  50. package/cli/wiki.js +7 -2
  51. package/config.d.ts +4 -4
  52. package/config.js +1 -1
  53. package/control-flow/basic-cfg-guided-visitor.js +7 -8
  54. package/control-flow/cfg-dead-code.js +3 -2
  55. package/control-flow/control-flow-graph.d.ts +1 -1
  56. package/control-flow/semantic-cfg-guided-visitor.d.ts +1 -1
  57. package/control-flow/semantic-cfg-guided-visitor.js +1 -1
  58. package/control-flow/useless-loop.js +4 -2
  59. package/core/steps/all/static-slicing/00-slice.d.ts +3 -0
  60. package/core/steps/all/static-slicing/00-slice.js +2 -1
  61. package/core/steps/pipeline/default-pipelines.d.ts +42 -42
  62. package/dataflow/cluster.js +2 -2
  63. package/dataflow/environments/append.d.ts +5 -0
  64. package/dataflow/environments/append.js +6 -20
  65. package/dataflow/environments/built-in.d.ts +2 -1
  66. package/dataflow/environments/clone.d.ts +1 -1
  67. package/dataflow/environments/clone.js +3 -27
  68. package/dataflow/environments/define.d.ts +7 -3
  69. package/dataflow/environments/define.js +9 -56
  70. package/dataflow/environments/diff.js +1 -1
  71. package/dataflow/environments/environment.d.ts +48 -28
  72. package/dataflow/environments/environment.js +187 -62
  73. package/dataflow/environments/overwrite.js +2 -45
  74. package/dataflow/environments/reference-to-maybe.d.ts +13 -0
  75. package/dataflow/environments/reference-to-maybe.js +54 -0
  76. package/dataflow/environments/resolve-by-name.d.ts +6 -1
  77. package/dataflow/environments/resolve-by-name.js +56 -4
  78. package/dataflow/environments/scoping.d.ts +2 -2
  79. package/dataflow/environments/scoping.js +7 -7
  80. package/dataflow/eval/resolve/alias-tracking.d.ts +10 -4
  81. package/dataflow/eval/resolve/alias-tracking.js +16 -14
  82. package/dataflow/eval/resolve/resolve-argument.d.ts +2 -1
  83. package/dataflow/eval/resolve/resolve-argument.js +8 -8
  84. package/dataflow/eval/resolve/resolve.d.ts +13 -11
  85. package/dataflow/eval/resolve/resolve.js +16 -15
  86. package/dataflow/extractor.js +1 -7
  87. package/dataflow/fn/higher-order-function.d.ts +2 -1
  88. package/dataflow/fn/higher-order-function.js +4 -4
  89. package/dataflow/graph/dataflowgraph-builder.d.ts +9 -5
  90. package/dataflow/graph/dataflowgraph-builder.js +21 -11
  91. package/dataflow/graph/diff-dataflow-graph.js +2 -2
  92. package/dataflow/graph/graph.d.ts +10 -2
  93. package/dataflow/graph/graph.js +41 -12
  94. package/dataflow/graph/invert-dfg.d.ts +3 -2
  95. package/dataflow/graph/invert-dfg.js +3 -3
  96. package/dataflow/graph/resolve-graph.d.ts +2 -1
  97. package/dataflow/graph/resolve-graph.js +2 -2
  98. package/dataflow/graph/vertex.d.ts +3 -3
  99. package/dataflow/graph/vertex.js +3 -3
  100. package/dataflow/info.d.ts +1 -1
  101. package/dataflow/internal/linker.d.ts +2 -0
  102. package/dataflow/internal/linker.js +13 -19
  103. package/dataflow/internal/process/functions/call/argument/unpack-argument.d.ts +7 -1
  104. package/dataflow/internal/process/functions/call/argument/unpack-argument.js +12 -3
  105. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +3 -3
  106. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +2 -2
  107. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +3 -1
  108. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +3 -3
  109. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +9 -9
  110. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +9 -7
  111. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +3 -3
  112. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +2 -1
  113. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +9 -13
  114. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +1 -1
  115. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.d.ts +3 -1
  116. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +8 -6
  117. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +1 -1
  118. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +1 -1
  119. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +1 -1
  120. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +3 -3
  121. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +6 -4
  122. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +1 -1
  123. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +5 -5
  124. package/dataflow/internal/process/functions/call/common.js +2 -3
  125. package/dataflow/internal/process/functions/call/known-call-handling.js +1 -1
  126. package/dataflow/internal/process/functions/call/unnamed-call-handling.js +1 -1
  127. package/dataflow/internal/process/functions/process-argument.js +1 -1
  128. package/dataflow/internal/process/process-symbol.js +1 -1
  129. package/dataflow/internal/process/process-value.d.ts +1 -1
  130. package/dataflow/internal/process/process-value.js +7 -7
  131. package/dataflow/processor.d.ts +1 -5
  132. package/documentation/doc-capabilities.d.ts +1 -1
  133. package/documentation/doc-readme.d.ts +1 -1
  134. package/documentation/doc-util/doc-cfg.js +1 -1
  135. package/documentation/doc-util/doc-cli-option.d.ts +6 -6
  136. package/documentation/doc-util/doc-cli-option.js +3 -3
  137. package/documentation/doc-util/doc-dfg.d.ts +1 -1
  138. package/documentation/doc-util/doc-dfg.js +3 -2
  139. package/documentation/doc-util/doc-files.d.ts +3 -0
  140. package/documentation/doc-util/doc-files.js +4 -1
  141. package/documentation/doc-util/doc-normalized-ast.js +5 -4
  142. package/documentation/doc-util/doc-types.d.ts +1 -1
  143. package/documentation/doc-util/doc-types.js +2 -2
  144. package/documentation/issue-linting-rule.d.ts +1 -1
  145. package/documentation/wiki-analyzer.d.ts +1 -1
  146. package/documentation/wiki-analyzer.js +14 -1
  147. package/documentation/wiki-cfg.d.ts +1 -1
  148. package/documentation/wiki-core.d.ts +1 -1
  149. package/documentation/wiki-dataflow-graph.d.ts +1 -1
  150. package/documentation/wiki-dataflow-graph.js +10 -11
  151. package/documentation/wiki-engine.d.ts +1 -1
  152. package/documentation/wiki-engine.js +9 -10
  153. package/documentation/wiki-faq.d.ts +1 -1
  154. package/documentation/wiki-faq.js +0 -1
  155. package/documentation/wiki-interface.d.ts +1 -1
  156. package/documentation/wiki-interface.js +12 -13
  157. package/documentation/wiki-linter.d.ts +1 -1
  158. package/documentation/wiki-linter.js +1 -1
  159. package/documentation/wiki-linting-and-testing.d.ts +1 -1
  160. package/documentation/wiki-mk/doc-context.d.ts +54 -1
  161. package/documentation/wiki-mk/doc-context.js +17 -0
  162. package/documentation/wiki-mk/doc-maker.d.ts +5 -5
  163. package/documentation/wiki-mk/doc-maker.js +5 -2
  164. package/documentation/wiki-normalized-ast.d.ts +1 -1
  165. package/documentation/wiki-onboarding.d.ts +1 -1
  166. package/documentation/wiki-overview.d.ts +9 -0
  167. package/documentation/wiki-overview.js +248 -0
  168. package/documentation/wiki-query.d.ts +1 -1
  169. package/documentation/wiki-query.js +17 -1
  170. package/documentation/wiki-search.d.ts +1 -1
  171. package/documentation/wiki-setup.d.ts +9 -0
  172. package/documentation/wiki-setup.js +122 -0
  173. package/linter/linter-rules.d.ts +2 -2
  174. package/linter/rules/absolute-path.js +4 -4
  175. package/linter/rules/dataframe-access-validation.d.ts +2 -2
  176. package/linter/rules/dataframe-access-validation.js +9 -11
  177. package/linter/rules/function-finder-util.d.ts +2 -2
  178. package/linter/rules/function-finder-util.js +1 -1
  179. package/linter/rules/network-functions.js +1 -1
  180. package/linter/rules/seeded-randomness.d.ts +1 -1
  181. package/linter/rules/seeded-randomness.js +5 -5
  182. package/linter/rules/unused-definition.js +1 -1
  183. package/package.json +1 -2
  184. package/project/context/flowr-analyzer-context.d.ts +11 -0
  185. package/project/context/flowr-analyzer-context.js +3 -0
  186. package/project/context/flowr-analyzer-environment-context.d.ts +47 -0
  187. package/project/context/flowr-analyzer-environment-context.js +50 -0
  188. package/project/context/flowr-analyzer-files-context.d.ts +9 -1
  189. package/project/context/flowr-analyzer-files-context.js +4 -0
  190. package/project/context/flowr-file.d.ts +2 -0
  191. package/project/context/flowr-file.js +2 -0
  192. package/project/plugins/file-plugins/{flowr-description-file.d.ts → files/flowr-description-file.d.ts} +1 -1
  193. package/project/plugins/file-plugins/files/flowr-description-file.js +75 -0
  194. package/project/plugins/file-plugins/files/flowr-news-file.d.ts +27 -0
  195. package/project/plugins/file-plugins/files/flowr-news-file.js +152 -0
  196. package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.d.ts +1 -1
  197. package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.js +1 -1
  198. package/project/plugins/file-plugins/flowr-analyzer-news-file-plugin.d.ts +23 -0
  199. package/project/plugins/file-plugins/flowr-analyzer-news-file-plugin.js +35 -0
  200. package/project/plugins/file-plugins/notebooks/flowr-analyzer-jupyter-file-plugin.d.ts +1 -1
  201. package/project/plugins/file-plugins/notebooks/flowr-analyzer-jupyter-file-plugin.js +1 -1
  202. package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.d.ts +1 -1
  203. package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.js +1 -1
  204. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.d.ts +1 -1
  205. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.js +1 -1
  206. package/project/plugins/flowr-analyzer-plugin-defaults.js +2 -0
  207. package/project/plugins/plugin-registry.d.ts +2 -1
  208. package/project/plugins/plugin-registry.js +2 -0
  209. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +7 -1
  210. package/queries/catalog/call-context-query/call-context-query-executor.js +1 -4
  211. package/queries/catalog/control-flow-query/control-flow-query-format.js +3 -2
  212. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.js +1 -1
  213. package/queries/catalog/dependencies-query/dependencies-query-executor.js +4 -4
  214. package/queries/catalog/df-shape-query/df-shape-query-executor.d.ts +1 -1
  215. package/queries/catalog/df-shape-query/df-shape-query-executor.js +5 -3
  216. package/queries/catalog/df-shape-query/df-shape-query-format.d.ts +4 -4
  217. package/queries/catalog/df-shape-query/df-shape-query-format.js +2 -2
  218. package/queries/catalog/files-query/files-query-executor.d.ts +6 -0
  219. package/queries/catalog/files-query/files-query-executor.js +49 -0
  220. package/queries/catalog/files-query/files-query-format.d.ts +36 -0
  221. package/queries/catalog/files-query/files-query-format.js +114 -0
  222. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +3 -3
  223. package/queries/catalog/linter-query/linter-query-format.js +1 -1
  224. package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +1 -1
  225. package/queries/catalog/static-slice-query/static-slice-query-executor.js +1 -1
  226. package/queries/query.d.ts +10 -1
  227. package/queries/query.js +3 -1
  228. package/r-bridge/lang-4.x/ast/model/model.d.ts +1 -1
  229. package/r-bridge/lang-4.x/ast/model/processing/decorate.js +8 -8
  230. package/r-bridge/lang-4.x/ast/model/processing/role.d.ts +8 -8
  231. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-parameter.js +0 -1
  232. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +0 -1
  233. package/slicing/static/slice-call.d.ts +3 -2
  234. package/slicing/static/slice-call.js +4 -4
  235. package/slicing/static/static-slicer.d.ts +3 -1
  236. package/slicing/static/static-slicer.js +6 -7
  237. package/statistics/features/supported/control-flow/control-flow.js +1 -1
  238. package/statistics/features/supported/data-access/data-access.js +1 -1
  239. package/statistics/features/supported/used-functions/used-functions.js +1 -1
  240. package/statistics/features/supported/variables/variables.js +2 -1
  241. package/util/containers.js +2 -2
  242. package/util/files.d.ts +0 -7
  243. package/util/files.js +0 -41
  244. package/util/mermaid/ast.d.ts +3 -2
  245. package/util/mermaid/ast.js +13 -7
  246. package/util/mermaid/cfg.d.ts +3 -2
  247. package/util/mermaid/cfg.js +26 -6
  248. package/util/mermaid/dfg.d.ts +2 -7
  249. package/util/mermaid/dfg.js +10 -6
  250. package/util/mermaid/info.d.ts +17 -0
  251. package/util/mermaid/info.js +5 -0
  252. package/util/prefix.d.ts +9 -5
  253. package/util/prefix.js +14 -6
  254. package/util/r-regex.d.ts +21 -0
  255. package/util/r-regex.js +25 -0
  256. package/util/simple-df/dfg-view.d.ts +2 -1
  257. package/util/simple-df/dfg-view.js +2 -2
  258. package/util/text/args.js +12 -3
  259. package/util/version.js +1 -1
  260. package/abstract-interpretation/data-frame/absint-info.d.ts +0 -109
  261. package/abstract-interpretation/data-frame/absint-info.js +0 -31
  262. package/abstract-interpretation/data-frame/absint-visitor.d.ts +0 -57
  263. package/abstract-interpretation/data-frame/absint-visitor.js +0 -176
  264. package/abstract-interpretation/data-frame/mappers/assignment-mapper.d.ts +0 -19
  265. package/abstract-interpretation/data-frame/mappers/assignment-mapper.js +0 -33
  266. package/dataflow/environments/remove.d.ts +0 -12
  267. package/dataflow/environments/remove.js +0 -52
  268. package/documentation/doc-util/doc-print.d.ts +0 -5
  269. package/documentation/doc-util/doc-print.js +0 -36
  270. package/project/plugins/file-plugins/flowr-description-file.js +0 -37
  271. package/project/plugins/file-plugins/notebooks/notebook.d.ts +0 -0
  272. package/project/plugins/file-plugins/notebooks/notebook.js +0 -2
  273. /package/project/plugins/file-plugins/{notebooks → files}/flowr-jupyter-file.d.ts +0 -0
  274. /package/project/plugins/file-plugins/{notebooks → files}/flowr-jupyter-file.js +0 -0
  275. /package/project/plugins/file-plugins/{notebooks → files}/flowr-rmarkdown-file.d.ts +0 -0
  276. /package/project/plugins/file-plugins/{notebooks → files}/flowr-rmarkdown-file.js +0 -0
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.FilesQueryDefinition = void 0;
7
+ const ansi_1 = require("../../../util/text/ansi");
8
+ const joi_1 = __importDefault(require("joi"));
9
+ const files_query_executor_1 = require("./files-query-executor");
10
+ const flowr_file_1 = require("../../../project/context/flowr-file");
11
+ const json_1 = require("../../../util/json");
12
+ const retriever_1 = require("../../../r-bridge/retriever");
13
+ function summarizeObjectWithLimit(obj, limitChars = 500, limitLines = 10) {
14
+ const str = JSON.stringify(obj, json_1.jsonReplacer, 2);
15
+ if (str.split('\n').length > limitLines) {
16
+ const lines = str.split('\n').slice(0, limitLines);
17
+ return lines.join('\n') + '\n... (truncated)';
18
+ }
19
+ else if (str.length > limitChars) {
20
+ return str.slice(0, limitChars) + '... (truncated)';
21
+ }
22
+ else {
23
+ return str;
24
+ }
25
+ }
26
+ function rolesFromInput(rolesPart) {
27
+ return rolesPart
28
+ .reduce((acc, roleName) => {
29
+ roleName = roleName.trim();
30
+ // check if it is one of the values
31
+ if (Object.values(flowr_file_1.FileRole).includes(roleName)) {
32
+ acc.valid.push(roleName);
33
+ }
34
+ else {
35
+ acc.invalid.push(roleName);
36
+ }
37
+ return acc;
38
+ }, { valid: [], invalid: [] });
39
+ }
40
+ const rolePrefix = 'role:';
41
+ function filesQueryLineParser(output, line, _config) {
42
+ let roles = undefined;
43
+ let input = undefined;
44
+ if (line.length > 0 && line[0].startsWith(rolePrefix)) {
45
+ const rolesPart = line[0].slice(rolePrefix.length).split(',');
46
+ const parseResult = rolesFromInput(rolesPart);
47
+ if (parseResult.invalid.length > 0) {
48
+ output.stderr(`Invalid roles: ${parseResult.invalid.map(r => (0, ansi_1.bold)(r, output.formatter)).join(', ')}`
49
+ + `\nValid roles are: ${Object.values(flowr_file_1.FileRole).map(r => (0, ansi_1.bold)(r, output.formatter)).join(', ')}`);
50
+ }
51
+ roles = parseResult.valid;
52
+ input = line[1];
53
+ }
54
+ else if (line.length > 0) {
55
+ input = line[0];
56
+ }
57
+ return { query: [{ type: 'files', roles }], rCode: input };
58
+ }
59
+ function filesQueryCompleter(line, startingNewArg, _config) {
60
+ const rolesPrefixNotPresent = line.length == 0 || (line.length == 1 && line[0].length < rolePrefix.length);
61
+ const rolesNotFinished = line.length == 1 && line[0].startsWith(rolePrefix) && !startingNewArg;
62
+ const endOfRoles = line.length == 1 && startingNewArg || line.length == 2;
63
+ if (rolesPrefixNotPresent) {
64
+ return { completions: [`${rolePrefix}`] };
65
+ }
66
+ else if (endOfRoles) {
67
+ return { completions: [retriever_1.fileProtocol] };
68
+ }
69
+ else if (rolesNotFinished) {
70
+ const rolesWithoutPrefix = line[0].slice(rolePrefix.length);
71
+ const usedRoles = rolesWithoutPrefix.split(',').map(r => r.trim());
72
+ const allRoles = Object.values(flowr_file_1.FileRole);
73
+ const unusedRoles = allRoles.filter(r => !usedRoles.includes(r));
74
+ const lastRole = usedRoles[usedRoles.length - 1];
75
+ const lastRoleIsUnfinished = !allRoles.includes(lastRole);
76
+ if (lastRoleIsUnfinished) {
77
+ return { completions: unusedRoles, argumentPart: lastRole };
78
+ }
79
+ else if (unusedRoles.length > 0) {
80
+ return { completions: [','], argumentPart: '' };
81
+ }
82
+ else {
83
+ return { completions: [' '], argumentPart: '' };
84
+ }
85
+ }
86
+ return { completions: [] };
87
+ }
88
+ exports.FilesQueryDefinition = {
89
+ executor: files_query_executor_1.executeFileQuery,
90
+ asciiSummarizer: (formatter, _analyzer, queryResults, result) => {
91
+ const out = queryResults;
92
+ result.push(`Query: ${(0, ansi_1.bold)('files', formatter)} (${out['.meta'].timing.toFixed(0)}ms)`);
93
+ result.push(` ╰ Found ${out.files.length} file${out.files.length === 1 ? '' : 's'}`);
94
+ for (const f of out.files) {
95
+ result.push(` ╰ ${(0, ansi_1.bold)(f.path, formatter)}${f.role ? ` [role: ${f.role}]` : ''}:`);
96
+ const summary = summarizeObjectWithLimit(f.content);
97
+ for (const line of summary.split('\n')) {
98
+ result.push(` ${line}`);
99
+ }
100
+ }
101
+ return true;
102
+ },
103
+ completer: filesQueryCompleter,
104
+ fromLine: filesQueryLineParser,
105
+ schema: joi_1.default.object({
106
+ type: joi_1.default.string().valid('files').required().description('The type of the query.'),
107
+ roles: joi_1.default.array().optional().items(joi_1.default.string().valid(...Object.values(flowr_file_1.FileRole))).description('Optional roles of the files to query. If not provided, all roles are considered.'),
108
+ matchesPathRegex: joi_1.default.string().optional().description('An optional regular expression to match the file paths against.')
109
+ }).description('The file query finds files in the project based on their roles and path patterns.'),
110
+ flattenInvolvedNodes: (_) => {
111
+ return [];
112
+ }
113
+ };
114
+ //# sourceMappingURL=files-query-format.js.map
@@ -32,11 +32,11 @@ async function executeHigherOrderQuery({ analyzer }, queries) {
32
32
  }
33
33
  }
34
34
  const graph = (await analyzer.dataflow()).graph;
35
- const fns = graph.vertices(true)
36
- .filter(([, v]) => (0, vertex_1.isFunctionDefinitionVertex)(v) && (filterFor.size === 0 || filterFor.has(v.id)));
35
+ const fns = graph.verticesOfType(vertex_1.VertexType.FunctionDefinition)
36
+ .filter(([, v]) => filterFor.size === 0 || filterFor.has(v.id));
37
37
  const result = {};
38
38
  for (const [id,] of fns) {
39
- result[id] = (0, higher_order_function_1.isHigherOrder)(id, graph);
39
+ result[id] = (0, higher_order_function_1.isHigherOrder)(id, graph, analyzer.inspectContext());
40
40
  }
41
41
  return {
42
42
  '.meta': {
@@ -34,7 +34,7 @@ function linterQueryLineParser(output, line, _config) {
34
34
  const rulesPart = line[0].slice(rulesPrefix.length).split(',');
35
35
  const parseResult = rulesFromInput(output, rulesPart);
36
36
  if (parseResult.invalid.length > 0) {
37
- output.stdout(`Invalid linting rule name(s): ${parseResult.invalid.map(r => (0, ansi_1.bold)(r, output.formatter)).join(', ')}`
37
+ output.stderr(`Invalid linting rule name(s): ${parseResult.invalid.map(r => (0, ansi_1.bold)(r, output.formatter)).join(', ')}`
38
38
  + `\nValid rule names are: ${Object.keys(linter_rules_1.LintingRules).map(r => (0, ansi_1.bold)(r, output.formatter)).join(', ')}`);
39
39
  }
40
40
  rules = parseResult.valid;
@@ -26,7 +26,7 @@ async function executeResolveValueQuery({ analyzer }, queries) {
26
26
  }
27
27
  const values = query.criteria
28
28
  .map(criteria => (0, parse_1.slicingCriterionToId)(criteria, ast.idMap))
29
- .flatMap(ident => (0, alias_tracking_1.resolveIdToValue)(ident, { graph, full: true, idMap: ast.idMap, resolve: analyzer.flowrConfig.solver.variables }));
29
+ .flatMap(ident => (0, alias_tracking_1.resolveIdToValue)(ident, { graph, full: true, idMap: ast.idMap, resolve: analyzer.flowrConfig.solver.variables, ctx: analyzer.inspectContext() }));
30
30
  results[key] = {
31
31
  values: values
32
32
  };
@@ -30,7 +30,7 @@ async function executeStaticSliceQuery({ analyzer }, queries) {
30
30
  }
31
31
  const { criteria, noReconstruction, noMagicComments } = query;
32
32
  const sliceStart = Date.now();
33
- const slice = (0, static_slicer_1.staticSlice)(await analyzer.dataflow(), await analyzer.normalize(), criteria, query.direction ?? _00_slice_1.SliceDirection.Backward, analyzer.flowrConfig.solver.slicer?.threshold);
33
+ const slice = (0, static_slicer_1.staticSlice)(analyzer.inspectContext(), await analyzer.dataflow(), await analyzer.normalize(), criteria, query.direction ?? _00_slice_1.SliceDirection.Backward, analyzer.flowrConfig.solver.slicer?.threshold);
34
34
  const sliceEnd = Date.now();
35
35
  if (noReconstruction) {
36
36
  results[key] = { slice: { ...slice, '.meta': { timing: sliceEnd - sliceStart } } };
@@ -28,10 +28,11 @@ import { type InspectHigherOrderQuery } from './catalog/inspect-higher-order-que
28
28
  import type { ReadonlyFlowrAnalysisProvider } from '../project/flowr-analyzer';
29
29
  import type { ReplOutput } from '../cli/repl/commands/repl-main';
30
30
  import type { CommandCompletions } from '../cli/repl/core';
31
+ import type { FilesQuery } from './catalog/files-query/files-query-format';
31
32
  /**
32
33
  * These are all queries that can be executed from within flowR
33
34
  */
34
- export type Query = CallContextQuery | ConfigQuery | SearchQuery | DataflowQuery | ControlFlowQuery | DataflowLensQuery | DfShapeQuery | NormalizedAstQuery | IdMapQuery | DataflowClusterQuery | StaticSliceQuery | DependenciesQuery | LocationMapQuery | HappensBeforeQuery | InspectHigherOrderQuery | ResolveValueQuery | ProjectQuery | OriginQuery | LinterQuery;
35
+ export type Query = CallContextQuery | ConfigQuery | SearchQuery | DataflowQuery | ControlFlowQuery | DataflowLensQuery | FilesQuery | DfShapeQuery | NormalizedAstQuery | IdMapQuery | DataflowClusterQuery | StaticSliceQuery | DependenciesQuery | LocationMapQuery | HappensBeforeQuery | InspectHigherOrderQuery | ResolveValueQuery | ProjectQuery | OriginQuery | LinterQuery;
35
36
  export type QueryArgumentsWithType<QueryType extends BaseQueryFormat['type']> = Query & {
36
37
  type: QueryType;
37
38
  };
@@ -105,6 +106,14 @@ export declare const SupportedQueries: {
105
106
  readonly schema: Joi.ObjectSchema<any>;
106
107
  readonly flattenInvolvedNodes: () => never[];
107
108
  };
109
+ readonly files: {
110
+ readonly executor: typeof import("./catalog/files-query/files-query-executor").executeFileQuery;
111
+ readonly asciiSummarizer: (formatter: OutputFormatter, _analyzer: ReadonlyFlowrAnalysisProvider<import("../r-bridge/parser").KnownParser>, queryResults: BaseQueryResult, result: string[]) => true;
112
+ readonly completer: (line: readonly string[], startingNewArg: boolean, _config: FlowrConfigOptions) => CommandCompletions;
113
+ readonly fromLine: (output: ReplOutput, line: readonly string[], _config: FlowrConfigOptions) => ParsedQueryLine<"files">;
114
+ readonly schema: Joi.ObjectSchema<any>;
115
+ readonly flattenInvolvedNodes: (_: BaseQueryResult) => NodeId[];
116
+ };
108
117
  readonly 'id-map': {
109
118
  readonly executor: typeof import("./catalog/id-map-query/id-map-query-executor").executeIdMapQuery;
110
119
  readonly asciiSummarizer: (formatter: OutputFormatter, _analyzer: ReadonlyFlowrAnalysisProvider<import("../r-bridge/parser").KnownParser>, queryResults: BaseQueryResult, result: string[]) => true;
package/queries/query.js CHANGED
@@ -35,6 +35,7 @@ const control_flow_query_format_1 = require("./catalog/control-flow-query/contro
35
35
  const df_shape_query_format_1 = require("./catalog/df-shape-query/df-shape-query-format");
36
36
  const inspect_higher_order_query_format_1 = require("./catalog/inspect-higher-order-query/inspect-higher-order-query-format");
37
37
  const log_1 = require("../util/log");
38
+ const files_query_format_1 = require("./catalog/files-query/files-query-format");
38
39
  exports.SupportedQueries = {
39
40
  'call-context': call_context_query_format_1.CallContextQueryDefinition,
40
41
  'config': config_query_format_1.ConfigQueryDefinition,
@@ -42,6 +43,7 @@ exports.SupportedQueries = {
42
43
  'dataflow': dataflow_query_format_1.DataflowQueryDefinition,
43
44
  'dataflow-lens': dataflow_lens_query_format_1.DataflowLensQueryDefinition,
44
45
  'df-shape': df_shape_query_format_1.DfShapeQueryDefinition,
46
+ 'files': files_query_format_1.FilesQueryDefinition,
45
47
  'id-map': id_map_query_format_1.IdMapQueryDefinition,
46
48
  'normalized-ast': normalized_ast_query_format_1.NormalizedAstQueryDefinition,
47
49
  'dataflow-cluster': cluster_query_format_1.ClusterQueryDefinition,
@@ -103,7 +105,7 @@ async function executeQueries(data, queries) {
103
105
  const results = [];
104
106
  for (const [type, group] of entries) {
105
107
  try {
106
- const result = await Promise.resolve(executeQueriesOfSameType(data, group));
108
+ const result = await executeQueriesOfSameType(data, group);
107
109
  results.push([type, result]);
108
110
  }
109
111
  catch (e) {
@@ -102,7 +102,7 @@ export interface Namespace {
102
102
  * The namespace attached to the given node
103
103
  * (e.g., a namespaced symbol in `x::y`).
104
104
  */
105
- namespace: NamespaceIdentifier | undefined;
105
+ namespace?: NamespaceIdentifier;
106
106
  }
107
107
  /**
108
108
  * This subtype of {@link RNode} represents all types of constants
@@ -187,7 +187,7 @@ function createFoldForUnaryOp(info) {
187
187
  info.idMap.set(id, decorated);
188
188
  const opInfo = operand.info;
189
189
  opInfo.parent = id;
190
- opInfo.role = "unary-operand" /* RoleInParent.UnaryOperand */;
190
+ opInfo.role = "unary-op" /* RoleInParent.UnaryOperand */;
191
191
  decorated.info.file = info.file;
192
192
  return decorated;
193
193
  };
@@ -208,7 +208,7 @@ function createFoldForAccess(info) {
208
208
  const curInfo = acc.info;
209
209
  curInfo.parent = id;
210
210
  curInfo.index = idx;
211
- curInfo.role = "index-access" /* RoleInParent.IndexAccess */;
211
+ curInfo.role = "index-acc" /* RoleInParent.IndexAccess */;
212
212
  }
213
213
  }
214
214
  }
@@ -223,11 +223,11 @@ function createFoldForForLoop(info) {
223
223
  info.idMap.set(id, decorated);
224
224
  const varInfo = variable.info;
225
225
  varInfo.parent = id;
226
- varInfo.role = "for-variable" /* RoleInParent.ForVariable */;
226
+ varInfo.role = "for-var" /* RoleInParent.ForVariable */;
227
227
  const vecInfo = vector.info;
228
228
  vecInfo.parent = id;
229
229
  vecInfo.index = 1;
230
- vecInfo.role = "for-vector" /* RoleInParent.ForVector */;
230
+ vecInfo.role = "for-vec" /* RoleInParent.ForVector */;
231
231
  const bodyInfo = body.info;
232
232
  bodyInfo.parent = id;
233
233
  bodyInfo.index = 2;
@@ -280,7 +280,7 @@ function createFoldForIfThenElse(info) {
280
280
  const otherwiseInfo = otherwise.info;
281
281
  otherwiseInfo.parent = id;
282
282
  otherwiseInfo.index = 2;
283
- otherwiseInfo.role = "if-otherwise" /* RoleInParent.IfOtherwise */;
283
+ otherwiseInfo.role = "if-other" /* RoleInParent.IfOtherwise */;
284
284
  }
285
285
  decorated.info.file = info.file;
286
286
  return decorated;
@@ -323,7 +323,7 @@ function createFoldForFunctionCall(info) {
323
323
  const argInfo = arg.info;
324
324
  argInfo.parent = id;
325
325
  argInfo.index = idx;
326
- argInfo.role = "call-argument" /* RoleInParent.FunctionCallArgument */;
326
+ argInfo.role = "call-arg" /* RoleInParent.FunctionCallArgument */;
327
327
  }
328
328
  }
329
329
  decorated.info.file = info.file;
@@ -340,12 +340,12 @@ function createFoldForFunctionDefinition(info) {
340
340
  const paramInfo = param.info;
341
341
  paramInfo.parent = id;
342
342
  paramInfo.index = idx++;
343
- paramInfo.role = "function-def-param" /* RoleInParent.FunctionDefinitionParameter */;
343
+ paramInfo.role = "param" /* RoleInParent.FunctionDefinitionParameter */;
344
344
  }
345
345
  const bodyInfo = body.info;
346
346
  bodyInfo.parent = id;
347
347
  bodyInfo.index = idx;
348
- bodyInfo.role = "function-def-body" /* RoleInParent.FunctionDefinitionBody */;
348
+ bodyInfo.role = "fun-body" /* RoleInParent.FunctionDefinitionBody */;
349
349
  decorated.info.file = info.file;
350
350
  return decorated;
351
351
  };
@@ -10,29 +10,29 @@ export declare const enum RoleInParent {
10
10
  Root = "root",
11
11
  IfCondition = "if-cond",
12
12
  IfThen = "if-then",
13
- IfOtherwise = "if-otherwise",
13
+ IfOtherwise = "if-other",
14
14
  WhileCondition = "while-cond",
15
15
  WhileBody = "while-body",
16
16
  RepeatBody = "repeat-body",
17
- ForVariable = "for-variable",
18
- ForVector = "for-vector",
17
+ ForVariable = "for-var",
18
+ ForVector = "for-vec",
19
19
  ForBody = "for-body",
20
20
  FunctionCallName = "call-name",
21
- FunctionCallArgument = "call-argument",
22
- FunctionDefinitionBody = "function-def-body",
23
- FunctionDefinitionParameter = "function-def-param",
21
+ FunctionCallArgument = "call-arg",
22
+ FunctionDefinitionBody = "fun-body",
23
+ FunctionDefinitionParameter = "param",
24
24
  ExpressionListChild = "expr-list-child",
25
25
  BinaryOperationLhs = "binop-lhs",
26
26
  BinaryOperationRhs = "binop-rhs",
27
27
  PipeLhs = "pipe-lhs",
28
28
  PipeRhs = "pipe-rhs",
29
- UnaryOperand = "unary-operand",
29
+ UnaryOperand = "unary-op",
30
30
  ParameterName = "param-name",
31
31
  ParameterDefaultValue = "param-value",
32
32
  ArgumentName = "arg-name",
33
33
  ArgumentValue = "arg-value",
34
34
  Accessed = "accessed",
35
- IndexAccess = "index-access"
35
+ IndexAccess = "index-acc"
36
36
  }
37
37
  /**
38
38
  * Returns the roles of the parents of the given node, starting with the parent-role of the node itself.
@@ -34,7 +34,6 @@ function tryNormalizeParameter(data, objs) {
34
34
  name: {
35
35
  type: type_1.RType.Symbol,
36
36
  location, content,
37
- namespace: undefined,
38
37
  lexeme: content,
39
38
  info: {
40
39
  fullRange: location,
@@ -483,7 +483,6 @@ function convertTreeNode(node) {
483
483
  name: {
484
484
  type: type_1.RType.Symbol,
485
485
  location: nameRange,
486
- namespace: undefined,
487
486
  content: name.text,
488
487
  lexeme: name.text,
489
488
  info: {
@@ -6,11 +6,12 @@ import type { REnvironmentInformation } from '../../dataflow/environments/enviro
6
6
  import { type DataflowGraph, type OutgoingEdges } from '../../dataflow/graph/graph';
7
7
  import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
8
8
  import type { DataflowInformation } from '../../dataflow/info';
9
+ import type { ReadOnlyFlowrAnalyzerContext } from '../../project/context/flowr-analyzer-context';
9
10
  /**
10
11
  * Returns the function call targets (definitions) by the given caller
11
12
  */
12
- export declare function getAllFunctionCallTargets(dataflowGraph: DataflowGraph, callerInfo: DataflowGraphVertexFunctionCall, baseEnvironment: REnvironmentInformation, queue: VisitingQueue): [Set<DataflowGraphVertexInfo>, REnvironmentInformation];
13
+ export declare function getAllFunctionCallTargets(dataflowGraph: DataflowGraph, callerInfo: DataflowGraphVertexFunctionCall, baseEnvironment: REnvironmentInformation, queue: VisitingQueue, ctx: ReadOnlyFlowrAnalyzerContext): [Set<DataflowGraphVertexInfo>, REnvironmentInformation];
13
14
  /** returns the new threshold hit count */
14
- export declare function sliceForCall(current: NodeToSlice, callerInfo: DataflowGraphVertexFunctionCall, dataflowInformation: DataflowInformation, queue: VisitingQueue): void;
15
+ export declare function sliceForCall(current: NodeToSlice, callerInfo: DataflowGraphVertexFunctionCall, dataflowInformation: DataflowInformation, queue: VisitingQueue, ctx: ReadOnlyFlowrAnalyzerContext): void;
15
16
  /** Returns true if we found at least one return edge */
16
17
  export declare function handleReturns(from: NodeId, queue: VisitingQueue, currentEdges: OutgoingEdges, baseEnvFingerprint: Fingerprint, baseEnvironment: REnvironmentInformation): boolean;
@@ -16,12 +16,12 @@ const static_slicer_1 = require("./static-slicer");
16
16
  /**
17
17
  * Returns the function call targets (definitions) by the given caller
18
18
  */
19
- function getAllFunctionCallTargets(dataflowGraph, callerInfo, baseEnvironment, queue) {
19
+ function getAllFunctionCallTargets(dataflowGraph, callerInfo, baseEnvironment, queue, ctx) {
20
20
  // bind with call-local environments during slicing
21
21
  const outgoingEdges = dataflowGraph.get(callerInfo.id, true);
22
22
  (0, assert_1.guard)(outgoingEdges !== undefined, () => `outgoing edges of id: ${callerInfo.id} must be in graph but can not be found, keep in slice to be sure`);
23
23
  // lift baseEnv on the same level
24
- const activeEnvironment = (0, built_in_function_definition_1.retrieveActiveEnvironment)(callerInfo.environment, baseEnvironment);
24
+ const activeEnvironment = (0, built_in_function_definition_1.retrieveActiveEnvironment)(callerInfo.environment, baseEnvironment, ctx);
25
25
  const name = callerInfo.name;
26
26
  (0, assert_1.guard)(name !== undefined, () => `name of id: ${callerInfo.id} can not be found in id map`);
27
27
  const functionCallDefs = (0, resolve_by_name_1.resolveByName)(name, activeEnvironment, identifier_1.ReferenceType.Unknown)?.filter(d => !(0, built_in_1.isBuiltIn)(d.definedAt))?.map(d => d.nodeId) ?? [];
@@ -59,9 +59,9 @@ function linkCallTargets(onlyForSideEffects, functionCallTargets, activeEnvironm
59
59
  }
60
60
  }
61
61
  /** returns the new threshold hit count */
62
- function sliceForCall(current, callerInfo, dataflowInformation, queue) {
62
+ function sliceForCall(current, callerInfo, dataflowInformation, queue, ctx) {
63
63
  const baseEnvironment = current.baseEnvironment;
64
- const [functionCallTargets, activeEnvironment] = getAllFunctionCallTargets(dataflowInformation.graph, callerInfo, current.baseEnvironment, queue);
64
+ const [functionCallTargets, activeEnvironment] = getAllFunctionCallTargets(dataflowInformation.graph, callerInfo, current.baseEnvironment, queue, ctx);
65
65
  const activeEnvironmentFingerprint = (0, fingerprint_1.envFingerprint)(activeEnvironment);
66
66
  if (functionCallTargets.size === 0) {
67
67
  /*
@@ -7,11 +7,13 @@ import { type REnvironmentInformation } from '../../dataflow/environments/enviro
7
7
  import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
8
8
  import { SliceDirection } from '../../core/steps/all/static-slicing/00-slice';
9
9
  import type { DataflowInformation } from '../../dataflow/info';
10
+ import type { ReadOnlyFlowrAnalyzerContext } from '../../project/context/flowr-analyzer-context';
10
11
  export declare const slicerLogger: import("tslog").Logger<import("tslog").ILogObj>;
11
12
  /**
12
13
  * This returns the ids to include in the static slice of the given type, when slicing with the given seed id's (must be at least one).
13
14
  * <p>
14
15
  * The returned ids can be used to {@link reconstructToCode|reconstruct the slice to R code}.
16
+ * @param ctx - The analyzer context used for slicing.
15
17
  * @param info - The dataflow information used for slicing.
16
18
  * @param idMap - The mapping from node ids to their information in the AST.
17
19
  * @param criteria - The criteria to slice on.
@@ -19,7 +21,7 @@ export declare const slicerLogger: import("tslog").Logger<import("tslog").ILogOb
19
21
  * @param threshold - The maximum number of nodes to visit in the graph. If the threshold is reached, the slice will side with inclusion and drop its minimal guarantee. The limit ensures that the algorithm halts.
20
22
  * @param cache - A cache to store the results of the slice. If provided, the slice may use this cache to speed up the slicing process.
21
23
  */
22
- export declare function staticSlice(info: DataflowInformation, { idMap }: NormalizedAst, criteria: SlicingCriteria, direction: SliceDirection, threshold?: number, cache?: Map<Fingerprint, Set<NodeId>>): Readonly<SliceResult>;
24
+ export declare function staticSlice(ctx: ReadOnlyFlowrAnalyzerContext, info: DataflowInformation, { idMap }: NormalizedAst, criteria: SlicingCriteria, direction: SliceDirection, threshold?: number, cache?: Map<Fingerprint, Set<NodeId>>): Readonly<SliceResult>;
23
25
  /**
24
26
  * Updates the potential addition for the given target node in the visiting queue.
25
27
  * This describes vertices that might be added *if* another path reaches them.
@@ -5,11 +5,9 @@ exports.staticSlice = staticSlice;
5
5
  exports.updatePotentialAddition = updatePotentialAddition;
6
6
  const assert_1 = require("../../util/assert");
7
7
  const log_1 = require("../../util/log");
8
- const fingerprint_1 = require("./fingerprint");
9
8
  const visiting_queue_1 = require("./visiting-queue");
10
9
  const slice_call_1 = require("./slice-call");
11
10
  const parse_1 = require("../criterion/parse");
12
- const environment_1 = require("../../dataflow/environments/environment");
13
11
  const vertex_1 = require("../../dataflow/graph/vertex");
14
12
  const edge_1 = require("../../dataflow/graph/edge");
15
13
  const _00_slice_1 = require("../../core/steps/all/static-slicing/00-slice");
@@ -19,6 +17,7 @@ exports.slicerLogger = log_1.log.getSubLogger({ name: 'slicer' });
19
17
  * This returns the ids to include in the static slice of the given type, when slicing with the given seed id's (must be at least one).
20
18
  * <p>
21
19
  * The returned ids can be used to {@link reconstructToCode|reconstruct the slice to R code}.
20
+ * @param ctx - The analyzer context used for slicing.
22
21
  * @param info - The dataflow information used for slicing.
23
22
  * @param idMap - The mapping from node ids to their information in the AST.
24
23
  * @param criteria - The criteria to slice on.
@@ -26,21 +25,21 @@ exports.slicerLogger = log_1.log.getSubLogger({ name: 'slicer' });
26
25
  * @param threshold - The maximum number of nodes to visit in the graph. If the threshold is reached, the slice will side with inclusion and drop its minimal guarantee. The limit ensures that the algorithm halts.
27
26
  * @param cache - A cache to store the results of the slice. If provided, the slice may use this cache to speed up the slicing process.
28
27
  */
29
- function staticSlice(info, { idMap }, criteria, direction, threshold = 75, cache) {
28
+ function staticSlice(ctx, info, { idMap }, criteria, direction, threshold = 75, cache) {
30
29
  (0, assert_1.guard)(criteria.length > 0, 'must have at least one seed id to calculate slice');
31
30
  const decodedCriteria = (0, parse_1.convertAllSlicingCriteriaToIds)(criteria, idMap);
32
31
  (0, log_1.expensiveTrace)(exports.slicerLogger, () => `calculating ${direction} slice for ${decodedCriteria.length} seed criteria: ${decodedCriteria.map(s => JSON.stringify(s)).join(', ')}`);
33
32
  let { graph } = info;
34
33
  if (direction === _00_slice_1.SliceDirection.Forward) {
35
- graph = (0, invert_dfg_1.invertDfg)(graph);
34
+ graph = (0, invert_dfg_1.invertDfg)(graph, ctx.env.makeCleanEnv());
36
35
  }
37
36
  const queue = new visiting_queue_1.VisitingQueue(threshold, cache);
38
37
  let minNesting = Number.MAX_SAFE_INTEGER;
39
38
  const sliceSeedIds = new Set();
40
39
  // every node ships the call environment which registers the calling environment
41
40
  {
42
- const emptyEnv = (0, environment_1.initializeCleanEnvironments)();
43
- const basePrint = (0, fingerprint_1.envFingerprint)(emptyEnv);
41
+ const emptyEnv = ctx.env.makeCleanEnv();
42
+ const basePrint = ctx.env.getCleanEnvFingerprint();
44
43
  for (const { id: startId } of decodedCriteria) {
45
44
  queue.add(startId, emptyEnv, basePrint, false);
46
45
  // retrieve the minimum nesting of all nodes to only add control dependencies if they are "part" of the current execution
@@ -77,7 +76,7 @@ function staticSlice(info, { idMap }, criteria, direction, threshold = 75, cache
77
76
  }
78
77
  if (!onlyForSideEffects) {
79
78
  if (currentVertex.tag === vertex_1.VertexType.FunctionCall && !currentVertex.onlyBuiltin) {
80
- (0, slice_call_1.sliceForCall)(current, currentVertex, info, queue);
79
+ (0, slice_call_1.sliceForCall)(current, currentVertex, info, queue, ctx);
81
80
  }
82
81
  const ret = (0, slice_call_1.handleReturns)(id, queue, currentEdges, baseEnvFingerprint, baseEnvironment);
83
82
  if (ret) {
@@ -23,7 +23,7 @@ function visitIfThenElse(info, input) {
23
23
  (0, visitor_1.visitAst)(input.normalizedRAst.ast.files.map(f => f.root), node => {
24
24
  if (node.type !== type_1.RType.IfThenElse) {
25
25
  if (node.type === type_1.RType.FunctionCall && node.named && node.functionName.content === 'switch') {
26
- const initialArg = (0, unpack_argument_1.unpackArgument)(node.arguments[0]);
26
+ const initialArg = (0, unpack_argument_1.unpackNonameArg)(node.arguments[0]);
27
27
  if (initialArg) {
28
28
  info.switchCase = (0, common_syntax_probability_1.updateCommonSyntaxTypeCounts)(info.switchCase, initialArg);
29
29
  }
@@ -58,7 +58,7 @@ function visitAccess(info, input) {
58
58
  acc = true;
59
59
  break; // we only account for the first one
60
60
  }
61
- else if (role === "index-access" /* RoleInParent.IndexAccess */) {
61
+ else if (role === "index-acc" /* RoleInParent.IndexAccess */) {
62
62
  idxAcc = true;
63
63
  break;
64
64
  }
@@ -84,7 +84,7 @@ function visitCalls(info, input) {
84
84
  hasCallsEdge ? 1 : 0
85
85
  ]);
86
86
  }
87
- classifyArguments(node.arguments.map(e => (0, unpack_argument_1.unpackArgument)(e)), info.args);
87
+ classifyArguments(node.arguments.map(e => (0, unpack_argument_1.unpackNonameArg)(e)), info.args);
88
88
  calls.push(node);
89
89
  }, node => {
90
90
  // drop again :D
@@ -7,6 +7,7 @@ const visitor_1 = require("../../../../r-bridge/lang-4.x/ast/model/processing/vi
7
7
  const type_1 = require("../../../../r-bridge/lang-4.x/ast/model/type");
8
8
  const r_symbol_1 = require("../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
9
9
  const statistics_file_1 = require("../../../output/statistics-file");
10
+ const vertex_1 = require("../../../../dataflow/graph/vertex");
10
11
  const initialVariableInfo = {
11
12
  numberOfVariableUses: 0,
12
13
  numberOfDefinitions: 0,
@@ -30,7 +31,7 @@ function visitVariables(info, input) {
30
31
  return;
31
32
  }
32
33
  const [dfNode] = mayNode;
33
- if (dfNode.tag === 'variable-definition') {
34
+ if (dfNode.tag === vertex_1.VertexType.VariableDefinition) {
34
35
  info.numberOfDefinitions++;
35
36
  const lexeme = node.info.fullLexeme ?? node.lexeme;
36
37
  (0, statistics_file_1.appendStatisticsFile)(exports.variables.name, 'definedVariables', [[
@@ -16,7 +16,7 @@ const type_1 = require("../r-bridge/lang-4.x/ast/model/type");
16
16
  function getAccessOperands(args) {
17
17
  const nonEmptyArgs = args.filter(arg => arg !== r_function_call_1.EmptyArgument);
18
18
  const accessedArg = nonEmptyArgs.find(arg => arg.info.role === "accessed" /* RoleInParent.Accessed */);
19
- const accessArg = nonEmptyArgs.find(arg => arg.info.role === "index-access" /* RoleInParent.IndexAccess */);
19
+ const accessArg = nonEmptyArgs.find(arg => arg.info.role === "index-acc" /* RoleInParent.IndexAccess */);
20
20
  return { accessedArg, accessArg };
21
21
  }
22
22
  /**
@@ -26,7 +26,7 @@ function getAccessOperands(args) {
26
26
  * @returns The indicesCollection of the resolved definitions
27
27
  */
28
28
  function resolveIndicesByName(name, environment) {
29
- const definitions = (0, resolve_by_name_1.resolveByName)(name, environment);
29
+ const definitions = (0, resolve_by_name_1.resolveByNameAnyType)(name, environment);
30
30
  return definitions?.flatMap(def => def?.indicesCollection ?? []);
31
31
  }
32
32
  /**
package/util/files.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { type PathLike } from 'fs';
2
2
  import type { RParseRequestFromFile } from '../r-bridge/retriever';
3
- import type { FlowrFileProvider } from '../project/context/flowr-file';
4
3
  /**
5
4
  * Represents a table, identified by a header and a list of rows.
6
5
  */
@@ -70,12 +69,6 @@ export declare function readLineByLineSync(filePath: string, onLine: (line: Buff
70
69
  * @param directory - The directory whose parent to return
71
70
  */
72
71
  export declare function getParentDirectory(directory: string): string;
73
- /**
74
- * Parses the given file in the 'Debian Control Format'.
75
- * @param file - The file to parse
76
- * @returns Map containing the keys and values of the provided file.
77
- */
78
- export declare function parseDCF(file: FlowrFileProvider): Map<string, string[]>;
79
72
  /**
80
73
  * Checks whether the given path-like object is a file that exists on the local filesystem.
81
74
  */
package/util/files.js CHANGED
@@ -44,7 +44,6 @@ exports.writeTableAsCsv = writeTableAsCsv;
44
44
  exports.readLineByLine = readLineByLine;
45
45
  exports.readLineByLineSync = readLineByLineSync;
46
46
  exports.getParentDirectory = getParentDirectory;
47
- exports.parseDCF = parseDCF;
48
47
  exports.isFilePath = isFilePath;
49
48
  const fs_1 = __importStar(require("fs"));
50
49
  const path_1 = __importDefault(require("path"));
@@ -201,46 +200,6 @@ function getParentDirectory(directory) {
201
200
  // apparently this is somehow the best way to do it in node, what
202
201
  return directory.split(path_1.default.sep).slice(0, -1).join(path_1.default.sep);
203
202
  }
204
- /**
205
- * Parses the given file in the 'Debian Control Format'.
206
- * @param file - The file to parse
207
- * @returns Map containing the keys and values of the provided file.
208
- */
209
- function parseDCF(file) {
210
- const result = new Map();
211
- let currentKey = '';
212
- let currentValue = '';
213
- const indentRegex = new RegExp(/^\s/);
214
- const firstColonRegex = new RegExp(/:(.*)/s);
215
- const fileContent = file.content().toString().split(/\r?\n/);
216
- for (const line of fileContent) {
217
- if (indentRegex.test(line)) {
218
- currentValue += '\n' + line.trim();
219
- }
220
- else {
221
- if (currentKey) {
222
- const values = currentValue ? cleanValues(currentValue) : [];
223
- result.set(currentKey, values);
224
- }
225
- const [key, rest] = line.split(firstColonRegex).map(s => s.trim());
226
- currentKey = key.trim();
227
- currentValue = rest.trim();
228
- }
229
- }
230
- if (currentKey) {
231
- const values = currentValue ? cleanValues(currentValue) : [];
232
- result.set(currentKey, values);
233
- }
234
- return result;
235
- }
236
- const cleanSplitRegex = /[\n,]+/;
237
- const cleanQuotesRegex = /'/g;
238
- function cleanValues(values) {
239
- return values
240
- .split(cleanSplitRegex)
241
- .map(s => s.trim().replace(cleanQuotesRegex, ''))
242
- .filter(s => s.length > 0);
243
- }
244
203
  /**
245
204
  * Checks whether the given path-like object is a file that exists on the local filesystem.
246
205
  */
@@ -1,10 +1,11 @@
1
1
  import type { ParentInformation, RNodeWithParent } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
2
2
  import type { RProject } from '../../r-bridge/lang-4.x/ast/model/nodes/r-project';
3
+ import type { MermaidGraphPrinterInfo } from './info';
3
4
  /**
4
5
  * Serialize the normalized AST to mermaid format
5
6
  */
6
- export declare function normalizedAstToMermaid(ast: RProject<ParentInformation> | RNodeWithParent, prefix?: string): string;
7
+ export declare function normalizedAstToMermaid(ast: RProject<ParentInformation> | RNodeWithParent, { prefix, markStyle, includeOnlyIds, mark }?: MermaidGraphPrinterInfo): string;
7
8
  /**
8
9
  * Use mermaid to visualize the normalized AST.
9
10
  */
10
- export declare function normalizedAstToMermaidUrl(ast: RProject<ParentInformation> | RNodeWithParent, prefix?: string): string;
11
+ export declare function normalizedAstToMermaidUrl(ast: RProject<ParentInformation> | RNodeWithParent, info?: MermaidGraphPrinterInfo): string;