@eagleoutice/flowr 2.0.4 → 2.0.5

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.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
  [![QA (and potentially deploy)](https://github.com/Code-Inspect/flowr/actions/workflows/qa.yaml/badge.svg)](https://github.com/Code-Inspect/flowr/actions/workflows/qa.yaml) [![codecov](https://codecov.io/gh/Code-Inspect/flowr/graph/badge.svg)](https://codecov.io/gh/Code-Inspect/flowr) [![Docker Image Version (latest semver)](https://img.shields.io/docker/v/eagleoutice/flowr?logo=docker&logoColor=white&label=dockerhub)](https://hub.docker.com/r/eagleoutice/flowr) [![latest tag](https://badgen.net/github/tag/Code-Inspect/flowr?label=latest&color=purple)](https://github.com/Code-Inspect/flowr/releases/latest) [![Marketplace](https://badgen.net/vs-marketplace/v/code-inspect.vscode-flowr)](https://marketplace.visualstudio.com/items?itemName=code-inspect.vscode-flowr)
3
3
 
4
4
 
5
- *flowR* is a static [dataflow analyzer](https://en.wikipedia.org/wiki/Data-flow_analysis) and [program slicer](https://github.com/Code-Inspect/flowr/wiki/Terminology#program-slice) for the [*R*](https://www.r-project.org/) programming language (currently tested for versions `4.x`). It is available as a [Visual Studio Code extension](https://marketplace.visualstudio.com/items?itemName=code-inspect.vscode-flowr) and as a [docker image](https://hub.docker.com/r/eagleoutice/flowr).
5
+ *flowR* is a static [dataflow analyzer](https://en.wikipedia.org/wiki/Data-flow_analysis) and [program slicer](https://github.com/Code-Inspect/flowr/wiki/Terminology#program-slice) for the [*R*](https://www.r-project.org/) programming language (currently tested for versions `4.x` and `3.6.x`). It is available as a [Visual Studio Code extension](https://marketplace.visualstudio.com/items?itemName=code-inspect.vscode-flowr) and as a [docker image](https://hub.docker.com/r/eagleoutice/flowr).
6
6
 
7
7
  ## ⭐ Getting Started
8
8
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eagleoutice/flowr",
3
- "version": "2.0.4",
3
+ "version": "2.0.5",
4
4
  "description": "Static Dataflow Analyzer and Program Slicer for the R Programming Language",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "repository": {
package/r-bridge/init.js CHANGED
@@ -7,8 +7,9 @@ exports.ErrorMarker = 'err';
7
7
  function initCommand(eol) {
8
8
  /* define the get function complete wrapped in a try so that we can handle failures gracefully on stdout
9
9
  * furthermore, we compile for performance reasons
10
+ * Please note that we add a `flowr_output` assignment before to avoid issues with earlier R versions
10
11
  */
11
- return 'flowr_get_ast<-compiler::cmpfun(function(...){tryCatch({'
12
+ return 'flowr_output<-NULL;flowr_get_ast<-compiler::cmpfun(function(...){tryCatch({'
12
13
  /* the actual code to parse the R code, ... allows us to keep the old 'file=path' and 'text=content' semantics. we define flowr_output using the super assignment to persist it in the env! */
13
14
  + 'flowr_output<<-getParseData(parse(...,keep.source=TRUE),includeText=TRUE);'
14
15
  /* json conversion of the output, dataframe="values" allows us to receive a list of lists (which is more compact)!
@@ -138,6 +138,12 @@ export declare const enum RawRType {
138
138
  * https://github.com/REditorSupport/languageserver/pull/328
139
139
  */
140
140
  ExprOfAssignOrHelp = "expr_or_assign_or_help",
141
+ /**
142
+ * Pre-4.0 version of expr_or_assign_or_help, which was seemingly silently renamed here:
143
+ * https://github.com/wch/r-source/commit/84bbf385f909c0223924c310af6c7c77aa810234
144
+ * (Also see {@link ExprOfAssignOrHelp} documentation for more context.)
145
+ */
146
+ LegacyEqualAssign = "equal_assign",
141
147
  /** T65 */
142
148
  ExpressionList = "exprlist"
143
149
  }
@@ -8,7 +8,13 @@ exports.RootId = 0;
8
8
  * Parses the given data and sets child relationship, return the list of root entries (with a parent of {@link RootId}).
9
9
  */
10
10
  function prepareParsedData(data) {
11
- const json = JSON.parse(`[${data}]`);
11
+ let json;
12
+ try {
13
+ json = JSON.parse(`[${data}]`);
14
+ }
15
+ catch (e) {
16
+ throw new Error(`Failed to parse data ${data}: ${e?.message}`);
17
+ }
12
18
  (0, assert_1.guard)(Array.isArray(json), () => `Expected ${data} to be an array but was not`);
13
19
  const ret = new Map(json.map(([line1, col1, line2, col2, id, parent, token, terminal, text]) => {
14
20
  return [id, { line1, col1, line2, col2, id, parent, token: (0, retriever_1.removeRQuotes)(token), terminal, text }];
@@ -22,7 +22,7 @@ const normalize_symbol_1 = require("../values/normalize-symbol");
22
22
  */
23
23
  function tryNormalizeFunctionCall(data, mappedWithName) {
24
24
  const fnBase = mappedWithName[0];
25
- if (fnBase.name !== "expr" /* RawRType.Expression */ && fnBase.name !== "expr_or_assign_or_help" /* RawRType.ExprOfAssignOrHelp */) {
25
+ if (fnBase.name !== "expr" /* RawRType.Expression */ && fnBase.name !== "expr_or_assign_or_help" /* RawRType.ExprOfAssignOrHelp */ && fnBase.name !== "equal_assign" /* RawRType.LegacyEqualAssign */) {
26
26
  parser_1.parseLog.trace(`expected function call name to be wrapped an expression, yet received ${fnBase.name}`);
27
27
  return undefined;
28
28
  }
@@ -18,7 +18,7 @@ function tryNormalizeFor(data, [forToken, head, body]) {
18
18
  else if (head.name !== "forcond" /* RawRType.ForCondition */) {
19
19
  throw new input_format_1.XmlParseError(`expected condition for for-loop but found ${JSON.stringify(head)}`);
20
20
  }
21
- else if (body.name !== "expr" /* RawRType.Expression */ && body.name !== "expr_or_assign_or_help" /* RawRType.ExprOfAssignOrHelp */) {
21
+ else if (body.name !== "expr" /* RawRType.Expression */ && body.name !== "expr_or_assign_or_help" /* RawRType.ExprOfAssignOrHelp */ && body.name !== "equal_assign" /* RawRType.LegacyEqualAssign */) {
22
22
  throw new input_format_1.XmlParseError(`expected expr body for for-loop but found ${JSON.stringify(body)}`);
23
23
  }
24
24
  parser_1.parseLog.debug('trying to parse for-loop');
@@ -72,7 +72,7 @@ function tryNormalizeAccess(data, mappedWithName) {
72
72
  return undefined;
73
73
  }
74
74
  const accessed = mappedWithName[0];
75
- if (accessed.name !== "expr" /* RawRType.Expression */ && accessed.name !== "expr_or_assign_or_help" /* RawRType.ExprOfAssignOrHelp */) {
75
+ if (accessed.name !== "expr" /* RawRType.Expression */ && accessed.name !== "expr_or_assign_or_help" /* RawRType.ExprOfAssignOrHelp */ && accessed.name !== "equal_assign" /* RawRType.LegacyEqualAssign */) {
76
76
  parser_1.parseLog.trace(`expected accessed element to be wrapped an expression, yet received ${accessed.name}`);
77
77
  return undefined;
78
78
  }
@@ -67,7 +67,7 @@ function splitExprs(tokens) {
67
67
  last = i + 1;
68
68
  }
69
69
  else {
70
- const thisExpr = token.name === "expr" /* RawRType.Expression */ || token.name === "expr_or_assign_or_help" /* RawRType.ExprOfAssignOrHelp */;
70
+ const thisExpr = token.name === "expr" /* RawRType.Expression */ || token.name === "expr_or_assign_or_help" /* RawRType.ExprOfAssignOrHelp */ || token.name === "equal_assign" /* RawRType.LegacyEqualAssign */;
71
71
  if (thisExpr && lastExpr) {
72
72
  if (i > last) {
73
73
  segments.push(tokens.slice(last, i));
@@ -35,6 +35,7 @@ function normalizeSingleNode(data, elem) {
35
35
  case "exprlist" /* RawRType.ExpressionList */:
36
36
  case "expr" /* RawRType.Expression */:
37
37
  case "expr_or_assign_or_help" /* RawRType.ExprOfAssignOrHelp */:
38
+ case "equal_assign" /* RawRType.LegacyEqualAssign */:
38
39
  return (0, normalize_expression_1.normalizeExpression)(data, elem.content);
39
40
  case "NUM_CONST" /* RawRType.NumericConst */:
40
41
  return (0, normalize_number_1.normalizeNumber)(data, elem.content);
package/r-bridge/shell.js CHANGED
@@ -51,7 +51,9 @@ exports.DEFAULT_OUTPUT_COLLECTOR_CONFIGURATION = {
51
51
  exports.DEFAULT_R_PATH = (0, os_1.getPlatform)() === 'windows' ? 'R.exe' : 'R';
52
52
  exports.DEFAULT_R_SHELL_EXEC_OPTIONS = {
53
53
  pathToRExecutable: (0, config_1.getConfig)().rPath ?? exports.DEFAULT_R_PATH,
54
- commandLineOptions: ['--vanilla', '--quiet', '--no-echo', '--no-save', '--slave'],
54
+ // -s is a short form of --no-echo (and the old version --slave), but this one works in R 3 and 4
55
+ // (see https://github.com/wch/r-source/commit/f1ff49e74593341c74c20de9517f31a22c8bcb04)
56
+ commandLineOptions: ['--vanilla', '--quiet', '--no-save', '-s'],
55
57
  cwd: process.cwd(),
56
58
  env: undefined,
57
59
  eol: '\n',
package/util/version.js CHANGED
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.flowrVersion = void 0;
4
4
  const semver_1 = require("semver");
5
5
  // this is automatically replaced with the current version by release-it
6
- const version = '2.0.4';
6
+ const version = '2.0.5';
7
7
  function flowrVersion() {
8
8
  return new semver_1.SemVer(version);
9
9
  }