@eagleoutice/flowr 2.13.1 → 2.13.3

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 (158) hide show
  1. package/README.md +46 -44
  2. package/abstract-interpretation/data-frame/mappers/access-mapper.js +1 -0
  3. package/abstract-interpretation/data-frame/mappers/function-mapper.d.ts +1 -1
  4. package/abstract-interpretation/data-frame/mappers/function-mapper.js +3 -0
  5. package/abstract-interpretation/domains/state-domain-like.d.ts +1 -1
  6. package/cli/flowr.js +21 -5
  7. package/cli/repl/commands/repl-commands.js +11 -9
  8. package/cli/repl/commands/repl-query.js +1 -1
  9. package/cli/repl/commands/repl-signature.js +8 -1
  10. package/cli/repl/core.js +13 -10
  11. package/cli/repl/print-version.js +1 -1
  12. package/cli/repl/server/connection.d.ts +1 -1
  13. package/cli/repl/server/net.js +15 -0
  14. package/config.d.ts +37 -0
  15. package/config.js +63 -3
  16. package/control-flow/control-flow-graph.js +2 -1
  17. package/control-flow/semantic-cfg-guided-visitor.d.ts +1 -1
  18. package/core/steps/all/core/11-normalize-tree-sitter.d.ts +1 -1
  19. package/data/sigdb/sigdb.remote.json +1 -1
  20. package/dataflow/environments/append.d.ts +1 -1
  21. package/dataflow/environments/clone.d.ts +1 -1
  22. package/dataflow/environments/environment.d.ts +28 -4
  23. package/dataflow/environments/environment.js +66 -11
  24. package/dataflow/environments/identifier.d.ts +9 -8
  25. package/dataflow/environments/identifier.js +21 -13
  26. package/dataflow/environments/overwrite.d.ts +1 -1
  27. package/dataflow/eval/resolve/alias-tracking.d.ts +1 -1
  28. package/dataflow/eval/resolve/resolve-working-directory.d.ts +29 -0
  29. package/dataflow/eval/resolve/resolve-working-directory.js +168 -0
  30. package/dataflow/extractor.js +2 -1
  31. package/dataflow/graph/dataflowgraph-builder.d.ts +1 -1
  32. package/dataflow/graph/df-helper.d.ts +3 -2
  33. package/dataflow/graph/df-helper.js +11 -15
  34. package/dataflow/graph/diff-dataflow-graph.js +1 -1
  35. package/dataflow/graph/graph-helper.js +2 -6
  36. package/dataflow/graph/graph.d.ts +24 -0
  37. package/dataflow/graph/graph.js +25 -1
  38. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +1 -1
  39. package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +1 -1
  40. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +7 -0
  41. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +51 -0
  42. package/dataflow/internal/process/functions/call/built-in/built-in-eval.d.ts +1 -1
  43. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +1 -1
  44. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +1 -1
  45. package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +5 -2
  46. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +15 -9
  47. package/dataflow/internal/process/functions/call/built-in/built-in-list.d.ts +1 -1
  48. package/dataflow/internal/process/functions/call/built-in/built-in-quote.d.ts +1 -1
  49. package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.d.ts +1 -1
  50. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-dispatch.d.ts +1 -1
  51. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +7 -1
  52. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +9 -2
  53. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -1
  54. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +2 -2
  55. package/dataflow/internal/process/functions/call/built-in/built-in-vector.d.ts +1 -1
  56. package/documentation/doc-readme.js +14 -12
  57. package/documentation/doc-util/doc-normalized-ast.d.ts +1 -1
  58. package/documentation/wiki-dataflow-graph.js +4 -24
  59. package/documentation/wiki-linter.js +1 -0
  60. package/documentation/wiki-mk/doc-context.d.ts +10 -0
  61. package/documentation/wiki-mk/doc-context.js +3 -0
  62. package/documentation/wiki-query.js +47 -0
  63. package/documentation/wiki-signature-database.js +18 -7
  64. package/linter/linter-rules.d.ts +24 -2
  65. package/linter/linter-rules.js +3 -1
  66. package/linter/rules/absolute-path.d.ts +4 -4
  67. package/linter/rules/absolute-path.js +7 -5
  68. package/linter/rules/dataframe-access-validation.d.ts +1 -1
  69. package/linter/rules/file-path-validity.d.ts +1 -1
  70. package/linter/rules/file-path-validity.js +48 -8
  71. package/linter/rules/function-finder-util.d.ts +2 -1
  72. package/linter/rules/syntactically-valid.d.ts +58 -0
  73. package/linter/rules/syntactically-valid.js +203 -0
  74. package/linter/rules/undefined-symbol-util.js +3 -1
  75. package/linter/rules/undefined-symbol.js +6 -6
  76. package/package.json +25 -12
  77. package/project/context/classify-project-kind.d.ts +40 -0
  78. package/project/context/classify-project-kind.js +76 -0
  79. package/project/context/flowr-analyzer-context.d.ts +4 -4
  80. package/project/context/flowr-analyzer-context.js +3 -3
  81. package/project/context/flowr-analyzer-dependencies-context.d.ts +34 -9
  82. package/project/context/flowr-analyzer-dependencies-context.js +30 -3
  83. package/project/context/flowr-analyzer-files-context.d.ts +10 -8
  84. package/project/context/flowr-analyzer-files-context.js +26 -67
  85. package/project/context/flowr-analyzer-meta-context.d.ts +1 -0
  86. package/project/context/flowr-file.d.ts +5 -0
  87. package/project/context/flowr-file.js +5 -0
  88. package/project/dependency-version-space.d.ts +118 -26
  89. package/project/dependency-version-space.js +343 -87
  90. package/project/plugins/file-plugins/files/flowr-description-file.d.ts +4 -0
  91. package/project/plugins/file-plugins/files/flowr-description-file.js +8 -1
  92. package/project/plugins/file-plugins/files/flowr-rda-file.js +27 -25
  93. package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.d.ts +12 -4
  94. package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.js +25 -10
  95. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.d.ts +1 -1
  96. package/project/plugins/file-plugins/notebooks/flowr-analyzer-sweave-file-plugin.d.ts +1 -1
  97. package/project/plugins/package-version-plugins/flowr-analyzer-meta-description-file-plugin.js +2 -1
  98. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +1 -1
  99. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +4 -4
  100. package/project/plugins/package-version-plugins/package.d.ts +27 -10
  101. package/project/plugins/package-version-plugins/package.js +50 -25
  102. package/project/plugins/plugin-registry.d.ts +2 -1
  103. package/project/plugins/plugin-registry.js +4 -1
  104. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.d.ts +57 -2
  105. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +150 -28
  106. package/project/sigdb/decompress.d.ts +1 -1
  107. package/project/sigdb/decompress.js +4 -1
  108. package/project/sigdb/manifest.js +60 -26
  109. package/project/sigdb/reader.d.ts +26 -16
  110. package/project/sigdb/reader.js +52 -21
  111. package/project/sigdb/sigdb-download.d.ts +6 -7
  112. package/project/sigdb/sigdb-download.js +30 -9
  113. package/queries/catalog/dependencies-query/dependencies-query-executor.js +1 -1
  114. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +2 -12
  115. package/queries/catalog/dependencies-query/dependencies-query-format.js +2 -108
  116. package/queries/catalog/does-call-query/does-call-query-format.d.ts +1 -1
  117. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +39 -77
  118. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +12 -0
  119. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +54 -24
  120. package/queries/catalog/input-sources-query/input-source-functions.d.ts +13 -0
  121. package/queries/catalog/input-sources-query/input-source-functions.js +96 -1
  122. package/queries/catalog/input-sources-query/input-sources-query-executor.js +40 -4
  123. package/queries/catalog/input-sources-query/input-sources-query-format.js +21 -3
  124. package/queries/catalog/input-sources-query/input-types.d.ts +58 -0
  125. package/queries/catalog/input-sources-query/input-types.js +64 -0
  126. package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +62 -52
  127. package/queries/catalog/input-sources-query/simple-input-classifier.js +334 -101
  128. package/queries/catalog/linter-query/linter-query-format.js +9 -2
  129. package/queries/catalog/project-query/project-query-executor.js +1 -1
  130. package/queries/catalog/signature-query/signature-query-executor.d.ts +7 -1
  131. package/queries/catalog/signature-query/signature-query-executor.js +115 -39
  132. package/queries/catalog/signature-query/signature-query-format.d.ts +5 -1
  133. package/queries/catalog/signature-query/signature-query-format.js +1 -1
  134. package/queries/catalog/signature-query/signature-query-render.js +12 -7
  135. package/queries/query.js +9 -2
  136. package/r-bridge/data/data.d.ts +5 -0
  137. package/r-bridge/data/data.js +6 -0
  138. package/r-bridge/lang-4.x/ast/parser/json/format.js +1 -1
  139. package/r-bridge/retriever.d.ts +1 -1
  140. package/r-bridge/retriever.js +6 -1
  141. package/r-bridge/shell.js +5 -0
  142. package/search/flowr-search-filters.d.ts +2 -1
  143. package/search/flowr-search-printer.js +10 -8
  144. package/slicing/static/static-slicer.d.ts +2 -2
  145. package/util/files.d.ts +6 -4
  146. package/util/files.js +30 -8
  147. package/util/mermaid/dfg.js +1 -1
  148. package/util/objects.js +6 -4
  149. package/util/r-base-packages.d.ts +2 -0
  150. package/util/r-base-packages.js +3 -0
  151. package/util/r-license.js +1 -4
  152. package/util/r-version.d.ts +12 -0
  153. package/util/r-version.js +16 -0
  154. package/util/range.d.ts +6 -2
  155. package/util/range.js +33 -15
  156. package/util/text/ansi.d.ts +7 -3
  157. package/util/text/ansi.js +8 -5
  158. package/util/version.js +4 -4
@@ -4,7 +4,6 @@ exports.executeGuessDepVersionsQuery = executeGuessDepVersionsQuery;
4
4
  const guess_dep_versions_query_format_1 = require("./guess-dep-versions-query-format");
5
5
  const r_version_1 = require("../../../util/r-version");
6
6
  const objects_1 = require("../../../util/objects");
7
- const reader_1 = require("../../../project/sigdb/reader");
8
7
  const dependency_version_space_1 = require("../../../project/dependency-version-space");
9
8
  /** the sources `query` disables: `clean` is sugar for disabling `declared`+`transitive`, `disabled` adds any others by name */
10
9
  function disabledSources(query) {
@@ -100,7 +99,7 @@ function rangeString(survivors, nonContiguous, unsatisfiable, declaredRange, dec
100
99
  return survivors.length <= cap ? survivors.join(', ') : `${min}...${max} (${survivors.length} discrete)`;
101
100
  }
102
101
  /** build the reported guess for one package from its already-computed surviving versions and provenance */
103
- function guessPackage(name, cap, surviving, evidence, used, linkedWith) {
102
+ function guessPackage(name, cap, surviving, evidence, { used, linkedWith, coupledWith }) {
104
103
  const { declaredRange, declaredConstraints, unsatisfiable } = surviving;
105
104
  const survivors = surviving.survivors.map(e => e.ver);
106
105
  const preSignature = surviving.preSignature.map(e => e.ver);
@@ -121,6 +120,7 @@ function guessPackage(name, cap, surviving, evidence, used, linkedWith) {
121
120
  evidence: evidence.list,
122
121
  unsatisfiable: unsatisfiable ? true : undefined,
123
122
  linkedWith: linkedWith && linkedWith.length > 0 ? linkedWith : undefined,
123
+ coupledWith: coupledWith && coupledWith.length > 0 ? coupledWith : undefined,
124
124
  used
125
125
  });
126
126
  }
@@ -154,57 +154,23 @@ async function executeGuessDepVersionsQuery({ analyzer }, queries) {
154
154
  // the analyzed package guesses versions for its dependencies, not for itself
155
155
  const self = ctx.meta.getNamespace();
156
156
  const sorted = (query.packages && query.packages.length > 0 ? [...query.packages] : (0, dependency_version_space_1.defaultTargets)(deps, usage)).filter(name => name !== self).sort();
157
- // resolve (and cache) each target's timeline package key + merged source once, reused across both guess passes
158
- const sourceByName = new Map();
159
- const sourceFor = (name) => {
160
- let entry = sourceByName.get(name);
161
- if (entry === undefined) {
162
- const key = (0, dependency_version_space_1.timelinePackageKey)(name, sources);
163
- entry = { key, src: (0, reader_1.sourceForPackage)(sources, key) };
164
- sourceByName.set(name, entry);
165
- }
166
- return entry;
167
- };
168
157
  const disabled = disabledSources(query);
169
- // the guessed lower bound of every target under a set of transitive constraints (drives the mutual-constraint refinement)
170
- const guessLowerBounds = (trans) => {
171
- const out = new Map();
172
- for (const name of sorted) {
173
- const { key, src } = sourceFor(name);
174
- const s = (0, dependency_version_space_1.survivingEntries)(name, src, deps, usage.get(name), trans.get(name) ?? [], cutoff, rVersion, undefined, disabled, key);
175
- if (s.survivors.length > 0) {
176
- out.set(name, s.survivors[0].ver);
177
- }
178
- }
179
- return out;
180
- };
158
+ const space = new dependency_version_space_1.VersionSpace({ deps, usage, cutoff, rVersion, disabled });
181
159
  const maxIterations = query.maxIterations ?? dependency_version_space_1.DefaultFixpointIterations;
182
- let transitive = (0, dependency_version_space_1.collectTransitiveConstraints)(deps, sources);
183
- if (!disabled.has('transitive')) {
184
- let prev = '';
185
- (0, dependency_version_space_1.iterateToFixpoint)(maxIterations, () => {
186
- const pass = guessLowerBounds(transitive);
187
- const signature = Array.from(pass, ([k, v]) => `${k}=${v}`).sort().join(',');
188
- if (signature === prev) {
189
- return false;
190
- }
191
- prev = signature;
192
- transitive = (0, dependency_version_space_1.collectTransitiveConstraints)(deps, sources, name => pass.get(name));
193
- return true;
194
- });
195
- }
160
+ const transitive = space.refineTransitive(sorted, maxIterations);
196
161
  const cap = query.maxCandidates ?? guess_dep_versions_query_format_1.DefaultCandidateCap;
197
162
  const explodeOrder = query.explode?.order ?? 'newest';
198
163
  const guessedAll = sorted.map(name => {
199
- const { key, src } = sourceFor(name);
200
164
  const evidence = new EvidenceCollector();
201
- const surviving = (0, dependency_version_space_1.survivingEntries)(name, src, deps, usage.get(name), transitive.get(name) ?? [], cutoff, rVersion, evidence.add, disabled, key);
202
- return { name, src, key, evidence, surviving };
165
+ const surviving = space.survivors(name, transitive.get(name) ?? [], evidence.add);
166
+ return { name, evidence, surviving };
203
167
  });
204
- const arcEntries = guessedAll.map(g => ({ name: g.name, src: g.src, key: g.key, survivors: g.surviving.survivors }));
205
- const blockers = query.clean || disabled.has('indirect') ? new Map() : (0, dependency_version_space_1.enforceArcConsistency)(arcEntries, maxIterations);
206
- guessedAll.forEach((g, i) => {
207
- g.surviving = { ...g.surviving, survivors: arcEntries[i].survivors };
168
+ const initial = new Map(guessedAll.map(g => [g.name, g.surviving.survivors]));
169
+ const { survivors: pruned, blockers } = query.clean || disabled.has('indirect')
170
+ ? { survivors: initial, blockers: new Map() }
171
+ : (0, dependency_version_space_1.enforceArcConsistency)(space, initial, maxIterations);
172
+ guessedAll.forEach(g => {
173
+ g.surviving = { ...g.surviving, survivors: pruned.get(g.name) ?? g.surviving.survivors };
208
174
  const max = g.surviving.survivors.at(-1)?.ver;
209
175
  for (const [partner, constraint] of blockers.get(g.name) ?? []) {
210
176
  if (max !== undefined) {
@@ -232,44 +198,39 @@ async function executeGuessDepVersionsQuery({ analyzer }, queries) {
232
198
  }
233
199
  }
234
200
  }
235
- // runnable combinations: the base/R group is the shared hub every other constrained package is counted against
236
- const grouped = new Set(linkedGroups.flat());
237
- const factorOf = (g) => ({ name: g.name, src: g.src, key: g.key, survivors: g.surviving.survivors.map(e => e.ver) });
238
- let hub, hubTotal = 1, othersTotal = 1;
239
- const others = [];
240
- for (const group of linkedGroups) {
241
- const rep = guessedAll.find(g => group.includes(g.name));
242
- if (rep === undefined) {
243
- continue;
244
- }
245
- if (rep.surviving.base && hub === undefined) {
246
- hub = factorOf(rep);
247
- hubTotal = rep.surviving.total ?? 1;
248
- }
249
- else {
250
- others.push(factorOf(rep));
251
- othersTotal *= rep.surviving.total ?? 1;
252
- }
253
- }
254
- // a package is a counted factor only when a *real* constraint narrows it (declared/transitive/signature/indirect);
201
+ // a package is a counted factor only when a *real* constraint bears on it (declared/transitive/signature/indirect);
255
202
  // date/available narrowing alone must not promote an otherwise any-version package into the product, or a tighter
256
- // date cutoff could paradoxically grow the count by turning more packages into factors
203
+ // date cutoff could paradoxically grow the count by turning more packages into factors. A partial constraint does
204
+ // count: it does not narrow the package on its own, but it does couple it to the package that declares it
257
205
  const reallyConstrained = (g) => g.evidence.list.some(e => e.source === 'declared' || e.source === 'transitive' || e.source === 'signature' || e.source === 'indirect');
258
- for (const g of guessedAll) {
259
- const total = g.surviving.total ?? 0;
260
- if (grouped.has(g.name) || total === 0 || !reallyConstrained(g)) {
261
- continue;
206
+ // one factor per linked group (its members share a version) plus every other constrained package
207
+ const grouped = new Set(linkedGroups.flat());
208
+ const representatives = [
209
+ ...linkedGroups.map(group => guessedAll.find(g => group.includes(g.name))).filter(g => g !== undefined),
210
+ ...guessedAll.filter(g => !grouped.has(g.name) && (g.surviving.total ?? 0) > 0 && reallyConstrained(g))
211
+ ];
212
+ const factors = representatives.map(g => ({ name: g.name, survivors: g.surviving.survivors.map(e => e.ver) }));
213
+ const { total: runnableCombinations, couplings } = (0, dependency_version_space_1.countRunnableCombinations)(space, factors);
214
+ const possibleCombinations = representatives.reduce((p, g) => p * (g.surviving.total ?? 1), 1);
215
+ // the baseline the guess narrows down from: what the project already declares, before usage and interdependencies
216
+ const anyDeclared = !disabled.has('declared') && representatives.some(g => g.surviving.declaredConstraints.length > 0);
217
+ const declaredCombinations = anyDeclared ? representatives.reduce((p, g) => p * g.surviving.declared, 1) : undefined;
218
+ // a coupled package's version is not free: report the partners, flagging one that only some versions impose
219
+ const coupledWith = new Map();
220
+ for (const c of couplings) {
221
+ for (const [pkg, partner] of [[c.a, c.b], [c.b, c.a]]) {
222
+ coupledWith.set(pkg, [...coupledWith.get(pkg) ?? [], c.always ? partner : `${partner} (partial)`]);
262
223
  }
263
- others.push(factorOf(g));
264
- othersTotal *= total;
265
224
  }
266
- const runnableCombinations = (0, dependency_version_space_1.countRunnableCombinations)(hub, others);
267
- const possibleCombinations = hubTotal * othersTotal;
268
225
  const dependencies = [];
269
226
  const ordered = [];
270
227
  for (const g of guessedAll) {
271
- dependencies.push(guessPackage(g.name, cap, g.surviving, g.evidence, usage.has(g.name), linkedWith.get(g.name)));
272
- const oc = query.explode ? (0, dependency_version_space_1.orderedCandidatesOf)(g.src, g.name, g.surviving, query.explode.prefer?.[g.name], explodeOrder) : undefined;
228
+ dependencies.push(guessPackage(g.name, cap, g.surviving, g.evidence, {
229
+ used: usage.has(g.name),
230
+ linkedWith: linkedWith.get(g.name),
231
+ coupledWith: coupledWith.get(g.name)
232
+ }));
233
+ const oc = query.explode ? (0, dependency_version_space_1.orderedCandidatesOf)(space.resolve(g.name).src, g.name, g.surviving, query.explode.prefer?.[g.name], explodeOrder) : undefined;
273
234
  if (oc) {
274
235
  ordered.push(oc);
275
236
  }
@@ -285,6 +246,7 @@ async function executeGuessDepVersionsQuery({ analyzer }, queries) {
285
246
  versionSelection: ctx.config.solver.sigdb.versionSelection,
286
247
  runnableCombinations,
287
248
  possibleCombinations,
249
+ declaredCombinations,
288
250
  linkedGroups: linkedGroups.length > 0 ? linkedGroups : undefined,
289
251
  assignments,
290
252
  message
@@ -80,6 +80,12 @@ export interface GuessedDependency {
80
80
  readonly unsatisfiable?: boolean;
81
81
  /** the other packages this one shares a version with, so its range is not independent of theirs */
82
82
  readonly linkedWith?: readonly string[];
83
+ /**
84
+ * The other packages whose version requirements this one's version choice interacts with, so the two cannot be
85
+ * picked independently (`A 0.2.5` requiring `B == 0.2.1` while `A 0.3.0` requires `B == 0.3.2`). A partner marked
86
+ * `(partial)` only requires (or is required by) this package in some of their versions.
87
+ */
88
+ readonly coupledWith?: readonly string[];
83
89
  /**
84
90
  * Whether the analyzed code actually uses this package (a declared-but-never-used dependency is unconstrained):
85
91
  * either a direct call, or the project's own NAMESPACE registering an S3 method for a class this package OWNS
@@ -100,6 +106,12 @@ export interface GuessDepVersionsQueryResult extends BaseQueryResult {
100
106
  readonly runnableCombinations?: number;
101
107
  /** the whole version space those tuples are drawn from (product of each counted factor's total versions) */
102
108
  readonly possibleCombinations?: number;
109
+ /**
110
+ * The tuples the *declared* constraints alone leave, i.e. what the project already pins down before code usage and
111
+ * interdependencies are taken into account. Set only when something is declared and the `declared` source is active,
112
+ * so `runnableCombinations` relative to it says how much the guess added.
113
+ */
114
+ readonly declaredCombinations?: number;
103
115
  /** groups of packages interlinked to one shared version (the base/R group plus any configured groups), so their versions are not independent */
104
116
  readonly linkedGroups?: readonly (readonly string[])[];
105
117
  /** concrete version assignments, present when {@link GuessDepVersionsQuery.explode} was requested (most-preferred first) */
@@ -29,7 +29,7 @@ function guessDepVersionsLineParser(_output, line, _config) {
29
29
  const prefer = {};
30
30
  const disabled = new Set();
31
31
  // an optional parenthesised clause `(clean)`, `(<=2025)`, or `(clean:<=2025)`: `clean` drops declared constraints, a (`<=`-prefixed) date caps the window
32
- const tokens = [...line];
32
+ const tokens = line.slice();
33
33
  const open = tokens.findIndex(t => t.startsWith('('));
34
34
  const close = open < 0 ? -1 : tokens.findIndex((t, i) => i >= open && t.endsWith(')'));
35
35
  if (open >= 0 && close >= open) {
@@ -88,8 +88,8 @@ function guessDepVersionsLineParser(_output, line, _config) {
88
88
  }
89
89
  }
90
90
  else if (!tok.startsWith('--')) {
91
- // every bare token is the code to analyse (a `file://`/`watch://` target, a bare path -- auto-prepended to
92
- // `file://` by the repl -- or inline R code); package filters are the explicit `--only` flag, so nothing is guessed
91
+ // every bare token is the code to analyse (a `file://`/`watch://` target, a bare path the repl
92
+ // auto-prepends `file://` to, or inline R code); package filters are the explicit `--only` flag, so nothing is guessed
93
93
  codeParts.push(tok);
94
94
  }
95
95
  }
@@ -168,6 +168,23 @@ function versionBound(bound) {
168
168
  }
169
169
  return { op: m[1] === '>=' ? '>=' : '<=', ver: m[2] };
170
170
  }
171
+ /**
172
+ * Order the bounds the way they are read: enforced before partial (which narrow nothing), lower bounds before upper
173
+ * ones, and the tightest of each first, so the bound that actually decides the range heads its group.
174
+ */
175
+ function compareBounds(a, b) {
176
+ if (Boolean(a.partial) !== Boolean(b.partial)) {
177
+ return a.partial ? 1 : -1;
178
+ }
179
+ const va = versionBound(a.bound), vb = versionBound(b.bound);
180
+ if (va === undefined || vb === undefined) {
181
+ return va === vb ? 0 : va === undefined ? 1 : -1; // a non-version bound (a date, `*`) sorts last
182
+ }
183
+ if (va.op !== vb.op) {
184
+ return va.op === '>=' ? -1 : 1;
185
+ }
186
+ return va.op === '>=' ? r_version_1.RVersion.compare(vb.ver, va.ver) : r_version_1.RVersion.compare(va.ver, vb.ver);
187
+ }
171
188
  /** whether a dependency's version is actually narrowed (not every database version survives); a fully redundant one is unconstrained */
172
189
  function isConstrained(dep) {
173
190
  return dep.totalVersions !== undefined && dep.candidateCount !== dep.totalVersions;
@@ -176,21 +193,22 @@ function isConstrained(dep) {
176
193
  function formatCombinations(n) {
177
194
  return n >= 1e12 ? n.toExponential(1) : String(Math.round(n)).replace(/\B(?=(\d{3})+(?!\d))/g, ',');
178
195
  }
179
- /** a parameter list, truncated with `...` once it gets long so a many-argument function stays on one readable line */
180
- function formatParams(params) {
181
- const shown = 4;
182
- return params.length > shown ? `${params.slice(0, shown).join(', ')} (+${params.length - shown})` : params.join(', ');
196
+ /** a list, truncated with a `(+n)` tail once it gets long, so it stays on one readable line */
197
+ function truncatedList(items, shown = 4) {
198
+ return items.length > shown ? `${items.slice(0, shown).join(', ')} (+${items.length - shown})` : items.join(', ');
183
199
  }
184
200
  /** a short, readable phrase for one non-signature bound, its origin(s) folded in (so several packages sharing a bound collapse to one line) */
185
- function nonSignaturePhrase(source, bound, origins) {
186
- const b = bound ? bound.replace(/([<>]=?)\s+/g, '$1') + ' ' : '';
187
- switch (source) {
201
+ function nonSignaturePhrase(ev, origins) {
202
+ const b = ev.bound ? ev.bound.replace(/([<>]=?)\s+/g, '$1') + ' ' : '';
203
+ // a partial bound holds for only some versions of its origin, so it never narrows: say so instead of implying it did
204
+ const some = ev.partial ? 'some ' : '', not = ev.partial ? ' (not applied)' : '';
205
+ switch (ev.source) {
188
206
  case 'declared': return `${b}declared`;
189
- case 'transitive': return `${b}required by ${origins.join(', ')}`;
207
+ case 'transitive': return `${b}required by ${some}${origins.join(', ')}${ev.partial ? ' versions' : ''}${not}`;
190
208
  case 'date': return `releases up to ${origins[0]}`;
191
209
  case 'base-r': return `${b}bounded by ${origins[0]}`;
192
210
  case 'available': return `${b}available in database`;
193
- case 'indirect': return `${b}via ${origins.join(', ')}`;
211
+ case 'indirect': return `${b}via ${origins.join(', ')}${not}`;
194
212
  default: return b.trim();
195
213
  }
196
214
  }
@@ -241,8 +259,14 @@ exports.GuessDepVersionsQueryDefinition = {
241
259
  result.push(` ${(0, ansi_1.color)('▶', 2 /* Colors.Green */, formatter)} ${(0, ansi_1.bold)('sample', formatter)} ${(0, ansi_1.faint)(`(${selection})`, formatter)}: ${sample.join(', ')}${latestSuffix}`);
242
260
  const runnable = out.runnableCombinations, possible = out.possibleCombinations;
243
261
  if (runnable !== undefined && possible !== undefined && possible > 0) {
244
- const pct = runnable / possible * 100;
245
- result.push(` ${(0, ansi_1.italic)('runnable combinations', formatter)}: ${(0, ansi_1.bold)(formatCombinations(runnable), formatter)} ${(0, ansi_1.faint)(`(${pct < 10 ? pct.toFixed(1) : Math.round(pct)}%)`, formatter)}`);
262
+ const share = (of) => {
263
+ const pct = runnable / of * 100;
264
+ return pct < 10 ? pct.toFixed(1) : String(Math.round(pct));
265
+ };
266
+ // against the whole database, and against what the project already declares (so: what the guess added)
267
+ const declared = out.declaredCombinations;
268
+ const ofDeclared = declared !== undefined && declared > 0 ? `, ${share(declared)}% of declared` : '';
269
+ result.push(` ${(0, ansi_1.italic)('runnable combinations', formatter)}: ${(0, ansi_1.bold)(formatCombinations(runnable), formatter)} ${(0, ansi_1.faint)(`(${share(possible)}%${ofDeclared})`, formatter)}`);
246
270
  }
247
271
  }
248
272
  // the packages locked to one shared version
@@ -251,9 +275,12 @@ exports.GuessDepVersionsQueryDefinition = {
251
275
  result.push(` ${(0, ansi_1.italic)('linked', formatter)}: ${group.join(' + ')}${rep?.maxVersion ? (0, ansi_1.faint)(' @ ' + rep.maxVersion, formatter) : ''}`);
252
276
  }
253
277
  for (const dep of out.dependencies) {
254
- const groupTag = dep.base ? ' ' + (0, ansi_1.italic)('[base]', formatter)
255
- : dep.linkedWith ? ' ' + (0, ansi_1.italic)(`[linked: ${dep.linkedWith.join(', ')}]`, formatter) : '';
256
- const note = dep.base ? '' : dep.used === false ? ' ' + (0, ansi_1.faint)('(not called)', formatter) : !isConstrained(dep) && dep.totalVersions ? ' ' + (0, ansi_1.faint)('(any version)', formatter) : '';
278
+ const coupled = dep.coupledWith ?? [];
279
+ const groupTag = (dep.base ? ' ' + (0, ansi_1.italic)('[base]', formatter)
280
+ : dep.linkedWith ? ' ' + (0, ansi_1.italic)(`[linked: ${dep.linkedWith.join(', ')}]`, formatter) : '')
281
+ + (coupled.length > 0 ? ' ' + (0, ansi_1.italic)(`[coupled: ${truncatedList(coupled, 3)}]`, formatter) : '');
282
+ const anyVersion = coupled.length > 0 ? '(any version on its own)' : '(any version)';
283
+ const note = dep.base ? '' : dep.used === false ? ' ' + (0, ansi_1.faint)('(not called)', formatter) : !isConstrained(dep) && dep.totalVersions ? ' ' + (0, ansi_1.faint)(anyVersion, formatter) : '';
257
284
  const tag = groupTag + note;
258
285
  const range = dep.unsatisfiable ? (0, ansi_1.color)('unsatisfiable', 1 /* Colors.Red */, formatter) : (0, ansi_1.bold)(dep.range, formatter);
259
286
  const count = dep.totalVersions !== undefined ? `${dep.candidateCount}/${dep.totalVersions} versions` : `${dep.candidateCount} candidate${dep.candidateCount === 1 ? '' : 's'}`;
@@ -261,11 +288,14 @@ exports.GuessDepVersionsQueryDefinition = {
261
288
  const dbGe = versionBound(tightestBound(avail, '>='))?.ver, dbLe = versionBound(tightestBound(avail, '<='))?.ver;
262
289
  const dbRange = dbGe !== undefined && dbLe !== undefined ? `, db ${dbGe} - ${dbLe}` : '';
263
290
  result.push(` ${(0, ansi_1.bold)('━ ' + dep.package, formatter)}${tag} ${range} ${(0, ansi_1.faint)('(' + count + dbRange + ')', formatter)}`);
264
- const tightestGe = versionBound(tightestBound(dep.evidence, '>='))?.ver;
265
- const tightestLe = versionBound(tightestBound(dep.evidence.filter(e => versionBound(e.bound)), '<='))?.ver;
291
+ // only enforced evidence sets the tightest bound; a partial one narrows nothing and must not hide a real bound
292
+ const enforced = dep.evidence.filter(e => !e.partial);
293
+ const tightestGe = versionBound(tightestBound(enforced, '>='))?.ver;
294
+ const tightestLe = versionBound(tightestBound(enforced.filter(e => versionBound(e.bound)), '<='))?.ver;
266
295
  const active = [], dominated = [];
267
- const nonSig = [...(0, arrays_1.arraysGroupBy)(dep.evidence.filter(e => e.source !== 'signature' && e.source !== 'available'), e => `${e.source}|${e.bound ?? ''}`)]
268
- .map(([, evs]) => ({ ev: evs[0], origins: [...new Set(evs.map(e => e.origin))] }));
296
+ const nonSig = [...(0, arrays_1.arraysGroupBy)(dep.evidence.filter(e => e.source !== 'signature' && e.source !== 'available'), e => `${e.source}|${e.bound ?? ''}|${e.partial ? 'p' : ''}`)]
297
+ .map(([, evs]) => ({ ev: evs[0], origins: [...new Set(evs.map(e => e.origin))] }))
298
+ .sort((x, y) => compareBounds(x.ev, y.ev));
269
299
  const bestRankByBound = new Map();
270
300
  for (const { ev } of nonSig) {
271
301
  const vb = versionBound(ev.bound);
@@ -279,7 +309,7 @@ exports.GuessDepVersionsQueryDefinition = {
279
309
  }
280
310
  }
281
311
  for (const { ev, origins } of nonSig) {
282
- const phrase = nonSignaturePhrase(ev.source, ev.bound, origins);
312
+ const phrase = nonSignaturePhrase(ev, origins);
283
313
  const vb = versionBound(ev.bound);
284
314
  const best = vb === undefined ? undefined : bestRankByBound.get(vb.op + vb.ver);
285
315
  const redundant = best !== undefined && sourceRank[ev.source] > best;
@@ -296,10 +326,10 @@ exports.GuessDepVersionsQueryDefinition = {
296
326
  const ge = tightestBound(evs, '>='), le = tightestBound(evs, '<=');
297
327
  const geVer = versionBound(ge)?.ver, leVer = versionBound(le)?.ver;
298
328
  const params = [...new Set(evs.map(e => e.parameter).filter((pm) => pm !== undefined))];
299
- const reasons = [evs.some(e => !e.parameter) ? 'new' : undefined, params.length > 0 ? `params: [${formatParams(params)}]` : undefined].filter(Boolean).join(', ');
329
+ const reasons = [evs.some(e => !e.parameter) ? 'new' : undefined, params.length > 0 ? `params: [${truncatedList(params)}]` : undefined].filter(Boolean).join(', ');
300
330
  const name = identifier_1.Identifier.getName(identifier_1.Identifier.parse(fn));
301
331
  const url = (0, signature_query_executor_1.rdrrDocUrl)(dep.package, name, { base: dep.base, cran: !dep.base });
302
- const label = (url ? formatter.hyperlink(name, url) : name) + (reasons ? ` (${reasons})` : '');
332
+ const label = (url ? formatter.hyperlink(name, url, true) : name) + (reasons ? ` (${reasons})` : '');
303
333
  const redundant = !(geVer !== undefined && geVer === tightestGe) && !(leVer !== undefined && leVer === tightestLe);
304
334
  return { bounds: [ge, le].filter(Boolean).join(' '), label, redundant, geVer, leVer };
305
335
  }).sort((a, b) => r_version_1.RVersion.compare(b.geVer, a.geVer) || r_version_1.RVersion.compare(b.leVer, a.leVer));
@@ -1,4 +1,17 @@
1
1
  import { Identifier } from '../../../dataflow/environments/identifier';
2
+ import type { LinkedInputEntryPoint, LinkedInputObject } from './simple-input-classifier';
3
+ /**
4
+ * Objects that a framework binds for its users, without a definition visible in the code.
5
+ * The `withParams` and `requires` guards keep ordinary functions that happen to have a parameter of the same
6
+ * name out of this; where the framework is handed the function, {@link LinkedInputEntryPoints} is exact instead.
7
+ * @see {@link LinkedInputObject}
8
+ */
9
+ export declare const LinkedInputObjects: readonly LinkedInputObject[];
10
+ /**
11
+ * Calls that hand a function to a framework which binds its parameters by position.
12
+ * @see {@link LinkedInputEntryPoint}
13
+ */
14
+ export declare const LinkedInputEntryPoints: readonly LinkedInputEntryPoint[];
2
15
  export declare const PureFunctions: Identifier[];
3
16
  export declare const SystemFunctions: Identifier[];
4
17
  export declare const FfiFunctions: Identifier[];
@@ -1,7 +1,42 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TempFileFunctions = exports.UserFunctions = exports.OptionsFunctions = exports.LangFunctions = exports.FfiFunctions = exports.SystemFunctions = exports.PureFunctions = void 0;
3
+ exports.TempFileFunctions = exports.UserFunctions = exports.OptionsFunctions = exports.LangFunctions = exports.FfiFunctions = exports.SystemFunctions = exports.PureFunctions = exports.LinkedInputEntryPoints = exports.LinkedInputObjects = void 0;
4
4
  const identifier_1 = require("../../../dataflow/environments/identifier");
5
+ const simple_input_classifier_1 = require("./simple-input-classifier");
6
+ /** shiny's ui-side control widgets, all taking the id of the `input` entry they feed as their first argument */
7
+ const ShinyInputWidgets = {
8
+ argName: 'inputId',
9
+ argIdx: 0,
10
+ calls: [
11
+ 'actionButton', 'actionLink', 'checkboxInput', 'checkboxGroupInput', 'dateInput', 'dateRangeInput',
12
+ 'fileInput', 'numericInput', 'passwordInput', 'radioButtons', 'selectInput', 'selectizeInput',
13
+ 'sliderInput', 'submitButton', 'textAreaInput', 'textInput', 'varSelectInput', 'varSelectizeInput'
14
+ ].map(n => identifier_1.Identifier.make(n, 'shiny'))
15
+ };
16
+ /**
17
+ * Objects that a framework binds for its users, without a definition visible in the code.
18
+ * The `withParams` and `requires` guards keep ordinary functions that happen to have a parameter of the same
19
+ * name out of this; where the framework is handed the function, {@link LinkedInputEntryPoints} is exact instead.
20
+ * @see {@link LinkedInputObject}
21
+ */
22
+ exports.LinkedInputObjects = [
23
+ /* shiny hands the server function its reactive `input` and `session` objects */
24
+ { name: 'input', type: simple_input_classifier_1.InputType.User, withParams: ['output'], requires: 'shiny', declaredBy: ShinyInputWidgets },
25
+ /* of the session only what the browser sends is user input, `userData` and `token` are the app's own */
26
+ { name: 'session', type: simple_input_classifier_1.InputType.User, withParams: ['input', 'output'], requires: 'shiny', fields: ['clientData', 'request'] }
27
+ ];
28
+ /** shiny binds `input`, `output`, and `session` positionally, so their names are up to whoever writes the server */
29
+ const ShinyServerParams = ['input', undefined, 'session'];
30
+ /**
31
+ * Calls that hand a function to a framework which binds its parameters by position.
32
+ * @see {@link LinkedInputEntryPoint}
33
+ */
34
+ exports.LinkedInputEntryPoints = [
35
+ { call: identifier_1.Identifier.make('shinyApp', 'shiny'), argName: 'server', argIdx: 1, params: ShinyServerParams },
36
+ { call: identifier_1.Identifier.make('shinyServer', 'shiny'), argName: 'func', argIdx: 0, params: ShinyServerParams },
37
+ { call: identifier_1.Identifier.make('moduleServer', 'shiny'), argName: 'module', argIdx: 1, params: ShinyServerParams },
38
+ { call: identifier_1.Identifier.make('callModule', 'shiny'), argName: 'module', argIdx: 0, params: ShinyServerParams }
39
+ ];
5
40
  exports.PureFunctions = [
6
41
  /* operators - syntax elements, impossible to call with :: in practice */
7
42
  '+', '-', '*', '/', '^', '%%', '%/%',
@@ -212,6 +247,40 @@ exports.PureFunctions = [
212
247
  identifier_1.Identifier.make('cov', 'stats'),
213
248
  identifier_1.Identifier.make('na.omit', 'stats'),
214
249
  identifier_1.Identifier.make('xtabs', 'stats'),
250
+ /* shiny - wrappers that hand their expression on; the reactives among them do so through a call (`r()`).
251
+ `observe`/`observeEvent`/`render*` are left out on purpose: they return an observer or render handle,
252
+ not the value of their expression. */
253
+ identifier_1.Identifier.make('reactive', 'shiny'),
254
+ identifier_1.Identifier.make('eventReactive', 'shiny'),
255
+ identifier_1.Identifier.make('bindEvent', 'shiny'),
256
+ identifier_1.Identifier.make('bindCache', 'shiny'),
257
+ identifier_1.Identifier.make('isolate', 'shiny'),
258
+ identifier_1.Identifier.make('req', 'shiny'),
259
+ identifier_1.Identifier.make('debounce', 'shiny'),
260
+ identifier_1.Identifier.make('throttle', 'shiny'),
261
+ identifier_1.Identifier.make('reactiveVal', 'shiny'),
262
+ identifier_1.Identifier.make('reactiveValues', 'shiny'),
263
+ identifier_1.Identifier.make('reactiveValuesToList', 'shiny'),
264
+ identifier_1.Identifier.make('freezeReactiveVal', 'shiny'),
265
+ /* cohortBuilder - assembling a cohort keeps the data of its source */
266
+ identifier_1.Identifier.make('cohort', 'cohortBuilder'),
267
+ identifier_1.Identifier.make('set_source', 'cohortBuilder'),
268
+ identifier_1.Identifier.make('add_source', 'cohortBuilder'),
269
+ identifier_1.Identifier.make('update_source', 'cohortBuilder'),
270
+ identifier_1.Identifier.make('add_filter', 'cohortBuilder'),
271
+ identifier_1.Identifier.make('update_filter', 'cohortBuilder'),
272
+ identifier_1.Identifier.make('rm_filter', 'cohortBuilder'),
273
+ identifier_1.Identifier.make('bind_key', 'cohortBuilder'),
274
+ identifier_1.Identifier.make('bind_keys', 'cohortBuilder'),
275
+ identifier_1.Identifier.make('as.tblist', 'cohortBuilder'),
276
+ identifier_1.Identifier.make('tblist', 'cohortBuilder'),
277
+ /* generic names, only matched bare while cohortBuilder is attached */
278
+ identifier_1.Identifier.make('filter', 'cohortBuilder'),
279
+ identifier_1.Identifier.make('step', 'cohortBuilder'),
280
+ identifier_1.Identifier.make('add_step', 'cohortBuilder'),
281
+ identifier_1.Identifier.make('rm_step', 'cohortBuilder'),
282
+ identifier_1.Identifier.make('run', 'cohortBuilder'),
283
+ identifier_1.Identifier.make('restore', 'cohortBuilder'),
215
284
  ];
216
285
  exports.SystemFunctions = [
217
286
  /* base */
@@ -321,6 +390,32 @@ exports.UserFunctions = [
321
390
  /* tcltk */
322
391
  identifier_1.Identifier.make('tk_choose.files', 'tcltk'),
323
392
  identifier_1.Identifier.make('tk_choose.dir', 'tcltk'),
393
+ /* shiny - everything the browser sends along with a request */
394
+ identifier_1.Identifier.make('parseQueryString', 'shiny'),
395
+ identifier_1.Identifier.make('getQueryString', 'shiny'),
396
+ identifier_1.Identifier.make('getUrlHash', 'shiny'),
397
+ identifier_1.Identifier.make('restoreInput', 'shiny'),
398
+ /* shinyFiles - paths the user picks in the browser */
399
+ identifier_1.Identifier.make('parseFilePaths', 'shinyFiles'),
400
+ identifier_1.Identifier.make('parseDirPath', 'shinyFiles'),
401
+ identifier_1.Identifier.make('parseSavePath', 'shinyFiles'),
402
+ identifier_1.Identifier.make('shinyFileChoose', 'shinyFiles'),
403
+ identifier_1.Identifier.make('shinyDirChoose', 'shinyFiles'),
404
+ identifier_1.Identifier.make('shinyFileSave', 'shinyFiles'),
405
+ /* cohortBuilder - the data that comes out of a cohort depends on the filters the user set */
406
+ identifier_1.Identifier.make('get_data', 'cohortBuilder'),
407
+ identifier_1.Identifier.make('sum_up', 'cohortBuilder'),
408
+ identifier_1.Identifier.make('attrition', 'cohortBuilder'),
409
+ identifier_1.Identifier.make('get_state', 'cohortBuilder'),
410
+ identifier_1.Identifier.make('code', 'cohortBuilder'),
411
+ identifier_1.Identifier.make('stat', 'cohortBuilder'),
412
+ /* shinyCohortBuilder - the gui that lets the user set those filters */
413
+ identifier_1.Identifier.make('cb_server', 'shinyCohortBuilder'),
414
+ identifier_1.Identifier.make('cb_ui', 'shinyCohortBuilder'),
415
+ identifier_1.Identifier.make('cb_chat_server', 'shinyCohortBuilder'),
416
+ identifier_1.Identifier.make('cb_chat_ui', 'shinyCohortBuilder'),
417
+ identifier_1.Identifier.make('gui', 'shinyCohortBuilder'),
418
+ identifier_1.Identifier.make('demo_app', 'shinyCohortBuilder'),
324
419
  ];
325
420
  /** R functions that produce temporary file/directory paths (sub-type of {@link InputType.File}). */
326
421
  exports.TempFileFunctions = [
@@ -10,6 +10,9 @@ const df_helper_1 = require("../../../dataflow/graph/df-helper");
10
10
  const simple_input_classifier_1 = require("./simple-input-classifier");
11
11
  const flowr_search_executor_1 = require("../../../search/flowr-search-executor");
12
12
  const record_1 = require("../../../util/record");
13
+ const identifier_1 = require("../../../dataflow/environments/identifier");
14
+ const r_base_packages_1 = require("../../../util/r-base-packages");
15
+ const environment_1 = require("../../../dataflow/environments/environment");
13
16
  /**
14
17
  * Execute an input sources query
15
18
  */
@@ -18,7 +21,9 @@ async function executeInputSourcesQuery({ analyzer }, queries) {
18
21
  const results = {};
19
22
  const nast = await analyzer.normalize();
20
23
  const df = await analyzer.dataflow();
21
- const defaultConfig = await resolveSearches(analyzer, input_sources_query_format_1.DefaultInputClassifierConfig);
24
+ // flowR's defaults, extended by whatever the (possibly project-kind specialized) configuration adds
25
+ const defaultConfig = addAll(await resolveSearches(analyzer, input_sources_query_format_1.DefaultInputClassifierConfig), await resolveSearches(analyzer, analyzer.inspectContext().config.inputSources ?? {}));
26
+ const packages = attachedPackages(analyzer, df.environment);
22
27
  for (const query of queries) {
23
28
  const criteria = Array.isArray(query.criterion)
24
29
  ? query.criterion
@@ -33,7 +38,7 @@ async function executeInputSourcesQuery({ analyzer }, queries) {
33
38
  const provenanceNode = nast.idMap.get(criterionId);
34
39
  const fdef = r_function_definition_1.RFunctionDefinition.rootFunctionDefinition(provenanceNode, nast.idMap);
35
40
  const provenance = df_helper_1.Dataflow.provenanceGraph(criterionId, df.graph, fdef ? model_1.RNode.collectAllIds(fdef) : undefined);
36
- results[criterion] = (0, simple_input_classifier_1.classifyInput)(criterionId, provenance, config, df.graph);
41
+ results[criterion] = (0, simple_input_classifier_1.classifyInput)(criterionId, provenance, config, df.graph, packages);
37
42
  }
38
43
  }
39
44
  return {
@@ -43,11 +48,42 @@ async function executeInputSourcesQuery({ analyzer }, queries) {
43
48
  results
44
49
  };
45
50
  }
51
+ /**
52
+ * The packages whose exports are usable without a namespace: those R has on its search path at the end of the
53
+ * program, the ones the project declares, and the base packages R attaches on startup.
54
+ */
55
+ function attachedPackages(analyzer, environment) {
56
+ return new Set([
57
+ ...environment_1.REnvironment.attachedPackages(environment.current),
58
+ ...analyzer.inspectContext().deps.getDependencies().map(d => d.name),
59
+ ...r_base_packages_1.AttachedBasePackages
60
+ ]);
61
+ }
62
+ /** every entry of `extra` appended to the matching list of `base`, so configured entries extend the defaults instead of replacing them */
63
+ function addAll(base, extra) {
64
+ const result = { ...base };
65
+ for (const [key, value] of record_1.Record.entries(extra)) {
66
+ if (value !== undefined) {
67
+ result[key] = [...(base[key] ?? []), ...value];
68
+ }
69
+ }
70
+ return result;
71
+ }
46
72
  async function resolveSearches(analyzer, config) {
47
73
  const result = {};
74
+ if (config.linkedObjects !== undefined) {
75
+ result.linkedObjects = config.linkedObjects;
76
+ }
77
+ if (config.linkedEntryPoints !== undefined) {
78
+ result.linkedEntryPoints = config.linkedEntryPoints;
79
+ }
48
80
  for (const [key, value] of record_1.Record.entries(config)) {
49
- if (value === undefined || Array.isArray(value)) {
50
- result[key] = value;
81
+ if (key === 'linkedObjects' || key === 'linkedEntryPoints') {
82
+ continue;
83
+ }
84
+ else if (value === undefined || Array.isArray(value)) {
85
+ // entries may be written as `pkg::fn` strings in the configuration, which only mean the namespaced function once parsed
86
+ result[key] = value?.map(e => typeof e === 'string' ? identifier_1.Identifier.parse(e) : e);
51
87
  }
52
88
  else {
53
89
  const searchResult = await (0, flowr_search_executor_1.runSearch)(value, analyzer);
@@ -13,6 +13,7 @@ const input_sources_query_executor_1 = require("./input-sources-query-executor")
13
13
  const range_1 = require("../../../util/range");
14
14
  const flowr_search_builder_1 = require("../../../search/flowr-search-builder");
15
15
  const linter_format_1 = require("../../../linter/linter-format");
16
+ const record_1 = require("../../../util/record");
16
17
  const read_functions_1 = require("../dependencies-query/function-info/read-functions");
17
18
  const input_source_functions_1 = require("./input-source-functions");
18
19
  exports.DefaultInputClassifierConfig = {
@@ -25,7 +26,9 @@ exports.DefaultInputClassifierConfig = {
25
26
  [simple_input_classifier_1.InputType.Ffi]: input_source_functions_1.FfiFunctions,
26
27
  [simple_input_classifier_1.InputType.Lang]: input_source_functions_1.LangFunctions,
27
28
  [simple_input_classifier_1.InputType.Options]: input_source_functions_1.OptionsFunctions,
28
- [simple_input_classifier_1.InputType.User]: input_source_functions_1.UserFunctions
29
+ [simple_input_classifier_1.InputType.User]: input_source_functions_1.UserFunctions,
30
+ linkedObjects: input_source_functions_1.LinkedInputObjects,
31
+ linkedEntryPoints: input_source_functions_1.LinkedInputEntryPoints
29
32
  };
30
33
  function inputSourcesQueryLineParser(output, line, _config) {
31
34
  const criterion = (0, slice_query_parser_1.sliceCriteriaParser)(line[0]);
@@ -47,12 +50,16 @@ exports.InputSourcesDefinition = {
47
50
  const nast = (await analyzer.normalize()).idMap;
48
51
  for (const [key, sources] of Object.entries(out.results)) {
49
52
  result.push(` ╰ Input Sources for ${key}`);
50
- for (const { id, trace, types, name, value } of sources) {
53
+ for (const { id, trace, types, name, value, declaredAt } of sources) {
51
54
  const kNode = nast.get(id);
52
55
  const kLoc = kNode ? range_1.SourceLocation.format(range_1.SourceLocation.fromNode(kNode)) : 'unknown location';
53
56
  const nameStr = name !== undefined ? `, name: ${name}` : '';
54
57
  const valueStr = value !== undefined ? `, value: ${JSON.stringify(value)}` : '';
55
- result.push(` ╰ ${kLoc} (id: ${id}), type: ${JSON.stringify(types)}, trace: ${trace}${nameStr}${valueStr}`);
58
+ const declStr = declaredAt ? `, declared at: ${declaredAt.map(d => {
59
+ const dNode = nast.get(d);
60
+ return dNode ? range_1.SourceLocation.format(range_1.SourceLocation.fromNode(dNode)) : String(d);
61
+ }).join(', ')}` : '';
62
+ result.push(` ╰ ${kLoc} (id: ${id}), type: ${JSON.stringify(types)}, trace: ${trace}${nameStr}${valueStr}${declStr}`);
56
63
  }
57
64
  }
58
65
  return true;
@@ -74,6 +81,17 @@ exports.InputSourcesDefinition = {
74
81
  [simple_input_classifier_1.InputType.Lang]: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that produce language objects (e.g., substitute, quote, bquote, expression).'),
75
82
  [simple_input_classifier_1.InputType.Options]: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that access or set global options (e.g., options, getOption).'),
76
83
  [simple_input_classifier_1.InputType.User]: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that read interactive user input (e.g., file.choose, readline, menu, askYesNo).'),
84
+ linkedObjects: joi_1.default.array().items(joi_1.default.object({
85
+ name: joi_1.default.string().required().description('Name of the object, e.g. input.'),
86
+ type: joi_1.default.string().valid(...record_1.Record.values(simple_input_classifier_1.InputType)).required().description('How reads of the object (or of its fields) are classified.'),
87
+ withParams: joi_1.default.array().items(joi_1.default.string()).optional().description('Only link the object if the function binding it declares all of these parameters as well.')
88
+ })).optional().description('Objects a framework provides without a definition in the code, e.g. shiny\'s input.'),
89
+ linkedEntryPoints: joi_1.default.array().items(joi_1.default.object({
90
+ call: joi_1.default.string().required().description('The call taking the function, e.g. shiny::shinyApp.'),
91
+ argName: joi_1.default.string().required().description('Name of the argument holding the function.'),
92
+ argIdx: joi_1.default.number().required().description('Index of that argument when it is passed positionally.'),
93
+ params: joi_1.default.array().items(joi_1.default.string().allow(null)).required().description('Which linkedObject the framework binds to each parameter, by position.')
94
+ })).optional().description('Calls that hand a function to a framework, which binds its objects to the parameters by position.')
77
95
  }).optional()
78
96
  }).description('Input Sources query definition'),
79
97
  flattenInvolvedNodes: (queryResults) => {