@eagleoutice/flowr 2.11.1 → 2.12.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 +187 -257
- package/abstract-interpretation/absint-visitor.d.ts +1 -0
- package/abstract-interpretation/data-frame/mappers/arguments.js +7 -1
- package/abstract-interpretation/domains/set-range-domain.js +1 -1
- package/abstract-interpretation/domains/set-upper-bound-domain.js +6 -2
- package/benchmark/slicer.d.ts +1 -1
- package/benchmark/slicer.js +3 -1
- package/benchmark/summarizer/second-phase/graph.js +5 -0
- package/cli/common/options.d.ts +8 -0
- package/cli/common/options.js +2 -0
- package/cli/common/scripts-info.d.ts +8 -0
- package/cli/repl/commands/repl-commands.d.ts +1 -0
- package/cli/repl/commands/repl-commands.js +66 -15
- package/cli/repl/commands/repl-dataflow.js +48 -4
- package/cli/repl/commands/repl-main.d.ts +2 -0
- package/cli/repl/commands/repl-main.js +5 -0
- package/cli/repl/commands/repl-query.d.ts +4 -1
- package/cli/repl/commands/repl-query.js +72 -22
- package/cli/repl/commands/repl-signature.d.ts +7 -0
- package/cli/repl/commands/repl-signature.js +119 -0
- package/cli/repl/core.d.ts +8 -1
- package/cli/repl/core.js +46 -6
- package/cli/repl/ghost-hint.d.ts +37 -0
- package/cli/repl/ghost-hint.js +72 -0
- package/cli/repl/parser/slice-query-parser.d.ts +11 -1
- package/cli/repl/parser/slice-query-parser.js +45 -16
- package/cli/repl/print-version.d.ts +2 -4
- package/cli/repl/print-version.js +41 -23
- package/cli/repl/server/connection.js +19 -17
- package/cli/slicer-app.d.ts +2 -0
- package/cli/slicer-app.js +3 -3
- package/cli/wiki.d.ts +2 -2
- package/cli/wiki.js +2 -2
- package/config.d.ts +63 -2
- package/config.js +64 -8
- package/control-flow/cfg-dead-code.js +0 -1
- package/control-flow/control-flow-graph.js +6 -6
- package/control-flow/diff-cfg.js +2 -2
- package/control-flow/semantic-cfg-guided-visitor.js +2 -0
- package/core/print/slice-diff-ansi.js +8 -8
- package/core/steps/all/core/20-dataflow.d.ts +2 -2
- package/core/steps/all/static-slicing/00-slice.d.ts +5 -0
- package/core/steps/all/static-slicing/00-slice.js +1 -1
- package/core/steps/all/static-slicing/10-reconstruct.d.ts +7 -0
- package/core/steps/all/static-slicing/10-reconstruct.js +6 -2
- package/core/steps/pipeline/default-pipelines.d.ts +20 -16
- package/data/r-base-packages.generated.d.ts +44 -0
- package/data/r-base-packages.generated.js +32 -0
- package/data/r-base-primitives.generated.d.ts +1 -0
- package/data/r-base-primitives.generated.js +15 -0
- package/data/sigdb/sigdb.remote.json +112 -0
- package/dataflow/environments/built-in-proc-name.d.ts +4 -0
- package/dataflow/environments/built-in-proc-name.js +4 -0
- package/dataflow/environments/built-in.d.ts +14 -4
- package/dataflow/environments/built-in.js +13 -2
- package/dataflow/environments/data-masking-functions.d.ts +12 -0
- package/dataflow/environments/data-masking-functions.js +46 -0
- package/dataflow/environments/default-builtin-config.d.ts +72 -19
- package/dataflow/environments/default-builtin-config.js +48 -14
- package/dataflow/environments/diff.js +1 -1
- package/dataflow/environments/environment.js +1 -2
- package/dataflow/environments/identifier.d.ts +11 -4
- package/dataflow/environments/identifier.js +28 -10
- package/dataflow/environments/resolve-by-name.js +16 -2
- package/dataflow/extractor.js +6 -3
- package/dataflow/graph/call-graph.d.ts +2 -2
- package/dataflow/graph/df-helper.d.ts +4 -4
- package/dataflow/graph/diff-dataflow-graph.js +2 -2
- package/dataflow/graph/edge.d.ts +3 -3
- package/dataflow/graph/edge.js +3 -3
- package/dataflow/graph/graph-helper.d.ts +2 -2
- package/dataflow/internal/linker.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +7 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +20 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +1 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +2 -49
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +6 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +7 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +19 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +111 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +13 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +2 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +9 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +19 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +12 -4
- package/dataflow/internal/process/functions/call/common.js +8 -1
- package/dataflow/internal/process/functions/call/default-call-handling.js +6 -0
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +17 -0
- package/dataflow/internal/process/functions/call/known-call-handling.js +32 -0
- package/dataflow/internal/process/functions/call/named-call-handling.js +29 -7
- package/dataflow/internal/process/functions/process-argument.js +12 -1
- package/dataflow/internal/process/process-named-call.d.ts +18 -1
- package/dataflow/internal/process/process-named-call.js +94 -0
- package/dataflow/processor.d.ts +18 -0
- package/documentation/data/faq/faqs.js +5 -1
- package/documentation/doc-capabilities.js +1 -1
- package/documentation/doc-util/doc-cli-option.d.ts +10 -0
- package/documentation/doc-util/doc-cli-option.js +23 -0
- package/documentation/doc-util/doc-dfg.js +2 -1
- package/documentation/doc-util/doc-query.d.ts +9 -3
- package/documentation/doc-util/doc-query.js +9 -4
- package/documentation/wiki-dataflow-graph.js +8 -5
- package/documentation/wiki-interface.js +4 -2
- package/documentation/wiki-linter.js +1 -1
- package/documentation/wiki-linting-and-testing.js +4 -1
- package/documentation/wiki-mk/doc-context.d.ts +14 -0
- package/documentation/wiki-mk/doc-context.js +3 -0
- package/documentation/wiki-mk/doc-maker.js +3 -1
- package/documentation/wiki-query.js +36 -15
- package/documentation/wiki-setup.js +10 -7
- package/documentation/wiki-signature-database.d.ts +16 -0
- package/documentation/wiki-signature-database.js +293 -0
- package/linter/linter-format.d.ts +7 -0
- package/linter/linter-rules.d.ts +10 -9
- package/linter/rules/naming-convention.d.ts +1 -0
- package/linter/rules/naming-convention.js +2 -0
- package/linter/rules/no-leaked-credentials.js +1 -2
- package/linter/rules/roxygen-arguments.js +18 -5
- package/linter/rules/stop-with-call-arg.js +2 -2
- package/linter/rules/undefined-symbol-util.d.ts +36 -0
- package/linter/rules/undefined-symbol-util.js +149 -0
- package/linter/rules/undefined-symbol.d.ts +58 -17
- package/linter/rules/undefined-symbol.js +143 -33
- package/linter/rules/unused-definition.d.ts +8 -1
- package/linter/rules/unused-definition.js +126 -1
- package/package.json +22 -10
- package/project/context/abstract-flowr-analyzer-context.js +7 -1
- package/project/context/flowr-analyzer-context.d.ts +8 -0
- package/project/context/flowr-analyzer-context.js +10 -0
- package/project/context/flowr-analyzer-dependencies-context.d.ts +28 -4
- package/project/context/flowr-analyzer-dependencies-context.js +51 -2
- package/project/context/flowr-analyzer-files-context.d.ts +1 -0
- package/project/context/flowr-analyzer-files-context.js +2 -1
- package/project/context/flowr-analyzer-functions-context.js +1 -1
- package/project/context/flowr-file.d.ts +5 -0
- package/project/context/flowr-file.js +5 -0
- package/project/flowr-analyzer-builder.js +12 -2
- package/project/plugins/file-plugins/files/flowr-description-file.js +6 -3
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +9 -3
- package/project/plugins/file-plugins/files/flowr-news-file.js +1 -3
- package/project/plugins/file-plugins/flowr-analyzer-inst-file-plugin.d.ts +26 -0
- package/project/plugins/file-plugins/flowr-analyzer-inst-file-plugin.js +39 -0
- 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.js +2 -2
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-namespace-file-plugin.js +1 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.d.ts +18 -2
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.js +19 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +120 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +518 -0
- package/project/plugins/package-version-plugins/package.d.ts +5 -3
- package/project/plugins/package-version-plugins/package.js +27 -25
- package/project/plugins/plugin-registry.d.ts +3 -2
- package/project/plugins/plugin-registry.js +4 -2
- package/project/plugins/project-discovery/flowr-analyzer-gitignore-project-discovery-plugin.js +7 -2
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +3 -1
- package/project/sigdb/build.d.ts +131 -0
- package/project/sigdb/build.js +628 -0
- package/project/sigdb/codec.d.ts +51 -0
- package/project/sigdb/codec.js +122 -0
- package/project/sigdb/decode.d.ts +58 -0
- package/project/sigdb/decode.js +129 -0
- package/project/sigdb/decompress.d.ts +44 -0
- package/project/sigdb/decompress.js +176 -0
- package/project/sigdb/hash.d.ts +9 -0
- package/project/sigdb/hash.js +54 -0
- package/project/sigdb/index-format.d.ts +40 -0
- package/project/sigdb/index-format.js +28 -0
- package/project/sigdb/manifest.d.ts +68 -0
- package/project/sigdb/manifest.js +146 -0
- package/project/sigdb/reader.d.ts +250 -0
- package/project/sigdb/reader.js +692 -0
- package/project/sigdb/schema.d.ts +196 -0
- package/project/sigdb/schema.js +33 -0
- package/project/sigdb/sigdb-download.d.ts +65 -0
- package/project/sigdb/sigdb-download.js +237 -0
- package/project/sigdb/signature-match.d.ts +26 -0
- package/project/sigdb/signature-match.js +40 -0
- package/project/sigdb/version.d.ts +20 -0
- package/project/sigdb/version.js +55 -0
- package/queries/catalog/absint-query/absint-query-executor.d.ts +6 -0
- package/queries/catalog/absint-query/absint-query-executor.js +63 -0
- package/queries/catalog/absint-query/absint-query-format.d.ts +37 -0
- package/queries/catalog/absint-query/absint-query-format.js +102 -0
- package/queries/catalog/call-context-query/call-context-query-executor.js +1 -3
- package/queries/catalog/config-query/config-query-format.d.ts +3 -1
- package/queries/catalog/config-query/config-query-format.js +68 -9
- package/queries/catalog/dataflow-query/dataflow-query-format.js +11 -1
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +1 -1
- package/queries/catalog/linter-query/linter-query-executor.d.ts +2 -0
- package/queries/catalog/linter-query/linter-query-executor.js +6 -1
- package/queries/catalog/linter-query/linter-query-format.d.ts +2 -1
- package/queries/catalog/linter-query/linter-query-format.js +40 -8
- package/queries/catalog/project-query/project-query-executor.d.ts +15 -0
- package/queries/catalog/project-query/project-query-executor.js +96 -4
- package/queries/catalog/project-query/project-query-format.d.ts +44 -0
- package/queries/catalog/project-query/project-query-format.js +33 -2
- package/queries/catalog/signature-query/signature-query-executor.d.ts +29 -0
- package/queries/catalog/signature-query/signature-query-executor.js +461 -0
- package/queries/catalog/signature-query/signature-query-format.d.ts +138 -0
- package/queries/catalog/signature-query/signature-query-format.js +76 -0
- package/queries/catalog/signature-query/signature-query-render.d.ts +15 -0
- package/queries/catalog/signature-query/signature-query-render.js +155 -0
- package/queries/catalog/static-slice-query/static-slice-query-executor.js +9 -3
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +10 -0
- package/queries/catalog/static-slice-query/static-slice-query-format.js +19 -1
- package/queries/query-print.js +5 -0
- package/queries/query.d.ts +15 -5
- package/queries/query.js +7 -4
- package/r-bridge/init.js +5 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +10 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +55 -0
- package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +16 -0
- package/r-bridge/lang-4.x/ast/model/processing/node-id.js +27 -0
- package/r-bridge/lang-4.x/ast/parser/json/format.js +89 -2
- package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-expressions.js +2 -4
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +2 -1
- package/r-bridge/parser.d.ts +2 -0
- package/r-bridge/retriever.js +4 -1
- package/r-bridge/roxygen2/documentation-provider.js +2 -1
- package/r-bridge/shell.d.ts +5 -0
- package/r-bridge/shell.js +17 -1
- package/reconstruct/inline/source-inline-map.d.ts +48 -0
- package/reconstruct/inline/source-inline-map.js +94 -0
- package/reconstruct/reconstruct.d.ts +19 -2
- package/reconstruct/reconstruct.js +79 -16
- package/search/search-executor/search-generators.js +5 -22
- package/search/search-executor/search-transformer.js +10 -6
- package/slicing/criterion/parse.d.ts +28 -4
- package/slicing/criterion/parse.js +133 -18
- package/slicing/static/slice-call.d.ts +24 -1
- package/slicing/static/slice-call.js +90 -0
- package/slicing/static/static-slicer.d.ts +7 -0
- package/slicing/static/static-slicer.js +38 -3
- package/util/collections/arrays.d.ts +4 -5
- package/util/collections/arrays.js +7 -18
- package/util/hash.d.ts +14 -0
- package/util/hash.js +31 -0
- package/util/mermaid/dfg.d.ts +7 -2
- package/util/mermaid/dfg.js +53 -13
- package/util/r-base-packages.d.ts +19 -0
- package/util/r-base-packages.js +72 -0
- package/util/r-license.js +2 -10
- package/util/r-version.d.ts +45 -15
- package/util/r-version.js +97 -36
- package/util/range.d.ts +15 -0
- package/util/range.js +39 -0
- package/util/schema.d.ts +10 -0
- package/util/schema.js +22 -0
- package/util/text/ansi.d.ts +3 -0
- package/util/text/ansi.js +10 -0
- package/util/text/args.js +1 -2
- package/util/version.js +28 -8
- package/data/pkgdb/pkgdb-latest.json.br +0 -0
- package/data/pkgdb/pkgdb-tiny.json.br +0 -0
- package/documentation/wiki-package-database.d.ts +0 -9
- package/documentation/wiki-package-database.js +0 -63
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin.d.ts +0 -63
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin.js +0 -176
- package/project/plugins/package-version-plugins/pkgdb.d.ts +0 -133
- package/project/plugins/package-version-plugins/pkgdb.js +0 -370
- package/queries/catalog/df-shape-query/df-shape-query-executor.d.ts +0 -6
- package/queries/catalog/df-shape-query/df-shape-query-executor.js +0 -58
- package/queries/catalog/df-shape-query/df-shape-query-format.d.ts +0 -27
- package/queries/catalog/df-shape-query/df-shape-query-format.js +0 -56
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.signatureCommand = exports.signatureSubcommandNames = void 0;
|
|
4
|
+
exports.replSignatureCompleter = replSignatureCompleter;
|
|
5
|
+
const ansi_1 = require("../../../util/text/ansi");
|
|
6
|
+
const args_1 = require("../../../util/text/args");
|
|
7
|
+
const query_1 = require("../../../queries/query");
|
|
8
|
+
const signature_query_format_1 = require("../../../queries/catalog/signature-query/signature-query-format");
|
|
9
|
+
const query_print_1 = require("../../../queries/query-print");
|
|
10
|
+
const sigdb_download_1 = require("../../../project/sigdb/sigdb-download");
|
|
11
|
+
const retriever_1 = require("../../../r-bridge/retriever");
|
|
12
|
+
const signature_query_executor_1 = require("../../../queries/catalog/signature-query/signature-query-executor");
|
|
13
|
+
/** treat the whole line as arguments, no R code to separate */
|
|
14
|
+
function parseArgs(line) {
|
|
15
|
+
return { rCode: undefined, remaining: (0, args_1.splitAtEscapeSensitive)(line) };
|
|
16
|
+
}
|
|
17
|
+
/** the (possibly space-containing) path/argument remainder passed to a subcommand */
|
|
18
|
+
function joinArgs(args) {
|
|
19
|
+
return args.filter(a => a.length > 0).join(' ').trim();
|
|
20
|
+
}
|
|
21
|
+
function printHelp(output) {
|
|
22
|
+
const f = output.formatter;
|
|
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
|
+
output.stdout('');
|
|
25
|
+
output.stdout(` ${(0, ansi_1.bold)(':signature query', f)} ${(0, ansi_1.italic)('[<package>[@<version>][::<function>] [<function>]] [--all] [--full]', f)}`);
|
|
26
|
+
output.stdout(` ${(0, ansi_1.italic)('inspect the database -- identical to :query @signature (run :signature query help for the full syntax)', f)}`);
|
|
27
|
+
output.stdout(` ${(0, ansi_1.bold)(':signature add', f)} ${(0, ansi_1.italic)('<path-to-.sigs.ndjson|.br|.manifest.json>', f)}`);
|
|
28
|
+
output.stdout(` ${(0, ansi_1.italic)('mount an additional signature database/source (dictionaries + shards); takes precedence over the bundle', f)}`);
|
|
29
|
+
output.stdout(` ${(0, ansi_1.bold)(':signature download', f)} ${(0, ansi_1.italic)('[<version>]', f)}`);
|
|
30
|
+
output.stdout(` ${(0, ansi_1.italic)('download the full-history database (all CRAN versions) from the release and mount it', f)}`);
|
|
31
|
+
}
|
|
32
|
+
/** `:signature query ...` -- inspect the database (identical to the signature query run via `:query`) */
|
|
33
|
+
async function runQuery(output, analyzer, args) {
|
|
34
|
+
const parsed = signature_query_format_1.SignatureQueryDefinition.fromLine(output, args, analyzer.flowrConfig).query;
|
|
35
|
+
const queries = parsed ? (Array.isArray(parsed) ? parsed : [parsed]) : [];
|
|
36
|
+
if (queries.length === 0) {
|
|
37
|
+
return; // e.g. `:signature query help` already printed the usage guide
|
|
38
|
+
}
|
|
39
|
+
const start = Date.now();
|
|
40
|
+
const results = await (0, query_1.executeQueries)({ analyzer }, queries);
|
|
41
|
+
output.stdout(await (0, query_print_1.asciiSummaryOfQueryResult)(output.formatter, Date.now() - start, results, analyzer, queries));
|
|
42
|
+
}
|
|
43
|
+
/** `:signature add <path>` -- mount an additional signature database/source (takes precedence over the bundle) */
|
|
44
|
+
async function runAdd(output, analyzer, rest) {
|
|
45
|
+
const f = output.formatter;
|
|
46
|
+
const source = joinArgs(rest);
|
|
47
|
+
if (!source) {
|
|
48
|
+
output.stderr(`Usage: ${(0, ansi_1.italic)(':signature add <path-to-.sigs.ndjson|.br|.manifest.json>', f)}`);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
await analyzer.context().deps.addDatabaseSource(source);
|
|
52
|
+
analyzer.reset();
|
|
53
|
+
output.stdout(`Mounted signature source ${(0, ansi_1.bold)(source, f)} (takes precedence over the bundled default).`);
|
|
54
|
+
output.stdout((0, ansi_1.italic)('Inspect it with :signature query.', f));
|
|
55
|
+
}
|
|
56
|
+
/** `:signature download [<version>]` -- fetch the full-history database from the release and mount it */
|
|
57
|
+
async function runDownload(output, analyzer, rest) {
|
|
58
|
+
const f = output.formatter;
|
|
59
|
+
const sigdb = analyzer.flowrConfig.solver.sigdb;
|
|
60
|
+
try {
|
|
61
|
+
const { dir, manifest, files } = await (0, sigdb_download_1.downloadFullSigDb)({
|
|
62
|
+
version: rest.find(a => a.length > 0),
|
|
63
|
+
repo: sigdb.downloadRepo,
|
|
64
|
+
onProgress: msg => output.stdout((0, ansi_1.italic)(` ${msg}`, f))
|
|
65
|
+
});
|
|
66
|
+
output.stdout(`Downloaded ${(0, ansi_1.bold)(String(files.length), f)} file(s) to ${(0, ansi_1.bold)(dir, f)}.`);
|
|
67
|
+
if (manifest) {
|
|
68
|
+
await analyzer.context().deps.addDatabaseSource(manifest);
|
|
69
|
+
analyzer.reset();
|
|
70
|
+
output.stdout(`Mounted ${(0, ansi_1.bold)(manifest, f)}.`);
|
|
71
|
+
}
|
|
72
|
+
output.stdout((0, ansi_1.italic)(`Add "${dir}" to solver.sigdb.additionalPaths to keep it mounted on every start.`, f));
|
|
73
|
+
}
|
|
74
|
+
catch (e) {
|
|
75
|
+
output.stderr(`Download failed: ${e.message}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/** every `:signature` subcommand keyed by name -- the single source driving both dispatch and completion */
|
|
79
|
+
const signatureSubcommands = {
|
|
80
|
+
query: runQuery,
|
|
81
|
+
add: runAdd,
|
|
82
|
+
download: runDownload,
|
|
83
|
+
help: output => printHelp(output),
|
|
84
|
+
};
|
|
85
|
+
/** the `:signature` subcommand names, offered as completions for its first argument */
|
|
86
|
+
exports.signatureSubcommandNames = Object.keys(signatureSubcommands);
|
|
87
|
+
/** completes `:signature`: its subcommands, then a file path for `add` (query args are freeform names) */
|
|
88
|
+
function replSignatureCompleter(splitLine, startingNewArg) {
|
|
89
|
+
const subArgs = splitLine.slice(1).map(s => s.trim()).filter(s => s.length > 0);
|
|
90
|
+
const inSubArgs = subArgs.length >= 2 || (subArgs.length === 1 && startingNewArg);
|
|
91
|
+
if (!inSubArgs) {
|
|
92
|
+
return { completions: exports.signatureSubcommandNames.map(s => s + ' ') };
|
|
93
|
+
}
|
|
94
|
+
if (subArgs[0] === 'add') {
|
|
95
|
+
return { completions: [retriever_1.fileProtocol] };
|
|
96
|
+
}
|
|
97
|
+
if (subArgs[0] === 'query') {
|
|
98
|
+
return (0, signature_query_executor_1.signatureQueryCompleter)(subArgs.slice(1), startingNewArg);
|
|
99
|
+
}
|
|
100
|
+
return { completions: [] };
|
|
101
|
+
}
|
|
102
|
+
exports.signatureCommand = {
|
|
103
|
+
description: 'Inspect and extend the signature database: `query` (identical to :query @signature), `add <path>` to mount another database/source, `download` to fetch the full-history database.',
|
|
104
|
+
isCodeCommand: true,
|
|
105
|
+
usageExample: ':signature <query|add|download> ...',
|
|
106
|
+
aliases: ['sig'],
|
|
107
|
+
script: false,
|
|
108
|
+
argsParser: parseArgs,
|
|
109
|
+
fn: async ({ output, analyzer, remainingArgs }) => {
|
|
110
|
+
const [sub = 'help', ...rest] = remainingArgs.filter(a => a.length > 0);
|
|
111
|
+
const handler = signatureSubcommands[sub];
|
|
112
|
+
if (!handler) {
|
|
113
|
+
output.stderr(`Unknown subcommand ${(0, ansi_1.bold)(sub, output.formatter)}. Use ${(0, ansi_1.italic)(':signature help', output.formatter)}.`);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
await handler(output, analyzer, rest);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
//# sourceMappingURL=repl-signature.js.map
|
package/cli/repl/core.d.ts
CHANGED
|
@@ -17,9 +17,16 @@ export interface CommandCompletions {
|
|
|
17
17
|
readonly argumentPart?: string;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
|
-
* Used by the repl to provide automatic completions for a given (partial) input line
|
|
20
|
+
* Used by the repl to provide automatic completions for a given (partial) input line. Returns every matching
|
|
21
|
+
* option, so Tab shows the full menu and only completes when a single option remains (standard readline behavior).
|
|
21
22
|
*/
|
|
22
23
|
export declare function replCompleter(line: string, config: FlowrConfig): [string[], string];
|
|
24
|
+
/**
|
|
25
|
+
* The remaining text of the best (first) completion, i.e. what the inline ghost previews as you type; empty when
|
|
26
|
+
* there is nothing to suggest. Independent of {@link replCompleter}: the ghost hints the best match even when Tab
|
|
27
|
+
* would still offer several.
|
|
28
|
+
*/
|
|
29
|
+
export declare function completionSuggestion(line: string, config: FlowrConfig): string;
|
|
23
30
|
/**
|
|
24
31
|
* Produces default readline options for the flowR REPL
|
|
25
32
|
*/
|
package/cli/repl/core.js
CHANGED
|
@@ -38,6 +38,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.watchProtocol = void 0;
|
|
40
40
|
exports.replCompleter = replCompleter;
|
|
41
|
+
exports.completionSuggestion = completionSuggestion;
|
|
41
42
|
exports.makeDefaultReplReadline = makeDefaultReplReadline;
|
|
42
43
|
exports.handleString = handleString;
|
|
43
44
|
exports.toFileStatement = toFileStatement;
|
|
@@ -53,6 +54,7 @@ exports.loadReplHistory = loadReplHistory;
|
|
|
53
54
|
*/
|
|
54
55
|
const prompt_1 = require("./prompt");
|
|
55
56
|
const readline = __importStar(require("readline"));
|
|
57
|
+
const ghost_hint_1 = require("./ghost-hint");
|
|
56
58
|
const repl_execute_1 = require("./commands/repl-execute");
|
|
57
59
|
const os_1 = __importDefault(require("os"));
|
|
58
60
|
const path_1 = __importDefault(require("path"));
|
|
@@ -65,6 +67,7 @@ const retriever_1 = require("../../r-bridge/retriever");
|
|
|
65
67
|
const repl_main_1 = require("./commands/repl-main");
|
|
66
68
|
const log_1 = require("../../util/log");
|
|
67
69
|
const query_1 = require("../../queries/query");
|
|
70
|
+
const repl_signature_1 = require("./commands/repl-signature");
|
|
68
71
|
const strings_1 = require("../../util/text/strings");
|
|
69
72
|
const instrument_dataflow_count_1 = require("../../dataflow/instrument/instrument-dataflow-count");
|
|
70
73
|
const proc_1 = require("../../util/proc");
|
|
@@ -76,10 +79,7 @@ function replCompleterKeywords() {
|
|
|
76
79
|
return _replCompleterKeywords;
|
|
77
80
|
}
|
|
78
81
|
const defaultHistoryFile = path_1.default.join(os_1.default.tmpdir(), '.flowrhistory');
|
|
79
|
-
|
|
80
|
-
* Used by the repl to provide automatic completions for a given (partial) input line
|
|
81
|
-
*/
|
|
82
|
-
function replCompleter(line, config) {
|
|
82
|
+
function computeCompletions(line, config) {
|
|
83
83
|
const splitLine = (0, args_1.splitAtEscapeSensitive)(line);
|
|
84
84
|
// did we just type a space (and are starting a new arg right now)?
|
|
85
85
|
const startingNewArg = line.endsWith(' ');
|
|
@@ -103,7 +103,14 @@ function replCompleter(line, config) {
|
|
|
103
103
|
}
|
|
104
104
|
completions = completions.concat(queryCompletions);
|
|
105
105
|
}
|
|
106
|
-
else {
|
|
106
|
+
else if (cmd === repl_signature_1.signatureCommand) {
|
|
107
|
+
const { completions: sigCompletions, argumentPart: splitArg } = (0, repl_signature_1.replSignatureCompleter)(splitLine, startingNewArg);
|
|
108
|
+
if (splitArg !== undefined) {
|
|
109
|
+
currentArg = splitArg;
|
|
110
|
+
}
|
|
111
|
+
completions = completions.concat(sigCompletions);
|
|
112
|
+
}
|
|
113
|
+
else if (cmd?.isCodeCommand) {
|
|
107
114
|
completions.push(retriever_1.fileProtocol);
|
|
108
115
|
completions.push(exports.watchProtocol);
|
|
109
116
|
}
|
|
@@ -113,9 +120,35 @@ function replCompleter(line, config) {
|
|
|
113
120
|
// if no command is already typed, just return all commands that match
|
|
114
121
|
return [replCompleterKeywords().filter(k => k.startsWith(line)).map(k => `${k} `), line];
|
|
115
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* Used by the repl to provide automatic completions for a given (partial) input line. Returns every matching
|
|
125
|
+
* option, so Tab shows the full menu and only completes when a single option remains (standard readline behavior).
|
|
126
|
+
*/
|
|
127
|
+
function replCompleter(line, config) {
|
|
128
|
+
return computeCompletions(line, config);
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* The remaining text of the best (first) completion, i.e. what the inline ghost previews as you type; empty when
|
|
132
|
+
* there is nothing to suggest. Independent of {@link replCompleter}: the ghost hints the best match even when Tab
|
|
133
|
+
* would still offer several.
|
|
134
|
+
*/
|
|
135
|
+
function completionSuggestion(line, config) {
|
|
136
|
+
if (line.length === 0) {
|
|
137
|
+
return '';
|
|
138
|
+
}
|
|
139
|
+
const [completions, fragment] = computeCompletions(line, config);
|
|
140
|
+
const best = completions[0];
|
|
141
|
+
if (best === undefined || !best.startsWith(fragment) || best.length <= fragment.length) {
|
|
142
|
+
return '';
|
|
143
|
+
}
|
|
144
|
+
else if (best === retriever_1.fileProtocol || best === exports.watchProtocol) {
|
|
145
|
+
return '';
|
|
146
|
+
}
|
|
147
|
+
return best.slice(fragment.length);
|
|
148
|
+
}
|
|
116
149
|
function replQueryCompleter(splitLine, startingNewArg, config) {
|
|
117
150
|
const nonEmpty = splitLine.slice(1).map(s => s.trim()).filter(s => s.length > 0);
|
|
118
|
-
const queryShorts = Object.keys(query_1.SupportedQueries).map(q => `@${q}`)
|
|
151
|
+
const queryShorts = ['help'].concat(Object.keys(query_1.SupportedQueries).map(q => `@${q}`));
|
|
119
152
|
if (nonEmpty.length === 0 || (nonEmpty.length === 1 && queryShorts.some(q => q.startsWith(nonEmpty[0]) && nonEmpty[0] !== q && !startingNewArg))) {
|
|
120
153
|
return { completions: queryShorts.map(q => `${q} `) };
|
|
121
154
|
}
|
|
@@ -321,6 +354,9 @@ async function repl({ analyzer, rl = readline.createInterface(makeDefaultReplRea
|
|
|
321
354
|
if (historyFile) {
|
|
322
355
|
rl.on('history', h => fs_1.default.writeFileSync(historyFile, h.join('\n'), { encoding: 'utf-8' }));
|
|
323
356
|
}
|
|
357
|
+
const ghostHint = (0, ghost_hint_1.installGhostHint)(rl, analyzer.flowrConfig, {
|
|
358
|
+
suggest: line => completionSuggestion(line, analyzer.flowrConfig)
|
|
359
|
+
});
|
|
324
360
|
let sigintCount = 0;
|
|
325
361
|
rl.on('SIGINT', () => {
|
|
326
362
|
process.stdout.write('\n');
|
|
@@ -353,6 +389,7 @@ async function repl({ analyzer, rl = readline.createInterface(makeDefaultReplRea
|
|
|
353
389
|
while (true) {
|
|
354
390
|
await new Promise((resolve, reject) => {
|
|
355
391
|
rl.question(activeWatcher !== undefined ? '' : (0, prompt_1.prompt)(), answer => {
|
|
392
|
+
ghostHint.clear();
|
|
356
393
|
sigintCount = 0;
|
|
357
394
|
rl.pause();
|
|
358
395
|
replProcessAnswer(analyzer, output, answer, allowRSessionAccess).then(() => {
|
|
@@ -360,6 +397,9 @@ async function repl({ analyzer, rl = readline.createInterface(makeDefaultReplRea
|
|
|
360
397
|
resolve();
|
|
361
398
|
}).catch(reject);
|
|
362
399
|
});
|
|
400
|
+
if (activeWatcher === undefined) {
|
|
401
|
+
ghostHint.show();
|
|
402
|
+
}
|
|
363
403
|
});
|
|
364
404
|
}
|
|
365
405
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type readline from 'readline';
|
|
2
|
+
import type { EventEmitter } from 'events';
|
|
3
|
+
import type { FlowrConfig } from '../../config';
|
|
4
|
+
export declare const defaultReplHint = ":help \u00B7 Tab completes \u00B7 :query @config +repl.hints=false to hide";
|
|
5
|
+
/** ANSI that draws the dimmed `hint` and restores the cursor to where it was. */
|
|
6
|
+
export declare function ghostHintShowSequence(hint: string): string;
|
|
7
|
+
export declare const ghostHintClearSequence = "\u001B[0K";
|
|
8
|
+
export interface GhostHintIO {
|
|
9
|
+
stdin: EventEmitter & {
|
|
10
|
+
isTTY?: boolean;
|
|
11
|
+
};
|
|
12
|
+
stdout: {
|
|
13
|
+
isTTY?: boolean;
|
|
14
|
+
columns?: number;
|
|
15
|
+
write(s: string): unknown;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export interface GhostHintOptions {
|
|
19
|
+
hint?: string;
|
|
20
|
+
suggest?: (line: string) => string;
|
|
21
|
+
}
|
|
22
|
+
export interface GhostHintController {
|
|
23
|
+
show(): void;
|
|
24
|
+
clear(): void;
|
|
25
|
+
}
|
|
26
|
+
/** Whether hints may be shown: enabled in the config and on an interactive TTY (honoring `NO_COLOR`/`TERM=dumb`). */
|
|
27
|
+
export declare function ghostHintEnabled(config: FlowrConfig, env?: NodeJS.ProcessEnv, stdout?: {
|
|
28
|
+
isTTY?: boolean;
|
|
29
|
+
}, stdin?: {
|
|
30
|
+
isTTY?: boolean;
|
|
31
|
+
}): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Installs an opt-out ghost hint on the REPL prompt: a dim placeholder on the empty prompt and, as the user
|
|
34
|
+
* types, a dim preview of the best Tab-completion. A no-op on non-interactive terminals (see
|
|
35
|
+
* {@link ghostHintEnabled}) and whenever the text would not fit the line, so it can never wrap or corrupt output.
|
|
36
|
+
*/
|
|
37
|
+
export declare function installGhostHint(rl: readline.Interface, config: FlowrConfig, { hint, suggest }?: GhostHintOptions, io?: GhostHintIO): GhostHintController;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ghostHintClearSequence = exports.defaultReplHint = void 0;
|
|
4
|
+
exports.ghostHintShowSequence = ghostHintShowSequence;
|
|
5
|
+
exports.ghostHintEnabled = ghostHintEnabled;
|
|
6
|
+
exports.installGhostHint = installGhostHint;
|
|
7
|
+
exports.defaultReplHint = ':help · Tab completes · :query @config +repl.hints=false to hide';
|
|
8
|
+
/** ANSI that draws the dimmed `hint` and restores the cursor to where it was. */
|
|
9
|
+
function ghostHintShowSequence(hint) {
|
|
10
|
+
return `\x1b7\x1b[2m${hint}\x1b[0m\x1b8`;
|
|
11
|
+
}
|
|
12
|
+
exports.ghostHintClearSequence = '\x1b[0K';
|
|
13
|
+
const noopController = { show: () => { }, clear: () => { } };
|
|
14
|
+
/** Whether hints may be shown: enabled in the config and on an interactive TTY (honoring `NO_COLOR`/`TERM=dumb`). */
|
|
15
|
+
function ghostHintEnabled(config, env = process.env, stdout = process.stdout, stdin = process.stdin) {
|
|
16
|
+
return Boolean(config.repl.hints && stdout.isTTY && stdin.isTTY && !env.NO_COLOR && env.TERM !== 'dumb');
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Installs an opt-out ghost hint on the REPL prompt: a dim placeholder on the empty prompt and, as the user
|
|
20
|
+
* types, a dim preview of the best Tab-completion. A no-op on non-interactive terminals (see
|
|
21
|
+
* {@link ghostHintEnabled}) and whenever the text would not fit the line, so it can never wrap or corrupt output.
|
|
22
|
+
*/
|
|
23
|
+
function installGhostHint(rl, config, { hint = exports.defaultReplHint, suggest } = {}, io = { stdin: process.stdin, stdout: process.stdout }) {
|
|
24
|
+
if (!ghostHintEnabled(config, process.env, io.stdout, io.stdin)) {
|
|
25
|
+
return noopController;
|
|
26
|
+
}
|
|
27
|
+
const state = rl;
|
|
28
|
+
const getLine = () => state.line ?? '';
|
|
29
|
+
const cursorAtEnd = () => state.cursor === undefined || state.cursor === getLine().length;
|
|
30
|
+
const fits = (text) => getLine().length + text.length + 6 < (io.stdout.columns ?? 80);
|
|
31
|
+
let shown = false;
|
|
32
|
+
const clear = () => {
|
|
33
|
+
if (shown) {
|
|
34
|
+
io.stdout.write(exports.ghostHintClearSequence);
|
|
35
|
+
shown = false;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const render = (text) => {
|
|
39
|
+
clear();
|
|
40
|
+
if (text && fits(text)) {
|
|
41
|
+
io.stdout.write(ghostHintShowSequence(text));
|
|
42
|
+
shown = true;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
const update = () => {
|
|
46
|
+
if (!config.repl.hints) {
|
|
47
|
+
clear();
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const line = getLine();
|
|
51
|
+
if (line.length === 0) {
|
|
52
|
+
render(hint);
|
|
53
|
+
}
|
|
54
|
+
else if (cursorAtEnd()) {
|
|
55
|
+
render(suggest?.(line) ?? '');
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
clear();
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
io.stdin.prependListener('keypress', clear);
|
|
62
|
+
io.stdin.on('keypress', (_s, key) => {
|
|
63
|
+
if (!isSubmitKey(key)) {
|
|
64
|
+
update();
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
return { show: update, clear };
|
|
68
|
+
}
|
|
69
|
+
function isSubmitKey(key) {
|
|
70
|
+
return key?.name === 'return' || key?.name === 'enter';
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=ghost-hint.js.map
|
|
@@ -3,9 +3,19 @@ import { SliceDirection } from '../../../util/slice-direction';
|
|
|
3
3
|
import type { CommandCompletions } from '../core';
|
|
4
4
|
import type { FlowrConfig } from '../../../config';
|
|
5
5
|
/**
|
|
6
|
-
* Checks whether the given argument represents a slicing direction with an `f` suffix.
|
|
6
|
+
* Checks whether the given argument represents a slicing direction with an `f` suffix (in any flag order).
|
|
7
7
|
*/
|
|
8
8
|
export declare function sliceDirectionParser(argument: string): SliceDirection;
|
|
9
|
+
/**
|
|
10
|
+
* Whether the argument requests inline slicing via an `i` suffix (e.g. `(12@x)i`, `(12@x)fi`), which inlines
|
|
11
|
+
* resolvable `source()` calls into the reconstruction so the slice is a single self-contained R text.
|
|
12
|
+
*/
|
|
13
|
+
export declare function sliceInlineParser(argument: string): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Whether the argument requests to slice past function-definition boundaries via a `c` suffix
|
|
16
|
+
* (e.g. `(12@x)c`, `(12@x)ic`), including the definition's binding and call sites in a backward slice.
|
|
17
|
+
*/
|
|
18
|
+
export declare function sliceIncludeCalleesParser(argument: string): boolean;
|
|
9
19
|
/**
|
|
10
20
|
* Parses a single slicing criterion from the given argument.
|
|
11
21
|
*/
|
|
@@ -1,37 +1,67 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.sliceDirectionParser = sliceDirectionParser;
|
|
4
|
+
exports.sliceInlineParser = sliceInlineParser;
|
|
5
|
+
exports.sliceIncludeCalleesParser = sliceIncludeCalleesParser;
|
|
4
6
|
exports.sliceCriterionParser = sliceCriterionParser;
|
|
5
7
|
exports.sliceCriteriaParser = sliceCriteriaParser;
|
|
6
8
|
exports.criteriaQueryCompleter = criteriaQueryCompleter;
|
|
7
9
|
exports.diceCriteriaParser = diceCriteriaParser;
|
|
8
10
|
const slice_direction_1 = require("../../../util/slice-direction");
|
|
9
11
|
/**
|
|
10
|
-
*
|
|
12
|
+
* Splits `(criteria)flags` into its two parts, matching the closing bracket by depth: a criterion may well
|
|
13
|
+
* carry brackets of its own (the `(file-regex)` suffix of e.g. `2@x(tmp/.*)`), so the first `)` is not it.
|
|
14
|
+
* Returns `undefined` if the argument does not start with a bracket, or if that bracket is never closed.
|
|
15
|
+
*/
|
|
16
|
+
function splitCriteriaArgument(argument) {
|
|
17
|
+
if (!argument?.startsWith('(')) {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
let depth = 0;
|
|
21
|
+
for (let i = 0; i < argument.length; i++) {
|
|
22
|
+
if (argument[i] === '(') {
|
|
23
|
+
depth++;
|
|
24
|
+
}
|
|
25
|
+
else if (argument[i] === ')' && --depth === 0) {
|
|
26
|
+
return { criteria: argument.slice(1, i), flags: argument.slice(i + 1) };
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
function sliceFlagSuffix(argument) {
|
|
32
|
+
return splitCriteriaArgument(argument)?.flags ?? '';
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Checks whether the given argument represents a slicing direction with an `f` suffix (in any flag order).
|
|
11
36
|
*/
|
|
12
37
|
function sliceDirectionParser(argument) {
|
|
13
|
-
|
|
14
|
-
|
|
38
|
+
return sliceFlagSuffix(argument).includes('f') ? slice_direction_1.SliceDirection.Forward : slice_direction_1.SliceDirection.Backward;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Whether the argument requests inline slicing via an `i` suffix (e.g. `(12@x)i`, `(12@x)fi`), which inlines
|
|
42
|
+
* resolvable `source()` calls into the reconstruction so the slice is a single self-contained R text.
|
|
43
|
+
*/
|
|
44
|
+
function sliceInlineParser(argument) {
|
|
45
|
+
return sliceFlagSuffix(argument).includes('i');
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Whether the argument requests to slice past function-definition boundaries via a `c` suffix
|
|
49
|
+
* (e.g. `(12@x)c`, `(12@x)ic`), including the definition's binding and call sites in a backward slice.
|
|
50
|
+
*/
|
|
51
|
+
function sliceIncludeCalleesParser(argument) {
|
|
52
|
+
return sliceFlagSuffix(argument).includes('c');
|
|
15
53
|
}
|
|
16
54
|
/**
|
|
17
55
|
* Parses a single slicing criterion from the given argument.
|
|
18
56
|
*/
|
|
19
57
|
function sliceCriterionParser(argument) {
|
|
20
|
-
|
|
21
|
-
const endBracket = argument.indexOf(')');
|
|
22
|
-
return argument.slice(1, endBracket);
|
|
23
|
-
}
|
|
58
|
+
return splitCriteriaArgument(argument)?.criteria;
|
|
24
59
|
}
|
|
25
60
|
/**
|
|
26
61
|
* Parses multiple slicing criteria from the given argument.
|
|
27
62
|
*/
|
|
28
63
|
function sliceCriteriaParser(argument) {
|
|
29
|
-
|
|
30
|
-
const endBracket = argument.indexOf(')');
|
|
31
|
-
const criteriaPart = argument.slice(1, endBracket);
|
|
32
|
-
const criteria = criteriaPart.split(';');
|
|
33
|
-
return criteria;
|
|
34
|
-
}
|
|
64
|
+
return splitCriteriaArgument(argument)?.criteria.split(';');
|
|
35
65
|
}
|
|
36
66
|
/** Last partial criterion fragment after the most recent `;` or after `(`. */
|
|
37
67
|
function lastCriterionFragment(arg) {
|
|
@@ -67,11 +97,10 @@ function criteriaQueryCompleter(line, startingNewArg, _config) {
|
|
|
67
97
|
* Each side is a semicolon-separated list of slicing criteria; a single criterion needs no semicolon.
|
|
68
98
|
*/
|
|
69
99
|
function diceCriteriaParser(argument) {
|
|
70
|
-
|
|
100
|
+
const inner = splitCriteriaArgument(argument)?.criteria;
|
|
101
|
+
if (inner === undefined) {
|
|
71
102
|
return undefined;
|
|
72
103
|
}
|
|
73
|
-
const endBracket = argument.indexOf(')');
|
|
74
|
-
const inner = argument.slice(1, endBracket);
|
|
75
104
|
const arrowIdx = inner.indexOf('->');
|
|
76
105
|
if (arrowIdx < 0) {
|
|
77
106
|
return undefined;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import type { KnownParser } from '../../r-bridge/parser';
|
|
2
|
-
/** a short `, package database: <scope> <date>` suffix for the bundled database, or empty if none */
|
|
3
|
-
export declare function pkgDbReplSuffix(): string;
|
|
4
2
|
/**
|
|
5
|
-
* Returns a version string for the REPL including flowR, R, and the
|
|
3
|
+
* Returns a version string for the REPL including flowR, R, and the engine in use.
|
|
6
4
|
*/
|
|
7
5
|
export declare function versionReplString(parser: KnownParser): Promise<string>;
|
|
8
6
|
/**
|
|
9
|
-
* Prints the version information for the REPL including flowR and
|
|
7
|
+
* Prints the version information for the REPL including flowR, R, and the bundled signature databases.
|
|
10
8
|
*/
|
|
11
9
|
export declare function printVersionRepl(parser: KnownParser): Promise<void>;
|
|
@@ -1,40 +1,58 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.pkgDbReplSuffix = pkgDbReplSuffix;
|
|
4
3
|
exports.versionReplString = versionReplString;
|
|
5
4
|
exports.printVersionRepl = printVersionRepl;
|
|
6
5
|
const version_1 = require("../../util/version");
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
try {
|
|
11
|
-
if (typeof process !== 'undefined' && process.env?.FLOWR_DISABLE_DEFAULT_PKGDB) {
|
|
12
|
-
return '';
|
|
13
|
-
}
|
|
14
|
-
const path = (0, pkgdb_1.defaultPkgDbPath)();
|
|
15
|
-
if (path === undefined) {
|
|
16
|
-
return '';
|
|
17
|
-
}
|
|
18
|
-
const db = pkgdb_1.PkgDatabase.fromFileSync(path);
|
|
19
|
-
return `, pkg-db: ${db.scope}/${db.content.date}`;
|
|
20
|
-
}
|
|
21
|
-
catch {
|
|
22
|
-
return '';
|
|
23
|
-
}
|
|
24
|
-
}
|
|
6
|
+
const manifest_1 = require("../../project/sigdb/manifest");
|
|
7
|
+
const ansi_1 = require("../../util/text/ansi");
|
|
8
|
+
const node_url_1 = require("node:url");
|
|
25
9
|
/**
|
|
26
|
-
* Returns a version string for the REPL including flowR, R, and the
|
|
10
|
+
* Returns a version string for the REPL including flowR, R, and the engine in use.
|
|
27
11
|
*/
|
|
28
12
|
async function versionReplString(parser) {
|
|
29
13
|
const version = await (0, version_1.retrieveVersionInformation)(parser);
|
|
30
14
|
const rVersion = version.r === 'none' ? '' : version.r === 'unknown' ? ', R version unknown' : `, R v${version.r}`;
|
|
31
15
|
const treeSitterVer = parser.name === 'tree-sitter' ? `, R grammar v${parser.treeSitterVersion()}` : '';
|
|
32
|
-
return `flowR repl v${version.flowr}${rVersion}${treeSitterVer} (${version.engine} engine
|
|
16
|
+
return `flowR repl v${version.flowr}${rVersion}${treeSitterVer} (${version.engine} engine)`;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Compact, dimmed note on the bundled signature databases (merged into the engine parenthesis): one linked ref per
|
|
20
|
+
* scope present on disk (`current`, `full-history`) with its last update; `base` only when nothing richer ships.
|
|
21
|
+
* The full history is on disk as `history.*` (mounted alongside `current.*`), or a merged `full.*` in a baked container.
|
|
22
|
+
*/
|
|
23
|
+
function sigDbSummaryString() {
|
|
24
|
+
const it = (s) => (0, ansi_1.italic)(s, ansi_1.formatter);
|
|
25
|
+
const entries = [];
|
|
26
|
+
const add = (label, file) => {
|
|
27
|
+
if (file === undefined) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
let date;
|
|
31
|
+
try {
|
|
32
|
+
date = (0, manifest_1.readManifestFile)(file).date;
|
|
33
|
+
}
|
|
34
|
+
catch { /* a corrupt/unreadable manifest must not break --version */ }
|
|
35
|
+
entries.push({ label, file, date });
|
|
36
|
+
};
|
|
37
|
+
add('current', (0, manifest_1.defaultSigDbPath)('current'));
|
|
38
|
+
add('full-history', (0, manifest_1.defaultSigDbPath)('full') ?? (0, manifest_1.defaultSigDbPath)('history'));
|
|
39
|
+
if (entries.length === 0) {
|
|
40
|
+
add('base', (0, manifest_1.defaultSigDbPath)('base'));
|
|
41
|
+
}
|
|
42
|
+
if (entries.length === 0) {
|
|
43
|
+
return it('no sigdb');
|
|
44
|
+
}
|
|
45
|
+
const link = (text, file) => it(ansi_1.formatter.hyperlink(text, (0, node_url_1.pathToFileURL)(file).href));
|
|
46
|
+
// if every ref shares the same date, print it once
|
|
47
|
+
const shared = entries.every(e => e.date !== undefined && e.date === entries[0].date) ? entries[0].date : undefined;
|
|
48
|
+
const refs = entries.map(e => link(shared === undefined && e.date !== undefined ? `${e.label} ${e.date}` : e.label, e.file));
|
|
49
|
+
return it('sigdb: ') + refs.join(it(', ')) + (shared !== undefined ? it(` ${shared}`) : '');
|
|
33
50
|
}
|
|
34
51
|
/**
|
|
35
|
-
* Prints the version information for the REPL including flowR and
|
|
52
|
+
* Prints the version information for the REPL including flowR, R, and the bundled signature databases.
|
|
36
53
|
*/
|
|
37
54
|
async function printVersionRepl(parser) {
|
|
38
|
-
|
|
55
|
+
const sigdb = sigDbSummaryString();
|
|
56
|
+
console.log((await versionReplString(parser)).replace(/\)$/, () => `, ${sigdb})`));
|
|
39
57
|
}
|
|
40
58
|
//# sourceMappingURL=print-version.js.map
|
|
@@ -194,7 +194,6 @@ class FlowRServerConnection {
|
|
|
194
194
|
cfg = await analyzer.controlflow();
|
|
195
195
|
}
|
|
196
196
|
const config = () => ({ context: message.filename ?? 'unknown', getId: (0, quads_1.defaultQuadIdGenerator)() });
|
|
197
|
-
const sanitizedResults = sanitizeAnalysisResults(await analyzer.parse(), await analyzer.normalize(), await analyzer.dataflow());
|
|
198
197
|
if (message.format === 'n-quads') {
|
|
199
198
|
(0, send_1.sendMessage)(this.socket, {
|
|
200
199
|
type: 'response-file-analysis',
|
|
@@ -208,23 +207,26 @@ class FlowRServerConnection {
|
|
|
208
207
|
}
|
|
209
208
|
});
|
|
210
209
|
}
|
|
211
|
-
else if (message.format === 'compact') {
|
|
212
|
-
(0, send_1.sendMessage)(this.socket, {
|
|
213
|
-
type: 'response-file-analysis',
|
|
214
|
-
format: 'compact',
|
|
215
|
-
id: message.id,
|
|
216
|
-
cfg: cfg ? (0, compact_1.compact)(cfg) : undefined,
|
|
217
|
-
results: (0, compact_1.compact)(sanitizedResults)
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
210
|
else {
|
|
221
|
-
(
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
211
|
+
const sanitizedResults = sanitizeAnalysisResults(await analyzer.parse(), await analyzer.normalize(), await analyzer.dataflow());
|
|
212
|
+
if (message.format === 'compact') {
|
|
213
|
+
(0, send_1.sendMessage)(this.socket, {
|
|
214
|
+
type: 'response-file-analysis',
|
|
215
|
+
format: 'compact',
|
|
216
|
+
id: message.id,
|
|
217
|
+
cfg: cfg ? (0, compact_1.compact)(cfg) : undefined,
|
|
218
|
+
results: (0, compact_1.compact)(sanitizedResults)
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
(0, send_1.sendMessage)(this.socket, {
|
|
223
|
+
type: 'response-file-analysis',
|
|
224
|
+
format: 'json',
|
|
225
|
+
id: message.id,
|
|
226
|
+
cfg,
|
|
227
|
+
results: sanitizedResults
|
|
228
|
+
});
|
|
229
|
+
}
|
|
228
230
|
}
|
|
229
231
|
}
|
|
230
232
|
async createAnalyzerForRequest(message, tempFile) {
|