@eagleoutice/flowr 2.5.0 → 2.6.1

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 (254) hide show
  1. package/README.md +46 -35
  2. package/abstract-interpretation/data-frame/absint-visitor.d.ts +1 -1
  3. package/abstract-interpretation/data-frame/absint-visitor.js +1 -1
  4. package/cli/flowr.js +11 -33
  5. package/cli/repl/commands/repl-cfg.d.ts +5 -5
  6. package/cli/repl/commands/repl-cfg.js +21 -22
  7. package/cli/repl/commands/repl-commands.d.ts +3 -3
  8. package/cli/repl/commands/repl-commands.js +2 -0
  9. package/cli/repl/commands/repl-dataflow.d.ts +5 -5
  10. package/cli/repl/commands/repl-dataflow.js +27 -30
  11. package/cli/repl/commands/repl-execute.d.ts +1 -1
  12. package/cli/repl/commands/repl-execute.js +8 -7
  13. package/cli/repl/commands/repl-lineage.d.ts +2 -2
  14. package/cli/repl/commands/repl-lineage.js +11 -11
  15. package/cli/repl/commands/repl-main.d.ts +35 -7
  16. package/cli/repl/commands/repl-normalize.d.ts +3 -3
  17. package/cli/repl/commands/repl-normalize.js +15 -19
  18. package/cli/repl/commands/repl-parse.d.ts +2 -2
  19. package/cli/repl/commands/repl-parse.js +14 -8
  20. package/cli/repl/commands/repl-query.d.ts +3 -3
  21. package/cli/repl/commands/repl-query.js +29 -19
  22. package/cli/repl/commands/repl-quit.js +1 -0
  23. package/cli/repl/commands/repl-version.d.ts +1 -16
  24. package/cli/repl/commands/repl-version.js +2 -18
  25. package/cli/repl/core.d.ts +12 -9
  26. package/cli/repl/core.js +26 -12
  27. package/cli/repl/print-version.js +2 -2
  28. package/cli/repl/server/connection.d.ts +7 -3
  29. package/cli/repl/server/connection.js +46 -50
  30. package/cli/repl/server/messages/message-hello.d.ts +1 -1
  31. package/cli/repl/server/messages/message-slice.d.ts +1 -1
  32. package/cli/repl/server/server.js +2 -2
  33. package/cli/slicer-app.js +1 -1
  34. package/config.d.ts +1 -1
  35. package/config.js +4 -1
  36. package/control-flow/extract-cfg.d.ts +1 -1
  37. package/control-flow/extract-cfg.js +1 -1
  38. package/core/pipeline-executor.d.ts +5 -0
  39. package/core/pipeline-executor.js +5 -0
  40. package/core/steps/all/core/20-dataflow.d.ts +3 -1
  41. package/core/steps/pipeline/create-pipeline.js +1 -1
  42. package/core/steps/pipeline/default-pipelines.d.ts +24 -8
  43. package/core/steps/pipeline/default-pipelines.js +4 -1
  44. package/dataflow/environments/default-builtin-config.js +8 -0
  45. package/dataflow/eval/resolve/alias-tracking.js +2 -0
  46. package/dataflow/eval/resolve/resolve.js +3 -0
  47. package/dataflow/eval/values/r-value.d.ts +4 -1
  48. package/dataflow/eval/values/r-value.js +2 -0
  49. package/dataflow/extractor.d.ts +4 -1
  50. package/dataflow/extractor.js +7 -5
  51. package/dataflow/fn/higher-order-function.d.ts +9 -0
  52. package/dataflow/fn/higher-order-function.js +75 -0
  53. package/dataflow/graph/dataflowgraph-builder.d.ts +11 -12
  54. package/dataflow/graph/dataflowgraph-builder.js +6 -6
  55. package/documentation/doc-util/doc-query.d.ts +3 -6
  56. package/documentation/doc-util/doc-query.js +5 -17
  57. package/documentation/doc-util/doc-repl.js +5 -2
  58. package/documentation/doc-util/doc-search.js +7 -10
  59. package/documentation/doc-util/doc-structure.d.ts +4 -0
  60. package/documentation/doc-util/doc-structure.js +28 -0
  61. package/documentation/doc-util/doc-types.d.ts +5 -1
  62. package/documentation/doc-util/doc-types.js +29 -3
  63. package/documentation/print-analyzer-wiki.d.ts +1 -0
  64. package/documentation/print-analyzer-wiki.js +137 -0
  65. package/documentation/print-core-wiki.d.ts +2 -1
  66. package/documentation/print-core-wiki.js +58 -4
  67. package/documentation/print-dataflow-graph-wiki.js +16 -23
  68. package/documentation/print-interface-wiki.js +18 -1
  69. package/documentation/print-linter-wiki.js +5 -1
  70. package/documentation/print-normalized-ast-wiki.js +6 -8
  71. package/documentation/print-query-wiki.js +20 -0
  72. package/documentation/print-readme.js +1 -1
  73. package/engines.d.ts +9 -0
  74. package/engines.js +38 -0
  75. package/linter/linter-executor.d.ts +2 -8
  76. package/linter/linter-executor.js +9 -4
  77. package/linter/linter-format.d.ts +8 -9
  78. package/linter/linter-rules.d.ts +57 -15
  79. package/linter/linter-rules.js +2 -0
  80. package/linter/rules/absolute-path.d.ts +1 -0
  81. package/linter/rules/dataframe-access-validation.d.ts +4 -3
  82. package/linter/rules/dataframe-access-validation.js +7 -4
  83. package/linter/rules/dead-code.d.ts +2 -1
  84. package/linter/rules/deprecated-functions.d.ts +15 -28
  85. package/linter/rules/deprecated-functions.js +5 -43
  86. package/linter/rules/file-path-validity.d.ts +2 -1
  87. package/linter/rules/file-path-validity.js +1 -1
  88. package/linter/rules/function-finder-util.d.ts +51 -0
  89. package/linter/rules/function-finder-util.js +77 -0
  90. package/linter/rules/naming-convention.d.ts +2 -1
  91. package/linter/rules/network-functions.d.ts +40 -0
  92. package/linter/rules/network-functions.js +24 -0
  93. package/linter/rules/seeded-randomness.d.ts +2 -1
  94. package/linter/rules/unused-definition.d.ts +2 -1
  95. package/linter/rules/useless-loop.d.ts +3 -2
  96. package/linter/rules/useless-loop.js +4 -6
  97. package/package.json +2 -1
  98. package/project/cache/flowr-analyzer-cache.d.ts +94 -0
  99. package/project/cache/flowr-analyzer-cache.js +164 -0
  100. package/project/cache/flowr-cache.d.ts +28 -0
  101. package/project/cache/flowr-cache.js +49 -0
  102. package/project/cfg-kind.d.ts +17 -0
  103. package/project/cfg-kind.js +22 -0
  104. package/project/context/abstract-flowr-analyzer-context.d.ts +39 -0
  105. package/project/context/abstract-flowr-analyzer-context.js +46 -0
  106. package/project/context/flowr-analyzer-context.d.ts +54 -0
  107. package/project/context/flowr-analyzer-context.js +58 -0
  108. package/project/context/flowr-analyzer-dependencies-context.d.ts +39 -0
  109. package/project/context/flowr-analyzer-dependencies-context.js +43 -0
  110. package/project/context/flowr-analyzer-files-context.d.ts +87 -0
  111. package/project/context/flowr-analyzer-files-context.js +134 -0
  112. package/project/context/flowr-analyzer-loading-order-context.d.ts +77 -0
  113. package/project/context/flowr-analyzer-loading-order-context.js +96 -0
  114. package/project/context/flowr-file.d.ts +89 -0
  115. package/project/context/flowr-file.js +78 -0
  116. package/project/flowr-analyzer-builder.d.ts +106 -0
  117. package/project/flowr-analyzer-builder.js +197 -0
  118. package/project/flowr-analyzer.d.ts +126 -0
  119. package/project/flowr-analyzer.js +88 -0
  120. package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.d.ts +17 -0
  121. package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.js +28 -0
  122. package/project/plugins/file-plugins/flowr-analyzer-file-plugin.d.ts +21 -0
  123. package/project/plugins/file-plugins/flowr-analyzer-file-plugin.js +34 -0
  124. package/project/plugins/file-plugins/flowr-description-file.d.ts +24 -0
  125. package/project/plugins/file-plugins/flowr-description-file.js +38 -0
  126. package/project/plugins/flowr-analyzer-plugin.d.ts +90 -0
  127. package/project/plugins/flowr-analyzer-plugin.js +82 -0
  128. package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-description-file-plugin.d.ts +14 -0
  129. package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-description-file-plugin.js +56 -0
  130. package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-plugin.d.ts +13 -0
  131. package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-plugin.js +33 -0
  132. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.d.ts +14 -0
  133. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.js +41 -0
  134. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.d.ts +10 -0
  135. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.js +29 -0
  136. package/project/plugins/package-version-plugins/package.d.ts +15 -0
  137. package/project/plugins/package-version-plugins/package.js +56 -0
  138. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.d.ts +15 -0
  139. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +44 -0
  140. package/queries/base-query-format.d.ts +2 -8
  141. package/queries/catalog/call-context-query/call-context-query-executor.d.ts +1 -1
  142. package/queries/catalog/call-context-query/call-context-query-executor.js +21 -13
  143. package/queries/catalog/call-context-query/call-context-query-format.d.ts +2 -3
  144. package/queries/catalog/call-context-query/call-context-query-format.js +2 -2
  145. package/queries/catalog/cluster-query/cluster-query-executor.d.ts +1 -1
  146. package/queries/catalog/cluster-query/cluster-query-executor.js +2 -2
  147. package/queries/catalog/cluster-query/cluster-query-format.d.ts +1 -54
  148. package/queries/catalog/cluster-query/cluster-query-format.js +2 -2
  149. package/queries/catalog/config-query/config-query-executor.d.ts +1 -1
  150. package/queries/catalog/config-query/config-query-executor.js +5 -5
  151. package/queries/catalog/config-query/config-query-format.d.ts +1 -1
  152. package/queries/catalog/config-query/config-query-format.js +1 -1
  153. package/queries/catalog/control-flow-query/control-flow-query-executor.d.ts +1 -1
  154. package/queries/catalog/control-flow-query/control-flow-query-executor.js +3 -3
  155. package/queries/catalog/control-flow-query/control-flow-query-format.d.ts +1 -54
  156. package/queries/catalog/control-flow-query/control-flow-query-format.js +2 -2
  157. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.d.ts +1 -1
  158. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.js +2 -2
  159. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.d.ts +1 -54
  160. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.js +1 -1
  161. package/queries/catalog/dataflow-query/dataflow-query-executor.d.ts +1 -1
  162. package/queries/catalog/dataflow-query/dataflow-query-executor.js +2 -2
  163. package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +1 -54
  164. package/queries/catalog/dataflow-query/dataflow-query-format.js +1 -1
  165. package/queries/catalog/dependencies-query/dependencies-query-executor.d.ts +1 -1
  166. package/queries/catalog/dependencies-query/dependencies-query-executor.js +19 -12
  167. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +7 -56
  168. package/queries/catalog/dependencies-query/dependencies-query-format.js +7 -4
  169. package/queries/catalog/df-shape-query/df-shape-query-executor.d.ts +1 -1
  170. package/queries/catalog/df-shape-query/df-shape-query-executor.js +4 -4
  171. package/queries/catalog/df-shape-query/df-shape-query-format.d.ts +1 -54
  172. package/queries/catalog/df-shape-query/df-shape-query-format.js +1 -1
  173. package/queries/catalog/happens-before-query/happens-before-query-executor.d.ts +1 -1
  174. package/queries/catalog/happens-before-query/happens-before-query-executor.js +2 -1
  175. package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +1 -54
  176. package/queries/catalog/happens-before-query/happens-before-query-format.js +1 -1
  177. package/queries/catalog/id-map-query/id-map-query-executor.d.ts +1 -1
  178. package/queries/catalog/id-map-query/id-map-query-executor.js +2 -2
  179. package/queries/catalog/id-map-query/id-map-query-format.d.ts +1 -54
  180. package/queries/catalog/id-map-query/id-map-query-format.js +2 -2
  181. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.d.ts +3 -0
  182. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +45 -0
  183. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +22 -0
  184. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +32 -0
  185. package/queries/catalog/lineage-query/lineage-query-executor.d.ts +1 -1
  186. package/queries/catalog/lineage-query/lineage-query-executor.js +2 -2
  187. package/queries/catalog/lineage-query/lineage-query-format.d.ts +1 -54
  188. package/queries/catalog/lineage-query/lineage-query-format.js +1 -1
  189. package/queries/catalog/linter-query/linter-query-executor.d.ts +1 -1
  190. package/queries/catalog/linter-query/linter-query-executor.js +2 -3
  191. package/queries/catalog/linter-query/linter-query-format.d.ts +1 -54
  192. package/queries/catalog/linter-query/linter-query-format.js +1 -1
  193. package/queries/catalog/location-map-query/location-map-query-executor.d.ts +1 -1
  194. package/queries/catalog/location-map-query/location-map-query-executor.js +3 -2
  195. package/queries/catalog/location-map-query/location-map-query-format.d.ts +1 -1
  196. package/queries/catalog/location-map-query/location-map-query-format.js +1 -1
  197. package/queries/catalog/normalized-ast-query/normalized-ast-query-executor.d.ts +1 -1
  198. package/queries/catalog/normalized-ast-query/normalized-ast-query-executor.js +2 -2
  199. package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +1 -54
  200. package/queries/catalog/normalized-ast-query/normalized-ast-query-format.js +1 -1
  201. package/queries/catalog/origin-query/origin-query-executor.d.ts +2 -2
  202. package/queries/catalog/origin-query/origin-query-executor.js +3 -3
  203. package/queries/catalog/origin-query/origin-query-format.d.ts +1 -54
  204. package/queries/catalog/origin-query/origin-query-format.js +1 -1
  205. package/queries/catalog/project-query/project-query-executor.d.ts +1 -1
  206. package/queries/catalog/project-query/project-query-executor.js +2 -2
  207. package/queries/catalog/project-query/project-query-format.d.ts +1 -54
  208. package/queries/catalog/project-query/project-query-format.js +1 -1
  209. package/queries/catalog/resolve-value-query/resolve-value-query-executor.d.ts +1 -1
  210. package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +4 -2
  211. package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +1 -54
  212. package/queries/catalog/resolve-value-query/resolve-value-query-format.js +1 -1
  213. package/queries/catalog/search-query/search-query-executor.d.ts +1 -1
  214. package/queries/catalog/search-query/search-query-executor.js +3 -3
  215. package/queries/catalog/search-query/search-query-format.d.ts +1 -54
  216. package/queries/catalog/search-query/search-query-format.js +1 -1
  217. package/queries/catalog/static-slice-query/static-slice-query-executor.d.ts +1 -1
  218. package/queries/catalog/static-slice-query/static-slice-query-executor.js +3 -3
  219. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +1 -54
  220. package/queries/catalog/static-slice-query/static-slice-query-format.js +1 -1
  221. package/queries/query-print.d.ts +4 -4
  222. package/queries/query-print.js +12 -12
  223. package/queries/query.d.ts +37 -885
  224. package/queries/query.js +3 -1
  225. package/r-bridge/parser.d.ts +7 -0
  226. package/r-bridge/retriever.d.ts +6 -5
  227. package/r-bridge/retriever.js +9 -5
  228. package/search/flowr-search-executor.d.ts +3 -5
  229. package/search/flowr-search-executor.js +6 -4
  230. package/search/flowr-search-filters.d.ts +12 -6
  231. package/search/flowr-search-filters.js +1 -1
  232. package/search/flowr-search.d.ts +5 -16
  233. package/search/flowr-search.js +14 -5
  234. package/search/search-executor/search-enrichers.d.ts +37 -36
  235. package/search/search-executor/search-enrichers.js +5 -4
  236. package/search/search-executor/search-generators.d.ts +12 -12
  237. package/search/search-executor/search-generators.js +27 -19
  238. package/search/search-executor/search-mappers.d.ts +5 -5
  239. package/search/search-executor/search-transformer.d.ts +17 -17
  240. package/search/search-executor/search-transformer.js +14 -7
  241. package/util/collections/arrays.d.ts +1 -0
  242. package/util/collections/arrays.js +15 -0
  243. package/util/collections/objectmap.d.ts +17 -0
  244. package/util/collections/objectmap.js +28 -0
  245. package/util/containers.d.ts +0 -1
  246. package/util/containers.js +0 -1
  247. package/util/files.d.ts +17 -0
  248. package/util/files.js +65 -0
  249. package/util/formats/adapter.d.ts +4 -2
  250. package/util/formats/adapter.js +11 -4
  251. package/util/r-value.d.ts +1 -1
  252. package/util/r-value.js +2 -0
  253. package/util/version.d.ts +17 -0
  254. package/util/version.js +28 -1
@@ -59,14 +59,14 @@ exports.processors = {
59
59
  }
60
60
  };
61
61
  function resolveLinkToSideEffects(ast, graph) {
62
- let cfg = undefined;
62
+ let cf = undefined;
63
63
  for (const s of graph.unknownSideEffects) {
64
64
  if (typeof s !== 'object') {
65
65
  continue;
66
66
  }
67
- cfg ??= (0, extract_cfg_1.extractCfgQuick)(ast).graph;
67
+ cf ??= (0, extract_cfg_1.extractCfgQuick)(ast);
68
68
  /* this has to change whenever we add a new link to relations because we currently offer no abstraction for the type */
69
- const potentials = (0, identify_link_to_last_call_relation_1.identifyLinkToLastCallRelation)(s.id, cfg, graph, s.linkTo);
69
+ const potentials = (0, identify_link_to_last_call_relation_1.identifyLinkToLastCallRelation)(s.id, cf?.graph, graph, s.linkTo);
70
70
  for (const pot of potentials) {
71
71
  graph.addEdge(s.id, pot, edge_1.EdgeType.Reads);
72
72
  }
@@ -74,6 +74,7 @@ function resolveLinkToSideEffects(ast, graph) {
74
74
  graph.unknownSideEffects.delete(s);
75
75
  }
76
76
  }
77
+ return cf;
77
78
  }
78
79
  /**
79
80
  * This is the main function to produce the dataflow graph from a given request and normalized AST.
@@ -114,7 +115,8 @@ function produceDataFlowGraph(parser, request, completeAst, config) {
114
115
  }
115
116
  // finally, resolve linkages
116
117
  (0, built_in_function_definition_1.updateNestedFunctionCalls)(df.graph, df.environment);
117
- resolveLinkToSideEffects(completeAst, df.graph);
118
- return df;
118
+ const cfgQuick = resolveLinkToSideEffects(completeAst, df.graph);
119
+ // performance optimization: return cfgQuick as part of the result to avoid recomputation
120
+ return { ...df, cfgQuick };
119
121
  }
120
122
  //# sourceMappingURL=extractor.js.map
@@ -0,0 +1,9 @@
1
+ import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
2
+ import type { DataflowGraph } from '../graph/graph';
3
+ /**
4
+ * Determines whether the function with the given id is a higher-order function, i.e.,
5
+ * either takes a function as an argument or (may) returns a function.
6
+ * If the return is an identity, e.g., `function(x) x`, this is not considered higher-order,
7
+ * if no function is passed as an argument.
8
+ */
9
+ export declare function isHigherOrder(id: NodeId, graph: DataflowGraph): boolean;
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isHigherOrder = isHigherOrder;
4
+ const vertex_1 = require("../graph/vertex");
5
+ const assert_1 = require("../../util/assert");
6
+ const edge_1 = require("../graph/edge");
7
+ const alias_tracking_1 = require("../eval/resolve/alias-tracking");
8
+ const config_1 = require("../../config");
9
+ const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
10
+ const general_1 = require("../eval/values/general");
11
+ function isAnyReturnAFunction(def, graph) {
12
+ const workingQueue = def.exitPoints.map(d => graph.getVertex(d, true)).filter(assert_1.isNotUndefined);
13
+ const seen = new Set();
14
+ while (workingQueue.length > 0) {
15
+ const current = workingQueue.pop();
16
+ if (seen.has(current.id)) {
17
+ continue;
18
+ }
19
+ seen.add(current.id);
20
+ if ((0, vertex_1.isFunctionDefinitionVertex)(current)) {
21
+ return true;
22
+ }
23
+ const next = graph.outgoingEdges(current.id) ?? [];
24
+ for (const [t, { types }] of next) {
25
+ if ((0, edge_1.edgeIncludesType)(types, edge_1.EdgeType.Returns)) {
26
+ const v = graph.getVertex(t, true);
27
+ if (v) {
28
+ workingQueue.push(v);
29
+ }
30
+ }
31
+ }
32
+ }
33
+ return false;
34
+ }
35
+ function inspectCallSitesArgumentsFns(def, graph) {
36
+ const callSites = graph.ingoingEdges(def.id);
37
+ for (const [callerId, { types }] of callSites ?? []) {
38
+ if (!(0, edge_1.edgeIncludesType)(types, edge_1.EdgeType.Calls)) {
39
+ continue;
40
+ }
41
+ const caller = graph.getVertex(callerId, true);
42
+ if (!caller || !(0, vertex_1.isFunctionCallVertex)(caller)) {
43
+ continue;
44
+ }
45
+ for (const arg of caller.args) {
46
+ if (arg === r_function_call_1.EmptyArgument) {
47
+ continue;
48
+ }
49
+ const value = (0, general_1.valueSetGuard)((0, alias_tracking_1.resolveIdToValue)(arg.nodeId, { graph, idMap: graph.idMap, resolve: config_1.VariableResolve.Alias, full: true }));
50
+ if (value?.elements.some(e => e.type === 'function-definition')) {
51
+ return true;
52
+ }
53
+ }
54
+ }
55
+ return false;
56
+ }
57
+ /**
58
+ * Determines whether the function with the given id is a higher-order function, i.e.,
59
+ * either takes a function as an argument or (may) returns a function.
60
+ * If the return is an identity, e.g., `function(x) x`, this is not considered higher-order,
61
+ * if no function is passed as an argument.
62
+ */
63
+ function isHigherOrder(id, graph) {
64
+ const vert = graph.getVertex(id);
65
+ if (!vert || !(0, vertex_1.isFunctionDefinitionVertex)(vert)) {
66
+ return false;
67
+ }
68
+ // 1. check whether any of the exit types is a function
69
+ if (isAnyReturnAFunction(vert, graph)) {
70
+ return true;
71
+ }
72
+ // 2. check whether any of the callsites passes a function
73
+ return inspectCallSitesArgumentsFns(vert, graph);
74
+ }
75
+ //# sourceMappingURL=higher-order-function.js.map
@@ -7,8 +7,7 @@ import type { DataflowGraphVertexAstLink, DataflowGraphVertexUse, FunctionOrigin
7
7
  import type { ControlDependency } from '../info';
8
8
  import type { LinkTo } from '../../queries/catalog/call-context-query/call-context-query-format';
9
9
  import type { FlowrSearchLike } from '../../search/flowr-search-builder';
10
- import type { Pipeline } from '../../core/steps/pipeline/pipeline';
11
- import type { FlowrSearchInput } from '../../search/flowr-search';
10
+ import type { FlowrAnalysisProvider } from '../../project/flowr-analyzer';
12
11
  export declare function emptyGraph(idMap?: AstIdMap): DataflowGraphBuilder;
13
12
  export type DataflowGraphEdgeTarget = NodeId | (readonly NodeId[]);
14
13
  /**
@@ -103,9 +102,9 @@ export declare class DataflowGraphBuilder extends DataflowGraph {
103
102
  *
104
103
  * @param from - Either a node id or a query to find the node id.
105
104
  * @param to - Either a node id or a query to find the node id.
106
- * @param data - The data to search in i.e. the dataflow graph.
105
+ * @param input - The input to search in i.e. the dataflow graph.
107
106
  */
108
- readsQuery<P extends Pipeline>(from: FromQueryParam, to: ToQueryParam, data: FlowrSearchInput<P>): this;
107
+ readsQuery(from: FromQueryParam, to: ToQueryParam, input: FlowrAnalysisProvider): Promise<this>;
109
108
  /**
110
109
  * Adds a **defined-by edge** with from as defined variable, and to
111
110
  * as a variable/function contributing to its definition.
@@ -118,7 +117,7 @@ export declare class DataflowGraphBuilder extends DataflowGraph {
118
117
  *
119
118
  * @see {@link DataflowGraphBuilder#readsQuery|readsQuery} for parameters.
120
119
  */
121
- definedByQuery<P extends Pipeline>(from: FromQueryParam, to: ToQueryParam, data: FlowrSearchInput<P>): this;
120
+ definedByQuery(from: FromQueryParam, to: ToQueryParam, data: FlowrAnalysisProvider): Promise<this>;
122
121
  /**
123
122
  * Adds a **call edge** with from as caller, and to as callee.
124
123
  *
@@ -130,7 +129,7 @@ export declare class DataflowGraphBuilder extends DataflowGraph {
130
129
  *
131
130
  * @see {@link DataflowGraphBuilder#readsQuery|readsQuery} for parameters.
132
131
  */
133
- callsQuery<P extends Pipeline>(from: FromQueryParam, to: ToQueryParam, data: FlowrSearchInput<P>): this;
132
+ callsQuery(from: FromQueryParam, to: ToQueryParam, data: FlowrAnalysisProvider): Promise<this>;
134
133
  /**
135
134
  * Adds a **return edge** with from as function, and to as exit point.
136
135
  *
@@ -142,7 +141,7 @@ export declare class DataflowGraphBuilder extends DataflowGraph {
142
141
  *
143
142
  * @see {@link DataflowGraphBuilder#readsQuery|readsQuery} for parameters.
144
143
  */
145
- returnsQuery<P extends Pipeline>(from: FromQueryParam, to: ToQueryParam, data: FlowrSearchInput<P>): this;
144
+ returnsQuery(from: FromQueryParam, to: ToQueryParam, data: FlowrAnalysisProvider): Promise<this>;
146
145
  /**
147
146
  * Adds a **defines-on-call edge** with from as variable, and to as its definition
148
147
  *
@@ -154,7 +153,7 @@ export declare class DataflowGraphBuilder extends DataflowGraph {
154
153
  *
155
154
  * @see {@link DataflowGraphBuilder#readsQuery|readsQuery} for parameters.
156
155
  */
157
- definesOnCallQuery<P extends Pipeline>(from: FromQueryParam, to: ToQueryParam, data: FlowrSearchInput<P>): this;
156
+ definesOnCallQuery(from: FromQueryParam, to: ToQueryParam, data: FlowrAnalysisProvider): Promise<this>;
158
157
  /**
159
158
  * Adds a **defined-by-on-call edge** with from as definition, and to as variable.
160
159
  *
@@ -166,7 +165,7 @@ export declare class DataflowGraphBuilder extends DataflowGraph {
166
165
  *
167
166
  * @see {@link DataflowGraphBuilder#readsQuery|readsQuery} for parameters.
168
167
  */
169
- definedByOnCallQuery<P extends Pipeline>(from: FromQueryParam, to: ToQueryParam, data: FlowrSearchInput<P>): this;
168
+ definedByOnCallQuery(from: FromQueryParam, to: ToQueryParam, data: FlowrAnalysisProvider): Promise<this>;
170
169
  /**
171
170
  * Adds an **argument edge** with from as function call, and to as argument.
172
171
  *
@@ -178,7 +177,7 @@ export declare class DataflowGraphBuilder extends DataflowGraph {
178
177
  *
179
178
  * @see {@link DataflowGraphBuilder#readsQuery|readsQuery} for parameters.
180
179
  */
181
- argumentQuery<P extends Pipeline>(from: FromQueryParam, to: ToQueryParam, data: FlowrSearchInput<P>): this;
180
+ argumentQuery(from: FromQueryParam, to: ToQueryParam, data: FlowrAnalysisProvider): Promise<this>;
182
181
  /**
183
182
  * Adds a **non-standard evaluation edge** with from as vertex, and to as vertex.
184
183
  *
@@ -190,7 +189,7 @@ export declare class DataflowGraphBuilder extends DataflowGraph {
190
189
  *
191
190
  * @see {@link DataflowGraphBuilder#readsQuery|readsQuery} for parameters.
192
191
  */
193
- nseQuery<P extends Pipeline>(from: FromQueryParam, to: ToQueryParam, data: FlowrSearchInput<P>): this;
192
+ nseQuery(from: FromQueryParam, to: ToQueryParam, data: FlowrAnalysisProvider): Promise<this>;
194
193
  /**
195
194
  * Adds a **side-effect-on-call edge** with from as vertex, and to as vertex.
196
195
  *
@@ -202,7 +201,7 @@ export declare class DataflowGraphBuilder extends DataflowGraph {
202
201
  *
203
202
  * @see {@link DataflowGraphBuilder#readsQuery|readsQuery} for parameters.
204
203
  */
205
- sideEffectOnCallQuery<P extends Pipeline>(from: FromQueryParam, to: ToQueryParam, data: FlowrSearchInput<P>): this;
204
+ sideEffectOnCallQuery(from: FromQueryParam, to: ToQueryParam, data: FlowrAnalysisProvider): Promise<this>;
206
205
  /**
207
206
  * explicitly overwrite the root ids of the graph,
208
207
  * this is just an easier variant in case you working with a lot of functions this saves you a lot of `false` flags.
@@ -174,13 +174,13 @@ class DataflowGraphBuilder extends graph_1.DataflowGraph {
174
174
  }
175
175
  return this.addEdge((0, node_id_1.normalizeIdToNumberIfPossible)(from), (0, node_id_1.normalizeIdToNumberIfPossible)(to), type);
176
176
  }
177
- queryHelper(from, to, data, type) {
177
+ async queryHelper(from, to, data, type) {
178
178
  let fromId;
179
179
  if ('nodeId' in from) {
180
180
  fromId = from.nodeId;
181
181
  }
182
182
  else {
183
- const result = (0, flowr_search_executor_1.runSearch)(from.query, data).getElements();
183
+ const result = (await (0, flowr_search_executor_1.runSearch)(from.query, data)).getElements();
184
184
  (0, assert_1.guard)(result.length === 1, `from query result should yield exactly one node, but yielded ${result.length}`);
185
185
  fromId = result[0].node.info.id;
186
186
  }
@@ -189,7 +189,7 @@ class DataflowGraphBuilder extends graph_1.DataflowGraph {
189
189
  toIds = to.target;
190
190
  }
191
191
  else {
192
- const result = (0, flowr_search_executor_1.runSearch)(to.query, data).getElements();
192
+ const result = (await (0, flowr_search_executor_1.runSearch)(to.query, data)).getElements();
193
193
  toIds = result.map(r => r.node.info.id);
194
194
  }
195
195
  return this.edgeHelper(fromId, toIds, type);
@@ -209,10 +209,10 @@ class DataflowGraphBuilder extends graph_1.DataflowGraph {
209
209
  *
210
210
  * @param from - Either a node id or a query to find the node id.
211
211
  * @param to - Either a node id or a query to find the node id.
212
- * @param data - The data to search in i.e. the dataflow graph.
212
+ * @param input - The input to search in i.e. the dataflow graph.
213
213
  */
214
- readsQuery(from, to, data) {
215
- return this.queryHelper(from, to, data, edge_1.EdgeType.Reads);
214
+ readsQuery(from, to, input) {
215
+ return this.queryHelper(from, to, input, edge_1.EdgeType.Reads);
216
216
  }
217
217
  /**
218
218
  * Adds a **defined-by edge** with from as defined variable, and to
@@ -1,16 +1,13 @@
1
1
  import type { RShell } from '../../r-bridge/shell';
2
- import type { Queries, QueryResults, SupportedQueryTypes } from '../../queries/query';
3
- import { DEFAULT_DATAFLOW_PIPELINE } from '../../core/steps/pipeline/default-pipelines';
2
+ import type { Queries, SupportedQueryTypes } from '../../queries/query';
4
3
  import type { SupportedVirtualQueryTypes } from '../../queries/virtual-query/virtual-queries';
5
4
  import type { VirtualCompoundConstraint } from '../../queries/virtual-query/compound-query';
6
- import type { PipelineOutput } from '../../core/steps/pipeline/pipeline';
7
- export interface ShowQueryOptions<Base extends SupportedQueryTypes> {
5
+ export interface ShowQueryOptions {
8
6
  readonly showCode?: boolean;
9
7
  readonly collapseResult?: boolean;
10
8
  readonly collapseQuery?: boolean;
11
- readonly addOutput?: (result: QueryResults<Base>, pipeline: PipelineOutput<typeof DEFAULT_DATAFLOW_PIPELINE>) => string;
12
9
  }
13
- export declare function showQuery<Base extends SupportedQueryTypes, VirtualArguments extends VirtualCompoundConstraint<Base> = VirtualCompoundConstraint<Base>>(shell: RShell, code: string, queries: Queries<Base, VirtualArguments>, { showCode, collapseResult, collapseQuery, addOutput }?: ShowQueryOptions<Base>): Promise<string>;
10
+ export declare function showQuery<Base extends SupportedQueryTypes, VirtualArguments extends VirtualCompoundConstraint<Base> = VirtualCompoundConstraint<Base>>(shell: RShell, code: string, queries: Queries<Base, VirtualArguments>, { showCode, collapseResult, collapseQuery }?: ShowQueryOptions): Promise<string>;
14
11
  export interface QueryDocumentation {
15
12
  readonly name: string;
16
13
  readonly type: 'virtual' | 'active';
@@ -6,9 +6,6 @@ exports.registerQueryDocumentation = registerQueryDocumentation;
6
6
  exports.linkToQueryOfName = linkToQueryOfName;
7
7
  exports.tocForQueryType = tocForQueryType;
8
8
  exports.explainQueries = explainQueries;
9
- const query_1 = require("../../queries/query");
10
- const pipeline_executor_1 = require("../../core/pipeline-executor");
11
- const default_pipelines_1 = require("../../core/steps/pipeline/default-pipelines");
12
9
  const retriever_1 = require("../../r-bridge/retriever");
13
10
  const json_1 = require("../../util/json");
14
11
  const ansi_1 = require("../../util/text/ansi");
@@ -17,19 +14,12 @@ const doc_dfg_1 = require("./doc-dfg");
17
14
  const doc_code_1 = require("./doc-code");
18
15
  const time_1 = require("../../util/text/time");
19
16
  const query_print_1 = require("../../queries/query-print");
17
+ const flowr_analyzer_builder_1 = require("../../project/flowr-analyzer-builder");
20
18
  const doc_cli_option_1 = require("./doc-cli-option");
21
- const config_1 = require("../../config");
22
- async function showQuery(shell, code, queries, { showCode, collapseResult, collapseQuery, addOutput = () => '' } = {}) {
19
+ async function showQuery(shell, code, queries, { showCode, collapseResult, collapseQuery } = {}) {
23
20
  const now = performance.now();
24
- const analysis = await new pipeline_executor_1.PipelineExecutor(default_pipelines_1.DEFAULT_DATAFLOW_PIPELINE, {
25
- parser: shell,
26
- request: (0, retriever_1.requestFromInput)(code)
27
- }, config_1.defaultConfigOptions).allRemainingSteps();
28
- const results = await Promise.resolve((0, query_1.executeQueries)({
29
- dataflow: analysis.dataflow,
30
- ast: analysis.normalize,
31
- config: (0, config_1.cloneConfig)(config_1.defaultConfigOptions)
32
- }, queries));
21
+ const analyzer = await new flowr_analyzer_builder_1.FlowrAnalyzerBuilder((0, retriever_1.requestFromInput)(code)).setParser(shell).build();
22
+ const results = await analyzer.query(queries);
33
23
  const duration = performance.now() - now;
34
24
  const metaInfo = `
35
25
  The analysis required _${(0, time_1.printAsMs)(duration)}_ (including parsing and normalization and the query) within the generation environment.
@@ -52,7 +42,7 @@ ${collapseResult ? ' <details> <summary style="color:gray">Show Results</summary
52
42
 
53
43
  _Results (prettified and summarized):_
54
44
 
55
- ${(0, query_print_1.asciiSummaryOfQueryResult)(ansi_1.markdownFormatter, duration, results, analysis, queries)}
45
+ ${await (0, query_print_1.asciiSummaryOfQueryResult)(ansi_1.markdownFormatter, duration, results, analyzer, queries)}
56
46
 
57
47
  <details> <summary style="color:gray">Show Detailed Results as Json</summary>
58
48
 
@@ -75,8 +65,6 @@ ${await (0, doc_dfg_1.printDfGraphForCode)(shell, code, { switchCodeAndGraph: tr
75
65
 
76
66
  ${collapseResult ? '</details>' : ''}
77
67
 
78
- ${addOutput(results, analysis)}
79
-
80
68
  `;
81
69
  }
82
70
  exports.RegisteredQueries = {
@@ -11,7 +11,7 @@ const doc_docker_1 = require("./doc-docker");
11
11
  const prompt_1 = require("../../cli/repl/prompt");
12
12
  const doc_code_1 = require("./doc-code");
13
13
  const print_version_1 = require("../../cli/repl/print-version");
14
- const config_1 = require("../../config");
14
+ const flowr_analyzer_builder_1 = require("../../project/flowr-analyzer-builder");
15
15
  function printHelpForScript(script, starredVersion) {
16
16
  let base = `| **${(0, doc_cli_option_1.getReplCommand)(script[0], false, starredVersion !== undefined)}** | ${script[1].description}`;
17
17
  if (starredVersion) {
@@ -52,7 +52,10 @@ async function documentReplSession(parser, commands, options) {
52
52
  entry.lines.push(msg);
53
53
  }
54
54
  };
55
- await (0, core_1.replProcessAnswer)(config_1.defaultConfigOptions, collectingOutput, command.command, parser, options?.allowRSessionAccess ?? false);
55
+ const analyzer = await new flowr_analyzer_builder_1.FlowrAnalyzerBuilder()
56
+ .setParser(parser)
57
+ .build();
58
+ await (0, core_1.replProcessAnswer)(analyzer, collectingOutput, command.command, options?.allowRSessionAccess ?? false);
56
59
  collect.push(entry);
57
60
  }
58
61
  let result = '';
@@ -6,29 +6,26 @@ exports.registerQueryDocumentation = registerQueryDocumentation;
6
6
  exports.linkToQueryOfName = linkToQueryOfName;
7
7
  exports.tocForQueryType = tocForQueryType;
8
8
  exports.explainQueries = explainQueries;
9
- const pipeline_executor_1 = require("../../core/pipeline-executor");
10
- const default_pipelines_1 = require("../../core/steps/pipeline/default-pipelines");
11
9
  const retriever_1 = require("../../r-bridge/retriever");
12
10
  const doc_files_1 = require("./doc-files");
13
11
  const doc_dfg_1 = require("./doc-dfg");
14
12
  const doc_code_1 = require("./doc-code");
15
13
  const time_1 = require("../../util/text/time");
16
- const flowr_search_executor_1 = require("../../search/flowr-search-executor");
17
14
  const flowr_search_printer_1 = require("../../search/flowr-search-printer");
18
15
  const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
19
16
  const dfg_1 = require("../../util/mermaid/dfg");
20
- const config_1 = require("../../config");
17
+ const flowr_analyzer_builder_1 = require("../../project/flowr-analyzer-builder");
21
18
  async function showSearch(shell, code, search, { collapseResult = true } = {}) {
22
19
  const now = performance.now();
23
- const analysis = await new pipeline_executor_1.PipelineExecutor(default_pipelines_1.DEFAULT_DATAFLOW_PIPELINE, {
24
- parser: shell,
25
- request: (0, retriever_1.requestFromInput)(code)
26
- }, config_1.defaultConfigOptions).allRemainingSteps();
27
- const result = (0, flowr_search_executor_1.runSearch)(search, { ...analysis, config: config_1.defaultConfigOptions });
20
+ const analyzer = await new flowr_analyzer_builder_1.FlowrAnalyzerBuilder((0, retriever_1.requestFromInput)(code))
21
+ .setParser(shell)
22
+ .build();
23
+ const result = await analyzer.runSearch(search);
28
24
  const duration = performance.now() - now;
29
25
  const metaInfo = `
30
26
  The search required _${(0, time_1.printAsMs)(duration)}_ (including parsing and normalization and the query) within the generation environment.
31
27
  `.trim();
28
+ const dataflow = await analyzer.dataflow();
32
29
  return `
33
30
 
34
31
  ${(0, doc_code_1.codeBlock)('ts', (0, flowr_search_printer_1.flowrSearchToCode)(search))}
@@ -53,7 +50,7 @@ ${(0, doc_code_1.codeBlock)('json', JSON.stringify(search, null, 2))}
53
50
  ${collapseResult ? ' <details> <summary style="color:gray">Show Results</summary>' : ''}
54
51
 
55
52
  The query returns the following vetices (all references to \`x\` in the code):
56
- ${result.getElements().map(({ node }) => `<b>${node.info.id} ('${(0, node_id_1.recoverContent)(node.info.id, analysis.dataflow.graph)}')</b> at L${(0, dfg_1.formatRange)(node.location)}`).join(', ')}
53
+ ${result.getElements().map(({ node }) => `<b>${node.info.id} ('${(0, node_id_1.recoverContent)(node.info.id, dataflow.graph)}')</b> at L${(0, dfg_1.formatRange)(node.location)}`).join(', ')}
57
54
 
58
55
  ${metaInfo}
59
56
 
@@ -11,3 +11,7 @@ export interface BlockOptions {
11
11
  }
12
12
  export declare function block({ type, content }: BlockOptions): string;
13
13
  export declare function section(title: string, depth?: 1 | 2 | 3 | 4 | 5 | 6, anchor?: string): string;
14
+ /**
15
+ * Supported pattern: `Name@link`
16
+ */
17
+ export declare function collapsibleToc(content: Record<string, Record<string, Record<string, undefined> | undefined> | undefined>): string;
@@ -3,8 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.details = details;
4
4
  exports.block = block;
5
5
  exports.section = section;
6
+ exports.collapsibleToc = collapsibleToc;
6
7
  const doc_general_1 = require("./doc-general");
7
8
  const mermaid_1 = require("../../util/mermaid/mermaid");
9
+ const strings_1 = require("../../util/text/strings");
8
10
  function details(title, content, { color, open = false, hideIfEmpty = true, prefixInit = '' } = {}) {
9
11
  return hideIfEmpty && content.trim().length === 0 ? '' : `
10
12
  ${prefixInit}<details${open ? ' open' : ''}><summary style="${color ? 'color:' + color : ''}">${title}</summary>
@@ -23,4 +25,30 @@ ${(0, doc_general_1.prefixLines)(content, '> ')}
23
25
  function section(title, depth = 2, anchor = (0, mermaid_1.escapeId)(title)) {
24
26
  return `<h${depth} id="${anchor}">${title}</h${depth}>`;
25
27
  }
28
+ function strToLink(str) {
29
+ const match = str.match(/^(.*?)@(.*)$/);
30
+ if (match) {
31
+ const [, name, link] = match;
32
+ return `[${name}](${link})`;
33
+ }
34
+ return `[${str}](#${(0, mermaid_1.escapeId)(str)})`;
35
+ }
36
+ /**
37
+ * Supported pattern: `Name@link`
38
+ */
39
+ function collapsibleToc(content) {
40
+ let output = '';
41
+ for (const [section, subsections] of Object.entries(content)) {
42
+ output += `- ${strToLink(section)}\n`;
43
+ if (subsections) {
44
+ for (const [subsection, items] of Object.entries(subsections)) {
45
+ output += ` - ${strToLink(subsection)} \n`;
46
+ if (items) {
47
+ output += ` ${(0, strings_1.joinWithLast)(Object.keys(items).map(strToLink))}\n`;
48
+ }
49
+ }
50
+ }
51
+ }
52
+ return output;
53
+ }
26
54
  //# sourceMappingURL=doc-structure.js.map
@@ -62,8 +62,12 @@ export declare function printHierarchy({ program, info, root, collapseFromNestin
62
62
  interface FnInfo {
63
63
  info: TypeElementInSource[];
64
64
  program: ts.Program;
65
+ dropLinesStart?: number;
66
+ dropLinesEnd?: number;
67
+ doNotAutoGobble?: boolean;
68
+ hideDefinedAt?: boolean;
65
69
  }
66
- export declare function printCodeOfElement({ program, info }: FnInfo, name: string): string;
70
+ export declare function printCodeOfElement({ program, info, dropLinesEnd, dropLinesStart, doNotAutoGobble, hideDefinedAt }: FnInfo, name: string): string;
67
71
  /**
68
72
  * Create a short link to a type in the documentation
69
73
  * @param name - The name of the type, e.g. `MyType`, may include a container, e.g.,`MyContainer::MyType` (this works with function nestings too)
@@ -387,14 +387,40 @@ function printHierarchy({ program, info, root, collapseFromNesting = 1, initialN
387
387
  return thisLine + (out ? '\n' + out : '');
388
388
  }
389
389
  }
390
- function printCodeOfElement({ program, info }, name) {
390
+ function printCodeOfElement({ program, info, dropLinesEnd = 0, dropLinesStart = 0, doNotAutoGobble, hideDefinedAt }, name) {
391
391
  const node = info.find(e => e.name === name);
392
392
  if (!node) {
393
393
  console.error(`Could not find node ${name} when resolving function!`);
394
394
  return '';
395
395
  }
396
- const code = node.node.getFullText(program.getSourceFile(node.node.getSourceFile().fileName));
397
- return `${(0, doc_code_1.codeBlock)('ts', code)}\n<i>Defined at <a href="${getTypePathLink(node)}">${getTypePathLink(node, '.')}</a></i>\n`;
396
+ let code = node.node.getFullText(program.getSourceFile(node.node.getSourceFile().fileName)).trim();
397
+ if (dropLinesStart > 0 || dropLinesEnd > 0) {
398
+ const lines = code.split(/\n/g);
399
+ if (dropLinesStart + dropLinesEnd >= lines.length) {
400
+ return '';
401
+ }
402
+ code = lines.slice(dropLinesStart, lines.length - dropLinesEnd).join('\n');
403
+ }
404
+ if (!doNotAutoGobble) {
405
+ // gobble leading spaces
406
+ const lines = code.replaceAll('\t', ' ').split(/\n/g);
407
+ let gobble = Number.POSITIVE_INFINITY;
408
+ for (const line of lines) {
409
+ const match = line.match(/^(\s+)\S+/);
410
+ if (match) {
411
+ gobble = Math.min(gobble, match[1].length);
412
+ }
413
+ }
414
+ if (gobble !== Number.POSITIVE_INFINITY && gobble > 0) {
415
+ code = lines.map(line => line.startsWith(' '.repeat(gobble)) ? line.slice(gobble) : line).join('\n');
416
+ }
417
+ }
418
+ if (hideDefinedAt) {
419
+ return (0, doc_code_1.codeBlock)('ts', code);
420
+ }
421
+ else {
422
+ return `${(0, doc_code_1.codeBlock)('ts', code)}\n<i>Defined at <a href="${getTypePathLink(node)}">${getTypePathLink(node, '.')}</a></i>\n`;
423
+ }
398
424
  }
399
425
  function fuzzyCompare(a, b) {
400
426
  const aStr = a.toLowerCase().replace(/[^a-z0-9]/g, '-').trim();
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,137 @@
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
+ const shell_1 = require("../r-bridge/shell");
7
+ const log_1 = require("../../test/functionality/_helper/log");
8
+ const doc_auto_gen_1 = require("./doc-util/doc-auto-gen");
9
+ const doc_types_1 = require("./doc-util/doc-types");
10
+ const path_1 = __importDefault(require("path"));
11
+ const flowr_analyzer_1 = require("../project/flowr-analyzer");
12
+ const flowr_analyzer_builder_1 = require("../project/flowr-analyzer-builder");
13
+ const doc_structure_1 = require("./doc-util/doc-structure");
14
+ const doc_files_1 = require("./doc-util/doc-files");
15
+ async function analyzerQuickExample() {
16
+ const analyzer = await new flowr_analyzer_builder_1.FlowrAnalyzerBuilder()
17
+ .addRequestFromInput('x <- 1; print(x)')
18
+ .setEngine('tree-sitter')
19
+ .build();
20
+ // get the dataflow
21
+ const df = await analyzer.dataflow();
22
+ // obtain the identified loading order
23
+ console.log(analyzer.inspectContext().files.loadingOrder.getLoadingOrder());
24
+ // run a dependency query
25
+ const results = await analyzer.query([{ type: 'dependencies' }]);
26
+ return { analyzer, df, results };
27
+ }
28
+ async function getText(shell) {
29
+ const rversion = (await shell.usedRVersion())?.format() ?? 'unknown';
30
+ const types = (0, doc_types_1.getTypesFromFolder)({
31
+ rootFolder: path_1.default.resolve('src/'),
32
+ inlineTypes: doc_types_1.mermaidHide
33
+ });
34
+ return `${(0, doc_auto_gen_1.autoGenHeader)({ filename: module.filename, purpose: 'analyzer', rVersion: rversion })}
35
+
36
+ We are currently working on documenting the capabilities of the analyzer (with the plugins, their loading order, etc.). In general, the code documentation
37
+ starting with the ${(0, doc_types_1.shortLink)(flowr_analyzer_1.FlowrAnalyzer.name, types.info)} and the ${(0, doc_types_1.shortLink)(flowr_analyzer_builder_1.FlowrAnalyzerBuilder.name, types.info)}
38
+ should be the best starting point.
39
+
40
+ ${(0, doc_structure_1.collapsibleToc)({
41
+ 'Overview': undefined,
42
+ 'Builder Configuration': undefined,
43
+ 'Plugins': {
44
+ 'Plugin Types': {
45
+ 'Dependency Identification': undefined,
46
+ 'Project Discovery': undefined,
47
+ 'File Loading': undefined,
48
+ 'Loading Order': undefined
49
+ },
50
+ 'How to add a new plugin': undefined,
51
+ 'How to add a new plugin type': undefined
52
+ },
53
+ 'Context Information': {
54
+ 'Files Context': undefined,
55
+ 'Loading Order Context': undefined,
56
+ 'Dependencies Context': undefined
57
+ },
58
+ 'Analyzer Internals': undefined
59
+ })}
60
+
61
+
62
+ ${(0, doc_structure_1.section)('Overview', 2)}
63
+
64
+ No matter whether you want to analyze a single R script, a couple of R notebooks, or a complete project,
65
+ your journey starts with the ${(0, doc_types_1.shortLink)(flowr_analyzer_builder_1.FlowrAnalyzerBuilder.name, types.info)} (further described in [Builder Configuration](#builder-configuration) below).
66
+ This builder allows you to configure the analysis in many different ways, for example, by specifying which files to analyze, which plugins to use, or
67
+ what [Engine](${doc_files_1.FlowrWikiBaseRef}/Engines) to use for the analysis.
68
+
69
+ ${(0, doc_structure_1.block)({
70
+ type: 'NOTE',
71
+ content: `If you want to quickly try out the analyzer, you can use the following code snippet that analyzes a simple R expression:
72
+
73
+ ${(0, doc_types_1.printCodeOfElement)({ program: types.program, info: types.info, dropLinesStart: 1, dropLinesEnd: 2, hideDefinedAt: true }, analyzerQuickExample.name)}
74
+ `
75
+ })}
76
+
77
+ **TODO**: mention [Context](#Context_Information)
78
+
79
+ ${(0, doc_structure_1.section)('Builder Configuration', 2)}
80
+
81
+ **TODO** also explain buildSync and that TreeSitter has to be initialized for this
82
+
83
+ ${(0, doc_structure_1.section)('Plugins', 2)}
84
+
85
+ ${(0, doc_structure_1.section)('Plugin Types', 3)}
86
+
87
+ During the construction of a new ${(0, doc_types_1.shortLink)(flowr_analyzer_1.FlowrAnalyzer.name, types.info)}, plugins of different types are applied at different stages of the analysis.
88
+ These plugins are grouped by their ${(0, doc_types_1.shortLink)('PluginType', types.info)} and are applied in the following order (as shown in the documentation of the ${(0, doc_types_1.shortLink)('PluginType', types.info)}):
89
+
90
+ ${(() => {
91
+ const doc = (0, doc_types_1.getDocumentationForType)('PluginType', types.info);
92
+ // skip until the first ```text
93
+ const lines = doc.split('\n');
94
+ const start = lines.findIndex(l => l.trim().startsWith('```text'));
95
+ const end = lines.findIndex((l, i) => i > start && l.trim().startsWith('```'));
96
+ // github rendering pls fix xD
97
+ return start >= 0 && end > start ? '```text\n' + lines.slice(start + 1, end).join('\n').replaceAll('▶', '>') + '\n```' : doc;
98
+ })()}
99
+
100
+ We describe the different plugin types in more detail below.
101
+
102
+
103
+ ${(0, doc_structure_1.section)('Project Discovery', 4)}
104
+
105
+ ${(0, doc_structure_1.section)('File Loading', 4)}
106
+
107
+ ${(0, doc_structure_1.section)('Dependency Identification', 4)}
108
+
109
+ ${(0, doc_structure_1.section)('Loading Order', 4)}
110
+
111
+ ${(0, doc_structure_1.section)('How to add a new plugin', 3)}
112
+
113
+ ${(0, doc_structure_1.section)('How to add a new plugin type', 3)}
114
+
115
+ ${(0, doc_structure_1.section)('Context Information', 2)}
116
+
117
+ ${(0, doc_structure_1.section)('Files Context', 3)}
118
+
119
+ ${(0, doc_structure_1.section)('Loading Order Context', 3)}
120
+
121
+ ${(0, doc_structure_1.section)('Dependencies Context', 3)}
122
+
123
+ ${(0, doc_structure_1.section)('Analyzer Internals', 2)}
124
+
125
+ `;
126
+ }
127
+ /** if we run this script, we want a Markdown representation of the capabilities */
128
+ if (require.main === module) {
129
+ (0, log_1.setMinLevelOfAllLogs)(6 /* LogLevel.Fatal */);
130
+ const shell = new shell_1.RShell();
131
+ void getText(shell).then(str => {
132
+ console.log(str);
133
+ }).finally(() => {
134
+ shell.close();
135
+ });
136
+ }
137
+ //# sourceMappingURL=print-analyzer-wiki.js.map