@eagleoutice/flowr 2.7.0 → 2.7.3

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 (168) hide show
  1. package/README.md +14 -14
  2. package/abstract-interpretation/absint-visitor.d.ts +160 -0
  3. package/abstract-interpretation/absint-visitor.js +279 -0
  4. package/abstract-interpretation/data-frame/dataframe-domain.d.ts +2 -2
  5. package/abstract-interpretation/data-frame/dataframe-domain.js +23 -7
  6. package/abstract-interpretation/data-frame/mappers/access-mapper.d.ts +6 -6
  7. package/abstract-interpretation/data-frame/mappers/access-mapper.js +10 -14
  8. package/abstract-interpretation/data-frame/mappers/arguments.d.ts +15 -9
  9. package/abstract-interpretation/data-frame/mappers/arguments.js +27 -4
  10. package/abstract-interpretation/data-frame/mappers/function-mapper.d.ts +17 -17
  11. package/abstract-interpretation/data-frame/mappers/function-mapper.js +55 -67
  12. package/abstract-interpretation/data-frame/mappers/replacement-mapper.d.ts +7 -7
  13. package/abstract-interpretation/data-frame/mappers/replacement-mapper.js +25 -29
  14. package/abstract-interpretation/data-frame/resolve-args.d.ts +1 -1
  15. package/abstract-interpretation/data-frame/resolve-args.js +1 -1
  16. package/abstract-interpretation/data-frame/semantics.js +5 -6
  17. package/abstract-interpretation/data-frame/shape-inference.d.ts +52 -28
  18. package/abstract-interpretation/data-frame/shape-inference.js +67 -90
  19. package/abstract-interpretation/domains/bounded-set-domain.d.ts +2 -2
  20. package/abstract-interpretation/domains/interval-domain.d.ts +2 -2
  21. package/abstract-interpretation/domains/set-range-domain.d.ts +10 -4
  22. package/abstract-interpretation/domains/set-range-domain.js +7 -1
  23. package/abstract-interpretation/domains/set-upper-bound-domain.d.ts +2 -2
  24. package/abstract-interpretation/domains/singleton-domain.d.ts +2 -2
  25. package/benchmark/slicer.js +13 -14
  26. package/cli/common/options.d.ts +431 -8
  27. package/cli/common/options.js +1 -1
  28. package/cli/common/scripts-info.d.ts +431 -7
  29. package/cli/flowr-main-options.d.ts +102 -2
  30. package/cli/flowr.d.ts +102 -2
  31. package/cli/repl/commands/repl-commands.d.ts +25 -0
  32. package/cli/repl/commands/repl-query.js +17 -5
  33. package/cli/wiki.d.ts +13 -0
  34. package/cli/wiki.js +7 -2
  35. package/config.d.ts +4 -4
  36. package/config.js +1 -1
  37. package/control-flow/basic-cfg-guided-visitor.js +7 -8
  38. package/control-flow/control-flow-graph.d.ts +1 -1
  39. package/control-flow/semantic-cfg-guided-visitor.d.ts +1 -1
  40. package/control-flow/semantic-cfg-guided-visitor.js +1 -1
  41. package/dataflow/eval/resolve/alias-tracking.js +1 -1
  42. package/dataflow/internal/linker.d.ts +2 -0
  43. package/dataflow/internal/linker.js +10 -12
  44. package/documentation/doc-capabilities.d.ts +1 -1
  45. package/documentation/doc-readme.d.ts +1 -1
  46. package/documentation/doc-util/doc-cfg.js +1 -1
  47. package/documentation/doc-util/doc-cli-option.d.ts +6 -6
  48. package/documentation/doc-util/doc-cli-option.js +3 -3
  49. package/documentation/doc-util/doc-dfg.d.ts +1 -1
  50. package/documentation/doc-util/doc-files.d.ts +3 -0
  51. package/documentation/doc-util/doc-files.js +4 -1
  52. package/documentation/doc-util/doc-normalized-ast.js +2 -2
  53. package/documentation/issue-linting-rule.d.ts +1 -1
  54. package/documentation/wiki-analyzer.d.ts +1 -1
  55. package/documentation/wiki-cfg.d.ts +1 -1
  56. package/documentation/wiki-core.d.ts +1 -1
  57. package/documentation/wiki-dataflow-graph.d.ts +1 -1
  58. package/documentation/wiki-dataflow-graph.js +6 -6
  59. package/documentation/wiki-engine.d.ts +1 -1
  60. package/documentation/wiki-engine.js +9 -10
  61. package/documentation/wiki-faq.d.ts +1 -1
  62. package/documentation/wiki-interface.d.ts +1 -1
  63. package/documentation/wiki-interface.js +12 -13
  64. package/documentation/wiki-linter.d.ts +1 -1
  65. package/documentation/wiki-linting-and-testing.d.ts +1 -1
  66. package/documentation/wiki-mk/doc-context.d.ts +54 -1
  67. package/documentation/wiki-mk/doc-context.js +17 -0
  68. package/documentation/wiki-mk/doc-maker.d.ts +5 -5
  69. package/documentation/wiki-mk/doc-maker.js +3 -1
  70. package/documentation/wiki-normalized-ast.d.ts +1 -1
  71. package/documentation/wiki-onboarding.d.ts +1 -1
  72. package/documentation/wiki-overview.d.ts +9 -0
  73. package/documentation/wiki-overview.js +248 -0
  74. package/documentation/wiki-query.d.ts +1 -1
  75. package/documentation/wiki-query.js +17 -1
  76. package/documentation/wiki-search.d.ts +1 -1
  77. package/documentation/wiki-setup.d.ts +9 -0
  78. package/documentation/wiki-setup.js +122 -0
  79. package/linter/rules/dataframe-access-validation.d.ts +1 -1
  80. package/linter/rules/dataframe-access-validation.js +8 -10
  81. package/linter/rules/unused-definition.js +1 -1
  82. package/package.json +1 -1
  83. package/project/context/flowr-analyzer-context.d.ts +4 -0
  84. package/project/context/flowr-analyzer-context.js +3 -1
  85. package/project/context/flowr-analyzer-dependencies-context.d.ts +3 -2
  86. package/project/context/flowr-analyzer-dependencies-context.js +4 -2
  87. package/project/context/flowr-analyzer-files-context.d.ts +9 -1
  88. package/project/context/flowr-analyzer-files-context.js +4 -0
  89. package/project/context/flowr-analyzer-functions-context.d.ts +29 -0
  90. package/project/context/flowr-analyzer-functions-context.js +68 -0
  91. package/project/context/flowr-file.d.ts +2 -0
  92. package/project/context/flowr-file.js +2 -0
  93. package/project/plugins/file-plugins/{flowr-description-file.d.ts → files/flowr-description-file.d.ts} +1 -1
  94. package/project/plugins/file-plugins/files/flowr-description-file.js +75 -0
  95. package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +32 -0
  96. package/project/plugins/file-plugins/files/flowr-namespace-file.js +102 -0
  97. package/project/plugins/file-plugins/files/flowr-news-file.d.ts +27 -0
  98. package/project/plugins/file-plugins/files/flowr-news-file.js +152 -0
  99. package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.d.ts +1 -1
  100. package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.js +1 -1
  101. package/project/plugins/file-plugins/flowr-analyzer-namespace-file-plugin.d.ts +22 -0
  102. package/project/plugins/file-plugins/flowr-analyzer-namespace-file-plugin.js +34 -0
  103. package/project/plugins/file-plugins/flowr-analyzer-news-file-plugin.d.ts +23 -0
  104. package/project/plugins/file-plugins/flowr-analyzer-news-file-plugin.js +35 -0
  105. package/project/plugins/file-plugins/notebooks/flowr-analyzer-jupyter-file-plugin.d.ts +1 -1
  106. package/project/plugins/file-plugins/notebooks/flowr-analyzer-jupyter-file-plugin.js +1 -1
  107. package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.d.ts +1 -1
  108. package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.js +1 -1
  109. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.d.ts +1 -1
  110. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.js +1 -1
  111. package/project/plugins/flowr-analyzer-plugin-defaults.js +4 -0
  112. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.js +5 -1
  113. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-namespace-file-plugin.d.ts +10 -0
  114. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-namespace-file-plugin.js +56 -0
  115. package/project/plugins/package-version-plugins/package.d.ts +15 -2
  116. package/project/plugins/package-version-plugins/package.js +33 -5
  117. package/project/plugins/plugin-registry.d.ts +3 -1
  118. package/project/plugins/plugin-registry.js +4 -0
  119. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +7 -1
  120. package/queries/catalog/dependencies-query/dependencies-query-executor.js +2 -1
  121. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +2 -0
  122. package/queries/catalog/dependencies-query/dependencies-query-format.js +2 -1
  123. package/queries/catalog/df-shape-query/df-shape-query-executor.js +4 -2
  124. package/queries/catalog/files-query/files-query-executor.d.ts +6 -0
  125. package/queries/catalog/files-query/files-query-executor.js +49 -0
  126. package/queries/catalog/files-query/files-query-format.d.ts +36 -0
  127. package/queries/catalog/files-query/files-query-format.js +114 -0
  128. package/queries/catalog/linter-query/linter-query-format.js +1 -1
  129. package/queries/query.d.ts +10 -1
  130. package/queries/query.js +3 -1
  131. package/r-bridge/lang-4.x/ast/model/model.d.ts +1 -1
  132. package/r-bridge/lang-4.x/ast/model/processing/decorate.js +8 -8
  133. package/r-bridge/lang-4.x/ast/model/processing/role.d.ts +8 -8
  134. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-parameter.js +0 -1
  135. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +0 -1
  136. package/statistics/features/supported/data-access/data-access.js +1 -1
  137. package/util/containers.js +1 -1
  138. package/util/files.d.ts +0 -7
  139. package/util/files.js +0 -41
  140. package/util/mermaid/ast.d.ts +3 -2
  141. package/util/mermaid/ast.js +13 -7
  142. package/util/mermaid/cfg.d.ts +3 -2
  143. package/util/mermaid/cfg.js +26 -6
  144. package/util/mermaid/dfg.d.ts +1 -7
  145. package/util/mermaid/dfg.js +7 -3
  146. package/util/mermaid/info.d.ts +17 -0
  147. package/util/mermaid/info.js +5 -0
  148. package/util/prefix.d.ts +9 -5
  149. package/util/prefix.js +14 -6
  150. package/util/r-regex.d.ts +21 -0
  151. package/util/r-regex.js +25 -0
  152. package/util/text/args.js +12 -3
  153. package/util/version.js +1 -1
  154. package/abstract-interpretation/data-frame/absint-info.d.ts +0 -109
  155. package/abstract-interpretation/data-frame/absint-info.js +0 -31
  156. package/abstract-interpretation/data-frame/absint-visitor.d.ts +0 -57
  157. package/abstract-interpretation/data-frame/absint-visitor.js +0 -176
  158. package/abstract-interpretation/data-frame/mappers/assignment-mapper.d.ts +0 -21
  159. package/abstract-interpretation/data-frame/mappers/assignment-mapper.js +0 -34
  160. package/documentation/doc-util/doc-print.d.ts +0 -5
  161. package/documentation/doc-util/doc-print.js +0 -36
  162. package/project/plugins/file-plugins/flowr-description-file.js +0 -37
  163. package/project/plugins/file-plugins/notebooks/notebook.d.ts +0 -0
  164. package/project/plugins/file-plugins/notebooks/notebook.js +0 -2
  165. /package/project/plugins/file-plugins/{notebooks → files}/flowr-jupyter-file.d.ts +0 -0
  166. /package/project/plugins/file-plugins/{notebooks → files}/flowr-jupyter-file.js +0 -0
  167. /package/project/plugins/file-plugins/{notebooks → files}/flowr-rmarkdown-file.d.ts +0 -0
  168. /package/project/plugins/file-plugins/{notebooks → files}/flowr-rmarkdown-file.js +0 -0
@@ -102,7 +102,7 @@ export interface Namespace {
102
102
  * The namespace attached to the given node
103
103
  * (e.g., a namespaced symbol in `x::y`).
104
104
  */
105
- namespace: NamespaceIdentifier | undefined;
105
+ namespace?: NamespaceIdentifier;
106
106
  }
107
107
  /**
108
108
  * This subtype of {@link RNode} represents all types of constants
@@ -187,7 +187,7 @@ function createFoldForUnaryOp(info) {
187
187
  info.idMap.set(id, decorated);
188
188
  const opInfo = operand.info;
189
189
  opInfo.parent = id;
190
- opInfo.role = "unary-operand" /* RoleInParent.UnaryOperand */;
190
+ opInfo.role = "unary-op" /* RoleInParent.UnaryOperand */;
191
191
  decorated.info.file = info.file;
192
192
  return decorated;
193
193
  };
@@ -208,7 +208,7 @@ function createFoldForAccess(info) {
208
208
  const curInfo = acc.info;
209
209
  curInfo.parent = id;
210
210
  curInfo.index = idx;
211
- curInfo.role = "index-access" /* RoleInParent.IndexAccess */;
211
+ curInfo.role = "index-acc" /* RoleInParent.IndexAccess */;
212
212
  }
213
213
  }
214
214
  }
@@ -223,11 +223,11 @@ function createFoldForForLoop(info) {
223
223
  info.idMap.set(id, decorated);
224
224
  const varInfo = variable.info;
225
225
  varInfo.parent = id;
226
- varInfo.role = "for-variable" /* RoleInParent.ForVariable */;
226
+ varInfo.role = "for-var" /* RoleInParent.ForVariable */;
227
227
  const vecInfo = vector.info;
228
228
  vecInfo.parent = id;
229
229
  vecInfo.index = 1;
230
- vecInfo.role = "for-vector" /* RoleInParent.ForVector */;
230
+ vecInfo.role = "for-vec" /* RoleInParent.ForVector */;
231
231
  const bodyInfo = body.info;
232
232
  bodyInfo.parent = id;
233
233
  bodyInfo.index = 2;
@@ -280,7 +280,7 @@ function createFoldForIfThenElse(info) {
280
280
  const otherwiseInfo = otherwise.info;
281
281
  otherwiseInfo.parent = id;
282
282
  otherwiseInfo.index = 2;
283
- otherwiseInfo.role = "if-otherwise" /* RoleInParent.IfOtherwise */;
283
+ otherwiseInfo.role = "if-other" /* RoleInParent.IfOtherwise */;
284
284
  }
285
285
  decorated.info.file = info.file;
286
286
  return decorated;
@@ -323,7 +323,7 @@ function createFoldForFunctionCall(info) {
323
323
  const argInfo = arg.info;
324
324
  argInfo.parent = id;
325
325
  argInfo.index = idx;
326
- argInfo.role = "call-argument" /* RoleInParent.FunctionCallArgument */;
326
+ argInfo.role = "call-arg" /* RoleInParent.FunctionCallArgument */;
327
327
  }
328
328
  }
329
329
  decorated.info.file = info.file;
@@ -340,12 +340,12 @@ function createFoldForFunctionDefinition(info) {
340
340
  const paramInfo = param.info;
341
341
  paramInfo.parent = id;
342
342
  paramInfo.index = idx++;
343
- paramInfo.role = "function-def-param" /* RoleInParent.FunctionDefinitionParameter */;
343
+ paramInfo.role = "param" /* RoleInParent.FunctionDefinitionParameter */;
344
344
  }
345
345
  const bodyInfo = body.info;
346
346
  bodyInfo.parent = id;
347
347
  bodyInfo.index = idx;
348
- bodyInfo.role = "function-def-body" /* RoleInParent.FunctionDefinitionBody */;
348
+ bodyInfo.role = "fun-body" /* RoleInParent.FunctionDefinitionBody */;
349
349
  decorated.info.file = info.file;
350
350
  return decorated;
351
351
  };
@@ -10,29 +10,29 @@ export declare const enum RoleInParent {
10
10
  Root = "root",
11
11
  IfCondition = "if-cond",
12
12
  IfThen = "if-then",
13
- IfOtherwise = "if-otherwise",
13
+ IfOtherwise = "if-other",
14
14
  WhileCondition = "while-cond",
15
15
  WhileBody = "while-body",
16
16
  RepeatBody = "repeat-body",
17
- ForVariable = "for-variable",
18
- ForVector = "for-vector",
17
+ ForVariable = "for-var",
18
+ ForVector = "for-vec",
19
19
  ForBody = "for-body",
20
20
  FunctionCallName = "call-name",
21
- FunctionCallArgument = "call-argument",
22
- FunctionDefinitionBody = "function-def-body",
23
- FunctionDefinitionParameter = "function-def-param",
21
+ FunctionCallArgument = "call-arg",
22
+ FunctionDefinitionBody = "fun-body",
23
+ FunctionDefinitionParameter = "param",
24
24
  ExpressionListChild = "expr-list-child",
25
25
  BinaryOperationLhs = "binop-lhs",
26
26
  BinaryOperationRhs = "binop-rhs",
27
27
  PipeLhs = "pipe-lhs",
28
28
  PipeRhs = "pipe-rhs",
29
- UnaryOperand = "unary-operand",
29
+ UnaryOperand = "unary-op",
30
30
  ParameterName = "param-name",
31
31
  ParameterDefaultValue = "param-value",
32
32
  ArgumentName = "arg-name",
33
33
  ArgumentValue = "arg-value",
34
34
  Accessed = "accessed",
35
- IndexAccess = "index-access"
35
+ IndexAccess = "index-acc"
36
36
  }
37
37
  /**
38
38
  * Returns the roles of the parents of the given node, starting with the parent-role of the node itself.
@@ -34,7 +34,6 @@ function tryNormalizeParameter(data, objs) {
34
34
  name: {
35
35
  type: type_1.RType.Symbol,
36
36
  location, content,
37
- namespace: undefined,
38
37
  lexeme: content,
39
38
  info: {
40
39
  fullRange: location,
@@ -483,7 +483,6 @@ function convertTreeNode(node) {
483
483
  name: {
484
484
  type: type_1.RType.Symbol,
485
485
  location: nameRange,
486
- namespace: undefined,
487
486
  content: name.text,
488
487
  lexeme: name.text,
489
488
  info: {
@@ -58,7 +58,7 @@ function visitAccess(info, input) {
58
58
  acc = true;
59
59
  break; // we only account for the first one
60
60
  }
61
- else if (role === "index-access" /* RoleInParent.IndexAccess */) {
61
+ else if (role === "index-acc" /* RoleInParent.IndexAccess */) {
62
62
  idxAcc = true;
63
63
  break;
64
64
  }
@@ -16,7 +16,7 @@ const type_1 = require("../r-bridge/lang-4.x/ast/model/type");
16
16
  function getAccessOperands(args) {
17
17
  const nonEmptyArgs = args.filter(arg => arg !== r_function_call_1.EmptyArgument);
18
18
  const accessedArg = nonEmptyArgs.find(arg => arg.info.role === "accessed" /* RoleInParent.Accessed */);
19
- const accessArg = nonEmptyArgs.find(arg => arg.info.role === "index-access" /* RoleInParent.IndexAccess */);
19
+ const accessArg = nonEmptyArgs.find(arg => arg.info.role === "index-acc" /* RoleInParent.IndexAccess */);
20
20
  return { accessedArg, accessArg };
21
21
  }
22
22
  /**
package/util/files.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { type PathLike } from 'fs';
2
2
  import type { RParseRequestFromFile } from '../r-bridge/retriever';
3
- import type { FlowrFileProvider } from '../project/context/flowr-file';
4
3
  /**
5
4
  * Represents a table, identified by a header and a list of rows.
6
5
  */
@@ -70,12 +69,6 @@ export declare function readLineByLineSync(filePath: string, onLine: (line: Buff
70
69
  * @param directory - The directory whose parent to return
71
70
  */
72
71
  export declare function getParentDirectory(directory: string): string;
73
- /**
74
- * Parses the given file in the 'Debian Control Format'.
75
- * @param file - The file to parse
76
- * @returns Map containing the keys and values of the provided file.
77
- */
78
- export declare function parseDCF(file: FlowrFileProvider): Map<string, string[]>;
79
72
  /**
80
73
  * Checks whether the given path-like object is a file that exists on the local filesystem.
81
74
  */
package/util/files.js CHANGED
@@ -44,7 +44,6 @@ exports.writeTableAsCsv = writeTableAsCsv;
44
44
  exports.readLineByLine = readLineByLine;
45
45
  exports.readLineByLineSync = readLineByLineSync;
46
46
  exports.getParentDirectory = getParentDirectory;
47
- exports.parseDCF = parseDCF;
48
47
  exports.isFilePath = isFilePath;
49
48
  const fs_1 = __importStar(require("fs"));
50
49
  const path_1 = __importDefault(require("path"));
@@ -201,46 +200,6 @@ function getParentDirectory(directory) {
201
200
  // apparently this is somehow the best way to do it in node, what
202
201
  return directory.split(path_1.default.sep).slice(0, -1).join(path_1.default.sep);
203
202
  }
204
- /**
205
- * Parses the given file in the 'Debian Control Format'.
206
- * @param file - The file to parse
207
- * @returns Map containing the keys and values of the provided file.
208
- */
209
- function parseDCF(file) {
210
- const result = new Map();
211
- let currentKey = '';
212
- let currentValue = '';
213
- const indentRegex = new RegExp(/^\s/);
214
- const firstColonRegex = new RegExp(/:(.*)/s);
215
- const fileContent = file.content().toString().split(/\r?\n/);
216
- for (const line of fileContent) {
217
- if (indentRegex.test(line)) {
218
- currentValue += '\n' + line.trim();
219
- }
220
- else {
221
- if (currentKey) {
222
- const values = currentValue ? cleanValues(currentValue) : [];
223
- result.set(currentKey, values);
224
- }
225
- const [key, rest] = line.split(firstColonRegex).map(s => s.trim());
226
- currentKey = key.trim();
227
- currentValue = rest.trim();
228
- }
229
- }
230
- if (currentKey) {
231
- const values = currentValue ? cleanValues(currentValue) : [];
232
- result.set(currentKey, values);
233
- }
234
- return result;
235
- }
236
- const cleanSplitRegex = /[\n,]+/;
237
- const cleanQuotesRegex = /'/g;
238
- function cleanValues(values) {
239
- return values
240
- .split(cleanSplitRegex)
241
- .map(s => s.trim().replace(cleanQuotesRegex, ''))
242
- .filter(s => s.length > 0);
243
- }
244
203
  /**
245
204
  * Checks whether the given path-like object is a file that exists on the local filesystem.
246
205
  */
@@ -1,10 +1,11 @@
1
1
  import type { ParentInformation, RNodeWithParent } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
2
2
  import type { RProject } from '../../r-bridge/lang-4.x/ast/model/nodes/r-project';
3
+ import type { MermaidGraphPrinterInfo } from './info';
3
4
  /**
4
5
  * Serialize the normalized AST to mermaid format
5
6
  */
6
- export declare function normalizedAstToMermaid(ast: RProject<ParentInformation> | RNodeWithParent, prefix?: string): string;
7
+ export declare function normalizedAstToMermaid(ast: RProject<ParentInformation> | RNodeWithParent, { prefix, markStyle, includeOnlyIds, mark }?: MermaidGraphPrinterInfo): string;
7
8
  /**
8
9
  * Use mermaid to visualize the normalized AST.
9
10
  */
10
- export declare function normalizedAstToMermaidUrl(ast: RProject<ParentInformation> | RNodeWithParent, prefix?: string): string;
11
+ export declare function normalizedAstToMermaidUrl(ast: RProject<ParentInformation> | RNodeWithParent, info?: MermaidGraphPrinterInfo): string;
@@ -7,6 +7,7 @@ const visitor_1 = require("../../r-bridge/lang-4.x/ast/model/processing/visitor"
7
7
  const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
8
8
  const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
9
9
  const flowr_file_1 = require("../../project/context/flowr-file");
10
+ const info_1 = require("./info");
10
11
  function identifyMermaidDirection(prefix) {
11
12
  const directionMatch = prefix.match(/flowchart (TD|LR|RL|BT)/);
12
13
  if (directionMatch) {
@@ -17,14 +18,20 @@ function identifyMermaidDirection(prefix) {
17
18
  /**
18
19
  * Serialize the normalized AST to mermaid format
19
20
  */
20
- function normalizedAstToMermaid(ast, prefix = 'flowchart TD\n') {
21
+ function normalizedAstToMermaid(ast, { prefix = 'flowchart TD\n', markStyle = info_1.MermaidDefaultMarkStyle, includeOnlyIds, mark } = {}) {
21
22
  let output = prefix;
22
23
  function showNode(n) {
24
+ if (includeOnlyIds && !includeOnlyIds.has(n.info.id)) {
25
+ return;
26
+ }
23
27
  const name = `${n.type} (${n.info.id})\\n${n.lexeme ?? ' '}`;
24
28
  output += ` n${n.info.id}(["${(0, mermaid_1.escapeMarkdown)(name)}"])\n`;
25
- if (n.info.parent !== undefined) {
29
+ if (mark?.has(n.info.id)) {
30
+ output += ` style n${n.info.id} ${markStyle.vertex}\n`;
31
+ }
32
+ if (n.info.parent !== undefined && (!includeOnlyIds || includeOnlyIds.has(n.info.parent))) {
26
33
  const context = n.info;
27
- const roleSuffix = context.role === "expr-list-child" /* RoleInParent.ExpressionListChild */ || context.role === "call-argument" /* RoleInParent.FunctionCallArgument */ || context.role === "function-def-param" /* RoleInParent.FunctionDefinitionParameter */ ? `-${context.index}` : '';
34
+ const roleSuffix = context.role === "expr-list-child" /* RoleInParent.ExpressionListChild */ || context.role === "call-arg" /* RoleInParent.FunctionCallArgument */ || context.role === "param" /* RoleInParent.FunctionDefinitionParameter */ ? `-${context.index}` : '';
28
35
  output += ` n${n.info.parent} -->|"${context.role}${roleSuffix}"| n${n.info.id}\n`;
29
36
  }
30
37
  if (n.type === type_1.RType.ExpressionList && n.grouping !== undefined) {
@@ -49,9 +56,8 @@ function normalizedAstToMermaid(ast, prefix = 'flowchart TD\n') {
49
56
  for (const f of ast.files) {
50
57
  // add a subgraph for each file
51
58
  if (ast.files.length !== 1 || (f.filePath && f.filePath !== flowr_file_1.FlowrFile.INLINE_PATH)) {
52
- output += ` subgraph "File: ${(0, mermaid_1.escapeMarkdown)(f.filePath ?? flowr_file_1.FlowrFile.INLINE_PATH)}"\n`;
53
59
  const direction = identifyMermaidDirection(prefix);
54
- output += ` direction ${direction}\n`;
60
+ output += ` subgraph "File: ${(0, mermaid_1.escapeMarkdown)(f.filePath ?? flowr_file_1.FlowrFile.INLINE_PATH)}" direction ${direction}\n`;
55
61
  showAst(f.root);
56
62
  output += ' end\n';
57
63
  }
@@ -68,7 +74,7 @@ function normalizedAstToMermaid(ast, prefix = 'flowchart TD\n') {
68
74
  /**
69
75
  * Use mermaid to visualize the normalized AST.
70
76
  */
71
- function normalizedAstToMermaidUrl(ast, prefix = 'flowchart TD\n') {
72
- return (0, mermaid_1.mermaidCodeToUrl)(normalizedAstToMermaid(ast, prefix));
77
+ function normalizedAstToMermaidUrl(ast, info) {
78
+ return (0, mermaid_1.mermaidCodeToUrl)(normalizedAstToMermaid(ast, info ?? {}));
73
79
  }
74
80
  //# sourceMappingURL=ast.js.map
@@ -1,5 +1,6 @@
1
1
  import type { NormalizedAst } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
2
2
  import { type ControlFlowInformation } from '../../control-flow/control-flow-graph';
3
+ import { type MermaidGraphPrinterInfo } from './info';
3
4
  /**
4
5
  * Convert the control flow graph to a mermaid string.
5
6
  * @param cfg - The control flow graph to convert.
@@ -7,8 +8,8 @@ import { type ControlFlowInformation } from '../../control-flow/control-flow-gra
7
8
  * @param prefix - The prefix to use for the mermaid string.
8
9
  * @param simplify - Whether to simplify the control flow graph (especially in the context of basic blocks).
9
10
  */
10
- export declare function cfgToMermaid(cfg: ControlFlowInformation, normalizedAst: NormalizedAst, prefix?: string, simplify?: boolean): string;
11
+ export declare function cfgToMermaid(cfg: ControlFlowInformation, normalizedAst: NormalizedAst, { prefix, simplify, markStyle, includeOnlyIds, mark }?: MermaidGraphPrinterInfo): string;
11
12
  /**
12
13
  * Use mermaid to visualize the normalized AST.
13
14
  */
14
- export declare function cfgToMermaidUrl(cfg: ControlFlowInformation, normalizedAst: NormalizedAst, prefix?: string): string;
15
+ export declare function cfgToMermaidUrl(cfg: ControlFlowInformation, normalizedAst: NormalizedAst, info?: MermaidGraphPrinterInfo): string;
@@ -7,6 +7,7 @@ const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
7
7
  const control_flow_graph_1 = require("../../control-flow/control-flow-graph");
8
8
  const reconstruct_1 = require("../../reconstruct/reconstruct");
9
9
  const auto_select_defaults_1 = require("../../reconstruct/auto-select/auto-select-defaults");
10
+ const info_1 = require("./info");
10
11
  function getLexeme(n) {
11
12
  return n ? n.info.fullLexeme ?? n.lexeme ?? '' : undefined;
12
13
  }
@@ -30,7 +31,7 @@ const getDirRegex = /flowchart\s+([A-Za-z]+)/;
30
31
  * @param prefix - The prefix to use for the mermaid string.
31
32
  * @param simplify - Whether to simplify the control flow graph (especially in the context of basic blocks).
32
33
  */
33
- function cfgToMermaid(cfg, normalizedAst, prefix = 'flowchart BT\n', simplify = false) {
34
+ function cfgToMermaid(cfg, normalizedAst, { prefix = 'flowchart BT\n', simplify = false, markStyle = info_1.MermaidDefaultMarkStyle, includeOnlyIds, mark } = {}) {
34
35
  let output = prefix;
35
36
  const dirIs = getDirRegex.exec(prefix)?.at(1) ?? 'LR';
36
37
  for (const [id, vertex] of cfg.graph.vertices(false)) {
@@ -52,6 +53,10 @@ function cfgToMermaid(cfg, normalizedAst, prefix = 'flowchart BT\n', simplify =
52
53
  output += ` direction ${dirIs}\n`;
53
54
  let last = undefined;
54
55
  for (const element of vertex.elems ?? []) {
56
+ if (includeOnlyIds && !includeOnlyIds.has(element.id)) {
57
+ last = undefined;
58
+ continue;
59
+ }
55
60
  const childNormalizedVertex = normalizedAst?.idMap.get(element.id);
56
61
  const childContent = getLexeme(childNormalizedVertex);
57
62
  output = cfgOfNode(vertex, childNormalizedVertex, element.id, childContent, output);
@@ -64,7 +69,7 @@ function cfgToMermaid(cfg, normalizedAst, prefix = 'flowchart BT\n', simplify =
64
69
  output += ' end\n';
65
70
  }
66
71
  }
67
- else {
72
+ else if (!includeOnlyIds || includeOnlyIds.has(id)) {
68
73
  output = cfgOfNode(vertex, normalizedVertex, id, content, output);
69
74
  }
70
75
  if (vertex.name === type_1.RType.ExpressionList && vertex.type === control_flow_graph_1.CfgVertexType.EndMarker) {
@@ -72,24 +77,39 @@ function cfgToMermaid(cfg, normalizedAst, prefix = 'flowchart BT\n', simplify =
72
77
  }
73
78
  }
74
79
  for (const [from, targets] of cfg.graph.edges()) {
80
+ if (includeOnlyIds && !includeOnlyIds.has(from)) {
81
+ continue;
82
+ }
75
83
  for (const [to, edge] of targets) {
84
+ if (includeOnlyIds && !includeOnlyIds.has(to)) {
85
+ continue;
86
+ }
76
87
  const edgeType = edge.label === 1 /* CfgEdgeType.Cd */ ? '-->' : '-.->';
77
88
  const edgeSuffix = edge.label === 1 /* CfgEdgeType.Cd */ ? ` (${edge.when})` : '';
78
89
  output += ` n${from} ${edgeType}|"${(0, mermaid_1.escapeMarkdown)((0, control_flow_graph_1.edgeTypeToString)(edge.label))}${edgeSuffix}"| n${to}\n`;
79
90
  }
80
91
  }
81
92
  for (const entryPoint of cfg.entryPoints) {
82
- output += ` style n${entryPoint} stroke:cyan,stroke-width:6.5px;`;
93
+ if (!includeOnlyIds || includeOnlyIds.has(entryPoint)) {
94
+ output += ` style n${entryPoint} stroke:cyan,stroke-width:6.5px;`;
95
+ }
83
96
  }
84
97
  for (const exitPoint of cfg.exitPoints) {
85
- output += ` style n${exitPoint} stroke:green,stroke-width:6.5px;`;
98
+ if (!includeOnlyIds || includeOnlyIds.has(exitPoint)) {
99
+ output += ` style n${exitPoint} stroke:green,stroke-width:6.5px;`;
100
+ }
101
+ }
102
+ if (mark) {
103
+ for (const id of mark.values()) {
104
+ output += ` style n${id} ${markStyle.vertex}`;
105
+ }
86
106
  }
87
107
  return output;
88
108
  }
89
109
  /**
90
110
  * Use mermaid to visualize the normalized AST.
91
111
  */
92
- function cfgToMermaidUrl(cfg, normalizedAst, prefix = 'flowchart BT\n') {
93
- return (0, mermaid_1.mermaidCodeToUrl)(cfgToMermaid(cfg, normalizedAst, prefix));
112
+ function cfgToMermaidUrl(cfg, normalizedAst, info) {
113
+ return (0, mermaid_1.mermaidCodeToUrl)(cfgToMermaid(cfg, normalizedAst, info ?? {}));
94
114
  }
95
115
  //# sourceMappingURL=cfg.js.map
@@ -2,13 +2,7 @@ import type { SourceRange } from '../range';
2
2
  import { type DataflowGraph } from '../../dataflow/graph/graph';
3
3
  import { type NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
4
4
  import { type IdentifierDefinition } from '../../dataflow/environments/identifier';
5
- type MarkVertex = NodeId;
6
- type MarkEdge = `${string}->${string}`;
7
- export type MermaidMarkdownMark = MarkVertex | MarkEdge;
8
- export interface MermaidMarkStyle {
9
- readonly vertex: string;
10
- readonly edge: string;
11
- }
5
+ import { type MermaidMarkdownMark, type MermaidMarkStyle } from './info';
12
6
  interface MermaidGraph {
13
7
  nodeLines: string[];
14
8
  edgeLines: string[];
@@ -15,6 +15,7 @@ const edge_1 = require("../../dataflow/graph/edge");
15
15
  const vertex_1 = require("../../dataflow/graph/vertex");
16
16
  const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
17
17
  const built_in_1 = require("../../dataflow/environments/built-in");
18
+ const info_1 = require("./info");
18
19
  /**
19
20
  * Prints a {@link SourceRange|range} as a human-readable string.
20
21
  */
@@ -147,7 +148,7 @@ function printEnvironmentToLines(env) {
147
148
  }
148
149
  return lines;
149
150
  }
150
- function vertexToMermaid(info, mermaid, id, idPrefix, mark) {
151
+ function vertexToMermaid(info, mermaid, id, idPrefix, mark, includeOnlyIds) {
151
152
  const fCall = info.tag === vertex_1.VertexType.FunctionCall;
152
153
  const { open, close } = mermaidNodeBrackets(info.tag);
153
154
  id = (0, mermaid_1.escapeId)(id);
@@ -184,6 +185,9 @@ function vertexToMermaid(info, mermaid, id, idPrefix, mark) {
184
185
  const artificialCdEdges = (info.cds ?? []).map(x => [x.id, { types: new Set([x.when ? 'CD-True' : 'CD-False']) }]);
185
186
  // eslint-disable-next-line prefer-const
186
187
  for (let [target, edge] of [...edges[1], ...artificialCdEdges]) {
188
+ if (includeOnlyIds && !includeOnlyIds.has(target)) {
189
+ continue;
190
+ }
187
191
  const originalTarget = target;
188
192
  target = (0, mermaid_1.escapeId)(target);
189
193
  const edgeTypes = typeof edge.types == 'number' ? new Set((0, edge_1.splitEdgeTypes)(edge.types)) : edge.types;
@@ -214,11 +218,11 @@ function vertexToMermaid(info, mermaid, id, idPrefix, mark) {
214
218
  }
215
219
  }
216
220
  // make the passing of root ids more performant again
217
- function graphToMermaidGraph(rootIds, { simplified, graph, prefix = 'flowchart BT', idPrefix = '', includeEnvironments = !simplified, mark, rootGraph, presentEdges = new Set(), markStyle = { vertex: 'stroke:teal,stroke-width:7px,stroke-opacity:.8;', edge: 'stroke:teal,stroke-width:4.2px,stroke-opacity:.8' } }) {
221
+ function graphToMermaidGraph(rootIds, { simplified, graph, prefix = 'flowchart BT', idPrefix = '', includeEnvironments = !simplified, mark, rootGraph, presentEdges = new Set(), markStyle = info_1.MermaidDefaultMarkStyle, includeOnlyIds }) {
218
222
  const mermaid = { nodeLines: prefix === null ? [] : [prefix], edgeLines: [], presentEdges, presentVertices: new Set(), mark, rootGraph: rootGraph ?? graph, includeEnvironments, markStyle, simplified };
219
223
  for (const [id, info] of graph.vertices(true)) {
220
224
  if (rootIds.has(id)) {
221
- vertexToMermaid(info, mermaid, id, idPrefix, mark);
225
+ vertexToMermaid(info, mermaid, id, idPrefix, mark, includeOnlyIds);
222
226
  }
223
227
  }
224
228
  return mermaid;
@@ -0,0 +1,17 @@
1
+ import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
2
+ type MarkVertex = NodeId;
3
+ type MarkEdge = `${string}->${string}`;
4
+ export type MermaidMarkdownMark = MarkVertex | MarkEdge;
5
+ export interface MermaidMarkStyle {
6
+ readonly vertex: string;
7
+ readonly edge: string;
8
+ }
9
+ export interface MermaidGraphPrinterInfo {
10
+ includeOnlyIds?: ReadonlySet<NodeId>;
11
+ mark?: ReadonlySet<MermaidMarkdownMark>;
12
+ markStyle?: MermaidMarkStyle;
13
+ prefix?: string;
14
+ simplify?: boolean;
15
+ }
16
+ export declare const MermaidDefaultMarkStyle: MermaidMarkStyle;
17
+ export {};
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MermaidDefaultMarkStyle = void 0;
4
+ exports.MermaidDefaultMarkStyle = { vertex: 'stroke:teal,stroke-width:7px,stroke-opacity:.8;', edge: 'stroke:teal,stroke-width:4.2px,stroke-opacity:.8' };
5
+ //# sourceMappingURL=info.js.map
package/util/prefix.d.ts CHANGED
@@ -1,12 +1,16 @@
1
1
  /**
2
- * given a potentially partial prefix like `hell`, this finds the matching name in the map, but only
2
+ * Given a potentially partial prefix like `hell`, this finds the matching name in the keys, but only
3
3
  * if it is unique!
4
+ * Please note, that `...` is considered special here, anything *afteR* `...` will not be matched by prefix but only by exact name,
5
+ * following R's pmatch semantics.
4
6
  * @example
5
7
  * ```typescript
6
- * findByPrefixIfUnique('hell', { 'hello', 'bar' }) // => 'hello'
7
- * findByPrefixIfUnique('hell', { 'hello', 'hell' }) // => 'hell' (full match)
8
- * findByPrefixIfUnique('h', { 'hello', 'hell' }) // => undefined (not unique)
9
- * findByPrefixIfUnique('', { 'hello', 'hell' }) // => undefined (empty prefix)
8
+ * findByPrefixIfUnique('hello', [ 'hello', 'bar' ]) // => 'hello'
9
+ * findByPrefixIfUnique('hell', [ 'hello', 'bar' ]) // => 'hello'
10
+ * findByPrefixIfUnique('hell', [ 'hello', 'hell' ]) // => 'hell' (full/exact match)
11
+ * findByPrefixIfUnique('hell', [ 'bar', '...', 'hello' ]) // => undefined (not matched due to being after `...`)
12
+ * findByPrefixIfUnique('h', [ 'hello', 'hell' ]) // => undefined (not unique)
13
+ * findByPrefixIfUnique('', [ 'hello', 'hell' ]) // => undefined (empty prefix)
10
14
  * ```
11
15
  */
12
16
  export declare function findByPrefixIfUnique(prefix: string, keys: readonly string[] | MapIterator<string>): string | undefined;
package/util/prefix.js CHANGED
@@ -2,14 +2,18 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.findByPrefixIfUnique = findByPrefixIfUnique;
4
4
  /**
5
- * given a potentially partial prefix like `hell`, this finds the matching name in the map, but only
5
+ * Given a potentially partial prefix like `hell`, this finds the matching name in the keys, but only
6
6
  * if it is unique!
7
+ * Please note, that `...` is considered special here, anything *afteR* `...` will not be matched by prefix but only by exact name,
8
+ * following R's pmatch semantics.
7
9
  * @example
8
10
  * ```typescript
9
- * findByPrefixIfUnique('hell', { 'hello', 'bar' }) // => 'hello'
10
- * findByPrefixIfUnique('hell', { 'hello', 'hell' }) // => 'hell' (full match)
11
- * findByPrefixIfUnique('h', { 'hello', 'hell' }) // => undefined (not unique)
12
- * findByPrefixIfUnique('', { 'hello', 'hell' }) // => undefined (empty prefix)
11
+ * findByPrefixIfUnique('hello', [ 'hello', 'bar' ]) // => 'hello'
12
+ * findByPrefixIfUnique('hell', [ 'hello', 'bar' ]) // => 'hello'
13
+ * findByPrefixIfUnique('hell', [ 'hello', 'hell' ]) // => 'hell' (full/exact match)
14
+ * findByPrefixIfUnique('hell', [ 'bar', '...', 'hello' ]) // => undefined (not matched due to being after `...`)
15
+ * findByPrefixIfUnique('h', [ 'hello', 'hell' ]) // => undefined (not unique)
16
+ * findByPrefixIfUnique('', [ 'hello', 'hell' ]) // => undefined (empty prefix)
13
17
  * ```
14
18
  */
15
19
  function findByPrefixIfUnique(prefix, keys) {
@@ -17,11 +21,15 @@ function findByPrefixIfUnique(prefix, keys) {
17
21
  return undefined;
18
22
  }
19
23
  let found = undefined;
24
+ let matchPartial = true;
20
25
  for (const key of keys) {
21
26
  if (key === prefix) {
22
27
  return key;
23
28
  }
24
- if (key.startsWith(prefix)) {
29
+ if (key === '...') {
30
+ matchPartial = false;
31
+ }
32
+ else if (matchPartial && key.startsWith(prefix)) {
25
33
  if (found) {
26
34
  return undefined;
27
35
  }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Represents R's `.standard_regexps` definitions.
3
+ * @see https://github.com/r-devel/r-svn/blob/44474af03ae77fd3b9a340279fa10cb698d106c3/src/library/base/R/utils.R#L52-L53
4
+ */
5
+ export declare const RStandardRegexp: {
6
+ /** `[[:alpha:]][[:alnum:].]*[[:alnum:]]` */
7
+ ValidPackageName: RegExp;
8
+ /** `([[:digit:]]+[.-]){1,}[[:digit:]]+` */
9
+ ValidPackageVersion: RegExp;
10
+ /** `[[:digit:]]+\\.[[:digit:]]+\\.[[:digit:]]+` */
11
+ ValidRSystemVersion: RegExp;
12
+ /** `([[:digit:]]+[.-])*[[:digit:]]+` */
13
+ ValidNumericVersion: RegExp;
14
+ };
15
+ /**
16
+ * Based on the C-definition:
17
+ * ```txt
18
+ * !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
19
+ * ```
20
+ */
21
+ export declare const RPunctuationChars = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~";
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RPunctuationChars = exports.RStandardRegexp = void 0;
4
+ /**
5
+ * Represents R's `.standard_regexps` definitions.
6
+ * @see https://github.com/r-devel/r-svn/blob/44474af03ae77fd3b9a340279fa10cb698d106c3/src/library/base/R/utils.R#L52-L53
7
+ */
8
+ exports.RStandardRegexp = {
9
+ /** `[[:alpha:]][[:alnum:].]*[[:alnum:]]` */
10
+ ValidPackageName: (/[A-Za-z][A-Za-z0-9._]*[A-Za-z0-9]/),
11
+ /** `([[:digit:]]+[.-]){1,}[[:digit:]]+` */
12
+ ValidPackageVersion: (/([0-9]+[.-])+[0-9]+/),
13
+ /** `[[:digit:]]+\\.[[:digit:]]+\\.[[:digit:]]+` */
14
+ ValidRSystemVersion: (/[0-9]+\.[0-9]+\.[0-9]+/),
15
+ /** `([[:digit:]]+[.-])*[[:digit:]]+` */
16
+ ValidNumericVersion: /([0-9]+[.-])*[0-9]+/
17
+ };
18
+ /**
19
+ * Based on the C-definition:
20
+ * ```txt
21
+ * !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
22
+ * ```
23
+ */
24
+ exports.RPunctuationChars = '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~';
25
+ //# sourceMappingURL=r-regex.js.map
package/util/text/args.js CHANGED
@@ -55,10 +55,19 @@ function splitAtEscapeSensitive(inputString, escapeQuote = true, split = ' ') {
55
55
  current = '';
56
56
  }
57
57
  else if (c === '"' || c === "'") {
58
- inQuotes = !inQuotes;
59
- if (!escapeQuote) {
60
- current += c;
58
+ if (!inQuotes) {
59
+ inQuotes = c;
60
+ if (escapeQuote) {
61
+ continue;
62
+ }
61
63
  }
64
+ else if (inQuotes === c) {
65
+ inQuotes = false;
66
+ if (escapeQuote) {
67
+ continue;
68
+ }
69
+ }
70
+ current += c;
62
71
  }
63
72
  else if (c === '\\' && escapeQuote) {
64
73
  escaped = true;
package/util/version.js CHANGED
@@ -6,7 +6,7 @@ exports.printVersionInformation = printVersionInformation;
6
6
  const semver_1 = require("semver");
7
7
  const assert_1 = require("./assert");
8
8
  // this is automatically replaced with the current version by release-it
9
- const version = '2.7.0';
9
+ const version = '2.7.3';
10
10
  /**
11
11
  * Retrieves the current flowR version as a new {@link SemVer} object.
12
12
  */