@eagleoutice/flowr 2.9.10 → 2.9.12

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 (175) hide show
  1. package/README.md +48 -50
  2. package/abstract-interpretation/absint-visitor.js +2 -1
  3. package/abstract-interpretation/data-frame/mappers/arguments.d.ts +1 -1
  4. package/abstract-interpretation/data-frame/mappers/arguments.js +2 -2
  5. package/abstract-interpretation/domains/set-range-domain.js +1 -1
  6. package/abstract-interpretation/normalized-ast-fold.d.ts +2 -2
  7. package/abstract-interpretation/normalized-ast-fold.js +4 -3
  8. package/benchmark/slicer.js +5 -5
  9. package/benchmark/summarizer/first-phase/process.js +4 -4
  10. package/cli/repl/commands/repl-normalize.js +2 -2
  11. package/cli/repl/core.js +2 -2
  12. package/config.js +1 -1
  13. package/control-flow/control-flow-graph.d.ts +1 -1
  14. package/control-flow/control-flow-graph.js +1 -2
  15. package/control-flow/extract-cfg.js +4 -3
  16. package/dataflow/cluster.js +12 -8
  17. package/dataflow/environments/built-in.d.ts +2 -15
  18. package/dataflow/environments/built-in.js +11 -31
  19. package/dataflow/eval/resolve/alias-tracking.d.ts +1 -1
  20. package/dataflow/eval/resolve/alias-tracking.js +2 -1
  21. package/dataflow/eval/resolve/resolve.js +4 -3
  22. package/dataflow/fn/exceptions-of-function.d.ts +1 -1
  23. package/dataflow/fn/exceptions-of-function.js +2 -1
  24. package/dataflow/graph/call-graph.d.ts +1 -1
  25. package/dataflow/graph/call-graph.js +4 -3
  26. package/dataflow/graph/dataflowgraph-builder.d.ts +1 -1
  27. package/dataflow/graph/dataflowgraph-builder.js +21 -21
  28. package/dataflow/graph/graph.d.ts +4 -4
  29. package/dataflow/graph/graph.js +27 -22
  30. package/dataflow/graph/quads.js +4 -7
  31. package/dataflow/internal/linker.d.ts +2 -2
  32. package/dataflow/internal/linker.js +15 -14
  33. package/dataflow/internal/process/functions/call/argument/make-argument.d.ts +2 -1
  34. package/dataflow/internal/process/functions/call/argument/make-argument.js +2 -1
  35. package/dataflow/internal/process/functions/call/built-in/built-in-access.d.ts +1 -1
  36. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +2 -1
  37. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +3 -5
  38. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.d.ts +1 -1
  39. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +6 -5
  40. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +1 -1
  41. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +3 -2
  42. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +4 -4
  43. package/dataflow/internal/process/functions/call/built-in/built-in-local.js +3 -3
  44. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.d.ts +1 -1
  45. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +2 -1
  46. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +3 -3
  47. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +3 -3
  48. package/dataflow/internal/process/functions/call/common.d.ts +1 -1
  49. package/dataflow/internal/process/functions/call/common.js +43 -35
  50. package/dataflow/internal/process/functions/process-argument.d.ts +1 -1
  51. package/dataflow/internal/process/functions/process-argument.js +3 -3
  52. package/dataflow/internal/process/functions/process-parameter.js +2 -2
  53. package/dataflow/origin/dfg-get-origin.d.ts +1 -1
  54. package/dataflow/origin/dfg-get-origin.js +2 -2
  55. package/documentation/doc-util/doc-types.js +1 -1
  56. package/documentation/wiki-cfg.js +3 -3
  57. package/documentation/wiki-dataflow-graph.js +86 -31
  58. package/documentation/wiki-engine.js +18 -0
  59. package/documentation/wiki-mk/doc-context.d.ts +52 -11
  60. package/documentation/wiki-mk/doc-context.js +20 -13
  61. package/documentation/wiki-normalized-ast.d.ts +1 -1
  62. package/documentation/wiki-normalized-ast.js +9 -6
  63. package/linter/linter-format.d.ts +10 -0
  64. package/linter/linter-format.js +15 -0
  65. package/linter/rules/absolute-path.js +3 -3
  66. package/linter/rules/file-path-validity.js +1 -1
  67. package/package.json +1 -1
  68. package/project/plugins/file-plugins/files/flowr-description-file.d.ts +5 -0
  69. package/project/plugins/file-plugins/files/flowr-description-file.js +8 -0
  70. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.d.ts +1 -1
  71. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +4 -5
  72. package/queries/catalog/dependencies-query/dependencies-query-executor.js +2 -1
  73. package/queries/catalog/dependencies-query/dependencies-query-format.js +6 -5
  74. package/queries/catalog/dependencies-query/function-info/library-functions.js +2 -1
  75. package/queries/catalog/dependencies-query/function-info/read-functions.js +1 -1
  76. package/queries/catalog/dependencies-query/function-info/visualize-functions.js +9 -1
  77. package/queries/catalog/dependencies-query/function-info/write-functions.js +1 -0
  78. package/queries/catalog/does-call-query/does-call-query-executor.js +3 -3
  79. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.d.ts +1 -1
  80. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +2 -2
  81. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +1 -1
  82. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +1 -1
  83. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.d.ts +1 -1
  84. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.js +1 -1
  85. package/queries/query-print.d.ts +1 -1
  86. package/queries/query-print.js +4 -3
  87. package/r-bridge/lang-4.x/ast/model/model.d.ts +151 -4
  88. package/r-bridge/lang-4.x/ast/model/model.js +249 -0
  89. package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.d.ts +11 -1
  90. package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.js +13 -0
  91. package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +19 -1
  92. package/r-bridge/lang-4.x/ast/model/nodes/r-access.js +26 -0
  93. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +36 -3
  94. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.js +48 -13
  95. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +16 -1
  96. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.js +21 -0
  97. package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +11 -1
  98. package/r-bridge/lang-4.x/ast/model/nodes/r-break.js +14 -0
  99. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +8 -2
  100. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.js +11 -5
  101. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +23 -1
  102. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.js +32 -0
  103. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +11 -1
  104. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.js +14 -0
  105. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +19 -1
  106. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +26 -1
  107. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +11 -1
  108. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.js +14 -0
  109. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +11 -1
  110. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.js +14 -0
  111. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +12 -2
  112. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.js +14 -0
  113. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +20 -2
  114. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.js +26 -0
  115. package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +12 -2
  116. package/r-bridge/lang-4.x/ast/model/nodes/r-next.js +14 -0
  117. package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +8 -2
  118. package/r-bridge/lang-4.x/ast/model/nodes/r-number.js +11 -5
  119. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +17 -1
  120. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.js +22 -0
  121. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +16 -1
  122. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.js +22 -0
  123. package/r-bridge/lang-4.x/ast/model/nodes/r-project.d.ts +45 -8
  124. package/r-bridge/lang-4.x/ast/model/nodes/r-project.js +57 -16
  125. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +12 -2
  126. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.js +14 -0
  127. package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +15 -3
  128. package/r-bridge/lang-4.x/ast/model/nodes/r-string.js +21 -6
  129. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +21 -6
  130. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.js +22 -5
  131. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +16 -1
  132. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.js +21 -0
  133. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +11 -1
  134. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.js +14 -0
  135. package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +39 -2
  136. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +52 -9
  137. package/r-bridge/lang-4.x/ast/model/processing/visitor.d.ts +8 -7
  138. package/r-bridge/lang-4.x/ast/model/processing/visitor.js +6 -13
  139. package/r-bridge/lang-4.x/ast/parser/json/parser.d.ts +1 -1
  140. package/r-bridge/lang-4.x/ast/parser/json/parser.js +1 -1
  141. package/r-bridge/lang-4.x/ast/parser/main/internal/expression/normalize-expression.js +4 -2
  142. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-number.js +1 -1
  143. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-string.js +2 -2
  144. package/r-bridge/lang-4.x/convert-values.d.ts +14 -5
  145. package/r-bridge/lang-4.x/convert-values.js +76 -72
  146. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +2 -2
  147. package/r-bridge/roxygen2/roxygen-parse.js +1 -1
  148. package/r-bridge/shell-executor.js +1 -1
  149. package/reconstruct/auto-select/magic-comments.js +4 -4
  150. package/reconstruct/reconstruct.js +2 -1
  151. package/search/search-executor/search-generators.js +2 -2
  152. package/slicing/criterion/filters/all-variables.js +1 -1
  153. package/slicing/criterion/parse.d.ts +1 -1
  154. package/slicing/criterion/parse.js +5 -3
  155. package/slicing/static/slice-call.d.ts +1 -1
  156. package/slicing/static/slice-call.js +2 -2
  157. package/statistics/features/supported/assignments/assignments.js +2 -2
  158. package/statistics/features/supported/control-flow/control-flow.js +2 -2
  159. package/statistics/features/supported/data-access/data-access.js +4 -3
  160. package/statistics/features/supported/defined-functions/defined-functions.js +9 -8
  161. package/statistics/features/supported/expression-list/statistics-expression-list.js +2 -2
  162. package/statistics/features/supported/loops/loops.js +6 -5
  163. package/statistics/features/supported/used-functions/used-functions.js +2 -2
  164. package/statistics/features/supported/variables/variables.js +8 -8
  165. package/util/mermaid/ast.js +2 -2
  166. package/util/mermaid/cfg.js +3 -4
  167. package/util/mermaid/dfg.d.ts +9 -1
  168. package/util/mermaid/dfg.js +13 -9
  169. package/util/quads.js +14 -6
  170. package/util/range.d.ts +3 -0
  171. package/util/range.js +3 -0
  172. package/util/simple-df/dfg-ascii.js +1 -1
  173. package/util/version.js +1 -1
  174. package/r-bridge/lang-4.x/ast/model/collect.d.ts +0 -10
  175. package/r-bridge/lang-4.x/ast/model/collect.js +0 -25
@@ -1,3 +1,35 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RExpressionList = void 0;
4
+ const type_1 = require("../type");
5
+ /**
6
+ * Helper for working with {@link RExpressionList} AST nodes.
7
+ */
8
+ exports.RExpressionList = {
9
+ name: 'RExpressionList',
10
+ /**
11
+ * Type guard for {@link RExpressionList} nodes.
12
+ */
13
+ is(node) {
14
+ return node?.type === type_1.RType.ExpressionList;
15
+ },
16
+ /**
17
+ * Type guard for implicit {@link RExpressionList} nodes, i.e., expression lists that are not created by a wrapper like `{}`.
18
+ */
19
+ isImplicit(node) {
20
+ return exports.RExpressionList.is(node) && node.grouping === undefined;
21
+ },
22
+ /**
23
+ * Returns the grouping symbol at the start of the expression list, if it exists. For example, for an expression list created by `{ ... }`, this would return the symbol for `{`.
24
+ */
25
+ groupStart(node) {
26
+ return node.grouping?.[0];
27
+ },
28
+ /**
29
+ * Returns the grouping symbol at the end of the expression list, if it exists. For example, for an expression list created by `{ ... }`, this would return the symbol for `}`.
30
+ */
31
+ groupEnd(node) {
32
+ return node.grouping?.[1];
33
+ }
34
+ };
3
35
  //# sourceMappingURL=r-expression-list.js.map
@@ -1,5 +1,5 @@
1
1
  import type { RAstNodeBase, Location, NoInfo, RNode } from '../model';
2
- import type { RType } from '../type';
2
+ import { RType } from '../type';
3
3
  import type { RSymbol } from './r-symbol';
4
4
  import type { RExpressionList } from './r-expression-list';
5
5
  /**
@@ -16,3 +16,13 @@ export interface RForLoop<Info = NoInfo> extends RAstNodeBase<Info>, Location {
16
16
  /** body used in for-loop: <p> `for(... in ...) <body>`*/
17
17
  body: RExpressionList<Info>;
18
18
  }
19
+ /**
20
+ * Helper for working with {@link RForLoop} AST nodes.
21
+ */
22
+ export declare const RForLoop: {
23
+ readonly name: "RForLoop";
24
+ /**
25
+ * Type guard for RForLoop nodes.
26
+ */
27
+ readonly is: <Info = object>(this: void, node: RNode<Info> | undefined) => node is RForLoop<Info>;
28
+ };
@@ -1,3 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RForLoop = void 0;
4
+ const type_1 = require("../type");
5
+ /**
6
+ * Helper for working with {@link RForLoop} AST nodes.
7
+ */
8
+ exports.RForLoop = {
9
+ name: 'RForLoop',
10
+ /**
11
+ * Type guard for RForLoop nodes.
12
+ */
13
+ is(node) {
14
+ return node?.type === type_1.RType.ForLoop;
15
+ }
16
+ };
3
17
  //# sourceMappingURL=r-for-loop.js.map
@@ -1,5 +1,5 @@
1
1
  import type { RAstNodeBase, Location, NoInfo, RNode } from '../model';
2
- import type { RType } from '../type';
2
+ import { RType } from '../type';
3
3
  import type { RSymbol } from './r-symbol';
4
4
  import type { RArgument } from './r-argument';
5
5
  export declare const EmptyArgument = "<>";
@@ -29,3 +29,21 @@ export interface RUnnamedFunctionCall<Info = NoInfo> extends RAstNodeBase<Info>,
29
29
  readonly arguments: readonly RFunctionArgument<Info>[];
30
30
  }
31
31
  export type RFunctionCall<Info = NoInfo> = RNamedFunctionCall<Info> | RUnnamedFunctionCall<Info>;
32
+ /**
33
+ * Helper for working with {@link RFunctionCall} AST nodes.
34
+ */
35
+ export declare const RFunctionCall: {
36
+ readonly name: "RFunctionCall";
37
+ /**
38
+ * Type guard for {@link RFunctionCall} nodes.
39
+ */
40
+ readonly is: <Info = object>(this: void, node: RNode<Info> | undefined) => node is RFunctionCall<Info>;
41
+ /**
42
+ * Type guard for {@link RNamedFunctionCall} nodes.
43
+ */
44
+ readonly isNamed: <Info = object>(this: void, node: RNode<Info> | undefined) => node is RNamedFunctionCall<Info>;
45
+ /**
46
+ * Type guard for {@link RUnnamedFunctionCall} nodes.
47
+ */
48
+ readonly isUnnamed: <Info = object>(this: void, node: RNode<Info> | undefined) => node is RUnnamedFunctionCall<Info>;
49
+ };
@@ -1,5 +1,30 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EmptyArgument = void 0;
3
+ exports.RFunctionCall = exports.EmptyArgument = void 0;
4
+ const type_1 = require("../type");
4
5
  exports.EmptyArgument = '<>';
6
+ /**
7
+ * Helper for working with {@link RFunctionCall} AST nodes.
8
+ */
9
+ exports.RFunctionCall = {
10
+ name: 'RFunctionCall',
11
+ /**
12
+ * Type guard for {@link RFunctionCall} nodes.
13
+ */
14
+ is(node) {
15
+ return node?.type === type_1.RType.FunctionCall;
16
+ },
17
+ /**
18
+ * Type guard for {@link RNamedFunctionCall} nodes.
19
+ */
20
+ isNamed(node) {
21
+ return exports.RFunctionCall.is(node) && node.named === true;
22
+ },
23
+ /**
24
+ * Type guard for {@link RUnnamedFunctionCall} nodes.
25
+ */
26
+ isUnnamed(node) {
27
+ return exports.RFunctionCall.is(node) && !node.named;
28
+ }
29
+ };
5
30
  //# sourceMappingURL=r-function-call.js.map
@@ -1,5 +1,5 @@
1
1
  import type { RAstNodeBase, Location, NoInfo, RNode } from '../model';
2
- import type { RType } from '../type';
2
+ import { RType } from '../type';
3
3
  import type { RParameter } from './r-parameter';
4
4
  /**
5
5
  * ```r
@@ -16,3 +16,13 @@ export interface RFunctionDefinition<Info = NoInfo> extends RAstNodeBase<Info>,
16
16
  parameters: RParameter<Info>[];
17
17
  body: RNode<Info>;
18
18
  }
19
+ /**
20
+ * Helper for working with {@link RFunctionDefinition} AST nodes.
21
+ */
22
+ export declare const RFunctionDefinition: {
23
+ readonly name: "RFunctionDefinition";
24
+ /**
25
+ * Type guard for {@link RFunctionDefinition} nodes.
26
+ */
27
+ readonly is: <Info = object>(this: void, node: RNode<Info> | undefined) => node is RFunctionDefinition<Info>;
28
+ };
@@ -1,3 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RFunctionDefinition = void 0;
4
+ const type_1 = require("../type");
5
+ /**
6
+ * Helper for working with {@link RFunctionDefinition} AST nodes.
7
+ */
8
+ exports.RFunctionDefinition = {
9
+ name: 'RFunctionDefinition',
10
+ /**
11
+ * Type guard for {@link RFunctionDefinition} nodes.
12
+ */
13
+ is(node) {
14
+ return node?.type === type_1.RType.FunctionDefinition;
15
+ }
16
+ };
3
17
  //# sourceMappingURL=r-function-definition.js.map
@@ -1,5 +1,5 @@
1
1
  import type { RAstNodeBase, Location, NoInfo, RNode } from '../model';
2
- import type { RType } from '../type';
2
+ import { RType } from '../type';
3
3
  import type { RExpressionList } from './r-expression-list';
4
4
  /**
5
5
  * ```r
@@ -12,3 +12,13 @@ export interface RIfThenElse<Info = NoInfo> extends RAstNodeBase<Info>, Location
12
12
  then: RExpressionList<Info>;
13
13
  otherwise?: RExpressionList<Info>;
14
14
  }
15
+ /**
16
+ * Helper for working with {@link RIfThenElse} AST nodes.
17
+ */
18
+ export declare const RIfThenElse: {
19
+ readonly name: "RIfThenElse";
20
+ /**
21
+ * Type guard for {@link RIfThenElse} nodes.
22
+ */
23
+ readonly is: <Info = object>(this: void, node: RNode<Info> | undefined) => node is RIfThenElse<Info>;
24
+ };
@@ -1,3 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RIfThenElse = void 0;
4
+ const type_1 = require("../type");
5
+ /**
6
+ * Helper for working with {@link RIfThenElse} AST nodes.
7
+ */
8
+ exports.RIfThenElse = {
9
+ name: 'RIfThenElse',
10
+ /**
11
+ * Type guard for {@link RIfThenElse} nodes.
12
+ */
13
+ is(node) {
14
+ return node?.type === type_1.RType.IfThenElse;
15
+ }
16
+ };
3
17
  //# sourceMappingURL=r-if-then-else.js.map
@@ -1,5 +1,5 @@
1
- import type { Leaf, Location, NoInfo } from '../model';
2
- import type { RType } from '../type';
1
+ import type { Leaf, Location, NoInfo, RNode } from '../model';
2
+ import { RType } from '../type';
3
3
  /**
4
4
  * Special comment to signal line mappings (e.g., in generated code) to the interpreter.
5
5
  */
@@ -8,3 +8,13 @@ export interface RLineDirective<Info = NoInfo> extends Location, Leaf<Info> {
8
8
  line: number;
9
9
  file: string;
10
10
  }
11
+ /**
12
+ * Helper for working with {@link RLineDirective} AST nodes.
13
+ */
14
+ export declare const RLineDirective: {
15
+ readonly name: "RLineDirective";
16
+ /**
17
+ * Type guard for {@link RLineDirective} nodes.
18
+ */
19
+ readonly is: <Info = object>(this: void, node: RNode<Info> | undefined) => node is RLineDirective<Info>;
20
+ };
@@ -1,3 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RLineDirective = void 0;
4
+ const type_1 = require("../type");
5
+ /**
6
+ * Helper for working with {@link RLineDirective} AST nodes.
7
+ */
8
+ exports.RLineDirective = {
9
+ name: 'RLineDirective',
10
+ /**
11
+ * Type guard for {@link RLineDirective} nodes.
12
+ */
13
+ is(node) {
14
+ return node?.type === type_1.RType.LineDirective;
15
+ }
16
+ };
3
17
  //# sourceMappingURL=r-line-directive.js.map
@@ -1,5 +1,5 @@
1
- import type { Leaf, Location, NoInfo } from '../model';
2
- import type { RType } from '../type';
1
+ import type { Leaf, Location, NoInfo, RNode } from '../model';
2
+ import { RType } from '../type';
3
3
  export type RLogicalValue = boolean;
4
4
  /**
5
5
  * Represents logical values (`TRUE` or `FALSE`).
@@ -8,3 +8,21 @@ export interface RLogical<Info = NoInfo> extends Leaf<Info>, Location {
8
8
  readonly type: RType.Logical;
9
9
  content: RLogicalValue;
10
10
  }
11
+ /**
12
+ * Helper for working with {@link RLogical} AST nodes.
13
+ */
14
+ export declare const RLogical: {
15
+ readonly name: "RLogical";
16
+ /**
17
+ * Type guard for {@link RLogical} nodes.
18
+ */
19
+ readonly is: <Info = object>(this: void, node: RNode<Info> | undefined) => node is RLogical<Info>;
20
+ /**
21
+ * Checks whether a node is a logical constant with value `TRUE`.
22
+ */
23
+ readonly isTrue: <Info = object>(this: void, node: RNode<Info> | undefined) => boolean;
24
+ /**
25
+ * Checks whether a node is a logical constant with value `FALSE`.
26
+ */
27
+ readonly isFalse: <Info = object>(this: void, node: RNode<Info> | undefined) => boolean;
28
+ };
@@ -1,3 +1,29 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RLogical = void 0;
4
+ const type_1 = require("../type");
5
+ /**
6
+ * Helper for working with {@link RLogical} AST nodes.
7
+ */
8
+ exports.RLogical = {
9
+ name: 'RLogical',
10
+ /**
11
+ * Type guard for {@link RLogical} nodes.
12
+ */
13
+ is(node) {
14
+ return node?.type === type_1.RType.Logical;
15
+ },
16
+ /**
17
+ * Checks whether a node is a logical constant with value `TRUE`.
18
+ */
19
+ isTrue(node) {
20
+ return exports.RLogical.is(node) && node.content;
21
+ },
22
+ /**
23
+ * Checks whether a node is a logical constant with value `FALSE`.
24
+ */
25
+ isFalse(node) {
26
+ return exports.RLogical.is(node) && !node.content;
27
+ }
28
+ };
3
29
  //# sourceMappingURL=r-logical.js.map
@@ -1,8 +1,18 @@
1
- import type { Leaf, Location, NoInfo } from '../model';
2
- import type { RType } from '../type';
1
+ import type { Leaf, Location, NoInfo, RNode } from '../model';
2
+ import { RType } from '../type';
3
3
  /**
4
4
  * A `next` statement.
5
5
  */
6
6
  export interface RNext<Info = NoInfo> extends Location, Leaf<Info> {
7
7
  readonly type: RType.Next;
8
8
  }
9
+ /**
10
+ * Helper for working with {@link RNext} AST nodes.
11
+ */
12
+ export declare const RNext: {
13
+ readonly name: "RNext";
14
+ /**
15
+ * Type guard for {@link RNext} nodes.
16
+ */
17
+ readonly is: <Info = object>(this: void, node: RNode<Info> | undefined) => node is RNext<Info>;
18
+ };
@@ -1,3 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RNext = void 0;
4
+ const type_1 = require("../type");
5
+ /**
6
+ * Helper for working with {@link RNext} AST nodes.
7
+ */
8
+ exports.RNext = {
9
+ name: 'RNext',
10
+ /**
11
+ * Type guard for {@link RNext} nodes.
12
+ */
13
+ is(node) {
14
+ return node?.type === type_1.RType.Next;
15
+ }
16
+ };
3
17
  //# sourceMappingURL=r-next.js.map
@@ -11,6 +11,12 @@ export interface RNumber<Info = NoInfo> extends Leaf<Info>, Location {
11
11
  content: RNumberValue;
12
12
  }
13
13
  /**
14
- * Checks whether the given node is an RNumber.
14
+ * Helper for working with {@link RNumber} AST nodes.
15
15
  */
16
- export declare function isRNumber(node: RNode | undefined): node is RNumber;
16
+ export declare const RNumber: {
17
+ readonly name: "RNumber";
18
+ /**
19
+ * Type guard for {@link RNumber} nodes.
20
+ */
21
+ readonly is: <Info = object>(this: void, node: RNode<Info> | undefined) => node is RNumber<Info>;
22
+ };
@@ -1,11 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isRNumber = isRNumber;
3
+ exports.RNumber = void 0;
4
4
  const type_1 = require("../type");
5
5
  /**
6
- * Checks whether the given node is an RNumber.
6
+ * Helper for working with {@link RNumber} AST nodes.
7
7
  */
8
- function isRNumber(node) {
9
- return node?.type === type_1.RType.Number;
10
- }
8
+ exports.RNumber = {
9
+ name: 'RNumber',
10
+ /**
11
+ * Type guard for {@link RNumber} nodes.
12
+ */
13
+ is(node) {
14
+ return node?.type === type_1.RType.Number;
15
+ }
16
+ };
11
17
  //# sourceMappingURL=r-number.js.map
@@ -1,5 +1,5 @@
1
1
  import type { RAstNodeBase, Location, NoInfo, RNode } from '../model';
2
- import type { RType } from '../type';
2
+ import { RType } from '../type';
3
3
  import type { RSymbol } from './r-symbol';
4
4
  import type { BrandedIdentifier } from '../../../../../dataflow/environments/identifier';
5
5
  /**
@@ -12,3 +12,19 @@ export interface RParameter<Info = NoInfo> extends RAstNodeBase<Info>, Location
12
12
  special: boolean;
13
13
  defaultValue: RNode<Info> | undefined;
14
14
  }
15
+ /**
16
+ * Helper for working with {@link RParameter} AST nodes.
17
+ */
18
+ export declare const RParameter: {
19
+ readonly name: "RParameter";
20
+ /**
21
+ * Type guard for {@link RParameter} nodes.
22
+ * @see {@link RParameter.isDotDotDotDot} - to check whether a parameter is the special `...` parameter
23
+ */
24
+ readonly is: <Info = object>(this: void, node: RNode<Info> | undefined) => node is RParameter<Info>;
25
+ /**
26
+ * Type guard for the special `...` parameter.
27
+ * @see {@link RParameter.is} - to check whether a node is a parameter at all
28
+ */
29
+ readonly isDotDotDotDot: <Info = object>(this: void, node: RNode<Info> | undefined) => node is RParameter<Info>;
30
+ };
@@ -1,3 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RParameter = void 0;
4
+ const type_1 = require("../type");
5
+ /**
6
+ * Helper for working with {@link RParameter} AST nodes.
7
+ */
8
+ exports.RParameter = {
9
+ name: 'RParameter',
10
+ /**
11
+ * Type guard for {@link RParameter} nodes.
12
+ * @see {@link RParameter.isDotDotDotDot} - to check whether a parameter is the special `...` parameter
13
+ */
14
+ is(node) {
15
+ return node?.type === type_1.RType.Parameter;
16
+ },
17
+ /**
18
+ * Type guard for the special `...` parameter.
19
+ * @see {@link RParameter.is} - to check whether a node is a parameter at all
20
+ */
21
+ isDotDotDotDot(node) {
22
+ return exports.RParameter.is(node) && node.special;
23
+ }
24
+ };
3
25
  //# sourceMappingURL=r-parameter.js.map
@@ -1,5 +1,6 @@
1
1
  import type { RAstNodeBase, Location, NoInfo, RNode } from '../model';
2
- import type { RType } from '../type';
2
+ import { RType } from '../type';
3
+ import { SemVer } from 'semver';
3
4
  /**
4
5
  * Variant of the binary operator, specifically for the new, built-in pipe operator.
5
6
  */
@@ -8,3 +9,17 @@ export interface RPipe<Info = NoInfo> extends RAstNodeBase<Info>, Location {
8
9
  readonly lhs: RNode<Info>;
9
10
  readonly rhs: RNode<Info>;
10
11
  }
12
+ /**
13
+ * Helper for working with {@link RPipe} AST nodes.
14
+ */
15
+ export declare const RPipe: {
16
+ readonly name: "RPipe";
17
+ /**
18
+ * Type guard for {@link RPipe} nodes.
19
+ */
20
+ readonly is: <Info = object>(this: void, node: RNode<Info> | undefined) => node is RPipe<Info>;
21
+ /**
22
+ * Returns the minimum R version that supports the pipe operator.
23
+ */
24
+ readonly availableFromRVersion: (this: void) => SemVer;
25
+ };
@@ -1,3 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RPipe = void 0;
4
+ const type_1 = require("../type");
5
+ const semver_1 = require("semver");
6
+ const versions_1 = require("../versions");
7
+ /**
8
+ * Helper for working with {@link RPipe} AST nodes.
9
+ */
10
+ exports.RPipe = {
11
+ name: 'RPipe',
12
+ /**
13
+ * Type guard for {@link RPipe} nodes.
14
+ */
15
+ is(node) {
16
+ return node?.type === type_1.RType.Pipe;
17
+ },
18
+ /**
19
+ * Returns the minimum R version that supports the pipe operator.
20
+ */
21
+ availableFromRVersion() {
22
+ return new semver_1.SemVer(versions_1.MIN_VERSION_PIPE);
23
+ },
24
+ };
3
25
  //# sourceMappingURL=r-pipe.js.map
@@ -1,7 +1,10 @@
1
1
  import type { NoInfo } from '../model';
2
+ import { RNode } from '../model';
2
3
  import { RType } from '../type';
3
4
  import type { RExpressionList } from './r-expression-list';
4
5
  import type { NodeId } from '../processing/node-id';
6
+ import type { OnEnter, OnExit } from '../processing/visitor';
7
+ import type { ParentInformation } from '../processing/decorate';
5
8
  /**
6
9
  * Holds a single R file starting with an expression list.
7
10
  */
@@ -11,8 +14,9 @@ export interface RProjectFile<Info = NoInfo> {
11
14
  }
12
15
  /**
13
16
  * Holds a collection of files (started with the expression list)
17
+ * @see {@link RProject.visitAst} - to visit all nodes in the project and related helper functions
14
18
  * @see {@link RExpressionList} - for the root of each file
15
- * @see {@link mergeProjects} - to merge multiple projects into a single one
19
+ * @see {@link RProject.merge} - to merge multiple projects into a single one
16
20
  * @see {@link RProjectFile} - for each file in the project
17
21
  */
18
22
  export interface RProject<Info = NoInfo> {
@@ -23,11 +27,44 @@ export interface RProject<Info = NoInfo> {
23
27
  };
24
28
  }
25
29
  /**
26
- * Type guard for RProject nodes.
30
+ * Helper object to identify RProject nodes by their type and to provide related functions.
31
+ * @see {@link RNode.visitAst} - to visit all nodes in the project
27
32
  */
28
- export declare function isRProject<Info = NoInfo>(node: unknown): node is RProject<Info>;
29
- /**
30
- * Merge multiple projects into a single one by concatenating their files.
31
- * This will remove the `info` property of the resulting project.
32
- */
33
- export declare function mergeProjects<Info = NoInfo>(projects: RProject<Info>[]): RProject<Info>;
33
+ export declare const RProject: {
34
+ readonly name: "RProject";
35
+ /**
36
+ * Visits all nodes in the project by visiting the root of each file.
37
+ * @param project - The project to visit file by file
38
+ * @param onVisit - Called before visiting the subtree of each node. Can be used to stop visiting the subtree starting with this node (return `true` stop)
39
+ * @param onExit - Called after the subtree of a node has been visited, called for leafs too (even though their subtree is empty)
40
+ */
41
+ readonly visitAst: <OtherInfo>(this: void, project: RProject<OtherInfo>, onVisit?: OnEnter<OtherInfo>, onExit?: OnExit<OtherInfo>) => void;
42
+ /**
43
+ * Collects all node ids within a project
44
+ * @param project - The project to collect ids from
45
+ * @see {@link RNode.collectAllIds} - to stop collecting at certain nodes
46
+ * @see {@link RProject.collectAllIdsWithStop} - to stop collecting at certain nodes
47
+ */
48
+ readonly collectAllIds: <OtherInfo>(this: void, project: RProject<OtherInfo & ParentInformation>) => Set<NodeId>;
49
+ /**
50
+ * Collects all node ids within a project, but stops collecting at nodes where the given `stop` function returns `true`.
51
+ * @param project - The project to collect ids from
52
+ * @param stop - A function that determines whether to stop collecting at a given node, does not stop by default
53
+ * @see {@link RNode.collectAllIdsWithStop} - to collect all ids without stopping
54
+ * @see {@link RProject.collectAllIds} - to collect all ids without stopping
55
+ */
56
+ readonly collectAllIdsWithStop: <OtherInfo>(this: void, project: RProject<OtherInfo & ParentInformation>, stop: (node: RNode<OtherInfo & ParentInformation>) => boolean) => Set<NodeId>;
57
+ /**
58
+ * Flattens the project to an array of nodes by collecting the root nodes of each file.
59
+ */
60
+ readonly asNodes: <OtherInfo>(this: void, project: RProject<OtherInfo>) => RNode<OtherInfo>[];
61
+ /**
62
+ * Type guard for RProject nodes.
63
+ */
64
+ readonly is: <OtherInfo = object>(this: void, node: unknown) => node is RProject<OtherInfo>;
65
+ /**
66
+ * Merge multiple projects into a single one by concatenating their files.
67
+ * This will remove the `info` property of the resulting project.
68
+ */
69
+ readonly merge: <Info = object>(this: void, projects: readonly RProject<Info>[]) => RProject<Info>;
70
+ };
@@ -1,22 +1,63 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isRProject = isRProject;
4
- exports.mergeProjects = mergeProjects;
3
+ exports.RProject = void 0;
4
+ const model_1 = require("../model");
5
5
  const type_1 = require("../type");
6
6
  /**
7
- * Type guard for RProject nodes.
7
+ * Helper object to identify RProject nodes by their type and to provide related functions.
8
+ * @see {@link RNode.visitAst} - to visit all nodes in the project
8
9
  */
9
- function isRProject(node) {
10
- return typeof node === 'object' && node !== null && 'type' in node && node.type === type_1.RType.Project;
11
- }
12
- /**
13
- * Merge multiple projects into a single one by concatenating their files.
14
- * This will remove the `info` property of the resulting project.
15
- */
16
- function mergeProjects(projects) {
17
- return {
18
- type: type_1.RType.Project,
19
- files: projects.flatMap(p => p.files)
20
- };
21
- }
10
+ exports.RProject = {
11
+ name: 'RProject',
12
+ /**
13
+ * Visits all nodes in the project by visiting the root of each file.
14
+ * @param project - The project to visit file by file
15
+ * @param onVisit - Called before visiting the subtree of each node. Can be used to stop visiting the subtree starting with this node (return `true` stop)
16
+ * @param onExit - Called after the subtree of a node has been visited, called for leafs too (even though their subtree is empty)
17
+ */
18
+ visitAst(project, onVisit, onExit) {
19
+ return model_1.RNode.visitAst(project.files.map(f => f.root), onVisit, onExit);
20
+ },
21
+ /**
22
+ * Collects all node ids within a project
23
+ * @param project - The project to collect ids from
24
+ * @see {@link RNode.collectAllIds} - to stop collecting at certain nodes
25
+ * @see {@link RProject.collectAllIdsWithStop} - to stop collecting at certain nodes
26
+ */
27
+ collectAllIds(project) {
28
+ return model_1.RNode.collectAllIds(exports.RProject.asNodes(project));
29
+ },
30
+ /**
31
+ * Collects all node ids within a project, but stops collecting at nodes where the given `stop` function returns `true`.
32
+ * @param project - The project to collect ids from
33
+ * @param stop - A function that determines whether to stop collecting at a given node, does not stop by default
34
+ * @see {@link RNode.collectAllIdsWithStop} - to collect all ids without stopping
35
+ * @see {@link RProject.collectAllIds} - to collect all ids without stopping
36
+ */
37
+ collectAllIdsWithStop(project, stop) {
38
+ return model_1.RNode.collectAllIdsWithStop(exports.RProject.asNodes(project), stop);
39
+ },
40
+ /**
41
+ * Flattens the project to an array of nodes by collecting the root nodes of each file.
42
+ */
43
+ asNodes(project) {
44
+ return project.files.map(f => f.root);
45
+ },
46
+ /**
47
+ * Type guard for RProject nodes.
48
+ */
49
+ is(node) {
50
+ return typeof node === 'object' && node !== null && 'type' in node && node.type === type_1.RType.Project;
51
+ },
52
+ /**
53
+ * Merge multiple projects into a single one by concatenating their files.
54
+ * This will remove the `info` property of the resulting project.
55
+ */
56
+ merge(projects) {
57
+ return {
58
+ type: type_1.RType.Project,
59
+ files: projects.flatMap(p => p.files)
60
+ };
61
+ }
62
+ };
22
63
  //# sourceMappingURL=r-project.js.map