@eagleoutice/flowr 2.8.15 → 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 (179) 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 +4 -0
  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/resolve-by-name.d.ts +4 -4
  43. package/dataflow/environments/resolve-by-name.js +24 -8
  44. package/dataflow/eval/resolve/resolve.d.ts +10 -6
  45. package/dataflow/eval/resolve/resolve.js +12 -7
  46. package/dataflow/extractor.js +6 -3
  47. package/dataflow/fn/higher-order-function.js +4 -4
  48. package/dataflow/graph/call-graph.d.ts +1 -1
  49. package/dataflow/graph/call-graph.js +10 -8
  50. package/dataflow/graph/diff-dataflow-graph.js +6 -4
  51. package/dataflow/graph/edge.d.ts +48 -31
  52. package/dataflow/graph/edge.js +66 -60
  53. package/dataflow/graph/graph.d.ts +7 -7
  54. package/dataflow/graph/quads.js +1 -1
  55. package/dataflow/graph/resolve-graph.js +1 -1
  56. package/dataflow/graph/unknown-replacement.d.ts +2 -1
  57. package/dataflow/graph/vertex.d.ts +2 -103
  58. package/dataflow/graph/vertex.js +0 -44
  59. package/dataflow/internal/linker.d.ts +2 -2
  60. package/dataflow/internal/linker.js +26 -18
  61. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +3 -65
  62. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +4 -6
  63. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +12 -46
  64. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +2 -1
  65. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +4 -4
  66. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +2 -2
  67. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +8 -5
  68. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +4 -4
  69. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +2 -2
  70. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +6 -2
  71. package/dataflow/internal/process/functions/call/built-in/built-in-list.js +1 -69
  72. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +1 -1
  73. package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +1 -1
  74. package/dataflow/internal/process/functions/call/built-in/built-in-recall.d.ts +11 -0
  75. package/dataflow/internal/process/functions/call/built-in/built-in-recall.js +46 -0
  76. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +3 -2
  77. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.d.ts +0 -2
  78. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +11 -72
  79. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +1 -2
  80. package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.js +2 -1
  81. package/dataflow/internal/process/functions/call/built-in/built-in-stop-if-not.js +4 -3
  82. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +3 -2
  83. package/dataflow/internal/process/functions/call/built-in/built-in-vector.js +1 -60
  84. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +3 -3
  85. package/dataflow/internal/process/functions/call/common.d.ts +3 -1
  86. package/dataflow/internal/process/functions/call/common.js +4 -16
  87. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +6 -2
  88. package/dataflow/internal/process/functions/call/known-call-handling.js +2 -3
  89. package/dataflow/internal/process/functions/call/unnamed-call-handling.d.ts +1 -1
  90. package/dataflow/internal/process/functions/call/unnamed-call-handling.js +1 -1
  91. package/dataflow/internal/process/functions/process-parameter.js +1 -1
  92. package/dataflow/internal/process/process-named-call.d.ts +2 -1
  93. package/dataflow/internal/process/process-named-call.js +0 -1
  94. package/dataflow/internal/process/process-symbol.d.ts +3 -1
  95. package/dataflow/internal/process/process-symbol.js +8 -5
  96. package/dataflow/origin/dfg-get-origin.d.ts +2 -2
  97. package/dataflow/origin/dfg-get-origin.js +4 -4
  98. package/dataflow/origin/dfg-get-symbol-refs.js +2 -2
  99. package/documentation/data/interface/doc-writing-code.d.ts +6 -0
  100. package/documentation/data/interface/doc-writing-code.js +176 -0
  101. package/documentation/doc-util/doc-types.d.ts +3 -1
  102. package/documentation/doc-util/doc-types.js +4 -2
  103. package/documentation/wiki-absint.js +2 -1
  104. package/documentation/wiki-analyzer.js +17 -2
  105. package/documentation/wiki-cfg.js +2 -2
  106. package/documentation/wiki-dataflow-graph.js +9 -8
  107. package/documentation/wiki-interface.js +8 -164
  108. package/documentation/wiki-mk/doc-context.d.ts +12 -1
  109. package/documentation/wiki-mk/doc-context.js +21 -4
  110. package/documentation/wiki-normalized-ast.js +5 -0
  111. package/linter/linter-rules.d.ts +3 -3
  112. package/linter/rules/absolute-path.js +23 -23
  113. package/linter/rules/dataframe-access-validation.js +2 -1
  114. package/linter/rules/deprecated-functions.d.ts +1 -1
  115. package/linter/rules/deprecated-functions.js +1 -1
  116. package/linter/rules/function-finder-util.d.ts +2 -2
  117. package/linter/rules/network-functions.d.ts +1 -1
  118. package/linter/rules/seeded-randomness.d.ts +2 -2
  119. package/linter/rules/seeded-randomness.js +5 -4
  120. package/linter/rules/unused-definition.js +4 -4
  121. package/package.json +5 -5
  122. package/project/context/flowr-analyzer-context.d.ts +17 -1
  123. package/project/context/flowr-analyzer-context.js +17 -1
  124. package/project/context/flowr-analyzer-meta-context.d.ts +51 -0
  125. package/project/context/flowr-analyzer-meta-context.js +47 -0
  126. package/project/flowr-analyzer.d.ts +17 -1
  127. package/project/flowr-analyzer.js +18 -0
  128. package/project/plugins/file-plugins/files/flowr-description-file.d.ts +15 -0
  129. package/project/plugins/file-plugins/files/flowr-description-file.js +26 -0
  130. package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +17 -3
  131. package/project/plugins/file-plugins/files/flowr-namespace-file.js +292 -10
  132. package/project/plugins/file-plugins/flowr-analyzer-namespace-files-plugin.d.ts +1 -1
  133. package/project/plugins/file-plugins/flowr-analyzer-namespace-files-plugin.js +2 -2
  134. package/project/plugins/flowr-analyzer-plugin-defaults.js +2 -0
  135. package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-description-file-plugin.js +1 -1
  136. package/project/plugins/package-version-plugins/flowr-analyzer-meta-description-file-plugin.d.ts +12 -0
  137. package/project/plugins/package-version-plugins/flowr-analyzer-meta-description-file-plugin.js +42 -0
  138. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.d.ts +1 -1
  139. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.js +2 -2
  140. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-namespace-file-plugin.d.ts +1 -1
  141. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-namespace-file-plugin.js +2 -2
  142. package/project/plugins/plugin-registry.d.ts +2 -1
  143. package/project/plugins/plugin-registry.js +2 -0
  144. package/queries/catalog/call-context-query/call-context-query-executor.js +6 -4
  145. package/queries/catalog/call-context-query/call-context-query-format.d.ts +2 -1
  146. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +3 -3
  147. package/queries/catalog/dependencies-query/dependencies-query-format.js +5 -3
  148. package/queries/catalog/does-call-query/does-call-query-executor.js +2 -1
  149. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.js +2 -2
  150. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +1 -1
  151. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.js +1 -1
  152. package/r-bridge/data/data.d.ts +8 -3
  153. package/r-bridge/data/data.js +9 -3
  154. package/r-bridge/lang-4.x/ast/model/model.d.ts +0 -11
  155. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +2 -1
  156. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +2 -1
  157. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +7 -3
  158. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +2 -1
  159. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-argument.js +0 -1
  160. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.js +0 -1
  161. package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-binary.js +0 -1
  162. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-number.js +0 -1
  163. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-symbol.d.ts +1 -2
  164. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-symbol.js +12 -13
  165. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +4 -11
  166. package/reconstruct/reconstruct.js +6 -5
  167. package/search/flowr-search-filters.js +2 -1
  168. package/search/search-executor/search-enrichers.d.ts +1 -2
  169. package/search/search-executor/search-enrichers.js +2 -1
  170. package/slicing/static/slice-call.js +5 -5
  171. package/slicing/static/static-slicer.js +2 -2
  172. package/statistics/features/common-syntax-probability.js +3 -2
  173. package/statistics/features/supported/defined-functions/defined-functions.js +3 -3
  174. package/statistics/features/supported/used-functions/used-functions.js +3 -2
  175. package/util/mermaid/dfg.js +3 -3
  176. package/util/simple-df/dfg-ascii.js +5 -5
  177. package/util/version.js +1 -1
  178. package/util/containers.d.ts +0 -66
  179. package/util/containers.js +0 -143
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eagleoutice/flowr",
3
- "version": "2.8.15",
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
  }