@eagleoutice/flowr 2.16.6 → 2.16.8
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 +21 -15
- package/abstract-interpretation/data-frame/dataframe-semantics.d.ts +2 -0
- package/abstract-interpretation/data-frame/dataframe-semantics.js +3 -1
- package/abstract-interpretation/data-frame/resolve-args.d.ts +1 -7
- package/abstract-interpretation/data-frame/resolve-args.js +2 -11
- package/cli/repl/commands/repl-cfg.js +5 -19
- package/cli/repl/commands/repl-code-command.d.ts +10 -0
- package/cli/repl/commands/repl-code-command.js +18 -0
- package/cli/repl/commands/repl-dataflow.js +34 -59
- package/cli/repl/commands/repl-normalize.js +24 -41
- package/cli/repl/commands/repl-query.js +10 -17
- package/config.js +3 -3
- package/control-flow/cfg-dead-code.js +15 -2
- package/control-flow/useless-loop.js +1 -2
- package/data/r-base-packages.generated.d.ts +1 -1
- package/data/r-base-packages.generated.js +3 -3
- package/dataflow/environments/ambient-state-name.d.ts +80 -0
- package/dataflow/environments/ambient-state-name.js +113 -0
- package/dataflow/environments/built-in-eval-name.d.ts +3 -1
- package/dataflow/environments/built-in-eval-name.js +2 -0
- package/dataflow/environments/built-in-props.d.ts +27 -7
- package/dataflow/environments/built-in-props.js +59 -44
- package/dataflow/environments/built-in.d.ts +5 -2
- package/dataflow/environments/built-in.js +22 -5
- package/dataflow/environments/default-builtin-config.d.ts +538 -14
- package/dataflow/environments/default-builtin-config.js +189 -123
- package/dataflow/environments/environment.d.ts +7 -1
- package/dataflow/environments/environment.js +19 -1
- package/dataflow/environments/identifier.d.ts +12 -1
- package/dataflow/environments/reference-to-maybe.js +1 -6
- package/dataflow/eval/resolve/alias-tracking.d.ts +13 -3
- package/dataflow/eval/resolve/alias-tracking.js +66 -37
- package/dataflow/eval/resolve/resolve-argument.d.ts +4 -2
- package/dataflow/eval/resolve/resolve-argument.js +23 -11
- package/dataflow/eval/resolve/resolve.d.ts +5 -0
- package/dataflow/eval/resolve/resolve.js +25 -3
- package/dataflow/eval/values/r-value.d.ts +4 -2
- package/dataflow/eval/values/r-value.js +3 -1
- package/dataflow/eval/values/string/string-constants.d.ts +7 -1
- package/dataflow/eval/values/string/string-constants.js +38 -36
- package/dataflow/extractor.js +105 -2
- package/dataflow/fn/argument-roles.js +22 -8
- package/dataflow/fn/function-semantics.d.ts +3 -2
- package/dataflow/fn/strict-function.js +13 -2
- package/dataflow/graph/dataflowgraph-builder.d.ts +4 -4
- package/dataflow/graph/df-helper.d.ts +14 -1
- package/dataflow/graph/df-helper.js +37 -4
- package/dataflow/graph/graph.d.ts +6 -0
- package/dataflow/graph/graph.js +9 -10
- package/dataflow/graph/vertex.d.ts +1 -1
- package/dataflow/hooks.d.ts +1 -1
- package/dataflow/info.d.ts +3 -3
- package/dataflow/internal/linker.d.ts +4 -1
- package/dataflow/internal/linker.js +12 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.d.ts +41 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.js +88 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +21 -46
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +125 -158
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +6 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +35 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +10 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +4 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +6 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +3 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +7 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +21 -12
- package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +8 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +4 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +5 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-local.js +5 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +11 -12
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +6 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-string-template.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +7 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +43 -7
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +11 -0
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +29 -4
- package/dataflow/internal/process/functions/call/common.js +3 -4
- package/dataflow/internal/process/functions/call/deferred.d.ts +3 -2
- package/dataflow/internal/process/functions/call/deferred.js +17 -9
- package/dataflow/internal/process/functions/call/quoted.js +1 -1
- package/dataflow/processor.d.ts +1 -1
- package/documentation/doc-capabilities.js +3 -2
- package/documentation/doc-readme.js +1 -2
- package/documentation/doc-util/doc-dfg.js +2 -2
- package/documentation/doc-util/doc-query.d.ts +3 -1
- package/documentation/doc-util/doc-query.js +4 -4
- package/documentation/wiki-create-linting-rules.js +1 -1
- package/documentation/wiki-linter.js +16 -206
- package/documentation/wiki-linting-and-testing.js +31 -64
- package/documentation/wiki-query.js +41 -0
- package/index.d.ts +1 -0
- package/index.js +5 -1
- package/linter/linter-format.d.ts +6 -0
- package/linter/linter-format.js +10 -0
- package/linter/linter-rules.d.ts +155 -103
- package/linter/linter-rules.js +2 -0
- package/linter/linter-util.d.ts +23 -0
- package/linter/linter-util.js +58 -0
- package/linter/rules/absolute-path.d.ts +2 -2
- package/linter/rules/absolute-path.js +1 -4
- package/linter/rules/cmd-check/bogus-return.d.ts +2 -2
- package/linter/rules/cmd-check/bogus-return.js +3 -7
- package/linter/rules/cmd-check/call-arguments.d.ts +2 -2
- package/linter/rules/cmd-check/class-string-comparison.d.ts +2 -2
- package/linter/rules/cmd-check/class-string-comparison.js +3 -7
- package/linter/rules/cmd-check/cmd-check-util.d.ts +8 -9
- package/linter/rules/cmd-check/cmd-check-util.js +14 -26
- package/linter/rules/cmd-check/compiled-code.d.ts +8 -3
- package/linter/rules/cmd-check/compiled-code.js +3 -13
- package/linter/rules/cmd-check/dependency-declaration.d.ts +2 -2
- package/linter/rules/cmd-check/dependency-declaration.js +6 -7
- package/linter/rules/cmd-check/description-metadata.d.ts +4 -4
- package/linter/rules/cmd-check/documentation-mismatch.d.ts +2 -2
- package/linter/rules/cmd-check/documentation-mismatch.js +4 -11
- package/linter/rules/cmd-check/file-checks.d.ts +19 -6
- package/linter/rules/cmd-check/file-checks.js +13 -5
- package/linter/rules/cmd-check/foreign-function-calls.d.ts +2 -2
- package/linter/rules/cmd-check/global-environment-modification.d.ts +2 -2
- package/linter/rules/cmd-check/global-environment-modification.js +3 -2
- package/linter/rules/cmd-check/namespace-tampering.d.ts +2 -2
- package/linter/rules/cmd-check/namespace-tampering.js +9 -9
- package/linter/rules/cmd-check/non-ascii-code.d.ts +2 -2
- package/linter/rules/cmd-check/package-data.d.ts +11 -5
- package/linter/rules/cmd-check/package-data.js +5 -12
- package/linter/rules/cmd-check/package-files.js +4 -10
- package/linter/rules/cmd-check/package-hooks.d.ts +2 -2
- package/linter/rules/cmd-check/package-hooks.js +10 -8
- package/linter/rules/cmd-check/package-metafiles.d.ts +8 -3
- package/linter/rules/cmd-check/package-metafiles.js +3 -12
- package/linter/rules/cmd-check/package-runtime.d.ts +18 -5
- package/linter/rules/cmd-check/package-runtime.js +64 -20
- package/linter/rules/cmd-check/package-structure.d.ts +11 -5
- package/linter/rules/cmd-check/package-structure.js +4 -12
- package/linter/rules/cmd-check/rd-files.d.ts +8 -3
- package/linter/rules/cmd-check/rd-files.js +4 -14
- package/linter/rules/cmd-check/s-three-method-consistency.d.ts +2 -2
- package/linter/rules/cmd-check/s-three-method-consistency.js +3 -4
- package/linter/rules/cmd-check/true-false-abbreviation.d.ts +2 -2
- package/linter/rules/dataframe-access-validation.d.ts +2 -2
- package/linter/rules/dataframe-access-validation.js +5 -8
- package/linter/rules/dead-code.d.ts +5 -4
- package/linter/rules/dead-code.js +25 -14
- package/linter/rules/deprecated-functions.d.ts +3 -3
- package/linter/rules/deprecated-functions.js +16 -23
- package/linter/rules/file-path-validity.d.ts +2 -2
- package/linter/rules/file-path-validity.js +3 -6
- package/linter/rules/function-finder-util.d.ts +3 -3
- package/linter/rules/function-finder-util.js +7 -14
- package/linter/rules/namespace-access.d.ts +2 -2
- package/linter/rules/namespace-access.js +6 -9
- package/linter/rules/naming-convention.d.ts +2 -2
- package/linter/rules/naming-convention.js +1 -4
- package/linter/rules/network-functions.d.ts +3 -3
- package/linter/rules/no-leaked-credentials.d.ts +2 -2
- package/linter/rules/no-leaked-credentials.js +1 -4
- package/linter/rules/overwritten-file.d.ts +38 -0
- package/linter/rules/overwritten-file.js +102 -0
- package/linter/rules/problematic-inputs.d.ts +16 -6
- package/linter/rules/problematic-inputs.js +78 -34
- package/linter/rules/roxygen-arguments.d.ts +2 -2
- package/linter/rules/roxygen-arguments.js +1 -4
- package/linter/rules/seeded-randomness.d.ts +3 -3
- package/linter/rules/seeded-randomness.js +6 -23
- package/linter/rules/software-has-license.d.ts +2 -2
- package/linter/rules/software-has-license.js +1 -4
- package/linter/rules/software-has-tests.d.ts +2 -2
- package/linter/rules/software-has-tests.js +1 -4
- package/linter/rules/stop-with-call-arg.d.ts +2 -2
- package/linter/rules/stop-with-call-arg.js +4 -11
- package/linter/rules/syntactically-valid.d.ts +4 -2
- package/linter/rules/syntactically-valid.js +29 -10
- package/linter/rules/unclosed-connection.d.ts +2 -2
- package/linter/rules/unclosed-connection.js +1 -4
- package/linter/rules/undefined-symbol.d.ts +2 -2
- package/linter/rules/undefined-symbol.js +25 -22
- package/linter/rules/unescaped-arguments.d.ts +2 -2
- package/linter/rules/unescaped-arguments.js +1 -4
- package/linter/rules/unused-definition.d.ts +2 -2
- package/linter/rules/unused-definition.js +37 -25
- package/linter/rules/unused-import.d.ts +2 -2
- package/linter/rules/unused-import.js +9 -14
- package/linter/rules/useless-loop.d.ts +7 -6
- package/linter/rules/useless-loop.js +4 -8
- package/package.json +5 -3
- package/project/cache/flowr-analyzer-cache.d.ts +2 -0
- package/project/cache/flowr-analyzer-cache.js +15 -11
- package/project/context/flowr-analyzer-files-context.d.ts +3 -0
- package/project/context/flowr-analyzer-files-context.js +6 -0
- package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +6 -1
- package/project/plugins/file-plugins/files/flowr-jupyter-file.js +35 -0
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +2 -1
- package/project/plugins/file-plugins/files/flowr-rsession-file.d.ts +26 -0
- package/project/plugins/file-plugins/files/flowr-rsession-file.js +44 -0
- package/project/plugins/file-plugins/files/r-session.d.ts +20 -0
- package/project/plugins/file-plugins/files/r-session.js +58 -0
- package/project/plugins/file-plugins/files/recorded-runs.d.ts +18 -0
- package/project/plugins/file-plugins/files/recorded-runs.js +8 -0
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rsession-file-plugin.d.ts +20 -0
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rsession-file-plugin.js +28 -0
- package/project/plugins/plugin-registry.d.ts +2 -1
- package/project/plugins/plugin-registry.js +2 -0
- package/project/sigdb/spec-query.d.ts +73 -0
- package/project/sigdb/spec-query.js +339 -0
- package/queries/base-query-format.d.ts +1 -1
- package/queries/base-query-format.js +2 -2
- package/queries/catalog/absint-query/absint-query-executor.js +3 -6
- package/queries/catalog/call-context-query/call-context-query-executor.d.ts +1 -0
- package/queries/catalog/call-context-query/call-context-query-executor.js +113 -73
- package/queries/catalog/call-graph-query/call-graph-query-executor.js +2 -3
- package/queries/catalog/cluster-query/cluster-query-executor.js +2 -3
- package/queries/catalog/config-query/config-query-format.d.ts +0 -1
- package/queries/catalog/config-query/config-query-format.js +1 -2
- package/queries/catalog/control-flow-query/control-flow-query-executor.js +2 -3
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.js +2 -4
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.d.ts +0 -1
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.js +1 -2
- package/queries/catalog/dataflow-query/dataflow-query-executor.js +2 -3
- package/queries/catalog/dependencies-query/dependencies-query-executor.d.ts +7 -0
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +72 -42
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +24 -6
- package/queries/catalog/dependencies-query/dependencies-query-format.js +108 -3
- package/queries/catalog/dependencies-query/function-info/function-info.d.ts +6 -1
- package/queries/catalog/dependencies-query/function-info/read-functions.js +6 -6
- package/queries/catalog/dependencies-query/function-info/write-functions.js +13 -7
- package/queries/catalog/dependencies-query/implicit-echo.js +21 -7
- package/queries/catalog/dice-query/dice-query-executor.js +2 -3
- package/queries/catalog/does-call-query/does-call-query-executor.js +2 -3
- package/queries/catalog/files-query/files-query-executor.js +2 -3
- package/queries/catalog/function-info-query/function-info-query-executor.js +2 -1
- package/queries/catalog/function-info-query/function-info-query-format.d.ts +0 -2
- package/queries/catalog/function-info-query/function-info-query-format.js +1 -2
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +3 -2
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +0 -2
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +1 -2
- package/queries/catalog/happens-before-query/happens-before-query-executor.js +2 -3
- package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +0 -1
- package/queries/catalog/happens-before-query/happens-before-query-format.js +1 -2
- package/queries/catalog/id-map-query/id-map-query-executor.js +2 -3
- package/queries/catalog/id-map-query/id-map-query-format.d.ts +0 -1
- package/queries/catalog/id-map-query/id-map-query-format.js +1 -2
- package/queries/catalog/input-sources-query/input-sources-query-executor.js +3 -4
- package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +2 -1
- package/queries/catalog/input-sources-query/simple-input-classifier.js +60 -13
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.js +2 -3
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-executor.js +2 -3
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.js +2 -1
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.d.ts +3 -2
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +1 -7
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +6 -9
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +8 -33
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.d.ts +3 -2
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.js +1 -7
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.d.ts +6 -7
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.js +8 -31
- package/queries/catalog/linter-query/linter-query-executor.js +2 -3
- package/queries/catalog/location-map-query/location-map-query-executor.js +2 -3
- package/queries/catalog/location-map-query/location-map-query-format.d.ts +0 -1
- package/queries/catalog/location-map-query/location-map-query-format.js +1 -2
- package/queries/catalog/normalized-ast-query/normalized-ast-query-executor.js +2 -3
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +0 -1
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.js +1 -2
- package/queries/catalog/origin-query/origin-query-executor.d.ts +0 -5
- package/queries/catalog/origin-query/origin-query-executor.js +3 -11
- package/queries/catalog/project-query/project-query-executor.js +23 -7
- package/queries/catalog/project-query/project-query-format.d.ts +5 -0
- package/queries/catalog/project-query/project-query-format.js +20 -2
- package/queries/catalog/provenance-query/provenance-query-executor.js +2 -3
- package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +2 -3
- package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +0 -1
- package/queries/catalog/resolve-value-query/resolve-value-query-format.js +1 -2
- package/queries/catalog/search-query/search-query-executor.js +2 -3
- package/queries/catalog/signature-query/signature-query-executor.js +39 -0
- package/queries/catalog/signature-query/signature-query-format.d.ts +7 -1
- package/queries/catalog/signature-query/signature-query-format.js +15 -1
- package/queries/catalog/signature-query/signature-query-render.js +2 -1
- package/queries/catalog/static-slice-query/static-slice-query-executor.js +2 -3
- package/queries/query-function-property.d.ts +28 -0
- package/queries/query-function-property.js +48 -0
- package/queries/query-meta.d.ts +3 -0
- package/queries/query-meta.js +8 -0
- package/queries/query.d.ts +13 -18
- package/r-bridge/lang-4.x/ast/model/processing/decorate.d.ts +2 -2
- package/r-bridge/lang-4.x/ast/model/processing/decorate.js +4 -3
- package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +6 -0
- package/r-bridge/lang-4.x/ast/model/processing/node-id.js +9 -0
- package/r-bridge/lang-4.x/ast/model/syntax-version.d.ts +8 -0
- package/r-bridge/lang-4.x/ast/model/syntax-version.js +49 -0
- package/r-bridge/lang-4.x/ast/model/type.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/type.js +3 -0
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-parameter.js +4 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-single-node.js +1 -0
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +1 -1
- package/reconstruct/reconstruct.js +35 -1
- package/search/search-executor/search-generators.js +1 -1
- package/slicing/static/fingerprint.js +7 -3
- package/slicing/static/static-slicer.js +6 -0
- package/util/assert.js +2 -2
- package/util/collections/arrays.d.ts +4 -0
- package/util/collections/arrays.js +11 -0
- package/util/collections/defaultmap.d.ts +5 -1
- package/util/collections/defaultmap.js +6 -1
- package/util/files.js +26 -5
- package/util/flowr-version.d.ts +10 -0
- package/util/flowr-version.js +20 -0
- package/util/glob.js +6 -4
- package/util/r-regex.d.ts +6 -0
- package/util/r-regex.js +17 -0
- package/util/text/args.d.ts +5 -0
- package/util/text/args.js +28 -22
- package/util/text/name-rank.d.ts +2 -0
- package/util/text/name-rank.js +3 -1
- package/util/text/regex.d.ts +10 -0
- package/util/text/regex.js +29 -0
- package/util/version.d.ts +1 -6
- package/util/version.js +6 -14
- package/documentation/doc-util/doc-functions.d.ts +0 -24
- package/documentation/doc-util/doc-functions.js +0 -65
|
@@ -2,12 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.executeDependenciesQuery = executeDependenciesQuery;
|
|
4
4
|
const query_1 = require("../../query");
|
|
5
|
+
const slice_direction_1 = require("../../../util/slice-direction");
|
|
6
|
+
const parse_1 = require("../../../slicing/criterion/parse");
|
|
5
7
|
const dependencies_query_format_1 = require("./dependencies-query-format");
|
|
6
8
|
const vertex_1 = require("../../../dataflow/graph/vertex");
|
|
7
9
|
const identifier_1 = require("../../../dataflow/environments/identifier");
|
|
8
10
|
const df_helper_1 = require("../../../dataflow/graph/df-helper");
|
|
9
11
|
const node_id_1 = require("../../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
10
12
|
const edge_1 = require("../../../dataflow/graph/edge");
|
|
13
|
+
const query_meta_1 = require("../../query-meta");
|
|
11
14
|
const objects_1 = require("../../../util/objects");
|
|
12
15
|
const function_info_1 = require("./function-info/function-info");
|
|
13
16
|
const identify_link_to_last_call_relation_1 = require("../call-context-query/identify-link-to-last-call-relation");
|
|
@@ -18,6 +21,7 @@ const model_1 = require("../../../r-bridge/lang-4.x/ast/model/model");
|
|
|
18
21
|
const graph_1 = require("../../../dataflow/graph/graph");
|
|
19
22
|
const link_devices_1 = require("./link-devices");
|
|
20
23
|
const arrays_1 = require("../../../util/collections/arrays");
|
|
24
|
+
const defaultmap_1 = require("../../../util/collections/defaultmap");
|
|
21
25
|
const library_functions_1 = require("./function-info/library-functions");
|
|
22
26
|
const plot_description_1 = require("./plot-description");
|
|
23
27
|
const data_flow_1 = require("./data-flow");
|
|
@@ -39,6 +43,7 @@ async function executeDependenciesQuery({ analyzer, }, queries) {
|
|
|
39
43
|
enabledCategories: query.enabledCategories === undefined && q.enabledCategories === undefined ? undefined : [...(query.enabledCategories ?? []), ...(q.enabledCategories ?? [])],
|
|
40
44
|
ignoreDefaultFunctions: query.ignoreDefaultFunctions || q.ignoreDefaultFunctions,
|
|
41
45
|
assumedPackages: query.assumedPackages || q.assumedPackages,
|
|
46
|
+
focus: query.focus === undefined && q.focus === undefined ? undefined : [...query.focus ?? [], ...q.focus ?? []],
|
|
42
47
|
additionalCategories: {
|
|
43
48
|
...query.additionalCategories,
|
|
44
49
|
...q.additionalCategories
|
|
@@ -64,12 +69,13 @@ async function executeDependenciesQuery({ analyzer, }, queries) {
|
|
|
64
69
|
await (0, query_1.executeQueriesOfSameType)(data, functions.entries().flatMap(makeCallContextQuery).toArray());
|
|
65
70
|
const g = (0, dependencies_query_format_1.getAllCategories)(queries, ctx);
|
|
66
71
|
const enabled = query.enabledCategories;
|
|
67
|
-
const run = { dataflow, config, normalize, memo: (0, data_flow_1.makeFlowMemo)(), formals: formalsLookup(dataflow.graph, ctx) };
|
|
72
|
+
const run = { dataflow, config, normalize, memo: (0, data_flow_1.makeFlowMemo)(), formals: formalsLookup(dataflow.graph, ctx), revalue: new Map() };
|
|
68
73
|
/* the packages the code attaches decide which package a bare call further down belongs to */
|
|
69
74
|
const library = getResults(g, run, queryResults, 'library', functions.get('library') ?? [], data);
|
|
70
75
|
const attaching = library.filter(library_functions_1.attachesPackage);
|
|
71
76
|
const results = Object.fromEntries(await Promise.all(functions.entries().map(async ([c, f]) => {
|
|
72
|
-
|
|
77
|
+
/* a call of an alias of several functions of the category, `if(u) r <- read.csv else r <- read.table`, is one entry */
|
|
78
|
+
const results = (0, arrays_1.uniqueArrayBy)(c === 'library' ? library : getResults(g, run, queryResults, c, f, data, attaching), e => `${String(e.nodeId)}\0${String(e.argumentId)}\0${e.value ?? ''}`);
|
|
73
79
|
/* only default categories allow additional analyses */
|
|
74
80
|
if (enabled === undefined || enabled.includes(c)) {
|
|
75
81
|
await g[c]?.additionalAnalysis?.(data, ignoreDefault, f, queryResults, results);
|
|
@@ -84,7 +90,7 @@ async function executeDependenciesQuery({ analyzer, }, queries) {
|
|
|
84
90
|
}
|
|
85
91
|
for (const [category, found] of Object.entries(results)) {
|
|
86
92
|
if (found !== undefined && !NotPassedOnByCalls.has(category)) {
|
|
87
|
-
results[category] = [...found, ...callSitesOf(found, dataflow.graph, normalize)];
|
|
93
|
+
results[category] = [...found, ...callSitesOf(found, dataflow.graph, normalize, run.revalue)];
|
|
88
94
|
}
|
|
89
95
|
}
|
|
90
96
|
if (query.assumedPackages && (enabled === undefined || enabled.includes('library'))) {
|
|
@@ -94,34 +100,65 @@ async function executeDependenciesQuery({ analyzer, }, queries) {
|
|
|
94
100
|
results.library = [...(results.library ?? []), ...assumed];
|
|
95
101
|
}
|
|
96
102
|
}
|
|
103
|
+
const focus = query.focus?.length ? await focusOf(data, query.focus) : undefined;
|
|
97
104
|
return {
|
|
98
|
-
'.meta': {
|
|
99
|
-
timing: Date.now() - now
|
|
100
|
-
},
|
|
105
|
+
'.meta': { ...(0, query_meta_1.metaSince)(now)['.meta'], ...focus === undefined ? {} : { focus } },
|
|
101
106
|
...results,
|
|
102
107
|
};
|
|
103
108
|
}
|
|
109
|
+
/** the nodes taking part in what the `criteria` name: the nodes themselves, what they depend on, and what depends on them */
|
|
110
|
+
async function focusOf(data, criteria) {
|
|
111
|
+
const { 'static-slice': slices } = await data.analyzer.query([slice_direction_1.SliceDirection.Backward, slice_direction_1.SliceDirection.Forward].map(direction => ({ type: 'static-slice', criteria: [...criteria], direction, noReconstruction: true })));
|
|
112
|
+
const ast = await data.analyzer.normalize();
|
|
113
|
+
const named = criteria.map(c => parse_1.SlicingCriterion.tryParse(c, ast.idMap)).filter(assert_1.isNotUndefined);
|
|
114
|
+
return (0, arrays_1.uniqueArray)([...named, ...Object.values(slices.results).flatMap(r => [...r.slice.result])]);
|
|
115
|
+
}
|
|
104
116
|
/** what a call of a function does not do itself: loading a package or a script there is still what the function does */
|
|
105
117
|
const NotPassedOnByCalls = new Set(['library', 'source', 'remote']);
|
|
106
118
|
/**
|
|
107
119
|
* The calls of the program's functions that do what the entries within their bodies do, transitively: a call of `report()`
|
|
108
120
|
* writes what the `cat()` in its body writes, and so does every call of a function that calls `report()`.
|
|
121
|
+
* A call gets the values the entry has for just this call, as `save("a.csv")` writes `a.csv` only, even though the
|
|
122
|
+
* `write.csv(d, n)` in the body of `save` writes whatever any call names. Where the entry cannot be asked again, a call
|
|
123
|
+
* only passes on a sole value, as it cannot tell which of several is its own.
|
|
109
124
|
*/
|
|
110
|
-
function callSitesOf(found, graph, ast) {
|
|
125
|
+
function callSitesOf(found, graph, ast, revalue) {
|
|
126
|
+
/* a call already found doing this needs no entry for it, but two writes of one file in one body both pass on to the call */
|
|
127
|
+
const named = (value) => value !== undefined && value !== dependencies_query_format_1.Unknown && value !== dependencies_query_format_1.Constant && value !== 'stdout' && value !== 'stderr';
|
|
128
|
+
const key = (id, value, root) => `${String(id)}\0${value ?? ''}\0${named(value) ? String(root) : ''}`;
|
|
129
|
+
const known = new Set(found.map(f => key(f.nodeId, f.value)));
|
|
130
|
+
const byNode = Map.groupBy(found.filter(f => f.nodeId !== undefined), f => f.nodeId);
|
|
131
|
+
/* asking again is only sound where it states what the entries say without a context, an analysis after the
|
|
132
|
+
* values (a plot taking the file of its device) may have changed them; only asked for entries some call reaches */
|
|
133
|
+
const askable = (0, defaultmap_1.memoize)((root) => {
|
|
134
|
+
const again = revalue.get(root)?.(new Map());
|
|
135
|
+
return again !== undefined && new Set(again).symmetricDifference(new Set(byNode.get(root)?.map(e => e.value))).size === 0;
|
|
136
|
+
});
|
|
137
|
+
const queue = [...byNode.entries().map(([id, entries]) => ({ nodeId: id, entries, root: id, context: new Map() }))];
|
|
111
138
|
const added = [];
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
139
|
+
for (const chain of queue) {
|
|
140
|
+
const definition = model_1.RNode.findEnclosing(chain.nodeId, ast.idMap, r_function_definition_1.RFunctionDefinition.is);
|
|
141
|
+
if (definition === undefined) {
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
const sole = (0, arrays_1.uniqueArray)(chain.entries.map(e => e.value));
|
|
145
|
+
const ask = askable(chain.root) ? revalue.get(chain.root) : undefined;
|
|
146
|
+
for (const call of df_helper_1.Dataflow.sourcesOf(graph, definition, edge_1.EdgeType.Calls)) {
|
|
117
147
|
const vertex = graph.getVertex(call);
|
|
118
|
-
if (!vertex_1.DfgVertex.isFunctionCall(vertex)
|
|
148
|
+
if (!vertex_1.DfgVertex.isFunctionCall(vertex)) {
|
|
119
149
|
continue;
|
|
120
150
|
}
|
|
121
|
-
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
|
|
151
|
+
const context = () => new Map(chain.context).set(definition, call);
|
|
152
|
+
const asked = ask?.(context());
|
|
153
|
+
const values = asked?.length ? asked : sole.length === 1 ? sole : [undefined];
|
|
154
|
+
const sites = (0, arrays_1.uniqueArray)(values).filter(v => !known.has(key(call, v)) && !known.has(key(call, v, chain.root))).map((value) => {
|
|
155
|
+
known.add(key(call, value, chain.root));
|
|
156
|
+
return { functionName: vertex.name ?? chain.entries[0].functionName, nodeId: call, via: chain.nodeId, ...value === undefined ? {} : { value } };
|
|
157
|
+
});
|
|
158
|
+
if (sites.length > 0) {
|
|
159
|
+
added.push(...sites);
|
|
160
|
+
queue.push({ nodeId: call, entries: sites, root: chain.root, context: context() });
|
|
161
|
+
}
|
|
125
162
|
}
|
|
126
163
|
}
|
|
127
164
|
return added;
|
|
@@ -180,7 +217,7 @@ function makeCallContextQuery([kind, functions]) {
|
|
|
180
217
|
type: 'call-context',
|
|
181
218
|
callName: f.name,
|
|
182
219
|
callTargets: identify_link_to_last_call_relation_1.CallTargets.MustIncludeGlobal,
|
|
183
|
-
includeAliases:
|
|
220
|
+
includeAliases: true,
|
|
184
221
|
callNameExact: true,
|
|
185
222
|
subkind: f.name,
|
|
186
223
|
linkTo: f.linkTo,
|
|
@@ -272,8 +309,10 @@ function getResults(categories, run, results, kind, functions, data, attaching =
|
|
|
272
309
|
continue;
|
|
273
310
|
}
|
|
274
311
|
const formals = run.formals(vertex, functionName);
|
|
275
|
-
const
|
|
276
|
-
const
|
|
312
|
+
const argsIn = (callContext) => (0, resolve_argument_1.getArgumentStringValue)(vars, dfg, vertex, info.argIdx, info.argName, info.resolveValue, ictx, formals, callContext);
|
|
313
|
+
const linkedIn = (args, callContext) => collectValuesFromLinks(args, { dataflow, config, ctx: ictx, formals: run.formals }, linkedIds, callContext);
|
|
314
|
+
const args = argsIn();
|
|
315
|
+
const linkedArgs = linkedIn(args);
|
|
277
316
|
const linked = linkedIds?.map(linkedId => typeof linkedId === 'object' ? linkedId.id : linkedId);
|
|
278
317
|
const ignoreOnArgVal = () => {
|
|
279
318
|
if (info.ignoreIf !== 'arg-true' && info.ignoreIf !== 'arg-false') {
|
|
@@ -287,30 +326,18 @@ function getResults(categories, run, results, kind, functions, data, attaching =
|
|
|
287
326
|
const ignoredValue = info.ignoreIf === 'arg-true' ? 'TRUE' : 'FALSE';
|
|
288
327
|
return valValues.length > 0 && valValues.every(v => v === ignoredValue);
|
|
289
328
|
};
|
|
290
|
-
const
|
|
291
|
-
if (info.ignoreIf !== 'arg-set') {
|
|
292
|
-
return;
|
|
293
|
-
}
|
|
294
|
-
const hasArg = (name, index) => vertex.args.some((arg, idx) => graph_1.FunctionArgument.isNamed(arg) && arg.name === name ||
|
|
295
|
-
graph_1.FunctionArgument.isPositional(arg) && idx === index);
|
|
296
|
-
if (hasArg(info.argName, info.argIdx)) {
|
|
297
|
-
return false;
|
|
298
|
-
}
|
|
299
|
-
const margs = info.additionalArgs?.argSet;
|
|
300
|
-
(0, assert_1.guard)(margs, 'Need additional argument argSet when checking for arg-set');
|
|
301
|
-
return hasArg(margs.argName, margs.argIdx);
|
|
302
|
-
};
|
|
329
|
+
const passesInline = info.inline !== undefined && vertex.args.some(arg => graph_1.FunctionArgument.isNamed(arg) && arg.name === info.inline?.argName);
|
|
303
330
|
const flow = dataFlowOf(kind, vertex, run);
|
|
304
331
|
const foundValues = linkedArgs ?? args;
|
|
305
332
|
if (!foundValues) {
|
|
306
|
-
if (info.ignoreIf !== 'arg-missing' && !ignoreOnArgVal()
|
|
333
|
+
if (info.ignoreIf !== 'arg-missing' && !ignoreOnArgVal()) {
|
|
307
334
|
finalResults.push((0, objects_1.compactRecord)({
|
|
308
335
|
nodeId: id,
|
|
309
336
|
functionName,
|
|
310
337
|
lexemeOfArgument: undefined,
|
|
311
338
|
linkedIds: linked?.length ? linked : undefined,
|
|
312
339
|
...flow,
|
|
313
|
-
value: info.defaultValue ?? defaultValue
|
|
340
|
+
value: passesInline ? dependencies_query_format_1.Constant : info.defaultValue ?? defaultValue
|
|
314
341
|
}));
|
|
315
342
|
}
|
|
316
343
|
continue;
|
|
@@ -326,15 +353,18 @@ function getResults(categories, run, results, kind, functions, data, attaching =
|
|
|
326
353
|
continue;
|
|
327
354
|
}
|
|
328
355
|
}
|
|
329
|
-
else if (ignoreOnArgVal()
|
|
356
|
+
else if (ignoreOnArgVal()) {
|
|
330
357
|
continue;
|
|
331
358
|
}
|
|
359
|
+
const replaced = (value) => value !== undefined && info.stringReplacements && Object.hasOwn(info.stringReplacements, value) ? info.stringReplacements[value] : value;
|
|
360
|
+
run.revalue.set(id, callContext => {
|
|
361
|
+
const args = argsIn(callContext);
|
|
362
|
+
const found = linkedIn(args, callContext) ?? args;
|
|
363
|
+
return found && [...found.values()].flatMap(values => [...values].map(v => replaced(v) ?? info.defaultValue ?? defaultValue)).filter(assert_1.isNotUndefined);
|
|
364
|
+
});
|
|
332
365
|
for (const [arg, values] of foundValues.entries()) {
|
|
333
366
|
for (const value of values) {
|
|
334
|
-
|
|
335
|
-
if (info.stringReplacements && value !== undefined && Object.hasOwn(info.stringReplacements, value)) {
|
|
336
|
-
resolvedValue = info.stringReplacements[value];
|
|
337
|
-
}
|
|
367
|
+
const resolvedValue = replaced(value);
|
|
338
368
|
const dep = resolvedValue ? d.getDependency(resolvedValue) ?? undefined : undefined;
|
|
339
369
|
const lexeme = unresolvedArgumentCode(value, arg);
|
|
340
370
|
finalResults.push((0, objects_1.compactRecord)({
|
|
@@ -362,7 +392,7 @@ function getResults(categories, run, results, kind, functions, data, attaching =
|
|
|
362
392
|
return model_1.RNode.lexeme(r_argument_1.RArgument.valueOf(normalize.idMap.get(id)));
|
|
363
393
|
}
|
|
364
394
|
}
|
|
365
|
-
function collectValuesFromLinks(args, data, linkedIds) {
|
|
395
|
+
function collectValuesFromLinks(args, data, linkedIds, callContext) {
|
|
366
396
|
if (!linkedIds || linkedIds.length === 0) {
|
|
367
397
|
return undefined;
|
|
368
398
|
}
|
|
@@ -380,7 +410,7 @@ function collectValuesFromLinks(args, data, linkedIds) {
|
|
|
380
410
|
if (!vertex_1.DfgVertex.isFunctionCall(vertex)) {
|
|
381
411
|
continue;
|
|
382
412
|
}
|
|
383
|
-
const args = (0, resolve_argument_1.getArgumentStringValue)(data.config.solver.variables, data.dataflow.graph, vertex, info.argIdx, info.argName, info.resolveValue, data.ctx, data.formals(vertex));
|
|
413
|
+
const args = (0, resolve_argument_1.getArgumentStringValue)(data.config.solver.variables, data.dataflow.graph, vertex, info.argIdx, info.argName, info.resolveValue, data.ctx, data.formals(vertex), callContext);
|
|
384
414
|
for (const [arg, values] of args?.entries() ?? []) {
|
|
385
415
|
map.set(arg, (map.get(arg) ?? new Set()).union(values));
|
|
386
416
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type BaseQueryFormat, type BaseQueryMeta, type BasicQueryData } from '../../base-query-format';
|
|
2
|
+
import { criteriaQueryCompleter } from '../../../cli/repl/parser/slice-query-parser';
|
|
3
|
+
import type { SlicingCriterion } from '../../../slicing/criterion/parse';
|
|
2
4
|
import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
3
5
|
import { type OutputFormatter } from '../../../util/text/ansi';
|
|
4
6
|
import Joi from 'joi';
|
|
@@ -55,8 +57,19 @@ export interface DependenciesQuery extends BaseQueryFormat, Partial<Record<`${De
|
|
|
55
57
|
* Off by default: for most callers these are noise, not a dependency they need to act on.
|
|
56
58
|
*/
|
|
57
59
|
readonly assumedPackages?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Focus on the dependencies at these criteria, like `2@read.csv`: the answer names every node that takes part in them,
|
|
62
|
+
* what they depend on and what depends on them, in {@link DependenciesQueryMeta#focus}, so a client can gray out the rest.
|
|
63
|
+
*/
|
|
64
|
+
readonly focus?: readonly SlicingCriterion[];
|
|
58
65
|
}
|
|
59
|
-
export
|
|
66
|
+
export interface DependenciesQueryMeta extends BaseQueryMeta {
|
|
67
|
+
/** the nodes taking part in the dependencies the query {@link DependenciesQuery#focus|focuses} on */
|
|
68
|
+
readonly focus?: readonly NodeId[];
|
|
69
|
+
}
|
|
70
|
+
export type DependenciesQueryResult = {
|
|
71
|
+
readonly '.meta': DependenciesQueryMeta;
|
|
72
|
+
} & {
|
|
60
73
|
[C in DefaultDependencyCategoryName]: DependencyInfo[];
|
|
61
74
|
} & {
|
|
62
75
|
[S in string]?: DependencyInfo[];
|
|
@@ -69,13 +82,15 @@ export interface DependencyInfo extends Record<string, unknown> {
|
|
|
69
82
|
linkedIds?: readonly NodeId[];
|
|
70
83
|
/**
|
|
71
84
|
* Set on a call of a function of the program that does what this entry reports, transitively: the call of
|
|
72
|
-
* `report()` writes what the `cat()` in its body writes. It names the entry within the called function.
|
|
85
|
+
* `report()` writes what the `cat()` in its body writes. It names the entry within the called function. The
|
|
86
|
+
* {@link value} is the one of this call, `save("a.csv")` writes `a.csv` even if other calls of `save` name other files.
|
|
73
87
|
*/
|
|
74
88
|
via?: NodeId;
|
|
75
89
|
/**
|
|
76
90
|
* The other statements that build this output: for a plot, the addons drawn onto it and, when it lands in a
|
|
77
91
|
* file, the device opener and closer around it. Answers *which statements produce this output* without
|
|
78
|
-
* rebuilding it from {@link linkedIds}.
|
|
92
|
+
* rebuilding it from {@link linkedIds}. A part is reported as an entry of its own as well, so to count
|
|
93
|
+
* plots rather than graphics calls, count the entries no other entry lists in its parts.
|
|
79
94
|
*/
|
|
80
95
|
parts?: readonly NodeId[];
|
|
81
96
|
/**
|
|
@@ -123,7 +138,10 @@ export declare function getAllCategoryNames(queries: readonly DependenciesQuery[
|
|
|
123
138
|
export declare const DependenciesQueryDefinition: {
|
|
124
139
|
readonly title: "Dependencies Query";
|
|
125
140
|
readonly executor: typeof executeDependenciesQuery;
|
|
126
|
-
readonly asciiSummarizer: (formatter: OutputFormatter, analyzer: import("../../..").ReadonlyFlowrAnalysisProvider<import("../../..").KnownParser>, queryResults: BaseQueryResult, result: string[], queries: readonly import("../../query").Query[]) =>
|
|
141
|
+
readonly asciiSummarizer: (formatter: OutputFormatter, analyzer: import("../../..").ReadonlyFlowrAnalysisProvider<import("../../..").KnownParser>, queryResults: import("../../base-query-format").BaseQueryResult, result: string[], queries: readonly import("../../query").Query[]) => Promise<boolean>;
|
|
142
|
+
readonly fromLine: (_output: import("../../../cli/repl/commands/repl-main").ReplOutput, line: readonly string[], _config: import("../../..").FlowrConfig) => import("../../query").ParsedQueryLine<"dependencies">;
|
|
143
|
+
readonly completer: typeof criteriaQueryCompleter;
|
|
144
|
+
readonly syntax: "@dependencies (<crit>;...) <code | file://path>";
|
|
127
145
|
readonly schema: Joi.ObjectSchema<any>;
|
|
128
|
-
readonly flattenInvolvedNodes: (queryResults: BaseQueryResult, query: readonly import("../../query").Query[]) => NodeId[];
|
|
146
|
+
readonly flattenInvolvedNodes: (queryResults: import("../../base-query-format").BaseQueryResult, query: readonly import("../../query").Query[]) => NodeId[];
|
|
129
147
|
};
|
|
@@ -6,6 +6,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.DependenciesQueryDefinition = exports.defaultDependencyCategories = exports.DefaultDependencyCategoryNames = exports.Attached = exports.Constant = exports.Unknown = void 0;
|
|
7
7
|
exports.getAllCategories = getAllCategories;
|
|
8
8
|
exports.getAllCategoryNames = getAllCategoryNames;
|
|
9
|
+
const base_query_format_1 = require("../../base-query-format");
|
|
10
|
+
const slice_query_parser_1 = require("../../../cli/repl/parser/slice-query-parser");
|
|
11
|
+
const vertex_1 = require("../../../dataflow/graph/vertex");
|
|
12
|
+
const df_helper_1 = require("../../../dataflow/graph/df-helper");
|
|
13
|
+
const edge_1 = require("../../../dataflow/graph/edge");
|
|
14
|
+
const dataframe_semantics_1 = require("../../../abstract-interpretation/data-frame/dataframe-semantics");
|
|
15
|
+
const built_in_proc_name_1 = require("../../../dataflow/environments/built-in-proc-name");
|
|
16
|
+
const r_access_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-access");
|
|
17
|
+
const r_function_call_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
9
18
|
const query_print_1 = require("../../query-print");
|
|
10
19
|
const ansi_1 = require("../../../util/text/ansi");
|
|
11
20
|
const joi_1 = __importDefault(require("joi"));
|
|
@@ -26,6 +35,8 @@ const objects_1 = require("../../../util/objects");
|
|
|
26
35
|
const r_symbol_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
|
|
27
36
|
const implicit_echo_1 = require("./implicit-echo");
|
|
28
37
|
const arrays_1 = require("../../../util/collections/arrays");
|
|
38
|
+
const defaultmap_1 = require("../../../util/collections/defaultmap");
|
|
39
|
+
const range_1 = require("../../../util/range");
|
|
29
40
|
/** The value could not be resolved, e.g. a path assembled at runtime. Such a dependency may be missing or fetchable. */
|
|
30
41
|
exports.Unknown = 'unknown';
|
|
31
42
|
/** The value resolved, but to data given inline rather than to a path (`matrix(0, 2, 2)`, `data.frame(a = 1)`). */
|
|
@@ -34,6 +45,85 @@ exports.Constant = 'constant';
|
|
|
34
45
|
exports.Attached = '<attached>';
|
|
35
46
|
/** the built-in categories; what each searches for is derived per configuration, see {@link defaultDependencyCategories} */
|
|
36
47
|
exports.DefaultDependencyCategoryNames = ['library', 'remote', 'source', 'read', 'write', 'visualize', 'transform', 'test', 'statistics'];
|
|
48
|
+
/** a definition or call reached again while working it out makes nothing new */
|
|
49
|
+
const NothingNew = { answer: false };
|
|
50
|
+
/**
|
|
51
|
+
* Tells whether the variable read at an id holds a data frame: it is defined by a call the data frame shape inference
|
|
52
|
+
* knows to return one ({@link DataFrameFunctions}, like `read.csv` or `merge`), by a call handing back what it is
|
|
53
|
+
* given (`(` in `d <- (data.frame(a = 1))`), by a copy of a variable holding one (`k <- d`), or by an assignment
|
|
54
|
+
* into a part of one. What each definition and call
|
|
55
|
+
* makes is only worked out once.
|
|
56
|
+
*/
|
|
57
|
+
function dataFrameHolders(graph) {
|
|
58
|
+
/* all of it starts at a call making a data frame, without one nothing holds one */
|
|
59
|
+
if (!graph.verticesOfType(vertex_1.VertexType.FunctionCall).some(([id]) => callsDataFrameFunction(graph, id))) {
|
|
60
|
+
return () => false;
|
|
61
|
+
}
|
|
62
|
+
const holds = (id) => (df_helper_1.Dataflow.origin(graph, id) ?? []).some(origin => (origin.type === 0 /* OriginType.ReadVariableOrigin */ || origin.type === 1 /* OriginType.WriteVariableOrigin */)
|
|
63
|
+
&& defines(origin.id));
|
|
64
|
+
const defines = (0, defaultmap_1.memoize)((definition) => df_helper_1.Dataflow.targetsOf(graph, definition, edge_1.EdgeType.DefinedBy).some(makes), NothingNew);
|
|
65
|
+
const makes = (0, defaultmap_1.memoize)((by) => {
|
|
66
|
+
const vertex = graph.getVertex(by);
|
|
67
|
+
if (vertex_1.DfgVertex.isUse(vertex)) {
|
|
68
|
+
/* a copy, `k <- d`, or what a call hands back, `(d)` */
|
|
69
|
+
return holds(by);
|
|
70
|
+
}
|
|
71
|
+
else if (!vertex_1.DfgVertex.isFunctionCall(vertex)) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
else if (vertex_1.DfgVertex.hasOrigin(vertex, built_in_proc_name_1.BuiltInProcName.Replacement)) {
|
|
75
|
+
const target = graph.idMap?.get(by);
|
|
76
|
+
return r_access_1.RAccess.is(target) && holds(target.accessed.info.id);
|
|
77
|
+
}
|
|
78
|
+
return callsDataFrameFunction(graph, by) || df_helper_1.Dataflow.targetsOf(graph, by, edge_1.EdgeType.Returns).some(makes);
|
|
79
|
+
}, NothingNew);
|
|
80
|
+
return holds;
|
|
81
|
+
}
|
|
82
|
+
/** whether the call is one the data frame shape inference knows to return a data frame, see {@link DataFrameFunctions} */
|
|
83
|
+
function callsDataFrameFunction(graph, call) {
|
|
84
|
+
const qualified = df_helper_1.Dataflow.qualify(call, graph);
|
|
85
|
+
const namespace = qualified === undefined ? undefined : identifier_1.Identifier.getNamespace(qualified);
|
|
86
|
+
return qualified !== undefined && namespace !== undefined && dataframe_semantics_1.DataFrameFunctions.has(`${namespace}::${identifier_1.Identifier.getName(qualified)}`);
|
|
87
|
+
}
|
|
88
|
+
/** data.table's arguments of `[` that group what `j` computes, `dt[, mean(x), by = g]` */
|
|
89
|
+
const GroupingArguments = new Set(['by', 'keyby']);
|
|
90
|
+
/** an entry for a call transforming the data the symbol `target` holds */
|
|
91
|
+
function transformOf(nodeId, functionName, target) {
|
|
92
|
+
const name = identifier_1.Identifier.getName(target.content);
|
|
93
|
+
return { nodeId, functionName, assignedTo: name, inputVariables: [name] };
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* What transforms data by its syntax rather than by a function: data.table's update by reference (`dt[, z := x + 1]`)
|
|
97
|
+
* and grouping (`dt[, mean(x), by = g]`), and an assignment into a part of a data frame, like `d$y <- d$x * 2` or
|
|
98
|
+
* `d[d$x > 1, "z"] <- 0`. The last only where the target is a data frame, see {@link dataFrameHolders}, as `x[1] <- 2`
|
|
99
|
+
* on a vector transforms no data.
|
|
100
|
+
*/
|
|
101
|
+
async function dataFrameParts(data) {
|
|
102
|
+
const [dataflow, ast] = await Promise.all([data.analyzer.dataflow(), data.analyzer.normalize()]);
|
|
103
|
+
/* an update by reference or a grouping */
|
|
104
|
+
const groups = (a) => a !== r_function_call_1.EmptyArgument && ((a.name !== undefined && GroupingArguments.has(identifier_1.Identifier.getName(a.name.content)))
|
|
105
|
+
|| (a.value !== undefined && vertex_1.DfgVertex.hasOrigin(dataflow.graph.getVertex(a.value.info.id), built_in_proc_name_1.BuiltInProcName.TableAssignment)));
|
|
106
|
+
const byTable = [];
|
|
107
|
+
r_project_1.RProject.visitAst(ast.ast, n => {
|
|
108
|
+
if (r_access_1.RAccess.is(n) && n.operator === '[' && r_symbol_1.RSymbol.is(n.accessed) && n.access.some(groups)) {
|
|
109
|
+
/* an update by reference changes the table itself, a grouping yields a new one */
|
|
110
|
+
const updates = n.access.some(a => a !== r_function_call_1.EmptyArgument && a.value !== undefined && vertex_1.DfgVertex.hasOrigin(dataflow.graph.getVertex(a.value.info.id), built_in_proc_name_1.BuiltInProcName.TableAssignment));
|
|
111
|
+
const name = identifier_1.Identifier.getName(n.accessed.content);
|
|
112
|
+
byTable.push({ nodeId: n.info.id, functionName: '[', inputVariables: [name], ...updates ? { assignedTo: name } : {} });
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
const parts = dataflow.graph.verticesOfType(vertex_1.VertexType.FunctionCall)
|
|
116
|
+
.filter(([, call]) => vertex_1.DfgVertex.hasOrigin(call, built_in_proc_name_1.BuiltInProcName.Replacement))
|
|
117
|
+
.flatMap(([id, call]) => {
|
|
118
|
+
const node = ast.idMap.get(id);
|
|
119
|
+
return r_access_1.RAccess.is(node) && r_symbol_1.RSymbol.is(node.accessed) ? [{ id, functionName: call.name, target: node.accessed }] : [];
|
|
120
|
+
}).toArray();
|
|
121
|
+
if (parts.length === 0) {
|
|
122
|
+
return byTable;
|
|
123
|
+
}
|
|
124
|
+
const holds = dataFrameHolders(dataflow.graph);
|
|
125
|
+
return [...byTable, ...parts.filter(p => holds(p.target.info.id)).map(p => transformOf(p.id, p.functionName, p.target))];
|
|
126
|
+
}
|
|
37
127
|
/**
|
|
38
128
|
* The categories flowR searches for by default. The functions of the categories flowR derives from its
|
|
39
129
|
* built-ins follow the ones the analyzer registered, so a configured built-in is searched for and a dropped
|
|
@@ -114,14 +204,19 @@ const dependencyCategoriesOf = (env) => ({
|
|
|
114
204
|
},
|
|
115
205
|
'transform': {
|
|
116
206
|
queryDisplayName: 'Data Transformations',
|
|
117
|
-
functions: (0, transform_functions_1.transformFunctions)(env.builtInIndex)
|
|
207
|
+
functions: (0, transform_functions_1.transformFunctions)(env.builtInIndex),
|
|
208
|
+
additionalAnalysis: async (data, ignoreDefault, _functions, _queryResults, result) => {
|
|
209
|
+
if (!ignoreDefault) {
|
|
210
|
+
result.push(...await dataFrameParts(data));
|
|
211
|
+
}
|
|
212
|
+
}
|
|
118
213
|
},
|
|
119
214
|
'test': {
|
|
120
215
|
queryDisplayName: 'Tests',
|
|
121
216
|
functions: test_functions_1.TestFunctions
|
|
122
217
|
},
|
|
123
218
|
'statistics': {
|
|
124
|
-
queryDisplayName: '
|
|
219
|
+
queryDisplayName: 'Statistics',
|
|
125
220
|
functions: (0, statistics_functions_1.statisticsFunctions)(env.builtInIndex)
|
|
126
221
|
}
|
|
127
222
|
});
|
|
@@ -180,19 +275,29 @@ const functionInfoSchema = joi_1.default.array().items(joi_1.default.object({
|
|
|
180
275
|
exports.DependenciesQueryDefinition = {
|
|
181
276
|
title: 'Dependencies Query',
|
|
182
277
|
executor: dependencies_query_executor_1.executeDependenciesQuery,
|
|
183
|
-
asciiSummarizer: (formatter, analyzer, queryResults, result, queries) => {
|
|
278
|
+
asciiSummarizer: async (formatter, analyzer, queryResults, result, queries) => {
|
|
184
279
|
const out = queryResults;
|
|
185
280
|
result.push((0, query_print_1.queryHeader)('dependencies', formatter, out['.meta'].timing));
|
|
186
281
|
for (const [category, value] of Object.entries(getAllCategories(queries, analyzer.inspectContext()))) {
|
|
187
282
|
printResultSection(value.queryDisplayName ?? category, out[category] ?? [], result, formatter);
|
|
188
283
|
}
|
|
284
|
+
const focus = out['.meta'].focus;
|
|
285
|
+
if (focus !== undefined) {
|
|
286
|
+
const { idMap } = await analyzer.normalize();
|
|
287
|
+
const lines = (0, arrays_1.uniqueArray)(focus.flatMap(id => range_1.SourceRange.getStartLine(idMap.get(id)?.location) ?? [])).sort((a, b) => a - b);
|
|
288
|
+
result.push(` ${(0, ansi_1.bold)('focus', formatter)} ${(0, ansi_1.faint)('the lines taking part:', formatter)} ${lines.join(', ')}`);
|
|
289
|
+
}
|
|
189
290
|
return true;
|
|
190
291
|
},
|
|
292
|
+
fromLine: (0, base_query_format_1.filterLineParser)('dependencies', 'focus'),
|
|
293
|
+
completer: slice_query_parser_1.criteriaQueryCompleter,
|
|
294
|
+
syntax: '@dependencies (<crit>;...) <code | file://path>',
|
|
191
295
|
schema: joi_1.default.object({
|
|
192
296
|
type: joi_1.default.string().valid('dependencies').required().description('The type of the query.'),
|
|
193
297
|
ignoreDefaultFunctions: joi_1.default.boolean().optional().description('Should the set of functions that are detected by default be ignored/skipped? Defaults to false.'),
|
|
194
298
|
...Object.fromEntries(exports.DefaultDependencyCategoryNames.map(c => [`${c}Functions`, functionInfoSchema.description(`The set of ${c} functions to search for.`)])),
|
|
195
299
|
enabledCategories: joi_1.default.array().optional().items(joi_1.default.string()).description('A set of flags that determines what types of dependencies are searched for. If unset, all dependency types are searched for.'),
|
|
300
|
+
focus: joi_1.default.array().items(joi_1.default.string()).optional().description('Focus on the dependencies at these slicing criteria: the result names every node taking part in them in `.meta.focus`.'),
|
|
196
301
|
assumedPackages: joi_1.default.boolean().optional().description('Also report the base packages R attaches on startup (e.g. `stats` for a bare `sd()`) that the code uses but never asks for explicitly, as `library` entries marked `implicit`. `base` is reported too, additionally marked `alwaysAttached`. Defaults to false.'),
|
|
197
302
|
additionalCategories: joi_1.default.object().allow(joi_1.default.object({
|
|
198
303
|
queryDisplayName: joi_1.default.string().description('The display name in the query result.'),
|
|
@@ -29,7 +29,12 @@ export interface FunctionInfo extends FunctionArgInfo {
|
|
|
29
29
|
/** default value for the argument if no binding value is found, please be aware, that categories can define global defaults, these are overwritten by the per-function defaults */
|
|
30
30
|
defaultValue?: string;
|
|
31
31
|
/** the function is not to be counted as a dependency if the argument is missing */
|
|
32
|
-
ignoreIf?: 'arg-missing' | 'mode-only-read' | 'mode-only-write' | 'arg-true' | 'arg-false'
|
|
32
|
+
ignoreIf?: 'arg-missing' | 'mode-only-read' | 'mode-only-write' | 'arg-true' | 'arg-false';
|
|
33
|
+
/**
|
|
34
|
+
* the argument holding the data itself, like `text` in `read.table(text = "a b")`: a call passing it instead of
|
|
35
|
+
* the file reads inline data, reported with the value {@link Constant}
|
|
36
|
+
*/
|
|
37
|
+
inline?: FunctionArgInfo;
|
|
33
38
|
/** additional info on arguments - e.g. for the mode flag */
|
|
34
39
|
additionalArgs?: Record<string, FunctionArgInfo>;
|
|
35
40
|
/** string replacements to apply to resolved values, e.g. `{ '': 'stdin' }` */
|
|
@@ -8,11 +8,11 @@ const other_path_functions_1 = require("./other-path-functions");
|
|
|
8
8
|
const source_functions_1 = require("./source-functions");
|
|
9
9
|
const ReadFunctionsWithMore = [
|
|
10
10
|
{ package: 'base', name: 'parse', argName: 'file', resolveValue: true, ignoreIf: 'arg-missing' },
|
|
11
|
-
{ package: 'utils', name: 'read.table', argIdx: 0, argName: 'file', resolveValue: true,
|
|
12
|
-
{ package: 'utils', name: 'read.csv', argIdx: 0, argName: 'file', resolveValue: true,
|
|
13
|
-
{ package: 'utils', name: 'read.csv2', argIdx: 0, argName: 'file', resolveValue: true,
|
|
14
|
-
{ package: 'utils', name: 'read.delim', argIdx: 0, argName: 'file', resolveValue: true,
|
|
15
|
-
{ package: 'utils', name: 'read.delim2', argIdx: 0, argName: 'file', resolveValue: true,
|
|
11
|
+
{ package: 'utils', name: 'read.table', argIdx: 0, argName: 'file', resolveValue: true, inline: { argName: 'text' } },
|
|
12
|
+
{ package: 'utils', name: 'read.csv', argIdx: 0, argName: 'file', resolveValue: true, inline: { argName: 'text' } },
|
|
13
|
+
{ package: 'utils', name: 'read.csv2', argIdx: 0, argName: 'file', resolveValue: true, inline: { argName: 'text' } },
|
|
14
|
+
{ package: 'utils', name: 'read.delim', argIdx: 0, argName: 'file', resolveValue: true, inline: { argName: 'text' } },
|
|
15
|
+
{ package: 'utils', name: 'read.delim2', argIdx: 0, argName: 'file', resolveValue: true, inline: { argName: 'text' } },
|
|
16
16
|
{ package: 'base', name: 'file', argIdx: 0, argName: 'description', resolveValue: true, ignoreIf: 'mode-only-write', additionalArgs: { mode: { argIdx: 1, argName: 'open', resolveValue: true } } },
|
|
17
17
|
{ package: 'base', name: 'url', argIdx: 0, argName: 'description', resolveValue: true, ignoreIf: 'mode-only-write', additionalArgs: { mode: { argIdx: 1, argName: 'open', resolveValue: true } } },
|
|
18
18
|
{ package: 'base', name: 'gzfile', argIdx: 0, argName: 'description', resolveValue: true, ignoreIf: 'mode-only-write', additionalArgs: { mode: { argIdx: 1, argName: 'open', resolveValue: true } } },
|
|
@@ -41,7 +41,7 @@ const ReadFunctionsWithMore = [
|
|
|
41
41
|
{ package: 'rpolars', name: 'pl_scan_parquet', argIdx: 0, argName: 'source', resolveValue: true, ignoreIf: 'arg-missing' },
|
|
42
42
|
{ package: 'compiler', name: 'loadcmp', argIdx: 0, argName: 'file', resolveValue: true },
|
|
43
43
|
{ package: 'compiler', name: 'cmpfile', argIdx: 0, argName: 'infile', resolveValue: true, invisible: true },
|
|
44
|
-
{ package: 'yaml', name: 'read_yaml', argIdx: 0, argName: 'file', resolveValue: true,
|
|
44
|
+
{ package: 'yaml', name: 'read_yaml', argIdx: 0, argName: 'file', resolveValue: true, inline: { argName: 'text' } },
|
|
45
45
|
{ package: 'shinyjs', name: 'extendShinyjs', argIdx: 0, argName: 'script', resolveValue: true, ignoreIf: 'arg-missing' }
|
|
46
46
|
];
|
|
47
47
|
/** The read entries the given built-in definitions imply, together with the ones written down here. */
|
|
@@ -31,15 +31,21 @@ const WriteFunctionsWithMore = [
|
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
// write functions that don't have argIndex are assumed to write to stdout
|
|
34
|
-
|
|
34
|
+
/* a print method may write to a file instead, like `print(xtable(d), file = "t.tex")` */
|
|
35
|
+
{ package: 'base', name: 'print', linkTo: OutputRedirects, argName: 'file', resolveValue: true },
|
|
35
36
|
{ package: 'graphics', name: 'stem', linkTo: OutputRedirects, resolveValue: false },
|
|
36
37
|
{ package: 'base', name: 'cat', linkTo: OutputRedirects, argName: 'file', resolveValue: true },
|
|
37
|
-
|
|
38
|
-
{ package: 'base', name: '
|
|
39
|
-
{ package: '
|
|
40
|
-
{ package: 'rlang', name: '
|
|
41
|
-
{ package: '
|
|
42
|
-
{ package: 'cli', name: '
|
|
38
|
+
/* conditions and messages go to the message stream, which is stderr */
|
|
39
|
+
{ package: 'base', name: 'message', linkTo: OutputRedirects, resolveValue: false, defaultValue: 'stderr' },
|
|
40
|
+
{ package: 'base', name: 'warning', linkTo: OutputRedirects, resolveValue: false, defaultValue: 'stderr' },
|
|
41
|
+
{ package: 'rlang', name: 'warn', linkTo: OutputRedirects, resolveValue: false, defaultValue: 'stderr' },
|
|
42
|
+
{ package: 'rlang', name: 'inform', linkTo: OutputRedirects, resolveValue: false, defaultValue: 'stderr' },
|
|
43
|
+
{ package: 'cli', name: 'cli_warn', linkTo: OutputRedirects, resolveValue: false, defaultValue: 'stderr' },
|
|
44
|
+
{ package: 'cli', name: 'cli_abort', linkTo: OutputRedirects, resolveValue: false, defaultValue: 'stderr' },
|
|
45
|
+
/* `output = "default"` shows the table where R prints */
|
|
46
|
+
{ package: 'modelsummary', name: 'modelsummary', argIdx: 1, argName: 'output', resolveValue: true, stringReplacements: { default: 'stdout' } },
|
|
47
|
+
{ package: 'modelsummary', name: 'msummary', argIdx: 1, argName: 'output', resolveValue: true, stringReplacements: { default: 'stdout' } },
|
|
48
|
+
{ package: 'modelsummary', name: 'datasummary', argIdx: 2, argName: 'output', resolveValue: true, stringReplacements: { default: 'stdout' } },
|
|
43
49
|
{ package: 'base', name: 'file.create', argIdx: 'unnamed', resolveValue: true },
|
|
44
50
|
{ package: 'base', name: 'file.copy', argIdx: 1, argName: 'to', resolveValue: true },
|
|
45
51
|
{ package: 'base', name: 'file.rename', argIdx: 1, argName: 'to', resolveValue: true },
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.collectImplicitEchoes = collectImplicitEchoes;
|
|
4
|
+
const r_function_call_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
4
5
|
const function_semantics_1 = require("../../../dataflow/fn/function-semantics");
|
|
5
6
|
const identifier_1 = require("../../../dataflow/environments/identifier");
|
|
6
7
|
const model_1 = require("../../../r-bridge/lang-4.x/ast/model/model");
|
|
7
8
|
const type_1 = require("../../../r-bridge/lang-4.x/ast/model/type");
|
|
9
|
+
const vertex_1 = require("../../../dataflow/graph/vertex");
|
|
10
|
+
const built_in_proc_name_1 = require("../../../dataflow/environments/built-in-proc-name");
|
|
8
11
|
const r_expression_list_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-expression-list");
|
|
9
12
|
const r_binary_op_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-binary-op");
|
|
10
|
-
const r_function_call_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
11
13
|
const r_argument_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
|
|
12
14
|
const r_comment_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-comment");
|
|
13
15
|
const r_line_directive_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-line-directive");
|
|
@@ -20,6 +22,10 @@ const data_flow_1 = require("./data-flow");
|
|
|
20
22
|
const test_functions_1 = require("./function-info/test-functions");
|
|
21
23
|
/** the node whose value R echoes for a statement, `undefined` if the statement yields nothing visible */
|
|
22
24
|
function echoedValue(node, dataflow, invisible, seen = new Set()) {
|
|
25
|
+
/* an assignment returns its value invisibly: `x <- 1`, `names(x) <- v` and `assign("x", 1)` print nothing */
|
|
26
|
+
if (isAssignment(node, dataflow)) {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
23
29
|
switch (node?.type) {
|
|
24
30
|
/* the loops hand back an invisible NULL, and the jumps never hand back anything at all */
|
|
25
31
|
case undefined:
|
|
@@ -48,13 +54,20 @@ function echoedValue(node, dataflow, invisible, seen = new Set()) {
|
|
|
48
54
|
/* whichever branch runs decides; without an `else` a false condition yields an invisible NULL */
|
|
49
55
|
case type_1.RType.IfThenElse:
|
|
50
56
|
return echoedValue(node.then, dataflow, invisible, seen) ?? echoedValue(node.otherwise, dataflow, invisible, seen);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
57
|
+
/* an update by reference, like `d[, z := x + 1]` with data.table, prints nothing although R calls it visible */
|
|
58
|
+
case type_1.RType.Access:
|
|
59
|
+
return node.access.some(a => a !== r_function_call_1.EmptyArgument && isAssignment(a.value, dataflow)) ? undefined : node;
|
|
60
|
+
/* a symbol, a constant, an operator, or a function definition is printed as it stands */
|
|
54
61
|
default:
|
|
55
62
|
return node;
|
|
56
63
|
}
|
|
57
64
|
}
|
|
65
|
+
/** the processors of assignments; the vertex of a replacement like `x$a <- 1` sits on its target `x` */
|
|
66
|
+
const Assigning = [built_in_proc_name_1.BuiltInProcName.Assignment, built_in_proc_name_1.BuiltInProcName.SuperAssignment, built_in_proc_name_1.BuiltInProcName.Replacement, built_in_proc_name_1.BuiltInProcName.TableAssignment];
|
|
67
|
+
function isAssignment(node, dataflow) {
|
|
68
|
+
const vertex = node === undefined ? undefined : dataflow.graph.getVertex(node.info.id);
|
|
69
|
+
return (r_binary_op_1.RBinaryOp.is(node) && r_binary_op_1.RBinaryOp.getOperatorInfo(node)?.usedAs === 'assignment') || Assigning.some(p => vertex_1.DfgVertex.hasOrigin(vertex, p));
|
|
70
|
+
}
|
|
58
71
|
/** whether the list is a `( )` group rather than a `{ }` block, which is what makes its value visible */
|
|
59
72
|
function grouped(node) {
|
|
60
73
|
return node.grouping?.[0].content === '(';
|
|
@@ -69,8 +82,8 @@ function aliased(node, dataflow, invisible) {
|
|
|
69
82
|
?.findIndex(([, p]) => (p & built_in_props_1.ArgProp.Alias) !== 0) ?? -1;
|
|
70
83
|
const arg = at < 0 ? undefined : node.arguments[at];
|
|
71
84
|
const value = typeof arg === 'object' && r_argument_1.RArgument.is(arg) ? arg.value : undefined;
|
|
72
|
-
/* only a call
|
|
73
|
-
return r_function_call_1.RFunctionCall.is(value) || r_expression_list_1.RExpressionList.is(value) ? value : undefined;
|
|
85
|
+
/* only a call, a block or an assignment can make a result invisible: `return(x <- 1)` prints nothing, `return(x)` does */
|
|
86
|
+
return r_function_call_1.RFunctionCall.is(value) || r_expression_list_1.RExpressionList.is(value) || isAssignment(value, dataflow) ? value : undefined;
|
|
74
87
|
}
|
|
75
88
|
/** the last statement of a block, which is what its value comes from */
|
|
76
89
|
function lastStatement(node) {
|
|
@@ -116,8 +129,9 @@ function isInvisible(name, invisible) {
|
|
|
116
129
|
/** what to report the echo under: the called name, or the operator or lexeme producing the value */
|
|
117
130
|
function echoName(node, dataflow) {
|
|
118
131
|
switch (node.type) {
|
|
132
|
+
/* a call without a name, like `o$bump()`, is named by the code it calls, `o$bump`, as its id changes with any edit */
|
|
119
133
|
case type_1.RType.FunctionCall:
|
|
120
|
-
return (0, plot_objects_1.callIdentifierOf)(node, dataflow) ?? '';
|
|
134
|
+
return node.named ? (0, plot_objects_1.callIdentifierOf)(node, dataflow) ?? '' : model_1.RNode.lexeme(node.calledFunction) ?? '';
|
|
121
135
|
case type_1.RType.BinaryOp:
|
|
122
136
|
case type_1.RType.UnaryOp:
|
|
123
137
|
case type_1.RType.Access:
|