@eagleoutice/flowr 2.10.10 → 2.11.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 (223) hide show
  1. package/README.md +35 -27
  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 +2 -2
  9. package/cli/repl/commands/repl-commands.js +7 -6
  10. package/cli/repl/print-version.d.ts +3 -1
  11. package/cli/repl/print-version.js +21 -2
  12. package/cli/repl/server/connection.d.ts +2 -0
  13. package/cli/repl/server/connection.js +40 -31
  14. package/cli/script-core/summarizer-core.js +13 -32
  15. package/cli/wiki.d.ts +2 -1
  16. package/cli/wiki.js +2 -0
  17. package/config.d.ts +9 -0
  18. package/config.js +10 -0
  19. package/control-flow/semantic-cfg-guided-visitor.js +1 -0
  20. package/core/steps/pipeline/default-pipelines.d.ts +146 -146
  21. package/data/pkgdb/pkgdb-latest.json.br +0 -0
  22. package/data/pkgdb/pkgdb-tiny.json.br +0 -0
  23. package/dataflow/environments/append.d.ts +1 -2
  24. package/dataflow/environments/append.js +3 -10
  25. package/dataflow/environments/apply-kill.d.ts +21 -0
  26. package/dataflow/environments/apply-kill.js +155 -0
  27. package/dataflow/environments/built-in-proc-name.d.ts +2 -0
  28. package/dataflow/environments/built-in-proc-name.js +2 -0
  29. package/dataflow/environments/built-in.d.ts +2 -0
  30. package/dataflow/environments/built-in.js +2 -0
  31. package/dataflow/environments/default-builtin-config.d.ts +63 -3
  32. package/dataflow/environments/default-builtin-config.js +40 -8
  33. package/dataflow/environments/environment.d.ts +49 -32
  34. package/dataflow/environments/environment.js +133 -18
  35. package/dataflow/environments/identifier.d.ts +10 -0
  36. package/dataflow/environments/identifier.js +23 -0
  37. package/dataflow/environments/overwrite.js +2 -10
  38. package/dataflow/environments/resolve-by-name.d.ts +1 -1
  39. package/dataflow/environments/resolve-by-name.js +10 -2
  40. package/dataflow/environments/scoping.d.ts +9 -2
  41. package/dataflow/environments/scoping.js +15 -2
  42. package/dataflow/extractor.js +23 -2
  43. package/dataflow/graph/df-helper.d.ts +8 -0
  44. package/dataflow/graph/df-helper.js +8 -0
  45. package/dataflow/graph/graph.d.ts +4 -1
  46. package/dataflow/graph/graph.js +5 -1
  47. package/dataflow/info.d.ts +26 -0
  48. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +7 -5
  49. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +19 -0
  50. package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +1 -8
  51. package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +7 -13
  52. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +9 -48
  53. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +30 -47
  54. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +17 -0
  55. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +6 -1
  56. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +2 -2
  57. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +8 -1
  58. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +9 -0
  59. package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +37 -3
  60. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +391 -21
  61. package/dataflow/internal/process/functions/call/built-in/built-in-rm.d.ts +2 -1
  62. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +131 -48
  63. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.d.ts +25 -0
  64. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +94 -0
  65. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +10 -3
  66. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +30 -0
  67. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +279 -0
  68. package/dataflow/internal/process/functions/call/named-call-handling.d.ts +1 -1
  69. package/dataflow/internal/process/functions/call/named-call-handling.js +17 -0
  70. package/documentation/data/faq/faqs.js +3 -0
  71. package/documentation/data/interface/doc-writing-code.js +4 -80
  72. package/documentation/doc-util/doc-structure.js +1 -2
  73. package/documentation/wiki-core.js +2 -1
  74. package/documentation/wiki-dataflow-graph.js +35 -1
  75. package/documentation/wiki-interface.js +2 -2
  76. package/documentation/wiki-linter.js +2 -0
  77. package/documentation/wiki-overview.js +1 -14
  78. package/documentation/wiki-package-database.d.ts +9 -0
  79. package/documentation/wiki-package-database.js +63 -0
  80. package/documentation/wiki-query.js +1 -0
  81. package/linter/linter-rules.d.ts +23 -0
  82. package/linter/linter-rules.js +3 -1
  83. package/linter/rules/absolute-path.js +2 -1
  84. package/linter/rules/undefined-symbol.d.ts +39 -0
  85. package/linter/rules/undefined-symbol.js +80 -0
  86. package/package.json +4 -4
  87. package/project/cache/flowr-analyzer-cache.d.ts +2 -0
  88. package/project/cache/flowr-analyzer-cache.js +9 -1
  89. package/project/context/flowr-analyzer-dependencies-context.d.ts +16 -8
  90. package/project/context/flowr-analyzer-dependencies-context.js +39 -4
  91. package/project/context/flowr-analyzer-environment-context.d.ts +2 -4
  92. package/project/context/flowr-analyzer-environment-context.js +3 -4
  93. package/project/context/flowr-analyzer-files-context.d.ts +1 -0
  94. package/project/context/flowr-file.d.ts +2 -0
  95. package/project/context/flowr-file.js +2 -0
  96. package/project/flowr-analyzer-builder.js +3 -0
  97. package/project/flowr-analyzer.d.ts +2 -1
  98. package/project/flowr-analyzer.js +3 -1
  99. package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +13 -15
  100. package/project/plugins/file-plugins/files/flowr-namespace-file.js +36 -13
  101. package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.d.ts +27 -0
  102. package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.js +41 -0
  103. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.d.ts +18 -0
  104. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +62 -0
  105. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin.d.ts +63 -0
  106. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin.js +176 -0
  107. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.d.ts +10 -0
  108. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.js +6 -0
  109. package/project/plugins/package-version-plugins/package.d.ts +3 -0
  110. package/project/plugins/package-version-plugins/package.js +12 -0
  111. package/project/plugins/package-version-plugins/pkgdb.d.ts +133 -0
  112. package/project/plugins/package-version-plugins/pkgdb.js +370 -0
  113. package/project/plugins/plugin-registry.d.ts +4 -1
  114. package/project/plugins/plugin-registry.js +7 -0
  115. package/queries/catalog/call-context-query/call-context-query-executor.js +8 -0
  116. package/queries/catalog/call-context-query/call-context-query-format.d.ts +2 -0
  117. package/queries/catalog/call-context-query/call-context-query-format.js +1 -0
  118. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +8 -0
  119. package/queries/catalog/dependencies-query/dependencies-query-executor.js +31 -3
  120. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +3 -1
  121. package/queries/catalog/dependencies-query/dependencies-query-format.js +3 -2
  122. package/queries/catalog/dependencies-query/function-info/function-info.d.ts +1 -1
  123. package/queries/catalog/dependencies-query/function-info/other-path-functions.d.ts +2 -0
  124. package/queries/catalog/dependencies-query/function-info/other-path-functions.js +27 -0
  125. package/queries/catalog/dependencies-query/function-info/read-functions.js +5 -4
  126. package/queries/catalog/dependencies-query/function-info/visualize-functions.js +3 -1
  127. package/queries/catalog/linter-query/linter-query-executor.js +1 -0
  128. package/r-bridge/data/data.d.ts +2 -2
  129. package/r-bridge/data/data.js +2 -2
  130. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +13 -4
  131. package/search/search-executor/search-enrichers.d.ts +1 -1
  132. package/search/search-executor/search-enrichers.js +7 -4
  133. package/util/mermaid/mermaid.d.ts +4 -0
  134. package/util/mermaid/mermaid.js +8 -1
  135. package/util/text/ansi.d.ts +10 -1
  136. package/util/text/ansi.js +17 -4
  137. package/util/version.js +10 -2
  138. package/cli/common/features.d.ts +0 -9
  139. package/cli/common/features.js +0 -35
  140. package/cli/script-core/statistics-core.d.ts +0 -6
  141. package/cli/script-core/statistics-core.js +0 -104
  142. package/cli/script-core/statistics-helper-core.d.ts +0 -6
  143. package/cli/script-core/statistics-helper-core.js +0 -86
  144. package/cli/statistics-app.d.ts +0 -11
  145. package/cli/statistics-app.js +0 -16
  146. package/cli/statistics-helper-app.d.ts +0 -11
  147. package/cli/statistics-helper-app.js +0 -14
  148. package/statistics/features/common-syntax-probability.d.ts +0 -38
  149. package/statistics/features/common-syntax-probability.js +0 -169
  150. package/statistics/features/feature.d.ts +0 -179
  151. package/statistics/features/feature.js +0 -38
  152. package/statistics/features/post-processing.d.ts +0 -18
  153. package/statistics/features/post-processing.js +0 -26
  154. package/statistics/features/supported/assignments/assignments.d.ts +0 -12
  155. package/statistics/features/supported/assignments/assignments.js +0 -56
  156. package/statistics/features/supported/assignments/post-process.d.ts +0 -6
  157. package/statistics/features/supported/assignments/post-process.js +0 -126
  158. package/statistics/features/supported/comments/comments.d.ts +0 -18
  159. package/statistics/features/supported/comments/comments.js +0 -143
  160. package/statistics/features/supported/comments/post-process.d.ts +0 -6
  161. package/statistics/features/supported/comments/post-process.js +0 -51
  162. package/statistics/features/supported/control-flow/control-flow.d.ts +0 -17
  163. package/statistics/features/supported/control-flow/control-flow.js +0 -69
  164. package/statistics/features/supported/control-flow/post-process.d.ts +0 -6
  165. package/statistics/features/supported/control-flow/post-process.js +0 -66
  166. package/statistics/features/supported/data-access/data-access.d.ts +0 -15
  167. package/statistics/features/supported/data-access/data-access.js +0 -122
  168. package/statistics/features/supported/data-access/post-process.d.ts +0 -6
  169. package/statistics/features/supported/data-access/post-process.js +0 -108
  170. package/statistics/features/supported/defined-functions/defined-functions.d.ts +0 -34
  171. package/statistics/features/supported/defined-functions/defined-functions.js +0 -145
  172. package/statistics/features/supported/defined-functions/post-process.d.ts +0 -6
  173. package/statistics/features/supported/defined-functions/post-process.js +0 -168
  174. package/statistics/features/supported/expression-list/post-process.d.ts +0 -6
  175. package/statistics/features/supported/expression-list/post-process.js +0 -45
  176. package/statistics/features/supported/expression-list/statistics-expression-list.d.ts +0 -9
  177. package/statistics/features/supported/expression-list/statistics-expression-list.js +0 -37
  178. package/statistics/features/supported/loops/loops.d.ts +0 -20
  179. package/statistics/features/supported/loops/loops.js +0 -81
  180. package/statistics/features/supported/loops/post-process.d.ts +0 -6
  181. package/statistics/features/supported/loops/post-process.js +0 -73
  182. package/statistics/features/supported/used-functions/post-process.d.ts +0 -6
  183. package/statistics/features/supported/used-functions/post-process.js +0 -176
  184. package/statistics/features/supported/used-functions/used-functions.d.ts +0 -24
  185. package/statistics/features/supported/used-functions/used-functions.js +0 -99
  186. package/statistics/features/supported/used-packages/post-process.d.ts +0 -6
  187. package/statistics/features/supported/used-packages/post-process.js +0 -122
  188. package/statistics/features/supported/used-packages/used-packages.d.ts +0 -16
  189. package/statistics/features/supported/used-packages/used-packages.js +0 -140
  190. package/statistics/features/supported/values/post-process.d.ts +0 -6
  191. package/statistics/features/supported/values/post-process.js +0 -73
  192. package/statistics/features/supported/values/values.d.ts +0 -14
  193. package/statistics/features/supported/values/values.js +0 -111
  194. package/statistics/features/supported/variables/post-process.d.ts +0 -15
  195. package/statistics/features/supported/variables/post-process.js +0 -126
  196. package/statistics/features/supported/variables/variables.d.ts +0 -15
  197. package/statistics/features/supported/variables/variables.js +0 -62
  198. package/statistics/meta-statistics.d.ts +0 -32
  199. package/statistics/meta-statistics.js +0 -16
  200. package/statistics/output/file-provider.d.ts +0 -36
  201. package/statistics/output/file-provider.js +0 -96
  202. package/statistics/output/print-stats.d.ts +0 -29
  203. package/statistics/output/print-stats.js +0 -81
  204. package/statistics/output/statistics-file.d.ts +0 -36
  205. package/statistics/output/statistics-file.js +0 -68
  206. package/statistics/statistics.d.ts +0 -29
  207. package/statistics/statistics.js +0 -108
  208. package/statistics/summarizer/auto-detect.d.ts +0 -5
  209. package/statistics/summarizer/auto-detect.js +0 -34
  210. package/statistics/summarizer/first-phase/process.d.ts +0 -6
  211. package/statistics/summarizer/first-phase/process.js +0 -81
  212. package/statistics/summarizer/post-process/clusterer.d.ts +0 -25
  213. package/statistics/summarizer/post-process/clusterer.js +0 -40
  214. package/statistics/summarizer/post-process/file-based-count.d.ts +0 -16
  215. package/statistics/summarizer/post-process/file-based-count.js +0 -47
  216. package/statistics/summarizer/post-process/histogram.d.ts +0 -57
  217. package/statistics/summarizer/post-process/histogram.js +0 -126
  218. package/statistics/summarizer/post-process/post-process-output.d.ts +0 -14
  219. package/statistics/summarizer/post-process/post-process-output.js +0 -102
  220. package/statistics/summarizer/second-phase/process.d.ts +0 -15
  221. package/statistics/summarizer/second-phase/process.js +0 -118
  222. package/statistics/summarizer/summarizer.d.ts +0 -34
  223. package/statistics/summarizer/summarizer.js +0 -141
@@ -21,16 +21,17 @@ const args_1 = require("../../../util/text/args");
21
21
  const assert_1 = require("../../../util/assert");
22
22
  const scripts_info_1 = require("../../common/scripts-info");
23
23
  const repl_query_1 = require("./repl-query");
24
+ const cmd = (name, f) => (0, ansi_1.color)(name, 6 /* Colors.Cyan */, f, { style: 1 /* FontStyles.Bold */ });
24
25
  function printHelpForScript(script, f, starredVersion) {
25
- let base = ` ${(0, ansi_1.bold)(padCmd(':' + script[0] + (starredVersion ? '[*]' : '')), f)}${script[1].description}`;
26
+ let base = ` ${cmd(padCmd(':' + script[0] + (starredVersion ? '[*]' : '')), f)}${script[1].description}`;
26
27
  if (starredVersion) {
27
- base += ` (star: ${starredVersion.description})`;
28
+ base += ` ${(0, ansi_1.italic)(`(star: ${starredVersion.description})`, f)}`;
28
29
  }
29
30
  if (script[1].aliases.length === 0) {
30
31
  return base;
31
32
  }
32
33
  const aliases = script[1].aliases;
33
- return `${base} (alias${aliases.length > 1 ? 'es' : ''}: ${aliases.map(a => (0, ansi_1.bold)(':' + a, f)).join(', ')})`;
34
+ return `${base} ${(0, ansi_1.italic)(`(alias${aliases.length > 1 ? 'es' : ''}:`, f)} ${aliases.map(a => cmd(':' + a, f)).join(', ')}${(0, ansi_1.italic)(')', f)}`;
34
35
  }
35
36
  function printCommandHelp(formatter) {
36
37
  const scriptHelp = [];
@@ -62,13 +63,13 @@ There are the following basic commands:
62
63
  ${printCommandHelp(output.formatter)}
63
64
 
64
65
  Furthermore, you can directly call the following scripts which accept arguments. If you are unsure, try to add ${(0, ansi_1.italic)('--help', output.formatter)} after the command.
65
- ${Array.from(Object.entries(getReplCommands())).filter(([, { script }]) => script).map(([command, { description }]) => ` ${(0, ansi_1.bold)(padCmd(':' + command), output.formatter)}${description}`).sort().join('\n')}
66
+ ${Array.from(Object.entries(getReplCommands())).filter(([, { script }]) => script).map(([command, { description }]) => ` ${cmd(padCmd(':' + command), output.formatter)}${description}`).sort().join('\n')}
66
67
 
67
68
  You can combine commands by separating them with a semicolon ${(0, ansi_1.bold)(';', output.formatter)}.
68
69
 
69
70
  Commands that accept a file path support two path prefixes:
70
- ${(0, ansi_1.bold)('file://<path>', output.formatter)} run the command once on the given file or folder
71
- ${(0, ansi_1.bold)('watch://<path>', output.formatter)} re-run the command whenever the file (or any file in the folder) changes
71
+ ${(0, ansi_1.color)('file://<path>', 2 /* Colors.Green */, output.formatter, { style: 1 /* FontStyles.Bold */ })} run the command once on the given file or folder
72
+ ${(0, ansi_1.color)('watch://<path>', 3 /* Colors.Yellow */, output.formatter, { style: 1 /* FontStyles.Bold */ })} re-run the command whenever the file (or any file in the folder) changes
72
73
  Press Ctrl+C or enter any other command to leave watch mode.
73
74
  `);
74
75
  }
@@ -1,6 +1,8 @@
1
1
  import type { KnownParser } from '../../r-bridge/parser';
2
+ /** a short `, package database: <scope> <date>` suffix for the bundled database, or empty if none */
3
+ export declare function pkgDbReplSuffix(): string;
2
4
  /**
3
- * Returns a version string for the REPL including flowR and R version.
5
+ * Returns a version string for the REPL including flowR, R, and the package database in use.
4
6
  */
5
7
  export declare function versionReplString(parser: KnownParser): Promise<string>;
6
8
  /**
@@ -1,16 +1,35 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pkgDbReplSuffix = pkgDbReplSuffix;
3
4
  exports.versionReplString = versionReplString;
4
5
  exports.printVersionRepl = printVersionRepl;
5
6
  const version_1 = require("../../util/version");
7
+ const pkgdb_1 = require("../../project/plugins/package-version-plugins/pkgdb");
8
+ /** a short `, package database: <scope> <date>` suffix for the bundled database, or empty if none */
9
+ function pkgDbReplSuffix() {
10
+ try {
11
+ if (typeof process !== 'undefined' && process.env?.FLOWR_DISABLE_DEFAULT_PKGDB) {
12
+ return '';
13
+ }
14
+ const path = (0, pkgdb_1.defaultPkgDbPath)();
15
+ if (path === undefined) {
16
+ return '';
17
+ }
18
+ const db = pkgdb_1.PkgDatabase.fromFileSync(path);
19
+ return `, pkg-db: ${db.scope}/${db.content.date}`;
20
+ }
21
+ catch {
22
+ return '';
23
+ }
24
+ }
6
25
  /**
7
- * Returns a version string for the REPL including flowR and R version.
26
+ * Returns a version string for the REPL including flowR, R, and the package database in use.
8
27
  */
9
28
  async function versionReplString(parser) {
10
29
  const version = await (0, version_1.retrieveVersionInformation)(parser);
11
30
  const rVersion = version.r === 'none' ? '' : version.r === 'unknown' ? ', R version unknown' : `, R v${version.r}`;
12
31
  const treeSitterVer = parser.name === 'tree-sitter' ? `, R grammar v${parser.treeSitterVersion()}` : '';
13
- return `flowR repl using flowR v${version.flowr}${rVersion}${treeSitterVer} (${version.engine} engine)`;
32
+ return `flowR repl v${version.flowr}${rVersion}${treeSitterVer} (${version.engine} engine${pkgDbReplSuffix()})`;
14
33
  }
15
34
  /**
16
35
  * Prints the version information for the REPL including flowR and R version.
@@ -21,7 +21,9 @@ export declare class FlowRServerConnection {
21
21
  private readonly fileMap;
22
22
  constructor(socket: Socket, name: string, parser: KnownParser, allowRSessionAccess: boolean, config: FlowrConfig);
23
23
  private currentMessageBuffer;
24
+ private requestQueue;
24
25
  private handleData;
26
+ private dispatch;
25
27
  private handleFileAnalysisRequest;
26
28
  private invalidateTokens;
27
29
  private sendFileAnalysisResponse;
@@ -88,6 +88,8 @@ class FlowRServerConnection {
88
88
  this.allowRSessionAccess = allowRSessionAccess;
89
89
  }
90
90
  currentMessageBuffer = '';
91
+ /* requests of a single client share one analyzer, so we handle them one after another to avoid racing on it */
92
+ requestQueue = Promise.resolve();
91
93
  handleData(message) {
92
94
  if (!message.endsWith('\n')) {
93
95
  this.currentMessageBuffer += message;
@@ -104,27 +106,31 @@ class FlowRServerConnection {
104
106
  (0, validate_1.answerForValidationError)(this.socket, request);
105
107
  return;
106
108
  }
107
- switch (request.message.type) {
109
+ this.requestQueue = this.requestQueue
110
+ .then(() => this.dispatch(request.message))
111
+ .catch(e => {
112
+ this.logger.error(`[${this.name}] Error while handling request: ${String(e)}`);
113
+ });
114
+ }
115
+ dispatch(message) {
116
+ switch (message.type) {
108
117
  case 'request-file-analysis':
109
- void this.handleFileAnalysisRequest(request.message);
110
- break;
118
+ return this.handleFileAnalysisRequest(message);
111
119
  case 'request-slice':
112
- this.handleSliceRequest(request.message);
113
- break;
120
+ return this.handleSliceRequest(message);
114
121
  case 'request-repl-execution':
115
- this.handleRepl(request.message);
116
- break;
122
+ return this.handleRepl(message);
117
123
  case 'request-query':
118
- this.handleQueryRequest(request.message);
119
- break;
124
+ return this.handleQueryRequest(message);
120
125
  default:
121
126
  (0, send_1.sendMessage)(this.socket, {
122
- id: request.message.id,
127
+ id: message.id,
123
128
  type: 'error',
124
129
  fatal: true,
125
- reason: `The message type ${JSON.stringify(request.message.type ?? 'undefined')} is not supported.`
130
+ reason: `The message type ${JSON.stringify(message.type ?? 'undefined')} is not supported.`
126
131
  });
127
132
  this.socket.end();
133
+ return Promise.resolve();
128
134
  }
129
135
  }
130
136
  async handleFileAnalysisRequest(base) {
@@ -253,7 +259,7 @@ class FlowRServerConnection {
253
259
  }
254
260
  return analyzer;
255
261
  }
256
- handleSliceRequest(base) {
262
+ async handleSliceRequest(base) {
257
263
  const requestResult = (0, validate_1.validateMessage)(base, message_slice_1.requestSliceMessage);
258
264
  if (requestResult.type === 'error') {
259
265
  (0, validate_1.answerForValidationError)(this.socket, requestResult, base.id);
@@ -271,19 +277,21 @@ class FlowRServerConnection {
271
277
  });
272
278
  return;
273
279
  }
274
- void fileInformation.analyzer.query([{
275
- type: 'static-slice',
276
- criteria: request.criterion,
277
- noMagicComments: request.noMagicComments,
278
- direction: request.direction
279
- }]).then(result => {
280
+ try {
281
+ const result = await fileInformation.analyzer.query([{
282
+ type: 'static-slice',
283
+ criteria: request.criterion,
284
+ noMagicComments: request.noMagicComments,
285
+ direction: request.direction
286
+ }]);
280
287
  (0, send_1.sendMessage)(this.socket, {
281
288
  type: 'response-slice',
282
289
  id: request.id,
283
290
  results: Object.fromEntries(Object.entries(result)
284
291
  .filter(([k]) => default_pipelines_1.DEFAULT_SLICING_PIPELINE.steps.get(k)?.executed === 1 /* PipelineStepStage.OncePerRequest */))
285
292
  });
286
- }).catch(e => {
293
+ }
294
+ catch (e) {
287
295
  this.logger.error(`[${this.name}] Error while analyzing file for token ${request.filetoken}: ${String(e)}`);
288
296
  (0, send_1.sendMessage)(this.socket, {
289
297
  id: request.id,
@@ -291,9 +299,9 @@ class FlowRServerConnection {
291
299
  fatal: false,
292
300
  reason: `Error while analyzing file for token ${request.filetoken}: ${String(e)}`
293
301
  });
294
- });
302
+ }
295
303
  }
296
- handleRepl(base) {
304
+ async handleRepl(base) {
297
305
  const requestResult = (0, validate_1.validateMessage)(base, message_repl_1.requestExecuteReplExpressionMessage);
298
306
  if (requestResult.type === 'error') {
299
307
  (0, validate_1.answerForValidationError)(this.socket, requestResult, base.id);
@@ -312,18 +320,17 @@ class FlowRServerConnection {
312
320
  .setConfig(this.config)
313
321
  .setParser(this.parser)
314
322
  .buildSync();
315
- void (0, core_1.replProcessAnswer)(analyzer, {
323
+ await (0, core_1.replProcessAnswer)(analyzer, {
316
324
  formatter: request.ansi ? ansi_1.ansiFormatter : ansi_1.voidFormatter,
317
325
  stdout: msg => out('stdout', msg),
318
326
  stderr: msg => out('stderr', msg)
319
- }, request.expression, this.allowRSessionAccess).then(() => {
320
- (0, send_1.sendMessage)(this.socket, {
321
- type: 'end-repl-execution',
322
- id: request.id
323
- });
327
+ }, request.expression, this.allowRSessionAccess);
328
+ (0, send_1.sendMessage)(this.socket, {
329
+ type: 'end-repl-execution',
330
+ id: request.id
324
331
  });
325
332
  }
326
- handleQueryRequest(base) {
333
+ async handleQueryRequest(base) {
327
334
  const requestResult = (0, validate_1.validateMessage)(base, message_query_1.requestQueryMessage);
328
335
  if (requestResult.type === 'error') {
329
336
  (0, validate_1.answerForValidationError)(this.socket, requestResult, base.id);
@@ -341,13 +348,15 @@ class FlowRServerConnection {
341
348
  });
342
349
  return;
343
350
  }
344
- void Promise.resolve(fileInformation.analyzer.query(request.query)).then(results => {
351
+ try {
352
+ const results = await fileInformation.analyzer.query(request.query);
345
353
  (0, send_1.sendMessage)(this.socket, {
346
354
  type: 'response-query',
347
355
  id: request.id,
348
356
  results
349
357
  });
350
- }).catch(e => {
358
+ }
359
+ catch (e) {
351
360
  this.logger.error(`[${this.name}] Error while executing query: ${String(e)}`);
352
361
  (0, send_1.sendMessage)(this.socket, {
353
362
  id: request.id,
@@ -355,7 +364,7 @@ class FlowRServerConnection {
355
364
  fatal: false,
356
365
  reason: `Error while executing query: ${String(e)}`
357
366
  });
358
- });
367
+ }
359
368
  }
360
369
  }
361
370
  exports.FlowRServerConnection = FlowRServerConnection;
@@ -1,12 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.flowrScriptSummarizer = flowrScriptSummarizer;
4
- const summarizer_1 = require("../../statistics/summarizer/summarizer");
5
- const summarizer_2 = require("../../benchmark/summarizer/summarizer");
6
- const auto_detect_1 = require("../../statistics/summarizer/auto-detect");
7
- const feature_1 = require("../../statistics/features/feature");
4
+ const summarizer_1 = require("../../benchmark/summarizer/summarizer");
8
5
  function getBenchmarkSummarizer(options, outputBase) {
9
- return new summarizer_2.BenchmarkSummarizer({
6
+ return new summarizer_1.BenchmarkSummarizer({
10
7
  graphOutputPath: options.graph ? `${outputBase}-graph.json` : undefined,
11
8
  inputPath: options.input,
12
9
  intermediateOutputPath: outputBase,
@@ -14,40 +11,24 @@ function getBenchmarkSummarizer(options, outputBase) {
14
11
  logger: console.log
15
12
  });
16
13
  }
17
- function getStatisticsSummarizer(options, outputBase) {
18
- return new summarizer_1.StatisticsSummarizer({
19
- inputPath: options.input,
20
- outputPath: `${outputBase}-final`,
21
- intermediateOutputPath: `${outputBase}-intermediate/`,
22
- projectSkip: options['project-skip'],
23
- featuresToUse: feature_1.allFeatureNames,
24
- logger: console.log
25
- });
26
- }
27
- async function retrieveSummarizer(options, outputBase) {
28
- const type = options.type === 'auto' ? await (0, auto_detect_1.detectSummarizationType)(options.input) : options.type;
29
- if (type === "benchmark" /* SummarizerType.Benchmark */) {
30
- console.log('Summarizing benchmark');
31
- return getBenchmarkSummarizer(options, outputBase);
32
- }
33
- else if (type === "statistics" /* SummarizerType.Statistics */) {
34
- console.log('Summarizing statistics');
35
- return getStatisticsSummarizer(options, outputBase);
36
- }
37
- else {
38
- console.error('Unknown type', type, 'either give "benchmark" or "statistics"');
39
- process.exit(1);
40
- }
41
- }
42
14
  /**
43
15
  * The core function for the 'flowr summarize' script.
44
16
  */
45
17
  async function flowrScriptSummarizer(options) {
18
+ if (options.type && options.type !== 'benchmark') {
19
+ console.error(`Warning: --type ${options.type} is no longer supported. The summarizer only produces benchmark summaries.`);
20
+ }
21
+ if (options.categorize) {
22
+ console.error('Warning: --categorize is no longer supported.');
23
+ }
24
+ if (options['project-skip'] && options['project-skip'] > 0) {
25
+ console.error(`Warning: --project-skip ${options['project-skip']} is no longer supported.`);
26
+ }
46
27
  const outputBase = (options.output ?? options.input).replace(/\.json$|\/$/, '-summary');
47
28
  console.log(`Writing outputs to base ${outputBase}`);
48
- const summarizer = await retrieveSummarizer(options, outputBase);
29
+ const summarizer = getBenchmarkSummarizer(options, outputBase);
49
30
  if (!options['ultimate-only']) {
50
- await summarizer.preparationPhase(options.categorize);
31
+ await summarizer.preparationPhase();
51
32
  }
52
33
  await summarizer.summarizePhase();
53
34
  }
package/cli/wiki.d.ts CHANGED
@@ -10,7 +10,8 @@ import { WikiSetup } from '../documentation/wiki-setup';
10
10
  import { WikiOverview } from '../documentation/wiki-overview';
11
11
  import { WikiAbsint } from '../documentation/wiki-absint';
12
12
  import { WikiCreateLintingRules } from '../documentation/wiki-create-linting-rules';
13
- export declare const AllWikiDocuments: [WikiFaq, WikiSearch, WikiCfg, WikiQuery, WikiOnboarding, WikiAnalyzer, WikiEngine, WikiNormalizedAst, WikiCore, WikiSetup, WikiOverview, WikiInterface, WikiDataflowGraph, WikiLintingAndTesting, WikiLinter, WikiAbsint, WikiCreateLintingRules, IssueLintingRule, DocReadme, DocCapabilities];
13
+ import { WikiPackageDatabase } from '../documentation/wiki-package-database';
14
+ export declare const AllWikiDocuments: [WikiFaq, WikiSearch, WikiCfg, WikiQuery, WikiOnboarding, WikiAnalyzer, WikiEngine, WikiNormalizedAst, WikiCore, WikiSetup, WikiOverview, WikiInterface, WikiDataflowGraph, WikiLintingAndTesting, WikiLinter, WikiAbsint, WikiCreateLintingRules, WikiPackageDatabase, IssueLintingRule, DocReadme, DocCapabilities];
14
15
  export type ValidWikiDocumentTargets = ReturnType<typeof AllWikiDocuments[number]['getTarget']>;
15
16
  export type ValidWikiDocumentTargetsNoSuffix = ValidWikiDocumentTargets extends `${infer Name}.${string}` ? Name : never;
16
17
  /**
package/cli/wiki.js CHANGED
@@ -28,6 +28,7 @@ const wiki_setup_1 = require("../documentation/wiki-setup");
28
28
  const wiki_overview_1 = require("../documentation/wiki-overview");
29
29
  const wiki_absint_1 = require("../documentation/wiki-absint");
30
30
  const wiki_create_linting_rules_1 = require("../documentation/wiki-create-linting-rules");
31
+ const wiki_package_database_1 = require("../documentation/wiki-package-database");
31
32
  exports.AllWikiDocuments = [
32
33
  new wiki_faq_1.WikiFaq(),
33
34
  new documentation_1.WikiSearch(),
@@ -46,6 +47,7 @@ exports.AllWikiDocuments = [
46
47
  new wiki_linter_1.WikiLinter(),
47
48
  new wiki_absint_1.WikiAbsint(),
48
49
  new wiki_create_linting_rules_1.WikiCreateLintingRules(),
50
+ new wiki_package_database_1.WikiPackageDatabase(),
49
51
  new issue_linting_rule_1.IssueLintingRule(),
50
52
  new doc_readme_1.DocReadme(),
51
53
  new documentation_1.DocCapabilities()
package/config.d.ts CHANGED
@@ -149,6 +149,15 @@ export interface FlowrConfig extends MergeableRecord {
149
149
  * When disabled all envir-style calls fall through to the conservative global treatment.
150
150
  */
151
151
  readonly trackEnvironments: boolean;
152
+ /** Resolving `library()`/`use()` exports from a package database (e.g. the bundled `flowr-pkgdb`). */
153
+ readonly pkgdb: {
154
+ /** Resolve library exports from a package database (default `true`); when `false` no database is consulted. */
155
+ readonly enabled: boolean;
156
+ /** Parse the database up front rather than on the first package load (default `false`, ignored if disabled). */
157
+ readonly eagerlyLoad: boolean;
158
+ /** Add a vertex for every export on load rather than on demand (default `false`); keeps the graph small. */
159
+ readonly eagerlyLoadExports: boolean;
160
+ };
152
161
  /** These keys are only intended for use within code, allowing to instrument the dataflow analyzer! */
153
162
  readonly instrument: {
154
163
  /**
package/config.js CHANGED
@@ -54,6 +54,9 @@ const defaultEngineConfigs = {
54
54
  exports.FlowrDefaultPlugins = [
55
55
  'file:description',
56
56
  'versions:description',
57
+ 'versions:pkgdb',
58
+ 'versions:renv',
59
+ 'versions:rv',
57
60
  'loading-order:description',
58
61
  'meta:description',
59
62
  'files:vignette',
@@ -65,6 +68,7 @@ exports.FlowrDefaultPlugins = [
65
68
  'file:namespace',
66
69
  'file:news',
67
70
  'file:license',
71
+ 'file:virtualenv',
68
72
  ];
69
73
  /**
70
74
  * Helper Object to work with {@link FlowrConfig}, provides the default config and the Joi schema for validation.
@@ -101,6 +105,7 @@ exports.FlowrConfig = {
101
105
  variables: VariableResolve.Alias,
102
106
  evalStrings: true,
103
107
  trackEnvironments: true,
108
+ pkgdb: { enabled: true, eagerlyLoad: false, eagerlyLoadExports: false },
104
109
  resolveSource: {
105
110
  dropPaths: DropPathsOption.No,
106
111
  ignoreCapitalization: true,
@@ -171,6 +176,11 @@ exports.FlowrConfig = {
171
176
  variables: joi_1.default.string().valid(...Object.values(VariableResolve)).description('How to resolve variables and their values.'),
172
177
  evalStrings: joi_1.default.boolean().description('Should we include eval(parse(text="...")) calls in the dataflow graph?'),
173
178
  trackEnvironments: joi_1.default.boolean().optional().description('Track user-created environments (new.env, assign/get/local with envir=, dollar-assign, attach). When false, all envir-style calls fall through conservatively.'),
179
+ pkgdb: joi_1.default.object({
180
+ enabled: joi_1.default.boolean().optional().description('Resolve library()/use() exports from a package database (default true); when false no database is consulted.'),
181
+ eagerlyLoad: joi_1.default.boolean().optional().description('Parse the database up front rather than on the first package load (default false, ignored if disabled).'),
182
+ eagerlyLoadExports: joi_1.default.boolean().optional().description('Add a vertex for every export on load rather than on demand (default false); keeps the dataflow graph small.')
183
+ }).description('Resolving library exports from a package database.'),
174
184
  instrument: joi_1.default.object({
175
185
  dataflowExtractors: joi_1.default.any().optional().description('These keys are only intended for use within code, allowing to instrument the dataflow analyzer!')
176
186
  }),
@@ -255,6 +255,7 @@ class SemanticCfgGuidedVisitor extends dfg_cfg_guided_visitor_1.DataflowAwareCfg
255
255
  return this.onPurrFormulaCall({ call });
256
256
  case built_in_proc_name_1.BuiltInProcName.NamespaceAccess:
257
257
  case built_in_proc_name_1.BuiltInProcName.NewEnv:
258
+ case built_in_proc_name_1.BuiltInProcName.StackEnv:
258
259
  case built_in_proc_name_1.BuiltInProcName.With:
259
260
  case built_in_proc_name_1.BuiltInProcName.Attach:
260
261
  case built_in_proc_name_1.BuiltInProcName.Default: