@eagleoutice/flowr 2.14.4 → 2.15.1
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 +77 -64
- package/abstract-interpretation/absint-inference.d.ts +347 -0
- package/abstract-interpretation/{absint-visitor.js → absint-inference.js} +327 -97
- package/abstract-interpretation/abstract-semantics.d.ts +246 -0
- package/abstract-interpretation/abstract-semantics.js +3 -0
- package/abstract-interpretation/data-frame/{mappers/arguments.d.ts → arguments.d.ts} +18 -16
- package/abstract-interpretation/data-frame/{mappers/arguments.js → arguments.js} +20 -21
- package/abstract-interpretation/data-frame/dataframe-semantics.d.ts +52 -0
- package/abstract-interpretation/data-frame/dataframe-semantics.js +1665 -0
- package/abstract-interpretation/data-frame/resolve-args.js +4 -4
- package/abstract-interpretation/data-frame/semantics.d.ts +15 -21
- package/abstract-interpretation/data-frame/semantics.js +27 -29
- package/abstract-interpretation/data-frame/shape-inference.d.ts +28 -24
- package/abstract-interpretation/data-frame/shape-inference.js +14 -79
- package/abstract-interpretation/domains/interval-domain.d.ts +5 -1
- package/abstract-interpretation/domains/interval-domain.js +25 -33
- package/abstract-interpretation/domains/multi-value-state-domain.d.ts +6 -3
- package/abstract-interpretation/domains/multi-value-state-domain.js +24 -4
- package/abstract-interpretation/domains/partial-product-domain.d.ts +12 -6
- package/abstract-interpretation/domains/partial-product-domain.js +26 -43
- package/abstract-interpretation/domains/positive-interval-domain.d.ts +1 -6
- package/abstract-interpretation/domains/positive-interval-domain.js +3 -29
- package/abstract-interpretation/domains/product-domain.d.ts +1 -1
- package/abstract-interpretation/domains/set-range-domain.d.ts +6 -0
- package/abstract-interpretation/domains/set-range-domain.js +29 -62
- package/abstract-interpretation/domains/state-abstract-domain.d.ts +9 -2
- package/abstract-interpretation/domains/state-abstract-domain.js +26 -37
- package/abstract-interpretation/domains/{state-domain-like.d.ts → state-domain.d.ts} +10 -6
- package/abstract-interpretation/domains/{state-domain-like.js → state-domain.js} +1 -1
- package/abstract-interpretation/value-semantics.d.ts +113 -0
- package/abstract-interpretation/value-semantics.js +115 -0
- package/benchmark/slicer.js +12 -6
- package/benchmark/stats/feature-counts.d.ts +2 -1
- package/benchmark/stats/feature-counts.js +25 -1
- package/benchmark/stats/stats.d.ts +4 -0
- package/benchmark/summarizer/second-phase/graph.js +7 -0
- package/cli/repl/commands/repl-parse.js +11 -22
- package/cli/repl/parser/slice-query-parser.d.ts +2 -0
- package/cli/repl/parser/slice-query-parser.js +1 -0
- package/config.d.ts +30 -205
- package/config.js +37 -3
- package/control-flow/cfg-properties.d.ts +5 -0
- package/control-flow/cfg-properties.js +25 -7
- package/control-flow/control-flow-graph.d.ts +11 -37
- package/control-flow/control-flow-graph.js +33 -77
- package/control-flow/semantic-cfg-guided-visitor.d.ts +63 -320
- package/control-flow/semantic-cfg-guided-visitor.js +65 -320
- package/dataflow/environments/built-in-config.d.ts +2 -0
- package/dataflow/environments/built-in-proc-name.d.ts +4 -0
- package/dataflow/environments/built-in-proc-name.js +4 -0
- package/dataflow/environments/built-in-props.d.ts +192 -82
- package/dataflow/environments/built-in-props.js +336 -106
- package/dataflow/environments/built-in.d.ts +21 -9
- package/dataflow/environments/built-in.js +43 -12
- package/dataflow/environments/default-builtin-config.d.ts +3219 -313
- package/dataflow/environments/default-builtin-config.js +803 -1012
- package/dataflow/environments/environment.d.ts +26 -49
- package/dataflow/environments/environment.js +34 -47
- package/dataflow/environments/group-generics.d.ts +11 -2
- package/dataflow/environments/group-generics.js +22 -3
- package/dataflow/environments/identifier.d.ts +106 -6
- package/dataflow/environments/identifier.js +19 -1
- package/dataflow/environments/query-fn-props.d.ts +16 -8
- package/dataflow/environments/query-fn-props.js +45 -21
- package/dataflow/environments/resolve-by-name.js +9 -2
- package/dataflow/environments/scoping.d.ts +5 -0
- package/dataflow/environments/scoping.js +11 -0
- package/dataflow/eval/resolve/alias-tracking.d.ts +1 -1
- package/dataflow/eval/resolve/alias-tracking.js +24 -6
- package/dataflow/eval/resolve/resolve-numbers.d.ts +182 -7
- package/dataflow/eval/resolve/resolve-numbers.js +44 -9
- package/dataflow/eval/resolve/resolve-strings.d.ts +79 -2
- package/dataflow/eval/resolve/resolve-strings.js +16 -7
- package/dataflow/eval/resolve/resolve.d.ts +5 -22
- package/dataflow/eval/resolve/resolve.js +34 -34
- package/dataflow/eval/values/general.d.ts +9 -1
- package/dataflow/eval/values/general.js +22 -3
- package/dataflow/eval/values/sets/set-constants.d.ts +5 -0
- package/dataflow/eval/values/sets/set-constants.js +9 -1
- package/dataflow/eval/values/string/string-constants.d.ts +16 -15
- package/dataflow/eval/values/string/string-constants.js +59 -27
- package/dataflow/extractor.d.ts +2 -1
- package/dataflow/extractor.js +16 -4
- package/dataflow/fn/argument-roles.d.ts +35 -0
- package/dataflow/fn/argument-roles.js +252 -0
- package/dataflow/fn/class-declaration.d.ts +148 -0
- package/dataflow/fn/class-declaration.js +317 -0
- package/dataflow/fn/condition-handlers.d.ts +5 -0
- package/dataflow/fn/condition-handlers.js +13 -0
- package/dataflow/fn/exceptions-of-function.d.ts +21 -7
- package/dataflow/fn/exceptions-of-function.js +74 -43
- package/dataflow/fn/frame-reflection.d.ts +46 -0
- package/dataflow/fn/frame-reflection.js +169 -0
- package/dataflow/fn/function-props.d.ts +32 -0
- package/dataflow/fn/function-props.js +160 -0
- package/dataflow/fn/higher-order-function.d.ts +23 -5
- package/dataflow/fn/higher-order-function.js +64 -18
- package/dataflow/fn/strict-function.d.ts +24 -2
- package/dataflow/fn/strict-function.js +49 -19
- package/dataflow/graph/call-graph.js +10 -2
- package/dataflow/graph/df-helper.d.ts +1 -12
- package/dataflow/graph/df-helper.js +2 -19
- package/dataflow/graph/diff-dataflow-graph.d.ts +1 -1
- package/dataflow/graph/diff-dataflow-graph.js +2 -2
- package/dataflow/graph/graph.d.ts +39 -188
- package/dataflow/graph/graph.js +46 -163
- package/dataflow/graph/match-args.d.ts +34 -2
- package/dataflow/graph/match-args.js +45 -12
- package/dataflow/graph/vertex.d.ts +8 -0
- package/dataflow/info.d.ts +7 -5
- package/dataflow/info.js +1 -5
- package/dataflow/internal/control-flow.js +20 -17
- package/dataflow/internal/linker.d.ts +8 -37
- package/dataflow/internal/linker.js +22 -55
- package/dataflow/internal/process/functions/call/built-in/built-in-access.d.ts +1 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +7 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +3 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +8 -14
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +43 -50
- package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.d.ts +4 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +5 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-class-relation.d.ts +23 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-class-relation.js +24 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.d.ts +0 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +73 -27
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +2 -11
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +131 -92
- package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +17 -12
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +187 -99
- package/dataflow/internal/process/functions/call/built-in/built-in-load.d.ts +4 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-load.js +2 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.d.ts +2 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +4 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.d.ts +1 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +0 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-four.d.ts +31 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-s-four.js +101 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-dispatch.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +7 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +23 -21
- package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.d.ts +1 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-string-template.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +22 -1
- package/dataflow/internal/process/functions/call/common.d.ts +4 -6
- package/dataflow/internal/process/functions/call/common.js +2 -2
- package/dataflow/internal/process/functions/call/deferred.d.ts +1 -1
- package/dataflow/internal/process/functions/call/deferred.js +2 -2
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +5 -3
- package/dataflow/internal/process/functions/call/known-call-handling.js +6 -4
- package/dataflow/internal/process/functions/call/named-call-handling.js +19 -13
- package/dataflow/internal/process/functions/call/quoted.d.ts +2 -2
- package/dataflow/internal/process/functions/call/quoted.js +144 -28
- package/dataflow/origin/dfg-get-origin.js +23 -10
- package/dataflow/processor.d.ts +2 -1
- package/dataflow/processor.js +6 -0
- package/documentation/data/interface/doc-writing-code.js +2 -0
- package/documentation/doc-util/doc-search.js +1 -1
- package/documentation/wiki-absint.d.ts +11 -14
- package/documentation/wiki-absint.js +73 -59
- package/documentation/wiki-core.js +64 -24
- package/documentation/wiki-linter.js +1 -0
- package/documentation/wiki-query.js +82 -264
- package/documentation/wiki-signature-database.js +17 -5
- package/gas.d.ts +91 -47
- package/gas.js +97 -13
- package/index.d.ts +31 -0
- package/index.js +52 -0
- package/linter/linter-rules.d.ts +87 -23
- package/linter/linter-rules.js +3 -1
- package/linter/rules/absolute-path.d.ts +1 -1
- package/linter/rules/dataframe-access-validation.d.ts +1 -1
- package/linter/rules/dataframe-access-validation.js +10 -8
- package/linter/rules/dead-code.d.ts +1 -1
- package/linter/rules/deprecated-functions.js +14 -5
- package/linter/rules/file-path-validity.d.ts +1 -1
- package/linter/rules/naming-convention.d.ts +1 -1
- package/linter/rules/naming-convention.js +13 -2
- package/linter/rules/network-functions.d.ts +10 -5
- package/linter/rules/network-functions.js +48 -36
- package/linter/rules/no-leaked-credentials.d.ts +1 -1
- package/linter/rules/problematic-inputs.d.ts +1 -1
- package/linter/rules/problematic-inputs.js +1 -1
- package/linter/rules/seeded-randomness.d.ts +3 -2
- package/linter/rules/seeded-randomness.js +7 -3
- package/linter/rules/software-has-license.d.ts +1 -1
- package/linter/rules/software-has-tests.d.ts +1 -1
- package/linter/rules/stop-with-call-arg.d.ts +1 -1
- package/linter/rules/syntactically-valid.d.ts +1 -1
- package/linter/rules/unclosed-connection.d.ts +3 -3
- package/linter/rules/unclosed-connection.js +3 -4
- package/linter/rules/undefined-symbol.d.ts +1 -1
- package/linter/rules/unescaped-arguments.d.ts +161 -0
- package/linter/rules/unescaped-arguments.js +293 -0
- package/linter/rules/unused-definition.d.ts +1 -1
- package/linter/rules/unused-definition.js +49 -4
- package/linter/rules/unused-import.d.ts +1 -1
- package/linter/rules/useless-loop.d.ts +1 -1
- package/package.json +3 -198
- package/project/context/flowr-analyzer-environment-context.d.ts +12 -1
- package/project/context/flowr-analyzer-environment-context.js +33 -1
- package/project/context/flowr-analyzer-files-context.d.ts +24 -1
- package/project/context/flowr-analyzer-files-context.js +42 -21
- package/project/context/flowr-analyzer-functions-context.d.ts +8 -0
- package/project/context/flowr-analyzer-functions-context.js +2 -0
- package/project/context/flowr-analyzer-gas-context.d.ts +9 -1
- package/project/context/flowr-analyzer-gas-context.js +21 -0
- package/project/context/flowr-file.d.ts +16 -1
- package/project/context/flowr-file.js +26 -2
- package/project/plugins/file-plugins/files/flowr-description-file.d.ts +19 -20
- package/project/plugins/file-plugins/files/flowr-description-file.js +55 -41
- package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +9 -4
- package/project/plugins/file-plugins/files/flowr-jupyter-file.js +11 -3
- package/project/plugins/file-plugins/files/flowr-manifest-files.d.ts +6 -9
- package/project/plugins/file-plugins/files/flowr-manifest-files.js +5 -21
- package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +11 -12
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +48 -61
- package/project/plugins/file-plugins/files/flowr-news-file.d.ts +3 -12
- package/project/plugins/file-plugins/files/flowr-news-file.js +2 -19
- package/project/plugins/file-plugins/files/flowr-rd-file.d.ts +145 -0
- package/project/plugins/file-plugins/files/flowr-rd-file.js +676 -0
- package/project/plugins/file-plugins/files/flowr-rda-file.d.ts +122 -422
- package/project/plugins/file-plugins/files/flowr-rda-file.js +517 -1005
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +8 -2
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +10 -1
- package/project/plugins/file-plugins/files/flowr-sweave-file.d.ts +7 -2
- package/project/plugins/file-plugins/files/flowr-sweave-file.js +9 -1
- package/project/plugins/file-plugins/files/flowr-sysdata-file.d.ts +17 -0
- package/project/plugins/file-plugins/files/flowr-sysdata-file.js +40 -0
- package/project/plugins/file-plugins/flowr-analyzer-file-plugin.d.ts +2 -0
- package/project/plugins/file-plugins/flowr-analyzer-file-plugin.js +3 -1
- package/project/plugins/file-plugins/flowr-analyzer-rd-file-plugin.d.ts +58 -0
- package/project/plugins/file-plugins/flowr-analyzer-rd-file-plugin.js +95 -0
- package/project/plugins/file-plugins/flowr-analyzer-sysdata-file-plugin.d.ts +23 -0
- package/project/plugins/file-plugins/flowr-analyzer-sysdata-file-plugin.js +33 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +33 -72
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-namespace-file-plugin.js +17 -15
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +20 -37
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +29 -53
- package/project/plugins/package-version-plugins/package.js +2 -1
- package/project/plugins/plugin-registry.d.ts +3 -1
- package/project/plugins/plugin-registry.js +11 -0
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +20 -4
- package/project/sigdb/build.d.ts +9 -15
- package/project/sigdb/build.js +101 -42
- package/project/sigdb/decode.d.ts +10 -4
- package/project/sigdb/decode.js +60 -21
- package/project/sigdb/memory-source.d.ts +4 -0
- package/project/sigdb/memory-source.js +8 -0
- package/project/sigdb/reader.d.ts +57 -100
- package/project/sigdb/reader.js +157 -108
- package/project/sigdb/schema.d.ts +90 -26
- package/project/sigdb/schema.js +12 -6
- package/queries/base-query-format.d.ts +7 -0
- package/queries/base-query-format.js +29 -0
- package/queries/catalog/absint-query/absint-query-executor.js +8 -6
- package/queries/catalog/absint-query/absint-query-format.d.ts +20 -9
- package/queries/catalog/absint-query/absint-query-format.js +32 -19
- package/queries/catalog/call-context-query/call-context-query-executor.js +3 -3
- package/queries/catalog/call-graph-query/call-graph-query-format.d.ts +1 -1
- package/queries/catalog/cluster-query/cluster-query-format.d.ts +1 -1
- package/queries/catalog/control-flow-query/control-flow-query-format.d.ts +1 -1
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.js +1 -1
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.d.ts +1 -1
- package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +1 -1
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +33 -7
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +1 -1
- package/queries/catalog/dependencies-query/function-info/derived-functions.d.ts +2 -2
- package/queries/catalog/dependencies-query/function-info/derived-functions.js +14 -4
- package/queries/catalog/dependencies-query/function-info/read-functions.js +7 -121
- package/queries/catalog/dependencies-query/function-info/statistics-functions.d.ts +1 -1
- package/queries/catalog/dependencies-query/function-info/statistics-functions.js +2 -2
- package/queries/catalog/dependencies-query/function-info/visualize-functions.js +4 -46
- package/queries/catalog/dependencies-query/function-info/write-functions.js +3 -76
- package/queries/catalog/dependencies-query/implicit-echo.js +2 -2
- package/queries/catalog/dependencies-query/link-devices.d.ts +2 -2
- package/queries/catalog/dependencies-query/link-devices.js +6 -7
- package/queries/catalog/dice-query/dice-query-executor.js +1 -1
- package/queries/catalog/dice-query/dice-query-format.d.ts +1 -1
- package/queries/catalog/does-call-query/does-call-query-executor.js +4 -0
- package/queries/catalog/does-call-query/does-call-query-format.d.ts +7 -1
- package/queries/catalog/files-query/files-query-format.d.ts +1 -1
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +1 -1
- package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +1 -1
- package/queries/catalog/id-map-query/id-map-query-format.d.ts +1 -1
- package/queries/catalog/input-sources-query/input-source-functions.d.ts +1 -1
- package/queries/catalog/input-sources-query/input-source-functions.js +2 -2
- package/queries/catalog/input-sources-query/input-sources-query-format.d.ts +7 -17
- package/queries/catalog/input-sources-query/input-sources-query-format.js +11 -27
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.js +1 -1
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.d.ts +3 -8
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +2 -11
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-executor.d.ts +4 -0
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-executor.js +60 -0
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.d.ts +35 -0
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.js +63 -0
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +3 -6
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +3 -8
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +2 -11
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.d.ts +3 -8
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.js +2 -12
- package/queries/catalog/linter-query/linter-query-format.d.ts +1 -1
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +1 -1
- package/queries/catalog/origin-query/origin-query-format.d.ts +1 -1
- package/queries/catalog/project-query/project-query-format.d.ts +1 -1
- package/queries/catalog/provenance-query/provenance-query-format.d.ts +3 -8
- package/queries/catalog/provenance-query/provenance-query-format.js +2 -14
- package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +1 -1
- package/queries/catalog/search-query/search-query-format.d.ts +1 -1
- package/queries/catalog/signature-query/signature-query-executor.d.ts +5 -10
- package/queries/catalog/signature-query/signature-query-executor.js +87 -93
- package/queries/catalog/signature-query/signature-query-format.d.ts +20 -5
- package/queries/catalog/signature-query/signature-query-format.js +16 -4
- package/queries/catalog/signature-query/signature-query-render.js +18 -4
- package/queries/catalog/slice-query-options.d.ts +14 -0
- package/queries/catalog/slice-query-options.js +15 -0
- package/queries/catalog/static-slice-query/static-slice-query-executor.d.ts +2 -1
- package/queries/catalog/static-slice-query/static-slice-query-executor.js +3 -2
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +4 -3
- package/queries/catalog/static-slice-query/static-slice-query-format.js +7 -5
- package/queries/query-function-filter.d.ts +8 -3
- package/queries/query-function-filter.js +16 -6
- package/queries/query.d.ts +38 -38
- package/queries/query.js +30 -4
- package/r-bridge/lang-4.x/ast/model/model.d.ts +5 -0
- package/r-bridge/lang-4.x/ast/model/model.js +14 -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-argument.d.ts +1 -0
- 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-break.d.ts +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-expression-list.d.ts +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-function-call.d.ts +1 -0
- 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-if-then-else.d.ts +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-logical.d.ts +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-number.d.ts +1 -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-pipe.d.ts +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-string.d.ts +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-unary-op.d.ts +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/processing/node-id.d.ts +17 -9
- package/r-bridge/lang-4.x/ast/model/processing/node-id.js +35 -27
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +33 -22
- package/reconstruct/reconstruct.d.ts +9 -20
- package/reconstruct/reconstruct.js +66 -28
- package/search/flowr-search-filters.d.ts +7 -6
- package/search/flowr-search-filters.js +6 -4
- package/search/search-executor/search-enrichers.d.ts +10 -10
- package/search/search-executor/search-enrichers.js +32 -3
- package/search/search-executor/search-transformer.js +15 -23
- package/slicing/criterion/parse.js +2 -12
- package/slicing/static/slice-call.js +1 -8
- package/slicing/static/static-slicer.js +1 -1
- package/util/collections/bimap.js +14 -6
- package/util/objects.js +16 -17
- package/util/r-value.d.ts +5 -4
- package/util/record.d.ts +38 -3
- package/util/record.js +48 -1
- package/util/simple-df/dfg-ascii.js +1 -1
- package/util/text/strings.d.ts +5 -0
- package/util/text/strings.js +10 -0
- package/util/version.js +2 -2
- package/abstract-interpretation/absint-visitor.d.ts +0 -223
- package/abstract-interpretation/data-frame/mappers/access-mapper.d.ts +0 -19
- package/abstract-interpretation/data-frame/mappers/access-mapper.js +0 -151
- package/abstract-interpretation/data-frame/mappers/function-mapper.d.ts +0 -287
- package/abstract-interpretation/data-frame/mappers/function-mapper.js +0 -1096
- package/abstract-interpretation/data-frame/mappers/replacement-mapper.d.ts +0 -15
- package/abstract-interpretation/data-frame/mappers/replacement-mapper.js +0 -207
- package/queries/catalog/inspect-strictness-query/inspect-strictness-query-executor.d.ts +0 -6
- package/queries/catalog/inspect-strictness-query/inspect-strictness-query-executor.js +0 -25
- package/queries/catalog/inspect-strictness-query/inspect-strictness-query-format.d.ts +0 -31
- package/queries/catalog/inspect-strictness-query/inspect-strictness-query-format.js +0 -56
|
@@ -0,0 +1,676 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.FlowrDataListFile = exports.FlowrRdMetaFile = exports.FlowrRdTopicIndexFile = exports.FlowrRdMacroFile = exports.FlowrRdIndexFile = exports.FlowrRdFile = exports.RdIndex = void 0;
|
|
7
|
+
exports.parseAnIndex = parseAnIndex;
|
|
8
|
+
exports.parseRdTopicIndex = parseRdTopicIndex;
|
|
9
|
+
exports.parseDataList = parseDataList;
|
|
10
|
+
exports.rdMetaOf = rdMetaOf;
|
|
11
|
+
exports.parseRdMacros = parseRdMacros;
|
|
12
|
+
exports.expandRdMacros = expandRdMacros;
|
|
13
|
+
exports.parseRdPage = parseRdPage;
|
|
14
|
+
exports.rdIndexOf = rdIndexOf;
|
|
15
|
+
const fs_1 = __importDefault(require("fs"));
|
|
16
|
+
const path_1 = __importDefault(require("path"));
|
|
17
|
+
const flowr_file_1 = require("../../../context/flowr-file");
|
|
18
|
+
const flowr_rda_file_1 = require("./flowr-rda-file");
|
|
19
|
+
const arrays_1 = require("../../../../util/collections/arrays");
|
|
20
|
+
const assert_1 = require("../../../../util/assert");
|
|
21
|
+
const strings_1 = require("../../../../util/text/strings");
|
|
22
|
+
const objects_1 = require("../../../../util/objects");
|
|
23
|
+
/** an S4 method alias, `sin,float32-method`; the generic is everything up to the first comma, as no R name holds one */
|
|
24
|
+
const S4MethodAlias = /^([^,]+),.*-method$/;
|
|
25
|
+
/** The manual of a package: its {@link RdPage}s plus the alias-to-topic mapping they (or an installed package's `help/AnIndex`) state. See {@link RdIndex.topicOf} and {@link RdIndex.documents}. */
|
|
26
|
+
class RdIndex {
|
|
27
|
+
/** alias to the topic documenting it */
|
|
28
|
+
aliases = new Map();
|
|
29
|
+
/** topic to its page, only for the pages that were parsed (an `AnIndex` states no page content) */
|
|
30
|
+
pages = new Map();
|
|
31
|
+
/** generic name to the topic of an S4 method registered on it, so `sin` finds `sin,float32-method`'s page */
|
|
32
|
+
s4 = new Map();
|
|
33
|
+
/** the distinct topics, grown as aliases arrive so {@link topics} never has to rebuild the union */
|
|
34
|
+
topicSet = new Set();
|
|
35
|
+
/** topic to its title, from whatever source stated one (`INDEX`, `Meta/Rd.rds`, a page's `\title{}`) */
|
|
36
|
+
titles = new Map();
|
|
37
|
+
/** memoized {@link topics}, dropped whenever {@link topicSet} grows */
|
|
38
|
+
topicList;
|
|
39
|
+
/** Adds a parsed page with all of its aliases. */
|
|
40
|
+
add(page) {
|
|
41
|
+
this.pages.set(page.name, page);
|
|
42
|
+
return this.addPage(page.name, page.aliases, page.title, true);
|
|
43
|
+
}
|
|
44
|
+
/** Adds the pages of an installed package's `Meta/Rd.rds`, which states aliases and titles but no content. */
|
|
45
|
+
addMeta(entries) {
|
|
46
|
+
for (const { name, aliases, title } of entries) {
|
|
47
|
+
this.addPage(name, aliases, title);
|
|
48
|
+
}
|
|
49
|
+
return this;
|
|
50
|
+
}
|
|
51
|
+
/** Adds the `topic -> title` entries of an `INDEX` or `demo/00Index`; such a table states no aliases. */
|
|
52
|
+
addTopics(entries) {
|
|
53
|
+
for (const [topic, title] of entries) {
|
|
54
|
+
this.addPage(topic, [], title.length > 0 ? title : undefined);
|
|
55
|
+
}
|
|
56
|
+
return this;
|
|
57
|
+
}
|
|
58
|
+
/** Adds the `alias -> topic` pairs of an installed package's `help/AnIndex`, which lists no page content. */
|
|
59
|
+
addAliases(mapping) {
|
|
60
|
+
for (const [alias, topic] of mapping) {
|
|
61
|
+
this.alias(alias, topic);
|
|
62
|
+
}
|
|
63
|
+
return this;
|
|
64
|
+
}
|
|
65
|
+
addPage(topic, aliases, title, overwriteTitle = false) {
|
|
66
|
+
this.alias(topic, topic);
|
|
67
|
+
for (const alias of aliases) {
|
|
68
|
+
this.alias(alias, topic);
|
|
69
|
+
}
|
|
70
|
+
if (title !== undefined && (overwriteTitle || !this.titles.has(topic))) {
|
|
71
|
+
this.titles.set(topic, title);
|
|
72
|
+
}
|
|
73
|
+
return this;
|
|
74
|
+
}
|
|
75
|
+
alias(alias, topic) {
|
|
76
|
+
if (!this.aliases.has(alias)) {
|
|
77
|
+
this.aliases.set(alias, topic);
|
|
78
|
+
}
|
|
79
|
+
if (!this.topicSet.has(topic)) {
|
|
80
|
+
this.topicSet.add(topic);
|
|
81
|
+
this.topicList = undefined;
|
|
82
|
+
}
|
|
83
|
+
const s4 = S4MethodAlias.exec(alias);
|
|
84
|
+
if (s4 && !this.s4.has(s4[1])) {
|
|
85
|
+
this.s4.set(s4[1], topic);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/** Every topic (page name) the manual knows, in insertion order. */
|
|
89
|
+
topics() {
|
|
90
|
+
return this.topicList ??= [...this.topicSet];
|
|
91
|
+
}
|
|
92
|
+
/** The parsed page of `topic`, `undefined` when only its aliases are known (an `AnIndex` without `man/`). */
|
|
93
|
+
page(topic) {
|
|
94
|
+
return this.pages.get(topic);
|
|
95
|
+
}
|
|
96
|
+
/** The one-line title of `topic`, `undefined` when no source that stated the topic also stated one. */
|
|
97
|
+
title(topic) {
|
|
98
|
+
return this.titles.get(topic);
|
|
99
|
+
}
|
|
100
|
+
/** Whether the manual holds nothing at all, so no answer of it means "undocumented". */
|
|
101
|
+
get empty() {
|
|
102
|
+
return this.aliases.size === 0;
|
|
103
|
+
}
|
|
104
|
+
/** The page documenting `name`, resolved as R's help system does: own alias first, then the fallbacks that let a name share a page (replacement, S4 method, S3 generic; longest generic first). */
|
|
105
|
+
topicOf(name) {
|
|
106
|
+
const direct = this.aliases.get(name);
|
|
107
|
+
if (direct !== undefined) {
|
|
108
|
+
return { topic: direct, via: this.pages.has(name) && direct === name ? "page" /* RdMatch.Page */ : "alias" /* RdMatch.Alias */ };
|
|
109
|
+
}
|
|
110
|
+
/* `dim<-` is documented on `dim`'s page far more often than on one of its own */
|
|
111
|
+
const swapped = this.aliases.get(name.endsWith('<-') ? name.slice(0, -2) : name + '<-');
|
|
112
|
+
if (swapped !== undefined) {
|
|
113
|
+
return { topic: swapped, via: "replacement" /* RdMatch.Replacement */ };
|
|
114
|
+
}
|
|
115
|
+
/* a method the package registered is only documented under its `generic,signature-method` alias */
|
|
116
|
+
const s4 = S4MethodAlias.exec(name);
|
|
117
|
+
const method = s4 ? this.aliases.get(s4[1]) : this.s4.get(name);
|
|
118
|
+
if (method !== undefined) {
|
|
119
|
+
return { topic: method, via: "s4-method" /* RdMatch.S4Method */ };
|
|
120
|
+
}
|
|
121
|
+
for (const [prefix] of (0, strings_1.dottedSplits)(name)) {
|
|
122
|
+
const generic = this.aliases.get(prefix);
|
|
123
|
+
if (generic !== undefined) {
|
|
124
|
+
return { topic: generic, via: "s3-generic" /* RdMatch.S3Generic */ };
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return undefined;
|
|
128
|
+
}
|
|
129
|
+
/** Whether any page documents `name` (see {@link topicOf} for what counts). */
|
|
130
|
+
documents(name) {
|
|
131
|
+
return this.topicOf(name) !== undefined;
|
|
132
|
+
}
|
|
133
|
+
/** The manual of the package installed at `dir` (the installation directory, holding its `DESCRIPTION`), from its `help/AnIndex`: aliases only, as an installed package ships no `man/`. */
|
|
134
|
+
static fromInstalledPackage(dir) {
|
|
135
|
+
const index = path_1.default.join(dir, 'help', 'AnIndex');
|
|
136
|
+
if (!fs_1.default.existsSync(index)) {
|
|
137
|
+
return undefined;
|
|
138
|
+
}
|
|
139
|
+
try {
|
|
140
|
+
return new RdIndex().addAliases(parseAnIndex(fs_1.default.readFileSync(index, 'utf8')));
|
|
141
|
+
}
|
|
142
|
+
catch {
|
|
143
|
+
return undefined;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
exports.RdIndex = RdIndex;
|
|
148
|
+
/** the non-empty lines of a table file, as the three parsers below all work line by line */
|
|
149
|
+
const lines = (content) => content.split(/\r?\n/).filter(l => l.trim().length > 0);
|
|
150
|
+
/** one `alias<TAB>topic` line of an `AnIndex`; anything else in the file is not a pair */
|
|
151
|
+
const AnIndexLine = /^(\S+)[ \t]+(\S+)\s*$/;
|
|
152
|
+
/** Parses an installed package's `help/AnIndex`: one `alias<TAB>topic` pair per line. */
|
|
153
|
+
function parseAnIndex(content) {
|
|
154
|
+
return lines(content).map(l => AnIndexLine.exec(l)).filter(m => m !== null).map(m => [m[1], m[2]]);
|
|
155
|
+
}
|
|
156
|
+
/** Parses R's fixed-width topic table (a package's `INDEX`, a `demo/00Index`): the topic starts in the first column, indented lines continue its title. Answers what a package documents where no `man/` sources are. */
|
|
157
|
+
function parseRdTopicIndex(content) {
|
|
158
|
+
const entries = [];
|
|
159
|
+
for (const line of lines(content)) {
|
|
160
|
+
const previous = entries[entries.length - 1];
|
|
161
|
+
if (Whitespace.test(line[0])) {
|
|
162
|
+
/* an indented line continues the title of the entry above it */
|
|
163
|
+
if (previous !== undefined) {
|
|
164
|
+
previous[1] = `${previous[1]} ${line.trim()}`.trim();
|
|
165
|
+
}
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
const gap = line.search(Whitespace);
|
|
169
|
+
entries.push(gap < 0 ? [line.trim(), ''] : [line.slice(0, gap), line.slice(gap).trim()]);
|
|
170
|
+
}
|
|
171
|
+
return entries;
|
|
172
|
+
}
|
|
173
|
+
/** Parses a package's `data/datalist`: a bare line names a dataset whose object shares its name, a `set: a b c` line one providing several under other names, which is written down nowhere else. */
|
|
174
|
+
function parseDataList(content) {
|
|
175
|
+
return lines(content).map(line => {
|
|
176
|
+
const entry = line.trim();
|
|
177
|
+
const colon = entry.indexOf(':');
|
|
178
|
+
const dataset = colon < 0 ? entry : entry.slice(0, colon).trim();
|
|
179
|
+
const objects = colon < 0 ? [] : entry.slice(colon + 1).split(Whitespace).filter(o => o.length > 0);
|
|
180
|
+
return [dataset, objects.length > 0 ? objects : [dataset]];
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
/** Reads the `Meta/Rd.rds` data frame (as {@link RDAParser.parseObject} returns it) into one entry per page. */
|
|
184
|
+
function rdMetaOf(table) {
|
|
185
|
+
const frame = table;
|
|
186
|
+
const columns = frame?.type === flowr_rda_file_1.SexpType.VecSxp ? frame.value : undefined;
|
|
187
|
+
const names = (0, flowr_rda_file_1.stringsOf)((0, flowr_rda_file_1.attributeOf)(frame, 'names'));
|
|
188
|
+
if (columns === undefined || names.length !== columns.length) {
|
|
189
|
+
return [];
|
|
190
|
+
}
|
|
191
|
+
const column = (of) => columns[names.indexOf(of)];
|
|
192
|
+
const text = (of) => (0, flowr_rda_file_1.stringsOf)(column(of));
|
|
193
|
+
const lists = (of) => column(of)?.value ?? [];
|
|
194
|
+
const [files, topics, types, titles] = [text('File'), text('Name'), text('Type'), text('Title')];
|
|
195
|
+
const [aliases, keywords] = [lists('Aliases'), lists('Keywords')];
|
|
196
|
+
/* a page with no name is no topic anyone can ask for */
|
|
197
|
+
return topics.map((name, row) => !name ? undefined : (0, objects_1.compactRecord)({
|
|
198
|
+
name,
|
|
199
|
+
file: files[row] || undefined,
|
|
200
|
+
title: titles[row] || undefined,
|
|
201
|
+
type: types[row] || undefined,
|
|
202
|
+
aliases: (0, flowr_rda_file_1.stringsOf)(aliases[row]),
|
|
203
|
+
keywords: (0, flowr_rda_file_1.stringsOf)(keywords[row])
|
|
204
|
+
})).filter(assert_1.isNotUndefined);
|
|
205
|
+
}
|
|
206
|
+
/** `text` with its Rd comments removed. A `%` starts one in every section unless escaped, and only an *odd* run of backslashes escapes it. Newlines are kept, as a comment ends at one. */
|
|
207
|
+
function stripRdComments(text) {
|
|
208
|
+
let out = '';
|
|
209
|
+
let kept = 0;
|
|
210
|
+
let backslashes = 0;
|
|
211
|
+
for (let i = 0; i < text.length; i++) {
|
|
212
|
+
const c = text[i];
|
|
213
|
+
if (c === '%' && backslashes % 2 === 0) {
|
|
214
|
+
out += text.slice(kept, i);
|
|
215
|
+
const nl = text.indexOf('\n', i);
|
|
216
|
+
if (nl < 0) {
|
|
217
|
+
return out;
|
|
218
|
+
}
|
|
219
|
+
kept = nl; // the newline the comment ends at is not part of it
|
|
220
|
+
i = nl;
|
|
221
|
+
}
|
|
222
|
+
backslashes = c === '\\' ? backslashes + 1 : 0;
|
|
223
|
+
}
|
|
224
|
+
return out + text.slice(kept);
|
|
225
|
+
}
|
|
226
|
+
/** The group starting at `open` (must index a `{`), `undefined` when unclosed; `\{` is content, not a boundary. */
|
|
227
|
+
function readGroup(text, open) {
|
|
228
|
+
let depth = 0;
|
|
229
|
+
for (let i = open; i < text.length; i++) {
|
|
230
|
+
const c = text[i];
|
|
231
|
+
if (c === '\\') {
|
|
232
|
+
i++;
|
|
233
|
+
}
|
|
234
|
+
else if (c === '{') {
|
|
235
|
+
depth++;
|
|
236
|
+
}
|
|
237
|
+
else if (c === '}' && --depth === 0) {
|
|
238
|
+
return { body: text.slice(open + 1, i), end: i + 1 };
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return undefined;
|
|
242
|
+
}
|
|
243
|
+
/** The brace group that follows `from`, skipping the whitespace between them; `undefined` when none does. */
|
|
244
|
+
function readGroupAfter(text, from) {
|
|
245
|
+
let at = from;
|
|
246
|
+
while (at < text.length && Whitespace.test(text[at])) {
|
|
247
|
+
at++;
|
|
248
|
+
}
|
|
249
|
+
return text[at] === '{' ? readGroup(text, at) : undefined;
|
|
250
|
+
}
|
|
251
|
+
/** Every group opened by `marker`, in order, resuming past each so a nested occurrence is not read twice. */
|
|
252
|
+
function* groupsAt(text, marker, from = 0) {
|
|
253
|
+
marker.lastIndex = from;
|
|
254
|
+
let match;
|
|
255
|
+
while ((match = marker.exec(text)) !== null) {
|
|
256
|
+
const group = readGroup(text, match.index + match[0].length - 1);
|
|
257
|
+
if (group === undefined) {
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
yield group;
|
|
261
|
+
marker.lastIndex = Math.max(group.end, marker.lastIndex);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
/** Every `marker`-opened group paired with the group right after it, `undefined` when none follows; resumes past whichever of the two was found so neither is read twice. Shared by {@link parseArguments}'s `\item{names}{description}` and {@link parseRdMacros}'s `\newcommand{name}{body}`, which only differ in what a missing second group means to them. */
|
|
265
|
+
function* groupPairsAt(text, marker) {
|
|
266
|
+
for (const first of groupsAt(text, marker)) {
|
|
267
|
+
const second = readGroupAfter(text, first.end);
|
|
268
|
+
yield [first, second];
|
|
269
|
+
marker.lastIndex = second?.end ?? first.end;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
/** matches a `\macro{` opening at the current {@link RegExp.lastIndex}, i.e. it must be set before every use */
|
|
273
|
+
const RdMacroUseAt = /\\([A-Za-z]+)\s*\{/y;
|
|
274
|
+
/** The group opening at `open` (must index a `{`), read in the same sweep as every `\macro{...}` nested inside it -- self first, then each child in the order it was found, matching a macro named `name` (`undefined` for a group with no name of its own, e.g. one just used to scope a run of text). `undefined` when the group never closes: nothing found while scanning it is trustworthy then, so the caller gives up on it too. */
|
|
275
|
+
function consumeGroup(text, open, name) {
|
|
276
|
+
const bodyStart = open + 1;
|
|
277
|
+
const found = [];
|
|
278
|
+
for (let i = bodyStart; i < text.length; i++) {
|
|
279
|
+
const c = text[i];
|
|
280
|
+
if (c === '{') {
|
|
281
|
+
const child = consumeGroup(text, i, undefined);
|
|
282
|
+
if (child === undefined) {
|
|
283
|
+
return undefined;
|
|
284
|
+
}
|
|
285
|
+
found.push(...child.found);
|
|
286
|
+
i = child.end - 1;
|
|
287
|
+
}
|
|
288
|
+
else if (c === '}') {
|
|
289
|
+
const self = name === undefined ? [] : [[name, text.slice(bodyStart, i), open, i + 1]];
|
|
290
|
+
return { end: i + 1, found: [...self, ...found] };
|
|
291
|
+
}
|
|
292
|
+
else if (c === '\\') {
|
|
293
|
+
RdMacroUseAt.lastIndex = i;
|
|
294
|
+
const use = RdMacroUseAt.exec(text);
|
|
295
|
+
if (use === null) {
|
|
296
|
+
i++; // a lone escape, e.g. `\{` or `\%`, is content, not a boundary
|
|
297
|
+
continue;
|
|
298
|
+
}
|
|
299
|
+
const child = consumeGroup(text, i + use[0].length - 1, use[1]);
|
|
300
|
+
if (child === undefined) {
|
|
301
|
+
return undefined;
|
|
302
|
+
}
|
|
303
|
+
found.push(...child.found);
|
|
304
|
+
i = child.end - 1;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
return undefined;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* The bodies of every `\macro{...}` in `text`, keyed by macro and in order of appearance. A use of a macro
|
|
311
|
+
* inside a recorded group of the same macro is not a second use of it, which is how a per-macro scan reads
|
|
312
|
+
* `\alias{\alias{x}}`; a use of any other macro nested in there is found as usual.
|
|
313
|
+
*/
|
|
314
|
+
function macroGroups(text) {
|
|
315
|
+
const groups = new Map();
|
|
316
|
+
const recordedUntil = new Map();
|
|
317
|
+
for (let i = 0; i < text.length; i++) {
|
|
318
|
+
if (text[i] !== '\\') {
|
|
319
|
+
continue;
|
|
320
|
+
}
|
|
321
|
+
RdMacroUseAt.lastIndex = i;
|
|
322
|
+
const use = RdMacroUseAt.exec(text);
|
|
323
|
+
if (use === null) {
|
|
324
|
+
continue;
|
|
325
|
+
}
|
|
326
|
+
const group = consumeGroup(text, i + use[0].length - 1, use[1]);
|
|
327
|
+
if (group === undefined) {
|
|
328
|
+
break; // an unclosed group swallows the rest of the page; nothing past it can be trusted
|
|
329
|
+
}
|
|
330
|
+
for (const [macro, body, at, end] of group.found) {
|
|
331
|
+
if (at < (recordedUntil.get(macro) ?? 0)) {
|
|
332
|
+
continue;
|
|
333
|
+
}
|
|
334
|
+
recordedUntil.set(macro, end);
|
|
335
|
+
groups.set(macro, [...groups.get(macro) ?? [], body]);
|
|
336
|
+
}
|
|
337
|
+
i = group.end - 1;
|
|
338
|
+
}
|
|
339
|
+
return groups;
|
|
340
|
+
}
|
|
341
|
+
/** the characters an Rd backslash escapes to their literal selves, rather than starting a macro */
|
|
342
|
+
const RdEscapes = new Set(['%', '{', '}', '\\', '&', '$', '#', '_', '^', '~']);
|
|
343
|
+
/** the macros that stand for an ellipsis rather than for markup around their argument */
|
|
344
|
+
const RdEllipsisMacros = new Set(['dots', 'ldots']);
|
|
345
|
+
/** leading brace groups that hold no text: `\Sexpr{}` holds R code, `\if{}`/`\ifelse{}` open with an output format */
|
|
346
|
+
const RdNonTextGroups = new Map([['Sexpr', 1], ['if', 1], ['ifelse', 1]]);
|
|
347
|
+
/** the name following a backslash, e.g. the `code` of `\code{x}`; sticky so {@link plainText} need not slice */
|
|
348
|
+
const RdMacroName = /[A-Za-z]+/y;
|
|
349
|
+
/** the bracketed option a macro may carry, e.g. the `[pkg]` of `\link[pkg]{fn}`; sticky like {@link RdMacroName} */
|
|
350
|
+
const RdMacroOption = /\[[^\]]*\]/y;
|
|
351
|
+
const Whitespace = /\s/;
|
|
352
|
+
/** Rd markup reduced to the text it renders: escapes resolved, markup macros dropped in favor of what they wrap, whitespace collapsed. Escapes resolve *while* scanning, which is what lets base R's `\alias{\{}` survive; stripping the braces first would leave a stray backslash instead of the name. */
|
|
353
|
+
function plainText(body) {
|
|
354
|
+
let out = '';
|
|
355
|
+
for (let i = 0; i < body.length; i++) {
|
|
356
|
+
const c = body[i];
|
|
357
|
+
if (c === '{' || c === '}') {
|
|
358
|
+
out += ' '; // a boundary is no text, but it does separate the words around it
|
|
359
|
+
continue;
|
|
360
|
+
}
|
|
361
|
+
if (c !== '\\') {
|
|
362
|
+
out += c;
|
|
363
|
+
continue;
|
|
364
|
+
}
|
|
365
|
+
const next = body[i + 1];
|
|
366
|
+
if (next !== undefined && RdEscapes.has(next)) {
|
|
367
|
+
out += next;
|
|
368
|
+
i++;
|
|
369
|
+
continue;
|
|
370
|
+
}
|
|
371
|
+
RdMacroName.lastIndex = i + 1;
|
|
372
|
+
const macro = RdMacroName.exec(body)?.[0];
|
|
373
|
+
if (macro === undefined) {
|
|
374
|
+
continue; // a lone trailing backslash says nothing
|
|
375
|
+
}
|
|
376
|
+
i += macro.length;
|
|
377
|
+
if (RdEllipsisMacros.has(macro)) {
|
|
378
|
+
out += '...';
|
|
379
|
+
continue;
|
|
380
|
+
}
|
|
381
|
+
RdMacroOption.lastIndex = i + 1;
|
|
382
|
+
const option = RdMacroOption.exec(body)?.[0];
|
|
383
|
+
if (option !== undefined) {
|
|
384
|
+
i += option.length;
|
|
385
|
+
}
|
|
386
|
+
for (let group = RdNonTextGroups.get(macro) ?? 0; group > 0; group--) {
|
|
387
|
+
const skipped = readGroupAfter(body, i + 1);
|
|
388
|
+
if (skipped === undefined) {
|
|
389
|
+
break;
|
|
390
|
+
}
|
|
391
|
+
i = skipped.end - 1;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
return out.replace(/\s+/g, ' ').trim();
|
|
395
|
+
}
|
|
396
|
+
/** the `\item{a, b}` of an `\arguments{}` block, whose group holds the names one description documents */
|
|
397
|
+
const RdArgumentItem = /\\item\s*\{/g;
|
|
398
|
+
/** `\arguments{ \item{a, b}{...} }` unfolded to one entry per argument name */
|
|
399
|
+
function parseArguments(block) {
|
|
400
|
+
const args = new Map();
|
|
401
|
+
if (block === undefined) {
|
|
402
|
+
return args;
|
|
403
|
+
}
|
|
404
|
+
for (const [names, description] of groupPairsAt(block, RdArgumentItem)) {
|
|
405
|
+
const text = description === undefined ? '' : plainText(description.body);
|
|
406
|
+
/* `\item{x, y}{...}` documents both names with the one description */
|
|
407
|
+
for (const name of names.body.split(',').map(n => plainText(n)).filter(n => n.length > 0)) {
|
|
408
|
+
args.set(name, text);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
return args;
|
|
412
|
+
}
|
|
413
|
+
/** the `\method{}{}` spellings of a usage: `\method{print}{foo}` is `print.foo`, the S4 form its alias name */
|
|
414
|
+
const RdUsageMethod = /\\(S4method|S3method|method)\{([^{}]*)\}\{([^{}]*)\}/g;
|
|
415
|
+
/** the `\dots` an Rd usage writes for the `...` parameter */
|
|
416
|
+
const RdUsageDots = /\\l?dots(?![A-Za-z])/g;
|
|
417
|
+
/** `\special{...}`, which wraps a usage R cannot state as an ordinary call */
|
|
418
|
+
const RdUsageSpecial = /\\special\{([^{}]*)\}/g;
|
|
419
|
+
/** The usage entries of a `\usage{}` block (`block`, `undefined` when the page states none) as R code, one per *expression*: an entry ends where its brackets balance again, so a call wrapped over three lines stays one usage. Rd escapes resolve to their characters. */
|
|
420
|
+
function parseUsage(block) {
|
|
421
|
+
if (block === undefined) {
|
|
422
|
+
return [];
|
|
423
|
+
}
|
|
424
|
+
const expanded = block
|
|
425
|
+
.replace(RdUsageMethod, (_m, kind, generic, signature) => kind === 'S4method' ? `${generic},${signature}-method` : `${generic}.${signature}`)
|
|
426
|
+
.replace(RdUsageDots, '...')
|
|
427
|
+
.replace(RdUsageSpecial, '$1');
|
|
428
|
+
const entries = [];
|
|
429
|
+
let current = '';
|
|
430
|
+
let depth = 0;
|
|
431
|
+
for (const line of lines(expanded)) {
|
|
432
|
+
const code = line.replace(/\\([%{}\\])/g, '$1').trim();
|
|
433
|
+
if (code.length === 0) {
|
|
434
|
+
continue; // a line that is only escapes adds nothing; the bracket depth is what ends an entry
|
|
435
|
+
}
|
|
436
|
+
current = current.length === 0 ? code : `${current} ${code}`;
|
|
437
|
+
depth += bracketDepth(code);
|
|
438
|
+
if (depth <= 0) {
|
|
439
|
+
entries.push(current);
|
|
440
|
+
current = '';
|
|
441
|
+
depth = 0;
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
if (current.length > 0) {
|
|
445
|
+
entries.push(current);
|
|
446
|
+
}
|
|
447
|
+
return entries;
|
|
448
|
+
}
|
|
449
|
+
/** how much `code` opens more brackets than it closes, ignoring what a string literal holds */
|
|
450
|
+
function bracketDepth(code) {
|
|
451
|
+
let depth = 0;
|
|
452
|
+
let quote = undefined;
|
|
453
|
+
for (let i = 0; i < code.length; i++) {
|
|
454
|
+
const c = code[i];
|
|
455
|
+
if (quote !== undefined) {
|
|
456
|
+
if (c === '\\') {
|
|
457
|
+
i++;
|
|
458
|
+
}
|
|
459
|
+
else if (c === quote) {
|
|
460
|
+
quote = undefined;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
else if (c === '"' || c === '\'' || c === '`') {
|
|
464
|
+
quote = c;
|
|
465
|
+
}
|
|
466
|
+
else if (c === '(' || c === '[' || c === '{') {
|
|
467
|
+
depth++;
|
|
468
|
+
}
|
|
469
|
+
else if (c === ')' || c === ']' || c === '}') {
|
|
470
|
+
depth--;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
return depth;
|
|
474
|
+
}
|
|
475
|
+
/** a `\newcommand`/`\renewcommand` definition, whose two groups are the name and the body */
|
|
476
|
+
const RdMacroDefinition = /\\(?:re)?newcommand\s*\{/g;
|
|
477
|
+
/** the `#1`..`#9` placeholders a macro body substitutes its arguments into */
|
|
478
|
+
const RdMacroParameter = /#([1-9])/g;
|
|
479
|
+
/** the name group of a definition holds the macro *with* its backslash, as it is written where it is used */
|
|
480
|
+
const RdDeclaredMacro = /^\s*\\([A-Za-z]+)\s*$/;
|
|
481
|
+
/** how often {@link expandRdMacros} rescans: a definition may use another, but R allows no recursion among them */
|
|
482
|
+
const MaxMacroExpansions = 4;
|
|
483
|
+
/** Parses the `\newcommand{\name}{body}` definitions of a `man/macros/` file (installed: `help/macros/`). It documents nothing itself, so pages have to be parsed {@link parseRdPage|with} it to read what they say. */
|
|
484
|
+
function parseRdMacros(content) {
|
|
485
|
+
const macros = new Map();
|
|
486
|
+
const text = stripRdComments(content);
|
|
487
|
+
for (const [name, body] of groupPairsAt(text, RdMacroDefinition)) {
|
|
488
|
+
if (body === undefined) {
|
|
489
|
+
break;
|
|
490
|
+
}
|
|
491
|
+
const declared = RdDeclaredMacro.exec(name.body)?.[1];
|
|
492
|
+
if (declared !== undefined) {
|
|
493
|
+
macros.set(declared, { params: highestMacroParameter(body.body), body: body.body });
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
return macros;
|
|
497
|
+
}
|
|
498
|
+
/** the highest `#n` a macro body uses, which is how many arguments a use of it carries */
|
|
499
|
+
function highestMacroParameter(body) {
|
|
500
|
+
let highest = 0;
|
|
501
|
+
RdMacroParameter.lastIndex = 0;
|
|
502
|
+
let match;
|
|
503
|
+
while ((match = RdMacroParameter.exec(body)) !== null) {
|
|
504
|
+
highest = Math.max(highest, Number(match[1]));
|
|
505
|
+
}
|
|
506
|
+
return highest;
|
|
507
|
+
}
|
|
508
|
+
/** `text` (the Rd source, comments already stripped) with every use of a package-defined macro replaced by what it stands for, using `macros` (what {@link parseRdMacros} read from the package's macro files); a use carrying fewer groups than its definition takes is left alone rather than half-applied. */
|
|
509
|
+
function expandRdMacros(text, macros) {
|
|
510
|
+
let out = text;
|
|
511
|
+
for (let round = 0; round < MaxMacroExpansions; round++) {
|
|
512
|
+
const next = expandMacrosOnce(out, macros);
|
|
513
|
+
if (next === out) {
|
|
514
|
+
break;
|
|
515
|
+
}
|
|
516
|
+
out = next;
|
|
517
|
+
}
|
|
518
|
+
return out;
|
|
519
|
+
}
|
|
520
|
+
/** one pass of {@link expandRdMacros}, so a body that itself uses a macro is caught by the next */
|
|
521
|
+
function expandMacrosOnce(text, macros) {
|
|
522
|
+
let out = '';
|
|
523
|
+
let kept = 0;
|
|
524
|
+
for (let i = 0; i < text.length; i++) {
|
|
525
|
+
if (text[i] !== '\\') {
|
|
526
|
+
continue;
|
|
527
|
+
}
|
|
528
|
+
RdMacroName.lastIndex = i + 1;
|
|
529
|
+
const name = RdMacroName.exec(text)?.[0];
|
|
530
|
+
if (name === undefined) {
|
|
531
|
+
continue;
|
|
532
|
+
}
|
|
533
|
+
const macro = macros.get(name);
|
|
534
|
+
if (macro === undefined) {
|
|
535
|
+
i += name.length; // skip the name so its own letters are not rescanned for a backslash
|
|
536
|
+
continue;
|
|
537
|
+
}
|
|
538
|
+
let at = i + 1 + name.length;
|
|
539
|
+
const args = [];
|
|
540
|
+
for (let arg = 0; arg < macro.params; arg++) {
|
|
541
|
+
const group = readGroupAfter(text, at);
|
|
542
|
+
if (group === undefined) {
|
|
543
|
+
break;
|
|
544
|
+
}
|
|
545
|
+
args.push(group.body);
|
|
546
|
+
at = group.end;
|
|
547
|
+
}
|
|
548
|
+
if (args.length < macro.params) {
|
|
549
|
+
i = at; // not enough groups to apply it, so this use stays as written
|
|
550
|
+
continue;
|
|
551
|
+
}
|
|
552
|
+
out += text.slice(kept, i) + macro.body.replace(RdMacroParameter, (m, n) => args[Number(n) - 1] ?? m);
|
|
553
|
+
kept = at;
|
|
554
|
+
i = at - 1;
|
|
555
|
+
}
|
|
556
|
+
return out + text.slice(kept);
|
|
557
|
+
}
|
|
558
|
+
/** Parses one `.Rd` manual page: `content` is the raw page, `fallbackName` the topic to assume when the page states no `\name{}` (usually the file's basename), and `macros` the package's own `\newcommand`s, so a page using them states what it renders. */
|
|
559
|
+
function parseRdPage(content, fallbackName = '', macros) {
|
|
560
|
+
const stripped = stripRdComments(content);
|
|
561
|
+
const text = macros !== undefined && macros.size > 0 ? expandRdMacros(stripped, macros) : stripped;
|
|
562
|
+
const groups = macroGroups(text);
|
|
563
|
+
const one = (macro) => groups.get(macro)?.[0];
|
|
564
|
+
const many = (macro) => (groups.get(macro) ?? []).map(plainText).filter(e => e.length > 0);
|
|
565
|
+
const [name, title, docType] = [one('name'), one('title'), one('docType')];
|
|
566
|
+
return (0, objects_1.compactRecord)({
|
|
567
|
+
name: name === undefined ? fallbackName : plainText(name),
|
|
568
|
+
aliases: many('alias'),
|
|
569
|
+
keywords: many('keyword'),
|
|
570
|
+
docType: docType === undefined ? undefined : plainText(docType),
|
|
571
|
+
title: title === undefined ? undefined : plainText(title),
|
|
572
|
+
usage: parseUsage(one('usage')),
|
|
573
|
+
arguments: parseArguments(one('arguments'))
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
/** the topic a page file documents when it states no `\name{}`: its basename without the `.Rd` extension */
|
|
577
|
+
function topicOfPath(filePath) {
|
|
578
|
+
return path_1.default.basename(filePath).replace(/\.rd$/i, '');
|
|
579
|
+
}
|
|
580
|
+
/** Decorates a text file to expose its content as the {@link RdPage} it documents. */
|
|
581
|
+
class FlowrRdFile extends flowr_file_1.FlowrWrappedFile {
|
|
582
|
+
loadContent() {
|
|
583
|
+
return this.pageWith();
|
|
584
|
+
}
|
|
585
|
+
/** The page with `macros` (what {@link parseRdMacros} read from the package's `man/macros/` files) expanded. Without any it is the cached {@link content}; with them it is parsed afresh, as the macros live in *other* files this one cannot know when loaded. */
|
|
586
|
+
pageWith(macros) {
|
|
587
|
+
if (macros !== undefined && macros.size === 0) {
|
|
588
|
+
return this.content();
|
|
589
|
+
}
|
|
590
|
+
const file = this.wrapped;
|
|
591
|
+
return parseRdPage(file.content().toString(), topicOfPath(file.path()), macros);
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
exports.FlowrRdFile = FlowrRdFile;
|
|
595
|
+
/** Decorates an installed package's `help/AnIndex` to expose its `alias -> topic` pairs. */
|
|
596
|
+
class FlowrRdIndexFile extends flowr_file_1.FlowrWrappedFile {
|
|
597
|
+
loadContent() {
|
|
598
|
+
return parseAnIndex(this.wrapped.content().toString());
|
|
599
|
+
}
|
|
600
|
+
/** Reads the `help/AnIndex` of the package installed at `dir` as a file, without touching the disk yet. */
|
|
601
|
+
static forInstalledPackage(dir) {
|
|
602
|
+
return new FlowrRdIndexFile(new flowr_file_1.FlowrTextFile(path_1.default.join(dir, 'help', 'AnIndex')));
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
exports.FlowrRdIndexFile = FlowrRdIndexFile;
|
|
606
|
+
/** Decorates a `man/macros/` file to expose the `\newcommand`s it defines for the package's pages. */
|
|
607
|
+
class FlowrRdMacroFile extends flowr_file_1.FlowrWrappedFile {
|
|
608
|
+
loadContent() {
|
|
609
|
+
return parseRdMacros(this.wrapped.content().toString());
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
exports.FlowrRdMacroFile = FlowrRdMacroFile;
|
|
613
|
+
/** Decorates an `INDEX` (or a `demo/00Index`) to expose its `topic -> title` table. */
|
|
614
|
+
class FlowrRdTopicIndexFile extends flowr_file_1.FlowrWrappedFile {
|
|
615
|
+
loadContent() {
|
|
616
|
+
return parseRdTopicIndex(this.wrapped.content().toString());
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
exports.FlowrRdTopicIndexFile = FlowrRdTopicIndexFile;
|
|
620
|
+
/** Decorates an installed package's `Meta/Rd.rds` to expose the help table it serializes. */
|
|
621
|
+
class FlowrRdMetaFile extends flowr_file_1.FlowrWrappedFile {
|
|
622
|
+
loadContent() {
|
|
623
|
+
try {
|
|
624
|
+
return rdMetaOf(new flowr_rda_file_1.RDAParser(this.wrapped, false).parseObject());
|
|
625
|
+
}
|
|
626
|
+
catch {
|
|
627
|
+
/* a bundle written by an R newer than the deserializer knows is no reason to fail the analysis */
|
|
628
|
+
return [];
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
exports.FlowrRdMetaFile = FlowrRdMetaFile;
|
|
633
|
+
/** Decorates a `data/datalist` to expose which objects each of a package's datasets provides. */
|
|
634
|
+
class FlowrDataListFile extends flowr_file_1.FlowrWrappedFile {
|
|
635
|
+
loadContent() {
|
|
636
|
+
return parseDataList(this.wrapped.content().toString());
|
|
637
|
+
}
|
|
638
|
+
/** The objects `data(<dataset>)` brings into scope, empty for a dataset this file does not list. */
|
|
639
|
+
objectsOf(dataset) {
|
|
640
|
+
return this.content().find(([name]) => name === dataset)?.[1] ?? [];
|
|
641
|
+
}
|
|
642
|
+
/** Every object any of the package's datasets provides. */
|
|
643
|
+
objects() {
|
|
644
|
+
return (0, arrays_1.uniqueArray)(this.content().flatMap(([, objects]) => objects));
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
exports.FlowrDataListFile = FlowrDataListFile;
|
|
648
|
+
/** Collects every loaded manual source of `files` (the project's documentation files, i.e. `ctx.files.getFilesByRole(FileRole.Documentation)`) into one {@link RdIndex}: `man/` pages, `INDEX` tables, an installed package's `help/AnIndex` and `Meta/Rd.rds`. Nothing is cached, so keep the result rather than asking again. The `man/macros/` definitions come first, as a page using one only renders once they are known. */
|
|
649
|
+
function rdIndexOf(files) {
|
|
650
|
+
const all = [...files];
|
|
651
|
+
const macros = new Map();
|
|
652
|
+
for (const file of all) {
|
|
653
|
+
if (file instanceof FlowrRdMacroFile) {
|
|
654
|
+
for (const [name, macro] of file.content()) {
|
|
655
|
+
macros.set(name, macro);
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
const index = new RdIndex();
|
|
660
|
+
for (const file of all) {
|
|
661
|
+
if (file instanceof FlowrRdFile) {
|
|
662
|
+
index.add(file.pageWith(macros));
|
|
663
|
+
}
|
|
664
|
+
else if (file instanceof FlowrRdIndexFile) {
|
|
665
|
+
index.addAliases(file.content());
|
|
666
|
+
}
|
|
667
|
+
else if (file instanceof FlowrRdTopicIndexFile) {
|
|
668
|
+
index.addTopics(file.content());
|
|
669
|
+
}
|
|
670
|
+
else if (file instanceof FlowrRdMetaFile) {
|
|
671
|
+
index.addMeta(file.content());
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
return index;
|
|
675
|
+
}
|
|
676
|
+
//# sourceMappingURL=flowr-rd-file.js.map
|