@eagleoutice/flowr 2.12.2 → 2.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -91
- package/abstract-interpretation/data-frame/dataframe-domain.d.ts +3 -3
- package/abstract-interpretation/data-frame/dataframe-domain.js +14 -6
- package/abstract-interpretation/data-frame/semantics.js +12 -16
- package/abstract-interpretation/domains/abstract-domain.d.ts +46 -44
- package/abstract-interpretation/domains/abstract-domain.js +146 -6
- package/abstract-interpretation/domains/bounded-set-domain.d.ts +16 -25
- package/abstract-interpretation/domains/bounded-set-domain.js +22 -69
- package/abstract-interpretation/domains/interval-domain.d.ts +27 -36
- package/abstract-interpretation/domains/interval-domain.js +111 -146
- package/abstract-interpretation/domains/lattice.d.ts +3 -3
- package/abstract-interpretation/domains/multi-value-state-domain.js +3 -3
- package/abstract-interpretation/domains/partial-product-domain.d.ts +12 -19
- package/abstract-interpretation/domains/partial-product-domain.js +21 -54
- package/abstract-interpretation/domains/positive-interval-domain.d.ts +8 -12
- package/abstract-interpretation/domains/positive-interval-domain.js +21 -50
- package/abstract-interpretation/domains/product-domain.d.ts +1 -1
- package/abstract-interpretation/domains/product-domain.js +4 -4
- package/abstract-interpretation/domains/set-range-domain.d.ts +60 -56
- package/abstract-interpretation/domains/set-range-domain.js +141 -200
- package/abstract-interpretation/domains/set-upper-bound-domain.d.ts +17 -23
- package/abstract-interpretation/domains/set-upper-bound-domain.js +59 -103
- package/abstract-interpretation/domains/singleton-domain.d.ts +15 -18
- package/abstract-interpretation/domains/singleton-domain.js +33 -72
- package/abstract-interpretation/domains/state-abstract-domain.d.ts +12 -16
- package/abstract-interpretation/domains/state-abstract-domain.js +36 -126
- package/abstract-interpretation/domains/state-domain-like.d.ts +2 -2
- package/abstract-interpretation/domains/value-abstract-domain.d.ts +120 -0
- package/abstract-interpretation/domains/{satisfiable-domain.js → value-abstract-domain.js} +14 -2
- package/benchmark/slicer.d.ts +2 -2
- package/benchmark/slicer.js +6 -5
- package/cli/common/options.d.ts +10 -0
- package/cli/common/options.js +2 -0
- package/cli/common/scripts-info.d.ts +10 -0
- package/cli/flowr-main-options.d.ts +4 -0
- package/cli/flowr-main-options.js +5 -0
- package/cli/flowr.d.ts +5 -0
- package/cli/flowr.js +15 -7
- package/cli/repl/commands/repl-query.js +42 -20
- package/cli/repl/commands/repl-signature.js +2 -2
- package/cli/repl/core.d.ts +14 -5
- package/cli/repl/core.js +32 -17
- package/cli/repl/parser/slice-query-parser.d.ts +69 -8
- package/cli/repl/parser/slice-query-parser.js +82 -13
- package/cli/repl/path-input.d.ts +6 -0
- package/cli/repl/path-input.js +41 -0
- package/cli/repl/print-version.js +3 -5
- package/cli/slicer-app.d.ts +2 -0
- package/cli/slicer-app.js +2 -1
- package/config.d.ts +54 -6
- package/config.js +133 -12
- package/control-flow/control-flow-graph.d.ts +3 -2
- package/control-flow/control-flow-graph.js +34 -14
- package/control-flow/semantic-cfg-guided-visitor.d.ts +3 -0
- package/control-flow/semantic-cfg-guided-visitor.js +3 -0
- package/core/steps/all/static-slicing/10-reconstruct.d.ts +6 -0
- package/core/steps/all/static-slicing/10-reconstruct.js +3 -1
- package/data/r-base-packages.generated.d.ts +1 -1
- package/data/r-base-packages.generated.js +3 -3
- package/data/sigdb/sigdb.remote.json +53 -53
- package/dataflow/environments/built-in-proc-name.d.ts +2 -0
- package/dataflow/environments/built-in-proc-name.js +2 -0
- package/dataflow/environments/built-in.d.ts +2 -0
- package/dataflow/environments/built-in.js +2 -0
- package/dataflow/environments/default-builtin-config.d.ts +3 -5
- package/dataflow/environments/default-builtin-config.js +2 -2
- package/dataflow/environments/environment.d.ts +9 -0
- package/dataflow/environments/environment.js +28 -7
- package/dataflow/environments/identifier.d.ts +1 -2
- package/dataflow/environments/identifier.js +1 -5
- package/dataflow/extractor.js +1 -2
- package/dataflow/graph/dataflowgraph-builder.js +42 -3
- package/dataflow/graph/df-helper.d.ts +15 -0
- package/dataflow/graph/df-helper.js +20 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +4 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +7 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +13 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +4 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +57 -11
- package/dataflow/internal/process/functions/call/built-in/built-in-load.d.ts +12 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-load.js +233 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +5 -3
- package/documentation/data/faq/faqs.js +12 -1
- package/documentation/doc-readme.js +1 -1
- package/documentation/doc-util/doc-files.d.ts +2 -2
- package/documentation/doc-util/doc-files.js +4 -7
- package/documentation/doc-util/doc-query.d.ts +12 -9
- package/documentation/doc-util/doc-query.js +63 -28
- package/documentation/wiki-absint.js +1 -4
- package/documentation/wiki-analyzer.js +8 -3
- package/documentation/wiki-cfg.js +3 -2
- package/documentation/wiki-dataflow-graph.js +14 -4
- package/documentation/wiki-interface.js +29 -16
- package/documentation/wiki-mk/doc-maker.js +1 -1
- package/documentation/wiki-query.js +189 -30
- package/documentation/wiki-signature-database.d.ts +1 -1
- package/documentation/wiki-signature-database.js +53 -27
- package/linter/linter-output.d.ts +24 -0
- package/linter/linter-output.js +117 -0
- package/linter/linter-rules.d.ts +2 -4
- package/linter/rules/dataframe-access-validation.js +4 -4
- package/linter/rules/deprecated-functions.d.ts +2 -4
- package/linter/rules/deprecated-functions.js +58 -3
- package/linter/rules/undefined-symbol.js +18 -10
- package/linter/rules/unused-definition.js +24 -0
- package/package.json +5 -2
- package/project/context/flowr-analyzer-context.d.ts +59 -1
- package/project/context/flowr-analyzer-context.js +118 -3
- package/project/context/flowr-analyzer-dependencies-context.d.ts +32 -7
- package/project/context/flowr-analyzer-dependencies-context.js +33 -3
- package/project/context/flowr-analyzer-files-context.d.ts +32 -0
- package/project/context/flowr-analyzer-files-context.js +132 -14
- package/project/context/flowr-analyzer-loading-order-context.d.ts +6 -0
- package/project/context/flowr-analyzer-loading-order-context.js +20 -0
- package/project/context/flowr-analyzer-meta-context.d.ts +92 -10
- package/project/context/flowr-analyzer-meta-context.js +64 -23
- package/project/context/flowr-file.d.ts +7 -0
- package/project/context/flowr-file.js +7 -0
- package/project/context/project-kind.d.ts +22 -0
- package/project/context/project-kind.js +27 -0
- package/project/dependency-version-space.d.ts +166 -0
- package/project/dependency-version-space.js +564 -0
- package/project/flowr-analyzer-builder.js +1 -1
- package/project/flowr-analyzer.d.ts +4 -0
- package/project/flowr-analyzer.js +5 -0
- package/project/plugins/file-plugins/files/flowr-description-file.d.ts +4 -0
- package/project/plugins/file-plugins/files/flowr-description-file.js +7 -0
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +5 -1
- package/project/plugins/file-plugins/files/flowr-rda-file.d.ts +739 -0
- package/project/plugins/file-plugins/files/flowr-rda-file.js +2407 -0
- package/project/plugins/file-plugins/files/flowr-rproject-file.d.ts +31 -0
- package/project/plugins/file-plugins/files/flowr-rproject-file.js +66 -0
- package/project/plugins/file-plugins/files/r-fun-tab.d.ts +828 -0
- package/project/plugins/file-plugins/files/r-fun-tab.js +1039 -0
- package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.js +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-file-plugin.js +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-inst-file-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-inst-file-plugin.js +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-license-file-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-license-file-plugin.js +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-namespace-files-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-namespace-files-plugin.js +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-news-file-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-news-file-plugin.js +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-rda-file-plugin.d.ts +26 -0
- package/project/plugins/file-plugins/flowr-analyzer-rda-file-plugin.js +38 -0
- package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.d.ts +17 -0
- package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.js +30 -0
- package/project/plugins/file-plugins/flowr-analyzer-rproject-file-plugin.d.ts +22 -0
- package/project/plugins/file-plugins/flowr-analyzer-rproject-file-plugin.js +36 -0
- package/project/plugins/file-plugins/flowr-analyzer-test-file-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-test-file-plugin.js +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-vignette-file-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-vignette-file-plugin.js +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.d.ts +3 -4
- package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.js +5 -6
- package/project/plugins/flowr-analyzer-plugin.js +5 -0
- package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-description-file-plugin.d.ts +1 -1
- package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-description-file-plugin.js +1 -1
- package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-implicit-sources-plugin.d.ts +14 -0
- package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-implicit-sources-plugin.js +53 -0
- package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-plugin.js +1 -1
- package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-rprofile-plugin.d.ts +15 -0
- package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-rprofile-plugin.js +33 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-description-file-plugin.d.ts +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-description-file-plugin.js +18 -13
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-rproject-file-plugin.d.ts +13 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-rproject-file-plugin.js +32 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.d.ts +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.js +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.d.ts +8 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +70 -7
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-namespace-file-plugin.d.ts +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-namespace-file-plugin.js +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.js +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-session-info-plugin.d.ts +18 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-session-info-plugin.js +62 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +4 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +5 -13
- package/project/plugins/package-version-plugins/package.d.ts +4 -1
- package/project/plugins/package-version-plugins/package.js +8 -5
- package/project/plugins/plugin-registry.d.ts +11 -3
- package/project/plugins/plugin-registry.js +24 -5
- package/project/plugins/project-discovery/flowr-analyzer-ignore-file-project-discovery-plugin.d.ts +51 -0
- package/project/plugins/project-discovery/flowr-analyzer-ignore-file-project-discovery-plugin.js +101 -0
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +10 -5
- package/project/sigdb/build.js +12 -2
- package/project/sigdb/decode.d.ts +7 -0
- package/project/sigdb/decode.js +35 -4
- package/project/sigdb/decompress.d.ts +2 -0
- package/project/sigdb/decompress.js +5 -0
- package/project/sigdb/manifest.d.ts +5 -0
- package/project/sigdb/manifest.js +37 -6
- package/project/sigdb/reader.d.ts +82 -2
- package/project/sigdb/reader.js +226 -14
- package/project/sigdb/schema.d.ts +31 -5
- package/project/sigdb/schema.js +7 -3
- package/project/sigdb/{version.d.ts → sigdb-version.d.ts} +21 -1
- package/project/sigdb/sigdb-version.js +119 -0
- package/queries/catalog/absint-query/absint-query-format.d.ts +2 -0
- package/queries/catalog/absint-query/absint-query-format.js +2 -0
- package/queries/catalog/call-context-query/call-context-query-executor.js +30 -3
- package/queries/catalog/call-context-query/call-context-query-format.d.ts +1 -0
- package/queries/catalog/call-context-query/call-context-query-format.js +1 -0
- package/queries/catalog/call-graph-query/call-graph-query-executor.js +3 -1
- package/queries/catalog/call-graph-query/call-graph-query-format.d.ts +6 -0
- package/queries/catalog/call-graph-query/call-graph-query-format.js +2 -0
- package/queries/catalog/call-graph-query/expand-library-internals.d.ts +19 -0
- package/queries/catalog/call-graph-query/expand-library-internals.js +59 -0
- package/queries/catalog/cluster-query/cluster-query-format.d.ts +1 -0
- package/queries/catalog/cluster-query/cluster-query-format.js +1 -0
- package/queries/catalog/config-query/config-query-executor.js +15 -6
- package/queries/catalog/config-query/config-query-format.d.ts +18 -4
- package/queries/catalog/config-query/config-query-format.js +246 -96
- package/queries/catalog/control-flow-query/control-flow-query-format.d.ts +1 -0
- package/queries/catalog/control-flow-query/control-flow-query-format.js +1 -0
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.d.ts +1 -0
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.js +1 -0
- package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +1 -0
- package/queries/catalog/dataflow-query/dataflow-query-format.js +1 -0
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +2 -7
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +13 -1
- package/queries/catalog/dependencies-query/dependencies-query-format.js +117 -17
- package/queries/catalog/dice-query/dice-query-executor.js +6 -9
- package/queries/catalog/dice-query/dice-query-format.d.ts +4 -5
- package/queries/catalog/dice-query/dice-query-format.js +10 -6
- package/queries/catalog/does-call-query/does-call-query-executor.js +15 -2
- package/queries/catalog/does-call-query/does-call-query-format.d.ts +8 -0
- package/queries/catalog/does-call-query/does-call-query-format.js +4 -1
- package/queries/catalog/files-query/files-query-format.d.ts +2 -0
- package/queries/catalog/files-query/files-query-format.js +2 -0
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.d.ts +6 -0
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +277 -0
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +119 -0
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +331 -0
- package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +1 -0
- package/queries/catalog/happens-before-query/happens-before-query-format.js +1 -0
- package/queries/catalog/id-map-query/id-map-query-format.d.ts +1 -0
- package/queries/catalog/id-map-query/id-map-query-format.js +1 -0
- package/queries/catalog/input-sources-query/input-sources-query-format.d.ts +2 -0
- package/queries/catalog/input-sources-query/input-sources-query-format.js +2 -0
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.d.ts +2 -0
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +2 -0
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +2 -0
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +2 -0
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.d.ts +2 -0
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.js +2 -0
- package/queries/catalog/linter-query/linter-query-executor.js +11 -2
- package/queries/catalog/linter-query/linter-query-format.d.ts +9 -4
- package/queries/catalog/linter-query/linter-query-format.js +44 -21
- package/queries/catalog/location-map-query/location-map-query-format.d.ts +2 -0
- package/queries/catalog/location-map-query/location-map-query-format.js +2 -0
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +1 -0
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.js +1 -0
- package/queries/catalog/origin-query/origin-query-format.d.ts +2 -0
- package/queries/catalog/origin-query/origin-query-format.js +2 -0
- package/queries/catalog/project-query/project-query-executor.d.ts +0 -15
- package/queries/catalog/project-query/project-query-executor.js +19 -62
- package/queries/catalog/project-query/project-query-format.d.ts +7 -18
- package/queries/catalog/project-query/project-query-format.js +3 -18
- package/queries/catalog/provenance-query/provenance-query-format.d.ts +2 -0
- package/queries/catalog/provenance-query/provenance-query-format.js +2 -0
- package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +2 -0
- package/queries/catalog/resolve-value-query/resolve-value-query-format.js +2 -0
- package/queries/catalog/search-query/search-query-format.d.ts +1 -0
- package/queries/catalog/search-query/search-query-format.js +1 -0
- package/queries/catalog/signature-query/signature-query-executor.d.ts +5 -0
- package/queries/catalog/signature-query/signature-query-executor.js +267 -57
- package/queries/catalog/signature-query/signature-query-format.d.ts +37 -6
- package/queries/catalog/signature-query/signature-query-format.js +41 -5
- package/queries/catalog/signature-query/signature-query-render.js +48 -6
- package/queries/catalog/slice-query-options.d.ts +49 -0
- package/queries/catalog/slice-query-options.js +50 -0
- package/queries/catalog/static-slice-query/static-slice-query-executor.js +4 -12
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +4 -15
- package/queries/catalog/static-slice-query/static-slice-query-format.js +9 -10
- package/queries/query-print.js +3 -1
- package/queries/query.d.ts +63 -3
- package/queries/query.js +9 -2
- package/r-bridge/data/data.d.ts +16 -0
- package/r-bridge/data/data.js +20 -0
- package/r-bridge/lang-4.x/ast/model/model.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/processing/decorate.js +2 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/normalize-access.js +2 -1
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +19 -16
- package/reconstruct/reconstruct.d.ts +18 -1
- package/reconstruct/reconstruct.js +42 -19
- package/slicing/criterion/parse.d.ts +4 -0
- package/slicing/criterion/parse.js +4 -0
- package/slicing/static/slice-call.js +17 -9
- package/slicing/static/static-slicer.d.ts +1 -1
- package/slicing/static/static-slicer.js +5 -4
- package/util/files.d.ts +19 -1
- package/util/files.js +45 -3
- package/util/glob.d.ts +19 -0
- package/util/glob.js +67 -0
- package/util/log.d.ts +12 -0
- package/util/log.js +17 -1
- package/util/logic.d.ts +6 -0
- package/util/logic.js +31 -1
- package/util/mermaid/dfg.js +17 -12
- package/util/mermaid/mermaid.js +2 -2
- package/util/objects.d.ts +5 -0
- package/util/objects.js +8 -0
- package/util/r-version.d.ts +9 -1
- package/util/r-version.js +27 -2
- package/util/schema.d.ts +16 -0
- package/util/schema.js +89 -4
- package/util/text/ansi.d.ts +4 -0
- package/util/text/ansi.js +27 -3
- package/util/text/strings.d.ts +9 -0
- package/util/text/strings.js +29 -0
- package/util/version.js +79 -6
- package/abstract-interpretation/domains/satisfiable-domain.d.ts +0 -29
- package/project/plugins/project-discovery/flowr-analyzer-gitignore-project-discovery-plugin.d.ts +0 -22
- package/project/plugins/project-discovery/flowr-analyzer-gitignore-project-discovery-plugin.js +0 -52
- package/project/sigdb/version.js +0 -55
|
@@ -13,7 +13,18 @@ const flowr_file_1 = require("./flowr-file");
|
|
|
13
13
|
const log_1 = require("../../util/log");
|
|
14
14
|
const fs_1 = __importDefault(require("fs"));
|
|
15
15
|
const path_1 = __importDefault(require("path"));
|
|
16
|
+
const files_1 = require("../../util/files");
|
|
17
|
+
const project_kind_1 = require("./project-kind");
|
|
16
18
|
const fileLog = log_1.log.getSubLogger({ name: 'flowr-analyzer-files-context' });
|
|
19
|
+
const notebookExtension = /\.(ipynb|rmd|qmd|rnw)$/;
|
|
20
|
+
const shinyDescriptionTypes = new Set(['shiny', 'shiny-app', 'shinyapp']);
|
|
21
|
+
/** the (lower-cased) file names a shiny app is assembled from; the app is `app.r`, or the `ui.r`+`server.r` pair */
|
|
22
|
+
const shinyEntryFiles = new Set(['app.r', 'ui.r', 'server.r', 'global.r']);
|
|
23
|
+
/**
|
|
24
|
+
* Evidence that a file actually is part of a shiny app rather than just sharing a name: a load of the shiny stack
|
|
25
|
+
* or a call to one of its entry points. Kept broad enough to also catch `bslib`/`shinydashboard`/`golem` apps.
|
|
26
|
+
*/
|
|
27
|
+
const shinyUsage = /(?:library|require|requireNamespace|loadNamespace)\s*\(\s*['"]?(?:shiny|bslib|shinydashboard|shinyMobile|golem|flexdashboard)\b|\b(?:shinyApp|shinyServer|shinyUI|runApp|fluidPage|fluidRow|navbarPage|bootstrapPage|fillPage|dashboardPage|page_fluid|page_sidebar|page_navbar|pageWithSidebar)\s*\(/;
|
|
17
28
|
function wrapFile(file, roles) {
|
|
18
29
|
if (typeof file === 'string') {
|
|
19
30
|
return new flowr_file_1.FlowrTextFile(file, roles);
|
|
@@ -43,6 +54,12 @@ class FlowrAnalyzerFilesContext extends abstract_flowr_analyzer_context_1.Abstra
|
|
|
43
54
|
discoveryPlugins;
|
|
44
55
|
/* files that are part of the analysis, e.g. source files */
|
|
45
56
|
byRole = Object.fromEntries(Object.values(flowr_file_1.FileRole).map(k => [k, []]));
|
|
57
|
+
/** cached {@link projectKind}, invalidated whenever the files change (added or reset) */
|
|
58
|
+
projectKindCache = undefined;
|
|
59
|
+
requestedRoots = [];
|
|
60
|
+
/** cached {@link root}, fixed on first use as the ids built from it have to stay stable */
|
|
61
|
+
rootCache = undefined;
|
|
62
|
+
rootResolved = false;
|
|
46
63
|
constructor(loadingOrder, plugins, fileLoaders) {
|
|
47
64
|
super(loadingOrder.getAttachedContext(), flowr_analyzer_project_discovery_plugin_1.FlowrAnalyzerProjectDiscoveryPlugin.defaultPlugin(), []);
|
|
48
65
|
this.discoveryPlugins = plugins;
|
|
@@ -55,12 +72,30 @@ class FlowrAnalyzerFilesContext extends abstract_flowr_analyzer_context_1.Abstra
|
|
|
55
72
|
this.consideredFiles.length = 0;
|
|
56
73
|
this.inlineFiles.length = 0;
|
|
57
74
|
this.byRole = Object.fromEntries(Object.values(flowr_file_1.FileRole).map(k => [k, []]));
|
|
75
|
+
this.projectKindCache = undefined;
|
|
76
|
+
this.requestedRoots.length = 0;
|
|
77
|
+
this.rootCache = undefined;
|
|
78
|
+
this.rootResolved = false;
|
|
79
|
+
}
|
|
80
|
+
/** The directory the analysis was asked about: a `project`'s folder, or the one holding the requested file(s). */
|
|
81
|
+
root() {
|
|
82
|
+
if (!this.rootResolved) {
|
|
83
|
+
this.rootResolved = true;
|
|
84
|
+
this.rootCache = (0, files_1.commonDirectory)(this.requestedRoots);
|
|
85
|
+
}
|
|
86
|
+
return this.rootCache;
|
|
87
|
+
}
|
|
88
|
+
/** The path of `filePath` seen from the {@link root}, see {@link relativeTo}. */
|
|
89
|
+
relativePath(filePath) {
|
|
90
|
+
const root = this.root();
|
|
91
|
+
return root === undefined ? filePath : (0, files_1.relativeTo)(root, filePath);
|
|
58
92
|
}
|
|
59
93
|
/**
|
|
60
94
|
* Record that a file has been considered during dataflow analysis.
|
|
61
95
|
*/
|
|
62
96
|
addConsideredFile(path) {
|
|
63
97
|
this.consideredFiles.push(path);
|
|
98
|
+
this.projectKindCache = undefined;
|
|
64
99
|
}
|
|
65
100
|
/**
|
|
66
101
|
* Get all files that have been considered during dataflow analysis.
|
|
@@ -68,6 +103,82 @@ class FlowrAnalyzerFilesContext extends abstract_flowr_analyzer_context_1.Abstra
|
|
|
68
103
|
consideredFilesList() {
|
|
69
104
|
return this.consideredFiles;
|
|
70
105
|
}
|
|
106
|
+
projectKind() {
|
|
107
|
+
return this.projectKindCache ??= this.classifyProject();
|
|
108
|
+
}
|
|
109
|
+
classifyProject() {
|
|
110
|
+
const descriptions = this.getFilesByRole(flowr_file_1.FileRole.Description);
|
|
111
|
+
// an explicit `Type: shiny` in the DESCRIPTION settles it without looking at any source
|
|
112
|
+
if (descriptions.some(d => shinyDescriptionTypes.has(d.type() ?? ''))) {
|
|
113
|
+
return project_kind_1.ProjectKind.ShinyApp;
|
|
114
|
+
}
|
|
115
|
+
// the readable entry files by (lower-cased) name, plus every known file name for the coarser checks below
|
|
116
|
+
const entries = new Map();
|
|
117
|
+
const names = new Set();
|
|
118
|
+
for (const f of this.getAllFiles()) {
|
|
119
|
+
const name = path_1.default.basename(f.path()).toLowerCase();
|
|
120
|
+
names.add(name);
|
|
121
|
+
if (shinyEntryFiles.has(name)) {
|
|
122
|
+
entries.set(name, f);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
const pending = this.loadingOrder.getUnorderedRequests()
|
|
126
|
+
.filter(r => r.request === 'file').map(r => r.content);
|
|
127
|
+
for (const p of [...pending, ...this.consideredFiles]) {
|
|
128
|
+
const name = path_1.default.basename(p).toLowerCase();
|
|
129
|
+
names.add(name);
|
|
130
|
+
if (shinyEntryFiles.has(name) && !entries.has(name)) {
|
|
131
|
+
entries.set(name, this.getFileByPath(p) ?? new flowr_file_1.FlowrTextFile(p));
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (this.isShinyApp(names, entries)) {
|
|
135
|
+
return project_kind_1.ProjectKind.ShinyApp;
|
|
136
|
+
}
|
|
137
|
+
if (descriptions.length > 0) {
|
|
138
|
+
return project_kind_1.ProjectKind.Package;
|
|
139
|
+
}
|
|
140
|
+
if (names.size === 0) {
|
|
141
|
+
return project_kind_1.ProjectKind.Unknown;
|
|
142
|
+
}
|
|
143
|
+
for (const name of names) {
|
|
144
|
+
if (notebookExtension.test(name)) {
|
|
145
|
+
return project_kind_1.ProjectKind.Notebook;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
let rSources = 0;
|
|
149
|
+
for (const name of names) {
|
|
150
|
+
if (name.endsWith('.r')) {
|
|
151
|
+
rSources++;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return rSources <= 1 ? project_kind_1.ProjectKind.Script : project_kind_1.ProjectKind.Project;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Whether the project is a shiny app: it has the canonical entry files (a single `app.R`, or the `ui.R`+`server.R`
|
|
158
|
+
* pair -- a lone `server.R` is not enough) and one of them actually loads or calls the shiny stack. The usage
|
|
159
|
+
* check keeps a coincidental `ui.R`/`server.R` pair from being mistaken for an app; only when none of the entry
|
|
160
|
+
* files can be read do we fall back to trusting the file names alone.
|
|
161
|
+
*/
|
|
162
|
+
isShinyApp(names, entries) {
|
|
163
|
+
if (!names.has('app.r') && !(names.has('ui.r') && names.has('server.r'))) {
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
let couldRead = false;
|
|
167
|
+
for (const f of entries.values()) {
|
|
168
|
+
let content;
|
|
169
|
+
try {
|
|
170
|
+
content = f.content().toString();
|
|
171
|
+
}
|
|
172
|
+
catch {
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
couldRead = true;
|
|
176
|
+
if (shinyUsage.test(content)) {
|
|
177
|
+
return true;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return !couldRead;
|
|
181
|
+
}
|
|
71
182
|
/**
|
|
72
183
|
* Add multiple requests to the context. This is just a convenience method that calls {@link addRequest} for each request.
|
|
73
184
|
*/
|
|
@@ -82,9 +193,14 @@ class FlowrAnalyzerFilesContext extends abstract_flowr_analyzer_context_1.Abstra
|
|
|
82
193
|
*/
|
|
83
194
|
addRequest(request) {
|
|
84
195
|
if (request.request !== 'project') {
|
|
196
|
+
if (request.request === 'file') {
|
|
197
|
+
this.requestedRoots.push(path_1.default.dirname(request.content));
|
|
198
|
+
}
|
|
85
199
|
this.loadingOrder.addRequest(request);
|
|
200
|
+
this.projectKindCache = undefined;
|
|
86
201
|
return;
|
|
87
202
|
}
|
|
203
|
+
this.requestedRoots.push(request.content);
|
|
88
204
|
const active = this.discoveryPlugins.length > 0
|
|
89
205
|
? this.discoveryPlugins
|
|
90
206
|
: [flowr_analyzer_project_discovery_plugin_1.FlowrAnalyzerProjectDiscoveryPlugin.defaultPlugin()];
|
|
@@ -125,6 +241,7 @@ class FlowrAnalyzerFilesContext extends abstract_flowr_analyzer_context_1.Abstra
|
|
|
125
241
|
this.byRole[r].push(f);
|
|
126
242
|
}
|
|
127
243
|
}
|
|
244
|
+
this.projectKindCache = undefined;
|
|
128
245
|
return f;
|
|
129
246
|
}
|
|
130
247
|
hasCached(path) {
|
|
@@ -200,24 +317,25 @@ class FlowrAnalyzerFilesContext extends abstract_flowr_analyzer_context_1.Abstra
|
|
|
200
317
|
}
|
|
201
318
|
return fFinal;
|
|
202
319
|
}
|
|
320
|
+
/** Resolve the file at `path`, loading it from disk through the {@link FlowrAnalyzerFilePlugin}s if unknown. */
|
|
321
|
+
resolveFile(path) {
|
|
322
|
+
const file = this.files.get(path);
|
|
323
|
+
if (file !== undefined && file !== null) {
|
|
324
|
+
return file;
|
|
325
|
+
}
|
|
326
|
+
if (this.ctx.config.project.resolveUnknownPathsOnDisk) {
|
|
327
|
+
fileLog.debug(`File ${path} not found in context, trying to load from disk.`);
|
|
328
|
+
if (fs_1.default.existsSync(path)) {
|
|
329
|
+
return this.addFile(new flowr_file_1.FlowrTextFile(path));
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
return undefined;
|
|
333
|
+
}
|
|
203
334
|
resolveRequest(r) {
|
|
204
335
|
if (r.request === 'text') {
|
|
205
336
|
return { r };
|
|
206
337
|
}
|
|
207
|
-
const file = this.
|
|
208
|
-
if (file === undefined && this.ctx.config.project.resolveUnknownPathsOnDisk) {
|
|
209
|
-
fileLog.debug(`File ${r.content} not found in context, trying to load from disk.`);
|
|
210
|
-
if (fs_1.default.existsSync(r.content)) {
|
|
211
|
-
const loadedFile = this.addFile(new flowr_file_1.FlowrTextFile(r.content));
|
|
212
|
-
return {
|
|
213
|
-
r: {
|
|
214
|
-
request: 'text',
|
|
215
|
-
content: loadedFile.content().toString(),
|
|
216
|
-
},
|
|
217
|
-
path: loadedFile.path()
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
|
-
}
|
|
338
|
+
const file = this.resolveFile(r.content);
|
|
221
339
|
(0, assert_1.guard)(file !== undefined && file !== null, `File ${r.content} not found in context.`);
|
|
222
340
|
const content = file.content();
|
|
223
341
|
return {
|
|
@@ -69,6 +69,12 @@ export declare class FlowrAnalyzerLoadingOrderContext extends AbstractFlowrAnaly
|
|
|
69
69
|
* In case you have a certain order, use the `certain` flag to indicate this -- but please take care of *really* being certain!
|
|
70
70
|
*/
|
|
71
71
|
addGuess(guess: readonly RParseRequest[], certain?: boolean): void;
|
|
72
|
+
/**
|
|
73
|
+
* Move `requests` to the front of every order known so far, keeping their relative order.
|
|
74
|
+
* Use this for files R evaluates before anything else (e.g. `.Rprofile`), as it refines the
|
|
75
|
+
* existing orders instead of competing with them like {@link addGuess} would.
|
|
76
|
+
*/
|
|
77
|
+
prependToOrder(requests: readonly RParseRequest[]): void;
|
|
72
78
|
currentGuesses(): readonly (readonly RParseRequest[])[];
|
|
73
79
|
currentKnownOrder(): readonly RParseRequest[] | undefined;
|
|
74
80
|
peekLoadingOrder(): readonly RParseRequest[] | undefined;
|
|
@@ -76,6 +76,26 @@ class FlowrAnalyzerLoadingOrderContext extends abstract_flowr_analyzer_context_1
|
|
|
76
76
|
this.guesses.push(guess);
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* Move `requests` to the front of every order known so far, keeping their relative order.
|
|
81
|
+
* Use this for files R evaluates before anything else (e.g. `.Rprofile`), as it refines the
|
|
82
|
+
* existing orders instead of competing with them like {@link addGuess} would.
|
|
83
|
+
*/
|
|
84
|
+
prependToOrder(requests) {
|
|
85
|
+
if (requests.length === 0) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const front = (order) => [...requests, ...order.filter(r => !requests.includes(r))];
|
|
89
|
+
if (this.knownOrder) {
|
|
90
|
+
this.knownOrder = front(this.knownOrder);
|
|
91
|
+
}
|
|
92
|
+
for (let i = 0; i < this.guesses.length; i++) {
|
|
93
|
+
this.guesses[i] = front(this.guesses[i]);
|
|
94
|
+
}
|
|
95
|
+
if (!this.knownOrder && this.guesses.length === 0) {
|
|
96
|
+
this.addGuess(front(this.unordered));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
79
99
|
currentGuesses() {
|
|
80
100
|
return this.guesses;
|
|
81
101
|
}
|
|
@@ -1,4 +1,55 @@
|
|
|
1
1
|
import type { SemVer } from 'semver';
|
|
2
|
+
import type { RAuthorInfo } from '../../util/r-author';
|
|
3
|
+
import type { RLicenseElementInfo } from '../../util/r-license';
|
|
4
|
+
import type { Package } from '../plugins/package-version-plugins/package';
|
|
5
|
+
/**
|
|
6
|
+
* How much a {@link ProjectMetaFields | contribution} is trusted, in case several sources disagree.
|
|
7
|
+
* A higher value wins; among equal values the first contribution stays.
|
|
8
|
+
*/
|
|
9
|
+
export declare enum MetaPriority {
|
|
10
|
+
/** derived from a lockfile, e.g. the `r_version` of an `rv.lock` */
|
|
11
|
+
Lockfile = 0,
|
|
12
|
+
/** declared in a project manifest, e.g. an `rproject.toml` */
|
|
13
|
+
Manifest = 1,
|
|
14
|
+
/** declared in a `DESCRIPTION` file, which identifies an actual R package */
|
|
15
|
+
Description = 2
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The packages a project declares, grouped as a `DESCRIPTION` groups them. A source without such groups
|
|
19
|
+
* (an `rproject.toml` just lists `dependencies`) reports them as {@link DeclaredPackages#imports}.
|
|
20
|
+
*/
|
|
21
|
+
export interface DeclaredPackages {
|
|
22
|
+
imports?: readonly Package[];
|
|
23
|
+
depends?: readonly Package[];
|
|
24
|
+
suggests?: readonly Package[];
|
|
25
|
+
linkingTo?: readonly Package[];
|
|
26
|
+
}
|
|
27
|
+
/** The project metadata a plugin may contribute, see {@link FlowrAnalyzerMetaContext#contribute}. */
|
|
28
|
+
export interface ProjectMetaFields {
|
|
29
|
+
/** the project name, e.g. the `Package` of a `DESCRIPTION` or the `[project] name` of an `rproject.toml` */
|
|
30
|
+
name?: string;
|
|
31
|
+
/** the human-readable project title */
|
|
32
|
+
title?: string;
|
|
33
|
+
/** the project version */
|
|
34
|
+
version?: SemVer & {
|
|
35
|
+
str: string;
|
|
36
|
+
};
|
|
37
|
+
/** the R version the project targets, e.g. the `r_version` of an `rproject.toml` */
|
|
38
|
+
rVersion?: string;
|
|
39
|
+
/**
|
|
40
|
+
* The namespace `a::b` resolves against. Only set this for a real R package: a plain project
|
|
41
|
+
* (e.g. an rv project) has a name but no namespace, and claiming one changes symbol resolution.
|
|
42
|
+
*/
|
|
43
|
+
namespace?: string;
|
|
44
|
+
/** the project authors */
|
|
45
|
+
authors?: RAuthorInfo[];
|
|
46
|
+
/** the encoding the project's files are written in */
|
|
47
|
+
encoding?: string;
|
|
48
|
+
/** the project licenses */
|
|
49
|
+
licenses?: RLicenseElementInfo[];
|
|
50
|
+
/** the packages the project declares, used to report on them; what is loadable lives in the dependency context */
|
|
51
|
+
declares?: DeclaredPackages;
|
|
52
|
+
}
|
|
2
53
|
export interface ReadOnlyFlowrAnalyzerMetaContext {
|
|
3
54
|
/**
|
|
4
55
|
* The name of this context.
|
|
@@ -18,34 +69,65 @@ export interface ReadOnlyFlowrAnalyzerMetaContext {
|
|
|
18
69
|
getProjectVersion(): SemVer & {
|
|
19
70
|
str: string;
|
|
20
71
|
} | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* Get the R version the project targets, if any source declares one.
|
|
74
|
+
*/
|
|
75
|
+
getRVersion(): string | undefined;
|
|
21
76
|
/**
|
|
22
77
|
* Get the project namespace.
|
|
23
78
|
* Any symbol resolve like `a::b` will resolve against this, if `a` matches the namespace.
|
|
24
79
|
*/
|
|
25
80
|
getNamespace(): string | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* Get the project authors.
|
|
83
|
+
*/
|
|
84
|
+
getAuthors(): RAuthorInfo[] | undefined;
|
|
85
|
+
/**
|
|
86
|
+
* Get the encoding the project's files are written in.
|
|
87
|
+
*/
|
|
88
|
+
getEncoding(): string | undefined;
|
|
89
|
+
/**
|
|
90
|
+
* Get the project licenses.
|
|
91
|
+
*/
|
|
92
|
+
getLicenses(): RLicenseElementInfo[] | undefined;
|
|
93
|
+
/**
|
|
94
|
+
* Get the packages the project declares, grouped by how they are declared.
|
|
95
|
+
*/
|
|
96
|
+
getDeclaredPackages(): DeclaredPackages;
|
|
26
97
|
}
|
|
27
98
|
/**
|
|
28
99
|
* This is the context responsible for managing the project metadata such as name, version, title, and namespace.
|
|
29
100
|
*
|
|
101
|
+
* The metadata is source-agnostic: plugins {@link FlowrAnalyzerMetaContext#contribute | contribute} whatever their
|
|
102
|
+
* file declares (`DESCRIPTION`, `rproject.toml`, a lockfile, ...) and consumers read it from here rather than from
|
|
103
|
+
* any particular file. Conflicts are settled by {@link MetaPriority}, so contributions are order-independent.
|
|
104
|
+
*
|
|
30
105
|
* If you are interested in inspecting this metadata, refer to {@link ReadOnlyFlowrAnalyzerMetaContext}.
|
|
31
106
|
*/
|
|
32
107
|
export declare class FlowrAnalyzerMetaContext implements ReadOnlyFlowrAnalyzerMetaContext {
|
|
33
108
|
readonly name = "flowr-analyzer-meta-context";
|
|
34
|
-
private
|
|
35
|
-
|
|
36
|
-
private
|
|
37
|
-
|
|
109
|
+
private readonly fields;
|
|
110
|
+
/** runs the plugins that contribute the metadata, as they only do so on demand */
|
|
111
|
+
private readonly ensureContributed;
|
|
112
|
+
constructor(ensureContributed?: () => void);
|
|
38
113
|
reset(): void;
|
|
39
|
-
|
|
114
|
+
/**
|
|
115
|
+
* Contribute what a source declares about the project; `undefined` fields are ignored, so a plugin can pass
|
|
116
|
+
* whatever it happens to know.
|
|
117
|
+
* @param fields - the metadata to contribute
|
|
118
|
+
* @param priority - how much to trust these fields against other sources
|
|
119
|
+
*/
|
|
120
|
+
contribute(fields: ProjectMetaFields, priority: MetaPriority): this;
|
|
121
|
+
private get;
|
|
40
122
|
getProjectName(): string | undefined;
|
|
41
|
-
setProjectTitle(title: string): void;
|
|
42
123
|
getProjectTitle(): string | undefined;
|
|
43
|
-
setProjectVersion(version: SemVer & {
|
|
44
|
-
str: string;
|
|
45
|
-
}): void;
|
|
46
124
|
getProjectVersion(): SemVer & {
|
|
47
125
|
str: string;
|
|
48
126
|
} | undefined;
|
|
49
|
-
|
|
127
|
+
getRVersion(): string | undefined;
|
|
50
128
|
getNamespace(): string | undefined;
|
|
129
|
+
getAuthors(): RAuthorInfo[] | undefined;
|
|
130
|
+
getEncoding(): string | undefined;
|
|
131
|
+
getLicenses(): RLicenseElementInfo[] | undefined;
|
|
132
|
+
getDeclaredPackages(): DeclaredPackages;
|
|
51
133
|
}
|
|
@@ -1,46 +1,87 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FlowrAnalyzerMetaContext = void 0;
|
|
3
|
+
exports.FlowrAnalyzerMetaContext = exports.MetaPriority = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* How much a {@link ProjectMetaFields | contribution} is trusted, in case several sources disagree.
|
|
6
|
+
* A higher value wins; among equal values the first contribution stays.
|
|
7
|
+
*/
|
|
8
|
+
var MetaPriority;
|
|
9
|
+
(function (MetaPriority) {
|
|
10
|
+
/** derived from a lockfile, e.g. the `r_version` of an `rv.lock` */
|
|
11
|
+
MetaPriority[MetaPriority["Lockfile"] = 0] = "Lockfile";
|
|
12
|
+
/** declared in a project manifest, e.g. an `rproject.toml` */
|
|
13
|
+
MetaPriority[MetaPriority["Manifest"] = 1] = "Manifest";
|
|
14
|
+
/** declared in a `DESCRIPTION` file, which identifies an actual R package */
|
|
15
|
+
MetaPriority[MetaPriority["Description"] = 2] = "Description";
|
|
16
|
+
})(MetaPriority || (exports.MetaPriority = MetaPriority = {}));
|
|
4
17
|
/**
|
|
5
18
|
* This is the context responsible for managing the project metadata such as name, version, title, and namespace.
|
|
6
19
|
*
|
|
20
|
+
* The metadata is source-agnostic: plugins {@link FlowrAnalyzerMetaContext#contribute | contribute} whatever their
|
|
21
|
+
* file declares (`DESCRIPTION`, `rproject.toml`, a lockfile, ...) and consumers read it from here rather than from
|
|
22
|
+
* any particular file. Conflicts are settled by {@link MetaPriority}, so contributions are order-independent.
|
|
23
|
+
*
|
|
7
24
|
* If you are interested in inspecting this metadata, refer to {@link ReadOnlyFlowrAnalyzerMetaContext}.
|
|
8
25
|
*/
|
|
9
26
|
class FlowrAnalyzerMetaContext {
|
|
10
27
|
name = 'flowr-analyzer-meta-context';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
28
|
+
fields = new Map();
|
|
29
|
+
/** runs the plugins that contribute the metadata, as they only do so on demand */
|
|
30
|
+
ensureContributed;
|
|
31
|
+
constructor(ensureContributed = () => { }) {
|
|
32
|
+
this.ensureContributed = ensureContributed;
|
|
33
|
+
}
|
|
15
34
|
reset() {
|
|
16
|
-
this.
|
|
17
|
-
this.projectTitle = undefined;
|
|
18
|
-
this.projectVersion = undefined;
|
|
19
|
-
this.namespace = undefined;
|
|
35
|
+
this.fields.clear();
|
|
20
36
|
}
|
|
21
|
-
|
|
22
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Contribute what a source declares about the project; `undefined` fields are ignored, so a plugin can pass
|
|
39
|
+
* whatever it happens to know.
|
|
40
|
+
* @param fields - the metadata to contribute
|
|
41
|
+
* @param priority - how much to trust these fields against other sources
|
|
42
|
+
*/
|
|
43
|
+
contribute(fields, priority) {
|
|
44
|
+
for (const [key, value] of Object.entries(fields)) {
|
|
45
|
+
if (value === undefined) {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
const have = this.fields.get(key);
|
|
49
|
+
if (have === undefined || priority > have.priority) {
|
|
50
|
+
this.fields.set(key, { value, priority });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return this;
|
|
23
54
|
}
|
|
24
|
-
|
|
25
|
-
|
|
55
|
+
get(key) {
|
|
56
|
+
this.ensureContributed();
|
|
57
|
+
return this.fields.get(key)?.value;
|
|
26
58
|
}
|
|
27
|
-
|
|
28
|
-
this.
|
|
59
|
+
getProjectName() {
|
|
60
|
+
return this.get('name');
|
|
29
61
|
}
|
|
30
62
|
getProjectTitle() {
|
|
31
|
-
return this.
|
|
32
|
-
}
|
|
33
|
-
setProjectVersion(version) {
|
|
34
|
-
this.projectVersion = version;
|
|
63
|
+
return this.get('title');
|
|
35
64
|
}
|
|
36
65
|
getProjectVersion() {
|
|
37
|
-
return this.
|
|
66
|
+
return this.get('version');
|
|
38
67
|
}
|
|
39
|
-
|
|
40
|
-
this.
|
|
68
|
+
getRVersion() {
|
|
69
|
+
return this.get('rVersion');
|
|
41
70
|
}
|
|
42
71
|
getNamespace() {
|
|
43
|
-
return this.namespace;
|
|
72
|
+
return this.get('namespace');
|
|
73
|
+
}
|
|
74
|
+
getAuthors() {
|
|
75
|
+
return this.get('authors');
|
|
76
|
+
}
|
|
77
|
+
getEncoding() {
|
|
78
|
+
return this.get('encoding');
|
|
79
|
+
}
|
|
80
|
+
getLicenses() {
|
|
81
|
+
return this.get('licenses');
|
|
82
|
+
}
|
|
83
|
+
getDeclaredPackages() {
|
|
84
|
+
return this.get('declares') ?? {};
|
|
44
85
|
}
|
|
45
86
|
}
|
|
46
87
|
exports.FlowrAnalyzerMetaContext = FlowrAnalyzerMetaContext;
|
|
@@ -32,6 +32,13 @@ export declare enum FileRole {
|
|
|
32
32
|
License = "license",
|
|
33
33
|
/** Files describing a project's virtual/pinned package environment, e.g., `renv.lock` or `rv.lock`. */
|
|
34
34
|
VirtualEnv = "virtual-env",
|
|
35
|
+
/** A project manifest that is no `DESCRIPTION`, e.g. the `rproject.toml` of an rv project. */
|
|
36
|
+
Manifest = "manifest",
|
|
37
|
+
/**
|
|
38
|
+
* R sources evaluated at startup, before any project code (`.Rprofile`, `Rprofile.site`).
|
|
39
|
+
* These commonly bootstrap a package manager, e.g. by sourcing `packrat/init.R` or `renv/activate.R`.
|
|
40
|
+
*/
|
|
41
|
+
Startup = "startup",
|
|
35
42
|
/**
|
|
36
43
|
* Catch-all for any file that provides usable R source code to incorporate into the analysis.
|
|
37
44
|
* Please note, that the loading order/inclusion and even potential relevance of these source files
|
|
@@ -33,6 +33,13 @@ var FileRole;
|
|
|
33
33
|
FileRole["License"] = "license";
|
|
34
34
|
/** Files describing a project's virtual/pinned package environment, e.g., `renv.lock` or `rv.lock`. */
|
|
35
35
|
FileRole["VirtualEnv"] = "virtual-env";
|
|
36
|
+
/** A project manifest that is no `DESCRIPTION`, e.g. the `rproject.toml` of an rv project. */
|
|
37
|
+
FileRole["Manifest"] = "manifest";
|
|
38
|
+
/**
|
|
39
|
+
* R sources evaluated at startup, before any project code (`.Rprofile`, `Rprofile.site`).
|
|
40
|
+
* These commonly bootstrap a package manager, e.g. by sourcing `packrat/init.R` or `renv/activate.R`.
|
|
41
|
+
*/
|
|
42
|
+
FileRole["Startup"] = "startup";
|
|
36
43
|
/**
|
|
37
44
|
* Catch-all for any file that provides usable R source code to incorporate into the analysis.
|
|
38
45
|
* Please note, that the loading order/inclusion and even potential relevance of these source files
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The kind of project that flowR is analyzing.
|
|
3
|
+
*
|
|
4
|
+
* This lives in its own module as the configuration refers to it (see `FlowrConfig.specializeConfig`) and the
|
|
5
|
+
* files context, which classifies it, pulls in the config itself.
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
/** The kind of project that flowR is analyzing, see {@link FlowrAnalyzerFilesContext#projectKind}. */
|
|
9
|
+
export declare enum ProjectKind {
|
|
10
|
+
/** An R package (has a `DESCRIPTION` file that does not mark it as a {@link ProjectKind.ShinyApp}). */
|
|
11
|
+
Package = "package",
|
|
12
|
+
/** A single R script. */
|
|
13
|
+
Script = "script",
|
|
14
|
+
/** A Shiny application (`Type: shiny` in the `DESCRIPTION`, `app.R`, or `ui.R` with `server.R`). */
|
|
15
|
+
ShinyApp = "shiny-app",
|
|
16
|
+
/** A notebook or literate document (`.ipynb`, `.Rmd`, `.qmd`, `.rnw`). */
|
|
17
|
+
Notebook = "notebook",
|
|
18
|
+
/** A multi-file project that is not a package. */
|
|
19
|
+
Project = "project",
|
|
20
|
+
/** The kind could not be determined (e.g. before the files are known). */
|
|
21
|
+
Unknown = "unknown"
|
|
22
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The kind of project that flowR is analyzing.
|
|
4
|
+
*
|
|
5
|
+
* This lives in its own module as the configuration refers to it (see `FlowrConfig.specializeConfig`) and the
|
|
6
|
+
* files context, which classifies it, pulls in the config itself.
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.ProjectKind = void 0;
|
|
11
|
+
/** The kind of project that flowR is analyzing, see {@link FlowrAnalyzerFilesContext#projectKind}. */
|
|
12
|
+
var ProjectKind;
|
|
13
|
+
(function (ProjectKind) {
|
|
14
|
+
/** An R package (has a `DESCRIPTION` file that does not mark it as a {@link ProjectKind.ShinyApp}). */
|
|
15
|
+
ProjectKind["Package"] = "package";
|
|
16
|
+
/** A single R script. */
|
|
17
|
+
ProjectKind["Script"] = "script";
|
|
18
|
+
/** A Shiny application (`Type: shiny` in the `DESCRIPTION`, `app.R`, or `ui.R` with `server.R`). */
|
|
19
|
+
ProjectKind["ShinyApp"] = "shiny-app";
|
|
20
|
+
/** A notebook or literate document (`.ipynb`, `.Rmd`, `.qmd`, `.rnw`). */
|
|
21
|
+
ProjectKind["Notebook"] = "notebook";
|
|
22
|
+
/** A multi-file project that is not a package. */
|
|
23
|
+
ProjectKind["Project"] = "project";
|
|
24
|
+
/** The kind could not be determined (e.g. before the files are known). */
|
|
25
|
+
ProjectKind["Unknown"] = "unknown";
|
|
26
|
+
})(ProjectKind || (exports.ProjectKind = ProjectKind = {}));
|
|
27
|
+
//# sourceMappingURL=project-kind.js.map
|