@eagleoutice/flowr 2.10.10 → 2.11.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 (220) hide show
  1. package/README.md +37 -29
  2. package/cli/common/options.d.ts +2 -108
  3. package/cli/common/options.js +3 -27
  4. package/cli/common/scripts-info.d.ts +2 -123
  5. package/cli/common/scripts-info.js +0 -17
  6. package/cli/flowr-main-options.d.ts +5 -0
  7. package/cli/flowr-main-options.js +10 -0
  8. package/cli/flowr.js +1 -1
  9. package/cli/repl/print-version.d.ts +3 -1
  10. package/cli/repl/print-version.js +21 -2
  11. package/cli/repl/server/connection.d.ts +2 -0
  12. package/cli/repl/server/connection.js +40 -31
  13. package/cli/script-core/summarizer-core.js +13 -32
  14. package/cli/wiki.d.ts +2 -1
  15. package/cli/wiki.js +2 -0
  16. package/config.d.ts +13 -0
  17. package/config.js +8 -0
  18. package/control-flow/semantic-cfg-guided-visitor.js +1 -0
  19. package/core/steps/pipeline/default-pipelines.d.ts +146 -146
  20. package/data/pkgdb/pkgdb-latest.json.br +0 -0
  21. package/data/pkgdb/pkgdb-tiny.json.br +0 -0
  22. package/dataflow/environments/append.d.ts +1 -2
  23. package/dataflow/environments/append.js +3 -10
  24. package/dataflow/environments/apply-kill.d.ts +21 -0
  25. package/dataflow/environments/apply-kill.js +155 -0
  26. package/dataflow/environments/built-in-proc-name.d.ts +2 -0
  27. package/dataflow/environments/built-in-proc-name.js +2 -0
  28. package/dataflow/environments/built-in.d.ts +2 -0
  29. package/dataflow/environments/built-in.js +2 -0
  30. package/dataflow/environments/default-builtin-config.d.ts +63 -3
  31. package/dataflow/environments/default-builtin-config.js +40 -8
  32. package/dataflow/environments/environment.d.ts +49 -32
  33. package/dataflow/environments/environment.js +133 -18
  34. package/dataflow/environments/identifier.d.ts +10 -0
  35. package/dataflow/environments/identifier.js +23 -0
  36. package/dataflow/environments/overwrite.js +2 -10
  37. package/dataflow/environments/resolve-by-name.d.ts +1 -1
  38. package/dataflow/environments/resolve-by-name.js +10 -2
  39. package/dataflow/environments/scoping.d.ts +9 -2
  40. package/dataflow/environments/scoping.js +15 -2
  41. package/dataflow/extractor.js +23 -2
  42. package/dataflow/graph/df-helper.d.ts +8 -0
  43. package/dataflow/graph/df-helper.js +8 -0
  44. package/dataflow/graph/graph.d.ts +4 -1
  45. package/dataflow/graph/graph.js +5 -1
  46. package/dataflow/info.d.ts +26 -0
  47. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +7 -5
  48. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +19 -0
  49. package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +1 -8
  50. package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +7 -13
  51. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +9 -48
  52. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +30 -47
  53. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +17 -0
  54. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +6 -1
  55. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +2 -2
  56. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +8 -1
  57. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +9 -0
  58. package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +37 -3
  59. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +391 -21
  60. package/dataflow/internal/process/functions/call/built-in/built-in-rm.d.ts +2 -1
  61. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +131 -48
  62. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.d.ts +25 -0
  63. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +94 -0
  64. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +10 -3
  65. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +30 -0
  66. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +279 -0
  67. package/dataflow/internal/process/functions/call/named-call-handling.d.ts +1 -1
  68. package/dataflow/internal/process/functions/call/named-call-handling.js +17 -0
  69. package/documentation/data/faq/faqs.js +3 -0
  70. package/documentation/data/interface/doc-writing-code.js +4 -80
  71. package/documentation/doc-util/doc-structure.js +1 -2
  72. package/documentation/wiki-core.js +2 -1
  73. package/documentation/wiki-dataflow-graph.js +35 -1
  74. package/documentation/wiki-interface.js +3 -2
  75. package/documentation/wiki-linter.js +2 -0
  76. package/documentation/wiki-overview.js +1 -14
  77. package/documentation/wiki-package-database.d.ts +9 -0
  78. package/documentation/wiki-package-database.js +63 -0
  79. package/documentation/wiki-query.js +1 -0
  80. package/linter/linter-rules.d.ts +23 -0
  81. package/linter/linter-rules.js +3 -1
  82. package/linter/rules/absolute-path.js +2 -1
  83. package/linter/rules/undefined-symbol.d.ts +39 -0
  84. package/linter/rules/undefined-symbol.js +80 -0
  85. package/package.json +3 -4
  86. package/project/cache/flowr-analyzer-cache.d.ts +2 -0
  87. package/project/cache/flowr-analyzer-cache.js +9 -1
  88. package/project/context/flowr-analyzer-dependencies-context.d.ts +16 -8
  89. package/project/context/flowr-analyzer-dependencies-context.js +36 -4
  90. package/project/context/flowr-analyzer-environment-context.d.ts +2 -4
  91. package/project/context/flowr-analyzer-environment-context.js +3 -4
  92. package/project/context/flowr-analyzer-files-context.d.ts +1 -0
  93. package/project/context/flowr-file.d.ts +2 -0
  94. package/project/context/flowr-file.js +2 -0
  95. package/project/flowr-analyzer-builder.js +3 -0
  96. package/project/flowr-analyzer.d.ts +2 -1
  97. package/project/flowr-analyzer.js +3 -1
  98. package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +13 -15
  99. package/project/plugins/file-plugins/files/flowr-namespace-file.js +36 -13
  100. package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.d.ts +27 -0
  101. package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.js +41 -0
  102. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.d.ts +18 -0
  103. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +62 -0
  104. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin.d.ts +63 -0
  105. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin.js +174 -0
  106. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.d.ts +10 -0
  107. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.js +6 -0
  108. package/project/plugins/package-version-plugins/package.d.ts +3 -0
  109. package/project/plugins/package-version-plugins/package.js +12 -0
  110. package/project/plugins/package-version-plugins/pkgdb.d.ts +133 -0
  111. package/project/plugins/package-version-plugins/pkgdb.js +370 -0
  112. package/project/plugins/plugin-registry.d.ts +4 -1
  113. package/project/plugins/plugin-registry.js +7 -0
  114. package/queries/catalog/call-context-query/call-context-query-executor.js +8 -0
  115. package/queries/catalog/call-context-query/call-context-query-format.d.ts +2 -0
  116. package/queries/catalog/call-context-query/call-context-query-format.js +1 -0
  117. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +8 -0
  118. package/queries/catalog/dependencies-query/dependencies-query-executor.js +31 -3
  119. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +3 -1
  120. package/queries/catalog/dependencies-query/dependencies-query-format.js +3 -2
  121. package/queries/catalog/dependencies-query/function-info/function-info.d.ts +1 -1
  122. package/queries/catalog/dependencies-query/function-info/other-path-functions.d.ts +2 -0
  123. package/queries/catalog/dependencies-query/function-info/other-path-functions.js +27 -0
  124. package/queries/catalog/dependencies-query/function-info/read-functions.js +5 -4
  125. package/queries/catalog/dependencies-query/function-info/visualize-functions.js +3 -1
  126. package/queries/catalog/linter-query/linter-query-executor.js +1 -0
  127. package/r-bridge/data/data.d.ts +2 -2
  128. package/r-bridge/data/data.js +2 -2
  129. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +13 -4
  130. package/search/search-executor/search-enrichers.d.ts +1 -1
  131. package/search/search-executor/search-enrichers.js +7 -4
  132. package/util/mermaid/mermaid.d.ts +4 -0
  133. package/util/mermaid/mermaid.js +8 -1
  134. package/util/version.js +10 -2
  135. package/cli/common/features.d.ts +0 -9
  136. package/cli/common/features.js +0 -35
  137. package/cli/script-core/statistics-core.d.ts +0 -6
  138. package/cli/script-core/statistics-core.js +0 -104
  139. package/cli/script-core/statistics-helper-core.d.ts +0 -6
  140. package/cli/script-core/statistics-helper-core.js +0 -86
  141. package/cli/statistics-app.d.ts +0 -11
  142. package/cli/statistics-app.js +0 -16
  143. package/cli/statistics-helper-app.d.ts +0 -11
  144. package/cli/statistics-helper-app.js +0 -14
  145. package/statistics/features/common-syntax-probability.d.ts +0 -38
  146. package/statistics/features/common-syntax-probability.js +0 -169
  147. package/statistics/features/feature.d.ts +0 -179
  148. package/statistics/features/feature.js +0 -38
  149. package/statistics/features/post-processing.d.ts +0 -18
  150. package/statistics/features/post-processing.js +0 -26
  151. package/statistics/features/supported/assignments/assignments.d.ts +0 -12
  152. package/statistics/features/supported/assignments/assignments.js +0 -56
  153. package/statistics/features/supported/assignments/post-process.d.ts +0 -6
  154. package/statistics/features/supported/assignments/post-process.js +0 -126
  155. package/statistics/features/supported/comments/comments.d.ts +0 -18
  156. package/statistics/features/supported/comments/comments.js +0 -143
  157. package/statistics/features/supported/comments/post-process.d.ts +0 -6
  158. package/statistics/features/supported/comments/post-process.js +0 -51
  159. package/statistics/features/supported/control-flow/control-flow.d.ts +0 -17
  160. package/statistics/features/supported/control-flow/control-flow.js +0 -69
  161. package/statistics/features/supported/control-flow/post-process.d.ts +0 -6
  162. package/statistics/features/supported/control-flow/post-process.js +0 -66
  163. package/statistics/features/supported/data-access/data-access.d.ts +0 -15
  164. package/statistics/features/supported/data-access/data-access.js +0 -122
  165. package/statistics/features/supported/data-access/post-process.d.ts +0 -6
  166. package/statistics/features/supported/data-access/post-process.js +0 -108
  167. package/statistics/features/supported/defined-functions/defined-functions.d.ts +0 -34
  168. package/statistics/features/supported/defined-functions/defined-functions.js +0 -145
  169. package/statistics/features/supported/defined-functions/post-process.d.ts +0 -6
  170. package/statistics/features/supported/defined-functions/post-process.js +0 -168
  171. package/statistics/features/supported/expression-list/post-process.d.ts +0 -6
  172. package/statistics/features/supported/expression-list/post-process.js +0 -45
  173. package/statistics/features/supported/expression-list/statistics-expression-list.d.ts +0 -9
  174. package/statistics/features/supported/expression-list/statistics-expression-list.js +0 -37
  175. package/statistics/features/supported/loops/loops.d.ts +0 -20
  176. package/statistics/features/supported/loops/loops.js +0 -81
  177. package/statistics/features/supported/loops/post-process.d.ts +0 -6
  178. package/statistics/features/supported/loops/post-process.js +0 -73
  179. package/statistics/features/supported/used-functions/post-process.d.ts +0 -6
  180. package/statistics/features/supported/used-functions/post-process.js +0 -176
  181. package/statistics/features/supported/used-functions/used-functions.d.ts +0 -24
  182. package/statistics/features/supported/used-functions/used-functions.js +0 -99
  183. package/statistics/features/supported/used-packages/post-process.d.ts +0 -6
  184. package/statistics/features/supported/used-packages/post-process.js +0 -122
  185. package/statistics/features/supported/used-packages/used-packages.d.ts +0 -16
  186. package/statistics/features/supported/used-packages/used-packages.js +0 -140
  187. package/statistics/features/supported/values/post-process.d.ts +0 -6
  188. package/statistics/features/supported/values/post-process.js +0 -73
  189. package/statistics/features/supported/values/values.d.ts +0 -14
  190. package/statistics/features/supported/values/values.js +0 -111
  191. package/statistics/features/supported/variables/post-process.d.ts +0 -15
  192. package/statistics/features/supported/variables/post-process.js +0 -126
  193. package/statistics/features/supported/variables/variables.d.ts +0 -15
  194. package/statistics/features/supported/variables/variables.js +0 -62
  195. package/statistics/meta-statistics.d.ts +0 -32
  196. package/statistics/meta-statistics.js +0 -16
  197. package/statistics/output/file-provider.d.ts +0 -36
  198. package/statistics/output/file-provider.js +0 -96
  199. package/statistics/output/print-stats.d.ts +0 -29
  200. package/statistics/output/print-stats.js +0 -81
  201. package/statistics/output/statistics-file.d.ts +0 -36
  202. package/statistics/output/statistics-file.js +0 -68
  203. package/statistics/statistics.d.ts +0 -29
  204. package/statistics/statistics.js +0 -108
  205. package/statistics/summarizer/auto-detect.d.ts +0 -5
  206. package/statistics/summarizer/auto-detect.js +0 -34
  207. package/statistics/summarizer/first-phase/process.d.ts +0 -6
  208. package/statistics/summarizer/first-phase/process.js +0 -81
  209. package/statistics/summarizer/post-process/clusterer.d.ts +0 -25
  210. package/statistics/summarizer/post-process/clusterer.js +0 -40
  211. package/statistics/summarizer/post-process/file-based-count.d.ts +0 -16
  212. package/statistics/summarizer/post-process/file-based-count.js +0 -47
  213. package/statistics/summarizer/post-process/histogram.d.ts +0 -57
  214. package/statistics/summarizer/post-process/histogram.js +0 -126
  215. package/statistics/summarizer/post-process/post-process-output.d.ts +0 -14
  216. package/statistics/summarizer/post-process/post-process-output.js +0 -102
  217. package/statistics/summarizer/second-phase/process.d.ts +0 -15
  218. package/statistics/summarizer/second-phase/process.js +0 -118
  219. package/statistics/summarizer/summarizer.d.ts +0 -34
  220. package/statistics/summarizer/summarizer.js +0 -141
@@ -5,8 +5,7 @@ const environment_1 = require("../../dataflow/environments/environment");
5
5
  const built_in_config_1 = require("../../dataflow/environments/built-in-config");
6
6
  const fingerprint_1 = require("../../slicing/static/fingerprint");
7
7
  /**
8
- * This context is responsible for providing the built-in environment.
9
- * It creates the built-in environment based on the configuration provided in the {@link FlowrAnalyzerContext}.
8
+ * Provides the built-in environment, created from the {@link FlowrAnalyzerContext} configuration.
10
9
  */
11
10
  class FlowrAnalyzerEnvironmentContext {
12
11
  name = 'flowr-analyzer-environment-context';
@@ -29,7 +28,7 @@ class FlowrAnalyzerEnvironmentContext {
29
28
  }
30
29
  makeCleanEnv() {
31
30
  return {
32
- current: new environment_1.Environment(this.builtInEnv),
31
+ current: new environment_1.Environment(this.builtInEnv).asGlobal(),
33
32
  level: 0
34
33
  };
35
34
  }
@@ -41,7 +40,7 @@ class FlowrAnalyzerEnvironmentContext {
41
40
  }
42
41
  makeCleanEnvWithEmptyBuiltIns() {
43
42
  return {
44
- current: new environment_1.Environment(this.emptyBuiltInEnv),
43
+ current: new environment_1.Environment(this.emptyBuiltInEnv).asGlobal(),
45
44
  level: 0
46
45
  };
47
46
  }
@@ -25,6 +25,7 @@ export type RoleBasedFiles = {
25
25
  [FileRole.Vignette]: FlowrFileProvider[];
26
26
  [FileRole.Test]: FlowrFileProvider[];
27
27
  [FileRole.License]: FlowrFileProvider[];
28
+ [FileRole.VirtualEnv]: FlowrFileProvider[];
28
29
  [FileRole.Source]: FlowrFileProvider[];
29
30
  [FileRole.Data]: FlowrFileProvider[];
30
31
  [FileRole.Other]: FlowrFileProvider[];
@@ -25,6 +25,8 @@ export declare enum FileRole {
25
25
  Data = "data",
26
26
  /** Signals separate license files, but please note, that DESCRIPTION files may contain license info too */
27
27
  License = "license",
28
+ /** Files describing a project's virtual/pinned package environment, e.g., `renv.lock` or `rv.lock`. */
29
+ VirtualEnv = "virtual-env",
28
30
  /**
29
31
  * Catch-all for any file that provides usable R source code to incorporate into the analysis.
30
32
  * Please note, that the loading order/inclusion and even potential relevance of these source files
@@ -26,6 +26,8 @@ var FileRole;
26
26
  FileRole["Data"] = "data";
27
27
  /** Signals separate license files, but please note, that DESCRIPTION files may contain license info too */
28
28
  FileRole["License"] = "license";
29
+ /** Files describing a project's virtual/pinned package environment, e.g., `renv.lock` or `rv.lock`. */
30
+ FileRole["VirtualEnv"] = "virtual-env";
29
31
  /**
30
32
  * Catch-all for any file that provides usable R source code to incorporate into the analysis.
31
33
  * Please note, that the loading order/inclusion and even potential relevance of these source files
@@ -159,6 +159,9 @@ class FlowrAnalyzerBuilder {
159
159
  buildSync() {
160
160
  (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');
161
161
  const context = new flowr_analyzer_context_1.FlowrAnalyzerContext(this.flowrConfig, this.plugins);
162
+ if (this.flowrConfig.solver.eagerlyLoadPackageDatabase) {
163
+ context.deps.eagerlyLoadPackageDatabases();
164
+ }
162
165
  const cache = flowr_analyzer_cache_1.FlowrAnalyzerCache.create({
163
166
  parser: this.parser,
164
167
  context,
@@ -197,7 +197,8 @@ export declare class FlowrAnalyzer<Parser extends KnownParser = KnownParser> imp
197
197
  query<Types extends SupportedQueryTypes = SupportedQueryTypes>(query: Queries<Types>): Promise<QueryResults<Types>>;
198
198
  runSearch<Search extends FlowrSearchLike>(search: Search): Promise<GetSearchElements<SearchOutput<Search>>>;
199
199
  /**
200
- * Close the parser if it was created by this builder. This is only required if you rely on an RShell/remote engine.
200
+ * Free the cached analyses (including any WASM-backed parse trees) and close the parser.
201
+ * Closing is only required for an RShell/remote engine, but this also frees the cached parse trees.
201
202
  */
202
203
  close(): boolean | void;
203
204
  }
@@ -146,9 +146,11 @@ class FlowrAnalyzer {
146
146
  return (0, flowr_search_executor_1.runSearch)(search, this);
147
147
  }
148
148
  /**
149
- * Close the parser if it was created by this builder. This is only required if you rely on an RShell/remote engine.
149
+ * Free the cached analyses (including any WASM-backed parse trees) and close the parser.
150
+ * Closing is only required for an RShell/remote engine, but this also frees the cached parse trees.
150
151
  */
151
152
  close() {
153
+ this.cache.reset();
152
154
  return this.parser?.close();
153
155
  }
154
156
  }
@@ -10,10 +10,8 @@ export interface NamespaceInfo {
10
10
  exportedPatterns: string[];
11
11
  importedPackages: Map<string, string[] | 'all'>;
12
12
  loadsWithSideEffects: boolean;
13
- /**
14
- * This will only be present in complex parsed NAMESPACE files and tell you
15
- * about which parts are only active with given conditions!
16
- */
13
+ callable: string[];
14
+ /** Present only in complex parsed NAMESPACE files. Maps conditions to the parts they gate. */
17
15
  conditional?: Map<RNode<ParentInformation>, NamespaceInfo>;
18
16
  }
19
17
  export interface NamespaceFormat {
@@ -21,20 +19,15 @@ export interface NamespaceFormat {
21
19
  [packageName: string]: NamespaceInfo;
22
20
  }
23
21
  /**
24
- * This decorates a text file and provides access to its content in the {@link NamespaceFormat}.
25
- * Namespace files can be parsed in a simple mode which is much quicker, but does not support `if`/other R-constructs!
22
+ * Decorates a text file to expose its content as a {@link NamespaceFormat}.
23
+ * Simple parsing is quicker but does not support `if`/other R constructs.
26
24
  */
27
25
  export declare class FlowrNamespaceFile extends FlowrFile<NamespaceFormat> {
28
26
  private readonly wrapped;
29
27
  private readonly ctx;
30
- /**
31
- * Prefer the static {@link FlowrNamespaceFile.from} method to create instances of this class as it will not re-create if already a namespace file
32
- * and handle role assignments.
33
- */
28
+ /** Prefer {@link FlowrNamespaceFile.from}, which avoids re-wrapping and handles roles. */
34
29
  constructor(file: FlowrFileProvider, ctx?: FlowrAnalyzerContext);
35
- /**
36
- * Creates a {@link FlowrNamespaceFile} from a given {@link NamespaceFormat}, path and optional roles. This is useful if you already have the namespace content parsed and want to create a namespace file instance without re-parsing.
37
- */
30
+ /** Creates a {@link FlowrNamespaceFile} from an already-parsed {@link NamespaceFormat}. */
38
31
  static fromNamespaceFormat(fmt: NamespaceFormat, path: string, roles?: FileRole[]): FlowrNamespaceFile;
39
32
  /**
40
33
  * Loads and parses the content of the wrapped file in the {@link NamespaceFormat}.
@@ -50,8 +43,7 @@ export declare class FlowrNamespaceFile extends FlowrFile<NamespaceFormat> {
50
43
  */
51
44
  isExported(name: string, pkg?: string): boolean | RNode<ParentInformation>[];
52
45
  /**
53
- * Namespace file lifter, this does not re-create if already a namespace file
54
- * and handles role assignments.
46
+ * Lifts a file to a {@link FlowrNamespaceFile}, reusing it if already one and assigning roles.
55
47
  * @param file - The file to lift or return if already a namespace file
56
48
  * @param ctx - An optional analyzer context to use for complex parsing
57
49
  * @param role - An optional role to assign to the file
@@ -73,3 +65,9 @@ export declare function isExportedInNamespaceFormat(this: void, fmt: NamespaceFo
73
65
  * @param nsInfo - The namespace info to check in
74
66
  */
75
67
  export declare function isExportedInInfo(this: void, name: string, nsInfo: NamespaceInfo): boolean | RNode<ParentInformation>[];
68
+ /** All exported names of a namespace that can be referenced (functions, symbols, patterns and S3 methods as `generic.class`). */
69
+ export declare function getExportedNames(info: NamespaceInfo): string[];
70
+ /** The names a package makes callable: the explicitly configured {@link NamespaceInfo#callable} subset, or all exports (see {@link getExportedNames}) by default. */
71
+ export declare function getCallables(info: NamespaceInfo): string[];
72
+ /** Sets the given list of strings as callable functions */
73
+ export declare function setCallable(info: NamespaceInfo, func: string[]): NamespaceInfo;
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FlowrNamespaceFile = void 0;
4
4
  exports.isExportedInNamespaceFormat = isExportedInNamespaceFormat;
5
5
  exports.isExportedInInfo = isExportedInInfo;
6
+ exports.getExportedNames = getExportedNames;
7
+ exports.getCallables = getCallables;
8
+ exports.setCallable = setCallable;
6
9
  const flowr_file_1 = require("../../../context/flowr-file");
7
10
  const resolve_args_1 = require("../../../../abstract-interpretation/data-frame/resolve-args");
8
11
  const retriever_1 = require("../../../../r-bridge/retriever");
@@ -15,24 +18,19 @@ const make_argument_1 = require("../../../../dataflow/internal/process/functions
15
18
  const range_1 = require("../../../../util/range");
16
19
  const r_regex_1 = require("../../../../util/r-regex");
17
20
  /**
18
- * This decorates a text file and provides access to its content in the {@link NamespaceFormat}.
19
- * Namespace files can be parsed in a simple mode which is much quicker, but does not support `if`/other R-constructs!
21
+ * Decorates a text file to expose its content as a {@link NamespaceFormat}.
22
+ * Simple parsing is quicker but does not support `if`/other R constructs.
20
23
  */
21
24
  class FlowrNamespaceFile extends flowr_file_1.FlowrFile {
22
25
  wrapped;
23
26
  ctx;
24
- /**
25
- * Prefer the static {@link FlowrNamespaceFile.from} method to create instances of this class as it will not re-create if already a namespace file
26
- * and handle role assignments.
27
- */
27
+ /** Prefer {@link FlowrNamespaceFile.from}, which avoids re-wrapping and handles roles. */
28
28
  constructor(file, ctx) {
29
29
  super(file.path(), file.roles);
30
30
  this.wrapped = file;
31
31
  this.ctx = ctx;
32
32
  }
33
- /**
34
- * Creates a {@link FlowrNamespaceFile} from a given {@link NamespaceFormat}, path and optional roles. This is useful if you already have the namespace content parsed and want to create a namespace file instance without re-parsing.
35
- */
33
+ /** Creates a {@link FlowrNamespaceFile} from an already-parsed {@link NamespaceFormat}. */
36
34
  static fromNamespaceFormat(fmt, path, roles) {
37
35
  const file = new FlowrNamespaceFile(new flowr_file_1.FlowrTextFile(path, roles));
38
36
  file.setContent(fmt);
@@ -57,8 +55,7 @@ class FlowrNamespaceFile extends flowr_file_1.FlowrFile {
57
55
  return isExportedInNamespaceFormat(fmt, name, pkg);
58
56
  }
59
57
  /**
60
- * Namespace file lifter, this does not re-create if already a namespace file
61
- * and handles role assignments.
58
+ * Lifts a file to a {@link FlowrNamespaceFile}, reusing it if already one and assigning roles.
62
59
  * @param file - The file to lift or return if already a namespace file
63
60
  * @param ctx - An optional analyzer context to use for complex parsing
64
61
  * @param role - An optional role to assign to the file
@@ -99,7 +96,6 @@ function isExportedInInfo(name, nsInfo) {
99
96
  }
100
97
  }
101
98
  }
102
- // pattern
103
99
  for (const pattern of nsInfo.exportedPatterns) {
104
100
  const regex = (0, r_regex_1.parseRRegexPattern)(pattern);
105
101
  if (regex.test(name)) {
@@ -107,7 +103,6 @@ function isExportedInInfo(name, nsInfo) {
107
103
  }
108
104
  }
109
105
  if (nsInfo.conditional) {
110
- // nested with recursion
111
106
  for (const [cond, info] of nsInfo.conditional) {
112
107
  const res = isExportedInInfo(name, info);
113
108
  if (res === true) {
@@ -196,6 +191,30 @@ function parseNamespaceComplex(file, ctx) {
196
191
  }
197
192
  });
198
193
  }
194
+ /** All exported names of a namespace that can be referenced (functions, symbols, patterns and S3 methods as `generic.class`). */
195
+ function getExportedNames(info) {
196
+ const s3 = [];
197
+ for (const [g, methods] of info.exportS3Generics) {
198
+ for (const m of methods) {
199
+ s3.push(`${g}.${m}`);
200
+ }
201
+ }
202
+ return [...new Set([...info.exportedSymbols, ...info.exportedFunctions, ...info.exportedPatterns, ...s3])];
203
+ }
204
+ /** The names a package makes callable: the explicitly configured {@link NamespaceInfo#callable} subset, or all exports (see {@link getExportedNames}) by default. */
205
+ function getCallables(info) {
206
+ return info.callable.length > 0 ? info.callable : getExportedNames(info);
207
+ }
208
+ /** Sets the given list of strings as callable functions */
209
+ function setCallable(info, func) {
210
+ const all = new Set(getExportedNames(info));
211
+ for (const f of func) {
212
+ if (all.has(f)) {
213
+ info.callable.push(f);
214
+ }
215
+ }
216
+ return info;
217
+ }
199
218
  function handleConditionCall(idMap, cond, thenBranch, elseBranch) {
200
219
  const g = getEmptyNamespaceFormat();
201
220
  const condMap = g.current.conditional ?? new Map();
@@ -302,6 +321,7 @@ function handleUseDynLibCall(g, args) {
302
321
  exportS3Generics: new Map(),
303
322
  exportedPatterns: [],
304
323
  importedPackages: new Map(),
324
+ callable: [],
305
325
  loadsWithSideEffects: false,
306
326
  };
307
327
  }
@@ -325,6 +345,7 @@ function getEmptyNamespaceFormat() {
325
345
  exportS3Generics: new Map(),
326
346
  exportedPatterns: [],
327
347
  importedPackages: new Map(),
348
+ callable: [],
328
349
  loadsWithSideEffects: false,
329
350
  },
330
351
  };
@@ -388,6 +409,7 @@ function mergeNamespaceInfo(target, source) {
388
409
  }
389
410
  }
390
411
  return {
412
+ callable: [...target.callable, ...source.callable],
391
413
  exportedSymbols: [...target.exportedSymbols, ...source.exportedSymbols],
392
414
  exportedFunctions: [...target.exportedFunctions, ...source.exportedFunctions],
393
415
  exportS3Generics: mergedS3Generics,
@@ -447,6 +469,7 @@ function parseNamespaceSimple(file) {
447
469
  exportS3Generics: new Map(),
448
470
  exportedPatterns: [],
449
471
  importedPackages: new Map(),
472
+ callable: [],
450
473
  loadsWithSideEffects: false,
451
474
  };
452
475
  }
@@ -0,0 +1,27 @@
1
+ import { FlowrAnalyzerFilePlugin } from './flowr-analyzer-file-plugin';
2
+ import { SemVer } from 'semver';
3
+ import type { PathLike } from 'fs';
4
+ import type { FlowrAnalyzerContext } from '../../context/flowr-analyzer-context';
5
+ import type { FlowrFileProvider } from '../../context/flowr-file';
6
+ /**
7
+ * Tags a project's virtual-environment lockfiles (e.g. `renv.lock`, `rv.lock`) with the
8
+ * {@link FileRole.VirtualEnv} role, so the version plugins that read them (renv/rv) can look them up
9
+ * by role instead of scanning every project file.
10
+ */
11
+ export declare class FlowrAnalyzerVirtualEnvFilePlugin extends FlowrAnalyzerFilePlugin {
12
+ readonly name = "flowr-analyzer-virtualenv-files-plugin";
13
+ readonly description = "This plugin marks virtual-environment lockfiles (renv.lock, rv.lock).";
14
+ readonly version: SemVer;
15
+ private readonly pathPattern;
16
+ /**
17
+ * Creates a new instance of the virtual-environment file plugin.
18
+ * @param pathPattern - The pattern to identify lockfiles, see {@link VirtualEnvFilePattern} for the default.
19
+ */
20
+ constructor(pathPattern?: RegExp);
21
+ applies(file: PathLike): boolean;
22
+ /**
23
+ * Processes the given file, assigning it the {@link FileRole.VirtualEnv} role. The file may still be
24
+ * relevant to other plugins, so this returns the `true` flag to keep the loader chain going.
25
+ */
26
+ process(_ctx: FlowrAnalyzerContext, file: FlowrFileProvider): [FlowrFileProvider, true];
27
+ }
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FlowrAnalyzerVirtualEnvFilePlugin = void 0;
4
+ const flowr_analyzer_file_plugin_1 = require("./flowr-analyzer-file-plugin");
5
+ const semver_1 = require("semver");
6
+ const flowr_file_1 = require("../../context/flowr-file");
7
+ const built_in_source_1 = require("../../../dataflow/internal/process/functions/call/built-in/built-in-source");
8
+ /** Lockfiles pinning a project's package environment (`renv.lock`, `rv.lock`). */
9
+ const VirtualEnvFilePattern = /^(renv|rv)\.lock$/i;
10
+ /**
11
+ * Tags a project's virtual-environment lockfiles (e.g. `renv.lock`, `rv.lock`) with the
12
+ * {@link FileRole.VirtualEnv} role, so the version plugins that read them (renv/rv) can look them up
13
+ * by role instead of scanning every project file.
14
+ */
15
+ class FlowrAnalyzerVirtualEnvFilePlugin extends flowr_analyzer_file_plugin_1.FlowrAnalyzerFilePlugin {
16
+ name = 'flowr-analyzer-virtualenv-files-plugin';
17
+ description = 'This plugin marks virtual-environment lockfiles (renv.lock, rv.lock).';
18
+ version = new semver_1.SemVer('0.1.0');
19
+ pathPattern;
20
+ /**
21
+ * Creates a new instance of the virtual-environment file plugin.
22
+ * @param pathPattern - The pattern to identify lockfiles, see {@link VirtualEnvFilePattern} for the default.
23
+ */
24
+ constructor(pathPattern = VirtualEnvFilePattern) {
25
+ super();
26
+ this.pathPattern = pathPattern;
27
+ }
28
+ applies(file) {
29
+ return this.pathPattern.test((0, built_in_source_1.platformBasename)(file.toString()));
30
+ }
31
+ /**
32
+ * Processes the given file, assigning it the {@link FileRole.VirtualEnv} role. The file may still be
33
+ * relevant to other plugins, so this returns the `true` flag to keep the loader chain going.
34
+ */
35
+ process(_ctx, file) {
36
+ file.assignRole(flowr_file_1.FileRole.VirtualEnv);
37
+ return [file, true];
38
+ }
39
+ }
40
+ exports.FlowrAnalyzerVirtualEnvFilePlugin = FlowrAnalyzerVirtualEnvFilePlugin;
41
+ //# sourceMappingURL=flowr-analyzer-virtualenv-file-plugin.js.map
@@ -0,0 +1,18 @@
1
+ import { FlowrAnalyzerPackageVersionsPlugin } from './flowr-analyzer-package-versions-plugin';
2
+ import { SemVer } from 'semver';
3
+ import type { FlowrAnalyzerContext } from '../../context/flowr-analyzer-context';
4
+ export declare const lockfileLog: import("tslog").Logger<import("tslog").ILogObj>;
5
+ /** Reads package versions from an `renv.lock` (JSON). renv pins are exact. */
6
+ export declare class FlowrAnalyzerPackageVersionsRenvPlugin extends FlowrAnalyzerPackageVersionsPlugin {
7
+ readonly name = "flowr-analyzer-package-versions-renv-plugin";
8
+ readonly description = "Extracts package versions from an renv.lock lockfile.";
9
+ readonly version: SemVer;
10
+ process(ctx: FlowrAnalyzerContext): void;
11
+ }
12
+ /** Reads package versions from an `rv.lock` (the resolved rv project lockfile, TOML). */
13
+ export declare class FlowrAnalyzerPackageVersionsRvPlugin extends FlowrAnalyzerPackageVersionsPlugin {
14
+ readonly name = "flowr-analyzer-package-versions-rv-plugin";
15
+ readonly description = "Extracts package versions from an rv.lock lockfile.";
16
+ readonly version: SemVer;
17
+ process(ctx: FlowrAnalyzerContext): void;
18
+ }
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FlowrAnalyzerPackageVersionsRvPlugin = exports.FlowrAnalyzerPackageVersionsRenvPlugin = exports.lockfileLog = void 0;
4
+ const flowr_analyzer_package_versions_plugin_1 = require("./flowr-analyzer-package-versions-plugin");
5
+ const semver_1 = require("semver");
6
+ const package_1 = require("./package");
7
+ const flowr_file_1 = require("../../context/flowr-file");
8
+ const built_in_source_1 = require("../../../dataflow/internal/process/functions/call/built-in/built-in-source");
9
+ const log_1 = require("../../../util/log");
10
+ exports.lockfileLog = log_1.log.getSubLogger({ name: 'flowr-analyzer-package-versions-lockfile-plugin' });
11
+ /** The {@link FileRole.VirtualEnv} lockfiles named `name` (e.g. `renv.lock`), collected by role like the DESCRIPTION reader. */
12
+ function virtualEnvFiles(ctx, name) {
13
+ return ctx.files.getFilesByRole(flowr_file_1.FileRole.VirtualEnv).filter(f => (0, built_in_source_1.platformBasename)(f.path()) === name);
14
+ }
15
+ function pin(ctx, name, version) {
16
+ const range = package_1.Package.parsePackageVersionRange(undefined, version);
17
+ ctx.deps.addDependency(new package_1.Package({ name, versionConstraints: range ? [range] : undefined }));
18
+ }
19
+ /** Reads package versions from an `renv.lock` (JSON). renv pins are exact. */
20
+ class FlowrAnalyzerPackageVersionsRenvPlugin extends flowr_analyzer_package_versions_plugin_1.FlowrAnalyzerPackageVersionsPlugin {
21
+ name = 'flowr-analyzer-package-versions-renv-plugin';
22
+ description = 'Extracts package versions from an renv.lock lockfile.';
23
+ version = new semver_1.SemVer('0.1.0');
24
+ process(ctx) {
25
+ for (const file of virtualEnvFiles(ctx, 'renv.lock')) {
26
+ let lock;
27
+ try {
28
+ lock = JSON.parse(file.content().toString());
29
+ }
30
+ catch (e) {
31
+ exports.lockfileLog.warn(`Could not parse renv.lock: ${e.message}`);
32
+ continue;
33
+ }
34
+ for (const [pkg, meta] of Object.entries(lock.Packages ?? {})) {
35
+ if (typeof meta?.Version === 'string') {
36
+ pin(ctx, pkg, meta.Version);
37
+ }
38
+ }
39
+ }
40
+ }
41
+ }
42
+ exports.FlowrAnalyzerPackageVersionsRenvPlugin = FlowrAnalyzerPackageVersionsRenvPlugin;
43
+ /** Reads package versions from an `rv.lock` (the resolved rv project lockfile, TOML). */
44
+ class FlowrAnalyzerPackageVersionsRvPlugin extends flowr_analyzer_package_versions_plugin_1.FlowrAnalyzerPackageVersionsPlugin {
45
+ name = 'flowr-analyzer-package-versions-rv-plugin';
46
+ description = 'Extracts package versions from an rv.lock lockfile.';
47
+ version = new semver_1.SemVer('0.1.0');
48
+ process(ctx) {
49
+ for (const file of virtualEnvFiles(ctx, 'rv.lock')) {
50
+ // rv.lock is TOML with repeated `[[packages]]` tables carrying `name`/`version`
51
+ for (const block of file.content().toString().split(/\[\[packages\]\]/).slice(1)) {
52
+ const name = /^\s*name\s*=\s*"([^"]+)"/m.exec(block)?.[1];
53
+ const version = /^\s*version\s*=\s*"([^"]+)"/m.exec(block)?.[1];
54
+ if (name && version) {
55
+ pin(ctx, name, version);
56
+ }
57
+ }
58
+ }
59
+ }
60
+ }
61
+ exports.FlowrAnalyzerPackageVersionsRvPlugin = FlowrAnalyzerPackageVersionsRvPlugin;
62
+ //# sourceMappingURL=flowr-analyzer-package-versions-lockfile-plugin.js.map
@@ -0,0 +1,63 @@
1
+ import { FlowrAnalyzerPackageVersionsPlugin, type PkgDbLoadedInfo } from './flowr-analyzer-package-versions-plugin';
2
+ import { SemVer } from 'semver';
3
+ import type { FlowrAnalyzerContext } from '../../context/flowr-analyzer-context';
4
+ import { PkgDatabase, type PkgDb } from './pkgdb';
5
+ /** the plugin's instance name (pass to `unregisterPlugins` to disable the default pkgdb resolver) */
6
+ export declare const PkgDbPluginName = "flowr-analyzer-package-versions-pkgdb-plugin";
7
+ export declare const pkgDbLog: import("tslog").Logger<import("tslog").ILogObj>;
8
+ /** a database, a parsed object, or a local file path */
9
+ export type PkgDbSource = PkgDatabase | PkgDb | string;
10
+ /**
11
+ * The database flattens S3 methods into the export list, so we recover the `generic -> classes` map for
12
+ * dispatch: an export `generic.class` is a method when the `generic` is itself exported (e.g. `print.foo`).
13
+ */
14
+ export declare function reconstructS3Generics(exported: readonly string[]): Map<string, string[]>;
15
+ /**
16
+ * Resolves `library(pkg)` / `use(pkg, fn)` from precomputed `flowr-pkgdb` databases: the one bundled
17
+ * with flowR plus any extra sources (constructor args or `$FLOWR_PKGDB`). Extra sources are consulted
18
+ * first, so they override the bundle; packages only in the bundle still resolve. Everything is loaded
19
+ * lazily on the first miss (never touched if a project uses no external packages). On by default; opt
20
+ * out via `unregisterPlugins(PkgDbPluginName)` or `$FLOWR_DISABLE_DEFAULT_PKGDB`.
21
+ *
22
+ * A source may be an `http(s)` URL to a downloadable summary; call {@link preload} once at the
23
+ * analyzer boundary to fetch it, so resolution falls through to it for packages not in the bundle.
24
+ */
25
+ export declare class FlowrAnalyzerPackageVersionsPkgDbPlugin extends FlowrAnalyzerPackageVersionsPlugin {
26
+ readonly name = "flowr-analyzer-package-versions-pkgdb-plugin";
27
+ readonly description = "Resolves library exports from precomputed flowr-pkgdb databases.";
28
+ readonly version: SemVer;
29
+ /**
30
+ * Process-wide cache of parsed file databases, keyed by their source path, so a flowR session parses
31
+ * each file once. Parsing the bundled database is ~25ms and a fresh plugin instance is created per
32
+ * analyzer, so without this every analysis touching a `library()` call would re-parse the multi-MB file.
33
+ */
34
+ private static readonly fileCache;
35
+ private readonly extraSources;
36
+ private databases;
37
+ constructor(...sources: PkgDbSource[]);
38
+ process(ctx: FlowrAnalyzerContext): void;
39
+ /** Mount the databases up front (see `solver.eagerlyLoadPackageDatabase`) instead of on the first library load. */
40
+ preloadDatabasesSync(): void;
41
+ /** metadata of the databases currently loaded (the synchronously available, non-URL sources) */
42
+ loadedDatabases(): PkgDbLoadedInfo[];
43
+ /**
44
+ * Sources in priority order: explicit constructor sources, then `$FLOWR_PKGDB`, then the bundled
45
+ * default. The bundled default is skipped when `$FLOWR_DISABLE_DEFAULT_PKGDB` is set (explicit
46
+ * sources are always honored) - the env opt-out for the shipped database.
47
+ */
48
+ private sources;
49
+ private static isUrl;
50
+ /** synchronously loaded databases; remote (URL) summaries are only added by {@link preload}. */
51
+ private loadDatabases;
52
+ /**
53
+ * Download and load every source, including remote (URL) summaries. Call this once at the
54
+ * analyzer boundary to let `library()` resolution fall through to additional downloaded databases
55
+ * (e.g. the full `all` summary or a richer `latest`). Without it, only local sources are used.
56
+ */
57
+ preload(): Promise<void>;
58
+ private load;
59
+ private mustLoad;
60
+ /** Load a file source once per session, reusing the parsed database across analyzer instances. */
61
+ private static loadFileCached;
62
+ private resolve;
63
+ }