@eagleoutice/flowr 2.9.9 → 2.9.11

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 (198) hide show
  1. package/README.md +57 -54
  2. package/abstract-interpretation/absint-visitor.d.ts +16 -14
  3. package/abstract-interpretation/absint-visitor.js +93 -47
  4. package/abstract-interpretation/data-frame/mappers/arguments.d.ts +1 -1
  5. package/abstract-interpretation/data-frame/mappers/arguments.js +2 -2
  6. package/abstract-interpretation/data-frame/shape-inference.d.ts +2 -5
  7. package/abstract-interpretation/data-frame/shape-inference.js +4 -5
  8. package/abstract-interpretation/domains/abstract-domain.d.ts +4 -4
  9. package/abstract-interpretation/domains/abstract-domain.js +8 -8
  10. package/abstract-interpretation/domains/mapped-abstract-domain.d.ts +12 -5
  11. package/abstract-interpretation/domains/mapped-abstract-domain.js +47 -23
  12. package/abstract-interpretation/domains/set-range-domain.js +1 -1
  13. package/abstract-interpretation/domains/state-abstract-domain.d.ts +30 -1
  14. package/abstract-interpretation/domains/state-abstract-domain.js +130 -4
  15. package/abstract-interpretation/normalized-ast-fold.d.ts +2 -2
  16. package/abstract-interpretation/normalized-ast-fold.js +4 -3
  17. package/benchmark/slicer.js +5 -5
  18. package/benchmark/summarizer/first-phase/process.js +4 -4
  19. package/cli/repl/commands/repl-normalize.js +2 -2
  20. package/cli/repl/core.js +2 -2
  21. package/config.js +1 -1
  22. package/control-flow/cfg-simplification.d.ts +1 -0
  23. package/control-flow/cfg-simplification.js +1 -0
  24. package/control-flow/control-flow-graph.d.ts +1 -1
  25. package/control-flow/control-flow-graph.js +1 -2
  26. package/control-flow/extract-cfg.js +34 -15
  27. package/control-flow/semantic-cfg-guided-visitor.js +1 -0
  28. package/dataflow/cluster.js +1 -1
  29. package/dataflow/environments/built-in.d.ts +6 -15
  30. package/dataflow/environments/built-in.js +25 -33
  31. package/dataflow/environments/default-builtin-config.d.ts +4 -8
  32. package/dataflow/environments/default-builtin-config.js +8 -5
  33. package/dataflow/environments/reference-to-maybe.d.ts +8 -0
  34. package/dataflow/environments/reference-to-maybe.js +46 -3
  35. package/dataflow/eval/resolve/alias-tracking.d.ts +2 -2
  36. package/dataflow/eval/resolve/alias-tracking.js +6 -6
  37. package/dataflow/eval/resolve/resolve.js +12 -10
  38. package/dataflow/fn/exceptions-of-function.d.ts +1 -1
  39. package/dataflow/fn/exceptions-of-function.js +2 -1
  40. package/dataflow/graph/call-graph.d.ts +1 -1
  41. package/dataflow/graph/call-graph.js +4 -3
  42. package/dataflow/graph/dataflowgraph-builder.d.ts +1 -1
  43. package/dataflow/graph/dataflowgraph-builder.js +21 -21
  44. package/dataflow/graph/graph.d.ts +5 -5
  45. package/dataflow/graph/graph.js +36 -32
  46. package/dataflow/graph/unknown-side-effect.js +3 -1
  47. package/dataflow/info.d.ts +4 -0
  48. package/dataflow/info.js +2 -2
  49. package/dataflow/internal/linker.d.ts +4 -4
  50. package/dataflow/internal/linker.js +59 -33
  51. package/dataflow/internal/process/functions/call/argument/make-argument.d.ts +2 -1
  52. package/dataflow/internal/process/functions/call/argument/make-argument.js +3 -1
  53. package/dataflow/internal/process/functions/call/built-in/built-in-access.d.ts +1 -1
  54. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +2 -1
  55. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +3 -5
  56. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.d.ts +1 -1
  57. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +6 -5
  58. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +15 -6
  59. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +1 -1
  60. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +3 -2
  61. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +4 -4
  62. package/dataflow/internal/process/functions/call/built-in/built-in-local.js +3 -3
  63. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +2 -2
  64. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.d.ts +1 -1
  65. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +2 -1
  66. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +7 -7
  67. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +3 -3
  68. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +22 -11
  69. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +22 -19
  70. package/dataflow/internal/process/functions/call/common.d.ts +1 -1
  71. package/dataflow/internal/process/functions/call/common.js +43 -35
  72. package/dataflow/internal/process/functions/call/known-call-handling.js +0 -2
  73. package/dataflow/internal/process/functions/process-argument.d.ts +1 -1
  74. package/dataflow/internal/process/functions/process-argument.js +3 -3
  75. package/dataflow/internal/process/functions/process-parameter.js +2 -2
  76. package/dataflow/origin/dfg-get-origin.d.ts +1 -1
  77. package/dataflow/origin/dfg-get-origin.js +2 -2
  78. package/documentation/doc-util/doc-types.js +1 -1
  79. package/documentation/wiki-absint.js +7 -8
  80. package/documentation/wiki-cfg.js +3 -3
  81. package/documentation/wiki-mk/doc-context.d.ts +8 -0
  82. package/documentation/wiki-mk/doc-context.js +4 -0
  83. package/documentation/wiki-normalized-ast.d.ts +1 -1
  84. package/documentation/wiki-normalized-ast.js +9 -6
  85. package/linter/linter-format.d.ts +10 -0
  86. package/linter/linter-format.js +15 -0
  87. package/linter/rules/absolute-path.js +3 -3
  88. package/linter/rules/dead-code.js +1 -1
  89. package/linter/rules/file-path-validity.js +1 -1
  90. package/linter/rules/seeded-randomness.js +1 -1
  91. package/linter/rules/unused-definition.js +1 -1
  92. package/package.json +7 -7
  93. package/project/plugins/file-plugins/files/flowr-description-file.d.ts +9 -0
  94. package/project/plugins/file-plugins/files/flowr-description-file.js +12 -0
  95. package/queries/catalog/call-context-query/call-context-query-executor.js +1 -1
  96. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.d.ts +1 -1
  97. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +4 -5
  98. package/queries/catalog/dependencies-query/dependencies-query-executor.js +2 -1
  99. package/queries/catalog/dependencies-query/dependencies-query-format.js +6 -5
  100. package/queries/catalog/df-shape-query/df-shape-query-format.d.ts +1 -1
  101. package/queries/catalog/df-shape-query/df-shape-query-format.js +3 -3
  102. package/queries/catalog/does-call-query/does-call-query-executor.js +3 -3
  103. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.d.ts +1 -1
  104. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +2 -2
  105. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +1 -1
  106. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +1 -1
  107. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.d.ts +1 -1
  108. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.js +1 -1
  109. package/queries/query-print.d.ts +1 -1
  110. package/queries/query-print.js +4 -3
  111. package/r-bridge/lang-4.x/ast/model/model.d.ts +151 -4
  112. package/r-bridge/lang-4.x/ast/model/model.js +249 -0
  113. package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.d.ts +11 -1
  114. package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.js +13 -0
  115. package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +19 -1
  116. package/r-bridge/lang-4.x/ast/model/nodes/r-access.js +26 -0
  117. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +36 -3
  118. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.js +48 -13
  119. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +16 -1
  120. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.js +21 -0
  121. package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +11 -1
  122. package/r-bridge/lang-4.x/ast/model/nodes/r-break.js +14 -0
  123. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +8 -2
  124. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.js +11 -5
  125. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +23 -1
  126. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.js +32 -0
  127. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +11 -1
  128. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.js +14 -0
  129. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +19 -1
  130. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +26 -1
  131. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +11 -1
  132. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.js +14 -0
  133. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +11 -1
  134. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.js +14 -0
  135. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +12 -2
  136. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.js +14 -0
  137. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +20 -2
  138. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.js +26 -0
  139. package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +12 -2
  140. package/r-bridge/lang-4.x/ast/model/nodes/r-next.js +14 -0
  141. package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +8 -2
  142. package/r-bridge/lang-4.x/ast/model/nodes/r-number.js +11 -5
  143. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +17 -1
  144. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.js +22 -0
  145. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +16 -1
  146. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.js +22 -0
  147. package/r-bridge/lang-4.x/ast/model/nodes/r-project.d.ts +45 -8
  148. package/r-bridge/lang-4.x/ast/model/nodes/r-project.js +57 -16
  149. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +12 -2
  150. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.js +14 -0
  151. package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +15 -3
  152. package/r-bridge/lang-4.x/ast/model/nodes/r-string.js +21 -6
  153. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +21 -6
  154. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.js +22 -5
  155. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +16 -1
  156. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.js +21 -0
  157. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +11 -1
  158. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.js +14 -0
  159. package/r-bridge/lang-4.x/ast/model/processing/decorate.js +23 -17
  160. package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +39 -2
  161. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +52 -9
  162. package/r-bridge/lang-4.x/ast/model/processing/role.d.ts +18 -17
  163. package/r-bridge/lang-4.x/ast/model/processing/visitor.d.ts +8 -7
  164. package/r-bridge/lang-4.x/ast/model/processing/visitor.js +6 -13
  165. package/r-bridge/lang-4.x/ast/parser/json/parser.d.ts +1 -1
  166. package/r-bridge/lang-4.x/ast/parser/json/parser.js +1 -1
  167. package/r-bridge/lang-4.x/ast/parser/main/internal/expression/normalize-expression.js +4 -2
  168. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-number.js +1 -1
  169. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-string.js +2 -2
  170. package/r-bridge/lang-4.x/convert-values.d.ts +14 -5
  171. package/r-bridge/lang-4.x/convert-values.js +76 -72
  172. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +33 -15
  173. package/r-bridge/roxygen2/roxygen-parse.js +1 -1
  174. package/r-bridge/shell-executor.js +1 -1
  175. package/reconstruct/auto-select/magic-comments.js +4 -4
  176. package/reconstruct/reconstruct.js +2 -1
  177. package/search/search-executor/search-generators.js +2 -2
  178. package/slicing/criterion/filters/all-variables.js +1 -1
  179. package/slicing/criterion/parse.d.ts +1 -1
  180. package/slicing/criterion/parse.js +5 -3
  181. package/slicing/static/slice-call.d.ts +1 -1
  182. package/slicing/static/slice-call.js +2 -2
  183. package/statistics/features/supported/assignments/assignments.js +2 -2
  184. package/statistics/features/supported/control-flow/control-flow.js +2 -2
  185. package/statistics/features/supported/data-access/data-access.js +6 -5
  186. package/statistics/features/supported/defined-functions/defined-functions.js +9 -8
  187. package/statistics/features/supported/expression-list/statistics-expression-list.js +2 -2
  188. package/statistics/features/supported/loops/loops.js +6 -5
  189. package/statistics/features/supported/used-functions/used-functions.js +2 -2
  190. package/statistics/features/supported/variables/variables.js +8 -8
  191. package/util/mermaid/ast.js +3 -3
  192. package/util/mermaid/cfg.js +3 -4
  193. package/util/mermaid/dfg.d.ts +1 -1
  194. package/util/mermaid/dfg.js +13 -12
  195. package/util/simple-df/dfg-ascii.js +1 -1
  196. package/util/version.js +1 -1
  197. package/r-bridge/lang-4.x/ast/model/collect.d.ts +0 -10
  198. package/r-bridge/lang-4.x/ast/model/collect.js +0 -25
@@ -260,7 +260,8 @@ function convertTreeNode(node) {
260
260
  ...defaultInfo
261
261
  };
262
262
  case tree_sitter_types_1.TreeSitterType.IfStatement: {
263
- const [ifNode, /* ( */ , condition, /* ) */ , then, /* else */ , ...otherwise] = nonErrorChildren(node);
263
+ const [comments, children] = splitComments(nonErrorChildren(node));
264
+ const [ifNode, /* ( */ , condition, /* ) */ , then, /* else */ , ...otherwise] = children;
264
265
  const filteredOtherwise = otherwise.filter(n => n.type !== tree_sitter_types_1.TreeSitterType.ElseStatement);
265
266
  return {
266
267
  type: type_1.RType.IfThenElse,
@@ -269,11 +270,14 @@ function convertTreeNode(node) {
269
270
  otherwise: filteredOtherwise.length > 0 ? (0, normalize_meta_1.ensureExpressionList)(convertTreeNode(filteredOtherwise[0])) : undefined,
270
271
  location: makeSourceRange(ifNode),
271
272
  lexeme: ifNode.text,
272
- ...defaultInfo
273
+ info: {
274
+ ...defaultInfo.info,
275
+ adToks: comments.map(c => c[1]),
276
+ }
273
277
  };
274
278
  }
275
279
  case tree_sitter_types_1.TreeSitterType.ForStatement: {
276
- const children = nonErrorChildren(node);
280
+ const [comments, children] = splitComments(nonErrorChildren(node));
277
281
  const forNode = children[0]; // we follow with a (
278
282
  const variable = getNodesUntil(children, 'in', 2); // we follow with the "in"
279
283
  const sequence = getNodesUntil(children, ')', 2 + variable.length + 1); // we follow with a (
@@ -300,31 +304,38 @@ function convertTreeNode(node) {
300
304
  lexeme: forNode.text,
301
305
  info: {
302
306
  fullRange: range,
303
- adToks: variableComments.concat(sequenceComments).map(c => c[1]),
307
+ adToks: variableComments.concat(comments, sequenceComments).map(c => c[1]),
304
308
  fullLexeme: node.text,
305
309
  tsId: node.id
306
310
  }
307
311
  };
308
312
  }
309
313
  case tree_sitter_types_1.TreeSitterType.WhileStatement: {
310
- const [whileNode, /* ( */ , condition, /* ) */ , body] = nonErrorChildren(node);
314
+ const [comments, children] = splitComments(nonErrorChildren(node));
315
+ const [whileNode, /* ( */ , condition, /* ) */ , body] = children;
311
316
  return {
312
317
  type: type_1.RType.WhileLoop,
313
318
  condition: convertTreeNode(condition),
314
319
  body: (0, normalize_meta_1.ensureExpressionList)(convertTreeNode(body)),
315
320
  location: makeSourceRange(whileNode),
316
321
  lexeme: whileNode.text,
317
- ...defaultInfo
322
+ info: {
323
+ ...defaultInfo.info,
324
+ adToks: comments.map(c => c[1]),
325
+ }
318
326
  };
319
327
  }
320
328
  case tree_sitter_types_1.TreeSitterType.RepeatStatement: {
321
- const [repeatNode, body] = nonErrorChildren(node);
329
+ const [comments, [repeatNode, body]] = splitComments(nonErrorChildren(node));
322
330
  return {
323
331
  type: type_1.RType.RepeatLoop,
324
332
  body: (0, normalize_meta_1.ensureExpressionList)(convertTreeNode(body)),
325
333
  location: makeSourceRange(repeatNode),
326
334
  lexeme: repeatNode.text,
327
- ...defaultInfo
335
+ info: {
336
+ ...defaultInfo.info,
337
+ adToks: comments.map(c => c[1]),
338
+ }
328
339
  };
329
340
  }
330
341
  case tree_sitter_types_1.TreeSitterType.Call: {
@@ -404,7 +415,7 @@ function convertTreeNode(node) {
404
415
  return {
405
416
  type: type_1.RType.String,
406
417
  location: range,
407
- content: (0, convert_values_1.string2ts)(node.text),
418
+ content: convert_values_1.RStringValue.fromRLexeme(node.text),
408
419
  lexeme: node.text,
409
420
  ...defaultInfo
410
421
  };
@@ -416,7 +427,7 @@ function convertTreeNode(node) {
416
427
  return {
417
428
  type: type_1.RType.Number,
418
429
  location: range,
419
- content: (0, convert_values_1.number2ts)(node.text),
430
+ content: convert_values_1.RNumberValue.fromRLexeme(node.text),
420
431
  lexeme: node.text,
421
432
  ...defaultInfo
422
433
  };
@@ -449,7 +460,8 @@ function convertTreeNode(node) {
449
460
  const [func, content] = nonErrorChildren(node);
450
461
  // bracket is now [ or [[ and argsClosing is x] or x]]
451
462
  const [bracket, ...argsClosing] = nonErrorChildren(content);
452
- const args = (0, arrays_1.splitArrayOn)(argsClosing.slice(0, -1), x => x.type === 'comma');
463
+ const [argsComments, argsNoComments] = splitComments(argsClosing.slice(0, -1));
464
+ const args = (0, arrays_1.splitArrayOn)(argsNoComments, x => x.type === 'comma');
453
465
  return {
454
466
  type: type_1.RType.Access,
455
467
  operator: bracket.text,
@@ -457,7 +469,10 @@ function convertTreeNode(node) {
457
469
  access: args.map(n => n.length === 0 ? r_function_call_1.EmptyArgument : convertTreeNode(n[0])),
458
470
  location: makeSourceRange(bracket),
459
471
  lexeme: bracket.text,
460
- ...defaultInfo
472
+ info: {
473
+ ...defaultInfo.info,
474
+ adToks: argsComments.map(c => c[1]),
475
+ }
461
476
  };
462
477
  }
463
478
  case tree_sitter_types_1.TreeSitterType.ExtractOperator: {
@@ -523,7 +538,7 @@ function convertTreeNode(node) {
523
538
  };
524
539
  }
525
540
  case tree_sitter_types_1.TreeSitterType.Argument: {
526
- const children = nonErrorChildren(node);
541
+ const [commentChildren, children] = splitComments(nonErrorChildren(node));
527
542
  if (children.length === 1) {
528
543
  const [arg] = children;
529
544
  return {
@@ -532,7 +547,10 @@ function convertTreeNode(node) {
532
547
  value: convertTreeNode(arg),
533
548
  location: range,
534
549
  lexeme: node.text,
535
- ...defaultInfo
550
+ info: {
551
+ ...defaultInfo.info,
552
+ adToks: commentChildren.map(c => c[1]),
553
+ }
536
554
  };
537
555
  }
538
556
  else {
@@ -558,7 +576,7 @@ function convertTreeNode(node) {
558
576
  lexeme: nameNode.text,
559
577
  info: {
560
578
  fullRange: nameRange,
561
- adToks: [],
579
+ adToks: commentChildren.map(c => c[1]),
562
580
  fullLexeme: nameNode.text,
563
581
  tsId: nameNode.id
564
582
  }
@@ -36,7 +36,7 @@ function parseRoxygenCommentsOfNode(node, idMap) {
36
36
  let cur = node;
37
37
  do {
38
38
  comments = cur?.info.adToks
39
- ?.filter(r_comment_1.isRComment).filter(r => (0, assert_1.isNotUndefined)(r.lexeme));
39
+ ?.filter(r_comment_1.RComment.is).filter(r => (0, assert_1.isNotUndefined)(r.lexeme));
40
40
  cur = cur?.info.parent ? idMap?.get(cur.info.parent) : undefined;
41
41
  } while ((comments === undefined || comments.length === 0) && cur !== undefined);
42
42
  if (comments === undefined || comments.length === 0) {
@@ -35,7 +35,7 @@ class RShellExecutor {
35
35
  * Adds commands that should be executed for every {@link RShellExecutor#run|run}.
36
36
  */
37
37
  addPrerequisites(commands) {
38
- this.prerequisites.push(...(typeof commands == 'string' ? [commands] : commands));
38
+ this.prerequisites.push(...(typeof commands === 'string' ? [commands] : commands));
39
39
  return this;
40
40
  }
41
41
  /**
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.makeMagicCommentHandler = makeMagicCommentHandler;
4
- const visitor_1 = require("../../r-bridge/lang-4.x/ast/model/processing/visitor");
5
- const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
4
+ const r_comment_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-comment");
6
5
  const assert_1 = require("../../util/assert");
6
+ const r_project_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-project");
7
7
  function getLoc({ location, info: { fullRange } }) {
8
8
  const loc = location ?? fullRange;
9
9
  (0, assert_1.guard)(loc !== undefined, 'TODO: support location-less nodes!');
@@ -52,13 +52,13 @@ function makeMagicCommentHandler(and) {
52
52
  if (!lines) {
53
53
  lines = new Set();
54
54
  const startLineStack = [];
55
- (0, visitor_1.visitAst)(normalizedAst.ast.files.map(f => f.root), n => {
55
+ r_project_1.RProject.visitAst(normalizedAst.ast, n => {
56
56
  const comments = n.info.adToks;
57
57
  if (!comments) {
58
58
  return;
59
59
  }
60
60
  for (const c of comments) {
61
- if (c.type !== type_1.RType.Comment || !c.lexeme.startsWith('# flowr@')) {
61
+ if (!r_comment_1.RComment.is(c) || !c.lexeme.startsWith('# flowr@')) {
62
62
  continue;
63
63
  }
64
64
  const match = commentTriggerRegex.exec(c.lexeme);
@@ -9,6 +9,7 @@ exports.reconstructLogger = void 0;
9
9
  exports.reconstructToCode = reconstructToCode;
10
10
  const log_1 = require("../util/log");
11
11
  const assert_1 = require("../util/assert");
12
+ const model_1 = require("../r-bridge/lang-4.x/ast/model/model");
12
13
  const type_1 = require("../r-bridge/lang-4.x/ast/model/type");
13
14
  const r_function_call_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
14
15
  const stateful_fold_1 = require("../r-bridge/lang-4.x/ast/model/processing/stateful-fold");
@@ -19,7 +20,7 @@ function plain(text) {
19
20
  }
20
21
  exports.reconstructLogger = log_1.log.getSubLogger({ name: 'reconstruct' });
21
22
  function getLexeme(n) {
22
- return n.info.fullLexeme ?? n.lexeme ?? '';
23
+ return model_1.RNode.lexeme(n) ?? '';
23
24
  }
24
25
  function reconstructAsLeaf(leaf, configuration) {
25
26
  const selectionHasLeaf = configuration.selection.has(leaf.info.id) || configuration.autoSelectIf(leaf, configuration.fullAst);
@@ -7,8 +7,8 @@ const parse_1 = require("../../slicing/criterion/parse");
7
7
  const assert_1 = require("../../util/assert");
8
8
  const query_1 = require("../../queries/query");
9
9
  const search_enrichers_1 = require("./search-enrichers");
10
- const visitor_1 = require("../../r-bridge/lang-4.x/ast/model/processing/visitor");
11
10
  const log_1 = require("../../util/log");
11
+ const r_project_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-project");
12
12
  exports.searchLogger = log_1.log.getSubLogger({ name: 'search' });
13
13
  /**
14
14
  * All supported generators!
@@ -110,7 +110,7 @@ async function generateSyntax(input, args) {
110
110
  return new flowr_search_1.FlowrSearchElements([]);
111
111
  }
112
112
  const nodesByTreeSitterId = new Map();
113
- (0, visitor_1.visitAst)((await input.normalize()).ast.files.map(f => f.root), node => {
113
+ r_project_1.RProject.visitAst((await input.normalize()).ast, node => {
114
114
  const treeSitterInfo = node.info;
115
115
  if (treeSitterInfo.tsId) {
116
116
  nodesByTreeSitterId.set(treeSitterInfo.tsId, node);
@@ -16,7 +16,7 @@ const defaultAllVariablesCollectorFolds = {
16
16
  foldNumber: onLeaf,
17
17
  foldString: onLeaf,
18
18
  foldLogical: onLeaf,
19
- foldSymbol: (symbol) => (0, r_symbol_1.isSpecialSymbol)(symbol) ? [] : [symbol.info.id],
19
+ foldSymbol: (symbol) => r_symbol_1.RSymbol.isSpecial(symbol) ? [] : [symbol.info.id],
20
20
  foldAccess: (_, name, access) => [...name, ...access.filter(assert_1.isNotNull).flat()],
21
21
  foldBinaryOp: onBinary,
22
22
  foldPipe: onBinary,
@@ -1,4 +1,4 @@
1
- import { type NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
1
+ import { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
2
2
  import type { AstIdMap } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
3
3
  /** Either `line:column`, `line@variable-name`, or `$id` */
4
4
  export type SingleSlicingCriterion = `${number}:${number}` | `${number}@${string}` | `$${NodeId | number}`;
@@ -25,11 +25,13 @@ exports.CriteriaParseError = CriteriaParseError;
25
25
  function slicingCriterionToId(criterion, idMap) {
26
26
  let resolved;
27
27
  if (criterion.startsWith('$')) {
28
- resolved = (0, node_id_1.normalizeIdToNumberIfPossible)(criterion.substring(1));
28
+ resolved = node_id_1.NodeId.normalize(criterion.substring(1));
29
29
  }
30
30
  else if (criterion.includes('@')) {
31
- const [line, name] = criterion.split(/@(.*)/s); // only split at first occurrence
32
- resolved = conventionalCriteriaToId(parseInt(line), name, idMap);
31
+ const at = criterion.indexOf('@');
32
+ const line = parseInt(criterion.substring(0, at));
33
+ const name = criterion.substring(at + 1);
34
+ resolved = conventionalCriteriaToId(line, name, idMap);
33
35
  }
34
36
  else if (criterion.includes(':')) {
35
37
  const [line, column] = criterion.split(':').map(c => parseInt(c));
@@ -4,7 +4,7 @@ import { type Fingerprint } from './fingerprint';
4
4
  import type { DataflowGraphVertexFunctionCall, DataflowGraphVertexInfo } from '../../dataflow/graph/vertex';
5
5
  import type { REnvironmentInformation } from '../../dataflow/environments/environment';
6
6
  import { type DataflowGraph, type OutgoingEdges } from '../../dataflow/graph/graph';
7
- import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
7
+ import { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
8
8
  import type { DataflowInformation } from '../../dataflow/info';
9
9
  import type { ReadOnlyFlowrAnalyzerContext } from '../../project/context/flowr-analyzer-context';
10
10
  /**
@@ -7,9 +7,9 @@ const assert_1 = require("../../util/assert");
7
7
  const fingerprint_1 = require("./fingerprint");
8
8
  const linker_1 = require("../../dataflow/internal/linker");
9
9
  const graph_1 = require("../../dataflow/graph/graph");
10
- const built_in_1 = require("../../dataflow/environments/built-in");
11
10
  const resolve_by_name_1 = require("../../dataflow/environments/resolve-by-name");
12
11
  const edge_1 = require("../../dataflow/graph/edge");
12
+ const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
13
13
  const identifier_1 = require("../../dataflow/environments/identifier");
14
14
  const built_in_function_definition_1 = require("../../dataflow/internal/process/functions/call/built-in/built-in-function-definition");
15
15
  const static_slicer_1 = require("./static-slicer");
@@ -24,7 +24,7 @@ function getAllFunctionCallTargetsForSlice(dataflowGraph, callerInfo, baseEnviro
24
24
  const activeEnvironment = (0, built_in_function_definition_1.retrieveActiveEnvironment)(callerInfo.environment, baseEnvironment, ctx);
25
25
  const name = callerInfo.name;
26
26
  (0, assert_1.guard)(name !== undefined, () => `name of id: ${callerInfo.id} can not be found in id map`);
27
- const functionCallDefs = (0, resolve_by_name_1.resolveByName)(name, activeEnvironment, identifier_1.ReferenceType.Unknown)?.filter(d => !(0, built_in_1.isBuiltIn)(d.definedAt))?.map(d => d.nodeId) ?? [];
27
+ const functionCallDefs = (0, resolve_by_name_1.resolveByName)(name, activeEnvironment, identifier_1.ReferenceType.Unknown)?.filter(d => !node_id_1.NodeId.isBuiltIn(d.definedAt))?.map(d => d.nodeId) ?? [];
28
28
  for (const [target, outgoingEdge] of outgoingEdges[1].entries()) {
29
29
  if (edge_1.DfEdge.includesType(outgoingEdge, edge_1.EdgeType.Calls)) {
30
30
  functionCallDefs.push(target);
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.assignments = exports.AssignmentOperators = void 0;
4
4
  const common_syntax_probability_1 = require("../../common-syntax-probability");
5
5
  const post_process_1 = require("./post-process");
6
- const visitor_1 = require("../../../../r-bridge/lang-4.x/ast/model/processing/visitor");
7
6
  const type_1 = require("../../../../r-bridge/lang-4.x/ast/model/type");
8
7
  const operators_1 = require("../../../../r-bridge/lang-4.x/ast/model/operators");
8
+ const model_1 = require("../../../../r-bridge/lang-4.x/ast/model/model");
9
9
  const initialAssignmentInfo = {
10
10
  // operator to occurrence count
11
11
  assignmentOperator: {},
@@ -17,7 +17,7 @@ const initialAssignmentInfo = {
17
17
  exports.AssignmentOperators = new Set(operators_1.Operators.filter(op => operators_1.OperatorDatabase[op].usedAs === 'assignment'));
18
18
  function visitAssignment(info, input) {
19
19
  const assignmentStack = [];
20
- (0, visitor_1.visitAst)(input.normalizedRAst.ast.files.map(r => r.root), node => {
20
+ model_1.RNode.visitAst(input.normalizedRAst.ast.files.map(r => r.root), node => {
21
21
  if (node.type !== type_1.RType.BinaryOp || !exports.AssignmentOperators.has(node.operator)) {
22
22
  return;
23
23
  }
@@ -5,7 +5,7 @@ const common_syntax_probability_1 = require("../../common-syntax-probability");
5
5
  const post_process_1 = require("./post-process");
6
6
  const unpack_argument_1 = require("../../../../dataflow/internal/process/functions/call/argument/unpack-argument");
7
7
  const type_1 = require("../../../../r-bridge/lang-4.x/ast/model/type");
8
- const visitor_1 = require("../../../../r-bridge/lang-4.x/ast/model/processing/visitor");
8
+ const r_project_1 = require("../../../../r-bridge/lang-4.x/ast/model/nodes/r-project");
9
9
  const initialControlflowInfo = {
10
10
  ifThen: (0, common_syntax_probability_1.emptyCommonSyntaxTypeCounts)(),
11
11
  thenBody: (0, common_syntax_probability_1.emptyCommonSyntaxTypeCounts)(),
@@ -20,7 +20,7 @@ const initialControlflowInfo = {
20
20
  };
21
21
  function visitIfThenElse(info, input) {
22
22
  const ifThenElseStack = [];
23
- (0, visitor_1.visitAst)(input.normalizedRAst.ast.files.map(f => f.root), node => {
23
+ r_project_1.RProject.visitAst(input.normalizedRAst.ast, node => {
24
24
  if (node.type !== type_1.RType.IfThenElse) {
25
25
  if (node.type === type_1.RType.FunctionCall && node.named && node.functionName.content === 'switch') {
26
26
  const initialArg = (0, unpack_argument_1.unpackNonameArg)(node.arguments[0]);
@@ -5,10 +5,11 @@ const common_syntax_probability_1 = require("../../common-syntax-probability");
5
5
  const post_process_1 = require("./post-process");
6
6
  const assert_1 = require("../../../../util/assert");
7
7
  const type_1 = require("../../../../r-bridge/lang-4.x/ast/model/type");
8
- const visitor_1 = require("../../../../r-bridge/lang-4.x/ast/model/processing/visitor");
9
8
  const role_1 = require("../../../../r-bridge/lang-4.x/ast/model/processing/role");
10
9
  const statistics_file_1 = require("../../../output/statistics-file");
11
10
  const r_function_call_1 = require("../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
11
+ const r_project_1 = require("../../../../r-bridge/lang-4.x/ast/model/nodes/r-project");
12
+ const model_1 = require("../../../../r-bridge/lang-4.x/ast/model/model");
12
13
  const initialDataAccessInfo = {
13
14
  // for the nth argument, how many of them are constant, etc.
14
15
  singleBracket: {
@@ -46,7 +47,7 @@ function visitAccess(info, input) {
46
47
  const accessNest = [];
47
48
  const accessChain = [];
48
49
  const parentRoleCache = new Map();
49
- (0, visitor_1.visitAst)(input.normalizedRAst.ast.files.map(f => f.root), node => {
50
+ r_project_1.RProject.visitAst(input.normalizedRAst.ast, node => {
50
51
  if (node.type !== type_1.RType.Access) {
51
52
  return;
52
53
  }
@@ -54,11 +55,11 @@ function visitAccess(info, input) {
54
55
  let acc = false;
55
56
  let idxAcc = false;
56
57
  for (const role of roles) {
57
- if (role === "accessed" /* RoleInParent.Accessed */) {
58
+ if (role === "acc" /* RoleInParent.Accessed */) {
58
59
  acc = true;
59
60
  break; // we only account for the first one
60
61
  }
61
- else if (role === "index-acc" /* RoleInParent.IndexAccess */) {
62
+ else if (role === "idx-acc" /* RoleInParent.IndexAccess */) {
62
63
  idxAcc = true;
63
64
  break;
64
65
  }
@@ -76,7 +77,7 @@ function visitAccess(info, input) {
76
77
  }
77
78
  parentRoleCache.set(node.info.id, { acc, idxAcc });
78
79
  if (accessNest.length === 0 && accessChain.length === 0) { // store topmost, after add as it must not be a child to do that
79
- (0, statistics_file_1.appendStatisticsFile)(exports.dataAccess.name, 'dataAccess', [node.info.fullLexeme ?? node.lexeme], input.filepath);
80
+ (0, statistics_file_1.appendStatisticsFile)(exports.dataAccess.name, 'dataAccess', [model_1.RNode.lexeme(node)], input.filepath);
80
81
  }
81
82
  const op = node.operator;
82
83
  switch (op) {
@@ -6,9 +6,10 @@ const range_1 = require("../../../../util/range");
6
6
  const assert_1 = require("../../../../util/assert");
7
7
  const edge_1 = require("../../../../dataflow/graph/edge");
8
8
  const type_1 = require("../../../../r-bridge/lang-4.x/ast/model/type");
9
- const visitor_1 = require("../../../../r-bridge/lang-4.x/ast/model/processing/visitor");
10
9
  const statistics_file_1 = require("../../../output/statistics-file");
11
10
  const vertex_1 = require("../../../../dataflow/graph/vertex");
11
+ const r_project_1 = require("../../../../r-bridge/lang-4.x/ast/model/nodes/r-project");
12
+ const model_1 = require("../../../../r-bridge/lang-4.x/ast/model/model");
12
13
  const initialFunctionDefinitionInfo = {
13
14
  /** all, anonymous, assigned, non-assigned, ... */
14
15
  total: 0,
@@ -45,7 +46,7 @@ function retrieveAllCallsites(input, node, recursiveCalls) {
45
46
  function visitDefinitions(info, input) {
46
47
  const definitionStack = [];
47
48
  const allDefinitions = [];
48
- (0, visitor_1.visitAst)(input.normalizedRAst.ast.files.map(f => f.root), node => {
49
+ r_project_1.RProject.visitAst(input.normalizedRAst.ast, node => {
49
50
  if (node.type !== type_1.RType.FunctionDefinition) {
50
51
  return;
51
52
  }
@@ -67,15 +68,15 @@ function visitDefinitions(info, input) {
67
68
  if (definitionStack.length > 0) {
68
69
  info.nestedFunctions++;
69
70
  info.deepestNesting = Math.max(info.deepestNesting, definitionStack.length);
70
- (0, statistics_file_1.appendStatisticsFile)(exports.definedFunctions.name, 'nested-definitions', [node.info.fullLexeme ?? node.lexeme], input.filepath);
71
+ (0, statistics_file_1.appendStatisticsFile)(exports.definedFunctions.name, 'nested-definitions', [model_1.RNode.lexeme(node)], input.filepath);
71
72
  }
72
73
  // parameter names:
73
- const parameterNames = node.parameters.map(p => p.info.fullLexeme ?? p.lexeme);
74
+ const parameterNames = node.parameters.map(model_1.RNode.lexeme);
74
75
  (0, statistics_file_1.appendStatisticsFile)(exports.definedFunctions.name, 'usedParameterNames', parameterNames, input.filepath);
75
76
  const isLambda = node.lexeme.startsWith('\\');
76
77
  if (isLambda) {
77
78
  info.lambdasOnly++;
78
- (0, statistics_file_1.appendStatisticsFile)(exports.definedFunctions.name, 'allLambdas', [node.info.fullLexeme ?? node.lexeme], input.filepath);
79
+ (0, statistics_file_1.appendStatisticsFile)(exports.definedFunctions.name, 'allLambdas', [model_1.RNode.lexeme(node)], input.filepath);
79
80
  }
80
81
  definitionStack.push(node);
81
82
  // we find definitions with silly defined-by edges
@@ -86,7 +87,7 @@ function visitDefinitions(info, input) {
86
87
  if (edge_1.DfEdge.includesType(edge, edge_1.EdgeType.DefinedBy)) {
87
88
  const target = input.normalizedRAst.idMap.get(targetId);
88
89
  (0, assert_1.guard)(target !== undefined, 'Dataflow edge points to unknown node');
89
- const name = target.info.fullLexeme ?? target.lexeme;
90
+ const name = model_1.RNode.lexeme(target);
90
91
  if (name) {
91
92
  assigned.add(name);
92
93
  }
@@ -101,14 +102,14 @@ function visitDefinitions(info, input) {
101
102
  }
102
103
  // track all calls with the same name that do not already have a bound calls edge, superfluous if recursive tracking is explicit
103
104
  const recursiveCalls = [];
104
- (0, visitor_1.visitAst)(node.body, n => {
105
+ model_1.RNode.visitAst(node.body, n => {
105
106
  if (n.type === type_1.RType.FunctionCall && n.named && assigned.has(n.functionName.lexeme)) {
106
107
  recursiveCalls.push(n);
107
108
  }
108
109
  });
109
110
  // one recursive definition, but we record all
110
111
  info.recursive += recursiveCalls.length > 0 ? 1 : 0;
111
- (0, statistics_file_1.appendStatisticsFile)(exports.definedFunctions.name, 'recursive', recursiveCalls.map(n => n.info.fullLexeme ?? n.lexeme ?? 'unknown'), input.filepath);
112
+ (0, statistics_file_1.appendStatisticsFile)(exports.definedFunctions.name, 'recursive', recursiveCalls.map(n => model_1.RNode.lexeme(n) ?? 'unknown'), input.filepath);
112
113
  const lexeme = node.info.fullLexeme;
113
114
  const lexemeSplit = lexeme?.split('\n');
114
115
  allDefinitions.push({
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.expressionList = void 0;
4
4
  const post_process_1 = require("./post-process");
5
- const visitor_1 = require("../../../../r-bridge/lang-4.x/ast/model/processing/visitor");
6
5
  const type_1 = require("../../../../r-bridge/lang-4.x/ast/model/type");
6
+ const r_project_1 = require("../../../../r-bridge/lang-4.x/ast/model/nodes/r-project");
7
7
  const initialExpressionListInfo = {
8
8
  allExpressionLists: 0,
9
9
  deepestNesting: 0
@@ -11,7 +11,7 @@ const initialExpressionListInfo = {
11
11
  function visitLists(info, input) {
12
12
  let nest = -1; // we start with nesting 0
13
13
  let total = 0;
14
- (0, visitor_1.visitAst)(input.normalizedRAst.ast.files.map(f => f.root), node => {
14
+ r_project_1.RProject.visitAst(input.normalizedRAst.ast, node => {
15
15
  if (node.type === type_1.RType.ExpressionList) {
16
16
  nest++;
17
17
  total++;
@@ -5,7 +5,8 @@ const common_syntax_probability_1 = require("../../common-syntax-probability");
5
5
  const post_process_1 = require("./post-process");
6
6
  const type_1 = require("../../../../r-bridge/lang-4.x/ast/model/type");
7
7
  const statistics_file_1 = require("../../../output/statistics-file");
8
- const visitor_1 = require("../../../../r-bridge/lang-4.x/ast/model/processing/visitor");
8
+ const r_project_1 = require("../../../../r-bridge/lang-4.x/ast/model/nodes/r-project");
9
+ const model_1 = require("../../../../r-bridge/lang-4.x/ast/model/model");
9
10
  const initialLoopInfo = {
10
11
  forLoops: (0, common_syntax_probability_1.emptyCommonSyntaxTypeCounts)(),
11
12
  forLoopVar: (0, common_syntax_probability_1.emptyCommonSyntaxTypeCounts)(),
@@ -25,7 +26,7 @@ const isImplicitLoop = /[lsvmt]?apply/;
25
26
  function visitLoops(info, input) {
26
27
  // holds number of loops and their nesting depths
27
28
  const loopStack = [];
28
- (0, visitor_1.visitAst)(input.normalizedRAst.ast.files.map(f => f.root), node => {
29
+ r_project_1.RProject.visitAst(input.normalizedRAst.ast, node => {
29
30
  switch (node.type) {
30
31
  case type_1.RType.Next:
31
32
  info.nextStatements++;
@@ -36,7 +37,7 @@ function visitLoops(info, input) {
36
37
  case type_1.RType.FunctionCall:
37
38
  if (node.named && isImplicitLoop.test(node.functionName.lexeme)) {
38
39
  info.implicitLoops++;
39
- (0, statistics_file_1.appendStatisticsFile)(exports.loops.name, 'implicit-loop', [node.functionName.info.fullLexeme ?? node.functionName.lexeme], input.filepath);
40
+ (0, statistics_file_1.appendStatisticsFile)(exports.loops.name, 'implicit-loop', [model_1.RNode.lexeme(node.functionName)], input.filepath);
40
41
  }
41
42
  return;
42
43
  case type_1.RType.ForLoop:
@@ -54,7 +55,7 @@ function visitLoops(info, input) {
54
55
  break;
55
56
  default: return;
56
57
  }
57
- (0, statistics_file_1.appendStatisticsFile)(exports.loops.name, 'all-loops', [node.info.fullLexeme ?? node.lexeme], input.filepath);
58
+ (0, statistics_file_1.appendStatisticsFile)(exports.loops.name, 'all-loops', [model_1.RNode.lexeme(node)], input.filepath);
58
59
  if (loopStack.length > 0) {
59
60
  info.nestedExplicitLoops++;
60
61
  info.deepestExplicitNesting = Math.max(info.deepestExplicitNesting, loopStack.length);
@@ -62,7 +63,7 @@ function visitLoops(info, input) {
62
63
  loopStack.push(node);
63
64
  }, node => {
64
65
  // drop again :D
65
- if (node.type === type_1.RType.ForLoop || node.type === type_1.RType.WhileLoop || node.type === type_1.RType.RepeatLoop) {
66
+ if (model_1.RLoopConstructs.is(node)) {
66
67
  loopStack.pop();
67
68
  }
68
69
  });
@@ -4,12 +4,12 @@ exports.usedFunctions = exports.AllCallsFileBase = void 0;
4
4
  const common_syntax_probability_1 = require("../../common-syntax-probability");
5
5
  const post_process_1 = require("./post-process");
6
6
  const unpack_argument_1 = require("../../../../dataflow/internal/process/functions/call/argument/unpack-argument");
7
- const visitor_1 = require("../../../../r-bridge/lang-4.x/ast/model/processing/visitor");
8
7
  const type_1 = require("../../../../r-bridge/lang-4.x/ast/model/type");
9
8
  const statistics_file_1 = require("../../../output/statistics-file");
10
9
  const edge_1 = require("../../../../dataflow/graph/edge");
11
10
  const identifier_1 = require("../../../../dataflow/environments/identifier");
12
11
  const range_1 = require("../../../../util/range");
12
+ const r_project_1 = require("../../../../r-bridge/lang-4.x/ast/model/nodes/r-project");
13
13
  const initialFunctionUsageInfo = {
14
14
  allFunctionCalls: 0,
15
15
  args: {
@@ -51,7 +51,7 @@ function classifyArguments(args, existing) {
51
51
  function visitCalls(info, input) {
52
52
  const calls = [];
53
53
  const allCalls = [];
54
- (0, visitor_1.visitAst)(input.normalizedRAst.ast.files.map(f => f.root), node => {
54
+ r_project_1.RProject.visitAst(input.normalizedRAst.ast, node => {
55
55
  if (node.type !== type_1.RType.FunctionCall) {
56
56
  return;
57
57
  }
@@ -2,12 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.variables = void 0;
4
4
  const post_process_1 = require("./post-process");
5
- const visitor_1 = require("../../../../r-bridge/lang-4.x/ast/model/processing/visitor");
6
- const type_1 = require("../../../../r-bridge/lang-4.x/ast/model/type");
7
- const r_symbol_1 = require("../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
8
5
  const statistics_file_1 = require("../../../output/statistics-file");
9
6
  const vertex_1 = require("../../../../dataflow/graph/vertex");
10
7
  const range_1 = require("../../../../util/range");
8
+ const r_project_1 = require("../../../../r-bridge/lang-4.x/ast/model/nodes/r-project");
9
+ const r_symbol_1 = require("../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
10
+ const model_1 = require("../../../../r-bridge/lang-4.x/ast/model/model");
11
11
  const initialVariableInfo = {
12
12
  numberOfVariableUses: 0,
13
13
  numberOfDefinitions: 0,
@@ -16,8 +16,8 @@ const initialVariableInfo = {
16
16
  unknownVariables: 0
17
17
  };
18
18
  function visitVariables(info, input) {
19
- (0, visitor_1.visitAst)(input.normalizedRAst.ast.files.map(f => f.root), node => {
20
- if (node.type !== type_1.RType.Symbol || (0, r_symbol_1.isSpecialSymbol)(node)) {
19
+ r_project_1.RProject.visitAst(input.normalizedRAst.ast, node => {
20
+ if (!r_symbol_1.RSymbol.is(node) || r_symbol_1.RSymbol.isSpecial(node)) {
21
21
  return;
22
22
  }
23
23
  // search for the node in the DF graph
@@ -25,7 +25,7 @@ function visitVariables(info, input) {
25
25
  if (mayNode === undefined) {
26
26
  info.unknownVariables++;
27
27
  (0, statistics_file_1.appendStatisticsFile)(exports.variables.name, 'unknown', [[
28
- node.info.fullLexeme ?? node.lexeme,
28
+ model_1.RNode.lexeme(node),
29
29
  range_1.SourceRange.getStart(node.location)
30
30
  ]], input.filepath);
31
31
  return;
@@ -33,7 +33,7 @@ function visitVariables(info, input) {
33
33
  const [dfNode] = mayNode;
34
34
  if (dfNode.tag === vertex_1.VertexType.VariableDefinition) {
35
35
  info.numberOfDefinitions++;
36
- const lexeme = node.info.fullLexeme ?? node.lexeme;
36
+ const lexeme = model_1.RNode.lexeme(node);
37
37
  (0, statistics_file_1.appendStatisticsFile)(exports.variables.name, 'definedVariables', [[
38
38
  lexeme,
39
39
  range_1.SourceRange.getStart(node.location)
@@ -43,7 +43,7 @@ function visitVariables(info, input) {
43
43
  else if (dfNode.tag === 'use') {
44
44
  info.numberOfVariableUses++;
45
45
  (0, statistics_file_1.appendStatisticsFile)(exports.variables.name, 'usedVariables', [[
46
- node.info.fullLexeme ?? node.lexeme,
46
+ model_1.RNode.lexeme(node),
47
47
  range_1.SourceRange.getStart(node.location)
48
48
  ]], input.filepath);
49
49
  }
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalizedAstToMermaid = normalizedAstToMermaid;
4
4
  exports.normalizedAstToMermaidUrl = normalizedAstToMermaidUrl;
5
5
  const mermaid_1 = require("./mermaid");
6
- const visitor_1 = require("../../r-bridge/lang-4.x/ast/model/processing/visitor");
7
6
  const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
8
7
  const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
9
8
  const flowr_file_1 = require("../../project/context/flowr-file");
10
9
  const info_1 = require("./info");
10
+ const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
11
11
  function identifyMermaidDirection(prefix) {
12
12
  const directionMatch = prefix.match(/flowchart (TD|LR|RL|BT)/);
13
13
  if (directionMatch) {
@@ -31,7 +31,7 @@ function normalizedAstToMermaid(ast, { prefix = 'flowchart TD\n', markStyle = in
31
31
  }
32
32
  if (n.info.parent !== undefined && (!includeOnlyIds || includeOnlyIds.has(n.info.parent))) {
33
33
  const context = n.info;
34
- const roleSuffix = context.role === "expr-list-child" /* RoleInParent.ExpressionListChild */ || context.role === "call-arg" /* RoleInParent.FunctionCallArgument */ || context.role === "param" /* RoleInParent.FunctionDefinitionParameter */ ? `-${context.index}` : '';
34
+ const roleSuffix = context.role === "el-c" /* RoleInParent.ExpressionListChild */ || context.role === "call-arg" /* RoleInParent.FunctionCallArgument */ || context.role === "param" /* RoleInParent.FunctionDefinitionParameter */ ? `-${context.index}` : '';
35
35
  output += ` n${n.info.parent} -->|"${context.role}${roleSuffix}"| n${n.info.id}\n`;
36
36
  }
37
37
  if (n.type === type_1.RType.ExpressionList && n.grouping !== undefined) {
@@ -40,7 +40,7 @@ function normalizedAstToMermaid(ast, { prefix = 'flowchart TD\n', markStyle = in
40
40
  }
41
41
  }
42
42
  function showAst(ast) {
43
- (0, visitor_1.visitAst)(ast, n => {
43
+ model_1.RNode.visitAst(ast, n => {
44
44
  showNode(n);
45
45
  if (n.type === 'RAccess' && (n.operator !== '[' && n.operator !== '[[')) {
46
46
  for (const k of n.access) {