@eagleoutice/flowr 2.8.14 → 2.9.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 (187) hide show
  1. package/README.md +25 -26
  2. package/abstract-interpretation/data-frame/mappers/access-mapper.d.ts +4 -3
  3. package/abstract-interpretation/data-frame/mappers/access-mapper.js +4 -3
  4. package/abstract-interpretation/data-frame/mappers/arguments.d.ts +2 -1
  5. package/abstract-interpretation/data-frame/mappers/arguments.js +2 -1
  6. package/abstract-interpretation/data-frame/mappers/function-mapper.d.ts +4 -3
  7. package/abstract-interpretation/data-frame/mappers/function-mapper.js +13 -10
  8. package/abstract-interpretation/data-frame/mappers/replacement-mapper.js +7 -6
  9. package/abstract-interpretation/data-frame/resolve-args.js +2 -1
  10. package/benchmark/slicer.d.ts +0 -16
  11. package/benchmark/slicer.js +0 -47
  12. package/benchmark/stats/print.js +0 -6
  13. package/benchmark/stats/stats.d.ts +0 -3
  14. package/benchmark/summarizer/second-phase/process.js +0 -6
  15. package/cli/benchmark-app.d.ts +0 -1
  16. package/cli/benchmark-app.js +0 -1
  17. package/cli/benchmark-helper-app.d.ts +0 -1
  18. package/cli/benchmark-helper-app.js +1 -5
  19. package/cli/common/options.d.ts +0 -10
  20. package/cli/common/options.js +0 -2
  21. package/cli/common/scripts-info.d.ts +0 -10
  22. package/cli/repl/server/connection.js +1 -1
  23. package/config.d.ts +0 -15
  24. package/config.js +0 -21
  25. package/control-flow/cfg-dead-code.js +0 -3
  26. package/control-flow/extract-cfg.js +5 -1
  27. package/control-flow/semantic-cfg-guided-visitor.d.ts +7 -0
  28. package/control-flow/semantic-cfg-guided-visitor.js +11 -4
  29. package/dataflow/cluster.js +2 -2
  30. package/dataflow/environments/built-in-config.d.ts +1 -0
  31. package/dataflow/environments/built-in.d.ts +9 -3
  32. package/dataflow/environments/built-in.js +15 -7
  33. package/dataflow/environments/default-builtin-config.d.ts +10 -1
  34. package/dataflow/environments/default-builtin-config.js +6 -4
  35. package/dataflow/environments/define.d.ts +4 -11
  36. package/dataflow/environments/define.js +16 -96
  37. package/dataflow/environments/diff.js +3 -2
  38. package/dataflow/environments/environment.d.ts +17 -6
  39. package/dataflow/environments/environment.js +69 -18
  40. package/dataflow/environments/identifier.d.ts +92 -6
  41. package/dataflow/environments/identifier.js +159 -1
  42. package/dataflow/environments/reference-to-maybe.js +1 -1
  43. package/dataflow/environments/resolve-by-name.d.ts +4 -4
  44. package/dataflow/environments/resolve-by-name.js +24 -8
  45. package/dataflow/eval/resolve/resolve.d.ts +10 -6
  46. package/dataflow/eval/resolve/resolve.js +12 -7
  47. package/dataflow/extractor.js +6 -3
  48. package/dataflow/fn/exceptions-of-function.d.ts +3 -1
  49. package/dataflow/fn/exceptions-of-function.js +23 -6
  50. package/dataflow/fn/higher-order-function.js +7 -7
  51. package/dataflow/graph/call-graph.d.ts +13 -0
  52. package/dataflow/graph/call-graph.js +46 -20
  53. package/dataflow/graph/diff-dataflow-graph.js +6 -4
  54. package/dataflow/graph/edge.d.ts +48 -31
  55. package/dataflow/graph/edge.js +66 -60
  56. package/dataflow/graph/graph.d.ts +18 -9
  57. package/dataflow/graph/graph.js +29 -13
  58. package/dataflow/graph/quads.js +1 -1
  59. package/dataflow/graph/resolve-graph.js +1 -1
  60. package/dataflow/graph/unknown-replacement.d.ts +2 -1
  61. package/dataflow/graph/vertex.d.ts +2 -103
  62. package/dataflow/graph/vertex.js +0 -44
  63. package/dataflow/internal/linker.d.ts +2 -2
  64. package/dataflow/internal/linker.js +27 -19
  65. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +3 -65
  66. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +4 -6
  67. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +13 -47
  68. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +2 -1
  69. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +5 -5
  70. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +2 -2
  71. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +8 -5
  72. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +4 -4
  73. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +2 -2
  74. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +6 -2
  75. package/dataflow/internal/process/functions/call/built-in/built-in-list.js +1 -69
  76. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +2 -2
  77. package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +1 -1
  78. package/dataflow/internal/process/functions/call/built-in/built-in-recall.d.ts +11 -0
  79. package/dataflow/internal/process/functions/call/built-in/built-in-recall.js +46 -0
  80. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +3 -2
  81. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.d.ts +0 -2
  82. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +11 -72
  83. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +1 -2
  84. package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.js +2 -1
  85. package/dataflow/internal/process/functions/call/built-in/built-in-stop-if-not.js +4 -3
  86. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +3 -2
  87. package/dataflow/internal/process/functions/call/built-in/built-in-vector.js +1 -60
  88. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +3 -3
  89. package/dataflow/internal/process/functions/call/common.d.ts +3 -1
  90. package/dataflow/internal/process/functions/call/common.js +4 -16
  91. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +6 -2
  92. package/dataflow/internal/process/functions/call/known-call-handling.js +2 -3
  93. package/dataflow/internal/process/functions/call/unnamed-call-handling.d.ts +1 -1
  94. package/dataflow/internal/process/functions/call/unnamed-call-handling.js +1 -1
  95. package/dataflow/internal/process/functions/process-parameter.js +1 -1
  96. package/dataflow/internal/process/process-named-call.d.ts +2 -1
  97. package/dataflow/internal/process/process-named-call.js +0 -1
  98. package/dataflow/internal/process/process-symbol.d.ts +3 -1
  99. package/dataflow/internal/process/process-symbol.js +8 -5
  100. package/dataflow/origin/dfg-get-origin.d.ts +2 -2
  101. package/dataflow/origin/dfg-get-origin.js +4 -4
  102. package/dataflow/origin/dfg-get-symbol-refs.js +2 -2
  103. package/documentation/data/interface/doc-writing-code.d.ts +6 -0
  104. package/documentation/data/interface/doc-writing-code.js +176 -0
  105. package/documentation/doc-util/doc-types.d.ts +3 -1
  106. package/documentation/doc-util/doc-types.js +4 -2
  107. package/documentation/wiki-absint.js +2 -1
  108. package/documentation/wiki-analyzer.js +17 -2
  109. package/documentation/wiki-cfg.js +2 -2
  110. package/documentation/wiki-dataflow-graph.js +9 -8
  111. package/documentation/wiki-interface.js +8 -164
  112. package/documentation/wiki-mk/doc-context.d.ts +12 -1
  113. package/documentation/wiki-mk/doc-context.js +21 -4
  114. package/documentation/wiki-normalized-ast.js +5 -0
  115. package/linter/linter-rules.d.ts +6 -6
  116. package/linter/rules/absolute-path.js +23 -23
  117. package/linter/rules/dataframe-access-validation.js +2 -1
  118. package/linter/rules/deprecated-functions.d.ts +2 -2
  119. package/linter/rules/deprecated-functions.js +1 -1
  120. package/linter/rules/function-finder-util.d.ts +3 -3
  121. package/linter/rules/function-finder-util.js +1 -1
  122. package/linter/rules/network-functions.d.ts +2 -2
  123. package/linter/rules/seeded-randomness.d.ts +3 -3
  124. package/linter/rules/seeded-randomness.js +7 -5
  125. package/linter/rules/unused-definition.js +4 -4
  126. package/package.json +5 -5
  127. package/project/context/flowr-analyzer-context.d.ts +17 -1
  128. package/project/context/flowr-analyzer-context.js +17 -1
  129. package/project/context/flowr-analyzer-meta-context.d.ts +51 -0
  130. package/project/context/flowr-analyzer-meta-context.js +47 -0
  131. package/project/flowr-analyzer.d.ts +17 -1
  132. package/project/flowr-analyzer.js +18 -0
  133. package/project/plugins/file-plugins/files/flowr-description-file.d.ts +15 -0
  134. package/project/plugins/file-plugins/files/flowr-description-file.js +26 -0
  135. package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +17 -3
  136. package/project/plugins/file-plugins/files/flowr-namespace-file.js +292 -10
  137. package/project/plugins/file-plugins/flowr-analyzer-namespace-files-plugin.d.ts +1 -1
  138. package/project/plugins/file-plugins/flowr-analyzer-namespace-files-plugin.js +2 -2
  139. package/project/plugins/flowr-analyzer-plugin-defaults.js +2 -0
  140. package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-description-file-plugin.js +1 -1
  141. package/project/plugins/package-version-plugins/flowr-analyzer-meta-description-file-plugin.d.ts +12 -0
  142. package/project/plugins/package-version-plugins/flowr-analyzer-meta-description-file-plugin.js +42 -0
  143. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.d.ts +1 -1
  144. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.js +2 -2
  145. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-namespace-file-plugin.d.ts +1 -1
  146. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-namespace-file-plugin.js +2 -2
  147. package/project/plugins/plugin-registry.d.ts +2 -1
  148. package/project/plugins/plugin-registry.js +2 -0
  149. package/queries/catalog/call-context-query/call-context-query-executor.js +6 -4
  150. package/queries/catalog/call-context-query/call-context-query-format.d.ts +2 -1
  151. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +4 -4
  152. package/queries/catalog/dependencies-query/dependencies-query-format.js +5 -3
  153. package/queries/catalog/does-call-query/does-call-query-executor.js +2 -1
  154. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.d.ts +1 -1
  155. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.js +14 -4
  156. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +1 -1
  157. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.js +1 -1
  158. package/r-bridge/data/data.d.ts +8 -3
  159. package/r-bridge/data/data.js +9 -3
  160. package/r-bridge/lang-4.x/ast/model/model.d.ts +0 -11
  161. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +2 -1
  162. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +2 -1
  163. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +7 -3
  164. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +2 -1
  165. package/r-bridge/lang-4.x/ast/model/processing/stateful-fold.js +1 -1
  166. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-argument.js +0 -1
  167. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.js +0 -1
  168. package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-binary.js +0 -1
  169. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-number.js +0 -1
  170. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-symbol.d.ts +1 -2
  171. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-symbol.js +12 -13
  172. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +4 -11
  173. package/reconstruct/reconstruct.js +6 -5
  174. package/search/flowr-search-filters.d.ts +1 -1
  175. package/search/flowr-search-filters.js +37 -6
  176. package/search/search-executor/search-enrichers.d.ts +1 -2
  177. package/search/search-executor/search-enrichers.js +9 -7
  178. package/slicing/static/slice-call.js +5 -5
  179. package/slicing/static/static-slicer.js +2 -2
  180. package/statistics/features/common-syntax-probability.js +3 -2
  181. package/statistics/features/supported/defined-functions/defined-functions.js +3 -3
  182. package/statistics/features/supported/used-functions/used-functions.js +3 -2
  183. package/util/mermaid/dfg.js +3 -3
  184. package/util/simple-df/dfg-ascii.js +5 -5
  185. package/util/version.js +1 -1
  186. package/util/containers.d.ts +0 -66
  187. package/util/containers.js +0 -143
@@ -5,6 +5,7 @@ const linter_format_1 = require("../linter-format");
5
5
  const flowr_search_builder_1 = require("../../search/flowr-search-builder");
6
6
  const dfg_1 = require("../../util/mermaid/dfg");
7
7
  const search_enrichers_1 = require("../../search/search-executor/search-enrichers");
8
+ const identifier_1 = require("../../dataflow/environments/identifier");
8
9
  const flowr_search_filters_1 = require("../../search/flowr-search-filters");
9
10
  const default_builtin_config_1 = require("../../dataflow/environments/default-builtin-config");
10
11
  const graph_1 = require("../../dataflow/graph/graph");
@@ -14,12 +15,13 @@ const linter_tags_1 = require("../linter-tags");
14
15
  const alias_tracking_1 = require("../../dataflow/eval/resolve/alias-tracking");
15
16
  const general_1 = require("../../dataflow/eval/values/general");
16
17
  const config_1 = require("../../config");
18
+ const vertex_1 = require("../../dataflow/graph/vertex");
17
19
  const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
18
20
  const r_value_1 = require("../../dataflow/eval/values/r-value");
19
21
  const info_1 = require("../../dataflow/info");
20
22
  const built_in_1 = require("../../dataflow/environments/built-in");
21
23
  exports.SEEDED_RANDOMNESS = {
22
- createSearch: (config) => flowr_search_builder_1.Q.all()
24
+ createSearch: (config) => flowr_search_builder_1.Q.all().filter(vertex_1.VertexType.FunctionCall)
23
25
  .with(search_enrichers_1.Enrichment.CallTargets, { onlyBuiltin: true })
24
26
  .filter({
25
27
  name: flowr_search_filters_1.FlowrFilter.MatchesEnrichment,
@@ -30,11 +32,11 @@ exports.SEEDED_RANDOMNESS = {
30
32
  })
31
33
  .with(search_enrichers_1.Enrichment.LastCall, [
32
34
  { callName: config.randomnessProducers.filter(p => p.type === 'function').map(p => p.name) },
33
- { callName: getDefaultAssignments().flatMap(b => b.names), cascadeIf: () => cascade_action_1.CascadeAction.Continue }
35
+ { callName: getDefaultAssignments().flatMap(b => b.names).map(identifier_1.Identifier.getName), cascadeIf: () => cascade_action_1.CascadeAction.Continue }
34
36
  ]),
35
37
  processSearchResult: (elements, config, { dataflow, analyzer }) => {
36
38
  const assignmentProducers = new Set(config.randomnessProducers.filter(p => p.type == 'assignment').map(p => p.name));
37
- const assignmentArgIndexes = new Map(getDefaultAssignments().flatMap(a => a.names.map(n => ([n, a.config?.swapSourceAndTarget ? 1 : 0]))));
39
+ const assignmentArgIndexes = new Map(getDefaultAssignments().flatMap(a => a.names.map(n => ([identifier_1.Identifier.getName(n), a.config?.swapSourceAndTarget ? 1 : 0]))));
38
40
  const metadata = {
39
41
  consumerCalls: 0,
40
42
  callsWithFunctionProducers: 0,
@@ -60,7 +62,7 @@ exports.SEEDED_RANDOMNESS = {
60
62
  const cds = dfgElement ? new Set(dfgElement.cds) : new Set();
61
63
  const producers = (0, search_enrichers_1.enrichmentContent)(element.searchElement, search_enrichers_1.Enrichment.LastCall).linkedIds
62
64
  .map(e => dataflow.graph.getVertex(e.node.info.id));
63
- const { assignment, func } = Object.groupBy(producers, f => assignmentArgIndexes.has(f.name) ? 'assignment' : 'func');
65
+ const { assignment, func } = Object.groupBy(producers, f => assignmentArgIndexes.has(identifier_1.Identifier.getName(f.name)) ? 'assignment' : 'func');
64
66
  let nonConstant = false;
65
67
  const cdsOfProduces = new Set();
66
68
  // function calls are already taken care of through the LastCall enrichment itself
@@ -83,7 +85,7 @@ exports.SEEDED_RANDOMNESS = {
83
85
  }
84
86
  // assignments have to be queried for their destination
85
87
  for (const a of assignment ?? []) {
86
- const argIdx = assignmentArgIndexes.get(a.name);
88
+ const argIdx = assignmentArgIndexes.get(identifier_1.Identifier.getName(a.name));
87
89
  const dest = (0, graph_1.getReferenceOfArgument)(a.args[argIdx]);
88
90
  if (dest !== undefined && assignmentProducers.has((0, node_id_1.recoverName)(dest, dataflow.graph.idMap))) {
89
91
  // we either have arg index 0 or 1 for the assignmentProducers destination, so we select the assignment value as 1-argIdx here
@@ -14,7 +14,7 @@ const InterestingEdgesVariable = edge_1.EdgeType.Reads | edge_1.EdgeType.Calls |
14
14
  const InterestingEdgesFunction = edge_1.EdgeType.Reads | edge_1.EdgeType.Calls; // include read as this could print the function definition
15
15
  const InterestingEdgesTargets = edge_1.EdgeType.SideEffectOnCall;
16
16
  function getDefinitionArguments(def, dfg) {
17
- return [...dfg.outgoingEdges(def) ?? []].filter(([, { types }]) => (0, edge_1.edgeIncludesType)(types, edge_1.EdgeType.DefinedBy))
17
+ return [...dfg.outgoingEdges(def) ?? []].filter(([, e]) => edge_1.DfEdge.includesType(e, edge_1.EdgeType.DefinedBy))
18
18
  .map(([target]) => target);
19
19
  }
20
20
  function buildQuickFix(variable, dfg, ast) {
@@ -27,8 +27,8 @@ function buildQuickFix(variable, dfg, ast) {
27
27
  const definedBys = getDefinitionArguments(variable.info.id, dfg);
28
28
  const hasImportantArgs = definedBys.some(d => dfg.unknownSideEffects.has(d))
29
29
  || definedBys.flatMap(e => [...dfg.outgoingEdges(e) ?? []])
30
- .some(([target, { types }]) => {
31
- return (0, edge_1.edgeIncludesType)(types, InterestingEdgesTargets) || dfg.unknownSideEffects.has(target);
30
+ .some(([target, e]) => {
31
+ return edge_1.DfEdge.includesType(e, InterestingEdgesTargets) || dfg.unknownSideEffects.has(target);
32
32
  });
33
33
  if (hasImportantArgs) {
34
34
  return undefined; // we can not remove this definition, it has important arguments
@@ -74,7 +74,7 @@ exports.UNUSED_DEFINITION = {
74
74
  }
75
75
  const ingoingEdges = data.dataflow.graph.ingoingEdges(dfgVertex.id);
76
76
  const interestedIn = (0, vertex_1.isVariableDefinitionVertex)(dfgVertex) ? InterestingEdgesVariable : InterestingEdgesFunction;
77
- const ingoingInteresting = ingoingEdges?.values().some(e => (0, edge_1.edgeIncludesType)(e.types, interestedIn));
77
+ const ingoingInteresting = ingoingEdges?.values().some(e => edge_1.DfEdge.includesType(e, interestedIn));
78
78
  if (ingoingInteresting) {
79
79
  return undefined;
80
80
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eagleoutice/flowr",
3
- "version": "2.8.14",
3
+ "version": "2.9.0",
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": {
@@ -166,9 +166,9 @@
166
166
  "devDependencies": {
167
167
  "@commitlint/cli": "^19.7.1",
168
168
  "@commitlint/config-angular": "^19.7.1",
169
- "@eagleoutice/eslint-config-flowr": "^1.0.27",
170
- "@eslint/eslintrc": "^3.3.1",
171
- "@eslint/js": "^9.34.0",
169
+ "@eagleoutice/eslint-config-flowr": "^1.0.36",
170
+ "@eslint/eslintrc": "^3.3.3",
171
+ "@eslint/js": "^9.39.2",
172
172
  "@j-ulrich/release-it-regex-bumper": "^5.3.0",
173
173
  "@types/command-line-args": "^5.2.3",
174
174
  "@types/command-line-usage": "^5.0.4",
@@ -184,7 +184,7 @@
184
184
  "@typescript-eslint/eslint-plugin": "^8.40.0",
185
185
  "@vitest/coverage-v8": "^3.2.4",
186
186
  "esbuild": "^0.27.2",
187
- "eslint": "^9.34.0",
187
+ "eslint": "^9.39.2",
188
188
  "license-checker-rseidelsohn": "^4.4.2",
189
189
  "npm-run-all": "^4.1.5",
190
190
  "release-it": "^19.2.3",
@@ -6,12 +6,19 @@ import type { FlowrConfigOptions } from '../../config';
6
6
  import type { FlowrFileProvider } from './flowr-file';
7
7
  import type { ReadOnlyFlowrAnalyzerEnvironmentContext } from './flowr-analyzer-environment-context';
8
8
  import { FlowrAnalyzerEnvironmentContext } from './flowr-analyzer-environment-context';
9
+ import type { ReadOnlyFlowrAnalyzerMetaContext } from './flowr-analyzer-meta-context';
10
+ import { FlowrAnalyzerMetaContext } from './flowr-analyzer-meta-context';
11
+ import type { FlowrAnalyzer } from '../flowr-analyzer';
9
12
  /**
10
13
  * This is a read-only interface to the {@link FlowrAnalyzerContext}.
11
14
  * It prevents you from modifying the context, but allows you to inspect it (which is probably what you want when using the {@link FlowrAnalyzer}).
12
15
  * If you are a {@link FlowrAnalyzerPlugin} and want to modify the context, you can use the {@link FlowrAnalyzerContext} directly.
13
16
  */
14
17
  export interface ReadOnlyFlowrAnalyzerContext {
18
+ /**
19
+ * The meta context provides access to the project metadata such as name, version, and namespace.
20
+ */
21
+ readonly meta: ReadOnlyFlowrAnalyzerMetaContext;
15
22
  /**
16
23
  * The files context provides access to the files to be analyzed and their loading order.
17
24
  */
@@ -46,11 +53,20 @@ export interface ReadOnlyFlowrAnalyzerContext {
46
53
  * If you are just interested in inspecting the context, you can use {@link ReadOnlyFlowrAnalyzerContext} instead (e.g., via {@link inspect}).
47
54
  */
48
55
  export declare class FlowrAnalyzerContext implements ReadOnlyFlowrAnalyzerContext {
56
+ readonly meta: FlowrAnalyzerMetaContext;
49
57
  readonly files: FlowrAnalyzerFilesContext;
50
58
  readonly deps: FlowrAnalyzerDependenciesContext;
51
59
  readonly env: FlowrAnalyzerEnvironmentContext;
60
+ private _analyzer;
52
61
  readonly config: FlowrConfigOptions;
53
62
  constructor(config: FlowrConfigOptions, plugins: ReadonlyMap<PluginType, readonly FlowrAnalyzerPlugin[]>);
63
+ /**
64
+ * Provides the analyzer associated with this context, if any.
65
+ * This is usually set when the context is used within an analyzer instance.
66
+ * Please note, that this may be `undefined` if the context is used standalone (e.g., during setup or in plugins that do not have access to the analyzer).
67
+ */
68
+ get analyzer(): FlowrAnalyzer | undefined;
69
+ setAnalyzer(analyzer: FlowrAnalyzer): void;
54
70
  /** delegate request addition */
55
71
  addRequests(requests: readonly RAnalysisRequest[]): void;
56
72
  addFile(f: string | FlowrFileProvider | RParseRequestFromFile): void;
@@ -64,7 +80,7 @@ export declare class FlowrAnalyzerContext implements ReadOnlyFlowrAnalyzerContex
64
80
  */
65
81
  inspect(): ReadOnlyFlowrAnalyzerContext;
66
82
  /**
67
- * Reset the context to its initial state, removing all files, dependencies, and loading orders.
83
+ * Reset the context to its initial state, e.g., removing all files, dependencies, and loading orders.
68
84
  */
69
85
  reset(): void;
70
86
  }
@@ -13,6 +13,7 @@ const retriever_1 = require("../../r-bridge/retriever");
13
13
  const config_1 = require("../../config");
14
14
  const flowr_file_1 = require("./flowr-file");
15
15
  const flowr_analyzer_environment_context_1 = require("./flowr-analyzer-environment-context");
16
+ const flowr_analyzer_meta_context_1 = require("./flowr-analyzer-meta-context");
16
17
  /**
17
18
  * This summarizes the other context layers used by the {@link FlowrAnalyzer}.
18
19
  * Have a look at the attributes and layers listed below (e.g., {@link files} and {@link deps})
@@ -26,9 +27,11 @@ const flowr_analyzer_environment_context_1 = require("./flowr-analyzer-environme
26
27
  * If you are just interested in inspecting the context, you can use {@link ReadOnlyFlowrAnalyzerContext} instead (e.g., via {@link inspect}).
27
28
  */
28
29
  class FlowrAnalyzerContext {
30
+ meta;
29
31
  files;
30
32
  deps;
31
33
  env;
34
+ _analyzer;
32
35
  config;
33
36
  constructor(config, plugins) {
34
37
  this.config = config;
@@ -37,6 +40,18 @@ class FlowrAnalyzerContext {
37
40
  this.env = new flowr_analyzer_environment_context_1.FlowrAnalyzerEnvironmentContext(this);
38
41
  const functions = new flowr_analyzer_functions_context_1.FlowrAnalyzerFunctionsContext(this);
39
42
  this.deps = new flowr_analyzer_dependencies_context_1.FlowrAnalyzerDependenciesContext(functions, (plugins.get(flowr_analyzer_plugin_1.PluginType.DependencyIdentification) ?? []));
43
+ this.meta = new flowr_analyzer_meta_context_1.FlowrAnalyzerMetaContext();
44
+ }
45
+ /**
46
+ * Provides the analyzer associated with this context, if any.
47
+ * This is usually set when the context is used within an analyzer instance.
48
+ * Please note, that this may be `undefined` if the context is used standalone (e.g., during setup or in plugins that do not have access to the analyzer).
49
+ */
50
+ get analyzer() {
51
+ return this._analyzer;
52
+ }
53
+ setAnalyzer(analyzer) {
54
+ this._analyzer = analyzer;
40
55
  }
41
56
  /** delegate request addition */
42
57
  addRequests(requests) {
@@ -62,11 +77,12 @@ class FlowrAnalyzerContext {
62
77
  return this;
63
78
  }
64
79
  /**
65
- * Reset the context to its initial state, removing all files, dependencies, and loading orders.
80
+ * Reset the context to its initial state, e.g., removing all files, dependencies, and loading orders.
66
81
  */
67
82
  reset() {
68
83
  this.files.reset();
69
84
  this.deps.reset();
85
+ this.meta.reset();
70
86
  }
71
87
  }
72
88
  exports.FlowrAnalyzerContext = FlowrAnalyzerContext;
@@ -0,0 +1,51 @@
1
+ import type { SemVer } from 'semver';
2
+ export interface ReadOnlyFlowrAnalyzerMetaContext {
3
+ /**
4
+ * The name of this context.
5
+ */
6
+ readonly name: string;
7
+ /**
8
+ * Get the project name.
9
+ */
10
+ getProjectName(): string | undefined;
11
+ /**
12
+ * Get the project title.
13
+ */
14
+ getProjectTitle(): string | undefined;
15
+ /**
16
+ * Get the project version.
17
+ */
18
+ getProjectVersion(): SemVer & {
19
+ str: string;
20
+ } | undefined;
21
+ /**
22
+ * Get the project namespace.
23
+ * Any symbol resolve like `a::b` will resolve against this, if `a` matches the namespace.
24
+ */
25
+ getNamespace(): string | undefined;
26
+ }
27
+ /**
28
+ * This is the context responsible for managing the project metadata such as name, version, title, and namespace.
29
+ *
30
+ * If you are interested in inspecting this metadata, refer to {@link ReadOnlyFlowrAnalyzerMetaContext}.
31
+ */
32
+ export declare class FlowrAnalyzerMetaContext implements ReadOnlyFlowrAnalyzerMetaContext {
33
+ readonly name = "flowr-analyzer-meta-context";
34
+ private projectName;
35
+ private projectTitle;
36
+ private projectVersion;
37
+ private namespace;
38
+ reset(): void;
39
+ setProjectName(name: string): void;
40
+ getProjectName(): string | undefined;
41
+ setProjectTitle(title: string): void;
42
+ getProjectTitle(): string | undefined;
43
+ setProjectVersion(version: SemVer & {
44
+ str: string;
45
+ }): void;
46
+ getProjectVersion(): SemVer & {
47
+ str: string;
48
+ } | undefined;
49
+ setNamespace(namespace: string): void;
50
+ getNamespace(): string | undefined;
51
+ }
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FlowrAnalyzerMetaContext = void 0;
4
+ /**
5
+ * This is the context responsible for managing the project metadata such as name, version, title, and namespace.
6
+ *
7
+ * If you are interested in inspecting this metadata, refer to {@link ReadOnlyFlowrAnalyzerMetaContext}.
8
+ */
9
+ class FlowrAnalyzerMetaContext {
10
+ name = 'flowr-analyzer-meta-context';
11
+ projectName;
12
+ projectTitle;
13
+ projectVersion;
14
+ namespace;
15
+ reset() {
16
+ this.projectName = undefined;
17
+ this.projectTitle = undefined;
18
+ this.projectVersion = undefined;
19
+ this.namespace = undefined;
20
+ }
21
+ setProjectName(name) {
22
+ this.projectName = name;
23
+ }
24
+ getProjectName() {
25
+ return this.projectName;
26
+ }
27
+ setProjectTitle(title) {
28
+ this.projectTitle = title;
29
+ }
30
+ getProjectTitle() {
31
+ return this.projectTitle;
32
+ }
33
+ setProjectVersion(version) {
34
+ this.projectVersion = version;
35
+ }
36
+ getProjectVersion() {
37
+ return this.projectVersion;
38
+ }
39
+ setNamespace(namespace) {
40
+ this.namespace = namespace;
41
+ }
42
+ getNamespace() {
43
+ return this.namespace;
44
+ }
45
+ }
46
+ exports.FlowrAnalyzerMetaContext = FlowrAnalyzerMetaContext;
47
+ //# sourceMappingURL=flowr-analyzer-meta-context.js.map
@@ -12,10 +12,11 @@ import { type GetSearchElements } from '../search/flowr-search-executor';
12
12
  import type { FlowrAnalyzerContext, ReadOnlyFlowrAnalyzerContext } from './context/flowr-analyzer-context';
13
13
  import { CfgKind } from './cfg-kind';
14
14
  import type { RAnalysisRequest } from './context/flowr-analyzer-files-context';
15
- import type { RParseRequestFromFile } from '../r-bridge/retriever';
15
+ import type { RParseRequest, RParseRequestFromFile } from '../r-bridge/retriever';
16
16
  import { fileProtocol } from '../r-bridge/retriever';
17
17
  import type { FlowrFileProvider } from './context/flowr-file';
18
18
  import type { CallGraph } from '../dataflow/graph/call-graph';
19
+ import type { Tree } from 'web-tree-sitter';
19
20
  /**
20
21
  * Extends the {@link ReadonlyFlowrAnalysisProvider} with methods that allow modifying the analyzer state.
21
22
  */
@@ -47,6 +48,7 @@ export interface FlowrAnalysisProvider<Parser extends KnownParser = KnownParser>
47
48
  /**
48
49
  * Exposes the central analyses and information provided by the {@link FlowrAnalyzer} to the linter, search, and query APIs.
49
50
  * This allows us to exchange the underlying implementation of the analyzer without affecting the APIs.
51
+ * You can also use {@link ReadonlyFlowrAnalysisProvider#parseStandalone|parseStandalone} to parse standalone R code snippets.
50
52
  */
51
53
  export interface ReadonlyFlowrAnalysisProvider<Parser extends KnownParser = KnownParser> {
52
54
  /**
@@ -71,6 +73,12 @@ export interface ReadonlyFlowrAnalysisProvider<Parser extends KnownParser = Know
71
73
  * Peek at the parse output for the request, if it was already computed.
72
74
  */
73
75
  peekParse(): NonNullable<AnalyzerCacheType<Parser>['parse']> | undefined;
76
+ /**
77
+ * Parse standalone R code provided as a string or via the `file://` protocol.
78
+ * @note this method will always use the {@link TreeSitterExecutor} internally, make sure it is initialized!
79
+ * @param data - The R code to parse, either as a string or as a `file://` URL.
80
+ */
81
+ parseStandalone(data: `${typeof fileProtocol}${string}` | string | RParseRequest): Tree;
74
82
  /**
75
83
  * Get the normalized abstract syntax tree for the request.
76
84
  * @param force - Do not use the cache, instead force new analyses.
@@ -81,6 +89,12 @@ export interface ReadonlyFlowrAnalysisProvider<Parser extends KnownParser = Know
81
89
  * Peek at the normalized abstract syntax tree for the request, if it was already computed.
82
90
  */
83
91
  peekNormalize(): NormalizedAst & PipelinePerStepMetaInformation | undefined;
92
+ /**
93
+ * Normalize standalone R code provided as a string or via the `file://` protocol.
94
+ * @note this method will always use the {@link TreeSitterExecutor} internally, make sure it is initialized!
95
+ * @param data - The R code to normalize, either as a string or as a `file://` URL.
96
+ */
97
+ normalizeStandalone(data: `${typeof fileProtocol}${string}` | string | RParseRequest): NormalizedAst;
84
98
  /**
85
99
  * Get the dataflow graph for the request.
86
100
  * @param force - Do not use the cache, instead force new analyses.
@@ -156,6 +170,8 @@ export declare class FlowrAnalyzer<Parser extends KnownParser = KnownParser> imp
156
170
  parserInformation(): KnownParserInformation;
157
171
  inspectContext(): ReadOnlyFlowrAnalyzerContext;
158
172
  reset(): void;
173
+ parseStandalone(data: `${typeof fileProtocol}${string}` | string | RParseRequest): Tree;
174
+ normalizeStandalone(data: `${typeof fileProtocol}${string}` | string | RParseRequest): NormalizedAst;
159
175
  addRequest(...request: (RAnalysisRequest | readonly RAnalysisRequest[] | `${typeof fileProtocol}${string}` | string)[]): this;
160
176
  addFile(...f: (string | FlowrFileProvider | RParseRequestFromFile)[]): this;
161
177
  /**
@@ -2,10 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FlowrAnalyzer = void 0;
4
4
  const query_1 = require("../queries/query");
5
+ const decorate_1 = require("../r-bridge/lang-4.x/ast/model/processing/decorate");
5
6
  const flowr_search_executor_1 = require("../search/flowr-search-executor");
6
7
  const cfg_kind_1 = require("./cfg-kind");
7
8
  const retriever_1 = require("../r-bridge/retriever");
8
9
  const files_1 = require("../util/files");
10
+ const tree_sitter_normalize_1 = require("../r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize");
11
+ const tree_sitter_executor_1 = require("../r-bridge/lang-4.x/tree-sitter/tree-sitter-executor");
9
12
  /**
10
13
  * Central class for conducting analyses with FlowR.
11
14
  * Use the {@link FlowrAnalyzerBuilder} to create a new instance.
@@ -32,6 +35,7 @@ class FlowrAnalyzer {
32
35
  constructor(parser, ctx, cache) {
33
36
  this.parser = parser;
34
37
  this.ctx = ctx;
38
+ ctx.setAnalyzer(this);
35
39
  this.cache = cache;
36
40
  }
37
41
  get flowrConfig() {
@@ -51,6 +55,20 @@ class FlowrAnalyzer {
51
55
  this.ctx.reset();
52
56
  this.cache.reset();
53
57
  }
58
+ parseStandalone(data) {
59
+ const request = (0, retriever_1.isParseRequest)(data) ? data : (0, retriever_1.requestFromInput)(data);
60
+ if (this.parser.name === 'tree-sitter') {
61
+ return this.parser.parse(request);
62
+ }
63
+ else {
64
+ const ts = new tree_sitter_executor_1.TreeSitterExecutor();
65
+ return ts.parse(request);
66
+ }
67
+ }
68
+ normalizeStandalone(data) {
69
+ const parse = this.parseStandalone(data);
70
+ return (0, decorate_1.decorateAst)((0, tree_sitter_normalize_1.normalizeTreeSitterTreeToAst)([{ parsed: parse, filePath: undefined }], true), {});
71
+ }
54
72
  addRequest(...request) {
55
73
  for (const r of request) {
56
74
  if (typeof r === 'string') {
@@ -3,6 +3,7 @@ import type { RAuthorInfo } from '../../../../util/r-author';
3
3
  import type { DeepReadonly } from 'ts-essentials';
4
4
  import type { RLicenseElementInfo } from '../../../../util/r-license';
5
5
  import { Package, type PackageType } from '../../package-version-plugins/package';
6
+ import type { SemVer } from 'semver';
6
7
  export type DCF = Map<string, string[]>;
7
8
  /**
8
9
  * This decorates a text file and provides access to its content as a DCF (Debian Control File)-like structure.
@@ -31,6 +32,12 @@ export declare class FlowrDescriptionFile extends FlowrFile<DeepReadonly<DCF>> {
31
32
  * Returns the parsed license information from the 'License' field in the DESCRIPTION file.
32
33
  */
33
34
  license(): RLicenseElementInfo[] | undefined;
35
+ /**
36
+ * Returns the parsed version from the 'Version' field in the DESCRIPTION file.
37
+ */
38
+ version(): SemVer & {
39
+ str: string;
40
+ } | undefined;
34
41
  /**
35
42
  * Returns the parsed authors from the `Authors@R` field in the DESCRIPTION file.
36
43
  */
@@ -51,6 +58,14 @@ export declare class FlowrDescriptionFile extends FlowrFile<DeepReadonly<DCF>> {
51
58
  * Returns the parsed imports from the 'Imports' field in the DESCRIPTION file.
52
59
  */
53
60
  imports(): readonly Package[] | undefined;
61
+ /**
62
+ * Returns the package name from the 'Package' field in the DESCRIPTION file.
63
+ */
64
+ packageName(): string | undefined;
65
+ /**
66
+ * Returns the package title from the 'Title' field in the DESCRIPTION file.
67
+ */
68
+ packageTitle(): string | undefined;
54
69
  }
55
70
  /**
56
71
  * Parses the 'License' field from an R DESCRIPTION file into SPDX license expressions.
@@ -9,6 +9,7 @@ const args_1 = require("../../../../util/text/args");
9
9
  const r_license_1 = require("../../../../util/r-license");
10
10
  const package_1 = require("../../package-version-plugins/package");
11
11
  const retriever_1 = require("../../../../r-bridge/retriever");
12
+ const r_version_1 = require("../../../../util/r-version");
12
13
  /**
13
14
  * This decorates a text file and provides access to its content as a DCF (Debian Control File)-like structure.
14
15
  * Please use the static {@link FlowrDescriptionFile.from} method to create instances of this class.
@@ -52,6 +53,17 @@ class FlowrDescriptionFile extends flowr_file_1.FlowrFile {
52
53
  }
53
54
  return parseRLicenseField(...licenses);
54
55
  }
56
+ /**
57
+ * Returns the parsed version from the 'Version' field in the DESCRIPTION file.
58
+ */
59
+ version() {
60
+ const v = this.content().get('Version');
61
+ if (!v || v.length === 0) {
62
+ return undefined;
63
+ }
64
+ const verStr = v[0].trim();
65
+ return (0, r_version_1.parseRVersion)(verStr);
66
+ }
55
67
  /**
56
68
  * Returns the parsed authors from the `Authors@R` field in the DESCRIPTION file.
57
69
  */
@@ -93,6 +105,20 @@ class FlowrDescriptionFile extends flowr_file_1.FlowrFile {
93
105
  const imps = this.content().get('Imports');
94
106
  return imps ? parsePackagesWithVersions(imps, 'package') : undefined;
95
107
  }
108
+ /**
109
+ * Returns the package name from the 'Package' field in the DESCRIPTION file.
110
+ */
111
+ packageName() {
112
+ const names = this.content().get('Package');
113
+ return names && names.length > 0 ? names[0] : names?.join(' ');
114
+ }
115
+ /**
116
+ * Returns the package title from the 'Title' field in the DESCRIPTION file.
117
+ */
118
+ packageTitle() {
119
+ const titles = this.content().get('Title');
120
+ return titles && titles.length > 0 ? titles[0] : titles?.join(' ');
121
+ }
96
122
  }
97
123
  exports.FlowrDescriptionFile = FlowrDescriptionFile;
98
124
  /**
@@ -1,5 +1,7 @@
1
1
  import type { FileRole, FlowrFileProvider } from '../../../context/flowr-file';
2
2
  import { FlowrFile } from '../../../context/flowr-file';
3
+ import type { RNode } from '../../../../r-bridge/lang-4.x/ast/model/model';
4
+ import type { FlowrAnalyzerContext } from '../../../context/flowr-analyzer-context';
3
5
  export interface NamespaceInfo {
4
6
  exportedSymbols: string[];
5
7
  exportedFunctions: string[];
@@ -7,6 +9,11 @@ export interface NamespaceInfo {
7
9
  exportedPatterns: string[];
8
10
  importedPackages: Map<string, string[] | 'all'>;
9
11
  loadsWithSideEffects: boolean;
12
+ /**
13
+ * This will only be present in complex parsed NAMESPACE files and tell you
14
+ * about which parts are only active with given conditions!
15
+ */
16
+ conditional?: Map<RNode, NamespaceInfo>;
10
17
  }
11
18
  export interface NamespaceFormat {
12
19
  current: NamespaceInfo;
@@ -14,21 +21,28 @@ export interface NamespaceFormat {
14
21
  }
15
22
  /**
16
23
  * This decorates a text file and provides access to its content in the {@link NamespaceFormat}.
24
+ * Namespace files can be parsed in a simple mode which is much quicker, but does not support `if`/other R-constructs!
17
25
  */
18
26
  export declare class FlowrNamespaceFile extends FlowrFile<NamespaceFormat> {
19
27
  private readonly wrapped;
28
+ private readonly ctx;
20
29
  /**
21
30
  * Prefer the static {@link FlowrNamespaceFile.from} method to create instances of this class as it will not re-create if already a namespace file
22
31
  * and handle role assignments.
23
32
  */
24
- constructor(file: FlowrFileProvider);
33
+ constructor(file: FlowrFileProvider, ctx?: FlowrAnalyzerContext);
25
34
  /**
26
35
  * Loads and parses the content of the wrapped file in the {@link NamespaceFormat}.
27
- * @see {@link parseNamespace} for details on the parsing logic.
36
+ * @see {@link parseNamespaceSimple} for details on the parsing logic.
37
+ * @see {@link parseNamespaceComplex} for a more complex parser.
28
38
  */
29
39
  protected loadContent(): NamespaceFormat;
30
40
  /**
31
41
  * Namespace file lifter, this does not re-create if already a namespace file
42
+ * and handles role assignments.
43
+ * @param file - The file to lift or return if already a namespace file
44
+ * @param ctx - An optional analyzer context to use for complex parsing
45
+ * @param role - An optional role to assign to the file
32
46
  */
33
- static from(file: FlowrFileProvider | FlowrNamespaceFile, role?: FileRole): FlowrNamespaceFile;
47
+ static from(file: FlowrFileProvider | FlowrNamespaceFile, ctx?: FlowrAnalyzerContext, role?: FileRole): FlowrNamespaceFile;
34
48
  }