@eagleoutice/flowr 2.10.9 → 2.11.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 +116 -38
- package/abstract-interpretation/absint-visitor.js +6 -3
- package/abstract-interpretation/domains/abstract-domain.d.ts +1 -1
- package/abstract-interpretation/domains/bounded-set-domain.d.ts +1 -1
- package/abstract-interpretation/domains/bounded-set-domain.js +1 -1
- package/abstract-interpretation/domains/interval-domain.d.ts +1 -1
- package/abstract-interpretation/domains/interval-domain.js +1 -1
- package/abstract-interpretation/domains/lattice.d.ts +1 -1
- package/abstract-interpretation/domains/partial-product-domain.d.ts +1 -1
- package/abstract-interpretation/domains/partial-product-domain.js +2 -2
- package/abstract-interpretation/domains/set-range-domain.d.ts +1 -1
- package/abstract-interpretation/domains/set-range-domain.js +1 -1
- package/abstract-interpretation/domains/set-upper-bound-domain.d.ts +1 -1
- package/abstract-interpretation/domains/set-upper-bound-domain.js +1 -1
- package/abstract-interpretation/domains/singleton-domain.d.ts +1 -1
- package/abstract-interpretation/domains/singleton-domain.js +1 -1
- package/abstract-interpretation/domains/state-abstract-domain.d.ts +1 -1
- package/abstract-interpretation/domains/state-abstract-domain.js +2 -2
- package/abstract-interpretation/unsupported-functions.d.ts +3 -2
- package/abstract-interpretation/unsupported-functions.js +38 -28
- package/cli/benchmark-app.js +2 -1
- package/cli/common/options.d.ts +2 -108
- package/cli/common/options.js +3 -27
- package/cli/common/script.js +3 -2
- package/cli/common/scripts-info.d.ts +2 -123
- package/cli/common/scripts-info.js +0 -17
- package/cli/flowr-main-options.d.ts +5 -0
- package/cli/flowr-main-options.js +10 -0
- package/cli/flowr.js +48 -11
- package/cli/repl/commands/repl-cfg.js +9 -9
- package/cli/repl/commands/repl-commands.js +5 -0
- package/cli/repl/commands/repl-dataflow.js +31 -24
- package/cli/repl/commands/repl-main.d.ts +6 -0
- package/cli/repl/commands/repl-normalize.js +15 -12
- package/cli/repl/commands/repl-parse.js +1 -1
- package/cli/repl/commands/repl-query.js +4 -5
- package/cli/repl/commands/repl-quit.js +2 -1
- package/cli/repl/core.d.ts +11 -0
- package/cli/repl/core.js +101 -3
- package/cli/repl/execute.js +3 -2
- package/cli/repl/parser/slice-query-parser.d.ts +16 -0
- package/cli/repl/parser/slice-query-parser.js +52 -0
- package/cli/repl/print-version.d.ts +3 -1
- package/cli/repl/print-version.js +21 -2
- package/cli/repl/server/connection.d.ts +3 -0
- package/cli/repl/server/connection.js +65 -31
- package/cli/repl/server/messages/message-analysis.d.ts +10 -0
- package/cli/repl/server/messages/message-analysis.js +6 -2
- package/cli/repl/server/messages/message-slice.d.ts +1 -1
- package/cli/script-core/summarizer-core.js +13 -32
- package/cli/wiki.d.ts +3 -1
- package/cli/wiki.js +6 -1
- package/config.d.ts +22 -10
- package/config.js +33 -7
- package/control-flow/diff-cfg.d.ts +1 -1
- package/control-flow/diff-cfg.js +1 -1
- package/control-flow/semantic-cfg-guided-visitor.js +2 -0
- package/control-flow/simple-visitor.js +6 -5
- package/control-flow/useless-loop.js +2 -2
- package/core/print/dataflow-printer.d.ts +2 -2
- package/core/print/dataflow-printer.js +2 -2
- package/core/steps/all/static-slicing/00-slice.js +1 -1
- package/data/pkgdb/pkgdb-latest.json.br +0 -0
- package/data/pkgdb/pkgdb-tiny.json.br +0 -0
- package/dataflow/environments/append.d.ts +2 -2
- package/dataflow/environments/append.js +4 -10
- package/dataflow/environments/apply-kill.d.ts +21 -0
- package/dataflow/environments/apply-kill.js +155 -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.d.ts +4 -0
- package/dataflow/environments/built-in.js +4 -0
- package/dataflow/environments/default-builtin-config.d.ts +183 -67
- package/dataflow/environments/default-builtin-config.js +358 -147
- package/dataflow/environments/environment.d.ts +49 -31
- package/dataflow/environments/environment.js +144 -25
- package/dataflow/environments/identifier.d.ts +65 -2
- package/dataflow/environments/identifier.js +37 -2
- package/dataflow/environments/overwrite.js +2 -10
- package/dataflow/environments/reference-to-maybe.d.ts +2 -0
- package/dataflow/environments/reference-to-maybe.js +56 -11
- package/dataflow/environments/resolve-by-name.d.ts +1 -1
- package/dataflow/environments/resolve-by-name.js +23 -9
- package/dataflow/environments/scoping.d.ts +9 -2
- package/dataflow/environments/scoping.js +15 -2
- package/dataflow/eval/values/general.js +4 -0
- package/dataflow/extractor.js +35 -4
- package/dataflow/graph/df-helper.d.ts +14 -0
- package/dataflow/graph/df-helper.js +41 -0
- package/dataflow/graph/graph.d.ts +4 -1
- package/dataflow/graph/graph.js +6 -2
- package/dataflow/info.d.ts +27 -1
- package/dataflow/internal/linker.d.ts +5 -1
- package/dataflow/internal/linker.js +34 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +7 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +19 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +1 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +7 -13
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +9 -48
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +30 -47
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +17 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +7 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +61 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +9 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +37 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +391 -21
- package/dataflow/internal/process/functions/call/built-in/built-in-namespace-access.d.ts +13 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-namespace-access.js +58 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.d.ts +3 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +132 -25
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +9 -10
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.d.ts +25 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +94 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +11 -4
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +30 -0
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +279 -0
- package/dataflow/internal/process/functions/call/known-call-handling.js +4 -3
- package/dataflow/internal/process/functions/call/named-call-handling.d.ts +1 -1
- package/dataflow/internal/process/functions/call/named-call-handling.js +23 -0
- package/dataflow/origin/dfg-get-origin.d.ts +1 -1
- package/dataflow/origin/dfg-get-origin.js +1 -1
- package/dataflow/processor.d.ts +6 -0
- package/documentation/data/faq/faqs.d.ts +2 -1
- package/documentation/data/faq/faqs.js +78 -57
- package/documentation/data/interface/doc-writing-code.js +4 -80
- package/documentation/data/server/doc-data-server-messages.d.ts +2 -1
- package/documentation/data/server/doc-data-server-messages.js +15 -7
- package/documentation/doc-readme.js +15 -15
- package/documentation/doc-util/doc-cfg.d.ts +3 -1
- package/documentation/doc-util/doc-cfg.js +3 -3
- package/documentation/doc-util/doc-dfg.d.ts +3 -1
- package/documentation/doc-util/doc-dfg.js +3 -3
- package/documentation/doc-util/doc-files.d.ts +3 -1
- package/documentation/doc-util/doc-files.js +9 -6
- package/documentation/doc-util/doc-normalized-ast.d.ts +3 -1
- package/documentation/doc-util/doc-normalized-ast.js +2 -2
- package/documentation/doc-util/doc-query.d.ts +2 -1
- package/documentation/doc-util/doc-query.js +2 -2
- package/documentation/doc-util/doc-repl.js +1 -0
- package/documentation/doc-util/doc-structure.js +1 -2
- package/documentation/doc-util/doc-types.d.ts +6 -6
- package/documentation/doc-util/doc-types.js +11 -9
- package/documentation/issue-linting-rule.js +1 -2
- package/documentation/wiki-analyzer.js +9 -9
- package/documentation/wiki-cfg.js +40 -41
- package/documentation/wiki-core.js +121 -32
- package/documentation/wiki-create-linting-rules.d.ts +6 -0
- package/documentation/wiki-create-linting-rules.js +95 -0
- package/documentation/wiki-dataflow-graph.js +112 -77
- package/documentation/wiki-engine.js +1 -2
- package/documentation/wiki-faq.d.ts +2 -1
- package/documentation/wiki-faq.js +4 -4
- package/documentation/wiki-interface.js +22 -8
- package/documentation/wiki-linter.d.ts +1 -1
- package/documentation/wiki-linter.js +16 -6
- package/documentation/wiki-linting-and-testing.js +2 -2
- package/documentation/wiki-mk/doc-context.d.ts +3 -3
- package/documentation/wiki-mk/doc-maker.d.ts +2 -0
- package/documentation/wiki-mk/doc-maker.js +7 -1
- package/documentation/wiki-normalized-ast.js +5 -5
- package/documentation/wiki-onboarding.d.ts +2 -1
- package/documentation/wiki-onboarding.js +5 -5
- package/documentation/wiki-overview.js +4 -17
- package/documentation/wiki-package-database.d.ts +9 -0
- package/documentation/wiki-package-database.js +63 -0
- package/documentation/wiki-query.js +86 -84
- package/documentation/wiki-search.js +4 -5
- package/documentation/wiki-setup.js +6 -7
- package/gas.d.ts +74 -0
- package/gas.js +18 -0
- package/linter/linter-executor.js +2 -8
- package/linter/linter-format.d.ts +4 -11
- package/linter/linter-rules.d.ts +111 -86
- package/linter/linter-rules.js +9 -1
- package/linter/rules/absolute-path.d.ts +2 -7
- package/linter/rules/absolute-path.js +8 -5
- package/linter/rules/dataframe-access-validation.d.ts +1 -6
- package/linter/rules/dataframe-access-validation.js +8 -6
- package/linter/rules/dead-code.d.ts +2 -11
- package/linter/rules/dead-code.js +16 -11
- package/linter/rules/deprecated-functions.d.ts +3 -3
- package/linter/rules/file-path-validity.d.ts +1 -6
- package/linter/rules/file-path-validity.js +5 -5
- package/linter/rules/function-finder-util.d.ts +7 -11
- package/linter/rules/function-finder-util.js +9 -6
- package/linter/rules/naming-convention.d.ts +2 -7
- package/linter/rules/naming-convention.js +3 -2
- package/linter/rules/network-functions.d.ts +2 -7
- package/linter/rules/network-functions.js +14 -12
- package/linter/rules/no-leaked-credentials.d.ts +36 -0
- package/linter/rules/no-leaked-credentials.js +75 -0
- package/linter/rules/problematic-inputs.d.ts +1 -8
- package/linter/rules/problematic-inputs.js +5 -4
- package/linter/rules/roxygen-arguments.d.ts +2 -7
- package/linter/rules/roxygen-arguments.js +13 -20
- package/linter/rules/seeded-randomness.d.ts +2 -7
- package/linter/rules/seeded-randomness.js +7 -4
- package/linter/rules/software-has-license.d.ts +31 -0
- package/linter/rules/software-has-license.js +46 -0
- package/linter/rules/software-has-tests.d.ts +38 -0
- package/linter/rules/software-has-tests.js +48 -0
- package/linter/rules/stop-with-call-arg.d.ts +2 -7
- package/linter/rules/stop-with-call-arg.js +3 -2
- package/linter/rules/undefined-symbol.d.ts +39 -0
- package/linter/rules/undefined-symbol.js +80 -0
- package/linter/rules/unused-definition.d.ts +3 -8
- package/linter/rules/unused-definition.js +7 -5
- package/linter/rules/useless-loop.d.ts +2 -7
- package/linter/rules/useless-loop.js +5 -2
- package/package.json +5 -5
- package/project/cache/flowr-analyzer-cache.d.ts +2 -0
- package/project/cache/flowr-analyzer-cache.js +9 -1
- package/project/context/flowr-analyzer-context.d.ts +13 -14
- package/project/context/flowr-analyzer-context.js +4 -0
- package/project/context/flowr-analyzer-dependencies-context.d.ts +16 -8
- package/project/context/flowr-analyzer-dependencies-context.js +36 -4
- package/project/context/flowr-analyzer-environment-context.d.ts +2 -4
- package/project/context/flowr-analyzer-environment-context.js +3 -4
- package/project/context/flowr-analyzer-files-context.d.ts +13 -0
- package/project/context/flowr-analyzer-files-context.js +12 -2
- package/project/context/flowr-analyzer-gas-context.d.ts +28 -0
- package/project/context/flowr-analyzer-gas-context.js +101 -0
- package/project/context/flowr-file.d.ts +2 -0
- package/project/context/flowr-file.js +2 -0
- package/project/flowr-analyzer-builder.js +3 -0
- package/project/flowr-analyzer.d.ts +2 -1
- package/project/flowr-analyzer.js +3 -1
- package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +13 -15
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +36 -13
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +13 -7
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +56 -11
- package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.d.ts +27 -0
- package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.js +41 -0
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.js +2 -2
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.d.ts +2 -1
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.js +5 -5
- package/project/plugins/flowr-analyzer-plugin.d.ts +15 -8
- package/project/plugins/flowr-analyzer-plugin.js +14 -7
- package/project/plugins/gas-plugins/flowr-analyzer-gas-plugin.d.ts +19 -0
- package/project/plugins/gas-plugins/flowr-analyzer-gas-plugin.js +35 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.d.ts +18 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +62 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin.d.ts +63 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin.js +174 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.d.ts +10 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.js +6 -0
- package/project/plugins/package-version-plugins/package.d.ts +3 -0
- package/project/plugins/package-version-plugins/package.js +12 -0
- package/project/plugins/package-version-plugins/pkgdb.d.ts +133 -0
- package/project/plugins/package-version-plugins/pkgdb.js +370 -0
- package/project/plugins/plugin-registry.d.ts +5 -1
- package/project/plugins/plugin-registry.js +10 -1
- package/project/plugins/project-discovery/flowr-analyzer-gitignore-project-discovery-plugin.d.ts +22 -0
- package/project/plugins/project-discovery/flowr-analyzer-gitignore-project-discovery-plugin.js +47 -0
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +1 -1
- package/queries/catalog/call-context-query/call-context-query-executor.js +62 -8
- package/queries/catalog/call-context-query/call-context-query-format.d.ts +4 -2
- package/queries/catalog/call-context-query/call-context-query-format.js +1 -0
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +8 -0
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +31 -3
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +3 -1
- package/queries/catalog/dependencies-query/dependencies-query-format.js +3 -2
- package/queries/catalog/dependencies-query/function-info/function-info.d.ts +1 -1
- package/queries/catalog/dependencies-query/function-info/other-path-functions.d.ts +2 -0
- package/queries/catalog/dependencies-query/function-info/other-path-functions.js +27 -0
- package/queries/catalog/dependencies-query/function-info/read-functions.js +5 -4
- package/queries/catalog/dependencies-query/function-info/test-functions.d.ts +2 -0
- package/queries/catalog/dependencies-query/function-info/test-functions.js +18 -177
- package/queries/catalog/dependencies-query/function-info/visualize-functions.js +3 -1
- package/queries/catalog/df-shape-query/df-shape-query-format.js +1 -1
- package/queries/catalog/dice-query/dice-query-executor.d.ts +8 -0
- package/queries/catalog/dice-query/dice-query-executor.js +52 -0
- package/queries/catalog/dice-query/dice-query-format.d.ts +53 -0
- package/queries/catalog/dice-query/dice-query-format.js +102 -0
- package/queries/catalog/happens-before-query/happens-before-query-executor.js +2 -2
- 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 +1 -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 +1 -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 +1 -0
- package/queries/catalog/linter-query/linter-query-executor.js +8 -0
- 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 +1 -0
- package/queries/catalog/origin-query/origin-query-format.d.ts +2 -0
- package/queries/catalog/origin-query/origin-query-format.js +1 -0
- package/queries/catalog/provenance-query/provenance-query-format.d.ts +2 -0
- package/queries/catalog/provenance-query/provenance-query-format.js +1 -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 +1 -0
- package/queries/catalog/static-slice-query/static-slice-query-executor.js +1 -1
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +2 -0
- package/queries/catalog/static-slice-query/static-slice-query-format.js +1 -0
- package/queries/query.d.ts +18 -1
- package/queries/query.js +3 -1
- package/r-bridge/data/data.d.ts +7 -2
- package/r-bridge/data/data.js +8 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +0 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-number.d.ts +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-number.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-string.d.ts +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-string.js +1 -1
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +13 -4
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +55 -44
- package/r-bridge/parser.js +2 -9
- package/r-bridge/shell.d.ts +8 -1
- package/r-bridge/shell.js +26 -7
- package/search/flowr-search-builder.d.ts +2 -2
- package/search/flowr-search-builder.js +1 -1
- package/search/flowr-search-filters.d.ts +30 -9
- package/search/flowr-search-filters.js +26 -21
- package/search/search-executor/search-enrichers.d.ts +601 -1
- package/search/search-executor/search-enrichers.js +30 -6
- package/slicing/static/static-slicer.d.ts +39 -11
- package/slicing/static/static-slicer.js +44 -14
- package/util/collections/queue.d.ts +16 -0
- package/util/collections/queue.js +38 -0
- package/util/log.d.ts +1 -1
- package/util/log.js +1 -1
- package/util/mermaid/dfg.d.ts +2 -2
- package/util/mermaid/dfg.js +2 -2
- package/util/mermaid/mermaid.d.ts +4 -0
- package/util/mermaid/mermaid.js +8 -1
- package/util/objects.d.ts +9 -0
- package/util/objects.js +54 -0
- package/util/proc.d.ts +6 -0
- package/util/proc.js +20 -0
- package/util/version.js +10 -2
- package/cli/common/features.d.ts +0 -9
- package/cli/common/features.js +0 -35
- package/cli/script-core/statistics-core.d.ts +0 -6
- package/cli/script-core/statistics-core.js +0 -103
- package/cli/script-core/statistics-helper-core.d.ts +0 -6
- package/cli/script-core/statistics-helper-core.js +0 -85
- package/cli/statistics-app.d.ts +0 -11
- package/cli/statistics-app.js +0 -16
- package/cli/statistics-helper-app.d.ts +0 -11
- package/cli/statistics-helper-app.js +0 -14
- package/statistics/features/common-syntax-probability.d.ts +0 -38
- package/statistics/features/common-syntax-probability.js +0 -169
- package/statistics/features/feature.d.ts +0 -179
- package/statistics/features/feature.js +0 -38
- package/statistics/features/post-processing.d.ts +0 -18
- package/statistics/features/post-processing.js +0 -26
- package/statistics/features/supported/assignments/assignments.d.ts +0 -12
- package/statistics/features/supported/assignments/assignments.js +0 -56
- package/statistics/features/supported/assignments/post-process.d.ts +0 -6
- package/statistics/features/supported/assignments/post-process.js +0 -126
- package/statistics/features/supported/comments/comments.d.ts +0 -18
- package/statistics/features/supported/comments/comments.js +0 -143
- package/statistics/features/supported/comments/post-process.d.ts +0 -6
- package/statistics/features/supported/comments/post-process.js +0 -51
- package/statistics/features/supported/control-flow/control-flow.d.ts +0 -17
- package/statistics/features/supported/control-flow/control-flow.js +0 -69
- package/statistics/features/supported/control-flow/post-process.d.ts +0 -6
- package/statistics/features/supported/control-flow/post-process.js +0 -66
- package/statistics/features/supported/data-access/data-access.d.ts +0 -15
- package/statistics/features/supported/data-access/data-access.js +0 -122
- package/statistics/features/supported/data-access/post-process.d.ts +0 -6
- package/statistics/features/supported/data-access/post-process.js +0 -108
- package/statistics/features/supported/defined-functions/defined-functions.d.ts +0 -34
- package/statistics/features/supported/defined-functions/defined-functions.js +0 -145
- package/statistics/features/supported/defined-functions/post-process.d.ts +0 -6
- package/statistics/features/supported/defined-functions/post-process.js +0 -168
- package/statistics/features/supported/expression-list/post-process.d.ts +0 -6
- package/statistics/features/supported/expression-list/post-process.js +0 -45
- package/statistics/features/supported/expression-list/statistics-expression-list.d.ts +0 -9
- package/statistics/features/supported/expression-list/statistics-expression-list.js +0 -37
- package/statistics/features/supported/loops/loops.d.ts +0 -20
- package/statistics/features/supported/loops/loops.js +0 -81
- package/statistics/features/supported/loops/post-process.d.ts +0 -6
- package/statistics/features/supported/loops/post-process.js +0 -73
- package/statistics/features/supported/used-functions/post-process.d.ts +0 -6
- package/statistics/features/supported/used-functions/post-process.js +0 -176
- package/statistics/features/supported/used-functions/used-functions.d.ts +0 -24
- package/statistics/features/supported/used-functions/used-functions.js +0 -99
- package/statistics/features/supported/used-packages/post-process.d.ts +0 -6
- package/statistics/features/supported/used-packages/post-process.js +0 -122
- package/statistics/features/supported/used-packages/used-packages.d.ts +0 -16
- package/statistics/features/supported/used-packages/used-packages.js +0 -140
- package/statistics/features/supported/values/post-process.d.ts +0 -6
- package/statistics/features/supported/values/post-process.js +0 -73
- package/statistics/features/supported/values/values.d.ts +0 -14
- package/statistics/features/supported/values/values.js +0 -111
- package/statistics/features/supported/variables/post-process.d.ts +0 -15
- package/statistics/features/supported/variables/post-process.js +0 -126
- package/statistics/features/supported/variables/variables.d.ts +0 -15
- package/statistics/features/supported/variables/variables.js +0 -62
- package/statistics/meta-statistics.d.ts +0 -32
- package/statistics/meta-statistics.js +0 -16
- package/statistics/output/file-provider.d.ts +0 -36
- package/statistics/output/file-provider.js +0 -96
- package/statistics/output/print-stats.d.ts +0 -29
- package/statistics/output/print-stats.js +0 -81
- package/statistics/output/statistics-file.d.ts +0 -36
- package/statistics/output/statistics-file.js +0 -68
- package/statistics/statistics.d.ts +0 -29
- package/statistics/statistics.js +0 -108
- package/statistics/summarizer/auto-detect.d.ts +0 -5
- package/statistics/summarizer/auto-detect.js +0 -34
- package/statistics/summarizer/first-phase/process.d.ts +0 -6
- package/statistics/summarizer/first-phase/process.js +0 -81
- package/statistics/summarizer/post-process/clusterer.d.ts +0 -25
- package/statistics/summarizer/post-process/clusterer.js +0 -40
- package/statistics/summarizer/post-process/file-based-count.d.ts +0 -16
- package/statistics/summarizer/post-process/file-based-count.js +0 -47
- package/statistics/summarizer/post-process/histogram.d.ts +0 -57
- package/statistics/summarizer/post-process/histogram.js +0 -126
- package/statistics/summarizer/post-process/post-process-output.d.ts +0 -14
- package/statistics/summarizer/post-process/post-process-output.js +0 -102
- package/statistics/summarizer/second-phase/process.d.ts +0 -15
- package/statistics/summarizer/second-phase/process.js +0 -118
- package/statistics/summarizer/summarizer.d.ts +0 -34
- package/statistics/summarizer/summarizer.js +0 -141
|
@@ -0,0 +1,370 @@
|
|
|
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.PkgDatabase = exports.PkgDbBuilder = exports.DefaultCranBase = exports.PkgDbSchema = exports.PkgDbMagic = void 0;
|
|
7
|
+
exports.cranBlobUrl = cranBlobUrl;
|
|
8
|
+
exports.validatePkgDb = validatePkgDb;
|
|
9
|
+
exports.defaultPkgDbPath = defaultPkgDbPath;
|
|
10
|
+
const fs_1 = __importDefault(require("fs"));
|
|
11
|
+
const zlib_1 = __importDefault(require("zlib"));
|
|
12
|
+
const path_1 = __importDefault(require("path"));
|
|
13
|
+
/*
|
|
14
|
+
* Reader/writer for the `flowr-pkgdb` database (schema 4) produced by crawlr's `dump`.
|
|
15
|
+
* An export list mixes `strings`-pool indices (number) and inline single-use names.
|
|
16
|
+
* latest: pkgs[name] = [version, exported]. all: shares a `lists` pool and stores
|
|
17
|
+
* pkgs[name] = [latest, versions, nonCran?] with each version [ver, exported, internal?, deprecated?].
|
|
18
|
+
* Optional `all` definition locations: a `files` pool + locs[pkg][id] = [fileIndex, line] (latest only).
|
|
19
|
+
* CRAN urls are reconstructed on load. {@link PkgDbBuilder} writes, {@link PkgDatabase} reads - both in flowR.
|
|
20
|
+
*/
|
|
21
|
+
exports.PkgDbMagic = 'flowr-pkgdb';
|
|
22
|
+
exports.PkgDbSchema = 4;
|
|
23
|
+
exports.DefaultCranBase = 'https://cran.r-project.org/src/contrib/';
|
|
24
|
+
/** Reconstruct the CRAN source blob link; the newest non-archived version lives under `src/contrib`, every other under `Archive`. */
|
|
25
|
+
function cranBlobUrl(cranBase, pkg, version, opts) {
|
|
26
|
+
if (!opts.cran) {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
const base = cranBase.endsWith('/') ? cranBase : cranBase + '/';
|
|
30
|
+
return version === opts.latest && !opts.archived
|
|
31
|
+
? `${base}${pkg}_${version}.tar.gz`
|
|
32
|
+
: `${base}Archive/${pkg}/${pkg}_${version}.tar.gz`;
|
|
33
|
+
}
|
|
34
|
+
/** Validate the structural invariants of a decoded database, throwing a descriptive error on failure. */
|
|
35
|
+
function validatePkgDb(o) {
|
|
36
|
+
const fail = (msg) => {
|
|
37
|
+
throw new Error(`invalid flowr-pkgdb database: ${msg}`);
|
|
38
|
+
};
|
|
39
|
+
if (typeof o !== 'object' || o === null) {
|
|
40
|
+
fail('not an object');
|
|
41
|
+
}
|
|
42
|
+
const db = o;
|
|
43
|
+
if (db.format !== exports.PkgDbMagic) {
|
|
44
|
+
fail(`missing/invalid format (expected "${exports.PkgDbMagic}")`);
|
|
45
|
+
}
|
|
46
|
+
if (db.schema !== exports.PkgDbSchema) {
|
|
47
|
+
fail(`unsupported schema version ${String(db.schema)} (expected ${exports.PkgDbSchema})`);
|
|
48
|
+
}
|
|
49
|
+
if (db.scope !== 'latest' && db.scope !== 'all') {
|
|
50
|
+
fail(`invalid scope ${String(db.scope)}`);
|
|
51
|
+
}
|
|
52
|
+
if (!Array.isArray(db.strings)) {
|
|
53
|
+
fail('missing strings pool');
|
|
54
|
+
}
|
|
55
|
+
if (typeof db.pkgs !== 'object' || db.pkgs === null) {
|
|
56
|
+
fail('missing pkgs');
|
|
57
|
+
}
|
|
58
|
+
if (db.scope === 'all' && !Array.isArray(db.lists)) {
|
|
59
|
+
fail('all-scope database is missing the lists pool');
|
|
60
|
+
}
|
|
61
|
+
if (typeof db.content !== 'object' || db.content === null || typeof db.content.version !== 'number') {
|
|
62
|
+
fail('missing/invalid content header');
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/** portable gunzip (Node + browser + VS Code) via the Web Streams API */
|
|
66
|
+
async function gunzip(bytes) {
|
|
67
|
+
return new Response(new Blob([bytes]).stream().pipeThrough(new DecompressionStream('gzip'))).text();
|
|
68
|
+
}
|
|
69
|
+
function isGzip(bytes) {
|
|
70
|
+
return bytes[0] === 0x1f && bytes[1] === 0x8b;
|
|
71
|
+
}
|
|
72
|
+
/** richest first: `all` carries every version, `latest`/`tiny` only the current one */
|
|
73
|
+
const PkgDbScopeOrder = ['all', 'latest', 'tiny'];
|
|
74
|
+
/** layouts a bundled database may sit in, relative to a search root */
|
|
75
|
+
const PkgDbSubDirs = ['data/pkgdb', 'src/data/pkgdb', 'dist/src/data/pkgdb'];
|
|
76
|
+
/** roots to search for a bundled database; extendable via `$FLOWR_PKGDB_DIR` (path-delimiter separated) */
|
|
77
|
+
function pkgDbSearchRoots(extra) {
|
|
78
|
+
const roots = [...(extra ?? [])];
|
|
79
|
+
const env = typeof process !== 'undefined' ? process.env?.FLOWR_PKGDB_DIR : undefined;
|
|
80
|
+
if (env) {
|
|
81
|
+
roots.push(...env.split(path_1.default.delimiter).filter(Boolean));
|
|
82
|
+
}
|
|
83
|
+
if (typeof __dirname !== 'undefined') {
|
|
84
|
+
roots.push(__dirname);
|
|
85
|
+
}
|
|
86
|
+
if (typeof process !== 'undefined' && typeof process.cwd === 'function') {
|
|
87
|
+
roots.push(process.cwd());
|
|
88
|
+
}
|
|
89
|
+
return roots;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Location of a bundled database, found by walking up from several roots (this module,
|
|
93
|
+
* `$FLOWR_PKGDB_DIR`, the working directory) across the dev (`src`) and build (`dist`) layouts. With
|
|
94
|
+
* no `scope` it returns the richest available tier (brotli, then gzip, then plain json). Node only
|
|
95
|
+
* (needs `fs`); pass `searchRoots` to override where it looks.
|
|
96
|
+
*/
|
|
97
|
+
function defaultPkgDbPath(scope, searchRoots) {
|
|
98
|
+
if (typeof fs_1.default?.existsSync !== 'function') {
|
|
99
|
+
return undefined;
|
|
100
|
+
}
|
|
101
|
+
const scopes = scope ? [scope] : PkgDbScopeOrder;
|
|
102
|
+
for (const root of pkgDbSearchRoots(searchRoots)) {
|
|
103
|
+
for (let dir = root, i = 0; i < 10; i++) {
|
|
104
|
+
for (const sub of PkgDbSubDirs) {
|
|
105
|
+
for (const s of scopes) {
|
|
106
|
+
for (const suffix of ['.br', '.gz', '']) {
|
|
107
|
+
const candidate = path_1.default.join(dir, sub, `pkgdb-${s}.json${suffix}`);
|
|
108
|
+
if (fs_1.default.existsSync(candidate)) {
|
|
109
|
+
return candidate;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const parent = path_1.default.dirname(dir);
|
|
115
|
+
if (parent === dir) {
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
dir = parent;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return undefined;
|
|
122
|
+
}
|
|
123
|
+
/** portable non-cryptographic 64-bit hash (cyrb53), hex, for update detection */
|
|
124
|
+
function hash53(str) {
|
|
125
|
+
let h1 = 0xdeadbeef, h2 = 0x41c6ce57;
|
|
126
|
+
for (let i = 0; i < str.length; i++) {
|
|
127
|
+
const ch = str.charCodeAt(i);
|
|
128
|
+
h1 = Math.imul(h1 ^ ch, 2654435761);
|
|
129
|
+
h2 = Math.imul(h2 ^ ch, 1597334677);
|
|
130
|
+
}
|
|
131
|
+
h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^ Math.imul(h2 ^ (h2 >>> 13), 3266489909);
|
|
132
|
+
h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^ Math.imul(h1 ^ (h1 >>> 13), 3266489909);
|
|
133
|
+
return (h2 >>> 0).toString(16).padStart(8, '0') + (h1 >>> 0).toString(16).padStart(8, '0');
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Serializes a {@link PkgDb}. Accumulate per-version exports with {@link addPackage}/{@link addVersion},
|
|
137
|
+
* then {@link build} a scope. The multi-use string pool is computed per scope; the `latest` scope may
|
|
138
|
+
* be pruned to the most-downloaded packages. This is the counterpart of {@link PkgDatabase} (the reader).
|
|
139
|
+
*/
|
|
140
|
+
class PkgDbBuilder {
|
|
141
|
+
raw = new Map();
|
|
142
|
+
versionCount = 0;
|
|
143
|
+
addPackage(name, opts) {
|
|
144
|
+
const p = this.raw.get(name);
|
|
145
|
+
if (p) {
|
|
146
|
+
p.latest = opts.latest;
|
|
147
|
+
p.archived = opts.archived ?? p.archived;
|
|
148
|
+
p.downloads = opts.downloads ?? p.downloads;
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
this.raw.set(name, { latest: opts.latest, archived: opts.archived ?? false, downloads: opts.downloads ?? 0, versions: new Map() });
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
addVersion(name, version, exports) {
|
|
155
|
+
const p = this.raw.get(name) ?? { latest: version, archived: false, downloads: 0, versions: new Map() };
|
|
156
|
+
if (!this.raw.has(name)) {
|
|
157
|
+
this.raw.set(name, p);
|
|
158
|
+
}
|
|
159
|
+
p.versions.set(version, exports);
|
|
160
|
+
this.versionCount++;
|
|
161
|
+
}
|
|
162
|
+
relevant(scope, prune) {
|
|
163
|
+
if (scope === 'all') {
|
|
164
|
+
const out = [];
|
|
165
|
+
for (const [name, p] of this.raw) {
|
|
166
|
+
for (const [version, ex] of p.versions) {
|
|
167
|
+
out.push({ name, version, ex });
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return out;
|
|
171
|
+
}
|
|
172
|
+
let pkgs = [...this.raw].filter(([, p]) => p.downloads >= prune.minDownloads && p.versions.has(p.latest));
|
|
173
|
+
if (prune.topN !== undefined && pkgs.length > prune.topN) {
|
|
174
|
+
pkgs = pkgs.sort((a, b) => b[1].downloads - a[1].downloads).slice(0, prune.topN);
|
|
175
|
+
}
|
|
176
|
+
return pkgs.map(([name, p]) => ({ name, version: p.latest, ex: p.versions.get(p.latest) }));
|
|
177
|
+
}
|
|
178
|
+
buildPool(relevant, scope) {
|
|
179
|
+
const freq = new Map();
|
|
180
|
+
for (const { ex } of relevant) {
|
|
181
|
+
const names = scope === 'all' ? [...ex.exported, ...ex.internal, ...ex.deprecated] : ex.exported;
|
|
182
|
+
for (const name of names) {
|
|
183
|
+
freq.set(name, (freq.get(name) ?? 0) + 1);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
const strings = [...freq.entries()].filter(([, c]) => c >= 2).sort((a, b) => b[1] - a[1]).map(([n]) => n);
|
|
187
|
+
return { strings, index: new Map(strings.map((n, i) => [n, i])) };
|
|
188
|
+
}
|
|
189
|
+
build(scope, meta) {
|
|
190
|
+
const relevant = this.relevant(scope, { minDownloads: meta.minDownloads ?? 0, topN: meta.topN });
|
|
191
|
+
const { strings, index } = this.buildPool(relevant, scope);
|
|
192
|
+
const encode = (names) => [...new Set(names)].sort().map(n => index.get(n) ?? n);
|
|
193
|
+
const content = {
|
|
194
|
+
version: meta.version, date: meta.date, hash: '', generated: meta.generated,
|
|
195
|
+
packages: scope === 'latest' ? relevant.length : this.raw.size, versions: this.versionCount
|
|
196
|
+
};
|
|
197
|
+
const cranBase = meta.cranBase && meta.cranBase !== exports.DefaultCranBase ? meta.cranBase : undefined;
|
|
198
|
+
const archived = [];
|
|
199
|
+
let db;
|
|
200
|
+
if (scope === 'latest') {
|
|
201
|
+
const noncran = [];
|
|
202
|
+
const pkgs = {};
|
|
203
|
+
for (const { name, version, ex } of relevant) {
|
|
204
|
+
pkgs[name] = [version, encode(ex.exported)];
|
|
205
|
+
if (this.raw.get(name)?.archived) {
|
|
206
|
+
archived.push(name);
|
|
207
|
+
}
|
|
208
|
+
if (!ex.cran) {
|
|
209
|
+
noncran.push(name);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
db = { format: exports.PkgDbMagic, schema: exports.PkgDbSchema, scope, content, cranBase, strings, pkgs,
|
|
213
|
+
...(archived.length ? { archived } : {}), ...(noncran.length ? { noncran } : {}) };
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
const lists = [];
|
|
217
|
+
const listIndex = new Map();
|
|
218
|
+
const internList = (names) => {
|
|
219
|
+
const enc = encode(names);
|
|
220
|
+
const key = JSON.stringify(enc);
|
|
221
|
+
let idx = listIndex.get(key);
|
|
222
|
+
if (idx === undefined) {
|
|
223
|
+
idx = lists.length;
|
|
224
|
+
lists.push(enc);
|
|
225
|
+
listIndex.set(key, idx);
|
|
226
|
+
}
|
|
227
|
+
return idx;
|
|
228
|
+
};
|
|
229
|
+
internList([]);
|
|
230
|
+
const files = [];
|
|
231
|
+
const fileIndex = new Map();
|
|
232
|
+
const internFile = (f) => {
|
|
233
|
+
let idx = fileIndex.get(f);
|
|
234
|
+
if (idx === undefined) {
|
|
235
|
+
idx = files.length;
|
|
236
|
+
files.push(f);
|
|
237
|
+
fileIndex.set(f, idx);
|
|
238
|
+
}
|
|
239
|
+
return idx;
|
|
240
|
+
};
|
|
241
|
+
const locs = {};
|
|
242
|
+
const pkgs = {};
|
|
243
|
+
for (const [name, p] of this.raw) {
|
|
244
|
+
const versions = [];
|
|
245
|
+
const nc = [];
|
|
246
|
+
for (const [version, ex] of p.versions) {
|
|
247
|
+
const e = internList(ex.exported), i = internList(ex.internal), d = internList(ex.deprecated);
|
|
248
|
+
versions.push(d !== 0 ? [version, e, i, d] : i !== 0 ? [version, e, i] : [version, e]);
|
|
249
|
+
if (!ex.cran) {
|
|
250
|
+
nc.push(version);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
pkgs[name] = nc.length ? [p.latest, versions, nc] : [p.latest, versions];
|
|
254
|
+
if (p.archived) {
|
|
255
|
+
archived.push(name);
|
|
256
|
+
}
|
|
257
|
+
// optional: record the latest version's definition locations, if the source carried them
|
|
258
|
+
const latestLoc = p.versions.get(p.latest)?.locations;
|
|
259
|
+
if (latestLoc && latestLoc.size > 0) {
|
|
260
|
+
const entry = {};
|
|
261
|
+
for (const [id, [file, line]] of latestLoc) {
|
|
262
|
+
entry[id] = [internFile(file), line];
|
|
263
|
+
}
|
|
264
|
+
locs[name] = entry;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
db = { format: exports.PkgDbMagic, schema: exports.PkgDbSchema, scope, content, cranBase, strings, lists, pkgs,
|
|
268
|
+
...(archived.length ? { archived } : {}),
|
|
269
|
+
...(files.length ? { files, locs } : {}) };
|
|
270
|
+
}
|
|
271
|
+
return { ...db, content: { ...content, hash: hash53(JSON.stringify(db)) } };
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
exports.PkgDbBuilder = PkgDbBuilder;
|
|
275
|
+
class PkgDatabase {
|
|
276
|
+
db;
|
|
277
|
+
archived;
|
|
278
|
+
noncran;
|
|
279
|
+
constructor(db) {
|
|
280
|
+
this.db = db;
|
|
281
|
+
this.archived = new Set(db.archived ?? []);
|
|
282
|
+
this.noncran = new Set(db.noncran ?? []);
|
|
283
|
+
}
|
|
284
|
+
get content() {
|
|
285
|
+
return this.db.content;
|
|
286
|
+
}
|
|
287
|
+
get scope() {
|
|
288
|
+
return this.db.scope;
|
|
289
|
+
}
|
|
290
|
+
/** parse an already-loaded object (validates the schema, throwing a descriptive error on failure) */
|
|
291
|
+
static fromObject(obj) {
|
|
292
|
+
validatePkgDb(obj);
|
|
293
|
+
return new PkgDatabase(obj);
|
|
294
|
+
}
|
|
295
|
+
/** portable async load from raw bytes (gzip auto-detected) */
|
|
296
|
+
static async fromBytes(bytes) {
|
|
297
|
+
const text = isGzip(bytes) ? await gunzip(bytes) : new TextDecoder().decode(bytes);
|
|
298
|
+
return PkgDatabase.fromObject(JSON.parse(text));
|
|
299
|
+
}
|
|
300
|
+
/** portable async load from a URL (works in Node 18+, browser and VS Code) */
|
|
301
|
+
static async fromUrl(url) {
|
|
302
|
+
return PkgDatabase.fromBytes(new Uint8Array(await (await fetch(url)).arrayBuffer()));
|
|
303
|
+
}
|
|
304
|
+
/** synchronous load from a local file (Node only; brotli by `.br`, else gzip auto-detected, else plain) */
|
|
305
|
+
static fromFileSync(file) {
|
|
306
|
+
const raw = fs_1.default.readFileSync(file);
|
|
307
|
+
const bytes = new Uint8Array(raw.buffer, raw.byteOffset, raw.byteLength);
|
|
308
|
+
const text = file.endsWith('.br') ? zlib_1.default.brotliDecompressSync(raw).toString('utf8')
|
|
309
|
+
: isGzip(bytes) ? zlib_1.default.gunzipSync(raw).toString('utf8')
|
|
310
|
+
: raw.toString('utf8');
|
|
311
|
+
return PkgDatabase.fromObject(JSON.parse(text));
|
|
312
|
+
}
|
|
313
|
+
has(pkg) {
|
|
314
|
+
return this.db.pkgs[pkg] !== undefined;
|
|
315
|
+
}
|
|
316
|
+
decode(list) {
|
|
317
|
+
return (list ?? []).map(x => typeof x === 'number' ? this.db.strings[x] : x);
|
|
318
|
+
}
|
|
319
|
+
result(pkg, version, latest, cran, exported, internal, deprecated, locations) {
|
|
320
|
+
const cranBase = this.db.cranBase ?? exports.DefaultCranBase;
|
|
321
|
+
return {
|
|
322
|
+
version, exported, internal, deprecated, cran,
|
|
323
|
+
cranUrl: cranBlobUrl(cranBase, pkg, version, { latest, archived: this.archived.has(pkg), cran }),
|
|
324
|
+
...(locations ? { locations } : {})
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
/** definition locations of the latest version, if the (`all`-scope) database carries them */
|
|
328
|
+
locations(pkg) {
|
|
329
|
+
if (this.db.scope !== 'all' || !this.db.locs || !this.db.files) {
|
|
330
|
+
return undefined;
|
|
331
|
+
}
|
|
332
|
+
const entry = this.db.locs[pkg];
|
|
333
|
+
if (!entry) {
|
|
334
|
+
return undefined;
|
|
335
|
+
}
|
|
336
|
+
const files = this.db.files;
|
|
337
|
+
const map = new Map();
|
|
338
|
+
for (const id in entry) {
|
|
339
|
+
const [fileIdx, line] = entry[id];
|
|
340
|
+
map.set(id, { file: files[fileIdx], line });
|
|
341
|
+
}
|
|
342
|
+
return map;
|
|
343
|
+
}
|
|
344
|
+
/** look up the identifiers of a package (defaulting to its latest version) */
|
|
345
|
+
lookup(pkg, version) {
|
|
346
|
+
if (this.db.scope === 'latest') {
|
|
347
|
+
const entry = this.db.pkgs[pkg];
|
|
348
|
+
if (!entry) {
|
|
349
|
+
return undefined;
|
|
350
|
+
}
|
|
351
|
+
return this.result(pkg, entry[0], entry[0], !this.noncran.has(pkg), this.decode(entry[1]), [], []);
|
|
352
|
+
}
|
|
353
|
+
const entry = this.db.pkgs[pkg];
|
|
354
|
+
if (!entry) {
|
|
355
|
+
return undefined;
|
|
356
|
+
}
|
|
357
|
+
const [latest, versions, nc] = entry;
|
|
358
|
+
const vt = (version ? versions.find(v => v[0] === version) : undefined)
|
|
359
|
+
?? versions.find(v => v[0] === latest) ?? versions[versions.length - 1];
|
|
360
|
+
if (!vt) {
|
|
361
|
+
return undefined;
|
|
362
|
+
}
|
|
363
|
+
const lists = this.db.lists;
|
|
364
|
+
// locations are only stored for the latest version
|
|
365
|
+
const locations = vt[0] === latest ? this.locations(pkg) : undefined;
|
|
366
|
+
return this.result(pkg, vt[0], latest, !nc?.includes(vt[0]), this.decode(lists[vt[1]]), this.decode(lists[vt[2] ?? 0]), this.decode(lists[vt[3] ?? 0]), locations);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
exports.PkgDatabase = PkgDatabase;
|
|
370
|
+
//# sourceMappingURL=pkgdb.js.map
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { FlowrAnalyzerPlugin } from './flowr-analyzer-plugin';
|
|
2
2
|
import { FlowrAnalyzerDescriptionFilePlugin } from './file-plugins/flowr-analyzer-description-file-plugin';
|
|
3
3
|
import { FlowrAnalyzerPackageVersionsDescriptionFilePlugin } from './package-version-plugins/flowr-analyzer-package-versions-description-file-plugin';
|
|
4
|
+
import { FlowrAnalyzerPackageVersionsPkgDbPlugin } from './package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin';
|
|
5
|
+
import { FlowrAnalyzerPackageVersionsRenvPlugin, FlowrAnalyzerPackageVersionsRvPlugin } from './package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin';
|
|
4
6
|
import { FlowrAnalyzerLoadingOrderDescriptionFilePlugin } from './loading-order-plugins/flowr-analyzer-loading-order-description-file-plugin';
|
|
5
7
|
import { FlowrAnalyzerRmdFilePlugin } from './file-plugins/notebooks/flowr-analyzer-rmd-file-plugin';
|
|
6
8
|
import { FlowrAnalyzerQmdFilePlugin } from './file-plugins/notebooks/flowr-analyzer-qmd-file-plugin';
|
|
@@ -10,12 +12,14 @@ import { FlowrAnalyzerNewsFilePlugin } from './file-plugins/flowr-analyzer-news-
|
|
|
10
12
|
import { FlowrAnalyzerMetaVignetteFilesPlugin } from './file-plugins/flowr-analyzer-vignette-file-plugin';
|
|
11
13
|
import { FlowrAnalyzerMetaTestFilesPlugin } from './file-plugins/flowr-analyzer-test-file-plugin';
|
|
12
14
|
import { FlowrAnalyzerLicenseFilePlugin } from './file-plugins/flowr-analyzer-license-file-plugin';
|
|
15
|
+
import { FlowrAnalyzerVirtualEnvFilePlugin } from './file-plugins/flowr-analyzer-virtualenv-file-plugin';
|
|
13
16
|
import { FlowrAnalyzerMetaDescriptionFilePlugin } from './package-version-plugins/flowr-analyzer-meta-description-file-plugin';
|
|
14
17
|
import { FlowrAnalyzerSweaveFilePlugin } from './file-plugins/notebooks/flowr-analyzer-sweave-file-plugin';
|
|
18
|
+
import { FlowrAnalyzerGitignoreProjectDiscoveryPlugin } from './project-discovery/flowr-analyzer-gitignore-project-discovery-plugin';
|
|
15
19
|
/**
|
|
16
20
|
* The built-in Flowr Analyzer plugins that are always available.
|
|
17
21
|
*/
|
|
18
|
-
export declare const BuiltInPlugins: [["file:description", typeof FlowrAnalyzerDescriptionFilePlugin], ["versions:description", typeof FlowrAnalyzerPackageVersionsDescriptionFilePlugin], ["loading-order:description", typeof FlowrAnalyzerLoadingOrderDescriptionFilePlugin], ["meta:description", typeof FlowrAnalyzerMetaDescriptionFilePlugin], ["files:vignette", typeof FlowrAnalyzerMetaVignetteFilesPlugin], ["files:test", typeof FlowrAnalyzerMetaTestFilesPlugin], ["file:rmd", typeof FlowrAnalyzerRmdFilePlugin], ["file:qmd", typeof FlowrAnalyzerQmdFilePlugin], ["file:rnw", typeof FlowrAnalyzerSweaveFilePlugin], ["file:ipynb", typeof FlowrAnalyzerJupyterFilePlugin], ["file:namespace", typeof FlowrAnalyzerNamespaceFilesPlugin], ["file:news", typeof FlowrAnalyzerNewsFilePlugin], ["file:license", typeof FlowrAnalyzerLicenseFilePlugin]];
|
|
22
|
+
export declare const BuiltInPlugins: [["file:description", typeof FlowrAnalyzerDescriptionFilePlugin], ["versions:description", typeof FlowrAnalyzerPackageVersionsDescriptionFilePlugin], ["versions:pkgdb", typeof FlowrAnalyzerPackageVersionsPkgDbPlugin], ["versions:renv", typeof FlowrAnalyzerPackageVersionsRenvPlugin], ["versions:rv", typeof FlowrAnalyzerPackageVersionsRvPlugin], ["loading-order:description", typeof FlowrAnalyzerLoadingOrderDescriptionFilePlugin], ["meta:description", typeof FlowrAnalyzerMetaDescriptionFilePlugin], ["files:vignette", typeof FlowrAnalyzerMetaVignetteFilesPlugin], ["files:test", typeof FlowrAnalyzerMetaTestFilesPlugin], ["file:rmd", typeof FlowrAnalyzerRmdFilePlugin], ["file:qmd", typeof FlowrAnalyzerQmdFilePlugin], ["file:rnw", typeof FlowrAnalyzerSweaveFilePlugin], ["file:ipynb", typeof FlowrAnalyzerJupyterFilePlugin], ["file:namespace", typeof FlowrAnalyzerNamespaceFilesPlugin], ["file:news", typeof FlowrAnalyzerNewsFilePlugin], ["file:license", typeof FlowrAnalyzerLicenseFilePlugin], ["file:virtualenv", typeof FlowrAnalyzerVirtualEnvFilePlugin], ["project-discovery:gitignore", typeof FlowrAnalyzerGitignoreProjectDiscoveryPlugin]];
|
|
19
23
|
export type BuiltInFlowrPluginName = typeof BuiltInPlugins[number][0];
|
|
20
24
|
export type BuiltInFlowrPluginArgs<N extends BuiltInFlowrPluginName> = N extends typeof BuiltInPlugins[number][0] ? ConstructorParameters<Extract<typeof BuiltInPlugins[number], [N, PluginProducer]>[1]> : never;
|
|
21
25
|
type PluginProducer = new (...args: never[]) => FlowrAnalyzerPlugin;
|
|
@@ -6,6 +6,8 @@ exports.getPlugin = getPlugin;
|
|
|
6
6
|
exports.makePlugin = makePlugin;
|
|
7
7
|
const flowr_analyzer_description_file_plugin_1 = require("./file-plugins/flowr-analyzer-description-file-plugin");
|
|
8
8
|
const flowr_analyzer_package_versions_description_file_plugin_1 = require("./package-version-plugins/flowr-analyzer-package-versions-description-file-plugin");
|
|
9
|
+
const flowr_analyzer_package_versions_pkgdb_plugin_1 = require("./package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin");
|
|
10
|
+
const flowr_analyzer_package_versions_lockfile_plugin_1 = require("./package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin");
|
|
9
11
|
const flowr_analyzer_loading_order_description_file_plugin_1 = require("./loading-order-plugins/flowr-analyzer-loading-order-description-file-plugin");
|
|
10
12
|
const flowr_analyzer_rmd_file_plugin_1 = require("./file-plugins/notebooks/flowr-analyzer-rmd-file-plugin");
|
|
11
13
|
const flowr_analyzer_qmd_file_plugin_1 = require("./file-plugins/notebooks/flowr-analyzer-qmd-file-plugin");
|
|
@@ -16,14 +18,19 @@ const flowr_analyzer_news_file_plugin_1 = require("./file-plugins/flowr-analyzer
|
|
|
16
18
|
const flowr_analyzer_vignette_file_plugin_1 = require("./file-plugins/flowr-analyzer-vignette-file-plugin");
|
|
17
19
|
const flowr_analyzer_test_file_plugin_1 = require("./file-plugins/flowr-analyzer-test-file-plugin");
|
|
18
20
|
const flowr_analyzer_license_file_plugin_1 = require("./file-plugins/flowr-analyzer-license-file-plugin");
|
|
21
|
+
const flowr_analyzer_virtualenv_file_plugin_1 = require("./file-plugins/flowr-analyzer-virtualenv-file-plugin");
|
|
19
22
|
const flowr_analyzer_meta_description_file_plugin_1 = require("./package-version-plugins/flowr-analyzer-meta-description-file-plugin");
|
|
20
23
|
const flowr_analyzer_sweave_file_plugin_1 = require("./file-plugins/notebooks/flowr-analyzer-sweave-file-plugin");
|
|
24
|
+
const flowr_analyzer_gitignore_project_discovery_plugin_1 = require("./project-discovery/flowr-analyzer-gitignore-project-discovery-plugin");
|
|
21
25
|
/**
|
|
22
26
|
* The built-in Flowr Analyzer plugins that are always available.
|
|
23
27
|
*/
|
|
24
28
|
exports.BuiltInPlugins = [
|
|
25
29
|
['file:description', flowr_analyzer_description_file_plugin_1.FlowrAnalyzerDescriptionFilePlugin],
|
|
26
30
|
['versions:description', flowr_analyzer_package_versions_description_file_plugin_1.FlowrAnalyzerPackageVersionsDescriptionFilePlugin],
|
|
31
|
+
['versions:pkgdb', flowr_analyzer_package_versions_pkgdb_plugin_1.FlowrAnalyzerPackageVersionsPkgDbPlugin],
|
|
32
|
+
['versions:renv', flowr_analyzer_package_versions_lockfile_plugin_1.FlowrAnalyzerPackageVersionsRenvPlugin],
|
|
33
|
+
['versions:rv', flowr_analyzer_package_versions_lockfile_plugin_1.FlowrAnalyzerPackageVersionsRvPlugin],
|
|
27
34
|
['loading-order:description', flowr_analyzer_loading_order_description_file_plugin_1.FlowrAnalyzerLoadingOrderDescriptionFilePlugin],
|
|
28
35
|
['meta:description', flowr_analyzer_meta_description_file_plugin_1.FlowrAnalyzerMetaDescriptionFilePlugin],
|
|
29
36
|
['files:vignette', flowr_analyzer_vignette_file_plugin_1.FlowrAnalyzerMetaVignetteFilesPlugin],
|
|
@@ -34,7 +41,9 @@ exports.BuiltInPlugins = [
|
|
|
34
41
|
['file:ipynb', flowr_analyzer_jupyter_file_plugin_1.FlowrAnalyzerJupyterFilePlugin],
|
|
35
42
|
['file:namespace', flowr_analyzer_namespace_files_plugin_1.FlowrAnalyzerNamespaceFilesPlugin],
|
|
36
43
|
['file:news', flowr_analyzer_news_file_plugin_1.FlowrAnalyzerNewsFilePlugin],
|
|
37
|
-
['file:license', flowr_analyzer_license_file_plugin_1.FlowrAnalyzerLicenseFilePlugin]
|
|
44
|
+
['file:license', flowr_analyzer_license_file_plugin_1.FlowrAnalyzerLicenseFilePlugin],
|
|
45
|
+
['file:virtualenv', flowr_analyzer_virtualenv_file_plugin_1.FlowrAnalyzerVirtualEnvFilePlugin],
|
|
46
|
+
['project-discovery:gitignore', flowr_analyzer_gitignore_project_discovery_plugin_1.FlowrAnalyzerGitignoreProjectDiscoveryPlugin]
|
|
38
47
|
];
|
|
39
48
|
/**
|
|
40
49
|
* The registry of built-in and user-registered Flowr Analyzer plugins.
|
package/project/plugins/project-discovery/flowr-analyzer-gitignore-project-discovery-plugin.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { FlowrAnalyzerProjectDiscoveryPlugin } from './flowr-analyzer-project-discovery-plugin';
|
|
2
|
+
import { SemVer } from 'semver';
|
|
3
|
+
import type { FlowrAnalyzerContext } from '../../context/flowr-analyzer-context';
|
|
4
|
+
import type { RProjectAnalysisRequest } from '../../context/flowr-analyzer-files-context';
|
|
5
|
+
import type { RParseRequest } from '../../../r-bridge/retriever';
|
|
6
|
+
import type { FlowrFile } from '../../context/flowr-file';
|
|
7
|
+
/**
|
|
8
|
+
* Decorator around any {@link FlowrAnalyzerProjectDiscoveryPlugin} that filters discovered files
|
|
9
|
+
* by the rules in a `.gitignore` file found at the project root.
|
|
10
|
+
* If no `.gitignore` exists, the inner plugin's results are returned unchanged.
|
|
11
|
+
*
|
|
12
|
+
* Register as `'project-discovery:gitignore'` (see {@link BuiltInPlugins}) to replace the
|
|
13
|
+
* default discovery plugin with a gitignore-aware variant.
|
|
14
|
+
*/
|
|
15
|
+
export declare class FlowrAnalyzerGitignoreProjectDiscoveryPlugin extends FlowrAnalyzerProjectDiscoveryPlugin {
|
|
16
|
+
readonly name = "flowr-analyzer-gitignore-project-discovery-plugin";
|
|
17
|
+
readonly description = "Wraps a project discovery plugin and filters results by .gitignore rules.";
|
|
18
|
+
readonly version: SemVer;
|
|
19
|
+
private readonly inner;
|
|
20
|
+
constructor(inner?: FlowrAnalyzerProjectDiscoveryPlugin);
|
|
21
|
+
protected process(context: FlowrAnalyzerContext, args: RProjectAnalysisRequest): (RParseRequest | FlowrFile<string>)[];
|
|
22
|
+
}
|
package/project/plugins/project-discovery/flowr-analyzer-gitignore-project-discovery-plugin.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
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.FlowrAnalyzerGitignoreProjectDiscoveryPlugin = void 0;
|
|
7
|
+
const flowr_analyzer_project_discovery_plugin_1 = require("./flowr-analyzer-project-discovery-plugin");
|
|
8
|
+
const semver_1 = require("semver");
|
|
9
|
+
const retriever_1 = require("../../../r-bridge/retriever");
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const fs_1 = __importDefault(require("fs"));
|
|
12
|
+
const ignore_1 = __importDefault(require("ignore"));
|
|
13
|
+
/**
|
|
14
|
+
* Decorator around any {@link FlowrAnalyzerProjectDiscoveryPlugin} that filters discovered files
|
|
15
|
+
* by the rules in a `.gitignore` file found at the project root.
|
|
16
|
+
* If no `.gitignore` exists, the inner plugin's results are returned unchanged.
|
|
17
|
+
*
|
|
18
|
+
* Register as `'project-discovery:gitignore'` (see {@link BuiltInPlugins}) to replace the
|
|
19
|
+
* default discovery plugin with a gitignore-aware variant.
|
|
20
|
+
*/
|
|
21
|
+
class FlowrAnalyzerGitignoreProjectDiscoveryPlugin extends flowr_analyzer_project_discovery_plugin_1.FlowrAnalyzerProjectDiscoveryPlugin {
|
|
22
|
+
name = 'flowr-analyzer-gitignore-project-discovery-plugin';
|
|
23
|
+
description = 'Wraps a project discovery plugin and filters results by .gitignore rules.';
|
|
24
|
+
version = new semver_1.SemVer('0.1.0');
|
|
25
|
+
inner;
|
|
26
|
+
constructor(inner = flowr_analyzer_project_discovery_plugin_1.FlowrAnalyzerProjectDiscoveryPlugin.defaultPlugin()) {
|
|
27
|
+
super();
|
|
28
|
+
this.inner = inner;
|
|
29
|
+
}
|
|
30
|
+
process(context, args) {
|
|
31
|
+
const ig = (0, ignore_1.default)();
|
|
32
|
+
const gitignorePath = path_1.default.join(args.content, '.gitignore');
|
|
33
|
+
if (fs_1.default.existsSync(gitignorePath)) {
|
|
34
|
+
ig.add(fs_1.default.readFileSync(gitignorePath, 'utf-8'));
|
|
35
|
+
}
|
|
36
|
+
return this.inner.processor(context, args).filter(r => {
|
|
37
|
+
const filePath = (0, retriever_1.isParseRequest)(r) && r.request === 'file' ? r.content : !(0, retriever_1.isParseRequest)(r) ? r.path() : undefined;
|
|
38
|
+
if (filePath === undefined) {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
const relative = path_1.default.relative(args.content, filePath);
|
|
42
|
+
return relative === '' || !ig.ignores(relative);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.FlowrAnalyzerGitignoreProjectDiscoveryPlugin = FlowrAnalyzerGitignoreProjectDiscoveryPlugin;
|
|
47
|
+
//# sourceMappingURL=flowr-analyzer-gitignore-project-discovery-plugin.js.map
|
|
@@ -25,7 +25,7 @@ class FlowrAnalyzerProjectDiscoveryPlugin extends flowr_analyzer_plugin_1.FlowrA
|
|
|
25
25
|
}
|
|
26
26
|
exports.FlowrAnalyzerProjectDiscoveryPlugin = FlowrAnalyzerProjectDiscoveryPlugin;
|
|
27
27
|
const discoverRSourcesRegex = /\.(r|rmd|ipynb|qmd|rnw)$/i;
|
|
28
|
-
const ignorePathsWith = /(\.git|\.svn|\.hg|renv|packrat|node_modules|__pycache__|\.Rproj\.user)/i;
|
|
28
|
+
const ignorePathsWith = /(\.git|\.svn|\.hg|rv|renv|packrat|node_modules|__pycache__|\.Rproj\.user)/i;
|
|
29
29
|
const excludeRequestsForPaths = /vignettes?|tests?|revdep|inst|data/i;
|
|
30
30
|
/**
|
|
31
31
|
* This is the default dummy implementation of the {@link FlowrAnalyzerProjectDiscoveryPlugin}.
|
|
@@ -12,6 +12,8 @@ const cfg_kind_1 = require("../../../project/cfg-kind");
|
|
|
12
12
|
const extract_cfg_1 = require("../../../control-flow/extract-cfg");
|
|
13
13
|
const identify_link_to_relation_1 = require("./identify-link-to-relation");
|
|
14
14
|
const identifier_1 = require("../../../dataflow/environments/identifier");
|
|
15
|
+
const dfg_get_origin_1 = require("../../../dataflow/origin/dfg-get-origin");
|
|
16
|
+
const queue_1 = require("../../../util/collections/queue");
|
|
15
17
|
/* if the node is effected by nse, we have an ingoing nse edge */
|
|
16
18
|
function isQuoted(node, graph) {
|
|
17
19
|
const vertex = graph.ingoingEdges(node);
|
|
@@ -65,14 +67,23 @@ function promoteCallName(callName, exact = false) {
|
|
|
65
67
|
return (t) => r.test(t);
|
|
66
68
|
}
|
|
67
69
|
}
|
|
70
|
+
/** string arrays always match exactly, plain strings only if the query requests an exact match */
|
|
71
|
+
function exactNamesOf(callName, exact) {
|
|
72
|
+
if (Array.isArray(callName)) {
|
|
73
|
+
return callName;
|
|
74
|
+
}
|
|
75
|
+
return exact && typeof callName === 'string' ? [callName] : undefined;
|
|
76
|
+
}
|
|
68
77
|
function promoteQueryCallNames(queries) {
|
|
69
78
|
let requiresCfg = false;
|
|
70
|
-
const promotedQueries = queries.map(q => {
|
|
79
|
+
const promotedQueries = queries.map((q, idx) => {
|
|
71
80
|
if (isSubCallQuery(q)) {
|
|
72
81
|
requiresCfg = true;
|
|
73
82
|
return {
|
|
74
83
|
...q,
|
|
75
84
|
callName: promoteCallName(q.callName, q.callNameExact),
|
|
85
|
+
exactNames: exactNamesOf(q.callName, q.callNameExact),
|
|
86
|
+
idx,
|
|
76
87
|
fileFilter: q.fileFilter && {
|
|
77
88
|
...q.fileFilter,
|
|
78
89
|
filter: promoteCallName(q.fileFilter.filter)
|
|
@@ -91,6 +102,8 @@ function promoteQueryCallNames(queries) {
|
|
|
91
102
|
return {
|
|
92
103
|
...q,
|
|
93
104
|
callName: promoteCallName(q.callName, q.callNameExact),
|
|
105
|
+
exactNames: exactNamesOf(q.callName, q.callNameExact),
|
|
106
|
+
idx,
|
|
94
107
|
fileFilter: q.fileFilter && {
|
|
95
108
|
...q.fileFilter,
|
|
96
109
|
filter: promoteCallName(q.fileFilter.filter)
|
|
@@ -105,10 +118,10 @@ function retrieveAllCallAliases(nodeId, graph) {
|
|
|
105
118
|
/* we want the names of all functions called at the source id, including synonyms and returns */
|
|
106
119
|
const aliases = new Map();
|
|
107
120
|
const visited = new Set();
|
|
108
|
-
/* we store the current call name */
|
|
109
|
-
const queue = [[(0, node_id_1.recoverContent)(nodeId, graph) ?? '', nodeId]];
|
|
110
|
-
while (queue.
|
|
111
|
-
const [str, id] = queue.
|
|
121
|
+
/* we store the current call name alongside each id */
|
|
122
|
+
const queue = new queue_1.ArrayQueue([[(0, node_id_1.recoverContent)(nodeId, graph) ?? '', nodeId]]);
|
|
123
|
+
while (!queue.isEmpty()) {
|
|
124
|
+
const [str, id] = queue.dequeue();
|
|
112
125
|
if (visited.has(id)) {
|
|
113
126
|
continue;
|
|
114
127
|
}
|
|
@@ -134,7 +147,9 @@ function retrieveAllCallAliases(nodeId, graph) {
|
|
|
134
147
|
.map(([t]) => [(0, node_id_1.recoverContent)(t, graph) ?? '', t])
|
|
135
148
|
.toArray();
|
|
136
149
|
/** only follow defined-by and reads */
|
|
137
|
-
|
|
150
|
+
for (const e of x) {
|
|
151
|
+
queue.enqueue(e);
|
|
152
|
+
}
|
|
138
153
|
continue;
|
|
139
154
|
}
|
|
140
155
|
let track = edge_1.EdgeType.Calls | edge_1.EdgeType.Reads | edge_1.EdgeType.DefinedBy | edge_1.EdgeType.DefinedByOnCall;
|
|
@@ -145,7 +160,7 @@ function retrieveAllCallAliases(nodeId, graph) {
|
|
|
145
160
|
.filter(([, e]) => edge_1.DfEdge.includesType(e, track) && (nodeId !== id || edge_1.DfEdge.doesNotIncludeType(e, edge_1.EdgeType.Argument)))
|
|
146
161
|
.map(([t]) => t);
|
|
147
162
|
for (const call of out) {
|
|
148
|
-
queue.
|
|
163
|
+
queue.enqueue([(0, node_id_1.recoverContent)(call, graph) ?? (0, node_id_1.recoverContent)(id, graph) ?? '', call]);
|
|
149
164
|
}
|
|
150
165
|
}
|
|
151
166
|
return aliases;
|
|
@@ -210,6 +225,28 @@ async function executeCallContextQueries({ analyzer }, queries) {
|
|
|
210
225
|
}
|
|
211
226
|
const calls = cfg ? (0, extract_cfg_1.getCallsInCfg)(cfg, dataflow.graph) : undefined;
|
|
212
227
|
const queriesWhichWantAliases = promotedQueries.filter(q => q.includeAliases);
|
|
228
|
+
/* index exact-name queries so each vertex costs one map lookup instead of a predicate check per query */
|
|
229
|
+
const nonAliasByName = new Map();
|
|
230
|
+
const nonAliasPatterns = [];
|
|
231
|
+
for (const query of promotedQueries) {
|
|
232
|
+
if (query.includeAliases) {
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
if (query.exactNames) {
|
|
236
|
+
for (const name of query.exactNames) {
|
|
237
|
+
const present = nonAliasByName.get(name);
|
|
238
|
+
if (present) {
|
|
239
|
+
present.push(query);
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
nonAliasByName.set(name, [query]);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
nonAliasPatterns.push(query);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
213
250
|
for (const [nodeId, info] of dataflow.graph.verticesOfType(vertex_1.VertexType.FunctionCall)) {
|
|
214
251
|
/* if we have a vertex, and we check for aliased calls, we want to know if we define this as desired! */
|
|
215
252
|
if (queriesWhichWantAliases.length > 0) {
|
|
@@ -228,7 +265,17 @@ async function executeCallContextQueries({ analyzer }, queries) {
|
|
|
228
265
|
}
|
|
229
266
|
}
|
|
230
267
|
const n = identifier_1.Identifier.getName(info.name);
|
|
231
|
-
|
|
268
|
+
const byName = nonAliasByName.get(n) ?? [];
|
|
269
|
+
let matching;
|
|
270
|
+
if (nonAliasPatterns.length === 0) {
|
|
271
|
+
matching = byName;
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
const patternMatches = nonAliasPatterns.filter(q => q.callName(n));
|
|
275
|
+
matching = byName.length === 0 ? patternMatches
|
|
276
|
+
: [...byName, ...patternMatches].sort((a, b) => a.idx - b.idx);
|
|
277
|
+
}
|
|
278
|
+
for (const query of matching) {
|
|
232
279
|
const file = ast.idMap.get(nodeId)?.info.file;
|
|
233
280
|
if (!doesFilepathMatch(file, query.fileFilter)) {
|
|
234
281
|
continue;
|
|
@@ -240,6 +287,13 @@ async function executeCallContextQueries({ analyzer }, queries) {
|
|
|
240
287
|
continue;
|
|
241
288
|
}
|
|
242
289
|
}
|
|
290
|
+
if (query.callTargetNamespace !== undefined) {
|
|
291
|
+
// the resolved package (a loaded-library export) or the call's explicit namespace
|
|
292
|
+
const pkg = identifier_1.Identifier.getNamespace(identifier_1.Identifier.toQualified((0, dfg_get_origin_1.getOriginInDfg)(dataflow.graph, nodeId)) ?? info.name);
|
|
293
|
+
if (pkg !== query.callTargetNamespace) {
|
|
294
|
+
continue;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
243
297
|
if (isQuoted(nodeId, dataflow.graph)) {
|
|
244
298
|
/* if the call is quoted, we do not want to link to it */
|
|
245
299
|
continue;
|