@eagleoutice/flowr 2.14.1 → 2.14.3
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 +142 -87
- package/abstract-interpretation/absint-visitor.d.ts +132 -25
- package/abstract-interpretation/absint-visitor.js +459 -99
- 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 +11 -6
- package/benchmark/calibration.js +19 -8
- package/benchmark/slicer.d.ts +7 -1
- package/benchmark/slicer.js +38 -34
- 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/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/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 +21 -8
- package/config.js +12 -5
- 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 -3
- 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 +63 -31
- package/dataflow/environments/built-in-props.d.ts +5 -1
- package/dataflow/environments/built-in-props.js +4 -0
- 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 +114 -3
- package/dataflow/environments/default-builtin-config.js +137 -35
- package/dataflow/environments/environment.d.ts +5 -5
- package/dataflow/environments/environment.js +5 -5
- package/dataflow/environments/identifier.d.ts +11 -1
- package/dataflow/environments/identifier.js +4 -1
- package/dataflow/environments/resolve-by-name.d.ts +7 -0
- package/dataflow/environments/resolve-by-name.js +12 -0
- 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 +3 -3
- package/dataflow/eval/resolve/alias-tracking.js +3 -3
- 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 +9 -6
- package/dataflow/eval/resolve/resolve-strings.js +2 -2
- package/dataflow/eval/resolve/resolve-working-directory.js +4 -3
- 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 +3 -1
- package/dataflow/fn/strict-function.js +7 -5
- package/dataflow/graph/call-graph.js +2 -2
- package/dataflow/graph/df-helper.d.ts +8 -1
- 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 +4 -3
- package/dataflow/graph/graph.js +6 -2
- package/dataflow/graph/match-args.d.ts +69 -0
- package/dataflow/graph/match-args.js +167 -0
- package/dataflow/info.d.ts +15 -6
- package/dataflow/info.js +0 -17
- package/dataflow/internal/control-flow.d.ts +114 -0
- package/dataflow/internal/control-flow.js +224 -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 +18 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +12 -1
- 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 +38 -30
- 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 +36 -8
- 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 +9 -4
- 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.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +11 -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 +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +71 -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 +13 -14
- 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 +14 -11
- 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 +50 -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 +20 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +6 -2
- 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 +41 -15
- 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 +33 -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 +17 -5
- package/documentation/wiki-analyzer.js +2 -2
- package/documentation/wiki-cfg.js +101 -106
- package/documentation/wiki-dataflow-graph.js +84 -53
- package/documentation/wiki-interface.js +1 -0
- package/documentation/wiki-linter.js +15 -1
- package/documentation/wiki-linting-and-testing.js +1 -16
- package/documentation/wiki-mk/doc-maker.js +6 -4
- package/documentation/wiki-query.js +14 -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 +46 -10
- package/linter/linter-rules.d.ts +40 -9
- package/linter/linter-rules.js +2 -0
- 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 +311 -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 +2 -2
- package/linter/rules/stop-with-call-arg.js +2 -2
- package/linter/rules/unclosed-connection.js +2 -2
- 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 +2 -2
- 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 +1 -7
- package/project/dependency-version-space.js +9 -8
- package/project/flowr-analyzer-builder.d.ts +4 -4
- package/project/flowr-analyzer.d.ts +4 -6
- package/project/flowr-analyzer.js +4 -5
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +22 -34
- 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/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 +2 -2
- package/project/sigdb/reader.d.ts +54 -13
- package/project/sigdb/reader.js +4 -3
- package/project/sigdb/schema.d.ts +3 -1
- 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/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-format.d.ts +2 -2
- package/queries/catalog/signature-query/signature-query-executor.js +4 -3
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +1 -1
- 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 +8 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.js +8 -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/node-id.d.ts +5 -1
- package/r-bridge/lang-4.x/ast/model/processing/node-id.js +0 -5
- 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 +3 -2
- package/search/search-executor/search-enrichers.d.ts +6 -0
- package/search/search-executor/search-enrichers.js +44 -5
- package/slicing/criterion/filters/all-variables.js +2 -1
- package/slicing/criterion/parse.js +8 -6
- 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 +24 -4
- package/util/objects.js +12 -0
- package/util/prefix.d.ts +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
package/util/mermaid/ast.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ParentInformation, RNodeWithParent } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
2
|
-
import
|
|
2
|
+
import { RProject } from '../../r-bridge/lang-4.x/ast/model/nodes/r-project';
|
|
3
3
|
import type { MermaidGraphPrinterInfo } from './info';
|
|
4
4
|
/**
|
|
5
5
|
* Serialize the normalized AST to mermaid format
|
package/util/mermaid/ast.js
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalizedAstToMermaid = normalizedAstToMermaid;
|
|
4
4
|
exports.normalizedAstToMermaidUrl = normalizedAstToMermaidUrl;
|
|
5
|
-
const
|
|
6
|
-
const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
5
|
+
const r_project_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-project");
|
|
7
6
|
const flowr_file_1 = require("../../project/context/flowr-file");
|
|
8
7
|
const info_1 = require("./info");
|
|
9
8
|
const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
|
|
10
9
|
const mermaid_1 = require("./mermaid");
|
|
10
|
+
const r_expression_list_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-expression-list");
|
|
11
|
+
const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
11
12
|
function identifyMermaidDirection(prefix) {
|
|
12
13
|
const directionMatch = prefix.match(/flowchart (TD|LR|RL|BT)/);
|
|
13
14
|
if (directionMatch) {
|
|
@@ -34,7 +35,7 @@ function normalizedAstToMermaid(ast, { prefix = 'flowchart TD\n', markStyle = in
|
|
|
34
35
|
const roleSuffix = context.role === "el-c" /* RoleInParent.ExpressionListChild */ || context.role === "call-arg" /* RoleInParent.FunctionCallArgument */ || context.role === "param" /* RoleInParent.FunctionDefinitionParameter */ ? `-${context.index}` : '';
|
|
35
36
|
output += ` n${n.info.parent} -->|"${context.role}${roleSuffix}"| n${n.info.id}\n`;
|
|
36
37
|
}
|
|
37
|
-
if (
|
|
38
|
+
if (r_expression_list_1.RExpressionList.is(n) && n.grouping !== undefined) {
|
|
38
39
|
output += ` n${n.info.id} -.-|"group-open"| n${n.grouping[0].info.id}\n`;
|
|
39
40
|
output += ` n${n.info.id} -.-|"group-close"| n${n.grouping[1].info.id}\n`;
|
|
40
41
|
}
|
|
@@ -52,7 +53,7 @@ function normalizedAstToMermaid(ast, { prefix = 'flowchart TD\n', markStyle = in
|
|
|
52
53
|
return false;
|
|
53
54
|
});
|
|
54
55
|
}
|
|
55
|
-
if (
|
|
56
|
+
if (r_project_1.RProject.is(ast)) {
|
|
56
57
|
for (const f of ast.files) {
|
|
57
58
|
// add a subgraph for each file
|
|
58
59
|
if (ast.files.length !== 1 || (f.filePath && f.filePath !== flowr_file_1.FlowrFile.INLINE_PATH)) {
|
package/util/mermaid/cfg.js
CHANGED
|
@@ -9,6 +9,8 @@ const auto_select_defaults_1 = require("../../reconstruct/auto-select/auto-selec
|
|
|
9
9
|
const info_1 = require("./info");
|
|
10
10
|
const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
|
|
11
11
|
const mermaid_1 = require("./mermaid");
|
|
12
|
+
const r_function_definition_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
|
|
13
|
+
const convert_values_1 = require("../../r-bridge/lang-4.x/convert-values");
|
|
12
14
|
exports.MermaidEntryPointDefaultMarkStyle = 'stroke:cyan,stroke-width:6.5px;';
|
|
13
15
|
exports.MermaidExitPointDefaultMarkStyle = 'stroke:green,stroke-width:6.5px;';
|
|
14
16
|
function getLexeme(n) {
|
|
@@ -18,28 +20,107 @@ function cfgOfNode(vert, normalizedVertex, id, content, output) {
|
|
|
18
20
|
if (normalizedVertex && content !== undefined) {
|
|
19
21
|
const start = control_flow_graph_1.CfgVertex.isExpression(vert) ? '([' : '[';
|
|
20
22
|
const end = control_flow_graph_1.CfgVertex.isExpression(vert) ? '])' : ']';
|
|
21
|
-
|
|
23
|
+
/* the code is set in bold so it stands out from the type and id above it */
|
|
24
|
+
const code = content ? `\n**${mermaid_1.Mermaid.escape(content.replaceAll(/\s+/gu, ' '))}**` : '';
|
|
25
|
+
const calls = control_flow_graph_1.CfgVertex.getCallTargets(vert) ? '\n calls:' + mermaid_1.Mermaid.escape(JSON.stringify([...control_flow_graph_1.CfgVertex.getCallTargets(vert)])) : '';
|
|
26
|
+
const name = `"\`${mermaid_1.Mermaid.escape(normalizedVertex.type)} (${id})${code}${calls}\`"`;
|
|
22
27
|
output += ` n${id}${start}${name}${end}\n`;
|
|
23
28
|
}
|
|
24
29
|
else {
|
|
25
|
-
output +=
|
|
30
|
+
output += ` n${id}[[${id}]]\n`;
|
|
26
31
|
}
|
|
27
32
|
return output;
|
|
28
33
|
}
|
|
29
34
|
const getDirRegex = /flowchart\s+([A-Za-z]+)/;
|
|
35
|
+
/**
|
|
36
|
+
* The vertices that make up each function body, keyed by the definition that holds it.
|
|
37
|
+
* Nothing flows into such a region, so it is reachable only from the entry the definition points at.
|
|
38
|
+
*/
|
|
39
|
+
function collectBodies(graph) {
|
|
40
|
+
const bodies = new Map();
|
|
41
|
+
for (const [id] of graph.vertices(false)) {
|
|
42
|
+
const children = graph.childrenOf(id);
|
|
43
|
+
if (children === undefined || children.length === 0) {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
const body = new Set();
|
|
47
|
+
const stack = [...children];
|
|
48
|
+
while (stack.length > 0) {
|
|
49
|
+
const current = stack.pop();
|
|
50
|
+
if (body.has(current)) {
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
body.add(current);
|
|
54
|
+
for (const next of graph.successors(current)) {
|
|
55
|
+
stack.push(next);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
bodies.set(id, [...body]);
|
|
59
|
+
}
|
|
60
|
+
return bodies;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The region a vertex belongs to: the function definition it is part of and whether it sits in its parameter list.
|
|
64
|
+
* A definition itself belongs to the region it is written in, not to the one it opens.
|
|
65
|
+
*/
|
|
66
|
+
function regionOf(id, normalizedAst) {
|
|
67
|
+
let current = normalizedAst.idMap.get(id);
|
|
68
|
+
current = current?.info.parent === undefined ? undefined : normalizedAst.idMap.get(current.info.parent);
|
|
69
|
+
let inParameters = false;
|
|
70
|
+
while (current !== undefined) {
|
|
71
|
+
inParameters ||= current.info.role === "param" /* RoleInParent.FunctionDefinitionParameter */;
|
|
72
|
+
if (r_function_definition_1.RFunctionDefinition.is(current)) {
|
|
73
|
+
return `${current.info.id}-${inParameters ? 'parameters' : 'body'}`;
|
|
74
|
+
}
|
|
75
|
+
current = current.info.parent === undefined ? undefined : normalizedAst.idMap.get(current.info.parent);
|
|
76
|
+
}
|
|
77
|
+
return 'top-level';
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* The code a simplified basic block stands for.
|
|
81
|
+
* Its elements are reconstructed per region, so the parameters of a function do not end up looking like its body,
|
|
82
|
+
* and a run that reconstructs to nothing but braces is named by its vertices instead.
|
|
83
|
+
*/
|
|
84
|
+
function blockCode(elems, normalizedAst) {
|
|
85
|
+
const runs = [];
|
|
86
|
+
let lastRegion = undefined;
|
|
87
|
+
for (const elem of elems) {
|
|
88
|
+
const region = regionOf(control_flow_graph_1.CfgVertex.getId(elem), normalizedAst);
|
|
89
|
+
if (region !== lastRegion) {
|
|
90
|
+
runs.push([]);
|
|
91
|
+
lastRegion = region;
|
|
92
|
+
}
|
|
93
|
+
runs[runs.length - 1].push(elem);
|
|
94
|
+
}
|
|
95
|
+
return runs.map(run => {
|
|
96
|
+
const code = (0, reconstruct_1.reconstructToCode)(normalizedAst, { nodes: new Set(run.map(control_flow_graph_1.CfgVertex.getId)) }, auto_select_defaults_1.doNotAutoSelect).code;
|
|
97
|
+
if (/[\p{L}\p{N}]/u.test(code)) {
|
|
98
|
+
return code;
|
|
99
|
+
}
|
|
100
|
+
/* nothing but braces means these vertices are where a structure is over, so we name them as the graph does */
|
|
101
|
+
return run.map(elem => `${normalizedAst.idMap.get(control_flow_graph_1.CfgVertex.getId(elem))?.type} (${control_flow_graph_1.CfgVertex.getId(elem)})`).join('\n');
|
|
102
|
+
}).join('\n');
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Name the condition a branch is decided by, which is where the branch starts from.
|
|
106
|
+
* Within a basic block that is its last element, so an edge still tells what triggers it.
|
|
107
|
+
*/
|
|
108
|
+
function conditionName(cfg, normalizedAst, from) {
|
|
109
|
+
const vertex = cfg.graph.getVertex(from);
|
|
110
|
+
const condition = control_flow_graph_1.CfgVertex.isBlock(vertex) ? control_flow_graph_1.CfgVertex.getId(control_flow_graph_1.CfgVertex.getBasicBlockElements(vertex).at(-1)) ?? from : from;
|
|
111
|
+
const lexeme = getLexeme(normalizedAst.idMap.get(condition));
|
|
112
|
+
return lexeme ? `${lexeme} (${condition})` : String(condition);
|
|
113
|
+
}
|
|
30
114
|
function shouldIncludeNode(simplify, v, include) {
|
|
31
115
|
if (simplify) {
|
|
32
116
|
// Only basic blocks are shown, so include the BB, if at least one child is selected
|
|
33
117
|
return control_flow_graph_1.CfgVertex.isBlock(v) && control_flow_graph_1.CfgVertex.getBasicBlockElements(v)
|
|
34
|
-
.filter(elem => !control_flow_graph_1.CfgVertex.isMarker(elem))
|
|
35
118
|
.some(elem => include.has(control_flow_graph_1.CfgVertex.getId(elem)));
|
|
36
119
|
}
|
|
37
120
|
else {
|
|
38
121
|
// Basic blocks and vertices are shown, include the BB, if all children are highlighted
|
|
39
122
|
return control_flow_graph_1.CfgVertex.isBlock(v)
|
|
40
|
-
? control_flow_graph_1.CfgVertex.getBasicBlockElements(v)
|
|
41
|
-
.filter(elem => !control_flow_graph_1.CfgVertex.isMarker(elem))
|
|
42
|
-
.every(elem => include.has(control_flow_graph_1.CfgVertex.getId(elem)))
|
|
123
|
+
? control_flow_graph_1.CfgVertex.getBasicBlockElements(v).every(elem => include.has(control_flow_graph_1.CfgVertex.getId(elem)))
|
|
43
124
|
: include.has(control_flow_graph_1.CfgVertex.getId(v));
|
|
44
125
|
}
|
|
45
126
|
}
|
|
@@ -47,7 +128,7 @@ function shouldIncludeNode(simplify, v, include) {
|
|
|
47
128
|
* Convert the control flow graph to a mermaid string.
|
|
48
129
|
* @see {@link MermaidCfgGraphPrinterInfo} for additional options.
|
|
49
130
|
*/
|
|
50
|
-
function cfgToMermaid(cfg, normalizedAst, { prefix = 'flowchart
|
|
131
|
+
function cfgToMermaid(cfg, normalizedAst, { prefix = 'flowchart TD\n', simplify = false, markStyle = info_1.MermaidDefaultMarkStyle, entryPointStyle = exports.MermaidEntryPointDefaultMarkStyle, exitPointStyle = exports.MermaidExitPointDefaultMarkStyle, includeOnlyIds, mark, includeBasicBlockLabel = true, basicBlockCharacterLimit = 100 } = {}) {
|
|
51
132
|
const hasBbandSimplify = simplify && cfg.graph.mayHaveBasicBlocks();
|
|
52
133
|
let output = prefix;
|
|
53
134
|
if (includeOnlyIds) {
|
|
@@ -62,16 +143,33 @@ function cfgToMermaid(cfg, normalizedAst, { prefix = 'flowchart BT\n', simplify
|
|
|
62
143
|
completed.add(childId);
|
|
63
144
|
}
|
|
64
145
|
}
|
|
65
|
-
// if we have a filter, we automatically add all vertices in the cfg that are *markers* for these ids and
|
|
66
|
-
for (const [id, v] of cfg.graph.vertices()) {
|
|
67
|
-
if (control_flow_graph_1.CfgVertex.isMarker(v) && completed.has(control_flow_graph_1.CfgVertex.unpackRootId(v))) {
|
|
68
|
-
completed.add(id);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
146
|
includeOnlyIds = completed;
|
|
72
147
|
}
|
|
73
148
|
const dirIs = getDirRegex.exec(prefix)?.at(1) ?? 'LR';
|
|
74
149
|
const diagramIncludedIds = new Set();
|
|
150
|
+
/* a function body runs when the function is called, so it is drawn as a region of its own instead of floating free */
|
|
151
|
+
const bodies = cfg.graph.mayHaveBasicBlocks() ? new Map() : collectBodies(cfg.graph);
|
|
152
|
+
const partOfBody = new Set(bodies.values().flatMap(body => body));
|
|
153
|
+
const emitBody = (defId) => {
|
|
154
|
+
const body = bodies.get(defId)?.filter(v => !includeOnlyIds || includeOnlyIds.has(v));
|
|
155
|
+
if (body === undefined || body.length === 0) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
const definition = normalizedAst.idMap.get(defId);
|
|
159
|
+
output += ` subgraph n${defId}-body ["body of ${mermaid_1.Mermaid.escape(limitTo(getLexeme(definition) ?? String(defId), 40))}"]\n`;
|
|
160
|
+
output += ` direction ${dirIs}\n`;
|
|
161
|
+
for (const vertexId of body) {
|
|
162
|
+
const vertex = cfg.graph.getVertex(vertexId);
|
|
163
|
+
if (vertex === undefined || control_flow_graph_1.CfgVertex.isBlock(vertex)) {
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
const node = normalizedAst.idMap.get(vertexId);
|
|
167
|
+
output = cfgOfNode(vertex, node, vertexId, getLexeme(node), output);
|
|
168
|
+
diagramIncludedIds.add(vertexId);
|
|
169
|
+
emitBody(vertexId);
|
|
170
|
+
}
|
|
171
|
+
output += ' end\n';
|
|
172
|
+
};
|
|
75
173
|
for (const [id, vertex] of cfg.graph.vertices(false)) {
|
|
76
174
|
const normalizedVertex = normalizedAst?.idMap.get(id);
|
|
77
175
|
const content = getLexeme(normalizedVertex);
|
|
@@ -81,9 +179,8 @@ function cfgToMermaid(cfg, normalizedAst, { prefix = 'flowchart BT\n', simplify
|
|
|
81
179
|
if (includeOnlyIds && !elems.some(elem => includeOnlyIds.has(control_flow_graph_1.CfgVertex.getId(elem)))) {
|
|
82
180
|
continue;
|
|
83
181
|
}
|
|
84
|
-
const
|
|
85
|
-
const
|
|
86
|
-
const name = `"\`${includeBasicBlockLabel ? `Basic Block (${id})\n` : ''}${mermaid_1.Mermaid.escape(reconstruct)}\`"`;
|
|
182
|
+
const code = limitTo(blockCode(elems, normalizedAst), basicBlockCharacterLimit);
|
|
183
|
+
const name = `"\`${includeBasicBlockLabel ? `Basic Block (${id})\n` : ''}${mermaid_1.Mermaid.escape(code)}\`"`;
|
|
87
184
|
output += ` n${id}[[${name}]]\n`;
|
|
88
185
|
diagramIncludedIds.add(control_flow_graph_1.CfgVertex.getId(vertex));
|
|
89
186
|
}
|
|
@@ -103,20 +200,21 @@ function cfgToMermaid(cfg, normalizedAst, { prefix = 'flowchart BT\n', simplify
|
|
|
103
200
|
const eid = control_flow_graph_1.CfgVertex.getId(element);
|
|
104
201
|
const childNormalizedVertex = normalizedAst?.idMap.get(eid);
|
|
105
202
|
const childContent = getLexeme(childNormalizedVertex);
|
|
106
|
-
output = cfgOfNode(
|
|
203
|
+
output = cfgOfNode(element, childNormalizedVertex, eid, childContent, output);
|
|
107
204
|
diagramIncludedIds.add(eid);
|
|
108
|
-
|
|
205
|
+
/* everything in a block runs one after the other, which is what these arrows show */
|
|
109
206
|
if (last) {
|
|
110
|
-
output += ` ${last}
|
|
207
|
+
output += ` ${last} --> n${eid}\n`;
|
|
111
208
|
}
|
|
112
209
|
last = `n${eid}`;
|
|
113
210
|
}
|
|
114
211
|
output += ' end\n';
|
|
115
212
|
}
|
|
116
213
|
}
|
|
117
|
-
else if (!includeOnlyIds || includeOnlyIds.has(id)) {
|
|
214
|
+
else if ((!includeOnlyIds || includeOnlyIds.has(id)) && !partOfBody.has(id)) {
|
|
118
215
|
output = cfgOfNode(vertex, normalizedVertex, id, content, output);
|
|
119
216
|
diagramIncludedIds.add(id);
|
|
217
|
+
emitBody(id);
|
|
120
218
|
}
|
|
121
219
|
}
|
|
122
220
|
for (const [from, targets] of cfg.graph.edges()) {
|
|
@@ -127,10 +225,18 @@ function cfgToMermaid(cfg, normalizedAst, { prefix = 'flowchart BT\n', simplify
|
|
|
127
225
|
if (!diagramIncludedIds.has(to)) {
|
|
128
226
|
continue;
|
|
129
227
|
}
|
|
130
|
-
|
|
131
|
-
const
|
|
132
|
-
const
|
|
133
|
-
|
|
228
|
+
/* a branch is drawn dashed, so what always runs stands out from what only runs under a condition */
|
|
229
|
+
const isBranch = control_flow_graph_1.CfgEdge.isControlDependency(edge);
|
|
230
|
+
const arrow = isBranch ? '-.->' : '-->';
|
|
231
|
+
const label = isBranch ? `branch on ${conditionName(cfg, normalizedAst, from)} if ${control_flow_graph_1.CfgEdge.unpackWhen(edge) === convert_values_1.RTrue ? 'T' : 'F'}` : control_flow_graph_1.CfgEdge.typeToString(edge);
|
|
232
|
+
output += ` n${from} ${arrow}|"${mermaid_1.Mermaid.escape(label)}"| n${to}\n`;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
for (const [defId] of bodies) {
|
|
236
|
+
const entry = cfg.graph.childrenOf(defId)?.[0];
|
|
237
|
+
/* no arrow head: the definition does not run its body, it only holds it */
|
|
238
|
+
if (entry !== undefined && diagramIncludedIds.has(defId) && diagramIncludedIds.has(entry)) {
|
|
239
|
+
output += ` n${defId} -. holds .- n${entry}\n`;
|
|
134
240
|
}
|
|
135
241
|
}
|
|
136
242
|
for (const entryPoint of cfg.entryPoints) {
|
package/util/mermaid/dfg.js
CHANGED
|
@@ -12,12 +12,12 @@ const identifier_1 = require("../../dataflow/environments/identifier");
|
|
|
12
12
|
const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
13
13
|
const edge_1 = require("../../dataflow/graph/edge");
|
|
14
14
|
const vertex_1 = require("../../dataflow/graph/vertex");
|
|
15
|
-
const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
|
|
16
15
|
const info_1 = require("./info");
|
|
17
16
|
const range_1 = require("../range");
|
|
18
17
|
const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
|
|
19
18
|
const info_2 = require("../../dataflow/info");
|
|
20
19
|
const df_helper_1 = require("../../dataflow/graph/df-helper");
|
|
20
|
+
const r_expression_list_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-expression-list");
|
|
21
21
|
function subflowToMermaid(nodeId, subflow, mermaid, idPrefix = '') {
|
|
22
22
|
if (subflow === undefined) {
|
|
23
23
|
return;
|
|
@@ -181,7 +181,7 @@ function vertexToMermaid(info, mermaid, id, idPrefix, mark, includeOnlyIds) {
|
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
183
|
const node = mermaid.rootGraph.idMap?.get(info.id);
|
|
184
|
-
const lexeme = node?.lexeme ?? (
|
|
184
|
+
const lexeme = node?.lexeme ?? (r_expression_list_1.RExpressionList.is(node) ? node?.grouping?.[0]?.lexeme : '') ?? '??';
|
|
185
185
|
let display = lexeme;
|
|
186
186
|
if (fCall && vertex_1.FunctionCallVertex.is(info)) {
|
|
187
187
|
const q = identifier_1.Identifier.toQualified(df_helper_1.Dataflow.origin(mermaid.rootGraph, origId), info.name, mermaid.qualifyBaseR !== false);
|
|
@@ -201,7 +201,7 @@ function vertexToMermaid(info, mermaid, id, idPrefix, mark, includeOnlyIds) {
|
|
|
201
201
|
const lnks = info.link?.origin ? ', links: ' + info.link.origin.map(o => mermaid_1.Mermaid.escapeId(o)).join(', ') : '';
|
|
202
202
|
const source = vertex_1.VariableDefinitionVertex.is(info) ? info.source : undefined;
|
|
203
203
|
const sources = source ? ', v: ' + source.map(s => mermaid_1.Mermaid.escapeId(s)).join(', ') : '';
|
|
204
|
-
const n = node?.info.fullRange ?? node?.location ?? (
|
|
204
|
+
const n = node?.info.fullRange ?? node?.location ?? (r_expression_list_1.RExpressionList.is(node) ? node?.grouping?.[0].location : undefined);
|
|
205
205
|
mermaid.nodeLines.push(` ${idPrefix}${id}${open}"\`${escapedName}\n *${range_1.SourceRange.format(n)}* (**id: ${id}**${deps}${lnks}${sources})${fCall ? displayFunctionArgMapping(info.args) : '' + (vertex_1.FunctionDefinitionVertex.is(info) && info.mode && info.mode.length > 0 ? mermaid_1.Mermaid.escape(JSON.stringify(info.mode)) : '')}\`"${close}`);
|
|
206
206
|
}
|
|
207
207
|
if (mark?.has(id)) {
|
|
@@ -218,25 +218,35 @@ function vertexToMermaid(info, mermaid, id, idPrefix, mark, includeOnlyIds) {
|
|
|
218
218
|
mermaid.nodeLines.push(' %% No edges found for ' + id);
|
|
219
219
|
return;
|
|
220
220
|
}
|
|
221
|
-
const artificialCdEdges = (info.cds ?? []).map(x => [x.id, { types: new Set([x.when ? 'CD-True' : 'CD-False']), file: x.file }]);
|
|
222
221
|
// eslint-disable-next-line prefer-const
|
|
223
|
-
for (let [target, edge] of
|
|
222
|
+
for (let [target, edge] of edges) {
|
|
224
223
|
if (includeOnlyIds && !includeOnlyIds.has(target)) {
|
|
225
224
|
continue;
|
|
226
225
|
}
|
|
227
226
|
const originalTarget = target;
|
|
228
227
|
target = mermaid_1.Mermaid.escapeId(target);
|
|
229
228
|
const edgeTypes = typeof edge.types == 'number' ? new Set(edge_1.DfEdge.splitTypes(edge)) : edge.types;
|
|
229
|
+
const carriesControlFlow = edgeTypes.has(edge_1.EdgeType.FlowEdge) || edgeTypes.has(edge_1.EdgeType.ControlEdge);
|
|
230
|
+
/* an edge that carries dataflow as well stays a dataflow edge, it just says the control flow goes there too */
|
|
231
|
+
const onlyControlFlow = carriesControlFlow && ![...edgeTypes].some(t => typeof t === 'number' && (t & ~edge_1.ControlFlowEdgeTypes) !== 0);
|
|
232
|
+
if (mermaid.simplified && onlyControlFlow) {
|
|
233
|
+
/* a simplified view is about the dataflow, and the control flow is a graph of its own */
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
230
236
|
const edgeId = encodeEdge(idPrefix + id, idPrefix + target, edgeTypes);
|
|
231
237
|
if (!mermaid.presentEdges.has(edgeId)) {
|
|
232
238
|
mermaid.presentEdges.add(edgeId);
|
|
233
|
-
const style = node_id_1.NodeId.isBuiltIn(target) ? '-.->' : '-->';
|
|
234
|
-
|
|
239
|
+
const style = node_id_1.NodeId.isBuiltIn(target) || onlyControlFlow ? '-.->' : '-->';
|
|
240
|
+
const names = [...edgeTypes].map(e => typeof e === 'number' ? edgeName(e) : e).join(', ');
|
|
241
|
+
const cd = edgeTypes.has(edge_1.EdgeType.ControlEdge) ? edge.cd : undefined;
|
|
242
|
+
const when = cd === undefined ? '' : ` (when: ${cd.when ?? 'any'})`;
|
|
243
|
+
const assumedFile = cd?.file ? `, from: ${mermaid_1.Mermaid.escape(cd.file)}` : '';
|
|
244
|
+
mermaid.edgeLines.push(` ${idPrefix}${id} ${style}|"${names}${when}${assumedFile}"| ${idPrefix}${target}`);
|
|
235
245
|
if (mermaid.mark?.has(id + '->' + target)) {
|
|
236
246
|
// who invented this syntax?!
|
|
237
247
|
mermaid.edgeLines.push(` linkStyle ${mermaid.presentEdges.size - 1} ${mermaid.markStyle.edge}`);
|
|
238
248
|
}
|
|
239
|
-
if (
|
|
249
|
+
if (onlyControlFlow) {
|
|
240
250
|
mermaid.edgeLines.push(` linkStyle ${mermaid.presentEdges.size - 1} stroke:gray,color:gray;`);
|
|
241
251
|
}
|
|
242
252
|
if (node_id_1.NodeId.isBuiltIn(target)) {
|
|
@@ -250,8 +260,19 @@ function vertexToMermaid(info, mermaid, id, idPrefix, mark, includeOnlyIds) {
|
|
|
250
260
|
}
|
|
251
261
|
}
|
|
252
262
|
}
|
|
263
|
+
/** control flow edges are drawn all over the graph, so they get a short name to save space */
|
|
264
|
+
function edgeName(type) {
|
|
265
|
+
switch (type) {
|
|
266
|
+
case edge_1.EdgeType.FlowEdge:
|
|
267
|
+
return 'flow';
|
|
268
|
+
case edge_1.EdgeType.ControlEdge:
|
|
269
|
+
return 'branch';
|
|
270
|
+
default:
|
|
271
|
+
return edge_1.DfEdge.typeToName(type);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
253
274
|
// make the passing of root ids more performant again
|
|
254
|
-
function graphToMermaidGraph(rootIds, { simplified, graph, prefix = 'flowchart
|
|
275
|
+
function graphToMermaidGraph(rootIds, { simplified, graph, prefix = 'flowchart TD', idPrefix = '', includeEnvironments = !simplified, mark, rootGraph, presentEdges = new Set(), markStyle = info_1.MermaidDefaultMarkStyle, includeOnlyIds, qualifyBaseR = true }) {
|
|
255
276
|
const mermaid = { nodeLines: prefix === null ? [] : [prefix], edgeLines: [], presentEdges, presentVertices: new Set(), mark, rootGraph: rootGraph ?? graph, includeEnvironments, markStyle, simplified, qualifyBaseR };
|
|
256
277
|
for (const [id, info] of graph.vertices(true)) {
|
|
257
278
|
if (rootIds.has(id)) {
|
|
@@ -265,7 +286,7 @@ function diffGraphsToMermaid(left, right, prefix) {
|
|
|
265
286
|
// we add the prefix ourselves
|
|
266
287
|
const { string: leftGraph, mermaid } = exports.DataflowMermaid.convert({ graph: left.graph, prefix: '', idPrefix: `l-${left.label}`, includeEnvironments: true, mark: left.mark });
|
|
267
288
|
const { string: rightGraph } = exports.DataflowMermaid.convert({ graph: right.graph, prefix: '', idPrefix: `r-${right.label}`, includeEnvironments: true, mark: right.mark, presentEdges: mermaid.presentEdges });
|
|
268
|
-
return `${prefix}flowchart
|
|
289
|
+
return `${prefix}flowchart TD\nsubgraph "${left.label}"\n${leftGraph}\nend\nsubgraph "${right.label}"\n${rightGraph}\nend`;
|
|
269
290
|
}
|
|
270
291
|
/**
|
|
271
292
|
* Converts two dataflow graphs to a mermaid url that visualizes their differences.
|
package/util/mermaid/mermaid.js
CHANGED
|
@@ -68,6 +68,8 @@ exports.Mermaid = {
|
|
|
68
68
|
*/
|
|
69
69
|
escapeId(text) {
|
|
70
70
|
text = String(text).replace(/[^a-zA-Z0-9:\-./]/g, '_');
|
|
71
|
+
/* a dash before a dash or a dot reads as the start of a link, e.g. the id of `$<-.grouped_df` would cut the line in two */
|
|
72
|
+
text = text.replace(/-(?=[-.])/g, '_');
|
|
71
73
|
return text.replace(/(^|[:\-./])([a-zA-Z0-9_]+)/g, (_m, sep, tok) => sep + (exports.Mermaid.reservedIds.has(tok) ? tok + '_' : tok));
|
|
72
74
|
},
|
|
73
75
|
/**
|
package/util/objects.d.ts
CHANGED
|
@@ -40,11 +40,22 @@ export declare function compactRecord(record: undefined): undefined;
|
|
|
40
40
|
export declare function compactRecord<T extends Record<string, unknown>>(record: T | undefined): DefinedRecord<T> | undefined;
|
|
41
41
|
type Primitive = string | number | boolean | bigint | symbol | null | undefined | Date | Function;
|
|
42
42
|
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
43
|
+
* What sits at the given path of `T`, the counterpart of {@link AutocompletablePaths}.
|
|
44
|
+
* `never` whenever the path names nothing.
|
|
45
45
|
*/
|
|
46
|
-
export type
|
|
47
|
-
|
|
46
|
+
export type ValueAtPath<T, Path extends string> = Path extends `${infer Key}.${infer Rest}` ? Key extends keyof T ? ValueAtPath<NonNullable<T[Key]>, Rest> : never : Path extends keyof T ? T[Path] : never;
|
|
47
|
+
/**
|
|
48
|
+
* Every path into `T`, as a union of string literals, so that an editor can complete them.
|
|
49
|
+
*
|
|
50
|
+
* The paths are built from the leaves up rather than by carrying a prefix down: a prefix that grows with the
|
|
51
|
+
* recursion costs enough instantiations that TypeScript gives up and hands back `any`, which type-checks
|
|
52
|
+
* everything and completes nothing. `Depth` bounds it whatever the shape of `T`.
|
|
53
|
+
*/
|
|
54
|
+
type OneLess = [never, 0, 1, 2, 3, 4, 5, 6, 7];
|
|
55
|
+
export type AutocompletablePaths<T, Depth extends number = 6> = [
|
|
56
|
+
Depth
|
|
57
|
+
] extends [never] ? never : T extends Primitive | readonly unknown[] ? never : {
|
|
58
|
+
[K in keyof T & string]: K | (NonNullable<T[K]> extends Primitive | readonly unknown[] ? never : `${K}.${AutocompletablePaths<NonNullable<T[K]>, OneLess[Depth]> & string}`);
|
|
48
59
|
}[keyof T & string];
|
|
49
60
|
/**
|
|
50
61
|
* This is a version of a deep clone that preserves unclonable values (like functions, symbols, ...) by keeping the same reference to them.
|
|
@@ -70,4 +81,13 @@ export declare function getOnPath(obj: unknown, path: string): unknown;
|
|
|
70
81
|
* @see {@link getOnPath} for the counterpart that reads such a path
|
|
71
82
|
*/
|
|
72
83
|
export declare function setOnPath(obj: object, path: string, value: unknown): void;
|
|
84
|
+
/**
|
|
85
|
+
* The members of an enum as name-value pairs.
|
|
86
|
+
* A numeric enum maps its values back to their names as well, which this leaves out.
|
|
87
|
+
* @example
|
|
88
|
+
* ```ts
|
|
89
|
+
* enumMembers(CfgVertexType) // [['Statement', 1], ['Expression', 2], ['Block', 3]]
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
export declare function enumMembers<T extends object>(enumObject: T): [name: string, value: T[keyof T]][];
|
|
73
93
|
export {};
|
package/util/objects.js
CHANGED
|
@@ -9,6 +9,7 @@ exports.deepClonePreserveUnclonable = deepClonePreserveUnclonable;
|
|
|
9
9
|
exports.looselyCompareObjects = looselyCompareObjects;
|
|
10
10
|
exports.getOnPath = getOnPath;
|
|
11
11
|
exports.setOnPath = setOnPath;
|
|
12
|
+
exports.enumMembers = enumMembers;
|
|
12
13
|
const assert_1 = require("./assert");
|
|
13
14
|
const json_1 = require("./json");
|
|
14
15
|
const log_1 = require("./log");
|
|
@@ -242,4 +243,15 @@ function setOnPath(obj, path, value) {
|
|
|
242
243
|
}
|
|
243
244
|
at[segments[segments.length - 1]] = value;
|
|
244
245
|
}
|
|
246
|
+
/**
|
|
247
|
+
* The members of an enum as name-value pairs.
|
|
248
|
+
* A numeric enum maps its values back to their names as well, which this leaves out.
|
|
249
|
+
* @example
|
|
250
|
+
* ```ts
|
|
251
|
+
* enumMembers(CfgVertexType) // [['Statement', 1], ['Expression', 2], ['Block', 3]]
|
|
252
|
+
* ```
|
|
253
|
+
*/
|
|
254
|
+
function enumMembers(enumObject) {
|
|
255
|
+
return Object.entries(enumObject).filter(([name]) => Number.isNaN(Number(name)));
|
|
256
|
+
}
|
|
245
257
|
//# sourceMappingURL=objects.js.map
|
package/util/prefix.d.ts
CHANGED
|
@@ -13,4 +13,4 @@
|
|
|
13
13
|
* findByPrefixIfUnique('', [ 'hello', 'hell' ]) // => undefined (empty prefix)
|
|
14
14
|
* ```
|
|
15
15
|
*/
|
|
16
|
-
export declare function findByPrefixIfUnique(prefix: string, keys:
|
|
16
|
+
export declare function findByPrefixIfUnique(prefix: string, keys: Iterable<string>): string | undefined;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/** the parts of the page a mark can point at, rather than a place in the script */
|
|
2
|
+
export declare enum PlaygroundBox {
|
|
3
|
+
/** the program slice the page built for the criterion the cursor sits on */
|
|
4
|
+
Slice = "slice",
|
|
5
|
+
/** flowR's own repl, which a mark of this name opens as it marks it */
|
|
6
|
+
Repl = "repl",
|
|
7
|
+
/** what the dependency query found */
|
|
8
|
+
Deps = "deps",
|
|
9
|
+
/** what the linter found */
|
|
10
|
+
Lints = "lints"
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* What a link can point at, written the way flowR names a place in a script:
|
|
14
|
+
*
|
|
15
|
+
* - `12` is the whole line, `12-15` the lines from 12 to 15
|
|
16
|
+
* - `12@sum` is the name `sum` on line 12, `12:5` whatever starts at that column
|
|
17
|
+
* - `lint:<rule>` is everything a linting rule reported, `lint:<rule>@12` its finding on that line
|
|
18
|
+
* - `dep:<kind>` is what the dependency query found of that kind, `dep:<kind>@12` the one on that line
|
|
19
|
+
* - a {@link PlaygroundBox} is one of the boxes of the page itself
|
|
20
|
+
* @see {@link PlaygroundMark.isValid} to check one, {@link PlaygroundMark.compress} to shorten a list
|
|
21
|
+
*/
|
|
22
|
+
export type PlaygroundMark = `${number}` | `${number}-${number}` | `${number}:${number}` | `${number}@${string}` | `lint:${string}` | `dep:${string}` | PlaygroundBox;
|
|
23
|
+
/**
|
|
24
|
+
* The helper object associated with {@link PlaygroundMark}, which makes it easy to check a mark and to
|
|
25
|
+
* keep a list of them as short as a link should be.
|
|
26
|
+
*/
|
|
27
|
+
export declare const PlaygroundMark: {
|
|
28
|
+
name: string;
|
|
29
|
+
/**
|
|
30
|
+
* Checks whether a value has a valid mark syntax. This does not check whether the mark points at
|
|
31
|
+
* anything: a line past the end of the script is valid and simply marks nothing.
|
|
32
|
+
*/
|
|
33
|
+
isValid(this: void, mark: unknown): mark is PlaygroundMark;
|
|
34
|
+
/**
|
|
35
|
+
* The same marks, as short as they go: without repetition, without what another mark already covers,
|
|
36
|
+
* and with runs of plain lines written as ranges. A link is read by people as well as by the page,
|
|
37
|
+
* so this shortens rather than packs.
|
|
38
|
+
*/
|
|
39
|
+
compress(this: void, marks: readonly PlaygroundMark[]): PlaygroundMark[];
|
|
40
|
+
/** the inverse of {@link PlaygroundMark.compress}: every range back to the lines it stands for */
|
|
41
|
+
expand(this: void, marks: readonly string[]): PlaygroundMark[];
|
|
42
|
+
};
|
|
43
|
+
/** everything a link can say about the page it opens; whatever is left out the page fills in itself */
|
|
44
|
+
export interface PlaygroundLinkParts {
|
|
45
|
+
/** the script the page opens with; left out, the page keeps its own sample */
|
|
46
|
+
readonly code?: string;
|
|
47
|
+
/** what the page marks when it opens, and what alt-click toggles from there on */
|
|
48
|
+
readonly marks?: readonly PlaygroundMark[];
|
|
49
|
+
/** the boxes that open folded away, for whatever the example is not about */
|
|
50
|
+
readonly collapsed?: readonly PlaygroundBox[];
|
|
51
|
+
/** where the cursor lands, as a slicing criterion (`12@sum`, `12:5`) or a bare line */
|
|
52
|
+
readonly at?: string;
|
|
53
|
+
/** slice forward from the criterion rather than backward */
|
|
54
|
+
readonly forward?: boolean;
|
|
55
|
+
/** the lines outside the slice step back, as the `dim the rest` box does on the page */
|
|
56
|
+
readonly dim?: boolean;
|
|
57
|
+
/** the repl is open, rather than folded away under the panes */
|
|
58
|
+
readonly replOpen?: boolean;
|
|
59
|
+
/** the whole slice is shown, rather than as much of it as the window has room for */
|
|
60
|
+
readonly wholeSlice?: boolean;
|
|
61
|
+
/** the configuration keys that differ from the defaults, as `a.b.c=<json>` */
|
|
62
|
+
readonly config?: readonly string[];
|
|
63
|
+
/** how wide the code pane is, in percent, and how tall the repl is, in pixels */
|
|
64
|
+
readonly split?: number;
|
|
65
|
+
readonly repl?: number;
|
|
66
|
+
/** another deployment of the page, for a local build or a fork */
|
|
67
|
+
readonly base?: string;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Everything about flowR's playground that is not the page itself: what a link to it carries, and how
|
|
71
|
+
* one is written. The page reads back exactly what {@link Playground.link} writes.
|
|
72
|
+
* @example
|
|
73
|
+
* ```ts
|
|
74
|
+
* Playground.link({ code: 'x <- 1\nprint(x)', at: '2@x', marks: ['2@x'] });
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
export declare const Playground: {
|
|
78
|
+
name: string;
|
|
79
|
+
/** where the page these links point at is served from */
|
|
80
|
+
BaseRef: string;
|
|
81
|
+
/** what a link can point at */
|
|
82
|
+
Mark: {
|
|
83
|
+
name: string;
|
|
84
|
+
/**
|
|
85
|
+
* Checks whether a value has a valid mark syntax. This does not check whether the mark points at
|
|
86
|
+
* anything: a line past the end of the script is valid and simply marks nothing.
|
|
87
|
+
*/
|
|
88
|
+
isValid(this: void, mark: unknown): mark is PlaygroundMark;
|
|
89
|
+
/**
|
|
90
|
+
* The same marks, as short as they go: without repetition, without what another mark already covers,
|
|
91
|
+
* and with runs of plain lines written as ranges. A link is read by people as well as by the page,
|
|
92
|
+
* so this shortens rather than packs.
|
|
93
|
+
*/
|
|
94
|
+
compress(this: void, marks: readonly PlaygroundMark[]): PlaygroundMark[];
|
|
95
|
+
/** the inverse of {@link PlaygroundMark.compress}: every range back to the lines it stands for */
|
|
96
|
+
expand(this: void, marks: readonly string[]): PlaygroundMark[];
|
|
97
|
+
};
|
|
98
|
+
/** the boxes of the page a mark can point at */
|
|
99
|
+
Box: typeof PlaygroundBox;
|
|
100
|
+
/**
|
|
101
|
+
* The link that opens the playground on exactly this: a script, what it points at, where its cursor
|
|
102
|
+
* sits, and how the page is laid out.
|
|
103
|
+
*/
|
|
104
|
+
link(this: void, parts: PlaygroundLinkParts): string;
|
|
105
|
+
/**
|
|
106
|
+
* A fragment is not a query, so `,`, `:`, and the braces a configuration carries stand in it as they
|
|
107
|
+
* are and only what would end it, split it, or read back as something else has to be escaped. `<` and
|
|
108
|
+
* `>` go together: both are excluded from a URI, and a bare one of either ends the autolink a chat
|
|
109
|
+
* client or a markdown reader made of the address. A link is also made not to end on punctuation,
|
|
110
|
+
* because that is where a chat client stops reading it.
|
|
111
|
+
*/
|
|
112
|
+
hash(this: void, fields: readonly (readonly [string, string])[]): string;
|
|
113
|
+
/**
|
|
114
|
+
* Where a criterion points in the given code, as the `<line>:<column>` the page opens the cursor on.
|
|
115
|
+
* `12@sum` is the name `sum` in line 12, `12:5` that column, `12` the first name on the line.
|
|
116
|
+
*/
|
|
117
|
+
positionOf(this: void, code: string, criterion: string): string | undefined;
|
|
118
|
+
/**
|
|
119
|
+
* The same script with what is nobody's business taken out: the directories a path names, addresses,
|
|
120
|
+
* and whatever a name like `token` or `password` was set to. This is what makes a script safe enough
|
|
121
|
+
* to travel in a bug report, and it is best-effort: it is not a guarantee that nothing private is left.
|
|
122
|
+
*/
|
|
123
|
+
sanitize(this: void, code: string): string;
|
|
124
|
+
/**
|
|
125
|
+
* The link a bug report carries, or `undefined` when the script is too long to travel in one. What
|
|
126
|
+
* {@link Playground.sanitize} takes out never enters the link.
|
|
127
|
+
*/
|
|
128
|
+
reportLink(this: void, code: string, parts?: Omit<PlaygroundLinkParts, "code">): string | undefined;
|
|
129
|
+
/** where a name stands in a line, as a name rather than as a substring of a longer one */
|
|
130
|
+
nameIndexIn(this: void, text: string, name: string): number | undefined;
|
|
131
|
+
};
|