@eagleoutice/flowr 2.13.8 → 2.13.9
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/dataflow/cluster.js +48 -24
- package/dataflow/environments/default-builtin-config.d.ts +30 -0
- package/dataflow/environments/default-builtin-config.js +9 -0
- package/dataflow/graph/graph.d.ts +1 -0
- package/dataflow/graph/graph.js +21 -6
- package/package.json +2 -2
- package/project/dependency-version-space.d.ts +18 -3
- package/project/dependency-version-space.js +40 -6
- package/project/plugins/package-version-plugins/package.d.ts +2 -0
- package/project/plugins/package-version-plugins/package.js +4 -0
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.d.ts +4 -2
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +25 -0
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.js +11 -1
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +3 -2
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +8 -0
- package/queries/catalog/dependencies-query/dependencies-query-format.js +47 -5
- package/queries/catalog/dependencies-query/function-info/library-functions.js +2 -1
- package/queries/catalog/dependencies-query/function-info/read-functions.js +26 -0
- package/queries/catalog/dependencies-query/function-info/test-functions.d.ts +2 -0
- package/queries/catalog/dependencies-query/function-info/test-functions.js +33 -31
- package/queries/catalog/dependencies-query/function-info/write-functions.js +20 -1
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +1 -1
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +1 -1
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +1 -1
- package/queries/catalog/happens-before-query/happens-before-query-format.js +3 -2
- package/queries/catalog/static-slice-query/static-slice-query-format.js +1 -0
- package/r-bridge/data/data.d.ts +1 -1
- package/r-bridge/data/data.js +1 -1
- package/slicing/criterion/parse.d.ts +2 -1
- package/slicing/criterion/parse.js +37 -1
- package/slicing/static/fingerprint.d.ts +1 -1
- package/slicing/static/fingerprint.js +40 -8
- package/slicing/static/static-slicer.js +1 -1
- package/slicing/static/visiting-queue.d.ts +4 -2
- package/slicing/static/visiting-queue.js +10 -1
- package/util/version.js +1 -1
package/dataflow/cluster.js
CHANGED
|
@@ -10,41 +10,65 @@ const assert_1 = require("../util/assert");
|
|
|
10
10
|
function findAllClusters(graph) {
|
|
11
11
|
const clusters = [];
|
|
12
12
|
// we reverse the vertices since dependencies usually point "backwards" from later nodes
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
const ids = graph.vertices(true).map(([id]) => id).toArray().reverse();
|
|
14
|
+
/* walking the ids picks the same start nodes in the same order as draining the set did, without re-opening an
|
|
15
|
+
* iterator over the shrinking set for every cluster */
|
|
16
|
+
const notReached = new Set(ids);
|
|
17
|
+
/* `graph.ingoingEdges` rebuilds the reverse adjacency by scanning every edge of the graph, and clustering asks
|
|
18
|
+
* for it once per node; building it a single time turns that quadratic sweep into one pass */
|
|
19
|
+
const incoming = new Map();
|
|
20
|
+
for (const [source, outgoing] of graph.edges()) {
|
|
21
|
+
for (const [target, edge] of outgoing) {
|
|
22
|
+
const into = incoming.get(target);
|
|
23
|
+
if (into === undefined) {
|
|
24
|
+
incoming.set(target, new Map([[source, edge]]));
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
into.set(source, edge);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
for (const startNode of ids) {
|
|
32
|
+
if (!notReached.delete(startNode)) {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
17
35
|
clusters.push({
|
|
18
36
|
startNode: startNode,
|
|
19
|
-
members: Array.from(makeCluster(graph, startNode, notReached)),
|
|
37
|
+
members: Array.from(makeCluster(graph, startNode, notReached, incoming)),
|
|
20
38
|
hasUnknownSideEffects: graph.unknownSideEffects.has(startNode)
|
|
21
39
|
});
|
|
22
40
|
}
|
|
23
41
|
return clusters;
|
|
24
42
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
43
|
+
/* one shared accumulator, filled iteratively: merging a set per node cost a copy of the whole cluster per member
|
|
44
|
+
* (quadratic in the cluster size), and the recursion ran as deep as the cluster was large */
|
|
45
|
+
function makeCluster(graph, from, notReached, incoming) {
|
|
28
46
|
const nodes = new Set([from]);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
47
|
+
const pending = [from];
|
|
48
|
+
while (pending.length > 0) {
|
|
49
|
+
const current = pending.pop();
|
|
50
|
+
const info = graph.getVertex(current);
|
|
51
|
+
(0, assert_1.guard)(info !== undefined, () => `Vertex ${current} not found in graph`);
|
|
52
|
+
function reach(dest) {
|
|
53
|
+
if (notReached.delete(dest)) {
|
|
54
|
+
nodes.add(dest);
|
|
55
|
+
pending.push(dest);
|
|
36
56
|
}
|
|
37
57
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
// don't cluster for function content if it isn't returned
|
|
43
|
-
if (edge_1.DfEdge.doesNotIncludeType(e, edge_1.EdgeType.Returns) && info.onlyBuiltin && info.name === '{') {
|
|
44
|
-
continue;
|
|
58
|
+
// cluster function def exit points
|
|
59
|
+
if (info.tag === vertex_1.VertexType.FunctionDefinition) {
|
|
60
|
+
for (const { nodeId } of info.exitPoints) {
|
|
61
|
+
reach(nodeId);
|
|
45
62
|
}
|
|
46
|
-
|
|
47
|
-
|
|
63
|
+
}
|
|
64
|
+
// cluster adjacent edges
|
|
65
|
+
for (const edges of [graph.outgoingEdges(current), incoming.get(current)]) {
|
|
66
|
+
for (const [dest, e] of edges ?? []) {
|
|
67
|
+
// don't cluster for function content if it isn't returned
|
|
68
|
+
if (edge_1.DfEdge.doesNotIncludeType(e, edge_1.EdgeType.Returns) && info.onlyBuiltin && info.name === '{') {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
reach(dest);
|
|
48
72
|
}
|
|
49
73
|
}
|
|
50
74
|
}
|
|
@@ -2221,6 +2221,36 @@ export declare const WrittenBuiltinDefinitions: [{
|
|
|
2221
2221
|
};
|
|
2222
2222
|
};
|
|
2223
2223
|
readonly assumePrimitive: true;
|
|
2224
|
+
}, {
|
|
2225
|
+
readonly type: "function";
|
|
2226
|
+
readonly names: [Identifier];
|
|
2227
|
+
readonly processor: BuiltInProcName.Default;
|
|
2228
|
+
readonly config: {
|
|
2229
|
+
readonly libFn: true;
|
|
2230
|
+
readonly props: number;
|
|
2231
|
+
readonly sig: [["expr", ArgProp.Forced], ["env", ArgProp.Value], ["ns", ArgProp.Value]];
|
|
2232
|
+
};
|
|
2233
|
+
readonly assumePrimitive: false;
|
|
2234
|
+
}, {
|
|
2235
|
+
readonly type: "function";
|
|
2236
|
+
readonly names: [Identifier];
|
|
2237
|
+
readonly processor: BuiltInProcName.Default;
|
|
2238
|
+
readonly config: {
|
|
2239
|
+
readonly libFn: true;
|
|
2240
|
+
readonly props: number;
|
|
2241
|
+
readonly sig: [["pkg", ArgProp.Value], ["expr", ArgProp.Forced], ["env", ArgProp.Value]];
|
|
2242
|
+
};
|
|
2243
|
+
readonly assumePrimitive: false;
|
|
2244
|
+
}, {
|
|
2245
|
+
readonly type: "function";
|
|
2246
|
+
readonly names: [Identifier];
|
|
2247
|
+
readonly processor: BuiltInProcName.Default;
|
|
2248
|
+
readonly config: {
|
|
2249
|
+
readonly libFn: true;
|
|
2250
|
+
readonly props: number;
|
|
2251
|
+
readonly sig: [["ns", ArgProp.Value]];
|
|
2252
|
+
};
|
|
2253
|
+
readonly assumePrimitive: false;
|
|
2224
2254
|
}, {
|
|
2225
2255
|
readonly type: "function";
|
|
2226
2256
|
readonly names: [Identifier];
|
|
@@ -990,6 +990,15 @@ exports.WrittenBuiltinDefinitions = [
|
|
|
990
990
|
},
|
|
991
991
|
assumePrimitive: true
|
|
992
992
|
},
|
|
993
|
+
{ type: 'function', names: [identifier_1.Identifier.from(['on_load', "rlang" /* PkgName.Rlang */])],
|
|
994
|
+
processor: built_in_proc_name_1.BuiltInProcName.Default,
|
|
995
|
+
config: { libFn: true, props: built_in_props_1.CallProp.Invisible | built_in_props_1.CallProp.Scope | built_in_props_1.CallProp.MayPure, sig: [['expr', built_in_props_1.ArgProp.Forced], ['env', built_in_props_1.ArgProp.Value], ['ns', built_in_props_1.ArgProp.Value]] }, assumePrimitive: false },
|
|
996
|
+
{ type: 'function', names: [identifier_1.Identifier.from(['on_package_load', "rlang" /* PkgName.Rlang */])],
|
|
997
|
+
processor: built_in_proc_name_1.BuiltInProcName.Default,
|
|
998
|
+
config: { libFn: true, props: built_in_props_1.CallProp.Invisible | built_in_props_1.CallProp.Scope | built_in_props_1.CallProp.MayPure, sig: [['pkg', built_in_props_1.ArgProp.Value], ['expr', built_in_props_1.ArgProp.Forced], ['env', built_in_props_1.ArgProp.Value]] }, assumePrimitive: false },
|
|
999
|
+
{ type: 'function', names: [identifier_1.Identifier.from(['run_on_load', "rlang" /* PkgName.Rlang */])],
|
|
1000
|
+
processor: built_in_proc_name_1.BuiltInProcName.Default,
|
|
1001
|
+
config: { libFn: true, props: built_in_props_1.CallProp.Invisible | built_in_props_1.CallProp.Scope | built_in_props_1.CallProp.MayPure, sig: [['ns', built_in_props_1.ArgProp.Value]] }, assumePrimitive: false },
|
|
993
1002
|
/* `parse(text=)` turns text into an expression, with `file=` it reads that file */
|
|
994
1003
|
{ type: 'function', names: [identifier_1.Identifier.from(['parse', "base" /* PkgName.Base */])],
|
|
995
1004
|
processor: built_in_proc_name_1.BuiltInProcName.Default, config: { forceArgs: 'all', props: built_in_props_1.CallProp.Pure }, assumePrimitive: false },
|
|
@@ -210,6 +210,7 @@ export declare class DataflowGraph<Vertex extends DataflowGraphVertexInfo = Data
|
|
|
210
210
|
private vertexInformation;
|
|
211
211
|
/** All edges in the complete graph (including those nested in function definition) */
|
|
212
212
|
private edgeInformation;
|
|
213
|
+
private incomingIndex?;
|
|
213
214
|
private readonly types;
|
|
214
215
|
toJSON(): DataflowGraphJson;
|
|
215
216
|
/**
|
package/dataflow/graph/graph.js
CHANGED
|
@@ -178,6 +178,9 @@ class DataflowGraph {
|
|
|
178
178
|
vertexInformation = new Map();
|
|
179
179
|
/** All edges in the complete graph (including those nested in function definition) */
|
|
180
180
|
edgeInformation = new Map();
|
|
181
|
+
/* the reverse of `edgeInformation`, built on demand and dropped whenever an edge is added: rebuilding it per
|
|
182
|
+
* lookup made every caller asking for the ingoing edges of many nodes scan the whole graph once per node */
|
|
183
|
+
incomingIndex;
|
|
181
184
|
types = new Map();
|
|
182
185
|
toJSON() {
|
|
183
186
|
return {
|
|
@@ -226,14 +229,23 @@ class DataflowGraph {
|
|
|
226
229
|
return this.edgeInformation.get(id);
|
|
227
230
|
}
|
|
228
231
|
ingoingEdges(id) {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
const
|
|
232
|
-
|
|
233
|
-
|
|
232
|
+
if (this.incomingIndex === undefined) {
|
|
233
|
+
const index = new Map();
|
|
234
|
+
for (const [source, outgoing] of this.edgeInformation.entries()) {
|
|
235
|
+
for (const [target, edge] of outgoing) {
|
|
236
|
+
const into = index.get(target);
|
|
237
|
+
if (into === undefined) {
|
|
238
|
+
index.set(target, new Map([[source, edge]]));
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
into.set(source, edge);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
234
244
|
}
|
|
245
|
+
this.incomingIndex = index;
|
|
235
246
|
}
|
|
236
|
-
|
|
247
|
+
/* the historic contract is an (possibly empty) map for every id, never `undefined` */
|
|
248
|
+
return this.incomingIndex.get(id) ?? new Map();
|
|
237
249
|
}
|
|
238
250
|
/**
|
|
239
251
|
* Given a node in the normalized AST this either:
|
|
@@ -350,6 +362,7 @@ class DataflowGraph {
|
|
|
350
362
|
if (fromId === toId) {
|
|
351
363
|
return this;
|
|
352
364
|
}
|
|
365
|
+
this.incomingIndex = undefined;
|
|
353
366
|
let fromEdges = this.edgeInformation.get(fromId);
|
|
354
367
|
if (fromEdges === undefined) {
|
|
355
368
|
fromEdges = new Map([[toId, { types: type }]]);
|
|
@@ -409,6 +422,7 @@ class DataflowGraph {
|
|
|
409
422
|
}
|
|
410
423
|
}
|
|
411
424
|
mergeEdges(otherGraph) {
|
|
425
|
+
this.incomingIndex = undefined;
|
|
412
426
|
for (const [id, edges] of otherGraph.edgeInformation.entries()) {
|
|
413
427
|
let existing = this.edgeInformation.get(id);
|
|
414
428
|
if (existing === undefined) {
|
|
@@ -530,6 +544,7 @@ class DataflowGraph {
|
|
|
530
544
|
}
|
|
531
545
|
}
|
|
532
546
|
graph.edgeInformation = new Map(data.edgeInformation.map(([id, edges]) => [id, new Map(edges)]));
|
|
547
|
+
graph.incomingIndex = undefined;
|
|
533
548
|
for (const unknown of data._unknownSideEffects) {
|
|
534
549
|
graph._unknownSideEffects.add(unknown);
|
|
535
550
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eagleoutice/flowr",
|
|
3
|
-
"version": "2.13.
|
|
3
|
+
"version": "2.13.9",
|
|
4
4
|
"description": "Static Dataflow Analyzer and Program Slicer for the R Programming Language",
|
|
5
5
|
"types": "dist/src/index.d.ts",
|
|
6
6
|
"repository": {
|
|
@@ -208,7 +208,7 @@
|
|
|
208
208
|
"eslint-plugin-jsdoc": "^62.9.0",
|
|
209
209
|
"eslint-plugin-tsdoc": "^0.5.2",
|
|
210
210
|
"eslint-plugin-unused-imports": "^4.4.1",
|
|
211
|
-
"license-checker-rseidelsohn": "^
|
|
211
|
+
"license-checker-rseidelsohn": "^4.4.2",
|
|
212
212
|
"release-it": "^20.0.0",
|
|
213
213
|
"ts-node": "^10.9.2",
|
|
214
214
|
"typedoc": "^0.28.17",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { type Range } from 'semver';
|
|
9
9
|
import { type VersionString } from '../util/r-version';
|
|
10
10
|
import { type PackageSignatureSource } from './sigdb/reader';
|
|
11
|
-
import type { DecodedFunction } from './sigdb/decode';
|
|
11
|
+
import type { DecodedFunction, ResolvedDependency } from './sigdb/decode';
|
|
12
12
|
import { FunctionArgument, type DataflowGraph } from '../dataflow/graph/graph';
|
|
13
13
|
import type { ReadOnlyFlowrAnalyzerDependenciesContext } from './context/flowr-analyzer-dependencies-context';
|
|
14
14
|
import type { ReadonlyFlowrAnalysisProvider } from './flowr-analyzer';
|
|
@@ -284,8 +284,23 @@ export declare function timelinePackageKey(name: string, sources: readonly Packa
|
|
|
284
284
|
export declare function orderedCandidatesOf(src: PackageSignatureSource | undefined, name: string, surviving: SurvivingEntries, prefer: string | undefined, order: 'newest' | 'oldest'): OrderedCandidates | undefined;
|
|
285
285
|
/** the default explosion targets: every declared and used dependency (excluding `current`, the analyzed package's own namespace) */
|
|
286
286
|
export declare function defaultTargets(deps: ReadOnlyFlowrAnalyzerDependenciesContext, usage: ReadonlyMap<string, PackageUsage>): string[];
|
|
287
|
-
/**
|
|
288
|
-
export
|
|
287
|
+
/** the requirements one concrete version declares, as {@link isCoInstallable} reads them */
|
|
288
|
+
export type DependencyResolver = (pkg: string, version: VersionString) => readonly ResolvedDependency[] | undefined;
|
|
289
|
+
/**
|
|
290
|
+
* Whether the chosen versions can be loaded together. The per-package candidates are narrowed by requirements
|
|
291
|
+
* merged over *all* versions of the requiring package, so a combination can still pair a version with one that
|
|
292
|
+
* the version it was actually chosen alongside rules out (`library()` then reports the conflict). Packages
|
|
293
|
+
* outside the assignment and requirements without a version qualifier constrain nothing.
|
|
294
|
+
*/
|
|
295
|
+
export declare function isCoInstallable(versions: ReadonlyMap<string, VersionString>, declares: DependencyResolver): boolean;
|
|
296
|
+
/**
|
|
297
|
+
* Lazily yield concrete version assignments (one version per package) in odometer order over the per-package lists.
|
|
298
|
+
* With `declares`, a combination whose versions cannot be loaded together is skipped rather than proposed; `limit`
|
|
299
|
+
* bounds the combinations *considered* either way, so fewer than `limit` assignments may come out.
|
|
300
|
+
*/
|
|
301
|
+
export declare function assignmentsOf(perPackage: readonly OrderedCandidates[], limit: number, declares?: DependencyResolver): Generator<VersionAssignment>;
|
|
302
|
+
/** the {@link DependencyResolver} backed by the signature database a version space resolves each package in */
|
|
303
|
+
export declare function declaredDependenciesOf(space: VersionSpace): DependencyResolver;
|
|
289
304
|
/**
|
|
290
305
|
* Explode the guessed constraint space into concrete, signature-database-available version assignments: a lazy
|
|
291
306
|
* iterator over one chosen version per resolvable dependency. Each package's versions are ordered by preference
|
|
@@ -14,7 +14,9 @@ exports.survivingEntries = survivingEntries;
|
|
|
14
14
|
exports.timelinePackageKey = timelinePackageKey;
|
|
15
15
|
exports.orderedCandidatesOf = orderedCandidatesOf;
|
|
16
16
|
exports.defaultTargets = defaultTargets;
|
|
17
|
+
exports.isCoInstallable = isCoInstallable;
|
|
17
18
|
exports.assignmentsOf = assignmentsOf;
|
|
19
|
+
exports.declaredDependenciesOf = declaredDependenciesOf;
|
|
18
20
|
exports.explodeDependencyVersions = explodeDependencyVersions;
|
|
19
21
|
/**
|
|
20
22
|
* The dependency version space: for each dependency, the set of signature-database versions that survive the
|
|
@@ -854,8 +856,33 @@ function orderedCandidatesOf(src, name, surviving, prefer, order) {
|
|
|
854
856
|
function defaultTargets(deps, usage) {
|
|
855
857
|
return [...new Set([...deps.getDependencies().map(d => d.name), ...usage.keys()])].filter(name => name !== exports.ProjectPackage);
|
|
856
858
|
}
|
|
857
|
-
/**
|
|
858
|
-
|
|
859
|
+
/**
|
|
860
|
+
* Whether the chosen versions can be loaded together. The per-package candidates are narrowed by requirements
|
|
861
|
+
* merged over *all* versions of the requiring package, so a combination can still pair a version with one that
|
|
862
|
+
* the version it was actually chosen alongside rules out (`library()` then reports the conflict). Packages
|
|
863
|
+
* outside the assignment and requirements without a version qualifier constrain nothing.
|
|
864
|
+
*/
|
|
865
|
+
function isCoInstallable(versions, declares) {
|
|
866
|
+
for (const [pkg, version] of versions) {
|
|
867
|
+
for (const dep of declares(pkg, version) ?? []) {
|
|
868
|
+
const chosen = versions.get(dep.name);
|
|
869
|
+
if (chosen === undefined || dep.constraint === undefined) {
|
|
870
|
+
continue;
|
|
871
|
+
}
|
|
872
|
+
const range = r_version_1.RRange.parse(dep.constraint);
|
|
873
|
+
if (range !== undefined && !r_version_1.RRange.satisfies(chosen, range)) {
|
|
874
|
+
return false;
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
return true;
|
|
879
|
+
}
|
|
880
|
+
/**
|
|
881
|
+
* Lazily yield concrete version assignments (one version per package) in odometer order over the per-package lists.
|
|
882
|
+
* With `declares`, a combination whose versions cannot be loaded together is skipped rather than proposed; `limit`
|
|
883
|
+
* bounds the combinations *considered* either way, so fewer than `limit` assignments may come out.
|
|
884
|
+
*/
|
|
885
|
+
function* assignmentsOf(perPackage, limit, declares) {
|
|
859
886
|
if (perPackage.length === 0 || perPackage.some(p => p.versions.length === 0)) {
|
|
860
887
|
return;
|
|
861
888
|
}
|
|
@@ -865,7 +892,9 @@ function* assignmentsOf(perPackage, limit) {
|
|
|
865
892
|
for (let i = 0; i < perPackage.length; i++) {
|
|
866
893
|
versions.set(perPackage[i].pkg, perPackage[i].versions[idx[i]]);
|
|
867
894
|
}
|
|
868
|
-
|
|
895
|
+
if (declares === undefined || isCoInstallable(versions, declares)) {
|
|
896
|
+
yield { versions };
|
|
897
|
+
}
|
|
869
898
|
// advance the odometer: the last package varies fastest
|
|
870
899
|
let k = perPackage.length - 1;
|
|
871
900
|
for (; k >= 0; k--) {
|
|
@@ -885,7 +914,7 @@ async function orderedCandidatesFor(analyzer, options) {
|
|
|
885
914
|
const deps = ctx.deps;
|
|
886
915
|
const sources = deps.signatureSources();
|
|
887
916
|
if (sources.length === 0) {
|
|
888
|
-
return [];
|
|
917
|
+
return { candidates: [], declares: () => undefined };
|
|
889
918
|
}
|
|
890
919
|
const cutoff = options.date ? dateCutoff(options.date) : undefined;
|
|
891
920
|
// bound base packages by R only when genuinely known (a config pin, metadata, or detection); `auto` with nothing detected imposes no R ceiling
|
|
@@ -903,7 +932,11 @@ async function orderedCandidatesFor(analyzer, options) {
|
|
|
903
932
|
out.push(oc);
|
|
904
933
|
}
|
|
905
934
|
}
|
|
906
|
-
return out;
|
|
935
|
+
return { candidates: out, declares: declaredDependenciesOf(space) };
|
|
936
|
+
}
|
|
937
|
+
/** the {@link DependencyResolver} backed by the signature database a version space resolves each package in */
|
|
938
|
+
function declaredDependenciesOf(space) {
|
|
939
|
+
return (pkg, version) => space.resolve(pkg).src?.dependencies(pkg, version);
|
|
907
940
|
}
|
|
908
941
|
/**
|
|
909
942
|
* Explode the guessed constraint space into concrete, signature-database-available version assignments: a lazy
|
|
@@ -913,6 +946,7 @@ async function orderedCandidatesFor(analyzer, options) {
|
|
|
913
946
|
* {@link VersionExplodeOptions.limit} so an enormous product cannot run away.
|
|
914
947
|
*/
|
|
915
948
|
async function* explodeDependencyVersions(analyzer, options = {}) {
|
|
916
|
-
|
|
949
|
+
const { candidates, declares } = await orderedCandidatesFor(analyzer, options);
|
|
950
|
+
yield* assignmentsOf(candidates, options.limit ?? exports.DefaultExplodeLimit, declares);
|
|
917
951
|
}
|
|
918
952
|
//# sourceMappingURL=dependency-version-space.js.map
|
|
@@ -35,6 +35,8 @@ export declare class Package {
|
|
|
35
35
|
get resolvedVersion(): string | undefined;
|
|
36
36
|
get versionConstraints(): readonly Range[];
|
|
37
37
|
get derivedRange(): Range | undefined;
|
|
38
|
+
/** {@link derivedRange} if a source declared one, else the {@link resolvedVersion} the exports were read from. */
|
|
39
|
+
get effectiveRange(): Range | undefined;
|
|
38
40
|
constructor(info: {
|
|
39
41
|
name: string;
|
|
40
42
|
} & PackageOptions);
|
|
@@ -44,6 +44,10 @@ class Package {
|
|
|
44
44
|
this._derivedRange ??= this.deriveRange();
|
|
45
45
|
return this._derivedRange;
|
|
46
46
|
}
|
|
47
|
+
/** {@link derivedRange} if a source declared one, else the {@link resolvedVersion} the exports were read from. */
|
|
48
|
+
get effectiveRange() {
|
|
49
|
+
return this.derivedRange ?? (this._resolvedVersion !== undefined ? r_version_1.RRange.parse('=' + this._resolvedVersion) : undefined);
|
|
50
|
+
}
|
|
47
51
|
constructor(info) {
|
|
48
52
|
this.name = info.name;
|
|
49
53
|
this.addInfo(info);
|
|
@@ -7,6 +7,7 @@ import type { LinkToLastCall } from './call-context-query-format';
|
|
|
7
7
|
import type { PromotedLinkTo } from './call-context-query-executor';
|
|
8
8
|
import type { ReadonlyFlowrAnalysisProvider } from '../../../project/flowr-analyzer';
|
|
9
9
|
import type { ControlFlowGraph } from '../../../control-flow/control-flow-graph';
|
|
10
|
+
type KnownCalls = Map<NodeId, Required<DataflowGraphVertexFunctionCall>>;
|
|
10
11
|
export declare enum CallTargets {
|
|
11
12
|
/** call targets a function that is not defined locally in the script (e.g., the call targets a library function) */
|
|
12
13
|
OnlyGlobal = "global",
|
|
@@ -41,8 +42,9 @@ export declare function getValueOfArgument<Types extends readonly RType[] = read
|
|
|
41
42
|
* the known calls available.
|
|
42
43
|
* @see {@link identifyLinkToLastCallRelationSync} for the synchronous version.
|
|
43
44
|
*/
|
|
44
|
-
export declare function identifyLinkToLastCallRelation(from: NodeId, analyzer: ReadonlyFlowrAnalysisProvider, l: LinkToLastCall<RegExp> | PromotedLinkTo<LinkToLastCall<RegExp>>, knownCalls?:
|
|
45
|
+
export declare function identifyLinkToLastCallRelation(from: NodeId, analyzer: ReadonlyFlowrAnalysisProvider, l: LinkToLastCall<RegExp> | PromotedLinkTo<LinkToLastCall<RegExp>>, knownCalls?: KnownCalls): Promise<NodeId[]>;
|
|
45
46
|
/**
|
|
46
47
|
* Synchronous version of {@link identifyLinkToLastCallRelation}.
|
|
47
48
|
*/
|
|
48
|
-
export declare function identifyLinkToLastCallRelationSync(from: NodeId, cfg: ControlFlowGraph, graph: DataflowGraph, { callName, cascadeIf, ignoreIf }: LinkToLastCall<RegExp> | PromotedLinkTo<LinkToLastCall<RegExp>>, knownCalls?:
|
|
49
|
+
export declare function identifyLinkToLastCallRelationSync(from: NodeId, cfg: ControlFlowGraph, graph: DataflowGraph, { callName, cascadeIf, ignoreIf }: LinkToLastCall<RegExp> | PromotedLinkTo<LinkToLastCall<RegExp>>, knownCalls?: KnownCalls): NodeId[];
|
|
50
|
+
export {};
|
|
@@ -133,6 +133,25 @@ async function identifyLinkToLastCallRelation(from, analyzer, l, knownCalls) {
|
|
|
133
133
|
const cfg = (await analyzer.controlflow([], cfg_kind_1.CfgKind.WithDataflow)).graph;
|
|
134
134
|
return identifyLinkToLastCallRelationSync(from, cfg, graph, l, knownCalls);
|
|
135
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* Memoizes, per set of known calls and per `callName`, whether any call can match it at all. One link keeps the same
|
|
138
|
+
* `callName` object across every call site it is evaluated against, so identity is enough to key it.
|
|
139
|
+
*/
|
|
140
|
+
const candidatesPerCallSet = new WeakMap();
|
|
141
|
+
function anyCallMatches(knownCalls, callName, matches) {
|
|
142
|
+
let perName = candidatesPerCallSet.get(knownCalls);
|
|
143
|
+
if (perName === undefined) {
|
|
144
|
+
perName = new Map();
|
|
145
|
+
candidatesPerCallSet.set(knownCalls, perName);
|
|
146
|
+
}
|
|
147
|
+
const cached = perName.get(callName);
|
|
148
|
+
if (cached !== undefined) {
|
|
149
|
+
return cached;
|
|
150
|
+
}
|
|
151
|
+
const matched = knownCalls.values().some(matches);
|
|
152
|
+
perName.set(callName, matched);
|
|
153
|
+
return matched;
|
|
154
|
+
}
|
|
136
155
|
/**
|
|
137
156
|
* Synchronous version of {@link identifyLinkToLastCallRelation}.
|
|
138
157
|
*/
|
|
@@ -143,6 +162,12 @@ function identifyLinkToLastCallRelationSync(from, cfg, graph, { callName, cascad
|
|
|
143
162
|
const found = [];
|
|
144
163
|
const cNameCheck = callName instanceof RegExp ? ({ name }) => callName.test(identifier_1.Identifier.getName(name))
|
|
145
164
|
: ({ name }) => callName(identifier_1.Identifier.getName(name));
|
|
165
|
+
/* only a call matching `callName` is ever collected, so with none in the whole graph every walk below returns
|
|
166
|
+
* nothing: skipping them turns one reverse walk per call site into a single scan (a `sink` redirect in a
|
|
167
|
+
* script that never sinks is the common case) */
|
|
168
|
+
if (knownCalls !== undefined && !anyCallMatches(knownCalls, callName, cNameCheck)) {
|
|
169
|
+
return [];
|
|
170
|
+
}
|
|
146
171
|
const getVertex = knownCalls ?
|
|
147
172
|
(node) => knownCalls.get(node) :
|
|
148
173
|
(node) => {
|
|
@@ -4,6 +4,16 @@ exports.executeDataflowLensQuery = executeDataflowLensQuery;
|
|
|
4
4
|
const log_1 = require("../../../util/log");
|
|
5
5
|
const dfg_view_1 = require("../../../util/simple-df/dfg-view");
|
|
6
6
|
const vertex_1 = require("../../../dataflow/graph/vertex");
|
|
7
|
+
const arguments_1 = require("../../../abstract-interpretation/data-frame/mappers/arguments");
|
|
8
|
+
const operators_1 = require("../../../r-bridge/lang-4.x/ast/model/operators");
|
|
9
|
+
/**
|
|
10
|
+
* The lens hides syntax: every operator R has, the native pipe (which {@link OperatorDatabase} does not list), and the
|
|
11
|
+
* control-flow keywords. None of them names anything, unlike the built-in *functions* (`print`, `ifelse`) it keeps.
|
|
12
|
+
* Anchored and escaped, as most of these are regex syntax themselves and an unanchored alternative would also drop
|
|
13
|
+
* every lexeme merely *containing* one (`if` in `identifier`).
|
|
14
|
+
*/
|
|
15
|
+
const HiddenLexemes = `^(${[...Object.keys(operators_1.OperatorDatabase), '|>', 'function', 'repeat', 'if', 'next', 'break']
|
|
16
|
+
.map(name => (0, arguments_1.escapeRegExp)(name)).join('|')})$`;
|
|
7
17
|
/**
|
|
8
18
|
* Executes the given dataflow lens queries using the provided analyzer.
|
|
9
19
|
*/
|
|
@@ -17,7 +27,7 @@ async function executeDataflowLensQuery({ analyzer }, queries) {
|
|
|
17
27
|
keepEnv: false,
|
|
18
28
|
keepCd: true,
|
|
19
29
|
tags: [vertex_1.VertexType.Use, vertex_1.VertexType.VariableDefinition, vertex_1.VertexType.FunctionDefinition, vertex_1.VertexType.FunctionCall],
|
|
20
|
-
nameRegex:
|
|
30
|
+
nameRegex: HiddenLexemes,
|
|
21
31
|
blacklistWithName: true
|
|
22
32
|
}
|
|
23
33
|
}, analyzer.inspectContext().env.makeCleanEnv());
|
|
@@ -48,7 +48,8 @@ async function executeDependenciesQuery({ analyzer, }, queries) {
|
|
|
48
48
|
if (query.additionalCategories !== undefined) {
|
|
49
49
|
for (const [category, value] of Object.entries(query.additionalCategories)) {
|
|
50
50
|
// custom categories only use the "functions" collection and do not allow specifying additional functions in the object itself, so we "undefined" a lot here
|
|
51
|
-
|
|
51
|
+
const custom = getFunctionsToCheck(undefined, category, undefined, false, value.functions);
|
|
52
|
+
functions.set(category, [...(functions.get(category) ?? []), ...custom]);
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
const queryResults = !functions.values().toArray().some(f => f.length > 0) ? { kinds: {}, '.meta': { timing: 0 } } :
|
|
@@ -197,7 +198,7 @@ function getResults(queries, { dataflow, config, normalize }, results, kind, fun
|
|
|
197
198
|
linkedIds: linked?.length ? linked : undefined,
|
|
198
199
|
value: resolvedValue ?? info.defaultValue ?? defaultValue,
|
|
199
200
|
versionConstraints: dep?.versionConstraints,
|
|
200
|
-
derivedRange: dep?.
|
|
201
|
+
derivedRange: dep?.effectiveRange,
|
|
201
202
|
namespaceInfo: dep?.namespaceInfo
|
|
202
203
|
}));
|
|
203
204
|
}
|
|
@@ -48,6 +48,12 @@ export declare const DefaultDependencyCategories: {
|
|
|
48
48
|
readonly functions: FunctionInfo[];
|
|
49
49
|
readonly defaultValue: "stdout";
|
|
50
50
|
};
|
|
51
|
+
readonly print: {
|
|
52
|
+
readonly queryDisplayName: "Auto-printed Results";
|
|
53
|
+
readonly functions: [];
|
|
54
|
+
readonly defaultValue: "stdout";
|
|
55
|
+
readonly additionalAnalysis: (data: BasicQueryData, ignoreDefault: boolean, _functions: FunctionInfo[], queryResults: CallContextQueryResult, result: DependencyInfo[]) => Promise<void>;
|
|
56
|
+
};
|
|
51
57
|
readonly visualize: {
|
|
52
58
|
readonly queryDisplayName: "Visualizations";
|
|
53
59
|
readonly functions: FunctionInfo[];
|
|
@@ -63,6 +69,7 @@ export interface DependenciesQuery extends BaseQueryFormat, Partial<Record<`${De
|
|
|
63
69
|
readonly type: 'dependencies';
|
|
64
70
|
readonly enabledCategories?: DependencyCategoryName[];
|
|
65
71
|
readonly ignoreDefaultFunctions?: boolean;
|
|
72
|
+
/** Naming a built-in category extends it; use `ignoreDefaultFunctions` to drop the built-in functions. */
|
|
66
73
|
readonly additionalCategories?: Record<string, MarkOptional<DependencyCategorySettings, 'additionalAnalysis'>>;
|
|
67
74
|
}
|
|
68
75
|
export type DependenciesQueryResult = BaseQueryResult & {
|
|
@@ -85,6 +92,7 @@ export interface DependencyInfo extends Record<string, unknown> {
|
|
|
85
92
|
}
|
|
86
93
|
/**
|
|
87
94
|
* Gets all dependency categories, including user-defined additional categories.
|
|
95
|
+
* A category named like a built-in one extends it instead of replacing it.
|
|
88
96
|
*/
|
|
89
97
|
export declare function getAllCategories(queries: readonly DependenciesQuery[]): Record<DependencyCategoryName, DependencyCategorySettings>;
|
|
90
98
|
export declare const DependenciesQueryDefinition: {
|
|
@@ -19,6 +19,11 @@ const test_functions_1 = require("./function-info/test-functions");
|
|
|
19
19
|
const identifier_1 = require("../../../dataflow/environments/identifier");
|
|
20
20
|
const r_project_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-project");
|
|
21
21
|
const model_1 = require("../../../r-bridge/lang-4.x/ast/model/model");
|
|
22
|
+
const objects_1 = require("../../../util/objects");
|
|
23
|
+
const query_fn_props_1 = require("../../../dataflow/environments/query-fn-props");
|
|
24
|
+
const built_in_props_1 = require("../../../dataflow/environments/built-in-props");
|
|
25
|
+
const vertex_1 = require("../../../dataflow/graph/vertex");
|
|
26
|
+
const df_helper_1 = require("../../../dataflow/graph/df-helper");
|
|
22
27
|
exports.Unknown = 'unknown';
|
|
23
28
|
exports.DefaultDependencyCategories = {
|
|
24
29
|
'library': {
|
|
@@ -38,7 +43,7 @@ exports.DefaultDependencyCategories = {
|
|
|
38
43
|
functionName: model_1.RNode.lexeme(node).includes(':::') ? ':::' : '::',
|
|
39
44
|
value: ns,
|
|
40
45
|
versionConstraints: dep?.versionConstraints,
|
|
41
|
-
derivedRange: dep?.
|
|
46
|
+
derivedRange: dep?.effectiveRange,
|
|
42
47
|
namespaceInfo: dep?.namespaceInfo
|
|
43
48
|
});
|
|
44
49
|
}
|
|
@@ -61,6 +66,37 @@ exports.DefaultDependencyCategories = {
|
|
|
61
66
|
functions: write_functions_1.WriteFunctions,
|
|
62
67
|
defaultValue: 'stdout'
|
|
63
68
|
},
|
|
69
|
+
'print': {
|
|
70
|
+
queryDisplayName: 'Auto-printed Results',
|
|
71
|
+
functions: [],
|
|
72
|
+
defaultValue: 'stdout',
|
|
73
|
+
additionalAnalysis: async (data, ignoreDefault, _functions, queryResults, result) => {
|
|
74
|
+
if (ignoreDefault) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const [{ ast }, dataflow] = await Promise.all([data.analyzer.normalize(), data.analyzer.dataflow()]);
|
|
78
|
+
const accountedFor = new Set(Object.values(queryResults?.kinds ?? {})
|
|
79
|
+
.flatMap(k => Object.values(k.subkinds).flat()).map(r => r.id));
|
|
80
|
+
for (const file of ast.files) {
|
|
81
|
+
for (const statement of file.root.children) {
|
|
82
|
+
if (statement.type !== type_1.RType.FunctionCall || accountedFor.has(statement.info.id)) {
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
const vertex = dataflow.graph.getVertex(statement.info.id);
|
|
86
|
+
const functionName = vertex?.tag === vertex_1.VertexType.FunctionCall
|
|
87
|
+
? df_helper_1.Dataflow.qualify(statement.info.id, dataflow.graph, false) ?? vertex.name : undefined;
|
|
88
|
+
if (functionName === undefined) {
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
const props = (0, query_fn_props_1.queryFnProps)(functionName, { environment: dataflow.environment })?.props ?? 0;
|
|
92
|
+
if ((props & (built_in_props_1.CallProp.Invisible | built_in_props_1.CallProp.Graphics)) !== 0 || test_functions_1.ExpectFunctionNames.test(identifier_1.Identifier.getName(functionName))) {
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
result.push({ nodeId: statement.info.id, functionName, value: 'stdout' });
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
},
|
|
64
100
|
'visualize': {
|
|
65
101
|
queryDisplayName: 'Visualizations',
|
|
66
102
|
functions: visualize_functions_1.VisualizeFunctions
|
|
@@ -86,12 +122,18 @@ function printResultSection(title, infos, result, formatter) {
|
|
|
86
122
|
}
|
|
87
123
|
/**
|
|
88
124
|
* Gets all dependency categories, including user-defined additional categories.
|
|
125
|
+
* A category named like a built-in one extends it instead of replacing it.
|
|
89
126
|
*/
|
|
90
127
|
function getAllCategories(queries) {
|
|
91
|
-
|
|
128
|
+
const categories = { ...exports.DefaultDependencyCategories };
|
|
92
129
|
for (const query of queries) {
|
|
93
|
-
|
|
94
|
-
|
|
130
|
+
for (const [name, settings] of Object.entries(query.additionalCategories ?? {})) {
|
|
131
|
+
const known = categories[name];
|
|
132
|
+
categories[name] = known === undefined ? settings : {
|
|
133
|
+
...known,
|
|
134
|
+
...(0, objects_1.compactRecord)(settings),
|
|
135
|
+
functions: [...known.functions, ...settings.functions]
|
|
136
|
+
};
|
|
95
137
|
}
|
|
96
138
|
}
|
|
97
139
|
return categories;
|
|
@@ -122,7 +164,7 @@ exports.DependenciesQueryDefinition = {
|
|
|
122
164
|
queryDisplayName: joi_1.default.string().description('The display name in the query result.'),
|
|
123
165
|
functions: functionInfoSchema.description('The functions that this additional category should search for.'),
|
|
124
166
|
defaultValue: joi_1.default.string().description('The default value to return when there is no value to gather from the function information.').optional()
|
|
125
|
-
})).description('A set of additional, user-supplied dependency categories, whose results will be included in the query return value.').optional()
|
|
167
|
+
})).description('A set of additional, user-supplied dependency categories, whose results will be included in the query return value. Using the name of a built-in category extends it instead of replacing it.').optional()
|
|
126
168
|
}).description('The dependencies query retrieves and returns the set of all dependencies in the dataflow graph, which includes libraries, sourced files, read data, and written data.'),
|
|
127
169
|
flattenInvolvedNodes: (queryResults, query) => {
|
|
128
170
|
const out = queryResults;
|
|
@@ -16,6 +16,7 @@ exports.LibraryFunctions = [
|
|
|
16
16
|
{ package: 'librarian', name: 'shelf', argIdx: 'unnamed', resolveValue: true },
|
|
17
17
|
{ package: 'devtools', name: 'load_all', argIdx: 0, argName: 'path', resolveValue: true, defaultValue: '.' },
|
|
18
18
|
{ package: 'devtools', name: 'load_code', argIdx: 0, argName: 'path', resolveValue: true, defaultValue: '.' },
|
|
19
|
-
{ package: 'import', name: 'from', argIdx: 0, argName: 'package', resolveValue: true }
|
|
19
|
+
{ package: 'import', name: 'from', argIdx: 0, argName: 'package', resolveValue: true },
|
|
20
|
+
{ package: 'rlang', name: 'on_package_load', argIdx: 0, argName: 'pkg', resolveValue: true }
|
|
20
21
|
];
|
|
21
22
|
//# sourceMappingURL=library-functions.js.map
|
|
@@ -132,6 +132,32 @@ const ReadFunctionsWithMore = [
|
|
|
132
132
|
{ package: 'tuneR', name: 'readMidi', argIdx: 0, argName: 'file', resolveValue: true },
|
|
133
133
|
{ package: 'seewave', name: 'read.audacity', argIdx: 0, argName: 'file', resolveValue: true },
|
|
134
134
|
{ package: 'audio', name: 'load.wave', argIdx: 0, argName: 'where', resolveValue: true },
|
|
135
|
+
/* geospatial (no `raster::stack`: only the name is matched on and `utils::stack` shares it) */
|
|
136
|
+
{ package: 'terra', name: 'rast', argIdx: 0, argName: 'x', resolveValue: true },
|
|
137
|
+
{ package: 'terra', name: 'vect', argIdx: 0, argName: 'x', resolveValue: true },
|
|
138
|
+
{ package: 'raster', name: 'raster', argIdx: 0, argName: 'x', resolveValue: true },
|
|
139
|
+
{ package: 'raster', name: 'brick', argIdx: 0, argName: 'x', resolveValue: true },
|
|
140
|
+
{ package: 'raster', name: 'shapefile', argIdx: 0, argName: 'x', resolveValue: true },
|
|
141
|
+
{ package: 'stars', name: 'read_stars', argIdx: 0, argName: '.x', resolveValue: true },
|
|
142
|
+
{ package: 'stars', name: 'read_ncdf', argIdx: 0, argName: '.x', resolveValue: true },
|
|
143
|
+
{ package: 'maptools', name: 'readShapeLines', argIdx: 0, argName: 'fn', resolveValue: true },
|
|
144
|
+
{ package: 'maptools', name: 'readShapePoints', argIdx: 0, argName: 'fn', resolveValue: true },
|
|
145
|
+
{ package: 'maptools', name: 'readShapeSpatial', argIdx: 0, argName: 'fn', resolveValue: true },
|
|
146
|
+
/* array / binary science formats */
|
|
147
|
+
{ package: 'ncdf4', name: 'nc_open', argIdx: 0, argName: 'filename', resolveValue: true },
|
|
148
|
+
{ package: 'RNetCDF', name: 'open.nc', argIdx: 0, argName: 'con', resolveValue: true },
|
|
149
|
+
{ package: 'R.matlab', name: 'readMat', argIdx: 0, argName: 'con', resolveValue: true },
|
|
150
|
+
{ package: 'rhdf5', name: 'h5read', argIdx: 0, argName: 'file', resolveValue: true },
|
|
151
|
+
{ package: 'rhdf5', name: 'h5ls', argIdx: 0, argName: 'file', resolveValue: true },
|
|
152
|
+
{ package: 'fst', name: 'read_fst', argIdx: 0, argName: 'path', resolveValue: true },
|
|
153
|
+
{ package: 'qs', name: 'qread', argIdx: 0, argName: 'file', resolveValue: true },
|
|
154
|
+
{ package: 'yaml', name: 'read_yaml', argIdx: 0, argName: 'file', resolveValue: true, ignoreIf: 'arg-set', additionalArgs: { argSet: { argName: 'text' } } },
|
|
155
|
+
/* phylogeny / sequence */
|
|
156
|
+
{ package: 'ape', name: 'read.nexus', argIdx: 0, argName: 'file', resolveValue: true },
|
|
157
|
+
{ package: 'ape', name: 'read.nexus.data', argIdx: 0, argName: 'file', resolveValue: true },
|
|
158
|
+
{ package: 'ape', name: 'read.dna', argIdx: 0, argName: 'file', resolveValue: true },
|
|
159
|
+
{ package: 'ape', name: 'read.FASTA', argIdx: 0, argName: 'file', resolveValue: true },
|
|
160
|
+
{ package: 'seqinr', name: 'read.fasta', argIdx: 0, argName: 'file', resolveValue: true },
|
|
135
161
|
/* shinyjs - loads an external JavaScript file */
|
|
136
162
|
{ package: 'shinyjs', name: 'extendShinyjs', argIdx: 0, argName: 'script', resolveValue: true, ignoreIf: 'arg-missing' }
|
|
137
163
|
];
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { FunctionInfo } from './function-info';
|
|
2
2
|
import type { LinkToNestedCall } from '../../call-context-query/call-context-query-format';
|
|
3
|
+
/** the assertion helpers of the test frameworks; each hands its input back invisibly, so none reaches stdout */
|
|
4
|
+
export declare const ExpectFunctionNames: RegExp;
|
|
3
5
|
export declare const ExpectFunctions: LinkToNestedCall;
|
|
4
6
|
export declare const TestFunctions: FunctionInfo[];
|
|
@@ -1,38 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TestFunctions = exports.ExpectFunctions = void 0;
|
|
3
|
+
exports.TestFunctions = exports.ExpectFunctions = exports.ExpectFunctionNames = void 0;
|
|
4
|
+
/** the assertion helpers of the test frameworks; each hands its input back invisibly, so none reaches stdout */
|
|
5
|
+
exports.ExpectFunctionNames = new RegExp(/* testthat */ '^(expect_equal|expect_identical|expect_error|expect_warning|expect_message|expect_condition|' +
|
|
6
|
+
'expect_true|expect_false|expect_all_equal|expect_all_true|expect_all_false|expect_lt|expect_lte|expect_gt|expect_gte|' +
|
|
7
|
+
'expect_length|expect_shape|expect_match|expect_no_match|expect_named|expect_null|expect_setequal|expect_mapequal|' +
|
|
8
|
+
'expect_contains|expect_in|expect_disjoint|expect_type|expect_s3_class|expect_s4_class|expect_r6_class|expect_s7_class|' +
|
|
9
|
+
'expect_vector|expect_no_error|expect_no_warning|expect_no_message|expect_no_condition|expect_invisible|expect_visible|' +
|
|
10
|
+
'expect_output|expect_silent|expect_snapshot|expect_snapshot_value|expect_snapshot_file|announce_snapshot_file|' +
|
|
11
|
+
'compare_file_binary|compare_file_text|snapshot_accept|snapshot_reject|snapshot_review|' +
|
|
12
|
+
'fail|pass|expect_success|expect_failure|expect_snapshot_failure|show_failure|' +
|
|
13
|
+
/* tinytest */
|
|
14
|
+
'exit_file|exit_if_not|expect_equal|expect_identical|expect_equivalent|expect_true|expect_false|expect_silent|expect_null|' +
|
|
15
|
+
'expect_inherits|expect_error|expect_warning|expect_message|expect_stdout|expect_equal_to_reference|' +
|
|
16
|
+
'expect_equivalent_to_reference|expect_length|expect_match|ignore|report_side_effects|' +
|
|
17
|
+
/* testit */
|
|
18
|
+
'assert|' +
|
|
19
|
+
/* RUnit */
|
|
20
|
+
'checkEquals|checkEqualsNumeric|checkIdentical|checkTrue|checkException|' +
|
|
21
|
+
/* checkmate */
|
|
22
|
+
'assertAccess|assert_access|assertArray|assert_array|assert_atomic|assertAtomic|assert_atomic_vector|assertAtomicVector|' +
|
|
23
|
+
'assert_character|assertCharacter|assert_choice|assertChoice|assert_class|assertClass|assert_complex|assertComplex|' +
|
|
24
|
+
'assert_count|assertCount|assert_data_frame|assertDataFrame|assert_data_table|assertDataTable|assert_date|assertDate|' +
|
|
25
|
+
'assert_directory|assertDirectory|assert_directory_exists|assertDirectoryExists|assert_disjunct|assertDisjunct|assert_double|' +
|
|
26
|
+
'assertDouble|assert_environment|assertEnvironment|assert_factor|assertFactor|assert_false|assertFalse|assert_file|assertFile|' +
|
|
27
|
+
'assert_file_exists|assertFileExists|assert_flag|assertFlag|assert_formula|assertFormula|assert_function|assertFunction|' +
|
|
28
|
+
'assert_int|assertInt|assert_integer|assertInteger|assert_list|assertList|assert_logical|assertLogical|assert_matrix|' +
|
|
29
|
+
'assertMatrix|assert_multi_class|assertMultiClass|assert_named|assertNamed|assert_names|assertNames|assert_null|assertNull|' +
|
|
30
|
+
'assert_number|assertNumber|assert_numeric|assertNumeric|assert_os|assertOs|assert_path_for_output|assertPathForOutput|' +
|
|
31
|
+
'assert_permutation|assertPermutation|assert_posixct|assertPOSIXct|assert_r6|assertR6|assert_raw|assertRaw|assert_scalar|' +
|
|
32
|
+
'assertScalar|assert_scalar_na|assertScalarNA|assert_set_equal|assertSetEqual|assert_string|assertString|assert_subset|' +
|
|
33
|
+
'assertSubset|assert_tibble|assertTibble|assert_true|assertTrue|assert_vector|assertVector' +
|
|
34
|
+
')$');
|
|
4
35
|
exports.ExpectFunctions = {
|
|
5
36
|
type: 'link-to-nested-call',
|
|
6
|
-
callName:
|
|
7
|
-
'expect_true|expect_false|expect_all_equal|expect_all_true|expect_all_false|expect_lt|expect_lte|expect_gt|expect_gte|' +
|
|
8
|
-
'expect_length|expect_shape|expect_match|expect_no_match|expect_named|expect_null|expect_setequal|expect_mapequal|' +
|
|
9
|
-
'expect_contains|expect_in|expect_disjoint|expect_type|expect_s3_class|expect_s4_class|expect_r6_class|expect_s7_class|' +
|
|
10
|
-
'expect_vector|expect_no_error|expect_no_warning|expect_no_message|expect_no_condition|expect_invisible|expect_visible|' +
|
|
11
|
-
'expect_output|expect_silent|expect_snapshot|expect_snapshot_value|expect_snapshot_file|announce_snapshot_file|' +
|
|
12
|
-
'compare_file_binary|compare_file_text|snapshot_accept|snapshot_reject|snapshot_review|' +
|
|
13
|
-
'fail|pass|expect_success|expect_failure|expect_snapshot_failure|show_failure|' +
|
|
14
|
-
/* tinytest */
|
|
15
|
-
'exit_file|exit_if_not|expect_equal|expect_identical|expect_equivalent|expect_true|expect_false|expect_silent|expect_null|' +
|
|
16
|
-
'expect_inherits|expect_error|expect_warning|expect_message|expect_stdout|expect_equal_to_reference|' +
|
|
17
|
-
'expect_equivalent_to_reference|expect_length|expect_match|ignore|report_side_effects|' +
|
|
18
|
-
/* testit */
|
|
19
|
-
'assert|' +
|
|
20
|
-
/* RUnit */
|
|
21
|
-
'checkEquals|checkEqualsNumeric|checkIdentical|checkTrue|checkException|' +
|
|
22
|
-
/* checkmate */
|
|
23
|
-
'assertAccess|assert_access|assertArray|assert_array|assert_atomic|assertAtomic|assert_atomic_vector|assertAtomicVector|' +
|
|
24
|
-
'assert_character|assertCharacter|assert_choice|assertChoice|assert_class|assertClass|assert_complex|assertComplex|' +
|
|
25
|
-
'assert_count|assertCount|assert_data_frame|assertDataFrame|assert_data_table|assertDataTable|assert_date|assertDate|' +
|
|
26
|
-
'assert_directory|assertDirectory|assert_directory_exists|assertDirectoryExists|assert_disjunct|assertDisjunct|assert_double|' +
|
|
27
|
-
'assertDouble|assert_environment|assertEnvironment|assert_factor|assertFactor|assert_false|assertFalse|assert_file|assertFile|' +
|
|
28
|
-
'assert_file_exists|assertFileExists|assert_flag|assertFlag|assert_formula|assertFormula|assert_function|assertFunction|' +
|
|
29
|
-
'assert_int|assertInt|assert_integer|assertInteger|assert_list|assertList|assert_logical|assertLogical|assert_matrix|' +
|
|
30
|
-
'assertMatrix|assert_multi_class|assertMultiClass|assert_named|assertNamed|assert_names|assertNames|assert_null|assertNull|' +
|
|
31
|
-
'assert_number|assertNumber|assert_numeric|assertNumeric|assert_os|assertOs|assert_path_for_output|assertPathForOutput|' +
|
|
32
|
-
'assert_permutation|assertPermutation|assert_posixct|assertPOSIXct|assert_r6|assertR6|assert_raw|assertRaw|assert_scalar|' +
|
|
33
|
-
'assertScalar|assert_scalar_na|assertScalarNA|assert_set_equal|assertSetEqual|assert_string|assertString|assert_subset|' +
|
|
34
|
-
'assertSubset|assert_tibble|assertTibble|assert_true|assertTrue|assert_vector|assertVector' +
|
|
35
|
-
')$')
|
|
37
|
+
callName: exports.ExpectFunctionNames
|
|
36
38
|
};
|
|
37
39
|
const ContextFunctions = {
|
|
38
40
|
type: 'link-to-last-call',
|
|
@@ -128,7 +128,26 @@ const WriteFunctionsWithMore = [
|
|
|
128
128
|
{ package: 'av', name: 'av_capture_graphics', argIdx: 1, argName: 'output', resolveValue: true },
|
|
129
129
|
{ package: 'tuneR', name: 'writeWave', argIdx: 1, argName: 'filename', resolveValue: true },
|
|
130
130
|
{ package: 'seewave', name: 'savewav', argName: 'filename', resolveValue: true, defaultValue: '<wave-name>' },
|
|
131
|
-
{ package: 'audio', name: 'save.wave', argIdx: 1, argName: 'where', resolveValue: true }
|
|
131
|
+
{ package: 'audio', name: 'save.wave', argIdx: 1, argName: 'where', resolveValue: true },
|
|
132
|
+
/* geospatial */
|
|
133
|
+
{ package: 'terra', name: 'writeRaster', argIdx: 1, argName: 'filename', resolveValue: true },
|
|
134
|
+
{ package: 'terra', name: 'writeVector', argIdx: 1, argName: 'filename', resolveValue: true },
|
|
135
|
+
{ package: 'terra', name: 'writeCDF', argIdx: 1, argName: 'filename', resolveValue: true },
|
|
136
|
+
{ package: 'raster', name: 'writeRaster', argIdx: 1, argName: 'filename', resolveValue: true },
|
|
137
|
+
{ package: 'stars', name: 'write_stars', argIdx: 1, argName: 'dsn', resolveValue: true },
|
|
138
|
+
/* array / binary science formats */
|
|
139
|
+
{ package: 'ncdf4', name: 'nc_create', argIdx: 0, argName: 'filename', resolveValue: true },
|
|
140
|
+
{ package: 'RNetCDF', name: 'create.nc', argIdx: 0, argName: 'filename', resolveValue: true },
|
|
141
|
+
{ package: 'R.matlab', name: 'writeMat', argIdx: 0, argName: 'con', resolveValue: true },
|
|
142
|
+
{ package: 'rhdf5', name: 'h5write', argIdx: 1, argName: 'file', resolveValue: true },
|
|
143
|
+
{ package: 'rhdf5', name: 'h5createFile', argIdx: 0, argName: 'file', resolveValue: true },
|
|
144
|
+
{ package: 'fst', name: 'write_fst', argIdx: 1, argName: 'path', resolveValue: true },
|
|
145
|
+
{ package: 'qs', name: 'qsave', argIdx: 1, argName: 'file', resolveValue: true },
|
|
146
|
+
{ package: 'yaml', name: 'write_yaml', argIdx: 1, argName: 'file', resolveValue: true },
|
|
147
|
+
/* phylogeny / sequence */
|
|
148
|
+
{ package: 'ape', name: 'write.dna', argIdx: 1, argName: 'file', resolveValue: true },
|
|
149
|
+
{ package: 'ape', name: 'write.nexus.data', argIdx: 1, argName: 'file', resolveValue: true },
|
|
150
|
+
{ package: 'seqinr', name: 'write.fasta', argIdx: 2, argName: 'file.out', resolveValue: true }
|
|
132
151
|
];
|
|
133
152
|
exports.WriteFunctions = [
|
|
134
153
|
...WriteFunctionsWithMore,
|
|
@@ -266,7 +266,7 @@ async function executeGuessDepVersionsQuery({ analyzer }, queries) {
|
|
|
266
266
|
}
|
|
267
267
|
}
|
|
268
268
|
const assignments = query.explode
|
|
269
|
-
? [...(0, dependency_version_space_1.assignmentsOf)(ordered, query.explode.limit ?? dependency_version_space_1.DefaultExplodeLimit)].map(a => ({ versions: Object.fromEntries(a.versions) }))
|
|
269
|
+
? [...(0, dependency_version_space_1.assignmentsOf)(ordered, query.explode.limit ?? dependency_version_space_1.DefaultExplodeLimit, (0, dependency_version_space_1.declaredDependenciesOf)(space))].map(a => ({ versions: Object.fromEntries(a.versions) }))
|
|
270
270
|
: undefined;
|
|
271
271
|
return (0, objects_1.compactRecord)({
|
|
272
272
|
'.meta': { timing: Date.now() - start },
|
|
@@ -39,7 +39,7 @@ export interface GuessExplodeOptions {
|
|
|
39
39
|
readonly order?: 'newest' | 'oldest';
|
|
40
40
|
/** a version to prefer per dependency when it survives the constraints (package name to version) */
|
|
41
41
|
readonly prefer?: Readonly<Record<string, VersionString>>;
|
|
42
|
-
/** cap the number of
|
|
42
|
+
/** cap the number of combinations considered; the ones that cannot be loaded together are skipped, not returned */
|
|
43
43
|
readonly limit?: number;
|
|
44
44
|
}
|
|
45
45
|
/** one concrete version choice per resolvable dependency (`package -> version`) */
|
|
@@ -374,7 +374,7 @@ exports.GuessDepVersionsQueryDefinition = {
|
|
|
374
374
|
explode: joi_1.default.object({
|
|
375
375
|
order: joi_1.default.string().valid('newest', 'oldest').optional().description('Iterate each dependency newest-first (default) or oldest-first.'),
|
|
376
376
|
prefer: joi_1.default.object().pattern(joi_1.default.string(), joi_1.default.string()).optional().description('A version to prefer per dependency when it survives the constraints.'),
|
|
377
|
-
limit: joi_1.default.number().integer().min(0).optional().description('Cap the number of
|
|
377
|
+
limit: joi_1.default.number().integer().min(0).optional().description('Cap the number of version combinations considered. Combinations whose versions cannot be loaded together are skipped, so fewer assignments may come out.')
|
|
378
378
|
}).optional().description('Also explode the guessed space into concrete per-dependency version assignments.')
|
|
379
379
|
}).description('Guesses the possible version range of every dependency from declared constraints and signature-database usage.'),
|
|
380
380
|
flattenInvolvedNodes: () => []
|
|
@@ -14,8 +14,9 @@ exports.HappensBeforeQueryDefinition = {
|
|
|
14
14
|
asciiSummarizer: (formatter, _analyzer, queryResults, result) => {
|
|
15
15
|
const out = queryResults;
|
|
16
16
|
result.push(`Query: ${(0, ansi_1.bold)('happens-before', formatter)} (${(0, time_1.printAsMs)(out['.meta'].timing, 0)})`);
|
|
17
|
-
for (const [
|
|
18
|
-
|
|
17
|
+
for (const [fingerprint, value] of Object.entries(out.results)) {
|
|
18
|
+
const { a, b } = JSON.parse(fingerprint);
|
|
19
|
+
result.push(` ╰ ${(0, ansi_1.bold)(a, formatter)} happens before ${(0, ansi_1.bold)(b, formatter)}: ${value}`);
|
|
19
20
|
}
|
|
20
21
|
return true;
|
|
21
22
|
},
|
|
@@ -18,6 +18,7 @@ const SliceCriterionHelp = [
|
|
|
18
18
|
' <line>@[<n>]<name> the n-th occurrence of <name> in line <line> (e.g. 2@[2]x, 2@[-1]x)',
|
|
19
19
|
' <line>:<col> the element starting at line <line>, column <col> (e.g. 2:5)',
|
|
20
20
|
' <line>~<col> the innermost element containing line <line>, column <col> (e.g. 2~5)',
|
|
21
|
+
' <line>^ the top-level statement line <line> belongs to (e.g. 2^)',
|
|
21
22
|
' $<id> the normalized node with the id <id> (e.g. $42)',
|
|
22
23
|
'A negative <line> counts from the end; a trailing (file-regex) restricts to a file (e.g. 2@x(tmp/.*)).',
|
|
23
24
|
`Append flags after the ")": ${(0, slice_query_parser_1.describeSliceFlags)(slice_query_parser_1.StaticSliceFlags)}.`,
|
package/r-bridge/data/data.d.ts
CHANGED
|
@@ -565,7 +565,7 @@ export declare const flowrCapabilities: {
|
|
|
565
565
|
readonly name: "Hooks";
|
|
566
566
|
readonly id: "hooks";
|
|
567
567
|
readonly supported: "partially";
|
|
568
|
-
readonly description: "_Handle hooks like [`userhooks`](https://stat.ethz.ch/R-manual/R-devel/library/base/html/userhooks.html) and [`on.exit`](https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/on.exit)._ We
|
|
568
|
+
readonly description: "_Handle hooks like [`userhooks`](https://stat.ethz.ch/R-manual/R-devel/library/base/html/userhooks.html) and [`on.exit`](https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/on.exit)._ We support `on.exit` and rlang's [`on_load`/`run_on_load`/`on_package_load`](https://rlang.r-lib.org/reference/on_load.html), whose expressions we analyze where they are registered. `setHook` and the other user hooks are not modelled.";
|
|
569
569
|
}, {
|
|
570
570
|
readonly name: "Precedence";
|
|
571
571
|
readonly id: "precedence";
|
package/r-bridge/data/data.js
CHANGED
|
@@ -715,7 +715,7 @@ ${await (0, doc_dfg_1.printDfGraphForCode)(parser, code, { simplified: true })}
|
|
|
715
715
|
name: 'Hooks',
|
|
716
716
|
id: 'hooks',
|
|
717
717
|
supported: 'partially',
|
|
718
|
-
description: '_Handle hooks like [`userhooks`](https://stat.ethz.ch/R-manual/R-devel/library/base/html/userhooks.html) and [`on.exit`](https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/on.exit)._ We
|
|
718
|
+
description: '_Handle hooks like [`userhooks`](https://stat.ethz.ch/R-manual/R-devel/library/base/html/userhooks.html) and [`on.exit`](https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/on.exit)._ We support `on.exit` and rlang\'s [`on_load`/`run_on_load`/`on_package_load`](https://rlang.r-lib.org/reference/on_load.html), whose expressions we analyze where they are registered. `setHook` and the other user hooks are not modelled.'
|
|
719
719
|
},
|
|
720
720
|
{
|
|
721
721
|
name: 'Precedence',
|
|
@@ -6,7 +6,7 @@ type FileFilterSuffix = '' | `(${string})`;
|
|
|
6
6
|
* Either `line:column`, `line~column`, `line@variable-name`, or `$id`; all but `$id` accept a trailing
|
|
7
7
|
* `(file-regex)`. See {@link SlicingCriterion.tryParse} for what each of them resolves to.
|
|
8
8
|
*/
|
|
9
|
-
export type SlicingCriterion = `${number}:${number}${FileFilterSuffix}` | `${number}~${number}${FileFilterSuffix}` | `${number}@${string}` | `$${NodeId | number}`;
|
|
9
|
+
export type SlicingCriterion = `${number}:${number}${FileFilterSuffix}` | `${number}~${number}${FileFilterSuffix}` | `${number}^${FileFilterSuffix}` | `${number}@${string}` | `$${NodeId | number}`;
|
|
10
10
|
/**
|
|
11
11
|
* The helper object associated with {@link SlicingCriterion} which makes it easy
|
|
12
12
|
* to parse, validate and resolve slicing criteria.
|
|
@@ -33,6 +33,7 @@ export declare const SlicingCriterion: {
|
|
|
33
33
|
* | `2@[3]x` | the 3rd occurrence of `x` in line 2 (by column); `[-1]` for the last |
|
|
34
34
|
* | `2:5` | the element *starting* at line 2, column 5 |
|
|
35
35
|
* | `2~5` | the innermost element *containing* line 2, column 5 |
|
|
36
|
+
* | `2^` | the top-level statement line 2 belongs to, the first one when several share the line |
|
|
36
37
|
* | `$42` | the node with the normalized id 42 |
|
|
37
38
|
*
|
|
38
39
|
* A negative line counts from the end of the input (`-1` being the last line). Every criterion but `$id`
|
|
@@ -18,7 +18,7 @@ exports.SlicingCriterion = {
|
|
|
18
18
|
* @see {@link SlicingCriterion.parse} to parse a slicing criterion to a node ID
|
|
19
19
|
*/
|
|
20
20
|
isValid(criterion) {
|
|
21
|
-
return typeof criterion === 'string' &&
|
|
21
|
+
return typeof criterion === 'string' && /^(-?\d+([:~]\d+|\^|@.+)|\$.+)$/.test(criterion);
|
|
22
22
|
},
|
|
23
23
|
/**
|
|
24
24
|
* Takes a criterion in the form of `line:column`, `line~column`, or `line@variable-name` and returns the corresponding node id
|
|
@@ -40,6 +40,7 @@ exports.SlicingCriterion = {
|
|
|
40
40
|
* | `2@[3]x` | the 3rd occurrence of `x` in line 2 (by column); `[-1]` for the last |
|
|
41
41
|
* | `2:5` | the element *starting* at line 2, column 5 |
|
|
42
42
|
* | `2~5` | the innermost element *containing* line 2, column 5 |
|
|
43
|
+
* | `2^` | the top-level statement line 2 belongs to, the first one when several share the line |
|
|
43
44
|
* | `$42` | the node with the normalized id 42 |
|
|
44
45
|
*
|
|
45
46
|
* A negative line counts from the end of the input (`-1` being the last line). Every criterion but `$id`
|
|
@@ -81,6 +82,10 @@ exports.SlicingCriterion = {
|
|
|
81
82
|
const location = parseLocation(base, '~', idMap, file);
|
|
82
83
|
return location && fuzzyLocationToId(location, idMap, file);
|
|
83
84
|
}
|
|
85
|
+
else if (base.endsWith('^')) {
|
|
86
|
+
const line = parseLineNumber(base.slice(0, -1), idMap, file);
|
|
87
|
+
return line === undefined ? undefined : topLevelStatementToId(line, idMap, file);
|
|
88
|
+
}
|
|
84
89
|
},
|
|
85
90
|
/**
|
|
86
91
|
* Converts a node id to a slicing criterion in the form of `$id`
|
|
@@ -149,6 +154,37 @@ function fuzzyLocationToId(location, dataflowIdMap, file) {
|
|
|
149
154
|
// prefer the call over the symbol it refers to, exactly as locationToId does
|
|
150
155
|
return (candidates.find(n => n.type === type_1.RType.FunctionCall) ?? candidates[0])?.info.id;
|
|
151
156
|
}
|
|
157
|
+
/** Walks up to the statement `node` belongs to: the outermost node still below the root of its file. */
|
|
158
|
+
function enclosingTopLevelStatement(node, idMap) {
|
|
159
|
+
let current = node;
|
|
160
|
+
for (;;) {
|
|
161
|
+
const parent = current.info.parent !== undefined ? idMap.get(current.info.parent) : undefined;
|
|
162
|
+
if (parent === undefined || parent.info.parent === undefined) {
|
|
163
|
+
return current;
|
|
164
|
+
}
|
|
165
|
+
current = parent;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Resolves a `line^` criterion: the top-level statement covering the line, which is what has to be excised to
|
|
170
|
+
* remove that line from the program. Unlike {@link fuzzyLocationToId} this widens rather than narrows, so an
|
|
171
|
+
* inner sub-expression on the line never stands in for the statement carrying it.
|
|
172
|
+
*/
|
|
173
|
+
function topLevelStatementToId(line, idMap, file) {
|
|
174
|
+
const potentials = [...idMap.values()].filter(nodeInfo => matchesFile(nodeInfo, file));
|
|
175
|
+
let best;
|
|
176
|
+
let bestRange;
|
|
177
|
+
for (const node of range_1.SourceRange.nodesContaining(potentials, line)) {
|
|
178
|
+
const statement = enclosingTopLevelStatement(node, idMap);
|
|
179
|
+
const range = range_1.SourceRange.fromNode(statement);
|
|
180
|
+
/* several statements may cover the line (`a <- 1; b <- 2`), the one starting first wins */
|
|
181
|
+
if (range !== undefined && (bestRange === undefined || range_1.SourceRange.compare(range, bestRange) < 0)) {
|
|
182
|
+
best = statement;
|
|
183
|
+
bestRange = range;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return best?.info.id;
|
|
187
|
+
}
|
|
152
188
|
/**
|
|
153
189
|
* Splits the optional trailing `(file-regex)` off a criterion (e.g. `2@x(tmp/.*)`), which restricts it to nodes
|
|
154
190
|
* originating from a matching file. Returns `undefined` if the regex is malformed.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { REnvironmentInformation } from '../../dataflow/environments/environment';
|
|
2
2
|
import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
3
3
|
export type Fingerprint = string;
|
|
4
4
|
/**
|
|
@@ -7,19 +7,51 @@ exports.envFingerprint = envFingerprint;
|
|
|
7
7
|
exports.fingerprint = fingerprint;
|
|
8
8
|
const object_hash_1 = __importDefault(require("object-hash"));
|
|
9
9
|
const environment_1 = require("../../dataflow/environments/environment");
|
|
10
|
+
const HashOptions = {
|
|
11
|
+
algorithm: 'md5',
|
|
12
|
+
excludeKeys: (key) => key === 'id' || key === 'value',
|
|
13
|
+
respectFunctionProperties: false,
|
|
14
|
+
respectFunctionNames: false,
|
|
15
|
+
ignoreUnknown: true,
|
|
16
|
+
replacer: (v) => (0, environment_1.isDefaultBuiltInEnvironment)(v) ? undefined : v
|
|
17
|
+
};
|
|
18
|
+
/* definitions and frames are shared across the environments a slice builds, and a definition may hold a whole
|
|
19
|
+
* environment of its own (`envState`), so each is hashed once instead of on every fingerprint */
|
|
20
|
+
const definitionHashes = new WeakMap();
|
|
21
|
+
const frameHashes = new WeakMap();
|
|
22
|
+
function definitionHash(definition) {
|
|
23
|
+
let hash = definitionHashes.get(definition);
|
|
24
|
+
if (hash === undefined) {
|
|
25
|
+
hash = (0, object_hash_1.default)(definition, HashOptions);
|
|
26
|
+
definitionHashes.set(definition, hash);
|
|
27
|
+
}
|
|
28
|
+
return hash;
|
|
29
|
+
}
|
|
30
|
+
function frameHash(frame) {
|
|
31
|
+
let hash = frameHashes.get(frame);
|
|
32
|
+
if (hash === undefined) {
|
|
33
|
+
const entries = [];
|
|
34
|
+
for (const [name, definitions] of frame.memory) {
|
|
35
|
+
entries.push(`${String(name)}=${definitions.map(definitionHash).join(',')}`);
|
|
36
|
+
}
|
|
37
|
+
entries.sort();
|
|
38
|
+
hash = (0, object_hash_1.default)([frame.n, frame.t, frame.closure, frame.globalEnv === true, entries], HashOptions);
|
|
39
|
+
frameHashes.set(frame, hash);
|
|
40
|
+
}
|
|
41
|
+
return hash;
|
|
42
|
+
}
|
|
10
43
|
/**
|
|
11
44
|
* Calculate a fingerprint for the given R environment information
|
|
12
45
|
* @see {@link fingerprint}
|
|
13
46
|
*/
|
|
14
47
|
function envFingerprint(env) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
});
|
|
48
|
+
const parts = [String(env.level)];
|
|
49
|
+
let frame = env.current;
|
|
50
|
+
while (frame !== undefined && !frame.builtInEnv) {
|
|
51
|
+
parts.push(frameHash(frame));
|
|
52
|
+
frame = frame.parent;
|
|
53
|
+
}
|
|
54
|
+
return parts.join('|');
|
|
23
55
|
}
|
|
24
56
|
/**
|
|
25
57
|
* Calculate a fingerprint for the given node id and environment fingerprint
|
|
@@ -39,7 +39,7 @@ function staticSlice(options) {
|
|
|
39
39
|
graph = df_helper_1.Dataflow.invertGraph(graph, ctx.env.makeCleanEnv());
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
-
const queue = new visiting_queue_1.VisitingQueue(threshold, cache);
|
|
42
|
+
const queue = new visiting_queue_1.VisitingQueue(threshold, cache, id => graph.hasVertex(id));
|
|
43
43
|
let minNesting = Number.MAX_SAFE_INTEGER;
|
|
44
44
|
const sliceSeedIds = new Set();
|
|
45
45
|
// every node ships the call environment which registers the calling environment
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Fingerprint } from './fingerprint';
|
|
2
2
|
import type { NodeToSlice, SliceResult } from './slicer-types';
|
|
3
3
|
import type { REnvironmentInformation } from '../../dataflow/environments/environment';
|
|
4
|
-
import
|
|
4
|
+
import { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
5
5
|
import type { DataflowGraphVertexInfo } from '../../dataflow/graph/vertex';
|
|
6
6
|
export declare class VisitingQueue {
|
|
7
7
|
private readonly threshold;
|
|
@@ -13,7 +13,9 @@ export declare class VisitingQueue {
|
|
|
13
13
|
private readonly cache?;
|
|
14
14
|
potentialAdditions: Map<NodeId, [NodeId, NodeToSlice]>;
|
|
15
15
|
private cachedCallTargets;
|
|
16
|
-
|
|
16
|
+
/** whether the dataflow graph has a vertex for an id, i.e. whether the traversal could continue from it */
|
|
17
|
+
private readonly isGraphVertex?;
|
|
18
|
+
constructor(threshold: number, cache?: Map<Fingerprint, Set<NodeId>>, isGraphVertex?: (id: NodeId) => boolean);
|
|
17
19
|
/**
|
|
18
20
|
* Adds a node to the queue if it has not been seen before.
|
|
19
21
|
* @param target - the node to add
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VisitingQueue = void 0;
|
|
4
4
|
const fingerprint_1 = require("./fingerprint");
|
|
5
|
+
const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
5
6
|
class VisitingQueue {
|
|
6
7
|
threshold;
|
|
7
8
|
timesHitThreshold = 0;
|
|
@@ -14,9 +15,12 @@ class VisitingQueue {
|
|
|
14
15
|
// additionally it holds which node id added the addition so we can separate their inclusion on the structure
|
|
15
16
|
potentialAdditions = new Map();
|
|
16
17
|
cachedCallTargets = new Map();
|
|
17
|
-
|
|
18
|
+
/** whether the dataflow graph has a vertex for an id, i.e. whether the traversal could continue from it */
|
|
19
|
+
isGraphVertex;
|
|
20
|
+
constructor(threshold, cache, isGraphVertex) {
|
|
18
21
|
this.threshold = threshold;
|
|
19
22
|
this.cache = cache;
|
|
23
|
+
this.isGraphVertex = isGraphVertex;
|
|
20
24
|
}
|
|
21
25
|
/**
|
|
22
26
|
* Adds a node to the queue if it has not been seen before.
|
|
@@ -26,6 +30,11 @@ class VisitingQueue {
|
|
|
26
30
|
* @param onlyForSideEffects - whether the node is only used for its side effects
|
|
27
31
|
*/
|
|
28
32
|
add(target, env, envFingerprint, onlyForSideEffects) {
|
|
33
|
+
/* a built-in without a vertex is R's own definition (`x <- 1` reads `built-in:<-`), a dead end the traversal
|
|
34
|
+
* would drop right back out of, so it only ever widened the result */
|
|
35
|
+
if (node_id_1.NodeId.isBuiltIn(target) && this.isGraphVertex?.(target) === false) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
29
38
|
const idCounter = this.idThreshold.get(target) ?? 0;
|
|
30
39
|
if (idCounter > this.threshold) {
|
|
31
40
|
this.timesHitThreshold++;
|
package/util/version.js
CHANGED
|
@@ -42,7 +42,7 @@ const assert_1 = require("./assert");
|
|
|
42
42
|
const sigdb_download_1 = require("../project/sigdb/sigdb-download");
|
|
43
43
|
const doc_files_1 = require("../documentation/doc-util/doc-files");
|
|
44
44
|
// this is automatically replaced with the current version by release-it
|
|
45
|
-
const version = '2.13.
|
|
45
|
+
const version = '2.13.9';
|
|
46
46
|
// this is automatically replaced with the release date by release-it (regex-bumper, see package.json)
|
|
47
47
|
const versionDate = '2026-07-15T07:13:44Z';
|
|
48
48
|
/**
|