@eagleoutice/flowr 2.13.4 → 2.13.6

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 (133) hide show
  1. package/README.md +29 -29
  2. package/cli/repl/core.js +10 -2
  3. package/config.d.ts +4 -1
  4. package/config.js +10 -1
  5. package/control-flow/cfg-dead-code.js +19 -4
  6. package/control-flow/extract-cfg.js +12 -4
  7. package/dataflow/environments/built-in-config.d.ts +6 -3
  8. package/dataflow/environments/built-in-eval-name.d.ts +20 -0
  9. package/dataflow/environments/built-in-eval-name.js +25 -0
  10. package/dataflow/environments/built-in-props.d.ts +175 -0
  11. package/dataflow/environments/built-in-props.js +207 -0
  12. package/dataflow/environments/built-in.d.ts +26 -22
  13. package/dataflow/environments/built-in.js +37 -10
  14. package/dataflow/environments/default-builtin-config.d.ts +1068 -95
  15. package/dataflow/environments/default-builtin-config.js +549 -216
  16. package/dataflow/environments/identifier.d.ts +24 -1
  17. package/dataflow/environments/identifier.js +24 -2
  18. package/dataflow/environments/query-fn-props.d.ts +102 -0
  19. package/dataflow/environments/query-fn-props.js +188 -0
  20. package/dataflow/eval/resolve/alias-tracking.d.ts +6 -5
  21. package/dataflow/eval/resolve/alias-tracking.js +45 -12
  22. package/dataflow/eval/resolve/match-arguments.d.ts +15 -0
  23. package/dataflow/eval/resolve/match-arguments.js +77 -0
  24. package/dataflow/eval/resolve/resolve-numbers.d.ts +202 -0
  25. package/dataflow/eval/resolve/resolve-numbers.js +163 -0
  26. package/dataflow/eval/resolve/resolve-operators.d.ts +60 -0
  27. package/dataflow/eval/resolve/resolve-operators.js +115 -0
  28. package/dataflow/eval/resolve/resolve-strings.d.ts +98 -0
  29. package/dataflow/eval/resolve/resolve-strings.js +116 -0
  30. package/dataflow/eval/resolve/resolve.d.ts +5 -37
  31. package/dataflow/eval/resolve/resolve.js +56 -134
  32. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +1 -1
  33. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +5 -4
  34. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +1 -4
  35. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +1 -1
  36. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +2 -1
  37. package/dataflow/internal/process/functions/call/known-call-handling.js +2 -1
  38. package/documentation/data/faq/faqs.js +11 -0
  39. package/documentation/doc-util/doc-types.js +1 -1
  40. package/documentation/wiki-analyzer.js +75 -0
  41. package/documentation/wiki-core.js +81 -16
  42. package/documentation/wiki-interface.js +3 -0
  43. package/linter/linter-rules.d.ts +10 -11
  44. package/linter/rules/deprecated-functions.js +5 -3
  45. package/linter/rules/function-finder-util.d.ts +2 -2
  46. package/linter/rules/function-finder-util.js +10 -3
  47. package/linter/rules/network-functions.d.ts +25 -5
  48. package/linter/rules/network-functions.js +51 -11
  49. package/linter/rules/problematic-inputs.d.ts +1 -1
  50. package/linter/rules/problematic-inputs.js +7 -1
  51. package/linter/rules/seeded-randomness.d.ts +5 -8
  52. package/linter/rules/seeded-randomness.js +18 -10
  53. package/linter/rules/unused-definition.js +29 -17
  54. package/package.json +4 -2
  55. package/project/cache/flowr-analyzer-cache.d.ts +4 -3
  56. package/project/cache/flowr-analyzer-cache.js +32 -13
  57. package/project/cache/flowr-cache.d.ts +39 -12
  58. package/project/cache/flowr-cache.js +5 -3
  59. package/project/context/flowr-analyzer-context.d.ts +8 -1
  60. package/project/context/flowr-analyzer-context.js +11 -1
  61. package/project/context/flowr-analyzer-dependencies-context.d.ts +8 -2
  62. package/project/context/flowr-analyzer-dependencies-context.js +43 -11
  63. package/project/context/flowr-analyzer-files-context.d.ts +8 -4
  64. package/project/context/flowr-analyzer-files-context.js +20 -1
  65. package/project/context/flowr-analyzer-incremental-analysis-context.d.ts +33 -0
  66. package/project/context/flowr-analyzer-incremental-analysis-context.js +63 -0
  67. package/project/context/flowr-analyzer-meta-context.d.ts +3 -1
  68. package/project/context/flowr-analyzer-meta-context.js +14 -0
  69. package/project/context/flowr-file.d.ts +25 -3
  70. package/project/context/flowr-file.js +24 -2
  71. package/project/dependency-version-space.d.ts +37 -0
  72. package/project/dependency-version-space.js +118 -26
  73. package/project/flowr-analyzer.d.ts +6 -0
  74. package/project/flowr-analyzer.js +6 -2
  75. package/project/incremental/incremental-parse/edit-computation.d.ts +7 -0
  76. package/project/incremental/incremental-parse/edit-computation.js +61 -0
  77. package/project/incremental/incremental-parse/incremental-parse.d.ts +12 -0
  78. package/project/incremental/incremental-parse/incremental-parse.js +37 -0
  79. package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +1 -1
  80. package/project/plugins/file-plugins/files/flowr-manifest-files.d.ts +57 -0
  81. package/project/plugins/file-plugins/files/flowr-manifest-files.js +121 -0
  82. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +2 -2
  83. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +2 -2
  84. package/project/plugins/file-plugins/files/flowr-sweave-file.d.ts +1 -1
  85. package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.d.ts +33 -0
  86. package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.js +53 -0
  87. package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.d.ts +1 -1
  88. package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.js +3 -3
  89. package/project/plugins/package-version-plugins/flowr-analyzer-meta-manifest-file-plugin.d.ts +27 -0
  90. package/project/plugins/package-version-plugins/flowr-analyzer-meta-manifest-file-plugin.js +47 -0
  91. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.d.ts +7 -0
  92. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +31 -3
  93. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +10 -4
  94. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +17 -4
  95. package/project/plugins/plugin-registry.d.ts +4 -4
  96. package/project/plugins/plugin-registry.js +7 -4
  97. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +4 -4
  98. package/project/sigdb/reader.d.ts +7 -0
  99. package/project/sigdb/reader.js +12 -0
  100. package/queries/catalog/dependencies-query/function-info/derived-functions.d.ts +10 -0
  101. package/queries/catalog/dependencies-query/function-info/derived-functions.js +41 -0
  102. package/queries/catalog/dependencies-query/function-info/read-functions.js +13 -12
  103. package/queries/catalog/dependencies-query/function-info/write-functions.js +16 -23
  104. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +33 -3
  105. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +31 -0
  106. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +9 -2
  107. package/queries/catalog/input-sources-query/input-source-functions.d.ts +8 -10
  108. package/queries/catalog/input-sources-query/input-source-functions.js +23 -388
  109. package/queries/catalog/input-sources-query/input-sources-query-format.d.ts +7 -0
  110. package/queries/catalog/input-sources-query/input-sources-query-format.js +27 -10
  111. package/queries/catalog/signature-query/signature-query-executor.d.ts +2 -1
  112. package/queries/catalog/signature-query/signature-query-executor.js +79 -3
  113. package/queries/catalog/signature-query/signature-query-format.d.ts +27 -0
  114. package/queries/catalog/signature-query/signature-query-render.js +21 -3
  115. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.d.ts +6 -2
  116. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +21 -2
  117. package/r-bridge/parser.d.ts +11 -1
  118. package/r-bridge/parser.js +7 -4
  119. package/r-bridge/shell-executor.d.ts +1 -0
  120. package/r-bridge/shell-executor.js +1 -0
  121. package/r-bridge/shell.d.ts +1 -0
  122. package/r-bridge/shell.js +1 -0
  123. package/search/flowr-search-filters.d.ts +1 -6
  124. package/search/flowr-search-filters.js +1 -8
  125. package/search/search-executor/search-enrichers.d.ts +2 -0
  126. package/search/search-executor/search-enrichers.js +29 -12
  127. package/util/version.js +1 -1
  128. package/project/plugins/file-plugins/files/flowr-rproject-file.d.ts +0 -31
  129. package/project/plugins/file-plugins/files/flowr-rproject-file.js +0 -66
  130. package/project/plugins/file-plugins/flowr-analyzer-rproject-file-plugin.d.ts +0 -22
  131. package/project/plugins/file-plugins/flowr-analyzer-rproject-file-plugin.js +0 -36
  132. package/project/plugins/package-version-plugins/flowr-analyzer-meta-rproject-file-plugin.d.ts +0 -13
  133. package/project/plugins/package-version-plugins/flowr-analyzer-meta-rproject-file-plugin.js +0 -32
@@ -20,15 +20,24 @@ const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-fun
20
20
  const r_value_1 = require("../../dataflow/eval/values/r-value");
21
21
  const info_1 = require("../../dataflow/info");
22
22
  const built_in_proc_name_1 = require("../../dataflow/environments/built-in-proc-name");
23
+ const built_in_props_1 = require("../../dataflow/environments/built-in-props");
24
+ const query_fn_props_1 = require("../../dataflow/environments/query-fn-props");
25
+ const RandomnessProducers = [
26
+ { type: 'function', name: 'set.seed' },
27
+ { type: 'assignment', name: '.Random.seed' }
28
+ ];
23
29
  exports.SEEDED_RANDOMNESS = {
24
30
  createSearch: (config) => flowr_search_builder_1.Q.all().filter(vertex_1.VertexType.FunctionCall)
25
- .with(search_enrichers_1.Enrichment.CallTargets, { onlyBuiltin: true })
31
+ .with(search_enrichers_1.Enrichment.CallTargets, {
32
+ onlyBuiltin: true,
33
+ qualifyNames: false // we don't use qualified names for this rule yet
34
+ })
26
35
  .filter({
27
36
  name: flowr_search_filters_1.FlowrFilter.MatchesEnrichment,
28
37
  args: {
29
38
  enrichment: search_enrichers_1.Enrichment.CallTargets,
30
39
  test: {
31
- targets: (0, flowr_search_filters_1.testFunctionsIgnoringPackage)(config.randomnessConsumers)
40
+ targets: identifier_1.Identifier.regex(...config.randomnessConsumers)
32
41
  }
33
42
  }
34
43
  })
@@ -128,14 +137,13 @@ exports.SEEDED_RANDOMNESS = {
128
137
  },
129
138
  info: {
130
139
  defaultConfig: {
131
- randomnessProducers: [{ type: 'function', name: 'set.seed' }, { type: 'assignment', name: '.Random.seed' }],
140
+ randomnessProducers: RandomnessProducers,
132
141
  randomnessConsumers: [
133
- 'jitter', 'sample', 'sample.int', 'arima.sim', 'kmeans', 'princomp', 'rcauchy', 'rchisq', 'rexp',
134
- 'rgamma', 'rgeom', 'rlnorm', 'rlogis', 'rmultinom', 'rnbinom', 'rnorm', 'rpois', 'runif', 'pointLabel',
135
- 'some', 'rbernoulli', 'rdunif', 'generateSeedVectors',
136
- 'rbeta', 'rf', 'rhyper', 'rweibull', 'rt', 'rvonmises', 'rwilcox', 'rxor', 'rhyper', 'rmvnorm',
137
- 'rsignrank', 'randomForest',
138
- 'permuted', 'permute', 'shuffle', 'shuffleSet', 'data_shuffle', 'sample_frac', 'sample_n', 'slice_sample',
142
+ ...query_fn_props_1.BuiltInIndex.default().with(built_in_props_1.CallProp.Random).map(identifier_1.Identifier.getName)
143
+ .filter(n => !RandomnessProducers.some(p => p.name === n)),
144
+ 'princomp', 'pointLabel', 'some', 'rbernoulli', 'rdunif', 'generateSeedVectors', 'rvonmises',
145
+ 'rxor', 'rmvnorm', 'randomForest',
146
+ 'permuted', 'permute', 'shuffle', 'shuffleSet', 'data_shuffle', 'sample_frac', 'sample_n',
139
147
  ],
140
148
  },
141
149
  tags: [linter_tags_1.LintingRuleTag.Robustness, linter_tags_1.LintingRuleTag.Reproducibility],
@@ -150,7 +158,7 @@ exports.SEEDED_RANDOMNESS = {
150
158
  }
151
159
  };
152
160
  function getDefaultAssignments() {
153
- return default_builtin_config_1.DefaultBuiltinConfig.filter(b => b.type === 'function' && (b.processor === built_in_proc_name_1.BuiltInProcName.Assignment || b.processor === built_in_proc_name_1.BuiltInProcName.AssignmentLike));
161
+ return default_builtin_config_1.DefaultBuiltinConfig.filter((b) => b.type === 'function' && (b.processor === built_in_proc_name_1.BuiltInProcName.Assignment || b.processor === built_in_proc_name_1.BuiltInProcName.AssignmentLike));
154
162
  }
155
163
  function isConstantArgument(graph, call, argIndex, ctx) {
156
164
  const args = call.args.filter(arg => arg !== r_function_call_1.EmptyArgument && !arg.name).map(graph_1.FunctionArgument.getReference);
@@ -14,26 +14,37 @@ const flowr_namespace_file_1 = require("../../project/plugins/file-plugins/files
14
14
  const identifier_1 = require("../../dataflow/environments/identifier");
15
15
  const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
16
16
  const retriever_1 = require("../../r-bridge/retriever");
17
+ const query_fn_props_1 = require("../../dataflow/environments/query-fn-props");
18
+ const built_in_props_1 = require("../../dataflow/environments/built-in-props");
19
+ const default_builtin_config_1 = require("../../dataflow/environments/default-builtin-config");
17
20
  const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
18
21
  const r_function_definition_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
19
22
  /**
20
23
  * The dots parameter is a special parameter and must never be reported as an unused definition.
21
24
  */
22
25
  const DotsParameter = '...';
26
+ /** the standard-library S3 generics flowR models no built-in for, so the store cannot state them */
27
+ const OtherKnownS3Generics = new Set([
28
+ 'summary', 'coef', 'vcov', 'residuals', 'fitted', 'predict', 'as.vector', 'str', 'toString', 'all.equal',
29
+ 'aggregate', 'update', 'anova', 'confint', 'logLik', 'AIC', 'BIC', 'deviance', 'df.residual',
30
+ 'model.matrix', 'terms', 'weights', 'merge', 'split', 'window'
31
+ ]);
32
+ let knownS3Generics;
23
33
  /**
24
- * Common base/standard-library S3 generics. A definition named `generic.class` where `generic` is one of these
25
- * is an S3 method dispatched indirectly (e.g. `print(x)` on an object of class `class`), so it is used even
26
- * without a direct textual call.
34
+ * Whether a definition named `name.class` may be an S3 method: `name` is a built-in flowR labels
35
+ * {@link CallProp.Generic} or one of {@link OtherKnownS3Generics}. Such a method is dispatched indirectly
36
+ * (`print(x)` on an object of that class), so it is used without a textual call.
27
37
  */
28
- const KnownS3Generics = new Set([
29
- 'print', 'format', 'summary', 'plot', 'coef', 'vcov', 'residuals', 'fitted', 'predict',
30
- 'as.character', 'as.data.frame', 'as.list', 'as.matrix', 'as.vector', 'as.numeric',
31
- 'length', 'dim', 'dimnames', 'names', 'str', 'toString', 'all.equal', 'aggregate',
32
- 'update', 'anova', 'confint', 'logLik', 'AIC', 'BIC', 'deviance', 'df.residual',
33
- 'model.matrix', 'terms', 'weights', 'simulate', 'lines', 'points', 'head', 'tail',
34
- 'merge', 'rbind', 'cbind', 'split', 'window', 'subset', 'sort', 'rev', 'unique',
35
- 'mean', 'median', 'quantile', 'range', 'diff', 't'
36
- ]);
38
+ function isKnownS3Generic(name) {
39
+ knownS3Generics ??= new Set([...OtherKnownS3Generics, ...Object.keys(default_builtin_config_1.RGroupGenerics),
40
+ ...query_fn_props_1.BuiltInIndex.default().with(built_in_props_1.CallProp.Generic).map(g => identifier_1.Identifier.getName(g))]);
41
+ return knownS3Generics.has(name);
42
+ }
43
+ /** Whether `generic`, or any member of it when it is a group generic (`Ops.cls` dispatches on `+`), is called. */
44
+ function isDispatched(generic, called) {
45
+ const group = default_builtin_config_1.RGroupGenerics[generic];
46
+ return called.has(generic) || (group?.some(member => called.has(member)) ?? false);
47
+ }
37
48
  /**
38
49
  * R package lifecycle hooks called automatically by R's package machinery.
39
50
  * These functions are invoked by the package system, so they are used even without textual callers.
@@ -104,8 +115,9 @@ function isConsideredUsed(lexeme, config, pkg, called) {
104
115
  if (lexeme === undefined) {
105
116
  return false;
106
117
  }
107
- // non-syntactic definition names (e.g. S3 methods like `"[.irts"`) carry their R quotes in the lexeme
108
- const name = (0, retriever_1.removeRQuotes)(lexeme);
118
+ // non-syntactic definition names (e.g. S3 methods like `"[.irts"`) carry their R quotes or backticks in the lexeme
119
+ const unquoted = (0, retriever_1.removeRQuotes)(lexeme);
120
+ const name = unquoted.length > 1 && unquoted.startsWith('`') && unquoted.endsWith('`') ? unquoted.slice(1, -1) : unquoted;
109
121
  // the dots are a special parameter and must never be reported
110
122
  if (name === DotsParameter) {
111
123
  return true;
@@ -114,10 +126,10 @@ function isConsideredUsed(lexeme, config, pkg, called) {
114
126
  if (PackageHookFunctions.has(name)) {
115
127
  return true;
116
128
  }
117
- const dot = name.indexOf('.');
118
- if (dot > 0) {
129
+ // every dot may be the one splitting method from class, as the generic may carry dots itself (`as.character.foo`)
130
+ for (let dot = name.indexOf('.'); dot > 0; dot = name.indexOf('.', dot + 1)) {
119
131
  const generic = name.slice(0, dot);
120
- if (KnownS3Generics.has(generic) || pkg.s3Generics.has(generic) || called.has(generic)) {
132
+ if (isKnownS3Generic(generic) || pkg.s3Generics.has(generic) || isDispatched(generic, called)) {
121
133
  return true;
122
134
  }
123
135
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eagleoutice/flowr",
3
- "version": "2.13.4",
3
+ "version": "2.13.6",
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": {
@@ -30,6 +30,7 @@
30
30
  "build": "npm run gen:base-packages && tsc --project . && npm run build:copy-data",
31
31
  "gen:base-packages": "ts-node --transpile-only scripts/gen-base-packages.ts",
32
32
  "sync:sigdb": "ts-node --transpile-only scripts/sigdb-sync.ts",
33
+ "check:generic-labels": "ts-node --transpile-only scripts/check-generic-labels.ts",
33
34
  "gen:sigdb-remote": "ts-node --transpile-only scripts/sigdb-remote.ts",
34
35
  "publish:sigdb": "ts-node scripts/publish-sigdb.ts",
35
36
  "build:copy-data": "ts-node --transpile-only scripts/sigdb-copy.ts",
@@ -182,7 +183,7 @@
182
183
  "devDependencies": {
183
184
  "@commitlint/cli": "^20.5.0",
184
185
  "@commitlint/config-angular": "^20.5.0",
185
- "@eagleoutice/eslint-config-flowr": "^2.0.1",
186
+ "@eagleoutice/eslint-config-flowr": "^2.0.2",
186
187
  "@j-ulrich/release-it-regex-bumper": "^5.4.0",
187
188
  "@stylistic/eslint-plugin": "^5.10.0",
188
189
  "@types/command-line-args": "^5.2.3",
@@ -227,6 +228,7 @@
227
228
  "command-line-usage": "^7.0.3",
228
229
  "commonmark": "^0.31.2",
229
230
  "dagre": "^0.8.5",
231
+ "diff": "^8.0.3",
230
232
  "gray-matter": "^4.0.3",
231
233
  "ignore": "^5.3.2",
232
234
  "joi": "^18.0.1",
@@ -1,5 +1,5 @@
1
1
  import type { KnownParser } from '../../r-bridge/parser';
2
- import { type CacheInvalidationEvent, FlowrCache } from './flowr-cache';
2
+ import { FlowrCache, type InvalidationEvent } from './flowr-cache';
3
3
  import { type DEFAULT_DATAFLOW_PIPELINE, type TREE_SITTER_DATAFLOW_PIPELINE } from '../../core/steps/pipeline/default-pipelines';
4
4
  import type { IdGenerator } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
5
5
  import type { NoInfo } from '../../r-bridge/lang-4.x/ast/model/model';
@@ -27,13 +27,14 @@ export declare class FlowrAnalyzerCache<Parser extends KnownParser> extends Flow
27
27
  private callGraphCache;
28
28
  protected constructor(args: FlowrAnalyzerCacheOptions<Parser>);
29
29
  private initCacheProviders;
30
+ static create<Parser extends KnownParser>(data: FlowrAnalyzerCacheOptions<Parser>): FlowrAnalyzerCache<Parser>;
30
31
  /** Free the current parse trees: tree-sitter trees live on the WASM heap, which the GC does not reclaim. */
31
32
  private disposeParse;
32
- static create<Parser extends KnownParser>(data: FlowrAnalyzerCacheOptions<Parser>): FlowrAnalyzerCache<Parser>;
33
- receive(event: CacheInvalidationEvent): void;
33
+ receive(event: InvalidationEvent): void;
34
34
  private get;
35
35
  reset(): void;
36
36
  private runTapeUntil;
37
+ private storeIncrementalSnapshotIfAvailable;
37
38
  /**
38
39
  * Get the parse output for the request, parsing if necessary.
39
40
  * @param force - Do not use the cache, instead force a new parse.
@@ -6,6 +6,10 @@ const default_pipelines_1 = require("../../core/steps/pipeline/default-pipelines
6
6
  const assert_1 = require("../../util/assert");
7
7
  const flowr_analyzer_controlflow_cache_1 = require("./flowr-analyzer-controlflow-cache");
8
8
  const call_graph_1 = require("../../dataflow/graph/call-graph");
9
+ function isTreeSitterParse(parse) {
10
+ return typeof parse === 'object' && parse !== null && 'files' in parse
11
+ && parse.files.every(f => typeof f.parsed === 'object' && f.parsed !== null && 'rootNode' in f.parsed);
12
+ }
9
13
  /**
10
14
  * This provides the full analyzer caching layer, please avoid using this directly
11
15
  * and prefer the {@link FlowrAnalyzer}.
@@ -27,6 +31,10 @@ class FlowrAnalyzerCache extends flowr_cache_1.FlowrCache {
27
31
  });
28
32
  this.controlFlowCache = new flowr_analyzer_controlflow_cache_1.FlowrAnalyzerControlFlowCache();
29
33
  this.callGraphCache = undefined;
34
+ this.computeIfAbsent(true, () => this.pipeline?.getResults(true));
35
+ }
36
+ static create(data) {
37
+ return new FlowrAnalyzerCache(data);
30
38
  }
31
39
  /** Free the current parse trees: tree-sitter trees live on the WASM heap, which the GC does not reclaim. */
32
40
  disposeParse() {
@@ -35,26 +43,27 @@ class FlowrAnalyzerCache extends flowr_cache_1.FlowrCache {
35
43
  file.parsed?.delete?.();
36
44
  }
37
45
  }
38
- static create(data) {
39
- return new FlowrAnalyzerCache(data);
40
- }
41
46
  receive(event) {
42
- switch (event.type) {
43
- case "full" /* CacheInvalidationEventType.Full */:
44
- this.disposeParse();
45
- super.receive(event);
47
+ super.receive(event);
48
+ const type = event.type;
49
+ if (type === "full" /* InvalidationEventType.Full */) {
50
+ this.disposeParse();
51
+ }
52
+ switch (type) {
53
+ case "full" /* InvalidationEventType.Full */:
54
+ case "single-file-invalidate" /* InvalidationEventType.SingleFileInvalidate */:
46
55
  this.initCacheProviders();
47
56
  break;
48
57
  default:
49
- (0, assert_1.assertUnreachable)(event.type);
58
+ (0, assert_1.assertUnreachable)(type);
50
59
  }
51
60
  }
52
61
  get() {
53
62
  /* this will do a ref assignment, so indirect force */
54
- return this.computeIfAbsent(false, () => this.pipeline.getResults(true));
63
+ return this.computeIfAbsent(false, () => this.pipeline?.getResults(true));
55
64
  }
56
65
  reset() {
57
- this.receive({ type: "full" /* CacheInvalidationEventType.Full */ });
66
+ this.receive({ type: "full" /* InvalidationEventType.Full */ });
58
67
  }
59
68
  async runTapeUntil(force, until) {
60
69
  (0, assert_1.guard)(this.args.context.files.loadingOrder.getUnorderedRequests().length > 0, 'At least one request must be set to run the analysis pipeline');
@@ -65,9 +74,19 @@ class FlowrAnalyzerCache extends flowr_cache_1.FlowrCache {
65
74
  while ((g = until()) === undefined && this.pipeline.hasNextStep()) {
66
75
  await this.pipeline.nextStep();
67
76
  }
77
+ this.storeIncrementalSnapshotIfAvailable();
68
78
  (0, assert_1.guard)(g !== undefined, 'Could not reach the desired pipeline step, invalid cache state(?)');
69
79
  return g;
70
80
  }
81
+ storeIncrementalSnapshotIfAvailable() {
82
+ if (this.args.parser.name !== 'tree-sitter') {
83
+ return;
84
+ }
85
+ const parse = this.peekParse();
86
+ if (isTreeSitterParse(parse)) {
87
+ this.args.context.inc.storeOldParseResults(parse);
88
+ }
89
+ }
71
90
  /**
72
91
  * Get the parse output for the request, parsing if necessary.
73
92
  * @param force - Do not use the cache, instead force a new parse.
@@ -83,7 +102,7 @@ class FlowrAnalyzerCache extends flowr_cache_1.FlowrCache {
83
102
  * @see {@link FlowrAnalyzerCache#parse} - to get the parse output, parsing if necessary.
84
103
  */
85
104
  peekParse() {
86
- return this.get().parse;
105
+ return this.get()?.parse;
87
106
  }
88
107
  /**
89
108
  * Get the normalized abstract syntax tree for the request, normalizing if necessary.
@@ -100,7 +119,7 @@ class FlowrAnalyzerCache extends flowr_cache_1.FlowrCache {
100
119
  * @see {@link FlowrAnalyzerCache#normalize} - to get the normalized AST, normalizing if necessary.
101
120
  */
102
121
  peekNormalize() {
103
- return this.get().normalize;
122
+ return this.get()?.normalize;
104
123
  }
105
124
  /**
106
125
  * Get the dataflow graph for the request, computing if necessary.
@@ -117,7 +136,7 @@ class FlowrAnalyzerCache extends flowr_cache_1.FlowrCache {
117
136
  * @see {@link FlowrAnalyzerCache#dataflow} - to get the dataflow graph, computing if necessary.
118
137
  */
119
138
  peekDataflow() {
120
- return this.get().dataflow;
139
+ return this.get()?.dataflow;
121
140
  }
122
141
  /**
123
142
  * Get the control flow graph (CFG) for the request, computing if necessary.
@@ -1,25 +1,52 @@
1
- export declare const enum CacheInvalidationEventType {
2
- Full = "full"
1
+ import type { StringableContent } from '../context/flowr-file';
2
+ /**
3
+ * Invalidation events describe how the cached analyzer state became stale.
4
+ *
5
+ * The current codebase triggers these events in two main ways:
6
+ * - {@link InvalidationEventType.Full}: emitted by explicit reset flows such as
7
+ * {@link FlowrAnalyzerContext#reset} or {@link FlowrAnalyzerCache#reset}. Use this
8
+ * when the whole project state should be treated as stale.
9
+ * - {@link InvalidationEventType.SingleFileInvalidate}: emitted by
10
+ * {@link FlowrFile#invalidate}, including {@link FlowrInlineTextFile#updateInlineContent},
11
+ * when one known file changed.
12
+ */
13
+ export declare const enum InvalidationEventType {
14
+ Full = "full",
15
+ SingleFileInvalidate = "single-file-invalidate"
16
+ }
17
+ /**
18
+ * Invalidation event for a single file identified by {@link filePath}.
19
+ *
20
+ * {@link oldContent} contains the file content from immediately before the
21
+ * change that triggered this event. In other words, it is the pre-change content
22
+ * for this invalidation, not necessarily the content from the last completed
23
+ * analysis run.
24
+ */
25
+ export interface SingleFileInvalidationEvent<Content extends StringableContent = StringableContent> {
26
+ readonly type: InvalidationEventType.SingleFileInvalidate;
27
+ readonly oldContent: Content | undefined;
28
+ readonly filePath: string;
3
29
  }
4
- export type CacheInvalidationEvent = {
5
- type: CacheInvalidationEventType.Full;
6
- };
7
- export interface CacheInvalidationEventReceiver {
8
- receive(event: CacheInvalidationEvent): void;
30
+ export type InvalidationEvent<Content extends StringableContent = StringableContent> = {
31
+ type: InvalidationEventType.Full;
32
+ } | SingleFileInvalidationEvent<Content>;
33
+ export type InvalidationEventHandler<Content extends StringableContent = StringableContent> = (event: InvalidationEvent<Content>) => void;
34
+ export interface InvalidationEventReceiver<Content extends StringableContent = StringableContent> {
35
+ receive: InvalidationEventHandler<Content>;
9
36
  }
10
37
  /**
11
38
  * Central class for caching analysis results in FlowR.
12
39
  */
13
- export declare abstract class FlowrCache<Cache> implements CacheInvalidationEventReceiver {
40
+ export declare abstract class FlowrCache<Cache> implements InvalidationEventReceiver {
14
41
  private value;
15
42
  private dependents;
16
- registerDependent(dependent: CacheInvalidationEventReceiver): void;
17
- removeDependent(dependent: CacheInvalidationEventReceiver): void;
18
- receive(event: CacheInvalidationEvent): void;
43
+ registerDependent(dependent: InvalidationEventReceiver): void;
44
+ removeDependent(dependent: InvalidationEventReceiver): void;
45
+ receive(event: InvalidationEvent): void;
19
46
  /**
20
47
  * Notify all dependents of a cache invalidation event.
21
48
  */
22
- notifyDependents(event: CacheInvalidationEvent): void;
49
+ notifyDependents(event: InvalidationEvent): void;
23
50
  /**
24
51
  * Get the cached value or compute it if not present.
25
52
  * This will, by default, not trigger any {@link notifyDependents} calls, as this is only a cache retrieval.
@@ -15,13 +15,15 @@ class FlowrCache {
15
15
  this.dependents = this.dependents.filter(d => d !== dependent);
16
16
  }
17
17
  receive(event) {
18
+ const type = event.type;
18
19
  /* we will update this as soon as we support incremental update patterns */
19
- switch (event.type) {
20
- case "full" /* CacheInvalidationEventType.Full */:
20
+ switch (type) {
21
+ case "full" /* InvalidationEventType.Full */:
22
+ case "single-file-invalidate" /* InvalidationEventType.SingleFileInvalidate */:
21
23
  this.value = undefined;
22
24
  break;
23
25
  default:
24
- (0, assert_1.assertUnreachable)(event.type);
26
+ (0, assert_1.assertUnreachable)(type);
25
27
  }
26
28
  /* in the future we want to defer this *after* the dataflow is re-computed, then all receivers can decide whether they need to update */
27
29
  this.notifyDependents(event);
@@ -12,6 +12,9 @@ import { FlowrAnalyzerEnvironmentContext } from './flowr-analyzer-environment-co
12
12
  import type { ReadOnlyFlowrAnalyzerMetaContext } from './flowr-analyzer-meta-context';
13
13
  import { FlowrAnalyzerMetaContext } from './flowr-analyzer-meta-context';
14
14
  import type { FlowrAnalyzer } from '../flowr-analyzer';
15
+ import type { ReadOnlyFlowrAnalyzerIncrementalAnalysisContext } from './flowr-analyzer-incremental-analysis-context';
16
+ import { FlowrAnalyzerIncrementalAnalysisContext } from './flowr-analyzer-incremental-analysis-context';
17
+ import type { InvalidationEvent, InvalidationEventReceiver } from '../cache/flowr-cache';
15
18
  import { FlowrAnalyzerGasContext, type ReadOnlyFlowrAnalyzerGasContext } from './flowr-analyzer-gas-context';
16
19
  /**
17
20
  * This is a read-only interface to the {@link FlowrAnalyzerContext}.
@@ -27,6 +30,8 @@ export interface ReadOnlyFlowrAnalyzerContext {
27
30
  readonly deps: ReadOnlyFlowrAnalyzerDependenciesContext;
28
31
  /** Environment information used during analysis. */
29
32
  readonly env: ReadOnlyFlowrAnalyzerEnvironmentContext;
33
+ /** The incremental context provides potential information for the next incremental analysis run */
34
+ readonly inc: ReadOnlyFlowrAnalyzerIncrementalAnalysisContext;
30
35
  /** The configuration options used by the analyzer. */
31
36
  readonly config: FlowrConfig;
32
37
  /** class names of plugins that activated (produced a result) since the last reset; only filled when `config.repl.showPlugins` is set */
@@ -63,11 +68,12 @@ export interface ReadOnlyFlowrAnalyzerContext {
63
68
  * {@link deps.getDependency}.
64
69
  * If you are just interested in inspecting the context, you can use {@link ReadOnlyFlowrAnalyzerContext} instead (e.g., via {@link inspect}).
65
70
  */
66
- export declare class FlowrAnalyzerContext implements ReadOnlyFlowrAnalyzerContext {
71
+ export declare class FlowrAnalyzerContext implements ReadOnlyFlowrAnalyzerContext, InvalidationEventReceiver {
67
72
  readonly meta: FlowrAnalyzerMetaContext;
68
73
  readonly files: FlowrAnalyzerFilesContext;
69
74
  readonly deps: FlowrAnalyzerDependenciesContext;
70
75
  readonly env: FlowrAnalyzerEnvironmentContext;
76
+ readonly inc: FlowrAnalyzerIncrementalAnalysisContext;
71
77
  /** class names of plugins that activated since the last reset; only filled when `config.repl.showPlugins` is set */
72
78
  readonly activatedPlugins: Set<string>;
73
79
  readonly gas: FlowrAnalyzerGasContext;
@@ -143,6 +149,7 @@ export declare class FlowrAnalyzerContext implements ReadOnlyFlowrAnalyzerContex
143
149
  * Reset the context to its initial state, e.g., removing all files, dependencies, and loading orders.
144
150
  */
145
151
  reset(): void;
152
+ receive(event: InvalidationEvent): void;
146
153
  }
147
154
  /**
148
155
  * Lifting {@link requestFromInput} to create a full {@link FlowrAnalyzerContext} from input requests.
@@ -16,6 +16,7 @@ const log_1 = require("../../util/log");
16
16
  const flowr_file_1 = require("./flowr-file");
17
17
  const flowr_analyzer_environment_context_1 = require("./flowr-analyzer-environment-context");
18
18
  const flowr_analyzer_meta_context_1 = require("./flowr-analyzer-meta-context");
19
+ const flowr_analyzer_incremental_analysis_context_1 = require("./flowr-analyzer-incremental-analysis-context");
19
20
  const flowr_analyzer_gas_context_1 = require("./flowr-analyzer-gas-context");
20
21
  /**
21
22
  * This summarizes the other context layers used by the {@link FlowrAnalyzer}.
@@ -33,6 +34,7 @@ class FlowrAnalyzerContext {
33
34
  files;
34
35
  deps;
35
36
  env;
37
+ inc;
36
38
  /** class names of plugins that activated since the last reset; only filled when `config.repl.showPlugins` is set */
37
39
  activatedPlugins = new Set();
38
40
  gas;
@@ -143,8 +145,9 @@ class FlowrAnalyzerContext {
143
145
  this.baseConfig = config;
144
146
  this._config = config;
145
147
  const loadingOrder = new flowr_analyzer_loading_order_context_1.FlowrAnalyzerLoadingOrderContext(this, plugins.get(flowr_analyzer_plugin_1.PluginType.LoadingOrder));
146
- 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) ?? []));
148
+ this.files = new flowr_analyzer_files_context_1.FlowrAnalyzerFilesContext(this, loadingOrder, (plugins.get(flowr_analyzer_plugin_1.PluginType.ProjectDiscovery) ?? []), (plugins.get(flowr_analyzer_plugin_1.PluginType.FileLoad) ?? []));
147
149
  this.env = new flowr_analyzer_environment_context_1.FlowrAnalyzerEnvironmentContext(this);
150
+ this.inc = new flowr_analyzer_incremental_analysis_context_1.FlowrAnalyzerIncrementalAnalysisContext(this);
148
151
  const functions = new flowr_analyzer_functions_context_1.FlowrAnalyzerFunctionsContext(this);
149
152
  this.deps = new flowr_analyzer_dependencies_context_1.FlowrAnalyzerDependenciesContext(functions, (plugins.get(flowr_analyzer_plugin_1.PluginType.DependencyIdentification) ?? []));
150
153
  // the plugins contributing the metadata are the ones the dependency context runs on demand
@@ -212,6 +215,13 @@ class FlowrAnalyzerContext {
212
215
  this.meta.reset();
213
216
  this.gas.reset();
214
217
  this.activatedPlugins.clear();
218
+ this.receive({ type: "full" /* InvalidationEventType.Full */ });
219
+ }
220
+ receive(event) {
221
+ this.meta.receive(event);
222
+ this.files.receive(event);
223
+ this.deps.receive(event);
224
+ this.inc.receive(event);
215
225
  }
216
226
  }
217
227
  exports.FlowrAnalyzerContext = FlowrAnalyzerContext;
@@ -6,6 +6,7 @@ import { Identifier } from '../../dataflow/environments/identifier';
6
6
  import type { DecodedFunction } from '../sigdb/decode';
7
7
  import type { Range } from 'semver';
8
8
  import type { FlowrAnalyzerFunctionsContext, ReadOnlyFlowrAnalyzerFunctionsContext } from './flowr-analyzer-functions-context';
9
+ import type { InvalidationEvent, InvalidationEventReceiver } from '../cache/flowr-cache';
9
10
  /**
10
11
  * Read-only interface to the {@link FlowrAnalyzerDependenciesContext} for inspecting dependencies without modifying them.
11
12
  */
@@ -84,10 +85,12 @@ export interface ReadOnlyFlowrAnalyzerDependenciesContext {
84
85
  /**
85
86
  * Manages the project's dependencies, their versions, and their interplay with {@link FlowrAnalyzerPackageVersionsPlugin}s.
86
87
  */
87
- export declare class FlowrAnalyzerDependenciesContext extends AbstractFlowrAnalyzerContext<undefined, void, FlowrAnalyzerPackageVersionsPlugin> implements ReadOnlyFlowrAnalyzerDependenciesContext {
88
+ export declare class FlowrAnalyzerDependenciesContext extends AbstractFlowrAnalyzerContext<undefined, void, FlowrAnalyzerPackageVersionsPlugin> implements ReadOnlyFlowrAnalyzerDependenciesContext, InvalidationEventReceiver {
88
89
  readonly name = "flowr-analyzer-dependencies-context";
89
90
  readonly functionsContext: FlowrAnalyzerFunctionsContext;
90
91
  private dependencies;
92
+ /** what {@link getDependency} resolved for a package the project does not depend on, so a lookup never makes it one */
93
+ private resolvedOnly;
91
94
  private staticsLoaded;
92
95
  /** resolvers consulted lazily to fill in exports; `existing` carries version info from other plugins */
93
96
  private lazyResolvers;
@@ -109,12 +112,13 @@ export declare class FlowrAnalyzerDependenciesContext extends AbstractFlowrAnaly
109
112
  addDatabaseSource(source: string): Promise<void>;
110
113
  /** Eagerly mount every version plugin's signature database up front (see `solver.sigdb.eagerlyLoad`). */
111
114
  eagerlyLoadSignatureDatabases(): void;
115
+ receive(event: InvalidationEvent): void;
112
116
  constructor(functionsContext: FlowrAnalyzerFunctionsContext, plugins?: readonly FlowrAnalyzerPackageVersionsPlugin[]);
113
117
  resolveStaticDependencies(): void;
114
118
  /** Runs the static plugins once. They fill this context and the project metadata, so both gate their reads on it. */
115
119
  ensureStaticsLoaded(): void;
116
120
  /**
117
- * Register a dependency declared by a project metadata file (`DESCRIPTION`, `renv.lock`, `rv.lock`). Gated by
121
+ * Register a dependency declared by a project metadata file (`DESCRIPTION`, `renv.lock`, `rv.lock`, `uvr.lock`). Gated by
118
122
  * `solver.sigdb.loadProjectDependencies`: when project-dependency loading is disabled this is a no-op, so the
119
123
  * declared deps never enter the context (unlike {@link addDependency}, used for on-demand signature-database
120
124
  * resolution).
@@ -122,6 +126,8 @@ export declare class FlowrAnalyzerDependenciesContext extends AbstractFlowrAnaly
122
126
  addDeclaredDependency(pkg: Package): this;
123
127
  addDependency(pkg: Package): this;
124
128
  getDependency(name: string, version?: string | Range): Package | undefined;
129
+ /** Like {@link getDependency}, but for a package the code pulls in (`library(p)`): the result joins the project's {@link getDependencies|dependencies}. */
130
+ loadDependency(name: string): Package | undefined;
125
131
  /** Resolve `name` constrained to `range` via the plugins (uncached); falls back to the cached dependency. */
126
132
  private resolvePinnedDependency;
127
133
  inferredRange(name: string): Range | undefined;
@@ -5,6 +5,7 @@ const abstract_flowr_analyzer_context_1 = require("./abstract-flowr-analyzer-con
5
5
  const flowr_analyzer_package_versions_plugin_1 = require("../plugins/package-version-plugins/flowr-analyzer-package-versions-plugin");
6
6
  const package_1 = require("../plugins/package-version-plugins/package");
7
7
  const identifier_1 = require("../../dataflow/environments/identifier");
8
+ const assert_1 = require("../../util/assert");
8
9
  const config_1 = require("../../config");
9
10
  const r_version_1 = require("../../util/r-version");
10
11
  /**
@@ -14,12 +15,15 @@ class FlowrAnalyzerDependenciesContext extends abstract_flowr_analyzer_context_1
14
15
  name = 'flowr-analyzer-dependencies-context';
15
16
  functionsContext;
16
17
  dependencies = new Map();
18
+ /** what {@link getDependency} resolved for a package the project does not depend on, so a lookup never makes it one */
19
+ resolvedOnly = new Map();
17
20
  staticsLoaded = false;
18
21
  /** resolvers consulted lazily to fill in exports; `existing` carries version info from other plugins */
19
22
  lazyResolvers = [];
20
23
  resolvedMisses = new Set();
21
24
  reset() {
22
25
  this.dependencies = new Map();
26
+ this.resolvedOnly = new Map();
23
27
  this.staticsLoaded = false;
24
28
  this.lazyResolvers = [];
25
29
  this.resolvedMisses = new Set();
@@ -101,6 +105,19 @@ class FlowrAnalyzerDependenciesContext extends abstract_flowr_analyzer_context_1
101
105
  p.preloadDatabasesSync();
102
106
  }
103
107
  }
108
+ receive(event) {
109
+ const type = event.type;
110
+ switch (type) {
111
+ case "full" /* InvalidationEventType.Full */:
112
+ this.reset();
113
+ break;
114
+ case "single-file-invalidate" /* InvalidationEventType.SingleFileInvalidate */:
115
+ // nothing to do
116
+ break;
117
+ default:
118
+ (0, assert_1.assertUnreachable)(type);
119
+ }
120
+ }
104
121
  constructor(functionsContext, plugins) {
105
122
  super(functionsContext.getAttachedContext(), flowr_analyzer_package_versions_plugin_1.FlowrAnalyzerPackageVersionsPlugin.defaultPlugin(), plugins);
106
123
  this.functionsContext = functionsContext;
@@ -116,7 +133,7 @@ class FlowrAnalyzerDependenciesContext extends abstract_flowr_analyzer_context_1
116
133
  }
117
134
  }
118
135
  /**
119
- * Register a dependency declared by a project metadata file (`DESCRIPTION`, `renv.lock`, `rv.lock`). Gated by
136
+ * Register a dependency declared by a project metadata file (`DESCRIPTION`, `renv.lock`, `rv.lock`, `uvr.lock`). Gated by
120
137
  * `solver.sigdb.loadProjectDependencies`: when project-dependency loading is disabled this is a no-op, so the
121
138
  * declared deps never enter the context (unlike {@link addDependency}, used for on-demand signature-database
122
139
  * resolution).
@@ -128,13 +145,7 @@ class FlowrAnalyzerDependenciesContext extends abstract_flowr_analyzer_context_1
128
145
  return this.addDependency(pkg);
129
146
  }
130
147
  addDependency(pkg) {
131
- const p = this.dependencies.get(pkg.name);
132
- if (p) {
133
- p.mergeInPlace(pkg);
134
- }
135
- else {
136
- this.dependencies.set(pkg.name, pkg);
137
- }
148
+ mergeIntoMap(this.dependencies, pkg);
138
149
  return this;
139
150
  }
140
151
  getDependency(name, version) {
@@ -144,7 +155,7 @@ class FlowrAnalyzerDependenciesContext extends abstract_flowr_analyzer_context_1
144
155
  if (version !== undefined) {
145
156
  return this.resolvePinnedDependency(name, typeof version === 'string' ? r_version_1.RRange.parse('=' + version) : version);
146
157
  }
147
- const existing = this.dependencies.get(name);
158
+ const existing = this.dependencies.get(name) ?? this.resolvedOnly.get(name);
148
159
  // a package already carrying exports is complete; a version-only one is still enriched below
149
160
  if (existing?.namespaceInfo || (!existing && this.resolvedMisses.has(name))) {
150
161
  return existing;
@@ -153,14 +164,26 @@ class FlowrAnalyzerDependenciesContext extends abstract_flowr_analyzer_context_1
153
164
  for (const resolve of this.lazyResolvers) {
154
165
  const resolved = resolve(name, existing);
155
166
  if (resolved) {
156
- this.addDependency(resolved); // merges exports into any existing version info
157
- return this.dependencies.get(name);
167
+ // merges exports into any existing version info, of a dependency or of a mere lookup
168
+ const into = this.dependencies.has(name) ? this.dependencies : this.resolvedOnly;
169
+ mergeIntoMap(into, resolved);
170
+ return into.get(name);
158
171
  }
159
172
  }
160
173
  this.resolvedMisses.add(name);
161
174
  }
162
175
  return existing;
163
176
  }
177
+ /** Like {@link getDependency}, but for a package the code pulls in (`library(p)`): the result joins the project's {@link getDependencies|dependencies}. */
178
+ loadDependency(name) {
179
+ const found = this.getDependency(name);
180
+ const cached = this.resolvedOnly.get(name);
181
+ if (cached !== undefined) {
182
+ this.resolvedOnly.delete(name);
183
+ mergeIntoMap(this.dependencies, cached);
184
+ }
185
+ return this.dependencies.get(name) ?? found;
186
+ }
164
187
  /** Resolve `name` constrained to `range` via the plugins (uncached); falls back to the cached dependency. */
165
188
  resolvePinnedDependency(name, range) {
166
189
  const pin = new package_1.Package({ name, versionConstraints: range ? [range] : [] });
@@ -189,4 +212,13 @@ class FlowrAnalyzerDependenciesContext extends abstract_flowr_analyzer_context_1
189
212
  }
190
213
  }
191
214
  exports.FlowrAnalyzerDependenciesContext = FlowrAnalyzerDependenciesContext;
215
+ function mergeIntoMap(map, pkg) {
216
+ const existing = map.get(pkg.name);
217
+ if (existing) {
218
+ existing.mergeInPlace(pkg);
219
+ }
220
+ else {
221
+ map.set(pkg.name, pkg);
222
+ }
223
+ }
192
224
  //# sourceMappingURL=flowr-analyzer-dependencies-context.js.map