@eagleoutice/flowr 2.13.9 → 2.13.11
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.
- package/README.md +40 -40
- package/config.d.ts +50 -2
- package/config.js +37 -6
- package/dataflow/environments/apply-kill.js +4 -4
- package/dataflow/environments/built-in-props.d.ts +28 -4
- package/dataflow/environments/built-in-props.js +31 -8
- package/dataflow/environments/built-in.d.ts +7 -2
- package/dataflow/environments/built-in.js +10 -12
- package/dataflow/environments/default-builtin-config.d.ts +46 -6
- package/dataflow/environments/default-builtin-config.js +30 -16
- package/dataflow/environments/environment.d.ts +16 -0
- package/dataflow/environments/environment.js +114 -26
- package/dataflow/environments/identifier.d.ts +6 -0
- package/dataflow/environments/identifier.js +18 -5
- package/dataflow/environments/query-fn-props.js +34 -2
- package/dataflow/environments/reference-to-maybe.js +1 -1
- package/dataflow/environments/resolve-by-name.js +16 -6
- package/dataflow/environments/resolve-helper.d.ts +43 -0
- package/dataflow/environments/resolve-helper.js +47 -0
- package/dataflow/eval/resolve/alias-tracking.js +45 -1
- package/dataflow/eval/resolve/resolve-argument.js +25 -17
- package/dataflow/eval/resolve/resolve-strings.d.ts +17 -0
- package/dataflow/eval/resolve/resolve-strings.js +16 -9
- package/dataflow/eval/resolve/resolve.js +3 -1
- package/dataflow/graph/call-graph.d.ts +7 -0
- package/dataflow/graph/call-graph.js +103 -0
- package/dataflow/graph/df-helper.d.ts +50 -1
- package/dataflow/graph/df-helper.js +63 -0
- package/dataflow/graph/graph.d.ts +5 -8
- package/dataflow/graph/graph.js +24 -13
- package/dataflow/internal/linker.d.ts +5 -5
- package/dataflow/internal/linker.js +31 -92
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +3 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +4 -30
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +7 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-load.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +5 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-with.d.ts +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +5 -6
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +32 -14
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +16 -4
- package/dataflow/internal/process/functions/call/known-call-handling.js +29 -8
- package/documentation/data/faq/faqs.js +1 -1
- package/documentation/data/faq/wiki-faq-store.js +3 -2
- package/documentation/data/server/doc-data-server-messages.js +1 -1
- package/documentation/doc-readme.js +1 -1
- package/documentation/doc-util/doc-files.d.ts +5 -0
- package/documentation/doc-util/doc-files.js +13 -3
- package/documentation/doc-util/doc-sigdb.d.ts +9 -0
- package/documentation/doc-util/doc-sigdb.js +32 -0
- package/documentation/wiki-analyzer.js +10 -10
- package/documentation/wiki-core.js +1 -1
- package/documentation/wiki-dataflow-graph.js +3 -3
- package/documentation/wiki-interface.js +13 -2
- package/documentation/wiki-linting-and-testing.js +13 -13
- package/documentation/wiki-mk/doc-context.d.ts +1 -1
- package/documentation/wiki-mk/doc-context.js +9 -5
- package/documentation/wiki-normalized-ast.js +1 -1
- package/documentation/wiki-overview.js +2 -2
- package/documentation/wiki-query.js +4 -1
- package/documentation/wiki-setup.js +3 -3
- package/documentation/wiki-signature-database.js +2 -5
- package/gas.d.ts +6 -0
- package/gas.js +7 -1
- package/linter/linter-rules.d.ts +1 -1
- package/linter/rules/syntactically-valid.d.ts +12 -1
- package/linter/rules/syntactically-valid.js +88 -17
- package/package.json +7 -8
- package/project/attached-packages.d.ts +13 -0
- package/project/attached-packages.js +30 -0
- package/project/context/flowr-analyzer-context.d.ts +15 -0
- package/project/context/flowr-analyzer-context.js +14 -3
- package/project/context/flowr-analyzer-files-context.d.ts +11 -0
- package/project/context/flowr-analyzer-files-context.js +3 -0
- package/project/context/flowr-analyzer-incremental-analysis-context.d.ts +4 -0
- package/project/context/flowr-analyzer-incremental-analysis-context.js +69 -0
- package/project/context/flowr-analyzer-loading-order-context.d.ts +8 -0
- package/project/context/flowr-analyzer-loading-order-context.js +23 -2
- package/project/dependency-version-space.d.ts +33 -11
- package/project/dependency-version-space.js +58 -32
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +52 -24
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-library-plugin.d.ts +22 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-library-plugin.js +101 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +30 -11
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +79 -37
- package/project/plugins/plugin-registry.d.ts +2 -1
- package/project/plugins/plugin-registry.js +2 -0
- package/project/sigdb/manifest.js +9 -5
- package/project/sigdb/reader.d.ts +20 -0
- package/project/sigdb/reader.js +93 -10
- package/project/sigdb/signature-match.d.ts +5 -18
- package/project/sigdb/signature-match.js +5 -18
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +1 -1
- package/queries/catalog/call-graph-query/call-graph-query-executor.js +3 -1
- package/queries/catalog/call-graph-query/call-graph-query-format.d.ts +4 -0
- package/queries/catalog/call-graph-query/call-graph-query-format.js +4 -0
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +11 -3
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +25 -1
- package/queries/catalog/dependencies-query/dependencies-query-format.js +22 -2
- package/queries/catalog/dependencies-query/function-info/library-functions.js +7 -1
- package/queries/catalog/dependencies-query/function-info/read-functions.js +5 -5
- package/queries/catalog/dependencies-query/function-info/remote-functions.d.ts +18 -0
- package/queries/catalog/dependencies-query/function-info/remote-functions.js +46 -0
- package/queries/catalog/dependencies-query/function-info/visualize-functions.js +52 -2
- package/queries/catalog/dependencies-query/function-info/write-functions.js +8 -4
- package/queries/catalog/dependencies-query/link-devices.d.ts +16 -0
- package/queries/catalog/dependencies-query/link-devices.js +104 -0
- package/queries/catalog/dice-query/dice-query-format.d.ts +2 -0
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +25 -6
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +37 -6
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +17 -4
- package/queries/catalog/happens-before-query/happens-before-query-executor.js +2 -1
- package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +14 -0
- package/queries/catalog/happens-before-query/happens-before-query-format.js +18 -2
- package/queries/catalog/input-sources-query/input-sources-query-format.js +4 -0
- package/queries/catalog/input-sources-query/input-types.d.ts +10 -0
- package/queries/catalog/input-sources-query/input-types.js +10 -0
- package/queries/catalog/location-map-query/location-map-query-executor.js +16 -6
- package/queries/catalog/location-map-query/location-map-query-format.d.ts +15 -1
- package/queries/catalog/location-map-query/location-map-query-format.js +22 -5
- package/queries/catalog/signature-query/signature-query-executor.js +3 -0
- package/queries/catalog/signature-query/signature-query-format.d.ts +5 -0
- package/queries/catalog/slice-query-options.d.ts +11 -1
- package/queries/catalog/slice-query-options.js +8 -4
- package/queries/catalog/static-slice-query/static-slice-query-executor.js +4 -1
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +5 -1
- package/queries/query.d.ts +1 -1
- package/r-bridge/lang-4.x/ast/model/model.d.ts +23 -2
- package/r-bridge/lang-4.x/ast/model/model.js +44 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +8 -8
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +9 -46
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +0 -5
- package/r-bridge/lang-4.x/ast/model/processing/node-id.js +6 -3
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +1 -1
- package/reconstruct/reconstruct.d.ts +9 -0
- package/reconstruct/reconstruct.js +1 -0
- package/search/flowr-search-filters.d.ts +25 -1
- package/search/flowr-search-filters.js +42 -7
- package/search/search-executor/search-generators.js +7 -2
- package/search/search-executor/search-transformer.js +4 -1
- package/slicing/criterion/parse.d.ts +5 -25
- package/slicing/criterion/parse.js +15 -20
- package/slicing/static/fingerprint.js +18 -6
- package/slicing/static/slice-call.js +2 -2
- package/slicing/static/slicer-types.d.ts +10 -0
- package/slicing/static/static-slicer.d.ts +1 -1
- package/slicing/static/static-slicer.js +29 -6
- package/slicing/static/visiting-queue.d.ts +12 -2
- package/slicing/static/visiting-queue.js +28 -3
- package/util/arg-matching.d.ts +18 -0
- package/util/arg-matching.js +70 -0
- package/util/collections/bimap.d.ts +21 -1
- package/util/collections/bimap.js +43 -7
- package/util/r-regex.js +19 -1
- package/util/range.d.ts +7 -8
- package/util/range.js +10 -11
- package/util/version.js +1 -1
package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts
CHANGED
|
@@ -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
|
-
/**
|
|
32
|
-
private
|
|
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
|
|
77
|
-
* `undefined-symbol` linter) do not re-scan
|
|
78
|
-
*
|
|
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
|
package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js
CHANGED
|
@@ -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
|
-
/**
|
|
129
|
-
|
|
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.
|
|
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
|
|
258
|
-
* `undefined-symbol` linter) do not re-scan
|
|
259
|
-
*
|
|
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
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
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
|
-
|
|
294
|
-
|
|
295
|
-
|
|
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
|
-
|
|
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
|
-
|
|
174
|
-
|
|
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 (
|
|
178
|
-
keep(standalones, (0, codec_1.stripCompressedExt)(file),
|
|
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
|
}
|
|
@@ -133,6 +133,16 @@ export declare class SigDatabase implements PackageSignatureSource {
|
|
|
133
133
|
/** parsed blobs by blob index so repeated lookups skip the re-read + JSON.parse; FIFO-bounded to cap memory */
|
|
134
134
|
private readonly blobCache;
|
|
135
135
|
private static readonly BlobCacheCap;
|
|
136
|
+
/** a version's function indices plus its `name -> index` view; FIFO-bounded like {@link blobCache} */
|
|
137
|
+
private readonly versionFnCache;
|
|
138
|
+
/**
|
|
139
|
+
* Which names a package can offer at all, as sorted dictionary ids -- integers, so the whole database of
|
|
140
|
+
* them costs a few MB where the parsed blobs cost hundreds. Filled for a package the first time its blob is
|
|
141
|
+
* read, so a later lookup for a name it does not have answers without touching the file again.
|
|
142
|
+
*/
|
|
143
|
+
private readonly nameIdsOfBlob;
|
|
144
|
+
/** dictionary id per name asked for, so only the names someone actually queried are ever resolved */
|
|
145
|
+
private readonly nameIds;
|
|
136
146
|
/** reverse index `S3 class -> owning package`, over every package's latest version; built once (see {@link classOwner}) */
|
|
137
147
|
private classIndex;
|
|
138
148
|
private readonly fd;
|
|
@@ -164,6 +174,16 @@ export declare class SigDatabase implements PackageSignatureSource {
|
|
|
164
174
|
packageNames(): string[];
|
|
165
175
|
/** load a single package's blob by seeking to its line (undefined if absent); cached by blob index */
|
|
166
176
|
blob(pkg: string): PkgBlob | undefined;
|
|
177
|
+
/** the dictionary id of `name`, or `-1` if the dictionary does not hold it, so no package can offer it */
|
|
178
|
+
private nameId;
|
|
179
|
+
/**
|
|
180
|
+
* Whether `pkg` can offer `name` in any of its versions, answered from {@link nameIdsOfBlob} alone.
|
|
181
|
+
* `true` whenever nothing is known about the package yet, so this only ever skips work that would have
|
|
182
|
+
* found nothing: the ids cover every function record, of which a version selects a subset.
|
|
183
|
+
*/
|
|
184
|
+
private mayOffer;
|
|
185
|
+
/** store `value` under `key`, dropping the oldest entry first once the cache sits at {@link BlobCacheCap} */
|
|
186
|
+
private static cache;
|
|
167
187
|
/** seek to a byte range, read + decode the package blob there (no caching) */
|
|
168
188
|
private readBlobAt;
|
|
169
189
|
/** read every unique package blob in index order (used to re-hash a whole shard during verification) */
|
package/project/sigdb/reader.js
CHANGED
|
@@ -262,6 +262,16 @@ class SigDatabase {
|
|
|
262
262
|
/** parsed blobs by blob index so repeated lookups skip the re-read + JSON.parse; FIFO-bounded to cap memory */
|
|
263
263
|
blobCache = new Map();
|
|
264
264
|
static BlobCacheCap = 2048;
|
|
265
|
+
/** a version's function indices plus its `name -> index` view; FIFO-bounded like {@link blobCache} */
|
|
266
|
+
versionFnCache = new Map();
|
|
267
|
+
/**
|
|
268
|
+
* Which names a package can offer at all, as sorted dictionary ids -- integers, so the whole database of
|
|
269
|
+
* them costs a few MB where the parsed blobs cost hundreds. Filled for a package the first time its blob is
|
|
270
|
+
* read, so a later lookup for a name it does not have answers without touching the file again.
|
|
271
|
+
*/
|
|
272
|
+
nameIdsOfBlob = new Map();
|
|
273
|
+
/** dictionary id per name asked for, so only the names someone actually queried are ever resolved */
|
|
274
|
+
nameIds = new Map();
|
|
265
275
|
/** reverse index `S3 class -> owning package`, over every package's latest version; built once (see {@link classOwner}) */
|
|
266
276
|
classIndex;
|
|
267
277
|
fd;
|
|
@@ -351,14 +361,59 @@ class SigDatabase {
|
|
|
351
361
|
return undefined; // an in-memory database starts out with every blob cached
|
|
352
362
|
}
|
|
353
363
|
const blob = this.readBlobAt(this.index.blobs[blobIdx]);
|
|
354
|
-
if (this.
|
|
355
|
-
|
|
364
|
+
if (!this.nameIdsOfBlob.has(blobIdx)) {
|
|
365
|
+
this.nameIdsOfBlob.set(blobIdx, Int32Array.from(new Set(blob.fns.map(fn => fn[0]))).sort());
|
|
366
|
+
}
|
|
367
|
+
return SigDatabase.cache(this.blobCache, blobIdx, blob);
|
|
368
|
+
}
|
|
369
|
+
/** the dictionary id of `name`, or `-1` if the dictionary does not hold it, so no package can offer it */
|
|
370
|
+
nameId(name) {
|
|
371
|
+
let id = this.nameIds.get(name);
|
|
372
|
+
if (id === undefined) {
|
|
373
|
+
this.nameIds.set(name, id = this.strings.indexOf(name));
|
|
374
|
+
}
|
|
375
|
+
return id;
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Whether `pkg` can offer `name` in any of its versions, answered from {@link nameIdsOfBlob} alone.
|
|
379
|
+
* `true` whenever nothing is known about the package yet, so this only ever skips work that would have
|
|
380
|
+
* found nothing: the ids cover every function record, of which a version selects a subset.
|
|
381
|
+
*/
|
|
382
|
+
mayOffer(pkg, name) {
|
|
383
|
+
const blobIdx = this.index.pkgs[pkg];
|
|
384
|
+
const ids = blobIdx === undefined ? undefined : this.nameIdsOfBlob.get(blobIdx);
|
|
385
|
+
if (ids === undefined) {
|
|
386
|
+
return true;
|
|
387
|
+
}
|
|
388
|
+
const id = this.nameId(name);
|
|
389
|
+
if (id < 0) {
|
|
390
|
+
return false;
|
|
391
|
+
}
|
|
392
|
+
let lo = 0, hi = ids.length - 1;
|
|
393
|
+
while (lo <= hi) {
|
|
394
|
+
const mid = (lo + hi) >> 1;
|
|
395
|
+
if (ids[mid] === id) {
|
|
396
|
+
return true;
|
|
397
|
+
}
|
|
398
|
+
else if (ids[mid] < id) {
|
|
399
|
+
lo = mid + 1;
|
|
400
|
+
}
|
|
401
|
+
else {
|
|
402
|
+
hi = mid - 1;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
return false;
|
|
406
|
+
}
|
|
407
|
+
/** store `value` under `key`, dropping the oldest entry first once the cache sits at {@link BlobCacheCap} */
|
|
408
|
+
static cache(cache, key, value) {
|
|
409
|
+
if (cache.size >= SigDatabase.BlobCacheCap) {
|
|
410
|
+
const oldest = cache.keys().next().value;
|
|
356
411
|
if (oldest !== undefined) {
|
|
357
|
-
|
|
412
|
+
cache.delete(oldest);
|
|
358
413
|
}
|
|
359
414
|
}
|
|
360
|
-
|
|
361
|
-
return
|
|
415
|
+
cache.set(key, value);
|
|
416
|
+
return value;
|
|
362
417
|
}
|
|
363
418
|
/** seek to a byte range, read + decode the package blob there (no caching) */
|
|
364
419
|
readBlobAt([start, bytes]) {
|
|
@@ -414,19 +469,47 @@ class SigDatabase {
|
|
|
414
469
|
if (!blob || !meta) {
|
|
415
470
|
return undefined;
|
|
416
471
|
}
|
|
472
|
+
// keyed on the resolved version, so `undefined` and the version it stands for share one entry
|
|
417
473
|
const ver = (0, sigdb_version_1.resolveVersion)(blob, meta[0], version);
|
|
418
|
-
|
|
419
|
-
|
|
474
|
+
if (ver === undefined) {
|
|
475
|
+
return undefined;
|
|
476
|
+
}
|
|
477
|
+
const key = `${pkg}\0${ver}`;
|
|
478
|
+
const cached = this.versionFnCache.get(key);
|
|
479
|
+
if (cached !== undefined) {
|
|
480
|
+
return cached;
|
|
481
|
+
}
|
|
482
|
+
const idxs = (0, decode_1.versionFnIndices)(blob, ver);
|
|
483
|
+
if (idxs === undefined) {
|
|
484
|
+
return undefined;
|
|
485
|
+
}
|
|
486
|
+
return SigDatabase.cache(this.versionFnCache, key, { blob, idxs });
|
|
420
487
|
}
|
|
421
488
|
functions(pkg, version) {
|
|
422
489
|
const r = this.versionFns(pkg, version);
|
|
423
490
|
return r?.idxs.map(i => (0, decode_1.decodeFunction)(this.strings, r.blob, i));
|
|
424
491
|
}
|
|
425
492
|
functionByName(pkg, name, version) {
|
|
493
|
+
if (!this.mayOffer(pkg, name)) {
|
|
494
|
+
return undefined;
|
|
495
|
+
}
|
|
426
496
|
const r = this.versionFns(pkg, version);
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
497
|
+
if (r === undefined) {
|
|
498
|
+
return undefined;
|
|
499
|
+
}
|
|
500
|
+
if (r.byName === undefined) {
|
|
501
|
+
const byName = new Map();
|
|
502
|
+
for (const i of r.idxs) {
|
|
503
|
+
const fn = this.strings[r.blob.fns[i][0]];
|
|
504
|
+
// first record wins, as the linear scan did
|
|
505
|
+
if (!byName.has(fn)) {
|
|
506
|
+
byName.set(fn, i);
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
r.byName = byName;
|
|
510
|
+
}
|
|
511
|
+
const hit = r.byName.get(name);
|
|
512
|
+
return hit !== undefined ? (0, decode_1.decodeFunction)(this.strings, r.blob, hit) : undefined;
|
|
430
513
|
}
|
|
431
514
|
transitiveCallees(pkg, name, version) {
|
|
432
515
|
const fns = this.functions(pkg, version);
|
|
@@ -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
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
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
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
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
|
}
|
|
@@ -55,7 +55,7 @@ function satisfiesCallTargets(info, graph, callTarget) {
|
|
|
55
55
|
* for performance and scoping reasons, flowR will not identify the global linkage,
|
|
56
56
|
* including any potential built-in mapping.
|
|
57
57
|
*/
|
|
58
|
-
const reResolved = (0, resolve_by_name_1.
|
|
58
|
+
const reResolved = (0, resolve_by_name_1.resolveByNameAnyType)(info.name, info.environment);
|
|
59
59
|
if (reResolved?.some(t => node_id_1.NodeId.isBuiltIn(t.definedAt))) {
|
|
60
60
|
builtIn = true;
|
|
61
61
|
}
|
|
@@ -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 = [];
|