@eagleoutice/flowr 2.2.12 → 2.2.14

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 (282) hide show
  1. package/README.md +82 -20
  2. package/benchmark/slicer.js +2 -2
  3. package/benchmark/summarizer/first-phase/input.js +1 -1
  4. package/benchmark/summarizer/first-phase/process.js +3 -3
  5. package/benchmark/summarizer/second-phase/process.js +1 -1
  6. package/benchmark/summarizer/summarizer.js +1 -1
  7. package/cli/common/options.js +4 -4
  8. package/cli/common/script.js +1 -1
  9. package/cli/flowr.js +1 -1
  10. package/cli/repl/commands/repl-cfg.d.ts +2 -0
  11. package/cli/repl/commands/repl-cfg.js +38 -24
  12. package/cli/repl/commands/repl-commands.js +4 -2
  13. package/cli/repl/commands/repl-dataflow.js +3 -3
  14. package/cli/repl/commands/repl-execute.js +1 -1
  15. package/cli/repl/commands/repl-main.d.ts +1 -1
  16. package/cli/repl/commands/repl-main.js +1 -1
  17. package/cli/repl/commands/repl-normalize.js +1 -1
  18. package/cli/repl/commands/repl-query.js +2 -2
  19. package/cli/repl/core.js +1 -1
  20. package/cli/repl/prompt.js +1 -1
  21. package/cli/repl/server/connection.js +4 -4
  22. package/cli/repl/server/messages/message-analysis.d.ts +1 -1
  23. package/cli/script-core/statistics-core.js +1 -1
  24. package/cli/script-core/statistics-helper-core.js +4 -4
  25. package/config.d.ts +47 -24
  26. package/config.js +3 -3
  27. package/control-flow/basic-cfg-guided-visitor.d.ts +39 -0
  28. package/control-flow/basic-cfg-guided-visitor.js +114 -0
  29. package/control-flow/cfg-properties.d.ts +26 -0
  30. package/control-flow/cfg-properties.js +100 -0
  31. package/control-flow/cfg-simplification.d.ts +18 -0
  32. package/control-flow/cfg-simplification.js +55 -0
  33. package/control-flow/cfg-to-basic-blocks.d.ts +5 -0
  34. package/control-flow/cfg-to-basic-blocks.js +81 -0
  35. package/control-flow/control-flow-graph.d.ts +247 -0
  36. package/control-flow/control-flow-graph.js +290 -0
  37. package/control-flow/dfg-cfg-guided-visitor.d.ts +32 -0
  38. package/control-flow/dfg-cfg-guided-visitor.js +71 -0
  39. package/control-flow/diff-cfg.d.ts +11 -0
  40. package/control-flow/diff-cfg.js +161 -0
  41. package/control-flow/extract-cfg.d.ts +30 -0
  42. package/control-flow/extract-cfg.js +475 -0
  43. package/control-flow/happens-before.d.ts +7 -0
  44. package/{util/cfg → control-flow}/happens-before.js +3 -3
  45. package/control-flow/semantic-cfg-guided-visitor.d.ts +452 -0
  46. package/control-flow/semantic-cfg-guided-visitor.js +492 -0
  47. package/control-flow/simple-visitor.d.ts +25 -0
  48. package/control-flow/simple-visitor.js +80 -0
  49. package/control-flow/syntax-cfg-guided-visitor.d.ts +128 -0
  50. package/control-flow/syntax-cfg-guided-visitor.js +166 -0
  51. package/core/print/print.d.ts +1 -1
  52. package/core/print/slice-diff-ansi.js +1 -1
  53. package/core/steps/pipeline/create-pipeline.js +1 -1
  54. package/dataflow/environments/built-in-config.js +9 -6
  55. package/dataflow/environments/built-in.d.ts +8 -4
  56. package/dataflow/environments/built-in.js +47 -5
  57. package/dataflow/environments/default-builtin-config.d.ts +2 -0
  58. package/dataflow/environments/default-builtin-config.js +81 -14
  59. package/dataflow/environments/resolve-by-name.js +15 -4
  60. package/dataflow/extractor.js +2 -2
  61. package/dataflow/graph/dataflowgraph-builder.d.ts +3 -1
  62. package/dataflow/graph/dataflowgraph-builder.js +4 -2
  63. package/dataflow/graph/diff-dataflow-graph.d.ts +16 -0
  64. package/dataflow/graph/{diff.js → diff-dataflow-graph.js} +30 -56
  65. package/dataflow/graph/graph.d.ts +11 -3
  66. package/dataflow/graph/graph.js +27 -12
  67. package/dataflow/graph/vertex.d.ts +17 -2
  68. package/dataflow/internal/linker.d.ts +3 -2
  69. package/dataflow/internal/linker.js +33 -24
  70. package/dataflow/internal/process/functions/call/argument/unpack-argument.d.ts +1 -1
  71. package/dataflow/internal/process/functions/call/argument/unpack-argument.js +1 -1
  72. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +12 -9
  73. package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +1 -1
  74. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +84 -16
  75. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +23 -16
  76. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +5 -5
  77. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +9 -4
  78. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +3 -2
  79. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +15 -4
  80. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +4 -3
  81. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +4 -3
  82. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +4 -3
  83. package/dataflow/internal/process/functions/call/built-in/built-in-list.js +1 -1
  84. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +1 -1
  85. package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +9 -7
  86. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +3 -2
  87. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.d.ts +1 -0
  88. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +19 -4
  89. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +2 -2
  90. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +19 -4
  91. package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.js +4 -3
  92. package/dataflow/internal/process/functions/call/built-in/built-in-vector.js +3 -3
  93. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +3 -3
  94. package/dataflow/internal/process/functions/call/common.d.ts +4 -1
  95. package/dataflow/internal/process/functions/call/common.js +5 -3
  96. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +3 -2
  97. package/dataflow/internal/process/functions/call/known-call-handling.js +2 -1
  98. package/dataflow/internal/process/functions/call/named-call-handling.js +1 -1
  99. package/dataflow/internal/process/functions/call/unnamed-call-handling.d.ts +1 -0
  100. package/dataflow/internal/process/functions/call/unnamed-call-handling.js +6 -4
  101. package/dataflow/internal/process/process-named-call.d.ts +1 -1
  102. package/dataflow/internal/process/process-named-call.js +5 -5
  103. package/dataflow/origin/dfg-get-origin.d.ts +82 -0
  104. package/dataflow/origin/dfg-get-origin.js +116 -0
  105. package/documentation/doc-util/doc-cfg.d.ts +13 -6
  106. package/documentation/doc-util/doc-cfg.js +20 -15
  107. package/documentation/doc-util/doc-cli-option.js +4 -2
  108. package/documentation/doc-util/doc-dfg.js +3 -3
  109. package/documentation/doc-util/doc-escape.d.ts +7 -0
  110. package/documentation/doc-util/doc-escape.js +19 -0
  111. package/documentation/doc-util/doc-files.d.ts +1 -0
  112. package/documentation/doc-util/doc-files.js +2 -1
  113. package/documentation/doc-util/doc-normalized-ast.js +3 -3
  114. package/documentation/doc-util/doc-query.js +2 -2
  115. package/documentation/doc-util/doc-repl.js +1 -1
  116. package/documentation/doc-util/doc-search.js +1 -1
  117. package/documentation/doc-util/doc-server-message.js +2 -2
  118. package/documentation/doc-util/doc-structure.d.ts +1 -0
  119. package/documentation/doc-util/doc-structure.js +5 -0
  120. package/documentation/doc-util/doc-types.d.ts +7 -1
  121. package/documentation/doc-util/doc-types.js +13 -2
  122. package/documentation/print-capabilities-markdown.js +27 -1
  123. package/documentation/print-cfg-wiki.js +508 -20
  124. package/documentation/print-dataflow-graph-wiki.js +180 -25
  125. package/documentation/print-engines-wiki.js +1 -1
  126. package/documentation/print-faq-wiki.d.ts +1 -0
  127. package/documentation/print-faq-wiki.js +75 -0
  128. package/documentation/print-interface-wiki.js +1 -1
  129. package/documentation/print-linter-wiki.d.ts +1 -0
  130. package/documentation/print-linter-wiki.js +76 -0
  131. package/documentation/print-linting-and-testing-wiki.js +52 -36
  132. package/documentation/print-normalized-ast-wiki.js +1 -1
  133. package/documentation/print-onboarding-wiki.d.ts +1 -0
  134. package/documentation/print-onboarding-wiki.js +42 -0
  135. package/documentation/print-query-wiki.js +21 -1
  136. package/documentation/print-readme.js +10 -3
  137. package/linter/linter-executor.d.ts +9 -0
  138. package/linter/linter-executor.js +26 -0
  139. package/linter/linter-format.d.ts +65 -0
  140. package/linter/linter-format.js +9 -0
  141. package/linter/linter-rules.d.ts +42 -0
  142. package/linter/linter-rules.js +14 -0
  143. package/linter/rules/1-deprecated-functions.d.ts +34 -0
  144. package/linter/rules/1-deprecated-functions.js +54 -0
  145. package/linter/rules/2-file-path-validity.d.ts +48 -0
  146. package/linter/rules/2-file-path-validity.js +93 -0
  147. package/package.json +10 -6
  148. package/queries/catalog/call-context-query/call-context-query-executor.js +5 -5
  149. package/queries/catalog/call-context-query/call-context-query-format.d.ts +3 -3
  150. package/queries/catalog/call-context-query/call-context-query-format.js +7 -3
  151. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.d.ts +2 -2
  152. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +24 -21
  153. package/queries/catalog/cluster-query/cluster-query-format.d.ts +3 -1
  154. package/queries/catalog/cluster-query/cluster-query-format.js +6 -2
  155. package/queries/catalog/config-query/config-query-format.d.ts +2 -1
  156. package/queries/catalog/config-query/config-query-format.js +4 -3
  157. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.d.ts +2 -1
  158. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.js +4 -3
  159. package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +3 -1
  160. package/queries/catalog/dataflow-query/dataflow-query-format.js +11 -3
  161. package/queries/catalog/dependencies-query/dependencies-query-executor.js +4 -2
  162. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +2 -1
  163. package/queries/catalog/dependencies-query/dependencies-query-format.js +12 -3
  164. package/queries/catalog/happens-before-query/happens-before-query-executor.d.ts +1 -1
  165. package/queries/catalog/happens-before-query/happens-before-query-executor.js +4 -4
  166. package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +2 -1
  167. package/queries/catalog/happens-before-query/happens-before-query-format.js +4 -3
  168. package/queries/catalog/id-map-query/id-map-query-format.d.ts +2 -1
  169. package/queries/catalog/id-map-query/id-map-query-format.js +4 -3
  170. package/queries/catalog/lineage-query/lineage-query-format.d.ts +2 -1
  171. package/queries/catalog/lineage-query/lineage-query-format.js +7 -3
  172. package/queries/catalog/linter-query/linter-query-executor.d.ts +3 -0
  173. package/queries/catalog/linter-query/linter-query-executor.js +28 -0
  174. package/queries/catalog/linter-query/linter-query-format.d.ts +80 -0
  175. package/queries/catalog/linter-query/linter-query-format.js +43 -0
  176. package/queries/catalog/location-map-query/location-map-query-format.d.ts +2 -1
  177. package/queries/catalog/location-map-query/location-map-query-format.js +4 -3
  178. package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +2 -1
  179. package/queries/catalog/normalized-ast-query/normalized-ast-query-format.js +4 -3
  180. package/queries/catalog/origin-query/origin-query-executor.d.ts +5 -0
  181. package/queries/catalog/origin-query/origin-query-executor.js +33 -0
  182. package/queries/catalog/origin-query/origin-query-format.d.ts +73 -0
  183. package/queries/catalog/origin-query/origin-query-format.js +31 -0
  184. package/queries/catalog/project-query/project-query-executor.js +1 -1
  185. package/queries/catalog/project-query/project-query-format.d.ts +2 -1
  186. package/queries/catalog/project-query/project-query-format.js +4 -3
  187. package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +2 -1
  188. package/queries/catalog/resolve-value-query/resolve-value-query-format.js +4 -3
  189. package/queries/catalog/search-query/search-query-format.d.ts +2 -1
  190. package/queries/catalog/search-query/search-query-format.js +7 -3
  191. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +3 -1
  192. package/queries/catalog/static-slice-query/static-slice-query-format.js +11 -3
  193. package/queries/query-print.d.ts +1 -1
  194. package/queries/query-print.js +4 -4
  195. package/queries/query.d.ts +143 -2
  196. package/queries/query.js +5 -1
  197. package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +3 -2
  198. package/r-bridge/lang-4.x/ast/model/nodes/r-number.js +5 -0
  199. package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +3 -2
  200. package/r-bridge/lang-4.x/ast/model/nodes/r-string.js +5 -0
  201. package/r-bridge/lang-4.x/ast/model/processing/decorate.d.ts +1 -1
  202. package/r-bridge/lang-4.x/ast/model/processing/decorate.js +1 -1
  203. package/r-bridge/lang-4.x/ast/model/processing/fold.js +3 -1
  204. package/r-bridge/lang-4.x/ast/model/processing/stateful-fold.d.ts +1 -1
  205. package/r-bridge/lang-4.x/ast/parser/main/internal/expression/normalize-expression.js +1 -1
  206. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-argument.js +1 -1
  207. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.js +1 -1
  208. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-definition.js +1 -1
  209. package/r-bridge/lang-4.x/ast/parser/main/internal/normalize-access.js +1 -1
  210. package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-binary.js +1 -1
  211. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-root.js +1 -1
  212. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-symbol.js +1 -1
  213. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.d.ts +2 -2
  214. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +4 -4
  215. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +26 -8
  216. package/r-bridge/retriever.js +2 -2
  217. package/search/flowr-search-builder.d.ts +31 -2
  218. package/search/flowr-search-builder.js +30 -0
  219. package/search/flowr-search.d.ts +7 -1
  220. package/search/search-executor/search-enrichers.d.ts +73 -0
  221. package/search/search-executor/search-enrichers.js +98 -0
  222. package/search/search-executor/search-generators.d.ts +7 -2
  223. package/search/search-executor/search-generators.js +21 -1
  224. package/search/search-executor/search-mappers.d.ts +19 -0
  225. package/search/search-executor/search-mappers.js +21 -0
  226. package/search/search-executor/search-transformer.d.ts +13 -1
  227. package/search/search-executor/search-transformer.js +11 -1
  228. package/slicing/criterion/collect-all.js +1 -1
  229. package/slicing/static/slice-call.js +13 -3
  230. package/statistics/features/supported/assignments/post-process.js +1 -1
  231. package/statistics/features/supported/defined-functions/post-process.js +2 -2
  232. package/statistics/features/supported/used-functions/post-process.js +1 -1
  233. package/statistics/features/supported/used-packages/post-process.js +2 -2
  234. package/statistics/features/supported/values/post-process.js +2 -2
  235. package/statistics/output/print-stats.js +2 -2
  236. package/statistics/summarizer/post-process/clusterer.d.ts +1 -1
  237. package/statistics/summarizer/post-process/clusterer.js +1 -1
  238. package/statistics/summarizer/post-process/histogram.js +3 -3
  239. package/statistics/summarizer/post-process/post-process-output.js +3 -3
  240. package/statistics/summarizer/second-phase/process.js +2 -2
  241. package/statistics/summarizer/summarizer.js +2 -2
  242. package/util/assert.js +36 -1
  243. package/util/cfg/cfg.d.ts +0 -80
  244. package/util/cfg/cfg.js +0 -549
  245. package/util/{arrays.d.ts → collections/arrays.d.ts} +1 -1
  246. package/util/{arrays.js → collections/arrays.js} +3 -3
  247. package/util/collections/set.js +17 -0
  248. package/util/diff-graph.d.ts +47 -0
  249. package/util/diff-graph.js +61 -0
  250. package/util/diff.d.ts +6 -6
  251. package/util/diff.js +1 -1
  252. package/util/mermaid/cfg.d.ts +9 -2
  253. package/util/mermaid/cfg.js +64 -12
  254. package/util/mermaid/dfg.d.ts +2 -1
  255. package/util/mermaid/dfg.js +26 -10
  256. package/util/mermaid/mermaid.d.ts +2 -0
  257. package/util/mermaid/mermaid.js +6 -0
  258. package/util/quads.js +1 -1
  259. package/util/schema.d.ts +1 -1
  260. package/util/schema.js +1 -1
  261. package/util/summarizer.js +1 -1
  262. package/util/{text.js → text/text.js} +1 -1
  263. package/util/{time.js → text/time.js} +1 -1
  264. package/util/version.js +1 -1
  265. package/dataflow/graph/diff.d.ts +0 -36
  266. package/util/cfg/happens-before.d.ts +0 -7
  267. package/util/cfg/visitor.d.ts +0 -9
  268. package/util/cfg/visitor.js +0 -30
  269. package/util/set.js +0 -31
  270. /package/util/{bimap.d.ts → collections/bimap.d.ts} +0 -0
  271. /package/util/{bimap.js → collections/bimap.js} +0 -0
  272. /package/util/{defaultmap.d.ts → collections/defaultmap.d.ts} +0 -0
  273. /package/util/{defaultmap.js → collections/defaultmap.js} +0 -0
  274. /package/util/{set.d.ts → collections/set.d.ts} +0 -0
  275. /package/util/{ansi.d.ts → text/ansi.d.ts} +0 -0
  276. /package/util/{ansi.js → text/ansi.js} +0 -0
  277. /package/util/{args.d.ts → text/args.d.ts} +0 -0
  278. /package/util/{args.js → text/args.js} +0 -0
  279. /package/util/{strings.d.ts → text/strings.d.ts} +0 -0
  280. /package/util/{strings.js → text/strings.js} +0 -0
  281. /package/util/{text.d.ts → text/text.d.ts} +0 -0
  282. /package/util/{time.d.ts → text/time.d.ts} +0 -0
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UnnamedFunctionCallPrefix = void 0;
3
+ exports.UnnamedFunctionCallOrigin = exports.UnnamedFunctionCallPrefix = void 0;
4
4
  exports.processUnnamedFunctionCall = processUnnamedFunctionCall;
5
5
  const processor_1 = require("../../../../processor");
6
6
  const common_1 = require("./common");
@@ -12,6 +12,7 @@ const type_1 = require("../../../../../r-bridge/lang-4.x/ast/model/type");
12
12
  const logger_1 = require("../../../../logger");
13
13
  const identifier_1 = require("../../../../environments/identifier");
14
14
  exports.UnnamedFunctionCallPrefix = 'unnamed-function-call-';
15
+ exports.UnnamedFunctionCallOrigin = 'unnamed';
15
16
  function processUnnamedFunctionCall(functionCall, data) {
16
17
  const calledFunction = (0, processor_1.processDataflowFor)(functionCall.calledFunction, data);
17
18
  const finalGraph = new graph_1.DataflowGraph(data.completeAst.idMap);
@@ -39,15 +40,16 @@ function processUnnamedFunctionCall(functionCall, data) {
39
40
  /* can never be a direct built-in-call */
40
41
  onlyBuiltin: false,
41
42
  cds: data.controlDependencies,
42
- args: callArgs // same reference
43
+ args: callArgs, // same reference
44
+ origin: [exports.UnnamedFunctionCallOrigin]
43
45
  });
44
- const inIds = remainingReadInArgs;
46
+ let inIds = remainingReadInArgs;
45
47
  inIds.push({ nodeId: functionRootId, name: functionCallName, controlDependencies: data.controlDependencies, type: identifier_1.ReferenceType.Function });
46
48
  if (functionCall.calledFunction.type === type_1.RType.FunctionDefinition) {
47
49
  (0, linker_1.linkArgumentsOnCall)(callArgs, functionCall.calledFunction.parameters, finalGraph);
48
50
  }
49
51
  // push the called function to the ids:
50
- inIds.push(...calledFunction.in, ...calledFunction.unknownReferences);
52
+ inIds = inIds.concat(calledFunction.in, calledFunction.unknownReferences);
51
53
  return {
52
54
  unknownReferences: [],
53
55
  in: inIds,
@@ -6,4 +6,4 @@ import type { EmptyArgument } from '../../../r-bridge/lang-4.x/ast/model/nodes/r
6
6
  /**
7
7
  * Helper function for {@link processNamedCall} using the given `functionName` as the name of the function.
8
8
  */
9
- export declare function processAsNamedCall<OtherInfo>(functionName: RNode<OtherInfo & ParentInformation> & Base<OtherInfo> & Location, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, name: string, args: readonly (RNode<OtherInfo & ParentInformation> | typeof EmptyArgument | undefined)[]): DataflowInformation;
9
+ export declare function processAsNamedCall<OtherInfo>({ info, lexeme, location }: RNode<OtherInfo & ParentInformation> & Base<OtherInfo> & Location, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, name: string, args: readonly (RNode<OtherInfo & ParentInformation> | typeof EmptyArgument | undefined)[]): DataflowInformation;
@@ -7,14 +7,14 @@ const type_1 = require("../../../r-bridge/lang-4.x/ast/model/type");
7
7
  /**
8
8
  * Helper function for {@link processNamedCall} using the given `functionName` as the name of the function.
9
9
  */
10
- function processAsNamedCall(functionName, data, name, args) {
10
+ function processAsNamedCall({ info, lexeme, location }, data, name, args) {
11
11
  return (0, named_call_handling_1.processNamedCall)({
12
12
  type: type_1.RType.Symbol,
13
- info: functionName.info,
13
+ info,
14
14
  content: name,
15
- lexeme: functionName.lexeme,
16
- location: functionName.location,
15
+ lexeme,
16
+ location,
17
17
  namespace: undefined
18
- }, (0, make_argument_1.wrapArgumentsUnnamed)(args, data.completeAst.idMap), functionName.info.id, data);
18
+ }, (0, make_argument_1.wrapArgumentsUnnamed)(args, data.completeAst.idMap), info.id, data);
19
19
  }
20
20
  //# sourceMappingURL=process-named-call.js.map
@@ -0,0 +1,82 @@
1
+ import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
2
+ import type { DataflowGraph } from '../graph/graph';
3
+ export declare const enum OriginType {
4
+ ReadVariableOrigin = 0,
5
+ WriteVariableOrigin = 1,
6
+ FunctionCallOrigin = 2,
7
+ BuiltInFunctionOrigin = 3,
8
+ ConstantOrigin = 4
9
+ }
10
+ /**
11
+ * An origin that indicates that the definition is read, written, or simply a constant.
12
+ * These origins only reference the 'direct' dependencies. There is no transitivity.
13
+ *
14
+ * @example
15
+ * ```r
16
+ * x <- 2
17
+ * print(x)
18
+ * ```
19
+ *
20
+ * - Requesting the origins for the use of `x` in `print(x)` returns a {@link ReadVariableOrigin} for the definition of `x` in the first line.
21
+ * - Asking for the origin of the `2` in `x <- 2` returns a {@link ConstantOrigin} for itself.
22
+ * - Asking for the origin of `x` in `x <- 2` returns a {@link WriteVariableOrigin} for the variable `x`.
23
+ */
24
+ export interface SimpleOrigin {
25
+ readonly type: OriginType.ReadVariableOrigin | OriginType.WriteVariableOrigin | OriginType.ConstantOrigin;
26
+ readonly id: NodeId;
27
+ }
28
+ /**
29
+ * Determines the (transitive) origin of a function call (i.e., all anonymous function definitions within the program that
30
+ * can be called).
31
+ *
32
+ * @example
33
+ * ```r
34
+ * f <- function(x) {
35
+ * function(y) { y + x }
36
+ * }
37
+ * g <- f(2)
38
+ * g(3)
39
+ * ```
40
+ *
41
+ * - Requesting the origin of `g(3)` returns a {@link FunctionCallOrigin} for the anonymous function defined and returned within the body of `f`.
42
+ * - Requesting the origin of `f(2)` returns a {@link FunctionCallOrigin} for the anonymous function bound to f.
43
+ *
44
+ * Either also return the {@link SimpleOrigin} for the read of the respective variable definition.
45
+ */
46
+ export interface FunctionCallOrigin {
47
+ readonly type: OriginType.FunctionCallOrigin;
48
+ readonly id: NodeId;
49
+ }
50
+ /**
51
+ * This is similar to a {@link FunctionCallOrigin}, but used for built-in functions that have no direct correspondence in the dataflow graph.
52
+ */
53
+ export interface BuiltInFunctionOrigin {
54
+ readonly type: OriginType.BuiltInFunctionOrigin;
55
+ /** processor that is used to process the built-in function */
56
+ readonly id: NodeId;
57
+ readonly proc: string;
58
+ readonly fn: OriginIdentifier;
59
+ }
60
+ interface OriginIdentifier {
61
+ readonly name: string;
62
+ readonly namespace?: string;
63
+ }
64
+ export type Origin = SimpleOrigin | FunctionCallOrigin | BuiltInFunctionOrigin;
65
+ /**
66
+ * Obtain the (dataflow) origin of a given node in the dfg.
67
+ * @example consider the following code:
68
+ * ```r
69
+ * x <- 2
70
+ * if(u) {
71
+ * x <- 3
72
+ * }
73
+ * print(x)
74
+ * ```
75
+ * Requesting the origin of `x` in the `print(x)` node yields two {@link SimpleOriginOrigin|variable origins} for both
76
+ * definitions of `x`.
77
+ * Similarly, requesting the origin of `print` returns a {@link BuiltInFunctionOrigin|`BuiltInFunctionOrigin`}.
78
+ *
79
+ * This returns undefined only if there is no dataflow correspondence (e.g. in case of unevaluated non-standard eval).
80
+ */
81
+ export declare function getOriginInDfg(dfg: DataflowGraph, id: NodeId): Origin[] | undefined;
82
+ export {};
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getOriginInDfg = getOriginInDfg;
4
+ const vertex_1 = require("../graph/vertex");
5
+ const edge_1 = require("../graph/edge");
6
+ const linker_1 = require("../internal/linker");
7
+ const assert_1 = require("../../util/assert");
8
+ const built_in_1 = require("../environments/built-in");
9
+ /**
10
+ * Obtain the (dataflow) origin of a given node in the dfg.
11
+ * @example consider the following code:
12
+ * ```r
13
+ * x <- 2
14
+ * if(u) {
15
+ * x <- 3
16
+ * }
17
+ * print(x)
18
+ * ```
19
+ * Requesting the origin of `x` in the `print(x)` node yields two {@link SimpleOriginOrigin|variable origins} for both
20
+ * definitions of `x`.
21
+ * Similarly, requesting the origin of `print` returns a {@link BuiltInFunctionOrigin|`BuiltInFunctionOrigin`}.
22
+ *
23
+ * This returns undefined only if there is no dataflow correspondence (e.g. in case of unevaluated non-standard eval).
24
+ */
25
+ function getOriginInDfg(dfg, id) {
26
+ const vtx = dfg.getVertex(id);
27
+ switch (vtx?.tag) {
28
+ case undefined:
29
+ return undefined;
30
+ case vertex_1.VertexType.Value:
31
+ return [{ type: 4 /* OriginType.ConstantOrigin */, id }];
32
+ case vertex_1.VertexType.FunctionDefinition:
33
+ return [{ type: 4 /* OriginType.ConstantOrigin */, id }];
34
+ case vertex_1.VertexType.VariableDefinition:
35
+ return getVariableDefinitionOrigin(dfg, vtx);
36
+ case vertex_1.VertexType.Use:
37
+ return getVariableUseOrigin(dfg, vtx);
38
+ case vertex_1.VertexType.FunctionCall:
39
+ return getCallTarget(dfg, vtx);
40
+ }
41
+ }
42
+ const WantedVariableTypes = edge_1.EdgeType.Reads | edge_1.EdgeType.DefinedByOnCall;
43
+ const UnwantedVariableTypes = edge_1.EdgeType.NonStandardEvaluation;
44
+ function getVariableUseOrigin(dfg, use) {
45
+ // to identify the origins we have to track read edges and definitions on function calls
46
+ const origins = [];
47
+ for (const [target, { types }] of dfg.outgoingEdges(use.id) ?? []) {
48
+ if ((0, edge_1.edgeDoesNotIncludeType)(types, WantedVariableTypes) || (0, edge_1.edgeIncludesType)(types, UnwantedVariableTypes)) {
49
+ continue;
50
+ }
51
+ const targetVtx = dfg.getVertex(target);
52
+ if (!targetVtx) {
53
+ continue;
54
+ }
55
+ if (targetVtx.tag === vertex_1.VertexType.VariableDefinition) {
56
+ origins.push({
57
+ type: 0 /* OriginType.ReadVariableOrigin */,
58
+ id: target
59
+ });
60
+ }
61
+ }
62
+ return origins.length > 0 ? origins : undefined;
63
+ }
64
+ function getVariableDefinitionOrigin(dfg, vtx) {
65
+ const pool = [{ type: 1 /* OriginType.WriteVariableOrigin */, id: vtx.id }];
66
+ const outgoingReads = dfg.outgoingEdges(vtx.id) ?? [];
67
+ for (const [target, { types }] of outgoingReads) {
68
+ if ((0, edge_1.edgeIncludesType)(types, edge_1.EdgeType.Reads)) {
69
+ const targetVtx = dfg.getVertex(target);
70
+ if (!targetVtx) {
71
+ continue;
72
+ }
73
+ if (targetVtx.tag === vertex_1.VertexType.VariableDefinition) {
74
+ pool.push({
75
+ type: 0 /* OriginType.ReadVariableOrigin */,
76
+ id: target
77
+ });
78
+ }
79
+ }
80
+ }
81
+ return pool;
82
+ }
83
+ function getCallTarget(dfg, call) {
84
+ // check for built-ins:
85
+ const builtInTarget = call.origin !== 'unnamed' && call.origin.filter(o => o.startsWith('builtin:'));
86
+ let origins = builtInTarget ? builtInTarget.map(o => ({
87
+ type: 3 /* OriginType.BuiltInFunctionOrigin */,
88
+ fn: { name: call.name },
89
+ id: call.id,
90
+ proc: o
91
+ })) : undefined;
92
+ const targets = new Set((0, linker_1.getAllFunctionCallTargets)(call.id, dfg));
93
+ if (targets.size === 0) {
94
+ return origins;
95
+ }
96
+ origins = (origins ?? []).concat([...targets].map(target => {
97
+ if ((0, built_in_1.isBuiltIn)(target)) {
98
+ return {
99
+ type: 3 /* OriginType.BuiltInFunctionOrigin */,
100
+ fn: { name: call.name },
101
+ id: call.id,
102
+ proc: target
103
+ };
104
+ }
105
+ const get = dfg.getVertex(target);
106
+ if (get?.tag !== vertex_1.VertexType.FunctionDefinition && get?.tag !== vertex_1.VertexType.VariableDefinition) {
107
+ return undefined;
108
+ }
109
+ return {
110
+ type: get.tag === vertex_1.VertexType.FunctionDefinition ? 2 /* OriginType.FunctionCallOrigin */ : 0 /* OriginType.ReadVariableOrigin */,
111
+ id: target
112
+ };
113
+ }).filter(assert_1.isNotUndefined));
114
+ return origins;
115
+ }
116
+ //# sourceMappingURL=dfg-get-origin.js.map
@@ -1,16 +1,23 @@
1
- import type { ControlFlowInformation } from '../../util/cfg/cfg';
2
1
  import type { NormalizedAst } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
3
2
  import type { KnownParser } from '../../r-bridge/parser';
4
3
  import type { DataflowInformation } from '../../dataflow/info';
5
- export declare function getCfg(parser: KnownParser, code: string): Promise<{
4
+ import type { ControlFlowInformation } from '../../control-flow/control-flow-graph';
5
+ import type { CfgSimplificationPassName } from '../../control-flow/cfg-simplification';
6
+ type GetCfgReturn = {
6
7
  info: ControlFlowInformation;
7
8
  ast: NormalizedAst;
8
- dataflow: DataflowInformation;
9
- }>;
10
- export declare function printCfg(cfg: ControlFlowInformation, ast: NormalizedAst, prefix?: string): string;
9
+ dataflow?: DataflowInformation;
10
+ };
11
+ export declare function getCfg(parser: KnownParser, code: string, simplifications?: readonly CfgSimplificationPassName[], useDfg?: true): Promise<Required<GetCfgReturn>>;
12
+ export declare function getCfg(parser: KnownParser, code: string, simplifications?: readonly CfgSimplificationPassName[], useDfg?: boolean): Promise<GetCfgReturn>;
13
+ export declare function printCfg(cfg: ControlFlowInformation, ast: NormalizedAst, prefix?: string, simplify?: boolean): string;
11
14
  export interface PrintCfgOptions {
12
15
  readonly showCode?: boolean;
13
16
  readonly openCode?: boolean;
14
17
  readonly prefix?: string;
18
+ readonly simplifications?: readonly CfgSimplificationPassName[];
19
+ readonly simplify?: boolean;
20
+ readonly useDfg?: boolean;
15
21
  }
16
- export declare function printCFGCode(parser: KnownParser, code: string, { showCode, openCode, prefix }?: PrintCfgOptions): Promise<string>;
22
+ export declare function printCfgCode(parser: KnownParser, code: string, { showCode, openCode, prefix, simplifications, simplify, useDfg }?: PrintCfgOptions): Promise<string>;
23
+ export {};
@@ -2,36 +2,41 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getCfg = getCfg;
4
4
  exports.printCfg = printCfg;
5
- exports.printCFGCode = printCFGCode;
6
- const cfg_1 = require("../../util/cfg/cfg");
5
+ exports.printCfgCode = printCfgCode;
6
+ const extract_cfg_1 = require("../../control-flow/extract-cfg");
7
7
  const default_pipelines_1 = require("../../core/steps/pipeline/default-pipelines");
8
8
  const retriever_1 = require("../../r-bridge/retriever");
9
- const time_1 = require("../../util/time");
9
+ const time_1 = require("../../util/text/time");
10
10
  const doc_files_1 = require("./doc-files");
11
- const cfg_2 = require("../../util/mermaid/cfg");
11
+ const cfg_1 = require("../../util/mermaid/cfg");
12
12
  const doc_code_1 = require("./doc-code");
13
- async function getCfg(parser, code) {
14
- const result = await (0, default_pipelines_1.createDataflowPipeline)(parser, {
13
+ const cfg_simplification_1 = require("../../control-flow/cfg-simplification");
14
+ async function getCfg(parser, code, simplifications = [], useDfg = true) {
15
+ const result = useDfg ? await (0, default_pipelines_1.createDataflowPipeline)(parser, {
16
+ request: (0, retriever_1.requestFromInput)(code)
17
+ }).allRemainingSteps() : await (0, default_pipelines_1.createNormalizePipeline)(parser, {
15
18
  request: (0, retriever_1.requestFromInput)(code)
16
19
  }).allRemainingSteps();
17
- const cfg = (0, cfg_1.extractCFG)(result.normalize, result.dataflow.graph);
20
+ const cfg = (0, extract_cfg_1.extractCfg)(result.normalize, useDfg ? result.dataflow.graph : undefined, [...cfg_simplification_1.DefaultCfgSimplificationOrder, ...simplifications]);
18
21
  return {
19
22
  info: cfg,
20
23
  ast: result.normalize,
21
- dataflow: result.dataflow
24
+ dataflow: 'dataflow' in result ? result.dataflow : undefined
22
25
  };
23
26
  }
24
- function printCfg(cfg, ast, prefix = 'flowchart TD\n') {
27
+ function printCfg(cfg, ast, prefix = 'flowchart BT\n', simplify = false) {
25
28
  return `
26
- ${(0, doc_code_1.codeBlock)('mermaid', (0, cfg_2.cfgToMermaid)(cfg, ast, prefix))}
29
+ ${(0, doc_code_1.codeBlock)('mermaid', (0, cfg_1.cfgToMermaid)(cfg, ast, prefix, simplify))}
27
30
  `;
28
31
  }
29
- async function printCFGCode(parser, code, { showCode = true, openCode = false, prefix = 'flowchart BT\n' } = {}) {
32
+ async function printCfgCode(parser, code, { showCode = true, openCode = false, prefix = 'flowchart BT\n', simplifications = [], simplify = false, useDfg = true } = {}) {
30
33
  const now = performance.now();
31
- const res = await getCfg(parser, code);
34
+ const res = await getCfg(parser, code, simplifications, useDfg);
32
35
  const duration = performance.now() - now;
33
- const metaInfo = `The analysis required _${(0, time_1.printAsMs)(duration)}_ (including the dataflow analysis, normalization, and parsing with the [${parser.name}](${doc_files_1.FlowrWikiBaseRef}/Engines) engine) within the generation environment.`;
34
- return '\n\n' + printCfg(res.info, res.ast, prefix) + (showCode ? `
36
+ const metaInfo = `The analysis required _${(0, time_1.printAsMs)(duration)}_ (including the ${useDfg ? 'dataflow analysis, ' : ''} normalization${useDfg ? ', ' : ''} and parsing with the [${parser.name}](${doc_files_1.FlowrWikiBaseRef}/Engines) engine) within the generation environment.
37
+ We used the following simplification${(simplifications?.length ?? 0) + cfg_simplification_1.DefaultCfgSimplificationOrder.length != 1 ? 's' : ''}: ${[...cfg_simplification_1.DefaultCfgSimplificationOrder, ...simplifications].map(s => '`' + s + '`').join(', ')} ${simplify ? ' and render a simplified/compacted version' : ''}.
38
+ `;
39
+ return '\n\n' + printCfg(res.info, res.ast, prefix, simplify) + (showCode ? `
35
40
  <details${openCode ? ' open' : ''}>
36
41
 
37
42
  <summary style="color:gray">R Code of the CFG</summary>
@@ -42,6 +47,6 @@ ${(0, doc_code_1.codeBlock)('r', code)}
42
47
 
43
48
  </details>
44
49
 
45
- ` : '\n(' + metaInfo + ')\n\n');
50
+ ` : '\n_(' + metaInfo + ')_\n\n');
46
51
  }
47
52
  //# sourceMappingURL=doc-cfg.js.map
@@ -9,16 +9,18 @@ const assert_1 = require("../../util/assert");
9
9
  const html_hover_over_1 = require("../../util/html-hover-over");
10
10
  const flowr_main_options_1 = require("../../cli/flowr-main-options");
11
11
  const repl_commands_1 = require("../../cli/repl/commands/repl-commands");
12
+ const doc_escape_1 = require("./doc-escape");
12
13
  function getCliLongOptionOf(scriptName, optionName, withAlias = false, quote = true) {
13
14
  const script = scriptName === 'flowr' ? flowr_main_options_1.flowrMainOptionDefinitions : scripts_info_1.scripts[scriptName].options;
14
15
  (0, assert_1.guard)(script !== undefined, () => `Unknown script ${scriptName}, pick one of ${JSON.stringify(Object.keys(scripts_info_1.scripts))}.`);
15
16
  const option = script.find(({ name }) => name === optionName);
16
17
  (0, assert_1.guard)(option !== undefined, () => `Unknown option ${optionName}, pick one of ${JSON.stringify(script.map(o => o.name))}.`);
17
18
  const char = quote ? '`' : '';
18
- const alias = withAlias && option.alias ? ' (alias:' + (0, html_hover_over_1.textWithTooltip)(`${char}-${option.alias}${char}`, option.description) + ')' : '';
19
+ const description = (0, doc_escape_1.escapeHTML)(option.description);
20
+ const alias = withAlias && option.alias ? ' (alias:' + (0, html_hover_over_1.textWithTooltip)(`${char}-${option.alias}${char}`, description) + ')' : '';
19
21
  const ligatureBreaker = quote ? '' : '<span/>';
20
22
  // span ensures split even with ligatures
21
- return (0, html_hover_over_1.textWithTooltip)(`${char}-${ligatureBreaker}-${optionName}${char}`, 'Description (Command Line Argument): ' + option.description) + alias;
23
+ return (0, html_hover_over_1.textWithTooltip)(`${char}-${ligatureBreaker}-${optionName}${char}`, 'Description (Command Line Argument): ' + description) + alias;
22
24
  }
23
25
  function multipleCliOptions(scriptName, ...options) {
24
26
  return options.map(o => getCliLongOptionOf(scriptName, o, false, true)).join(' ');
@@ -10,9 +10,9 @@ const default_pipelines_1 = require("../../core/steps/pipeline/default-pipelines
10
10
  const retriever_1 = require("../../r-bridge/retriever");
11
11
  const decorate_1 = require("../../r-bridge/lang-4.x/ast/model/processing/decorate");
12
12
  const resolve_graph_1 = require("../../dataflow/graph/resolve-graph");
13
- const diff_1 = require("../../dataflow/graph/diff");
13
+ const diff_dataflow_graph_1 = require("../../dataflow/graph/diff-dataflow-graph");
14
14
  const assert_1 = require("../../util/assert");
15
- const time_1 = require("../../util/time");
15
+ const time_1 = require("../../util/text/time");
16
16
  const doc_files_1 = require("./doc-files");
17
17
  const doc_code_1 = require("./doc-code");
18
18
  function printDfGraph(graph, mark, simplified = false) {
@@ -79,7 +79,7 @@ async function verifyExpectedSubgraph(shell, code, expectedSubgraph) {
79
79
  }).allRemainingSteps();
80
80
  expectedSubgraph.setIdMap(info.normalize.idMap);
81
81
  expectedSubgraph = (0, resolve_graph_1.resolveDataflowGraph)(expectedSubgraph);
82
- const report = (0, diff_1.diffOfDataflowGraphs)({ name: 'expected', graph: expectedSubgraph }, { name: 'got', graph: info.dataflow.graph }, {
82
+ const report = (0, diff_dataflow_graph_1.diffOfDataflowGraphs)({ name: 'expected', graph: expectedSubgraph }, { name: 'got', graph: info.dataflow.graph }, {
83
83
  leftIsSubgraph: true
84
84
  });
85
85
  (0, assert_1.guard)(report.isEqual(), () => `report:\n * ${report.comments()?.join('\n * ') ?? ''}`);
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Escapes HTML special characters in a string.
3
+ *
4
+ * @param str - The string to escape
5
+ * @returns The escaped string
6
+ */
7
+ export declare function escapeHTML(str: string | undefined): string | undefined;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.escapeHTML = escapeHTML;
4
+ /**
5
+ * Escapes HTML special characters in a string.
6
+ *
7
+ * @param str - The string to escape
8
+ * @returns The escaped string
9
+ */
10
+ function escapeHTML(str) {
11
+ return str?.replace(/[&<>"']/g, (tag) => ({
12
+ '&': '&amp;',
13
+ '<': '&lt;',
14
+ '>': '&gt;',
15
+ '"': '&quot;',
16
+ "'": '&#39;',
17
+ }[tag] ?? tag));
18
+ }
19
+ //# sourceMappingURL=doc-escape.js.map
@@ -6,6 +6,7 @@ export declare const FlowrNpmRef = "https://www.npmjs.com/package/@eagleoutice/f
6
6
  export declare const FlowrDockerRef = "https://hub.docker.com/r/eagleoutice/flowr";
7
7
  export declare const FlowrCodecovRef = "https://app.codecov.io/gh/flowr-analysis/flowr";
8
8
  export declare const FlowrVsCode = "https://marketplace.visualstudio.com/items?itemName=code-inspect.vscode-flowr";
9
+ export declare const FlowrPositron = "https://open-vsx.org/extension/code-inspect/vscode-flowr";
9
10
  export declare function getFilePathMd(path: string): string;
10
11
  export declare function getFileContentFromRoot(path: string): string;
11
12
  export declare function linkFlowRSourceFile(path: string): string;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.FlowrVsCode = exports.FlowrCodecovRef = exports.FlowrDockerRef = exports.FlowrNpmRef = exports.FlowrWikiBaseRef = exports.RemoteFlowrFilePathBaseRef = exports.FlowrSiteBaseRef = exports.FlowrGithubBaseRef = void 0;
6
+ exports.FlowrPositron = exports.FlowrVsCode = exports.FlowrCodecovRef = exports.FlowrDockerRef = exports.FlowrNpmRef = exports.FlowrWikiBaseRef = exports.RemoteFlowrFilePathBaseRef = exports.FlowrSiteBaseRef = exports.FlowrGithubBaseRef = void 0;
7
7
  exports.getFilePathMd = getFilePathMd;
8
8
  exports.getFileContentFromRoot = getFileContentFromRoot;
9
9
  exports.linkFlowRSourceFile = linkFlowRSourceFile;
@@ -16,6 +16,7 @@ exports.FlowrNpmRef = 'https://www.npmjs.com/package/@eagleoutice/flowr';
16
16
  exports.FlowrDockerRef = 'https://hub.docker.com/r/eagleoutice/flowr';
17
17
  exports.FlowrCodecovRef = 'https://app.codecov.io/gh/flowr-analysis/flowr';
18
18
  exports.FlowrVsCode = 'https://marketplace.visualstudio.com/items?itemName=code-inspect.vscode-flowr';
19
+ exports.FlowrPositron = 'https://open-vsx.org/extension/code-inspect/vscode-flowr';
19
20
  function getFilePathMd(path) {
20
21
  // we go one up as we are in doc-util now :D #convenience
21
22
  const fullpath = require.resolve('../' + path);
@@ -7,10 +7,10 @@ const default_pipelines_1 = require("../../core/steps/pipeline/default-pipelines
7
7
  const retriever_1 = require("../../r-bridge/retriever");
8
8
  const decorate_1 = require("../../r-bridge/lang-4.x/ast/model/processing/decorate");
9
9
  const resolve_graph_1 = require("../../dataflow/graph/resolve-graph");
10
- const diff_1 = require("../../dataflow/graph/diff");
10
+ const diff_dataflow_graph_1 = require("../../dataflow/graph/diff-dataflow-graph");
11
11
  const assert_1 = require("../../util/assert");
12
12
  const ast_1 = require("../../util/mermaid/ast");
13
- const time_1 = require("../../util/time");
13
+ const time_1 = require("../../util/text/time");
14
14
  const doc_files_1 = require("./doc-files");
15
15
  function printNormalizedAst(ast, prefix = 'flowchart TD\n') {
16
16
  return `
@@ -60,7 +60,7 @@ async function verifyExpectedSubgraph(shell, code, expectedSubgraph) {
60
60
  }).allRemainingSteps();
61
61
  expectedSubgraph.setIdMap(info.normalize.idMap);
62
62
  expectedSubgraph = (0, resolve_graph_1.resolveDataflowGraph)(expectedSubgraph);
63
- const report = (0, diff_1.diffOfDataflowGraphs)({ name: 'expected', graph: expectedSubgraph }, { name: 'got', graph: info.dataflow.graph }, {
63
+ const report = (0, diff_dataflow_graph_1.diffOfDataflowGraphs)({ name: 'expected', graph: expectedSubgraph }, { name: 'got', graph: info.dataflow.graph }, {
64
64
  leftIsSubgraph: true
65
65
  });
66
66
  (0, assert_1.guard)(report.isEqual(), () => `report:\n * ${report.comments()?.join('\n * ') ?? ''}`);
@@ -11,11 +11,11 @@ const pipeline_executor_1 = require("../../core/pipeline-executor");
11
11
  const default_pipelines_1 = require("../../core/steps/pipeline/default-pipelines");
12
12
  const retriever_1 = require("../../r-bridge/retriever");
13
13
  const json_1 = require("../../util/json");
14
- const ansi_1 = require("../../util/ansi");
14
+ const ansi_1 = require("../../util/text/ansi");
15
15
  const doc_files_1 = require("./doc-files");
16
16
  const doc_dfg_1 = require("./doc-dfg");
17
17
  const doc_code_1 = require("./doc-code");
18
- const time_1 = require("../../util/time");
18
+ const time_1 = require("../../util/text/time");
19
19
  const query_print_1 = require("../../queries/query-print");
20
20
  async function showQuery(shell, code, queries, { showCode, collapseResult, collapseQuery } = {}) {
21
21
  const now = performance.now();
@@ -6,7 +6,7 @@ const repl_commands_1 = require("../../cli/repl/commands/repl-commands");
6
6
  const doc_cli_option_1 = require("./doc-cli-option");
7
7
  const html_hover_over_1 = require("../../util/html-hover-over");
8
8
  const core_1 = require("../../cli/repl/core");
9
- const ansi_1 = require("../../util/ansi");
9
+ const ansi_1 = require("../../util/text/ansi");
10
10
  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");
@@ -12,7 +12,7 @@ const retriever_1 = require("../../r-bridge/retriever");
12
12
  const doc_files_1 = require("./doc-files");
13
13
  const doc_dfg_1 = require("./doc-dfg");
14
14
  const doc_code_1 = require("./doc-code");
15
- const time_1 = require("../../util/time");
15
+ const time_1 = require("../../util/text/time");
16
16
  const flowr_search_executor_1 = require("../../search/flowr-search-executor");
17
17
  const flowr_search_printer_1 = require("../../search/flowr-search-printer");
18
18
  const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
@@ -6,11 +6,11 @@ exports.inServerContext = inServerContext;
6
6
  exports.documentServerMessageResponse = documentServerMessageResponse;
7
7
  const doc_files_1 = require("./doc-files");
8
8
  const schema_1 = require("../../util/schema");
9
- const ansi_1 = require("../../util/ansi");
9
+ const ansi_1 = require("../../util/text/ansi");
10
10
  const net_1 = require("../../../test/functionality/_helper/net");
11
11
  const doc_code_1 = require("./doc-code");
12
12
  const assert_1 = require("../../util/assert");
13
- const time_1 = require("../../util/time");
13
+ const time_1 = require("../../util/text/time");
14
14
  const messages = [];
15
15
  function documentServerMessage(description) {
16
16
  messages.push(description);
@@ -10,3 +10,4 @@ export interface BlockOptions {
10
10
  readonly content: string;
11
11
  }
12
12
  export declare function block({ type, content }: BlockOptions): string;
13
+ export declare function section(title: string, depth?: 1 | 2 | 3 | 4 | 5 | 6, anchor?: string): string;
@@ -2,7 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.details = details;
4
4
  exports.block = block;
5
+ exports.section = section;
5
6
  const doc_general_1 = require("./doc-general");
7
+ const mermaid_1 = require("../../util/mermaid/mermaid");
6
8
  function details(title, content, { color, open = false, hideIfEmpty = true, prefixInit = '' } = {}) {
7
9
  return hideIfEmpty && content.trim().length === 0 ? '' : `
8
10
  ${prefixInit}<details${open ? ' open' : ''}><summary style="${color ? 'color:' + color : ''}">${title}</summary>
@@ -18,4 +20,7 @@ function block({ type, content }) {
18
20
  ${(0, doc_general_1.prefixLines)(content, '> ')}
19
21
  `;
20
22
  }
23
+ function section(title, depth = 2, anchor = (0, mermaid_1.escapeId)(title)) {
24
+ return `<h${depth} id="${anchor}">${title}</h${depth}>`;
25
+ }
21
26
  //# sourceMappingURL=doc-structure.js.map
@@ -37,6 +37,11 @@ export interface PrintHierarchyArguments {
37
37
  }
38
38
  export declare const mermaidHide: string[];
39
39
  export declare function printHierarchy({ program, info, root, collapseFromNesting, initialNesting, maxDepth, openTop }: PrintHierarchyArguments): string;
40
+ interface FnInfo {
41
+ info: TypeElementInSource[];
42
+ program: ts.Program;
43
+ }
44
+ export declare function printCodeOfElement({ program, info }: FnInfo, name: string): string;
40
45
  /**
41
46
  * Create a short link to a type in the documentation
42
47
  * @param name - The name of the type, e.g. `MyType`, may include a container, e.g.,`MyContainer::MyType` (this works with function nestings too)
@@ -46,4 +51,5 @@ export declare function printHierarchy({ program, info, root, collapseFromNestin
46
51
  * @param realNameWrapper - How to highlight the function in name in the `x::y` format?
47
52
  */
48
53
  export declare function shortLink(name: string, hierarchy: readonly TypeElementInSource[], codeStyle?: boolean, realNameWrapper?: string): string;
49
- export declare function getDocumentationForType(name: string, hierarchy: TypeElementInSource[]): string;
54
+ export declare function getDocumentationForType(name: string, hierarchy: TypeElementInSource[], prefix?: string): string;
55
+ export {};
@@ -10,6 +10,7 @@ exports.getTypePathLink = getTypePathLink;
10
10
  exports.getTypesFromFolderAsMermaid = getTypesFromFolderAsMermaid;
11
11
  exports.implSnippet = implSnippet;
12
12
  exports.printHierarchy = printHierarchy;
13
+ exports.printCodeOfElement = printCodeOfElement;
13
14
  exports.shortLink = shortLink;
14
15
  exports.getDocumentationForType = getDocumentationForType;
15
16
  const typescript_1 = __importDefault(require("typescript"));
@@ -21,6 +22,7 @@ const mermaid_1 = require("../../util/mermaid/mermaid");
21
22
  const doc_code_1 = require("./doc-code");
22
23
  const doc_structure_1 = require("./doc-structure");
23
24
  const html_hover_over_1 = require("../../util/html-hover-over");
25
+ const doc_general_1 = require("./doc-general");
24
26
  function getSourceFiles(fileNames) {
25
27
  try {
26
28
  const program = typescript_1.default.createProgram(fileNames, { target: typescript_1.default.ScriptTarget.ESNext });
@@ -345,6 +347,15 @@ function printHierarchy({ program, info, root, collapseFromNesting = 1, initialN
345
347
  return thisLine + (out ? '\n' + out : '');
346
348
  }
347
349
  }
350
+ function printCodeOfElement({ program, info }, name) {
351
+ const node = info.find(e => e.name === name);
352
+ if (!node) {
353
+ console.error(`Could not find node ${name} when resolving function!`);
354
+ return '';
355
+ }
356
+ const code = node.node.getFullText(program.getSourceFile(node.node.getSourceFile().fileName));
357
+ return `${(0, doc_code_1.codeBlock)('ts', code)}\n<i>Defined at <a href="${getTypePathLink(node)}">${getTypePathLink(node, '.')}</a></i>\n`;
358
+ }
348
359
  function retrieveNode(name, hierarchy) {
349
360
  let container = undefined;
350
361
  if (name.includes('::')) {
@@ -385,12 +396,12 @@ function shortLink(name, hierarchy, codeStyle = true, realNameWrapper = 'b') {
385
396
  return `[${codeStyle ? '<code>' : ''}${(node.comments?.length ?? 0) > 0 ?
386
397
  (0, html_hover_over_1.textWithTooltip)(pkg ? `${pkg}::<${realNameWrapper}>${mainName}</${realNameWrapper}>` : mainName, comments.length > 400 ? comments.slice(0, 400) + '...' : comments) : node.name}${codeStyle ? '</code>' : ''}](${getTypePathLink(node)})`;
387
398
  }
388
- function getDocumentationForType(name, hierarchy) {
399
+ function getDocumentationForType(name, hierarchy, prefix = '') {
389
400
  const res = retrieveNode(name, hierarchy);
390
401
  if (!res) {
391
402
  return '';
392
403
  }
393
404
  const [, , node] = res;
394
- return node.comments?.join('\n') ?? '';
405
+ return (0, doc_general_1.prefixLines)(node.comments?.join('\n') ?? '', prefix);
395
406
  }
396
407
  //# sourceMappingURL=doc-types.js.map