@eagleoutice/flowr 2.12.3 → 2.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -95
- package/abstract-interpretation/data-frame/dataframe-domain.d.ts +3 -3
- package/abstract-interpretation/data-frame/dataframe-domain.js +14 -6
- package/abstract-interpretation/data-frame/semantics.js +12 -16
- package/abstract-interpretation/domains/abstract-domain.d.ts +46 -44
- package/abstract-interpretation/domains/abstract-domain.js +146 -6
- package/abstract-interpretation/domains/bounded-set-domain.d.ts +16 -25
- package/abstract-interpretation/domains/bounded-set-domain.js +22 -69
- package/abstract-interpretation/domains/interval-domain.d.ts +27 -36
- package/abstract-interpretation/domains/interval-domain.js +111 -146
- package/abstract-interpretation/domains/lattice.d.ts +3 -3
- package/abstract-interpretation/domains/multi-value-state-domain.js +3 -3
- package/abstract-interpretation/domains/partial-product-domain.d.ts +12 -19
- package/abstract-interpretation/domains/partial-product-domain.js +21 -54
- package/abstract-interpretation/domains/positive-interval-domain.d.ts +8 -12
- package/abstract-interpretation/domains/positive-interval-domain.js +21 -50
- package/abstract-interpretation/domains/product-domain.d.ts +1 -1
- package/abstract-interpretation/domains/product-domain.js +4 -4
- package/abstract-interpretation/domains/set-range-domain.d.ts +60 -56
- package/abstract-interpretation/domains/set-range-domain.js +141 -200
- package/abstract-interpretation/domains/set-upper-bound-domain.d.ts +17 -23
- package/abstract-interpretation/domains/set-upper-bound-domain.js +59 -103
- package/abstract-interpretation/domains/singleton-domain.d.ts +15 -18
- package/abstract-interpretation/domains/singleton-domain.js +33 -72
- package/abstract-interpretation/domains/state-abstract-domain.d.ts +12 -16
- package/abstract-interpretation/domains/state-abstract-domain.js +36 -126
- package/abstract-interpretation/domains/state-domain-like.d.ts +2 -2
- package/abstract-interpretation/domains/value-abstract-domain.d.ts +120 -0
- package/abstract-interpretation/domains/{satisfiable-domain.js → value-abstract-domain.js} +14 -2
- package/benchmark/slicer.d.ts +2 -2
- package/benchmark/slicer.js +6 -5
- package/cli/common/options.d.ts +20 -0
- package/cli/common/options.js +4 -0
- package/cli/common/scripts-info.d.ts +20 -0
- package/cli/flowr-main-options.d.ts +4 -0
- package/cli/flowr-main-options.js +5 -0
- package/cli/flowr.d.ts +5 -0
- package/cli/flowr.js +15 -7
- package/cli/repl/commands/repl-commands.d.ts +8 -0
- package/cli/repl/commands/repl-commands.js +16 -3
- package/cli/repl/commands/repl-query.js +50 -20
- package/cli/repl/commands/repl-signature.js +2 -2
- package/cli/repl/core.d.ts +14 -5
- package/cli/repl/core.js +32 -17
- package/cli/repl/parser/slice-query-parser.d.ts +69 -8
- package/cli/repl/parser/slice-query-parser.js +82 -13
- package/cli/repl/path-input.d.ts +6 -0
- package/cli/repl/path-input.js +41 -0
- package/cli/repl/print-version.js +3 -5
- package/cli/slicer-app.d.ts +4 -0
- package/cli/slicer-app.js +4 -2
- package/config.d.ts +56 -6
- package/config.js +134 -12
- package/control-flow/control-flow-graph.d.ts +3 -2
- package/control-flow/control-flow-graph.js +34 -14
- package/control-flow/semantic-cfg-guided-visitor.d.ts +3 -0
- package/control-flow/semantic-cfg-guided-visitor.js +3 -0
- package/core/steps/all/static-slicing/10-reconstruct.d.ts +6 -0
- package/core/steps/all/static-slicing/10-reconstruct.js +3 -1
- package/data/r-base-packages.generated.d.ts +1 -1
- package/data/r-base-packages.generated.js +3 -3
- package/data/sigdb/sigdb.remote.json +53 -53
- package/dataflow/environments/built-in-proc-name.d.ts +2 -0
- package/dataflow/environments/built-in-proc-name.js +2 -0
- package/dataflow/environments/built-in.d.ts +2 -0
- package/dataflow/environments/built-in.js +2 -0
- package/dataflow/environments/default-builtin-config.d.ts +3 -5
- package/dataflow/environments/default-builtin-config.js +2 -2
- package/dataflow/environments/environment.d.ts +9 -0
- package/dataflow/environments/environment.js +28 -7
- package/dataflow/environments/identifier.d.ts +1 -2
- package/dataflow/environments/identifier.js +1 -5
- package/dataflow/extractor.js +1 -2
- package/dataflow/graph/dataflowgraph-builder.js +42 -3
- package/dataflow/graph/df-helper.d.ts +15 -0
- package/dataflow/graph/df-helper.js +20 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +4 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +7 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +13 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +4 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +57 -11
- package/dataflow/internal/process/functions/call/built-in/built-in-load.d.ts +12 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-load.js +233 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +5 -3
- package/documentation/data/faq/faqs.js +12 -1
- package/documentation/doc-readme.js +1 -1
- package/documentation/doc-util/doc-files.d.ts +2 -2
- package/documentation/doc-util/doc-files.js +4 -7
- package/documentation/doc-util/doc-query.d.ts +12 -9
- package/documentation/doc-util/doc-query.js +63 -28
- package/documentation/wiki-absint.js +1 -4
- package/documentation/wiki-analyzer.js +8 -3
- package/documentation/wiki-cfg.js +3 -2
- package/documentation/wiki-dataflow-graph.js +14 -4
- package/documentation/wiki-interface.js +30 -16
- package/documentation/wiki-mk/doc-maker.js +1 -1
- package/documentation/wiki-query.js +190 -30
- package/documentation/wiki-signature-database.d.ts +1 -1
- package/documentation/wiki-signature-database.js +53 -27
- package/linter/linter-output.d.ts +24 -0
- package/linter/linter-output.js +117 -0
- package/linter/linter-rules.d.ts +2 -4
- package/linter/rules/dataframe-access-validation.js +4 -4
- package/linter/rules/deprecated-functions.d.ts +2 -4
- package/linter/rules/deprecated-functions.js +58 -3
- package/linter/rules/undefined-symbol.js +18 -10
- package/linter/rules/unused-definition.js +24 -0
- package/package.json +5 -2
- package/project/context/flowr-analyzer-context.d.ts +61 -1
- package/project/context/flowr-analyzer-context.js +124 -3
- package/project/context/flowr-analyzer-dependencies-context.d.ts +32 -7
- package/project/context/flowr-analyzer-dependencies-context.js +33 -3
- package/project/context/flowr-analyzer-files-context.d.ts +40 -0
- package/project/context/flowr-analyzer-files-context.js +171 -14
- package/project/context/flowr-analyzer-loading-order-context.d.ts +6 -0
- package/project/context/flowr-analyzer-loading-order-context.js +20 -0
- package/project/context/flowr-analyzer-meta-context.d.ts +92 -10
- package/project/context/flowr-analyzer-meta-context.js +64 -23
- package/project/context/flowr-file.d.ts +7 -0
- package/project/context/flowr-file.js +7 -0
- package/project/context/project-kind.d.ts +22 -0
- package/project/context/project-kind.js +27 -0
- package/project/dependency-version-space.d.ts +168 -0
- package/project/dependency-version-space.js +570 -0
- package/project/flowr-analyzer-builder.js +1 -1
- package/project/flowr-analyzer.d.ts +7 -0
- package/project/flowr-analyzer.js +9 -0
- package/project/plugins/file-plugins/files/flowr-description-file.d.ts +4 -0
- package/project/plugins/file-plugins/files/flowr-description-file.js +7 -0
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +5 -1
- package/project/plugins/file-plugins/files/flowr-rda-file.d.ts +739 -0
- package/project/plugins/file-plugins/files/flowr-rda-file.js +2407 -0
- package/project/plugins/file-plugins/files/flowr-rproject-file.d.ts +31 -0
- package/project/plugins/file-plugins/files/flowr-rproject-file.js +66 -0
- package/project/plugins/file-plugins/files/r-fun-tab.d.ts +828 -0
- package/project/plugins/file-plugins/files/r-fun-tab.js +1039 -0
- package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.js +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-file-plugin.js +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-inst-file-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-inst-file-plugin.js +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-license-file-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-license-file-plugin.js +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-namespace-files-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-namespace-files-plugin.js +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-news-file-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-news-file-plugin.js +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-rda-file-plugin.d.ts +26 -0
- package/project/plugins/file-plugins/flowr-analyzer-rda-file-plugin.js +38 -0
- package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.d.ts +17 -0
- package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.js +30 -0
- package/project/plugins/file-plugins/flowr-analyzer-rproject-file-plugin.d.ts +22 -0
- package/project/plugins/file-plugins/flowr-analyzer-rproject-file-plugin.js +36 -0
- package/project/plugins/file-plugins/flowr-analyzer-test-file-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-test-file-plugin.js +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-vignette-file-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-vignette-file-plugin.js +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.d.ts +3 -4
- package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.js +5 -6
- package/project/plugins/flowr-analyzer-plugin.js +5 -0
- package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-description-file-plugin.d.ts +1 -1
- package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-description-file-plugin.js +1 -1
- package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-implicit-sources-plugin.d.ts +14 -0
- package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-implicit-sources-plugin.js +53 -0
- package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-plugin.js +1 -1
- package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-rprofile-plugin.d.ts +15 -0
- package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-rprofile-plugin.js +33 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-description-file-plugin.d.ts +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-description-file-plugin.js +18 -13
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-rproject-file-plugin.d.ts +13 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-rproject-file-plugin.js +32 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.d.ts +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.js +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.d.ts +8 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +70 -7
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-namespace-file-plugin.d.ts +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-namespace-file-plugin.js +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.js +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-session-info-plugin.d.ts +18 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-session-info-plugin.js +62 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +4 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +5 -13
- package/project/plugins/package-version-plugins/package.d.ts +4 -1
- package/project/plugins/package-version-plugins/package.js +8 -5
- package/project/plugins/plugin-registry.d.ts +11 -3
- package/project/plugins/plugin-registry.js +24 -5
- package/project/plugins/project-discovery/flowr-analyzer-ignore-file-project-discovery-plugin.d.ts +51 -0
- package/project/plugins/project-discovery/flowr-analyzer-ignore-file-project-discovery-plugin.js +101 -0
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +10 -5
- package/project/sigdb/build.js +12 -2
- package/project/sigdb/decode.d.ts +7 -0
- package/project/sigdb/decode.js +35 -4
- package/project/sigdb/decompress.d.ts +2 -0
- package/project/sigdb/decompress.js +5 -0
- package/project/sigdb/manifest.d.ts +5 -0
- package/project/sigdb/manifest.js +37 -6
- package/project/sigdb/reader.d.ts +82 -2
- package/project/sigdb/reader.js +226 -14
- package/project/sigdb/schema.d.ts +31 -5
- package/project/sigdb/schema.js +7 -3
- package/project/sigdb/{version.d.ts → sigdb-version.d.ts} +21 -1
- package/project/sigdb/sigdb-version.js +119 -0
- package/queries/catalog/absint-query/absint-query-format.d.ts +2 -0
- package/queries/catalog/absint-query/absint-query-format.js +2 -0
- package/queries/catalog/call-context-query/call-context-query-executor.js +30 -3
- package/queries/catalog/call-context-query/call-context-query-format.d.ts +1 -0
- package/queries/catalog/call-context-query/call-context-query-format.js +1 -0
- package/queries/catalog/call-graph-query/call-graph-query-executor.js +3 -1
- package/queries/catalog/call-graph-query/call-graph-query-format.d.ts +6 -0
- package/queries/catalog/call-graph-query/call-graph-query-format.js +2 -0
- package/queries/catalog/call-graph-query/expand-library-internals.d.ts +19 -0
- package/queries/catalog/call-graph-query/expand-library-internals.js +59 -0
- package/queries/catalog/cluster-query/cluster-query-format.d.ts +1 -0
- package/queries/catalog/cluster-query/cluster-query-format.js +1 -0
- package/queries/catalog/config-query/config-query-executor.js +17 -5
- package/queries/catalog/config-query/config-query-format.d.ts +19 -3
- package/queries/catalog/config-query/config-query-format.js +258 -98
- package/queries/catalog/control-flow-query/control-flow-query-format.d.ts +1 -0
- package/queries/catalog/control-flow-query/control-flow-query-format.js +1 -0
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.d.ts +1 -0
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.js +1 -0
- package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +1 -0
- package/queries/catalog/dataflow-query/dataflow-query-format.js +1 -0
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +2 -7
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +13 -1
- package/queries/catalog/dependencies-query/dependencies-query-format.js +117 -17
- package/queries/catalog/dice-query/dice-query-executor.js +6 -9
- package/queries/catalog/dice-query/dice-query-format.d.ts +4 -5
- package/queries/catalog/dice-query/dice-query-format.js +10 -6
- package/queries/catalog/does-call-query/does-call-query-executor.js +15 -2
- package/queries/catalog/does-call-query/does-call-query-format.d.ts +8 -0
- package/queries/catalog/does-call-query/does-call-query-format.js +4 -1
- package/queries/catalog/files-query/files-query-format.d.ts +2 -0
- package/queries/catalog/files-query/files-query-format.js +2 -0
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.d.ts +6 -0
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +293 -0
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +121 -0
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +345 -0
- package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +1 -0
- package/queries/catalog/happens-before-query/happens-before-query-format.js +1 -0
- package/queries/catalog/id-map-query/id-map-query-format.d.ts +1 -0
- package/queries/catalog/id-map-query/id-map-query-format.js +1 -0
- package/queries/catalog/input-sources-query/input-sources-query-format.d.ts +2 -0
- package/queries/catalog/input-sources-query/input-sources-query-format.js +2 -0
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.d.ts +2 -0
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +2 -0
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +2 -0
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +2 -0
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.d.ts +2 -0
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.js +2 -0
- package/queries/catalog/linter-query/linter-query-executor.js +11 -2
- package/queries/catalog/linter-query/linter-query-format.d.ts +9 -4
- package/queries/catalog/linter-query/linter-query-format.js +44 -21
- package/queries/catalog/location-map-query/location-map-query-format.d.ts +2 -0
- package/queries/catalog/location-map-query/location-map-query-format.js +2 -0
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +1 -0
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.js +1 -0
- package/queries/catalog/origin-query/origin-query-format.d.ts +2 -0
- package/queries/catalog/origin-query/origin-query-format.js +2 -0
- package/queries/catalog/project-query/project-query-executor.d.ts +0 -15
- package/queries/catalog/project-query/project-query-executor.js +19 -62
- package/queries/catalog/project-query/project-query-format.d.ts +7 -18
- package/queries/catalog/project-query/project-query-format.js +3 -18
- package/queries/catalog/provenance-query/provenance-query-format.d.ts +2 -0
- package/queries/catalog/provenance-query/provenance-query-format.js +2 -0
- package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +2 -0
- package/queries/catalog/resolve-value-query/resolve-value-query-format.js +2 -0
- package/queries/catalog/search-query/search-query-format.d.ts +1 -0
- package/queries/catalog/search-query/search-query-format.js +1 -0
- package/queries/catalog/signature-query/signature-query-executor.d.ts +5 -0
- package/queries/catalog/signature-query/signature-query-executor.js +267 -57
- package/queries/catalog/signature-query/signature-query-format.d.ts +37 -6
- package/queries/catalog/signature-query/signature-query-format.js +41 -5
- package/queries/catalog/signature-query/signature-query-render.js +48 -6
- package/queries/catalog/slice-query-options.d.ts +49 -0
- package/queries/catalog/slice-query-options.js +50 -0
- package/queries/catalog/static-slice-query/static-slice-query-executor.js +4 -12
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +4 -15
- package/queries/catalog/static-slice-query/static-slice-query-format.js +9 -10
- package/queries/query-print.js +3 -1
- package/queries/query.d.ts +62 -2
- package/queries/query.js +9 -2
- package/r-bridge/data/data.d.ts +16 -0
- package/r-bridge/data/data.js +20 -0
- package/r-bridge/lang-4.x/ast/model/model.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/processing/decorate.js +2 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/normalize-access.js +2 -1
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +19 -16
- package/reconstruct/reconstruct.d.ts +18 -1
- package/reconstruct/reconstruct.js +42 -19
- package/slicing/criterion/parse.d.ts +4 -0
- package/slicing/criterion/parse.js +4 -0
- package/slicing/static/slice-call.js +17 -9
- package/slicing/static/static-slicer.d.ts +1 -1
- package/slicing/static/static-slicer.js +5 -4
- package/util/files.d.ts +19 -1
- package/util/files.js +45 -3
- package/util/glob.d.ts +19 -0
- package/util/glob.js +67 -0
- package/util/log.d.ts +12 -0
- package/util/log.js +17 -1
- package/util/logic.d.ts +6 -0
- package/util/logic.js +31 -1
- package/util/mermaid/dfg.js +17 -12
- package/util/mermaid/mermaid.js +2 -2
- package/util/objects.d.ts +5 -0
- package/util/objects.js +8 -0
- package/util/r-version.d.ts +9 -1
- package/util/r-version.js +27 -2
- package/util/schema.d.ts +18 -0
- package/util/schema.js +102 -4
- package/util/text/ansi.d.ts +4 -0
- package/util/text/ansi.js +27 -3
- package/util/text/strings.d.ts +9 -0
- package/util/text/strings.js +29 -0
- package/util/version.js +79 -6
- package/abstract-interpretation/domains/satisfiable-domain.d.ts +0 -29
- package/project/plugins/project-discovery/flowr-analyzer-gitignore-project-discovery-plugin.d.ts +0 -22
- package/project/plugins/project-discovery/flowr-analyzer-gitignore-project-discovery-plugin.js +0 -52
- package/project/sigdb/version.js +0 -55
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.helpCommand = void 0;
|
|
4
|
+
exports.masterScriptArgs = masterScriptArgs;
|
|
4
5
|
exports.getReplCommands = getReplCommands;
|
|
5
6
|
exports.getCommandNames = getCommandNames;
|
|
6
7
|
exports.getCommand = getCommand;
|
|
@@ -160,6 +161,18 @@ function hasModule(path) {
|
|
|
160
161
|
return false;
|
|
161
162
|
}
|
|
162
163
|
}
|
|
164
|
+
/**
|
|
165
|
+
* The args a master script is forked with: `remainingLine` tokenized, plus `--config-json <analyzer.flowrConfig>`
|
|
166
|
+
* so it sees the repl's current (possibly `:query \@config`-edited) config -- unless the script does not support
|
|
167
|
+
* that option, or the user already named a config themselves.
|
|
168
|
+
*/
|
|
169
|
+
function masterScriptArgs(remainingLine, config, scriptOptions) {
|
|
170
|
+
const args = (0, args_1.splitAtEscapeSensitive)(remainingLine);
|
|
171
|
+
if (scriptOptions.some(o => o.name === 'config-json') && !args.includes('--config-json') && !args.includes('--config-file')) {
|
|
172
|
+
args.push('--config-json', JSON.stringify(config));
|
|
173
|
+
}
|
|
174
|
+
return args;
|
|
175
|
+
}
|
|
163
176
|
/**
|
|
164
177
|
* Retrieve all REPL commands (including those generated from master scripts)
|
|
165
178
|
*/
|
|
@@ -168,7 +181,7 @@ function getReplCommands() {
|
|
|
168
181
|
return _commands;
|
|
169
182
|
}
|
|
170
183
|
commandsInitialized = true;
|
|
171
|
-
for (const [script, { target, description, type }] of Object.entries(scripts_info_1.scripts)) {
|
|
184
|
+
for (const [script, { target, description, type, options }] of Object.entries(scripts_info_1.scripts)) {
|
|
172
185
|
if (type === 'master script') {
|
|
173
186
|
_commands[script] = {
|
|
174
187
|
description,
|
|
@@ -176,7 +189,7 @@ function getReplCommands() {
|
|
|
176
189
|
script: true,
|
|
177
190
|
usageExample: `:${script} --help`,
|
|
178
191
|
isCodeCommand: false,
|
|
179
|
-
fn: async ({ output, remainingLine }) => {
|
|
192
|
+
fn: async ({ output, remainingLine, analyzer }) => {
|
|
180
193
|
// check if the target *module* exists in the current directory, else try two dirs up, otherwise, fail with a message
|
|
181
194
|
let path = `${__dirname}/${target}`;
|
|
182
195
|
if (!hasModule(path)) {
|
|
@@ -186,7 +199,7 @@ function getReplCommands() {
|
|
|
186
199
|
return;
|
|
187
200
|
}
|
|
188
201
|
}
|
|
189
|
-
await (0, execute_1.waitOnScript)(path, (
|
|
202
|
+
await (0, execute_1.waitOnScript)(path, masterScriptArgs(remainingLine, analyzer.flowrConfig, options), stdio => (0, execute_1.stdioCaptureProcessor)(stdio, msg => output.stdout(msg), msg => output.stderr(msg)));
|
|
190
203
|
}
|
|
191
204
|
};
|
|
192
205
|
}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.queryStarCommand = exports.queryCommand = void 0;
|
|
7
4
|
exports.validateQueries = validateQueries;
|
|
@@ -13,19 +10,7 @@ const json_1 = require("../../../util/json");
|
|
|
13
10
|
const args_1 = require("../../../util/text/args");
|
|
14
11
|
const record_1 = require("../../../util/record");
|
|
15
12
|
const retriever_1 = require("../../../r-bridge/retriever");
|
|
16
|
-
const
|
|
17
|
-
const fs_1 = __importDefault(require("fs"));
|
|
18
|
-
/** Whether `s` looks like a filesystem path the user likely meant to load via {@link fileProtocol}. */
|
|
19
|
-
function looksLikePath(s) {
|
|
20
|
-
if (s.startsWith(retriever_1.fileProtocol) || s.startsWith(core_1.watchProtocol)) {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
if (/^(~|\.{0,2}\/|[a-zA-Z]:[\\/])/.test(s)) {
|
|
24
|
-
return true;
|
|
25
|
-
}
|
|
26
|
-
// a single path-like token (a separator, no R-code punctuation) that actually exists on disk
|
|
27
|
-
return /^[^\s()]+\/[^\s()]+$/.test(s) && fs_1.default.existsSync(s);
|
|
28
|
-
}
|
|
13
|
+
const path_input_1 = require("../path-input");
|
|
29
14
|
/**
|
|
30
15
|
* Whether the analyzer already holds exactly `input` as its sole request, so a prior analysis (e.g. a
|
|
31
16
|
* dataflow computed via `:df#`) can be reused instead of being discarded by a reset.
|
|
@@ -38,15 +23,49 @@ function analyzerHasTarget(analyzer, input) {
|
|
|
38
23
|
function printHelp(output) {
|
|
39
24
|
output.stderr(`Format: ${(0, ansi_1.italic)(':query <query> <code>', output.formatter)}`);
|
|
40
25
|
output.stdout('Queries starting with \'@<type>\' are interpreted as a query of the given type.');
|
|
26
|
+
output.stdout(`Start with '?<type>' instead to see documentation on a query, e.g. ${(0, ansi_1.bold)(':query ?guess-dep-versions', output.formatter)} (a bare ${(0, ansi_1.bold)(':query ?', output.formatter)} lists them all).`);
|
|
41
27
|
output.stdout(`With this, ${(0, ansi_1.bold)(':query @config', output.formatter)} prints the result of the config query.`);
|
|
42
28
|
output.stdout(`If you want to run the linter on a project use:\n ${(0, ansi_1.bold)(':query @linter file://<path>', output.formatter)} (or ${(0, ansi_1.bold)('watch://<path>', output.formatter)} to re-run on changes).`);
|
|
43
29
|
output.stdout((0, ansi_1.ansiInfo)('Otherwise, you can also directly pass the query json. Then, the query is an array of query objects to represent multiple queries.'));
|
|
44
30
|
output.stdout((0, ansi_1.ansiInfo)('The example') + (0, ansi_1.italic)(String.raw `:query "[{\"type\": \"call-context\", \"callName\": \"mean\" }]" mean(1:10)`, output.formatter, { color: 7 /* Colors.White */, effect: ansi_1.ColorEffect.Foreground }) + (0, ansi_1.ansiInfo)('would return the call context of the mean function.'));
|
|
45
31
|
output.stdout('Please have a look at the wiki for more info: https://github.com/flowr-analysis/flowr/wiki/Query-API');
|
|
46
32
|
}
|
|
33
|
+
/** the single boundary cast for Joi's untyped {@link Joi.Description}, shared by the doc and template renderers */
|
|
34
|
+
function describeSchema(schema) {
|
|
35
|
+
return schema.describe();
|
|
36
|
+
}
|
|
37
|
+
/** Print documentation for one query type from its Joi schema (description + each parameter), or list all when no name is given. */
|
|
38
|
+
function printQueryDoc(output, name) {
|
|
39
|
+
if (name.length === 0) {
|
|
40
|
+
output.stdout(`Queries: ${Object.keys(query_1.SupportedQueries).sort().map(q => (0, ansi_1.bold)('@' + q, output.formatter)).join(', ')}`);
|
|
41
|
+
output.stdout(`Use ${(0, ansi_1.bold)(':query ?<type>', output.formatter)} for details on one, e.g. ${(0, ansi_1.bold)(':query ?guess-dep-versions', output.formatter)}.`);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const def = Object.entries(query_1.SupportedQueries).find(([key]) => key === name)?.[1];
|
|
45
|
+
if (def === undefined) {
|
|
46
|
+
output.stderr(`Unknown query ${(0, ansi_1.italic)(name, output.formatter)}; use ${(0, ansi_1.bold)(':query ?', output.formatter)} to list every query.`);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const desc = describeSchema(def.schema);
|
|
50
|
+
output.stdout(`${(0, ansi_1.bold)('@' + name, output.formatter)}${desc.flags?.description ? ` ${(0, ansi_1.faint)('— ' + desc.flags.description, output.formatter)}` : ''}`);
|
|
51
|
+
const params = Object.entries(desc.keys ?? {}).filter(([key]) => key !== 'type');
|
|
52
|
+
if (params.length === 0) {
|
|
53
|
+
output.stdout((0, ansi_1.faint)(' (no parameters)', output.formatter));
|
|
54
|
+
}
|
|
55
|
+
for (const [key, spec] of params) {
|
|
56
|
+
const presence = spec.flags?.presence === 'required' ? 'required' : 'optional';
|
|
57
|
+
const allowed = Array.isArray(spec.allow) && spec.allow.length > 0 ? ` {${spec.allow.join('|')}}` : '';
|
|
58
|
+
output.stdout(` ${(0, ansi_1.bold)(key, output.formatter)} ${(0, ansi_1.faint)(`(${spec.type}${allowed}, ${presence})`, output.formatter)}${spec.flags?.description ? ': ' + spec.flags.description : ''}`);
|
|
59
|
+
}
|
|
60
|
+
const syntax = 'syntax' in def && typeof def.syntax === 'string' ? def.syntax : `@${name} <code | file://path>`;
|
|
61
|
+
output.stdout(`Run: ${(0, ansi_1.bold)(':query ' + syntax, output.formatter)}`);
|
|
62
|
+
output.stdout(`JSON: ${(0, ansi_1.italic)(queryTemplate(name, def.schema), output.formatter)}`);
|
|
63
|
+
const wiki = `https://github.com/flowr-analysis/flowr/wiki/${encodeURIComponent((0, query_1.queryWikiPage)(def.title).replaceAll(' ', '-'))}`;
|
|
64
|
+
output.stdout(`Docs: ${(0, ansi_1.supportsHyperlinks)() ? output.formatter.hyperlink(`${name} query`, wiki) : wiki}`);
|
|
65
|
+
}
|
|
47
66
|
/** A copy-pasteable JSON template for a query type: its `type` plus each required field as a placeholder. */
|
|
48
67
|
function queryTemplate(type, schema) {
|
|
49
|
-
const keys = schema
|
|
68
|
+
const keys = describeSchema(schema).keys ?? {};
|
|
50
69
|
const fields = [`\\"type\\": \\"${type}\\"`];
|
|
51
70
|
for (const [key, value] of Object.entries(keys)) {
|
|
52
71
|
if (key !== 'type' && value.flags?.presence === 'required') {
|
|
@@ -88,6 +107,11 @@ async function processQueryArgs(output, analyzer, remainingArgs) {
|
|
|
88
107
|
printHelp(output);
|
|
89
108
|
return;
|
|
90
109
|
}
|
|
110
|
+
// `?<type>` (or `? <type>`) documents a query instead of running it; a bare `?` lists them all
|
|
111
|
+
if (query.startsWith('?')) {
|
|
112
|
+
printQueryDoc(output, query.slice(1) || (remainingArgs.shift() ?? ''));
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
91
115
|
let parsedQuery;
|
|
92
116
|
let input;
|
|
93
117
|
if (query.startsWith('@')) {
|
|
@@ -118,9 +142,7 @@ async function processQueryArgs(output, analyzer, remainingArgs) {
|
|
|
118
142
|
parsedQuery = [{ type: 'call-context', callName: query }];
|
|
119
143
|
}
|
|
120
144
|
if (input) {
|
|
121
|
-
|
|
122
|
-
output.stdout((0, ansi_1.ansiInfo)(`'${input}' looks like a path. To analyze it, use ${(0, ansi_1.bold)(retriever_1.fileProtocol + input, output.formatter)} (or ${(0, ansi_1.bold)(core_1.watchProtocol + input, output.formatter)} to re-run on changes). Use ${(0, ansi_1.bold)(':help', output.formatter)} for more.`));
|
|
123
|
-
}
|
|
145
|
+
input = (0, path_input_1.handlePathLikeInput)(output, input, analyzer.flowrConfig);
|
|
124
146
|
// reuse a prior analysis (e.g. a dataflow from :df#) when the target is unchanged
|
|
125
147
|
if (!analyzerHasTarget(analyzer, input)) {
|
|
126
148
|
analyzer.reset();
|
|
@@ -135,12 +157,20 @@ async function processQueryArgs(output, analyzer, remainingArgs) {
|
|
|
135
157
|
analyzer
|
|
136
158
|
};
|
|
137
159
|
}
|
|
160
|
+
const ConfigLineRegex = /^(@config)(?:\s+([\s\S]*))?$/;
|
|
138
161
|
/**
|
|
139
162
|
* Function for splitting the input line.
|
|
140
163
|
* All input is treated as arguments, no R code is separated so that the individual queries can handle it.
|
|
164
|
+
* `@config` is passed its rest-of-line untouched, since its own `fromLine` reads a single raw token and the
|
|
165
|
+
* generic tokenizer would otherwise strip quotes out of a `+path=["a"]` value.
|
|
141
166
|
* @param line - The input line
|
|
142
167
|
*/
|
|
143
168
|
function parseArgs(line) {
|
|
169
|
+
const configMatch = ConfigLineRegex.exec(line);
|
|
170
|
+
if (configMatch) {
|
|
171
|
+
const [, name, rest] = configMatch;
|
|
172
|
+
return { rCode: undefined, remaining: rest === undefined ? [name] : [name, rest] };
|
|
173
|
+
}
|
|
144
174
|
const args = (0, args_1.splitAtEscapeSensitive)(line);
|
|
145
175
|
return {
|
|
146
176
|
rCode: undefined,
|
|
@@ -22,8 +22,8 @@ function printHelp(output) {
|
|
|
22
22
|
const f = output.formatter;
|
|
23
23
|
output.stdout((0, ansi_1.bold)('Signature Database', f) + (0, ansi_1.italic)(' (inspect and extend the databases that resolve library()/`::` calls)', f));
|
|
24
24
|
output.stdout('');
|
|
25
|
-
output.stdout(` ${(0, ansi_1.bold)(':signature query', f)} ${(0, ansi_1.italic)('[<package>[@<version>][::<function>] [<function>]] [--
|
|
26
|
-
output.stdout(` ${(0, ansi_1.italic)('inspect the database -- identical to :query @signature (run :signature query help for the full syntax)', f)}`);
|
|
25
|
+
output.stdout(` ${(0, ansi_1.bold)(':signature query', f)} ${(0, ansi_1.italic)('[<package>[@<version>][::<function>] [<function>]] [--param <name>] [--required <n>]', f)}`);
|
|
26
|
+
output.stdout(` ${(0, ansi_1.italic)('inspect the database -- identical to :query @signature; with no package it summarizes the loaded databases and per-shard load state (run :signature query help for the full syntax)', f)}`);
|
|
27
27
|
output.stdout(` ${(0, ansi_1.bold)(':signature add', f)} ${(0, ansi_1.italic)('<path-to-.sigs.ndjson|.br|.manifest.json>', f)}`);
|
|
28
28
|
output.stdout(` ${(0, ansi_1.italic)('mount an additional signature database/source (dictionaries + shards); takes precedence over the bundle', f)}`);
|
|
29
29
|
output.stdout(` ${(0, ansi_1.bold)(':signature download', f)} ${(0, ansi_1.italic)('[<version>]', f)}`);
|
package/cli/repl/core.d.ts
CHANGED
|
@@ -15,7 +15,18 @@ export interface CommandCompletions {
|
|
|
15
15
|
* This is relevant if an argument is composed of multiple parts (e.g. comma-separated lists).
|
|
16
16
|
*/
|
|
17
17
|
readonly argumentPart?: string;
|
|
18
|
+
/** What Tab displays per completion, only used while several remain: readline inserts what it displays. */
|
|
19
|
+
readonly labels?: ReadonlyMap<string, string>;
|
|
20
|
+
/** Display-only suggestions (e.g. a `<string>` type placeholder): previewed as a ghost hint but never inserted on Tab. */
|
|
21
|
+
readonly hints?: readonly string[];
|
|
22
|
+
/**
|
|
23
|
+
* The completer already selected these, so they must not be filtered against the typed fragment again.
|
|
24
|
+
* Needed when a completion legitimately shares no prefix with what was typed, e.g. a glob expanding to the keys it matches.
|
|
25
|
+
*/
|
|
26
|
+
readonly preFiltered?: boolean;
|
|
18
27
|
}
|
|
28
|
+
/** Labels a completion with what it does, see {@link CommandCompletions#labels|labels}. */
|
|
29
|
+
export declare function describeCompletion(insert: string, describe: string): string;
|
|
19
30
|
/**
|
|
20
31
|
* Used by the repl to provide automatic completions for a given (partial) input line. Returns every matching
|
|
21
32
|
* option, so Tab shows the full menu and only completes when a single option remains (standard readline behavior).
|
|
@@ -30,7 +41,7 @@ export declare function completionSuggestion(line: string, config: FlowrConfig):
|
|
|
30
41
|
/**
|
|
31
42
|
* Produces default readline options for the flowR REPL
|
|
32
43
|
*/
|
|
33
|
-
export declare function makeDefaultReplReadline(config: FlowrConfig): readline.ReadLineOptions;
|
|
44
|
+
export declare function makeDefaultReplReadline(config: FlowrConfig, historyFile?: string | undefined): readline.ReadLineOptions;
|
|
34
45
|
/**
|
|
35
46
|
* Handles a string input for the REPL, returning the parsed string and any remaining input.
|
|
36
47
|
*/
|
|
@@ -38,8 +49,6 @@ export declare function handleString(code: string): {
|
|
|
38
49
|
rCode: string | undefined;
|
|
39
50
|
remaining: never[];
|
|
40
51
|
};
|
|
41
|
-
/** Path prefix that activates watch mode; use instead of {@link fileProtocol} to re-run on every file change. */
|
|
42
|
-
export declare const watchProtocol = "watch://";
|
|
43
52
|
/** Convert a statement containing {@link watchProtocol} into one using {@link fileProtocol} so it can be executed. */
|
|
44
53
|
export declare function toFileStatement(statement: string): string;
|
|
45
54
|
/** Return the watch path from the first `watch://<path>` token in `statement`, or `undefined` if none is present. */
|
|
@@ -71,7 +80,7 @@ export interface FlowrReplOptions extends MergeableRecord {
|
|
|
71
80
|
readonly rl?: readline.Interface;
|
|
72
81
|
/** Defines two methods that every function in the repl uses to output its data. */
|
|
73
82
|
readonly output?: ReplOutput;
|
|
74
|
-
/** The file to use for persisting the repl's history. Passing
|
|
83
|
+
/** The file to use for loading and persisting the repl's history. Passing an empty string neither reads nor writes it. */
|
|
75
84
|
readonly historyFile?: string;
|
|
76
85
|
/** If true, allows the execution of arbitrary R code. This is a security risk, as it allows the execution of arbitrary R code. */
|
|
77
86
|
readonly allowRSessionAccess?: boolean;
|
|
@@ -86,7 +95,7 @@ export interface FlowrReplOptions extends MergeableRecord {
|
|
|
86
95
|
*
|
|
87
96
|
* For the execution, this function makes use of {@link replProcessAnswer}.
|
|
88
97
|
*/
|
|
89
|
-
export declare function repl({ analyzer, rl, output,
|
|
98
|
+
export declare function repl({ analyzer, historyFile, rl, output, allowRSessionAccess }: FlowrReplOptions): Promise<void>;
|
|
90
99
|
/**
|
|
91
100
|
* Loads the REPL history from the given file.
|
|
92
101
|
*/
|
package/cli/repl/core.js
CHANGED
|
@@ -36,7 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.
|
|
39
|
+
exports.describeCompletion = describeCompletion;
|
|
40
40
|
exports.replCompleter = replCompleter;
|
|
41
41
|
exports.completionSuggestion = completionSuggestion;
|
|
42
42
|
exports.makeDefaultReplReadline = makeDefaultReplReadline;
|
|
@@ -53,6 +53,7 @@ exports.loadReplHistory = loadReplHistory;
|
|
|
53
53
|
* @module
|
|
54
54
|
*/
|
|
55
55
|
const prompt_1 = require("./prompt");
|
|
56
|
+
const path_input_1 = require("./path-input");
|
|
56
57
|
const readline = __importStar(require("readline"));
|
|
57
58
|
const ghost_hint_1 = require("./ghost-hint");
|
|
58
59
|
const repl_execute_1 = require("./commands/repl-execute");
|
|
@@ -79,6 +80,10 @@ function replCompleterKeywords() {
|
|
|
79
80
|
return _replCompleterKeywords;
|
|
80
81
|
}
|
|
81
82
|
const defaultHistoryFile = path_1.default.join(os_1.default.tmpdir(), '.flowrhistory');
|
|
83
|
+
/** Labels a completion with what it does, see {@link CommandCompletions#labels|labels}. */
|
|
84
|
+
function describeCompletion(insert, describe) {
|
|
85
|
+
return `${insert} ${ansi_1.ansiFormatter.format(describe, { style: 2 /* FontStyles.Faint */ })}`;
|
|
86
|
+
}
|
|
82
87
|
function computeCompletions(line, config) {
|
|
83
88
|
const splitLine = (0, args_1.splitAtEscapeSensitive)(line);
|
|
84
89
|
// did we just type a space (and are starting a new arg right now)?
|
|
@@ -89,6 +94,9 @@ function computeCompletions(line, config) {
|
|
|
89
94
|
if (commandNameColon) {
|
|
90
95
|
let completions = [];
|
|
91
96
|
let currentArg = startingNewArg ? '' : splitLine[splitLine.length - 1];
|
|
97
|
+
let labels;
|
|
98
|
+
let hints;
|
|
99
|
+
let preFiltered = false;
|
|
92
100
|
const commandName = commandNameColon.slice(1);
|
|
93
101
|
const cmd = (0, repl_commands_1.getCommand)(commandName);
|
|
94
102
|
if (cmd?.script === true) {
|
|
@@ -97,11 +105,14 @@ function computeCompletions(line, config) {
|
|
|
97
105
|
completions = completions.concat((0, scripts_info_1.getValidOptionsForCompletion)(options, splitLine).map(o => `${o} `));
|
|
98
106
|
}
|
|
99
107
|
else if (commandName.startsWith('query')) {
|
|
100
|
-
const { completions: queryCompletions, argumentPart: splitArg } = replQueryCompleter(splitLine, startingNewArg, config);
|
|
108
|
+
const { completions: queryCompletions, argumentPart: splitArg, labels: queryLabels, hints: queryHints, preFiltered: queryPreFiltered } = replQueryCompleter(splitLine, startingNewArg, config);
|
|
101
109
|
if (splitArg !== undefined) {
|
|
102
110
|
currentArg = splitArg;
|
|
103
111
|
}
|
|
104
112
|
completions = completions.concat(queryCompletions);
|
|
113
|
+
labels = queryLabels;
|
|
114
|
+
hints = queryHints;
|
|
115
|
+
preFiltered = queryPreFiltered ?? false;
|
|
105
116
|
}
|
|
106
117
|
else if (cmd === repl_signature_1.signatureCommand) {
|
|
107
118
|
const { completions: sigCompletions, argumentPart: splitArg } = (0, repl_signature_1.replSignatureCompleter)(splitLine, startingNewArg);
|
|
@@ -112,9 +123,10 @@ function computeCompletions(line, config) {
|
|
|
112
123
|
}
|
|
113
124
|
else if (cmd?.isCodeCommand) {
|
|
114
125
|
completions.push(retriever_1.fileProtocol);
|
|
115
|
-
completions.push(
|
|
126
|
+
completions.push(path_input_1.watchProtocol);
|
|
116
127
|
}
|
|
117
|
-
|
|
128
|
+
// prefix matches when any exist, else fuzzy (subsequence) matches, so e.g. `+sg` still completes to `+specializeConfig`
|
|
129
|
+
return [preFiltered ? completions : (0, strings_1.matchByPrefixOrSubsequence)(completions, currentArg), currentArg, labels, hints?.filter(h => h.startsWith(currentArg))];
|
|
118
130
|
}
|
|
119
131
|
}
|
|
120
132
|
// if no command is already typed, just return all commands that match
|
|
@@ -125,7 +137,11 @@ function computeCompletions(line, config) {
|
|
|
125
137
|
* option, so Tab shows the full menu and only completes when a single option remains (standard readline behavior).
|
|
126
138
|
*/
|
|
127
139
|
function replCompleter(line, config) {
|
|
128
|
-
|
|
140
|
+
const [completions, fragment, labels] = computeCompletions(line, config);
|
|
141
|
+
if (labels === undefined || completions.length <= 1) {
|
|
142
|
+
return [completions, fragment];
|
|
143
|
+
}
|
|
144
|
+
return [completions.map(c => labels.get(c) ?? c), fragment];
|
|
129
145
|
}
|
|
130
146
|
/**
|
|
131
147
|
* The remaining text of the best (first) completion, i.e. what the inline ghost previews as you type; empty when
|
|
@@ -136,12 +152,13 @@ function completionSuggestion(line, config) {
|
|
|
136
152
|
if (line.length === 0) {
|
|
137
153
|
return '';
|
|
138
154
|
}
|
|
139
|
-
const [completions, fragment] = computeCompletions(line, config);
|
|
140
|
-
|
|
155
|
+
const [completions, fragment, , hints] = computeCompletions(line, config);
|
|
156
|
+
// prefer an insertable completion; otherwise preview a display-only hint (e.g. a `<string>` type placeholder)
|
|
157
|
+
const best = completions[0] ?? hints?.[0];
|
|
141
158
|
if (best === undefined || !best.startsWith(fragment) || best.length <= fragment.length) {
|
|
142
159
|
return '';
|
|
143
160
|
}
|
|
144
|
-
else if (best === retriever_1.fileProtocol || best ===
|
|
161
|
+
else if (best === retriever_1.fileProtocol || best === path_input_1.watchProtocol) {
|
|
145
162
|
return '';
|
|
146
163
|
}
|
|
147
164
|
return best.slice(fragment.length);
|
|
@@ -164,13 +181,13 @@ function replQueryCompleter(splitLine, startingNewArg, config) {
|
|
|
164
181
|
/**
|
|
165
182
|
* Produces default readline options for the flowR REPL
|
|
166
183
|
*/
|
|
167
|
-
function makeDefaultReplReadline(config) {
|
|
184
|
+
function makeDefaultReplReadline(config, historyFile = defaultHistoryFile) {
|
|
168
185
|
return {
|
|
169
186
|
input: process.stdin,
|
|
170
187
|
output: process.stdout,
|
|
171
188
|
tabSize: 4,
|
|
172
189
|
terminal: true,
|
|
173
|
-
history: loadReplHistory(
|
|
190
|
+
history: historyFile ? loadReplHistory(historyFile) : [],
|
|
174
191
|
removeHistoryDuplicates: true,
|
|
175
192
|
completer: (c) => replCompleter(c, config)
|
|
176
193
|
};
|
|
@@ -184,11 +201,9 @@ function handleString(code) {
|
|
|
184
201
|
remaining: []
|
|
185
202
|
};
|
|
186
203
|
}
|
|
187
|
-
/** Path prefix that activates watch mode; use instead of {@link fileProtocol} to re-run on every file change. */
|
|
188
|
-
exports.watchProtocol = 'watch://';
|
|
189
204
|
/** Convert a statement containing {@link watchProtocol} into one using {@link fileProtocol} so it can be executed. */
|
|
190
205
|
function toFileStatement(statement) {
|
|
191
|
-
return statement.replaceAll(
|
|
206
|
+
return statement.replaceAll(path_input_1.watchProtocol, retriever_1.fileProtocol);
|
|
192
207
|
}
|
|
193
208
|
/** Return the watch path from the first `watch://<path>` token in `statement`, or `undefined` if none is present. */
|
|
194
209
|
function extractWatchPath(statement) {
|
|
@@ -241,7 +256,7 @@ async function executeStatement(output, statement, analyzer, allowRSessionAccess
|
|
|
241
256
|
const args = processor.argsParser(remainingLine);
|
|
242
257
|
if (args.rCode) {
|
|
243
258
|
analyzer.reset();
|
|
244
|
-
analyzer.addRequest(args.rCode);
|
|
259
|
+
analyzer.addRequest((0, path_input_1.handlePathLikeInput)(output, args.rCode, analyzer.flowrConfig));
|
|
245
260
|
}
|
|
246
261
|
await processor.fn({ output, analyzer, remainingArgs: args.remaining });
|
|
247
262
|
}
|
|
@@ -303,8 +318,8 @@ async function executeStatement(output, statement, analyzer, allowRSessionAccess
|
|
|
303
318
|
}
|
|
304
319
|
}
|
|
305
320
|
async function replProcessStatement(output, statement, analyzer, allowRSessionAccess) {
|
|
306
|
-
stopWatching(output, !statement.includes(
|
|
307
|
-
if (statement.includes(
|
|
321
|
+
stopWatching(output, !statement.includes(path_input_1.watchProtocol));
|
|
322
|
+
if (statement.includes(path_input_1.watchProtocol)) {
|
|
308
323
|
const watchPath = extractWatchPath(statement);
|
|
309
324
|
const effective = toFileStatement(statement);
|
|
310
325
|
await executeStatement(output, effective, analyzer, allowRSessionAccess);
|
|
@@ -350,7 +365,7 @@ async function replProcessAnswer(analyzer, output, expr, allowRSessionAccess) {
|
|
|
350
365
|
*
|
|
351
366
|
* For the execution, this function makes use of {@link replProcessAnswer}.
|
|
352
367
|
*/
|
|
353
|
-
async function repl({ analyzer, rl = readline.createInterface(makeDefaultReplReadline(analyzer.flowrConfig)), output = repl_main_1.standardReplOutput,
|
|
368
|
+
async function repl({ analyzer, historyFile = defaultHistoryFile, rl = readline.createInterface(makeDefaultReplReadline(analyzer.flowrConfig, historyFile)), output = repl_main_1.standardReplOutput, allowRSessionAccess = false }) {
|
|
354
369
|
if (historyFile) {
|
|
355
370
|
rl.on('history', h => fs_1.default.writeFileSync(historyFile, h.join('\n'), { encoding: 'utf-8' }));
|
|
356
371
|
}
|
|
@@ -1,21 +1,77 @@
|
|
|
1
1
|
import type { SlicingCriterion, SlicingCriteria } from '../../../slicing/criterion/parse';
|
|
2
2
|
import { SliceDirection } from '../../../util/slice-direction';
|
|
3
|
-
import type
|
|
3
|
+
import { type CommandCompletions } from '../core';
|
|
4
4
|
import type { FlowrConfig } from '../../../config';
|
|
5
|
+
import type { SliceQueryOptions } from '../../../queries/catalog/slice-query-options';
|
|
6
|
+
import type { ReplOutput } from '../commands/repl-main';
|
|
7
|
+
/** A flag that may follow the closing bracket of a criteria argument. */
|
|
8
|
+
export interface SliceFlag {
|
|
9
|
+
readonly flag: string;
|
|
10
|
+
/** what the flag does, kept to a few words as it is offered as a completion */
|
|
11
|
+
readonly describe: string;
|
|
12
|
+
/** the flag this one only makes sense with, if any */
|
|
13
|
+
readonly requires?: string;
|
|
14
|
+
/** the flags this one must not be combined with */
|
|
15
|
+
readonly conflicts?: readonly string[];
|
|
16
|
+
}
|
|
17
|
+
/** the flags every slicing query understands, see {@link sliceQueryOptionsParser} */
|
|
18
|
+
export declare const SharedSliceFlags: readonly [{
|
|
19
|
+
readonly flag: "i";
|
|
20
|
+
readonly describe: "inline sources";
|
|
21
|
+
readonly conflicts: readonly ["I"];
|
|
22
|
+
}, {
|
|
23
|
+
readonly flag: "c";
|
|
24
|
+
readonly describe: "include callees";
|
|
25
|
+
}, {
|
|
26
|
+
readonly flag: "I";
|
|
27
|
+
readonly describe: "inline all files";
|
|
28
|
+
readonly conflicts: readonly ["i"];
|
|
29
|
+
}, {
|
|
30
|
+
readonly flag: "B";
|
|
31
|
+
readonly describe: "banners";
|
|
32
|
+
readonly requires: "I";
|
|
33
|
+
}];
|
|
34
|
+
/** the flags of the `static-slice` query: a dice fixes both directions, so only it can be told to slice forward */
|
|
35
|
+
export declare const StaticSliceFlags: readonly [{
|
|
36
|
+
readonly flag: "f";
|
|
37
|
+
readonly describe: "slice forward";
|
|
38
|
+
}, {
|
|
39
|
+
readonly flag: "i";
|
|
40
|
+
readonly describe: "inline sources";
|
|
41
|
+
readonly conflicts: readonly ["I"];
|
|
42
|
+
}, {
|
|
43
|
+
readonly flag: "c";
|
|
44
|
+
readonly describe: "include callees";
|
|
45
|
+
}, {
|
|
46
|
+
readonly flag: "I";
|
|
47
|
+
readonly describe: "inline all files";
|
|
48
|
+
readonly conflicts: readonly ["i"];
|
|
49
|
+
}, {
|
|
50
|
+
readonly flag: "B";
|
|
51
|
+
readonly describe: "banners";
|
|
52
|
+
readonly requires: "I";
|
|
53
|
+
}];
|
|
5
54
|
/**
|
|
6
55
|
* Checks whether the given argument represents a slicing direction with an `f` suffix (in any flag order).
|
|
7
56
|
*/
|
|
8
57
|
export declare function sliceDirectionParser(argument: string): SliceDirection;
|
|
9
58
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
59
|
+
* The {@link SliceQueryOptions} the flag suffix of `argument` requests, see {@link SharedSliceFlags}.
|
|
60
|
+
* An absent flag is left out entirely, so the default of the query applies.
|
|
12
61
|
*/
|
|
13
|
-
export declare function
|
|
62
|
+
export declare function sliceQueryOptionsParser(argument: string): SliceQueryOptions;
|
|
63
|
+
/** the given flags and what they do, e.g. for a help text: `f (slice forward), B (banners, needs I)` */
|
|
64
|
+
export declare function describeSliceFlags(flags: readonly SliceFlag[]): string;
|
|
14
65
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
66
|
+
* Warns about the flags of `argument` that `flags` does not know (a `f` on a dice, a typo, ...) or that
|
|
67
|
+
* {@link SliceFlag#conflicts|conflict} with each other, as they are applied silently otherwise.
|
|
17
68
|
*/
|
|
18
|
-
export declare function
|
|
69
|
+
export declare function warnAboutSliceFlags(output: ReplOutput, argument: string, flags: readonly SliceFlag[]): void;
|
|
70
|
+
/**
|
|
71
|
+
* The R code of a query line, i.e. everything after the argument at `from`. The line is split at whitespace, so
|
|
72
|
+
* unquoted code arrives as several parts and only re-joining them yields all of it.
|
|
73
|
+
*/
|
|
74
|
+
export declare function queryLineCode(line: readonly string[], from?: number): string | undefined;
|
|
19
75
|
/**
|
|
20
76
|
* Parses a single slicing criterion from the given argument.
|
|
21
77
|
*/
|
|
@@ -24,9 +80,14 @@ export declare function sliceCriterionParser(argument: string | undefined): Slic
|
|
|
24
80
|
* Parses multiple slicing criteria from the given argument.
|
|
25
81
|
*/
|
|
26
82
|
export declare function sliceCriteriaParser(argument: string | undefined): SlicingCriteria | undefined;
|
|
83
|
+
/**
|
|
84
|
+
* The completions for the flag suffix of `arg`: every flag that fits the ones it carries already, plus a
|
|
85
|
+
* trailing space to move on to the code. Returns `undefined` while the criteria are still open.
|
|
86
|
+
*/
|
|
87
|
+
export declare function sliceFlagCompletions(arg: string, flags: readonly SliceFlag[]): CommandCompletions | undefined;
|
|
27
88
|
/**
|
|
28
89
|
* Tab-completer for query arguments of the form `(line@var;line@var;...)`.
|
|
29
|
-
* Guides the user step by step: `(` then digits then `@` then variable then `)
|
|
90
|
+
* Guides the user step by step: `(` then digits then `@` then variable then `)`, then the flags.
|
|
30
91
|
*/
|
|
31
92
|
export declare function criteriaQueryCompleter(line: readonly string[], startingNewArg: boolean, _config: FlowrConfig): CommandCompletions;
|
|
32
93
|
/**
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StaticSliceFlags = exports.SharedSliceFlags = void 0;
|
|
3
4
|
exports.sliceDirectionParser = sliceDirectionParser;
|
|
4
|
-
exports.
|
|
5
|
-
exports.
|
|
5
|
+
exports.sliceQueryOptionsParser = sliceQueryOptionsParser;
|
|
6
|
+
exports.describeSliceFlags = describeSliceFlags;
|
|
7
|
+
exports.warnAboutSliceFlags = warnAboutSliceFlags;
|
|
8
|
+
exports.queryLineCode = queryLineCode;
|
|
6
9
|
exports.sliceCriterionParser = sliceCriterionParser;
|
|
7
10
|
exports.sliceCriteriaParser = sliceCriteriaParser;
|
|
11
|
+
exports.sliceFlagCompletions = sliceFlagCompletions;
|
|
8
12
|
exports.criteriaQueryCompleter = criteriaQueryCompleter;
|
|
9
13
|
exports.diceCriteriaParser = diceCriteriaParser;
|
|
10
14
|
const slice_direction_1 = require("../../../util/slice-direction");
|
|
15
|
+
const core_1 = require("../core");
|
|
16
|
+
const ansi_1 = require("../../../util/text/ansi");
|
|
11
17
|
/**
|
|
12
18
|
* Splits `(criteria)flags` into its two parts, matching the closing bracket by depth: a criterion may well
|
|
13
19
|
* carry brackets of its own (the `(file-regex)` suffix of e.g. `2@x(tmp/.*)`), so the first `)` is not it.
|
|
@@ -31,6 +37,15 @@ function splitCriteriaArgument(argument) {
|
|
|
31
37
|
function sliceFlagSuffix(argument) {
|
|
32
38
|
return splitCriteriaArgument(argument)?.flags ?? '';
|
|
33
39
|
}
|
|
40
|
+
/** the flags every slicing query understands, see {@link sliceQueryOptionsParser} */
|
|
41
|
+
exports.SharedSliceFlags = [
|
|
42
|
+
{ flag: 'i', describe: 'inline sources', conflicts: ['I'] },
|
|
43
|
+
{ flag: 'c', describe: 'include callees' },
|
|
44
|
+
{ flag: 'I', describe: 'inline all files', conflicts: ['i'] },
|
|
45
|
+
{ flag: 'B', describe: 'banners', requires: 'I' }
|
|
46
|
+
];
|
|
47
|
+
/** the flags of the `static-slice` query: a dice fixes both directions, so only it can be told to slice forward */
|
|
48
|
+
exports.StaticSliceFlags = [{ flag: 'f', describe: 'slice forward' }, ...exports.SharedSliceFlags];
|
|
34
49
|
/**
|
|
35
50
|
* Checks whether the given argument represents a slicing direction with an `f` suffix (in any flag order).
|
|
36
51
|
*/
|
|
@@ -38,18 +53,49 @@ function sliceDirectionParser(argument) {
|
|
|
38
53
|
return sliceFlagSuffix(argument).includes('f') ? slice_direction_1.SliceDirection.Forward : slice_direction_1.SliceDirection.Backward;
|
|
39
54
|
}
|
|
40
55
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
56
|
+
* The {@link SliceQueryOptions} the flag suffix of `argument` requests, see {@link SharedSliceFlags}.
|
|
57
|
+
* An absent flag is left out entirely, so the default of the query applies.
|
|
43
58
|
*/
|
|
44
|
-
function
|
|
45
|
-
|
|
59
|
+
function sliceQueryOptionsParser(argument) {
|
|
60
|
+
const flags = sliceFlagSuffix(argument);
|
|
61
|
+
return {
|
|
62
|
+
...(flags.includes('i') ? { inlineSources: true } : {}),
|
|
63
|
+
...(flags.includes('I') ? { inlineFull: flags.includes('B') ? 'banner' : true } : {}),
|
|
64
|
+
...(flags.includes('c') ? { includeCallees: true } : {})
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/** the given flags and what they do, e.g. for a help text: `f (slice forward), B (banners, needs I)` */
|
|
68
|
+
function describeSliceFlags(flags) {
|
|
69
|
+
return flags.map(f => `${f.flag} (${f.describe}${f.requires ? `, needs ${f.requires}` : ''})`).join(', ');
|
|
70
|
+
}
|
|
71
|
+
function warn(output, message) {
|
|
72
|
+
output.stderr(output.formatter.format(message, { color: 3 /* Colors.Yellow */, effect: ansi_1.ColorEffect.Foreground }));
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Warns about the flags of `argument` that `flags` does not know (a `f` on a dice, a typo, ...) or that
|
|
76
|
+
* {@link SliceFlag#conflicts|conflict} with each other, as they are applied silently otherwise.
|
|
77
|
+
*/
|
|
78
|
+
function warnAboutSliceFlags(output, argument, flags) {
|
|
79
|
+
const given = [...new Set([...sliceFlagSuffix(argument)])];
|
|
80
|
+
const known = new Map(flags.map(f => [f.flag, f]));
|
|
81
|
+
const unknown = given.filter(f => !known.has(f));
|
|
82
|
+
if (unknown.length > 0) {
|
|
83
|
+
warn(output, `Ignoring unknown flag${unknown.length > 1 ? 's' : ''} ${unknown.map(f => `'${f}'`).join(', ')}. Known flags: ${describeSliceFlags(flags)}.`);
|
|
84
|
+
}
|
|
85
|
+
for (const [i, f] of given.entries()) {
|
|
86
|
+
const clash = known.get(f)?.conflicts?.filter(c => given.indexOf(c) > i) ?? [];
|
|
87
|
+
if (clash.length > 0) {
|
|
88
|
+
warn(output, `The flag '${f}' cannot be combined with ${clash.map(c => `'${c}'`).join(', ')}, the latter wins.`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
46
91
|
}
|
|
47
92
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
93
|
+
* The R code of a query line, i.e. everything after the argument at `from`. The line is split at whitespace, so
|
|
94
|
+
* unquoted code arrives as several parts and only re-joining them yields all of it.
|
|
50
95
|
*/
|
|
51
|
-
function
|
|
52
|
-
|
|
96
|
+
function queryLineCode(line, from = 1) {
|
|
97
|
+
const code = line.slice(from).join(' ').trim();
|
|
98
|
+
return code.length > 0 ? code : undefined;
|
|
53
99
|
}
|
|
54
100
|
/**
|
|
55
101
|
* Parses a single slicing criterion from the given argument.
|
|
@@ -67,9 +113,31 @@ function sliceCriteriaParser(argument) {
|
|
|
67
113
|
function lastCriterionFragment(arg) {
|
|
68
114
|
return arg.slice(Math.max(arg.indexOf('(') + 1, arg.lastIndexOf(';') + 1));
|
|
69
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* The completions for the flag suffix of `arg`: every flag that fits the ones it carries already, plus a
|
|
118
|
+
* trailing space to move on to the code. Returns `undefined` while the criteria are still open.
|
|
119
|
+
*/
|
|
120
|
+
function sliceFlagCompletions(arg, flags) {
|
|
121
|
+
const split = splitCriteriaArgument(arg);
|
|
122
|
+
if (!split) {
|
|
123
|
+
return undefined;
|
|
124
|
+
}
|
|
125
|
+
const has = (flag) => split.flags.includes(flag);
|
|
126
|
+
const offered = flags.filter(f => !has(f.flag)
|
|
127
|
+
&& (f.requires === undefined || has(f.requires))
|
|
128
|
+
&& !f.conflicts?.some(has));
|
|
129
|
+
return {
|
|
130
|
+
completions: [...offered.map(f => arg + f.flag), arg + ' '],
|
|
131
|
+
labels: new Map([
|
|
132
|
+
...offered.map(f => [arg + f.flag, (0, core_1.describeCompletion)(f.flag, f.describe)]),
|
|
133
|
+
[arg + ' ', (0, core_1.describeCompletion)('<space>', 'then the code')]
|
|
134
|
+
]),
|
|
135
|
+
argumentPart: arg
|
|
136
|
+
};
|
|
137
|
+
}
|
|
70
138
|
/**
|
|
71
139
|
* Tab-completer for query arguments of the form `(line@var;line@var;...)`.
|
|
72
|
-
* Guides the user step by step: `(` then digits then `@` then variable then `)
|
|
140
|
+
* Guides the user step by step: `(` then digits then `@` then variable then `)`, then the flags.
|
|
73
141
|
*/
|
|
74
142
|
function criteriaQueryCompleter(line, startingNewArg, _config) {
|
|
75
143
|
if (line.length === 0) {
|
|
@@ -79,8 +147,9 @@ function criteriaQueryCompleter(line, startingNewArg, _config) {
|
|
|
79
147
|
return { completions: [] };
|
|
80
148
|
}
|
|
81
149
|
const arg = line[0];
|
|
82
|
-
|
|
83
|
-
|
|
150
|
+
const flags = sliceFlagCompletions(arg, exports.StaticSliceFlags);
|
|
151
|
+
if (flags) {
|
|
152
|
+
return flags;
|
|
84
153
|
}
|
|
85
154
|
const fragment = lastCriterionFragment(arg);
|
|
86
155
|
if (/^\d+$/.test(fragment)) {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { FlowrConfig } from '../../config';
|
|
2
|
+
import type { ReplOutput } from './commands/repl-main';
|
|
3
|
+
/** Prefix of an input that is to be re-analyzed whenever the file changes, the counterpart of {@link fileProtocol}. */
|
|
4
|
+
export declare const watchProtocol = "watch://";
|
|
5
|
+
/** The input to analyze: one that looks like a path gets the {@link fileProtocol}, unless the repl config says not to. */
|
|
6
|
+
export declare function handlePathLikeInput(output: ReplOutput, input: string, config: FlowrConfig): string;
|