@eagleoutice/flowr 2.6.2 → 2.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -34
- package/abstract-interpretation/data-frame/absint-visitor.js +3 -3
- package/abstract-interpretation/data-frame/mappers/function-mapper.d.ts +7 -7
- package/abstract-interpretation/data-frame/mappers/function-mapper.js +20 -16
- package/abstract-interpretation/data-frame/semantics.js +8 -0
- package/abstract-interpretation/data-frame/shape-inference.d.ts +3 -3
- package/abstract-interpretation/data-frame/shape-inference.js +3 -3
- package/abstract-interpretation/normalized-ast-fold.d.ts +1 -1
- package/benchmark/slicer.d.ts +1 -0
- package/benchmark/slicer.js +13 -12
- package/benchmark/summarizer/first-phase/process.js +1 -1
- package/benchmark/summarizer/second-phase/graph.d.ts +3 -1
- package/benchmark/summarizer/second-phase/graph.js +3 -1
- package/cli/export-quads-app.js +1 -1
- package/cli/repl/commands/repl-dataflow.js +2 -1
- package/cli/repl/commands/repl-parse.js +16 -4
- package/cli/repl/commands/repl-query.js +1 -1
- package/cli/repl/core.js +16 -13
- package/cli/repl/server/connection.js +2 -1
- package/cli/script-core/statistics-helper-core.js +2 -1
- package/cli/slicer-app.js +3 -4
- package/cli/wiki.d.ts +4 -0
- package/cli/wiki.js +165 -0
- package/config.d.ts +4 -0
- package/config.js +6 -0
- package/control-flow/cfg-dead-code.js +13 -3
- package/control-flow/cfg-simplification.d.ts +5 -2
- package/control-flow/cfg-simplification.js +3 -0
- package/control-flow/extract-cfg.d.ts +9 -3
- package/control-flow/extract-cfg.js +44 -4
- package/control-flow/semantic-cfg-guided-visitor.d.ts +2 -2
- package/control-flow/simple-visitor.js +2 -2
- package/control-flow/useless-loop.d.ts +3 -3
- package/control-flow/useless-loop.js +14 -5
- package/core/pipeline-executor.d.ts +3 -6
- package/core/pipeline-executor.js +4 -7
- package/core/print/normalize-printer.d.ts +1 -1
- package/core/print/normalize-printer.js +2 -2
- package/core/steps/all/core/00-parse.d.ts +1 -1
- package/core/steps/all/core/00-parse.js +1 -1
- package/core/steps/all/core/10-normalize.d.ts +3 -9
- package/core/steps/all/core/10-normalize.js +1 -16
- package/core/steps/all/core/11-normalize-tree-sitter.d.ts +2 -3
- package/core/steps/all/core/11-normalize-tree-sitter.js +2 -3
- package/core/steps/all/core/20-dataflow.d.ts +3 -4
- package/core/steps/all/core/20-dataflow.js +2 -2
- package/core/steps/all/static-slicing/00-slice.d.ts +1 -2
- package/core/steps/all/static-slicing/00-slice.js +1 -1
- package/core/steps/all/static-slicing/10-reconstruct.d.ts +8 -0
- package/core/steps/all/static-slicing/10-reconstruct.js +4 -1
- package/core/steps/pipeline/default-pipelines.d.ts +55 -56
- package/core/steps/pipeline/default-pipelines.js +8 -8
- package/dataflow/environments/clone.d.ts +0 -1
- package/dataflow/environments/clone.js +12 -2
- package/dataflow/environments/diff.js +2 -2
- package/dataflow/environments/overwrite.d.ts +1 -5
- package/dataflow/environments/overwrite.js +3 -19
- package/dataflow/environments/scoping.d.ts +6 -2
- package/dataflow/environments/scoping.js +6 -2
- package/dataflow/eval/resolve/resolve-argument.js +2 -2
- package/dataflow/eval/values/string/string-constants.d.ts +9 -3
- package/dataflow/eval/values/string/string-constants.js +9 -3
- package/dataflow/extractor.d.ts +2 -3
- package/dataflow/extractor.js +25 -22
- package/dataflow/graph/graph.d.ts +3 -9
- package/dataflow/graph/graph.js +0 -13
- package/dataflow/graph/unknown-replacement.d.ts +4 -2
- package/dataflow/graph/unknown-replacement.js +4 -2
- package/dataflow/info.d.ts +7 -0
- package/dataflow/info.js +21 -0
- package/dataflow/internal/linker.js +7 -4
- package/dataflow/internal/process/functions/call/argument/make-argument.d.ts +2 -2
- package/dataflow/internal/process/functions/call/argument/make-argument.js +2 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-access.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +4 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +4 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +6 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-list.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.d.ts +6 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +6 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +15 -10
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +78 -75
- package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.d.ts +3 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.js +3 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-vector.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +1 -1
- package/dataflow/internal/process/functions/call/common.d.ts +1 -1
- package/dataflow/internal/process/functions/call/common.js +4 -4
- package/dataflow/internal/process/functions/call/default-call-handling.d.ts +3 -1
- package/dataflow/internal/process/functions/call/default-call-handling.js +3 -1
- package/dataflow/internal/process/functions/call/known-call-handling.js +3 -3
- package/dataflow/internal/process/functions/call/named-call-handling.js +4 -4
- package/dataflow/internal/process/functions/process-parameter.js +4 -4
- package/dataflow/origin/dfg-get-symbol-refs.d.ts +1 -1
- package/dataflow/origin/dfg-get-symbol-refs.js +1 -1
- package/dataflow/processor.d.ts +6 -11
- package/documentation/data/dfg/doc-data-dfg-util.d.ts +0 -2
- package/documentation/data/faq/faqs.js +27 -18
- package/documentation/data/faq/recommended-configs.d.ts +36 -0
- package/documentation/data/faq/recommended-configs.js +40 -0
- package/documentation/data/faq/wiki-faq-store.d.ts +1 -0
- package/documentation/data/faq/wiki-faq-store.js +10 -2
- package/documentation/data/server/doc-data-server-messages.js +1 -1
- package/documentation/doc-capabilities.d.ts +9 -0
- package/documentation/{print-capabilities-markdown.js → doc-capabilities.js} +18 -21
- package/documentation/doc-readme.d.ts +9 -0
- package/documentation/{print-readme.js → doc-readme.js} +31 -35
- package/documentation/doc-util/doc-benchmarks.d.ts +6 -4
- package/documentation/doc-util/doc-benchmarks.js +6 -4
- package/documentation/doc-util/doc-cfg.js +5 -8
- package/documentation/doc-util/doc-dfg.d.ts +7 -7
- package/documentation/doc-util/doc-dfg.js +13 -13
- package/documentation/doc-util/doc-escape.d.ts +6 -0
- package/documentation/doc-util/doc-escape.js +11 -0
- package/documentation/doc-util/doc-general.d.ts +22 -2
- package/documentation/doc-util/doc-general.js +22 -2
- package/documentation/doc-util/doc-normalized-ast.d.ts +10 -5
- package/documentation/doc-util/doc-normalized-ast.js +12 -9
- package/documentation/doc-util/doc-query.d.ts +12 -4
- package/documentation/doc-util/doc-query.js +18 -11
- package/documentation/doc-util/doc-search.d.ts +0 -30
- package/documentation/doc-util/doc-search.js +2 -73
- package/documentation/doc-util/doc-server-message.d.ts +5 -5
- package/documentation/doc-util/doc-server-message.js +4 -4
- package/documentation/doc-util/doc-types.d.ts +69 -32
- package/documentation/doc-util/doc-types.js +108 -61
- package/documentation/index.d.ts +9 -9
- package/documentation/index.js +9 -9
- package/documentation/issue-linting-rule.d.ts +9 -0
- package/documentation/{print-linter-issue.js → issue-linting-rule.js} +20 -23
- package/documentation/wiki-analyzer.d.ts +9 -0
- package/documentation/wiki-analyzer.js +412 -0
- package/documentation/wiki-cfg.d.ts +9 -0
- package/documentation/{print-cfg-wiki.js → wiki-cfg.js} +144 -160
- package/documentation/wiki-core.d.ts +14 -0
- package/documentation/{print-core-wiki.js → wiki-core.js} +164 -175
- package/documentation/wiki-dataflow-graph.d.ts +9 -0
- package/documentation/{print-dataflow-graph-wiki.js → wiki-dataflow-graph.js} +142 -172
- package/documentation/wiki-engine.d.ts +9 -0
- package/documentation/{print-engines-wiki.js → wiki-engine.js} +27 -42
- package/documentation/wiki-faq.d.ts +8 -0
- package/documentation/wiki-faq.js +22 -0
- package/documentation/wiki-interface.d.ts +9 -0
- package/documentation/{print-interface-wiki.js → wiki-interface.js} +59 -56
- package/documentation/wiki-linter.d.ts +9 -0
- package/documentation/{print-linter-wiki.js → wiki-linter.js} +52 -48
- package/documentation/wiki-linting-and-testing.d.ts +9 -0
- package/documentation/{print-linting-and-testing-wiki.js → wiki-linting-and-testing.js} +25 -32
- package/documentation/wiki-mk/doc-context.d.ts +186 -0
- package/documentation/wiki-mk/doc-context.js +84 -0
- package/documentation/wiki-mk/doc-maker.d.ts +95 -0
- package/documentation/wiki-mk/doc-maker.js +133 -0
- package/documentation/wiki-normalized-ast.d.ts +9 -0
- package/documentation/{print-normalized-ast-wiki.js → wiki-normalized-ast.js} +64 -47
- package/documentation/wiki-onboarding.d.ts +8 -0
- package/documentation/{print-onboarding-wiki.js → wiki-onboarding.js} +18 -15
- package/documentation/wiki-query.d.ts +9 -0
- package/documentation/{print-query-wiki.js → wiki-query.js} +62 -47
- package/documentation/wiki-search.d.ts +9 -0
- package/documentation/wiki-search.js +61 -0
- package/linter/linter-executor.js +3 -2
- package/linter/linter-format.d.ts +2 -2
- package/linter/linter-rules.d.ts +13 -17
- package/linter/rules/absolute-path.d.ts +1 -2
- package/linter/rules/absolute-path.js +2 -2
- package/linter/rules/dataframe-access-validation.d.ts +1 -1
- package/linter/rules/dataframe-access-validation.js +12 -8
- package/linter/rules/dead-code.d.ts +1 -1
- package/linter/rules/deprecated-functions.d.ts +1 -5
- package/linter/rules/file-path-validity.d.ts +1 -1
- package/linter/rules/file-path-validity.js +4 -4
- package/linter/rules/function-finder-util.d.ts +1 -5
- package/linter/rules/naming-convention.d.ts +2 -2
- package/linter/rules/naming-convention.js +1 -1
- package/linter/rules/network-functions.d.ts +1 -1
- package/linter/rules/network-functions.js +1 -1
- package/linter/rules/seeded-randomness.d.ts +3 -2
- package/linter/rules/seeded-randomness.js +33 -13
- package/linter/rules/unused-definition.d.ts +1 -1
- package/linter/rules/useless-loop.d.ts +2 -2
- package/linter/rules/useless-loop.js +2 -2
- package/package.json +6 -17
- package/project/cache/flowr-analyzer-cache.d.ts +7 -10
- package/project/cache/flowr-analyzer-cache.js +17 -38
- package/project/cache/flowr-analyzer-controlflow-cache.d.ts +34 -0
- package/project/cache/flowr-analyzer-controlflow-cache.js +79 -0
- package/project/context/flowr-analyzer-context.d.ts +30 -5
- package/project/context/flowr-analyzer-context.js +48 -4
- package/project/context/flowr-analyzer-files-context.d.ts +63 -13
- package/project/context/flowr-analyzer-files-context.js +110 -39
- package/project/context/flowr-file.d.ts +32 -10
- package/project/context/flowr-file.js +30 -9
- package/project/flowr-analyzer-builder.d.ts +22 -28
- package/project/flowr-analyzer-builder.js +32 -70
- package/project/flowr-analyzer.d.ts +55 -14
- package/project/flowr-analyzer.js +53 -8
- package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.d.ts +7 -1
- package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.js +13 -5
- package/project/plugins/file-plugins/flowr-analyzer-file-plugin.d.ts +3 -3
- package/project/plugins/file-plugins/flowr-analyzer-file-plugin.js +11 -5
- package/project/plugins/file-plugins/flowr-description-file.d.ts +3 -3
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-jupyter-file-plugin.d.ts +22 -0
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-jupyter-file-plugin.js +33 -0
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.d.ts +22 -0
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.js +33 -0
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.d.ts +22 -0
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.js +33 -0
- package/project/plugins/file-plugins/notebooks/flowr-jupyter-file.d.ts +20 -0
- package/project/plugins/file-plugins/notebooks/flowr-jupyter-file.js +42 -0
- package/project/plugins/file-plugins/notebooks/flowr-rmarkdown-file.d.ts +59 -0
- package/project/plugins/file-plugins/notebooks/flowr-rmarkdown-file.js +132 -0
- package/project/plugins/file-plugins/notebooks/notebook.d.ts +0 -0
- package/project/plugins/file-plugins/notebooks/notebook.js +2 -0
- package/project/plugins/flowr-analyzer-plugin-defaults.d.ts +5 -0
- package/project/plugins/flowr-analyzer-plugin-defaults.js +23 -0
- package/project/plugins/flowr-analyzer-plugin.d.ts +2 -0
- package/project/plugins/flowr-analyzer-plugin.js +2 -0
- package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-description-file-plugin.js +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.js +1 -1
- package/project/plugins/plugin-registry.d.ts +34 -0
- package/project/plugins/plugin-registry.js +62 -0
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +7 -1
- package/queries/catalog/call-context-query/call-context-query-executor.js +4 -2
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.d.ts +5 -2
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +25 -18
- package/queries/catalog/cluster-query/cluster-query-format.d.ts +1 -1
- package/queries/catalog/control-flow-query/control-flow-query-format.d.ts +1 -1
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.d.ts +1 -1
- package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +1 -1
- package/queries/catalog/dependencies-query/dependencies-query-executor.d.ts +1 -1
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +1 -1
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +1 -1
- package/queries/catalog/dependencies-query/dependencies-query-format.js +1 -1
- package/queries/catalog/df-shape-query/df-shape-query-executor.js +1 -1
- package/queries/catalog/df-shape-query/df-shape-query-format.d.ts +2 -2
- package/queries/catalog/df-shape-query/df-shape-query-format.js +6 -5
- package/queries/catalog/happens-before-query/happens-before-query-executor.d.ts +2 -1
- package/queries/catalog/happens-before-query/happens-before-query-executor.js +2 -1
- package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +1 -1
- package/queries/catalog/id-map-query/id-map-query-format.d.ts +1 -1
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.d.ts +1 -1
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +1 -1
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +1 -1
- package/queries/catalog/linter-query/linter-query-format.d.ts +1 -1
- package/queries/catalog/linter-query/linter-query-format.js +13 -2
- package/queries/catalog/location-map-query/location-map-query-executor.js +2 -1
- package/queries/catalog/location-map-query/location-map-query-format.d.ts +1 -1
- package/queries/catalog/location-map-query/location-map-query-format.js +1 -1
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +1 -1
- package/queries/catalog/origin-query/origin-query-format.d.ts +1 -1
- package/queries/catalog/project-query/project-query-executor.js +3 -1
- package/queries/catalog/project-query/project-query-format.d.ts +1 -1
- package/queries/catalog/resolve-value-query/resolve-value-query-executor.d.ts +2 -2
- package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +2 -2
- package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +1 -1
- package/queries/catalog/search-query/search-query-format.d.ts +1 -1
- package/queries/catalog/static-slice-query/static-slice-query-executor.js +1 -1
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +1 -1
- package/queries/catalog/static-slice-query/static-slice-query-format.js +13 -1
- package/queries/query.d.ts +26 -18
- package/queries/query.js +21 -1
- package/r-bridge/lang-4.x/ast/model/collect.d.ts +2 -1
- package/r-bridge/lang-4.x/ast/model/collect.js +4 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-project.d.ts +29 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-project.js +15 -0
- package/r-bridge/lang-4.x/ast/model/processing/decorate.d.ts +5 -7
- package/r-bridge/lang-4.x/ast/model/processing/decorate.js +24 -11
- package/r-bridge/lang-4.x/ast/model/type.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/type.js +2 -0
- package/r-bridge/lang-4.x/ast/parser/json/format.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/json/parser.d.ts +9 -8
- package/r-bridge/lang-4.x/ast/parser/json/parser.js +11 -10
- package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-root.d.ts +4 -3
- package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-root.js +20 -11
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.d.ts +3 -3
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +5 -4
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.d.ts +3 -2
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +14 -5
- package/r-bridge/parser.d.ts +15 -5
- package/r-bridge/parser.js +27 -13
- package/r-bridge/retriever.d.ts +9 -15
- package/r-bridge/retriever.js +14 -5
- package/r-bridge/shell.d.ts +1 -1
- package/r-bridge/shell.js +1 -1
- package/reconstruct/auto-select/auto-select-defaults.d.ts +0 -1
- package/reconstruct/auto-select/magic-comments.js +1 -1
- package/reconstruct/reconstruct.d.ts +17 -9
- package/reconstruct/reconstruct.js +19 -8
- package/search/flowr-search.d.ts +12 -0
- package/search/search-executor/search-enrichers.d.ts +9 -2
- package/search/search-executor/search-enrichers.js +1 -3
- package/search/search-executor/search-generators.d.ts +1 -1
- package/search/search-executor/search-generators.js +9 -4
- package/slicing/criterion/collect-all.d.ts +3 -2
- package/slicing/criterion/collect-all.js +1 -1
- package/slicing/criterion/parse.js +4 -4
- package/statistics/features/supported/assignments/assignments.js +1 -1
- package/statistics/features/supported/control-flow/control-flow.js +1 -1
- package/statistics/features/supported/data-access/data-access.js +1 -1
- package/statistics/features/supported/defined-functions/defined-functions.js +1 -1
- package/statistics/features/supported/expression-list/statistics-expression-list.js +1 -1
- package/statistics/features/supported/loops/loops.js +1 -1
- package/statistics/features/supported/used-functions/used-functions.js +1 -1
- package/statistics/features/supported/variables/variables.js +1 -1
- package/statistics/statistics.js +3 -2
- package/util/assert.d.ts +4 -0
- package/util/assert.js +4 -0
- package/util/files.d.ts +1 -1
- package/util/files.js +1 -1
- package/util/mermaid/ast.d.ts +4 -3
- package/util/mermaid/ast.js +36 -8
- package/util/mermaid/cfg.js +1 -1
- package/util/version.js +1 -1
- package/documentation/print-analyzer-wiki.d.ts +0 -1
- package/documentation/print-analyzer-wiki.js +0 -141
- package/documentation/print-capabilities-markdown.d.ts +0 -1
- package/documentation/print-cfg-wiki.d.ts +0 -1
- package/documentation/print-core-wiki.d.ts +0 -5
- package/documentation/print-dataflow-graph-wiki.d.ts +0 -1
- package/documentation/print-engines-wiki.d.ts +0 -1
- package/documentation/print-faq-wiki.d.ts +0 -1
- package/documentation/print-faq-wiki.js +0 -18
- package/documentation/print-interface-wiki.d.ts +0 -1
- package/documentation/print-linter-issue.d.ts +0 -1
- package/documentation/print-linter-wiki.d.ts +0 -1
- package/documentation/print-linting-and-testing-wiki.d.ts +0 -1
- package/documentation/print-normalized-ast-wiki.d.ts +0 -1
- package/documentation/print-onboarding-wiki.d.ts +0 -1
- package/documentation/print-query-wiki.d.ts +0 -1
- package/documentation/print-readme.d.ts +0 -1
- package/documentation/print-search-wiki.d.ts +0 -1
- package/documentation/print-search-wiki.js +0 -74
- package/util/formats/adapter-format.d.ts +0 -6
- package/util/formats/adapter-format.js +0 -3
- package/util/formats/adapter.d.ts +0 -27
- package/util/formats/adapter.js +0 -58
- package/util/formats/adapters/r-adapter.d.ts +0 -4
- package/util/formats/adapters/r-adapter.js +0 -7
- package/util/formats/adapters/rmd-adapter.d.ts +0 -35
- package/util/formats/adapters/rmd-adapter.js +0 -100
|
@@ -3,7 +3,7 @@ import type { Query, QueryCapture } from 'web-tree-sitter';
|
|
|
3
3
|
import type { RParseRequest } from '../../retriever';
|
|
4
4
|
import type { SyncParser, TreeSitterInformation } from '../../parser';
|
|
5
5
|
import type { TreeSitterEngineConfig } from '../../../config';
|
|
6
|
-
import type {
|
|
6
|
+
import type { ReadonlyFlowrAnalysisProvider } from '../../../project/flowr-analyzer';
|
|
7
7
|
export declare const DEFAULT_TREE_SITTER_R_WASM_PATH = "./node_modules/@eagleoutice/tree-sitter-r/tree-sitter-r.wasm";
|
|
8
8
|
export declare const DEFAULT_TREE_SITTER_WASM_PATH = "./node_modules/web-tree-sitter/tree-sitter.wasm";
|
|
9
9
|
/**
|
|
@@ -22,10 +22,10 @@ export declare class TreeSitterExecutor implements SyncParser<Parser.Tree> {
|
|
|
22
22
|
static initTreeSitter(config?: TreeSitterEngineConfig, overrideWasmPath?: string, overrideTreeSitterWasmPath?: string): Promise<void>;
|
|
23
23
|
constructor();
|
|
24
24
|
rVersion(): Promise<string | 'unknown' | 'none'>;
|
|
25
|
-
information(analyzer:
|
|
25
|
+
information(analyzer: ReadonlyFlowrAnalysisProvider): TreeSitterInformation;
|
|
26
26
|
treeSitterVersion(): number;
|
|
27
27
|
parse(request: RParseRequest): Parser.Tree;
|
|
28
28
|
createQuery(source: string): Query;
|
|
29
|
-
query(source: Query | string, tree: Parser.Tree): QueryCapture[];
|
|
29
|
+
query(source: Query | string, ...tree: Parser.Tree[]): QueryCapture[];
|
|
30
30
|
close(): void;
|
|
31
31
|
}
|
|
@@ -53,7 +53,7 @@ class TreeSitterExecutor {
|
|
|
53
53
|
name: 'tree-sitter',
|
|
54
54
|
grammarVersion: this.treeSitterVersion(),
|
|
55
55
|
treeSitterQuery: async (source, force) => {
|
|
56
|
-
return this.query(source, (await analyzer.parse(force)).parsed);
|
|
56
|
+
return this.query(source, ...(await analyzer.parse(force)).files.map(p => p.parsed));
|
|
57
57
|
}
|
|
58
58
|
};
|
|
59
59
|
}
|
|
@@ -73,10 +73,11 @@ class TreeSitterExecutor {
|
|
|
73
73
|
createQuery(source) {
|
|
74
74
|
return this.parser.getLanguage().query(source);
|
|
75
75
|
}
|
|
76
|
-
query(source, tree) {
|
|
76
|
+
query(source, ...tree) {
|
|
77
77
|
const query = typeof source === 'string' ? this.createQuery(source) : source;
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
return tree
|
|
79
|
+
.flatMap(t => query.matches(t.rootNode))
|
|
80
|
+
.flatMap(m => m.captures);
|
|
80
81
|
}
|
|
81
82
|
close() {
|
|
82
83
|
this.parser.delete();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { RExpressionList } from '../ast/model/nodes/r-expression-list';
|
|
2
1
|
import type { Tree } from 'web-tree-sitter';
|
|
2
|
+
import type { RProject } from '../ast/model/nodes/r-project';
|
|
3
|
+
import type { ParseStepOutputSingleFile } from '../../parser';
|
|
3
4
|
export interface TreeSitterInfo {
|
|
4
5
|
treeSitterId: number;
|
|
5
6
|
}
|
|
@@ -7,7 +8,7 @@ export interface TreeSitterInfo {
|
|
|
7
8
|
* @param tree - The tree to normalize
|
|
8
9
|
* @param lax - Whether to use lax parsing (i.e., ignore errors) or strict parsing (i.e., fail on errors)
|
|
9
10
|
*/
|
|
10
|
-
export declare function normalizeTreeSitterTreeToAst(tree: Tree, lax?: boolean):
|
|
11
|
+
export declare function normalizeTreeSitterTreeToAst(tree: ParseStepOutputSingleFile<Tree>[], lax?: boolean): RProject<TreeSitterInfo>;
|
|
11
12
|
/**
|
|
12
13
|
* Globally switch to lax parsing mode for tree-sitter normalization
|
|
13
14
|
* @see {@link makeTreeSitterStrict}
|
|
@@ -24,11 +24,20 @@ function normalizeTreeSitterTreeToAst(tree, lax) {
|
|
|
24
24
|
else {
|
|
25
25
|
makeTreeSitterStrict();
|
|
26
26
|
}
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
const files = tree.map(t => {
|
|
28
|
+
const root = convertTreeNode(t.parsed.rootNode);
|
|
29
|
+
if (root.type !== type_1.RType.ExpressionList) {
|
|
30
|
+
throw new normalizer_data_1.ParseError(`expected root to resolve to an expression list, got a ${root.type}`);
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
filePath: t.filePath,
|
|
34
|
+
root: root
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
return {
|
|
38
|
+
type: type_1.RType.Project,
|
|
39
|
+
files
|
|
40
|
+
};
|
|
32
41
|
}
|
|
33
42
|
function nonErrorChildrenStrict(node) {
|
|
34
43
|
return node.hasError ? [] : node.children;
|
package/r-bridge/parser.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RParseRequestFromText } from './retriever';
|
|
2
2
|
import type { OutputCollectorConfiguration, RShell } from './shell';
|
|
3
3
|
import type { RShellExecutor } from './shell-executor';
|
|
4
4
|
import type { TreeSitterExecutor } from './lang-4.x/tree-sitter/tree-sitter-executor';
|
|
5
5
|
import type { Query, QueryCapture } from 'web-tree-sitter';
|
|
6
6
|
import type { FlowrAnalysisProvider } from '../project/flowr-analyzer';
|
|
7
|
+
import type { FlowrAnalyzerContext } from '../project/context/flowr-analyzer-context';
|
|
7
8
|
interface ParserContent<T> {
|
|
8
9
|
readonly name: string;
|
|
9
10
|
information(analyzer: FlowrAnalysisProvider): BaseParserInformation;
|
|
10
|
-
parse(request:
|
|
11
|
+
parse(request: RParseRequestFromText): T;
|
|
11
12
|
close(): void;
|
|
12
13
|
}
|
|
13
14
|
export interface BaseParserInformation {
|
|
@@ -49,22 +50,31 @@ export type KnownParserName = KnownParser['name'];
|
|
|
49
50
|
export interface ParseRequiredInput<T> {
|
|
50
51
|
/** This is the {@link RShell}, {@link RShellExecutor} or {@link TreeSitterExecutor} connection to be used to obtain the original parses AST of the R code */
|
|
51
52
|
readonly parser: Parser<T>;
|
|
52
|
-
/**
|
|
53
|
-
|
|
53
|
+
/**
|
|
54
|
+
* The context from which to derive the requests from,
|
|
55
|
+
* please either relay on the {@link FlowrAnalyzer}
|
|
56
|
+
* or construct one with {@link contextFromInput}
|
|
57
|
+
*/
|
|
58
|
+
readonly context: FlowrAnalyzerContext;
|
|
54
59
|
}
|
|
55
|
-
export interface
|
|
60
|
+
export interface ParseStepOutputSingleFile<T> {
|
|
56
61
|
/** The parsed AST of the R code as given by the R parse side */
|
|
57
62
|
readonly parsed: T;
|
|
63
|
+
readonly filePath: string | undefined;
|
|
58
64
|
/** Additional meta information about the parse */
|
|
59
65
|
readonly '.parse-meta'?: {
|
|
60
66
|
/** The number of tokens in the AST */
|
|
61
67
|
readonly tokenCount: number;
|
|
62
68
|
};
|
|
63
69
|
}
|
|
70
|
+
export interface ParseStepOutput<T> {
|
|
71
|
+
readonly files: ParseStepOutputSingleFile<T>[];
|
|
72
|
+
}
|
|
64
73
|
/**
|
|
65
74
|
* Takes an input program and parses it using the given parser.
|
|
66
75
|
* @param _results - just a proxy for the pipeline, signifies that this function does not need prior knowledge of the pipeline
|
|
67
76
|
* @param input - the input to the parse step
|
|
77
|
+
* @returns The parsed AST per request in the loading order obtained from the {@link FlowrAnalyzerFilesContext|files context} of the given {@link FlowrAnalyzerContext}.
|
|
68
78
|
*/
|
|
69
79
|
export declare function parseRequests<T extends KnownParserType>(_results: unknown, input: Partial<ParseRequiredInput<T>>): Promise<ParseStepOutput<T>>;
|
|
70
80
|
export {};
|
package/r-bridge/parser.js
CHANGED
|
@@ -12,26 +12,40 @@ function countChildren(node) {
|
|
|
12
12
|
* Takes an input program and parses it using the given parser.
|
|
13
13
|
* @param _results - just a proxy for the pipeline, signifies that this function does not need prior knowledge of the pipeline
|
|
14
14
|
* @param input - the input to the parse step
|
|
15
|
+
* @returns The parsed AST per request in the loading order obtained from the {@link FlowrAnalyzerFilesContext|files context} of the given {@link FlowrAnalyzerContext}.
|
|
15
16
|
*/
|
|
16
17
|
async function parseRequests(_results, input) {
|
|
18
|
+
const loadingOrder = input.context.files.loadingOrder.getLoadingOrder();
|
|
17
19
|
/* in the future, we want to expose all cases */
|
|
18
|
-
const
|
|
20
|
+
const translatedRequests = loadingOrder.map(r => input.context.files.resolveRequest(r));
|
|
19
21
|
if (input.parser?.async) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
/* sadly we cannot Promise.all with the Rshell as it has to process commands in order and is not thread safe */
|
|
23
|
+
const files = [];
|
|
24
|
+
for (const req of translatedRequests) {
|
|
25
|
+
const parsed = await (input.parser).parse(req.r);
|
|
26
|
+
files.push({
|
|
27
|
+
parsed,
|
|
28
|
+
filePath: req.path,
|
|
29
|
+
'.parse-meta': typeof parsed === 'object' && 'rootNode' in parsed ? {
|
|
30
|
+
tokenCount: countChildren(parsed.rootNode),
|
|
31
|
+
} : undefined
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return { files };
|
|
27
35
|
}
|
|
28
36
|
else {
|
|
29
|
-
const
|
|
37
|
+
const p = input.parser;
|
|
30
38
|
return {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
39
|
+
files: translatedRequests.map(r => {
|
|
40
|
+
const parsed = p.parse(r.r);
|
|
41
|
+
return {
|
|
42
|
+
parsed,
|
|
43
|
+
filePath: r.path,
|
|
44
|
+
'.parse-meta': typeof parsed === 'object' && 'rootNode' in parsed ? {
|
|
45
|
+
tokenCount: countChildren(parsed.rootNode),
|
|
46
|
+
} : undefined
|
|
47
|
+
};
|
|
48
|
+
})
|
|
35
49
|
};
|
|
36
50
|
}
|
|
37
51
|
}
|
package/r-bridge/retriever.d.ts
CHANGED
|
@@ -2,24 +2,21 @@ import { type RShell } from './shell';
|
|
|
2
2
|
import type { AsyncOrSync } from 'ts-essentials';
|
|
3
3
|
import { RShellExecutor } from './shell-executor';
|
|
4
4
|
import { type NormalizedAst } from './lang-4.x/ast/model/processing/decorate';
|
|
5
|
-
import type { SupportedFormats } from '../util/formats/adapter-format';
|
|
6
5
|
export declare const fileProtocol = "file://";
|
|
7
|
-
export interface
|
|
8
|
-
type: SupportedFormats;
|
|
9
|
-
}
|
|
10
|
-
export interface RParseRequestFromFile<AdditionalInfo extends ParseRequestAdditionalInfoBase = ParseRequestAdditionalInfoBase> {
|
|
6
|
+
export interface RParseRequestFromFile {
|
|
11
7
|
readonly request: 'file';
|
|
12
8
|
/**
|
|
13
|
-
* The path to the file
|
|
9
|
+
* The path to the file represented in the {@link FlowrAnalyzerFilesContext}.
|
|
14
10
|
* See {@link RParseRequests} for multiple files.
|
|
15
11
|
*/
|
|
16
12
|
readonly content: string;
|
|
17
|
-
/**
|
|
18
|
-
* Additional info from different file formates like .Rmd
|
|
19
|
-
*/
|
|
20
|
-
readonly info?: AdditionalInfo;
|
|
21
13
|
}
|
|
22
|
-
|
|
14
|
+
/**
|
|
15
|
+
* A request to parse R code given as text.
|
|
16
|
+
* This option is mostly useful for quick tests or injects, as usually files are controlled by the {@link RParseRequestFromFile} request
|
|
17
|
+
* referring to a file in the {@link FlowrAnalyzerFilesContext}.
|
|
18
|
+
*/
|
|
19
|
+
export interface RParseRequestFromText {
|
|
23
20
|
readonly request: 'text';
|
|
24
21
|
/**
|
|
25
22
|
* Source code to parse (not a file path).
|
|
@@ -28,10 +25,6 @@ export interface RParseRequestFromText<AdditionalInfo extends ParseRequestAdditi
|
|
|
28
25
|
* or concatenate their contents to pass them with this request.
|
|
29
26
|
*/
|
|
30
27
|
readonly content: string;
|
|
31
|
-
/**
|
|
32
|
-
* Additional info from different file formates like .Rmd
|
|
33
|
-
*/
|
|
34
|
-
readonly info?: AdditionalInfo;
|
|
35
28
|
}
|
|
36
29
|
/**
|
|
37
30
|
* A provider for an {@link RParseRequests} that can be used, for example, to override source file parsing behavior in tests
|
|
@@ -77,6 +70,7 @@ export declare function retrieveParseDataFromRCode(request: RParseRequest, shell
|
|
|
77
70
|
/**
|
|
78
71
|
* Uses {@link retrieveParseDataFromRCode} and returns the nicely formatted object-AST.
|
|
79
72
|
* If successful, allows further querying the last result with {@link retrieveNumberOfRTokensOfLastParse}.
|
|
73
|
+
* This function is outdated and should only be used for legacy reasons. Please use the {@link FlowrAnalyzer} instead.
|
|
80
74
|
*/
|
|
81
75
|
export declare function retrieveNormalizedAstFromRCode(request: RParseRequest, shell: RShell): Promise<NormalizedAst>;
|
|
82
76
|
/**
|
package/r-bridge/retriever.js
CHANGED
|
@@ -23,7 +23,6 @@ const decorate_1 = require("./lang-4.x/ast/model/processing/decorate");
|
|
|
23
23
|
const type_1 = require("./lang-4.x/ast/model/type");
|
|
24
24
|
const fs_1 = __importDefault(require("fs"));
|
|
25
25
|
const path_1 = __importDefault(require("path"));
|
|
26
|
-
const adapter_1 = require("../util/formats/adapter");
|
|
27
26
|
exports.fileProtocol = 'file://';
|
|
28
27
|
/**
|
|
29
28
|
* Type guard for {@link RParseRequest}
|
|
@@ -39,18 +38,25 @@ function isParseRequest(request) {
|
|
|
39
38
|
* If your input starts with {@link fileProtocol}, it is assumed to be a file path and will be processed as such.
|
|
40
39
|
* Giving an array, you can mix file paths and text content (again using the {@link fileProtocol}).
|
|
41
40
|
*
|
|
41
|
+
* To obtain a {@link FlowrAnalyzerContext} from such an input, use {@link contextFromInput}.
|
|
42
42
|
*/
|
|
43
|
-
function requestFromInput(input
|
|
43
|
+
function requestFromInput(input) {
|
|
44
44
|
if (Array.isArray(input)) {
|
|
45
45
|
return input.flatMap(requestFromInput);
|
|
46
46
|
}
|
|
47
47
|
const content = input;
|
|
48
48
|
const file = content.startsWith(exports.fileProtocol);
|
|
49
49
|
if (file) {
|
|
50
|
-
return
|
|
50
|
+
return {
|
|
51
|
+
request: 'file',
|
|
52
|
+
content: content.substring(exports.fileProtocol.length),
|
|
53
|
+
};
|
|
51
54
|
}
|
|
52
55
|
else {
|
|
53
|
-
return
|
|
56
|
+
return {
|
|
57
|
+
request: 'text',
|
|
58
|
+
content
|
|
59
|
+
};
|
|
54
60
|
}
|
|
55
61
|
}
|
|
56
62
|
/**
|
|
@@ -134,10 +140,13 @@ function retrieveParseDataFromRCode(request, shell) {
|
|
|
134
140
|
/**
|
|
135
141
|
* Uses {@link retrieveParseDataFromRCode} and returns the nicely formatted object-AST.
|
|
136
142
|
* If successful, allows further querying the last result with {@link retrieveNumberOfRTokensOfLastParse}.
|
|
143
|
+
* This function is outdated and should only be used for legacy reasons. Please use the {@link FlowrAnalyzer} instead.
|
|
137
144
|
*/
|
|
138
145
|
async function retrieveNormalizedAstFromRCode(request, shell) {
|
|
139
146
|
const data = await retrieveParseDataFromRCode(request, shell);
|
|
140
|
-
return (0, parser_1.normalize)({
|
|
147
|
+
return (0, parser_1.normalize)({
|
|
148
|
+
files: [{ parsed: data, filePath: request.request === 'file' ? request.content : undefined }]
|
|
149
|
+
}, (0, decorate_1.deterministicCountingIdGenerator)(0));
|
|
141
150
|
}
|
|
142
151
|
/**
|
|
143
152
|
* If the string has (R-)quotes around it, they will be removed; otherwise the string is returned unchanged.
|
package/r-bridge/shell.d.ts
CHANGED
|
@@ -70,7 +70,7 @@ export interface RShellOptions extends RShellSessionOptions {
|
|
|
70
70
|
}
|
|
71
71
|
export declare const DEFAULT_R_PATH: string;
|
|
72
72
|
/**
|
|
73
|
-
*
|
|
73
|
+
* Get the default RShell options, possibly using the given config to override some values
|
|
74
74
|
*/
|
|
75
75
|
export declare function getDefaultRShellOptions(config?: RShellEngineConfig): RShellOptions;
|
|
76
76
|
/**
|
package/r-bridge/shell.js
CHANGED
|
@@ -62,7 +62,7 @@ exports.DEFAULT_OUTPUT_COLLECTOR_CONFIGURATION = {
|
|
|
62
62
|
exports.DEFAULT_R_PATH = (0, os_1.getPlatform)() === 'windows' ? 'R.exe' : 'R';
|
|
63
63
|
let DEFAULT_R_SHELL_OPTIONS = undefined;
|
|
64
64
|
/**
|
|
65
|
-
*
|
|
65
|
+
* Get the default RShell options, possibly using the given config to override some values
|
|
66
66
|
*/
|
|
67
67
|
function getDefaultRShellOptions(config) {
|
|
68
68
|
if (!DEFAULT_R_SHELL_OPTIONS) {
|
|
@@ -6,7 +6,6 @@ import type { ParentInformation, NormalizedAst } from '../../r-bridge/lang-4.x/a
|
|
|
6
6
|
* independent of if it is selected by the slice or not.
|
|
7
7
|
* @see reconstructToCode
|
|
8
8
|
* @see doNotAutoSelect
|
|
9
|
-
* @see autoSelectLibrary
|
|
10
9
|
*/
|
|
11
10
|
export type AutoSelectPredicate = (node: RNode<ParentInformation>, fullAst: NormalizedAst) => boolean;
|
|
12
11
|
/**
|
|
@@ -52,7 +52,7 @@ function makeMagicCommentHandler(and) {
|
|
|
52
52
|
if (!lines) {
|
|
53
53
|
lines = new Set();
|
|
54
54
|
const startLineStack = [];
|
|
55
|
-
(0, visitor_1.visitAst)(normalizedAst.ast, n => {
|
|
55
|
+
(0, visitor_1.visitAst)(normalizedAst.ast.files.map(f => f.root), n => {
|
|
56
56
|
const comments = n.info.additionalTokens;
|
|
57
57
|
if (!comments) {
|
|
58
58
|
return;
|
|
@@ -6,19 +6,27 @@
|
|
|
6
6
|
import type { NormalizedAst } from '../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
7
7
|
import type { NodeId } from '../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
8
8
|
import { type AutoSelectPredicate } from './auto-select/auto-select-defaults';
|
|
9
|
-
|
|
9
|
+
interface Selection {
|
|
10
|
+
/**
|
|
11
|
+
* The set of node ids to be reconstructed.
|
|
12
|
+
*/
|
|
13
|
+
nodes: ReadonlySet<NodeId>;
|
|
14
|
+
/**
|
|
15
|
+
* @see {@link ReconstructRequiredInput#reconstructFiles}
|
|
16
|
+
*/
|
|
17
|
+
reconstructFiles?: 'all' | number[];
|
|
18
|
+
}
|
|
10
19
|
export declare const reconstructLogger: import("tslog").Logger<import("tslog").ILogObj>;
|
|
11
20
|
export interface ReconstructionResult {
|
|
12
|
-
code
|
|
21
|
+
/** Returns the reconstructed code as string or array of code reconstructions (corresponding to the desired file indices in the {@link Selection}) */
|
|
22
|
+
code: string | string[];
|
|
13
23
|
/** number of lines that contain nodes that triggered the `autoSelectIf` predicate {@link reconstructToCode} */
|
|
14
24
|
linesWithAutoSelected: number;
|
|
15
25
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
* @returns The number of lines for which `autoSelectIf` triggered, as well as the reconstructed code itself.
|
|
22
|
-
*/
|
|
26
|
+
export declare function reconstructToCode(ast: NormalizedAst, selection: Selection & {
|
|
27
|
+
reconstructFiles?: [number] | undefined;
|
|
28
|
+
}, autoSelectIf?: AutoSelectPredicate): ReconstructionResult & {
|
|
29
|
+
code: string;
|
|
30
|
+
};
|
|
23
31
|
export declare function reconstructToCode(ast: NormalizedAst, selection: Selection, autoSelectIf?: AutoSelectPredicate): ReconstructionResult;
|
|
24
32
|
export {};
|
|
@@ -408,25 +408,25 @@ function getIndentString(indent) {
|
|
|
408
408
|
function prettyPrintCodeToString(code, lf = '\n') {
|
|
409
409
|
return code.map(({ line, indent }) => `${getIndentString(indent)}${line}`).join(lf);
|
|
410
410
|
}
|
|
411
|
-
function removeOuterExpressionListIfApplicable(result
|
|
411
|
+
function removeOuterExpressionListIfApplicable(result) {
|
|
412
412
|
if (result.length > 1 && result[0].line === '{' && result[result.length - 1].line === '}') {
|
|
413
413
|
// remove outer block
|
|
414
|
-
return
|
|
414
|
+
return prettyPrintCodeToString(indentBy(result.slice(1, result.length - 1), -1));
|
|
415
415
|
}
|
|
416
416
|
else {
|
|
417
|
-
return
|
|
417
|
+
return prettyPrintCodeToString(result);
|
|
418
418
|
}
|
|
419
419
|
}
|
|
420
420
|
/**
|
|
421
421
|
* Reconstructs parts of a normalized R ast into R code on an expression basis.
|
|
422
422
|
* @param ast - The {@link NormalizedAst|normalized ast} to be used as a basis for reconstruction
|
|
423
423
|
* @param selection - The selection of nodes to be reconstructed (probably the {@link NodeId|NodeIds} identified by the slicer)
|
|
424
|
-
* @param autoSelectIf - A predicate that can be used to force the reconstruction of a node
|
|
424
|
+
* @param autoSelectIf - A predicate that can be used to force the reconstruction of a node
|
|
425
425
|
* @returns The number of lines for which `autoSelectIf` triggered, as well as the reconstructed code itself.
|
|
426
426
|
*/
|
|
427
427
|
function reconstructToCode(ast, selection, autoSelectIf = auto_select_defaults_1.doNotAutoSelect) {
|
|
428
428
|
if (exports.reconstructLogger.settings.minLevel <= 1 /* LogLevel.Trace */) {
|
|
429
|
-
exports.reconstructLogger.trace(`reconstruct ast with ids: ${JSON.stringify([...selection])}`);
|
|
429
|
+
exports.reconstructLogger.trace(`reconstruct ast with ids: ${JSON.stringify([...selection.nodes])} for files: ${JSON.stringify(selection.reconstructFiles)}`);
|
|
430
430
|
}
|
|
431
431
|
// we use a wrapper to count the number of lines for which the autoSelectIf predicate triggered
|
|
432
432
|
const linesWithAutoSelected = new Set();
|
|
@@ -439,9 +439,20 @@ function reconstructToCode(ast, selection, autoSelectIf = auto_select_defaults_1
|
|
|
439
439
|
}
|
|
440
440
|
return result;
|
|
441
441
|
};
|
|
442
|
+
const indices = selection.reconstructFiles === 'all' ? ast.ast.files.map((_, i) => i) : (selection.reconstructFiles ?? [0]);
|
|
443
|
+
(0, assert_1.guard)(indices.every(i => i >= 0 && i < ast.ast.files.length), `reconstructToCode: reconstructFiles contains invalid file indices: ${JSON.stringify(indices)} for ast with ${ast.ast.files.length} files`);
|
|
444
|
+
const results = [];
|
|
442
445
|
// fold of the normalized ast
|
|
443
|
-
const
|
|
444
|
-
|
|
445
|
-
|
|
446
|
+
for (const i of indices) {
|
|
447
|
+
if (exports.reconstructLogger.settings.minLevel <= 1 /* LogLevel.Trace */) {
|
|
448
|
+
exports.reconstructLogger.trace(`reconstructing file index ${i} with root id ${ast.ast.files[i].root.info.id}`);
|
|
449
|
+
}
|
|
450
|
+
results.push(removeOuterExpressionListIfApplicable((0, stateful_fold_1.foldAstStateful)(ast.ast.files[i].root, { selection: selection.nodes, autoSelectIf: autoSelectIfWrapper, fullAst: ast }, reconstructAstFolds)));
|
|
451
|
+
}
|
|
452
|
+
(0, log_1.expensiveTrace)(exports.reconstructLogger, () => `reconstructed ast before string conversion: ${JSON.stringify(results)}`);
|
|
453
|
+
return {
|
|
454
|
+
code: indices.length === 1 ? results[0] : results,
|
|
455
|
+
linesWithAutoSelected: linesWithAutoSelected.size
|
|
456
|
+
};
|
|
446
457
|
}
|
|
447
458
|
//# sourceMappingURL=reconstruct.js.map
|
package/search/flowr-search.d.ts
CHANGED
|
@@ -41,6 +41,18 @@ export interface FlowrSearchGetFilter extends Record<string, unknown> {
|
|
|
41
41
|
* The node must have the given id.
|
|
42
42
|
*/
|
|
43
43
|
readonly id?: NodeId;
|
|
44
|
+
/**
|
|
45
|
+
* The node must stem form a file with the given path matching the regex
|
|
46
|
+
* Please note that you can address the full path!
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* // matches all files in any 'tests' folder
|
|
50
|
+
* filePath: '.*\\tests\\.*'
|
|
51
|
+
* // matches all files named 'myfile.R' in any folder
|
|
52
|
+
* filePath: '.*\\/myfile\\.R$'
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
readonly filePathRegex?: string;
|
|
44
56
|
}
|
|
45
57
|
/** Intentionally, we abstract away from an array to avoid the use of conventional typescript operations */
|
|
46
58
|
export declare class FlowrSearchElements<Info = NoInfo, Elements extends FlowrSearchElement<Info>[] = FlowrSearchElement<Info>[]> {
|
|
@@ -10,6 +10,7 @@ import { type CfgSimplificationPassName } from '../../control-flow/cfg-simplific
|
|
|
10
10
|
import type { AsyncOrSync } from 'ts-essentials';
|
|
11
11
|
import type { ReadonlyFlowrAnalysisProvider } from '../../project/flowr-analyzer';
|
|
12
12
|
import type { DataflowInformation } from '../../dataflow/info';
|
|
13
|
+
import type { FlowrConfigOptions } from '../../config';
|
|
13
14
|
export interface EnrichmentData<ElementContent extends MergeableRecord, ElementArguments = undefined, SearchContent extends MergeableRecord = never, SearchArguments = ElementArguments> {
|
|
14
15
|
/**
|
|
15
16
|
* A function that is applied to each element of the search to enrich it with additional data.
|
|
@@ -18,6 +19,7 @@ export interface EnrichmentData<ElementContent extends MergeableRecord, ElementA
|
|
|
18
19
|
dataflow: DataflowInformation;
|
|
19
20
|
normalize: NormalizedAst;
|
|
20
21
|
cfg: ControlFlowInformation;
|
|
22
|
+
config: FlowrConfigOptions;
|
|
21
23
|
}, args: ElementArguments | undefined, previousValue: ElementContent | undefined) => AsyncOrSync<ElementContent>;
|
|
22
24
|
readonly enrichSearch?: (search: FlowrSearchElements<ParentInformation>, data: ReadonlyFlowrAnalysisProvider, args: SearchArguments | undefined, previousValue: SearchContent | undefined) => AsyncOrSync<SearchContent>;
|
|
23
25
|
/**
|
|
@@ -98,6 +100,7 @@ export declare const Enrichments: {
|
|
|
98
100
|
dataflow: DataflowInformation;
|
|
99
101
|
normalize: NormalizedAst;
|
|
100
102
|
cfg: ControlFlowInformation;
|
|
103
|
+
config: FlowrConfigOptions;
|
|
101
104
|
}, args: {
|
|
102
105
|
onlyBuiltin?: boolean;
|
|
103
106
|
} | undefined, prev: CallTargetsContent | undefined) => CallTargetsContent;
|
|
@@ -108,6 +111,7 @@ export declare const Enrichments: {
|
|
|
108
111
|
dataflow: DataflowInformation;
|
|
109
112
|
normalize: NormalizedAst;
|
|
110
113
|
cfg: ControlFlowInformation;
|
|
114
|
+
config: FlowrConfigOptions;
|
|
111
115
|
}, args: Omit<LinkToLastCall<import("../../queries/catalog/call-context-query/call-context-query-format").CallNameTypes>, "type">[] | undefined, prev: LastCallContent | undefined) => LastCallContent;
|
|
112
116
|
mapper: ({ linkedIds }: LastCallContent) => FlowrSearchElement<ParentInformation>[];
|
|
113
117
|
};
|
|
@@ -116,19 +120,21 @@ export declare const Enrichments: {
|
|
|
116
120
|
dataflow: DataflowInformation;
|
|
117
121
|
normalize: NormalizedAst;
|
|
118
122
|
cfg: ControlFlowInformation;
|
|
123
|
+
config: FlowrConfigOptions;
|
|
119
124
|
}, _args: CfgInformationArguments | undefined, prev: CfgInformationElementContent | undefined) => {
|
|
120
125
|
isRoot: boolean;
|
|
121
126
|
isReachable: boolean | undefined;
|
|
122
127
|
};
|
|
123
|
-
enrichSearch: (_search: FlowrSearchElements<ParentInformation, FlowrSearchElement<ParentInformation>[]>, data: ReadonlyFlowrAnalysisProvider
|
|
128
|
+
enrichSearch: (_search: FlowrSearchElements<ParentInformation, FlowrSearchElement<ParentInformation>[]>, data: ReadonlyFlowrAnalysisProvider<import("../../r-bridge/parser").KnownParser>, args: CfgInformationArguments | undefined, prev: CfgInformationSearchContent | undefined) => Promise<CfgInformationSearchContent>;
|
|
124
129
|
};
|
|
125
130
|
readonly "query-data": {
|
|
126
131
|
enrichElement: (_e: FlowrSearchElement<ParentInformation>, _search: FlowrSearchElements<ParentInformation, FlowrSearchElement<ParentInformation>[]>, _data: {
|
|
127
132
|
dataflow: DataflowInformation;
|
|
128
133
|
normalize: NormalizedAst;
|
|
129
134
|
cfg: ControlFlowInformation;
|
|
135
|
+
config: FlowrConfigOptions;
|
|
130
136
|
}, args: QueryDataElementContent | undefined, prev: QueryDataElementContent | undefined) => QueryDataElementContent;
|
|
131
|
-
enrichSearch: (_search: FlowrSearchElements<ParentInformation, FlowrSearchElement<ParentInformation>[]>, _data: ReadonlyFlowrAnalysisProvider
|
|
137
|
+
enrichSearch: (_search: FlowrSearchElements<ParentInformation, FlowrSearchElement<ParentInformation>[]>, _data: ReadonlyFlowrAnalysisProvider<import("../../r-bridge/parser").KnownParser>, args: QueryDataSearchContent | undefined, prev: QueryDataSearchContent | undefined) => Required<QueryDataSearchContent>;
|
|
132
138
|
};
|
|
133
139
|
};
|
|
134
140
|
/**
|
|
@@ -145,4 +151,5 @@ export declare function enrichElement<Element extends FlowrSearchElement<ParentI
|
|
|
145
151
|
dataflow: DataflowInformation;
|
|
146
152
|
normalize: NormalizedAst;
|
|
147
153
|
cfg: ControlFlowInformation;
|
|
154
|
+
config: FlowrConfigOptions;
|
|
148
155
|
}, enrichment: E, args?: EnrichmentElementArguments<E>): Promise<Element>;
|
|
@@ -7,7 +7,6 @@ const objects_1 = require("../../util/objects");
|
|
|
7
7
|
const vertex_1 = require("../../dataflow/graph/vertex");
|
|
8
8
|
const identify_link_to_last_call_relation_1 = require("../../queries/catalog/call-context-query/identify-link-to-last-call-relation");
|
|
9
9
|
const assert_1 = require("../../util/assert");
|
|
10
|
-
const extract_cfg_1 = require("../../control-flow/extract-cfg");
|
|
11
10
|
const dfg_get_origin_1 = require("../../dataflow/origin/dfg-get-origin");
|
|
12
11
|
const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
13
12
|
const cfg_simplification_1 = require("../../control-flow/cfg-simplification");
|
|
@@ -76,9 +75,8 @@ exports.Enrichments = {
|
|
|
76
75
|
const content = prev ?? { linkedIds: [] };
|
|
77
76
|
const vertex = data.dataflow.graph.get(e.node.info.id);
|
|
78
77
|
if (vertex !== undefined && vertex[0].tag === vertex_1.VertexType.FunctionCall) {
|
|
79
|
-
const cfg = (0, extract_cfg_1.extractCfgQuick)(data.normalize);
|
|
80
78
|
for (const arg of args) {
|
|
81
|
-
const lastCalls = (0, identify_link_to_last_call_relation_1.identifyLinkToLastCallRelation)(vertex[0].id, cfg.graph, data.dataflow.graph, {
|
|
79
|
+
const lastCalls = (0, identify_link_to_last_call_relation_1.identifyLinkToLastCallRelation)(vertex[0].id, data.cfg.graph, data.dataflow.graph, {
|
|
82
80
|
...arg,
|
|
83
81
|
callName: (0, call_context_query_executor_1.promoteCallName)(arg.callName),
|
|
84
82
|
type: 'link-to-last-call',
|
|
@@ -28,7 +28,7 @@ export declare const generators: {
|
|
|
28
28
|
readonly syntax: typeof generateSyntax;
|
|
29
29
|
};
|
|
30
30
|
declare function generateAll(data: ReadonlyFlowrAnalysisProvider): Promise<FlowrSearchElements<ParentInformation>>;
|
|
31
|
-
declare function generateGet(input: ReadonlyFlowrAnalysisProvider, { filter: { line, column, id, name, nameIsRegex } }: {
|
|
31
|
+
declare function generateGet(input: ReadonlyFlowrAnalysisProvider, { filter: { line, column, id, name, nameIsRegex, filePathRegex } }: {
|
|
32
32
|
filter: FlowrSearchGetFilter;
|
|
33
33
|
}): Promise<FlowrSearchElements<ParentInformation>>;
|
|
34
34
|
declare function generateFrom(_input: ReadonlyFlowrAnalysisProvider, args: {
|
|
@@ -30,13 +30,18 @@ async function getAllNodes(data) {
|
|
|
30
30
|
return [...new Map([...normalize.idMap.values()].map(n => [n.info.id, n]))
|
|
31
31
|
.values()];
|
|
32
32
|
}
|
|
33
|
-
async function generateGet(input, { filter: { line, column, id, name, nameIsRegex } }) {
|
|
33
|
+
async function generateGet(input, { filter: { line, column, id, name, nameIsRegex, filePathRegex } }) {
|
|
34
34
|
const normalize = await input.normalize();
|
|
35
35
|
let potentials = (id ?
|
|
36
36
|
[normalize.idMap.get(id)].filter(assert_1.isNotUndefined) :
|
|
37
37
|
await getAllNodes(input));
|
|
38
|
+
if (filePathRegex) {
|
|
39
|
+
const filePathFilter = new RegExp(filePathRegex);
|
|
40
|
+
potentials = potentials.filter(({ info }) => info.file && filePathFilter.test(info.file));
|
|
41
|
+
}
|
|
38
42
|
if (line && line < 0) {
|
|
39
|
-
|
|
43
|
+
(0, assert_1.guard)(normalize.ast.files.length === 1, 'Currently, negative line numbers are only supported for single-file inputs');
|
|
44
|
+
const maxLines = normalize.ast.files[0].root.info.fullRange?.[2] ??
|
|
40
45
|
(id ? (await getAllNodes(input)) : potentials).reduce((maxLine, { location }) => location && location[2] > maxLine ? location[2] : maxLine, 0);
|
|
41
46
|
line = maxLines + line + 1;
|
|
42
47
|
}
|
|
@@ -85,7 +90,7 @@ async function generateFromQuery(input, args) {
|
|
|
85
90
|
.enrich(input, search_enrichers_1.Enrichment.QueryData, { queries: result });
|
|
86
91
|
return elements.mutate(s => Promise.all(s.map(async (e) => {
|
|
87
92
|
const [query, _] = [...nodesByQuery].find(([_, nodes]) => nodes.has(e));
|
|
88
|
-
return await (0, search_enrichers_1.enrichElement)(e, elements, { normalize, dataflow, cfg }, search_enrichers_1.Enrichment.QueryData, { query });
|
|
93
|
+
return await (0, search_enrichers_1.enrichElement)(e, elements, { normalize, dataflow, cfg, config: input.flowrConfig }, search_enrichers_1.Enrichment.QueryData, { query });
|
|
89
94
|
})));
|
|
90
95
|
}
|
|
91
96
|
async function generateSyntax(input, args) {
|
|
@@ -107,7 +112,7 @@ async function generateSyntax(input, args) {
|
|
|
107
112
|
return new flowr_search_1.FlowrSearchElements([]);
|
|
108
113
|
}
|
|
109
114
|
const nodesByTreeSitterId = new Map();
|
|
110
|
-
(0, visitor_1.visitAst)((await input.normalize()).ast, node => {
|
|
115
|
+
(0, visitor_1.visitAst)((await input.normalize()).ast.files.map(f => f.root), node => {
|
|
111
116
|
const treeSitterInfo = node.info;
|
|
112
117
|
if (treeSitterInfo.treeSitterId) {
|
|
113
118
|
nodesByTreeSitterId.set(treeSitterInfo.treeSitterId, node);
|
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { MergeableRecord } from '../../util/objects';
|
|
7
7
|
import type { SlicingCriteria } from './parse';
|
|
8
|
-
import type { RNodeWithParent } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
8
|
+
import type { ParentInformation, RNodeWithParent } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
9
9
|
import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
10
|
+
import type { RProject } from '../../r-bridge/lang-4.x/ast/model/nodes/r-project';
|
|
10
11
|
/**
|
|
11
12
|
* Defines the filter for collecting all possible slicing criteria.
|
|
12
13
|
* @see DefaultAllVariablesFilter
|
|
@@ -34,4 +35,4 @@ export interface SlicingCriteriaFilter extends MergeableRecord {
|
|
|
34
35
|
* The slicing criteria will be *ordered* (i.e., it will not return `[1:2,3:4]` and `[3:4,1:2]` if `maximumSize` \> 1).
|
|
35
36
|
* If there are not enough matching nodes within the ast, this will return *no* slicing criteria!
|
|
36
37
|
*/
|
|
37
|
-
export declare function collectAllSlicingCriteria<OtherInfo>(ast:
|
|
38
|
+
export declare function collectAllSlicingCriteria<OtherInfo>(ast: RProject<OtherInfo & ParentInformation>, filter: Readonly<SlicingCriteriaFilter>): Generator<SlicingCriteria, void, void>;
|
|
@@ -12,7 +12,7 @@ const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-fun
|
|
|
12
12
|
function* collectAllSlicingCriteria(ast, filter) {
|
|
13
13
|
(0, assert_1.guard)(filter.minimumSize >= 1, `Minimum size must be at least 1, but was ${filter.minimumSize}`);
|
|
14
14
|
(0, assert_1.guard)(filter.maximumSize >= filter.minimumSize, `Maximum size must be at least minimum size, but was ${filter.maximumSize} < ${filter.minimumSize}`);
|
|
15
|
-
const potentialSlicingNodes = filter.collectAll(
|
|
15
|
+
const potentialSlicingNodes = ast.files.flatMap(f => filter.collectAll(f.root));
|
|
16
16
|
if (potentialSlicingNodes.length < filter.minimumSize) {
|
|
17
17
|
return;
|
|
18
18
|
}
|