@eagleoutice/flowr 2.16.6 → 2.16.7
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 +21 -15
- package/abstract-interpretation/data-frame/dataframe-semantics.d.ts +2 -0
- package/abstract-interpretation/data-frame/dataframe-semantics.js +3 -1
- package/abstract-interpretation/data-frame/resolve-args.d.ts +1 -7
- package/abstract-interpretation/data-frame/resolve-args.js +2 -11
- package/cli/repl/commands/repl-cfg.js +5 -19
- package/cli/repl/commands/repl-code-command.d.ts +10 -0
- package/cli/repl/commands/repl-code-command.js +18 -0
- package/cli/repl/commands/repl-dataflow.js +34 -59
- package/cli/repl/commands/repl-normalize.js +24 -41
- package/cli/repl/commands/repl-query.js +10 -17
- package/config.js +3 -3
- package/control-flow/cfg-dead-code.js +15 -2
- package/control-flow/useless-loop.js +1 -2
- package/data/r-base-packages.generated.d.ts +1 -1
- package/data/r-base-packages.generated.js +3 -3
- package/dataflow/environments/ambient-state-name.d.ts +80 -0
- package/dataflow/environments/ambient-state-name.js +113 -0
- package/dataflow/environments/built-in-eval-name.d.ts +3 -1
- package/dataflow/environments/built-in-eval-name.js +2 -0
- package/dataflow/environments/built-in-props.d.ts +27 -7
- package/dataflow/environments/built-in-props.js +59 -44
- package/dataflow/environments/built-in.d.ts +5 -2
- package/dataflow/environments/built-in.js +22 -5
- package/dataflow/environments/default-builtin-config.d.ts +538 -14
- package/dataflow/environments/default-builtin-config.js +189 -123
- package/dataflow/environments/environment.d.ts +7 -1
- package/dataflow/environments/environment.js +19 -1
- package/dataflow/environments/identifier.d.ts +11 -0
- package/dataflow/eval/resolve/alias-tracking.d.ts +13 -3
- package/dataflow/eval/resolve/alias-tracking.js +66 -37
- package/dataflow/eval/resolve/resolve-argument.d.ts +4 -2
- package/dataflow/eval/resolve/resolve-argument.js +23 -11
- package/dataflow/eval/resolve/resolve.d.ts +5 -0
- package/dataflow/eval/resolve/resolve.js +25 -3
- package/dataflow/eval/values/r-value.d.ts +4 -2
- package/dataflow/eval/values/r-value.js +3 -1
- package/dataflow/eval/values/string/string-constants.d.ts +7 -1
- package/dataflow/eval/values/string/string-constants.js +38 -36
- package/dataflow/extractor.js +105 -2
- package/dataflow/fn/argument-roles.js +22 -8
- package/dataflow/fn/function-semantics.d.ts +3 -2
- package/dataflow/fn/strict-function.js +13 -2
- package/dataflow/graph/df-helper.d.ts +14 -1
- package/dataflow/graph/df-helper.js +37 -4
- package/dataflow/graph/graph.d.ts +6 -0
- package/dataflow/graph/graph.js +6 -0
- package/dataflow/internal/linker.d.ts +4 -1
- package/dataflow/internal/linker.js +11 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.d.ts +41 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.js +88 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +19 -44
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +125 -158
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +6 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +35 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +10 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +4 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +6 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +3 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +7 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +21 -12
- 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 +8 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +3 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +5 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-local.js +5 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +11 -12
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +6 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-string-template.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +7 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +42 -0
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +11 -0
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +29 -4
- package/dataflow/internal/process/functions/call/common.js +3 -4
- package/dataflow/internal/process/functions/call/deferred.d.ts +3 -2
- package/dataflow/internal/process/functions/call/deferred.js +17 -9
- package/dataflow/internal/process/functions/call/quoted.js +1 -1
- package/documentation/doc-capabilities.js +3 -2
- package/documentation/doc-readme.js +1 -2
- package/documentation/doc-util/doc-dfg.js +2 -2
- package/documentation/doc-util/doc-query.d.ts +3 -1
- package/documentation/doc-util/doc-query.js +4 -4
- package/documentation/wiki-create-linting-rules.js +1 -1
- package/documentation/wiki-linter.js +16 -206
- package/documentation/wiki-linting-and-testing.js +31 -64
- package/documentation/wiki-query.js +41 -0
- package/index.d.ts +1 -0
- package/index.js +5 -1
- package/linter/linter-format.d.ts +6 -0
- package/linter/linter-format.js +10 -0
- package/linter/linter-rules.d.ts +155 -103
- package/linter/linter-rules.js +2 -0
- package/linter/linter-util.d.ts +23 -0
- package/linter/linter-util.js +58 -0
- package/linter/rules/absolute-path.d.ts +2 -2
- package/linter/rules/absolute-path.js +1 -4
- package/linter/rules/cmd-check/bogus-return.d.ts +2 -2
- package/linter/rules/cmd-check/bogus-return.js +3 -7
- package/linter/rules/cmd-check/call-arguments.d.ts +2 -2
- package/linter/rules/cmd-check/class-string-comparison.d.ts +2 -2
- package/linter/rules/cmd-check/class-string-comparison.js +3 -7
- package/linter/rules/cmd-check/cmd-check-util.d.ts +8 -9
- package/linter/rules/cmd-check/cmd-check-util.js +14 -26
- package/linter/rules/cmd-check/compiled-code.d.ts +8 -3
- package/linter/rules/cmd-check/compiled-code.js +3 -13
- package/linter/rules/cmd-check/dependency-declaration.d.ts +2 -2
- package/linter/rules/cmd-check/dependency-declaration.js +6 -7
- package/linter/rules/cmd-check/description-metadata.d.ts +4 -4
- package/linter/rules/cmd-check/documentation-mismatch.d.ts +2 -2
- package/linter/rules/cmd-check/documentation-mismatch.js +4 -11
- package/linter/rules/cmd-check/file-checks.d.ts +19 -6
- package/linter/rules/cmd-check/file-checks.js +13 -5
- package/linter/rules/cmd-check/foreign-function-calls.d.ts +2 -2
- package/linter/rules/cmd-check/global-environment-modification.d.ts +2 -2
- package/linter/rules/cmd-check/global-environment-modification.js +3 -2
- package/linter/rules/cmd-check/namespace-tampering.d.ts +2 -2
- package/linter/rules/cmd-check/namespace-tampering.js +9 -9
- package/linter/rules/cmd-check/non-ascii-code.d.ts +2 -2
- package/linter/rules/cmd-check/package-data.d.ts +11 -5
- package/linter/rules/cmd-check/package-data.js +5 -12
- package/linter/rules/cmd-check/package-files.js +4 -10
- package/linter/rules/cmd-check/package-hooks.d.ts +2 -2
- package/linter/rules/cmd-check/package-hooks.js +10 -8
- package/linter/rules/cmd-check/package-metafiles.d.ts +8 -3
- package/linter/rules/cmd-check/package-metafiles.js +3 -12
- package/linter/rules/cmd-check/package-runtime.d.ts +18 -5
- package/linter/rules/cmd-check/package-runtime.js +64 -20
- package/linter/rules/cmd-check/package-structure.d.ts +11 -5
- package/linter/rules/cmd-check/package-structure.js +4 -12
- package/linter/rules/cmd-check/rd-files.d.ts +8 -3
- package/linter/rules/cmd-check/rd-files.js +4 -14
- package/linter/rules/cmd-check/s-three-method-consistency.d.ts +2 -2
- package/linter/rules/cmd-check/s-three-method-consistency.js +3 -4
- package/linter/rules/cmd-check/true-false-abbreviation.d.ts +2 -2
- package/linter/rules/dataframe-access-validation.d.ts +2 -2
- package/linter/rules/dataframe-access-validation.js +5 -8
- package/linter/rules/dead-code.d.ts +5 -4
- package/linter/rules/dead-code.js +25 -14
- package/linter/rules/deprecated-functions.d.ts +3 -3
- package/linter/rules/deprecated-functions.js +16 -23
- package/linter/rules/file-path-validity.d.ts +2 -2
- package/linter/rules/file-path-validity.js +3 -6
- package/linter/rules/function-finder-util.d.ts +3 -3
- package/linter/rules/function-finder-util.js +7 -14
- package/linter/rules/namespace-access.d.ts +2 -2
- package/linter/rules/namespace-access.js +6 -9
- package/linter/rules/naming-convention.d.ts +2 -2
- package/linter/rules/naming-convention.js +1 -4
- package/linter/rules/network-functions.d.ts +3 -3
- package/linter/rules/no-leaked-credentials.d.ts +2 -2
- package/linter/rules/no-leaked-credentials.js +1 -4
- package/linter/rules/overwritten-file.d.ts +38 -0
- package/linter/rules/overwritten-file.js +102 -0
- package/linter/rules/problematic-inputs.d.ts +16 -6
- package/linter/rules/problematic-inputs.js +78 -34
- package/linter/rules/roxygen-arguments.d.ts +2 -2
- package/linter/rules/roxygen-arguments.js +1 -4
- package/linter/rules/seeded-randomness.d.ts +3 -3
- package/linter/rules/seeded-randomness.js +6 -23
- package/linter/rules/software-has-license.d.ts +2 -2
- package/linter/rules/software-has-license.js +1 -4
- package/linter/rules/software-has-tests.d.ts +2 -2
- package/linter/rules/software-has-tests.js +1 -4
- package/linter/rules/stop-with-call-arg.d.ts +2 -2
- package/linter/rules/stop-with-call-arg.js +4 -11
- package/linter/rules/syntactically-valid.d.ts +4 -2
- package/linter/rules/syntactically-valid.js +29 -10
- package/linter/rules/unclosed-connection.d.ts +2 -2
- package/linter/rules/unclosed-connection.js +1 -4
- package/linter/rules/undefined-symbol.d.ts +2 -2
- package/linter/rules/undefined-symbol.js +25 -22
- package/linter/rules/unescaped-arguments.d.ts +2 -2
- package/linter/rules/unescaped-arguments.js +1 -4
- package/linter/rules/unused-definition.d.ts +2 -2
- package/linter/rules/unused-definition.js +37 -25
- package/linter/rules/unused-import.d.ts +2 -2
- package/linter/rules/unused-import.js +9 -14
- package/linter/rules/useless-loop.d.ts +7 -6
- package/linter/rules/useless-loop.js +4 -8
- package/package.json +5 -3
- package/project/cache/flowr-analyzer-cache.d.ts +2 -0
- package/project/cache/flowr-analyzer-cache.js +15 -11
- package/project/context/flowr-analyzer-files-context.d.ts +3 -0
- package/project/context/flowr-analyzer-files-context.js +6 -0
- package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +6 -1
- package/project/plugins/file-plugins/files/flowr-jupyter-file.js +35 -0
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +2 -1
- package/project/plugins/file-plugins/files/flowr-rsession-file.d.ts +26 -0
- package/project/plugins/file-plugins/files/flowr-rsession-file.js +44 -0
- package/project/plugins/file-plugins/files/r-session.d.ts +20 -0
- package/project/plugins/file-plugins/files/r-session.js +58 -0
- package/project/plugins/file-plugins/files/recorded-runs.d.ts +18 -0
- package/project/plugins/file-plugins/files/recorded-runs.js +8 -0
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rsession-file-plugin.d.ts +20 -0
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rsession-file-plugin.js +28 -0
- package/project/plugins/plugin-registry.d.ts +2 -1
- package/project/plugins/plugin-registry.js +2 -0
- package/project/sigdb/spec-query.d.ts +73 -0
- package/project/sigdb/spec-query.js +339 -0
- package/queries/base-query-format.d.ts +1 -1
- package/queries/base-query-format.js +2 -2
- package/queries/catalog/absint-query/absint-query-executor.js +3 -6
- package/queries/catalog/call-context-query/call-context-query-executor.d.ts +1 -0
- package/queries/catalog/call-context-query/call-context-query-executor.js +113 -73
- package/queries/catalog/call-graph-query/call-graph-query-executor.js +2 -3
- package/queries/catalog/cluster-query/cluster-query-executor.js +2 -3
- package/queries/catalog/config-query/config-query-format.d.ts +0 -1
- package/queries/catalog/config-query/config-query-format.js +1 -2
- package/queries/catalog/control-flow-query/control-flow-query-executor.js +2 -3
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.js +2 -4
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.d.ts +0 -1
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.js +1 -2
- package/queries/catalog/dataflow-query/dataflow-query-executor.js +2 -3
- package/queries/catalog/dependencies-query/dependencies-query-executor.d.ts +7 -0
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +72 -42
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +24 -6
- package/queries/catalog/dependencies-query/dependencies-query-format.js +108 -3
- package/queries/catalog/dependencies-query/function-info/function-info.d.ts +6 -1
- package/queries/catalog/dependencies-query/function-info/read-functions.js +6 -6
- package/queries/catalog/dependencies-query/function-info/write-functions.js +13 -7
- package/queries/catalog/dependencies-query/implicit-echo.js +21 -7
- package/queries/catalog/dice-query/dice-query-executor.js +2 -3
- package/queries/catalog/does-call-query/does-call-query-executor.js +2 -3
- package/queries/catalog/files-query/files-query-executor.js +2 -3
- package/queries/catalog/function-info-query/function-info-query-executor.js +2 -1
- package/queries/catalog/function-info-query/function-info-query-format.d.ts +0 -2
- package/queries/catalog/function-info-query/function-info-query-format.js +1 -2
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +3 -2
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +0 -2
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +1 -2
- package/queries/catalog/happens-before-query/happens-before-query-executor.js +2 -3
- package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +0 -1
- package/queries/catalog/happens-before-query/happens-before-query-format.js +1 -2
- package/queries/catalog/id-map-query/id-map-query-executor.js +2 -3
- package/queries/catalog/id-map-query/id-map-query-format.d.ts +0 -1
- package/queries/catalog/id-map-query/id-map-query-format.js +1 -2
- package/queries/catalog/input-sources-query/input-sources-query-executor.js +3 -4
- package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +2 -1
- package/queries/catalog/input-sources-query/simple-input-classifier.js +60 -13
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.js +2 -3
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-executor.js +2 -3
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.js +2 -1
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.d.ts +3 -2
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +1 -7
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +6 -9
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +8 -33
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.d.ts +3 -2
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.js +1 -7
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.d.ts +6 -7
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.js +8 -31
- package/queries/catalog/linter-query/linter-query-executor.js +2 -3
- package/queries/catalog/location-map-query/location-map-query-executor.js +2 -3
- package/queries/catalog/location-map-query/location-map-query-format.d.ts +0 -1
- package/queries/catalog/location-map-query/location-map-query-format.js +1 -2
- package/queries/catalog/normalized-ast-query/normalized-ast-query-executor.js +2 -3
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +0 -1
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.js +1 -2
- package/queries/catalog/origin-query/origin-query-executor.d.ts +0 -5
- package/queries/catalog/origin-query/origin-query-executor.js +3 -11
- package/queries/catalog/project-query/project-query-executor.js +23 -7
- package/queries/catalog/project-query/project-query-format.d.ts +5 -0
- package/queries/catalog/project-query/project-query-format.js +20 -2
- package/queries/catalog/provenance-query/provenance-query-executor.js +2 -3
- package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +2 -3
- package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +0 -1
- package/queries/catalog/resolve-value-query/resolve-value-query-format.js +1 -2
- package/queries/catalog/search-query/search-query-executor.js +2 -3
- package/queries/catalog/signature-query/signature-query-executor.js +39 -0
- package/queries/catalog/signature-query/signature-query-format.d.ts +7 -1
- package/queries/catalog/signature-query/signature-query-format.js +15 -1
- package/queries/catalog/signature-query/signature-query-render.js +2 -1
- package/queries/catalog/static-slice-query/static-slice-query-executor.js +2 -3
- package/queries/query-function-property.d.ts +28 -0
- package/queries/query-function-property.js +48 -0
- package/queries/query-meta.d.ts +3 -0
- package/queries/query-meta.js +8 -0
- package/queries/query.d.ts +13 -18
- package/r-bridge/lang-4.x/ast/model/processing/decorate.d.ts +2 -2
- package/r-bridge/lang-4.x/ast/model/processing/decorate.js +4 -3
- package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +6 -0
- package/r-bridge/lang-4.x/ast/model/processing/node-id.js +9 -0
- package/r-bridge/lang-4.x/ast/model/syntax-version.d.ts +8 -0
- package/r-bridge/lang-4.x/ast/model/syntax-version.js +49 -0
- package/r-bridge/lang-4.x/ast/model/type.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/type.js +3 -0
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-parameter.js +4 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-single-node.js +1 -0
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +1 -1
- package/reconstruct/reconstruct.js +35 -1
- package/search/search-executor/search-generators.js +1 -1
- package/slicing/static/fingerprint.js +7 -3
- package/slicing/static/static-slicer.js +6 -0
- package/util/assert.js +2 -2
- package/util/collections/arrays.d.ts +4 -0
- package/util/collections/arrays.js +11 -0
- package/util/collections/defaultmap.d.ts +5 -1
- package/util/collections/defaultmap.js +6 -1
- package/util/files.js +26 -5
- package/util/flowr-version.d.ts +10 -0
- package/util/flowr-version.js +20 -0
- package/util/glob.js +6 -4
- package/util/r-regex.d.ts +6 -0
- package/util/r-regex.js +17 -0
- package/util/text/args.d.ts +5 -0
- package/util/text/args.js +28 -22
- package/util/text/name-rank.d.ts +2 -0
- package/util/text/name-rank.js +3 -1
- package/util/text/regex.d.ts +10 -0
- package/util/text/regex.js +29 -0
- package/util/version.d.ts +1 -6
- package/util/version.js +6 -14
- package/documentation/doc-util/doc-functions.d.ts +0 -24
- package/documentation/doc-util/doc-functions.js +0 -65
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/** R console transcripts: `> ` input lines, `+ ` continuations, and recorded output in between */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.codeOfInput = exports.PromptWidth = void 0;
|
|
5
|
+
exports.isRSession = isRSession;
|
|
6
|
+
exports.parseRSession = parseRSession;
|
|
7
|
+
exports.sessionAsScript = sessionAsScript;
|
|
8
|
+
exports.recordedRuns = recordedRuns;
|
|
9
|
+
const SessionName = /\.(rout|rsession|rconsole)$/i;
|
|
10
|
+
const Prompt = /^[>+](?: |$)/;
|
|
11
|
+
const Command = /^>(?: |$)/;
|
|
12
|
+
const Continuation = /^\+(?: |$)/;
|
|
13
|
+
const LineBreak = /\r\n|\r|\n/;
|
|
14
|
+
/** the width of `> ` and `+ `, which the code of a line starts behind */
|
|
15
|
+
exports.PromptWidth = 2;
|
|
16
|
+
/** whether a file is a console transcript, by its name or by its first non-blank line starting with a prompt */
|
|
17
|
+
function isRSession(name, text) {
|
|
18
|
+
return SessionName.test(name) || (text.split(LineBreak).find(line => line.trim() !== '') ?? '').startsWith('> ');
|
|
19
|
+
}
|
|
20
|
+
/** the transcript as runs of input (a command with its continuations) and output; blank lines are output */
|
|
21
|
+
function parseRSession(text) {
|
|
22
|
+
const segments = [];
|
|
23
|
+
for (const [at, line] of text.split(LineBreak).entries()) {
|
|
24
|
+
const last = segments.at(-1);
|
|
25
|
+
if (Continuation.test(line) && last?.kind === 'input') {
|
|
26
|
+
last.lines.push(line);
|
|
27
|
+
}
|
|
28
|
+
else if (Command.test(line)) {
|
|
29
|
+
segments.push({ kind: 'input', lines: [line], firstLine: at + 1 });
|
|
30
|
+
}
|
|
31
|
+
else if (last?.kind === 'output') {
|
|
32
|
+
last.lines.push(line);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
segments.push({ kind: 'output', lines: [line], firstLine: at + 1 });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return segments;
|
|
39
|
+
}
|
|
40
|
+
/** the code of an input line, behind its prompt */
|
|
41
|
+
const codeOfInput = (line) => Prompt.test(line) ? line.slice(exports.PromptWidth) : line;
|
|
42
|
+
exports.codeOfInput = codeOfInput;
|
|
43
|
+
/** the script flowR reads: prompts blanked to the same width, output as comments, every line where it was */
|
|
44
|
+
function sessionAsScript(text) {
|
|
45
|
+
return parseRSession(text).flatMap(({ kind, lines }) => kind === 'input'
|
|
46
|
+
? lines.map(line => ' '.repeat(Math.min(exports.PromptWidth, line.length)) + (0, exports.codeOfInput)(line))
|
|
47
|
+
: lines.map(line => line.trim() === '' ? line : `# ${line}`)).join('\n');
|
|
48
|
+
}
|
|
49
|
+
/** the commands of a transcript with the output recorded below each */
|
|
50
|
+
function recordedRuns(text) {
|
|
51
|
+
const segments = parseRSession(text);
|
|
52
|
+
return segments.flatMap((s, at) => s.kind === 'input' ? [{
|
|
53
|
+
line: s.firstLine,
|
|
54
|
+
code: s.lines.map(exports.codeOfInput).join('\n'),
|
|
55
|
+
output: segments[at + 1]?.kind === 'output' ? segments[at + 1].lines.join('\n').trim() : ''
|
|
56
|
+
}] : []);
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=r-session.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** a command (or several lines of code) with the output a notebook or transcript recorded for it */
|
|
2
|
+
export interface RecordedRun {
|
|
3
|
+
/** 1-based line the code starts at in the file, if the format has lines */
|
|
4
|
+
readonly line?: number;
|
|
5
|
+
readonly code: string;
|
|
6
|
+
readonly output: string;
|
|
7
|
+
/** how many plots the run drew, if the format records images */
|
|
8
|
+
readonly plots?: number;
|
|
9
|
+
/** the recorded plots as data URLs, if the format records images */
|
|
10
|
+
readonly images?: readonly string[];
|
|
11
|
+
}
|
|
12
|
+
/** a file that keeps the output of the code it holds, like an R console transcript or a Jupyter notebook */
|
|
13
|
+
export interface RecordsRuns {
|
|
14
|
+
/** the runs in the order of the file, empty if the file records none (or cannot be read) */
|
|
15
|
+
recorded(): readonly RecordedRun[];
|
|
16
|
+
}
|
|
17
|
+
/** whether a file records the output of its code, whichever format it is */
|
|
18
|
+
export declare function recordsRuns<F extends object>(file: F | undefined): file is F & RecordsRuns;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.recordsRuns = recordsRuns;
|
|
4
|
+
/** whether a file records the output of its code, whichever format it is */
|
|
5
|
+
function recordsRuns(file) {
|
|
6
|
+
return file !== undefined && typeof file.recorded === 'function';
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=recorded-runs.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { SemVer } from 'semver';
|
|
2
|
+
import type { FlowrAnalyzerContext } from '../../../context/flowr-analyzer-context';
|
|
3
|
+
import type { FlowrFileProvider } from '../../../context/flowr-file';
|
|
4
|
+
import { FlowrAnalyzerPatternFilePlugin } from '../flowr-analyzer-file-plugin';
|
|
5
|
+
import { FlowrRSessionFile } from '../files/flowr-rsession-file';
|
|
6
|
+
export declare const RSessionPattern: RegExp;
|
|
7
|
+
/**
|
|
8
|
+
* The plugin provides support for R console transcripts (`.Rout`, `.Rout.save`)
|
|
9
|
+
*/
|
|
10
|
+
export declare class FlowrAnalyzerRSessionFilePlugin extends FlowrAnalyzerPatternFilePlugin {
|
|
11
|
+
readonly name = "rsession-file-plugin";
|
|
12
|
+
readonly description = "Parses R console transcripts";
|
|
13
|
+
readonly version: SemVer;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a new instance of the transcript file plugin.
|
|
16
|
+
* @param filePattern - The pattern to identify transcripts, see {@link RSessionPattern} for the default pattern.
|
|
17
|
+
*/
|
|
18
|
+
constructor(filePattern?: RegExp);
|
|
19
|
+
protected process(_ctx: FlowrAnalyzerContext, arg: FlowrFileProvider<string>): FlowrRSessionFile;
|
|
20
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FlowrAnalyzerRSessionFilePlugin = exports.RSessionPattern = void 0;
|
|
4
|
+
const semver_1 = require("semver");
|
|
5
|
+
const flowr_analyzer_file_plugin_1 = require("../flowr-analyzer-file-plugin");
|
|
6
|
+
const flowr_rsession_file_1 = require("../files/flowr-rsession-file");
|
|
7
|
+
/* `R CMD check` compares a test against its `.Rout.save` */
|
|
8
|
+
exports.RSessionPattern = /\.(rout|rout\.save|rsession|rconsole)$/i;
|
|
9
|
+
/**
|
|
10
|
+
* The plugin provides support for R console transcripts (`.Rout`, `.Rout.save`)
|
|
11
|
+
*/
|
|
12
|
+
class FlowrAnalyzerRSessionFilePlugin extends flowr_analyzer_file_plugin_1.FlowrAnalyzerPatternFilePlugin {
|
|
13
|
+
name = 'rsession-file-plugin';
|
|
14
|
+
description = 'Parses R console transcripts';
|
|
15
|
+
version = new semver_1.SemVer('0.1.0');
|
|
16
|
+
/**
|
|
17
|
+
* Creates a new instance of the transcript file plugin.
|
|
18
|
+
* @param filePattern - The pattern to identify transcripts, see {@link RSessionPattern} for the default pattern.
|
|
19
|
+
*/
|
|
20
|
+
constructor(filePattern = exports.RSessionPattern) {
|
|
21
|
+
super(filePattern);
|
|
22
|
+
}
|
|
23
|
+
process(_ctx, arg) {
|
|
24
|
+
return flowr_rsession_file_1.FlowrRSessionFile.from(arg);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.FlowrAnalyzerRSessionFilePlugin = FlowrAnalyzerRSessionFilePlugin;
|
|
28
|
+
//# sourceMappingURL=flowr-analyzer-rsession-file-plugin.js.map
|
|
@@ -8,6 +8,7 @@ import { FlowrAnalyzerLoadingOrderDescriptionFilePlugin } from './loading-order-
|
|
|
8
8
|
import { FlowrAnalyzerLoadingOrderImplicitSourcesPlugin } from './loading-order-plugins/flowr-analyzer-loading-order-implicit-sources-plugin';
|
|
9
9
|
import { FlowrAnalyzerRmdFilePlugin } from './file-plugins/notebooks/flowr-analyzer-rmd-file-plugin';
|
|
10
10
|
import { FlowrAnalyzerQmdFilePlugin } from './file-plugins/notebooks/flowr-analyzer-qmd-file-plugin';
|
|
11
|
+
import { FlowrAnalyzerRSessionFilePlugin } from './file-plugins/notebooks/flowr-analyzer-rsession-file-plugin';
|
|
11
12
|
import { FlowrAnalyzerJupyterFilePlugin } from './file-plugins/notebooks/flowr-analyzer-jupyter-file-plugin';
|
|
12
13
|
import { FlowrAnalyzerNamespaceFilesPlugin } from './file-plugins/flowr-analyzer-namespace-files-plugin';
|
|
13
14
|
import { FlowrAnalyzerPackageVersionsNamespaceFilePlugin } from './package-version-plugins/flowr-analyzer-package-versions-namespace-file-plugin';
|
|
@@ -33,7 +34,7 @@ import { FlowrAnalyzerLoadingOrderIncludedFilesPlugin } from './loading-order-pl
|
|
|
33
34
|
/**
|
|
34
35
|
* The built-in Flowr Analyzer plugins that are always available.
|
|
35
36
|
*/
|
|
36
|
-
export declare const BuiltInPlugins: [["file:description", typeof FlowrAnalyzerDescriptionFilePlugin], ["versions:description", typeof FlowrAnalyzerPackageVersionsDescriptionFilePlugin], ["versions:sigdb", typeof FlowrAnalyzerPackageVersionsSigDbPlugin], ["versions:library", typeof FlowrAnalyzerPackageVersionsLibraryPlugin], ["versions:renv", typeof FlowrAnalyzerPackageVersionsRenvPlugin], ["versions:rv", typeof FlowrAnalyzerPackageVersionsRvPlugin], ["versions:uvr", typeof FlowrAnalyzerPackageVersionsUvrPlugin], ["versions:packrat", typeof FlowrAnalyzerPackageVersionsPackratPlugin], ["versions:session-info", typeof FlowrAnalyzerPackageVersionsSessionInfoPlugin], ["loading-order:description", typeof FlowrAnalyzerLoadingOrderDescriptionFilePlugin], ["loading-order:implicit-sources", typeof FlowrAnalyzerLoadingOrderImplicitSourcesPlugin], ["loading-order:rprofile", typeof FlowrAnalyzerLoadingOrderRprofilePlugin], ["loading-order:included-files", typeof FlowrAnalyzerLoadingOrderIncludedFilesPlugin], ["meta:description", typeof FlowrAnalyzerMetaDescriptionFilePlugin], ["meta:rproject", typeof FlowrAnalyzerMetaRProjectFilePlugin], ["meta:uvr", typeof FlowrAnalyzerMetaUvrManifestFilePlugin], ["file-roles:vignette", typeof FlowrAnalyzerMetaVignetteFilesPlugin], ["file-roles:test", typeof FlowrAnalyzerMetaTestFilesPlugin], ["file-roles:inst", typeof FlowrAnalyzerMetaInstFilesPlugin], ["file:rmd", typeof FlowrAnalyzerRmdFilePlugin], ["file:qmd", typeof FlowrAnalyzerQmdFilePlugin], ["file:rnw", typeof FlowrAnalyzerSweaveFilePlugin], ["file:ipynb", typeof FlowrAnalyzerJupyterFilePlugin], ["file:namespace", typeof FlowrAnalyzerNamespaceFilesPlugin], ["versions:namespace", typeof FlowrAnalyzerPackageVersionsNamespaceFilePlugin], ["file:news", typeof FlowrAnalyzerNewsFilePlugin], ["file:rd-macros", typeof FlowrAnalyzerRdMacroFilePlugin], ["file:rd", typeof FlowrAnalyzerRdFilePlugin], ["file:rd-index", typeof FlowrAnalyzerRdIndexFilePlugin], ["file:rd-topics", typeof FlowrAnalyzerRdTopicIndexFilePlugin], ["file:rd-meta", typeof FlowrAnalyzerRdMetaFilePlugin], ["file:datalist", typeof FlowrAnalyzerDataListFilePlugin], ["file:sysdata", typeof FlowrAnalyzerSysdataFilePlugin], ["file:rda", typeof FlowrAnalyzerRdaFilePlugin], ["file:license", typeof FlowrAnalyzerLicenseFilePlugin], ["file:virtualenv", typeof FlowrAnalyzerVirtualEnvFilePlugin], ["file:rproject", typeof FlowrAnalyzerRProjectFilePlugin], ["file:uvr", typeof FlowrAnalyzerUvrManifestFilePlugin], ["file:rprofile", typeof FlowrAnalyzerRprofileFilePlugin], ["project-discovery:gitignore", typeof FlowrAnalyzerGitignoreProjectDiscoveryPlugin], ["project-discovery:rbuildignore", typeof FlowrAnalyzerRbuildignoreProjectDiscoveryPlugin], ["project-discovery:ignore-files", typeof FlowrAnalyzerIgnoreFileProjectDiscoveryPlugin], ["project-discovery:default", typeof FlowrAnalyzerDefaultProjectDiscoveryPlugin], ["project-discovery:full", typeof FlowrAnalyzerFullProjectDiscoveryPlugin]];
|
|
37
|
+
export declare const BuiltInPlugins: [["file:description", typeof FlowrAnalyzerDescriptionFilePlugin], ["versions:description", typeof FlowrAnalyzerPackageVersionsDescriptionFilePlugin], ["versions:sigdb", typeof FlowrAnalyzerPackageVersionsSigDbPlugin], ["versions:library", typeof FlowrAnalyzerPackageVersionsLibraryPlugin], ["versions:renv", typeof FlowrAnalyzerPackageVersionsRenvPlugin], ["versions:rv", typeof FlowrAnalyzerPackageVersionsRvPlugin], ["versions:uvr", typeof FlowrAnalyzerPackageVersionsUvrPlugin], ["versions:packrat", typeof FlowrAnalyzerPackageVersionsPackratPlugin], ["versions:session-info", typeof FlowrAnalyzerPackageVersionsSessionInfoPlugin], ["loading-order:description", typeof FlowrAnalyzerLoadingOrderDescriptionFilePlugin], ["loading-order:implicit-sources", typeof FlowrAnalyzerLoadingOrderImplicitSourcesPlugin], ["loading-order:rprofile", typeof FlowrAnalyzerLoadingOrderRprofilePlugin], ["loading-order:included-files", typeof FlowrAnalyzerLoadingOrderIncludedFilesPlugin], ["meta:description", typeof FlowrAnalyzerMetaDescriptionFilePlugin], ["meta:rproject", typeof FlowrAnalyzerMetaRProjectFilePlugin], ["meta:uvr", typeof FlowrAnalyzerMetaUvrManifestFilePlugin], ["file-roles:vignette", typeof FlowrAnalyzerMetaVignetteFilesPlugin], ["file-roles:test", typeof FlowrAnalyzerMetaTestFilesPlugin], ["file-roles:inst", typeof FlowrAnalyzerMetaInstFilesPlugin], ["file:rmd", typeof FlowrAnalyzerRmdFilePlugin], ["file:qmd", typeof FlowrAnalyzerQmdFilePlugin], ["file:rnw", typeof FlowrAnalyzerSweaveFilePlugin], ["file:ipynb", typeof FlowrAnalyzerJupyterFilePlugin], ["file:rout", typeof FlowrAnalyzerRSessionFilePlugin], ["file:namespace", typeof FlowrAnalyzerNamespaceFilesPlugin], ["versions:namespace", typeof FlowrAnalyzerPackageVersionsNamespaceFilePlugin], ["file:news", typeof FlowrAnalyzerNewsFilePlugin], ["file:rd-macros", typeof FlowrAnalyzerRdMacroFilePlugin], ["file:rd", typeof FlowrAnalyzerRdFilePlugin], ["file:rd-index", typeof FlowrAnalyzerRdIndexFilePlugin], ["file:rd-topics", typeof FlowrAnalyzerRdTopicIndexFilePlugin], ["file:rd-meta", typeof FlowrAnalyzerRdMetaFilePlugin], ["file:datalist", typeof FlowrAnalyzerDataListFilePlugin], ["file:sysdata", typeof FlowrAnalyzerSysdataFilePlugin], ["file:rda", typeof FlowrAnalyzerRdaFilePlugin], ["file:license", typeof FlowrAnalyzerLicenseFilePlugin], ["file:virtualenv", typeof FlowrAnalyzerVirtualEnvFilePlugin], ["file:rproject", typeof FlowrAnalyzerRProjectFilePlugin], ["file:uvr", typeof FlowrAnalyzerUvrManifestFilePlugin], ["file:rprofile", typeof FlowrAnalyzerRprofileFilePlugin], ["project-discovery:gitignore", typeof FlowrAnalyzerGitignoreProjectDiscoveryPlugin], ["project-discovery:rbuildignore", typeof FlowrAnalyzerRbuildignoreProjectDiscoveryPlugin], ["project-discovery:ignore-files", typeof FlowrAnalyzerIgnoreFileProjectDiscoveryPlugin], ["project-discovery:default", typeof FlowrAnalyzerDefaultProjectDiscoveryPlugin], ["project-discovery:full", typeof FlowrAnalyzerFullProjectDiscoveryPlugin]];
|
|
37
38
|
export type BuiltInFlowrPluginName = typeof BuiltInPlugins[number][0];
|
|
38
39
|
export type BuiltInFlowrPluginArgs<N extends BuiltInFlowrPluginName> = N extends typeof BuiltInPlugins[number][0] ? ConstructorParameters<Extract<typeof BuiltInPlugins[number], [N, PluginProducer]>[1]> : never;
|
|
39
40
|
type PluginProducer = new (...args: never[]) => FlowrAnalyzerPlugin;
|
|
@@ -14,6 +14,7 @@ const flowr_analyzer_loading_order_implicit_sources_plugin_1 = require("./loadin
|
|
|
14
14
|
const flowr_analyzer_rmd_file_plugin_1 = require("./file-plugins/notebooks/flowr-analyzer-rmd-file-plugin");
|
|
15
15
|
const flowr_analyzer_qmd_file_plugin_1 = require("./file-plugins/notebooks/flowr-analyzer-qmd-file-plugin");
|
|
16
16
|
const assert_1 = require("../../util/assert");
|
|
17
|
+
const flowr_analyzer_rsession_file_plugin_1 = require("./file-plugins/notebooks/flowr-analyzer-rsession-file-plugin");
|
|
17
18
|
const flowr_analyzer_jupyter_file_plugin_1 = require("./file-plugins/notebooks/flowr-analyzer-jupyter-file-plugin");
|
|
18
19
|
const flowr_analyzer_namespace_files_plugin_1 = require("./file-plugins/flowr-analyzer-namespace-files-plugin");
|
|
19
20
|
const flowr_analyzer_package_versions_namespace_file_plugin_1 = require("./package-version-plugins/flowr-analyzer-package-versions-namespace-file-plugin");
|
|
@@ -63,6 +64,7 @@ exports.BuiltInPlugins = [
|
|
|
63
64
|
['file:qmd', flowr_analyzer_qmd_file_plugin_1.FlowrAnalyzerQmdFilePlugin],
|
|
64
65
|
['file:rnw', flowr_analyzer_sweave_file_plugin_1.FlowrAnalyzerSweaveFilePlugin],
|
|
65
66
|
['file:ipynb', flowr_analyzer_jupyter_file_plugin_1.FlowrAnalyzerJupyterFilePlugin],
|
|
67
|
+
['file:rout', flowr_analyzer_rsession_file_plugin_1.FlowrAnalyzerRSessionFilePlugin],
|
|
66
68
|
['file:namespace', flowr_analyzer_namespace_files_plugin_1.FlowrAnalyzerNamespaceFilesPlugin],
|
|
67
69
|
['versions:namespace', flowr_analyzer_package_versions_namespace_file_plugin_1.FlowrAnalyzerPackageVersionsNamespaceFilePlugin],
|
|
68
70
|
['file:news', flowr_analyzer_news_file_plugin_1.FlowrAnalyzerNewsFilePlugin],
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { type PropWord } from '../../dataflow/environments/built-in-props';
|
|
2
|
+
/** The query language of the sigdb page: `name(arg, [role], name[role], *)[prop]`. */
|
|
3
|
+
/** the kinds of words a query states: roles of an argument in parentheses, properties of a call outside */
|
|
4
|
+
export declare enum WordKind {
|
|
5
|
+
Role = "role",
|
|
6
|
+
Prop = "prop"
|
|
7
|
+
}
|
|
8
|
+
/** the words of each kind, as the built-in configuration words them */
|
|
9
|
+
export declare const Vocabulary: Readonly<Record<WordKind, readonly PropWord[]>>;
|
|
10
|
+
/** the short form of a word, the word itself where it has none */
|
|
11
|
+
export declare function shortOf(word: string): string;
|
|
12
|
+
/** what a role or property word means, `undefined` for any other word */
|
|
13
|
+
export declare function aboutWord(word: string): string | undefined;
|
|
14
|
+
/** The words of a `|`-joined statement. */
|
|
15
|
+
export declare function wordsOf(joined: string): string[];
|
|
16
|
+
/** The formals of a stated signature with the roles each one has. */
|
|
17
|
+
export declare function argsOf(args: string): (readonly [string, readonly string[]])[];
|
|
18
|
+
export interface ArgPattern {
|
|
19
|
+
/** `*` or `+` after the item (a bare `*` is any argument): any number of arguments like it, including none or at least one */
|
|
20
|
+
readonly repeat?: '*' | '+';
|
|
21
|
+
/** the formal's name, empty for any */
|
|
22
|
+
readonly name: string;
|
|
23
|
+
/** a `/pattern/` for the formal's name instead of an exact one */
|
|
24
|
+
readonly regex?: RegExp;
|
|
25
|
+
readonly roles: readonly string[];
|
|
26
|
+
}
|
|
27
|
+
export interface Spec {
|
|
28
|
+
readonly rest: string;
|
|
29
|
+
/** a `/pattern/` for the function's name; `rest` is empty then */
|
|
30
|
+
readonly nameRegex?: RegExp;
|
|
31
|
+
readonly args?: readonly ArgPattern[];
|
|
32
|
+
readonly props: readonly string[];
|
|
33
|
+
}
|
|
34
|
+
/** The short form of a word, so `forced` and `F` are the same. */
|
|
35
|
+
export declare const norm: (word: string) => string;
|
|
36
|
+
/** Splits `name(arg, [role], name[role], *)[prop]` into the name and the constraints on the arguments and the function. */
|
|
37
|
+
export declare function parseSpec(input: string): Spec;
|
|
38
|
+
/** Whether the arguments a signature states fit the patterns, `*` standing for any number of them. */
|
|
39
|
+
export declare function matchArgs(patterns: readonly ArgPattern[], actual: readonly (readonly [string, readonly string[]])[]): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* The pattern for a name with `*` in it, like `read*` or `*csv`, which has to match the whole name.
|
|
42
|
+
* Names with other punctuation (`%*%`, `[[<-`) and a bare `*` are names, not patterns.
|
|
43
|
+
*/
|
|
44
|
+
export declare function globOf(name: string): RegExp | undefined;
|
|
45
|
+
export interface Completion {
|
|
46
|
+
/** the span of `text` the choice replaces */
|
|
47
|
+
readonly from: number;
|
|
48
|
+
readonly to: number;
|
|
49
|
+
readonly options: readonly string[];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The words that fit at `caret` while a `[` is open: roles inside the parentheses of an argument list, properties
|
|
53
|
+
* outside. A `[` that starts the query or follows another `[` belongs to a name like `[[<-`, so it offers nothing.
|
|
54
|
+
*/
|
|
55
|
+
export declare function completeAt(text: string, caret: number): Completion | undefined;
|
|
56
|
+
export type TokenKind = 'plain' | 'punct' | 'op' | WordKind | 'bad' | 'regex';
|
|
57
|
+
/**
|
|
58
|
+
* The query cut into pieces to color, never changing the text: joining the pieces gives `text` back.
|
|
59
|
+
* Only a query that asks for a constraint is colored, a plain name like `[[<-` stays plain.
|
|
60
|
+
*/
|
|
61
|
+
export declare function highlight(text: string): readonly (readonly [text: string, kind: TokenKind])[];
|
|
62
|
+
/** What the piece at `at` in the query stands for, for a tooltip; `undefined` where there is nothing to say. */
|
|
63
|
+
export declare function explainAt(text: string, at: number): string | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* Whether the query is still being written: a bracket or parenthesis is open, or a role or property is not a known word.
|
|
66
|
+
* Such a query asks for nothing yet, so the page keeps showing the last answer instead of an empty one.
|
|
67
|
+
* Names like `[[<-` or `(` are never incomplete.
|
|
68
|
+
*/
|
|
69
|
+
export declare function isIncomplete(text: string): boolean;
|
|
70
|
+
/** The query with whatever is open closed again, so a word offered inside brackets can be judged as if it were finished. */
|
|
71
|
+
export declare function closed(text: string): string;
|
|
72
|
+
/** What is wrong with the query as written, for the reader to fix: an open bracket, an unknown word, a pattern that does not compile. */
|
|
73
|
+
export declare function problemsOf(text: string): string[];
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.norm = exports.Vocabulary = exports.WordKind = void 0;
|
|
4
|
+
exports.shortOf = shortOf;
|
|
5
|
+
exports.aboutWord = aboutWord;
|
|
6
|
+
exports.wordsOf = wordsOf;
|
|
7
|
+
exports.argsOf = argsOf;
|
|
8
|
+
exports.parseSpec = parseSpec;
|
|
9
|
+
exports.matchArgs = matchArgs;
|
|
10
|
+
exports.globOf = globOf;
|
|
11
|
+
exports.completeAt = completeAt;
|
|
12
|
+
exports.highlight = highlight;
|
|
13
|
+
exports.explainAt = explainAt;
|
|
14
|
+
exports.isIncomplete = isIncomplete;
|
|
15
|
+
exports.closed = closed;
|
|
16
|
+
exports.problemsOf = problemsOf;
|
|
17
|
+
const built_in_props_1 = require("../../dataflow/environments/built-in-props");
|
|
18
|
+
const regex_1 = require("../../util/text/regex");
|
|
19
|
+
/** The query language of the sigdb page: `name(arg, [role], name[role], *)[prop]`. */
|
|
20
|
+
/** the kinds of words a query states: roles of an argument in parentheses, properties of a call outside */
|
|
21
|
+
var WordKind;
|
|
22
|
+
(function (WordKind) {
|
|
23
|
+
WordKind["Role"] = "role";
|
|
24
|
+
WordKind["Prop"] = "prop";
|
|
25
|
+
})(WordKind || (exports.WordKind = WordKind = {}));
|
|
26
|
+
/** the words of each kind, as the built-in configuration words them */
|
|
27
|
+
exports.Vocabulary = {
|
|
28
|
+
[WordKind.Role]: Object.values(built_in_props_1.ArgProps.vocabulary),
|
|
29
|
+
[WordKind.Prop]: Object.values(built_in_props_1.CallProps.vocabulary)
|
|
30
|
+
};
|
|
31
|
+
/** the short forms of the tags whose words are long, the roles and properties state their own */
|
|
32
|
+
const TagShorts = {
|
|
33
|
+
[built_in_props_1.SemanticCallTag.TempFile]: 'tmpfile',
|
|
34
|
+
[built_in_props_1.SemanticCallTag.User]: 'user',
|
|
35
|
+
[built_in_props_1.SemanticCallTag.CommandLine]: 'argv',
|
|
36
|
+
[built_in_props_1.SemanticCallTag.Graphics]: 'plot',
|
|
37
|
+
[built_in_props_1.SemanticCallTag.Opens]: 'opens',
|
|
38
|
+
[built_in_props_1.SemanticCallTag.Closes]: 'closes',
|
|
39
|
+
[built_in_props_1.SemanticCallTag.Narrows]: 'narrows',
|
|
40
|
+
[built_in_props_1.SemanticCallTag.Statistics]: 'stats',
|
|
41
|
+
[built_in_props_1.SemanticCallTag.JavaScript]: 'js'
|
|
42
|
+
};
|
|
43
|
+
/** every word of either kind */
|
|
44
|
+
const AllWords = Object.values(exports.Vocabulary).flat();
|
|
45
|
+
const Shorts = new Map([
|
|
46
|
+
...AllWords.flatMap(({ word, short }) => short === undefined ? [] : [[word, short]]),
|
|
47
|
+
...Object.entries(TagShorts)
|
|
48
|
+
]);
|
|
49
|
+
/** the short form of a word, the word itself where it has none */
|
|
50
|
+
function shortOf(word) {
|
|
51
|
+
return Shorts.get(word) ?? word;
|
|
52
|
+
}
|
|
53
|
+
/** what a role or property word means, `undefined` for any other word */
|
|
54
|
+
function aboutWord(word) {
|
|
55
|
+
return AllWords.find(w => w.word === word)?.about;
|
|
56
|
+
}
|
|
57
|
+
/** The words of a `|`-joined statement. */
|
|
58
|
+
function wordsOf(joined) {
|
|
59
|
+
return joined.split('|').filter(Boolean);
|
|
60
|
+
}
|
|
61
|
+
/** The formals of a stated signature with the roles each one has. */
|
|
62
|
+
function argsOf(args) {
|
|
63
|
+
return args.split(',').filter(Boolean).map((arg) => {
|
|
64
|
+
const at = arg.indexOf(':');
|
|
65
|
+
return at < 0 ? [arg.trim(), []] : [arg.slice(0, at).trim(), wordsOf(arg.slice(at + 1))];
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
/** The short form of a word, so `forced` and `F` are the same. */
|
|
69
|
+
const norm = (word) => shortOf(word.trim().toLowerCase()).toLowerCase();
|
|
70
|
+
exports.norm = norm;
|
|
71
|
+
const listOf = (words) => words.split(/[,|+]/).map(exports.norm).filter(Boolean);
|
|
72
|
+
/** The `[props]` groups outside the parentheses, wherever they sit, and what is left of the query without them. */
|
|
73
|
+
function takeProps(typed) {
|
|
74
|
+
const props = [];
|
|
75
|
+
let body = '';
|
|
76
|
+
let depth = 0;
|
|
77
|
+
for (let at = 0; at < typed.length; at++) {
|
|
78
|
+
const c = typed[at];
|
|
79
|
+
const close = typed.indexOf(']', at);
|
|
80
|
+
if (c === '[' && depth === 0 && close >= 0 && ((at > 0 && typed[at - 1] !== '[') || (at === 0 && leads(typed)))) {
|
|
81
|
+
props.push(...listOf(typed.slice(at + 1, close)));
|
|
82
|
+
at = close;
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
depth += c === '(' ? 1 : c === ')' ? -1 : 0;
|
|
86
|
+
body += c;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return { body: body.trim().replace(/\s+\(/, '('), props };
|
|
90
|
+
}
|
|
91
|
+
/** `[props] rest`: a bracket group at the start only counts when something follows it, so `[` and `[[` stay names */
|
|
92
|
+
const LeadingProps = /^\[([^\]]*)\]\s+(\S.*)$/;
|
|
93
|
+
/** whether a `[` at the very start opens properties: something follows the group, or it is all there is */
|
|
94
|
+
const leads = (text) => LeadingProps.test(text) || /^\[[^\]]+\]$/.test(text);
|
|
95
|
+
const anyArgs = { repeat: '*', name: '', roles: [] };
|
|
96
|
+
const Mark = '\uE000';
|
|
97
|
+
/** a `/pattern/` standing where a name could: after the start, a space, `(`, `,` or `]`, before whatever ends a name */
|
|
98
|
+
const Slashed = /(^|[\s(,\]])\/((?:\\.|[^/\\\n])+)\/(?=[\s(),[*+?]|$)/g;
|
|
99
|
+
/** Splits `name(arg, [role], name[role], *)[prop]` into the name and the constraints on the arguments and the function. */
|
|
100
|
+
function parseSpec(input) {
|
|
101
|
+
const typed = input;
|
|
102
|
+
/* a pattern may hold anything, brackets and commas included, so it is set aside while the rest is read */
|
|
103
|
+
const patterns = [];
|
|
104
|
+
const shielded = typed.replace(Slashed, (whole, before, source) => {
|
|
105
|
+
const pattern = (0, regex_1.compileRegex)(source, 'i');
|
|
106
|
+
return pattern === undefined ? whole : before + Mark + (patterns.push(pattern) - 1) + Mark;
|
|
107
|
+
});
|
|
108
|
+
const patternOf = (word) => {
|
|
109
|
+
const held = new RegExp(`^${Mark}(\\d+)${Mark}$`).exec(word.trim());
|
|
110
|
+
return held === null ? undefined : patterns[Number(held[1])];
|
|
111
|
+
};
|
|
112
|
+
const { body: left, props } = takeProps(shielded);
|
|
113
|
+
const withArgs = /^([^(]*)\(([^]*)\)$/.exec(left);
|
|
114
|
+
const args = withArgs === null || withArgs[2].trim() === '' ? undefined : withArgs[2].split(/,(?![^[]*\])/).flatMap((item) => {
|
|
115
|
+
const part = new RegExp(`^(${Mark}\\d+${Mark}|[^[*+?]*)(?:\\[([^\\]]*)\\])?([*+?])?$`).exec(item.trim());
|
|
116
|
+
const name = (part?.[1] ?? '').trim();
|
|
117
|
+
const regex = patternOf(name);
|
|
118
|
+
const own = {
|
|
119
|
+
repeat: part?.[3] === '?' ? undefined : part?.[3],
|
|
120
|
+
name: name === '_' || regex !== undefined ? '' : name,
|
|
121
|
+
regex,
|
|
122
|
+
roles: listOf(part?.[2] ?? '')
|
|
123
|
+
};
|
|
124
|
+
/* `[role]?` is at least one argument like it, with any others around it */
|
|
125
|
+
return part?.[3] === '?' ? [anyArgs, own, anyArgs] : [own];
|
|
126
|
+
});
|
|
127
|
+
if (args === undefined && props.length === 0) {
|
|
128
|
+
/* no constraint was asked for, so this is a plain name: `*`, `[`, `[[<-` or `(` are functions too */
|
|
129
|
+
const nameRegex = (0, regex_1.slashedRegex)(typed, 'i');
|
|
130
|
+
return { rest: nameRegex === undefined ? typed.replace(/\(\s*\)$/, '').replace(/^`(.*)`$/, '$1').trim() : '', nameRegex, props };
|
|
131
|
+
}
|
|
132
|
+
const rest = (args === undefined ? left.replace(/\(\s*\)$/, '') : withArgs?.[1] ?? '').replace(/^`(.*)`$/, '$1').trim();
|
|
133
|
+
const nameRegex = patternOf(rest);
|
|
134
|
+
return { rest: nameRegex !== undefined || /^\*+$/.test(rest) ? '' : rest, nameRegex, args, props };
|
|
135
|
+
}
|
|
136
|
+
/** Whether the arguments a signature states fit the patterns, `*` standing for any number of them. */
|
|
137
|
+
function matchArgs(patterns, actual) {
|
|
138
|
+
/* `...` only counts when the query names it, so `print([alias])` still finds `print(x, ...)` */
|
|
139
|
+
if (!patterns.some(p => p.name === '...' || p.regex?.test('...'))) {
|
|
140
|
+
actual = actual.filter(([name]) => name !== '...');
|
|
141
|
+
}
|
|
142
|
+
if (patterns.length === 0) {
|
|
143
|
+
return actual.length === 0;
|
|
144
|
+
}
|
|
145
|
+
const [first, ...others] = patterns;
|
|
146
|
+
const one = ([name, roles]) => (first.regex?.test(name) ?? (first.name === '' || first.name === name)) && first.roles.every(role => roles.map(exports.norm).includes(role));
|
|
147
|
+
if (first.repeat === undefined) {
|
|
148
|
+
return actual.length > 0 && one(actual[0]) && matchArgs(others, actual.slice(1));
|
|
149
|
+
}
|
|
150
|
+
for (let taken = first.repeat === '+' ? 1 : 0; taken <= actual.length && actual.slice(0, taken).every(one); taken++) {
|
|
151
|
+
if (matchArgs(others, actual.slice(taken))) {
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* The pattern for a name with `*` in it, like `read*` or `*csv`, which has to match the whole name.
|
|
159
|
+
* Names with other punctuation (`%*%`, `[[<-`) and a bare `*` are names, not patterns.
|
|
160
|
+
*/
|
|
161
|
+
function globOf(name) {
|
|
162
|
+
if (!name.includes('*') || !/^[\w.*]+$/.test(name) || /^\*+$/.test(name)) {
|
|
163
|
+
return undefined;
|
|
164
|
+
}
|
|
165
|
+
return new RegExp('^' + name.split('*').map(part => part.replaceAll('.', '\\.')).join('.*') + '$', 'i');
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* The words that fit at `caret` while a `[` is open: roles inside the parentheses of an argument list, properties
|
|
169
|
+
* outside. A `[` that starts the query or follows another `[` belongs to a name like `[[<-`, so it offers nothing.
|
|
170
|
+
*/
|
|
171
|
+
function completeAt(text, caret) {
|
|
172
|
+
const before = text.slice(0, caret);
|
|
173
|
+
const open = before.lastIndexOf('[');
|
|
174
|
+
if (open <= 0 || before[open - 1] === '[' || before.includes(']', open)) {
|
|
175
|
+
return undefined;
|
|
176
|
+
}
|
|
177
|
+
const inside = before.slice(open + 1);
|
|
178
|
+
const start = open + 1 + Math.max(inside.lastIndexOf(','), inside.lastIndexOf('|'), inside.lastIndexOf('+')) + 1;
|
|
179
|
+
const typed = before.slice(start).trimStart();
|
|
180
|
+
const words = exports.Vocabulary[[...before.slice(0, open)].filter(c => c === '(').length > [...before.slice(0, open)].filter(c => c === ')').length ? WordKind.Role : WordKind.Prop].map(w => w.word);
|
|
181
|
+
const taken = new Set(listOf(inside));
|
|
182
|
+
const options = words.filter(word => word.startsWith(typed.toLowerCase()) && word !== typed.toLowerCase() && !taken.has((0, exports.norm)(word)));
|
|
183
|
+
return options.length === 0 ? undefined : { from: caret - typed.length, to: caret, options };
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* The query cut into pieces to color, never changing the text: joining the pieces gives `text` back.
|
|
187
|
+
* Only a query that asks for a constraint is colored, a plain name like `[[<-` stays plain.
|
|
188
|
+
*/
|
|
189
|
+
function highlight(text) {
|
|
190
|
+
const spec = parseSpec(text.trim().replace(/^\?/, '').trim());
|
|
191
|
+
if (spec.nameRegex !== undefined && spec.args === undefined && spec.props.length === 0) {
|
|
192
|
+
return [[text, 'regex']];
|
|
193
|
+
}
|
|
194
|
+
if (spec.args === undefined && spec.props.length === 0 && !/[^[]\[/.test(text)) {
|
|
195
|
+
return [[text, 'plain']];
|
|
196
|
+
}
|
|
197
|
+
const out = [];
|
|
198
|
+
let depth = 0;
|
|
199
|
+
for (let at = 0; at < text.length;) {
|
|
200
|
+
const c = text[at];
|
|
201
|
+
const slashed = c === '/' && (at === 0 || /[\s(,\]]/.test(text[at - 1])) ? new RegExp(Slashed.source, 'y') : undefined;
|
|
202
|
+
if (slashed !== undefined) {
|
|
203
|
+
slashed.lastIndex = Math.max(0, at - 1);
|
|
204
|
+
}
|
|
205
|
+
const found = slashed?.exec(text);
|
|
206
|
+
if (found !== null && found !== undefined && (0, regex_1.compileRegex)(found[2], 'i') !== undefined && found.index + found[1].length === at) {
|
|
207
|
+
const whole = found[0].slice(found[1].length);
|
|
208
|
+
out.push([whole, 'regex']);
|
|
209
|
+
at += whole.length;
|
|
210
|
+
}
|
|
211
|
+
else if (c === '[' && ((at > 0 && text[at - 1] !== '[') || (at === 0 && leads(text)))) {
|
|
212
|
+
const close = text.indexOf(']', at);
|
|
213
|
+
const end = close < 0 ? text.length : close;
|
|
214
|
+
const kind = depth > 0 ? WordKind.Role : WordKind.Prop;
|
|
215
|
+
out.push(['[', 'punct']);
|
|
216
|
+
for (const part of text.slice(at + 1, end).split(/([,|+])/)) {
|
|
217
|
+
const known = exports.Vocabulary[kind].some(({ word }) => (0, exports.norm)(word) === (0, exports.norm)(part));
|
|
218
|
+
out.push([part, /^[,|+]$/.test(part) ? 'punct' : part.trim() === '' ? 'plain' : known ? kind : 'bad']);
|
|
219
|
+
}
|
|
220
|
+
if (close >= 0) {
|
|
221
|
+
out.push([']', 'punct']);
|
|
222
|
+
}
|
|
223
|
+
at = end + 1;
|
|
224
|
+
}
|
|
225
|
+
else if ('(),*+?'.includes(c)) {
|
|
226
|
+
depth += c === '(' ? 1 : c === ')' ? -1 : 0;
|
|
227
|
+
out.push([c, '*+?'.includes(c) ? 'op' : 'punct']);
|
|
228
|
+
at++;
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
const last = out[out.length - 1];
|
|
232
|
+
if (last?.[1] === 'plain') {
|
|
233
|
+
last[0] += c;
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
out.push([c, 'plain']);
|
|
237
|
+
}
|
|
238
|
+
at++;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return out;
|
|
242
|
+
}
|
|
243
|
+
const SymbolInfo = {
|
|
244
|
+
'*': 'any number of arguments', '+': 'one or more, all like the one before', '?': 'at least one like the one before'
|
|
245
|
+
};
|
|
246
|
+
/** What the piece at `at` in the query stands for, for a tooltip; `undefined` where there is nothing to say. */
|
|
247
|
+
function explainAt(text, at) {
|
|
248
|
+
let start = 0;
|
|
249
|
+
for (const [part, kind] of highlight(text)) {
|
|
250
|
+
if (at >= start && at < start + part.length) {
|
|
251
|
+
switch (kind) {
|
|
252
|
+
case WordKind.Role:
|
|
253
|
+
case WordKind.Prop: return exports.Vocabulary[kind].find(({ word }) => (0, exports.norm)(word) === (0, exports.norm)(part))?.about;
|
|
254
|
+
case 'bad': return 'unknown';
|
|
255
|
+
case 'regex': return 'pattern';
|
|
256
|
+
default: return kind === 'plain' ? undefined : SymbolInfo[part];
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
start += part.length;
|
|
260
|
+
}
|
|
261
|
+
return undefined;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Whether the query is still being written: a bracket or parenthesis is open, or a role or property is not a known word.
|
|
265
|
+
* Such a query asks for nothing yet, so the page keeps showing the last answer instead of an empty one.
|
|
266
|
+
* Names like `[[<-` or `(` are never incomplete.
|
|
267
|
+
*/
|
|
268
|
+
function isIncomplete(text) {
|
|
269
|
+
const pieces = highlight(text);
|
|
270
|
+
if (pieces.some(([, kind]) => kind === 'bad')) {
|
|
271
|
+
return true;
|
|
272
|
+
}
|
|
273
|
+
/* what is written outside the closed bracket groups and patterns, where only the parentheses are left to count */
|
|
274
|
+
const bare = text.replace(Slashed, '$1').replace(/(?<=[^[])\[[^\]]*\]/g, '');
|
|
275
|
+
const depth = [...bare.replace(/^\(+/, '')].reduce((sum, c) => sum + (c === '(' ? 1 : c === ')' ? -1 : 0), 0);
|
|
276
|
+
return /(?<=[^[])\[[^\]]*$/.test(bare) || depth > 0;
|
|
277
|
+
}
|
|
278
|
+
/** The query with whatever is open closed again, so a word offered inside brackets can be judged as if it were finished. */
|
|
279
|
+
function closed(text) {
|
|
280
|
+
const bare = text.replace(Slashed, '$1').replace(/(?<=[^[])\[[^\]]*\]/g, '');
|
|
281
|
+
const depth = [...bare.replace(/^\(+/, '')].reduce((sum, c) => sum + (c === '(' ? 1 : c === ')' ? -1 : 0), 0);
|
|
282
|
+
const open = /(?<=[^[])\[[^\]]*$/.test(bare) ? ']' : '';
|
|
283
|
+
return text + open + ')'.repeat(Math.max(0, depth));
|
|
284
|
+
}
|
|
285
|
+
/** The closest known word to a misspelled one: one it starts, or else within two edits. */
|
|
286
|
+
function closestWord(word, words) {
|
|
287
|
+
const lower = word.toLowerCase();
|
|
288
|
+
const starts = words.find(w => lower.length > 0 && w.startsWith(lower));
|
|
289
|
+
if (starts !== undefined) {
|
|
290
|
+
return starts;
|
|
291
|
+
}
|
|
292
|
+
const distance = (a, b) => {
|
|
293
|
+
let row = Array.from({ length: b.length + 1 }, (_, i) => i);
|
|
294
|
+
for (let i = 1; i <= a.length; i++) {
|
|
295
|
+
const next = [i];
|
|
296
|
+
for (let j = 1; j <= b.length; j++) {
|
|
297
|
+
next[j] = Math.min(row[j] + 1, next[j - 1] + 1, row[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));
|
|
298
|
+
}
|
|
299
|
+
row = next;
|
|
300
|
+
}
|
|
301
|
+
return row[b.length];
|
|
302
|
+
};
|
|
303
|
+
return words.map((w) => [w, distance(lower, w)]).filter(([, d]) => d <= 2).sort((a, b) => a[1] - b[1])[0]?.[0];
|
|
304
|
+
}
|
|
305
|
+
/** What is wrong with the query as written, for the reader to fix: an open bracket, an unknown word, a pattern that does not compile. */
|
|
306
|
+
function problemsOf(text) {
|
|
307
|
+
const out = [];
|
|
308
|
+
const bare = text.replace(Slashed, '$1').replace(/(?<=[^[])\[[^\]]*\]/g, '');
|
|
309
|
+
const depth = [...bare.replace(/^\(+/, '')].reduce((sum, c) => sum + (c === '(' ? 1 : c === ')' ? -1 : 0), 0);
|
|
310
|
+
if (/(?<=[^[])\[[^\]]*$/.test(bare)) {
|
|
311
|
+
out.push('missing `]`');
|
|
312
|
+
}
|
|
313
|
+
if (depth > 0) {
|
|
314
|
+
out.push(depth === 1 ? 'missing `)`' : `missing ${depth} times \`)\``);
|
|
315
|
+
}
|
|
316
|
+
else if (depth < 0) {
|
|
317
|
+
out.push('unexpected `)`');
|
|
318
|
+
}
|
|
319
|
+
let parens = 0;
|
|
320
|
+
for (const [part, kind] of highlight(text)) {
|
|
321
|
+
if (kind === 'punct' && (part === '(' || part === ')')) {
|
|
322
|
+
parens += part === '(' ? 1 : -1;
|
|
323
|
+
}
|
|
324
|
+
else if (kind === 'bad') {
|
|
325
|
+
const word = part.trim();
|
|
326
|
+
const role = parens > 0;
|
|
327
|
+
const near = closestWord(word, exports.Vocabulary[role ? WordKind.Role : WordKind.Prop].map(w => w.word));
|
|
328
|
+
out.push(`\`${word}\` is no known ${role ? 'argument role' : 'function property'}${near === undefined ? '' : `, did you mean \`${near}\`?`}`);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
for (const slashed of text.matchAll(Slashed)) {
|
|
332
|
+
const regex = (0, regex_1.tryRegex)(slashed[2], 'i');
|
|
333
|
+
if (!(regex instanceof RegExp)) {
|
|
334
|
+
out.push(`invalid pattern /${slashed[2]}/: ${regex.message.replace(/^Invalid regular expression: /, '').replace(/^\/.*\/[a-z]*: /, '')}`);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
return out;
|
|
338
|
+
}
|
|
339
|
+
//# sourceMappingURL=spec-query.js.map
|
|
@@ -17,7 +17,7 @@ export interface BasicQueryData {
|
|
|
17
17
|
readonly analyzer: ReadonlyFlowrAnalysisProvider;
|
|
18
18
|
}
|
|
19
19
|
/** {@link SupportedQuery#fromLine} for a query whose only argument is an optional multi-criterion `filter` */
|
|
20
|
-
export declare function filterLineParser<T extends string>(type: T): (_output: ReplOutput, line: readonly string[], _config: FlowrConfig) => ParsedQueryLine<T>;
|
|
20
|
+
export declare function filterLineParser<T extends string>(type: T, key?: string): (_output: ReplOutput, line: readonly string[], _config: FlowrConfig) => ParsedQueryLine<T>;
|
|
21
21
|
/** Reports a malformed query line (with optional unformatted `details`), yielding no query. */
|
|
22
22
|
export declare function invalidQueryLine<T extends string>(output: ReplOutput, message: string, details?: string): ParsedQueryLine<T>;
|
|
23
23
|
/** {@link SupportedQuery#fromLine} for a query keyed by a single slicing criterion, erroring (naming the query as `label`) when it is missing */
|
|
@@ -6,11 +6,11 @@ exports.singleCriterionLineParser = singleCriterionLineParser;
|
|
|
6
6
|
const slice_query_parser_1 = require("../cli/repl/parser/slice-query-parser");
|
|
7
7
|
const ansi_1 = require("../util/text/ansi");
|
|
8
8
|
/** {@link SupportedQuery#fromLine} for a query whose only argument is an optional multi-criterion `filter` */
|
|
9
|
-
function filterLineParser(type) {
|
|
9
|
+
function filterLineParser(type, key = 'filter') {
|
|
10
10
|
return function (_output, line, _config) {
|
|
11
11
|
const criteria = (0, slice_query_parser_1.sliceCriteriaParser)(line[0]);
|
|
12
12
|
return {
|
|
13
|
-
query: { type,
|
|
13
|
+
query: { type, [key]: criteria },
|
|
14
14
|
rCode: (0, slice_query_parser_1.queryLineCode)(line, criteria ? 1 : 0)
|
|
15
15
|
};
|
|
16
16
|
};
|