@eagleoutice/flowr 2.7.5 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (208) hide show
  1. package/README.md +68 -65
  2. package/cli/wiki.js +1 -1
  3. package/control-flow/extract-cfg.js +3 -3
  4. package/control-flow/useless-loop.d.ts +1 -1
  5. package/control-flow/useless-loop.js +2 -2
  6. package/dataflow/cluster.js +3 -3
  7. package/dataflow/environments/built-in-config.d.ts +8 -4
  8. package/dataflow/environments/built-in.d.ts +27 -14
  9. package/dataflow/environments/built-in.js +27 -12
  10. package/dataflow/environments/default-builtin-config.d.ts +614 -3
  11. package/dataflow/environments/default-builtin-config.js +50 -15
  12. package/dataflow/environments/environment.js +3 -2
  13. package/dataflow/environments/identifier.d.ts +5 -1
  14. package/dataflow/environments/reference-to-maybe.d.ts +2 -2
  15. package/dataflow/environments/reference-to-maybe.js +23 -14
  16. package/dataflow/environments/resolve-by-name.d.ts +6 -2
  17. package/dataflow/environments/resolve-by-name.js +5 -1
  18. package/dataflow/environments/scoping.js +1 -3
  19. package/dataflow/eval/resolve/alias-tracking.js +5 -1
  20. package/dataflow/extractor.js +3 -3
  21. package/dataflow/fn/exceptions-of-function.d.ts +13 -0
  22. package/dataflow/fn/exceptions-of-function.js +47 -0
  23. package/dataflow/fn/higher-order-function.d.ts +1 -1
  24. package/dataflow/fn/higher-order-function.js +3 -3
  25. package/dataflow/fn/recursive-function.d.ts +6 -0
  26. package/dataflow/fn/recursive-function.js +32 -0
  27. package/dataflow/graph/call-graph.d.ts +10 -0
  28. package/dataflow/graph/call-graph.js +209 -0
  29. package/dataflow/graph/dataflowgraph-builder.d.ts +7 -2
  30. package/dataflow/graph/dataflowgraph-builder.js +14 -9
  31. package/dataflow/graph/diff-dataflow-graph.js +96 -2
  32. package/dataflow/graph/graph.d.ts +10 -7
  33. package/dataflow/graph/graph.js +7 -8
  34. package/dataflow/graph/vertex.d.ts +6 -3
  35. package/dataflow/hooks.d.ts +30 -0
  36. package/dataflow/hooks.js +38 -0
  37. package/dataflow/info.d.ts +28 -5
  38. package/dataflow/info.js +66 -31
  39. package/dataflow/internal/linker.d.ts +13 -3
  40. package/dataflow/internal/linker.js +155 -53
  41. package/dataflow/internal/process/functions/call/argument/unpack-argument.d.ts +4 -0
  42. package/dataflow/internal/process/functions/call/argument/unpack-argument.js +7 -0
  43. package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +1 -1
  44. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +19 -3
  45. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +14 -0
  46. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +30 -0
  47. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +2 -1
  48. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +24 -17
  49. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +2 -1
  50. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +5 -1
  51. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +59 -21
  52. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +4 -3
  53. package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.d.ts +34 -0
  54. package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.js +92 -0
  55. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +1 -0
  56. package/dataflow/internal/process/functions/call/built-in/built-in-stop-if-not.d.ts +21 -0
  57. package/dataflow/internal/process/functions/call/built-in/built-in-stop-if-not.js +129 -0
  58. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +16 -0
  59. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +127 -0
  60. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +5 -3
  61. package/dataflow/internal/process/functions/call/common.d.ts +13 -1
  62. package/dataflow/internal/process/functions/call/common.js +33 -2
  63. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +13 -1
  64. package/dataflow/internal/process/functions/call/known-call-handling.js +29 -3
  65. package/dataflow/internal/process/functions/call/named-call-handling.js +2 -1
  66. package/dataflow/internal/process/functions/call/unnamed-call-handling.js +6 -4
  67. package/dataflow/internal/process/functions/process-argument.js +7 -6
  68. package/dataflow/internal/process/functions/process-parameter.js +2 -1
  69. package/dataflow/internal/process/process-named-call.d.ts +2 -2
  70. package/dataflow/internal/process/process-symbol.js +3 -2
  71. package/dataflow/internal/process/process-value.d.ts +3 -2
  72. package/dataflow/internal/process/process-value.js +8 -6
  73. package/dataflow/origin/dfg-get-origin.js +2 -1
  74. package/dataflow/origin/dfg-get-symbol-refs.js +1 -1
  75. package/documentation/doc-readme.d.ts +1 -1
  76. package/documentation/doc-readme.js +6 -6
  77. package/documentation/doc-util/doc-code.js +1 -1
  78. package/documentation/doc-util/doc-dfg.d.ts +1 -0
  79. package/documentation/doc-util/doc-dfg.js +7 -4
  80. package/documentation/doc-util/doc-query.d.ts +1 -0
  81. package/documentation/doc-util/doc-query.js +1 -1
  82. package/documentation/doc-util/doc-repl.d.ts +2 -1
  83. package/documentation/doc-util/doc-repl.js +11 -3
  84. package/documentation/wiki-analyzer.js +2 -0
  85. package/documentation/wiki-dataflow-graph.js +59 -16
  86. package/documentation/wiki-interface.js +33 -5
  87. package/documentation/wiki-mk/doc-context.d.ts +2 -1
  88. package/documentation/wiki-mk/doc-context.js +2 -2
  89. package/documentation/wiki-mk/doc-maker.js +4 -3
  90. package/documentation/wiki-normalized-ast.js +6 -0
  91. package/documentation/wiki-query.js +109 -1
  92. package/linter/linter-rules.d.ts +1 -1
  93. package/linter/rules/seeded-randomness.js +17 -12
  94. package/linter/rules/useless-loop.d.ts +1 -1
  95. package/package.json +9 -11
  96. package/project/cache/flowr-analyzer-cache.d.ts +11 -0
  97. package/project/cache/flowr-analyzer-cache.js +19 -0
  98. package/project/context/flowr-analyzer-dependencies-context.d.ts +6 -1
  99. package/project/context/flowr-analyzer-dependencies-context.js +6 -0
  100. package/project/context/flowr-analyzer-files-context.d.ts +5 -2
  101. package/project/context/flowr-analyzer-files-context.js +24 -17
  102. package/project/context/flowr-file.d.ts +9 -4
  103. package/project/context/flowr-file.js +20 -6
  104. package/project/flowr-analyzer.d.ts +11 -0
  105. package/project/flowr-analyzer.js +6 -0
  106. package/project/plugins/file-plugins/files/flowr-description-file.d.ts +11 -3
  107. package/project/plugins/file-plugins/files/flowr-description-file.js +38 -28
  108. package/project/plugins/file-plugins/files/flowr-jupyter-file.js +1 -1
  109. package/project/plugins/file-plugins/files/flowr-namespace-file.js +1 -1
  110. package/project/plugins/file-plugins/files/flowr-news-file.js +1 -1
  111. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +1 -1
  112. package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.js +1 -1
  113. package/project/plugins/file-plugins/flowr-analyzer-file-plugin.d.ts +4 -1
  114. package/project/plugins/file-plugins/flowr-analyzer-file-plugin.js +3 -0
  115. package/project/plugins/file-plugins/{flowr-analyzer-namespace-file-plugin.d.ts → flowr-analyzer-namespace-files-plugin.d.ts} +1 -1
  116. package/project/plugins/file-plugins/{flowr-analyzer-namespace-file-plugin.js → flowr-analyzer-namespace-files-plugin.js} +4 -4
  117. package/project/plugins/file-plugins/flowr-analyzer-test-file-plugin.d.ts +26 -0
  118. package/project/plugins/file-plugins/flowr-analyzer-test-file-plugin.js +39 -0
  119. package/project/plugins/file-plugins/flowr-analyzer-vignette-file-plugin.d.ts +26 -0
  120. package/project/plugins/file-plugins/flowr-analyzer-vignette-file-plugin.js +39 -0
  121. package/project/plugins/flowr-analyzer-plugin-defaults.js +6 -2
  122. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.js +3 -13
  123. package/project/plugins/package-version-plugins/package.d.ts +1 -1
  124. package/project/plugins/package-version-plugins/package.js +3 -3
  125. package/project/plugins/plugin-registry.d.ts +4 -2
  126. package/project/plugins/plugin-registry.js +6 -2
  127. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.d.ts +11 -0
  128. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +5 -2
  129. package/queries/catalog/call-context-query/call-context-query-format.d.ts +4 -12
  130. package/queries/catalog/call-graph-query/call-graph-query-executor.d.ts +6 -0
  131. package/queries/catalog/call-graph-query/call-graph-query-executor.js +21 -0
  132. package/queries/catalog/call-graph-query/call-graph-query-format.d.ts +21 -0
  133. package/queries/catalog/call-graph-query/call-graph-query-format.js +32 -0
  134. package/queries/catalog/dataflow-query/dataflow-query-executor.js +4 -3
  135. package/queries/catalog/dependencies-query/dependencies-query-executor.js +29 -3
  136. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +1 -0
  137. package/queries/catalog/dependencies-query/function-info/function-info.d.ts +8 -1
  138. package/queries/catalog/dependencies-query/function-info/write-functions.js +13 -0
  139. package/queries/catalog/does-call-query/does-call-query-executor.d.ts +6 -0
  140. package/queries/catalog/does-call-query/does-call-query-executor.js +100 -0
  141. package/queries/catalog/does-call-query/does-call-query-format.d.ts +51 -0
  142. package/queries/catalog/does-call-query/does-call-query-format.js +102 -0
  143. package/queries/catalog/files-query/files-query-executor.js +4 -4
  144. package/queries/catalog/files-query/files-query-format.d.ts +2 -1
  145. package/queries/catalog/files-query/files-query-format.js +18 -2
  146. package/queries/catalog/id-map-query/id-map-query-executor.js +4 -3
  147. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.d.ts +18 -0
  148. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.js +56 -0
  149. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.d.ts +34 -0
  150. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +54 -0
  151. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +3 -28
  152. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +6 -0
  153. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +12 -0
  154. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.d.ts +6 -0
  155. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.js +23 -0
  156. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.d.ts +28 -0
  157. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.js +44 -0
  158. package/queries/catalog/linter-query/linter-query-format.js +4 -1
  159. package/queries/catalog/location-map-query/location-map-query-executor.js +1 -1
  160. package/queries/catalog/normalized-ast-query/normalized-ast-query-executor.js +4 -3
  161. package/queries/catalog/project-query/project-query-executor.js +9 -3
  162. package/queries/catalog/project-query/project-query-format.d.ts +8 -3
  163. package/queries/catalog/project-query/project-query-format.js +35 -9
  164. package/queries/query.d.ts +34 -2
  165. package/queries/query.js +9 -0
  166. package/r-bridge/data/data.d.ts +10 -5
  167. package/r-bridge/data/data.js +11 -5
  168. package/r-bridge/lang-4.x/ast/model/model.d.ts +7 -7
  169. package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +2 -2
  170. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +2 -2
  171. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +2 -2
  172. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +5 -2
  173. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.js +8 -0
  174. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +2 -2
  175. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +2 -2
  176. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +3 -3
  177. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +2 -2
  178. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +2 -2
  179. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +2 -2
  180. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +2 -2
  181. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +2 -2
  182. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +2 -2
  183. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +2 -2
  184. package/r-bridge/lang-4.x/ast/parser/main/internal/other/normalize-comment.js +0 -1
  185. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +0 -2
  186. package/r-bridge/roxygen2/roxygen-ast.d.ts +218 -0
  187. package/r-bridge/roxygen2/roxygen-ast.js +82 -0
  188. package/r-bridge/roxygen2/roxygen-parse.d.ts +24 -0
  189. package/r-bridge/roxygen2/roxygen-parse.js +214 -0
  190. package/reconstruct/auto-select/magic-comments.js +4 -4
  191. package/slicing/static/slice-call.js +3 -4
  192. package/slicing/static/static-slicer.js +2 -2
  193. package/statistics/features/supported/defined-functions/defined-functions.js +1 -1
  194. package/util/collections/defaultmap.d.ts +3 -3
  195. package/util/mermaid/dfg.js +5 -5
  196. package/util/objects.js +1 -1
  197. package/util/r-author.d.ts +5 -0
  198. package/util/r-author.js +110 -0
  199. package/util/r-license.d.ts +32 -0
  200. package/util/r-license.js +217 -0
  201. package/util/r-version.d.ts +19 -0
  202. package/util/r-version.js +106 -0
  203. package/util/range.d.ts +6 -0
  204. package/util/range.js +7 -0
  205. package/util/simple-df/dfg-ascii.js +2 -2
  206. package/util/text/args.d.ts +9 -0
  207. package/util/text/args.js +65 -0
  208. package/util/version.js +1 -1
package/queries/query.js CHANGED
@@ -36,11 +36,17 @@ const df_shape_query_format_1 = require("./catalog/df-shape-query/df-shape-query
36
36
  const inspect_higher_order_query_format_1 = require("./catalog/inspect-higher-order-query/inspect-higher-order-query-format");
37
37
  const log_1 = require("../util/log");
38
38
  const files_query_format_1 = require("./catalog/files-query/files-query-format");
39
+ const call_graph_query_format_1 = require("./catalog/call-graph-query/call-graph-query-format");
40
+ const inspect_recursion_query_format_1 = require("./catalog/inspect-recursion-query/inspect-recursion-query-format");
41
+ const does_call_query_format_1 = require("./catalog/does-call-query/does-call-query-format");
42
+ const inspect_exception_query_format_1 = require("./catalog/inspect-exceptions-query/inspect-exception-query-format");
39
43
  exports.SupportedQueries = {
40
44
  'call-context': call_context_query_format_1.CallContextQueryDefinition,
41
45
  'config': config_query_format_1.ConfigQueryDefinition,
42
46
  'control-flow': control_flow_query_format_1.ControlFlowQueryDefinition,
47
+ 'call-graph': call_graph_query_format_1.CallGraphQueryDefinition,
43
48
  'dataflow': dataflow_query_format_1.DataflowQueryDefinition,
49
+ 'does-call': does_call_query_format_1.DoesCallQueryDefinition,
44
50
  'dataflow-lens': dataflow_lens_query_format_1.DataflowLensQueryDefinition,
45
51
  'df-shape': df_shape_query_format_1.DfShapeQueryDefinition,
46
52
  'files': files_query_format_1.FilesQueryDefinition,
@@ -52,7 +58,9 @@ exports.SupportedQueries = {
52
58
  'location-map': location_map_query_format_1.LocationMapQueryDefinition,
53
59
  'search': search_query_format_1.SearchQueryDefinition,
54
60
  'happens-before': happens_before_query_format_1.HappensBeforeQueryDefinition,
61
+ 'inspect-exception': inspect_exception_query_format_1.InspectExceptionQueryDefinition,
55
62
  'inspect-higher-order': inspect_higher_order_query_format_1.InspectHigherOrderQueryDefinition,
63
+ 'inspect-recursion': inspect_recursion_query_format_1.InspectRecursionQueryDefinition,
56
64
  'resolve-value': resolve_value_query_format_1.ResolveValueQueryDefinition,
57
65
  'project': project_query_format_1.ProjectQueryDefinition,
58
66
  'origin': origin_query_format_1.OriginQueryDefinition,
@@ -161,6 +169,7 @@ async function genericWrapReplFailIfNoRequest(fn, output, analyzer) {
161
169
  output.stderr(output.formatter.format('No requests to analyze were found.', { color: 1 /* Colors.Red */, style: 1 /* FontStyles.Bold */, effect: ansi_1.ColorEffect.Foreground })
162
170
  + '\nIf you consider this an error, please report a bug: '
163
171
  + (0, assert_1.getGuardIssueUrl)('analyzer found no requests to analyze'));
172
+ output.stderr((e instanceof Error) ? e.message : String(e));
164
173
  }
165
174
  else {
166
175
  throw e;
@@ -162,6 +162,11 @@ export declare const flowrCapabilities: {
162
162
  readonly supported: "partially";
163
163
  readonly description: "_Handle side-effects of function calls (e.g., `setXTo(3)`, ...) for example achieved with the super assignment._ We need more tests and handlings. Furthermore, we do not detect side effects with external files, network, logging, etc.";
164
164
  }];
165
+ }, {
166
+ readonly name: "Recursion";
167
+ readonly id: "recursion";
168
+ readonly supported: "fully";
169
+ readonly description: "_Recognize and resolve recursive calls like `f(3)` inside the definition of `f`, ..._";
165
170
  }, {
166
171
  readonly name: "Anonymous Calls";
167
172
  readonly id: "call-anonymous";
@@ -349,9 +354,9 @@ export declare const flowrCapabilities: {
349
354
  readonly supported: "fully";
350
355
  readonly description: "_Handle `return(3)`, ... in function definitions_";
351
356
  }, {
352
- readonly name: "exceptions";
353
- readonly id: "exceptions";
354
- readonly supported: "not";
357
+ readonly name: "Exceptions and Errors";
358
+ readonly id: "exceptions-and-errors";
359
+ readonly supported: "partially";
355
360
  readonly description: "_Handle `try`, `stop`, ..._";
356
361
  }];
357
362
  }, {
@@ -513,7 +518,7 @@ export declare const flowrCapabilities: {
513
518
  }, {
514
519
  readonly name: "Hooks";
515
520
  readonly id: "hooks";
516
- readonly supported: "not";
521
+ readonly supported: "partially";
517
522
  readonly description: "_Handle hooks like [`userhooks`](https://stat.ethz.ch/R-manual/R-devel/library/base/html/userhooks.html) and [`on.exit`](https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/on.exit)._ We do not support hooks.";
518
523
  }, {
519
524
  readonly name: "Precedence";
@@ -577,7 +582,7 @@ export declare const flowrCapabilities: {
577
582
  readonly name: string;
578
583
  readonly href: "https://adv-r.hadley.nz/s4.html";
579
584
  }];
580
- readonly supported: "not";
585
+ readonly supported: "partially";
581
586
  readonly description: "_Handle S4 classes and methods as one unit. Including Dispatch and Inheritance_ We do not support typing currently and do not handle objects of these classes \"as units.\"";
582
587
  }, {
583
588
  readonly name: "R6";
@@ -217,6 +217,12 @@ ${await (0, doc_dfg_1.printDfGraphForCode)(parser, code, { simplified: true })}
217
217
  }
218
218
  ]
219
219
  },
220
+ {
221
+ name: 'Recursion',
222
+ id: 'recursion',
223
+ supported: 'fully',
224
+ description: '_Recognize and resolve recursive calls like `f(3)` inside the definition of `f`, ..._'
225
+ },
220
226
  {
221
227
  name: 'Anonymous Calls',
222
228
  id: 'call-anonymous',
@@ -446,9 +452,9 @@ ${await (0, doc_dfg_1.printDfGraphForCode)(parser, code, { simplified: true })}
446
452
  description: '_Handle `return(3)`, ... in function definitions_'
447
453
  },
448
454
  {
449
- name: 'exceptions',
450
- id: 'exceptions',
451
- supported: 'not',
455
+ name: 'Exceptions and Errors',
456
+ id: 'exceptions-and-errors',
457
+ supported: 'partially',
452
458
  description: '_Handle `try`, `stop`, ..._'
453
459
  }
454
460
  ]
@@ -652,7 +658,7 @@ ${await (0, doc_dfg_1.printDfGraphForCode)(parser, code, { simplified: true })}
652
658
  {
653
659
  name: 'Hooks',
654
660
  id: 'hooks',
655
- supported: 'not',
661
+ supported: 'partially',
656
662
  description: '_Handle hooks like [`userhooks`](https://stat.ethz.ch/R-manual/R-devel/library/base/html/userhooks.html) and [`on.exit`](https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/on.exit)._ We do not support hooks.'
657
663
  },
658
664
  {
@@ -728,7 +734,7 @@ ${await (0, doc_dfg_1.printDfGraphForCode)(parser, code, { simplified: true })}
728
734
  url: [
729
735
  { name: AdvancedR('S4'), href: 'https://adv-r.hadley.nz/s4.html' }
730
736
  ],
731
- supported: 'not',
737
+ supported: 'partially',
732
738
  description: '_Handle S4 classes and methods as one unit. Including Dispatch and Inheritance_ We do not support typing currently and do not handle objects of these classes "as units."'
733
739
  },
734
740
  {
@@ -23,7 +23,7 @@ import type { RUnaryOp } from './nodes/r-unary-op';
23
23
  import type { RBinaryOp } from './nodes/r-binary-op';
24
24
  import type { RPipe } from './nodes/r-pipe';
25
25
  import type { RDelimiter } from './nodes/info/r-delimiter';
26
- /** Simply an empty type constraint used to say that there are additional decorations (see {@link Base}). */
26
+ /** Simply an empty type constraint used to say that there are additional decorations (see {@link RAstNodeBase}). */
27
27
  export type NoInfo = object;
28
28
  /**
29
29
  * Will be used to reconstruct the source of the given element in the R-ast.
@@ -57,27 +57,27 @@ interface Source {
57
57
  * @typeParam Info - can be used to store additional information about the node
58
58
  * @typeParam LexemeType - the type of the lexeme, probably always a `string` or `string | undefined`
59
59
  */
60
- export interface Base<Info, LexemeType = string> extends MergeableRecord {
60
+ export interface RAstNodeBase<Info, LexemeType = string> extends MergeableRecord {
61
61
  type: RType;
62
62
  /** the original string retrieved from R, can be used for further identification */
63
63
  lexeme: LexemeType;
64
64
  /** allows to attach additional information to the node */
65
65
  info: Info & Source;
66
66
  }
67
- export interface WithChildren<Info, Children extends Base<Info, string | undefined>> {
67
+ export interface WithChildren<Info, Children extends RAstNodeBase<Info, string | undefined>> {
68
68
  children: readonly Children[];
69
69
  }
70
70
  /**
71
71
  * A helper interface we use to "mark" leaf nodes.
72
72
  * <p>
73
73
  * Please be aware, that this is not marking from a language perspective,
74
- * as it is equivalent to the {@link Base} interface.
74
+ * as it is equivalent to the {@link RAstNodeBase} interface.
75
75
  * It is intended to help humans understand the code.
76
76
  */
77
- export interface Leaf<Info = NoInfo, LexemeType = string> extends Base<Info, LexemeType> {
77
+ export interface Leaf<Info = NoInfo, LexemeType = string> extends RAstNodeBase<Info, LexemeType> {
78
78
  }
79
79
  /**
80
- * Indicates, that the respective {@link Base} node has known source code
80
+ * Indicates, that the respective {@link RAstNodeBase} node has known source code
81
81
  * location information.
82
82
  */
83
83
  export interface Location {
@@ -95,7 +95,7 @@ export interface Location {
95
95
  export type NamespaceIdentifier = string;
96
96
  /**
97
97
  * Similar to {@link Location} this is an interface that indicates that
98
- * the respective {@link Base} node has a respective property (a namespace).
98
+ * the respective {@link RAstNodeBase} node has a respective property (a namespace).
99
99
  */
100
100
  export interface Namespace {
101
101
  /**
@@ -1,11 +1,11 @@
1
- import type { Base, Location, NoInfo, RNode } from '../model';
1
+ import type { RAstNodeBase, Location, NoInfo, RNode } from '../model';
2
2
  import type { RType } from '../type';
3
3
  import type { RArgument, RUnnamedArgument } from './r-argument';
4
4
  import type { EmptyArgument } from './r-function-call';
5
5
  /**
6
6
  * Represents an R Indexing operation with `$`, `@`, `[[`, or `[`.
7
7
  */
8
- interface RAccessBase<Info = NoInfo> extends Base<Info>, Location {
8
+ interface RAccessBase<Info = NoInfo> extends RAstNodeBase<Info>, Location {
9
9
  readonly type: RType.Access;
10
10
  /** the accessed container/variable/expression */
11
11
  accessed: RNode<Info>;
@@ -1,10 +1,10 @@
1
- import type { Base, Location, NoInfo, RNode } from '../model';
1
+ import type { RAstNodeBase, Location, NoInfo, RNode } from '../model';
2
2
  import type { RType } from '../type';
3
3
  import type { RSymbol } from './r-symbol';
4
4
  /**
5
5
  * Represents a named or unnamed argument of a function definition in R.
6
6
  */
7
- export interface RArgument<Info = NoInfo> extends Base<Info>, Location {
7
+ export interface RArgument<Info = NoInfo> extends RAstNodeBase<Info>, Location {
8
8
  readonly type: RType.Argument;
9
9
  name: RSymbol<Info> | undefined;
10
10
  value: RNode<Info> | undefined;
@@ -1,9 +1,9 @@
1
- import type { Base, Location, NoInfo, RNode } from '../model';
1
+ import type { RAstNodeBase, Location, NoInfo, RNode } from '../model';
2
2
  import type { RType } from '../type';
3
3
  /**
4
4
  * Operators like `+`, `==`, `&&`, etc.
5
5
  */
6
- export interface RBinaryOp<Info = NoInfo> extends Base<Info>, Location {
6
+ export interface RBinaryOp<Info = NoInfo> extends RAstNodeBase<Info>, Location {
7
7
  readonly type: RType.BinaryOp;
8
8
  operator: string;
9
9
  lhs: RNode<Info>;
@@ -1,5 +1,5 @@
1
1
  import type { Leaf, Location, NoInfo } from '../model';
2
- import type { RType } from '../type';
2
+ import { RType } from '../type';
3
3
  /**
4
4
  * ```r
5
5
  * # I am a line comment
@@ -7,5 +7,8 @@ import type { RType } from '../type';
7
7
  */
8
8
  export interface RComment<Info = NoInfo> extends Location, Leaf<Info> {
9
9
  readonly type: RType.Comment;
10
- content: string;
11
10
  }
11
+ /**
12
+ * Checks whether the given node is an R comment.
13
+ */
14
+ export declare function isRComment<Info = NoInfo>(node: unknown): node is RComment<Info>;
@@ -1,3 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isRComment = isRComment;
4
+ const type_1 = require("../type");
5
+ /**
6
+ * Checks whether the given node is an R comment.
7
+ */
8
+ function isRComment(node) {
9
+ return typeof node === 'object' && node !== null && node.type === type_1.RType.Comment;
10
+ }
3
11
  //# sourceMappingURL=r-comment.js.map
@@ -1,11 +1,11 @@
1
- import type { Base, Location, NoInfo, RNode, WithChildren } from '../model';
1
+ import type { RAstNodeBase, Location, NoInfo, RNode, WithChildren } from '../model';
2
2
  import type { RType } from '../type';
3
3
  import type { RSymbol } from './r-symbol';
4
4
  /**
5
5
  * Holds a list of expressions (and hence may be the root of an AST, summarizing all expressions in a file).
6
6
  * The `grouping` property holds information on if the expression list is structural or created by a wrapper like `{}` or `()`.
7
7
  */
8
- export interface RExpressionList<Info = NoInfo> extends WithChildren<Info, RNode<Info>>, Base<Info, string | undefined>, Partial<Location> {
8
+ export interface RExpressionList<Info = NoInfo> extends WithChildren<Info, RNode<Info>>, RAstNodeBase<Info, string | undefined>, Partial<Location> {
9
9
  readonly type: RType.ExpressionList;
10
10
  /** encodes wrappers like `{}` or `()` */
11
11
  readonly grouping: undefined | [start: RSymbol<Info>, end: RSymbol<Info>];
@@ -1,4 +1,4 @@
1
- import type { Base, Location, NoInfo, RNode } from '../model';
1
+ import type { RAstNodeBase, Location, NoInfo, RNode } from '../model';
2
2
  import type { RType } from '../type';
3
3
  import type { RSymbol } from './r-symbol';
4
4
  import type { RExpressionList } from './r-expression-list';
@@ -7,7 +7,7 @@ import type { RExpressionList } from './r-expression-list';
7
7
  * for(<variable> in <vector>) <body>
8
8
  * ```
9
9
  */
10
- export interface RForLoop<Info = NoInfo> extends Base<Info>, Location {
10
+ export interface RForLoop<Info = NoInfo> extends RAstNodeBase<Info>, Location {
11
11
  readonly type: RType.ForLoop;
12
12
  /** variable used in for-loop: <p> `for(<variable> in ...) ...`*/
13
13
  variable: RSymbol<Info>;
@@ -1,4 +1,4 @@
1
- import type { Base, Location, NoInfo, RNode } from '../model';
1
+ import type { RAstNodeBase, Location, NoInfo, RNode } from '../model';
2
2
  import type { RType } from '../type';
3
3
  import type { RSymbol } from './r-symbol';
4
4
  import type { RArgument } from './r-argument';
@@ -8,7 +8,7 @@ export type RFunctionArgument<Info = NoInfo> = RArgument<Info> | typeof EmptyArg
8
8
  * Calls of functions like `a()` and `foo(42, "hello")`.
9
9
  * @see RUnnamedFunctionCall
10
10
  */
11
- export interface RNamedFunctionCall<Info = NoInfo> extends Base<Info>, Location {
11
+ export interface RNamedFunctionCall<Info = NoInfo> extends RAstNodeBase<Info>, Location {
12
12
  readonly type: RType.FunctionCall;
13
13
  readonly named: true;
14
14
  functionName: RSymbol<Info>;
@@ -19,7 +19,7 @@ export interface RNamedFunctionCall<Info = NoInfo> extends Base<Info>, Location
19
19
  * Direct calls of functions like `(function(x) { x })(3)`.
20
20
  * @see RNamedFunctionCall
21
21
  */
22
- export interface RUnnamedFunctionCall<Info = NoInfo> extends Base<Info>, Location {
22
+ export interface RUnnamedFunctionCall<Info = NoInfo> extends RAstNodeBase<Info>, Location {
23
23
  readonly type: RType.FunctionCall;
24
24
  readonly named: false | undefined;
25
25
  calledFunction: RNode<Info>;
@@ -1,4 +1,4 @@
1
- import type { Base, Location, NoInfo, RNode } from '../model';
1
+ import type { RAstNodeBase, Location, NoInfo, RNode } from '../model';
2
2
  import type { RType } from '../type';
3
3
  import type { RParameter } from './r-parameter';
4
4
  /**
@@ -10,7 +10,7 @@ import type { RParameter } from './r-parameter';
10
10
  * \(<parameters>) <body>
11
11
  * ```
12
12
  */
13
- export interface RFunctionDefinition<Info = NoInfo> extends Base<Info>, Location {
13
+ export interface RFunctionDefinition<Info = NoInfo> extends RAstNodeBase<Info>, Location {
14
14
  readonly type: RType.FunctionDefinition;
15
15
  /** the R formals, to our knowledge, they must be unique */
16
16
  parameters: RParameter<Info>[];
@@ -1,4 +1,4 @@
1
- import type { Base, Location, NoInfo, RNode } from '../model';
1
+ import type { RAstNodeBase, Location, NoInfo, RNode } from '../model';
2
2
  import type { RType } from '../type';
3
3
  import type { RExpressionList } from './r-expression-list';
4
4
  /**
@@ -6,7 +6,7 @@ import type { RExpressionList } from './r-expression-list';
6
6
  * if(<condition>) <then> [else <otherwise>]
7
7
  * ```
8
8
  */
9
- export interface RIfThenElse<Info = NoInfo> extends Base<Info>, Location {
9
+ export interface RIfThenElse<Info = NoInfo> extends RAstNodeBase<Info>, Location {
10
10
  readonly type: RType.IfThenElse;
11
11
  condition: RNode<Info>;
12
12
  then: RExpressionList<Info>;
@@ -1,10 +1,10 @@
1
- import type { Base, Location, NoInfo, RNode } from '../model';
1
+ import type { RAstNodeBase, Location, NoInfo, RNode } from '../model';
2
2
  import type { RType } from '../type';
3
3
  import type { RSymbol } from './r-symbol';
4
4
  /**
5
5
  * Represents a parameter of a function definition in R.
6
6
  */
7
- export interface RParameter<Info = NoInfo> extends Base<Info>, Location {
7
+ export interface RParameter<Info = NoInfo> extends RAstNodeBase<Info>, Location {
8
8
  readonly type: RType.Parameter;
9
9
  name: RSymbol<Info>;
10
10
  /** is it the special ... parameter? */
@@ -1,9 +1,9 @@
1
- import type { Base, Location, NoInfo, RNode } from '../model';
1
+ import type { RAstNodeBase, Location, NoInfo, RNode } from '../model';
2
2
  import type { RType } from '../type';
3
3
  /**
4
4
  * Variant of the binary operator, specifically for the new, built-in pipe operator.
5
5
  */
6
- export interface RPipe<Info = NoInfo> extends Base<Info>, Location {
6
+ export interface RPipe<Info = NoInfo> extends RAstNodeBase<Info>, Location {
7
7
  readonly type: RType.Pipe;
8
8
  readonly lhs: RNode<Info>;
9
9
  readonly rhs: RNode<Info>;
@@ -1,4 +1,4 @@
1
- import type { Base, Location, NoInfo } from '../model';
1
+ import type { RAstNodeBase, Location, NoInfo } from '../model';
2
2
  import type { RType } from '../type';
3
3
  import type { RExpressionList } from './r-expression-list';
4
4
  /**
@@ -6,7 +6,7 @@ import type { RExpressionList } from './r-expression-list';
6
6
  * repeat <body>
7
7
  * ```
8
8
  */
9
- export interface RRepeatLoop<Info = NoInfo> extends Base<Info>, Location {
9
+ export interface RRepeatLoop<Info = NoInfo> extends RAstNodeBase<Info>, Location {
10
10
  readonly type: RType.RepeatLoop;
11
11
  body: RExpressionList<Info>;
12
12
  }
@@ -1,9 +1,9 @@
1
- import type { Base, Location, NoInfo, RNode } from '../model';
1
+ import type { RAstNodeBase, Location, NoInfo, RNode } from '../model';
2
2
  import type { RType } from '../type';
3
3
  /**
4
4
  * Unary operations like `+` and `-`
5
5
  */
6
- export interface RUnaryOp<Info = NoInfo> extends Base<Info>, Location {
6
+ export interface RUnaryOp<Info = NoInfo> extends RAstNodeBase<Info>, Location {
7
7
  readonly type: RType.UnaryOp;
8
8
  operator: string;
9
9
  operand: RNode<Info>;
@@ -1,4 +1,4 @@
1
- import type { Base, Location, NoInfo, RNode } from '../model';
1
+ import type { RAstNodeBase, Location, NoInfo, RNode } from '../model';
2
2
  import type { RType } from '../type';
3
3
  import type { RExpressionList } from './r-expression-list';
4
4
  /**
@@ -6,7 +6,7 @@ import type { RExpressionList } from './r-expression-list';
6
6
  * while(<condition>) <body>
7
7
  * ```
8
8
  */
9
- export interface RWhileLoop<Info = NoInfo> extends Base<Info>, Location {
9
+ export interface RWhileLoop<Info = NoInfo> extends RAstNodeBase<Info>, Location {
10
10
  readonly type: RType.WhileLoop;
11
11
  condition: RNode<Info>;
12
12
  body: RExpressionList<Info>;
@@ -16,7 +16,6 @@ function normalizeComment(data, obj) {
16
16
  return {
17
17
  type: type_1.RType.Comment,
18
18
  location,
19
- content: content.slice(1),
20
19
  lexeme: content,
21
20
  info: {
22
21
  fullRange: data.currentRange,
@@ -552,7 +552,6 @@ function convertTreeNode(node) {
552
552
  return {
553
553
  type: type_1.RType.Comment,
554
554
  location: range,
555
- content: node.text.slice(1),
556
555
  lexeme: node.text,
557
556
  ...defaultInfo
558
557
  };
@@ -594,7 +593,6 @@ function splitComments(nodes) {
594
593
  comments.push([node, {
595
594
  type: type_1.RType.Comment,
596
595
  location: makeSourceRange(node),
597
- content: node.text.slice(1),
598
596
  lexeme: node.text,
599
597
  info: {
600
598
  additionalTokens: [],