@eagleoutice/flowr 2.1.12 → 2.2.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 (93) hide show
  1. package/README.md +0 -1
  2. package/benchmark/slicer.d.ts +5 -12
  3. package/benchmark/slicer.js +46 -28
  4. package/cli/benchmark-app.d.ts +2 -0
  5. package/cli/benchmark-app.js +2 -1
  6. package/cli/benchmark-helper-app.d.ts +2 -0
  7. package/cli/benchmark-helper-app.js +2 -2
  8. package/cli/common/options.js +3 -1
  9. package/cli/flowr-main-options.js +36 -2
  10. package/cli/flowr.d.ts +6 -0
  11. package/cli/flowr.js +51 -24
  12. package/cli/repl/commands/repl-cfg.js +2 -4
  13. package/cli/repl/commands/repl-dataflow.js +2 -4
  14. package/cli/repl/commands/repl-execute.d.ts +2 -2
  15. package/cli/repl/commands/repl-execute.js +15 -5
  16. package/cli/repl/commands/repl-lineage.js +2 -4
  17. package/cli/repl/commands/repl-main.d.ts +2 -2
  18. package/cli/repl/commands/repl-normalize.js +2 -4
  19. package/cli/repl/commands/repl-parse.js +2 -4
  20. package/cli/repl/commands/repl-query.js +6 -8
  21. package/cli/repl/commands/repl-version.d.ts +5 -4
  22. package/cli/repl/commands/repl-version.js +10 -9
  23. package/cli/repl/core.d.ts +5 -5
  24. package/cli/repl/core.js +8 -12
  25. package/cli/repl/print-version.d.ts +2 -2
  26. package/cli/repl/print-version.js +3 -3
  27. package/cli/repl/server/connection.d.ts +3 -3
  28. package/cli/repl/server/connection.js +5 -7
  29. package/cli/repl/server/messages/message-hello.js +2 -1
  30. package/cli/repl/server/server.d.ts +4 -3
  31. package/cli/repl/server/server.js +7 -5
  32. package/cli/slicer-app.js +1 -1
  33. package/config.d.ts +36 -4
  34. package/config.js +30 -1
  35. package/core/pipeline-executor.d.ts +1 -1
  36. package/core/pipeline-executor.js +1 -1
  37. package/core/steps/all/core/00-parse.d.ts +4 -18
  38. package/core/steps/all/core/00-parse.js +2 -11
  39. package/core/steps/all/core/01-parse-tree-sitter.d.ts +23 -0
  40. package/core/steps/all/core/01-parse-tree-sitter.js +19 -0
  41. package/core/steps/all/core/10-normalize.d.ts +3 -2
  42. package/core/steps/all/core/10-normalize.js +1 -0
  43. package/core/steps/all/core/11-normalize-tree-sitter.d.ts +25 -0
  44. package/core/steps/all/core/11-normalize-tree-sitter.js +27 -0
  45. package/core/steps/all/core/20-dataflow.d.ts +2 -0
  46. package/core/steps/all/core/20-dataflow.js +1 -1
  47. package/core/steps/pipeline/default-pipelines.d.ts +368 -23
  48. package/core/steps/pipeline/default-pipelines.js +42 -4
  49. package/dataflow/extractor.d.ts +2 -1
  50. package/dataflow/extractor.js +2 -1
  51. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +6 -5
  52. package/dataflow/processor.d.ts +2 -0
  53. package/documentation/doc-util/doc-auto-gen.js +2 -1
  54. package/documentation/doc-util/doc-cfg.js +1 -1
  55. package/documentation/doc-util/doc-dfg.js +2 -2
  56. package/documentation/doc-util/doc-files.d.ts +1 -0
  57. package/documentation/doc-util/doc-files.js +4 -0
  58. package/documentation/doc-util/doc-normalized-ast.js +2 -3
  59. package/documentation/doc-util/doc-query.js +1 -1
  60. package/documentation/doc-util/doc-search.js +1 -1
  61. package/documentation/doc-util/doc-types.js +2 -2
  62. package/documentation/print-dataflow-graph-wiki.js +15 -15
  63. package/documentation/print-engines-wiki.d.ts +1 -0
  64. package/documentation/print-engines-wiki.js +82 -0
  65. package/documentation/print-interface-wiki.js +6 -7
  66. package/documentation/print-normalized-ast-wiki.js +1 -1
  67. package/package.json +9 -5
  68. package/queries/catalog/cluster-query/cluster-query-format.d.ts +5 -4
  69. package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +5 -4
  70. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +5 -4
  71. package/queries/catalog/id-map-query/id-map-query-format.d.ts +5 -4
  72. package/queries/catalog/lineage-query/lineage-query-format.d.ts +5 -4
  73. package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +5 -4
  74. package/queries/catalog/search-query/search-query-format.d.ts +5 -4
  75. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +5 -4
  76. package/queries/query.d.ts +40 -32
  77. package/r-bridge/lang-4.x/ast/parser/json/parser.d.ts +4 -2
  78. package/r-bridge/lang-4.x/ast/parser/json/parser.js +5 -0
  79. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.d.ts +18 -0
  80. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +57 -0
  81. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.d.ts +3 -0
  82. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +541 -0
  83. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-types.d.ts +35 -0
  84. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-types.js +40 -0
  85. package/r-bridge/parser.d.ts +32 -0
  86. package/r-bridge/parser.js +14 -0
  87. package/r-bridge/shell-executor.d.ts +37 -1
  88. package/r-bridge/shell-executor.js +39 -0
  89. package/r-bridge/shell.d.ts +12 -6
  90. package/r-bridge/shell.js +15 -6
  91. package/search/search-optimizer/search-optimizer.js +1 -1
  92. package/statistics/statistics.js +1 -1
  93. package/util/version.js +1 -1
@@ -1,10 +1,46 @@
1
1
  import type { RShellExecutionOptions } from './shell';
2
2
  import type { SemVer } from 'semver';
3
- export declare class RShellExecutor {
3
+ import type { SyncParser } from './parser';
4
+ import { type RParseRequest } from './retriever';
5
+ /**
6
+ * This is a synchronous alternative to the {@link RShell}.
7
+ * Please be aware that using this is expensive.
8
+ * Every request effectively causes a new initialization of the R interpreter.
9
+ *
10
+ * With this class you can {@link RShellExecutor#run|run(command)} commands,
11
+ * that are potentially decorated with {@link RShellExecutor#addPrerequisites|prerequisites}.
12
+ * For compatibility,
13
+ * we provide {@link RShellExecutor#parse|parse(request)} and {@link RShellExecutor#rVersion|rVersion()}.
14
+ */
15
+ export declare class RShellExecutor implements SyncParser<string> {
16
+ readonly name = "r-shell";
4
17
  readonly options: Readonly<RShellExecutionOptions>;
5
18
  private readonly prerequisites;
6
19
  constructor(options?: Partial<RShellExecutionOptions>);
20
+ /**
21
+ * Adds commands that should be executed for every {@link RShellExecutor#run|run}.
22
+ */
7
23
  addPrerequisites(commands: string | string[]): this;
24
+ /**
25
+ * @returns the version of the R interpreter available to this executor.
26
+ *
27
+ * @see {@link RShellExecutor#usedRVersion}
28
+ * @see {@link RShell#rVersion}
29
+ * @see {@link RShell#usedRVersion}
30
+ */
31
+ rVersion(): Promise<string | 'unknown' | 'none'>;
32
+ /**
33
+ * Instead of returning a promise, this method returns the version of the R interpreter available to this executor,
34
+ * in the SemVer format.
35
+ */
8
36
  usedRVersion(): SemVer | null;
37
+ /**
38
+ * Runs the given command in the R interpreter.
39
+ */
9
40
  run(command: string, returnErr?: boolean): string;
41
+ /**
42
+ * Parses the given request and returns the result.
43
+ */
44
+ parse(request: RParseRequest): string;
45
+ close(): void;
10
46
  }
@@ -11,23 +11,55 @@ const preload_1 = __importDefault(require("semver/preload"));
11
11
  const log_1 = require("../util/log");
12
12
  const init_1 = require("./init");
13
13
  const convert_values_1 = require("./lang-4.x/convert-values");
14
+ const retriever_1 = require("./retriever");
14
15
  const executorLog = log_1.log.getSubLogger({ name: 'RShellExecutor' });
16
+ /**
17
+ * This is a synchronous alternative to the {@link RShell}.
18
+ * Please be aware that using this is expensive.
19
+ * Every request effectively causes a new initialization of the R interpreter.
20
+ *
21
+ * With this class you can {@link RShellExecutor#run|run(command)} commands,
22
+ * that are potentially decorated with {@link RShellExecutor#addPrerequisites|prerequisites}.
23
+ * For compatibility,
24
+ * we provide {@link RShellExecutor#parse|parse(request)} and {@link RShellExecutor#rVersion|rVersion()}.
25
+ */
15
26
  class RShellExecutor {
27
+ name = 'r-shell';
16
28
  options;
17
29
  prerequisites;
18
30
  constructor(options) {
19
31
  this.options = (0, objects_1.deepMergeObject)((0, shell_1.getDefaultRShellOptions)(), options);
20
32
  this.prerequisites = [(0, init_1.initCommand)(this.options.eol)];
21
33
  }
34
+ /**
35
+ * Adds commands that should be executed for every {@link RShellExecutor#run|run}.
36
+ */
22
37
  addPrerequisites(commands) {
23
38
  this.prerequisites.push(...(typeof commands == 'string' ? [commands] : commands));
24
39
  return this;
25
40
  }
41
+ /**
42
+ * @returns the version of the R interpreter available to this executor.
43
+ *
44
+ * @see {@link RShellExecutor#usedRVersion}
45
+ * @see {@link RShell#rVersion}
46
+ * @see {@link RShell#usedRVersion}
47
+ */
48
+ rVersion() {
49
+ return Promise.resolve(this.usedRVersion()?.format() ?? 'unknown');
50
+ }
51
+ /**
52
+ * Instead of returning a promise, this method returns the version of the R interpreter available to this executor,
53
+ * in the SemVer format.
54
+ */
26
55
  usedRVersion() {
27
56
  const version = this.run(`cat(paste0(R.version$major,".",R.version$minor), ${(0, convert_values_1.ts2r)(this.options.eol)})`);
28
57
  (0, log_1.expensiveTrace)(executorLog, () => `raw version: ${JSON.stringify(version)}`);
29
58
  return preload_1.default.coerce(version);
30
59
  }
60
+ /**
61
+ * Runs the given command in the R interpreter.
62
+ */
31
63
  run(command, returnErr = false) {
32
64
  command += ';base::quit()';
33
65
  (0, log_1.expensiveTrace)(executorLog, () => `> ${JSON.stringify(command)}`);
@@ -40,6 +72,13 @@ class RShellExecutor {
40
72
  });
41
73
  return (returnErr ? returns.stderr : returns.stdout).trim();
42
74
  }
75
+ /**
76
+ * Parses the given request and returns the result.
77
+ */
78
+ parse(request) {
79
+ return (0, retriever_1.retrieveParseDataFromRCode)(request, this);
80
+ }
81
+ close() { }
43
82
  }
44
83
  exports.RShellExecutor = RShellExecutor;
45
84
  //# sourceMappingURL=shell-executor.js.map
@@ -1,6 +1,8 @@
1
1
  import { type MergeableRecord } from '../util/objects';
2
2
  import type { SemVer } from 'semver';
3
3
  import type { AsyncOrSync } from 'ts-essentials';
4
+ import type { AsyncParser } from './parser';
5
+ import type { RParseRequest } from './retriever';
4
6
  export type OutputStreamSelector = 'stdout' | 'stderr' | 'both';
5
7
  export interface CollectorTimeout extends MergeableRecord {
6
8
  /**
@@ -72,22 +74,26 @@ export declare function getDefaultRShellOptions(): RShellOptions;
72
74
  * You can configure it by {@link RShellOptions}.
73
75
  *
74
76
  * At the moment we are using a live R session (and not networking etc.) to communicate with R easily,
75
- * which allows us to install packages etc. However, this might and probably will change in the future (leaving this
76
- * as a legacy mode :D)
77
+ * which allows us to install packages etc. However, this might and probably will change in the future
78
+ * (leaving this as a legacy mode :D)
77
79
  */
78
- export declare class RShell {
80
+ export declare class RShell implements AsyncParser<string> {
81
+ readonly name = "r-shell";
82
+ readonly async = true;
79
83
  readonly options: Readonly<RShellOptions>;
80
84
  private session;
81
85
  private readonly log;
82
86
  private versionCache;
83
87
  private tempDirs;
84
88
  constructor(options?: Partial<RShellOptions>);
89
+ parse(request: RParseRequest): Promise<string>;
85
90
  private revive;
86
91
  /**
87
- * sends the given command directly to the current R session
88
- * will not do anything to alter input markers!
89
- */
92
+ * sends the given command directly to the current R session
93
+ * will not do anything to alter input markers!
94
+ */
90
95
  sendCommand(command: string): void;
96
+ rVersion(): Promise<string | 'unknown' | 'none'>;
91
97
  usedRVersion(): Promise<SemVer | null>;
92
98
  injectLibPaths(...paths: readonly string[]): void;
93
99
  tryToInjectHomeLibPath(): void;
package/r-bridge/shell.js CHANGED
@@ -38,6 +38,7 @@ const fs_1 = __importDefault(require("fs"));
38
38
  const init_1 = require("./init");
39
39
  const config_1 = require("../config");
40
40
  const convert_values_1 = require("./lang-4.x/convert-values");
41
+ const retriever_1 = require("./retriever");
41
42
  exports.DEFAULT_OUTPUT_COLLECTOR_CONFIGURATION = {
42
43
  from: 'stdout',
43
44
  postamble: `🐧${'-'.repeat(5)}🐧`,
@@ -54,7 +55,7 @@ let DEFAULT_R_SHELL_OPTIONS = undefined;
54
55
  function getDefaultRShellOptions() {
55
56
  if (!DEFAULT_R_SHELL_OPTIONS) {
56
57
  DEFAULT_R_SHELL_OPTIONS = {
57
- pathToRExecutable: (0, config_1.getConfig)().rPath ?? exports.DEFAULT_R_PATH,
58
+ pathToRExecutable: (0, config_1.getEngineConfig)('r-shell')?.rPath ?? exports.DEFAULT_R_PATH,
58
59
  // -s is a short form of --no-echo (and the old version --slave), but this one works in R 3 and 4
59
60
  // (see https://github.com/wch/r-source/commit/f1ff49e74593341c74c20de9517f31a22c8bcb04)
60
61
  commandLineOptions: ['--vanilla', '--quiet', '--no-save', '-s'],
@@ -74,10 +75,12 @@ function getDefaultRShellOptions() {
74
75
  * You can configure it by {@link RShellOptions}.
75
76
  *
76
77
  * At the moment we are using a live R session (and not networking etc.) to communicate with R easily,
77
- * which allows us to install packages etc. However, this might and probably will change in the future (leaving this
78
- * as a legacy mode :D)
78
+ * which allows us to install packages etc. However, this might and probably will change in the future
79
+ * (leaving this as a legacy mode :D)
79
80
  */
80
81
  class RShell {
82
+ name = 'r-shell';
83
+ async = true;
81
84
  options;
82
85
  session;
83
86
  log;
@@ -90,6 +93,9 @@ class RShell {
90
93
  this.session = new RShellSession(this.options, this.log);
91
94
  this.revive();
92
95
  }
96
+ parse(request) {
97
+ return (0, retriever_1.retrieveParseDataFromRCode)(request, this);
98
+ }
93
99
  revive() {
94
100
  if (this.options.revive === 0 /* RShellReviveOptions.Never */) {
95
101
  return;
@@ -104,15 +110,18 @@ class RShell {
104
110
  });
105
111
  }
106
112
  /**
107
- * sends the given command directly to the current R session
108
- * will not do anything to alter input markers!
109
- */
113
+ * sends the given command directly to the current R session
114
+ * will not do anything to alter input markers!
115
+ */
110
116
  sendCommand(command) {
111
117
  if (this.log.settings.minLevel <= 1 /* LogLevel.Trace */) {
112
118
  this.log.trace(`> ${JSON.stringify(command)}`);
113
119
  }
114
120
  this._sendCommand(command);
115
121
  }
122
+ async rVersion() {
123
+ return (await this.usedRVersion())?.format() ?? 'unknown';
124
+ }
116
125
  async usedRVersion() {
117
126
  if (this.versionCache !== null) {
118
127
  return this.versionCache;
@@ -71,7 +71,7 @@ function dropAnyNameRegex(generator) {
71
71
  if (generator.name !== 'get' || !generator.args.filter.nameIsRegex) {
72
72
  return generator;
73
73
  }
74
- if (generator.args.filter.name === '.') {
74
+ if (generator.args.filter.name === '.*') {
75
75
  return {
76
76
  ...generator,
77
77
  args: {
@@ -82,7 +82,7 @@ function processMetaOnSuccessful(meta, request) {
82
82
  const parser = new xmldom_1.DOMParser();
83
83
  async function extractSingle(result, shell, request, features, suffixFilePath) {
84
84
  const slicerOutput = await new pipeline_executor_1.PipelineExecutor(default_pipelines_1.DEFAULT_DATAFLOW_PIPELINE, {
85
- request, shell
85
+ request, parser: shell
86
86
  }).allRemainingSteps();
87
87
  // retrieve parsed xml through (legacy) xmlparsedata
88
88
  const suffix = request.request === 'file' ? ', encoding="utf-8"' : '';
package/util/version.js CHANGED
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.flowrVersion = flowrVersion;
4
4
  const semver_1 = require("semver");
5
5
  // this is automatically replaced with the current version by release-it
6
- const version = '2.1.12';
6
+ const version = '2.2.0';
7
7
  function flowrVersion() {
8
8
  return new semver_1.SemVer(version);
9
9
  }