@eagleoutice/flowr 2.13.9 → 2.13.10

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 (138) hide show
  1. package/config.d.ts +50 -2
  2. package/config.js +37 -6
  3. package/dataflow/environments/apply-kill.js +4 -4
  4. package/dataflow/environments/built-in-props.d.ts +28 -4
  5. package/dataflow/environments/built-in-props.js +31 -8
  6. package/dataflow/environments/built-in.d.ts +7 -2
  7. package/dataflow/environments/built-in.js +10 -12
  8. package/dataflow/environments/default-builtin-config.d.ts +46 -6
  9. package/dataflow/environments/default-builtin-config.js +30 -16
  10. package/dataflow/environments/environment.d.ts +16 -0
  11. package/dataflow/environments/environment.js +70 -18
  12. package/dataflow/environments/identifier.d.ts +6 -0
  13. package/dataflow/environments/identifier.js +18 -5
  14. package/dataflow/environments/query-fn-props.js +34 -2
  15. package/dataflow/environments/reference-to-maybe.js +1 -1
  16. package/dataflow/eval/resolve/alias-tracking.js +45 -1
  17. package/dataflow/eval/resolve/resolve-argument.js +25 -17
  18. package/dataflow/eval/resolve/resolve-strings.d.ts +17 -0
  19. package/dataflow/eval/resolve/resolve-strings.js +16 -9
  20. package/dataflow/eval/resolve/resolve.js +3 -1
  21. package/dataflow/graph/call-graph.d.ts +7 -0
  22. package/dataflow/graph/call-graph.js +103 -0
  23. package/dataflow/graph/df-helper.d.ts +2 -0
  24. package/dataflow/graph/graph.d.ts +5 -8
  25. package/dataflow/internal/linker.d.ts +5 -5
  26. package/dataflow/internal/linker.js +31 -92
  27. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +2 -2
  28. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +3 -9
  29. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +4 -30
  30. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +2 -1
  31. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +1 -1
  32. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +7 -1
  33. package/dataflow/internal/process/functions/call/built-in/built-in-load.js +3 -3
  34. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.d.ts +1 -1
  35. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +5 -1
  36. package/dataflow/internal/process/functions/call/built-in/built-in-with.d.ts +2 -2
  37. package/dataflow/internal/process/functions/call/built-in/built-in-with.js +5 -6
  38. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +32 -14
  39. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +16 -4
  40. package/dataflow/internal/process/functions/call/known-call-handling.js +29 -8
  41. package/documentation/doc-util/doc-sigdb.d.ts +9 -0
  42. package/documentation/doc-util/doc-sigdb.js +32 -0
  43. package/documentation/wiki-interface.js +13 -2
  44. package/documentation/wiki-query.js +3 -0
  45. package/documentation/wiki-signature-database.js +2 -5
  46. package/gas.d.ts +6 -0
  47. package/gas.js +7 -1
  48. package/package.json +1 -1
  49. package/project/attached-packages.d.ts +13 -0
  50. package/project/attached-packages.js +30 -0
  51. package/project/context/flowr-analyzer-context.d.ts +15 -0
  52. package/project/context/flowr-analyzer-context.js +14 -3
  53. package/project/context/flowr-analyzer-files-context.d.ts +11 -0
  54. package/project/context/flowr-analyzer-files-context.js +3 -0
  55. package/project/context/flowr-analyzer-incremental-analysis-context.d.ts +4 -0
  56. package/project/context/flowr-analyzer-incremental-analysis-context.js +69 -0
  57. package/project/dependency-version-space.d.ts +33 -11
  58. package/project/dependency-version-space.js +58 -32
  59. package/project/plugins/file-plugins/files/flowr-namespace-file.js +52 -24
  60. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-library-plugin.d.ts +22 -0
  61. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-library-plugin.js +101 -0
  62. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +30 -11
  63. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +79 -37
  64. package/project/plugins/plugin-registry.d.ts +2 -1
  65. package/project/plugins/plugin-registry.js +2 -0
  66. package/project/sigdb/manifest.js +9 -5
  67. package/project/sigdb/signature-match.d.ts +5 -18
  68. package/project/sigdb/signature-match.js +5 -18
  69. package/queries/catalog/call-graph-query/call-graph-query-executor.js +3 -1
  70. package/queries/catalog/call-graph-query/call-graph-query-format.d.ts +4 -0
  71. package/queries/catalog/call-graph-query/call-graph-query-format.js +4 -0
  72. package/queries/catalog/dependencies-query/dependencies-query-executor.js +10 -3
  73. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +19 -1
  74. package/queries/catalog/dependencies-query/dependencies-query-format.js +22 -2
  75. package/queries/catalog/dependencies-query/function-info/library-functions.js +7 -1
  76. package/queries/catalog/dependencies-query/function-info/read-functions.js +5 -5
  77. package/queries/catalog/dependencies-query/function-info/remote-functions.d.ts +18 -0
  78. package/queries/catalog/dependencies-query/function-info/remote-functions.js +46 -0
  79. package/queries/catalog/dependencies-query/function-info/visualize-functions.js +52 -2
  80. package/queries/catalog/dependencies-query/function-info/write-functions.js +8 -4
  81. package/queries/catalog/dependencies-query/link-devices.d.ts +12 -0
  82. package/queries/catalog/dependencies-query/link-devices.js +58 -0
  83. package/queries/catalog/dice-query/dice-query-format.d.ts +2 -0
  84. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +25 -6
  85. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +37 -6
  86. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +17 -4
  87. package/queries/catalog/input-sources-query/input-sources-query-format.js +4 -0
  88. package/queries/catalog/input-sources-query/input-types.d.ts +10 -0
  89. package/queries/catalog/input-sources-query/input-types.js +10 -0
  90. package/queries/catalog/location-map-query/location-map-query-executor.js +16 -6
  91. package/queries/catalog/location-map-query/location-map-query-format.d.ts +15 -1
  92. package/queries/catalog/location-map-query/location-map-query-format.js +22 -5
  93. package/queries/catalog/signature-query/signature-query-executor.js +3 -0
  94. package/queries/catalog/signature-query/signature-query-format.d.ts +5 -0
  95. package/queries/query.d.ts +1 -1
  96. package/r-bridge/lang-4.x/ast/model/model.d.ts +14 -2
  97. package/r-bridge/lang-4.x/ast/model/model.js +32 -0
  98. package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +2 -0
  99. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +2 -0
  100. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +2 -0
  101. package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +2 -0
  102. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +2 -0
  103. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +2 -0
  104. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +2 -0
  105. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +7 -8
  106. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +9 -46
  107. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +2 -0
  108. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +2 -0
  109. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +2 -0
  110. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +2 -0
  111. package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +2 -0
  112. package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +2 -0
  113. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +2 -0
  114. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +2 -0
  115. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +2 -0
  116. package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +2 -0
  117. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +2 -0
  118. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +2 -0
  119. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +2 -0
  120. package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +0 -5
  121. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +6 -3
  122. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +1 -1
  123. package/search/flowr-search-filters.d.ts +17 -1
  124. package/search/flowr-search-filters.js +23 -0
  125. package/slicing/criterion/parse.d.ts +5 -25
  126. package/slicing/criterion/parse.js +15 -20
  127. package/slicing/static/fingerprint.js +18 -6
  128. package/slicing/static/slicer-types.d.ts +10 -0
  129. package/slicing/static/static-slicer.d.ts +1 -1
  130. package/slicing/static/static-slicer.js +29 -6
  131. package/slicing/static/visiting-queue.d.ts +12 -2
  132. package/slicing/static/visiting-queue.js +28 -3
  133. package/util/arg-matching.d.ts +18 -0
  134. package/util/arg-matching.js +70 -0
  135. package/util/r-regex.js +19 -1
  136. package/util/range.d.ts +7 -8
  137. package/util/range.js +10 -11
  138. package/util/version.js +1 -1
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.FlowrAnalyzerPackageVersionsLibraryPlugin = exports.libraryLog = void 0;
7
+ const flowr_analyzer_package_versions_plugin_1 = require("./flowr-analyzer-package-versions-plugin");
8
+ const semver_1 = require("semver");
9
+ const package_1 = require("./package");
10
+ const flowr_file_1 = require("../../context/flowr-file");
11
+ const flowr_description_file_1 = require("../file-plugins/files/flowr-description-file");
12
+ const flowr_namespace_file_1 = require("../file-plugins/files/flowr-namespace-file");
13
+ const log_1 = require("../../../util/log");
14
+ const fs_1 = __importDefault(require("fs"));
15
+ const path_1 = __importDefault(require("path"));
16
+ exports.libraryLog = log_1.log.getSubLogger({ name: 'flowr-analyzer-package-versions-library-plugin' });
17
+ /** the directories below `root` that may hold a library, stopping at an installed package (it holds none) */
18
+ function libraryDirs(root, depth) {
19
+ if (depth <= 0 || !fs_1.default.existsSync(root)) {
20
+ return [];
21
+ }
22
+ return fs_1.default.readdirSync(root, { withFileTypes: true }).filter(e => e.isDirectory()).flatMap(e => {
23
+ const dir = path_1.default.join(root, e.name);
24
+ return fs_1.default.existsSync(path_1.default.join(dir, 'DESCRIPTION')) ? [] : [dir, ...libraryDirs(dir, depth - 1)];
25
+ });
26
+ }
27
+ /**
28
+ * The library directories to search: the ones configured, or else the ones R's environment names (which
29
+ * already are libraries) and a project-local `renv`/`packrat` one (which nests its library below a platform
30
+ * and an R version).
31
+ */
32
+ function libraryRoots(opts, projectRoot) {
33
+ if (opts.paths?.length) {
34
+ return opts.paths;
35
+ }
36
+ const fromEnv = opts.useEnvironment === false ? [] :
37
+ [process.env.R_LIBS_USER, process.env.R_LIBS, process.env.R_LIBS_SITE].flatMap(v => v?.split(path_1.default.delimiter) ?? []);
38
+ const local = opts.useProjectLibrary === false || projectRoot === undefined ? [] :
39
+ ['renv/library', 'renv/staging', 'packrat/lib'].map(d => path_1.default.join(projectRoot, d))
40
+ .flatMap(d => [d, ...libraryDirs(d, opts.maxDepth ?? 3)]);
41
+ return [...new Set([...fromEnv, ...local])].filter(d => d.length > 0);
42
+ }
43
+ /**
44
+ * The package installed under `name` in one of `roots`, read from its own `DESCRIPTION` and `NAMESPACE`.
45
+ * An installed package keeps both, so its exports are recoverable even when no signature database knows it.
46
+ */
47
+ function installedPackage(name, roots) {
48
+ for (const root of roots) {
49
+ const dir = path_1.default.join(root, name);
50
+ const description = path_1.default.join(dir, 'DESCRIPTION');
51
+ const namespace = path_1.default.join(dir, 'NAMESPACE');
52
+ if (!fs_1.default.existsSync(description) || !fs_1.default.existsSync(namespace)) {
53
+ continue;
54
+ }
55
+ try {
56
+ const version = new flowr_description_file_1.FlowrDescriptionFile(new flowr_file_1.FlowrTextFile(description)).version();
57
+ const namespaceInfo = flowr_namespace_file_1.FlowrNamespaceFile.from(new flowr_file_1.FlowrTextFile(namespace)).content().current;
58
+ exports.libraryLog.debug(`Recovered ${name}${version ? ` ${version.str}` : ''} from ${dir}`);
59
+ return new package_1.Package({ name, resolvedVersion: version?.str, namespaceInfo });
60
+ }
61
+ catch (e) {
62
+ exports.libraryLog.warn(`Could not read the installed ${name} in ${dir}`, e);
63
+ }
64
+ }
65
+ return undefined;
66
+ }
67
+ /**
68
+ * Fills in packages no signature database knows from the copy installed on this machine: a package that CRAN
69
+ * archived (`maptools`, `rgdal`, ...) is in no database, but if it is installed, its `NAMESPACE` states its
70
+ * exports just as well. Off unless `solver.sigdb.installedLibrary.enabled` says otherwise, and consulted only
71
+ * for a package nothing else could resolve, so it never overrides a database entry.
72
+ */
73
+ class FlowrAnalyzerPackageVersionsLibraryPlugin extends flowr_analyzer_package_versions_plugin_1.FlowrAnalyzerPackageVersionsPlugin {
74
+ name = 'flowr-analyzer-package-version-library-plugin';
75
+ description = 'Recovers the exports of packages no database knows from their installed copy.';
76
+ version = new semver_1.SemVer('0.1.0');
77
+ overrides;
78
+ /** @param overrides - options replacing what `solver.sigdb.installedLibrary` states, `enabled` included */
79
+ constructor(overrides) {
80
+ super();
81
+ this.overrides = overrides;
82
+ }
83
+ process(ctx) {
84
+ const opts = { ...ctx.config.solver.sigdb.installedLibrary, ...this.overrides };
85
+ if (!opts.enabled) {
86
+ return;
87
+ }
88
+ const only = opts.packages?.map(p => new RegExp(p)) ?? [];
89
+ /* walking the library directories is only worth it once something actually goes unresolved */
90
+ let roots;
91
+ ctx.deps.addLazyResolver((name, existing) => {
92
+ if (existing?.namespaceInfo !== undefined || (only.length > 0 && !only.some(p => p.test(name)))) {
93
+ return undefined;
94
+ }
95
+ roots ??= libraryRoots(opts, ctx.files.root());
96
+ return installedPackage(name, roots);
97
+ });
98
+ }
99
+ }
100
+ exports.FlowrAnalyzerPackageVersionsLibraryPlugin = FlowrAnalyzerPackageVersionsLibraryPlugin;
101
+ //# sourceMappingURL=flowr-analyzer-package-versions-library-plugin.js.map
@@ -13,6 +13,30 @@ export type SigDbSource = PackageSignatureSource | string;
13
13
  * dispatch: an export `generic.class` is a method when the `generic` is itself exported (e.g. `print.foo`).
14
14
  */
15
15
  export declare function reconstructS3Generics(exported: readonly string[]): Map<string, string[]>;
16
+ /**
17
+ * The packages exporting one name: the sole exporter bare, the rivals as an array. Roughly 95% of the names in a
18
+ * bundle are exported by exactly one package, so giving those an array of their own would cost more than the
19
+ * index itself.
20
+ */
21
+ export type ExportIndexEntry = string | string[];
22
+ /**
23
+ * The reverse `export name -> packages exporting it` view of a signature source, each entry ordered by download
24
+ * count (descending, ties by name) so whoever has to pick one exporter starts with the package a script most
25
+ * likely means.
26
+ *
27
+ * Building the view reads every package blob of a bundle, which is why {@link of} memoizes it on the source
28
+ * object rather than on the caller: signature sources are opened once per process (see {@link getSharedSigSource})
29
+ * and are immutable, so every analyzer mounting the same bundle shares one index instead of re-scanning the
30
+ * database per analysis. It is deliberately analyzer-independent -- self-package exclusion belongs to the caller
31
+ * (see {@link FlowrAnalyzerPackageVersionsSigDbPlugin.packagesExporting}), not to the index.
32
+ */
33
+ export declare const ExportIndex: {
34
+ readonly name: "ExportIndex";
35
+ /** The index of `src`, built on first use and shared by every later caller; see {@link ExportIndex}. */
36
+ readonly of: (this: void, src: PackageSignatureSource) => ReadonlyMap<string, ExportIndexEntry>;
37
+ /** The packages an {@link ExportIndexEntry} names, as a list; empty when no package exports the name. */
38
+ readonly owners: (this: void, entry: ExportIndexEntry | undefined) => readonly string[];
39
+ };
16
40
  /**
17
41
  * Resolves `library(pkg)` / `use(pkg, fn)` from precomputed `flowr-sigdb` databases via the
18
42
  * {@link PackageSignatureSource} contract. For an R-core package it picks the version shipped with the assumed
@@ -28,8 +52,8 @@ export declare class FlowrAnalyzerPackageVersionsSigDbPlugin extends FlowrAnalyz
28
52
  /** the `additionalPaths` the current {@link sources} were assembled with, so a later config resolves a rebuild */
29
53
  private sourcesKey;
30
54
  private analyzerCtx;
31
- /** cached reverse index `export name -> packages exporting it`, built once per source set (see {@link packagesExporting}) */
32
- private exportIndex;
55
+ /** `packagesExporting` answers, merged across the source set and self-filtered; the scan itself is {@link ExportIndex} */
56
+ private exportsByName;
33
57
  /** `pkg@assumedR` keys already reported via {@link baseVersionFor}'s fallback, so the info is logged once */
34
58
  private readonly baseFallbacksLogged;
35
59
  /** installed package versions for `versionSelection: 'system'`, read once from R (see {@link warmInstalledVersions}) */
@@ -73,17 +97,12 @@ export declare class FlowrAnalyzerPackageVersionsSigDbPlugin extends FlowrAnalyz
73
97
  /**
74
98
  * Packages in the loaded sources (respecting `self`-package exclusion) that export `name`, **most downloaded
75
99
  * first**, so whoever has to pick one (or show only a few) starts with the package a script most likely means.
76
- * Backed by a reverse index built once per source set, so repeated hint lookups (e.g. from the
77
- * `undefined-symbol` linter) do not re-scan every package. The first call still pays one full pass over the
78
- * sources.
100
+ * Backed by {@link ExportIndex}, a reverse index built once per *source* (and hence shared by every analyzer
101
+ * mounting the same bundle), so repeated hint lookups (e.g. from the `undefined-symbol` linter) do not re-scan
102
+ * every package. Self-package exclusion is applied here rather than baked into the index, which keeps the
103
+ * index analyzer-independent.
79
104
  */
80
105
  packagesExporting(name: string): readonly string[];
81
- /**
82
- * One pass over every loaded source building `export name -> packages`, honoring self-package exclusion.
83
- * Each list ends up sorted by download count (descending, ties by name), which the sort at the end does
84
- * once per name rather than at every lookup.
85
- */
86
- private buildExportIndex;
87
106
  /**
88
107
  * The raw sources in priority order: explicit constructor sources, `$FLOWR_SIGDB`, then **every** bundled
89
108
  * database discovered in the data dirs (see {@link defaultSigDbPaths}), so an extra bundle dropped next to
@@ -36,7 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
36
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.FlowrAnalyzerPackageVersionsSigDbPlugin = exports.sigDbLog = exports.SigDbPluginName = void 0;
39
+ exports.FlowrAnalyzerPackageVersionsSigDbPlugin = exports.ExportIndex = exports.sigDbLog = exports.SigDbPluginName = void 0;
40
40
  exports.reconstructS3Generics = reconstructS3Generics;
41
41
  const flowr_analyzer_package_versions_plugin_1 = require("./flowr-analyzer-package-versions-plugin");
42
42
  const semver_1 = require("semver");
@@ -110,6 +110,58 @@ function reconstructS3Generics(exported) {
110
110
  }
111
111
  return generics;
112
112
  }
113
+ /** the built {@link ExportIndex} of each source, see {@link ExportIndex.of} for why it is keyed by the source */
114
+ const exportIndices = new WeakMap();
115
+ /**
116
+ * The reverse `export name -> packages exporting it` view of a signature source, each entry ordered by download
117
+ * count (descending, ties by name) so whoever has to pick one exporter starts with the package a script most
118
+ * likely means.
119
+ *
120
+ * Building the view reads every package blob of a bundle, which is why {@link of} memoizes it on the source
121
+ * object rather than on the caller: signature sources are opened once per process (see {@link getSharedSigSource})
122
+ * and are immutable, so every analyzer mounting the same bundle shares one index instead of re-scanning the
123
+ * database per analysis. It is deliberately analyzer-independent -- self-package exclusion belongs to the caller
124
+ * (see {@link FlowrAnalyzerPackageVersionsSigDbPlugin.packagesExporting}), not to the index.
125
+ */
126
+ exports.ExportIndex = {
127
+ name: 'ExportIndex',
128
+ /** The index of `src`, built on first use and shared by every later caller; see {@link ExportIndex}. */
129
+ of(src) {
130
+ const cached = exportIndices.get(src);
131
+ if (cached !== undefined) {
132
+ return cached;
133
+ }
134
+ const index = new Map();
135
+ for (const pkg of src.packageNames()) {
136
+ for (const exp of src.lookup(pkg)?.exported ?? []) {
137
+ const owners = index.get(exp);
138
+ if (owners === undefined) {
139
+ index.set(exp, pkg);
140
+ }
141
+ else if (typeof owners === 'string') {
142
+ if (owners !== pkg) {
143
+ index.set(exp, [owners, pkg]);
144
+ }
145
+ }
146
+ else if (owners[owners.length - 1] !== pkg) {
147
+ owners.push(pkg);
148
+ }
149
+ }
150
+ }
151
+ // sorting once per name here beats sorting at every lookup
152
+ for (const owners of index.values()) {
153
+ if (typeof owners !== 'string') {
154
+ owners.sort((a, b) => src.downloads(b) - src.downloads(a) || a.localeCompare(b));
155
+ }
156
+ }
157
+ exportIndices.set(src, index);
158
+ return index;
159
+ },
160
+ /** The packages an {@link ExportIndexEntry} names, as a list; empty when no package exports the name. */
161
+ owners(entry) {
162
+ return entry === undefined ? [] : typeof entry === 'string' ? [entry] : entry;
163
+ }
164
+ };
113
165
  /**
114
166
  * Resolves `library(pkg)` / `use(pkg, fn)` from precomputed `flowr-sigdb` databases via the
115
167
  * {@link PackageSignatureSource} contract. For an R-core package it picks the version shipped with the assumed
@@ -125,8 +177,8 @@ class FlowrAnalyzerPackageVersionsSigDbPlugin extends flowr_analyzer_package_ver
125
177
  /** the `additionalPaths` the current {@link sources} were assembled with, so a later config resolves a rebuild */
126
178
  sourcesKey;
127
179
  analyzerCtx;
128
- /** cached reverse index `export name -> packages exporting it`, built once per source set (see {@link packagesExporting}) */
129
- exportIndex;
180
+ /** `packagesExporting` answers, merged across the source set and self-filtered; the scan itself is {@link ExportIndex} */
181
+ exportsByName = new Map();
130
182
  /** `pkg@assumedR` keys already reported via {@link baseVersionFor}'s fallback, so the info is logged once */
131
183
  baseFallbacksLogged = new Set();
132
184
  /** installed package versions for `versionSelection: 'system'`, read once from R (see {@link warmInstalledVersions}) */
@@ -137,7 +189,7 @@ class FlowrAnalyzerPackageVersionsSigDbPlugin extends flowr_analyzer_package_ver
137
189
  resetAssembled() {
138
190
  this.sources = undefined;
139
191
  this.sourcesKey = undefined;
140
- this.exportIndex = undefined;
192
+ this.exportsByName = new Map();
141
193
  }
142
194
  constructor(...sources) {
143
195
  super();
@@ -254,48 +306,38 @@ class FlowrAnalyzerPackageVersionsSigDbPlugin extends flowr_analyzer_package_ver
254
306
  /**
255
307
  * Packages in the loaded sources (respecting `self`-package exclusion) that export `name`, **most downloaded
256
308
  * first**, so whoever has to pick one (or show only a few) starts with the package a script most likely means.
257
- * Backed by a reverse index built once per source set, so repeated hint lookups (e.g. from the
258
- * `undefined-symbol` linter) do not re-scan every package. The first call still pays one full pass over the
259
- * sources.
309
+ * Backed by {@link ExportIndex}, a reverse index built once per *source* (and hence shared by every analyzer
310
+ * mounting the same bundle), so repeated hint lookups (e.g. from the `undefined-symbol` linter) do not re-scan
311
+ * every package. Self-package exclusion is applied here rather than baked into the index, which keeps the
312
+ * index analyzer-independent.
260
313
  */
261
314
  packagesExporting(name) {
262
315
  if (!(0, config_1.isSigDbEnabled)(this.analyzerCtx?.config)) {
263
316
  return [];
264
317
  }
265
- this.exportIndex ??= this.buildExportIndex();
266
- return this.exportIndex.get(name) ?? [];
267
- }
268
- /**
269
- * One pass over every loaded source building `export name -> packages`, honoring self-package exclusion.
270
- * Each list ends up sorted by download count (descending, ties by name), which the sort at the end does
271
- * once per name rather than at every lookup.
272
- */
273
- buildExportIndex() {
274
- const index = new Map();
275
- const downloads = new Map();
276
- for (const src of this.loadSources()) {
277
- for (const pkg of src.packageNames()) {
278
- if (this.isSelfPackage(pkg)) {
279
- continue;
280
- }
281
- downloads.set(pkg, Math.max(downloads.get(pkg) ?? 0, src.downloads(pkg)));
282
- for (const exp of src.lookup(pkg)?.exported ?? []) {
283
- const owners = index.get(exp);
284
- if (owners === undefined) {
285
- index.set(exp, [pkg]);
286
- }
287
- else if (!owners.includes(pkg)) {
288
- owners.push(pkg);
289
- }
318
+ const cached = this.exportsByName.get(name);
319
+ if (cached !== undefined) {
320
+ return cached;
321
+ }
322
+ const sources = this.loadSources();
323
+ const seen = new Set();
324
+ const owners = [];
325
+ for (const src of sources) {
326
+ for (const pkg of exports.ExportIndex.owners(exports.ExportIndex.of(src).get(name))) {
327
+ if (!seen.has(pkg) && !this.isSelfPackage(pkg)) {
328
+ seen.add(pkg);
329
+ owners.push(pkg);
290
330
  }
291
331
  }
292
332
  }
293
- for (const owners of index.values()) {
294
- if (owners.length > 1) {
295
- owners.sort((a, b) => (downloads.get(b) ?? 0) - (downloads.get(a) ?? 0) || a.localeCompare(b));
296
- }
333
+ // each source's list is already sorted; a merge of several needs one more pass to be globally ordered
334
+ if (owners.length > 1 && sources.length > 1) {
335
+ /* the comparator runs O(n log n) times, so each package is counted once up front */
336
+ const downloads = new Map(owners.map(pkg => [pkg, sources.reduce((m, s) => Math.max(m, s.has(pkg) ? s.downloads(pkg) : 0), 0)]));
337
+ owners.sort((a, b) => downloads.get(b) - downloads.get(a) || a.localeCompare(b));
297
338
  }
298
- return index;
339
+ this.exportsByName.set(name, owners);
340
+ return owners;
299
341
  }
300
342
  /**
301
343
  * The raw sources in priority order: explicit constructor sources, `$FLOWR_SIGDB`, then **every** bundled
@@ -26,11 +26,12 @@ import { FlowrAnalyzerGitignoreProjectDiscoveryPlugin, FlowrAnalyzerIgnoreFilePr
26
26
  import { FlowrAnalyzerDefaultProjectDiscoveryPlugin, FlowrAnalyzerFullProjectDiscoveryPlugin } from './project-discovery/flowr-analyzer-project-discovery-plugin';
27
27
  import { FlowrAnalyzerRprofileFilePlugin } from './file-plugins/flowr-analyzer-rprofile-file-plugin';
28
28
  import { FlowrAnalyzerLoadingOrderRprofilePlugin } from './loading-order-plugins/flowr-analyzer-loading-order-rprofile-plugin';
29
+ import { FlowrAnalyzerPackageVersionsLibraryPlugin } from './package-version-plugins/flowr-analyzer-package-versions-library-plugin';
29
30
  import { FlowrAnalyzerLoadingOrderIncludedFilesPlugin } from './loading-order-plugins/flowr-analyzer-loading-order-included-files-plugin';
30
31
  /**
31
32
  * The built-in Flowr Analyzer plugins that are always available.
32
33
  */
33
- export declare const BuiltInPlugins: [["file:description", typeof FlowrAnalyzerDescriptionFilePlugin], ["versions:description", typeof FlowrAnalyzerPackageVersionsDescriptionFilePlugin], ["versions:sigdb", typeof FlowrAnalyzerPackageVersionsSigDbPlugin], ["versions:renv", typeof FlowrAnalyzerPackageVersionsRenvPlugin], ["versions:rv", typeof FlowrAnalyzerPackageVersionsRvPlugin], ["versions:uvr", typeof FlowrAnalyzerPackageVersionsUvrPlugin], ["versions:packrat", typeof FlowrAnalyzerPackageVersionsPackratPlugin], ["versions:session-info", typeof FlowrAnalyzerPackageVersionsSessionInfoPlugin], ["loading-order:description", typeof FlowrAnalyzerLoadingOrderDescriptionFilePlugin], ["loading-order:implicit-sources", typeof FlowrAnalyzerLoadingOrderImplicitSourcesPlugin], ["loading-order:rprofile", typeof FlowrAnalyzerLoadingOrderRprofilePlugin], ["loading-order:included-files", typeof FlowrAnalyzerLoadingOrderIncludedFilesPlugin], ["meta:description", typeof FlowrAnalyzerMetaDescriptionFilePlugin], ["meta:rproject", typeof FlowrAnalyzerMetaRProjectFilePlugin], ["meta:uvr", typeof FlowrAnalyzerMetaUvrManifestFilePlugin], ["file-roles:vignette", typeof FlowrAnalyzerMetaVignetteFilesPlugin], ["file-roles:test", typeof FlowrAnalyzerMetaTestFilesPlugin], ["file-roles:inst", typeof FlowrAnalyzerMetaInstFilesPlugin], ["file:rmd", typeof FlowrAnalyzerRmdFilePlugin], ["file:qmd", typeof FlowrAnalyzerQmdFilePlugin], ["file:rnw", typeof FlowrAnalyzerSweaveFilePlugin], ["file:ipynb", typeof FlowrAnalyzerJupyterFilePlugin], ["file:namespace", typeof FlowrAnalyzerNamespaceFilesPlugin], ["versions:namespace", typeof FlowrAnalyzerPackageVersionsNamespaceFilePlugin], ["file:news", typeof FlowrAnalyzerNewsFilePlugin], ["file:rda", typeof FlowrAnalyzerRdaFilePlugin], ["file:license", typeof FlowrAnalyzerLicenseFilePlugin], ["file:virtualenv", typeof FlowrAnalyzerVirtualEnvFilePlugin], ["file:rproject", typeof FlowrAnalyzerRProjectFilePlugin], ["file:uvr", typeof FlowrAnalyzerUvrManifestFilePlugin], ["file:rprofile", typeof FlowrAnalyzerRprofileFilePlugin], ["project-discovery:gitignore", typeof FlowrAnalyzerGitignoreProjectDiscoveryPlugin], ["project-discovery:rbuildignore", typeof FlowrAnalyzerRbuildignoreProjectDiscoveryPlugin], ["project-discovery:ignore-files", typeof FlowrAnalyzerIgnoreFileProjectDiscoveryPlugin], ["project-discovery:default", typeof FlowrAnalyzerDefaultProjectDiscoveryPlugin], ["project-discovery:full", typeof FlowrAnalyzerFullProjectDiscoveryPlugin]];
34
+ export declare const BuiltInPlugins: [["file:description", typeof FlowrAnalyzerDescriptionFilePlugin], ["versions:description", typeof FlowrAnalyzerPackageVersionsDescriptionFilePlugin], ["versions:sigdb", typeof FlowrAnalyzerPackageVersionsSigDbPlugin], ["versions:library", typeof FlowrAnalyzerPackageVersionsLibraryPlugin], ["versions:renv", typeof FlowrAnalyzerPackageVersionsRenvPlugin], ["versions:rv", typeof FlowrAnalyzerPackageVersionsRvPlugin], ["versions:uvr", typeof FlowrAnalyzerPackageVersionsUvrPlugin], ["versions:packrat", typeof FlowrAnalyzerPackageVersionsPackratPlugin], ["versions:session-info", typeof FlowrAnalyzerPackageVersionsSessionInfoPlugin], ["loading-order:description", typeof FlowrAnalyzerLoadingOrderDescriptionFilePlugin], ["loading-order:implicit-sources", typeof FlowrAnalyzerLoadingOrderImplicitSourcesPlugin], ["loading-order:rprofile", typeof FlowrAnalyzerLoadingOrderRprofilePlugin], ["loading-order:included-files", typeof FlowrAnalyzerLoadingOrderIncludedFilesPlugin], ["meta:description", typeof FlowrAnalyzerMetaDescriptionFilePlugin], ["meta:rproject", typeof FlowrAnalyzerMetaRProjectFilePlugin], ["meta:uvr", typeof FlowrAnalyzerMetaUvrManifestFilePlugin], ["file-roles:vignette", typeof FlowrAnalyzerMetaVignetteFilesPlugin], ["file-roles:test", typeof FlowrAnalyzerMetaTestFilesPlugin], ["file-roles:inst", typeof FlowrAnalyzerMetaInstFilesPlugin], ["file:rmd", typeof FlowrAnalyzerRmdFilePlugin], ["file:qmd", typeof FlowrAnalyzerQmdFilePlugin], ["file:rnw", typeof FlowrAnalyzerSweaveFilePlugin], ["file:ipynb", typeof FlowrAnalyzerJupyterFilePlugin], ["file:namespace", typeof FlowrAnalyzerNamespaceFilesPlugin], ["versions:namespace", typeof FlowrAnalyzerPackageVersionsNamespaceFilePlugin], ["file:news", typeof FlowrAnalyzerNewsFilePlugin], ["file:rda", typeof FlowrAnalyzerRdaFilePlugin], ["file:license", typeof FlowrAnalyzerLicenseFilePlugin], ["file:virtualenv", typeof FlowrAnalyzerVirtualEnvFilePlugin], ["file:rproject", typeof FlowrAnalyzerRProjectFilePlugin], ["file:uvr", typeof FlowrAnalyzerUvrManifestFilePlugin], ["file:rprofile", typeof FlowrAnalyzerRprofileFilePlugin], ["project-discovery:gitignore", typeof FlowrAnalyzerGitignoreProjectDiscoveryPlugin], ["project-discovery:rbuildignore", typeof FlowrAnalyzerRbuildignoreProjectDiscoveryPlugin], ["project-discovery:ignore-files", typeof FlowrAnalyzerIgnoreFileProjectDiscoveryPlugin], ["project-discovery:default", typeof FlowrAnalyzerDefaultProjectDiscoveryPlugin], ["project-discovery:full", typeof FlowrAnalyzerFullProjectDiscoveryPlugin]];
34
35
  export type BuiltInFlowrPluginName = typeof BuiltInPlugins[number][0];
35
36
  export type BuiltInFlowrPluginArgs<N extends BuiltInFlowrPluginName> = N extends typeof BuiltInPlugins[number][0] ? ConstructorParameters<Extract<typeof BuiltInPlugins[number], [N, PluginProducer]>[1]> : never;
36
37
  type PluginProducer = new (...args: never[]) => FlowrAnalyzerPlugin;
@@ -32,6 +32,7 @@ const flowr_analyzer_ignore_file_project_discovery_plugin_1 = require("./project
32
32
  const flowr_analyzer_project_discovery_plugin_1 = require("./project-discovery/flowr-analyzer-project-discovery-plugin");
33
33
  const flowr_analyzer_rprofile_file_plugin_1 = require("./file-plugins/flowr-analyzer-rprofile-file-plugin");
34
34
  const flowr_analyzer_loading_order_rprofile_plugin_1 = require("./loading-order-plugins/flowr-analyzer-loading-order-rprofile-plugin");
35
+ const flowr_analyzer_package_versions_library_plugin_1 = require("./package-version-plugins/flowr-analyzer-package-versions-library-plugin");
35
36
  const flowr_analyzer_loading_order_included_files_plugin_1 = require("./loading-order-plugins/flowr-analyzer-loading-order-included-files-plugin");
36
37
  /**
37
38
  * The built-in Flowr Analyzer plugins that are always available.
@@ -40,6 +41,7 @@ exports.BuiltInPlugins = [
40
41
  ['file:description', flowr_analyzer_description_file_plugin_1.FlowrAnalyzerDescriptionFilePlugin],
41
42
  ['versions:description', flowr_analyzer_package_versions_description_file_plugin_1.FlowrAnalyzerPackageVersionsDescriptionFilePlugin],
42
43
  ['versions:sigdb', flowr_analyzer_package_versions_sigdb_plugin_1.FlowrAnalyzerPackageVersionsSigDbPlugin],
44
+ ['versions:library', flowr_analyzer_package_versions_library_plugin_1.FlowrAnalyzerPackageVersionsLibraryPlugin],
43
45
  ['versions:renv', flowr_analyzer_package_versions_lockfile_plugin_1.FlowrAnalyzerPackageVersionsRenvPlugin],
44
46
  ['versions:rv', flowr_analyzer_package_versions_lockfile_plugin_1.FlowrAnalyzerPackageVersionsRvPlugin],
45
47
  ['versions:uvr', flowr_analyzer_package_versions_lockfile_plugin_1.FlowrAnalyzerPackageVersionsUvrPlugin],
@@ -60,6 +60,10 @@ function readManifestDate(manifestFile) {
60
60
  const SigDbScopeOrder = ['full', 'current', 'base'];
61
61
  /** layouts a bundled sigdb may sit in, relative to a search root -- the root itself (e.g. a `$FLOWR_SIGDB_DIR` data mount), then the dev `src`, build `dist` and data-dir layouts */
62
62
  const SigDbSubDirs = ['', 'data/sigdb', 'src/data/sigdb', 'dist/src/data/sigdb'];
63
+ /** a `<scope>.manifest.json`, in any of the codecs we can read */
64
+ const ManifestFilePattern = new RegExp(`\\.manifest\\.json${codec_1.CompressedExtPattern}$`);
65
+ /** a `<name>.sigs.ndjson` bundle, in any of the codecs we can read */
66
+ const BundleFilePattern = new RegExp(`${schema_1.SigDbExt.replace(/\./g, '\\.')}${codec_1.CompressedExtPattern}$`);
63
67
  function sigDbBundleDirs() {
64
68
  if (typeof node_fs_1.default?.readdirSync !== 'function') {
65
69
  return [];
@@ -169,13 +173,13 @@ function defaultSigDbPaths(searchRoots) {
169
173
  catch {
170
174
  continue; // directory does not exist on this root
171
175
  }
176
+ const dir = node_path_1.default.join(base, sub);
172
177
  for (const file of entries) {
173
- const full = node_path_1.default.join(base, sub, file);
174
- if (new RegExp(`\\.manifest\\.json${codec_1.CompressedExtPattern}$`).test(file)) {
175
- keep(manifests, (0, codec_1.stripCompressedExt)(file), full, node_path_1.default.join(base, sub));
178
+ if (ManifestFilePattern.test(file)) {
179
+ keep(manifests, (0, codec_1.stripCompressedExt)(file), node_path_1.default.join(dir, file), dir);
176
180
  }
177
- else if (new RegExp(`${schema_1.SigDbExt.replace(/\./g, '\\.')}${codec_1.CompressedExtPattern}$`).test(file) && !file.includes('.dict' + schema_1.SigDbExt)) {
178
- keep(standalones, (0, codec_1.stripCompressedExt)(file), full, node_path_1.default.join(base, sub));
181
+ else if (BundleFilePattern.test(file) && !file.includes('.dict' + schema_1.SigDbExt)) {
182
+ keep(standalones, (0, codec_1.stripCompressedExt)(file), node_path_1.default.join(dir, file), dir);
179
183
  }
180
184
  }
181
185
  }
@@ -1,26 +1,13 @@
1
1
  import type { FunctionArgument } from '../../dataflow/graph/graph';
2
2
  import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
3
3
  import type { SigParameter } from './decode';
4
- /**
5
- * The {@link pMatch} parameter spec for a *known* signature (e.g. one resolved from the signature database):
6
- * every formal parameter name maps to itself as its own target. A `...` parameter is kept as-is, so `pMatch`
7
- * collects the overflow/unmatched arguments into it exactly as R does; a signature without `...` simply leaves
8
- * extra arguments unbound.
9
- */
4
+ /** the {@link pMatch} parameter spec of a *known* signature: every formal maps to itself as its own target */
10
5
  export declare function signatureParameterSpec(signature: readonly SigParameter[]): Record<string, string>;
11
6
  /**
12
- * Match a call's `args` against a *known* signature using R's argument-matching rules via the canonical
13
- * {@link pMatch} (exact name, then partial `pmatch`, then positional; `...` collects the rest). Returns a map
14
- * from parameter name to the id(s) of the argument(s) bound to it, so
15
- * `matchArgumentsToSignature(ggplotCall.args, ggplotSignature).get('data')` yields the node(s) passed as
16
- * ggplot's `data` argument. The signature typically comes from the signature database (a {@link SigParameter}
17
- * list, e.g. via `PackageSignatureSource.functions(pkg)`).
7
+ * {@link pMatch|Matches} a call's `args` against a *known* signature (typically from the signature database via
8
+ * `PackageSignatureSource.functions(pkg)`), returning per parameter name the id(s) bound to it, e.g.
9
+ * `matchArgumentsToSignature(ggplotCall.args, ggplotSignature).get('data')`.
18
10
  */
19
11
  export declare function matchArgumentsToSignature(args: readonly FunctionArgument[], signature: readonly SigParameter[]): Map<string, NodeId[]>;
20
- /**
21
- * The id(s) of the argument bound to a single named `parameter` of a *known* signature, or `undefined` when
22
- * nothing is bound to it. A convenience over {@link matchArgumentsToSignature} for the common
23
- * "give me one parameter's argument" query, e.g.
24
- * `argumentForParameter(ggplotCall.args, ggplotSignature, 'data')` returns ggplot's `data` argument node(s).
25
- */
12
+ /** the id(s) {@link matchArgumentsToSignature} binds to a single `parameter`, `undefined` if nothing is */
26
13
  export declare function argumentForParameter(args: readonly FunctionArgument[], signature: readonly SigParameter[], parameter: string): NodeId[] | undefined;
@@ -4,12 +4,7 @@ exports.signatureParameterSpec = signatureParameterSpec;
4
4
  exports.matchArgumentsToSignature = matchArgumentsToSignature;
5
5
  exports.argumentForParameter = argumentForParameter;
6
6
  const linker_1 = require("../../dataflow/internal/linker");
7
- /**
8
- * The {@link pMatch} parameter spec for a *known* signature (e.g. one resolved from the signature database):
9
- * every formal parameter name maps to itself as its own target. A `...` parameter is kept as-is, so `pMatch`
10
- * collects the overflow/unmatched arguments into it exactly as R does; a signature without `...` simply leaves
11
- * extra arguments unbound.
12
- */
7
+ /** the {@link pMatch} parameter spec of a *known* signature: every formal maps to itself as its own target */
13
8
  function signatureParameterSpec(signature) {
14
9
  const spec = {};
15
10
  for (const p of signature) {
@@ -18,22 +13,14 @@ function signatureParameterSpec(signature) {
18
13
  return spec;
19
14
  }
20
15
  /**
21
- * Match a call's `args` against a *known* signature using R's argument-matching rules via the canonical
22
- * {@link pMatch} (exact name, then partial `pmatch`, then positional; `...` collects the rest). Returns a map
23
- * from parameter name to the id(s) of the argument(s) bound to it, so
24
- * `matchArgumentsToSignature(ggplotCall.args, ggplotSignature).get('data')` yields the node(s) passed as
25
- * ggplot's `data` argument. The signature typically comes from the signature database (a {@link SigParameter}
26
- * list, e.g. via `PackageSignatureSource.functions(pkg)`).
16
+ * {@link pMatch|Matches} a call's `args` against a *known* signature (typically from the signature database via
17
+ * `PackageSignatureSource.functions(pkg)`), returning per parameter name the id(s) bound to it, e.g.
18
+ * `matchArgumentsToSignature(ggplotCall.args, ggplotSignature).get('data')`.
27
19
  */
28
20
  function matchArgumentsToSignature(args, signature) {
29
21
  return (0, linker_1.pMatch)(args, signatureParameterSpec(signature));
30
22
  }
31
- /**
32
- * The id(s) of the argument bound to a single named `parameter` of a *known* signature, or `undefined` when
33
- * nothing is bound to it. A convenience over {@link matchArgumentsToSignature} for the common
34
- * "give me one parameter's argument" query, e.g.
35
- * `argumentForParameter(ggplotCall.args, ggplotSignature, 'data')` returns ggplot's `data` argument node(s).
36
- */
23
+ /** the id(s) {@link matchArgumentsToSignature} binds to a single `parameter`, `undefined` if nothing is */
37
24
  function argumentForParameter(args, signature, parameter) {
38
25
  return matchArgumentsToSignature(args, signature).get(parameter);
39
26
  }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.executeCallGraphQuery = executeCallGraphQuery;
4
4
  const log_1 = require("../../../util/log");
5
5
  const expand_library_internals_1 = require("./expand-library-internals");
6
+ const call_graph_1 = require("../../../dataflow/graph/call-graph");
6
7
  /**
7
8
  * Executes the given call graph queries.
8
9
  */
@@ -17,7 +18,8 @@ async function executeCallGraphQuery({ analyzer }, queries) {
17
18
  '.meta': {
18
19
  timing: Date.now() - startTime
19
20
  },
20
- graph: expand ? (0, expand_library_internals_1.expandCallGraphLibraryInternals)(graph, analyzer.inspectContext().deps) : graph
21
+ graph: expand ? (0, expand_library_internals_1.expandCallGraphLibraryInternals)(graph, analyzer.inspectContext().deps) : graph,
22
+ unreachable: queries.some(q => q.reportUnreachable) ? call_graph_1.CallGraph.unreachableCalls(graph) : undefined
21
23
  };
22
24
  }
23
25
  //# sourceMappingURL=call-graph-query-executor.js.map
@@ -13,10 +13,14 @@ export interface CallGraphQuery extends BaseQueryFormat {
13
13
  * `transitiveCallees` (a no-op if no signature database is loaded). Default false.
14
14
  */
15
15
  readonly expandLibraryInternals?: boolean;
16
+ /** If set, also report the calls top-level execution never reaches. Default false. */
17
+ readonly reportUnreachable?: boolean;
16
18
  }
17
19
  export interface CallGraphQueryResult extends BaseQueryResult {
18
20
  /** Please be aware that this is the graph in its JSON representation, use {@link DataflowGraph#fromJson} if the result is serialized */
19
21
  readonly graph: CallGraph;
22
+ /** the calls no top-level execution reaches, only present if {@link CallGraphQuery#reportUnreachable} was set */
23
+ readonly unreachable?: readonly NodeId[];
20
24
  }
21
25
  export declare const CallGraphQueryDefinition: {
22
26
  readonly title: "Call-Graph Query";
@@ -16,11 +16,15 @@ exports.CallGraphQueryDefinition = {
16
16
  const out = queryResults;
17
17
  result.push(`Query: ${(0, ansi_1.bold)('call-graph', formatter)} (${(0, time_1.printAsMs)(out['.meta'].timing, 0)})`);
18
18
  result.push(` ╰ [Call Graph](${call_graph_1.CallGraph.visualize.mermaid.url(out.graph)})`);
19
+ if (out.unreachable !== undefined) {
20
+ result.push(` ╰ Unreachable calls: {${out.unreachable.join(', ')}}`);
21
+ }
19
22
  return true;
20
23
  },
21
24
  schema: joi_1.default.object({
22
25
  type: joi_1.default.string().valid('call-graph').required().description('The type of the query.'),
23
26
  expandLibraryInternals: joi_1.default.boolean().optional().description('Expand library/built-in leaf calls into their internal callees via the signature database (default false).'),
27
+ reportUnreachable: joi_1.default.boolean().optional().description('Also report the calls that top-level execution never reaches (default false).'),
24
28
  }).description('A query to compute the Call Graph of the analyzed project.'),
25
29
  flattenInvolvedNodes: queryResults => {
26
30
  const flattened = [];
@@ -15,6 +15,7 @@ const assert_1 = require("../../../util/assert");
15
15
  const log_1 = require("../../../util/log");
16
16
  const model_1 = require("../../../r-bridge/lang-4.x/ast/model/model");
17
17
  const graph_1 = require("../../../dataflow/graph/graph");
18
+ const link_devices_1 = require("./link-devices");
18
19
  /**
19
20
  * Executes a dependencies query.
20
21
  */
@@ -64,6 +65,9 @@ async function executeDependenciesQuery({ analyzer, }, queries) {
64
65
  }
65
66
  return [c, results];
66
67
  })));
68
+ if (results.visualize?.length && results.write?.length) {
69
+ (0, link_devices_1.linkPlotsToDevices)(results.write, results.visualize, dataflow, normalize);
70
+ }
67
71
  return {
68
72
  '.meta': {
69
73
  timing: Date.now() - now
@@ -191,10 +195,13 @@ function getResults(queries, { dataflow, config, normalize }, results, kind, fun
191
195
  resolvedValue = info.stringReplacements[resolvedValue];
192
196
  }
193
197
  const dep = resolvedValue ? d.getDependency(resolvedValue) ?? undefined : undefined;
198
+ const lexeme = getLexeme(value, arg);
194
199
  finalResults.push((0, objects_1.compactRecord)({
195
200
  nodeId: id,
196
201
  functionName,
197
- lexemeOfArgument: getLexeme(value, arg),
202
+ /* only a value we could not make sense of is worth asking about further */
203
+ argumentId: lexeme === undefined ? undefined : arg,
204
+ lexemeOfArgument: lexeme,
198
205
  linkedIds: linked?.length ? linked : undefined,
199
206
  value: resolvedValue ?? info.defaultValue ?? defaultValue,
200
207
  versionConstraints: dep?.versionConstraints,
@@ -207,7 +214,7 @@ function getResults(queries, { dataflow, config, normalize }, results, kind, fun
207
214
  }
208
215
  return finalResults;
209
216
  function getLexeme(argument, id) {
210
- if ((argument && argument !== dependencies_query_format_1.Unknown) || !id) {
217
+ if ((argument && argument !== dependencies_query_format_1.Unknown && argument !== dependencies_query_format_1.Constant) || !id) {
211
218
  return undefined;
212
219
  }
213
220
  let get = normalize.idMap.get(id);
@@ -221,7 +228,7 @@ function collectValuesFromLinks(args, data, linkedIds) {
221
228
  if (!linkedIds || linkedIds.length === 0) {
222
229
  return undefined;
223
230
  }
224
- const hasAtLeastAValue = args !== undefined && args.values().flatMap(x => Array.from(x)).toArray().some(v => v !== dependencies_query_format_1.Unknown && v !== undefined);
231
+ const hasAtLeastAValue = args !== undefined && args.values().flatMap(x => Array.from(x)).toArray().some(v => v !== dependencies_query_format_1.Unknown && v !== dependencies_query_format_1.Constant && v !== undefined);
225
232
  const map = new Map();
226
233
  for (const linkedId of linkedIds) {
227
234
  if (typeof linkedId !== 'object' || !linkedId.info) {
@@ -9,7 +9,10 @@ import type { Range } from 'semver';
9
9
  import type { AsyncOrSync, MarkOptional } from 'ts-essentials';
10
10
  import type { NamespaceInfo } from '../../../project/plugins/file-plugins/files/flowr-namespace-file';
11
11
  import { Identifier } from '../../../dataflow/environments/identifier';
12
+ /** The value could not be resolved, e.g. a path assembled at runtime. Such a dependency may be missing or fetchable. */
12
13
  export declare const Unknown = "unknown";
14
+ /** The value resolved, but to data given inline rather than to a path (`matrix(0, 2, 2)`, `data.frame(a = 1)`). */
15
+ export declare const Constant = "constant";
13
16
  export interface DependencyCategorySettings {
14
17
  queryDisplayName?: string;
15
18
  functions: FunctionInfo[];
@@ -33,6 +36,12 @@ export declare const DefaultDependencyCategories: {
33
36
  readonly defaultValue: "unknown";
34
37
  readonly additionalAnalysis: (data: BasicQueryData, ignoreDefault: boolean, _functions: FunctionInfo[], _queryResults: CallContextQueryResult, result: DependencyInfo[]) => Promise<void>;
35
38
  };
39
+ readonly remote: {
40
+ readonly queryDisplayName: "Remote Installs";
41
+ readonly functions: FunctionInfo[];
42
+ readonly defaultValue: "unknown";
43
+ readonly additionalAnalysis: (_data: BasicQueryData, _ignoreDefault: boolean, _functions: FunctionInfo[], _queryResults: CallContextQueryResult, result: DependencyInfo[]) => void;
44
+ };
36
45
  readonly source: {
37
46
  readonly queryDisplayName: "Sourced Files";
38
47
  readonly functions: FunctionInfo[];
@@ -82,13 +91,22 @@ export interface DependencyInfo extends Record<string, unknown> {
82
91
  /** the called name; an {@link Identifier}, so a namespaced call like `maps::map` keeps its package */
83
92
  functionName: Identifier;
84
93
  linkedIds?: readonly NodeId[];
85
- /** the lexeme is presented whenever the specific info is of {@link Unknown} */
94
+ /**
95
+ * the argument the value was read from, under the id the {@link InputSourcesQuery} reports it with: ask that
96
+ * query about {@link nodeId} and this entry of its answer says whether the value is a glob, a prompt, ...
97
+ */
98
+ argumentId?: NodeId;
99
+ /** the lexeme is presented whenever the specific info is {@link Unknown} or {@link Constant} */
86
100
  lexemeOfArgument?: string;
87
101
  /** The library name, file, source, destination etc. being sourced, read from, or written to. */
88
102
  value?: string;
89
103
  versionConstraints?: readonly Range[];
90
104
  derivedRange?: Range;
91
105
  namespaceInfo?: NamespaceInfo;
106
+ /** the package the dependency provides, when the {@link value} names it only implicitly (a `user/repo` slug, a clone url) */
107
+ packageName?: string;
108
+ /** the revision such a reference pins, the `v1.2` of `user/repo@v1.2` */
109
+ revision?: string;
92
110
  }
93
111
  /**
94
112
  * Gets all dependency categories, including user-defined additional categories.