@eagleoutice/flowr 2.11.0 → 2.12.0
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 +190 -260
- package/abstract-interpretation/data-frame/mappers/arguments.js +7 -1
- package/abstract-interpretation/domains/set-range-domain.js +1 -1
- package/abstract-interpretation/domains/set-upper-bound-domain.js +6 -2
- package/benchmark/slicer.d.ts +1 -1
- package/benchmark/slicer.js +3 -1
- package/benchmark/summarizer/second-phase/graph.js +5 -0
- package/cli/common/options.d.ts +8 -0
- package/cli/common/options.js +2 -0
- package/cli/common/scripts-info.d.ts +8 -0
- package/cli/flowr.js +1 -1
- package/cli/repl/commands/repl-commands.d.ts +1 -0
- package/cli/repl/commands/repl-commands.js +69 -17
- package/cli/repl/commands/repl-dataflow.js +48 -4
- package/cli/repl/commands/repl-main.d.ts +2 -0
- package/cli/repl/commands/repl-main.js +5 -0
- package/cli/repl/commands/repl-query.d.ts +4 -1
- package/cli/repl/commands/repl-query.js +72 -22
- package/cli/repl/commands/repl-signature.d.ts +7 -0
- package/cli/repl/commands/repl-signature.js +119 -0
- package/cli/repl/core.d.ts +8 -1
- package/cli/repl/core.js +46 -6
- package/cli/repl/ghost-hint.d.ts +37 -0
- package/cli/repl/ghost-hint.js +72 -0
- package/cli/repl/parser/slice-query-parser.d.ts +11 -1
- package/cli/repl/parser/slice-query-parser.js +45 -16
- package/cli/repl/print-version.d.ts +2 -4
- package/cli/repl/print-version.js +41 -23
- package/cli/repl/server/connection.js +19 -17
- package/cli/slicer-app.d.ts +2 -0
- package/cli/slicer-app.js +3 -3
- package/cli/wiki.d.ts +2 -2
- package/cli/wiki.js +2 -2
- package/config.d.ts +70 -13
- package/config.js +65 -7
- package/control-flow/cfg-dead-code.js +0 -1
- package/control-flow/control-flow-graph.js +6 -6
- package/control-flow/diff-cfg.js +2 -2
- package/control-flow/semantic-cfg-guided-visitor.js +2 -0
- package/core/print/slice-diff-ansi.js +8 -8
- package/core/steps/all/core/20-dataflow.d.ts +2 -2
- package/core/steps/all/static-slicing/00-slice.d.ts +5 -0
- package/core/steps/all/static-slicing/00-slice.js +1 -1
- package/core/steps/all/static-slicing/10-reconstruct.d.ts +7 -0
- package/core/steps/all/static-slicing/10-reconstruct.js +6 -2
- package/core/steps/pipeline/default-pipelines.d.ts +20 -16
- package/data/r-base-packages.generated.d.ts +44 -0
- package/data/r-base-packages.generated.js +32 -0
- package/data/r-base-primitives.generated.d.ts +1 -0
- package/data/r-base-primitives.generated.js +15 -0
- package/data/sigdb/sigdb.remote.json +112 -0
- package/dataflow/environments/built-in-proc-name.d.ts +4 -0
- package/dataflow/environments/built-in-proc-name.js +4 -0
- package/dataflow/environments/built-in.d.ts +14 -4
- package/dataflow/environments/built-in.js +13 -2
- package/dataflow/environments/data-masking-functions.d.ts +12 -0
- package/dataflow/environments/data-masking-functions.js +46 -0
- package/dataflow/environments/default-builtin-config.d.ts +72 -19
- package/dataflow/environments/default-builtin-config.js +48 -14
- package/dataflow/environments/diff.js +1 -1
- package/dataflow/environments/environment.js +1 -2
- package/dataflow/environments/identifier.d.ts +11 -4
- package/dataflow/environments/identifier.js +28 -10
- package/dataflow/environments/resolve-by-name.js +16 -2
- package/dataflow/extractor.js +6 -3
- package/dataflow/graph/call-graph.d.ts +2 -2
- package/dataflow/graph/df-helper.d.ts +4 -4
- package/dataflow/graph/diff-dataflow-graph.js +2 -2
- package/dataflow/graph/edge.d.ts +3 -3
- package/dataflow/graph/edge.js +3 -3
- package/dataflow/graph/graph-helper.d.ts +2 -2
- package/dataflow/internal/linker.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +7 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +20 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +1 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +2 -49
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +6 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +7 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +19 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +111 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +13 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +2 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +9 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +19 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +12 -4
- package/dataflow/internal/process/functions/call/common.js +8 -1
- package/dataflow/internal/process/functions/call/default-call-handling.js +6 -0
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +17 -0
- package/dataflow/internal/process/functions/call/known-call-handling.js +32 -0
- package/dataflow/internal/process/functions/call/named-call-handling.js +29 -7
- package/dataflow/internal/process/functions/process-argument.js +12 -1
- package/dataflow/internal/process/process-named-call.d.ts +18 -1
- package/dataflow/internal/process/process-named-call.js +94 -0
- package/dataflow/processor.d.ts +18 -0
- package/documentation/data/faq/faqs.js +5 -1
- package/documentation/doc-capabilities.js +1 -1
- package/documentation/doc-util/doc-cli-option.d.ts +10 -0
- package/documentation/doc-util/doc-cli-option.js +23 -0
- package/documentation/doc-util/doc-dfg.js +2 -1
- package/documentation/doc-util/doc-query.d.ts +9 -3
- package/documentation/doc-util/doc-query.js +9 -4
- package/documentation/wiki-dataflow-graph.js +8 -5
- package/documentation/wiki-interface.js +3 -2
- package/documentation/wiki-linter.js +1 -1
- package/documentation/wiki-linting-and-testing.js +4 -1
- package/documentation/wiki-mk/doc-context.d.ts +14 -0
- package/documentation/wiki-mk/doc-context.js +3 -0
- package/documentation/wiki-mk/doc-maker.js +3 -1
- package/documentation/wiki-query.js +19 -1
- package/documentation/wiki-setup.js +10 -7
- package/documentation/wiki-signature-database.d.ts +16 -0
- package/documentation/wiki-signature-database.js +293 -0
- package/linter/linter-format.d.ts +7 -0
- package/linter/linter-rules.d.ts +10 -9
- package/linter/rules/naming-convention.d.ts +1 -0
- package/linter/rules/naming-convention.js +2 -0
- package/linter/rules/no-leaked-credentials.js +1 -2
- package/linter/rules/roxygen-arguments.js +18 -5
- package/linter/rules/stop-with-call-arg.js +2 -2
- package/linter/rules/undefined-symbol-util.d.ts +36 -0
- package/linter/rules/undefined-symbol-util.js +149 -0
- package/linter/rules/undefined-symbol.d.ts +58 -17
- package/linter/rules/undefined-symbol.js +143 -33
- package/linter/rules/unused-definition.d.ts +8 -1
- package/linter/rules/unused-definition.js +126 -1
- package/package.json +23 -10
- package/project/context/abstract-flowr-analyzer-context.js +7 -1
- package/project/context/flowr-analyzer-context.d.ts +8 -0
- package/project/context/flowr-analyzer-context.js +10 -0
- package/project/context/flowr-analyzer-dependencies-context.d.ts +28 -4
- package/project/context/flowr-analyzer-dependencies-context.js +53 -1
- package/project/context/flowr-analyzer-files-context.d.ts +1 -0
- package/project/context/flowr-analyzer-files-context.js +2 -1
- package/project/context/flowr-analyzer-functions-context.js +1 -1
- package/project/context/flowr-file.d.ts +5 -0
- package/project/context/flowr-file.js +5 -0
- package/project/flowr-analyzer-builder.js +12 -2
- package/project/plugins/file-plugins/files/flowr-description-file.js +6 -3
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +9 -3
- package/project/plugins/file-plugins/files/flowr-news-file.js +1 -3
- package/project/plugins/file-plugins/flowr-analyzer-inst-file-plugin.d.ts +26 -0
- package/project/plugins/file-plugins/flowr-analyzer-inst-file-plugin.js +39 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.js +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +2 -2
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-namespace-file-plugin.js +1 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.d.ts +18 -2
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.js +19 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +120 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +518 -0
- package/project/plugins/package-version-plugins/package.d.ts +5 -3
- package/project/plugins/package-version-plugins/package.js +27 -25
- package/project/plugins/plugin-registry.d.ts +3 -2
- package/project/plugins/plugin-registry.js +4 -2
- package/project/plugins/project-discovery/flowr-analyzer-gitignore-project-discovery-plugin.js +7 -2
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +3 -1
- package/project/sigdb/build.d.ts +131 -0
- package/project/sigdb/build.js +628 -0
- package/project/sigdb/codec.d.ts +51 -0
- package/project/sigdb/codec.js +122 -0
- package/project/sigdb/decode.d.ts +58 -0
- package/project/sigdb/decode.js +129 -0
- package/project/sigdb/decompress.d.ts +44 -0
- package/project/sigdb/decompress.js +176 -0
- package/project/sigdb/hash.d.ts +9 -0
- package/project/sigdb/hash.js +54 -0
- package/project/sigdb/index-format.d.ts +40 -0
- package/project/sigdb/index-format.js +28 -0
- package/project/sigdb/manifest.d.ts +68 -0
- package/project/sigdb/manifest.js +146 -0
- package/project/sigdb/reader.d.ts +250 -0
- package/project/sigdb/reader.js +692 -0
- package/project/sigdb/schema.d.ts +196 -0
- package/project/sigdb/schema.js +33 -0
- package/project/sigdb/sigdb-download.d.ts +65 -0
- package/project/sigdb/sigdb-download.js +237 -0
- package/project/sigdb/signature-match.d.ts +26 -0
- package/project/sigdb/signature-match.js +40 -0
- package/project/sigdb/version.d.ts +20 -0
- package/project/sigdb/version.js +55 -0
- package/queries/catalog/call-context-query/call-context-query-executor.js +1 -3
- package/queries/catalog/config-query/config-query-format.d.ts +3 -1
- package/queries/catalog/config-query/config-query-format.js +68 -9
- package/queries/catalog/dataflow-query/dataflow-query-format.js +11 -1
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +1 -1
- package/queries/catalog/linter-query/linter-query-executor.d.ts +2 -0
- package/queries/catalog/linter-query/linter-query-executor.js +6 -1
- package/queries/catalog/linter-query/linter-query-format.d.ts +2 -1
- package/queries/catalog/linter-query/linter-query-format.js +40 -8
- package/queries/catalog/project-query/project-query-executor.d.ts +15 -0
- package/queries/catalog/project-query/project-query-executor.js +96 -4
- package/queries/catalog/project-query/project-query-format.d.ts +44 -0
- package/queries/catalog/project-query/project-query-format.js +33 -2
- package/queries/catalog/signature-query/signature-query-executor.d.ts +29 -0
- package/queries/catalog/signature-query/signature-query-executor.js +461 -0
- package/queries/catalog/signature-query/signature-query-format.d.ts +138 -0
- package/queries/catalog/signature-query/signature-query-format.js +76 -0
- package/queries/catalog/signature-query/signature-query-render.d.ts +15 -0
- package/queries/catalog/signature-query/signature-query-render.js +155 -0
- package/queries/catalog/static-slice-query/static-slice-query-executor.js +9 -3
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +10 -0
- package/queries/catalog/static-slice-query/static-slice-query-format.js +19 -1
- package/queries/query-print.js +5 -0
- package/queries/query.d.ts +10 -1
- package/queries/query.js +5 -2
- package/r-bridge/init.js +5 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +10 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +55 -0
- package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +16 -0
- package/r-bridge/lang-4.x/ast/model/processing/node-id.js +27 -0
- package/r-bridge/lang-4.x/ast/parser/json/format.js +89 -2
- package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-expressions.js +2 -4
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +2 -1
- package/r-bridge/parser.d.ts +2 -0
- package/r-bridge/retriever.js +4 -1
- package/r-bridge/roxygen2/documentation-provider.js +2 -1
- package/r-bridge/shell.d.ts +5 -0
- package/r-bridge/shell.js +17 -1
- package/reconstruct/inline/source-inline-map.d.ts +48 -0
- package/reconstruct/inline/source-inline-map.js +94 -0
- package/reconstruct/reconstruct.d.ts +19 -2
- package/reconstruct/reconstruct.js +79 -16
- package/search/search-executor/search-generators.js +5 -22
- package/search/search-executor/search-transformer.js +10 -6
- package/slicing/criterion/parse.d.ts +22 -4
- package/slicing/criterion/parse.js +125 -18
- package/slicing/static/slice-call.d.ts +24 -1
- package/slicing/static/slice-call.js +90 -0
- package/slicing/static/static-slicer.d.ts +7 -0
- package/slicing/static/static-slicer.js +38 -3
- package/util/collections/arrays.d.ts +4 -5
- package/util/collections/arrays.js +7 -18
- package/util/hash.d.ts +14 -0
- package/util/hash.js +31 -0
- package/util/mermaid/dfg.d.ts +7 -2
- package/util/mermaid/dfg.js +53 -13
- package/util/r-base-packages.d.ts +19 -0
- package/util/r-base-packages.js +72 -0
- package/util/r-license.js +2 -10
- package/util/r-version.d.ts +45 -15
- package/util/r-version.js +97 -36
- package/util/range.d.ts +15 -0
- package/util/range.js +39 -0
- package/util/schema.d.ts +10 -0
- package/util/schema.js +22 -0
- package/util/text/ansi.d.ts +13 -1
- package/util/text/ansi.js +27 -4
- package/util/text/args.js +1 -2
- package/util/version.js +28 -8
- package/data/pkgdb/pkgdb-latest.json.br +0 -0
- package/data/pkgdb/pkgdb-tiny.json.br +0 -0
- package/documentation/wiki-package-database.d.ts +0 -9
- package/documentation/wiki-package-database.js +0 -63
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin.d.ts +0 -63
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin.js +0 -174
- package/project/plugins/package-version-plugins/pkgdb.d.ts +0 -133
- package/project/plugins/package-version-plugins/pkgdb.js +0 -370
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NseArguments = void 0;
|
|
4
|
+
exports.markArgumentsAsNonStandardEvaluation = markArgumentsAsNonStandardEvaluation;
|
|
3
5
|
exports.markNonStandardEvaluationEdges = markNonStandardEvaluationEdges;
|
|
4
6
|
exports.processKnownFunctionCall = processKnownFunctionCall;
|
|
5
7
|
const processor_1 = require("../../../../processor");
|
|
@@ -11,6 +13,36 @@ const logger_1 = require("../../../../logger");
|
|
|
11
13
|
const vertex_1 = require("../../../../graph/vertex");
|
|
12
14
|
const unknown_side_effect_1 = require("../../../../graph/unknown-side-effect");
|
|
13
15
|
const built_in_proc_name_1 = require("../../../../environments/built-in-proc-name");
|
|
16
|
+
/**
|
|
17
|
+
* Which arguments of a call {@link markArgumentsAsNonStandardEvaluation|are non-standardly evaluated}:
|
|
18
|
+
* every argument, all but the (data) first one, or only the first one.
|
|
19
|
+
*/
|
|
20
|
+
var NseArguments;
|
|
21
|
+
(function (NseArguments) {
|
|
22
|
+
/** every argument, e.g. the operands of a formula `~` or `aes(x, y)` */
|
|
23
|
+
NseArguments["All"] = "all";
|
|
24
|
+
/** all but the first, e.g. `subset(data, col > 1)` where the first argument is the data object */
|
|
25
|
+
NseArguments["AllButFirst"] = "all-but-first";
|
|
26
|
+
/** only the first, e.g. the native routine name in `.C(routine, ...)` */
|
|
27
|
+
NseArguments["First"] = "first";
|
|
28
|
+
})(NseArguments || (exports.NseArguments = NseArguments = {}));
|
|
29
|
+
/**
|
|
30
|
+
* Marks the selected arguments - and everything within them - as {@link EdgeType.NonStandardEvaluation}
|
|
31
|
+
* (as `quote` does), so their nested symbols are recognised as non-standardly evaluated too.
|
|
32
|
+
*/
|
|
33
|
+
function markArgumentsAsNonStandardEvaluation(graph, rootId, processedArguments, which) {
|
|
34
|
+
const end = which === NseArguments.First ? 1 : processedArguments.length;
|
|
35
|
+
for (let i = which === NseArguments.AllButFirst ? 1 : 0; i < end; i++) {
|
|
36
|
+
const arg = processedArguments[i];
|
|
37
|
+
if (arg === undefined) {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
graph.addEdge(rootId, arg.entryPoint, edge_1.EdgeType.NonStandardEvaluation);
|
|
41
|
+
for (const [vtx] of arg.graph.vertices(true)) {
|
|
42
|
+
graph.addEdge(rootId, vtx, edge_1.EdgeType.NonStandardEvaluation);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
14
46
|
/**
|
|
15
47
|
* Marks the given arguments as being involved in R's non-standard evaluation.
|
|
16
48
|
*/
|
|
@@ -9,6 +9,7 @@ const node_id_1 = require("../../../../../r-bridge/lang-4.x/ast/model/processing
|
|
|
9
9
|
const resolve_by_name_1 = require("../../../../environments/resolve-by-name");
|
|
10
10
|
const vertex_1 = require("../../../../graph/vertex");
|
|
11
11
|
const identifier_1 = require("../../../../environments/identifier");
|
|
12
|
+
const r_base_packages_1 = require("../../../../../util/r-base-packages");
|
|
12
13
|
const edge_1 = require("../../../../graph/edge");
|
|
13
14
|
const built_in_library_1 = require("./built-in/built-in-library");
|
|
14
15
|
function mergeInformation(info, newInfo) {
|
|
@@ -26,12 +27,6 @@ function mergeInformation(info, newInfo) {
|
|
|
26
27
|
hooks: info.hooks.concat(newInfo.hooks)
|
|
27
28
|
};
|
|
28
29
|
}
|
|
29
|
-
function processDefaultFunctionProcessor(information, name, args, rootId, data) {
|
|
30
|
-
const resolve = (0, resolve_by_name_1.resolveByName)(name.content, data.environment, identifier_1.ReferenceType.Function);
|
|
31
|
-
/* if we do not know where we land, we force! */
|
|
32
|
-
const call = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, forceArgs: (resolve?.length ?? 0) > 0 ? undefined : 'all', origin: 'default' });
|
|
33
|
-
return mergeInformation(information, call.information);
|
|
34
|
-
}
|
|
35
30
|
/**
|
|
36
31
|
* Marks the given function call node as only calling built-in functions.
|
|
37
32
|
*/
|
|
@@ -67,7 +62,9 @@ function processNamedCall(name, args, rootId, data) {
|
|
|
67
62
|
}
|
|
68
63
|
}
|
|
69
64
|
if (defaultProcessor) {
|
|
70
|
-
|
|
65
|
+
/* if we do not know where we land, we force! reuse `resolved`, data.environment did not change above */
|
|
66
|
+
const call = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, forceArgs: resolved.length > 0 ? undefined : 'all', origin: 'default' });
|
|
67
|
+
information = mergeInformation(information, call.information);
|
|
71
68
|
}
|
|
72
69
|
else if (information && builtIn) {
|
|
73
70
|
// mark the function call as built in only
|
|
@@ -77,15 +74,40 @@ function processNamedCall(name, args, rootId, data) {
|
|
|
77
74
|
// already know the loading call here, link to it (a function-local export is invisible to the later
|
|
78
75
|
// top-level linkMaterializedExportsToLoaders pass, so we must catch it at the call site)
|
|
79
76
|
if (information) {
|
|
77
|
+
const sigdb = data.ctx.config.solver.sigdb;
|
|
80
78
|
for (const r of resolved) {
|
|
81
79
|
if (r.type === identifier_1.ReferenceType.Function && r.nodeId !== undefined && node_id_1.NodeId.isBuiltIn(r.nodeId)) {
|
|
82
80
|
(0, built_in_library_1.attachExportVertex)(information.graph, r.nodeId, data.environment, data.ctx, data.cds);
|
|
83
81
|
const definedAt = r.definedAt;
|
|
84
82
|
if (definedAt !== undefined && !node_id_1.NodeId.isBuiltIn(definedAt)) {
|
|
85
83
|
information.graph.addEdge(r.nodeId, definedAt, edge_1.EdgeType.Reads | edge_1.EdgeType.Calls);
|
|
84
|
+
// the call itself reads the library() load that made this export resolvable
|
|
85
|
+
information.graph.addEdge(rootId, definedAt, edge_1.EdgeType.Reads);
|
|
86
|
+
}
|
|
87
|
+
// opt-in: a lightweight ref edge from the call to its sigdb-backed package function vertex
|
|
88
|
+
if (sigdb.linkPackageCalls && node_id_1.NodeId.toPkgFn(r.nodeId) !== undefined) {
|
|
89
|
+
information.graph.addEdge(rootId, r.nodeId, edge_1.EdgeType.Reads);
|
|
86
90
|
}
|
|
87
91
|
}
|
|
88
92
|
}
|
|
93
|
+
const ns = identifier_1.Identifier.getNamespace(name.content);
|
|
94
|
+
// an explicit `pkg::fn` links to a database-unresolved `library(pkg)` recorded below the global env
|
|
95
|
+
if (ns !== undefined) {
|
|
96
|
+
for (const loadNode of (0, built_in_library_1.loadNodesForNamespace)(data.environment, ns)) {
|
|
97
|
+
information.graph.addEdge(rootId, loadNode, edge_1.EdgeType.Reads);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
// opt-in: link a bare base-R call to its sigdb function vertex (base-R qualification is edge-free otherwise);
|
|
101
|
+
// same guards as Identifier.toQualified -- not namespaced, not resolving to a user definition
|
|
102
|
+
if (sigdb.linkBaseRCalls && ns === undefined && !resolved.some(r => r.nodeId !== undefined && !node_id_1.NodeId.isBuiltIn(r.nodeId))) {
|
|
103
|
+
const bare = identifier_1.Identifier.getName(name.content);
|
|
104
|
+
const owner = (0, r_base_packages_1.baseRExportOwner)(bare);
|
|
105
|
+
if (owner !== undefined) {
|
|
106
|
+
const builtInId = node_id_1.NodeId.fromPkgFn(owner, bare);
|
|
107
|
+
(0, built_in_library_1.attachExportVertex)(information.graph, builtInId, data.environment, data.ctx, data.cds);
|
|
108
|
+
information.graph.addEdge(rootId, builtInId, edge_1.EdgeType.Reads);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
89
111
|
}
|
|
90
112
|
return information ?? info_1.DataflowInformation.initialize(rootId, data);
|
|
91
113
|
}
|
|
@@ -25,7 +25,18 @@ function linkReadsForArgument(root, ingoingRefs, graph) {
|
|
|
25
25
|
*/
|
|
26
26
|
function processFunctionArgument(argument, data) {
|
|
27
27
|
const name = argument.name === undefined ? undefined : (0, processor_1.processDataflowFor)(argument.name, data);
|
|
28
|
-
|
|
28
|
+
let value;
|
|
29
|
+
if (argument.value === undefined) {
|
|
30
|
+
value = undefined;
|
|
31
|
+
}
|
|
32
|
+
else if (data.precomputedValue?.nodeId === argument.value.info.id) {
|
|
33
|
+
// the caller already processed this value iteratively (e.g., processChainedCall)
|
|
34
|
+
value = data.precomputedValue.info;
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
// call the value's processor directly instead of going through processDataflowFor, safes one stack frame
|
|
38
|
+
value = data.processors[argument.value.type](argument.value, data);
|
|
39
|
+
}
|
|
29
40
|
// we do not keep the graph of the name, as this is no node that should ever exist
|
|
30
41
|
const graph = value?.graph ?? new graph_1.DataflowGraph(data.completeAst.idMap);
|
|
31
42
|
const argumentName = argument.name?.content;
|
|
@@ -2,9 +2,26 @@ import type { DataflowProcessorInformation } from '../../processor';
|
|
|
2
2
|
import type { DataflowInformation } from '../../info';
|
|
3
3
|
import type { RAstNodeBase, RNode, Location } from '../../../r-bridge/lang-4.x/ast/model/model';
|
|
4
4
|
import type { ParentInformation } from '../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
5
|
-
import
|
|
5
|
+
import { EmptyArgument, type RNamedFunctionCall } from '../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
6
6
|
import type { Identifier } from '../../environments/identifier';
|
|
7
|
+
import type { RBinaryOp } from '../../../r-bridge/lang-4.x/ast/model/nodes/r-binary-op';
|
|
8
|
+
import type { RPipe } from '../../../r-bridge/lang-4.x/ast/model/nodes/r-pipe';
|
|
7
9
|
/**
|
|
8
10
|
* Helper function for {@link processNamedCall} using the given `functionName` as the name of the function.
|
|
9
11
|
*/
|
|
10
12
|
export declare function processAsNamedCall<OtherInfo>({ info, lexeme, location }: RNode<OtherInfo & ParentInformation> & RAstNodeBase<OtherInfo> & Location, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, name: Identifier, args: readonly (RNode<OtherInfo & ParentInformation> | typeof EmptyArgument | undefined)[]): DataflowInformation;
|
|
13
|
+
type RBinaryOpOrPipe<OtherInfo> = (RBinaryOp<OtherInfo & ParentInformation> | RPipe<OtherInfo & ParentInformation>) & RAstNodeBase<OtherInfo> & Location;
|
|
14
|
+
/** A named, infix-special call, e.g. magrittr's `lhs %>% rhs`: normalized as a {@link RType#FunctionCall}, not as {@link RType#BinaryOp}. */
|
|
15
|
+
type RInfixSpecialCall<OtherInfo> = RNamedFunctionCall<OtherInfo & ParentInformation>;
|
|
16
|
+
/** Any node shape that forms a left-associative operator chain through its first/left operand. */
|
|
17
|
+
type ChainNode<OtherInfo> = RBinaryOpOrPipe<OtherInfo> | RInfixSpecialCall<OtherInfo>;
|
|
18
|
+
/**
|
|
19
|
+
* Processes a {@link ChainNode}: {@link RType#BinaryOp}, {@link RType#Pipe}, and magrittr-style `%op%` calls
|
|
20
|
+
* (infix-special {@link RType#FunctionCall}s) all nest on their left operand, so a long `a + b + c + ...` or
|
|
21
|
+
* `a %>% f() %>% f() %>% ...` chain buries it arbitrarily deep.
|
|
22
|
+
* This walks the left spine of chain nodes with an explicit loop (bounded stack usage regardless of
|
|
23
|
+
* chain length), processes the innermost (leftmost) node normally, and then folds outward: each level's left
|
|
24
|
+
* operand is wrapped via {@link processFunctionArgument}.
|
|
25
|
+
*/
|
|
26
|
+
export declare function processChainedCall<OtherInfo>(node: ChainNode<OtherInfo>, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): DataflowInformation;
|
|
27
|
+
export {};
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.processAsNamedCall = processAsNamedCall;
|
|
4
|
+
exports.processChainedCall = processChainedCall;
|
|
4
5
|
const named_call_handling_1 = require("./functions/call/named-call-handling");
|
|
5
6
|
const make_argument_1 = require("./functions/call/argument/make-argument");
|
|
7
|
+
const process_argument_1 = require("./functions/process-argument");
|
|
6
8
|
const type_1 = require("../../../r-bridge/lang-4.x/ast/model/type");
|
|
9
|
+
const r_function_call_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
10
|
+
const r_argument_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
|
|
11
|
+
const assert_1 = require("../../../util/assert");
|
|
7
12
|
/**
|
|
8
13
|
* Helper function for {@link processNamedCall} using the given `functionName` as the name of the function.
|
|
9
14
|
*/
|
|
@@ -16,4 +21,93 @@ function processAsNamedCall({ info, lexeme, location }, data, name, args) {
|
|
|
16
21
|
location,
|
|
17
22
|
}, (0, make_argument_1.wrapArgumentsUnnamed)(args, data.completeAst.idMap), info.id, data);
|
|
18
23
|
}
|
|
24
|
+
function isBinaryOpOrPipe(node) {
|
|
25
|
+
return node.type === type_1.RType.BinaryOp || node.type === type_1.RType.Pipe;
|
|
26
|
+
}
|
|
27
|
+
function isInfixSpecialCall(node) {
|
|
28
|
+
return node.type === type_1.RType.FunctionCall && node.named === true && node.infixSpecial === true && node.arguments.length === 2;
|
|
29
|
+
}
|
|
30
|
+
function isChainNode(node) {
|
|
31
|
+
return node !== undefined && (isBinaryOpOrPipe(node) || isInfixSpecialCall(node));
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The raw (unwrapped) left operand of a chain node, used to detect whether the chain continues.
|
|
35
|
+
* <p>
|
|
36
|
+
* Unlike {@link RType#BinaryOp}, whose `lhs` is the raw operand, both parser backends always pre-wrap a
|
|
37
|
+
* {@link RType#Pipe}'s `lhs` (and an infix-special {@link RType#FunctionCall}'s first argument) as an
|
|
38
|
+
* {@link RArgument}, so those need unwrapping via `.value` first.
|
|
39
|
+
*/
|
|
40
|
+
function chainLhsRaw(node) {
|
|
41
|
+
if (node.type === type_1.RType.FunctionCall) {
|
|
42
|
+
const arg = node.arguments[0];
|
|
43
|
+
return arg === r_function_call_1.EmptyArgument ? undefined : arg.value;
|
|
44
|
+
}
|
|
45
|
+
return r_argument_1.RArgument.is(node.lhs) ? node.lhs.value : node.lhs;
|
|
46
|
+
}
|
|
47
|
+
/** The left operand of a chain node, wrapped as the {@link RArgument} that {@link processAllArguments} would process it as. */
|
|
48
|
+
function chainLhsArgument(node, idMap) {
|
|
49
|
+
if (node.type === type_1.RType.FunctionCall) {
|
|
50
|
+
const arg = node.arguments[0];
|
|
51
|
+
(0, assert_1.guard)(arg !== r_function_call_1.EmptyArgument, 'an infix-special call always has a non-empty first argument');
|
|
52
|
+
return arg;
|
|
53
|
+
}
|
|
54
|
+
if (r_argument_1.RArgument.is(node.lhs)) {
|
|
55
|
+
return node.lhs;
|
|
56
|
+
}
|
|
57
|
+
const wrapped = (0, make_argument_1.toUnnamedArgument)(node.lhs, idMap);
|
|
58
|
+
(0, assert_1.guard)(wrapped !== r_function_call_1.EmptyArgument, 'the lhs of a binary operator is never empty');
|
|
59
|
+
return wrapped;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Processes a single chain node (see {@link ChainNode}), recursing normally into its children. A caller folding
|
|
63
|
+
* a whole chain (see {@link processChainedCall}) may pass an already-processed left operand via
|
|
64
|
+
* `data.precomputedFirstArg` (keyed by `node.info.id`) to avoid recursing into it again.
|
|
65
|
+
*/
|
|
66
|
+
function processSingleChainNode(node, data) {
|
|
67
|
+
if (node.type === type_1.RType.FunctionCall) {
|
|
68
|
+
return (0, named_call_handling_1.processNamedCall)(node.functionName, node.arguments, node.info.id, data);
|
|
69
|
+
}
|
|
70
|
+
const { info, lexeme, location, lhs, rhs } = node;
|
|
71
|
+
return (0, named_call_handling_1.processNamedCall)({
|
|
72
|
+
type: type_1.RType.Symbol,
|
|
73
|
+
info,
|
|
74
|
+
content: node.type === type_1.RType.Pipe ? lexeme : node.operator,
|
|
75
|
+
lexeme,
|
|
76
|
+
location,
|
|
77
|
+
}, (0, make_argument_1.wrapArgumentsUnnamed)([lhs, rhs], data.completeAst.idMap), info.id, data);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Processes a {@link ChainNode}: {@link RType#BinaryOp}, {@link RType#Pipe}, and magrittr-style `%op%` calls
|
|
81
|
+
* (infix-special {@link RType#FunctionCall}s) all nest on their left operand, so a long `a + b + c + ...` or
|
|
82
|
+
* `a %>% f() %>% f() %>% ...` chain buries it arbitrarily deep.
|
|
83
|
+
* This walks the left spine of chain nodes with an explicit loop (bounded stack usage regardless of
|
|
84
|
+
* chain length), processes the innermost (leftmost) node normally, and then folds outward: each level's left
|
|
85
|
+
* operand is wrapped via {@link processFunctionArgument}.
|
|
86
|
+
*/
|
|
87
|
+
function processChainedCall(node, data) {
|
|
88
|
+
if (!isChainNode(chainLhsRaw(node))) {
|
|
89
|
+
return processSingleChainNode(node, data);
|
|
90
|
+
}
|
|
91
|
+
const spine = [node];
|
|
92
|
+
let cur = chainLhsRaw(node);
|
|
93
|
+
while (true) {
|
|
94
|
+
spine.push(cur);
|
|
95
|
+
const next = chainLhsRaw(cur);
|
|
96
|
+
if (!isChainNode(next)) {
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
cur = next;
|
|
100
|
+
}
|
|
101
|
+
// process the innermost (leftmost) node normally, then fold outward through the rest of the spine
|
|
102
|
+
let result = processSingleChainNode(spine[spine.length - 1], data);
|
|
103
|
+
for (let i = spine.length - 2; i >= 0; i--) {
|
|
104
|
+
const level = spine[i];
|
|
105
|
+
const lhsRaw = chainLhsRaw(level);
|
|
106
|
+
(0, assert_1.guard)(lhsRaw !== undefined, 'a chain node always has a left operand');
|
|
107
|
+
const wrappedLhs = chainLhsArgument(level, data.completeAst.idMap);
|
|
108
|
+
const lhsInfo = (0, process_argument_1.processFunctionArgument)(wrappedLhs, { ...data, precomputedValue: { nodeId: lhsRaw.info.id, info: result } });
|
|
109
|
+
result = processSingleChainNode(level, { ...data, precomputedFirstArg: { rootId: level.info.id, info: lhsInfo } });
|
|
110
|
+
}
|
|
111
|
+
return result;
|
|
112
|
+
}
|
|
19
113
|
//# sourceMappingURL=process-named-call.js.map
|
package/dataflow/processor.d.ts
CHANGED
|
@@ -41,6 +41,24 @@ export interface DataflowProcessorInformation<OtherInfo> {
|
|
|
41
41
|
* so its vertex needs no environment snapshot (it would be discarded by markAsOnlyBuiltIn anyway).
|
|
42
42
|
*/
|
|
43
43
|
readonly builtInNoEnv?: NodeId;
|
|
44
|
+
/**
|
|
45
|
+
* Escape hatch for hot recursive paths.
|
|
46
|
+
* When set and its `rootId` matches the function call currently being processed by {@link processAllArguments},
|
|
47
|
+
* its `info` is used as the already-processed first argument instead of processing that argument again.
|
|
48
|
+
*/
|
|
49
|
+
readonly precomputedFirstArg?: {
|
|
50
|
+
readonly rootId: NodeId;
|
|
51
|
+
readonly info: DataflowInformation;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Companion to {@link precomputedFirstArg}: when set and its `nodeId` matches the node
|
|
55
|
+
* {@link processFunctionArgument} is about to process as an argument's value, its `info` is used instead of
|
|
56
|
+
* processing (and recursing into) that node again. This allows to separate arg wrappers from their content!
|
|
57
|
+
*/
|
|
58
|
+
readonly precomputedValue?: {
|
|
59
|
+
readonly nodeId: NodeId;
|
|
60
|
+
readonly info: DataflowInformation;
|
|
61
|
+
};
|
|
44
62
|
}
|
|
45
63
|
export type DataflowProcessor<OtherInfo, NodeType extends RNodeWithParent<OtherInfo>> = (node: NodeType, data: DataflowProcessorInformation<OtherInfo>) => DataflowInformation;
|
|
46
64
|
type NodeWithKey<OtherInfo, Key> = RNode<OtherInfo & ParentInformation> & {
|
|
@@ -15,6 +15,10 @@ function registerFaqs(ctx) {
|
|
|
15
15
|
Tests are labeled based on the *flowR* capabilities that they test for.
|
|
16
16
|
The list of supported capabilities can be found on the ${ctx.linkPage('wiki/Capabilities', 'Capabilities')} wiki page.
|
|
17
17
|
For more extensive information on test labels, see the ${ctx.linkPage('wiki/Linting and Testing', 'test labels wiki section', 'test-labels')}.
|
|
18
|
+
`)
|
|
19
|
+
.addFaq('How do I run *all checks* before pushing?', `
|
|
20
|
+
Run \`npm run checkup\`: it runs the linter, the functionality and system tests, the wiki generation, and the docker image build + smoke test concurrently, then prints one pass/fail summary.
|
|
21
|
+
Run a subset with the job ids (e.g. \`npm run checkup -- lint tests\`) or skip the container build with \`npm run checkup -- --no-docker\`.
|
|
18
22
|
`)
|
|
19
23
|
.addFaq('How to get a REPL with debug-info/*hot-reload*?', `
|
|
20
24
|
To enter the development repl, execute \`npm run main-dev\` in contrast to \`npm run flowr\`
|
|
@@ -95,7 +99,7 @@ or [rdocumentation.org](https://rdocumentation.org/). Additionally, the package
|
|
|
95
99
|
be downloaded directly from [cran](https://cran.r-project.org/).
|
|
96
100
|
`)
|
|
97
101
|
.addFaq('How does flowR know a *package\'s exports*?', `
|
|
98
|
-
See the ${ctx.linkPage('wiki/
|
|
102
|
+
See the ${ctx.linkPage('wiki/Signature Database', 'Signature Database')} wiki page.
|
|
99
103
|
`);
|
|
100
104
|
wikiFaq.withTopic('editor.configs')
|
|
101
105
|
.addFaq('How can I make eslint and ZED work together?', `Use this project config (\`.zed/settings.json\`) to disable all formatters except eslint:
|
|
@@ -58,7 +58,7 @@ function getTestDetails(info, capability) {
|
|
|
58
58
|
grouped.delete('output');
|
|
59
59
|
const testString = [`${uniqueTests.length} test${uniqueTests.length !== 1 ? 's' : ''}`];
|
|
60
60
|
// sort by count
|
|
61
|
-
const sorted = [...grouped.entries()].sort((a, b) => b[
|
|
61
|
+
const sorted = [...grouped.entries()].sort((a, b) => b[0].localeCompare(a[0]));
|
|
62
62
|
for (const [context, count] of sorted) {
|
|
63
63
|
testString.push(`${context}: ${count}`);
|
|
64
64
|
}
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
import { scripts } from '../../cli/common/scripts-info';
|
|
3
3
|
import { flowrMainOptionDefinitions } from '../../cli/flowr-main-options';
|
|
4
4
|
import type { ReplCommandNames } from '../../cli/repl/commands/repl-commands';
|
|
5
|
+
import { FlowrConfig } from '../../config';
|
|
6
|
+
import type { AutocompletablePaths } from '../../util/objects';
|
|
5
7
|
export type ScriptOptions<Type extends keyof typeof scripts | 'flowr'> = Type extends keyof typeof scripts ? typeof scripts[Type]['options'][number]['name'] : Type extends 'flowr' ? typeof flowrMainOptionDefinitions[number]['name'] : never;
|
|
6
8
|
/**
|
|
7
9
|
* Produce the documentation string for a CLI long option
|
|
@@ -11,6 +13,14 @@ export declare function getCliLongOptionOf<ScriptName extends keyof typeof scrip
|
|
|
11
13
|
* Produce the documentation string for multiple CLI long options
|
|
12
14
|
*/
|
|
13
15
|
export declare function multipleCliOptions<ScriptName extends keyof typeof scripts | 'flowr', OptionName extends ScriptOptions<ScriptName>>(scriptName: ScriptName, ...options: OptionName[]): string;
|
|
16
|
+
/**
|
|
17
|
+
* Produce a documentation link for a flowR configuration option (e.g. `solver.sigdb.enabled`).
|
|
18
|
+
* The link points at the configuration section of the Interface wiki page and carries the option's
|
|
19
|
+
* schema type, description, and any enumerated values as a hover tooltip.
|
|
20
|
+
* @param path - The (autocompleted) `.`-separated configuration path.
|
|
21
|
+
* @param quote - Whether to render the path as inline code. Default is `true`.
|
|
22
|
+
*/
|
|
23
|
+
export declare function getConfigOption(path: AutocompletablePaths<FlowrConfig>, quote?: boolean): string;
|
|
14
24
|
/**
|
|
15
25
|
* Produce the documentation string for a REPL command
|
|
16
26
|
*/
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getCliLongOptionOf = getCliLongOptionOf;
|
|
4
4
|
exports.multipleCliOptions = multipleCliOptions;
|
|
5
|
+
exports.getConfigOption = getConfigOption;
|
|
5
6
|
exports.getReplCommand = getReplCommand;
|
|
6
7
|
/** Automatically provides hover over with the documentation for these! */
|
|
7
8
|
const scripts_info_1 = require("../../cli/common/scripts-info");
|
|
@@ -10,6 +11,9 @@ const html_hover_over_1 = require("../../util/html-hover-over");
|
|
|
10
11
|
const flowr_main_options_1 = require("../../cli/flowr-main-options");
|
|
11
12
|
const repl_commands_1 = require("../../cli/repl/commands/repl-commands");
|
|
12
13
|
const doc_escape_1 = require("./doc-escape");
|
|
14
|
+
const config_1 = require("../../config");
|
|
15
|
+
const schema_1 = require("../../util/schema");
|
|
16
|
+
const doc_files_1 = require("./doc-files");
|
|
13
17
|
/**
|
|
14
18
|
* Produce the documentation string for a CLI long option
|
|
15
19
|
*/
|
|
@@ -31,6 +35,25 @@ function getCliLongOptionOf(scriptName, optionName, withAlias = false, quote = t
|
|
|
31
35
|
function multipleCliOptions(scriptName, ...options) {
|
|
32
36
|
return options.map(o => getCliLongOptionOf(scriptName, o, false, true)).join(' ');
|
|
33
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Produce a documentation link for a flowR configuration option (e.g. `solver.sigdb.enabled`).
|
|
40
|
+
* The link points at the configuration section of the Interface wiki page and carries the option's
|
|
41
|
+
* schema type, description, and any enumerated values as a hover tooltip.
|
|
42
|
+
* @param path - The (autocompleted) `.`-separated configuration path.
|
|
43
|
+
* @param quote - Whether to render the path as inline code. Default is `true`.
|
|
44
|
+
*/
|
|
45
|
+
function getConfigOption(path, quote = true) {
|
|
46
|
+
const info = (0, schema_1.schemaPathInfo)(config_1.FlowrConfig.Schema, path.split('.'));
|
|
47
|
+
let tooltip = `Configuration Option (${info.type ?? 'option'})`;
|
|
48
|
+
if (info.description) {
|
|
49
|
+
tooltip += `: ${info.description}`;
|
|
50
|
+
}
|
|
51
|
+
if (info.valids && info.valids.length > 0) {
|
|
52
|
+
tooltip += ` (one of ${info.valids.map(v => JSON.stringify(v)).join(', ')})`;
|
|
53
|
+
}
|
|
54
|
+
const label = quote ? `<code>${(0, doc_escape_1.escapeHTML)(path)}</code>` : (0, doc_escape_1.escapeHTML)(path);
|
|
55
|
+
return `<a href="${doc_files_1.FlowrWikiBaseRef}/Interface#configuring-flowr" title=${JSON.stringify((0, doc_escape_1.escapeHTML)(tooltip))}>${label}</a>`;
|
|
56
|
+
}
|
|
34
57
|
/**
|
|
35
58
|
* Produce the documentation string for a REPL command
|
|
36
59
|
*/
|
|
@@ -52,7 +52,8 @@ async function printDfGraphForCode(parser, code, { callGraph = false, simplified
|
|
|
52
52
|
if (switchCodeAndGraph) {
|
|
53
53
|
(0, assert_1.guard)(showCode, 'can not switch code and graph if code is not shown');
|
|
54
54
|
}
|
|
55
|
-
const
|
|
55
|
+
const sigDbNote = `No ${ctx ? ctx.linkPage('wiki/Signature Database', 'signature database') : `[signature database](${doc_files_1.FlowrWikiBaseRef}/Signature-Database)`} is mounted for these generated graphs, so \`library()\` calls attach no package exports; base-R names are still qualified via the generated base-package store (e.g. \`acf\` as \`stats::acf\`).`;
|
|
56
|
+
const metaInfo = `The analysis required _${(0, time_1.printAsMs)(duration)}_ (including parse and normalize, using the ${ctx ? ctx.linkPage('wiki/Engines', parser.name) : `[${parser.name}](${doc_files_1.FlowrWikiBaseRef}/Engines)`} engine) within the generation environment. ${sigDbNote}`;
|
|
56
57
|
const graph = callGraph ? call_graph_1.CallGraph.compute(result.dataflow.graph) : result.dataflow.graph;
|
|
57
58
|
const dfGraph = printDfGraph(graph, mark, simplified);
|
|
58
59
|
const simplyText = simplified ? '(simplified) ' : '';
|
|
@@ -11,11 +11,16 @@ export interface ShowQueryOptions {
|
|
|
11
11
|
readonly collapseQuery?: boolean;
|
|
12
12
|
readonly shorthand?: string;
|
|
13
13
|
readonly ctx?: GeneralDocContext;
|
|
14
|
+
/** additional in-memory files registered before the request, e.g. the targets of `source(...)` calls */
|
|
15
|
+
readonly files?: readonly {
|
|
16
|
+
readonly name: string;
|
|
17
|
+
readonly content: string;
|
|
18
|
+
}[];
|
|
14
19
|
}
|
|
15
20
|
/**
|
|
16
21
|
* Visualizes a query and its results in markdown format.
|
|
17
22
|
*/
|
|
18
|
-
export declare function showQuery<Base extends SupportedQueryTypes, VirtualArguments extends VirtualCompoundConstraint<Base> = VirtualCompoundConstraint<Base>>(parser: KnownParser, code: string, queries: Queries<Base, VirtualArguments>, { showCode, collapseResult, collapseQuery, shorthand, ctx }?: ShowQueryOptions): Promise<string>;
|
|
23
|
+
export declare function showQuery<Base extends SupportedQueryTypes, VirtualArguments extends VirtualCompoundConstraint<Base> = VirtualCompoundConstraint<Base>>(parser: KnownParser, code: string, queries: Queries<Base, VirtualArguments>, { showCode, collapseResult, collapseQuery, shorthand, ctx, files }?: ShowQueryOptions): Promise<string>;
|
|
19
24
|
export interface QueryDocumentation {
|
|
20
25
|
readonly name: string;
|
|
21
26
|
readonly type: 'virtual' | 'active';
|
|
@@ -34,9 +39,10 @@ export declare const RegisteredQueries: {
|
|
|
34
39
|
*/
|
|
35
40
|
export declare function registerQueryDocumentation(query: SupportedQueryTypes | SupportedVirtualQueryTypes, doc: QueryDocumentation): void;
|
|
36
41
|
/**
|
|
37
|
-
* Creates a REPL shorthand for the given slicing criteria and R code
|
|
42
|
+
* Creates a REPL shorthand for the given slicing criteria and R code (`f` requests a forward slice,
|
|
43
|
+
* `i` inlines resolvable `source()` calls into the reconstruction; the flags may be combined as `fi`).
|
|
38
44
|
*/
|
|
39
|
-
export declare function sliceQueryShorthand(criteria: SlicingCriteria, code: string, forward?: boolean): string;
|
|
45
|
+
export declare function sliceQueryShorthand(criteria: SlicingCriteria, code: string, forward?: boolean, inline?: boolean): string;
|
|
40
46
|
/**
|
|
41
47
|
*
|
|
42
48
|
*/
|
|
@@ -15,13 +15,17 @@ const doc_code_1 = require("./doc-code");
|
|
|
15
15
|
const time_1 = require("../../util/text/time");
|
|
16
16
|
const query_print_1 = require("../../queries/query-print");
|
|
17
17
|
const flowr_analyzer_builder_1 = require("../../project/flowr-analyzer-builder");
|
|
18
|
+
const flowr_file_1 = require("../../project/context/flowr-file");
|
|
18
19
|
const doc_cli_option_1 = require("./doc-cli-option");
|
|
19
20
|
/**
|
|
20
21
|
* Visualizes a query and its results in markdown format.
|
|
21
22
|
*/
|
|
22
|
-
async function showQuery(parser, code, queries, { showCode, collapseResult, collapseQuery, shorthand, ctx } = {}) {
|
|
23
|
+
async function showQuery(parser, code, queries, { showCode, collapseResult, collapseQuery, shorthand, ctx, files } = {}) {
|
|
23
24
|
const now = performance.now();
|
|
24
25
|
const analyzer = await new flowr_analyzer_builder_1.FlowrAnalyzerBuilder().setParser(parser).build();
|
|
26
|
+
for (const file of files ?? []) {
|
|
27
|
+
analyzer.addFile(new flowr_file_1.FlowrInlineTextFile(file.name, file.content));
|
|
28
|
+
}
|
|
25
29
|
analyzer.addRequest(code);
|
|
26
30
|
const results = await analyzer.query(queries);
|
|
27
31
|
const duration = performance.now() - now;
|
|
@@ -86,10 +90,11 @@ function registerQueryDocumentation(query, doc) {
|
|
|
86
90
|
map.set(query, doc);
|
|
87
91
|
}
|
|
88
92
|
/**
|
|
89
|
-
* Creates a REPL shorthand for the given slicing criteria and R code
|
|
93
|
+
* Creates a REPL shorthand for the given slicing criteria and R code (`f` requests a forward slice,
|
|
94
|
+
* `i` inlines resolvable `source()` calls into the reconstruction; the flags may be combined as `fi`).
|
|
90
95
|
*/
|
|
91
|
-
function sliceQueryShorthand(criteria, code, forward) {
|
|
92
|
-
return `(${(criteria.join(';'))})${forward ? 'f' : ''} "${code}"`;
|
|
96
|
+
function sliceQueryShorthand(criteria, code, forward, inline) {
|
|
97
|
+
return `(${(criteria.join(';'))})${forward ? 'f' : ''}${inline ? 'i' : ''} "${code}"`;
|
|
93
98
|
}
|
|
94
99
|
function linkify(name) {
|
|
95
100
|
return name.toLowerCase().replace(/ /g, '-');
|
|
@@ -185,9 +185,11 @@ ${(0, doc_structure_1.block)({
|
|
|
185
185
|
type: vertex_1.VertexType.FunctionCall,
|
|
186
186
|
description: `
|
|
187
187
|
Describes any kind of function call, including unnamed calls and those that happen implicitly!
|
|
188
|
-
In general the vertex provides you with information about
|
|
188
|
+
In general the vertex provides you with information about
|
|
189
189
|
the _name_ of the called function, the passed _arguments_, and the _environment_ in which the call happens (if it is of importance).
|
|
190
190
|
|
|
191
|
+
Whenever flowR can determine which package a call resolves to — via a loaded \`library()\`/\`::\`, or via the always-available base-R packages taken from the ${ctx.linkPage('wiki/Signature Database', 'signature database')} — the mermaid visualization prints the **package-qualified name** in place of the bare one (e.g. \`acf\` is shown as \`stats::acf\`). To obtain this qualified identifier programmatically from a call's origins, use \`Identifier.toQualified\` (see the \`origin\` property below and the ${ctx.linkPage('wiki/Signature Database', 'signature database')} for where the base-R knowledge comes from).
|
|
192
|
+
|
|
191
193
|
However, the implementation reveals that it may hold an additional \`onlyBuiltin\` flag to indicate that the call is only calling builtin functions — however, this is only a flag to improve performance,
|
|
192
194
|
and it should not be relied on as it may under-approximate the actual calling targets (e.g., being \`false\` even though all calls resolve to builtins).
|
|
193
195
|
|
|
@@ -481,7 +483,7 @@ ${(0, doc_structure_1.details)('Example: Parameters of a Function', await (async
|
|
|
481
483
|
const code = 'f <- function(x, y = 3) x + y';
|
|
482
484
|
const [text, info] = await (0, doc_dfg_1.printDfGraphForCode)(parser, code, { mark: new Set([10, 1, 3]), exposeResult: true, ctx });
|
|
483
485
|
const ast = await (0, doc_normalized_ast_1.printNormalizedAstForCode)(parser, code, { prefix: 'flowchart LR\n', showCode: false, ctx });
|
|
484
|
-
const functionDefinition =
|
|
486
|
+
const functionDefinition = info.dataflow.graph.vertices(true).find(([, vertex]) => vertex.tag === vertex_1.VertexType.FunctionDefinition);
|
|
485
487
|
(0, assert_1.guard)(functionDefinition !== undefined, () => `Could not find function definition for ${code}`);
|
|
486
488
|
const [id] = functionDefinition;
|
|
487
489
|
const normalized = info.normalize.idMap.get(id);
|
|
@@ -861,11 +863,12 @@ ${(0, doc_structure_1.section)('Lexeme', 3, 'vtx-lexeme')}
|
|
|
861
863
|
|
|
862
864
|
Also in the first line, next to the [syntactic type](#vtx-synt-type), you can find the lexeme of the vertex (if it has one, e.g., for a variable definition or use).
|
|
863
865
|
This usually represents the textual source string of the respective vertex, and is also linked to the ${ctx.linkPage('wiki/Normalized AST')}.
|
|
866
|
+
For a clearer hierarchy, the lexeme is rendered in **bold** while the [syntactic type](#vtx-synt-type) is de-emphasized in _italics_ (mermaid markdown labels do not support a per-token font color, so a true gray tone would require styling the whole node). Only the token the source actually wrote is bold: when a call is shown with a package-qualified name that flowR *added* (e.g. the code wrote \`acf\` but it is displayed as \`stats::acf\`), the added \`stats::\` prefix stays non-bold, whereas a namespace written verbatim in the source is part of the lexeme and is bold as a whole.
|
|
864
867
|
You can access the lexeme too with ${ctx.linkO(model_1.RNode, 'lexeme')}.
|
|
865
868
|
|
|
866
869
|
${(0, doc_structure_1.section)('Vertex Id', 3, 'vtx-id')}
|
|
867
870
|
|
|
868
|
-
In the second line, you will usually find the id (in the form of a ${ctx.link(node_id_1.NodeId, undefined, { type: 'variable' })}) of the vertex,
|
|
871
|
+
In the second line, you will usually find the id (in the form of a ${ctx.link(node_id_1.NodeId, undefined, { type: 'variable' })}) of the vertex — kept compact by sharing the line with the [location](#vtx-location), in the form \`*location* (**id: <id>**)\` with the id in **bold** —
|
|
869
872
|
alongside its [control dependencies](#control-dependencies) if it has any. This id links the vertex to the respective node in the ${ctx.linkPage('wiki/Normalized AST')} (and all other perspectives created by flowR).
|
|
870
873
|
To give you an example, have a look at the following graph:
|
|
871
874
|
|
|
@@ -875,7 +878,7 @@ on the \`if\`, which only triggers when the condition is \`true\` (as indicated
|
|
|
875
878
|
|
|
876
879
|
${(0, doc_structure_1.section)('Location', 3, 'vtx-location')}
|
|
877
880
|
|
|
878
|
-
The
|
|
881
|
+
The second line also indicates the compressed ${ctx.link(range_1.SourceRange)} of the vertex (directly before the [id](#vtx-id)) in the format \`startLine.startCharacter - endLine.endCharacter\`. If the range reads \`1.7\`,
|
|
879
882
|
this is short for \`1.7-1.7\`, likewise, \`1.7-9\` is short for \`1.7-1.9\`. So, \`1.7-9\` describes something starting
|
|
880
883
|
in the first line at the seventh character and ending in the first line at the ninth character.
|
|
881
884
|
|
|
@@ -883,7 +886,7 @@ ${(0, doc_structure_1.section)('Arguments and Additional Information', 3, 'vtx-a
|
|
|
883
886
|
|
|
884
887
|
Some vertices (e.g., [function calls](#function-call-vertex)) have additional information, like the arguments of the call.
|
|
885
888
|
As you can see with the \`if\` example above alongside the [vertex id](#vtx-id),
|
|
886
|
-
these vertices also have an additional line which lists the ids of the arguments in order to clear any ambiguity in case, for example,
|
|
889
|
+
these vertices also have an additional line (prefixed with \`arg:\`) which lists the ids of the arguments in order to clear any ambiguity in case, for example,
|
|
887
890
|
the mermaid graph layouting fumbles the order.
|
|
888
891
|
|
|
889
892
|
${(0, doc_structure_1.section)('Vertices', 2, 'vertices')}
|
|
@@ -161,6 +161,7 @@ ${await (0, doc_repl_1.documentReplSession)(parser, [{
|
|
|
161
161
|
}], { openOutput: true })}
|
|
162
162
|
|
|
163
163
|
For the slicing with ${ctx.replCmd('slicer')}, you have access to the same [magic comments](#slice-magic-comments) as with the [slice request](#message-request-slice).
|
|
164
|
+
Pass \`--inline\` to splice resolvable \`source()\` calls into the reconstruction so the slice is a single self-contained R text (the same as the static slice query's \`inlineSources\` flag).
|
|
164
165
|
|
|
165
166
|
### Example: Interfacing with the File System
|
|
166
167
|
|
|
@@ -253,6 +254,7 @@ ${(0, doc_code_1.codeBlock)('json', JSON.stringify({
|
|
|
253
254
|
repl: {
|
|
254
255
|
quickStats: false,
|
|
255
256
|
dfProcessorHeat: false,
|
|
257
|
+
hints: true,
|
|
256
258
|
plugins: ['flowr:default']
|
|
257
259
|
},
|
|
258
260
|
project: {
|
|
@@ -263,8 +265,7 @@ ${(0, doc_code_1.codeBlock)('json', JSON.stringify({
|
|
|
263
265
|
variables: config_1.VariableResolve.Alias,
|
|
264
266
|
evalStrings: true,
|
|
265
267
|
trackEnvironments: true,
|
|
266
|
-
|
|
267
|
-
eagerlyLoadPackageDatabase: false,
|
|
268
|
+
sigdb: { enabled: true, loadProjectDependencies: true, eagerlyLoad: false, eagerlyLoadExports: false, linkBaseR: false, linkDescriptionDependencies: false },
|
|
268
269
|
resolveSource: {
|
|
269
270
|
dropPaths: config_1.DropPathsOption.No,
|
|
270
271
|
ignoreCapitalization: true,
|
|
@@ -210,7 +210,7 @@ async function getTextMainPage(knownParser, tagTypes, ctx) {
|
|
|
210
210
|
const rules = registerRules(knownParser, tagTypes.info);
|
|
211
211
|
return `
|
|
212
212
|
This page describes the flowR linter, which is a tool that utilizes flowR's dataflow analysis to find common issues in R scripts. The linter can currently be used through the linter ${ctx.linkPage('wiki/Query API', 'query')}.
|
|
213
|
-
Some rules also draw on the ${ctx.linkPage('wiki/
|
|
213
|
+
Some rules also draw on the ${ctx.linkPage('wiki/Signature Database', 'signature database')}.
|
|
214
214
|
For example:
|
|
215
215
|
|
|
216
216
|
${await (async () => {
|
|
@@ -43,8 +43,11 @@ for the latest benchmark results, see the [benchmark results](${doc_files_1.Flow
|
|
|
43
43
|
|
|
44
44
|
Currently, flowR contains three testing suites: one for [functionality](#functionality-tests),
|
|
45
45
|
one for [system tests](#system-tests), and one for [performance](#performance-tests). We explain each of them in the following.
|
|
46
|
-
In addition to running those tests, you can use the more generalized \`npm run checkup\`.
|
|
46
|
+
In addition to running those tests, you can use the more generalized \`npm run checkup\`.
|
|
47
47
|
This command includes the construction of the docker image, the generation of the wiki pages, and the linter.
|
|
48
|
+
It runs these jobs concurrently but caps the test workers so the combined run fits the machine (it splits the
|
|
49
|
+
available cores across the parallel \`vitest\` jobs via \`--maxWorkers\` instead of letting each grab every core).
|
|
50
|
+
Pass job ids to run a subset (e.g. \`npm run checkup -- lint tests\`) or \`--no-docker\` to skip the image build.
|
|
48
51
|
|
|
49
52
|
<a id='functionality-tests'></a>
|
|
50
53
|
### 🧪 Functionality Tests
|
|
@@ -4,6 +4,8 @@ import type { ValidWikiDocumentTargetsNoSuffix } from '../../cli/wiki';
|
|
|
4
4
|
import type { PathLike } from 'fs';
|
|
5
5
|
import type { scripts } from '../../cli/common/scripts-info';
|
|
6
6
|
import type { ScriptOptions } from '../doc-util/doc-cli-option';
|
|
7
|
+
import type { FlowrConfig } from '../../config';
|
|
8
|
+
import type { AutocompletablePaths } from '../../util/objects';
|
|
7
9
|
import type { ReplCommandNames } from '../../cli/repl/commands/repl-commands';
|
|
8
10
|
/**
|
|
9
11
|
* Context available when generating documentation for a wiki in markdown format
|
|
@@ -311,6 +313,18 @@ export interface GeneralDocContext {
|
|
|
311
313
|
* @see {@link getReplCommand} - for the underlying impl.
|
|
312
314
|
*/
|
|
313
315
|
replCmd(commandName: ReplCommandNames, quote?: boolean, showStar?: boolean): string;
|
|
316
|
+
/**
|
|
317
|
+
* Generates a link to a flowR configuration option, resolving its schema type and description as a hover tooltip.
|
|
318
|
+
* @example
|
|
319
|
+
* ```ts
|
|
320
|
+
* linkConfig('solver.sigdb.enabled')
|
|
321
|
+
* ```
|
|
322
|
+
* Returns a link to the configuration section of the Interface wiki page, showing `solver.sigdb.enabled` with its documentation on hover.
|
|
323
|
+
* @param path - The `.`-separated configuration path (autocompletes to valid config keys only).
|
|
324
|
+
* @param quote - Whether to render the path as inline code. Default is `false`.
|
|
325
|
+
* @see {@link getConfigOption} - for the underlying impl.
|
|
326
|
+
*/
|
|
327
|
+
linkConfig<K extends AutocompletablePaths<FlowrConfig>>(path: K, quote?: boolean): string;
|
|
314
328
|
}
|
|
315
329
|
/**
|
|
316
330
|
* Creates a wiki context for generating documentation for code elements.
|
|
@@ -136,6 +136,9 @@ function makeDocContextForTypes(shell, ...rootFolders) {
|
|
|
136
136
|
},
|
|
137
137
|
replCmd(commandName, quote = true, showStar = false) {
|
|
138
138
|
return (0, doc_cli_option_1.getReplCommand)(commandName, quote, showStar);
|
|
139
|
+
},
|
|
140
|
+
linkConfig(path, quote = false) {
|
|
141
|
+
return (0, doc_cli_option_1.getConfigOption)(path, quote);
|
|
139
142
|
}
|
|
140
143
|
};
|
|
141
144
|
}
|