@eagleoutice/flowr 2.15.10 → 2.16.1
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 +23 -26
- package/abstract-interpretation/data-frame/arguments.js +11 -7
- package/cli/flowr-main-options.d.ts +15 -0
- package/cli/flowr-main-options.js +18 -0
- package/cli/flowr.d.ts +18 -0
- package/cli/flowr.js +13 -2
- package/cli/repl/commands/repl-clipboard.js +2 -1
- package/cli/repl/commands/repl-commands.js +2 -0
- package/cli/repl/commands/repl-main.d.ts +5 -0
- package/cli/repl/commands/repl-signature.js +2 -0
- package/cli/repl/core.d.ts +7 -1
- package/cli/repl/core.js +17 -8
- package/cli/repl/execute.js +2 -0
- package/cli/repl/server/connection.js +2 -1
- package/cli/repl/server/net.d.ts +10 -0
- package/cli/repl/server/net.js +34 -1
- package/cli/slicer-app.js +2 -1
- package/config.d.ts +12 -2
- package/config.js +91 -14
- package/control-flow/happens-before.d.ts +5 -0
- package/control-flow/happens-before.js +48 -34
- package/control-flow/useless-loop.d.ts +1 -1
- package/control-flow/useless-loop.js +29 -42
- package/dataflow/environments/built-in-props.d.ts +9 -0
- package/dataflow/environments/built-in-props.js +25 -19
- package/dataflow/environments/built-in.d.ts +2 -2
- package/dataflow/environments/built-in.js +41 -77
- package/dataflow/environments/default-builtin-config.d.ts +181 -29
- package/dataflow/environments/default-builtin-config.js +38 -24
- package/dataflow/environments/environment.d.ts +6 -4
- package/dataflow/environments/environment.js +54 -121
- package/dataflow/environments/identifier.d.ts +4 -2
- package/dataflow/environments/identifier.js +23 -69
- package/dataflow/environments/reference-to-maybe.d.ts +9 -0
- package/dataflow/environments/reference-to-maybe.js +23 -51
- package/dataflow/environments/resolve-by-name.js +37 -76
- package/dataflow/eval/resolve/resolve-argument.d.ts +3 -1
- package/dataflow/eval/resolve/resolve-argument.js +61 -64
- package/dataflow/eval/resolve/resolve-working-directory.d.ts +8 -2
- package/dataflow/eval/resolve/resolve-working-directory.js +12 -20
- package/dataflow/eval/resolve/resolve.d.ts +4 -0
- package/dataflow/eval/resolve/resolve.js +23 -14
- package/dataflow/extractor.js +185 -59
- package/dataflow/fn/class-declaration.d.ts +8 -2
- package/dataflow/fn/class-declaration.js +96 -97
- package/dataflow/fn/exceptions-of-function.js +68 -37
- package/dataflow/fn/frame-reflection.d.ts +12 -4
- package/dataflow/fn/frame-reflection.js +64 -42
- package/dataflow/fn/function-props.js +15 -33
- package/dataflow/fn/function-semantics.d.ts +11 -3
- package/dataflow/fn/function-semantics.js +6 -0
- package/dataflow/fn/higher-order-function.js +13 -17
- package/dataflow/fn/strict-function.d.ts +13 -0
- package/dataflow/fn/strict-function.js +285 -122
- package/dataflow/graph/call-graph.d.ts +7 -6
- package/dataflow/graph/call-graph.js +35 -46
- package/dataflow/graph/graph.d.ts +6 -1
- package/dataflow/graph/graph.js +57 -66
- package/dataflow/info.d.ts +8 -1
- package/dataflow/info.js +24 -30
- package/dataflow/internal/control-flow.d.ts +42 -4
- package/dataflow/internal/control-flow.js +76 -39
- package/dataflow/internal/linker.d.ts +15 -9
- package/dataflow/internal/linker.js +253 -241
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +80 -14
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +441 -79
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +3 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +51 -48
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +119 -185
- package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +7 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +122 -147
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +55 -25
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +290 -252
- package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +30 -32
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +68 -67
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +72 -126
- package/dataflow/internal/process/functions/call/built-in/built-in-local.d.ts +1 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-local.js +10 -10
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.d.ts +4 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +9 -35
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +8 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-s-four.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-four.js +12 -28
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +40 -118
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +16 -24
- package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +2 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +93 -102
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +7 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +173 -114
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.d.ts +1 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +22 -27
- package/dataflow/internal/process/functions/call/built-in/built-in-with.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +34 -9
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +120 -93
- package/dataflow/internal/process/functions/call/common.d.ts +1 -3
- package/dataflow/internal/process/functions/call/common.js +36 -76
- package/dataflow/internal/process/functions/call/deferred.d.ts +6 -2
- package/dataflow/internal/process/functions/call/deferred.js +60 -58
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +4 -2
- package/dataflow/internal/process/functions/call/known-call-handling.js +65 -68
- package/dataflow/internal/process/functions/call/named-call-handling.d.ts +3 -5
- package/dataflow/internal/process/functions/call/named-call-handling.js +44 -21
- package/dataflow/internal/process/functions/call/quoted.d.ts +2 -0
- package/dataflow/internal/process/functions/call/quoted.js +162 -172
- package/dataflow/internal/process/functions/call/unnamed-call-handling.js +17 -38
- package/dataflow/internal/process/functions/process-parameter.js +25 -32
- package/dataflow/internal/process/process-symbol.js +3 -6
- package/dataflow/internal/program-order.d.ts +26 -0
- package/dataflow/internal/program-order.js +49 -0
- package/documentation/doc-capabilities.js +4 -1
- package/documentation/wiki-interface.js +4 -0
- package/documentation/wiki-setup.js +23 -0
- package/engines.js +11 -3
- package/linter/linter-executor.js +19 -1
- package/linter/linter-rules.d.ts +17 -8
- package/linter/rules/absolute-path.js +63 -87
- package/linter/rules/file-path-validity.d.ts +4 -2
- package/linter/rules/file-path-validity.js +117 -80
- package/linter/rules/namespace-access.js +21 -33
- package/linter/rules/naming-convention.d.ts +1 -1
- package/linter/rules/naming-convention.js +60 -48
- package/linter/rules/network-functions.js +11 -7
- package/linter/rules/no-leaked-credentials.js +15 -18
- package/linter/rules/problematic-inputs.d.ts +2 -1
- package/linter/rules/problematic-inputs.js +39 -59
- package/linter/rules/roxygen-arguments.d.ts +9 -4
- package/linter/rules/roxygen-arguments.js +29 -48
- package/linter/rules/seeded-randomness.d.ts +7 -4
- package/linter/rules/seeded-randomness.js +130 -89
- package/linter/rules/stop-with-call-arg.d.ts +4 -2
- package/linter/rules/stop-with-call-arg.js +25 -22
- package/linter/rules/unclosed-connection.js +31 -24
- package/linter/rules/undefined-symbol.d.ts +4 -6
- package/linter/rules/undefined-symbol.js +58 -75
- package/linter/rules/unescaped-arguments.js +18 -44
- package/linter/rules/unused-definition.d.ts +6 -0
- package/linter/rules/unused-definition.js +105 -145
- package/linter/rules/unused-import.d.ts +3 -0
- package/linter/rules/unused-import.js +25 -43
- package/package.json +5 -2
- package/project/flowr-analyzer.js +6 -2
- package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +2 -2
- package/project/plugins/file-plugins/files/flowr-jupyter-file.js +8 -12
- package/project/plugins/file-plugins/files/flowr-rda-file.d.ts +14 -5
- package/project/plugins/file-plugins/files/flowr-rda-file.js +35 -24
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +7 -5
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +34 -56
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +18 -42
- package/project/sigdb/decompress.js +3 -1
- package/project/sigdb/sigdb-download.js +9 -6
- package/queries/base-query-format.js +1 -2
- package/queries/catalog/absint-query/absint-query-format.js +1 -1
- package/queries/catalog/config-query/config-query-executor.js +9 -2
- package/queries/catalog/dataflow-query/dataflow-query-executor.js +2 -2
- package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +2 -0
- package/queries/catalog/dataflow-query/dataflow-query-format.js +4 -7
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +50 -114
- package/queries/catalog/dependencies-query/function-info/library-functions.d.ts +5 -9
- package/queries/catalog/dependencies-query/function-info/library-functions.js +6 -0
- package/queries/catalog/dependencies-query/function-info/read-functions.js +1 -1
- package/queries/catalog/dependencies-query/function-info/write-functions.js +7 -3
- package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +4 -4
- package/queries/catalog/input-sources-query/simple-input-classifier.js +192 -301
- package/r-bridge/lang-4.x/ast/model/model.d.ts +3 -1
- package/r-bridge/lang-4.x/ast/model/model.js +19 -43
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +1 -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-argument.js +5 -12
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +1 -0
- package/r-bridge/roxygen2/roxygen-parse.js +28 -42
- package/r-bridge/shell-executor.js +2 -0
- package/r-bridge/shell.js +8 -0
- package/search/search-executor/search-enrichers.js +25 -37
- package/slicing/static/slice-call.d.ts +4 -3
- package/slicing/static/slice-call.js +56 -88
- package/slicing/static/static-slicer.js +120 -79
- package/slicing/static/visiting-queue.d.ts +4 -6
- package/slicing/static/visiting-queue.js +9 -13
- package/util/files.d.ts +6 -0
- package/util/files.js +12 -0
- package/util/parallel.js +2 -0
- package/util/proc.js +2 -1
- package/util/r-base-packages.d.ts +2 -0
- package/util/r-base-packages.js +23 -13
- package/util/secure-mode.d.ts +42 -0
- package/util/secure-mode.js +70 -0
- package/util/text/playground-link.d.ts +12 -3
- package/util/text/playground-link.js +18 -27
- package/util/version.js +4 -10
|
@@ -8,6 +8,8 @@ import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/nod
|
|
|
8
8
|
*/
|
|
9
9
|
export interface DataflowQuery extends BaseQueryFormat {
|
|
10
10
|
readonly type: 'dataflow';
|
|
11
|
+
/** Whether to include the environments of the vertices and function definitions (default), see {@link DataflowGraph#withoutEnvironments}. */
|
|
12
|
+
readonly environments?: boolean;
|
|
11
13
|
}
|
|
12
14
|
export interface DataflowQueryResult extends BaseQueryResult {
|
|
13
15
|
/** Please be aware that this is the graph in its JSON representation, use {@link DataflowGraph#fromJson} if the result is serialized */
|
|
@@ -22,7 +22,7 @@ exports.DataflowQueryDefinition = {
|
|
|
22
22
|
result.push(` ╰ [Dataflow Graph](${url})`);
|
|
23
23
|
}
|
|
24
24
|
else {
|
|
25
|
-
const vertices =
|
|
25
|
+
const vertices = out.graph.vertices(true).toArray().length;
|
|
26
26
|
const edges = Array.from(out.graph.edges()).length;
|
|
27
27
|
result.push(` ╰ Dataflow Graph too large to link (${vertices} vertices, ${edges} edges, url would be ${url.length} chars); use ':df#' for more detail.`);
|
|
28
28
|
}
|
|
@@ -30,14 +30,11 @@ exports.DataflowQueryDefinition = {
|
|
|
30
30
|
},
|
|
31
31
|
schema: joi_1.default.object({
|
|
32
32
|
type: joi_1.default.string().valid('dataflow').required().description('The type of the query.'),
|
|
33
|
+
environments: joi_1.default.boolean().optional().description('Whether to include the environments of the vertices and function definitions (default: true). They make up most of the answer, so leave them out if only the graph itself is of interest.'),
|
|
33
34
|
}).description('The dataflow query simply returns the dataflow graph, there is no need to pass it multiple times!'),
|
|
34
|
-
flattenInvolvedNodes: queryResults => {
|
|
35
|
-
const flattened = [];
|
|
35
|
+
flattenInvolvedNodes: (queryResults) => {
|
|
36
36
|
const out = queryResults;
|
|
37
|
-
|
|
38
|
-
flattened.push(id);
|
|
39
|
-
}
|
|
40
|
-
return flattened;
|
|
37
|
+
return [...out.graph.idMap?.keys() ?? []];
|
|
41
38
|
}
|
|
42
39
|
};
|
|
43
40
|
//# sourceMappingURL=dataflow-query-format.js.map
|
|
@@ -23,7 +23,6 @@ const r_base_packages_1 = require("../../../util/r-base-packages");
|
|
|
23
23
|
async function executeDependenciesQuery({ analyzer, }, queries) {
|
|
24
24
|
let query = queries[0];
|
|
25
25
|
if (queries.length !== 1) {
|
|
26
|
-
// merge
|
|
27
26
|
for (let i = 1; i < queries.length; i++) {
|
|
28
27
|
const q = queries[i];
|
|
29
28
|
query = {
|
|
@@ -46,15 +45,11 @@ async function executeDependenciesQuery({ analyzer, }, queries) {
|
|
|
46
45
|
const now = Date.now();
|
|
47
46
|
const ignoreDefault = query.ignoreDefaultFunctions ?? false;
|
|
48
47
|
const ctx = analyzer.inspectContext();
|
|
49
|
-
const functions = new Map(Object.entries((0, dependencies_query_format_1.defaultDependencyCategories)(ctx)).map(([c, v]) => {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
// custom categories only use the "functions" collection and do not allow specifying additional functions in the object itself, so we "undefined" a lot here
|
|
55
|
-
const custom = getFunctionsToCheck(undefined, category, undefined, false, value.functions);
|
|
56
|
-
functions.set(category, [...(functions.get(category) ?? []), ...custom]);
|
|
57
|
-
}
|
|
48
|
+
const functions = new Map(Object.entries((0, dependencies_query_format_1.defaultDependencyCategories)(ctx)).map(([c, v]) => [c, getFunctionsToCheck(query[`${c}Functions`], c, query.enabledCategories, ignoreDefault, v.functions)]));
|
|
49
|
+
for (const [category, value] of Object.entries(query.additionalCategories ?? {})) {
|
|
50
|
+
/* custom categories only use their "functions" collection and allow no additional functions in the object itself */
|
|
51
|
+
const custom = getFunctionsToCheck(undefined, category, undefined, false, value.functions);
|
|
52
|
+
functions.set(category, [...(functions.get(category) ?? []), ...custom]);
|
|
58
53
|
}
|
|
59
54
|
const queryResults = !functions.values().toArray().some(f => f.length > 0) ? { kinds: {}, '.meta': { timing: 0 } } :
|
|
60
55
|
await (0, query_1.executeQueriesOfSameType)(data, functions.entries().flatMap(makeCallContextQuery).toArray());
|
|
@@ -62,8 +57,8 @@ async function executeDependenciesQuery({ analyzer, }, queries) {
|
|
|
62
57
|
const enabled = query.enabledCategories;
|
|
63
58
|
const results = Object.fromEntries(await Promise.all(functions.entries().map(async ([c, f]) => {
|
|
64
59
|
const results = getResults(g, { dataflow, config, normalize }, queryResults, c, f, data);
|
|
65
|
-
|
|
66
|
-
if (enabled === undefined ||
|
|
60
|
+
/* only default categories allow additional analyses */
|
|
61
|
+
if (enabled === undefined || enabled.includes(c)) {
|
|
67
62
|
await g[c]?.additionalAnalysis?.(data, ignoreDefault, f, queryResults, results);
|
|
68
63
|
}
|
|
69
64
|
return [c, results];
|
|
@@ -74,8 +69,7 @@ async function executeDependenciesQuery({ analyzer, }, queries) {
|
|
|
74
69
|
}
|
|
75
70
|
if (query.assumedPackages && (enabled === undefined || enabled.includes('library'))) {
|
|
76
71
|
const explicit = new Set((results.library ?? []).map(r => r.value).filter((v) => v !== undefined && v !== dependencies_query_format_1.Unknown && v !== dependencies_query_format_1.Constant));
|
|
77
|
-
const
|
|
78
|
-
const assumed = assumedBasePackageEntries(dataflow.graph, rVersion, explicit);
|
|
72
|
+
const assumed = assumedBasePackageEntries(dataflow.graph, ctx.resolvedRVersion, explicit);
|
|
79
73
|
if (assumed.length > 0) {
|
|
80
74
|
results.library = [...(results.library ?? []), ...assumed];
|
|
81
75
|
}
|
|
@@ -87,27 +81,22 @@ async function executeDependenciesQuery({ analyzer, }, queries) {
|
|
|
87
81
|
...results,
|
|
88
82
|
};
|
|
89
83
|
}
|
|
84
|
+
/** One implicit `library` entry per attached base package that the graph uses but that is not loaded explicitly. */
|
|
90
85
|
function assumedBasePackageEntries(dfg, rVersion, explicit) {
|
|
91
|
-
const
|
|
86
|
+
const used = [];
|
|
92
87
|
for (const [id, qualified] of df_helper_1.Dataflow.qualifyAll(dfg, true)) {
|
|
93
|
-
const pkg =
|
|
94
|
-
if (pkg
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
const known = usedBy.get(pkg);
|
|
98
|
-
if (known) {
|
|
99
|
-
known.push(id);
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
usedBy.set(pkg, [id]);
|
|
88
|
+
const pkg = identifier_1.Identifier.getNamespace(qualified);
|
|
89
|
+
if (pkg !== undefined && !explicit.has(pkg) && r_base_packages_1.AttachedBasePackageSet.has(pkg)) {
|
|
90
|
+
used.push({ id, pkg });
|
|
103
91
|
}
|
|
104
92
|
}
|
|
93
|
+
const usedBy = Map.groupBy(used, u => u.pkg);
|
|
105
94
|
return (0, r_base_packages_1.attachedBasePackages)(rVersion).filter(pkg => usedBy.has(pkg)).map(pkg => (0, objects_1.compactRecord)({
|
|
106
95
|
functionName: dependencies_query_format_1.Attached,
|
|
107
96
|
value: pkg,
|
|
108
97
|
implicit: true,
|
|
109
98
|
alwaysAttached: pkg === "base" /* PkgName.Base */ ? true : undefined,
|
|
110
|
-
linkedIds: usedBy.get(pkg)
|
|
99
|
+
linkedIds: usedBy.get(pkg)?.map(u => u.id)
|
|
111
100
|
}));
|
|
112
101
|
}
|
|
113
102
|
function makeCallContextQuery([kind, functions]) {
|
|
@@ -122,12 +111,6 @@ function makeCallContextQuery([kind, functions]) {
|
|
|
122
111
|
kind
|
|
123
112
|
}));
|
|
124
113
|
}
|
|
125
|
-
function dropInfoOnLinkedIds(linkedIds) {
|
|
126
|
-
if (!linkedIds) {
|
|
127
|
-
return undefined;
|
|
128
|
-
}
|
|
129
|
-
return linkedIds.map(id => typeof id === 'object' ? id.id : id);
|
|
130
|
-
}
|
|
131
114
|
const readOnlyModes = new Set(['r', 'rt', 'rb']);
|
|
132
115
|
const writeOnlyModes = new Set(['w', 'wt', 'wb', 'a', 'at', 'ab']);
|
|
133
116
|
/**
|
|
@@ -148,16 +131,7 @@ function pickFunctionInfo(candidates, callNamespace, isLoaded) {
|
|
|
148
131
|
function getResults(categories, { dataflow, config, normalize }, results, kind, functions, data) {
|
|
149
132
|
const defaultValue = categories[kind].defaultValue;
|
|
150
133
|
const vars = config.solver.variables;
|
|
151
|
-
const functionMap =
|
|
152
|
-
for (const f of functions) {
|
|
153
|
-
const known = functionMap.get(f.name);
|
|
154
|
-
if (known) {
|
|
155
|
-
known.push(f);
|
|
156
|
-
}
|
|
157
|
-
else {
|
|
158
|
-
functionMap.set(f.name, [f]);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
134
|
+
const functionMap = Map.groupBy(functions, f => f.name);
|
|
161
135
|
const kindEntries = Object.entries(results?.kinds[kind]?.subkinds ?? {});
|
|
162
136
|
const finalResults = [];
|
|
163
137
|
const ictx = data.analyzer.inspectContext();
|
|
@@ -170,36 +144,26 @@ function getResults(categories, { dataflow, config, normalize }, results, kind,
|
|
|
170
144
|
for (const { id, linkedIds } of results) {
|
|
171
145
|
const vertex = dfg.getVertex(id);
|
|
172
146
|
const functionName = df_helper_1.Dataflow.qualify(id, dfg, false) ?? vertex.name;
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
if (picked === undefined) {
|
|
147
|
+
const info = pickFunctionInfo(functionMap.get(name), identifier_1.Identifier.getNamespace(functionName), isLoadedPackage);
|
|
148
|
+
if (info === undefined) {
|
|
176
149
|
continue;
|
|
177
150
|
}
|
|
178
|
-
const info = picked;
|
|
179
151
|
const args = (0, resolve_argument_1.getArgumentStringValue)(vars, dfg, vertex, info.argIdx, info.argName, info.resolveValue, ictx);
|
|
180
152
|
const linkedArgs = collectValuesFromLinks(args, { dataflow, config, ctx: ictx }, linkedIds);
|
|
181
|
-
const linked =
|
|
182
|
-
|
|
183
|
-
if (info.ignoreIf
|
|
184
|
-
|
|
185
|
-
(0, assert_1.guard)(margs, 'Need additional argument val when checking for arg-true');
|
|
186
|
-
const valArgs = (0, resolve_argument_1.getArgumentStringValue)(vars, dfg, vertex, margs.argIdx, margs.argName, margs.resolveValue, data?.analyzer.inspectContext());
|
|
187
|
-
const valValues = valArgs?.values().flatMap(v => Array.from(v)).toArray() ?? [];
|
|
188
|
-
if (valValues.length === 0) {
|
|
189
|
-
return false;
|
|
190
|
-
}
|
|
191
|
-
if (info.ignoreIf === 'arg-true' && valValues.every(v => v === 'TRUE')) {
|
|
192
|
-
// all values are TRUE, so we can ignore this
|
|
193
|
-
return true;
|
|
194
|
-
}
|
|
195
|
-
else if (info.ignoreIf === 'arg-false' && valValues.every(v => v === 'FALSE')) {
|
|
196
|
-
// all values are FALSE, so we can ignore this
|
|
197
|
-
return true;
|
|
198
|
-
}
|
|
153
|
+
const linked = linkedIds?.map(linkedId => typeof linkedId === 'object' ? linkedId.id : linkedId);
|
|
154
|
+
const ignoreOnArgVal = () => {
|
|
155
|
+
if (info.ignoreIf !== 'arg-true' && info.ignoreIf !== 'arg-false') {
|
|
156
|
+
return false;
|
|
199
157
|
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
158
|
+
const margs = info.additionalArgs?.val;
|
|
159
|
+
(0, assert_1.guard)(margs, 'Need additional argument val when checking for arg-true');
|
|
160
|
+
const valArgs = (0, resolve_argument_1.getArgumentStringValue)(vars, dfg, vertex, margs.argIdx, margs.argName, margs.resolveValue, data?.analyzer.inspectContext());
|
|
161
|
+
const valValues = valArgs?.values().flatMap(v => Array.from(v)).toArray() ?? [];
|
|
162
|
+
/* ignore only if every value is the one the check asks for */
|
|
163
|
+
const ignoredValue = info.ignoreIf === 'arg-true' ? 'TRUE' : 'FALSE';
|
|
164
|
+
return valValues.length > 0 && valValues.every(v => v === ignoredValue);
|
|
165
|
+
};
|
|
166
|
+
const ignoreOnArgSet = () => {
|
|
203
167
|
if (info.ignoreIf !== 'arg-set') {
|
|
204
168
|
return;
|
|
205
169
|
}
|
|
@@ -211,38 +175,28 @@ function getResults(categories, { dataflow, config, normalize }, results, kind,
|
|
|
211
175
|
const margs = info.additionalArgs?.argSet;
|
|
212
176
|
(0, assert_1.guard)(margs, 'Need additional argument argSet when checking for arg-set');
|
|
213
177
|
return hasArg(margs.argName, margs.argIdx);
|
|
214
|
-
}
|
|
178
|
+
};
|
|
215
179
|
const foundValues = linkedArgs ?? args;
|
|
216
180
|
if (!foundValues) {
|
|
217
|
-
if (info.ignoreIf
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
functionName,
|
|
226
|
-
lexemeOfArgument: undefined,
|
|
227
|
-
linkedIds: linked?.length ? linked : undefined,
|
|
228
|
-
value: info.defaultValue ?? defaultValue
|
|
229
|
-
});
|
|
230
|
-
if (record) {
|
|
231
|
-
finalResults.push(record);
|
|
181
|
+
if (info.ignoreIf !== 'arg-missing' && !ignoreOnArgVal() && !ignoreOnArgSet()) {
|
|
182
|
+
finalResults.push((0, objects_1.compactRecord)({
|
|
183
|
+
nodeId: id,
|
|
184
|
+
functionName,
|
|
185
|
+
lexemeOfArgument: undefined,
|
|
186
|
+
linkedIds: linked?.length ? linked : undefined,
|
|
187
|
+
value: info.defaultValue ?? defaultValue
|
|
188
|
+
}));
|
|
232
189
|
}
|
|
233
190
|
continue;
|
|
234
191
|
}
|
|
235
192
|
else if (info.ignoreIf === 'mode-only-read' || info.ignoreIf === 'mode-only-write') {
|
|
236
193
|
const margs = info.additionalArgs?.mode;
|
|
237
194
|
(0, assert_1.guard)(margs, 'Need additional argument mode when checking for mode');
|
|
195
|
+
const modes = info.ignoreIf === 'mode-only-read' ? readOnlyModes : writeOnlyModes;
|
|
238
196
|
const modeArgs = (0, resolve_argument_1.getArgumentStringValue)(vars, dfg, vertex, margs.argIdx, margs.argName, margs.resolveValue, data?.analyzer.inspectContext());
|
|
239
197
|
const modeValues = modeArgs?.values().flatMap(v => Array.from(v)) ?? [];
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
continue;
|
|
243
|
-
}
|
|
244
|
-
else if (info.ignoreIf === 'mode-only-write' && modeValues.every(m => m && writeOnlyModes.has(m))) {
|
|
245
|
-
// all modes are write-only, so we can ignore this
|
|
198
|
+
/* all modes are read-only (resp. write-only), so we can ignore this */
|
|
199
|
+
if (modeValues.every(m => m && modes.has(m))) {
|
|
246
200
|
continue;
|
|
247
201
|
}
|
|
248
202
|
}
|
|
@@ -252,8 +206,8 @@ function getResults(categories, { dataflow, config, normalize }, results, kind,
|
|
|
252
206
|
for (const [arg, values] of foundValues.entries()) {
|
|
253
207
|
for (const value of values) {
|
|
254
208
|
let resolvedValue = value;
|
|
255
|
-
if (info.stringReplacements &&
|
|
256
|
-
resolvedValue = info.stringReplacements[
|
|
209
|
+
if (info.stringReplacements && value !== undefined && Object.hasOwn(info.stringReplacements, value)) {
|
|
210
|
+
resolvedValue = info.stringReplacements[value];
|
|
257
211
|
}
|
|
258
212
|
const dep = resolvedValue ? d.getDependency(resolvedValue) ?? undefined : undefined;
|
|
259
213
|
const lexeme = getLexeme(value, arg);
|
|
@@ -278,11 +232,7 @@ function getResults(categories, { dataflow, config, normalize }, results, kind,
|
|
|
278
232
|
if ((argument && argument !== dependencies_query_format_1.Unknown && argument !== dependencies_query_format_1.Constant) || !id) {
|
|
279
233
|
return undefined;
|
|
280
234
|
}
|
|
281
|
-
|
|
282
|
-
if (r_argument_1.RArgument.is(get)) {
|
|
283
|
-
get = get.value;
|
|
284
|
-
}
|
|
285
|
-
return model_1.RNode.lexeme(get);
|
|
235
|
+
return model_1.RNode.lexeme(r_argument_1.RArgument.valueOf(normalize.idMap.get(id)));
|
|
286
236
|
}
|
|
287
237
|
}
|
|
288
238
|
function collectValuesFromLinks(args, data, linkedIds) {
|
|
@@ -296,38 +246,24 @@ function collectValuesFromLinks(args, data, linkedIds) {
|
|
|
296
246
|
continue;
|
|
297
247
|
}
|
|
298
248
|
const info = linkedId.info;
|
|
299
|
-
// do not collect this one
|
|
300
249
|
if (hasAtLeastAValue && info.when !== function_info_1.DependencyInfoLinkConstraint.Always) {
|
|
301
250
|
continue;
|
|
302
251
|
}
|
|
303
|
-
// collect this one!
|
|
304
252
|
const vertex = data.dataflow.graph.getVertex(linkedId.id);
|
|
305
253
|
if (!vertex_1.DfgVertex.isFunctionCall(vertex)) {
|
|
306
254
|
continue;
|
|
307
255
|
}
|
|
308
256
|
const args = (0, resolve_argument_1.getArgumentStringValue)(data.config.solver.variables, data.dataflow.graph, vertex, info.argIdx, info.argName, info.resolveValue, data.ctx);
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
}
|
|
312
|
-
for (const [arg, values] of args.entries()) {
|
|
313
|
-
const set = map.get(arg) ?? new Set();
|
|
314
|
-
map.set(arg, set);
|
|
315
|
-
for (const value of values) {
|
|
316
|
-
set.add(value);
|
|
317
|
-
}
|
|
257
|
+
for (const [arg, values] of args?.entries() ?? []) {
|
|
258
|
+
map.set(arg, (map.get(arg) ?? new Set()).union(values));
|
|
318
259
|
}
|
|
319
260
|
}
|
|
320
261
|
return map.size ? map : undefined;
|
|
321
262
|
}
|
|
322
263
|
function getFunctionsToCheck(customFunctions, functionFlag, enabled, ignoreDefaultFunctions, defaultFunctions) {
|
|
323
|
-
|
|
324
|
-
if (enabled !== undefined && (enabled?.length === 0 || !enabled.includes(functionFlag))) {
|
|
264
|
+
if (enabled !== undefined && !enabled.includes(functionFlag)) {
|
|
325
265
|
return [];
|
|
326
266
|
}
|
|
327
|
-
|
|
328
|
-
if (customFunctions) {
|
|
329
|
-
functions = functions.concat(customFunctions);
|
|
330
|
-
}
|
|
331
|
-
return functions;
|
|
267
|
+
return [...(ignoreDefaultFunctions ? [] : defaultFunctions), ...(customFunctions ?? [])];
|
|
332
268
|
}
|
|
333
269
|
//# sourceMappingURL=dependencies-query-executor.js.map
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import type { FunctionInfo } from './function-info';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* @see {@link LibraryFunctions}
|
|
5
|
-
*/
|
|
2
|
+
import type { DependencyInfo } from '../dependencies-query-format';
|
|
3
|
+
/** A loader of the {@link LibraryFunctions|`library` category}, together with whether it attaches the package it names. */
|
|
6
4
|
export interface LibraryFunctionInfo extends FunctionInfo {
|
|
7
|
-
/**
|
|
8
|
-
* Whether the call makes the package's exports reachable by their bare name, which is what tells a package
|
|
9
|
-
* that is loaded and used apart from one that is loaded and never touched. `false` for a loader that only
|
|
10
|
-
* readies a namespace to reach as `pkg::fn`, and for one whose argument is not a package at all.
|
|
11
|
-
*/
|
|
5
|
+
/** Whether the call makes the package's exports reachable by their bare name, not only as `pkg::fn`. */
|
|
12
6
|
attaches: boolean;
|
|
13
7
|
}
|
|
14
8
|
export declare const LibraryFunctions: LibraryFunctionInfo[];
|
|
9
|
+
/** Whether the known loader a `library`-category finding came from attaches the package (`base::require` as well as `require`). */
|
|
10
|
+
export declare function attachesPackage(info: DependencyInfo): boolean;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LibraryFunctions = void 0;
|
|
4
|
+
exports.attachesPackage = attachesPackage;
|
|
5
|
+
const identifier_1 = require("../../../../dataflow/environments/identifier");
|
|
4
6
|
exports.LibraryFunctions = [
|
|
5
7
|
{ package: 'base', name: 'library', argIdx: 0, argName: 'package', resolveValue: 'library', attaches: true },
|
|
6
8
|
{ package: 'base', name: 'require', argIdx: 0, argName: 'package', resolveValue: 'library', attaches: true },
|
|
@@ -29,4 +31,8 @@ exports.LibraryFunctions = [
|
|
|
29
31
|
/* a hook that runs when the package is loaded by someone else, which loads nothing itself */
|
|
30
32
|
{ package: 'rlang', name: 'on_package_load', argIdx: 0, argName: 'pkg', resolveValue: true, attaches: false }
|
|
31
33
|
];
|
|
34
|
+
/** Whether the known loader a `library`-category finding came from attaches the package (`base::require` as well as `require`). */
|
|
35
|
+
function attachesPackage(info) {
|
|
36
|
+
return exports.LibraryFunctions.some(loader => loader.attaches && identifier_1.Identifier.matches(loader.name, info.functionName));
|
|
37
|
+
}
|
|
32
38
|
//# sourceMappingURL=library-functions.js.map
|
|
@@ -22,7 +22,7 @@ const ReadFunctionsWithMore = [
|
|
|
22
22
|
{ package: 'base', name: 'fifo', argIdx: 0, argName: 'description', resolveValue: true, ignoreIf: 'mode-only-write', additionalArgs: { mode: { argIdx: 1, argName: 'open', resolveValue: true } } },
|
|
23
23
|
{ package: 'base', name: 'unz', argIdx: 0, argName: 'description', resolveValue: true, ignoreIf: 'mode-only-write', additionalArgs: { mode: { argIdx: 1, argName: 'open', resolveValue: true } } },
|
|
24
24
|
{ package: 'base', name: 'matrix', argIdx: 0, argName: 'data', resolveValue: true },
|
|
25
|
-
{ package: 'utils', name: 'data', argIdx:
|
|
25
|
+
{ package: 'utils', name: 'data', argIdx: 'unnamed', argName: 'list', resolveValue: 'library', ignoreIf: 'arg-missing' },
|
|
26
26
|
{ package: 'readr', name: 'clipboard' },
|
|
27
27
|
{ package: 'sourcetools', name: 'tokenize', argName: 'file', resolveValue: true, ignoreIf: 'arg-missing' },
|
|
28
28
|
{ package: 'ape', name: 'read.tree', argName: 'file', resolveValue: true, ignoreIf: 'arg-missing' },
|
|
@@ -36,6 +36,13 @@ const WriteFunctionsWithMore = [
|
|
|
36
36
|
{ package: 'rlang', name: 'inform', linkTo: OutputRedirects, resolveValue: false },
|
|
37
37
|
{ package: 'cli', name: 'cli_warn', linkTo: OutputRedirects, resolveValue: false },
|
|
38
38
|
{ package: 'cli', name: 'cli_abort', linkTo: OutputRedirects, resolveValue: false },
|
|
39
|
+
{ package: 'base', name: 'file.create', argIdx: 'unnamed', resolveValue: true },
|
|
40
|
+
{ package: 'base', name: 'file.copy', argIdx: 1, argName: 'to', resolveValue: true },
|
|
41
|
+
{ package: 'base', name: 'file.rename', argIdx: 1, argName: 'to', resolveValue: true },
|
|
42
|
+
{ package: 'base', name: 'file.append', argIdx: 0, argName: 'file1', resolveValue: true },
|
|
43
|
+
{ package: 'base', name: 'file.symlink', argIdx: 1, argName: 'to', resolveValue: true },
|
|
44
|
+
{ package: 'base', name: 'file.link', argIdx: 1, argName: 'to', resolveValue: true },
|
|
45
|
+
{ package: 'utils', name: 'download.file', argIdx: 1, argName: 'destfile', resolveValue: true },
|
|
39
46
|
{ package: 'base', name: 'file', argIdx: 0, argName: 'description', resolveValue: true, ignoreIf: 'mode-only-read', additionalArgs: { mode: { argIdx: 1, argName: 'open', resolveValue: true } } },
|
|
40
47
|
{ package: 'base', name: 'url', argIdx: 0, argName: 'description', resolveValue: true, ignoreIf: 'mode-only-read', additionalArgs: { mode: { argIdx: 1, argName: 'open', resolveValue: true } } },
|
|
41
48
|
{ package: 'grDevices', name: 'jpeg', argIdx: 0, argName: 'filename', resolveValue: true },
|
|
@@ -77,9 +84,6 @@ const WriteFunctionsWithMore = [
|
|
|
77
84
|
{ package: 'png', name: 'writePNG', argIdx: 1, argName: 'target', resolveValue: true, ignoreIf: 'arg-missing' },
|
|
78
85
|
/* audio / video */
|
|
79
86
|
{ package: 'seewave', name: 'savewav', argName: 'filename', resolveValue: true, defaultValue: '<wave-name>' },
|
|
80
|
-
/* geospatial */
|
|
81
|
-
/* array / binary science formats */
|
|
82
|
-
/* phylogeny / sequence */
|
|
83
87
|
];
|
|
84
88
|
/** The write entries the given built-in definitions imply, together with the ones written down here. */
|
|
85
89
|
function computeWriteFunctions(definitions, read = (0, read_functions_1.computeReadFunctions)(definitions)) {
|
|
@@ -24,12 +24,12 @@ export interface LinkedInputObject {
|
|
|
24
24
|
readonly requires?: string;
|
|
25
25
|
/** if given, only these fields are inputs (`session$clientData` is, `session$userData` is not) and the object itself is none */
|
|
26
26
|
readonly fields?: readonly string[];
|
|
27
|
-
/** how the framework declares the entries of this object, so a read of `input$n` links to the `textInput("n",
|
|
27
|
+
/** how the framework declares the entries of this object, so a read of `input$n` links to the `textInput("n", ...)` defining it */
|
|
28
28
|
readonly declaredBy?: LinkedInputDeclaration;
|
|
29
29
|
}
|
|
30
30
|
/** The calls that declare the entries of a {@link LinkedInputObject}, and where they carry the entry's name. */
|
|
31
31
|
export interface LinkedInputDeclaration {
|
|
32
|
-
/** the declaring calls, e.g. shiny's `textInput`, `selectInput`,
|
|
32
|
+
/** the declaring calls, e.g. shiny's `textInput`, `selectInput`, ... */
|
|
33
33
|
readonly calls: readonly Identifier[];
|
|
34
34
|
/** the name of the argument holding the entry's name */
|
|
35
35
|
readonly argName: string;
|
|
@@ -81,11 +81,11 @@ export interface InputSource extends MergeableRecord {
|
|
|
81
81
|
name?: string;
|
|
82
82
|
/** the concrete scalar value when the source is a constant or a pure alias of one */
|
|
83
83
|
value?: ConstantValue;
|
|
84
|
-
/** where the framework entry this source reads is declared, e.g. the `textInput("n",
|
|
84
|
+
/** where the framework entry this source reads is declared, e.g. the `textInput("n", ...)` behind an `input$n` */
|
|
85
85
|
declaredAt?: NodeId[];
|
|
86
86
|
}
|
|
87
87
|
/**
|
|
88
|
-
*
|
|
88
|
+
* The input sources of a criterion, each classified with an {@link InputSource} object.
|
|
89
89
|
*/
|
|
90
90
|
export type InputSources = InputSource[];
|
|
91
91
|
/**
|