@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
|
@@ -15,17 +15,28 @@ function disabledSources(query) {
|
|
|
15
15
|
}
|
|
16
16
|
return new Set([...(query.clean ? ['declared', 'transitive'] : []), ...(query.disabled ?? [])]);
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
function locatorOf(idMap) {
|
|
19
|
+
return id => {
|
|
20
|
+
const node = id === undefined ? undefined : idMap.get(id);
|
|
21
|
+
const at = node?.location ?? node?.info.fullRange;
|
|
22
|
+
return at === undefined ? undefined : `${node?.info.file ? node.info.file + ':' : ''}${at[0]}:${at[1]}`;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/** collects and deduplicates provenance-carrying constraints, resolving their call site to a location */
|
|
19
26
|
class EvidenceCollector {
|
|
27
|
+
locate;
|
|
20
28
|
seen = new Set();
|
|
21
29
|
list = [];
|
|
30
|
+
constructor(locate) {
|
|
31
|
+
this.locate = locate;
|
|
32
|
+
}
|
|
22
33
|
add = (c) => {
|
|
23
34
|
const key = `${c.source}|${c.origin}|${c.bound ?? ''}|${c.detail}`;
|
|
24
35
|
if (this.seen.has(key)) {
|
|
25
36
|
return;
|
|
26
37
|
}
|
|
27
38
|
this.seen.add(key);
|
|
28
|
-
this.list.push((0, objects_1.compactRecord)({ ...c }));
|
|
39
|
+
this.list.push((0, objects_1.compactRecord)({ ...c, location: this.locate(c.at) }));
|
|
29
40
|
};
|
|
30
41
|
}
|
|
31
42
|
/** merge several guess-dep-versions queries into one: union the packages, keep the tightest (earliest date, smallest cap) */
|
|
@@ -102,7 +113,7 @@ function rangeString(survivors, nonContiguous, unsatisfiable, declaredRange, dec
|
|
|
102
113
|
return survivors.length <= cap ? survivors.join(', ') : `${min}...${max} (${survivors.length} discrete)`;
|
|
103
114
|
}
|
|
104
115
|
/** build the reported guess for one package from its already-computed surviving versions and provenance */
|
|
105
|
-
function guessPackage(name, cap, surviving, evidence, { used, linkedWith, coupledWith, orphanFunctions, orphanAlternatives }) {
|
|
116
|
+
function guessPackage(name, cap, surviving, evidence, { used, linkedWith, coupledWith, orphanFunctions, orphanEvidence, orphanAlternatives }) {
|
|
106
117
|
const { declaredRange, declaredConstraints, unsatisfiable } = surviving;
|
|
107
118
|
const survivors = surviving.survivors.map(e => e.ver);
|
|
108
119
|
const preSignature = surviving.preSignature.map(e => e.ver);
|
|
@@ -118,6 +129,7 @@ function guessPackage(name, cap, surviving, evidence, { used, linkedWith, couple
|
|
|
118
129
|
maxVersion: survivors.length > 0 ? survivors[survivors.length - 1] : undefined,
|
|
119
130
|
candidateCount: survivors.length,
|
|
120
131
|
totalVersions: surviving.total,
|
|
132
|
+
constrained: surviving.total !== undefined && survivors.length === surviving.total ? false : undefined,
|
|
121
133
|
candidates: candidates.length > 0 ? candidates : undefined,
|
|
122
134
|
truncated: survivors.length > cap ? true : undefined,
|
|
123
135
|
evidence: evidence.list,
|
|
@@ -127,6 +139,7 @@ function guessPackage(name, cap, surviving, evidence, { used, linkedWith, couple
|
|
|
127
139
|
known: surviving.known ? undefined : false,
|
|
128
140
|
orphan: orphanFunctions && orphanFunctions.length > 0 ? true : undefined,
|
|
129
141
|
orphanFunctions: orphanFunctions && orphanFunctions.length > 0 ? orphanFunctions : undefined,
|
|
142
|
+
orphanEvidence: orphanEvidence && orphanEvidence.length > 0 ? orphanEvidence : undefined,
|
|
130
143
|
orphanAlternatives: orphanAlternatives && orphanAlternatives.length > 0 ? orphanAlternatives : undefined,
|
|
131
144
|
used
|
|
132
145
|
});
|
|
@@ -157,9 +170,11 @@ async function executeGuessDepVersionsQuery({ analyzer }, queries) {
|
|
|
157
170
|
}
|
|
158
171
|
// bound base packages by R only when the version is genuinely known; in `auto` mode with nothing detected, base tries every R release
|
|
159
172
|
const rVersion = ctx.rVersionKnown ? (ctx.meta.getRVersion() ?? ctx.resolvedRVersion) : undefined;
|
|
173
|
+
const rVersionOrigin = rVersion !== undefined ? ctx.rVersionOrigin : undefined;
|
|
160
174
|
// the analyzed package guesses versions for its dependencies, not for itself
|
|
161
175
|
const self = ctx.meta.getNamespace();
|
|
162
176
|
const graph = (await analyzer.dataflow()).graph;
|
|
177
|
+
const locate = locatorOf((await analyzer.normalize()).idMap);
|
|
163
178
|
const usage = (0, dependency_version_space_1.collectUsage)(graph, deps);
|
|
164
179
|
// fold orphan calls (`ggplot()` with ggplot2 neither declared nor loaded) into usage; a package the project does
|
|
165
180
|
// not already know is flagged for downstream attachment (see collectOrphanUsage)
|
|
@@ -173,7 +188,7 @@ async function executeGuessDepVersionsQuery({ analyzer }, queries) {
|
|
|
173
188
|
const cap = query.maxCandidates ?? guess_dep_versions_query_format_1.DefaultCandidateCap;
|
|
174
189
|
const explodeOrder = query.explode?.order ?? 'newest';
|
|
175
190
|
const guessedAll = sorted.map(name => {
|
|
176
|
-
const evidence = new EvidenceCollector();
|
|
191
|
+
const evidence = new EvidenceCollector(locate);
|
|
177
192
|
const surviving = space.survivors(name, transitive.get(name) ?? [], evidence.add);
|
|
178
193
|
return { name, evidence, surviving };
|
|
179
194
|
});
|
|
@@ -253,11 +268,13 @@ async function executeGuessDepVersionsQuery({ analyzer }, queries) {
|
|
|
253
268
|
const dependencies = [];
|
|
254
269
|
const ordered = [];
|
|
255
270
|
for (const g of guessedAll) {
|
|
271
|
+
const orphanCalls = [...orphans.attributed.get(g.name) ?? []].sort(([a], [b]) => a.localeCompare(b));
|
|
256
272
|
dependencies.push(guessPackage(g.name, cap, g.surviving, g.evidence, {
|
|
257
273
|
used: usage.has(g.name),
|
|
258
274
|
linkedWith: linkedWith.get(g.name),
|
|
259
275
|
coupledWith: coupledWith.get(g.name),
|
|
260
|
-
orphanFunctions:
|
|
276
|
+
orphanFunctions: orphanCalls.map(([fn]) => fn),
|
|
277
|
+
orphanEvidence: orphanCalls.map(([fn, call]) => (0, objects_1.compactRecord)({ function: fn, location: locate(call.at), reason: call.reason, exporters: call.exporters })),
|
|
261
278
|
orphanAlternatives: orphanAlternatives(g.name)
|
|
262
279
|
}));
|
|
263
280
|
const oc = query.explode ? (0, dependency_version_space_1.orderedCandidatesOf)(space.resolve(g.name).src, g.name, g.surviving, query.explode.prefer?.[g.name], explodeOrder) : undefined;
|
|
@@ -266,13 +283,15 @@ async function executeGuessDepVersionsQuery({ analyzer }, queries) {
|
|
|
266
283
|
}
|
|
267
284
|
}
|
|
268
285
|
const assignments = query.explode
|
|
269
|
-
? [...(0, dependency_version_space_1.assignmentsOf)(ordered, query.explode.limit ?? dependency_version_space_1.DefaultExplodeLimit, (0, dependency_version_space_1.declaredDependenciesOf)(space))]
|
|
286
|
+
? [...(0, dependency_version_space_1.assignmentsOf)(ordered, query.explode.limit ?? dependency_version_space_1.DefaultExplodeLimit, (0, dependency_version_space_1.declaredDependenciesOf)(space))]
|
|
287
|
+
.map(a => (0, objects_1.compactRecord)({ versions: Object.fromEntries(a.versions), unverified: a.unverified }))
|
|
270
288
|
: undefined;
|
|
271
289
|
return (0, objects_1.compactRecord)({
|
|
272
290
|
'.meta': { timing: Date.now() - start },
|
|
273
291
|
dependencies,
|
|
274
292
|
dateCutoff: cutoff ? (0, dependency_version_space_1.isoDay)(cutoff) : undefined,
|
|
275
293
|
rVersion,
|
|
294
|
+
rVersionOrigin,
|
|
276
295
|
versionSelection: ctx.config.solver.sigdb.versionSelection,
|
|
277
296
|
runnableCombinations,
|
|
278
297
|
possibleCombinations,
|
|
@@ -2,11 +2,13 @@ import type { BaseQueryFormat, BaseQueryResult } from '../../base-query-format';
|
|
|
2
2
|
import Joi from 'joi';
|
|
3
3
|
import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
4
4
|
import type { ParsedQueryLine } from '../../query';
|
|
5
|
+
import { type OutputFormatter } from '../../../util/text/ansi';
|
|
5
6
|
import { type VersionString } from '../../../util/r-version';
|
|
6
7
|
import type { ReplOutput } from '../../../cli/repl/commands/repl-main';
|
|
7
8
|
import { VersionSelection, type FlowrConfig } from '../../../config';
|
|
8
9
|
import { executeGuessDepVersionsQuery } from './guess-dep-versions-query-executor';
|
|
9
|
-
import type { ConstraintSource, DerivedConstraint } from '../../../project/dependency-version-space';
|
|
10
|
+
import type { ConstraintSource, DerivedConstraint, OrphanReason } from '../../../project/dependency-version-space';
|
|
11
|
+
import type { RVersionOrigin } from '../../../project/context/flowr-analyzer-context';
|
|
10
12
|
/**
|
|
11
13
|
* Guesses the possible version range of every dependency of a project by combining what the project *declares*
|
|
12
14
|
* (a `DESCRIPTION` range, an `rproject.toml` entry, a lockfile pin, and their transitive constraints) with what
|
|
@@ -45,17 +47,32 @@ export interface GuessExplodeOptions {
|
|
|
45
47
|
/** one concrete version choice per resolvable dependency (`package -> version`) */
|
|
46
48
|
export interface VersionAssignmentView {
|
|
47
49
|
readonly versions: Readonly<Record<string, VersionString>>;
|
|
50
|
+
/** see {@link VersionAssignment.unverified}: requirements on packages this assignment does not choose */
|
|
51
|
+
readonly unverified?: readonly string[];
|
|
48
52
|
}
|
|
49
53
|
/** the default cap on how many surviving candidate versions are listed per dependency */
|
|
50
54
|
export declare const DefaultCandidateCap = 16;
|
|
51
55
|
/** where a single bound on a dependency's version came from (the {@link DerivedConstraint} source, from the resolver) */
|
|
52
56
|
export type GuessEvidenceSource = ConstraintSource;
|
|
53
57
|
/**
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* it can answer "it must be `>= 4.2.0` because ...". This is the resolver's {@link DerivedConstraint}.
|
|
58
|
+
* The resolver's {@link DerivedConstraint} with its {@link DerivedConstraint.at|call site} resolved to a readable
|
|
59
|
+
* location, so the evidence answers not only "it must be `>= 4.2.0` because it calls `filter(.by=)`" but also where.
|
|
57
60
|
*/
|
|
58
|
-
export
|
|
61
|
+
export interface GuessVersionEvidence extends DerivedConstraint {
|
|
62
|
+
/** the location of the call that carried the evidence, e.g. `12:3` or `helper.R:12:3` */
|
|
63
|
+
readonly location?: string;
|
|
64
|
+
}
|
|
65
|
+
/** why a package is reported as an orphan: the call that would be undefined without it, and how it was picked */
|
|
66
|
+
export interface OrphanEvidenceView {
|
|
67
|
+
/** the undefined function that is called, e.g. `ggplot` */
|
|
68
|
+
readonly function: string;
|
|
69
|
+
/** where it is called, e.g. `12:3` */
|
|
70
|
+
readonly location?: string;
|
|
71
|
+
/** why this package and not another exporter of the name */
|
|
72
|
+
readonly reason: OrphanReason;
|
|
73
|
+
/** how many packages export the name */
|
|
74
|
+
readonly exporters: number;
|
|
75
|
+
}
|
|
59
76
|
/** one package an orphan call could have meant instead, with the versions of it that fit those calls */
|
|
60
77
|
export interface OrphanAlternativeView {
|
|
61
78
|
readonly package: string;
|
|
@@ -109,6 +126,13 @@ export interface GuessedDependency {
|
|
|
109
126
|
* and never appears in {@link GuessDepVersionsQueryResult.assignments}, so a consumer should resolve it by other means.
|
|
110
127
|
*/
|
|
111
128
|
readonly known?: boolean;
|
|
129
|
+
/**
|
|
130
|
+
* Set to `false` when nothing narrowed the package: every version the database holds survives, so the range
|
|
131
|
+
* merely restates what is available. Its {@link minVersion}/{@link maxVersion} then say nothing about the code
|
|
132
|
+
* (an era read off the minimum would be the database's oldest release, not the script's), which a range that
|
|
133
|
+
* happens to end at the newest version does not reveal on its own.
|
|
134
|
+
*/
|
|
135
|
+
readonly constrained?: boolean;
|
|
112
136
|
/**
|
|
113
137
|
* Set when this package was inferred purely from *orphan* calls: bare calls (`ggplot()`) that flowR could not
|
|
114
138
|
* resolve and that no loaded package defines, but whose name is exported by exactly this one package in the
|
|
@@ -118,6 +142,8 @@ export interface GuessedDependency {
|
|
|
118
142
|
readonly orphan?: boolean;
|
|
119
143
|
/** the undefined orphan function names that inferred this package (only set when {@link orphan}), e.g. `['ggplot']` */
|
|
120
144
|
readonly orphanFunctions?: readonly string[];
|
|
145
|
+
/** per {@link orphanFunctions} entry, where the undefined call is and why it was pinned on this package */
|
|
146
|
+
readonly orphanEvidence?: readonly OrphanEvidenceView[];
|
|
121
147
|
/**
|
|
122
148
|
* The other packages that export the {@link orphanFunctions}, each with the versions of it that would fit the
|
|
123
149
|
* calls. Attributing an orphan is a guess: the most downloaded exporter wins, and these are the ones it beat,
|
|
@@ -131,6 +157,11 @@ export interface GuessDepVersionsQueryResult extends BaseQueryResult {
|
|
|
131
157
|
readonly dateCutoff?: string;
|
|
132
158
|
/** the R version the guess assumed when bounding base-R packages, if known */
|
|
133
159
|
readonly rVersion?: string;
|
|
160
|
+
/**
|
|
161
|
+
* Where {@link rVersion} comes from. An `engine` version is the R installation running the analysis, which
|
|
162
|
+
* bounds the guess without saying anything about the analyzed code, unlike a `config` pin or project `metadata`.
|
|
163
|
+
*/
|
|
164
|
+
readonly rVersionOrigin?: RVersionOrigin;
|
|
134
165
|
/** the configured version-selection policy the sample illustrates (newest by default; see `solver.sigdb.versionSelection`) */
|
|
135
166
|
readonly versionSelection?: VersionSelection;
|
|
136
167
|
/** version tuples that satisfy every interdependency (the base/R hub counted against each dependency) */
|
|
@@ -155,7 +186,7 @@ declare function guessDepVersionsLineParser(_output: ReplOutput, line: readonly
|
|
|
155
186
|
export declare const GuessDepVersionsQueryDefinition: {
|
|
156
187
|
readonly title: "Guess Dependency Versions Query";
|
|
157
188
|
readonly executor: typeof executeGuessDepVersionsQuery;
|
|
158
|
-
readonly asciiSummarizer: (formatter:
|
|
189
|
+
readonly asciiSummarizer: (formatter: OutputFormatter, _analyzer: import("../../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider<import("../../../r-bridge/parser").KnownParser>, queryResults: BaseQueryResult, result: string[], _query: readonly import("../../query").Query[]) => true;
|
|
159
190
|
readonly fromLine: typeof guessDepVersionsLineParser;
|
|
160
191
|
readonly syntax: "@guess-dep-versions [<pkg> ...] [(clean | <=YYYY.MM.DD)] [--date YYYY.MM.DD] [--max <n>] [--iterations <n>] [--disabled <letters>] [--explode [--oldest] [--limit <n>] [--prefer <pkg>=<ver>]] <code | file://path>";
|
|
161
192
|
readonly schema: Joi.ObjectSchema<any>;
|
|
@@ -187,7 +187,11 @@ function compareBounds(a, b) {
|
|
|
187
187
|
}
|
|
188
188
|
/** whether a dependency's version is actually narrowed (not every database version survives); a fully redundant one is unconstrained */
|
|
189
189
|
function isConstrained(dep) {
|
|
190
|
-
return dep.
|
|
190
|
+
return dep.constrained !== false;
|
|
191
|
+
}
|
|
192
|
+
/** the assumed R version with where it came from, as a detected one bounds the guess without describing the code */
|
|
193
|
+
function rVersionText(out, formatter) {
|
|
194
|
+
return (0, ansi_1.italic)(out.rVersion, formatter) + (out.rVersionOrigin ? ' ' + (0, ansi_1.faint)(`(${out.rVersionOrigin})`, formatter) : '');
|
|
191
195
|
}
|
|
192
196
|
/** a version-combination count with thousands separators (exponential only past a trillion, where digits stop being useful) */
|
|
193
197
|
function formatCombinations(n) {
|
|
@@ -228,10 +232,10 @@ exports.GuessDepVersionsQueryDefinition = {
|
|
|
228
232
|
const out = queryResults;
|
|
229
233
|
result.push(`Query: ${(0, ansi_1.bold)('guess-dep-versions', formatter)} (${(0, time_1.printAsMs)(out['.meta'].timing, 0)})`);
|
|
230
234
|
if (out.dateCutoff) {
|
|
231
|
-
result.push(` ╰ up to ${(0, ansi_1.italic)(out.dateCutoff, formatter)}${out.rVersion ? `, R ${(
|
|
235
|
+
result.push(` ╰ up to ${(0, ansi_1.italic)(out.dateCutoff, formatter)}${out.rVersion ? `, R ${rVersionText(out, formatter)}` : ''}`);
|
|
232
236
|
}
|
|
233
237
|
else if (out.rVersion) {
|
|
234
|
-
result.push(` ╰ R ${(
|
|
238
|
+
result.push(` ╰ R ${rVersionText(out, formatter)}`);
|
|
235
239
|
}
|
|
236
240
|
if (out.dependencies.some(d => d.evidence.length > 0)) {
|
|
237
241
|
const legend = Object.keys(evidenceLetter).map(s => `${(0, ansi_1.color)(evidenceLetter[s], evidenceColor[s], formatter)} ${s}`).join(' ');
|
|
@@ -290,6 +294,13 @@ exports.GuessDepVersionsQueryDefinition = {
|
|
|
290
294
|
const dbGe = versionBound(tightestBound(avail, '>='))?.ver, dbLe = versionBound(tightestBound(avail, '<='))?.ver;
|
|
291
295
|
const dbRange = dbGe !== undefined && dbLe !== undefined ? `, db ${dbGe} - ${dbLe}` : '';
|
|
292
296
|
result.push(` ${(0, ansi_1.bold)('━ ' + dep.package, formatter)}${tag} ${range} ${(0, ansi_1.faint)('(' + count + dbRange + ')', formatter)}`);
|
|
297
|
+
for (const o of dep.orphanEvidence ?? []) {
|
|
298
|
+
// why the package is inferred at all: the call is undefined without it, plus why it beat another exporter
|
|
299
|
+
const where = o.location ? ` at ${o.location}` : '';
|
|
300
|
+
const why = o.reason === 'sole exporter' ? ` ${(0, ansi_1.faint)(`(only ${dep.package})`, formatter)}`
|
|
301
|
+
: o.reason === 'most downloaded' ? ` ${(0, ansi_1.faint)(`(most downloaded of ${o.exporters})`, formatter)}` : '';
|
|
302
|
+
result.push(` ${(0, ansi_1.color)('!', 3 /* Colors.Yellow */, formatter)} ${o.function}()${where} resolves to no definition${why}`);
|
|
303
|
+
}
|
|
293
304
|
if (dep.orphanAlternatives?.length) {
|
|
294
305
|
// attributing an orphan is a guess, so name the exporters it beat and what each of them would fit
|
|
295
306
|
const alts = dep.orphanAlternatives.map(a => `${a.package} ${a.range}`);
|
|
@@ -333,7 +344,9 @@ exports.GuessDepVersionsQueryDefinition = {
|
|
|
333
344
|
const ge = tightestBound(evs, '>='), le = tightestBound(evs, '<=');
|
|
334
345
|
const geVer = versionBound(ge)?.ver, leVer = versionBound(le)?.ver;
|
|
335
346
|
const params = [...new Set(evs.map(e => e.parameter).filter((pm) => pm !== undefined))];
|
|
336
|
-
const
|
|
347
|
+
const at = evs.find(e => e.location)?.location;
|
|
348
|
+
const reasons = [evs.some(e => !e.parameter) ? 'new' : undefined, params.length > 0 ? `params: [${truncatedList(params)}]` : undefined,
|
|
349
|
+
at ? `at ${at}` : undefined].filter(Boolean).join(', ');
|
|
337
350
|
const name = identifier_1.Identifier.getName(identifier_1.Identifier.parse(fn));
|
|
338
351
|
const url = (0, signature_query_executor_1.rdrrDocUrl)(dep.package, name, { base: dep.base, cran: !dep.base });
|
|
339
352
|
const label = (url ? formatter.hyperlink(name, url, true) : name) + (reasons ? ` (${reasons})` : '');
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.executeHappensBefore = executeHappensBefore;
|
|
4
|
+
const happens_before_query_format_1 = require("./happens-before-query-format");
|
|
4
5
|
const logic_1 = require("../../../util/logic");
|
|
5
6
|
const log_1 = require("../../../util/log");
|
|
6
7
|
const happens_before_1 = require("../../../control-flow/happens-before");
|
|
@@ -17,7 +18,7 @@ async function executeHappensBefore({ analyzer }, queries) {
|
|
|
17
18
|
const cfg = await analyzer.controlflow(undefined, cfg_kind_1.CfgKind.Quick);
|
|
18
19
|
for (const query of queries) {
|
|
19
20
|
const { a, b } = query;
|
|
20
|
-
const fingerprint =
|
|
21
|
+
const fingerprint = happens_before_query_format_1.HappensBeforeKey.of(a, b);
|
|
21
22
|
if (fingerprint in results) {
|
|
22
23
|
log_1.log.warn('Duplicate happens-before query', query, 'ignoring');
|
|
23
24
|
}
|
|
@@ -11,6 +11,20 @@ export interface HappensBeforeQuery extends BaseQueryFormat {
|
|
|
11
11
|
export interface HappensBeforeQueryResult extends BaseQueryResult {
|
|
12
12
|
readonly results: Record<string, Ternary>;
|
|
13
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* How an answer of the {@link HappensBeforeQuery} is keyed: the two criteria it was asked about, so that both
|
|
16
|
+
* the executor writing an answer and anyone reading one spell the key the same way.
|
|
17
|
+
*/
|
|
18
|
+
export declare const HappensBeforeKey: {
|
|
19
|
+
readonly name: "HappensBeforeKey";
|
|
20
|
+
/** The key the answer for `a` and `b` is stored under. */
|
|
21
|
+
readonly of: (this: void, a: SlicingCriterion, b: SlicingCriterion) => string;
|
|
22
|
+
/** The two criteria a key was built from. */
|
|
23
|
+
readonly criteria: (this: void, key: string) => {
|
|
24
|
+
a: string;
|
|
25
|
+
b: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
14
28
|
export declare const HappensBeforeQueryDefinition: {
|
|
15
29
|
readonly title: "Happens-Before Query";
|
|
16
30
|
readonly executor: typeof executeHappensBefore;
|
|
@@ -3,11 +3,27 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.HappensBeforeQueryDefinition = void 0;
|
|
6
|
+
exports.HappensBeforeQueryDefinition = exports.HappensBeforeKey = void 0;
|
|
7
7
|
const ansi_1 = require("../../../util/text/ansi");
|
|
8
8
|
const time_1 = require("../../../util/text/time");
|
|
9
9
|
const joi_1 = __importDefault(require("joi"));
|
|
10
10
|
const happens_before_query_executor_1 = require("./happens-before-query-executor");
|
|
11
|
+
/**
|
|
12
|
+
* How an answer of the {@link HappensBeforeQuery} is keyed: the two criteria it was asked about, so that both
|
|
13
|
+
* the executor writing an answer and anyone reading one spell the key the same way.
|
|
14
|
+
*/
|
|
15
|
+
exports.HappensBeforeKey = {
|
|
16
|
+
name: 'HappensBeforeKey',
|
|
17
|
+
/** The key the answer for `a` and `b` is stored under. */
|
|
18
|
+
of(a, b) {
|
|
19
|
+
return `${a}<${b}`;
|
|
20
|
+
},
|
|
21
|
+
/** The two criteria a key was built from. */
|
|
22
|
+
criteria(key) {
|
|
23
|
+
const at = key.indexOf('<');
|
|
24
|
+
return at < 0 ? { a: key, b: '' } : { a: key.slice(0, at), b: key.slice(at + 1) };
|
|
25
|
+
}
|
|
26
|
+
};
|
|
11
27
|
exports.HappensBeforeQueryDefinition = {
|
|
12
28
|
title: 'Happens-Before Query',
|
|
13
29
|
executor: happens_before_query_executor_1.executeHappensBefore,
|
|
@@ -15,7 +31,7 @@ exports.HappensBeforeQueryDefinition = {
|
|
|
15
31
|
const out = queryResults;
|
|
16
32
|
result.push(`Query: ${(0, ansi_1.bold)('happens-before', formatter)} (${(0, time_1.printAsMs)(out['.meta'].timing, 0)})`);
|
|
17
33
|
for (const [fingerprint, value] of Object.entries(out.results)) {
|
|
18
|
-
const { a, b } =
|
|
34
|
+
const { a, b } = exports.HappensBeforeKey.criteria(fingerprint);
|
|
19
35
|
result.push(` ╰ ${(0, ansi_1.bold)(a, formatter)} happens before ${(0, ansi_1.bold)(b, formatter)}: ${value}`);
|
|
20
36
|
}
|
|
21
37
|
return true;
|
|
@@ -37,12 +37,14 @@ exports.DefaultInputClassifierConfig = {
|
|
|
37
37
|
[simple_input_classifier_1.InputTraceType.Pure]: builtIns.without(built_in_props_1.InputProps),
|
|
38
38
|
[simple_input_classifier_1.InputType.File]: [...read_functions_1.ReadFunctions.map(readFunction => readFunction.name), ...builtIns.withAll(built_in_props_1.FileInputProps)],
|
|
39
39
|
[simple_input_classifier_1.InputType.TempFile]: builtIns.with(built_in_props_1.CallProp.TempFile),
|
|
40
|
+
[simple_input_classifier_1.InputType.Glob]: builtIns.with(built_in_props_1.CallProp.Glob),
|
|
40
41
|
[simple_input_classifier_1.InputType.Network]: flowr_search_builder_1.Q.fromQuery({ type: 'linter', rules: ['network-functions'] }, linter_format_1.LintingResultCertainty.Certain),
|
|
41
42
|
[simple_input_classifier_1.InputType.Random]: flowr_search_builder_1.Q.fromQuery({ type: 'linter', rules: ['seeded-randomness'] }),
|
|
42
43
|
[simple_input_classifier_1.InputType.System]: builtIns.with(built_in_props_1.CallProp.Process),
|
|
43
44
|
[simple_input_classifier_1.InputType.Ffi]: builtIns.with(built_in_props_1.CallProp.Ffi),
|
|
44
45
|
[simple_input_classifier_1.InputType.Lang]: builtIns.with(built_in_props_1.CallProp.Lang),
|
|
45
46
|
[simple_input_classifier_1.InputType.Options]: builtIns.with(built_in_props_1.CallProp.Ambient),
|
|
47
|
+
[simple_input_classifier_1.InputType.CommandLine]: builtIns.with(built_in_props_1.CallProp.CommandLine),
|
|
46
48
|
[simple_input_classifier_1.InputType.User]: builtIns.with(built_in_props_1.CallProp.User),
|
|
47
49
|
linkedObjects: input_source_functions_1.LinkedInputObjects,
|
|
48
50
|
linkedEntryPoints: input_source_functions_1.LinkedInputEntryPoints,
|
|
@@ -92,12 +94,14 @@ exports.InputSourcesDefinition = {
|
|
|
92
94
|
[simple_input_classifier_1.InputTraceType.Pure]: joi_1.default.array().items(joi_1.default.string()).optional().description('Deterministic/pure functions: functions that preserve constantness of their inputs (e.g., arithmetic, parse).'),
|
|
93
95
|
[simple_input_classifier_1.InputType.File]: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that read from the filesystem and produce data (e.g., read.csv, readRDS).'),
|
|
94
96
|
[simple_input_classifier_1.InputType.TempFile]: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that produce a temporary file path, which on its own touches no file system (e.g., tempfile, tempdir).'),
|
|
97
|
+
[simple_input_classifier_1.InputType.Glob]: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that answer with the paths they match at run time (e.g., list.files, Sys.glob).'),
|
|
95
98
|
[simple_input_classifier_1.InputType.Network]: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that fetch data from the network (e.g., download.file, url connections).'),
|
|
96
99
|
[simple_input_classifier_1.InputType.Random]: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that produce randomness (e.g., runif, rnorm).'),
|
|
97
100
|
[simple_input_classifier_1.InputType.System]: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that execute system commands (e.g., system, system2, shell, pipe).'),
|
|
98
101
|
[simple_input_classifier_1.InputType.Ffi]: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that call native code via the R FFI (.C, .Call, .Fortran, .External, dyn.load).'),
|
|
99
102
|
[simple_input_classifier_1.InputType.Lang]: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that produce language objects (e.g., substitute, quote, bquote, expression).'),
|
|
100
103
|
[simple_input_classifier_1.InputType.Options]: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that access or set global options (e.g., options, getOption).'),
|
|
104
|
+
[simple_input_classifier_1.InputType.CommandLine]: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that hand back what the program was invoked with (e.g., commandArgs).'),
|
|
101
105
|
[simple_input_classifier_1.InputType.User]: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that read interactive user input (e.g., file.choose, readline, menu, askYesNo).'),
|
|
102
106
|
linkedObjects: joi_1.default.array().items(joi_1.default.object({
|
|
103
107
|
name: joi_1.default.string().required().description('Name of the object, e.g. input.'),
|
|
@@ -27,6 +27,11 @@ export declare enum InputType {
|
|
|
27
27
|
File = "file",
|
|
28
28
|
/** Temporary file paths produced by tempfile()/tempdir() and equivalents; a sub-type of {@link File} */
|
|
29
29
|
TempFile = "tempfile",
|
|
30
|
+
/**
|
|
31
|
+
* Paths matched on disk at run time by list.files()/Sys.glob() and equivalents; a sub-type of {@link File}.
|
|
32
|
+
* Such a read finds no missing input, only an empty answer.
|
|
33
|
+
*/
|
|
34
|
+
Glob = "glob",
|
|
30
35
|
Network = "net",
|
|
31
36
|
Random = "rand",
|
|
32
37
|
/** Calls to system/system2 and similar */
|
|
@@ -37,6 +42,11 @@ export declare enum InputType {
|
|
|
37
42
|
Lang = "lang",
|
|
38
43
|
/** Global options / option accessors (options, getOption) */
|
|
39
44
|
Options = "options",
|
|
45
|
+
/**
|
|
46
|
+
* What the program was invoked with (commandArgs and equivalents): neither missing nor resolvable, it is
|
|
47
|
+
* chosen when the program is called. Carries {@link Options} too, the command line being ambient state.
|
|
48
|
+
*/
|
|
49
|
+
CommandLine = "cmdline",
|
|
40
50
|
/** Interactive user input (file choosers, prompts, dialogs, menu selections) */
|
|
41
51
|
User = "user",
|
|
42
52
|
Constant = "const",
|
|
@@ -31,6 +31,11 @@ var InputType;
|
|
|
31
31
|
InputType["File"] = "file";
|
|
32
32
|
/** Temporary file paths produced by tempfile()/tempdir() and equivalents; a sub-type of {@link File} */
|
|
33
33
|
InputType["TempFile"] = "tempfile";
|
|
34
|
+
/**
|
|
35
|
+
* Paths matched on disk at run time by list.files()/Sys.glob() and equivalents; a sub-type of {@link File}.
|
|
36
|
+
* Such a read finds no missing input, only an empty answer.
|
|
37
|
+
*/
|
|
38
|
+
InputType["Glob"] = "glob";
|
|
34
39
|
InputType["Network"] = "net";
|
|
35
40
|
InputType["Random"] = "rand";
|
|
36
41
|
/** Calls to system/system2 and similar */
|
|
@@ -41,6 +46,11 @@ var InputType;
|
|
|
41
46
|
InputType["Lang"] = "lang";
|
|
42
47
|
/** Global options / option accessors (options, getOption) */
|
|
43
48
|
InputType["Options"] = "options";
|
|
49
|
+
/**
|
|
50
|
+
* What the program was invoked with (commandArgs and equivalents): neither missing nor resolvable, it is
|
|
51
|
+
* chosen when the program is called. Carries {@link Options} too, the command line being ambient state.
|
|
52
|
+
*/
|
|
53
|
+
InputType["CommandLine"] = "cmdline";
|
|
44
54
|
/** Interactive user input (file choosers, prompts, dialogs, menu selections) */
|
|
45
55
|
InputType["User"] = "user";
|
|
46
56
|
InputType["Constant"] = "const";
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.executeLocationMapQuery = executeLocationMapQuery;
|
|
4
|
+
const location_map_query_format_1 = require("./location-map-query-format");
|
|
5
|
+
const model_1 = require("../../../r-bridge/lang-4.x/ast/model/model");
|
|
4
6
|
const assert_1 = require("../../../util/assert");
|
|
5
7
|
const parse_1 = require("../../../slicing/criterion/parse");
|
|
6
8
|
const fileIdRegex = /^(?<file>.*(\.[rR]))-/;
|
|
@@ -22,6 +24,14 @@ function fuzzyFindFile(node, idMap) {
|
|
|
22
24
|
}
|
|
23
25
|
return '@inline';
|
|
24
26
|
}
|
|
27
|
+
/** The range reported for a node under the requested {@link LocationMapSpan}, falling back to its own location. */
|
|
28
|
+
function rangeOf(node, idMap, span) {
|
|
29
|
+
if (span === location_map_query_format_1.LocationMapSpan.Token) {
|
|
30
|
+
return node.location;
|
|
31
|
+
}
|
|
32
|
+
const of = span === location_map_query_format_1.LocationMapSpan.Statement ? model_1.RNode.topLevelStatement(node, idMap) : node;
|
|
33
|
+
return model_1.RNode.span(of) ?? node.location;
|
|
34
|
+
}
|
|
25
35
|
/**
|
|
26
36
|
* Executes a location map query
|
|
27
37
|
* @see {@link LocationMapQuery}
|
|
@@ -29,10 +39,8 @@ function fuzzyFindFile(node, idMap) {
|
|
|
29
39
|
async function executeLocationMapQuery({ analyzer }, queries) {
|
|
30
40
|
const ast = await analyzer.normalize();
|
|
31
41
|
const start = Date.now();
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
.map(c => parse_1.SlicingCriterion.tryParse(c, ast.idMap))
|
|
35
|
-
.filter(assert_1.isNotUndefined));
|
|
42
|
+
const requested = queries.flatMap(q => q.ids ?? []);
|
|
43
|
+
const criteriaOfInterest = new Set(requested.map(c => parse_1.SlicingCriterion.tryParse(c, ast.idMap)).filter(assert_1.isNotUndefined));
|
|
36
44
|
const locationMap = {
|
|
37
45
|
files: {},
|
|
38
46
|
ids: {}
|
|
@@ -45,12 +53,14 @@ async function executeLocationMapQuery({ analyzer }, queries) {
|
|
|
45
53
|
inverseMap.set(file, count);
|
|
46
54
|
count++;
|
|
47
55
|
}
|
|
56
|
+
const span = queries.find(q => q.span !== undefined)?.span ?? location_map_query_format_1.LocationMapSpan.Token;
|
|
48
57
|
for (const [id, node] of ast.idMap.entries()) {
|
|
49
|
-
|
|
58
|
+
/* asking for ids none of which resolve yields nothing, not everything */
|
|
59
|
+
if (node.location && (requested.length === 0 || criteriaOfInterest.has(id))) {
|
|
50
60
|
const file = fuzzyFindFile(node, ast.idMap);
|
|
51
61
|
locationMap.ids[id] = [
|
|
52
62
|
inverseMap.get(file) ?? -1,
|
|
53
|
-
node.
|
|
63
|
+
rangeOf(node, ast.idMap, span)
|
|
54
64
|
];
|
|
55
65
|
}
|
|
56
66
|
}
|
|
@@ -9,10 +9,24 @@ import type { ReplOutput } from '../../../cli/repl/commands/repl-main';
|
|
|
9
9
|
import type { FlowrConfig } from '../../../config';
|
|
10
10
|
import type { ParsedQueryLine } from '../../query';
|
|
11
11
|
import { criteriaQueryCompleter } from '../../../cli/repl/parser/slice-query-parser';
|
|
12
|
+
/**
|
|
13
|
+
* How much of the source an entry of the {@link LocationMapQueryResult} covers: the `<-` of a multi-line
|
|
14
|
+
* assignment is a single `token`, while its subtree (`full`) is the whole assignment.
|
|
15
|
+
*/
|
|
16
|
+
export declare enum LocationMapSpan {
|
|
17
|
+
/** the location of the node itself, which for an operator or a call name is just that token */
|
|
18
|
+
Token = "token",
|
|
19
|
+
/** the range the whole subtree of the node covers, see {@link RNode.span} */
|
|
20
|
+
Full = "full",
|
|
21
|
+
/** the {@link Full} range of the top-level statement the node belongs to, see {@link RNode.topLevelStatement} */
|
|
22
|
+
Statement = "statement"
|
|
23
|
+
}
|
|
12
24
|
export interface LocationMapQuery extends BaseQueryFormat {
|
|
13
25
|
readonly type: 'location-map';
|
|
14
26
|
/** Optional list of ids to filter the results by. If not provided, all ids will be included. */
|
|
15
27
|
readonly ids?: readonly SlicingCriterion[];
|
|
28
|
+
/** How much of the source the reported range covers, {@link LocationMapSpan.Token} by default. */
|
|
29
|
+
readonly span?: LocationMapSpan;
|
|
16
30
|
}
|
|
17
31
|
export type FileId = number & {
|
|
18
32
|
readonly __fileId?: unique symbol;
|
|
@@ -33,7 +47,7 @@ export declare const LocationMapQueryDefinition: {
|
|
|
33
47
|
readonly asciiSummarizer: (formatter: OutputFormatter, _analyzer: unknown, queryResults: BaseQueryResult, result: string[]) => true;
|
|
34
48
|
readonly fromLine: typeof locationMapLineParser;
|
|
35
49
|
readonly completer: typeof criteriaQueryCompleter;
|
|
36
|
-
readonly syntax: "@location-map [(<crit>;...)] <code | file://path>";
|
|
50
|
+
readonly syntax: "@location-map [(<crit>;...)] [token|full|statement] <code | file://path>";
|
|
37
51
|
readonly schema: Joi.ObjectSchema<any>;
|
|
38
52
|
readonly flattenInvolvedNodes: () => never[];
|
|
39
53
|
};
|
|
@@ -3,21 +3,37 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.LocationMapQueryDefinition = void 0;
|
|
6
|
+
exports.LocationMapQueryDefinition = exports.LocationMapSpan = void 0;
|
|
7
7
|
const location_map_query_executor_1 = require("./location-map-query-executor");
|
|
8
8
|
const ansi_1 = require("../../../util/text/ansi");
|
|
9
9
|
const time_1 = require("../../../util/text/time");
|
|
10
10
|
const joi_1 = __importDefault(require("joi"));
|
|
11
11
|
const query_print_1 = require("../../query-print");
|
|
12
12
|
const slice_query_parser_1 = require("../../../cli/repl/parser/slice-query-parser");
|
|
13
|
+
/**
|
|
14
|
+
* How much of the source an entry of the {@link LocationMapQueryResult} covers: the `<-` of a multi-line
|
|
15
|
+
* assignment is a single `token`, while its subtree (`full`) is the whole assignment.
|
|
16
|
+
*/
|
|
17
|
+
var LocationMapSpan;
|
|
18
|
+
(function (LocationMapSpan) {
|
|
19
|
+
/** the location of the node itself, which for an operator or a call name is just that token */
|
|
20
|
+
LocationMapSpan["Token"] = "token";
|
|
21
|
+
/** the range the whole subtree of the node covers, see {@link RNode.span} */
|
|
22
|
+
LocationMapSpan["Full"] = "full";
|
|
23
|
+
/** the {@link Full} range of the top-level statement the node belongs to, see {@link RNode.topLevelStatement} */
|
|
24
|
+
LocationMapSpan["Statement"] = "statement";
|
|
25
|
+
})(LocationMapSpan || (exports.LocationMapSpan = LocationMapSpan = {}));
|
|
13
26
|
function locationMapLineParser(_output, line, _config) {
|
|
14
27
|
const criteria = (0, slice_query_parser_1.sliceCriteriaParser)(line[0]);
|
|
28
|
+
const rest = criteria ? line.slice(1) : line;
|
|
29
|
+
const span = Object.values(LocationMapSpan).includes(rest[0]) ? rest[0] : undefined;
|
|
15
30
|
return {
|
|
16
31
|
query: {
|
|
17
32
|
type: 'location-map',
|
|
18
|
-
ids: criteria
|
|
33
|
+
ids: criteria,
|
|
34
|
+
...(span ? { span } : {})
|
|
19
35
|
},
|
|
20
|
-
rCode:
|
|
36
|
+
rCode: span ? rest[1] : rest[0]
|
|
21
37
|
};
|
|
22
38
|
}
|
|
23
39
|
exports.LocationMapQueryDefinition = {
|
|
@@ -35,10 +51,11 @@ exports.LocationMapQueryDefinition = {
|
|
|
35
51
|
},
|
|
36
52
|
fromLine: locationMapLineParser,
|
|
37
53
|
completer: slice_query_parser_1.criteriaQueryCompleter,
|
|
38
|
-
syntax: '@location-map [(<crit>;...)] <code | file://path>',
|
|
54
|
+
syntax: '@location-map [(<crit>;...)] [token|full|statement] <code | file://path>',
|
|
39
55
|
schema: joi_1.default.object({
|
|
40
56
|
type: joi_1.default.string().valid('location-map').required().description('The type of the query.'),
|
|
41
|
-
ids: joi_1.default.array().items(joi_1.default.string()).optional().description('Optional list of ids to filter the results by.')
|
|
57
|
+
ids: joi_1.default.array().items(joi_1.default.string()).optional().description('Optional list of ids to filter the results by.'),
|
|
58
|
+
span: joi_1.default.string().valid(...Object.values(LocationMapSpan)).optional().description('How much of the source the reported range covers: the token itself (default), the whole subtree of the node, or the top-level statement it belongs to.')
|
|
42
59
|
}).description('The location map query retrieves the location of every id in the ast.'),
|
|
43
60
|
flattenInvolvedNodes: () => []
|
|
44
61
|
};
|
|
@@ -12,6 +12,7 @@ const semver_1 = require("semver");
|
|
|
12
12
|
const reader_1 = require("../../../project/sigdb/reader");
|
|
13
13
|
const sigdb_version_1 = require("../../../project/sigdb/sigdb-version");
|
|
14
14
|
const schema_1 = require("../../../project/sigdb/schema");
|
|
15
|
+
const attached_packages_1 = require("../../../project/attached-packages");
|
|
15
16
|
const manifest_1 = require("../../../project/sigdb/manifest");
|
|
16
17
|
const query_fn_props_1 = require("../../../dataflow/environments/query-fn-props");
|
|
17
18
|
const resolve_by_name_1 = require("../../../dataflow/environments/resolve-by-name");
|
|
@@ -441,6 +442,7 @@ function signaturePackageInfo(src, pkg, resolved) {
|
|
|
441
442
|
const deps = (src.dependencies(pkg, resolved) ?? src.dependencies(pkg) ?? [])
|
|
442
443
|
.map(d => ({ type: schema_1.DepTypeNames[d.type], name: d.name, ...(d.constraint ? { constraint: d.constraint } : {}) }));
|
|
443
444
|
const release = src.releaseDate(pkg, resolved);
|
|
445
|
+
const attaches = (0, attached_packages_1.attachedAlongside)(pkg, [src], resolved);
|
|
444
446
|
return {
|
|
445
447
|
name: pkg,
|
|
446
448
|
version: exports.version,
|
|
@@ -457,6 +459,7 @@ function signaturePackageInfo(src, pkg, resolved) {
|
|
|
457
459
|
deprecated: exports.deprecated,
|
|
458
460
|
...(base && src.coreVersions(pkg) ? { coreVersions: src.coreVersions(pkg)?.map(v => v.str) } : {}),
|
|
459
461
|
dependencies: deps,
|
|
462
|
+
...(attaches.length > 0 ? { attaches } : {}),
|
|
460
463
|
functions: fns.map(f => decodedToView(pkg, f, exports.version, { cran: exports.cran, base }))
|
|
461
464
|
};
|
|
462
465
|
}
|
|
@@ -124,6 +124,11 @@ export interface SignaturePackageView {
|
|
|
124
124
|
/** for a base package: the R releases it was part of core, ascending */
|
|
125
125
|
readonly coreVersions?: readonly string[];
|
|
126
126
|
readonly dependencies: readonly SignatureDependencyView[];
|
|
127
|
+
/**
|
|
128
|
+
* The packages that end up on the search path together with this one, so that {@link exportsTotal} is not
|
|
129
|
+
* mistaken for everything `library(<name>)` brings into scope (see `attachedAlongside`).
|
|
130
|
+
*/
|
|
131
|
+
readonly attaches?: readonly string[];
|
|
127
132
|
readonly functions: readonly SignatureFunctionView[];
|
|
128
133
|
}
|
|
129
134
|
/** a compact hit from a wildcard function search */
|
|
@@ -31,6 +31,14 @@ export interface SliceQueryOptions {
|
|
|
31
31
|
* the definition's binding and call sites. Defaults to `false`.
|
|
32
32
|
*/
|
|
33
33
|
readonly includeCallees?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Reconstruct the slice as the project's files rather than as one program, reported in
|
|
36
|
+
* {@link ReconstructionResult#files} in loading order with their paths. Without this only the entry file is
|
|
37
|
+
* reconstructed. Overridden by {@link inlineSources}/{@link inlineFull}, which produce the opposite.
|
|
38
|
+
*/
|
|
39
|
+
readonly perFile?: boolean;
|
|
40
|
+
/** Also report the packages the slice calls into; see {@link Dataflow.packagesOf}. */
|
|
41
|
+
readonly reportPackages?: boolean;
|
|
34
42
|
}
|
|
35
43
|
/** The Joi keys of {@link SliceQueryOptions}, to be spread into the schema of every slicing query. */
|
|
36
44
|
export declare const SliceQueryOptionsSchema: {
|
|
@@ -39,11 +47,13 @@ export declare const SliceQueryOptionsSchema: {
|
|
|
39
47
|
readonly inlineSources: Joi.BooleanSchema<boolean>;
|
|
40
48
|
readonly inlineFull: Joi.AlternativesSchema<string | boolean>;
|
|
41
49
|
readonly includeCallees: Joi.BooleanSchema<boolean>;
|
|
50
|
+
readonly perFile: Joi.BooleanSchema<boolean>;
|
|
51
|
+
readonly reportPackages: Joi.BooleanSchema<boolean>;
|
|
42
52
|
};
|
|
43
53
|
/**
|
|
44
54
|
* Resolves the criteria to their node ids, reporting those that match no node: they would slice nothing,
|
|
45
55
|
* as {@link SlicingCriteria.convertAll} keeps them verbatim.
|
|
46
56
|
*/
|
|
47
57
|
export declare function resolveSliceCriteria(criteria: SlicingCriteria, ast: NormalizedAst): NodeId[];
|
|
48
|
-
/** Reconstruct the given `nodes` of `ast`, honoring the inlining and magic-comment options. */
|
|
58
|
+
/** Reconstruct the given `nodes` of `ast`, honoring the inlining, per-file and magic-comment options. */
|
|
49
59
|
export declare function reconstructSlice(ast: NormalizedAst, graph: DataflowGraph, nodes: ReadonlySet<NodeId>, options: SliceQueryOptions): ReconstructionResult;
|