@eagleoutice/flowr 2.6.3 → 2.7.2

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 (276) hide show
  1. package/README.md +22 -22
  2. package/abstract-interpretation/absint-visitor.d.ts +160 -0
  3. package/abstract-interpretation/absint-visitor.js +279 -0
  4. package/abstract-interpretation/data-frame/dataframe-domain.d.ts +4 -7
  5. package/abstract-interpretation/data-frame/dataframe-domain.js +26 -16
  6. package/abstract-interpretation/data-frame/mappers/access-mapper.d.ts +6 -4
  7. package/abstract-interpretation/data-frame/mappers/access-mapper.js +11 -14
  8. package/abstract-interpretation/data-frame/mappers/arguments.d.ts +10 -9
  9. package/abstract-interpretation/data-frame/mappers/arguments.js +8 -5
  10. package/abstract-interpretation/data-frame/mappers/function-mapper.d.ts +18 -18
  11. package/abstract-interpretation/data-frame/mappers/function-mapper.js +53 -58
  12. package/abstract-interpretation/data-frame/mappers/replacement-mapper.d.ts +7 -5
  13. package/abstract-interpretation/data-frame/mappers/replacement-mapper.js +26 -29
  14. package/abstract-interpretation/data-frame/semantics.js +48 -44
  15. package/abstract-interpretation/data-frame/shape-inference.d.ts +52 -28
  16. package/abstract-interpretation/data-frame/shape-inference.js +67 -90
  17. package/abstract-interpretation/domains/abstract-domain.d.ts +1 -0
  18. package/abstract-interpretation/domains/abstract-domain.js +3 -2
  19. package/abstract-interpretation/domains/bounded-set-domain.d.ts +2 -2
  20. package/abstract-interpretation/domains/bounded-set-domain.js +1 -1
  21. package/abstract-interpretation/domains/interval-domain.d.ts +4 -4
  22. package/abstract-interpretation/domains/interval-domain.js +3 -6
  23. package/abstract-interpretation/domains/lattice.d.ts +2 -0
  24. package/abstract-interpretation/domains/lattice.js +3 -1
  25. package/abstract-interpretation/domains/positive-interval-domain.d.ts +1 -1
  26. package/abstract-interpretation/domains/positive-interval-domain.js +1 -1
  27. package/abstract-interpretation/domains/satisfiable-domain.d.ts +2 -2
  28. package/abstract-interpretation/domains/satisfiable-domain.js +2 -2
  29. package/abstract-interpretation/domains/set-range-domain.d.ts +104 -0
  30. package/abstract-interpretation/domains/set-range-domain.js +406 -0
  31. package/abstract-interpretation/domains/set-upper-bound-domain.d.ts +2 -2
  32. package/abstract-interpretation/domains/set-upper-bound-domain.js +2 -2
  33. package/abstract-interpretation/domains/singleton-domain.d.ts +2 -2
  34. package/abstract-interpretation/domains/singleton-domain.js +2 -2
  35. package/benchmark/slicer.d.ts +2 -1
  36. package/benchmark/slicer.js +50 -29
  37. package/benchmark/stats/print.js +8 -5
  38. package/benchmark/stats/stats.d.ts +3 -2
  39. package/benchmark/summarizer/data.d.ts +11 -8
  40. package/benchmark/summarizer/first-phase/process.js +11 -8
  41. package/benchmark/summarizer/second-phase/process.js +24 -18
  42. package/cli/common/options.d.ts +431 -8
  43. package/cli/common/options.js +1 -1
  44. package/cli/common/scripts-info.d.ts +431 -7
  45. package/cli/flowr-main-options.d.ts +102 -2
  46. package/cli/flowr.d.ts +102 -2
  47. package/cli/repl/commands/repl-commands.d.ts +25 -0
  48. package/cli/repl/commands/repl-query.js +17 -5
  49. package/cli/wiki.d.ts +13 -0
  50. package/cli/wiki.js +7 -2
  51. package/config.d.ts +4 -4
  52. package/config.js +1 -1
  53. package/control-flow/basic-cfg-guided-visitor.js +7 -8
  54. package/control-flow/cfg-dead-code.js +3 -2
  55. package/control-flow/control-flow-graph.d.ts +1 -1
  56. package/control-flow/semantic-cfg-guided-visitor.d.ts +1 -1
  57. package/control-flow/semantic-cfg-guided-visitor.js +1 -1
  58. package/control-flow/useless-loop.js +4 -2
  59. package/core/steps/all/static-slicing/00-slice.d.ts +3 -0
  60. package/core/steps/all/static-slicing/00-slice.js +2 -1
  61. package/core/steps/pipeline/default-pipelines.d.ts +42 -42
  62. package/dataflow/cluster.js +2 -2
  63. package/dataflow/environments/append.d.ts +5 -0
  64. package/dataflow/environments/append.js +6 -20
  65. package/dataflow/environments/built-in.d.ts +2 -1
  66. package/dataflow/environments/clone.d.ts +1 -1
  67. package/dataflow/environments/clone.js +3 -27
  68. package/dataflow/environments/define.d.ts +7 -3
  69. package/dataflow/environments/define.js +9 -56
  70. package/dataflow/environments/diff.js +1 -1
  71. package/dataflow/environments/environment.d.ts +48 -28
  72. package/dataflow/environments/environment.js +187 -62
  73. package/dataflow/environments/overwrite.js +2 -45
  74. package/dataflow/environments/reference-to-maybe.d.ts +13 -0
  75. package/dataflow/environments/reference-to-maybe.js +54 -0
  76. package/dataflow/environments/resolve-by-name.d.ts +6 -1
  77. package/dataflow/environments/resolve-by-name.js +56 -4
  78. package/dataflow/environments/scoping.d.ts +2 -2
  79. package/dataflow/environments/scoping.js +7 -7
  80. package/dataflow/eval/resolve/alias-tracking.d.ts +10 -4
  81. package/dataflow/eval/resolve/alias-tracking.js +16 -14
  82. package/dataflow/eval/resolve/resolve-argument.d.ts +2 -1
  83. package/dataflow/eval/resolve/resolve-argument.js +8 -8
  84. package/dataflow/eval/resolve/resolve.d.ts +13 -11
  85. package/dataflow/eval/resolve/resolve.js +16 -15
  86. package/dataflow/extractor.js +1 -7
  87. package/dataflow/fn/higher-order-function.d.ts +2 -1
  88. package/dataflow/fn/higher-order-function.js +4 -4
  89. package/dataflow/graph/dataflowgraph-builder.d.ts +9 -5
  90. package/dataflow/graph/dataflowgraph-builder.js +21 -11
  91. package/dataflow/graph/diff-dataflow-graph.js +2 -2
  92. package/dataflow/graph/graph.d.ts +10 -2
  93. package/dataflow/graph/graph.js +41 -12
  94. package/dataflow/graph/invert-dfg.d.ts +3 -2
  95. package/dataflow/graph/invert-dfg.js +3 -3
  96. package/dataflow/graph/resolve-graph.d.ts +2 -1
  97. package/dataflow/graph/resolve-graph.js +2 -2
  98. package/dataflow/graph/vertex.d.ts +3 -3
  99. package/dataflow/graph/vertex.js +3 -3
  100. package/dataflow/info.d.ts +1 -1
  101. package/dataflow/internal/linker.d.ts +2 -0
  102. package/dataflow/internal/linker.js +13 -19
  103. package/dataflow/internal/process/functions/call/argument/unpack-argument.d.ts +7 -1
  104. package/dataflow/internal/process/functions/call/argument/unpack-argument.js +12 -3
  105. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +3 -3
  106. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +2 -2
  107. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +3 -1
  108. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +3 -3
  109. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +9 -9
  110. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +9 -7
  111. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +3 -3
  112. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +2 -1
  113. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +9 -13
  114. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +1 -1
  115. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.d.ts +3 -1
  116. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +8 -6
  117. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +1 -1
  118. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +1 -1
  119. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +1 -1
  120. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +3 -3
  121. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +6 -4
  122. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +1 -1
  123. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +5 -5
  124. package/dataflow/internal/process/functions/call/common.js +2 -3
  125. package/dataflow/internal/process/functions/call/known-call-handling.js +1 -1
  126. package/dataflow/internal/process/functions/call/unnamed-call-handling.js +1 -1
  127. package/dataflow/internal/process/functions/process-argument.js +1 -1
  128. package/dataflow/internal/process/process-symbol.js +1 -1
  129. package/dataflow/internal/process/process-value.d.ts +1 -1
  130. package/dataflow/internal/process/process-value.js +7 -7
  131. package/dataflow/processor.d.ts +1 -5
  132. package/documentation/doc-capabilities.d.ts +1 -1
  133. package/documentation/doc-readme.d.ts +1 -1
  134. package/documentation/doc-util/doc-cfg.js +1 -1
  135. package/documentation/doc-util/doc-cli-option.d.ts +6 -6
  136. package/documentation/doc-util/doc-cli-option.js +3 -3
  137. package/documentation/doc-util/doc-dfg.d.ts +1 -1
  138. package/documentation/doc-util/doc-dfg.js +3 -2
  139. package/documentation/doc-util/doc-files.d.ts +3 -0
  140. package/documentation/doc-util/doc-files.js +4 -1
  141. package/documentation/doc-util/doc-normalized-ast.js +5 -4
  142. package/documentation/doc-util/doc-types.d.ts +1 -1
  143. package/documentation/doc-util/doc-types.js +2 -2
  144. package/documentation/issue-linting-rule.d.ts +1 -1
  145. package/documentation/wiki-analyzer.d.ts +1 -1
  146. package/documentation/wiki-analyzer.js +14 -1
  147. package/documentation/wiki-cfg.d.ts +1 -1
  148. package/documentation/wiki-core.d.ts +1 -1
  149. package/documentation/wiki-dataflow-graph.d.ts +1 -1
  150. package/documentation/wiki-dataflow-graph.js +10 -11
  151. package/documentation/wiki-engine.d.ts +1 -1
  152. package/documentation/wiki-engine.js +9 -10
  153. package/documentation/wiki-faq.d.ts +1 -1
  154. package/documentation/wiki-faq.js +0 -1
  155. package/documentation/wiki-interface.d.ts +1 -1
  156. package/documentation/wiki-interface.js +12 -13
  157. package/documentation/wiki-linter.d.ts +1 -1
  158. package/documentation/wiki-linter.js +1 -1
  159. package/documentation/wiki-linting-and-testing.d.ts +1 -1
  160. package/documentation/wiki-mk/doc-context.d.ts +54 -1
  161. package/documentation/wiki-mk/doc-context.js +17 -0
  162. package/documentation/wiki-mk/doc-maker.d.ts +5 -5
  163. package/documentation/wiki-mk/doc-maker.js +5 -2
  164. package/documentation/wiki-normalized-ast.d.ts +1 -1
  165. package/documentation/wiki-onboarding.d.ts +1 -1
  166. package/documentation/wiki-overview.d.ts +9 -0
  167. package/documentation/wiki-overview.js +248 -0
  168. package/documentation/wiki-query.d.ts +1 -1
  169. package/documentation/wiki-query.js +17 -1
  170. package/documentation/wiki-search.d.ts +1 -1
  171. package/documentation/wiki-setup.d.ts +9 -0
  172. package/documentation/wiki-setup.js +122 -0
  173. package/linter/linter-rules.d.ts +2 -2
  174. package/linter/rules/absolute-path.js +4 -4
  175. package/linter/rules/dataframe-access-validation.d.ts +2 -2
  176. package/linter/rules/dataframe-access-validation.js +9 -11
  177. package/linter/rules/function-finder-util.d.ts +2 -2
  178. package/linter/rules/function-finder-util.js +1 -1
  179. package/linter/rules/network-functions.js +1 -1
  180. package/linter/rules/seeded-randomness.d.ts +1 -1
  181. package/linter/rules/seeded-randomness.js +5 -5
  182. package/linter/rules/unused-definition.js +1 -1
  183. package/package.json +1 -2
  184. package/project/context/flowr-analyzer-context.d.ts +11 -0
  185. package/project/context/flowr-analyzer-context.js +3 -0
  186. package/project/context/flowr-analyzer-environment-context.d.ts +47 -0
  187. package/project/context/flowr-analyzer-environment-context.js +50 -0
  188. package/project/context/flowr-analyzer-files-context.d.ts +9 -1
  189. package/project/context/flowr-analyzer-files-context.js +4 -0
  190. package/project/context/flowr-file.d.ts +2 -0
  191. package/project/context/flowr-file.js +2 -0
  192. package/project/plugins/file-plugins/{flowr-description-file.d.ts → files/flowr-description-file.d.ts} +1 -1
  193. package/project/plugins/file-plugins/files/flowr-description-file.js +75 -0
  194. package/project/plugins/file-plugins/files/flowr-news-file.d.ts +27 -0
  195. package/project/plugins/file-plugins/files/flowr-news-file.js +152 -0
  196. package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.d.ts +1 -1
  197. package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.js +1 -1
  198. package/project/plugins/file-plugins/flowr-analyzer-news-file-plugin.d.ts +23 -0
  199. package/project/plugins/file-plugins/flowr-analyzer-news-file-plugin.js +35 -0
  200. package/project/plugins/file-plugins/notebooks/flowr-analyzer-jupyter-file-plugin.d.ts +1 -1
  201. package/project/plugins/file-plugins/notebooks/flowr-analyzer-jupyter-file-plugin.js +1 -1
  202. package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.d.ts +1 -1
  203. package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.js +1 -1
  204. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.d.ts +1 -1
  205. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.js +1 -1
  206. package/project/plugins/flowr-analyzer-plugin-defaults.js +2 -0
  207. package/project/plugins/plugin-registry.d.ts +2 -1
  208. package/project/plugins/plugin-registry.js +2 -0
  209. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +7 -1
  210. package/queries/catalog/call-context-query/call-context-query-executor.js +1 -4
  211. package/queries/catalog/control-flow-query/control-flow-query-format.js +3 -2
  212. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.js +1 -1
  213. package/queries/catalog/dependencies-query/dependencies-query-executor.js +4 -4
  214. package/queries/catalog/df-shape-query/df-shape-query-executor.d.ts +1 -1
  215. package/queries/catalog/df-shape-query/df-shape-query-executor.js +5 -3
  216. package/queries/catalog/df-shape-query/df-shape-query-format.d.ts +4 -4
  217. package/queries/catalog/df-shape-query/df-shape-query-format.js +2 -2
  218. package/queries/catalog/files-query/files-query-executor.d.ts +6 -0
  219. package/queries/catalog/files-query/files-query-executor.js +49 -0
  220. package/queries/catalog/files-query/files-query-format.d.ts +36 -0
  221. package/queries/catalog/files-query/files-query-format.js +114 -0
  222. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +3 -3
  223. package/queries/catalog/linter-query/linter-query-format.js +1 -1
  224. package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +1 -1
  225. package/queries/catalog/static-slice-query/static-slice-query-executor.js +1 -1
  226. package/queries/query.d.ts +10 -1
  227. package/queries/query.js +3 -1
  228. package/r-bridge/lang-4.x/ast/model/model.d.ts +1 -1
  229. package/r-bridge/lang-4.x/ast/model/processing/decorate.js +8 -8
  230. package/r-bridge/lang-4.x/ast/model/processing/role.d.ts +8 -8
  231. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-parameter.js +0 -1
  232. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +0 -1
  233. package/slicing/static/slice-call.d.ts +3 -2
  234. package/slicing/static/slice-call.js +4 -4
  235. package/slicing/static/static-slicer.d.ts +3 -1
  236. package/slicing/static/static-slicer.js +6 -7
  237. package/statistics/features/supported/control-flow/control-flow.js +1 -1
  238. package/statistics/features/supported/data-access/data-access.js +1 -1
  239. package/statistics/features/supported/used-functions/used-functions.js +1 -1
  240. package/statistics/features/supported/variables/variables.js +2 -1
  241. package/util/containers.js +2 -2
  242. package/util/files.d.ts +0 -7
  243. package/util/files.js +0 -41
  244. package/util/mermaid/ast.d.ts +3 -2
  245. package/util/mermaid/ast.js +13 -7
  246. package/util/mermaid/cfg.d.ts +3 -2
  247. package/util/mermaid/cfg.js +26 -6
  248. package/util/mermaid/dfg.d.ts +2 -7
  249. package/util/mermaid/dfg.js +10 -6
  250. package/util/mermaid/info.d.ts +17 -0
  251. package/util/mermaid/info.js +5 -0
  252. package/util/prefix.d.ts +9 -5
  253. package/util/prefix.js +14 -6
  254. package/util/r-regex.d.ts +21 -0
  255. package/util/r-regex.js +25 -0
  256. package/util/simple-df/dfg-view.d.ts +2 -1
  257. package/util/simple-df/dfg-view.js +2 -2
  258. package/util/text/args.js +12 -3
  259. package/util/version.js +1 -1
  260. package/abstract-interpretation/data-frame/absint-info.d.ts +0 -109
  261. package/abstract-interpretation/data-frame/absint-info.js +0 -31
  262. package/abstract-interpretation/data-frame/absint-visitor.d.ts +0 -57
  263. package/abstract-interpretation/data-frame/absint-visitor.js +0 -176
  264. package/abstract-interpretation/data-frame/mappers/assignment-mapper.d.ts +0 -19
  265. package/abstract-interpretation/data-frame/mappers/assignment-mapper.js +0 -33
  266. package/dataflow/environments/remove.d.ts +0 -12
  267. package/dataflow/environments/remove.js +0 -52
  268. package/documentation/doc-util/doc-print.d.ts +0 -5
  269. package/documentation/doc-util/doc-print.js +0 -36
  270. package/project/plugins/file-plugins/flowr-description-file.js +0 -37
  271. package/project/plugins/file-plugins/notebooks/notebook.d.ts +0 -0
  272. package/project/plugins/file-plugins/notebooks/notebook.js +0 -2
  273. /package/project/plugins/file-plugins/{notebooks → files}/flowr-jupyter-file.d.ts +0 -0
  274. /package/project/plugins/file-plugins/{notebooks → files}/flowr-jupyter-file.js +0 -0
  275. /package/project/plugins/file-plugins/{notebooks → files}/flowr-rmarkdown-file.d.ts +0 -0
  276. /package/project/plugins/file-plugins/{notebooks → files}/flowr-rmarkdown-file.js +0 -0
@@ -49,15 +49,15 @@ function buildQuickFix(str, filePath, wd) {
49
49
  }
50
50
  /** return all strings constructable by these functions */
51
51
  const PathFunctions = {
52
- 'file.path': (df, vtx, config) => {
53
- const fsep = (0, resolve_argument_1.getArgumentStringValue)(config.solver.variables, df, vtx, undefined, 'fsep', true);
52
+ 'file.path': (df, vtx, ctx) => {
53
+ const fsep = (0, resolve_argument_1.getArgumentStringValue)(ctx.config.solver.variables, df, vtx, undefined, 'fsep', true, ctx);
54
54
  // in the future we can access `.Platform$file.sep` here
55
55
  const sepValues = fsep?.values()?.flatMap(s => s.values().filter(assert_1.isNotUndefined)).toArray() ?? [path_1.default.sep];
56
56
  if (sepValues.some(s => s === dependencies_query_format_1.Unknown || (0, assert_1.isUndefined)(s))) {
57
57
  // if we have no fsep, we cannot construct a path
58
58
  return undefined;
59
59
  }
60
- const args = (0, resolve_argument_1.getArgumentStringValue)(config.solver.variables, df, vtx, 'unnamed', undefined, true);
60
+ const args = (0, resolve_argument_1.getArgumentStringValue)(ctx.config.solver.variables, df, vtx, 'unnamed', undefined, true, ctx);
61
61
  const argValues = args ? Array.from(args.values()).flatMap(v => [...v]) : [];
62
62
  if (!argValues || argValues.length === 0 || argValues.some(v => v === dependencies_query_format_1.Unknown || (0, assert_1.isUndefined)(v))) {
63
63
  // if we have no arguments, we cannot construct a path
@@ -139,7 +139,7 @@ exports.ABSOLUTE_PATH = {
139
139
  const dfNode = data.dataflow.graph.getVertex(node.info.id);
140
140
  if ((0, vertex_1.isFunctionCallVertex)(dfNode)) {
141
141
  const handler = PathFunctions[dfNode.name ?? ''];
142
- const strings = handler ? handler(data.dataflow.graph, dfNode, data.analyzer.flowrConfig) : [];
142
+ const strings = handler ? handler(data.dataflow.graph, dfNode, data.analyzer.inspectContext()) : [];
143
143
  if (strings) {
144
144
  return strings.filter(s => (0, strings_1.isAbsolutePath)(s, regex)).map(str => ({
145
145
  certainty: linter_format_1.LintingResultCertainty.Uncertain,
@@ -2,7 +2,7 @@ import type { ParentInformation } from '../../r-bridge/lang-4.x/ast/model/proces
2
2
  import type { FlowrSearchElements } from '../../search/flowr-search';
3
3
  import { type MergeableRecord } from '../../util/objects';
4
4
  import { type SourceRange } from '../../util/range';
5
- import { type LintingResult, LintingRuleCertainty } from '../linter-format';
5
+ import { LintingRuleCertainty, type LintingResult } from '../linter-format';
6
6
  import { LintingRuleTag } from '../linter-tags';
7
7
  export interface DataFrameAccessValidationResult extends LintingResult {
8
8
  /** The type of the data frame access ("column" or "row") */
@@ -47,7 +47,7 @@ export declare const DATA_FRAME_ACCESS_VALIDATION: {
47
47
  readonly name: "Dataframe Access Validation";
48
48
  readonly tags: readonly [LintingRuleTag.Bug, LintingRuleTag.Usability, LintingRuleTag.Reproducibility];
49
49
  readonly certainty: LintingRuleCertainty.BestEffort;
50
- readonly description: "Validates the existance of accessed columns and rows of dataframes.";
50
+ readonly description: "Validates the existence of accessed columns and rows of dataframes.";
51
51
  readonly defaultConfig: {
52
52
  readonly readLoadedData: false;
53
53
  };
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DATA_FRAME_ACCESS_VALIDATION = void 0;
4
- const absint_info_1 = require("../../abstract-interpretation/data-frame/absint-info");
5
4
  const shape_inference_1 = require("../../abstract-interpretation/data-frame/shape-inference");
6
5
  const satisfiable_domain_1 = require("../../abstract-interpretation/domains/satisfiable-domain");
7
6
  const config_1 = require("../../config");
@@ -28,14 +27,15 @@ exports.DATA_FRAME_ACCESS_VALIDATION = {
28
27
  })
29
28
  };
30
29
  const cfg = (0, extract_cfg_1.extractCfg)(data.normalize, ctx, data.dataflow.graph);
31
- (0, shape_inference_1.inferDataFrameShapes)(cfg, data.dataflow.graph, data.normalize, ctx);
32
- const accessOperations = getAccessOperations(elements);
30
+ const inference = new shape_inference_1.DataFrameShapeInferenceVisitor({ controlFlow: cfg, dfg: data.dataflow.graph, normalizedAst: data.normalize, ctx });
31
+ inference.start();
32
+ const accessOperations = getAccessOperations(elements, inference);
33
33
  const accesses = [];
34
34
  for (const [nodeId, operations] of accessOperations) {
35
35
  const access = { nodeId };
36
36
  for (const operation of operations) {
37
37
  access.operand ??= operation.operand;
38
- access.operandShape ??= (0, shape_inference_1.resolveIdToDataFrameShape)(operation.operand, data.dataflow.graph);
38
+ access.operandShape ??= inference.getAbstractValue(operation.operand);
39
39
  if (operation.operation === 'accessCols' && operation.columns !== undefined) {
40
40
  access.accessedCols ??= [];
41
41
  access.accessedCols.push(...operation.columns);
@@ -85,17 +85,15 @@ exports.DATA_FRAME_ACCESS_VALIDATION = {
85
85
  tags: [linter_tags_1.LintingRuleTag.Bug, linter_tags_1.LintingRuleTag.Usability, linter_tags_1.LintingRuleTag.Reproducibility],
86
86
  // this rule is unable to detect all cases of dataframe access, but sufficiently ensures returned results are valid
87
87
  certainty: linter_format_1.LintingRuleCertainty.BestEffort,
88
- description: 'Validates the existance of accessed columns and rows of dataframes.',
88
+ description: 'Validates the existence of accessed columns and rows of dataframes.',
89
89
  defaultConfig: { readLoadedData: false }
90
90
  }
91
91
  };
92
- function getAccessOperations(elements) {
92
+ function getAccessOperations(elements, inference) {
93
93
  return new Map(elements.getElements()
94
- .map(element => element.node)
95
- .filter(absint_info_1.hasDataFrameExpressionInfo)
96
- .map(node => [node.info.id, node.info.dataFrame.operations
97
- .filter(({ operation }) => operation === 'accessCols' || operation === 'accessRows')
98
- .map(({ operation, operand, type: _type, options: _options, ...args }) => ({ operation, operand, ...args }))
94
+ .map(element => [element.node.info.id, inference.getAbstractOperations(element.node.info.id)
95
+ ?.filter(({ operation }) => operation === 'accessCols' || operation === 'accessRows')
96
+ .map(({ operation, operand, type: _type, options: _options, ...args }) => ({ operation, operand, ...args })) ?? []
99
97
  ])
100
98
  .filter(([, operations]) => operations.length > 0));
101
99
  }
@@ -5,8 +5,8 @@ import type { FlowrSearchElement, FlowrSearchElements } from '../../search/flowr
5
5
  import type { NormalizedAst, ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
6
6
  import type { MergeableRecord } from '../../util/objects';
7
7
  import type { DataflowInformation } from '../../dataflow/info';
8
- import type { FlowrConfigOptions } from '../../config';
9
8
  import type { FunctionInfo } from '../../queries/catalog/dependencies-query/function-info/function-info';
9
+ import type { ReadonlyFlowrAnalysisProvider } from '../../project/flowr-analyzer';
10
10
  export interface FunctionsResult extends LintingResult {
11
11
  function: string;
12
12
  range: SourceRange;
@@ -41,6 +41,6 @@ export declare const functionFinderUtil: {
41
41
  requireArgumentValue(element: FlowrSearchElement<ParentInformation>, pool: readonly FunctionInfo[], data: {
42
42
  normalize: NormalizedAst;
43
43
  dataflow: DataflowInformation;
44
- config: FlowrConfigOptions;
44
+ analyzer: ReadonlyFlowrAnalysisProvider;
45
45
  }, requireValue: RegExp | string | undefined): boolean;
46
46
  };
@@ -65,7 +65,7 @@ exports.functionFinderUtil = {
65
65
  }
66
66
  const vert = data.dataflow.graph.getVertex(element.node.info.id);
67
67
  if ((0, vertex_1.isFunctionCallVertex)(vert)) {
68
- const args = (0, resolve_argument_1.getArgumentStringValue)(data.config.solver.variables, data.dataflow.graph, vert, info.argIdx, info.argName, info.resolveValue);
68
+ const args = (0, resolve_argument_1.getArgumentStringValue)(data.analyzer.flowrConfig.solver.variables, data.dataflow.graph, vert, info.argIdx, info.argName, info.resolveValue, data.analyzer.inspectContext());
69
69
  // we obtain all values, at least one of them has to trigger for the request
70
70
  const argValues = args ? args.values().flatMap(v => [...v]).filter(assert_1.isNotUndefined).toArray() : [];
71
71
  /* if there are no arguments we assume they may access the network, otherwise we check for the flag */
@@ -7,7 +7,7 @@ const linter_tags_1 = require("../linter-tags");
7
7
  const read_functions_1 = require("../../queries/catalog/dependencies-query/function-info/read-functions");
8
8
  exports.NETWORK_FUNCTIONS = {
9
9
  createSearch: (config) => function_finder_util_1.functionFinderUtil.createSearch(config.fns),
10
- processSearchResult: (e, c, d) => function_finder_util_1.functionFinderUtil.processSearchResult(e, c, d, es => es.filter(e => function_finder_util_1.functionFinderUtil.requireArgumentValue(e, read_functions_1.ReadFunctions, { config: d.analyzer.flowrConfig, dataflow: d.dataflow, normalize: d.normalize }, c.onlyTriggerWithArgument))),
10
+ processSearchResult: (e, c, d) => function_finder_util_1.functionFinderUtil.processSearchResult(e, c, d, es => es.filter(e => function_finder_util_1.functionFinderUtil.requireArgumentValue(e, read_functions_1.ReadFunctions, { analyzer: d.analyzer, dataflow: d.dataflow, normalize: d.normalize }, c.onlyTriggerWithArgument))),
11
11
  prettyPrint: function_finder_util_1.functionFinderUtil.prettyPrint('network operations'),
12
12
  info: {
13
13
  name: 'Network Functions',
@@ -31,7 +31,7 @@ export interface SeededRandomnessMeta extends MergeableRecord {
31
31
  }
32
32
  export declare const SEEDED_RANDOMNESS: {
33
33
  readonly createSearch: (config: SeededRandomnessConfig) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["with", "filter", "with"], import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, Promise<import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>>;
34
- readonly processSearchResult: (elements: import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>, config: SeededRandomnessConfig, { dataflow }: {
34
+ readonly processSearchResult: (elements: import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>, config: SeededRandomnessConfig, { dataflow, analyzer }: {
35
35
  normalize: import("../../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
36
36
  dataflow: import("../../dataflow/info").DataflowInformation;
37
37
  cfg: import("../../control-flow/control-flow-graph").ControlFlowInformation;
@@ -31,7 +31,7 @@ exports.SEEDED_RANDOMNESS = {
31
31
  { callName: config.randomnessProducers.filter(p => p.type === 'function').map(p => p.name) },
32
32
  { callName: getDefaultAssignments().flatMap(b => b.names), cascadeIf: () => cascade_action_1.CascadeAction.Continue }
33
33
  ]),
34
- processSearchResult: (elements, config, { dataflow }) => {
34
+ processSearchResult: (elements, config, { dataflow, analyzer }) => {
35
35
  const assignmentProducers = new Set(config.randomnessProducers.filter(p => p.type == 'assignment').map(p => p.name));
36
36
  const assignmentArgIndexes = new Map(getDefaultAssignments().flatMap(a => a.names.map(n => ([n, a.config?.swapSourceAndTarget ? 1 : 0]))));
37
37
  const metadata = {
@@ -63,7 +63,7 @@ exports.SEEDED_RANDOMNESS = {
63
63
  let otherBranch = false;
64
64
  // function calls are already taken care of through the LastCall enrichment itself
65
65
  for (const f of func ?? []) {
66
- if (isConstantArgument(dataflow.graph, f, 0)) {
66
+ if (isConstantArgument(dataflow.graph, f, 0, analyzer.inspectContext())) {
67
67
  const fCds = new Set(f.cds).difference(cds);
68
68
  if (fCds.size <= 0 || (0, info_1.happensInEveryBranchSet)(fCds)) {
69
69
  metadata.callsWithFunctionProducers++;
@@ -83,7 +83,7 @@ exports.SEEDED_RANDOMNESS = {
83
83
  const dest = (0, graph_1.getReferenceOfArgument)(a.args[argIdx]);
84
84
  if (dest !== undefined && assignmentProducers.has((0, node_id_1.recoverName)(dest, dataflow.graph.idMap))) {
85
85
  // we either have arg index 0 or 1 for the assignmentProducers destination, so we select the assignment value as 1-argIdx here
86
- if (isConstantArgument(dataflow.graph, a, 1 - argIdx)) {
86
+ if (isConstantArgument(dataflow.graph, a, 1 - argIdx, analyzer.inspectContext())) {
87
87
  const aCds = new Set(a.cds).difference(cds);
88
88
  if (aCds.size <= 0 || (0, info_1.happensInEveryBranchSet)(aCds)) {
89
89
  metadata.callsWithAssignmentProducers++;
@@ -132,9 +132,9 @@ exports.SEEDED_RANDOMNESS = {
132
132
  function getDefaultAssignments() {
133
133
  return default_builtin_config_1.DefaultBuiltinConfig.filter(b => b.type === 'function' && b.processor == 'builtin:assignment');
134
134
  }
135
- function isConstantArgument(graph, call, argIndex) {
135
+ function isConstantArgument(graph, call, argIndex, ctx) {
136
136
  const args = call.args.filter(arg => arg !== r_function_call_1.EmptyArgument && !arg.name).map(graph_1.getReferenceOfArgument);
137
- const values = (0, general_1.valueSetGuard)((0, alias_tracking_1.resolveIdToValue)(args[argIndex], { graph: graph, resolve: config_1.VariableResolve.Alias }));
137
+ const values = (0, general_1.valueSetGuard)((0, alias_tracking_1.resolveIdToValue)(args[argIndex], { graph: graph, resolve: config_1.VariableResolve.Alias, ctx }));
138
138
  return values?.elements.every(v => v.type === 'number' ||
139
139
  v.type === 'logical' ||
140
140
  v.type === 'string' ||
@@ -20,7 +20,7 @@ function getDefinitionArguments(def, dfg) {
20
20
  function buildQuickFix(variable, dfg, ast) {
21
21
  // first we check whether any of the 'Defined by' targets have any obligations - if so, we can not remove the definition
22
22
  // otherwise we can automatically remove the full definition!
23
- if (variable.info.role === "accessed" /* RoleInParent.Accessed */ || variable.info.role === "for-variable" /* RoleInParent.ForVariable */) {
23
+ if (variable.info.role === "accessed" /* RoleInParent.Accessed */ || variable.info.role === "for-var" /* RoleInParent.ForVariable */) {
24
24
  // this is an access or a for variable, we can not remove it currently
25
25
  return undefined;
26
26
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eagleoutice/flowr",
3
- "version": "2.6.3",
3
+ "version": "2.7.2",
4
4
  "description": "Static Dataflow Analyzer and Program Slicer for the R Programming Language",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "repository": {
@@ -28,7 +28,6 @@
28
28
  "capabilities-markdown": "ts-node src/documentation/doc-capabilities.ts",
29
29
  "wiki": "ts-node src/cli/wiki.ts",
30
30
  "wiki:watch": "ts-node-dev src/cli/wiki.ts -- --keep-alive",
31
- "wiki:linter": "ts-node src/documentation/wiki-linter.ts",
32
31
  "build": "tsc --project .",
33
32
  "build-dev": "npm run build && npm run build:copy-wasm",
34
33
  "build:bundle-flowr": "npm run build && esbuild --bundle dist/src/cli/flowr.js --platform=node --tree-shaking=true --bundle --minify --external:clipboardy --target=node22 --outfile=dist/src/cli/flowr.min.js && npm run build:copy-wasm",
@@ -4,6 +4,8 @@ import { type FlowrAnalyzerPlugin, PluginType } from '../plugins/flowr-analyzer-
4
4
  import type { fileProtocol, RParseRequestFromFile, RParseRequests } from '../../r-bridge/retriever';
5
5
  import type { FlowrConfigOptions } from '../../config';
6
6
  import type { FlowrFileProvider } from './flowr-file';
7
+ import type { ReadOnlyFlowrAnalyzerEnvironmentContext } from './flowr-analyzer-environment-context';
8
+ import { FlowrAnalyzerEnvironmentContext } from './flowr-analyzer-environment-context';
7
9
  /**
8
10
  * This is a read-only interface to the {@link FlowrAnalyzerContext}.
9
11
  * It prevents you from modifying the context, but allows you to inspect it (which is probably what you want when using the {@link FlowrAnalyzer}).
@@ -18,10 +20,18 @@ export interface ReadOnlyFlowrAnalyzerContext {
18
20
  * The dependencies context provides access to the identified dependencies and their versions.
19
21
  */
20
22
  readonly deps: ReadOnlyFlowrAnalyzerDependenciesContext;
23
+ /**
24
+ * The environment context provides access to the environment information used during analysis.
25
+ */
26
+ readonly env: ReadOnlyFlowrAnalyzerEnvironmentContext;
21
27
  /**
22
28
  * The configuration options used by the analyzer.
23
29
  */
24
30
  readonly config: FlowrConfigOptions;
31
+ /**
32
+ * Run all resolution steps that can be done before the main analysis run.
33
+ */
34
+ readonly resolvePreAnalysis: () => void;
25
35
  }
26
36
  /**
27
37
  * This summarizes the other context layers used by the {@link FlowrAnalyzer}.
@@ -38,6 +48,7 @@ export interface ReadOnlyFlowrAnalyzerContext {
38
48
  export declare class FlowrAnalyzerContext implements ReadOnlyFlowrAnalyzerContext {
39
49
  readonly files: FlowrAnalyzerFilesContext;
40
50
  readonly deps: FlowrAnalyzerDependenciesContext;
51
+ readonly env: FlowrAnalyzerEnvironmentContext;
41
52
  readonly config: FlowrConfigOptions;
42
53
  constructor(config: FlowrConfigOptions, plugins: ReadonlyMap<PluginType, readonly FlowrAnalyzerPlugin[]>);
43
54
  /** delegate request addition */
@@ -11,6 +11,7 @@ const arrays_1 = require("../../util/collections/arrays");
11
11
  const retriever_1 = require("../../r-bridge/retriever");
12
12
  const config_1 = require("../../config");
13
13
  const flowr_file_1 = require("./flowr-file");
14
+ const flowr_analyzer_environment_context_1 = require("./flowr-analyzer-environment-context");
14
15
  /**
15
16
  * This summarizes the other context layers used by the {@link FlowrAnalyzer}.
16
17
  * Have a look at the attributes and layers listed below (e.g., {@link files} and {@link deps})
@@ -26,12 +27,14 @@ const flowr_file_1 = require("./flowr-file");
26
27
  class FlowrAnalyzerContext {
27
28
  files;
28
29
  deps;
30
+ env;
29
31
  config;
30
32
  constructor(config, plugins) {
31
33
  this.config = config;
32
34
  const loadingOrder = new flowr_analyzer_loading_order_context_1.FlowrAnalyzerLoadingOrderContext(this, plugins.get(flowr_analyzer_plugin_1.PluginType.LoadingOrder));
33
35
  this.files = new flowr_analyzer_files_context_1.FlowrAnalyzerFilesContext(loadingOrder, (plugins.get(flowr_analyzer_plugin_1.PluginType.ProjectDiscovery) ?? []), (plugins.get(flowr_analyzer_plugin_1.PluginType.FileLoad) ?? []));
34
36
  this.deps = new flowr_analyzer_dependencies_context_1.FlowrAnalyzerDependenciesContext(this, (plugins.get(flowr_analyzer_plugin_1.PluginType.DependencyIdentification) ?? []));
37
+ this.env = new flowr_analyzer_environment_context_1.FlowrAnalyzerEnvironmentContext(this);
35
38
  }
36
39
  /** delegate request addition */
37
40
  addRequests(requests) {
@@ -0,0 +1,47 @@
1
+ import type { FlowrAnalyzerContext } from './flowr-analyzer-context';
2
+ import type { IEnvironment, REnvironmentInformation } from '../../dataflow/environments/environment';
3
+ import type { DeepReadonly } from 'ts-essentials';
4
+ import type { Fingerprint } from '../../slicing/static/fingerprint';
5
+ /**
6
+ * This is the read-only interface to the {@link FlowrAnalyzerEnvironmentContext},
7
+ * which provides access to the built-in environment used during analysis.
8
+ */
9
+ export interface ReadOnlyFlowrAnalyzerEnvironmentContext {
10
+ /**
11
+ * Get the built-in environment used during analysis.
12
+ */
13
+ get builtInEnvironment(): DeepReadonly<IEnvironment>;
14
+ /**
15
+ * Get the empty built-in environment used during analysis.
16
+ * The empty built-in environment only contains primitive definitions.
17
+ */
18
+ get emptyBuiltInEnvironment(): DeepReadonly<IEnvironment>;
19
+ /**
20
+ * Create a new {@link REnvironmentInformation|environment} with the configured built-in environment as base.
21
+ */
22
+ makeCleanEnv(): REnvironmentInformation;
23
+ /**
24
+ * Get the fingerprint of the clean environment with the configured built-in environment as base.
25
+ */
26
+ getCleanEnvFingerprint(): Fingerprint;
27
+ /**
28
+ * Create a new {@link REnvironmentInformation|environment} with an empty built-in environment as base.
29
+ */
30
+ makeCleanEnvWithEmptyBuiltIns(): REnvironmentInformation;
31
+ }
32
+ /**
33
+ * This context is responsible for providing the built-in environment.
34
+ * It creates the built-in environment based on the configuration provided in the {@link FlowrAnalyzerContext}.
35
+ */
36
+ export declare class FlowrAnalyzerEnvironmentContext implements ReadOnlyFlowrAnalyzerEnvironmentContext {
37
+ readonly name = "flowr-analyzer-environment-context";
38
+ private readonly builtInEnv;
39
+ private readonly emptyBuiltInEnv;
40
+ private builtInEnvFingerprint;
41
+ constructor(ctx: FlowrAnalyzerContext);
42
+ get builtInEnvironment(): DeepReadonly<IEnvironment>;
43
+ get emptyBuiltInEnvironment(): DeepReadonly<IEnvironment>;
44
+ makeCleanEnv(): REnvironmentInformation;
45
+ getCleanEnvFingerprint(): Fingerprint;
46
+ makeCleanEnvWithEmptyBuiltIns(): REnvironmentInformation;
47
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FlowrAnalyzerEnvironmentContext = void 0;
4
+ const environment_1 = require("../../dataflow/environments/environment");
5
+ const built_in_config_1 = require("../../dataflow/environments/built-in-config");
6
+ const fingerprint_1 = require("../../slicing/static/fingerprint");
7
+ /**
8
+ * This context is responsible for providing the built-in environment.
9
+ * It creates the built-in environment based on the configuration provided in the {@link FlowrAnalyzerContext}.
10
+ */
11
+ class FlowrAnalyzerEnvironmentContext {
12
+ name = 'flowr-analyzer-environment-context';
13
+ builtInEnv;
14
+ emptyBuiltInEnv;
15
+ builtInEnvFingerprint;
16
+ constructor(ctx) {
17
+ const builtInsConfig = ctx.config.semantics.environment.overwriteBuiltIns;
18
+ const builtIns = (0, built_in_config_1.getBuiltInDefinitions)(builtInsConfig.definitions, builtInsConfig.loadDefaults);
19
+ this.builtInEnv = new environment_1.Environment(undefined, true);
20
+ this.builtInEnv.memory = builtIns.builtInMemory;
21
+ this.emptyBuiltInEnv = new environment_1.Environment(undefined, true);
22
+ this.emptyBuiltInEnv.memory = builtIns.emptyBuiltInMemory;
23
+ }
24
+ get builtInEnvironment() {
25
+ return this.builtInEnv;
26
+ }
27
+ get emptyBuiltInEnvironment() {
28
+ return this.emptyBuiltInEnv;
29
+ }
30
+ makeCleanEnv() {
31
+ return {
32
+ current: new environment_1.Environment(this.builtInEnv),
33
+ level: 0
34
+ };
35
+ }
36
+ getCleanEnvFingerprint() {
37
+ if (!this.builtInEnvFingerprint) {
38
+ this.builtInEnvFingerprint = (0, fingerprint_1.envFingerprint)(this.makeCleanEnv());
39
+ }
40
+ return this.builtInEnvFingerprint;
41
+ }
42
+ makeCleanEnvWithEmptyBuiltIns() {
43
+ return {
44
+ current: new environment_1.Environment(this.emptyBuiltInEnv),
45
+ level: 0
46
+ };
47
+ }
48
+ }
49
+ exports.FlowrAnalyzerEnvironmentContext = FlowrAnalyzerEnvironmentContext;
50
+ //# sourceMappingURL=flowr-analyzer-environment-context.js.map
@@ -4,7 +4,8 @@ import type { FlowrAnalyzerLoadingOrderContext, ReadOnlyFlowrAnalyzerLoadingOrde
4
4
  import { FlowrAnalyzerProjectDiscoveryPlugin } from '../plugins/project-discovery/flowr-analyzer-project-discovery-plugin';
5
5
  import { FlowrAnalyzerFilePlugin } from '../plugins/file-plugins/flowr-analyzer-file-plugin';
6
6
  import { FlowrFile, type FlowrFileProvider, FileRole } from './flowr-file';
7
- import type { FlowrDescriptionFile } from '../plugins/file-plugins/flowr-description-file';
7
+ import type { FlowrDescriptionFile } from '../plugins/file-plugins/files/flowr-description-file';
8
+ import type { FlowrNewsFile } from '../plugins/file-plugins/files/flowr-news-file';
8
9
  /**
9
10
  * This is a request to process a folder as a project, which will be expanded by the registered {@link FlowrAnalyzerProjectDiscoveryPlugin}s.
10
11
  */
@@ -18,6 +19,7 @@ export interface RProjectAnalysisRequest {
18
19
  export type RAnalysisRequest = RParseRequest | RProjectAnalysisRequest;
19
20
  export type RoleBasedFiles = {
20
21
  [FileRole.Description]: FlowrDescriptionFile[];
22
+ [FileRole.News]: FlowrNewsFile[];
21
23
  [FileRole.Namespace]: FlowrFileProvider[];
22
24
  [FileRole.Source]: FlowrFileProvider[];
23
25
  [FileRole.Data]: FlowrFileProvider[];
@@ -45,6 +47,11 @@ export interface ReadOnlyFlowrAnalyzerFilesContext {
45
47
  * ```
46
48
  */
47
49
  getFilesByRole<Role extends FileRole>(role: Role): RoleBasedFiles[Role];
50
+ /**
51
+ * Get all files known to this context.
52
+ * @returns An array of all files.
53
+ */
54
+ getAllFiles(): FlowrFileProvider[];
48
55
  /**
49
56
  * Check if the context has a file with the given path.
50
57
  * Please note, that this may also check the file system, depending on the configuration
@@ -132,4 +139,5 @@ export declare class FlowrAnalyzerFilesContext extends AbstractFlowrAnalyzerCont
132
139
  */
133
140
  computeLoadingOrder(): readonly RParseRequest[];
134
141
  getFilesByRole<Role extends FileRole>(role: Role): RoleBasedFiles[Role];
142
+ getAllFiles(): FlowrFileProvider[];
135
143
  }
@@ -42,6 +42,7 @@ class FlowrAnalyzerFilesContext extends abstract_flowr_analyzer_context_1.Abstra
42
42
  /* files that are part of the analysis, e.g. source files */
43
43
  byRole = {
44
44
  [flowr_file_1.FileRole.Description]: [],
45
+ [flowr_file_1.FileRole.News]: [],
45
46
  [flowr_file_1.FileRole.Namespace]: [],
46
47
  [flowr_file_1.FileRole.Source]: [],
47
48
  [flowr_file_1.FileRole.Data]: [],
@@ -200,6 +201,9 @@ class FlowrAnalyzerFilesContext extends abstract_flowr_analyzer_context_1.Abstra
200
201
  getFilesByRole(role) {
201
202
  return this.byRole[role];
202
203
  }
204
+ getAllFiles() {
205
+ return [...this.files.values(), ...this.inlineFiles];
206
+ }
203
207
  }
204
208
  exports.FlowrAnalyzerFilesContext = FlowrAnalyzerFilesContext;
205
209
  //# sourceMappingURL=flowr-analyzer-files-context.js.map
@@ -15,6 +15,8 @@ export declare enum FileRole {
15
15
  Description = "description",
16
16
  /** The `NAMESPACE` file in R packages, currently not specially supported. */
17
17
  Namespace = "namespace",
18
+ /** The `NEWS` file in R packages */
19
+ News = "news",
18
20
  /** Data files, e.g., `R/sysdata.rda`, currently not specially supported. */
19
21
  Data = "data",
20
22
  /**
@@ -17,6 +17,8 @@ var FileRole;
17
17
  FileRole["Description"] = "description";
18
18
  /** The `NAMESPACE` file in R packages, currently not specially supported. */
19
19
  FileRole["Namespace"] = "namespace";
20
+ /** The `NEWS` file in R packages */
21
+ FileRole["News"] = "news";
20
22
  /** Data files, e.g., `R/sysdata.rda`, currently not specially supported. */
21
23
  FileRole["Data"] = "data";
22
24
  /**
@@ -1,4 +1,4 @@
1
- import { type FlowrFileProvider, type FileRole, FlowrFile } from '../../context/flowr-file';
1
+ import { type FlowrFileProvider, type FileRole, FlowrFile } from '../../../context/flowr-file';
2
2
  export type DCF = Map<string, string[]>;
3
3
  /**
4
4
  * This decorates a text file and provides access to its content as a DCF (Debian Control File)-like structure.
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FlowrDescriptionFile = void 0;
4
+ const flowr_file_1 = require("../../../context/flowr-file");
5
+ /**
6
+ * This decorates a text file and provides access to its content as a DCF (Debian Control File)-like structure.
7
+ */
8
+ class FlowrDescriptionFile extends flowr_file_1.FlowrFile {
9
+ wrapped;
10
+ /**
11
+ * Prefer the static {@link FlowrDescriptionFile.from} method to create instances of this class as it will not re-create if already a description file
12
+ * and handle role assignments.
13
+ */
14
+ constructor(file) {
15
+ super(file.path(), file.role);
16
+ this.wrapped = file;
17
+ }
18
+ /**
19
+ * Loads and parses the content of the wrapped file as a DCF structure.
20
+ * @see {@link parseDCF} for details on the parsing logic.
21
+ */
22
+ loadContent() {
23
+ return parseDCF(this.wrapped);
24
+ }
25
+ /**
26
+ * Description file lifter, this does not re-create if already a description file
27
+ */
28
+ static from(file, role) {
29
+ if (role) {
30
+ file.assignRole(role);
31
+ }
32
+ return file instanceof FlowrDescriptionFile ? file : new FlowrDescriptionFile(file);
33
+ }
34
+ }
35
+ exports.FlowrDescriptionFile = FlowrDescriptionFile;
36
+ /**
37
+ * Parses the given file in the 'Debian Control Format'.
38
+ * @param file - The file to parse
39
+ */
40
+ function parseDCF(file) {
41
+ const result = new Map();
42
+ let currentKey = '';
43
+ let currentValue = '';
44
+ const indentRegex = new RegExp(/^\s/);
45
+ const firstColonRegex = new RegExp(/:(.*)/s);
46
+ const fileContent = file.content().toString().split(/\r?\n/);
47
+ for (const line of fileContent) {
48
+ if (indentRegex.test(line)) {
49
+ currentValue += '\n' + line.trim();
50
+ }
51
+ else {
52
+ if (currentKey) {
53
+ const values = currentValue ? cleanValues(currentValue) : [];
54
+ result.set(currentKey, values);
55
+ }
56
+ const [key, rest] = line.split(firstColonRegex).map(s => s.trim());
57
+ currentKey = key?.trim() ?? '';
58
+ currentValue = rest?.trim() ?? '';
59
+ }
60
+ }
61
+ if (currentKey) {
62
+ const values = currentValue ? cleanValues(currentValue) : [];
63
+ result.set(currentKey, values);
64
+ }
65
+ return result;
66
+ }
67
+ const cleanSplitRegex = /[\n,]+/;
68
+ const cleanQuotesRegex = /'/g;
69
+ function cleanValues(values) {
70
+ return values
71
+ .split(cleanSplitRegex)
72
+ .map(s => s.trim().replace(cleanQuotesRegex, ''))
73
+ .filter(s => s.length > 0);
74
+ }
75
+ //# sourceMappingURL=flowr-description-file.js.map
@@ -0,0 +1,27 @@
1
+ import { type FlowrFileProvider, type FileRole, FlowrFile } from '../../../context/flowr-file';
2
+ export interface NewsChunk {
3
+ header?: string;
4
+ version?: string;
5
+ date?: string;
6
+ entries: string[] | NewsChunk[];
7
+ }
8
+ /**
9
+ * This decorates a text file and provides access to its content following R's NEWS file structure.
10
+ */
11
+ export declare class FlowrNewsFile extends FlowrFile<NewsChunk[]> {
12
+ private readonly wrapped;
13
+ /**
14
+ * Prefer the static {@link FlowrNewsFile.from} method to create instances of this class as it will not re-create if already a news file
15
+ * and handle role assignments.
16
+ */
17
+ constructor(file: FlowrFileProvider);
18
+ /**
19
+ * Loads and parses the content of the wrapped file as news chunks.
20
+ * @see {@link parseNews} for details on the parsing logic.
21
+ */
22
+ protected loadContent(): NewsChunk[];
23
+ /**
24
+ * News file lifter, this does not re-create if already a news file
25
+ */
26
+ static from(file: FlowrFileProvider | FlowrNewsFile, role?: FileRole): FlowrNewsFile;
27
+ }