@eagleoutice/flowr 2.14.0 → 2.14.2
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 +169 -91
- package/abstract-interpretation/absint-visitor.d.ts +91 -25
- package/abstract-interpretation/absint-visitor.js +235 -74
- package/abstract-interpretation/data-frame/mappers/access-mapper.d.ts +1 -1
- package/abstract-interpretation/data-frame/mappers/access-mapper.js +4 -4
- package/abstract-interpretation/data-frame/mappers/arguments.d.ts +1 -1
- package/abstract-interpretation/data-frame/mappers/arguments.js +1 -1
- package/abstract-interpretation/data-frame/mappers/function-mapper.js +107 -254
- package/abstract-interpretation/data-frame/mappers/replacement-mapper.js +5 -5
- package/abstract-interpretation/data-frame/resolve-args.d.ts +1 -1
- package/abstract-interpretation/data-frame/resolve-args.js +6 -4
- package/abstract-interpretation/data-frame/shape-inference.d.ts +4 -9
- package/abstract-interpretation/domains/bounded-set-domain.d.ts +1 -0
- package/abstract-interpretation/domains/bounded-set-domain.js +1 -0
- package/abstract-interpretation/domains/partial-product-domain.js +1 -1
- package/abstract-interpretation/domains/set-range-domain.d.ts +3 -2
- package/abstract-interpretation/domains/set-range-domain.js +3 -2
- package/abstract-interpretation/domains/set-upper-bound-domain.d.ts +3 -2
- package/abstract-interpretation/domains/set-upper-bound-domain.js +3 -2
- package/benchmark/calibration.d.ts +18 -11
- package/benchmark/calibration.js +37 -27
- package/benchmark/slicer.d.ts +9 -2
- package/benchmark/slicer.js +44 -37
- package/benchmark/stats/count-comments.d.ts +16 -0
- package/benchmark/stats/count-comments.js +30 -0
- package/benchmark/stats/print.js +2 -0
- package/benchmark/stats/size-of.d.ts +7 -3
- package/benchmark/stats/size-of.js +7 -3
- package/benchmark/stats/stats.d.ts +7 -0
- package/benchmark/summarizer/first-phase/process.js +2 -19
- package/benchmark/summarizer/second-phase/graph.js +13 -3
- package/benchmark/summarizer/second-phase/process.js +2 -0
- package/cli/benchmark-app.js +4 -1
- package/cli/benchmark-helper-app.d.ts +1 -0
- package/cli/benchmark-helper-app.js +2 -2
- package/cli/common/options.d.ts +5 -0
- package/cli/common/options.js +1 -0
- package/cli/common/scripts-info.d.ts +5 -0
- package/cli/repl/commands/repl-dataflow.js +70 -27
- package/cli/repl/core.d.ts +1 -1
- package/cli/repl/core.js +1 -1
- package/cli/repl/execute.d.ts +2 -2
- package/cli/repl/execute.js +2 -2
- package/cli/repl/parser/slice-query-parser.js +2 -1
- package/cli/repl/server/connection.d.ts +4 -0
- package/cli/repl/server/connection.js +19 -16
- package/cli/repl/server/messages/message-analysis.d.ts +1 -1
- package/config.d.ts +6 -0
- package/config.js +12 -9
- package/control-flow/basic-cfg-guided-visitor.d.ts +7 -2
- package/control-flow/basic-cfg-guided-visitor.js +37 -24
- package/control-flow/cfg-dead-code.js +44 -33
- package/control-flow/cfg-properties.js +2 -2
- package/control-flow/cfg-simplification.js +6 -5
- package/control-flow/cfg-to-basic-blocks.js +11 -13
- package/control-flow/control-flow-graph.d.ts +179 -189
- package/control-flow/control-flow-graph.js +400 -263
- package/control-flow/dfg-cfg-guided-visitor.d.ts +21 -3
- package/control-flow/dfg-cfg-guided-visitor.js +17 -13
- package/control-flow/diff-cfg.js +6 -14
- package/control-flow/happens-before.js +5 -4
- package/control-flow/semantic-cfg-guided-visitor.d.ts +44 -101
- package/control-flow/semantic-cfg-guided-visitor.js +6 -26
- package/control-flow/simple-visitor.js +14 -15
- package/control-flow/syntax-cfg-guided-visitor.d.ts +2 -1
- package/control-flow/useless-loop.js +18 -14
- package/core/steps/all/core/20-dataflow.d.ts +1 -3
- package/core/steps/pipeline/default-pipelines.d.ts +141 -157
- package/dataflow/cluster.js +7 -0
- package/dataflow/environments/apply-kill.d.ts +6 -0
- package/dataflow/environments/apply-kill.js +64 -32
- package/dataflow/environments/built-in-props.d.ts +10 -2
- package/dataflow/environments/built-in-props.js +9 -1
- package/dataflow/environments/built-in.d.ts +6 -3
- package/dataflow/environments/built-in.js +8 -5
- package/dataflow/environments/clone.d.ts +3 -3
- package/dataflow/environments/clone.js +5 -5
- package/dataflow/environments/default-builtin-config.d.ts +188 -8
- package/dataflow/environments/default-builtin-config.js +112 -39
- package/dataflow/environments/environment.d.ts +9 -1
- package/dataflow/environments/environment.js +25 -7
- package/dataflow/environments/identifier.d.ts +12 -1
- package/dataflow/environments/identifier.js +4 -1
- package/dataflow/environments/query-fn-props.d.ts +6 -0
- package/dataflow/environments/query-fn-props.js +20 -0
- package/dataflow/environments/resolve-by-name.d.ts +7 -0
- package/dataflow/environments/resolve-by-name.js +26 -2
- package/dataflow/environments/resolve-helper.d.ts +3 -1
- package/dataflow/environments/resolve-helper.js +2 -0
- package/dataflow/eval/resolve/alias-tracking.d.ts +2 -2
- package/dataflow/eval/resolve/alias-tracking.js +2 -2
- package/dataflow/eval/resolve/match-arguments.js +7 -5
- package/dataflow/eval/resolve/node-value.d.ts +3 -1
- package/dataflow/eval/resolve/node-value.js +12 -0
- package/dataflow/eval/resolve/resolve-argument.js +5 -4
- package/dataflow/eval/resolve/resolve-operators.js +10 -7
- package/dataflow/eval/resolve/resolve-strings.js +2 -2
- package/dataflow/eval/resolve/resolve-working-directory.d.ts +1 -1
- package/dataflow/eval/resolve/resolve-working-directory.js +5 -5
- package/dataflow/eval/resolve/resolve.js +3 -2
- package/dataflow/eval/values/general.js +8 -5
- package/dataflow/extractor.d.ts +1 -4
- package/dataflow/extractor.js +11 -10
- package/dataflow/fn/exceptions-of-function.d.ts +6 -2
- package/dataflow/fn/exceptions-of-function.js +85 -38
- package/dataflow/fn/strict-function.d.ts +40 -0
- package/dataflow/fn/strict-function.js +339 -0
- package/dataflow/graph/call-graph.js +2 -2
- package/dataflow/graph/df-helper.d.ts +17 -2
- package/dataflow/graph/df-helper.js +19 -3
- package/dataflow/graph/diff-dataflow-graph.d.ts +1 -1
- package/dataflow/graph/diff-dataflow-graph.js +19 -2
- package/dataflow/graph/edge.d.ts +38 -2
- package/dataflow/graph/edge.js +32 -2
- package/dataflow/graph/graph.d.ts +32 -5
- package/dataflow/graph/graph.js +65 -4
- package/dataflow/graph/match-args.d.ts +69 -0
- package/dataflow/graph/match-args.js +167 -0
- package/dataflow/info.d.ts +40 -0
- package/dataflow/info.js +28 -1
- package/dataflow/internal/control-flow.d.ts +102 -0
- package/dataflow/internal/control-flow.js +200 -0
- package/dataflow/internal/linker.d.ts +6 -31
- package/dataflow/internal/linker.js +24 -81
- package/dataflow/internal/process/functions/call/argument/unpack-argument.d.ts +1 -1
- package/dataflow/internal/process/functions/call/argument/unpack-argument.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-access.d.ts +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +9 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +6 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +1 -10
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +18 -37
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +11 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +6 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +18 -14
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +8 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +11 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +27 -20
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +3 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +35 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +20 -17
- package/dataflow/internal/process/functions/call/built-in/built-in-list.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-list.js +6 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-load.js +4 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-local.js +8 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-namespace-access.d.ts +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-namespace-access.js +5 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-new-env.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-new-env.js +5 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +7 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.js +15 -13
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-recall.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.js +4 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +26 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.d.ts +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +17 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.d.ts +3 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +97 -33
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +6 -15
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +12 -13
- package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +15 -12
- package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.js +15 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +12 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-stop-if-not.js +6 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-string-template.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-string-template.js +5 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +45 -10
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.d.ts +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +19 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +6 -2
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +29 -8
- package/dataflow/internal/process/functions/call/common.js +5 -6
- package/dataflow/internal/process/functions/call/deferred.js +2 -2
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +12 -2
- package/dataflow/internal/process/functions/call/known-call-handling.js +23 -1
- package/dataflow/internal/process/functions/call/named-call-handling.js +2 -0
- package/dataflow/internal/process/functions/call/nse.d.ts +1 -1
- package/dataflow/internal/process/functions/call/nse.js +6 -1
- package/dataflow/internal/process/functions/call/quoted.js +2 -2
- package/dataflow/internal/process/functions/call/unnamed-call-handling.js +19 -6
- package/dataflow/internal/process/functions/process-argument.d.ts +1 -1
- package/dataflow/internal/process/functions/process-argument.js +12 -4
- package/dataflow/internal/process/functions/process-parameter.js +13 -0
- package/dataflow/internal/process/process-named-call.d.ts +2 -2
- package/dataflow/internal/process/process-named-call.js +9 -7
- package/documentation/data/server/doc-data-server-messages.js +4 -4
- package/documentation/doc-readme.js +45 -0
- package/documentation/doc-util/doc-cfg.d.ts +8 -7
- package/documentation/doc-util/doc-cfg.js +10 -10
- package/documentation/doc-util/doc-playground.d.ts +12 -0
- package/documentation/doc-util/doc-playground.js +21 -0
- package/documentation/doc-util/doc-query.d.ts +4 -1
- package/documentation/doc-util/doc-query.js +4 -2
- package/documentation/wiki-absint.d.ts +3 -4
- package/documentation/wiki-absint.js +12 -5
- package/documentation/wiki-analyzer.js +2 -2
- package/documentation/wiki-cfg.js +101 -106
- package/documentation/wiki-core.js +1 -1
- package/documentation/wiki-dataflow-graph.js +85 -53
- package/documentation/wiki-linter.js +16 -1
- package/documentation/wiki-linting-and-testing.js +1 -16
- package/documentation/wiki-mk/doc-maker.js +6 -4
- package/documentation/wiki-query.js +67 -4
- package/documentation/wiki-signature-database.js +28 -2
- package/linter/linter-fix.d.ts +16 -0
- package/linter/linter-fix.js +104 -0
- package/linter/linter-format.d.ts +18 -1
- package/linter/linter-format.js +31 -1
- package/linter/linter-output.js +47 -11
- package/linter/linter-rules.d.ts +64 -9
- package/linter/linter-rules.js +5 -1
- package/linter/rules/absolute-path.js +4 -2
- package/linter/rules/dataframe-access-validation.js +6 -7
- package/linter/rules/deprecated-functions.d.ts +107 -10
- package/linter/rules/deprecated-functions.js +309 -23
- package/linter/rules/file-path-validity.js +5 -4
- package/linter/rules/function-finder-util.d.ts +6 -0
- package/linter/rules/function-finder-util.js +21 -13
- package/linter/rules/naming-convention.js +1 -1
- package/linter/rules/network-functions.d.ts +3 -3
- package/linter/rules/stop-with-call-arg.js +2 -2
- package/linter/rules/unclosed-connection.d.ts +44 -0
- package/linter/rules/unclosed-connection.js +200 -0
- package/linter/rules/undefined-symbol-util.js +6 -4
- package/linter/rules/undefined-symbol.js +2 -2
- package/linter/rules/unused-definition.js +8 -4
- package/linter/rules/unused-import.d.ts +60 -0
- package/linter/rules/unused-import.js +179 -0
- package/package.json +5 -8
- package/project/attached-packages.js +2 -1
- package/project/cache/flowr-analyzer-cache.d.ts +2 -5
- package/project/cache/flowr-analyzer-cache.js +4 -7
- package/project/cache/flowr-analyzer-controlflow-cache.d.ts +9 -8
- package/project/cache/flowr-analyzer-controlflow-cache.js +17 -34
- package/project/cache/flowr-cache.d.ts +9 -0
- package/project/cache/flowr-cache.js +19 -0
- package/project/context/flowr-analyzer-context.d.ts +7 -3
- package/project/context/flowr-analyzer-context.js +15 -9
- package/project/context/flowr-analyzer-dependencies-context.d.ts +24 -3
- package/project/context/flowr-analyzer-dependencies-context.js +9 -14
- package/project/context/flowr-analyzer-files-context.js +15 -17
- package/project/context/flowr-analyzer-meta-context.js +2 -12
- package/project/dependency-version-space.d.ts +3 -10
- package/project/dependency-version-space.js +10 -9
- package/project/flowr-analyzer.d.ts +4 -6
- package/project/flowr-analyzer.js +4 -5
- package/project/plugins/file-plugins/files/flowr-description-file.d.ts +1 -1
- package/project/plugins/file-plugins/files/flowr-description-file.js +1 -1
- package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +1 -1
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +23 -35
- package/project/plugins/file-plugins/files/flowr-news-file.d.ts +1 -1
- package/project/plugins/file-plugins/files/flowr-news-file.js +1 -1
- package/project/plugins/file-plugins/files/flowr-rda-file.d.ts +13 -13
- package/project/plugins/file-plugins/files/flowr-rda-file.js +131 -286
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +1 -0
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +1 -0
- package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.d.ts +2 -5
- package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.js +2 -8
- package/project/plugins/file-plugins/flowr-analyzer-file-plugin.d.ts +32 -0
- package/project/plugins/file-plugins/flowr-analyzer-file-plugin.js +43 -1
- package/project/plugins/file-plugins/flowr-analyzer-inst-file-plugin.d.ts +4 -12
- package/project/plugins/file-plugins/flowr-analyzer-inst-file-plugin.js +3 -16
- package/project/plugins/file-plugins/flowr-analyzer-license-file-plugin.d.ts +5 -8
- package/project/plugins/file-plugins/flowr-analyzer-license-file-plugin.js +4 -10
- package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.d.ts +3 -10
- package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.js +1 -13
- package/project/plugins/file-plugins/flowr-analyzer-namespace-files-plugin.d.ts +3 -6
- package/project/plugins/file-plugins/flowr-analyzer-namespace-files-plugin.js +2 -8
- package/project/plugins/file-plugins/flowr-analyzer-news-file-plugin.d.ts +2 -5
- package/project/plugins/file-plugins/flowr-analyzer-news-file-plugin.js +2 -8
- package/project/plugins/file-plugins/flowr-analyzer-rda-file-plugin.d.ts +2 -5
- package/project/plugins/file-plugins/flowr-analyzer-rda-file-plugin.js +2 -8
- package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.d.ts +3 -4
- package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.js +3 -6
- package/project/plugins/file-plugins/flowr-analyzer-test-file-plugin.d.ts +4 -12
- package/project/plugins/file-plugins/flowr-analyzer-test-file-plugin.js +3 -16
- package/project/plugins/file-plugins/flowr-analyzer-vignette-file-plugin.d.ts +4 -12
- package/project/plugins/file-plugins/flowr-analyzer-vignette-file-plugin.js +3 -16
- package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.d.ts +4 -12
- package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.js +3 -16
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-jupyter-file-plugin.d.ts +2 -5
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-jupyter-file-plugin.js +2 -8
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmarkdown-file-plugin.d.ts +2 -6
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmarkdown-file-plugin.js +1 -10
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-sweave-file-plugin.d.ts +2 -5
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-sweave-file-plugin.js +2 -8
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-library-plugin.js +2 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +5 -5
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +33 -6
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +2 -2
- package/project/sigdb/build.d.ts +2 -2
- package/project/sigdb/decode.d.ts +0 -5
- package/project/sigdb/decode.js +0 -8
- package/project/sigdb/index-format.d.ts +4 -4
- package/project/sigdb/manifest.d.ts +5 -3
- package/project/sigdb/manifest.js +50 -9
- package/project/sigdb/reader.d.ts +48 -13
- package/project/sigdb/reader.js +3 -2
- package/project/sigdb/schema.d.ts +5 -3
- package/project/sigdb/schema.js +2 -2
- package/project/sigdb/signature-db.d.ts +69 -0
- package/project/sigdb/signature-db.js +54 -0
- package/project/sigdb/signature-match.d.ts +10 -5
- package/project/sigdb/signature-match.js +13 -8
- package/queries/catalog/absint-query/absint-query-executor.js +1 -2
- package/queries/catalog/call-context-query/call-context-query-executor.js +2 -4
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.d.ts +1 -1
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +33 -6
- package/queries/catalog/control-flow-query/control-flow-query-executor.js +1 -2
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +2 -2
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +8 -7
- package/queries/catalog/dependencies-query/dependencies-query-format.js +22 -35
- package/queries/catalog/dependencies-query/function-info/library-functions.d.ts +13 -1
- package/queries/catalog/dependencies-query/function-info/library-functions.js +26 -22
- package/queries/catalog/dependencies-query/function-info/statistics-functions.d.ts +9 -0
- package/queries/catalog/dependencies-query/function-info/statistics-functions.js +19 -0
- package/queries/catalog/dependencies-query/implicit-echo.d.ts +13 -0
- package/queries/catalog/dependencies-query/implicit-echo.js +133 -0
- package/queries/catalog/dependencies-query/link-devices.js +2 -8
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +2 -2
- package/queries/catalog/happens-before-query/happens-before-query-executor.js +1 -2
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.js +2 -1
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.d.ts +2 -2
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +1 -0
- package/queries/catalog/inspect-strictness-query/inspect-strictness-query-executor.d.ts +6 -0
- package/queries/catalog/inspect-strictness-query/inspect-strictness-query-executor.js +25 -0
- package/queries/catalog/inspect-strictness-query/inspect-strictness-query-format.d.ts +31 -0
- package/queries/catalog/inspect-strictness-query/inspect-strictness-query-format.js +56 -0
- package/queries/catalog/signature-query/signature-query-executor.js +4 -3
- package/queries/catalog/slice-query-options.d.ts +1 -1
- package/queries/catalog/slice-query-options.js +1 -1
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +1 -1
- package/queries/query-function-filter.d.ts +8 -2
- package/queries/query-function-filter.js +11 -1
- package/queries/query.d.ts +11 -1
- package/queries/query.js +2 -0
- package/r-bridge/lang-4.x/ast/model/model.d.ts +4 -4
- package/r-bridge/lang-4.x/ast/model/model.js +4 -4
- package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +4 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.js +5 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-break.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +6 -4
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +6 -4
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-logical.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-next.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +6 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-number.js +13 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-project.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-project.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.js +1 -0
- package/r-bridge/lang-4.x/ast/model/processing/decorate.js +2 -1
- package/r-bridge/lang-4.x/ast/model/processing/stateful-fold.d.ts +1 -1
- package/r-bridge/lang-4.x/ast/model/processing/stateful-fold.js +3 -2
- package/r-bridge/lang-4.x/ast/parser/main/internal/control/normalize-if-then-else.js +2 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/control/normalize-if-then.js +2 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/expression/normalize-expression.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-argument.js +2 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.d.ts +2 -2
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.js +6 -3
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-definition.js +2 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-parameter.js +2 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-for.js +5 -3
- package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-repeat.js +2 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-while.js +2 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/normalize-access.js +2 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-binary.js +5 -3
- package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-unary.js +2 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-expressions.d.ts +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-expressions.js +2 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-root.js +3 -1
- package/r-bridge/lang-4.x/ast/parser/main/normalize-meta.d.ts +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/normalize-meta.js +2 -1
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +5 -3
- package/reconstruct/inline/source-inline-map.js +3 -3
- package/reconstruct/reconstruct.js +6 -4
- package/search/flowr-search-builder.d.ts +8 -8
- package/search/flowr-search-builder.js +4 -4
- package/search/flowr-search-filters.d.ts +2 -2
- package/search/flowr-search-filters.js +4 -15
- package/search/search-executor/search-enrichers.d.ts +6 -4
- package/search/search-executor/search-enrichers.js +44 -5
- package/slicing/criterion/filters/all-variables.js +2 -1
- package/slicing/criterion/parse.d.ts +2 -2
- package/slicing/criterion/parse.js +10 -8
- package/slicing/static/fingerprint.js +1 -1
- package/slicing/static/slice-call.js +2 -2
- package/util/arg-matching.d.ts +3 -0
- package/util/arg-matching.js +12 -1
- package/util/collections/arrays.d.ts +0 -4
- package/util/collections/arrays.js +4 -26
- package/util/diff-graph.d.ts +1 -1
- package/util/diff-graph.js +17 -3
- package/util/diff.d.ts +6 -0
- package/util/mermaid/ast.d.ts +1 -1
- package/util/mermaid/ast.js +5 -4
- package/util/mermaid/cfg.js +130 -24
- package/util/mermaid/dfg.js +31 -10
- package/util/mermaid/mermaid.js +2 -0
- package/util/objects.d.ts +21 -0
- package/util/objects.js +60 -0
- package/util/prefix.d.ts +1 -1
- package/util/simple-df/dfg-ascii.js +14 -3
- package/util/text/name-rank.d.ts +1 -1
- package/util/text/name-rank.js +1 -1
- package/util/text/playground-link.d.ts +131 -0
- package/util/text/playground-link.js +214 -0
- package/util/text/strings.js +7 -3
- package/util/version.js +1 -1
- package/control-flow/cfg-builder.d.ts +0 -30
- package/control-flow/cfg-builder.js +0 -79
- package/control-flow/extract-cfg.d.ts +0 -36
- package/control-flow/extract-cfg.js +0 -693
- package/project/cfg-kind.d.ts +0 -21
- package/project/cfg-kind.js +0 -26
|
@@ -25,15 +25,14 @@ const doc_code_1 = require("./doc-util/doc-code");
|
|
|
25
25
|
const path_1 = __importDefault(require("path"));
|
|
26
26
|
const doc_general_1 = require("./doc-util/doc-general");
|
|
27
27
|
const node_id_1 = require("../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
28
|
+
const control_flow_graph_1 = require("../control-flow/control-flow-graph");
|
|
28
29
|
const identifier_1 = require("../dataflow/environments/identifier");
|
|
29
30
|
const r_function_call_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
30
31
|
const default_pipelines_1 = require("../core/steps/pipeline/default-pipelines");
|
|
31
|
-
const text_1 = require("../util/text/text");
|
|
32
32
|
const linker_1 = require("../dataflow/internal/linker");
|
|
33
33
|
const apply_kill_1 = require("../dataflow/environments/apply-kill");
|
|
34
34
|
const doc_normalized_ast_1 = require("./doc-util/doc-normalized-ast");
|
|
35
35
|
const identify_link_to_last_call_relation_1 = require("../queries/catalog/call-context-query/identify-link-to-last-call-relation");
|
|
36
|
-
const alias_tracking_1 = require("../dataflow/eval/resolve/alias-tracking");
|
|
37
36
|
const doc_issue_1 = require("./doc-util/doc-issue");
|
|
38
37
|
const unnamed_call_handling_1 = require("../dataflow/internal/process/functions/call/unnamed-call-handling");
|
|
39
38
|
const environment_builder_1 = require("../../test/functionality/_helper/dataflow/environment-builder");
|
|
@@ -48,8 +47,10 @@ const model_1 = require("../r-bridge/lang-4.x/ast/model/model");
|
|
|
48
47
|
const range_1 = require("../util/range");
|
|
49
48
|
const df_helper_1 = require("../dataflow/graph/df-helper");
|
|
50
49
|
const resolve_helper_1 = require("../dataflow/environments/resolve-helper");
|
|
50
|
+
const match_args_1 = require("../dataflow/graph/match-args");
|
|
51
51
|
const built_in_proc_name_1 = require("../dataflow/environments/built-in-proc-name");
|
|
52
52
|
const vertex_2 = require("../dataflow/graph/vertex");
|
|
53
|
+
const objects_1 = require("../util/objects");
|
|
53
54
|
async function subExplanation(parser, ctx, { description, code, expectedSubgraph }) {
|
|
54
55
|
expectedSubgraph = await (0, doc_dfg_1.verifyExpectedSubgraph)(parser, code, expectedSubgraph);
|
|
55
56
|
const marks = [];
|
|
@@ -147,7 +148,7 @@ The name of the symbol is not actually part of what we store in the dataflow gra
|
|
|
147
148
|
as we have it within the normalized AST.
|
|
148
149
|
To access the name, you can use the \`id\` of the vertex:
|
|
149
150
|
|
|
150
|
-
${(0, doc_code_1.codeBlock)('ts',
|
|
151
|
+
${(0, doc_code_1.codeBlock)('ts', 'const name = RNode.lexeme(graph.idMap?.get(id));')}
|
|
151
152
|
`
|
|
152
153
|
})}
|
|
153
154
|
|
|
@@ -194,6 +195,7 @@ In general the vertex provides you with information about
|
|
|
194
195
|
the _name_ of the called function, the passed _arguments_, and the _environment_ in which the call happens (if it is of importance).
|
|
195
196
|
|
|
196
197
|
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, prefer ${ctx.linkO(df_helper_1.Dataflow, 'qualify')} which, given only a call's id and its graph, reconstructs the \`pkg::fn\` identifier from the origins (and, for base R, from the exporting package) — the compact form of \`Identifier.toQualified\` (see the \`origin\` property below and the ${ctx.linkPage('wiki/Signature Database', 'signature database')} for where the base-R knowledge comes from).
|
|
198
|
+
The graph caches what it resolved, with and without the base-R step, and drops the cache whenever it changes, so asking twice costs a map lookup. If you want the qualified name of every call, use ${ctx.linkO(df_helper_1.Dataflow, 'qualifyAll')}: it walks the call vertices once and pays the (expensive) origin resolution once per call instead of once per ask.
|
|
197
199
|
|
|
198
200
|
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,
|
|
199
201
|
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).
|
|
@@ -214,7 +216,7 @@ ${(0, doc_structure_1.details)('Example: Simple Function Call (unresolved)', awa
|
|
|
214
216
|
const callInfo = info.dataflow.graph.vertices(true).find(([, vertex]) => vertex_2.FunctionCallVertex.is(vertex) && identifier_1.Identifier.getName(vertex.name) === 'foo');
|
|
215
217
|
(0, assert_1.guard)(callInfo !== undefined, () => `Could not find call vertex for ${code}`);
|
|
216
218
|
const [callId, callVert] = callInfo;
|
|
217
|
-
const inverseMapReferenceTypes = Object.fromEntries(
|
|
219
|
+
const inverseMapReferenceTypes = Object.fromEntries((0, objects_1.enumMembers)(identifier_1.ReferenceType).map(([name, value]) => [value, name]));
|
|
218
220
|
const identifierType = (0, doc_types_1.getTypesFromFolder)({
|
|
219
221
|
files: [path_1.default.resolve('./src/dataflow/environments/identifier.ts')],
|
|
220
222
|
inlineTypes: ['ControlDependency']
|
|
@@ -233,7 +235,7 @@ as the \`type\` of these references is a bit-mask, encoding one of the following
|
|
|
233
235
|
|
|
234
236
|
| Value | Reference Type |
|
|
235
237
|
|------:|----------------|
|
|
236
|
-
${
|
|
238
|
+
${(0, objects_1.enumMembers)(identifier_1.ReferenceType).map(([name, value]) => `| ${value} | ${name} |`).join('\n')}
|
|
237
239
|
|
|
238
240
|
In other words, we classify the references as ${(0, doc_general_1.lastJoin)(callVert.args.map(a => {
|
|
239
241
|
if (a === r_function_call_1.EmptyArgument) {
|
|
@@ -344,7 +346,7 @@ For starters, let's have a look at the environment of the call to \`<-\` in the
|
|
|
344
346
|
|
|
345
347
|
${(0, doc_env_1.printEnvironmentToMarkdown)(env.current)}
|
|
346
348
|
|
|
347
|
-
Great, you should see a definition of \`<-\` which is constraint by the [control dependency](#
|
|
349
|
+
Great, you should see a definition of \`<-\` which is constraint by the [control dependency](#branches) to the \`if\`.
|
|
348
350
|
Hence, trying to re-resolve the call using ${ctx.link(linker_1.getAllFunctionCallTargets)} (defined in ${(0, doc_files_1.getFilePathMd)('../dataflow/internal/linker.ts')}) with the id \`${id}\` of the call as starting point will present you with
|
|
349
351
|
the following target ids: { \`${[...(0, linker_1.getAllFunctionCallTargets)(id, info.dataflow.graph)].join('`, `')}\` }.
|
|
350
352
|
This way we know that the call may refer to the built-in assignment operator or to the multiplication.
|
|
@@ -410,7 +412,7 @@ Of only interest is \`par\`, which signals that the definitions is partial (e.g.
|
|
|
410
412
|
Of course, there are not just operators that define variables, but also functions, like \`assign\`.
|
|
411
413
|
|
|
412
414
|
${(0, doc_structure_1.details)('Example: Using <code>assign</code>', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'assign("x", 1)\nx', { mark: new Set([1]), ctx })
|
|
413
|
-
+ `\nThe example may be misleading as the visualization
|
|
415
|
+
+ `\nThe example may be misleading as the visualization prints the lexeme of the variable. However, this actually defines the variable \`x\` (without the quotes) as you can see with the ${linkEdgeName(edge_1.EdgeType.Reads)} edge.`)}
|
|
414
416
|
|
|
415
417
|
Please be aware, that the name of the symbol defined may differ from what you read in the program as R allows the assignments to strings, escaped names, and more:
|
|
416
418
|
|
|
@@ -735,6 +737,27 @@ ${ctx.link(deferred_1.Deferred.name, undefined, { type: 'variable' })} links an
|
|
|
735
737
|
.nse('1@quote', '1@x')
|
|
736
738
|
.nse('1@quote', '1@y')
|
|
737
739
|
}]]);
|
|
740
|
+
edgeExplanations.set(edge_1.EdgeType.FlowEdge, [{
|
|
741
|
+
name: 'FlowDependency Edge',
|
|
742
|
+
type: edge_1.EdgeType.FlowEdge,
|
|
743
|
+
description: `
|
|
744
|
+
Marks that the source is evaluated before the target, which is what the ${ctx.linkPage('wiki/Control Flow Graph', 'control flow graph')} is a view on.
|
|
745
|
+
The dataflow analysis records the control flow while it walks the program, so these edges (together with the
|
|
746
|
+
${linkEdgeName(edge_1.EdgeType.ControlEdge)} edges) already carry the program's control flow and no separate extraction is needed.
|
|
747
|
+
`,
|
|
748
|
+
code: 'x <- 1\ny <- 2',
|
|
749
|
+
expectedSubgraph: (0, dataflowgraph_builder_1.emptyGraph)()
|
|
750
|
+
}, []]);
|
|
751
|
+
edgeExplanations.set(edge_1.EdgeType.ControlEdge, [{
|
|
752
|
+
name: 'ControlDependency Edge',
|
|
753
|
+
type: edge_1.EdgeType.ControlEdge,
|
|
754
|
+
description: `
|
|
755
|
+
The counterpart of the ${linkEdgeName(edge_1.EdgeType.FlowEdge)} edge for everything that only happens under a condition:
|
|
756
|
+
the edge names the vertex that decides (e.g. an \`if\`) and whether it is the branch taken when that decision holds.
|
|
757
|
+
`,
|
|
758
|
+
code: 'if(u) 1 else 2',
|
|
759
|
+
expectedSubgraph: (0, dataflowgraph_builder_1.emptyGraph)()
|
|
760
|
+
}, []]);
|
|
738
761
|
const results = [];
|
|
739
762
|
let i = 0;
|
|
740
763
|
for (const [, edge] of (0, doc_data_dfg_util_1.getAllEdges)()) {
|
|
@@ -770,12 +793,13 @@ In summary, we discuss the following topics in this wiki page:
|
|
|
770
793
|
- [Reading the Visualization](#reading-the-visualization)
|
|
771
794
|
- [Vertices](#vertices)
|
|
772
795
|
- [Edges](#edges)
|
|
773
|
-
- [
|
|
796
|
+
- [Branches](#branches)
|
|
774
797
|
- [Dataflow Information](#dataflow-information)
|
|
775
798
|
- [Unknown Side Effects](#unknown-side-effects)
|
|
776
799
|
- [Perspectives on the Dataflow Graph](#perspectives)
|
|
777
800
|
- [Call Graph Perspective](#perspectives-cg)
|
|
778
801
|
- [Working with the Dataflow Graph](#dfg-working)
|
|
802
|
+
- [Matching Arguments to Parameters](#dfg-matching-arguments)
|
|
779
803
|
|
|
780
804
|
Please be aware that the accompanied [dataflow information](#dataflow-information) (${ctx.link('DataflowInformation')}) returned by _flowR_
|
|
781
805
|
contains things besides the graph, like the entry and exit points of the subgraphs, and currently active references (see [below](#dataflow-information)).
|
|
@@ -802,8 +826,9 @@ ${await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, introExampleCode, { showC
|
|
|
802
826
|
The above dataflow graph showcases the general gist. We define a dataflow graph as a directed graph G = (V, E),
|
|
803
827
|
differentiating between ${(0, doc_data_dfg_util_1.getAllVertices)().length} types of vertices V and
|
|
804
828
|
${(0, doc_data_dfg_util_1.getAllEdges)().length} types of edges E allowing each vertex to have a single, and each edge to have multiple distinct types.
|
|
805
|
-
|
|
806
|
-
|
|
829
|
+
Two of these edge types carry the control flow rather than the data: the ${ctx.linkPage('wiki/Control Flow Graph')} is a view on them.
|
|
830
|
+
Additionally, every vertex lists the [control dependencies](#branches) it runs under, which is the same
|
|
831
|
+
information a control edge carries, collected for the whole path that leads to the vertex.
|
|
807
832
|
|
|
808
833
|
${(0, doc_structure_1.details)('Simplified Version of the graph', await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'x <- 3\ny <- x + 1\ny', { simplified: true, showCode: false, ctx }))}
|
|
809
834
|
|
|
@@ -830,8 +855,8 @@ The following sections present details on the different types of vertices and ed
|
|
|
830
855
|
> So if you want more information about the respective vertex, you can usually access more information
|
|
831
856
|
> using the <code>${ctx.link(`${graph_1.DataflowGraph.name}`, { codeFont: false, realNameWrapper: 'i' })}::idMap</code> linked to the dataflow graph:
|
|
832
857
|
${(0, doc_general_1.prefixLines)((0, doc_code_1.codeBlock)('ts', 'const node = graph.idMap.get(id);'), '> ')}
|
|
833
|
-
> In case you just need the name (\`lexeme\`) of the respective vertex, ${ctx.
|
|
834
|
-
${(0, doc_general_1.prefixLines)((0, doc_code_1.codeBlock)('ts',
|
|
858
|
+
> In case you just need the name (\`lexeme\`) of the respective vertex, ${ctx.linkO(model_1.RNode, 'lexeme')} can help you out:
|
|
859
|
+
${(0, doc_general_1.prefixLines)((0, doc_code_1.codeBlock)('ts', 'const name = RNode.lexeme(graph.idMap?.get(id));'), '> ')}
|
|
835
860
|
>
|
|
836
861
|
> Please note, that not every node in the ${ctx.linkPage('wiki/Normalized AST', 'normalized AST')} is represented in the dataflow graph.
|
|
837
862
|
> For example, if the node is unreachable in a way that can be detected during the analysis and flowR
|
|
@@ -878,12 +903,11 @@ You can access the lexeme too with ${ctx.linkO(model_1.RNode, 'lexeme')}.
|
|
|
878
903
|
|
|
879
904
|
${(0, doc_structure_1.section)('Vertex Id', 3, 'vtx-id')}
|
|
880
905
|
|
|
881
|
-
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
|
|
882
|
-
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).
|
|
906
|
+
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**. This id links the vertex to the respective node in the ${ctx.linkPage('wiki/Normalized AST')} (and all other perspectives created by flowR).
|
|
883
907
|
To give you an example, have a look at the following graph:
|
|
884
908
|
|
|
885
909
|
${await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'if(u) a', { showCode: false, mark: new Set(['1']), ctx })}
|
|
886
|
-
The \`3+\` tells you that \`a\` has a [control dependency](#
|
|
910
|
+
The \`3+\` tells you that \`a\` has a [control dependency](#branches) on the vertex with id \`3\`, the \`if\`,
|
|
887
911
|
which only triggers when the condition is \`true\`; a \`-\` suffix marks the \`false\` case.
|
|
888
912
|
|
|
889
913
|
Other vertices are named by their id too: \`v: <id>\` is the value of a definition, \`links: <id>\` the AST vertices that
|
|
@@ -915,20 +939,25 @@ ${(0, doc_structure_1.section)('Edges', 2, 'edges')}
|
|
|
915
939
|
|
|
916
940
|
${await getEdgesExplanations(treeSitter, ctx)}
|
|
917
941
|
|
|
918
|
-
${(0, doc_structure_1.section)('
|
|
942
|
+
${(0, doc_structure_1.section)('Branches', 2, 'branches')}
|
|
943
|
+
|
|
944
|
+
A ${ctx.link('ControlDependency')} names the node that decides whether something is evaluated, together with a
|
|
945
|
+
\`when\` flag for the outcome it takes, e.g. \`{ id: <the if>, when: true }\`.
|
|
919
946
|
|
|
920
|
-
Each vertex
|
|
921
|
-
|
|
922
|
-
and a boolean flag \`when\` to indicate if the control dependency is active when the condition is \`true\` or \`false\`.
|
|
947
|
+
Each vertex lists the ones it runs under in its \`cds\`, and the control flow puts the very same objects on its
|
|
948
|
+
${ctx.linkE('EdgeType', 'ControlEdge')} edges, so the two never drift apart.
|
|
923
949
|
|
|
924
950
|
As an example, consider the following dataflow graph:
|
|
925
951
|
|
|
926
952
|
${await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'if(p) a else b', { ctx })}
|
|
927
953
|
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
954
|
+
Control flow is drawn dashed and gray, and such an edge reads \`branch\` (it is a \`branches-to\` edge, called
|
|
955
|
+
\`branch on ... if T\` in the ${ctx.linkPage('wiki/Control Flow Graph')}).
|
|
956
|
+
It starts at the condition, since that is what has to run first, and its label says which decision it belongs to,
|
|
957
|
+
so \`p\` leads to \`a\` when the \`if\` is \`true\` and to \`b\` when it is \`false\`.
|
|
958
|
+
Both \`a\` and \`b\` therefore depend on the \`if\` and not on the result of the condition itself, as the \`if\` is the more
|
|
959
|
+
general linkage point (and harmonizes with other control structures, especially those which are user-defined).
|
|
960
|
+
See the ${ctx.linkPage('wiki/Control Flow Graph', 'control flow graph')} for the view these edges make up.
|
|
932
961
|
|
|
933
962
|
${(0, doc_structure_1.details)('Example: Multiple Vertices (Assignment)', await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'if(p) a <- 1', { ctx }))}
|
|
934
963
|
${(0, doc_structure_1.details)('Example: Multiple Vertices (Arithmetic Expression)', await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'if(p) 3 + 2', { ctx }))}
|
|
@@ -940,23 +969,9 @@ ${(0, doc_structure_1.section)('Dataflow Information', 2, 'dataflow-information'
|
|
|
940
969
|
Using _flowR's_ code interface (see the ${ctx.linkPage('wiki/Interface', 'Interface', 'creating-analyses-with-flowr')} wiki page for more), you can generate the dataflow information
|
|
941
970
|
for a given piece of R code (in this case \`x <- 1; x + 1\`) as follows:
|
|
942
971
|
|
|
943
|
-
${(
|
|
944
|
-
const analyzer = await new FlowrAnalyzerBuilder(requestFromInput('x <- 1\nx + 1')).build();
|
|
945
|
-
const result = await analyzer.dataflow();
|
|
946
|
-
`)}
|
|
947
|
-
|
|
948
|
-
<details>
|
|
949
|
-
|
|
950
|
-
<summary style="color:gray">Transpiled Code</summary>
|
|
951
|
-
|
|
952
|
-
The actual code we are using in case the example above gets oudated:
|
|
953
|
-
|
|
954
|
-
${(0, doc_code_1.codeBlock)('ts', dummyDataflow.toString())}
|
|
955
|
-
|
|
956
|
-
</details>
|
|
957
|
-
|
|
972
|
+
${ctx.code(dummyDataflow, { dropLinesStart: 1, dropLinesEnd: 2 })}
|
|
958
973
|
|
|
959
|
-
|
|
974
|
+
The call returns the dataflow _information_, with the graph in \`result.graph\`, which looks like this:
|
|
960
975
|
|
|
961
976
|
${await (async () => {
|
|
962
977
|
const result = await dummyDataflow();
|
|
@@ -982,8 +997,8 @@ ${ctx.hierarchy('DataflowInformation')}
|
|
|
982
997
|
Let's start by looking at the properties of the dataflow information object: ${Object.keys(result).map(k => `\`${k}\``).join(', ')}.
|
|
983
998
|
|
|
984
999
|
${(() => {
|
|
985
|
-
/* this includes the meta field for timing
|
|
986
|
-
(0, assert_1.guard)(Object.keys(result).length ===
|
|
1000
|
+
/* this includes the meta field for timing as well as the control flow entry and exit of the program */
|
|
1001
|
+
(0, assert_1.guard)(Object.keys(result).length === 12, () => 'Update Dataflow Documentation! (Keys: ' + Object.keys(result).join(', ') + ')');
|
|
987
1002
|
return '';
|
|
988
1003
|
})()}
|
|
989
1004
|
|
|
@@ -1018,6 +1033,7 @@ Besides marking potential exits, the exit points also provide information about
|
|
|
1018
1033
|
|
|
1019
1034
|
Finally, the **kill** property (${ctx.link('KillReference', undefined, { type: 'type' })}) tracks references that are removed from scope within the current subtree (e.g., via \`rm(x)\`).
|
|
1020
1035
|
It is \`undefined\` unless such a removal occurred and, like the outgoing references, bubbles up so that the enclosing scope can apply the removal (see ${ctx.link(apply_kill_1.applyKills)}) at the right location.
|
|
1036
|
+
A definition that such a removal undid is dropped from the outgoing references, so \`x <- 1; rm(x)\` has an empty **out** set (a conditional removal keeps the now maybe-defined \`x\`).
|
|
1021
1037
|
|
|
1022
1038
|
### Unknown Side Effects
|
|
1023
1039
|
|
|
@@ -1094,20 +1110,19 @@ Generally, we recommend you check out the ${ctx.link(df_helper_1.Dataflow, undef
|
|
|
1094
1110
|
|
|
1095
1111
|
* The **${ctx.linkPage('wiki/Query API')}** provides many functions to query the dataflow graph for specific information (dependencies, calls, slices, clusters, ...)
|
|
1096
1112
|
* The **${ctx.linkPage('wiki/Search API')}** allows you to search for specific vertices or edges in the dataflow graph or the original program
|
|
1097
|
-
* ${ctx.
|
|
1098
|
-
* ${ctx.link(resolve_helper_1.Resolve.toValue)} to resolve the value of a variable or id (if possible, see [below](#dfg-resolving-values))
|
|
1099
|
-
* ${ctx.link(alias_tracking_1.getAliases)} to get all (potentially currently) aliases of a given definition
|
|
1100
|
-
* ${ctx.link(identify_link_to_last_call_relation_1.getValueOfArgument)} to get the (syntactical) value of an argument in a function call
|
|
1101
|
-
* ${ctx.link(df_helper_1.Dataflow.origin)} to get information about where a read, call, ... comes from (see [below](#dfg-resolving-values))
|
|
1113
|
+
* The ${ctx.linkPage('wiki/Control Flow Graph')} is a view on this graph, so ${ctx.link(control_flow_graph_1.ControlFlowGraph)} answers what runs before what without a second analysis
|
|
1102
1114
|
|
|
1103
|
-
|
|
1115
|
+
Everything else lives on a helper object named after the thing it works on:
|
|
1104
1116
|
|
|
1105
|
-
* ${ctx.link(
|
|
1106
|
-
* ${ctx.link(
|
|
1107
|
-
* ${ctx.link(
|
|
1108
|
-
* ${ctx.link(
|
|
1109
|
-
|
|
1110
|
-
|
|
1117
|
+
* ${ctx.link(df_helper_1.Dataflow, undefined, { type: 'variable' })} for the graph itself, e.g. ${ctx.linkO(df_helper_1.Dataflow, 'origin')} tells you where a read, call, ... comes from (see [below](#dfg-resolving-values))
|
|
1118
|
+
* ${ctx.link(edge_1.DfEdge, undefined, { type: 'variable' })} for edges, e.g. \`DfEdge.includesType(edge, EdgeType.Reads)\` (see [below](#dfg-resolving-values))
|
|
1119
|
+
* ${ctx.link(model_1.RNode, undefined, { type: 'variable' })} for the nodes behind the vertices, e.g. \`RNode.lexeme(graph.idMap?.get(id))\` for what a vertex is written as
|
|
1120
|
+
* ${ctx.link(identifier_1.Identifier, undefined, { type: 'variable' })} for identifiers, e.g. \`Identifier.toString(vertex.name)\`
|
|
1121
|
+
* ${ctx.link(graph_1.FunctionArgument, undefined, { type: 'variable' })} for the arguments of a call, e.g. \`FunctionArgument.isNotEmpty(arg)\`
|
|
1122
|
+
* ${ctx.link(resolve_helper_1.Resolve, undefined, { type: 'variable' })} (also reachable as \`Dataflow.resolve\`) for everything that resolves. Take the narrowest entry point:
|
|
1123
|
+
${ctx.linkO(resolve_helper_1.Resolve, 'byName')} walks the environment layers once, ${ctx.linkO(resolve_helper_1.Resolve, 'byNameAndType')} merges the definitions of every layer it passes,
|
|
1124
|
+
and ${ctx.linkO(resolve_helper_1.Resolve, 'toValue')} as well as ${ctx.linkO(resolve_helper_1.Resolve, 'argument')} run the evaluator on top of a resolution (see [below](#dfg-resolving-values))
|
|
1125
|
+
* ${ctx.link(match_args_1.MatchArgs, undefined, { type: 'variable' })} to bind a call's arguments to the formals of what it calls (see [below](#dfg-matching-arguments))
|
|
1111
1126
|
|
|
1112
1127
|
Some of these functions have been explained in their respective wiki pages. However, some are part of the ${ctx.linkPage('wiki/Dataflow Graph', 'Dataflow Graph API')} and so we explain them here.
|
|
1113
1128
|
If you are interested in which features we support and which features are still to be worked on, please refer to our ${ctx.linkPage('wiki/Capabilities', 'capabilities')} page.
|
|
@@ -1126,6 +1141,23 @@ Additionally, to ${ctx.link(resolve_helper_1.Resolve.toValue)}, we offer the afo
|
|
|
1126
1141
|
Be aware, that this function is currently not optimized for speed, so if you frequently require the values of multiple arguments of the same function call, you may want to open [an issue](${doc_issue_1.NewIssueUrl}) to request support for resolving
|
|
1127
1142
|
multiple arguments at once.
|
|
1128
1143
|
|
|
1144
|
+
${(0, doc_structure_1.section)('Matching Arguments to Parameters', 3, 'dfg-matching-arguments')}
|
|
1145
|
+
|
|
1146
|
+
R does not bind a call's arguments to the formals left to right. An exactly named argument takes its formal, then a
|
|
1147
|
+
uniquely abbreviated one does (\`pmatch\`), then the rest fill what is still free until \`...\`, and whatever is
|
|
1148
|
+
left over goes to \`...\`. ${ctx.link('matchArgumentsToParameters')} is that algorithm, and
|
|
1149
|
+
${ctx.link(match_args_1.MatchArgs, undefined, { type: 'variable' })} is how you ask for it:
|
|
1150
|
+
|
|
1151
|
+
| Use case | member |
|
|
1152
|
+
|----------|--------|
|
|
1153
|
+
| AST arguments and the formal names | ${ctx.linkO(match_args_1.MatchArgs, 'toNames')} |
|
|
1154
|
+
| graph arguments and the formals (a spec, or a database signature) | ${ctx.linkO(match_args_1.MatchArgs, 'toSpec')} |
|
|
1155
|
+
| graph arguments and the callee's ${ctx.link('RParameter')}s, **also adding the [DefinesOnCall](#5-definesoncall-edge) and [DefinedByOnCall](#6-definedbyoncall-edge) edges** | ${ctx.linkO(match_args_1.MatchArgs, 'onCallAndLink')} |
|
|
1156
|
+
| only the call, the formals are looked up for you | ${ctx.linkO(match_args_1.MatchArgs, 'toDefinition')} |
|
|
1157
|
+
|
|
1158
|
+
${ctx.linkO(match_args_1.MatchArgs, 'toDefinition')} takes the formals from the ${ctx.link('RFunctionDefinition')} the call
|
|
1159
|
+
resolves to in user code, and from the ${ctx.linkPage('wiki/Signature Database', 'signature database')} otherwise.
|
|
1160
|
+
|
|
1129
1161
|
${(0, doc_structure_1.section)('Assessing Edges', 3, 'dfg-assess-edge')}
|
|
1130
1162
|
|
|
1131
1163
|
The [edges](#edges) of the dataflow graph use bitmasks to represent an edge with multiple types. While this compacts the representation greatly, it makes it
|
|
@@ -19,6 +19,7 @@ const strings_1 = require("../util/text/strings");
|
|
|
19
19
|
const assert_1 = require("../util/assert");
|
|
20
20
|
const doc_functions_1 = require("./doc-util/doc-functions");
|
|
21
21
|
const linter_format_1 = require("../linter/linter-format");
|
|
22
|
+
const linter_fix_1 = require("../linter/linter-fix");
|
|
22
23
|
const doc_maker_1 = require("./wiki-mk/doc-maker");
|
|
23
24
|
const SpecialTagColors = {
|
|
24
25
|
[linter_tags_1.LintingRuleTag.Bug]: 'red',
|
|
@@ -91,7 +92,7 @@ See [here](${(0, doc_types_1.getTypePathLink)({ filePath: report.source.fileName
|
|
|
91
92
|
}
|
|
92
93
|
function registerRules(knownParser, tagTypes, format = 'short') {
|
|
93
94
|
const ruleExplanations = new Map();
|
|
94
|
-
rule(knownParser, 'deprecated-functions', '
|
|
95
|
+
rule(knownParser, 'deprecated-functions', 'DeprecatedFunctionsConfig', 'DEPRECATED_FUNCTIONS', 'lint-deprecated-functions', `
|
|
95
96
|
first <- data.frame(x = c(1, 2, 3), y = c(1, 2, 3))
|
|
96
97
|
second <- data.frame(x = c(1, 3, 2), y = c(1, 3, 2))
|
|
97
98
|
dplyr::all_equal(first, second)
|
|
@@ -134,6 +135,8 @@ function(x) {
|
|
|
134
135
|
rule(knownParser, 'no-leaked-credentials', 'NoLeakedCredentialsConfig', 'NO_LEAKED_CREDENTIALS', 'lint-no-leaked-credentials', 'password <- "s3cr3t"', tagTypes);
|
|
135
136
|
rule(knownParser, 'undefined-symbol', 'UndefinedSymbolConfig', 'UNDEFINED_SYMBOL', 'lint-undefined-symbol', 'undefined_helper(42)', tagTypes);
|
|
136
137
|
rule(knownParser, 'syntactically-valid', 'SyntacticallyValidConfig', 'SYNTACTICALLY_VALID', 'lint-syntactically-valid', 'x <- c(1, 2', tagTypes);
|
|
138
|
+
rule(knownParser, 'unclosed-connection', 'UnclosedConnectionConfig', 'UNCLOSED_CONNECTION', 'lint-unclosed-connection', 'con <- file("data.csv")\nreadLines(con)', tagTypes);
|
|
139
|
+
rule(knownParser, 'unused-import', 'UnusedImportConfig', 'UNUSED_IMPORT', 'lint-unused-import', 'library(stats)\nprint("no stats function is used")', tagTypes);
|
|
137
140
|
function rule(parser, name, configType, ruleType, testfile, example, types) {
|
|
138
141
|
const rule = linter_rules_1.LintingRules[name];
|
|
139
142
|
const tags = rule.info.tags.toSorted((a, b) => {
|
|
@@ -247,6 +250,18 @@ ${await (async () => {
|
|
|
247
250
|
return result;
|
|
248
251
|
})()}
|
|
249
252
|
|
|
253
|
+
${(0, doc_structure_1.section)('Quick Fixes', 2, 'quick-fixes')}
|
|
254
|
+
|
|
255
|
+
Rules tagged ${makeTagBadge(linter_tags_1.LintingRuleTag.QuickFix, tagTypes.info)} attach a ${(0, doc_types_1.shortLink)('LintQuickFix', tagTypes.info)} to their results,
|
|
256
|
+
describing the edit that resolves the finding. flowR does not only report them, it carries them out:
|
|
257
|
+
${ctx.link(linter_fix_1.LintQuickFixes.byFile)} collects the fixes of a lint run per file and ${ctx.link(linter_fix_1.LintQuickFixes.apply)}
|
|
258
|
+
returns that file's content with them applied. Of two overlapping fixes only the one coming first in the file is kept,
|
|
259
|
+
and a removal that leaves nothing but whitespace behind takes its line with it.
|
|
260
|
+
|
|
261
|
+
In ${ctx.linkE('LinterOutputFormat', 'Sarif')} output the fixes become SARIF \`fixes\`, which an editor
|
|
262
|
+
or code scanner can offer directly. ${ctx.linkE('LinterOutputFormat', 'Github')} annotations carry no
|
|
263
|
+
fix of their own, so the descriptions are appended to the message.
|
|
264
|
+
|
|
250
265
|
${(0, doc_structure_1.section)('Tags', 2, 'tags')}
|
|
251
266
|
|
|
252
267
|
We use tags to categorize linting rules for users. The following tags are available:
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.WikiLintingAndTesting = void 0;
|
|
7
4
|
const log_1 = require("../util/log");
|
|
@@ -9,19 +6,10 @@ const doc_code_1 = require("./doc-util/doc-code");
|
|
|
9
6
|
const doc_files_1 = require("./doc-util/doc-files");
|
|
10
7
|
const doc_structure_1 = require("./doc-util/doc-structure");
|
|
11
8
|
const doc_cli_option_1 = require("./doc-util/doc-cli-option");
|
|
12
|
-
const patterns_1 = __importDefault(require("@eagleoutice/eslint-config-flowr/patterns"));
|
|
13
9
|
const edge_1 = require("../dataflow/graph/edge");
|
|
14
10
|
const resolve_helper_1 = require("../dataflow/environments/resolve-helper");
|
|
15
11
|
const node_id_1 = require("../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
16
12
|
const doc_maker_1 = require("./wiki-mk/doc-maker");
|
|
17
|
-
/** the default patterns of `flowr/replacement-pattern`, rendered so the wiki cannot drift from the configuration */
|
|
18
|
-
/** two of the default patterns, kept generated so the wiki cannot drift from the configuration */
|
|
19
|
-
function patternExamples() {
|
|
20
|
-
const shown = ['edge-is-only-type', 'vertex-is'];
|
|
21
|
-
const cell = (text) => text.replaceAll('|', '\\|');
|
|
22
|
-
const rows = patterns_1.default.filter(p => p.id !== undefined && shown.includes(p.id)).map(p => `| \`${p.id}\` | ${cell(p.message ?? '')} | \`${cell(p.replace)}\` |`);
|
|
23
|
-
return ['| id | what it says | replacement |', '| :-- | :-- | :-- |', ...rows].join('\n');
|
|
24
|
-
}
|
|
25
13
|
/**
|
|
26
14
|
* https://github.com/flowr-analysis/flowr/wiki/Linting-and-Testing
|
|
27
15
|
*/
|
|
@@ -302,10 +290,7 @@ Never reported are the references that make the replacement exist: the wiring in
|
|
|
302
290
|
Some replacements are a shape of code rather than a renamed function, such as \`edge.types === EdgeType.Reads\`, which
|
|
303
291
|
reads like "has this type" (${ctx.linkO(edge_1.DfEdge, 'includesType')}) but holds only if it is the *only* type
|
|
304
292
|
(${ctx.linkO(edge_1.DfEdge, 'isOnlyType')}). These are matched with [esquery](https://github.com/estools/esquery) selectors,
|
|
305
|
-
the language \`no-restricted-syntax\` uses.
|
|
306
|
-
[\`patterns.ts\`](${doc_files_1.FlowrGithubBaseRef}/flowr-lint/blob/main/patterns.ts):
|
|
307
|
-
|
|
308
|
-
${patternExamples()}
|
|
293
|
+
the language \`no-restricted-syntax\` uses.
|
|
309
294
|
|
|
310
295
|
The [flowr-lint README](${doc_files_1.FlowrGithubBaseRef}/flowr-lint#flowrreplacement-pattern) documents the fields of a pattern,
|
|
311
296
|
and \`npx eslint\` names the id of whichever one fires.
|
|
@@ -12,7 +12,11 @@ var WikiChangeType;
|
|
|
12
12
|
function normalizeLineEndings(text) {
|
|
13
13
|
return text.replace(/\r\n/g, '\n');
|
|
14
14
|
}
|
|
15
|
+
/** url-encoded home paths like `%2Fhome%2Fuser%2Fgit%2F` or `C%3A%5CUsers%5Cuser%5C` */
|
|
16
|
+
const UrlEncodedHomePath = /(?:[a-z]%3A)?(%2F|%5C)(?:home|users)\1(?:[\w.%-]+\1)*/gi;
|
|
15
17
|
const DefaultReplacementPatterns = [
|
|
18
|
+
// mute signature database load time variance in wiki table (before the `ms` rule, which would eat half of it)
|
|
19
|
+
[/≈\s*<?[\d.]+\s*[µm]s/g, ''],
|
|
16
20
|
// eslint-disable-next-line no-irregular-whitespace -- we may produce it in output
|
|
17
21
|
[/\d+(\.\d+)?( |\s*)?ms/g, ''],
|
|
18
22
|
[/tmp[%A-Za-z0-9-]+/g, ''],
|
|
@@ -23,12 +27,10 @@ const DefaultReplacementPatterns = [
|
|
|
23
27
|
[/R\s*\d+\.\d+\.\d+/g, ''],
|
|
24
28
|
[/v\d+\.\d+\.\d+/g, ''],
|
|
25
29
|
// clean paths
|
|
26
|
-
[
|
|
30
|
+
[UrlEncodedHomePath, ''],
|
|
27
31
|
// async wrapper depends on whether the promise got fulfilled already
|
|
28
32
|
[/async|%20/g, ''],
|
|
29
|
-
[/\s*Copied mermaid url to clipboard\s*\([^)]+\)/gmi, '']
|
|
30
|
-
// mute signature database load time variance in wiki table
|
|
31
|
-
[/≈\s*<?[\d.]+\s*[µm]s/g, '']
|
|
33
|
+
[/\s*Copied mermaid url to clipboard\s*\([^)]+\)/gmi, '']
|
|
32
34
|
];
|
|
33
35
|
/**
|
|
34
36
|
* Abstract base class for generating wiki files.
|
|
@@ -31,10 +31,12 @@ const doc_cfg_1 = require("./doc-util/doc-cfg");
|
|
|
31
31
|
const doc_repl_1 = require("./doc-util/doc-repl");
|
|
32
32
|
const inspect_higher_order_query_executor_1 = require("../queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor");
|
|
33
33
|
const doc_escape_1 = require("./doc-util/doc-escape");
|
|
34
|
+
const config_1 = require("../config");
|
|
34
35
|
const doc_maker_1 = require("./wiki-mk/doc-maker");
|
|
35
36
|
const files_query_executor_1 = require("../queries/catalog/files-query/files-query-executor");
|
|
36
37
|
const call_graph_query_executor_1 = require("../queries/catalog/call-graph-query/call-graph-query-executor");
|
|
37
38
|
const inspect_recursion_query_executor_1 = require("../queries/catalog/inspect-recursion-query/inspect-recursion-query-executor");
|
|
39
|
+
const inspect_strictness_query_executor_1 = require("../queries/catalog/inspect-strictness-query/inspect-strictness-query-executor");
|
|
38
40
|
const does_call_query_executor_1 = require("../queries/catalog/does-call-query/does-call-query-executor");
|
|
39
41
|
const inspect_exception_query_executor_1 = require("../queries/catalog/inspect-exceptions-query/inspect-exception-query-executor");
|
|
40
42
|
const slice_direction_1 = require("../util/slice-direction");
|
|
@@ -314,6 +316,58 @@ ${await (0, doc_query_1.showQuery)(shell, exampleCode, [{
|
|
|
314
316
|
`;
|
|
315
317
|
}
|
|
316
318
|
});
|
|
319
|
+
(0, doc_query_1.registerQueryDocumentation)('inspect-strictness', {
|
|
320
|
+
type: 'active',
|
|
321
|
+
shortDescription: 'Determine whether functions force their arguments',
|
|
322
|
+
functionName: inspect_strictness_query_executor_1.executeStrictnessQuery.name,
|
|
323
|
+
functionFile: '../queries/catalog/inspect-strictness-query/inspect-strictness-query-executor.ts',
|
|
324
|
+
buildExplanation: async (shell, ctx) => {
|
|
325
|
+
const exampleCode = 'f <- function(a, b, c) { print(a); if(runif(1) > .5) print(b); 42 }';
|
|
326
|
+
return `
|
|
327
|
+
R hands arguments over as promises, so a parameter is only evaluated once something reads it.
|
|
328
|
+
With this query you can find out which functions rely on that: a function is \`always\` strict if every call
|
|
329
|
+
forces every one of its parameters, \`never\` strict if no call forces all of them, and \`conditionally\`
|
|
330
|
+
strict if it depends on the path taken, on the caller, or on a function flowR could not resolve.
|
|
331
|
+
The result carries the same verdict per parameter, keyed by the id of the parameter's name.
|
|
332
|
+
|
|
333
|
+
Please note that a read that only hands the parameter to another function does not force it by itself.
|
|
334
|
+
Whether it is forced then depends on the function receiving it, which is resolved through the call graph.
|
|
335
|
+
A read within a nested function definition, within a loop, or under a condition leaves the parameter
|
|
336
|
+
\`conditionally\` strict, as does a call whose target flowR does not know.
|
|
337
|
+
|
|
338
|
+
What a built-in does with an argument is taken from what flowR states about it rather than from its name: an
|
|
339
|
+
argument declared as quoted or as one whose presence alone matters (\`quote(expr)\`, \`missing(x)\`) is never
|
|
340
|
+
evaluated, one declared as forced (\`force(x)\`) always is, and the calls that reach an argument only on the
|
|
341
|
+
way the run happens to take are the ones flowR hands to the processor saying so (\`switch\` picking a branch,
|
|
342
|
+
\`tryCatch\` reaching a handler, \`on.exit\` running at exit, and the short-circuiting \`&&\`/\`||\`).
|
|
343
|
+
A definition of your own shadowing such a name is judged by its own body instead, as R would.
|
|
344
|
+
A parameter read only in the default of another parameter is \`conditionally\` strict, as that default is
|
|
345
|
+
evaluated only when the argument is left out.
|
|
346
|
+
|
|
347
|
+
A generic mentions none of its arguments, so its verdict comes from the methods that S3 dispatch reaches: if
|
|
348
|
+
they agree the answer is theirs, otherwise the parameter is \`conditionally\` strict. The object the dispatch
|
|
349
|
+
is on is forced by the dispatch itself, which also covers \`standardGeneric\`. A \`NextMethod\` carries the
|
|
350
|
+
question on to the methods it reaches, matched by the position the parameter is written in, and an argument
|
|
351
|
+
travelling in \`...\` is followed to the parameter it binds to. The method of an object flowR cannot resolve,
|
|
352
|
+
such as \`obj$m(x)\`, leaves the parameter \`conditionally\` strict:
|
|
353
|
+
${await (0, doc_query_1.showQuery)(shell, 'f <- function(x, y) UseMethod("f")\nf.default <- function(x, y) x\nf.numeric <- function(x, y) y', [{
|
|
354
|
+
type: 'inspect-strictness',
|
|
355
|
+
}], { showCode: true, collapseQuery: true, ctx })}
|
|
356
|
+
|
|
357
|
+
Using the example code \`${exampleCode}\` the following query returns the information for all identified
|
|
358
|
+
function definitions whether they are strict:
|
|
359
|
+
${await (0, doc_query_1.showQuery)(shell, exampleCode, [{
|
|
360
|
+
type: 'inspect-strictness',
|
|
361
|
+
}], { showCode: true, collapseQuery: true, ctx })}
|
|
362
|
+
|
|
363
|
+
This query also supports a slicing criterion based query mode that only returns information for functions matching the given criteria:
|
|
364
|
+
${await (0, doc_query_1.showQuery)(shell, exampleCode, [{
|
|
365
|
+
type: 'inspect-strictness',
|
|
366
|
+
filter: ['1@function']
|
|
367
|
+
}], { showCode: true, shorthand: (0, doc_query_1.sliceQueryShorthand)(['1@function'], (0, doc_escape_1.escapeNewline)(exampleCode)), ctx })}
|
|
368
|
+
`;
|
|
369
|
+
}
|
|
370
|
+
});
|
|
317
371
|
(0, doc_query_1.registerQueryDocumentation)('inspect-exception', {
|
|
318
372
|
type: 'active',
|
|
319
373
|
shortDescription: 'Determine whether functions throw exceptions (known to flowR)',
|
|
@@ -800,7 +854,7 @@ ${await (0, doc_query_1.showQuery)(shell, exampleCode, [{
|
|
|
800
854
|
|
|
801
855
|
this produces:
|
|
802
856
|
|
|
803
|
-
${await (0, doc_cfg_1.printCfgCode)(shell, exampleCode, { showCode: false, prefix: 'flowchart
|
|
857
|
+
${await (0, doc_cfg_1.printCfgCode)(shell, exampleCode, { showCode: false, prefix: 'flowchart LR\n', simplifications: ['to-basic-blocks'], ctx })}
|
|
804
858
|
|
|
805
859
|
|
|
806
860
|
If, on the other hand, you want to prune dead code edges:
|
|
@@ -813,7 +867,7 @@ ${await (0, doc_query_1.showQuery)(shell, exampleCode, [{
|
|
|
813
867
|
|
|
814
868
|
this produces:
|
|
815
869
|
|
|
816
|
-
${await (0, doc_cfg_1.printCfgCode)(shell, exampleCode, { showCode: false, prefix: 'flowchart
|
|
870
|
+
${await (0, doc_cfg_1.printCfgCode)(shell, exampleCode, { showCode: false, prefix: 'flowchart LR\n', simplifications: ['analyze-dead-code'], ctx })}
|
|
817
871
|
|
|
818
872
|
|
|
819
873
|
Or, completely remove dead code:
|
|
@@ -826,7 +880,7 @@ ${await (0, doc_query_1.showQuery)(shell, exampleCode, [{
|
|
|
826
880
|
|
|
827
881
|
this produces:
|
|
828
882
|
|
|
829
|
-
${await (0, doc_cfg_1.printCfgCode)(shell, exampleCode, { showCode: false, prefix: 'flowchart
|
|
883
|
+
${await (0, doc_cfg_1.printCfgCode)(shell, exampleCode, { showCode: false, prefix: 'flowchart LR\n', simplifications: ['analyze-dead-code', 'remove-dead-code'], ctx })}
|
|
830
884
|
|
|
831
885
|
`;
|
|
832
886
|
}
|
|
@@ -977,6 +1031,15 @@ To find out what a script _uses_, reach for the ${(0, doc_query_1.linkToQueryOfN
|
|
|
977
1031
|
`;
|
|
978
1032
|
}
|
|
979
1033
|
});
|
|
1034
|
+
/** Pins the R version so this page reports the same bounds, whatever R the machine regenerating it has. */
|
|
1035
|
+
function guessDepVersionsExampleOptions(ctx) {
|
|
1036
|
+
return {
|
|
1037
|
+
showCode: false,
|
|
1038
|
+
collapseResult: true,
|
|
1039
|
+
ctx,
|
|
1040
|
+
prepare: b => b.configure('solver.sigdb.assumedRVersion', config_1.DefaultAssumedRVersion)
|
|
1041
|
+
};
|
|
1042
|
+
}
|
|
980
1043
|
(0, doc_query_1.registerQueryDocumentation)('guess-dep-versions', {
|
|
981
1044
|
type: 'active',
|
|
982
1045
|
shortDescription: 'Guesses the version range each dependency must have, from declared constraints and actual code usage.',
|
|
@@ -1003,7 +1066,7 @@ ${(0, doc_code_1.codeBlock)('r', exampleCode)}
|
|
|
1003
1066
|
\`across\` was only introduced in dplyr 1.0.0, so the script cannot run on anything older. The result names the function
|
|
1004
1067
|
that produced the bound:
|
|
1005
1068
|
|
|
1006
|
-
${await (0, doc_query_1.showQuery)(shell, exampleCode, [{ type: 'guess-dep-versions' }],
|
|
1069
|
+
${await (0, doc_query_1.showQuery)(shell, exampleCode, [{ type: 'guess-dep-versions' }], guessDepVersionsExampleOptions(ctx))}
|
|
1007
1070
|
|
|
1008
1071
|
The guess can be narrowed further:
|
|
1009
1072
|
|
|
@@ -17,6 +17,7 @@ const codec_1 = require("../project/sigdb/codec");
|
|
|
17
17
|
const config_1 = require("../config");
|
|
18
18
|
const flowr_analyzer_package_versions_sigdb_plugin_1 = require("../project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin");
|
|
19
19
|
const flowr_analyzer_builder_1 = require("../project/flowr-analyzer-builder");
|
|
20
|
+
const identifier_1 = require("../dataflow/environments/identifier");
|
|
20
21
|
const flowr_analyzer_dependencies_context_1 = require("../project/context/flowr-analyzer-dependencies-context");
|
|
21
22
|
const doc_sigdb_1 = require("./doc-util/doc-sigdb");
|
|
22
23
|
/** point the resolver at your own database (a file path or manifest) */
|
|
@@ -24,6 +25,17 @@ function usePackageDatabase(parser) {
|
|
|
24
25
|
const sigdb = new flowr_analyzer_package_versions_sigdb_plugin_1.FlowrAnalyzerPackageVersionsSigDbPlugin('/path/to/sigs.manifest.json.br');
|
|
25
26
|
return new flowr_analyzer_builder_1.FlowrAnalyzerBuilder().setParser(parser).registerPlugins(sigdb).build();
|
|
26
27
|
}
|
|
28
|
+
/** the entry point: one database, versions already resolved the way the project's configuration says */
|
|
29
|
+
function fromTheAnalyzer(analyzer) {
|
|
30
|
+
const db = analyzer.inspectContext().deps.signatures();
|
|
31
|
+
const lead = identifier_1.Identifier.make('lead', 'dplyr');
|
|
32
|
+
return {
|
|
33
|
+
version: db.versionOf('dplyr'), // the version this analysis assumes
|
|
34
|
+
fn: db.functionOf(lead), // its entry, decoding only this one function
|
|
35
|
+
parameters: db.parametersOf(lead), // its formals, ready for MatchArgs.toNames
|
|
36
|
+
exports: db.exportsOf('dplyr')?.exported
|
|
37
|
+
};
|
|
38
|
+
}
|
|
27
39
|
function accessTheDatabase(source) {
|
|
28
40
|
const fn = source.functionByName('dplyr', 'lead', '1.1.4');
|
|
29
41
|
return {
|
|
@@ -214,7 +226,7 @@ class WikiSignatureDatabase extends doc_maker_1.DocMaker {
|
|
|
214
226
|
flowR ships a database of the complete history of all exports in every version of all CRAN packages so it can resolve calls into the packages you load.
|
|
215
227
|
After \`library(ggplot2)\`, a call to \`ggplot()\` resolves to \`ggplot2::ggplot\`. The same database
|
|
216
228
|
qualifies bare names and backs various components like the ${ctx.linkPage('wiki/Query API', 'dependencies and call-context queries')}
|
|
217
|
-
as well as the ${ctx.linkPage('wiki/Linter', 'undefined symbol')}
|
|
229
|
+
as well as the ${ctx.linkPage('wiki/Linter', 'undefined symbol')} and ${ctx.linkPage('wiki/Linter', 'unused import')} rules.
|
|
218
230
|
|
|
219
231
|
You can search what it knows at [flowr-analysis.github.io/flowr/wiki/sigdb](https://flowr-analysis.github.io/flowr/wiki/sigdb/),
|
|
220
232
|
a static page listing every exported name, generated from this database by \`npm run gen:landing\`.
|
|
@@ -242,7 +254,21 @@ These are derived on demand by the ${ctx.linkPage('wiki/Query API', 'signature q
|
|
|
242
254
|
- the S3 method to generic backlink ${ctx.link('SignatureFunctionView::s3method')}, for a ${ctx.linkE('FnProp', 'S3Method')} function, resolving its generic
|
|
243
255
|
- the transitive call graph ${ctx.linkM(reader_1.SigDatabase, 'transitiveCallees')}, expanding the stored local callees inside one version
|
|
244
256
|
|
|
245
|
-
|
|
257
|
+
## Reading It From an Analyzer
|
|
258
|
+
|
|
259
|
+
${ctx.linkM(flowr_analyzer_dependencies_context_1.FlowrAnalyzerDependenciesContext, 'signatures')} is the entry point, and it is the one you want.
|
|
260
|
+
|
|
261
|
+
${ctx.code(fromTheAnalyzer, { dropLinesStart: 1 })}
|
|
262
|
+
|
|
263
|
+
The ${ctx.link('SignatureDb')} it hands back is every loaded source as one database, answering for the version
|
|
264
|
+
*the analyzed project* assumes for each package, which is the version \`solver.sigdb.versionOverrides\`,
|
|
265
|
+
\`solver.sigdb.versionSelection\` and \`solver.sigdb.assumedRVersion\` produced. That matters, because a
|
|
266
|
+
${ctx.link('PackageSignatureSource')} asked without a version answers for whatever it happens to hold as newest,
|
|
267
|
+
which is not what the analysis assumes. When the assumed version is one the database does not carry, the answer
|
|
268
|
+
falls back to the newest it has and says so in the log rather than quietly answering for another version.
|
|
269
|
+
|
|
270
|
+
${ctx.link('SignatureDb::sources')} is the escape hatch to the raw sources for what the interface above does not
|
|
271
|
+
cover, and reaches the same functions directly.
|
|
246
272
|
|
|
247
273
|
${ctx.code(accessTheDatabase, { dropLinesStart: 1 })}
|
|
248
274
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { LintQuickFix } from './linter-format';
|
|
2
|
+
import type { LintResultsByRule } from './linter-output';
|
|
3
|
+
export declare const LintQuickFixes: {
|
|
4
|
+
/** Every quick fix a lint run offers, grouped by the file it changes. Fixes flowR cannot place are left out. */
|
|
5
|
+
readonly byFile: (this: void, results: LintResultsByRule) => Map<string, LintQuickFix[]>;
|
|
6
|
+
/**
|
|
7
|
+
* The content of one file with the given fixes carried out, as {@link LintQuickFixes.byFile} groups them. Of two
|
|
8
|
+
* overlapping fixes only the one coming first in the file is kept, since the second would be applied to a range
|
|
9
|
+
* that no longer says what it did. What survives is then carried out back to front, so the offsets of the edits
|
|
10
|
+
* still to come stay valid.
|
|
11
|
+
*
|
|
12
|
+
* Fixes naming a file must all name the same one, as those of another file would cut at offsets of a text that
|
|
13
|
+
* is not this one. Fixes naming none are taken to belong to whatever `code` is.
|
|
14
|
+
*/
|
|
15
|
+
readonly apply: (this: void, code: string, fixes: readonly LintQuickFix[]) => string;
|
|
16
|
+
};
|