@eagleoutice/flowr 2.15.9 → 2.16.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 (244) hide show
  1. package/README.md +47 -41
  2. package/abstract-interpretation/absint-inference.d.ts +2 -2
  3. package/abstract-interpretation/absint-inference.js +32 -79
  4. package/abstract-interpretation/data-frame/arguments.js +11 -7
  5. package/benchmark/slicer.d.ts +0 -1
  6. package/benchmark/slicer.js +1 -2
  7. package/cli/repl/commands/repl-signature.js +12 -3
  8. package/config.d.ts +5 -1
  9. package/control-flow/cfg-properties.js +0 -22
  10. package/control-flow/happens-before.d.ts +7 -2
  11. package/control-flow/happens-before.js +55 -31
  12. package/control-flow/useless-loop.d.ts +1 -1
  13. package/control-flow/useless-loop.js +29 -42
  14. package/dataflow/environments/apply-kill.js +6 -2
  15. package/dataflow/environments/built-in-config.d.ts +2 -0
  16. package/dataflow/environments/built-in-props.d.ts +16 -1
  17. package/dataflow/environments/built-in-props.js +33 -20
  18. package/dataflow/environments/built-in.d.ts +8 -3
  19. package/dataflow/environments/built-in.js +52 -82
  20. package/dataflow/environments/default-builtin-config.d.ts +551 -21
  21. package/dataflow/environments/default-builtin-config.js +121 -45
  22. package/dataflow/environments/define.d.ts +3 -2
  23. package/dataflow/environments/define.js +4 -3
  24. package/dataflow/environments/deprecation-info.d.ts +45 -0
  25. package/dataflow/environments/deprecation-info.js +13 -0
  26. package/dataflow/environments/environment.d.ts +7 -5
  27. package/dataflow/environments/environment.js +55 -121
  28. package/dataflow/environments/identifier.d.ts +6 -2
  29. package/dataflow/environments/identifier.js +23 -69
  30. package/dataflow/environments/reference-to-maybe.d.ts +9 -0
  31. package/dataflow/environments/reference-to-maybe.js +23 -51
  32. package/dataflow/environments/resolve-by-name.js +37 -76
  33. package/dataflow/eval/resolve/resolve-argument.d.ts +3 -1
  34. package/dataflow/eval/resolve/resolve-argument.js +61 -64
  35. package/dataflow/eval/resolve/resolve-working-directory.d.ts +8 -2
  36. package/dataflow/eval/resolve/resolve-working-directory.js +12 -20
  37. package/dataflow/eval/resolve/resolve.d.ts +4 -0
  38. package/dataflow/eval/resolve/resolve.js +23 -14
  39. package/dataflow/extractor.js +180 -58
  40. package/dataflow/fn/class-declaration.d.ts +8 -13
  41. package/dataflow/fn/class-declaration.js +95 -116
  42. package/dataflow/fn/exceptions-of-function.js +68 -37
  43. package/dataflow/fn/frame-reflection.d.ts +12 -4
  44. package/dataflow/fn/frame-reflection.js +51 -41
  45. package/dataflow/fn/function-props.js +15 -33
  46. package/dataflow/fn/function-semantics.d.ts +11 -3
  47. package/dataflow/fn/function-semantics.js +6 -0
  48. package/dataflow/fn/higher-order-function.d.ts +9 -1
  49. package/dataflow/fn/higher-order-function.js +27 -24
  50. package/dataflow/fn/strict-function.d.ts +13 -0
  51. package/dataflow/fn/strict-function.js +291 -123
  52. package/dataflow/graph/call-graph.d.ts +7 -6
  53. package/dataflow/graph/call-graph.js +35 -46
  54. package/dataflow/graph/graph.d.ts +13 -1
  55. package/dataflow/graph/graph.js +74 -66
  56. package/dataflow/graph/vertex.d.ts +1 -1
  57. package/dataflow/info.d.ts +8 -1
  58. package/dataflow/info.js +24 -30
  59. package/dataflow/internal/control-flow.d.ts +31 -4
  60. package/dataflow/internal/control-flow.js +61 -39
  61. package/dataflow/internal/linker.d.ts +17 -8
  62. package/dataflow/internal/linker.js +286 -213
  63. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +179 -0
  64. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +874 -0
  65. package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +3 -1
  66. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +60 -48
  67. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +4 -2
  68. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +135 -198
  69. package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +7 -9
  70. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +5 -1
  71. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +21 -14
  72. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +14 -4
  73. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.d.ts +1 -1
  74. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +141 -146
  75. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +56 -24
  76. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +292 -253
  77. package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +1 -1
  78. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +30 -32
  79. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +68 -67
  80. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +91 -129
  81. package/dataflow/internal/process/functions/call/built-in/built-in-local.d.ts +1 -3
  82. package/dataflow/internal/process/functions/call/built-in/built-in-local.js +16 -12
  83. package/dataflow/internal/process/functions/call/built-in/built-in-quote.d.ts +4 -4
  84. package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +9 -35
  85. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +2 -0
  86. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +8 -3
  87. package/dataflow/internal/process/functions/call/built-in/built-in-s-four.d.ts +5 -3
  88. package/dataflow/internal/process/functions/call/built-in/built-in-s-four.js +13 -31
  89. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +1 -1
  90. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +42 -119
  91. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -3
  92. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +21 -21
  93. package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +2 -0
  94. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +93 -102
  95. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +7 -3
  96. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +173 -114
  97. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.d.ts +1 -3
  98. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +23 -26
  99. package/dataflow/internal/process/functions/call/built-in/built-in-with.d.ts +1 -1
  100. package/dataflow/internal/process/functions/call/built-in/built-in-with.js +34 -9
  101. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +1 -1
  102. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +119 -93
  103. package/dataflow/internal/process/functions/call/common.d.ts +4 -4
  104. package/dataflow/internal/process/functions/call/common.js +49 -71
  105. package/dataflow/internal/process/functions/call/deferred.d.ts +12 -2
  106. package/dataflow/internal/process/functions/call/deferred.js +81 -63
  107. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +4 -2
  108. package/dataflow/internal/process/functions/call/known-call-handling.js +65 -68
  109. package/dataflow/internal/process/functions/call/named-call-handling.d.ts +3 -5
  110. package/dataflow/internal/process/functions/call/named-call-handling.js +48 -19
  111. package/dataflow/internal/process/functions/call/quoted.d.ts +2 -0
  112. package/dataflow/internal/process/functions/call/quoted.js +257 -154
  113. package/dataflow/internal/process/functions/call/unnamed-call-handling.js +17 -38
  114. package/dataflow/internal/process/functions/process-parameter.js +25 -32
  115. package/dataflow/internal/process/process-symbol.js +4 -3
  116. package/dataflow/internal/program-order.d.ts +26 -0
  117. package/dataflow/internal/program-order.js +49 -0
  118. package/documentation/data/faq/faqs.js +3 -3
  119. package/documentation/data/interface/doc-writing-code.js +1 -2
  120. package/documentation/data/server/doc-data-server-messages.js +7 -7
  121. package/documentation/doc-capabilities.js +80 -34
  122. package/documentation/doc-util/doc-query.d.ts +0 -3
  123. package/documentation/doc-util/doc-query.js +4 -3
  124. package/documentation/wiki-analyzer.js +1 -1
  125. package/documentation/wiki-cfg.js +5 -6
  126. package/documentation/wiki-core.js +8 -8
  127. package/documentation/wiki-dataflow-graph.js +10 -11
  128. package/documentation/wiki-interface.js +2 -2
  129. package/documentation/wiki-linting-and-testing.js +3 -3
  130. package/documentation/wiki-overview.js +6 -6
  131. package/documentation/wiki-query.js +9 -101
  132. package/documentation/wiki-setup.js +23 -0
  133. package/documentation/wiki-signature-database.js +1 -1
  134. package/linter/linter-rules.d.ts +18 -9
  135. package/linter/rules/absolute-path.js +63 -87
  136. package/linter/rules/deprecated-functions.d.ts +1 -45
  137. package/linter/rules/deprecated-functions.js +24 -33
  138. package/linter/rules/file-path-validity.d.ts +4 -2
  139. package/linter/rules/file-path-validity.js +114 -80
  140. package/linter/rules/namespace-access.js +21 -33
  141. package/linter/rules/naming-convention.d.ts +1 -1
  142. package/linter/rules/naming-convention.js +60 -48
  143. package/linter/rules/network-functions.js +11 -7
  144. package/linter/rules/no-leaked-credentials.js +15 -18
  145. package/linter/rules/problematic-inputs.d.ts +2 -1
  146. package/linter/rules/problematic-inputs.js +39 -59
  147. package/linter/rules/roxygen-arguments.d.ts +9 -4
  148. package/linter/rules/roxygen-arguments.js +29 -48
  149. package/linter/rules/seeded-randomness.d.ts +7 -4
  150. package/linter/rules/seeded-randomness.js +128 -89
  151. package/linter/rules/stop-with-call-arg.d.ts +4 -2
  152. package/linter/rules/stop-with-call-arg.js +25 -22
  153. package/linter/rules/unclosed-connection.js +31 -24
  154. package/linter/rules/undefined-symbol.d.ts +4 -6
  155. package/linter/rules/undefined-symbol.js +58 -75
  156. package/linter/rules/unescaped-arguments.js +18 -44
  157. package/linter/rules/unused-definition.d.ts +6 -0
  158. package/linter/rules/unused-definition.js +105 -145
  159. package/linter/rules/unused-import.d.ts +3 -0
  160. package/linter/rules/unused-import.js +25 -43
  161. package/package.json +5 -2
  162. package/project/flowr-analyzer.d.ts +2 -0
  163. package/project/flowr-analyzer.js +28 -1
  164. package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +2 -2
  165. package/project/plugins/file-plugins/files/flowr-jupyter-file.js +8 -12
  166. package/project/plugins/file-plugins/files/flowr-rda-file.d.ts +0 -2
  167. package/project/plugins/file-plugins/files/flowr-rda-file.js +10 -55
  168. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +7 -5
  169. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +34 -56
  170. package/project/plugins/file-plugins/flowr-analyzer-file-plugin.js +2 -1
  171. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +22 -45
  172. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +2 -2
  173. package/project/sigdb/build.js +4 -0
  174. package/project/sigdb/manifest.d.ts +2 -0
  175. package/project/sigdb/manifest.js +10 -1
  176. package/project/sigdb/reader.js +23 -61
  177. package/project/sigdb/sigdb-download.d.ts +29 -6
  178. package/project/sigdb/sigdb-download.js +212 -64
  179. package/queries/base-query-format.js +1 -2
  180. package/queries/catalog/absint-query/absint-query-format.js +1 -1
  181. package/queries/catalog/call-context-query/cascade-action.d.ts +3 -1
  182. package/queries/catalog/call-context-query/cascade-action.js +2 -0
  183. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +3 -0
  184. package/queries/catalog/dataflow-query/dataflow-query-executor.js +2 -2
  185. package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +2 -0
  186. package/queries/catalog/dataflow-query/dataflow-query-format.js +4 -7
  187. package/queries/catalog/dependencies-query/dependencies-query-executor.js +50 -114
  188. package/queries/catalog/dependencies-query/function-info/library-functions.d.ts +5 -9
  189. package/queries/catalog/dependencies-query/function-info/library-functions.js +6 -0
  190. package/queries/catalog/dependencies-query/function-info/read-functions.js +1 -1
  191. package/queries/catalog/dependencies-query/function-info/write-functions.js +7 -3
  192. package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +4 -4
  193. package/queries/catalog/input-sources-query/simple-input-classifier.js +192 -301
  194. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +2 -1
  195. package/queries/catalog/origin-query/origin-query-executor.d.ts +1 -1
  196. package/queries/catalog/origin-query/origin-query-executor.js +2 -2
  197. package/queries/catalog/origin-query/origin-query-format.d.ts +2 -2
  198. package/queries/catalog/origin-query/origin-query-format.js +1 -1
  199. package/queries/query.d.ts +1 -1
  200. package/r-bridge/data/data.d.ts +21 -14
  201. package/r-bridge/data/data.js +28 -20
  202. package/r-bridge/lang-4.x/ast/model/model.d.ts +3 -1
  203. package/r-bridge/lang-4.x/ast/model/model.js +19 -43
  204. package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +1 -0
  205. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +3 -0
  206. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.js +5 -12
  207. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +1 -0
  208. package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +1 -0
  209. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +1 -0
  210. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +1 -0
  211. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +1 -0
  212. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +1 -0
  213. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +1 -0
  214. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +1 -0
  215. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +1 -0
  216. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +1 -0
  217. package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +1 -0
  218. package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +1 -0
  219. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +1 -0
  220. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +1 -0
  221. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +1 -0
  222. package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +1 -0
  223. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +1 -0
  224. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +1 -0
  225. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +1 -0
  226. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.d.ts +2 -2
  227. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +11 -2
  228. package/r-bridge/roxygen2/roxygen-parse.js +28 -42
  229. package/r-bridge/shell.js +6 -0
  230. package/search/search-executor/search-enrichers.js +25 -37
  231. package/slicing/static/slice-call.d.ts +4 -3
  232. package/slicing/static/slice-call.js +56 -88
  233. package/slicing/static/static-slicer.js +115 -79
  234. package/slicing/static/visiting-queue.d.ts +4 -6
  235. package/slicing/static/visiting-queue.js +9 -13
  236. package/util/files.d.ts +2 -0
  237. package/util/files.js +3 -1
  238. package/util/mermaid/mermaid.js +6 -2
  239. package/util/proc.js +2 -1
  240. package/util/r-base-packages.d.ts +2 -0
  241. package/util/r-base-packages.js +23 -13
  242. package/util/text/playground-link.d.ts +12 -3
  243. package/util/text/playground-link.js +18 -27
  244. package/util/version.js +4 -10
@@ -16,9 +16,10 @@ async function executeHigherOrderQuery({ analyzer }, queries) {
16
16
  if (filterFor.size === 0 || filterFor.size > 10) {
17
17
  invertedGraph = df_helper_1.Dataflow.invertGraph(graph, analyzer.inspectContext().env.makeCleanEnv());
18
18
  }
19
+ const argumentFacts = new Map();
19
20
  const result = {};
20
21
  for (const id of fns) {
21
- result[id] = function_semantics_1.FunctionSemantics.isHigherOrder(id, graph, { ctx: analyzer.inspectContext(), invertedGraph });
22
+ result[id] = function_semantics_1.FunctionSemantics.isHigherOrder(id, graph, { ctx: analyzer.inspectContext(), invertedGraph, argumentFacts });
22
23
  }
23
24
  return {
24
25
  '.meta': {
@@ -8,4 +8,4 @@ export declare function fingerPrintOfQuery(query: OriginQuery): SlicingCriterion
8
8
  /**
9
9
  * Execute origin queries, catching duplicates with the same fingerprint
10
10
  */
11
- export declare function executeResolveValueQuery({ analyzer }: BasicQueryData, queries: readonly OriginQuery[]): Promise<OriginQueryResult>;
11
+ export declare function executeOriginQuery({ analyzer }: BasicQueryData, queries: readonly OriginQuery[]): Promise<OriginQueryResult>;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.fingerPrintOfQuery = fingerPrintOfQuery;
4
- exports.executeResolveValueQuery = executeResolveValueQuery;
4
+ exports.executeOriginQuery = executeOriginQuery;
5
5
  const log_1 = require("../../../util/log");
6
6
  const parse_1 = require("../../../slicing/criterion/parse");
7
7
  const df_helper_1 = require("../../../dataflow/graph/df-helper");
@@ -14,7 +14,7 @@ function fingerPrintOfQuery(query) {
14
14
  /**
15
15
  * Execute origin queries, catching duplicates with the same fingerprint
16
16
  */
17
- async function executeResolveValueQuery({ analyzer }, queries) {
17
+ async function executeOriginQuery({ analyzer }, queries) {
18
18
  const start = Date.now();
19
19
  const results = {};
20
20
  for (const query of queries) {
@@ -2,7 +2,7 @@ import type { BaseQueryFormat, BaseQueryResult } from '../../base-query-format';
2
2
  import type { SlicingCriterion } from '../../../slicing/criterion/parse';
3
3
  import type { ParsedQueryLine } from '../../query';
4
4
  import Joi from 'joi';
5
- import { executeResolveValueQuery } from './origin-query-executor';
5
+ import { executeOriginQuery } from './origin-query-executor';
6
6
  import type { Origin } from '../../../dataflow/origin/dfg-get-origin';
7
7
  import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
8
8
  import type { ReplOutput } from '../../../cli/repl/commands/repl-main';
@@ -19,7 +19,7 @@ export interface OriginQueryResult extends BaseQueryResult {
19
19
  declare function originQueryLineParser(output: ReplOutput, line: readonly string[], _config: FlowrConfig): ParsedQueryLine<'origin'>;
20
20
  export declare const OriginQueryDefinition: {
21
21
  readonly title: "Origin Query";
22
- readonly executor: typeof executeResolveValueQuery;
22
+ readonly executor: typeof executeOriginQuery;
23
23
  readonly asciiSummarizer: (formatter: import("../../../util/text/ansi").OutputFormatter, _analyzer: import("../../..").ReadonlyFlowrAnalysisProvider<import("../../..").KnownParser>, queryResults: BaseQueryResult, result: string[]) => true;
24
24
  readonly fromLine: typeof originQueryLineParser;
25
25
  readonly completer: typeof criteriaQueryCompleter;
@@ -25,7 +25,7 @@ function originQueryLineParser(output, line, _config) {
25
25
  }
26
26
  exports.OriginQueryDefinition = {
27
27
  title: 'Origin Query',
28
- executor: origin_query_executor_1.executeResolveValueQuery,
28
+ executor: origin_query_executor_1.executeOriginQuery,
29
29
  asciiSummarizer: (formatter, _analyzer, queryResults, result) => {
30
30
  const out = queryResults;
31
31
  result.push(`Query: ${(0, ansi_1.bold)('origin', formatter)} (${(0, time_1.printAsMs)(out['.meta'].timing, 0)})`);
@@ -306,7 +306,7 @@ export declare const SupportedQueries: {
306
306
  };
307
307
  readonly origin: {
308
308
  readonly title: "Origin Query";
309
- readonly executor: typeof import("./catalog/origin-query/origin-query-executor").executeResolveValueQuery;
309
+ readonly executor: typeof import("./catalog/origin-query/origin-query-executor").executeOriginQuery;
310
310
  readonly asciiSummarizer: (formatter: OutputFormatter, _analyzer: ReadonlyFlowrAnalysisProvider<import("..").KnownParser>, queryResults: BaseQueryResult, result: string[]) => true;
311
311
  readonly fromLine: (output: ReplOutput, line: readonly string[], _config: FlowrConfig) => ParsedQueryLine<"origin">;
312
312
  readonly completer: typeof import("../cli/repl/parser/slice-query-parser").criteriaQueryCompleter;
@@ -124,7 +124,7 @@ export declare const flowrCapabilities: {
124
124
  readonly name: "Dynamic Environment Resolution";
125
125
  readonly id: "dynamic-environment-resolution";
126
126
  readonly code: readonly ["new.env"];
127
- readonly description: `_An environment a program builds and names itself, rather than one a ${string} opens._ Covers \`new.env\`, \`assign\`/\`get\`/\`local\` with \`envir=\`, \`e$x\`, \`attach\`, \`with\`, and aliasing such an environment through a variable.`;
127
+ readonly description: `_An environment a program builds and names itself, rather than one a ${string} opens._ Covers \`new.env\`, \`assign\`/\`get\`/\`local\` with \`envir=\`, \`e$x\`, \`attach\`, \`with\`, and aliasing such an environment through a variable. A write from within a function reaches the environment it names, a read of the whole environment (\`as.list(e)\`) sees every field written, and copies of an environment variable (\`g <- e\`) share its fields.`;
128
128
  readonly example: string;
129
129
  readonly capabilities: readonly [{
130
130
  readonly name: "Environment in Control Flow";
@@ -311,8 +311,8 @@ export declare const flowrCapabilities: {
311
311
  }, {
312
312
  readonly name: "Local with Explicit Environment";
313
313
  readonly id: "local-envir-argument";
314
- readonly supported: "partially";
315
- readonly description: "_Send `local`'s body to a specific environment._ `new.env()` and `globalenv()` work, but inside a function that already binds the name the write lands in that frame instead.";
314
+ readonly supported: "fully";
315
+ readonly description: "_Send `local`'s body to a specific environment._ Its writes land in that environment, also inside a function that binds the same name itself.";
316
316
  readonly example: string;
317
317
  readonly url: [{
318
318
  readonly name: "`local`";
@@ -397,7 +397,7 @@ export declare const flowrCapabilities: {
397
397
  readonly name: "Side-Effects in Argument";
398
398
  readonly id: "side-effects-in-argument";
399
399
  readonly supported: "partially";
400
- readonly description: `_An argument that binds a name while it is evaluated, as \`f(x <- 3)\` does._ Whether the argument is ever forced is not modelled (see ${string}), so \`f <- function(a) 1; f(x <- 3)\` still believes \`x\` is 3.`;
400
+ readonly description: `_An argument that binds a name while it is evaluated, as \`f(x <- 3)\` does._ Whether the argument is ever forced is not modelled (see ${string}), so \`f <- function(a) 1; f(x <- 3)\` still believes \`x\` is 3. A call in the argument depends on the call it is handed to, so \`g(FALSE, f(4))\` keeps \`g\`.`;
401
401
  readonly example: string;
402
402
  readonly url: [{
403
403
  name: string;
@@ -458,7 +458,7 @@ export declare const flowrCapabilities: {
458
458
  readonly name: "Functions with global side effects";
459
459
  readonly id: "functions-with-global-side-effects";
460
460
  readonly supported: "partially";
461
- readonly description: `_A call that changes state the rest of the program reads without naming it, as \`setwd\` changes where a path points._ Only the ${string} is interpreted, while other ambient state such as ${string} stays an unknown side effect.`;
461
+ readonly description: `_A call that changes state the rest of the program reads without naming it, as \`setwd\` changes where a path points._ The ${string}, ${string}, and ${string} are tracked, so a read links to the calls that set what it reads. Other ambient state, like environment variables or the random seed, stays an unknown side effect.`;
462
462
  readonly example: string;
463
463
  }, {
464
464
  readonly name: "Working Directory";
@@ -652,7 +652,7 @@ export declare const flowrCapabilities: {
652
652
  readonly id: "assignment-functions";
653
653
  readonly code: readonly ["assign", "delayedAssign"];
654
654
  readonly supported: "partially";
655
- readonly description: `_Bind a name given as a string, with \`assign\`, \`delayedAssign\`, ..._ The name has to be a ${string}, and what a delayed assignment does when forced is not modelled.`;
655
+ readonly description: `_Bind a name given as a string, with \`assign\`, \`delayedAssign\`, ..._ The name has to be a ${string}. A delayed expression runs where the name is first read, so it sees the bindings at that point and its own writes happen there, in the \`assign.env\` given.`;
656
656
  readonly example: string;
657
657
  }, {
658
658
  readonly name: "Range Assignment";
@@ -946,7 +946,14 @@ export declare const flowrCapabilities: {
946
946
  readonly id: "built-in-options";
947
947
  readonly code: readonly ["options", "getOption"];
948
948
  readonly supported: "partially";
949
- readonly description: `_The global options \`options\` sets and \`getOption\` reads._ Option values are not tracked, so \`getOption("digits")\` does not reach a preceding \`options(digits = 3)\`. Unlike the ${string} they are not interpreted at all.`;
949
+ readonly description: "_The global options `options` sets and `getOption`, `.Options`, printing, and formatting read._ Each option is tracked by name, so `getOption(\"digits\")` reaches the last `options(digits = 3)`, `print` and `cat` reach the printing options, and an unrelated option usually stays out of a slice. `withr::with_options` and `local_options` scope a change, and `eval` of code that sets options counts as setting them. The values themselves are not interpreted, an `options(op)` restoring an unknown list may set any option, and options that change every conversion (`scipen`, `OutDec`) stay an unknown side effect. A function flowR cannot see into may read any option.";
950
+ readonly example: string;
951
+ }, {
952
+ readonly name: "Graphics State";
953
+ readonly id: "graphics-state";
954
+ readonly code: readonly ["par", "layout", "palette", "dev.off", "dev.set"];
955
+ readonly supported: "partially";
956
+ readonly description: "_The graphics parameters `par` and `layout` set for the active device, the `palette` all devices share, and the devices opened and closed._ A plot reads the state of the device it draws on, so it links to the `par` calls before it, a new device starts afresh, and `dev.off()` returns to the state of the device that becomes active. `withr::with_par` and the `with_<device>` functions scope a change. Within a function the open devices are unknown, so a device call only adds to what may hold, and grid-based plots like ggplot2 ignore the parameters.";
950
957
  readonly example: string;
951
958
  }, {
952
959
  readonly name: "Help";
@@ -1000,7 +1007,7 @@ export declare const flowrCapabilities: {
1000
1007
  readonly id: "built-in-evaluation";
1001
1008
  readonly code: readonly ["eval", "evalq", "eval.parent"];
1002
1009
  readonly supported: "partially";
1003
- readonly description: `_Run an expression that is a value with \`eval\`, \`evalq\`, \`eval.parent\`, ..._ \`eval(expr, envir)\` runs in an ${string} we may not know, so it is marked an unknown side effect.`;
1010
+ readonly description: `_Run an expression that is a value with \`eval\`, \`evalq\`, \`eval.parent\`, ..._ The captured code is linked where it is evaluated, also through a name bound once to \`quote\`, \`as.name\`, \`str2lang\`, or \`parse\`, but \`eval(expr, envir)\` with an ${string} we do not know stays an unknown side effect.`;
1004
1011
  readonly example: string;
1005
1012
  readonly url: [{
1006
1013
  name: string;
@@ -1019,9 +1026,9 @@ export declare const flowrCapabilities: {
1019
1026
  }, {
1020
1027
  readonly name: "Parsing";
1021
1028
  readonly id: "built-in-parsing";
1022
- readonly code: readonly ["parse", "deparse"];
1029
+ readonly code: readonly ["parse", "str2lang", "deparse"];
1023
1030
  readonly supported: "partially";
1024
- readonly description: `_Turn text into an expression with \`parse\`, and an expression back into text with \`deparse\`._ What \`parse\` produces is only reached through ${string}, and \`deparse\` is not modelled beyond reading its argument.`;
1031
+ readonly description: `_Turn text into an expression with \`parse\` or \`str2lang\`, and an expression back into text with \`deparse\`._ What \`parse\` produces is only reached through ${string}, and \`deparse\` is not modelled beyond reading its argument.`;
1025
1032
  readonly example: string;
1026
1033
  readonly url: [{
1027
1034
  name: string;
@@ -1231,7 +1238,7 @@ export declare const flowrCapabilities: {
1231
1238
  readonly id: "oop-s3-dispatch";
1232
1239
  readonly code: readonly ["UseMethod"];
1233
1240
  readonly supported: "partially";
1234
- readonly description: `_Route a generic call to the method that runs._ \`UseMethod\` links to every ${string} named \`generic.class\` in scope, so the ${string} an object carries narrows the target only where it is known (heavily over-approximating).`;
1241
+ readonly description: `_Route a generic call to the method that runs._ \`UseMethod\` and a built-in generic like \`length\` or \`toString\` link to every ${string} named \`generic.class\` in scope, so the ${string} an object carries narrows the target only where it is known (heavily over-approximating).`;
1235
1242
  readonly url: [{
1236
1243
  name: string;
1237
1244
  href: string;
@@ -1244,7 +1251,7 @@ export declare const flowrCapabilities: {
1244
1251
  readonly id: "oop-s3-inheritance";
1245
1252
  readonly code: readonly ["NextMethod"];
1246
1253
  readonly supported: "partially";
1247
- readonly description: `_Walk the class vector with \`NextMethod\`._ It reaches the generic's ${string}, the one it stands in included, rather than only the next class in the vector.`;
1254
+ readonly description: `_Walk the class vector with \`NextMethod\`._ It reaches the generic's ${string}, the one it stands in included, rather than only the next class in the vector, and hands on the current values of the formals.`;
1248
1255
  readonly url: [{
1249
1256
  name: string;
1250
1257
  href: string;
@@ -1275,9 +1282,9 @@ export declare const flowrCapabilities: {
1275
1282
  }, {
1276
1283
  readonly name: "Dispatch";
1277
1284
  readonly id: "oop-s4-dispatch";
1278
- readonly code: readonly ["standardGeneric", "setGeneric", "setMethod"];
1285
+ readonly code: readonly ["standardGeneric", "setGeneric", "setMethod", "setReplaceMethod"];
1279
1286
  readonly supported: "partially";
1280
- readonly description: `_Route a generic call to the method \`setMethod\` registered._ The generic reaches its methods through the chain they register in, but the signature does not narrow which of them runs, as ${string} for the argument.`;
1287
+ readonly description: `_Route a generic call to the method \`setMethod\` (or \`setReplaceMethod\`, for the \`<-\` generic) registered._ The generic reaches its methods through the chain they register in, but the signature does not narrow which of them runs, as ${string} for the argument.`;
1281
1288
  readonly url: [{
1282
1289
  name: string;
1283
1290
  href: string;
@@ -128,8 +128,8 @@ ${await (0, doc_dfg_1.printDfGraphForCode)(parser, code, { simplified: true, tim
128
128
  name: 'Dynamic Environment Resolution',
129
129
  id: 'dynamic-environment-resolution',
130
130
  code: ['new.env'],
131
- description: `_An environment a program builds and names itself, rather than one a ${LinkTo('function-definitions', 'definition')} opens._ Covers \`new.env\`, \`assign\`/\`get\`/\`local\` with \`envir=\`, \`e$x\`, \`attach\`, \`with\`, and aliasing such an environment through a variable.`,
132
- example: (0, doc_code_1.codeBlock)('r', 'e <- new.env()\nassign("x", 3, envir = e)\nget("x", envir = e) + e$x'),
131
+ description: `_An environment a program builds and names itself, rather than one a ${LinkTo('function-definitions', 'definition')} opens._ Covers \`new.env\`, \`assign\`/\`get\`/\`local\` with \`envir=\`, \`e$x\`, \`attach\`, \`with\`, and aliasing such an environment through a variable. A write from within a function reaches the environment it names, a read of the whole environment (\`as.list(e)\`) sees every field written, and copies of an environment variable (\`g <- e\`) share its fields.`,
132
+ example: (0, doc_code_1.codeBlock)('r', 'e <- new.env()\nassign("x", 3, envir = e)\nget("x", envir = e) + e$x\nf <- function() e$y <- 4\nf()\ng <- e\ng$z <- 5\nas.list(e)'),
133
133
  capabilities: [
134
134
  {
135
135
  name: 'Environment in Control Flow',
@@ -285,8 +285,8 @@ ${await (0, doc_dfg_1.printDfGraphForCode)(parser, code, { simplified: true, tim
285
285
  {
286
286
  name: 'Local with Explicit Environment',
287
287
  id: 'local-envir-argument',
288
- supported: 'partially',
289
- description: '_Send `local`\'s body to a specific environment._ `new.env()` and `globalenv()` work, but inside a function that already binds the name the write lands in that frame instead.',
288
+ supported: 'fully',
289
+ description: '_Send `local`\'s body to a specific environment._ Its writes land in that environment, also inside a function that binds the same name itself.',
290
290
  example: (0, doc_code_1.codeBlock)('r', 'e <- new.env()\nlocal(y <- 2, envir = e)\nget("y", envir = e)'),
291
291
  url: [{ name: '`local`', href: 'https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/local' }]
292
292
  },
@@ -366,8 +366,8 @@ ${await (0, doc_dfg_1.printDfGraphForCode)(parser, code, { simplified: true, tim
366
366
  name: 'Side-Effects in Argument',
367
367
  id: 'side-effects-in-argument',
368
368
  supported: 'partially',
369
- description: `_An argument that binds a name while it is evaluated, as \`f(x <- 3)\` does._ Whether the argument is ever forced is not modelled (see ${LinkTo('formals-promises', 'promises')}), so \`f <- function(a) 1; f(x <- 3)\` still believes \`x\` is 3.`,
370
- example: (0, doc_code_1.codeBlock)('r', 'f <- function(a) a\nf(x <- 3)\nx'),
369
+ description: `_An argument that binds a name while it is evaluated, as \`f(x <- 3)\` does._ Whether the argument is ever forced is not modelled (see ${LinkTo('formals-promises', 'promises')}), so \`f <- function(a) 1; f(x <- 3)\` still believes \`x\` is 3. A call in the argument depends on the call it is handed to, so \`g(FALSE, f(4))\` keeps \`g\`.`,
370
+ example: (0, doc_code_1.codeBlock)('r', 'f <- function(a) a\nf(x <- 3)\nx\ng <- function(a, b) if(a) b else 0\ng(FALSE, print("never"))'),
371
371
  url: [RLang('Argument evaluation')]
372
372
  },
373
373
  {
@@ -416,7 +416,7 @@ ${await (0, doc_dfg_1.printDfGraphForCode)(parser, code, { simplified: true, tim
416
416
  name: 'Functions with global side effects',
417
417
  id: 'functions-with-global-side-effects',
418
418
  supported: 'partially',
419
- description: `_A call that changes state the rest of the program reads without naming it, as \`setwd\` changes where a path points._ Only the ${LinkTo('working-directory', 'working directory')} is interpreted, while other ambient state such as ${LinkTo('built-in-options', 'the options')} stays an unknown side effect.`,
419
+ description: `_A call that changes state the rest of the program reads without naming it, as \`setwd\` changes where a path points._ The ${LinkTo('working-directory', 'working directory')}, ${LinkTo('built-in-options', 'the options')}, and ${LinkTo('graphics-state', 'the graphics state')} are tracked, so a read links to the calls that set what it reads. Other ambient state, like environment variables or the random seed, stays an unknown side effect.`,
420
420
  example: (0, doc_code_1.codeBlock)('r', 'setwd("/tmp")\nread.csv("data.csv")')
421
421
  },
422
422
  {
@@ -590,8 +590,8 @@ ${await (0, doc_dfg_1.printDfGraphForCode)(parser, code, { simplified: true, tim
590
590
  id: 'assignment-functions',
591
591
  code: ['assign', 'delayedAssign'],
592
592
  supported: 'partially',
593
- description: `_Bind a name given as a string, with \`assign\`, \`delayedAssign\`, ..._ The name has to be a ${LinkTo('name-created-resolved', 'resolvable string')}, and what a delayed assignment does when forced is not modelled.`,
594
- example: (0, doc_code_1.codeBlock)('r', 'assign("x", 3)\ndelayedAssign("y", x * 2)\ny')
593
+ description: `_Bind a name given as a string, with \`assign\`, \`delayedAssign\`, ..._ The name has to be a ${LinkTo('name-created-resolved', 'resolvable string')}. A delayed expression runs where the name is first read, so it sees the bindings at that point and its own writes happen there, in the \`assign.env\` given.`,
594
+ example: (0, doc_code_1.codeBlock)('r', 'assign("x", 3)\ndelayedAssign("y", x * 2)\nx <- 5\ny')
595
595
  },
596
596
  {
597
597
  name: 'Range Assignment',
@@ -838,8 +838,16 @@ ${await (0, doc_dfg_1.printDfGraphForCode)(parser, code, { simplified: true, tim
838
838
  id: 'built-in-options',
839
839
  code: ['options', 'getOption'],
840
840
  supported: 'partially',
841
- description: `_The global options \`options\` sets and \`getOption\` reads._ Option values are not tracked, so \`getOption("digits")\` does not reach a preceding \`options(digits = 3)\`. Unlike the ${LinkTo('working-directory', 'working directory')} they are not interpreted at all.`,
842
- example: (0, doc_code_1.codeBlock)('r', 'old <- options(digits = 3)\ngetOption("digits")\noptions(old)')
841
+ description: '_The global options `options` sets and `getOption`, `.Options`, printing, and formatting read._ Each option is tracked by name, so `getOption("digits")` reaches the last `options(digits = 3)`, `print` and `cat` reach the printing options, and an unrelated option usually stays out of a slice. `withr::with_options` and `local_options` scope a change, and `eval` of code that sets options counts as setting them. The values themselves are not interpreted, an `options(op)` restoring an unknown list may set any option, and options that change every conversion (`scipen`, `OutDec`) stay an unknown side effect. A function flowR cannot see into may read any option.',
842
+ example: (0, doc_code_1.codeBlock)('r', 'old <- options(digits = 3)\nprint(pi)\noptions(old)\ngetOption("digits")')
843
+ },
844
+ {
845
+ name: 'Graphics State',
846
+ id: 'graphics-state',
847
+ code: ['par', 'layout', 'palette', 'dev.off', 'dev.set'],
848
+ supported: 'partially',
849
+ description: '_The graphics parameters `par` and `layout` set for the active device, the `palette` all devices share, and the devices opened and closed._ A plot reads the state of the device it draws on, so it links to the `par` calls before it, a new device starts afresh, and `dev.off()` returns to the state of the device that becomes active. `withr::with_par` and the `with_<device>` functions scope a change. Within a function the open devices are unknown, so a device call only adds to what may hold, and grid-based plots like ggplot2 ignore the parameters.',
850
+ example: (0, doc_code_1.codeBlock)('r', 'par(mfrow = c(1, 2))\npng("a.png")\npar(mar = c(1, 1, 1, 1))\nplot(1:10)\ndev.off()\nplot(2:3)')
843
851
  },
844
852
  {
845
853
  name: 'Help',
@@ -886,8 +894,8 @@ ${await (0, doc_dfg_1.printDfGraphForCode)(parser, code, { simplified: true, tim
886
894
  id: 'built-in-evaluation',
887
895
  code: ['eval', 'evalq', 'eval.parent'],
888
896
  supported: 'partially',
889
- description: `_Run an expression that is a value with \`eval\`, \`evalq\`, \`eval.parent\`, ..._ \`eval(expr, envir)\` runs in an ${LinkTo('dynamic-environment-resolution', 'environment')} we may not know, so it is marked an unknown side effect.`,
890
- example: (0, doc_code_1.codeBlock)('r', 'e <- quote(x + 1)\nx <- 2\neval(e)'),
897
+ description: `_Run an expression that is a value with \`eval\`, \`evalq\`, \`eval.parent\`, ..._ The captured code is linked where it is evaluated, also through a name bound once to \`quote\`, \`as.name\`, \`str2lang\`, or \`parse\`, but \`eval(expr, envir)\` with an ${LinkTo('dynamic-environment-resolution', 'environment')} we do not know stays an unknown side effect.`,
898
+ example: (0, doc_code_1.codeBlock)('r', 'e <- quote(x + 1)\nx <- 2\neval(e)\nn <- as.name("x")\neval(n)'),
891
899
  url: [RLang('Evaluation of expressions'), AdvancedR('Evaluation', 'evaluation.html')]
892
900
  },
893
901
  {
@@ -901,10 +909,10 @@ ${await (0, doc_dfg_1.printDfGraphForCode)(parser, code, { simplified: true, tim
901
909
  {
902
910
  name: 'Parsing',
903
911
  id: 'built-in-parsing',
904
- code: ['parse', 'deparse'],
912
+ code: ['parse', 'str2lang', 'deparse'],
905
913
  supported: 'partially',
906
- description: `_Turn text into an expression with \`parse\`, and an expression back into text with \`deparse\`._ What \`parse\` produces is only reached through ${LinkTo('built-in-evaluation', 'evaluation')}, and \`deparse\` is not modelled beyond reading its argument.`,
907
- example: (0, doc_code_1.codeBlock)('r', 'eval(parse(text = "1 + 1"))\ndeparse(quote(x + y))'),
914
+ description: `_Turn text into an expression with \`parse\` or \`str2lang\`, and an expression back into text with \`deparse\`._ What \`parse\` produces is only reached through ${LinkTo('built-in-evaluation', 'evaluation')}, and \`deparse\` is not modelled beyond reading its argument.`,
915
+ example: (0, doc_code_1.codeBlock)('r', 'eval(parse(text = "1 + 1"))\neval(str2lang("2 * 3"))\ndeparse(quote(x + y))'),
908
916
  url: [RLang('The parsing process'), RLang('Deparsing')]
909
917
  }
910
918
  ]
@@ -1082,7 +1090,7 @@ ${await (0, doc_dfg_1.printDfGraphForCode)(parser, code, { simplified: true, tim
1082
1090
  id: 'oop-s3-dispatch',
1083
1091
  code: ['UseMethod'],
1084
1092
  supported: 'partially',
1085
- description: `_Route a generic call to the method that runs._ \`UseMethod\` links to every ${LinkTo('function-definitions', 'definition')} named \`generic.class\` in scope, so the ${LinkTo('oop-s3-construction', 'class')} an object carries narrows the target only where it is known (heavily over-approximating).`,
1093
+ description: `_Route a generic call to the method that runs._ \`UseMethod\` and a built-in generic like \`length\` or \`toString\` link to every ${LinkTo('function-definitions', 'definition')} named \`generic.class\` in scope, so the ${LinkTo('oop-s3-construction', 'class')} an object carries narrows the target only where it is known (heavily over-approximating).`,
1086
1094
  url: [RLang('UseMethod'), RLang('Method dispatching')]
1087
1095
  },
1088
1096
  {
@@ -1090,7 +1098,7 @@ ${await (0, doc_dfg_1.printDfGraphForCode)(parser, code, { simplified: true, tim
1090
1098
  id: 'oop-s3-inheritance',
1091
1099
  code: ['NextMethod'],
1092
1100
  supported: 'partially',
1093
- description: `_Walk the class vector with \`NextMethod\`._ It reaches the generic's ${LinkTo('oop-s3-dispatch', 'methods')}, the one it stands in included, rather than only the next class in the vector.`,
1101
+ description: `_Walk the class vector with \`NextMethod\`._ It reaches the generic's ${LinkTo('oop-s3-dispatch', 'methods')}, the one it stands in included, rather than only the next class in the vector, and hands on the current values of the formals.`,
1094
1102
  url: [RLang('NextMethod'), RLang('Inheritance')]
1095
1103
  }
1096
1104
  ]
@@ -1113,9 +1121,9 @@ ${await (0, doc_dfg_1.printDfGraphForCode)(parser, code, { simplified: true, tim
1113
1121
  {
1114
1122
  name: 'Dispatch',
1115
1123
  id: 'oop-s4-dispatch',
1116
- code: ['standardGeneric', 'setGeneric', 'setMethod'],
1124
+ code: ['standardGeneric', 'setGeneric', 'setMethod', 'setReplaceMethod'],
1117
1125
  supported: 'partially',
1118
- description: `_Route a generic call to the method \`setMethod\` registered._ The generic reaches its methods through the chain they register in, but the signature does not narrow which of them runs, as ${LinkTo('types-inference', 'no type is inferred')} for the argument.`,
1126
+ description: `_Route a generic call to the method \`setMethod\` (or \`setReplaceMethod\`, for the \`<-\` generic) registered._ The generic reaches its methods through the chain they register in, but the signature does not narrow which of them runs, as ${LinkTo('types-inference', 'no type is inferred')} for the argument.`,
1119
1127
  url: [RLang('Method dispatching')]
1120
1128
  },
1121
1129
  {
@@ -14,7 +14,7 @@ import type { RForLoop } from './nodes/r-for-loop';
14
14
  import type { RRepeatLoop } from './nodes/r-repeat-loop';
15
15
  import type { RWhileLoop } from './nodes/r-while-loop';
16
16
  import type { RIfThenElse } from './nodes/r-if-then-else';
17
- import type { RFunctionDefinition } from './nodes/r-function-definition';
17
+ import { RFunctionDefinition } from './nodes/r-function-definition';
18
18
  import type { EmptyArgument, RFunctionCall } from './nodes/r-function-call';
19
19
  import type { RParameter } from './nodes/r-parameter';
20
20
  import type { RArgument } from './nodes/r-argument';
@@ -263,6 +263,8 @@ export declare const RNode: {
263
263
  * which `isTarget` holds, `undefined` if the walk reaches the root of the file without a match.
264
264
  */
265
265
  readonly findEnclosing: <OtherInfo>(this: void, id: NodeId, idMap: AstIdMap<OtherInfo & ParentInformation>, isTarget: (node: RNode<OtherInfo & ParentInformation>) => boolean) => NodeId | undefined;
266
+ /** The function definition strictly enclosing `id`, i.e., `id` itself excluded. */
267
+ readonly strictlyEnclosingFunction: <OtherInfo>(this: void, id: NodeId, idMap: AstIdMap<OtherInfo & ParentInformation>) => NodeId | undefined;
266
268
  /**
267
269
  * A helper function to retrieve the type of a given node.
268
270
  */
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RNode = exports.ROther = exports.RFunctions = exports.RConstructs = exports.RLoopConstructs = exports.RSingleNode = exports.RConstant = void 0;
4
4
  const range_1 = require("../../../../util/range");
5
5
  const type_1 = require("./type");
6
+ const r_function_definition_1 = require("./nodes/r-function-definition");
6
7
  const r_access_1 = require("./nodes/r-access");
7
8
  const visitor_1 = require("./processing/visitor");
8
9
  const assert_1 = require("../../../../util/assert");
@@ -18,11 +19,7 @@ exports.RConstant = {
18
19
  * If you need the specific type, please either use the respective type guards (e.g., {@link RNumber.is}) or check the `type` node directly.
19
20
  */
20
21
  is(node) {
21
- if (!node) {
22
- return false;
23
- }
24
- const t = node.type;
25
- return t === type_1.RType.Number || t === type_1.RType.String || t === type_1.RType.Logical;
22
+ return node !== undefined && exports.RConstant.constantTypes.has(node.type);
26
23
  },
27
24
  /**
28
25
  * A set of all types of constants in the normalized AST, i.e. number, string, and logical constants.
@@ -39,11 +36,7 @@ exports.RSingleNode = {
39
36
  * If you need the specific type, please either use the respective type guards (e.g., {@link RComment.is}) or check the `type` node directly.
40
37
  */
41
38
  is(node) {
42
- if (!node) {
43
- return false;
44
- }
45
- const t = node.type;
46
- return t === type_1.RType.Comment || t === type_1.RType.Symbol || exports.RConstant.constantTypes.has(t) || t === type_1.RType.Break || t === type_1.RType.Next || t === type_1.RType.LineDirective;
39
+ return node !== undefined && exports.RSingleNode.singleNodeTypes.has(node.type);
47
40
  },
48
41
  /**
49
42
  * A set of all types of single nodes in the normalized AST, i.e. comment, symbol, constant, break, next, and line directive nodes.
@@ -57,11 +50,7 @@ exports.RLoopConstructs = {
57
50
  * If you need the specific type, please either use the respective type guards (e.g., {@link RForLoop.is}) or check the `type` node directly.
58
51
  */
59
52
  is(node) {
60
- if (!node) {
61
- return false;
62
- }
63
- const t = node.type;
64
- return t === type_1.RType.ForLoop || t === type_1.RType.RepeatLoop || t === type_1.RType.WhileLoop;
53
+ return node !== undefined && exports.RLoopConstructs.loopConstructTypes.has(node.type);
65
54
  },
66
55
  /**
67
56
  * A set of all types of loop constructs in the normalized AST, i.e. for, repeat and while loops.
@@ -75,11 +64,7 @@ exports.RConstructs = {
75
64
  * If you need the specific type, please either use the respective type guards (e.g., {@link RForLoop.is}) or check the `type` node directly.
76
65
  */
77
66
  is(node) {
78
- if (!node) {
79
- return false;
80
- }
81
- const t = node.type;
82
- return exports.RLoopConstructs.loopConstructTypes.has(t) || t === type_1.RType.IfThenElse;
67
+ return node !== undefined && exports.RConstructs.constructTypes.has(node.type);
83
68
  },
84
69
  /**
85
70
  * A set of all types of constructs in the normalized AST, i.e. for, repeat and while loops and if-then-else constructs.
@@ -93,11 +78,7 @@ exports.RFunctions = {
93
78
  * If you need the specific type, please either use the respective type guards (e.g., {@link RFunctionDefinition.is}) or check the `type` node directly.
94
79
  */
95
80
  is(node) {
96
- if (!node) {
97
- return false;
98
- }
99
- const t = node.type;
100
- return t === type_1.RType.FunctionDefinition || t === type_1.RType.FunctionCall || t === type_1.RType.Parameter || t === type_1.RType.Argument;
81
+ return node !== undefined && exports.RFunctions.functionTypes.has(node.type);
101
82
  },
102
83
  /**
103
84
  * A set of all types of function-related nodes in the normalized AST, i.e. function definitions, function calls, parameters, and arguments.
@@ -187,15 +168,18 @@ exports.RNode = {
187
168
  * which `isTarget` holds, `undefined` if the walk reaches the root of the file without a match.
188
169
  */
189
170
  findEnclosing(id, idMap, isTarget) {
190
- let node = idMap.get(id);
191
- while (node !== undefined) {
171
+ for (let node = idMap.get(id); node !== undefined; node = exports.RNode.directParent(node, idMap)) {
192
172
  if (isTarget(node)) {
193
173
  return node.info.id;
194
174
  }
195
- node = node.info.parent !== undefined ? idMap.get(node.info.parent) : undefined;
196
175
  }
197
176
  return undefined;
198
177
  },
178
+ /** The function definition strictly enclosing `id`, i.e., `id` itself excluded. */
179
+ strictlyEnclosingFunction(id, idMap) {
180
+ const parent = idMap.get(id)?.info.parent;
181
+ return parent === undefined ? undefined : exports.RNode.findEnclosing(parent, idMap, r_function_definition_1.RFunctionDefinition.is);
182
+ },
199
183
  /**
200
184
  * A helper function to retrieve the type of a given node.
201
185
  */
@@ -263,22 +247,16 @@ exports.RNode = {
263
247
  * @see {@link iterateParents} - to get all parents of a node
264
248
  */
265
249
  directParent(node, idMap) {
266
- const parentId = node.info.parent;
267
- if (parentId === undefined) {
268
- return undefined;
269
- }
270
- return idMap.get(parentId);
250
+ return node.info.parent === undefined ? undefined : idMap.get(node.info.parent);
271
251
  },
272
252
  /**
273
253
  * Returns an iterable of all parents of a node, starting with the direct parent and ending with the root node.
274
254
  */
275
255
  *iterateParents(node, idMap) {
276
- let currentNode = node;
277
- while (currentNode) {
278
- currentNode = exports.RNode.directParent(currentNode, idMap);
279
- if (currentNode) {
280
- yield currentNode;
281
- }
256
+ let current = node === undefined ? undefined : exports.RNode.directParent(node, idMap);
257
+ while (current !== undefined) {
258
+ yield current;
259
+ current = exports.RNode.directParent(current, idMap);
282
260
  }
283
261
  },
284
262
  /**
@@ -286,10 +264,8 @@ exports.RNode = {
286
264
  * this function calculates the depth of a node by counting the number of parents until the root node is reached.
287
265
  */
288
266
  depth(node, idMap) {
289
- let depth = 0;
290
- let currentNode = node;
291
- while (currentNode) {
292
- currentNode = exports.RNode.directParent(currentNode, idMap);
267
+ let depth = 1;
268
+ for (const _ of exports.RNode.iterateParents(node, idMap)) {
293
269
  depth++;
294
270
  }
295
271
  return depth;
@@ -50,6 +50,7 @@ export declare const RAccess: {
50
50
  readonly span: <OtherInfo>(this: void, node: RNode<OtherInfo> | undefined) => import("../../../../..").SourceRange | undefined;
51
51
  readonly topLevelStatement: <OtherInfo>(this: void, node: RNode<OtherInfo & import("../processing/decorate").ParentInformation>, idMap: import("../processing/decorate").AstIdMap<OtherInfo & import("../processing/decorate").ParentInformation>) => RNode<OtherInfo & import("../processing/decorate").ParentInformation>;
52
52
  readonly findEnclosing: <OtherInfo>(this: void, id: import("../processing/node-id").NodeId, idMap: import("../processing/decorate").AstIdMap<OtherInfo & import("../processing/decorate").ParentInformation>, isTarget: (node: RNode<OtherInfo & import("../processing/decorate").ParentInformation>) => boolean) => import("../processing/node-id").NodeId | undefined;
53
+ readonly strictlyEnclosingFunction: <OtherInfo>(this: void, id: import("../processing/node-id").NodeId, idMap: import("../processing/decorate").AstIdMap<OtherInfo & import("../processing/decorate").ParentInformation>) => import("../processing/node-id").NodeId | undefined;
53
54
  readonly getType: (this: void, node: RNode) => RType;
54
55
  readonly visitAst: <OtherInfo = object>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo>>, onVisit?: import("../processing/visitor").OnEnter<OtherInfo>, onExit?: import("../processing/visitor").OnExit<OtherInfo>) => void;
55
56
  readonly collectAllIds: <OtherInfo>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo & import("../processing/decorate").ParentInformation>>) => Set<import("../processing/node-id").NodeId>;
@@ -54,6 +54,8 @@ export declare const RArgument: {
54
54
  * Type guard for unnamed arguments, i.e. arguments without a name.
55
55
  */
56
56
  readonly isUnnamed: <Info = object>(this: void, node: RNode<Info> | typeof EmptyArgument | undefined) => node is RUnnamedArgument<Info>;
57
+ /** The value of an argument, the node itself for anything else, `undefined` for an empty argument. */
58
+ readonly valueOf: <Info = object>(this: void, node: RNode<Info> | typeof EmptyArgument | undefined) => RNode<Info> | undefined;
57
59
  /**
58
60
  * Type guard for arguments with a value, i.e. arguments that are not just placeholders without a value.
59
61
  */
@@ -71,6 +73,7 @@ export declare const RArgument: {
71
73
  readonly span: <OtherInfo>(this: void, node: RNode<OtherInfo> | undefined) => import("../../../../..").SourceRange | undefined;
72
74
  readonly topLevelStatement: <OtherInfo>(this: void, node: RNode<OtherInfo & ParentInformation>, idMap: import("../processing/decorate").AstIdMap<OtherInfo & ParentInformation>) => RNode<OtherInfo & ParentInformation>;
73
75
  readonly findEnclosing: <OtherInfo>(this: void, id: NodeId, idMap: import("../processing/decorate").AstIdMap<OtherInfo & ParentInformation>, isTarget: (node: RNode<OtherInfo & ParentInformation>) => boolean) => NodeId | undefined;
76
+ readonly strictlyEnclosingFunction: <OtherInfo>(this: void, id: NodeId, idMap: import("../processing/decorate").AstIdMap<OtherInfo & ParentInformation>) => NodeId | undefined;
74
77
  readonly getType: (this: void, node: RNode) => RType;
75
78
  readonly visitAst: <OtherInfo = object>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo>>, onVisit?: import("../processing/visitor").OnEnter<OtherInfo>, onExit?: import("../processing/visitor").OnExit<OtherInfo>) => void;
76
79
  readonly collectAllIds: <OtherInfo>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo & ParentInformation>>) => Set<NodeId>;
@@ -44,6 +44,10 @@ exports.RArgument = {
44
44
  isUnnamed(node) {
45
45
  return node !== r_function_call_1.EmptyArgument && exports.RArgument.is(node) && node.name === undefined && node.value !== undefined;
46
46
  },
47
+ /** The value of an argument, the node itself for anything else, `undefined` for an empty argument. */
48
+ valueOf(node) {
49
+ return node === r_function_call_1.EmptyArgument ? undefined : exports.RArgument.is(node) ? node.value : node;
50
+ },
47
51
  /**
48
52
  * Type guard for arguments with a value, i.e. arguments that are not just placeholders without a value.
49
53
  */
@@ -51,18 +55,7 @@ exports.RArgument = {
51
55
  return exports.RArgument.is(node) && node.value !== undefined;
52
56
  },
53
57
  getWithId(args, id) {
54
- if (id === undefined) {
55
- return undefined;
56
- }
57
- for (const arg of args) {
58
- if (exports.RArgument.isEmpty(arg)) {
59
- continue;
60
- }
61
- if (arg.info.id === id) {
62
- return arg;
63
- }
64
- }
65
- return undefined;
58
+ return id === undefined ? undefined : args.filter(exports.RArgument.isNotEmpty).find(arg => arg.info.id === id);
66
59
  },
67
60
  /**
68
61
  * Retrieve the value of the argument with the given id from the list of arguments.
@@ -31,6 +31,7 @@ export declare const RBinaryOp: {
31
31
  readonly span: <OtherInfo>(this: void, node: RNode<OtherInfo> | undefined) => import("../../../../..").SourceRange | undefined;
32
32
  readonly topLevelStatement: <OtherInfo>(this: void, node: RNode<OtherInfo & import("../processing/decorate").ParentInformation>, idMap: import("../processing/decorate").AstIdMap<OtherInfo & import("../processing/decorate").ParentInformation>) => RNode<OtherInfo & import("../processing/decorate").ParentInformation>;
33
33
  readonly findEnclosing: <OtherInfo>(this: void, id: import("../processing/node-id").NodeId, idMap: import("../processing/decorate").AstIdMap<OtherInfo & import("../processing/decorate").ParentInformation>, isTarget: (node: RNode<OtherInfo & import("../processing/decorate").ParentInformation>) => boolean) => import("../processing/node-id").NodeId | undefined;
34
+ readonly strictlyEnclosingFunction: <OtherInfo>(this: void, id: import("../processing/node-id").NodeId, idMap: import("../processing/decorate").AstIdMap<OtherInfo & import("../processing/decorate").ParentInformation>) => import("../processing/node-id").NodeId | undefined;
34
35
  readonly getType: (this: void, node: RNode) => RType;
35
36
  readonly visitAst: <OtherInfo = object>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo>>, onVisit?: import("../processing/visitor").OnEnter<OtherInfo>, onExit?: import("../processing/visitor").OnExit<OtherInfo>) => void;
36
37
  readonly collectAllIds: <OtherInfo>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo & import("../processing/decorate").ParentInformation>>) => Set<import("../processing/node-id").NodeId>;
@@ -23,6 +23,7 @@ export declare const RBreak: {
23
23
  readonly span: <OtherInfo>(this: void, node: RNode<OtherInfo> | undefined) => import("../../../../..").SourceRange | undefined;
24
24
  readonly topLevelStatement: <OtherInfo>(this: void, node: RNode<OtherInfo & import("../processing/decorate").ParentInformation>, idMap: import("../processing/decorate").AstIdMap<OtherInfo & import("../processing/decorate").ParentInformation>) => RNode<OtherInfo & import("../processing/decorate").ParentInformation>;
25
25
  readonly findEnclosing: <OtherInfo>(this: void, id: import("../processing/node-id").NodeId, idMap: import("../processing/decorate").AstIdMap<OtherInfo & import("../processing/decorate").ParentInformation>, isTarget: (node: RNode<OtherInfo & import("../processing/decorate").ParentInformation>) => boolean) => import("../processing/node-id").NodeId | undefined;
26
+ readonly strictlyEnclosingFunction: <OtherInfo>(this: void, id: import("../processing/node-id").NodeId, idMap: import("../processing/decorate").AstIdMap<OtherInfo & import("../processing/decorate").ParentInformation>) => import("../processing/node-id").NodeId | undefined;
26
27
  readonly getType: (this: void, node: RNode) => RType;
27
28
  readonly visitAst: <OtherInfo = object>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo>>, onVisit?: import("../processing/visitor").OnEnter<OtherInfo>, onExit?: import("../processing/visitor").OnExit<OtherInfo>) => void;
28
29
  readonly collectAllIds: <OtherInfo>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo & import("../processing/decorate").ParentInformation>>) => Set<import("../processing/node-id").NodeId>;
@@ -25,6 +25,7 @@ export declare const RComment: {
25
25
  readonly span: <OtherInfo>(this: void, node: RNode<OtherInfo> | undefined) => import("../../../../..").SourceRange | undefined;
26
26
  readonly topLevelStatement: <OtherInfo>(this: void, node: RNode<OtherInfo & import("../processing/decorate").ParentInformation>, idMap: import("../processing/decorate").AstIdMap<OtherInfo & import("../processing/decorate").ParentInformation>) => RNode<OtherInfo & import("../processing/decorate").ParentInformation>;
27
27
  readonly findEnclosing: <OtherInfo>(this: void, id: import("../processing/node-id").NodeId, idMap: import("../processing/decorate").AstIdMap<OtherInfo & import("../processing/decorate").ParentInformation>, isTarget: (node: RNode<OtherInfo & import("../processing/decorate").ParentInformation>) => boolean) => import("../processing/node-id").NodeId | undefined;
28
+ readonly strictlyEnclosingFunction: <OtherInfo>(this: void, id: import("../processing/node-id").NodeId, idMap: import("../processing/decorate").AstIdMap<OtherInfo & import("../processing/decorate").ParentInformation>) => import("../processing/node-id").NodeId | undefined;
28
29
  readonly getType: (this: void, node: RNode) => RType;
29
30
  readonly visitAst: <OtherInfo = object>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo>>, onVisit?: import("../processing/visitor").OnEnter<OtherInfo>, onExit?: import("../processing/visitor").OnExit<OtherInfo>) => void;
30
31
  readonly collectAllIds: <OtherInfo>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo & import("../processing/decorate").ParentInformation>>) => Set<import("../processing/node-id").NodeId>;
@@ -39,6 +39,7 @@ export declare const RExpressionList: {
39
39
  readonly span: <OtherInfo>(this: void, node: RNode<OtherInfo> | undefined) => import("../../../../..").SourceRange | undefined;
40
40
  readonly topLevelStatement: <OtherInfo>(this: void, node: RNode<OtherInfo & import("../processing/decorate").ParentInformation>, idMap: import("../processing/decorate").AstIdMap<OtherInfo & import("../processing/decorate").ParentInformation>) => RNode<OtherInfo & import("../processing/decorate").ParentInformation>;
41
41
  readonly findEnclosing: <OtherInfo>(this: void, id: import("../processing/node-id").NodeId, idMap: import("../processing/decorate").AstIdMap<OtherInfo & import("../processing/decorate").ParentInformation>, isTarget: (node: RNode<OtherInfo & import("../processing/decorate").ParentInformation>) => boolean) => import("../processing/node-id").NodeId | undefined;
42
+ readonly strictlyEnclosingFunction: <OtherInfo>(this: void, id: import("../processing/node-id").NodeId, idMap: import("../processing/decorate").AstIdMap<OtherInfo & import("../processing/decorate").ParentInformation>) => import("../processing/node-id").NodeId | undefined;
42
43
  readonly getType: (this: void, node: RNode) => RType;
43
44
  readonly visitAst: <OtherInfo = object>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo>>, onVisit?: import("../processing/visitor").OnEnter<OtherInfo>, onExit?: import("../processing/visitor").OnExit<OtherInfo>) => void;
44
45
  readonly collectAllIds: <OtherInfo>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo & import("../processing/decorate").ParentInformation>>) => Set<import("../processing/node-id").NodeId>;