@eagleoutice/flowr 2.4.8 → 2.6.0

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 (234) hide show
  1. package/README.md +66 -45
  2. package/benchmark/slicer.js +1 -1
  3. package/benchmark/summarizer/second-phase/graph.js +2 -2
  4. package/cli/flowr.js +3 -29
  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.js +1 -0
  12. package/cli/repl/commands/repl-lineage.js +1 -0
  13. package/cli/repl/commands/repl-main.d.ts +34 -3
  14. package/cli/repl/commands/repl-normalize.d.ts +3 -3
  15. package/cli/repl/commands/repl-normalize.js +15 -19
  16. package/cli/repl/commands/repl-parse.d.ts +2 -2
  17. package/cli/repl/commands/repl-parse.js +13 -8
  18. package/cli/repl/commands/repl-query.d.ts +3 -3
  19. package/cli/repl/commands/repl-query.js +29 -19
  20. package/cli/repl/commands/repl-quit.js +1 -0
  21. package/cli/repl/commands/repl-version.js +1 -0
  22. package/cli/repl/core.d.ts +4 -1
  23. package/cli/repl/core.js +21 -1
  24. package/cli/repl/server/connection.d.ts +7 -3
  25. package/cli/repl/server/connection.js +40 -48
  26. package/cli/repl/server/messages/message-slice.d.ts +1 -1
  27. package/cli/slicer-app.js +8 -3
  28. package/config.d.ts +1 -1
  29. package/config.js +4 -1
  30. package/control-flow/extract-cfg.d.ts +1 -1
  31. package/control-flow/extract-cfg.js +1 -1
  32. package/core/pipeline-executor.d.ts +5 -0
  33. package/core/pipeline-executor.js +5 -0
  34. package/core/steps/pipeline/create-pipeline.js +1 -1
  35. package/core/steps/pipeline/default-pipelines.d.ts +42 -42
  36. package/core/steps/pipeline/default-pipelines.js +4 -1
  37. package/dataflow/graph/dataflowgraph-builder.d.ts +11 -12
  38. package/dataflow/graph/dataflowgraph-builder.js +6 -6
  39. package/documentation/doc-util/doc-query.d.ts +3 -6
  40. package/documentation/doc-util/doc-query.js +5 -17
  41. package/documentation/doc-util/doc-search.js +7 -10
  42. package/documentation/doc-util/doc-structure.d.ts +4 -0
  43. package/documentation/doc-util/doc-structure.js +28 -0
  44. package/documentation/doc-util/doc-types.d.ts +5 -1
  45. package/documentation/doc-util/doc-types.js +29 -3
  46. package/documentation/print-analyzer-wiki.d.ts +1 -0
  47. package/documentation/print-analyzer-wiki.js +137 -0
  48. package/documentation/print-core-wiki.d.ts +2 -1
  49. package/documentation/print-core-wiki.js +58 -4
  50. package/documentation/print-dataflow-graph-wiki.js +15 -22
  51. package/documentation/print-interface-wiki.js +18 -1
  52. package/documentation/print-linter-wiki.js +5 -1
  53. package/documentation/print-linting-and-testing-wiki.js +4 -0
  54. package/documentation/print-normalized-ast-wiki.js +6 -8
  55. package/documentation/print-readme.js +6 -0
  56. package/engines.d.ts +9 -0
  57. package/engines.js +38 -0
  58. package/linter/linter-executor.d.ts +2 -8
  59. package/linter/linter-executor.js +9 -4
  60. package/linter/linter-format.d.ts +8 -9
  61. package/linter/linter-rules.d.ts +57 -15
  62. package/linter/linter-rules.js +2 -0
  63. package/linter/rules/absolute-path.d.ts +1 -0
  64. package/linter/rules/dataframe-access-validation.d.ts +4 -3
  65. package/linter/rules/dataframe-access-validation.js +7 -4
  66. package/linter/rules/dead-code.d.ts +2 -1
  67. package/linter/rules/deprecated-functions.d.ts +15 -28
  68. package/linter/rules/deprecated-functions.js +5 -43
  69. package/linter/rules/file-path-validity.d.ts +2 -1
  70. package/linter/rules/file-path-validity.js +1 -1
  71. package/linter/rules/function-finder-util.d.ts +51 -0
  72. package/linter/rules/function-finder-util.js +77 -0
  73. package/linter/rules/naming-convention.d.ts +2 -1
  74. package/linter/rules/network-functions.d.ts +40 -0
  75. package/linter/rules/network-functions.js +24 -0
  76. package/linter/rules/seeded-randomness.d.ts +2 -1
  77. package/linter/rules/unused-definition.d.ts +2 -1
  78. package/linter/rules/useless-loop.d.ts +3 -2
  79. package/linter/rules/useless-loop.js +4 -6
  80. package/package.json +5 -1
  81. package/project/cache/flowr-analyzer-cache.d.ts +93 -0
  82. package/project/cache/flowr-analyzer-cache.js +156 -0
  83. package/project/cache/flowr-cache.d.ts +28 -0
  84. package/project/cache/flowr-cache.js +49 -0
  85. package/project/context/abstract-flowr-analyzer-context.d.ts +35 -0
  86. package/project/context/abstract-flowr-analyzer-context.js +46 -0
  87. package/project/context/flowr-analyzer-context.d.ts +48 -0
  88. package/project/context/flowr-analyzer-context.js +47 -0
  89. package/project/context/flowr-analyzer-dependencies-context.d.ts +38 -0
  90. package/project/context/flowr-analyzer-dependencies-context.js +39 -0
  91. package/project/context/flowr-analyzer-files-context.d.ts +86 -0
  92. package/project/context/flowr-analyzer-files-context.js +130 -0
  93. package/project/context/flowr-analyzer-loading-order-context.d.ts +76 -0
  94. package/project/context/flowr-analyzer-loading-order-context.js +90 -0
  95. package/project/context/flowr-file.d.ts +89 -0
  96. package/project/context/flowr-file.js +78 -0
  97. package/project/flowr-analyzer-builder.d.ts +106 -0
  98. package/project/flowr-analyzer-builder.js +197 -0
  99. package/project/flowr-analyzer.d.ts +125 -0
  100. package/project/flowr-analyzer.js +81 -0
  101. package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.d.ts +17 -0
  102. package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.js +28 -0
  103. package/project/plugins/file-plugins/flowr-analyzer-file-plugin.d.ts +21 -0
  104. package/project/plugins/file-plugins/flowr-analyzer-file-plugin.js +34 -0
  105. package/project/plugins/file-plugins/flowr-description-file.d.ts +24 -0
  106. package/project/plugins/file-plugins/flowr-description-file.js +38 -0
  107. package/project/plugins/flowr-analyzer-plugin.d.ts +90 -0
  108. package/project/plugins/flowr-analyzer-plugin.js +82 -0
  109. package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-description-file-plugin.d.ts +14 -0
  110. package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-description-file-plugin.js +56 -0
  111. package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-plugin.d.ts +13 -0
  112. package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-plugin.js +33 -0
  113. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.d.ts +14 -0
  114. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.js +41 -0
  115. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.d.ts +10 -0
  116. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.js +29 -0
  117. package/project/plugins/package-version-plugins/package.d.ts +15 -0
  118. package/project/plugins/package-version-plugins/package.js +56 -0
  119. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.d.ts +15 -0
  120. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +44 -0
  121. package/queries/base-query-format.d.ts +2 -8
  122. package/queries/catalog/call-context-query/call-context-query-executor.d.ts +1 -1
  123. package/queries/catalog/call-context-query/call-context-query-executor.js +20 -13
  124. package/queries/catalog/call-context-query/call-context-query-format.d.ts +2 -3
  125. package/queries/catalog/call-context-query/call-context-query-format.js +2 -2
  126. package/queries/catalog/cluster-query/cluster-query-executor.d.ts +1 -1
  127. package/queries/catalog/cluster-query/cluster-query-executor.js +2 -2
  128. package/queries/catalog/cluster-query/cluster-query-format.d.ts +1 -54
  129. package/queries/catalog/cluster-query/cluster-query-format.js +2 -2
  130. package/queries/catalog/config-query/config-query-executor.d.ts +1 -1
  131. package/queries/catalog/config-query/config-query-executor.js +5 -5
  132. package/queries/catalog/config-query/config-query-format.d.ts +1 -1
  133. package/queries/catalog/config-query/config-query-format.js +1 -1
  134. package/queries/catalog/control-flow-query/control-flow-query-executor.d.ts +1 -1
  135. package/queries/catalog/control-flow-query/control-flow-query-executor.js +2 -3
  136. package/queries/catalog/control-flow-query/control-flow-query-format.d.ts +1 -54
  137. package/queries/catalog/control-flow-query/control-flow-query-format.js +2 -2
  138. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.d.ts +1 -1
  139. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.js +2 -2
  140. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.d.ts +1 -54
  141. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.js +1 -1
  142. package/queries/catalog/dataflow-query/dataflow-query-executor.d.ts +1 -1
  143. package/queries/catalog/dataflow-query/dataflow-query-executor.js +2 -2
  144. package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +1 -54
  145. package/queries/catalog/dataflow-query/dataflow-query-format.js +1 -1
  146. package/queries/catalog/dependencies-query/dependencies-query-executor.d.ts +1 -1
  147. package/queries/catalog/dependencies-query/dependencies-query-executor.js +19 -12
  148. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +7 -56
  149. package/queries/catalog/dependencies-query/dependencies-query-format.js +7 -4
  150. package/queries/catalog/df-shape-query/df-shape-query-executor.d.ts +1 -1
  151. package/queries/catalog/df-shape-query/df-shape-query-executor.js +4 -4
  152. package/queries/catalog/df-shape-query/df-shape-query-format.d.ts +1 -54
  153. package/queries/catalog/df-shape-query/df-shape-query-format.js +1 -1
  154. package/queries/catalog/happens-before-query/happens-before-query-executor.d.ts +1 -1
  155. package/queries/catalog/happens-before-query/happens-before-query-executor.js +2 -1
  156. package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +1 -54
  157. package/queries/catalog/happens-before-query/happens-before-query-format.js +1 -1
  158. package/queries/catalog/id-map-query/id-map-query-executor.d.ts +1 -1
  159. package/queries/catalog/id-map-query/id-map-query-executor.js +2 -2
  160. package/queries/catalog/id-map-query/id-map-query-format.d.ts +1 -54
  161. package/queries/catalog/id-map-query/id-map-query-format.js +2 -2
  162. package/queries/catalog/lineage-query/lineage-query-executor.d.ts +1 -1
  163. package/queries/catalog/lineage-query/lineage-query-executor.js +2 -2
  164. package/queries/catalog/lineage-query/lineage-query-format.d.ts +1 -54
  165. package/queries/catalog/lineage-query/lineage-query-format.js +1 -1
  166. package/queries/catalog/linter-query/linter-query-executor.d.ts +1 -1
  167. package/queries/catalog/linter-query/linter-query-executor.js +2 -3
  168. package/queries/catalog/linter-query/linter-query-format.d.ts +1 -54
  169. package/queries/catalog/linter-query/linter-query-format.js +1 -1
  170. package/queries/catalog/location-map-query/location-map-query-executor.d.ts +1 -1
  171. package/queries/catalog/location-map-query/location-map-query-executor.js +3 -2
  172. package/queries/catalog/location-map-query/location-map-query-format.d.ts +1 -1
  173. package/queries/catalog/location-map-query/location-map-query-format.js +1 -1
  174. package/queries/catalog/normalized-ast-query/normalized-ast-query-executor.d.ts +1 -1
  175. package/queries/catalog/normalized-ast-query/normalized-ast-query-executor.js +2 -2
  176. package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +1 -54
  177. package/queries/catalog/normalized-ast-query/normalized-ast-query-format.js +1 -1
  178. package/queries/catalog/origin-query/origin-query-executor.d.ts +2 -2
  179. package/queries/catalog/origin-query/origin-query-executor.js +3 -3
  180. package/queries/catalog/origin-query/origin-query-format.d.ts +1 -54
  181. package/queries/catalog/origin-query/origin-query-format.js +1 -1
  182. package/queries/catalog/project-query/project-query-executor.d.ts +1 -1
  183. package/queries/catalog/project-query/project-query-executor.js +2 -2
  184. package/queries/catalog/project-query/project-query-format.d.ts +1 -54
  185. package/queries/catalog/project-query/project-query-format.js +1 -1
  186. package/queries/catalog/resolve-value-query/resolve-value-query-executor.d.ts +1 -1
  187. package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +4 -2
  188. package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +1 -54
  189. package/queries/catalog/resolve-value-query/resolve-value-query-format.js +1 -1
  190. package/queries/catalog/search-query/search-query-executor.d.ts +1 -1
  191. package/queries/catalog/search-query/search-query-executor.js +3 -3
  192. package/queries/catalog/search-query/search-query-format.d.ts +1 -54
  193. package/queries/catalog/search-query/search-query-format.js +1 -1
  194. package/queries/catalog/static-slice-query/static-slice-query-executor.d.ts +1 -1
  195. package/queries/catalog/static-slice-query/static-slice-query-executor.js +3 -3
  196. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +1 -54
  197. package/queries/catalog/static-slice-query/static-slice-query-format.js +1 -1
  198. package/queries/query-print.d.ts +4 -4
  199. package/queries/query-print.js +12 -12
  200. package/queries/query.d.ts +29 -885
  201. package/queries/query.js +1 -1
  202. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +1 -1
  203. package/r-bridge/retriever.d.ts +15 -2
  204. package/r-bridge/retriever.js +15 -5
  205. package/search/flowr-search-executor.d.ts +3 -5
  206. package/search/flowr-search-executor.js +6 -4
  207. package/search/flowr-search-filters.d.ts +12 -6
  208. package/search/flowr-search-filters.js +1 -1
  209. package/search/flowr-search.d.ts +5 -16
  210. package/search/flowr-search.js +14 -5
  211. package/search/search-executor/search-enrichers.d.ts +37 -36
  212. package/search/search-executor/search-enrichers.js +4 -4
  213. package/search/search-executor/search-generators.d.ts +12 -12
  214. package/search/search-executor/search-generators.js +27 -19
  215. package/search/search-executor/search-mappers.d.ts +5 -5
  216. package/search/search-executor/search-transformer.d.ts +17 -17
  217. package/search/search-executor/search-transformer.js +14 -7
  218. package/util/collections/arrays.d.ts +1 -0
  219. package/util/collections/arrays.js +15 -0
  220. package/util/collections/objectmap.d.ts +17 -0
  221. package/util/collections/objectmap.js +28 -0
  222. package/util/containers.d.ts +0 -1
  223. package/util/containers.js +0 -1
  224. package/util/files.d.ts +17 -0
  225. package/util/files.js +65 -0
  226. package/util/formats/adapter-format.d.ts +6 -0
  227. package/util/formats/adapter-format.js +3 -0
  228. package/util/formats/adapter.d.ts +18 -0
  229. package/util/formats/adapter.js +49 -0
  230. package/util/formats/adapters/r-adapter.d.ts +4 -0
  231. package/util/formats/adapters/r-adapter.js +7 -0
  232. package/util/formats/adapters/rmd-adapter.d.ts +26 -0
  233. package/util/formats/adapters/rmd-adapter.js +91 -0
  234. package/util/version.js +1 -1
@@ -0,0 +1,130 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FlowrAnalyzerFilesContext = void 0;
4
+ const abstract_flowr_analyzer_context_1 = require("./abstract-flowr-analyzer-context");
5
+ const retriever_1 = require("../../r-bridge/retriever");
6
+ const assert_1 = require("../../util/assert");
7
+ const flowr_analyzer_project_discovery_plugin_1 = require("../plugins/project-discovery/flowr-analyzer-project-discovery-plugin");
8
+ const flowr_analyzer_file_plugin_1 = require("../plugins/file-plugins/flowr-analyzer-file-plugin");
9
+ const flowr_file_1 = require("./flowr-file");
10
+ const log_1 = require("../../util/log");
11
+ const fileLog = log_1.log.getSubLogger({ name: 'flowr-analyzer-files-context' });
12
+ function obtainFileAndPath(file, role) {
13
+ let f;
14
+ let p;
15
+ if (typeof file === 'string') {
16
+ f = new flowr_file_1.FlowrTextFile(file, role);
17
+ p = file;
18
+ }
19
+ else if ('request' in file) {
20
+ f = file;
21
+ p = file.content;
22
+ }
23
+ else {
24
+ f = file;
25
+ p = file.path().toString();
26
+ }
27
+ return { f, p };
28
+ }
29
+ /**
30
+ * This is the analyzer file context to be modified by all plugins that affect the files.
31
+ * If you are interested in inspecting these files, refer to {@link ReadOnlyFlowrAnalyzerFilesContext}.
32
+ * Plugins, however, can use this context directly to modify files.
33
+ */
34
+ class FlowrAnalyzerFilesContext extends abstract_flowr_analyzer_context_1.AbstractFlowrAnalyzerContext {
35
+ name = 'flowr-analyzer-files-context';
36
+ loadingOrder;
37
+ /* all project files etc., this contains *all* files, loading orders etc. are to be handled by plugins */
38
+ files = new Map();
39
+ fileLoaders;
40
+ /* files that are part of the analysis, e.g. source files */
41
+ specialFiles = {
42
+ [flowr_file_1.SpecialFileRole.Description]: [],
43
+ [flowr_file_1.SpecialFileRole.Namespace]: [],
44
+ [flowr_file_1.SpecialFileRole.Data]: [],
45
+ [flowr_file_1.SpecialFileRole.Other]: []
46
+ };
47
+ constructor(loadingOrder, plugins, fileLoaders) {
48
+ super(loadingOrder.getAttachedContext(), flowr_analyzer_project_discovery_plugin_1.FlowrAnalyzerProjectDiscoveryPlugin.defaultPlugin(), plugins);
49
+ this.fileLoaders = [...fileLoaders, flowr_analyzer_file_plugin_1.FlowrAnalyzerFilePlugin.defaultPlugin()];
50
+ this.loadingOrder = loadingOrder;
51
+ }
52
+ /**
53
+ * Add multiple requests to the context. This is just a convenience method that calls {@link addRequest} for each request.
54
+ */
55
+ addRequests(requests) {
56
+ for (const request of requests) {
57
+ this.addRequest(request);
58
+ }
59
+ }
60
+ /**
61
+ * Add a request to the context. If the request is of type `project`, it will be expanded using the registered {@link FlowrAnalyzerProjectDiscoveryPlugin}s.
62
+ */
63
+ addRequest(request) {
64
+ if (request.request !== 'project') {
65
+ this.loadingOrder.addRequest(request);
66
+ if (request.request === 'file') {
67
+ this.files.set(request.content, request);
68
+ }
69
+ return;
70
+ }
71
+ const expandedRequests = this.applyPlugins(request).flat();
72
+ for (const req of expandedRequests) {
73
+ if ((0, retriever_1.isParseRequest)(req)) {
74
+ this.addRequest(req);
75
+ }
76
+ else {
77
+ this.addFile(req, req.role);
78
+ }
79
+ }
80
+ }
81
+ /**
82
+ * Add multiple files to the context. This is just a convenience method that calls {@link addFile} for each file.
83
+ */
84
+ addFiles(...files) {
85
+ for (const file of files) {
86
+ this.addFile(file);
87
+ }
88
+ }
89
+ /**
90
+ * Add a file to the context. If the file has a special role, it will be added to the corresponding list of special files.
91
+ * This method also applies any registered {@link FlowrAnalyzerFilePlugin}s to the file before adding it to the context.
92
+ */
93
+ addFile(file, role) {
94
+ const { f, p } = obtainFileAndPath(file, role);
95
+ const { f: fA, p: pA } = this.fileLoadPlugins(f, p);
96
+ const exist = this.files.get(pA);
97
+ (0, assert_1.guard)(exist === undefined || exist === fA, `File ${pA} already added to the context.`);
98
+ this.files.set(pA, fA);
99
+ if (!(0, retriever_1.isParseRequest)(fA) && fA.role) {
100
+ this.specialFiles[fA.role].push(fA);
101
+ }
102
+ }
103
+ fileLoadPlugins(f, p) {
104
+ let fFinal = f;
105
+ let pFinal = p;
106
+ if (!(0, retriever_1.isParseRequest)(f)) { // we have to change the types when we integrate the adapters
107
+ for (const loader of this.fileLoaders) {
108
+ if (loader.applies(p)) {
109
+ fileLog.debug(`Applying file loader ${loader.name} to file ${p}`);
110
+ fFinal = loader.processor(this.ctx, f);
111
+ pFinal = f.path().toString();
112
+ break;
113
+ }
114
+ }
115
+ }
116
+ return { f: fFinal, p: pFinal };
117
+ }
118
+ /**
119
+ * Get all requests that have been added to this context.
120
+ * This is a convenience method that calls {@link FlowrAnalyzerLoadingOrderContext.getLoadingOrder}.
121
+ */
122
+ computeLoadingOrder() {
123
+ return this.loadingOrder.getLoadingOrder();
124
+ }
125
+ getFilesByRole(role) {
126
+ return this.specialFiles[role];
127
+ }
128
+ }
129
+ exports.FlowrAnalyzerFilesContext = FlowrAnalyzerFilesContext;
130
+ //# sourceMappingURL=flowr-analyzer-files-context.js.map
@@ -0,0 +1,76 @@
1
+ import { AbstractFlowrAnalyzerContext } from './abstract-flowr-analyzer-context';
2
+ import type { RParseRequest } from '../../r-bridge/retriever';
3
+ import { FlowrAnalyzerLoadingOrderPlugin } from '../plugins/loading-order-plugins/flowr-analyzer-loading-order-plugin';
4
+ import type { FlowrAnalyzerContext } from './flowr-analyzer-context';
5
+ /**
6
+ * Read-only interface for the loading order context, which is used to determine the order in which script files are loaded in a project.
7
+ *
8
+ * This interface prevents you from modifying the available files, but allows you to inspect them (which is probably what you want when using the {@link FlowrAnalyzer}).
9
+ * If you are a {@link FlowrAnalyzerLoadingOrderPlugin} and want to modify the available orders, you can use the {@link FlowrAnalyzerLoadingOrderContext} directly.
10
+ */
11
+ export interface ReadOnlyFlowrAnalyzerLoadingOrderContext {
12
+ /**
13
+ * The name of this context.
14
+ */
15
+ readonly name: string;
16
+ /**
17
+ * Peek whether we have a loading order known or guessed, this does not trigger any plugin runs.
18
+ * If you want to get the current loading order, including potential recompoutations, use {@link getLoadingOrder} instead.
19
+ */
20
+ peekLoadingOrder(): readonly RParseRequest[] | undefined;
21
+ /**
22
+ * Get the current loading order of requests, potentially triggering a re-computation if new requests have been added since the last computation.
23
+ */
24
+ getLoadingOrder(): readonly RParseRequest[];
25
+ /**
26
+ * Get all requests that have been added to this context, but for which no loading order is known or guessed.
27
+ */
28
+ getUnorderedRequests(): readonly RParseRequest[];
29
+ /**
30
+ * Get the current guesses for the loading order, if any. These are populated by {@link FlowrAnalyzerLoadingOrderPlugin}s.
31
+ */
32
+ currentGuesses(): readonly RParseRequest[][];
33
+ /**
34
+ * Get the current known loading order, if any. This is populated by {@link FlowrAnalyzerLoadingOrderPlugin}s if they have a source of identifying the order definitively.
35
+ */
36
+ currentKnownOrder(): readonly RParseRequest[] | undefined;
37
+ }
38
+ /**
39
+ * This context is responsible for managing the loading order of script files in a project, including guesses and known orders provided by {@link FlowrAnalyzerLoadingOrderPlugin}s.
40
+ *
41
+ * If you are interested in inspecting these orders, refer to {@link ReadOnlyFlowrAnalyzerLoadingOrderContext}.
42
+ * Plugins, however, can use this context directly to modify order guesses.
43
+ */
44
+ export declare class FlowrAnalyzerLoadingOrderContext extends AbstractFlowrAnalyzerContext<undefined, void, FlowrAnalyzerLoadingOrderPlugin> implements ReadOnlyFlowrAnalyzerLoadingOrderContext {
45
+ readonly name = "flowr-analyzer-loading-order-context";
46
+ private rerunRequired;
47
+ constructor(ctx: FlowrAnalyzerContext, plugins: readonly FlowrAnalyzerLoadingOrderPlugin[] | undefined);
48
+ private knownOrder?;
49
+ private guesses;
50
+ /** just the base collection of requests we know nothing about the order! */
51
+ private unordered;
52
+ /**
53
+ * Add one or multiple requests to the context.
54
+ * These are considered unordered (i.e., ordered implicitly by the order of addition) until a plugin provides either a guess or a known order.
55
+ *
56
+ * This is a batched version of {@link addRequest}.
57
+ */
58
+ addRequests(requests: readonly RParseRequest[]): void;
59
+ /**
60
+ * Add a single request to the context.
61
+ * This is considered unordered (i.e., ordered implicitly by the order of addition) until a plugin provides either a guess or a known order.
62
+ *
63
+ * If you want to add multiple requests, consider using {@link addRequests} instead for efficiency.
64
+ */
65
+ addRequest(request: RParseRequest): void;
66
+ /**
67
+ * Add a guess for the loading order. This is mostly for plugins to use.
68
+ * In case you have a certain order, use the `certain` flag to indicate this -- but please take care of *really* being certain!
69
+ */
70
+ addGuess(guess: readonly RParseRequest[], certain?: boolean): void;
71
+ currentGuesses(): readonly RParseRequest[][];
72
+ currentKnownOrder(): readonly RParseRequest[] | undefined;
73
+ peekLoadingOrder(): readonly RParseRequest[] | undefined;
74
+ getUnorderedRequests(): readonly RParseRequest[];
75
+ getLoadingOrder(): readonly RParseRequest[];
76
+ }
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FlowrAnalyzerLoadingOrderContext = void 0;
4
+ const abstract_flowr_analyzer_context_1 = require("./abstract-flowr-analyzer-context");
5
+ const log_1 = require("../../util/log");
6
+ const arrays_1 = require("../../util/collections/arrays");
7
+ const flowr_analyzer_loading_order_plugin_1 = require("../plugins/loading-order-plugins/flowr-analyzer-loading-order-plugin");
8
+ const loadingOrderLog = log_1.log.getSubLogger({ name: 'loading-order' });
9
+ /**
10
+ * This context is responsible for managing the loading order of script files in a project, including guesses and known orders provided by {@link FlowrAnalyzerLoadingOrderPlugin}s.
11
+ *
12
+ * If you are interested in inspecting these orders, refer to {@link ReadOnlyFlowrAnalyzerLoadingOrderContext}.
13
+ * Plugins, however, can use this context directly to modify order guesses.
14
+ */
15
+ class FlowrAnalyzerLoadingOrderContext extends abstract_flowr_analyzer_context_1.AbstractFlowrAnalyzerContext {
16
+ name = 'flowr-analyzer-loading-order-context';
17
+ rerunRequired;
18
+ constructor(ctx, plugins) {
19
+ super(ctx, flowr_analyzer_loading_order_plugin_1.FlowrAnalyzerLoadingOrderPlugin.defaultPlugin(), plugins);
20
+ this.rerunRequired = this.plugins.length > 0;
21
+ }
22
+ knownOrder;
23
+ guesses = [];
24
+ /** just the base collection of requests we know nothing about the order! */
25
+ unordered = [];
26
+ /**
27
+ * Add one or multiple requests to the context.
28
+ * These are considered unordered (i.e., ordered implicitly by the order of addition) until a plugin provides either a guess or a known order.
29
+ *
30
+ * This is a batched version of {@link addRequest}.
31
+ */
32
+ addRequests(requests) {
33
+ this.unordered.push(...requests);
34
+ if (this.knownOrder || this.guesses.length > 0) {
35
+ loadingOrderLog.warn(`Adding requests ${requests.map(r => r.request).join(', ')} after known order!`);
36
+ this.rerunRequired = true;
37
+ }
38
+ }
39
+ /**
40
+ * Add a single request to the context.
41
+ * This is considered unordered (i.e., ordered implicitly by the order of addition) until a plugin provides either a guess or a known order.
42
+ *
43
+ * If you want to add multiple requests, consider using {@link addRequests} instead for efficiency.
44
+ */
45
+ addRequest(request) {
46
+ this.unordered.push(request);
47
+ if (this.knownOrder || this.guesses.length > 0) {
48
+ loadingOrderLog.warn(`Adding request ${request.request} ${request.content} after known order!`);
49
+ this.rerunRequired = true;
50
+ }
51
+ }
52
+ /**
53
+ * Add a guess for the loading order. This is mostly for plugins to use.
54
+ * In case you have a certain order, use the `certain` flag to indicate this -- but please take care of *really* being certain!
55
+ */
56
+ addGuess(guess, certain) {
57
+ if (certain) {
58
+ if (this.knownOrder) {
59
+ loadingOrderLog.warn(`Adding certain guess ${guess.map(g => g.request).join(', ')} after known order!`);
60
+ if (!(0, arrays_1.arrayEqual)(this.knownOrder, guess)) {
61
+ loadingOrderLog.error(`Certain guess ${guess.map(g => g.request).join(', ')} does not match known order ${this.knownOrder.map(g => g.request).join(', ')}`);
62
+ }
63
+ }
64
+ else {
65
+ this.knownOrder = guess;
66
+ }
67
+ }
68
+ }
69
+ currentGuesses() {
70
+ return this.guesses;
71
+ }
72
+ currentKnownOrder() {
73
+ return this.knownOrder;
74
+ }
75
+ peekLoadingOrder() {
76
+ return this.knownOrder ?? (this.guesses.length > 0 ? this.guesses[0] : undefined);
77
+ }
78
+ getUnorderedRequests() {
79
+ return this.unordered;
80
+ }
81
+ getLoadingOrder() {
82
+ if (this.rerunRequired) {
83
+ this.rerunRequired = false;
84
+ this.applyPlugins(undefined);
85
+ }
86
+ return this.peekLoadingOrder() ?? this.unordered;
87
+ }
88
+ }
89
+ exports.FlowrAnalyzerLoadingOrderContext = FlowrAnalyzerLoadingOrderContext;
90
+ //# sourceMappingURL=flowr-analyzer-loading-order-context.js.map
@@ -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
+ }