@eagleoutice/flowr 2.13.14 → 2.13.16
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 +25 -31
- package/abstract-interpretation/data-frame/resolve-args.js +11 -12
- package/abstract-interpretation/unsupported-functions.d.ts +1 -0
- package/abstract-interpretation/unsupported-functions.js +1 -0
- package/benchmark/summarizer/second-phase/graph.d.ts +23 -0
- package/benchmark/summarizer/second-phase/graph.js +47 -14
- package/cli/repl/commands/repl-cfg.js +2 -42
- package/cli/repl/commands/repl-clipboard.d.ts +7 -0
- package/cli/repl/commands/repl-clipboard.js +53 -0
- package/cli/repl/commands/repl-dataflow.js +5 -70
- package/cli/repl/commands/repl-normalize.js +3 -51
- package/cli/repl/commands/repl-query.js +37 -2
- package/cli/repl/core.js +5 -2
- package/control-flow/cfg-dead-code.js +5 -29
- package/control-flow/control-flow-graph.d.ts +2 -0
- package/control-flow/control-flow-graph.js +2 -0
- package/control-flow/diff-cfg.js +2 -56
- package/control-flow/semantic-cfg-guided-visitor.d.ts +7 -0
- package/control-flow/semantic-cfg-guided-visitor.js +14 -0
- package/control-flow/useless-loop.js +4 -26
- package/core/steps/all/core/10-normalize.d.ts +8 -0
- package/core/steps/all/core/10-normalize.js +10 -8
- package/core/steps/all/core/11-normalize-tree-sitter.d.ts +5 -7
- package/core/steps/all/core/11-normalize-tree-sitter.js +2 -9
- package/data/r-base-packages.generated.d.ts +1 -0
- package/data/r-base-packages.generated.js +5 -3
- package/dataflow/environments/built-in-config.d.ts +9 -1
- package/dataflow/environments/built-in-proc-name.d.ts +2 -0
- package/dataflow/environments/built-in-proc-name.js +2 -0
- package/dataflow/environments/built-in-props.d.ts +4 -0
- package/dataflow/environments/built-in-props.js +3 -3
- package/dataflow/environments/built-in.d.ts +4 -2
- package/dataflow/environments/built-in.js +53 -3
- package/dataflow/environments/data-masking-functions.d.ts +3 -4
- package/dataflow/environments/data-masking-functions.js +7 -8
- package/dataflow/environments/default-builtin-config.d.ts +92 -12
- package/dataflow/environments/default-builtin-config.js +86 -43
- package/dataflow/environments/environment.d.ts +5 -0
- package/dataflow/environments/environment.js +17 -12
- package/dataflow/environments/identifier.d.ts +3 -0
- package/dataflow/eval/resolve/alias-tracking.js +4 -7
- package/dataflow/eval/resolve/node-value.d.ts +51 -0
- package/dataflow/eval/resolve/node-value.js +71 -0
- package/dataflow/eval/resolve/resolve-argument.js +10 -7
- package/dataflow/eval/resolve/resolve-operators.js +1 -2
- package/dataflow/eval/values/general.d.ts +4 -0
- package/dataflow/eval/values/general.js +14 -0
- package/dataflow/eval/values/r-value.d.ts +15 -0
- package/dataflow/eval/values/r-value.js +27 -1
- package/dataflow/extractor.js +2 -0
- package/dataflow/fn/higher-order-function.d.ts +1 -1
- package/dataflow/fn/higher-order-function.js +22 -4
- package/dataflow/graph/call-graph.d.ts +1 -1
- package/dataflow/graph/call-graph.js +1 -1
- package/dataflow/graph/df-helper.d.ts +2 -2
- package/dataflow/graph/df-helper.js +1 -1
- package/dataflow/graph/diff-dataflow-graph.js +3 -55
- package/dataflow/graph/graph-helper.d.ts +1 -0
- package/dataflow/graph/graph-helper.js +1 -0
- package/dataflow/graph/graph.d.ts +5 -0
- package/dataflow/graph/graph.js +27 -0
- package/dataflow/graph/vertex.d.ts +5 -0
- package/dataflow/graph/vertex.js +5 -0
- package/dataflow/internal/linker.d.ts +23 -0
- package/dataflow/internal/linker.js +70 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +4 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +2 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +8 -29
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +39 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +10 -22
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +29 -53
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +4 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +7 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-load.js +2 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +19 -12
- package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.d.ts +3 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +69 -52
- package/dataflow/internal/process/functions/call/built-in/built-in-recall.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.js +2 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +2 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +6 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +31 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.d.ts +5 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.js +7 -10
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.d.ts +6 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +20 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-stop-if-not.js +6 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-string-template.d.ts +25 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-string-template.js +105 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +1 -27
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +4 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +1 -1
- package/dataflow/internal/process/functions/call/deferred.d.ts +48 -0
- package/dataflow/internal/process/functions/call/deferred.js +149 -0
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +13 -12
- package/dataflow/internal/process/functions/call/known-call-handling.js +35 -35
- package/dataflow/internal/process/functions/call/named-call-handling.d.ts +1 -1
- package/dataflow/internal/process/functions/call/named-call-handling.js +8 -4
- package/dataflow/internal/process/functions/call/nse.d.ts +29 -0
- package/dataflow/internal/process/functions/call/nse.js +88 -0
- package/dataflow/internal/process/functions/call/quoted.d.ts +30 -0
- package/dataflow/internal/process/functions/call/quoted.js +191 -0
- package/documentation/doc-util/doc-types.js +15 -9
- package/documentation/wiki-dataflow-graph.js +8 -0
- package/linter/linter-format.d.ts +1 -0
- package/linter/linter-format.js +1 -0
- package/linter/rules/deprecated-functions.js +9 -3
- package/linter/rules/seeded-randomness.js +2 -3
- package/linter/rules/undefined-symbol.js +10 -1
- package/package.json +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.d.ts +6 -0
- package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.js +17 -1
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.d.ts +2 -11
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.js +3 -15
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmarkdown-file-plugin.d.ts +16 -0
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmarkdown-file-plugin.js +26 -0
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.d.ts +2 -11
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.js +3 -15
- package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-description-file-plugin.js +4 -10
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-description-file-plugin.js +2 -9
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.js +2 -9
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +1 -1
- package/project/sigdb/reader.d.ts +9 -0
- package/project/sigdb/reader.js +30 -0
- package/queries/catalog/absint-query/absint-query-format.js +1 -1
- package/queries/catalog/does-call-query/does-call-query-format.js +2 -1
- package/queries/catalog/input-sources-query/input-sources-query-format.js +2 -2
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.d.ts +0 -12
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.js +2 -37
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +1 -1
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +2 -23
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +1 -1
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.js +2 -2
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.js +1 -1
- package/queries/catalog/location-map-query/location-map-query-format.js +1 -1
- package/queries/catalog/origin-query/origin-query-format.js +1 -1
- package/queries/catalog/provenance-query/provenance-query-format.js +1 -1
- package/queries/catalog/resolve-value-query/resolve-value-query-format.js +1 -1
- package/queries/query-function-filter.d.ts +21 -0
- package/queries/query-function-filter.js +48 -0
- package/r-bridge/data/data.d.ts +13 -3
- package/r-bridge/data/data.js +15 -3
- package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +4 -0
- package/search/flowr-search-filters.d.ts +5 -1
- package/search/flowr-search-filters.js +31 -21
- package/search/search-executor/search-enrichers.d.ts +24 -4
- package/search/search-executor/search-enrichers.js +22 -9
- package/search/search-executor/search-transformer.js +1 -1
- package/slicing/criterion/parse.d.ts +1 -0
- package/slicing/criterion/parse.js +1 -0
- package/util/diff-graph.d.ts +13 -0
- package/util/diff-graph.js +64 -1
- package/util/files.js +9 -8
- package/util/r-base-packages.d.ts +2 -0
- package/util/r-base-packages.js +3 -1
- package/util/r-version.d.ts +2 -0
- package/util/r-version.js +2 -0
- package/util/record.d.ts +1 -0
- package/util/record.js +1 -0
- package/util/version.js +1 -1
|
@@ -30,11 +30,13 @@ function mergeInformation(info, newInfo) {
|
|
|
30
30
|
/**
|
|
31
31
|
* Marks the given function call node as only calling built-in functions.
|
|
32
32
|
*/
|
|
33
|
-
function markAsOnlyBuiltIn(graph, rootId) {
|
|
33
|
+
function markAsOnlyBuiltIn(graph, rootId, keepEnvironment = false) {
|
|
34
34
|
const v = graph.getVertex(rootId);
|
|
35
35
|
if (v?.tag === vertex_1.VertexType.FunctionCall) {
|
|
36
36
|
v.onlyBuiltin = true;
|
|
37
|
-
|
|
37
|
+
if (!keepEnvironment) {
|
|
38
|
+
v.environment = undefined;
|
|
39
|
+
}
|
|
38
40
|
}
|
|
39
41
|
}
|
|
40
42
|
/**
|
|
@@ -44,8 +46,10 @@ function markAsOnlyBuiltIn(graph, rootId) {
|
|
|
44
46
|
function processNamedCall(name, args, rootId, data) {
|
|
45
47
|
const resolved = (0, resolve_by_name_1.resolveByName)(name.content, data.environment, identifier_1.ReferenceType.Function) ?? [];
|
|
46
48
|
let defaultProcessor = resolved.length === 0;
|
|
49
|
+
/* a call whose meaning a later pass looks up in its environment has to keep it */
|
|
50
|
+
const keepEnvironment = resolved.some(r => r.type === identifier_1.ReferenceType.BuiltInFunction && r.config?.keepEnvironment === true);
|
|
47
51
|
/* if this call will be marked as built-in only (see below), its vertex needs no environment snapshot */
|
|
48
|
-
if (resolved.length > 0
|
|
52
|
+
if (resolved.length > 0 && !keepEnvironment
|
|
49
53
|
&& resolved.every(r => r.type === identifier_1.ReferenceType.BuiltInFunction && typeof r.processor === 'function')
|
|
50
54
|
&& resolved.some(r => r.type === identifier_1.ReferenceType.BuiltInFunction && r.config?.libFn !== true)) {
|
|
51
55
|
data = { ...data, builtInNoEnv: rootId };
|
|
@@ -68,7 +72,7 @@ function processNamedCall(name, args, rootId, data) {
|
|
|
68
72
|
}
|
|
69
73
|
else if (information && builtIn) {
|
|
70
74
|
// mark the function call as built in only
|
|
71
|
-
markAsOnlyBuiltIn(information.graph, rootId);
|
|
75
|
+
markAsOnlyBuiltIn(information.graph, rootId, keepEnvironment);
|
|
72
76
|
}
|
|
73
77
|
// on demand: materialize the built-in vertex for any package export this call resolves to and, when we
|
|
74
78
|
// already know the loading call here, link to it (a function-local export is invisible to the later
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { RNode } from '../../../../../r-bridge/lang-4.x/ast/model/model';
|
|
2
|
+
import type { NodeId } from '../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
3
|
+
import type { ParentInformation } from '../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
4
|
+
import { Identifier } from '../../../../environments/identifier';
|
|
5
|
+
import type { DataflowGraph } from '../../../../graph/graph';
|
|
6
|
+
import { type DataflowGraphVertexInfo } from '../../../../graph/vertex';
|
|
7
|
+
/** The escape a quoting function offers, a property of the function: `quote(!!x)` negates, `expr(!!x)` splices. */
|
|
8
|
+
export declare enum Unquote {
|
|
9
|
+
/** no escape at all, everything within the argument stays unevaluated */
|
|
10
|
+
None = "none",
|
|
11
|
+
/** rlang's `!!` and `!!!` splice in the value of their operand */
|
|
12
|
+
Rlang = "rlang",
|
|
13
|
+
/** `bquote`'s `.(x)` evaluates its operand */
|
|
14
|
+
Bquote = "bquote"
|
|
15
|
+
}
|
|
16
|
+
/** The parts of a call R does not evaluate the standard way. */
|
|
17
|
+
export declare const Nse: {
|
|
18
|
+
readonly name: "Nse";
|
|
19
|
+
/** The ids an {@link Unquote} escape hands back to standard evaluation, the markers themselves excluded. */
|
|
20
|
+
readonly unquoted: <Info extends ParentInformation>(this: void, root: RNode<Info> | undefined, style: Unquote) => ReadonlySet<NodeId> | undefined;
|
|
21
|
+
/** Whether everything below `node` is unquoted. */
|
|
22
|
+
readonly isUnquote: <Info>(this: void, node: RNode<Info>, style: Unquote) => boolean;
|
|
23
|
+
/** Drops the mask mark from names the caller binds: while `filter(d, k)` is processed `k` has no read yet. */
|
|
24
|
+
readonly dropResolvedMask: (this: void, graph: DataflowGraph, id: NodeId, name: Identifier) => void;
|
|
25
|
+
/** Drops the non-standard-evaluation mark from the outgoing edges of `id` that `which` accepts. */
|
|
26
|
+
readonly unmark: (this: void, graph: DataflowGraph, id: NodeId, which?: (target: NodeId) => boolean) => void;
|
|
27
|
+
/** Whether `id` is a name the data mask supplies, i.e. a use the caller does not bind itself. */
|
|
28
|
+
readonly suppliedByMask: (this: void, graph: DataflowGraph, id: NodeId, vertex?: DataflowGraphVertexInfo | undefined) => boolean;
|
|
29
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Nse = exports.Unquote = void 0;
|
|
4
|
+
const model_1 = require("../../../../../r-bridge/lang-4.x/ast/model/model");
|
|
5
|
+
const r_unary_op_1 = require("../../../../../r-bridge/lang-4.x/ast/model/nodes/r-unary-op");
|
|
6
|
+
const r_function_call_1 = require("../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
7
|
+
const identifier_1 = require("../../../../environments/identifier");
|
|
8
|
+
const data_masking_functions_1 = require("../../../../environments/data-masking-functions");
|
|
9
|
+
const vertex_1 = require("../../../../graph/vertex");
|
|
10
|
+
const edge_1 = require("../../../../graph/edge");
|
|
11
|
+
/** The escape a quoting function offers, a property of the function: `quote(!!x)` negates, `expr(!!x)` splices. */
|
|
12
|
+
var Unquote;
|
|
13
|
+
(function (Unquote) {
|
|
14
|
+
/** no escape at all, everything within the argument stays unevaluated */
|
|
15
|
+
Unquote["None"] = "none";
|
|
16
|
+
/** rlang's `!!` and `!!!` splice in the value of their operand */
|
|
17
|
+
Unquote["Rlang"] = "rlang";
|
|
18
|
+
/** `bquote`'s `.(x)` evaluates its operand */
|
|
19
|
+
Unquote["Bquote"] = "bquote";
|
|
20
|
+
})(Unquote || (exports.Unquote = Unquote = {}));
|
|
21
|
+
/** `!!x` parses as `!(!x)`, so peel the run of `!` to reach the operand. */
|
|
22
|
+
function unquotedOperandOf(node, style) {
|
|
23
|
+
if (style === Unquote.Bquote) {
|
|
24
|
+
if (!r_function_call_1.RFunctionCall.isNamed(node) || identifier_1.Identifier.getName(node.functionName.content) !== '.' || node.arguments.length !== 1) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
const arg = node.arguments[0];
|
|
28
|
+
return arg === r_function_call_1.EmptyArgument ? undefined : arg.value;
|
|
29
|
+
}
|
|
30
|
+
if (!isNegation(node) || !isNegation(node.operand)) {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
let operand = node.operand;
|
|
34
|
+
while (isNegation(operand)) {
|
|
35
|
+
operand = operand.operand;
|
|
36
|
+
}
|
|
37
|
+
return operand;
|
|
38
|
+
}
|
|
39
|
+
function isNegation(node) {
|
|
40
|
+
return r_unary_op_1.RUnaryOp.is(node) && node.operator === '!';
|
|
41
|
+
}
|
|
42
|
+
/** The parts of a call R does not evaluate the standard way. */
|
|
43
|
+
exports.Nse = {
|
|
44
|
+
name: 'Nse',
|
|
45
|
+
/** The ids an {@link Unquote} escape hands back to standard evaluation, the markers themselves excluded. */
|
|
46
|
+
unquoted(root, style) {
|
|
47
|
+
if (root === undefined || style === Unquote.None) {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
const evaluated = new Set();
|
|
51
|
+
model_1.RNode.visitAst(root, node => {
|
|
52
|
+
const operand = unquotedOperandOf(node, style);
|
|
53
|
+
if (operand === undefined) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
model_1.RNode.visitAst(operand, inner => {
|
|
57
|
+
evaluated.add(inner.info.id);
|
|
58
|
+
return false;
|
|
59
|
+
});
|
|
60
|
+
return true;
|
|
61
|
+
});
|
|
62
|
+
return evaluated.size > 0 ? evaluated : undefined;
|
|
63
|
+
},
|
|
64
|
+
/** Whether everything below `node` is unquoted. */
|
|
65
|
+
isUnquote(node, style) {
|
|
66
|
+
return style !== Unquote.None && unquotedOperandOf(node, style) !== undefined;
|
|
67
|
+
},
|
|
68
|
+
/** Drops the mask mark from names the caller binds: while `filter(d, k)` is processed `k` has no read yet. */
|
|
69
|
+
dropResolvedMask(graph, id, name) {
|
|
70
|
+
if (data_masking_functions_1.DataMaskingFunctionNames.has(identifier_1.Identifier.getName(name))) {
|
|
71
|
+
exports.Nse.unmark(graph, id, target => !exports.Nse.suppliedByMask(graph, target));
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
/** Drops the non-standard-evaluation mark from the outgoing edges of `id` that `which` accepts. */
|
|
75
|
+
unmark(graph, id, which = () => true) {
|
|
76
|
+
const edges = graph.outgoingEdges(id);
|
|
77
|
+
for (const [target, edge] of [...edges ?? []]) {
|
|
78
|
+
if (edge_1.DfEdge.includesType(edge, edge_1.EdgeType.NonStandardEvaluation) && which(target)) {
|
|
79
|
+
graph.removeEdgeType(id, target, edge_1.EdgeType.NonStandardEvaluation);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
/** Whether `id` is a name the data mask supplies, i.e. a use the caller does not bind itself. */
|
|
84
|
+
suppliedByMask(graph, id, vertex = graph.getVertex(id)) {
|
|
85
|
+
return vertex_1.UseVertex.is(vertex) && !graph.outgoingEdges(id)?.values().some(e => edge_1.DfEdge.includesType(e, edge_1.EdgeType.Reads));
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
//# sourceMappingURL=nse.js.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ControlFlowGraph } from '../../../../../control-flow/control-flow-graph';
|
|
2
|
+
import type { AstIdMap, ParentInformation } from '../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
3
|
+
import { NodeId } from '../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
4
|
+
import type { DataflowGraph } from '../../../../graph/graph';
|
|
5
|
+
import { linkExpressionIn } from '../../../linker';
|
|
6
|
+
/**
|
|
7
|
+
* A language object reads nothing where it is written and everything where it reaches `eval`, with the bindings
|
|
8
|
+
* in effect there. Working on the finished graph makes assignments, branches, loops, and calls one traversal.
|
|
9
|
+
*/
|
|
10
|
+
export declare const Quoted: {
|
|
11
|
+
readonly name: "Quoted";
|
|
12
|
+
/** The expression a capturing call holds on to. */
|
|
13
|
+
readonly capturedBy: (this: void, graph: DataflowGraph, id: NodeId) => NodeId | undefined;
|
|
14
|
+
/** Every expression the value at `id` may hold, with the call that captured it. Several is normal. */
|
|
15
|
+
readonly sourcesOf: (this: void, graph: DataflowGraph, id: NodeId) => readonly CapturedExpression[];
|
|
16
|
+
/** Links every name in `expr` against `environment` and hands back what stays unresolved. */
|
|
17
|
+
readonly evaluateIn: typeof linkExpressionIn;
|
|
18
|
+
/**
|
|
19
|
+
* The finishing pass over a complete graph: it settles what a call really evaluates, which the call itself
|
|
20
|
+
* could not know. A capture reaches the `eval` that forces it, a promise reaches the bindings it may be
|
|
21
|
+
* forced against, and a masked name the caller binds after all loses its mark.
|
|
22
|
+
*/
|
|
23
|
+
readonly finalize: <Info>(this: void, graph: DataflowGraph, idMap: AstIdMap<Info & ParentInformation>, controlFlow: () => ControlFlowGraph | undefined) => void;
|
|
24
|
+
};
|
|
25
|
+
interface CapturedExpression {
|
|
26
|
+
readonly expr: NodeId;
|
|
27
|
+
/** the capturing call, whose scope encloses `expr` */
|
|
28
|
+
readonly at: NodeId;
|
|
29
|
+
}
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Quoted = void 0;
|
|
4
|
+
const r_function_call_1 = require("../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
5
|
+
const type_1 = require("../../../../../r-bridge/lang-4.x/ast/model/type");
|
|
6
|
+
const node_id_1 = require("../../../../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
7
|
+
const identifier_1 = require("../../../../environments/identifier");
|
|
8
|
+
const built_in_proc_name_1 = require("../../../../environments/built-in-proc-name");
|
|
9
|
+
const edge_1 = require("../../../../graph/edge");
|
|
10
|
+
const graph_1 = require("../../../../graph/graph");
|
|
11
|
+
const vertex_1 = require("../../../../graph/vertex");
|
|
12
|
+
const linker_1 = require("../../../linker");
|
|
13
|
+
const nse_1 = require("./nse");
|
|
14
|
+
const deferred_1 = require("./deferred");
|
|
15
|
+
/** Calls capturing a language object. */
|
|
16
|
+
const CapturingProcessors = [built_in_proc_name_1.BuiltInProcName.Quote];
|
|
17
|
+
/** Calls capturing an expression as a promise, forced at some later read of the variable they bind. */
|
|
18
|
+
const DelayingCalls = new Set(['delayedAssign']);
|
|
19
|
+
/** Calls evaluating one. */
|
|
20
|
+
const EvaluatingProcessors = [built_in_proc_name_1.BuiltInProcName.Eval];
|
|
21
|
+
/** How a value reaches its use, `DefinedByOnCall` being the hop from a parameter to its argument. */
|
|
22
|
+
const ValueFlow = edge_1.EdgeType.Reads | edge_1.EdgeType.DefinedBy | edge_1.EdgeType.DefinedByOnCall | edge_1.EdgeType.Returns;
|
|
23
|
+
function hasOrigin(vertex, of) {
|
|
24
|
+
return vertex.origin !== 'unnamed' && vertex.origin.some(o => of.includes(o));
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* A language object reads nothing where it is written and everything where it reaches `eval`, with the bindings
|
|
28
|
+
* in effect there. Working on the finished graph makes assignments, branches, loops, and calls one traversal.
|
|
29
|
+
*/
|
|
30
|
+
exports.Quoted = {
|
|
31
|
+
name: 'Quoted',
|
|
32
|
+
/** The expression a capturing call holds on to. */
|
|
33
|
+
capturedBy(graph, id) {
|
|
34
|
+
const vertex = graph.getVertex(id);
|
|
35
|
+
return vertex_1.FunctionCallVertex.is(vertex) && hasOrigin(vertex, CapturingProcessors) ? capturedArgumentOf(graph, id) : undefined;
|
|
36
|
+
},
|
|
37
|
+
/** Every expression the value at `id` may hold, with the call that captured it. Several is normal. */
|
|
38
|
+
sourcesOf(graph, id) {
|
|
39
|
+
const found = [];
|
|
40
|
+
const seen = new Set([id]);
|
|
41
|
+
const pending = [id];
|
|
42
|
+
while (pending.length > 0) {
|
|
43
|
+
const current = pending.pop();
|
|
44
|
+
const captured = exports.Quoted.capturedBy(graph, current);
|
|
45
|
+
if (captured !== undefined) {
|
|
46
|
+
found.push({ expr: captured, at: current });
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
for (const [target, edge] of graph.outgoingEdges(current) ?? []) {
|
|
50
|
+
if (edge_1.DfEdge.includesType(edge, ValueFlow) && !seen.has(target)) {
|
|
51
|
+
seen.add(target);
|
|
52
|
+
pending.push(target);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return found;
|
|
57
|
+
},
|
|
58
|
+
/** Links every name in `expr` against `environment` and hands back what stays unresolved. */
|
|
59
|
+
evaluateIn: linker_1.linkExpressionIn,
|
|
60
|
+
/**
|
|
61
|
+
* The finishing pass over a complete graph: it settles what a call really evaluates, which the call itself
|
|
62
|
+
* could not know. A capture reaches the `eval` that forces it, a promise reaches the bindings it may be
|
|
63
|
+
* forced against, and a masked name the caller binds after all loses its mark.
|
|
64
|
+
*/
|
|
65
|
+
finalize(graph, idMap, controlFlow) {
|
|
66
|
+
let names = undefined;
|
|
67
|
+
let cfg = null;
|
|
68
|
+
const cfgOnce = () => (cfg === null ? (cfg = controlFlow()) : cfg);
|
|
69
|
+
for (const [id, vertex] of graph.verticesOfType(vertex_1.VertexType.FunctionCall)) {
|
|
70
|
+
nse_1.Nse.dropResolvedMask(graph, id, vertex.name);
|
|
71
|
+
if (DelayingCalls.has(identifier_1.Identifier.getName(vertex.name))) {
|
|
72
|
+
const promise = capturedArgumentOf(graph, id);
|
|
73
|
+
const binding = promise === undefined ? undefined : boundBy(graph, id);
|
|
74
|
+
if (promise !== undefined) {
|
|
75
|
+
names ??= deferred_1.Deferred.indexOf(graph, idMap);
|
|
76
|
+
const flow = binding === undefined ? undefined : cfgOnce();
|
|
77
|
+
const sites = flow === undefined || binding === undefined ? undefined : deferred_1.Deferred.forcedAt(graph, binding, flow);
|
|
78
|
+
deferred_1.Deferred.link(graph, promise, names, idMap, flow !== undefined && sites?.length && binding !== undefined ? { cfg: flow, sites, binding } : undefined);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else if (vertex.environment !== undefined && hasOrigin(vertex, EvaluatingProcessors) && !evaluatesElsewhere(idMap.get(id))) {
|
|
82
|
+
names ??= deferred_1.Deferred.indexOf(graph, idMap);
|
|
83
|
+
resolveEvaluation(graph, vertex, vertex.environment, idMap, names, cfgOnce());
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
for (const escaped of escapingArguments(graph, id)) {
|
|
87
|
+
names ??= deferred_1.Deferred.indexOf(graph, idMap);
|
|
88
|
+
deferred_1.Deferred.link(graph, escaped, names, idMap);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
/** The name a delaying call binds, which is the definition its reads have to go through. */
|
|
95
|
+
function boundBy(graph, id) {
|
|
96
|
+
for (const [target, edge] of graph.ingoingEdges(id) ?? []) {
|
|
97
|
+
if (edge_1.DfEdge.includesType(edge, edge_1.EdgeType.DefinedBy) && vertex_1.VariableDefinitionVertex.is(graph.getVertex(target))) {
|
|
98
|
+
return target;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
/** The argument a call takes but does not evaluate, which is the one it captured. */
|
|
104
|
+
function capturedArgumentOf(graph, id) {
|
|
105
|
+
for (const [target, edge] of graph.outgoingEdges(id) ?? []) {
|
|
106
|
+
if (edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Argument) && edge_1.DfEdge.includesType(edge, edge_1.EdgeType.NonStandardEvaluation)) {
|
|
107
|
+
return target;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return undefined;
|
|
111
|
+
}
|
|
112
|
+
/** Links a capture handed to an evaluating call, in that call's scope. */
|
|
113
|
+
function resolveEvaluation(graph, call, environment, idMap, names, cfg) {
|
|
114
|
+
const id = call.id;
|
|
115
|
+
const argument = call.args.find(a => !graph_1.FunctionArgument.isEmpty(a));
|
|
116
|
+
const reference = argument === undefined ? undefined : unwrapArgument(graph_1.FunctionArgument.getReference(argument), idMap);
|
|
117
|
+
const sources = reference === undefined ? [] : exports.Quoted.sourcesOf(graph, reference);
|
|
118
|
+
for (const { expr, at } of sources) {
|
|
119
|
+
const open = (0, linker_1.linkExpressionIn)(graph, expr, environment, idMap);
|
|
120
|
+
/* R falls through to the enclosing scope for names the evaluating frame does not bind */
|
|
121
|
+
const enclosing = open.length > 0 ? graph.getVertex(at)?.environment : undefined;
|
|
122
|
+
if (enclosing !== undefined) {
|
|
123
|
+
(0, linker_1.linkInputs)(open, enclosing, [], graph, false);
|
|
124
|
+
}
|
|
125
|
+
graph.addEdge(id, expr, edge_1.EdgeType.Returns);
|
|
126
|
+
deferred_1.Deferred.publish(graph, expr, names, idMap, id, cfg);
|
|
127
|
+
/* the capture said "not evaluated here", and being handed to `eval` settles that it is */
|
|
128
|
+
nse_1.Nse.unmark(graph, at);
|
|
129
|
+
}
|
|
130
|
+
if (sources.length > 0) {
|
|
131
|
+
forgetUnknownSideEffect(graph, id);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* The arguments of `id` whose promise outlives the call: the callee hands back a closure and never reads the
|
|
136
|
+
* parameter outside it, so R forces them wherever that closure is called, not here. A parameter read in the
|
|
137
|
+
* body itself (what `force` is for) is settled during the call and stays where it is.
|
|
138
|
+
*/
|
|
139
|
+
function* escapingArguments(graph, id) {
|
|
140
|
+
for (const [target, edge] of graph.outgoingEdges(id) ?? []) {
|
|
141
|
+
if (!edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Calls)) {
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
const callee = graph.getVertex(target);
|
|
145
|
+
if (callee?.tag !== vertex_1.VertexType.FunctionDefinition) {
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
for (const exit of callee.exitPoints) {
|
|
149
|
+
const closure = graph.getVertex(exit.nodeId);
|
|
150
|
+
if (closure?.tag !== vertex_1.VertexType.FunctionDefinition) {
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
for (const key of Object.keys(callee.params)) {
|
|
154
|
+
const parameter = node_id_1.NodeId.normalize(key);
|
|
155
|
+
let escapes = true;
|
|
156
|
+
for (const [reader, edge] of graph.ingoingEdges(parameter) ?? []) {
|
|
157
|
+
if (edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Reads) && !closure.subflow.graph.has(reader)) {
|
|
158
|
+
escapes = false;
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
if (!escapes) {
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
for (const [argument, edge] of graph.outgoingEdges(parameter) ?? []) {
|
|
166
|
+
if (edge_1.DfEdge.includesType(edge, edge_1.EdgeType.DefinedByOnCall)) {
|
|
167
|
+
yield argument;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
/** The value an argument reference points at. */
|
|
175
|
+
function unwrapArgument(reference, idMap) {
|
|
176
|
+
const node = reference === undefined ? undefined : idMap.get(reference);
|
|
177
|
+
return node?.type === type_1.RType.Argument ? node.value?.info.id : reference;
|
|
178
|
+
}
|
|
179
|
+
/** `eval(expr, envir)` runs elsewhere, so the bindings here say nothing. */
|
|
180
|
+
function evaluatesElsewhere(call) {
|
|
181
|
+
return r_function_call_1.RFunctionCall.isNamed(call) && call.arguments.length > 1;
|
|
182
|
+
}
|
|
183
|
+
/** Drops the marker the call carries while we cannot say what it evaluates. */
|
|
184
|
+
function forgetUnknownSideEffect(graph, id) {
|
|
185
|
+
for (const unknown of graph.unknownSideEffects) {
|
|
186
|
+
if (graph_1.UnknownSideEffect.id(unknown) === id) {
|
|
187
|
+
graph.unknownSideEffects.delete(unknown);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
//# sourceMappingURL=quoted.js.map
|
|
@@ -209,6 +209,16 @@ function followTypeReference(type, sourceFile) {
|
|
|
209
209
|
}
|
|
210
210
|
return [nodeLexeme, baseLexeme, ...args];
|
|
211
211
|
}
|
|
212
|
+
/** The base types a declaration extends or implements, with their generics dropped. */
|
|
213
|
+
function heritageTypeNames(node, sourceFile) {
|
|
214
|
+
return node.heritageClauses?.flatMap(clause => clause.types
|
|
215
|
+
.map(type => type.getText(sourceFile) ?? '')
|
|
216
|
+
.map(dropGenericsFromTypeName)) ?? [];
|
|
217
|
+
}
|
|
218
|
+
/** The names of the type parameters a declaration takes. */
|
|
219
|
+
function genericNames(node, sourceFile) {
|
|
220
|
+
return node.typeParameters?.map(param => param.getText(sourceFile) ?? '') ?? [];
|
|
221
|
+
}
|
|
212
222
|
function collectHierarchyInformation(sourceFiles, options) {
|
|
213
223
|
const hierarchyList = [];
|
|
214
224
|
const typeChecker = options.program.getTypeChecker();
|
|
@@ -218,10 +228,8 @@ function collectHierarchyInformation(sourceFiles, options) {
|
|
|
218
228
|
}
|
|
219
229
|
if (typescript_1.default.isInterfaceDeclaration(node)) {
|
|
220
230
|
const interfaceName = node.name?.getText(sourceFile) ?? '';
|
|
221
|
-
const baseTypes = node
|
|
222
|
-
|
|
223
|
-
.map(dropGenericsFromTypeName)) ?? [];
|
|
224
|
-
const generics = node.typeParameters?.map(param => param.getText(sourceFile) ?? '') ?? [];
|
|
231
|
+
const baseTypes = heritageTypeNames(node, sourceFile);
|
|
232
|
+
const generics = genericNames(node, sourceFile);
|
|
225
233
|
hierarchyList.push({
|
|
226
234
|
name: dropGenericsFromTypeName(interfaceName),
|
|
227
235
|
node,
|
|
@@ -246,7 +254,7 @@ function collectHierarchyInformation(sourceFiles, options) {
|
|
|
246
254
|
else if (typescript_1.default.isTypeReferenceNode(node.type)) {
|
|
247
255
|
baseTypes = followTypeReference(node.type, sourceFile).map(dropGenericsFromTypeName);
|
|
248
256
|
}
|
|
249
|
-
const generics = node
|
|
257
|
+
const generics = genericNames(node, sourceFile);
|
|
250
258
|
hierarchyList.push({
|
|
251
259
|
name: dropGenericsFromTypeName(typeName),
|
|
252
260
|
node,
|
|
@@ -288,10 +296,8 @@ function collectHierarchyInformation(sourceFiles, options) {
|
|
|
288
296
|
}
|
|
289
297
|
else if (typescript_1.default.isClassDeclaration(node)) {
|
|
290
298
|
const className = node.name?.getText(sourceFile) ?? '';
|
|
291
|
-
const baseTypes = node
|
|
292
|
-
|
|
293
|
-
.map(dropGenericsFromTypeName)) ?? [];
|
|
294
|
-
const generics = node.typeParameters?.map(param => param.getText(sourceFile) ?? '') ?? [];
|
|
299
|
+
const baseTypes = heritageTypeNames(node, sourceFile);
|
|
300
|
+
const generics = genericNames(node, sourceFile);
|
|
295
301
|
hierarchyList.push({
|
|
296
302
|
name: dropGenericsFromTypeName(className),
|
|
297
303
|
node,
|
|
@@ -5,6 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.WikiDataflowGraph = void 0;
|
|
7
7
|
const graph_1 = require("../dataflow/graph/graph");
|
|
8
|
+
const quoted_1 = require("../dataflow/internal/process/functions/call/quoted");
|
|
9
|
+
const nse_1 = require("../dataflow/internal/process/functions/call/nse");
|
|
10
|
+
const deferred_1 = require("../dataflow/internal/process/functions/call/deferred");
|
|
8
11
|
const doc_query_1 = require("./doc-util/doc-query");
|
|
9
12
|
const vertex_1 = require("../dataflow/graph/vertex");
|
|
10
13
|
const edge_1 = require("../dataflow/graph/edge");
|
|
@@ -714,6 +717,11 @@ some that may appear to be counter-intuitive. For example, a for-loop body, as i
|
|
|
714
717
|
|
|
715
718
|
${(0, doc_structure_1.details)('Example: For-Loop Body', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'for(i in v) b', { mark: new Set([2, '4->2']), ctx }))}
|
|
716
719
|
${(0, doc_structure_1.details)('Example: While-Loop Body', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'while(TRUE) b', { mark: new Set([1, '3->1']), ctx }))}
|
|
720
|
+
|
|
721
|
+
Three helpers decide what such a mark means once the graph is complete:
|
|
722
|
+
${ctx.link(quoted_1.Quoted.name, undefined, { type: 'variable' })} settles what a capture reaches when it is handed to \`eval\` (see ${ctx.linkO(quoted_1.Quoted, 'finalize')}),
|
|
723
|
+
${ctx.link(nse_1.Nse.name, undefined, { type: 'variable' })} models the escapes a quoting function offers (rlang's \`!!\` and \`bquote\`'s \`.(x)\`), and
|
|
724
|
+
${ctx.link(deferred_1.Deferred.name, undefined, { type: 'variable' })} links an expression R evaluates at a moment we cannot pin down, as \`delayedAssign\` binds one.
|
|
717
725
|
`
|
|
718
726
|
})}
|
|
719
727
|
`,
|
|
@@ -137,6 +137,7 @@ export type LintingResults<Name extends LintingRuleNames> = LintingResultsSucces
|
|
|
137
137
|
* Helper functions for working with {@link LintingResults}.
|
|
138
138
|
*/
|
|
139
139
|
export declare const LintingResults: {
|
|
140
|
+
readonly name: "LintingResults";
|
|
140
141
|
/**
|
|
141
142
|
* Checks whether the given linting results represent an error.
|
|
142
143
|
* @see {@link LintingResultsError}
|
package/linter/linter-format.js
CHANGED
|
@@ -6,6 +6,7 @@ const assert_1 = require("../util/assert");
|
|
|
6
6
|
* Helper functions for working with {@link LintingResults}.
|
|
7
7
|
*/
|
|
8
8
|
exports.LintingResults = {
|
|
9
|
+
name: 'LintingResults',
|
|
9
10
|
/**
|
|
10
11
|
* Checks whether the given linting results represent an error.
|
|
11
12
|
* @see {@link LintingResultsError}
|
|
@@ -29,6 +29,7 @@ exports.DEPRECATED_FUNCTIONS = {
|
|
|
29
29
|
// even when it is not part of the hardcoded `fns` list above
|
|
30
30
|
const graph = (await data.dataflow()).graph;
|
|
31
31
|
const alreadyFlagged = new Set(hardcoded.results.map(r => r.involvedId));
|
|
32
|
+
const deprecatedByName = new Map();
|
|
32
33
|
const sigdbFlagged = [];
|
|
33
34
|
for (const element of elements.getElements()) {
|
|
34
35
|
const id = element.node.info.id;
|
|
@@ -39,8 +40,13 @@ exports.DEPRECATED_FUNCTIONS = {
|
|
|
39
40
|
if (qualified === undefined) {
|
|
40
41
|
continue;
|
|
41
42
|
}
|
|
42
|
-
const
|
|
43
|
-
|
|
43
|
+
const name = identifier_1.Identifier.toString(qualified);
|
|
44
|
+
let deprecated = deprecatedByName.get(name);
|
|
45
|
+
if (deprecated === undefined) {
|
|
46
|
+
deprecated = deps.signatureOf(qualified)?.props.includes('deprecated') === true;
|
|
47
|
+
deprecatedByName.set(name, deprecated);
|
|
48
|
+
}
|
|
49
|
+
if (!deprecated) {
|
|
44
50
|
continue;
|
|
45
51
|
}
|
|
46
52
|
const loc = range_1.SourceLocation.fromNode(element.node);
|
|
@@ -51,7 +57,7 @@ exports.DEPRECATED_FUNCTIONS = {
|
|
|
51
57
|
sigdbFlagged.push({
|
|
52
58
|
certainty: linter_format_1.LintingResultCertainty.Certain,
|
|
53
59
|
involvedId: id,
|
|
54
|
-
function:
|
|
60
|
+
function: name,
|
|
55
61
|
loc
|
|
56
62
|
});
|
|
57
63
|
}
|
|
@@ -12,8 +12,7 @@ const graph_1 = require("../../dataflow/graph/graph");
|
|
|
12
12
|
const cascade_action_1 = require("../../queries/catalog/call-context-query/cascade-action");
|
|
13
13
|
const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
14
14
|
const linter_tags_1 = require("../linter-tags");
|
|
15
|
-
const
|
|
16
|
-
const general_1 = require("../../dataflow/eval/values/general");
|
|
15
|
+
const node_value_1 = require("../../dataflow/eval/resolve/node-value");
|
|
17
16
|
const config_1 = require("../../config");
|
|
18
17
|
const vertex_1 = require("../../dataflow/graph/vertex");
|
|
19
18
|
const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
@@ -162,7 +161,7 @@ function getDefaultAssignments() {
|
|
|
162
161
|
}
|
|
163
162
|
function isConstantArgument(graph, call, argIndex, ctx) {
|
|
164
163
|
const args = call.args.filter(arg => arg !== r_function_call_1.EmptyArgument && !arg.name).map(graph_1.FunctionArgument.getReference);
|
|
165
|
-
const values =
|
|
164
|
+
const values = node_value_1.NodeValue.inGraph.setOf(args[argIndex], graph, ctx, { resolve: config_1.VariableResolve.Alias });
|
|
166
165
|
return values?.elements.every(v => v.type === 'number' ||
|
|
167
166
|
v.type === 'logical' ||
|
|
168
167
|
v.type === 'string' ||
|
|
@@ -75,6 +75,15 @@ exports.UNDEFINED_SYMBOL = {
|
|
|
75
75
|
...deps.getDependencies().map(p => deps.getDependency(p.name) ?? p),
|
|
76
76
|
...r_base_packages_1.AttachedBasePackages.map(n => deps.getDependency(n)).filter(assert_1.isNotUndefined)
|
|
77
77
|
];
|
|
78
|
+
const exportedByLoaded = new Map();
|
|
79
|
+
const isExportedByLoadedPackage = (name) => {
|
|
80
|
+
let known = exportedByLoaded.get(name);
|
|
81
|
+
if (known === undefined) {
|
|
82
|
+
known = loadedPackages.some(p => p.has(name));
|
|
83
|
+
exportedByLoaded.set(name, known);
|
|
84
|
+
}
|
|
85
|
+
return known;
|
|
86
|
+
};
|
|
78
87
|
// hint an unloaded package that exports `name` (e.g. `ggplot` -> `ggplot2`), from the package database
|
|
79
88
|
const attached = new Set(r_base_packages_1.AttachedBasePackages);
|
|
80
89
|
const hintPackagesFor = (name) => deps.packagesExporting(name).filter(p => !attached.has(p)).slice(0, MaxHintPackages);
|
|
@@ -132,7 +141,7 @@ exports.UNDEFINED_SYMBOL = {
|
|
|
132
141
|
return suppress('loadedPackage');
|
|
133
142
|
}
|
|
134
143
|
// exported by a package in scope (`pkg::fn`, a loaded package, or a default-attached base package)
|
|
135
|
-
if (namespace !== undefined ? deps.getDependency(namespace)?.has(name) === true :
|
|
144
|
+
if (namespace !== undefined ? deps.getDependency(namespace)?.has(name) === true : isExportedByLoadedPackage(name)) {
|
|
136
145
|
return suppress('loadedPackage');
|
|
137
146
|
}
|
|
138
147
|
// forward-referenced closure binding flowR's dataflow did not link (unconditional bindings only)
|
package/package.json
CHANGED
|
@@ -5,6 +5,12 @@ import type { FlowrAnalyzerContext } from '../../context/flowr-analyzer-context'
|
|
|
5
5
|
import { FlowrDescriptionFile } from './files/flowr-description-file';
|
|
6
6
|
import { type FlowrFileProvider } from '../../context/flowr-file';
|
|
7
7
|
export declare const descriptionFileLog: import("tslog").Logger<import("tslog").ILogObj>;
|
|
8
|
+
/** Access to the `DESCRIPTION` file of the analyzed project. */
|
|
9
|
+
export declare const DescriptionFile: {
|
|
10
|
+
readonly name: "DescriptionFile";
|
|
11
|
+
/** The project's only `DESCRIPTION` file, `undefined` if there is none; `missing` states what cannot be done then. */
|
|
12
|
+
readonly single: (this: void, ctx: FlowrAnalyzerContext, missing: string) => FlowrDescriptionFile | undefined;
|
|
13
|
+
};
|
|
8
14
|
/**
|
|
9
15
|
* This plugin provides support for R `DESCRIPTION` files.
|
|
10
16
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FlowrAnalyzerDescriptionFilePlugin = exports.descriptionFileLog = void 0;
|
|
3
|
+
exports.FlowrAnalyzerDescriptionFilePlugin = exports.DescriptionFile = exports.descriptionFileLog = void 0;
|
|
4
4
|
const flowr_analyzer_file_plugin_1 = require("./flowr-analyzer-file-plugin");
|
|
5
5
|
const semver_1 = require("semver");
|
|
6
6
|
const log_1 = require("../../../util/log");
|
|
@@ -9,6 +9,22 @@ const flowr_file_1 = require("../../context/flowr-file");
|
|
|
9
9
|
const built_in_source_1 = require("../../../dataflow/internal/process/functions/call/built-in/built-in-source");
|
|
10
10
|
exports.descriptionFileLog = log_1.log.getSubLogger({ name: 'flowr-analyzer-loading-order-description-file-plugin' });
|
|
11
11
|
const DescriptionFilePattern = /^DESCRIPTION(\.(txt|in))?$/i;
|
|
12
|
+
/** Access to the `DESCRIPTION` file of the analyzed project. */
|
|
13
|
+
exports.DescriptionFile = {
|
|
14
|
+
name: 'DescriptionFile',
|
|
15
|
+
/** The project's only `DESCRIPTION` file, `undefined` if there is none; `missing` states what cannot be done then. */
|
|
16
|
+
single(ctx, missing) {
|
|
17
|
+
const descFiles = ctx.files.getFilesByRole(flowr_file_1.FileRole.Description);
|
|
18
|
+
if (descFiles.length === 0) {
|
|
19
|
+
exports.descriptionFileLog.debug(missing);
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
else if (descFiles.length > 1) {
|
|
23
|
+
exports.descriptionFileLog.warn(`Found ${descFiles.length} description files, expected exactly one.`);
|
|
24
|
+
}
|
|
25
|
+
return descFiles[0];
|
|
26
|
+
}
|
|
27
|
+
};
|
|
12
28
|
/**
|
|
13
29
|
* This plugin provides support for R `DESCRIPTION` files.
|
|
14
30
|
*/
|
|
@@ -1,22 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { SemVer } from 'semver';
|
|
3
|
-
import type { FlowrAnalyzerContext } from '../../../context/flowr-analyzer-context';
|
|
4
|
-
import type { FlowrFileProvider } from '../../../context/flowr-file';
|
|
5
|
-
import { FlowrAnalyzerFilePlugin } from '../flowr-analyzer-file-plugin';
|
|
6
|
-
import { FlowrRMarkdownFile } from '../files/flowr-rmarkdown-file';
|
|
1
|
+
import { FlowrAnalyzerRMarkdownFilePlugin } from './flowr-analyzer-rmarkdown-file-plugin';
|
|
7
2
|
/**
|
|
8
3
|
* The plugin provides support for Quarto R Markdown (`.qmd`) files
|
|
9
4
|
*/
|
|
10
|
-
export declare class FlowrAnalyzerQmdFilePlugin extends
|
|
5
|
+
export declare class FlowrAnalyzerQmdFilePlugin extends FlowrAnalyzerRMarkdownFilePlugin {
|
|
11
6
|
readonly name = "qmd-file-plugin";
|
|
12
7
|
readonly description = "Parses Quarto R Markdown files";
|
|
13
|
-
readonly version: SemVer;
|
|
14
|
-
private readonly pattern;
|
|
15
8
|
/**
|
|
16
9
|
* Creates a new instance of the Quarto R Markdown file plugin.
|
|
17
10
|
* @param filePattern - The pattern to identify Quarto R Markdown files, see {@link QmdPattern} for the default pattern.
|
|
18
11
|
*/
|
|
19
12
|
constructor(filePattern?: RegExp);
|
|
20
|
-
applies(file: PathLike): boolean;
|
|
21
|
-
protected process(ctx: FlowrAnalyzerContext, arg: FlowrFileProvider<string>): FlowrRMarkdownFile;
|
|
22
13
|
}
|