@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
@@ -0,0 +1,89 @@
1
+ import type { PathLike } from 'fs';
2
+ /**
3
+ * Just a readable alias for file paths, mostly for documentation purposes.
4
+ * We separate {@link PathLike} types from string paths that are used for project paths.
5
+ */
6
+ export type FilePath = string;
7
+ /**
8
+ * Some files have a special meaning in R projects, e.g., the `DESCRIPTION` file in R packages.
9
+ * This list may be extended in the future and reflects files that the {@link FlowrAnalyzer} can do something interesting with.
10
+ * If you add an interesting file that is only part of your plugin infrastructure, please use the `other` role.
11
+ */
12
+ export declare enum SpecialFileRole {
13
+ /** The `DESCRIPTION` file in R packages, this is the only currently supported special file. */
14
+ Description = "description",
15
+ /** The `NAMESPACE` file in R packages, currently not specially supported. */
16
+ Namespace = "namespace",
17
+ /** Data files, e.g., `R/sysdata.rda`, currently not specially supported. */
18
+ Data = "data",
19
+ /** Other special files that are not specifically supported by flowR but may be interesting for some analyses. */
20
+ Other = "other"
21
+ }
22
+ /**
23
+ * This is the basic interface for all files known to the FlowrAnalyzer.
24
+ * You can implement this interface to provide custom file loading mechanisms.
25
+ * Mostly, we will be interested in text files (or decorations thereof).
26
+ * If you want to load other file types, you either have to transform them into a presentation supported by flowR
27
+ * or add your own file loader plugin (similar to the {@link FlowrAnalyzerDescriptionFilePlugin}).
28
+ *
29
+ * See {@link FlowrFile} for a basic single-cache implementation and {@link FlowrTextFile} for a text-file specific implementation.
30
+ * If you want to pass in inline text files, see {@link FlowrInlineTextFile}.
31
+ *
32
+ * @typeParam Content - The type of the content returned by the `content()` method.
33
+ */
34
+ export interface FlowrFileProvider<Content = unknown> {
35
+ /**
36
+ * The role of this file, if any, in general your file should _not_ decide for itself what role it has in the project context,
37
+ * this is for the loaders plugins to decide (cf. {@link PluginType}) as they can, e.g., respect ignore files, updated mappings, etc.
38
+ * However, they will 1) set this role as soon as they decide on it (using {@link assignRole}) and 2) try to respect an already assigned role (however, user configurations may override this).
39
+ */
40
+ role?: SpecialFileRole;
41
+ /**
42
+ * The path to the file, this is used for identification and logging purposes.
43
+ * If the file does not exist on disk, this can be a virtual path (e.g. for inline files).
44
+ * Even though this is a getter, please make sure that the operation is cheap and deterministic (some decorators may overwrite the path, e.g., because they support other protocols).
45
+ */
46
+ path(): PathLike;
47
+ /**
48
+ * The content of the file, this may be cached by the implementation and does not have to be expensive.
49
+ * You can used stream based implementations but right now there is no external, project-wide expressions of life cycles for files.
50
+ * So make sure your implementation closes the resource as soon as possible.
51
+ */
52
+ content(): Content;
53
+ /**
54
+ * Assign a role to this file, this should be done by the loader plugins (cf. {@link PluginType}).
55
+ * **Do not call this method yourself unless you are a file-loader plugin and/or really know what you are doing, this may break plugin assumptions!**
56
+ */
57
+ assignRole(role: SpecialFileRole): void;
58
+ }
59
+ /**
60
+ * A basic implementation of the {@link FlowrFileProvider} interface that caches the content after the first load (i.e., updates on disk are ignored).
61
+ *
62
+ * See {@link FlowrTextFile} for a text-file specific implementation and {@link FlowrInlineTextFile} for inline text files.
63
+ */
64
+ export declare abstract class FlowrFile<Content = unknown> implements FlowrFileProvider<Content> {
65
+ private contentCache;
66
+ protected filePath: PathLike;
67
+ readonly role?: SpecialFileRole;
68
+ constructor(filePath: PathLike, role?: SpecialFileRole);
69
+ path(): PathLike;
70
+ content(): Content;
71
+ protected abstract loadContent(): Content;
72
+ assignRole(role: SpecialFileRole): void;
73
+ }
74
+ /**
75
+ * A basic implementation of the {@link FlowrFileProvider} interface for text files that caches the content after the first load (i.e., updates on disk are ignored).
76
+ */
77
+ export declare class FlowrTextFile extends FlowrFile<string> {
78
+ protected loadContent(): string;
79
+ }
80
+ /**
81
+ * A basic implementation of the {@link FlowrFileProvider} interface for (constant) inline text files.
82
+ * This is also useful for "special" files like the `DESCRIPTION` file in R packages that you want to pass in directly.
83
+ * These will be handled by the {@link FlowrAnalyzerDescriptionFilePlugin} (e.g., by using the {@link FlowrDescriptionFile#from} method decorator).
84
+ */
85
+ export declare class FlowrInlineTextFile extends FlowrFile<string> {
86
+ private readonly contentStr;
87
+ constructor(path: PathLike, content: string);
88
+ protected loadContent(): string;
89
+ }
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.FlowrInlineTextFile = exports.FlowrTextFile = exports.FlowrFile = exports.SpecialFileRole = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const assert_1 = require("../../util/assert");
9
+ /**
10
+ * Some files have a special meaning in R projects, e.g., the `DESCRIPTION` file in R packages.
11
+ * This list may be extended in the future and reflects files that the {@link FlowrAnalyzer} can do something interesting with.
12
+ * If you add an interesting file that is only part of your plugin infrastructure, please use the `other` role.
13
+ */
14
+ var SpecialFileRole;
15
+ (function (SpecialFileRole) {
16
+ /** The `DESCRIPTION` file in R packages, this is the only currently supported special file. */
17
+ SpecialFileRole["Description"] = "description";
18
+ /** The `NAMESPACE` file in R packages, currently not specially supported. */
19
+ SpecialFileRole["Namespace"] = "namespace";
20
+ /** Data files, e.g., `R/sysdata.rda`, currently not specially supported. */
21
+ SpecialFileRole["Data"] = "data";
22
+ /** Other special files that are not specifically supported by flowR but may be interesting for some analyses. */
23
+ SpecialFileRole["Other"] = "other";
24
+ })(SpecialFileRole || (exports.SpecialFileRole = SpecialFileRole = {}));
25
+ /**
26
+ * A basic implementation of the {@link FlowrFileProvider} interface that caches the content after the first load (i.e., updates on disk are ignored).
27
+ *
28
+ * See {@link FlowrTextFile} for a text-file specific implementation and {@link FlowrInlineTextFile} for inline text files.
29
+ */
30
+ class FlowrFile {
31
+ contentCache;
32
+ filePath;
33
+ role;
34
+ constructor(filePath, role) {
35
+ this.filePath = filePath;
36
+ this.role = role;
37
+ }
38
+ path() {
39
+ return this.filePath;
40
+ }
41
+ content() {
42
+ if (this.contentCache === undefined) {
43
+ this.contentCache = this.loadContent();
44
+ }
45
+ return this.contentCache;
46
+ }
47
+ assignRole(role) {
48
+ (0, assert_1.guard)(this.role === undefined || this.role === role, `File ${this.filePath.toString()} already has a role assigned: ${this.role}`);
49
+ this.role = role;
50
+ }
51
+ }
52
+ exports.FlowrFile = FlowrFile;
53
+ /**
54
+ * A basic implementation of the {@link FlowrFileProvider} interface for text files that caches the content after the first load (i.e., updates on disk are ignored).
55
+ */
56
+ class FlowrTextFile extends FlowrFile {
57
+ loadContent() {
58
+ return fs_1.default.readFileSync(this.filePath, 'utf8');
59
+ }
60
+ }
61
+ exports.FlowrTextFile = FlowrTextFile;
62
+ /**
63
+ * A basic implementation of the {@link FlowrFileProvider} interface for (constant) inline text files.
64
+ * This is also useful for "special" files like the `DESCRIPTION` file in R packages that you want to pass in directly.
65
+ * These will be handled by the {@link FlowrAnalyzerDescriptionFilePlugin} (e.g., by using the {@link FlowrDescriptionFile#from} method decorator).
66
+ */
67
+ class FlowrInlineTextFile extends FlowrFile {
68
+ contentStr;
69
+ constructor(path, content) {
70
+ super(path);
71
+ this.contentStr = content;
72
+ }
73
+ loadContent() {
74
+ return this.contentStr;
75
+ }
76
+ }
77
+ exports.FlowrInlineTextFile = FlowrInlineTextFile;
78
+ //# sourceMappingURL=flowr-file.js.map
@@ -0,0 +1,106 @@
1
+ import type { EngineConfig, FlowrConfigOptions } from '../config';
2
+ import type { DeepWritable } from 'ts-essentials';
3
+ import { fileProtocol, requestFromInput } from '../r-bridge/retriever';
4
+ import { FlowrAnalyzer } from './flowr-analyzer';
5
+ import type { KnownParser } from '../r-bridge/parser';
6
+ import type { FlowrAnalyzerPlugin } from './plugins/flowr-analyzer-plugin';
7
+ import type { NormalizeRequiredInput } from '../core/steps/all/core/10-normalize';
8
+ import type { RAnalysisRequest } from './context/flowr-analyzer-files-context';
9
+ /**
10
+ * Builder for the {@link FlowrAnalyzer}, use it to configure all analysis aspects before creating the analyzer instance
11
+ * with {@link FlowrAnalyzerBuilder#build|`.build()`} or {@link FlowrAnalyzerBuilder#buildSync|`.buildSync()`}.
12
+ *
13
+ * You can add new files and folders to analyze using the constructor or the {@link FlowrAnalyzerBuilder#add|`.add()`} method.
14
+ *
15
+ * @example Let's create an analyzer for a single R script file:
16
+ *
17
+ * ```ts
18
+ * const analyzer = new FlowrAnalyzerBuilder()
19
+ * .add('file:///path/to/script.R')
20
+ * .setParser(new TreeSitterExecutor())
21
+ * .buildSync();
22
+ * ```
23
+ *
24
+ * If you now want to get the dataflow information for the file, you can do this:
25
+ *
26
+ * ```ts
27
+ * const dfInfo = await analyzer.dataflow();
28
+ * console.log(dfInfo);
29
+ * ```
30
+ */
31
+ export declare class FlowrAnalyzerBuilder {
32
+ private flowrConfig;
33
+ private parser?;
34
+ private request;
35
+ private input?;
36
+ private plugins;
37
+ /**
38
+ * Create a new builder instance.
39
+ * @param request - The code to analyze
40
+ */
41
+ constructor(request?: RAnalysisRequest | readonly RAnalysisRequest[]);
42
+ /**
43
+ * Add one or multiple requests to analyze.
44
+ * This is a convenience method that uses {@link addRequest} and {@link addRequestFromInput} internally.
45
+ * @param request - One or multiple requests or a file path (with the `file://` protocol). If you just enter a string, it will be interpreted as R code.
46
+ */
47
+ add(request: RAnalysisRequest | readonly RAnalysisRequest[] | `${typeof fileProtocol}${string}` | string): this;
48
+ /**
49
+ * Add one or multiple requests to analyze the builder.
50
+ */
51
+ addRequest(request: RAnalysisRequest | readonly RAnalysisRequest[]): this;
52
+ /**
53
+ * Add a request created from the given input.
54
+ * This is a convenience method that uses {@link requestFromInput} internally.
55
+ */
56
+ addRequestFromInput(input: Parameters<typeof requestFromInput>[0]): this;
57
+ /**
58
+ * Apply an amendment to the configuration the builder currently holds.
59
+ * Per default, the {@link defaultConfigOptions} are used.
60
+ * @param func - Receives the current configuration of the builder and allows for amendment.
61
+ */
62
+ amendConfig(func: (config: DeepWritable<FlowrConfigOptions>) => FlowrConfigOptions | void): this;
63
+ /**
64
+ * Overwrite the configuration used by the resulting analyzer.
65
+ * @param config - The new configuration.
66
+ */
67
+ setConfig(config: FlowrConfigOptions): this;
68
+ /**
69
+ * Set the parser instance used by the analyzer.
70
+ * This is an alternative to {@link FlowrAnalyzerBuilder#setEngine} if you already have a parser instance.
71
+ * Please be aware, that if you want to parallelize multiple analyzers, there should be separate parser instances.
72
+ */
73
+ setParser(parser: KnownParser): this;
74
+ /**
75
+ * Set the engine and hence the parser that will be used by the analyzer.
76
+ * This is an alternative to {@link FlowrAnalyzerBuilder#setParser} if you do not have a parser instance at hand.
77
+ */
78
+ setEngine(engine: EngineConfig['type']): this;
79
+ /**
80
+ * Additional parameters for the analyses.
81
+ * @param input - The input.
82
+ */
83
+ setInput(input: Omit<NormalizeRequiredInput, 'request'>): this;
84
+ /**
85
+ * Register one or multiple additional plugins.
86
+ *
87
+ * @see {@link FlowrAnalyzerBuilder#unregisterPlugins} to remove plugins.
88
+ */
89
+ registerPlugins(...plugin: readonly FlowrAnalyzerPlugin[]): this;
90
+ /**
91
+ * Remove one or multiple plugins.
92
+ */
93
+ unregisterPlugins(...plugin: readonly FlowrAnalyzerPlugin[]): this;
94
+ /**
95
+ * Create the {@link FlowrAnalyzer} instance using the given information.
96
+ * Please note that the only reason this is `async` is that if no parser is set,
97
+ * we need to retrieve the default engine instance which is an async operation.
98
+ * If you set the parser using {@link FlowrAnalyzerBuilder#setParser},
99
+ */
100
+ build(): Promise<FlowrAnalyzer>;
101
+ /**
102
+ * Synchronous version of {@link FlowrAnalyzerBuilder#build}, please only use this if you have set the parser using
103
+ * {@link FlowrAnalyzerBuilder#setParser} before, otherwise an error will be thrown.
104
+ */
105
+ buildSync(): FlowrAnalyzer;
106
+ }
@@ -0,0 +1,197 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FlowrAnalyzerBuilder = void 0;
4
+ const config_1 = require("../config");
5
+ const retriever_1 = require("../r-bridge/retriever");
6
+ const flowr_analyzer_1 = require("./flowr-analyzer");
7
+ const engines_1 = require("../engines");
8
+ const assert_1 = require("../util/assert");
9
+ const files_1 = require("../util/files");
10
+ const flowr_analyzer_context_1 = require("./context/flowr-analyzer-context");
11
+ const flowr_analyzer_cache_1 = require("./cache/flowr-analyzer-cache");
12
+ /**
13
+ * Builder for the {@link FlowrAnalyzer}, use it to configure all analysis aspects before creating the analyzer instance
14
+ * with {@link FlowrAnalyzerBuilder#build|`.build()`} or {@link FlowrAnalyzerBuilder#buildSync|`.buildSync()`}.
15
+ *
16
+ * You can add new files and folders to analyze using the constructor or the {@link FlowrAnalyzerBuilder#add|`.add()`} method.
17
+ *
18
+ * @example Let's create an analyzer for a single R script file:
19
+ *
20
+ * ```ts
21
+ * const analyzer = new FlowrAnalyzerBuilder()
22
+ * .add('file:///path/to/script.R')
23
+ * .setParser(new TreeSitterExecutor())
24
+ * .buildSync();
25
+ * ```
26
+ *
27
+ * If you now want to get the dataflow information for the file, you can do this:
28
+ *
29
+ * ```ts
30
+ * const dfInfo = await analyzer.dataflow();
31
+ * console.log(dfInfo);
32
+ * ```
33
+ */
34
+ class FlowrAnalyzerBuilder {
35
+ flowrConfig = (0, config_1.cloneConfig)(config_1.defaultConfigOptions);
36
+ parser;
37
+ request;
38
+ input;
39
+ plugins = new Map();
40
+ /**
41
+ * Create a new builder instance.
42
+ * @param request - The code to analyze
43
+ */
44
+ constructor(request) {
45
+ this.addRequest(request ?? []);
46
+ }
47
+ /**
48
+ * Add one or multiple requests to analyze.
49
+ * This is a convenience method that uses {@link addRequest} and {@link addRequestFromInput} internally.
50
+ * @param request - One or multiple requests or a file path (with the `file://` protocol). If you just enter a string, it will be interpreted as R code.
51
+ */
52
+ add(request) {
53
+ if (Array.isArray(request) || (0, retriever_1.isParseRequest)(request)) {
54
+ this.addRequest(request);
55
+ }
56
+ else if (typeof request === 'string') {
57
+ const trimmed = request.substring(retriever_1.fileProtocol.length);
58
+ if (request.startsWith(retriever_1.fileProtocol) && !(0, files_1.isFilePath)(trimmed)) {
59
+ this.addRequest({ request: 'project', content: trimmed });
60
+ }
61
+ else {
62
+ this.addRequestFromInput(request);
63
+ }
64
+ }
65
+ else {
66
+ this.addRequest(request);
67
+ }
68
+ return this;
69
+ }
70
+ /**
71
+ * Add one or multiple requests to analyze the builder.
72
+ */
73
+ addRequest(request) {
74
+ const r = Array.isArray(request) ? request : [request];
75
+ if (this.request) {
76
+ this.request = this.request.concat(request);
77
+ }
78
+ else {
79
+ this.request = r;
80
+ }
81
+ return this;
82
+ }
83
+ /**
84
+ * Add a request created from the given input.
85
+ * This is a convenience method that uses {@link requestFromInput} internally.
86
+ */
87
+ addRequestFromInput(input) {
88
+ this.addRequest((0, retriever_1.requestFromInput)(input));
89
+ return this;
90
+ }
91
+ /**
92
+ * Apply an amendment to the configuration the builder currently holds.
93
+ * Per default, the {@link defaultConfigOptions} are used.
94
+ * @param func - Receives the current configuration of the builder and allows for amendment.
95
+ */
96
+ // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
97
+ amendConfig(func) {
98
+ this.flowrConfig = (0, config_1.amendConfig)(this.flowrConfig, func);
99
+ return this;
100
+ }
101
+ /**
102
+ * Overwrite the configuration used by the resulting analyzer.
103
+ * @param config - The new configuration.
104
+ */
105
+ setConfig(config) {
106
+ this.flowrConfig = config;
107
+ return this;
108
+ }
109
+ /**
110
+ * Set the parser instance used by the analyzer.
111
+ * This is an alternative to {@link FlowrAnalyzerBuilder#setEngine} if you already have a parser instance.
112
+ * Please be aware, that if you want to parallelize multiple analyzers, there should be separate parser instances.
113
+ */
114
+ setParser(parser) {
115
+ this.parser = parser;
116
+ return this;
117
+ }
118
+ /**
119
+ * Set the engine and hence the parser that will be used by the analyzer.
120
+ * This is an alternative to {@link FlowrAnalyzerBuilder#setParser} if you do not have a parser instance at hand.
121
+ */
122
+ setEngine(engine) {
123
+ this.flowrConfig.defaultEngine = engine;
124
+ return this;
125
+ }
126
+ /**
127
+ * Additional parameters for the analyses.
128
+ * @param input - The input.
129
+ */
130
+ setInput(input) {
131
+ this.input = input;
132
+ return this;
133
+ }
134
+ /**
135
+ * Register one or multiple additional plugins.
136
+ *
137
+ * @see {@link FlowrAnalyzerBuilder#unregisterPlugins} to remove plugins.
138
+ */
139
+ registerPlugins(...plugin) {
140
+ for (const p of plugin) {
141
+ const g = this.plugins.get(p.type);
142
+ if (g === undefined) {
143
+ this.plugins.set(p.type, [p]);
144
+ }
145
+ else {
146
+ g.push(p);
147
+ }
148
+ }
149
+ return this;
150
+ }
151
+ /**
152
+ * Remove one or multiple plugins.
153
+ */
154
+ unregisterPlugins(...plugin) {
155
+ for (const p of plugin) {
156
+ const g = this.plugins.get(p.type);
157
+ if (g !== undefined) {
158
+ this.plugins.set(p.type, g.filter(x => x !== p));
159
+ }
160
+ }
161
+ return this;
162
+ }
163
+ /**
164
+ * Create the {@link FlowrAnalyzer} instance using the given information.
165
+ * Please note that the only reason this is `async` is that if no parser is set,
166
+ * we need to retrieve the default engine instance which is an async operation.
167
+ * If you set the parser using {@link FlowrAnalyzerBuilder#setParser},
168
+ */
169
+ async build() {
170
+ if (!this.parser) {
171
+ const engines = await (0, engines_1.retrieveEngineInstances)(this.flowrConfig, true);
172
+ this.parser = engines.engines[engines.default];
173
+ }
174
+ return this.buildSync();
175
+ }
176
+ /**
177
+ * Synchronous version of {@link FlowrAnalyzerBuilder#build}, please only use this if you have set the parser using
178
+ * {@link FlowrAnalyzerBuilder#setParser} before, otherwise an error will be thrown.
179
+ */
180
+ buildSync() {
181
+ (0, assert_1.guard)(this.parser !== undefined, 'No parser set, please use the setParser or setEngine method to set a parser before building the analyzer');
182
+ (0, assert_1.guard)(this.request !== undefined, 'Currently we require at least one request to build an analyzer, please provide one using the constructor or the addRequest method');
183
+ const context = new flowr_analyzer_context_1.FlowrAnalyzerContext(this.plugins);
184
+ context.addRequests(this.request);
185
+ // we do it here to save time later if the analyzer is to be duplicated
186
+ context.resolvePreAnalysis();
187
+ const cache = flowr_analyzer_cache_1.FlowrAnalyzerCache.create({
188
+ parser: this.parser,
189
+ config: this.flowrConfig,
190
+ request: context.files.computeLoadingOrder(),
191
+ ...(this.input ?? {})
192
+ });
193
+ return new flowr_analyzer_1.FlowrAnalyzer(this.flowrConfig, this.parser, context, cache);
194
+ }
195
+ }
196
+ exports.FlowrAnalyzerBuilder = FlowrAnalyzerBuilder;
197
+ //# sourceMappingURL=flowr-analyzer-builder.js.map
@@ -0,0 +1,126 @@
1
+ import type { FlowrConfigOptions } from '../config';
2
+ import type { KnownParser, ParseStepOutput, RShellInformation, TreeSitterInformation } from '../r-bridge/parser';
3
+ import type { Queries, QueryResults, SupportedQueryTypes } from '../queries/query';
4
+ import type { ControlFlowInformation } from '../control-flow/control-flow-graph';
5
+ import type { NormalizedAst } from '../r-bridge/lang-4.x/ast/model/processing/decorate';
6
+ import type { DataflowInformation } from '../dataflow/info';
7
+ import type { CfgSimplificationPassName } from '../control-flow/cfg-simplification';
8
+ import type { PipelinePerStepMetaInformation } from '../core/steps/pipeline/pipeline';
9
+ import type { AnalyzerCacheType, FlowrAnalyzerCache } from './cache/flowr-analyzer-cache';
10
+ import type { FlowrSearchLike, SearchOutput } from '../search/flowr-search-builder';
11
+ import type { GetSearchElements } from '../search/flowr-search-executor';
12
+ import type { FlowrAnalyzerContext, ReadOnlyFlowrAnalyzerContext } from './context/flowr-analyzer-context';
13
+ import { CfgKind } from './cfg-kind';
14
+ import type { OutputCollectorConfiguration } from '../r-bridge/shell';
15
+ /**
16
+ * Exposes the central analyses and information provided by the {@link FlowrAnalyzer} to the linter, search, and query APIs.
17
+ * This allows us to exchange the underlying implementation of the analyzer without affecting the APIs.
18
+ */
19
+ export interface FlowrAnalysisProvider {
20
+ /**
21
+ * Get the name of the parser used by the analyzer.
22
+ */
23
+ parserInformation(): Promise<TreeSitterInformation | RShellInformation>;
24
+ /**
25
+ * Sends a command to the underlying R engine and collects the output.
26
+ * @param command - The command to send to the R engine.
27
+ * @param addonConfig - Additional configuration for the output collector.
28
+ */
29
+ sendCommandWithOutput(command: string, addonConfig?: Partial<OutputCollectorConfiguration>): Promise<string[]>;
30
+ /**
31
+ * Returns project context information.
32
+ * If you are a user that wants to inspect the context, prefer {@link inspectContext} instead.
33
+ * Please be aware that modifications to the context may break analyzer assumptions.
34
+ */
35
+ context(): FlowrAnalyzerContext;
36
+ /**
37
+ * Returns a read-only version of the project context information.
38
+ * This is the preferred method for users that want to inspect the context.
39
+ */
40
+ inspectContext(): ReadOnlyFlowrAnalyzerContext;
41
+ /**
42
+ * Get the parse output for the request.
43
+ *
44
+ * The parse result type depends on the {@link KnownParser} used by the analyzer.
45
+ * @param force - Do not use the cache, instead force a new parse.
46
+ */
47
+ parse(force?: boolean): Promise<ParseStepOutput<Awaited<ReturnType<KnownParser['parse']>>> & PipelinePerStepMetaInformation>;
48
+ /**
49
+ * Get the normalized abstract syntax tree for the request.
50
+ * @param force - Do not use the cache, instead force new analyses.
51
+ */
52
+ normalize(force?: boolean): Promise<NormalizedAst & PipelinePerStepMetaInformation>;
53
+ /**
54
+ * Get the dataflow graph for the request.
55
+ * @param force - Do not use the cache, instead force new analyses.
56
+ */
57
+ dataflow(force?: boolean): Promise<DataflowInformation & PipelinePerStepMetaInformation>;
58
+ /**
59
+ * Get the control flow graph (CFG) for the request.
60
+ * @param simplifications - Simplification passes to be applied to the CFG.
61
+ * @param kind - The kind of CFG that is requested. By default, the CFG without dataflow information is returned.
62
+ * @param force - Do not use the cache, instead force new analyses.
63
+ */
64
+ controlflow(simplifications?: readonly CfgSimplificationPassName[], kind?: CfgKind, force?: boolean): Promise<ControlFlowInformation>;
65
+ /**
66
+ * Access the query API for the request.
67
+ * @param query - The list of queries.
68
+ */
69
+ query<Types extends SupportedQueryTypes = SupportedQueryTypes>(query: Queries<Types>): Promise<QueryResults<Types>>;
70
+ /**
71
+ * Run a search on the current analysis.
72
+ */
73
+ runSearch<Search extends FlowrSearchLike>(search: Search): Promise<GetSearchElements<SearchOutput<Search>>>;
74
+ /**
75
+ * This executes all steps of the core analysis (parse, normalize, dataflow).
76
+ */
77
+ runFull(force?: boolean): Promise<void>;
78
+ /**
79
+ * Reset all caches used by the analyzer and effectively force all analyses to be redone.
80
+ */
81
+ reset(): void;
82
+ /** This is the config used for the analyzer */
83
+ flowrConfig: FlowrConfigOptions;
84
+ }
85
+ /**
86
+ * Central class for conducting analyses with FlowR.
87
+ * Use the {@link FlowrAnalyzerBuilder} to create a new instance.
88
+ *
89
+ * If you want the original pattern of creating a pipeline and running all steps, you can still do this with {@link FlowrAnalyzer#runFull}.
90
+ *
91
+ * To inspect the context of the analyzer, use {@link FlowrAnalyzer#inspectContext} (if you are a plugin and need to modify it, use {@link FlowrAnalyzer#context} instead).
92
+ */
93
+ export declare class FlowrAnalyzer<Parser extends KnownParser = KnownParser> implements FlowrAnalysisProvider {
94
+ readonly flowrConfig: FlowrConfigOptions;
95
+ /** The parser and engine backend */
96
+ private readonly parser;
97
+ /** The cache used for storing analysis results */
98
+ private readonly cache;
99
+ private readonly ctx;
100
+ /**
101
+ * Create a new analyzer instance.
102
+ * **Prefer the use of the {@link FlowrAnalyzerBuilder} instead of calling this constructor directly.**
103
+ *
104
+ * @param config - The FlowR config to use for the analyses
105
+ * @param parser - The parser to use for parsing the given request.
106
+ * @param ctx - The context to use for the analyses.
107
+ * @param cache - The caching layer to use for storing analysis results.
108
+ */
109
+ constructor(config: FlowrConfigOptions, parser: Parser, ctx: FlowrAnalyzerContext, cache: FlowrAnalyzerCache<Parser>);
110
+ context(): FlowrAnalyzerContext;
111
+ parserInformation(): Promise<TreeSitterInformation | RShellInformation>;
112
+ sendCommandWithOutput(command: string, addonConfig?: Partial<OutputCollectorConfiguration>): Promise<string[]>;
113
+ inspectContext(): ReadOnlyFlowrAnalyzerContext;
114
+ reset(): void;
115
+ parse(force?: boolean): Promise<NonNullable<AnalyzerCacheType<Parser>['parse']>>;
116
+ normalize(force?: boolean): Promise<NonNullable<AnalyzerCacheType<Parser>['normalize']>>;
117
+ dataflow(force?: boolean): Promise<NonNullable<AnalyzerCacheType<Parser>['dataflow']>>;
118
+ runFull(force?: boolean): Promise<void>;
119
+ controlflow(simplifications?: readonly CfgSimplificationPassName[], kind?: CfgKind, force?: boolean): Promise<ControlFlowInformation>;
120
+ query<Types extends SupportedQueryTypes = SupportedQueryTypes>(query: Queries<Types>): Promise<QueryResults<Types>>;
121
+ runSearch<Search extends FlowrSearchLike>(search: Search): Promise<GetSearchElements<SearchOutput<Search>>>;
122
+ /**
123
+ * Close the parser if it was created by this builder. This is only required if you rely on an RShell/remote engine.
124
+ */
125
+ close(): boolean | void;
126
+ }