@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,461 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cranPageUrl = cranPageUrl;
|
|
4
|
+
exports.cranMirrorSourceUrl = cranMirrorSourceUrl;
|
|
5
|
+
exports.signatureFunctionInfo = signatureFunctionInfo;
|
|
6
|
+
exports.signaturePackageInfo = signaturePackageInfo;
|
|
7
|
+
exports.signatureQueryCompleter = signatureQueryCompleter;
|
|
8
|
+
exports.executeSignatureQuery = executeSignatureQuery;
|
|
9
|
+
const semver_1 = require("semver");
|
|
10
|
+
const reader_1 = require("../../../project/sigdb/reader");
|
|
11
|
+
const schema_1 = require("../../../project/sigdb/schema");
|
|
12
|
+
const manifest_1 = require("../../../project/sigdb/manifest");
|
|
13
|
+
const r_version_1 = require("../../../util/r-version");
|
|
14
|
+
/** the CRAN package landing page (only meaningful for CRAN packages, not base R) */
|
|
15
|
+
function cranPageUrl(pkg) {
|
|
16
|
+
return `https://cran.r-project.org/package=${encodeURIComponent(pkg)}`;
|
|
17
|
+
}
|
|
18
|
+
/** whether a pattern uses glob wildcards (`*`, `?`) */
|
|
19
|
+
function hasGlob(pattern) {
|
|
20
|
+
return pattern !== undefined && /[*?]/.test(pattern);
|
|
21
|
+
}
|
|
22
|
+
/** compile a glob (`*` matches any run, `?` matches one char) into an anchored, case-sensitive RegExp */
|
|
23
|
+
function globToRegExp(glob) {
|
|
24
|
+
const escaped = glob.replace(/[.+^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '.*').replace(/\?/g, '.');
|
|
25
|
+
return new RegExp(`^${escaped}$`);
|
|
26
|
+
}
|
|
27
|
+
/** a name matcher: exact equality, or a glob test when the pattern uses wildcards */
|
|
28
|
+
function nameMatcher(pattern) {
|
|
29
|
+
if (hasGlob(pattern)) {
|
|
30
|
+
const re = globToRegExp(pattern);
|
|
31
|
+
return name => re.test(name);
|
|
32
|
+
}
|
|
33
|
+
return name => name === pattern;
|
|
34
|
+
}
|
|
35
|
+
/** whether a version spec can match more than one release (a glob or a semver range, not a single exact version) */
|
|
36
|
+
function isMultiVersion(spec) {
|
|
37
|
+
return /[*?xX]/.test(spec) || /[<>~^=]/.test(spec) || spec.includes('||') || spec.includes(' - ');
|
|
38
|
+
}
|
|
39
|
+
/** a version matcher for a spec: glob (`3.*`), semver range (`>=3.0.0`, `3.x`), or an exact version */
|
|
40
|
+
function versionMatcher(spec) {
|
|
41
|
+
if (hasGlob(spec)) {
|
|
42
|
+
const re = globToRegExp(spec);
|
|
43
|
+
return v => re.test(v);
|
|
44
|
+
}
|
|
45
|
+
const range = (0, semver_1.validRange)(spec, { loose: true });
|
|
46
|
+
if (range !== null) {
|
|
47
|
+
return v => {
|
|
48
|
+
const parsed = r_version_1.RVersion.parse(v);
|
|
49
|
+
return parsed !== undefined ? (0, semver_1.satisfies)(parsed, range, { loose: true, includePrerelease: true }) : v === spec;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
return v => v === spec;
|
|
53
|
+
}
|
|
54
|
+
/** the versions of a package the loaded source can answer (dated releases, base-R core releases, and the latest) */
|
|
55
|
+
function availableVersions(src, pkg) {
|
|
56
|
+
const set = new Set();
|
|
57
|
+
for (const r of src.releaseDates(pkg)) {
|
|
58
|
+
set.add(r.version.str);
|
|
59
|
+
}
|
|
60
|
+
for (const v of src.coreVersions(pkg) ?? []) {
|
|
61
|
+
set.add(v.str);
|
|
62
|
+
}
|
|
63
|
+
const latest = src.latestVersion(pkg);
|
|
64
|
+
if (latest) {
|
|
65
|
+
set.add(latest.str);
|
|
66
|
+
}
|
|
67
|
+
return [...set].sort((a, b) => r_version_1.RVersion.compare(a, b));
|
|
68
|
+
}
|
|
69
|
+
/** read-only CRAN GitHub mirror base; `github.com/cran/<pkg>` mirrors every CRAN package and tags each release */
|
|
70
|
+
const CranGithubMirror = 'https://github.com/cran';
|
|
71
|
+
/** the mirror repository of a CRAN package */
|
|
72
|
+
function cranMirrorRepoUrl(pkg) {
|
|
73
|
+
return `${CranGithubMirror}/${encodeURIComponent(pkg)}`;
|
|
74
|
+
}
|
|
75
|
+
/** deep-link a definition into the CRAN mirror at the package's version tag (falling back to `HEAD`) */
|
|
76
|
+
function cranMirrorSourceUrl(pkg, version, file, line) {
|
|
77
|
+
const ref = version ? encodeURIComponent(version) : 'HEAD';
|
|
78
|
+
const anchor = line !== undefined && line >= 0 ? `#L${line}` : '';
|
|
79
|
+
return `${cranMirrorRepoUrl(pkg)}/blob/${ref}/${file}${anchor}`;
|
|
80
|
+
}
|
|
81
|
+
/** function/topic names that map cleanly to an rdrr.io man page (skip operators like `+.gg`, `[.data.frame`) */
|
|
82
|
+
const RdrrTopicName = /^[A-Za-z.][A-Za-z0-9._]*$/;
|
|
83
|
+
/** best-effort rdrr.io documentation link: `/r/<pkg>/<fn>` for base R, `/cran/<pkg>/man/<fn>` for CRAN */
|
|
84
|
+
function rdrrDocUrl(pkg, fn, opts) {
|
|
85
|
+
if (!RdrrTopicName.test(fn)) {
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
88
|
+
if (opts.base) {
|
|
89
|
+
return `https://rdrr.io/r/${pkg}/${fn}.html`;
|
|
90
|
+
}
|
|
91
|
+
if (opts.cran) {
|
|
92
|
+
return `https://rdrr.io/cran/${pkg}/man/${fn}.html`;
|
|
93
|
+
}
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
/** the trailing fields shared by every function view: definition location, CRAN-mirror source link, rdrr.io doc link */
|
|
97
|
+
function locationFields(pkg, fn, version, base, cran) {
|
|
98
|
+
const doc = rdrrDocUrl(pkg, fn.name, { base, cran });
|
|
99
|
+
return {
|
|
100
|
+
...(fn.file ? { file: fn.file } : {}),
|
|
101
|
+
...(fn.line >= 0 ? { line: fn.line } : {}),
|
|
102
|
+
...(cran && !base && fn.file ? { sourceUrl: cranMirrorSourceUrl(pkg, version, fn.file, fn.line) } : {}),
|
|
103
|
+
...(doc ? { docUrl: doc } : {})
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/** the decoded view of one function, adding the CRAN-mirror source link and rdrr.io documentation link */
|
|
107
|
+
function decodedToView(pkg, fn, version, opts) {
|
|
108
|
+
return {
|
|
109
|
+
name: fn.name,
|
|
110
|
+
package: pkg,
|
|
111
|
+
...(version !== undefined ? { version } : {}),
|
|
112
|
+
exported: fn.exported,
|
|
113
|
+
properties: fn.props,
|
|
114
|
+
parameters: fn.signature.map(p => ({
|
|
115
|
+
name: p.name,
|
|
116
|
+
required: !p.optional,
|
|
117
|
+
forced: p.forced,
|
|
118
|
+
...(p.default !== undefined ? { default: p.default } : {})
|
|
119
|
+
})),
|
|
120
|
+
callees: fn.callees,
|
|
121
|
+
...locationFields(pkg, fn, version, opts.base, opts.cran)
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* The detailed view of a single function within a package: its signature (parameters, forced/optional,
|
|
126
|
+
* defaults), properties, definition location, call graph, and -- for a CRAN package -- a deep link into the
|
|
127
|
+
* read-only CRAN GitHub mirror. `version` defaults to the source's latest; `undefined` when the source does
|
|
128
|
+
* not carry that function.
|
|
129
|
+
*/
|
|
130
|
+
function signatureFunctionInfo(src, pkg, fnName, version) {
|
|
131
|
+
const fns = src.functions(pkg, version) ?? src.functions(pkg);
|
|
132
|
+
const fn = fns?.find(f => f.name === fnName);
|
|
133
|
+
if (fn === undefined) {
|
|
134
|
+
return undefined;
|
|
135
|
+
}
|
|
136
|
+
const exports = src.lookup(pkg, version) ?? src.lookup(pkg);
|
|
137
|
+
const view = decodedToView(pkg, fn, exports?.version, { cran: exports?.cran ?? false, base: src.isBaseR(pkg) });
|
|
138
|
+
// S3 dispatch targets are the `<generic>.<class>` functions in the same package (name-based, matching flowR's
|
|
139
|
+
// own S3 handling). We use this rather than the stored `UseMethod` callee, which the bundled call graphs
|
|
140
|
+
// aggregate transitively and so cannot distinguish a real generic from one that merely reaches a dispatch.
|
|
141
|
+
const methods = (fns ?? [])
|
|
142
|
+
.filter(f => f.name !== fn.name && f.name.startsWith(fn.name + '.'))
|
|
143
|
+
.map(f => f.name)
|
|
144
|
+
.sort();
|
|
145
|
+
if (methods.length > 0) {
|
|
146
|
+
return { ...view, s3generic: true, s3methods: methods };
|
|
147
|
+
}
|
|
148
|
+
return view;
|
|
149
|
+
}
|
|
150
|
+
/** the full view of a package: version, kind, export breakdown, dependencies, and every function's view */
|
|
151
|
+
function signaturePackageInfo(src, pkg, resolved) {
|
|
152
|
+
const exports = src.lookup(pkg, resolved) ?? src.lookup(pkg);
|
|
153
|
+
if (exports === undefined) {
|
|
154
|
+
return undefined;
|
|
155
|
+
}
|
|
156
|
+
const base = src.isBaseR(pkg);
|
|
157
|
+
const fns = src.functions(pkg, resolved) ?? src.functions(pkg) ?? [];
|
|
158
|
+
const fnNames = new Set(fns.map(f => f.name));
|
|
159
|
+
const constants = exports.exported.filter(n => !fnNames.has(n));
|
|
160
|
+
const deps = (src.dependencies(pkg, resolved) ?? src.dependencies(pkg) ?? [])
|
|
161
|
+
.map(d => ({ type: schema_1.DepTypeNames[d.type], name: d.name, ...(d.constraint ? { constraint: d.constraint } : {}) }));
|
|
162
|
+
const release = src.releaseDate(pkg, resolved);
|
|
163
|
+
return {
|
|
164
|
+
name: pkg,
|
|
165
|
+
version: exports.version,
|
|
166
|
+
...(resolved && resolved !== exports.version ? { resolved } : {}),
|
|
167
|
+
base,
|
|
168
|
+
cran: exports.cran,
|
|
169
|
+
...(exports.cranUrl ? { cranUrl: exports.cranUrl } : {}),
|
|
170
|
+
...(exports.cran && !base ? { cranPage: cranPageUrl(pkg), repoUrl: cranMirrorRepoUrl(pkg) } : {}),
|
|
171
|
+
...(release && !Number.isNaN(release.getTime()) ? { releaseDate: release.toISOString().slice(0, 10) } : {}),
|
|
172
|
+
exportsTotal: exports.exported.length,
|
|
173
|
+
functionCount: exports.exported.length - constants.length,
|
|
174
|
+
constants,
|
|
175
|
+
internalCount: exports.internal.length,
|
|
176
|
+
deprecated: exports.deprecated,
|
|
177
|
+
...(base && src.coreVersions(pkg) ? { coreVersions: src.coreVersions(pkg)?.map(v => v.str) } : {}),
|
|
178
|
+
dependencies: deps,
|
|
179
|
+
functions: fns.map(f => decodedToView(pkg, f, exports.version, { cran: exports.cran, base }))
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
/** a few near matches for a mistyped package/symbol (case-insensitive substring), for a friendly hint */
|
|
183
|
+
function suggest(candidates, query, limit = 6) {
|
|
184
|
+
const needle = query.toLowerCase();
|
|
185
|
+
const out = [];
|
|
186
|
+
for (const c of candidates) {
|
|
187
|
+
if (c.toLowerCase().includes(needle)) {
|
|
188
|
+
out.push(c);
|
|
189
|
+
if (out.length >= limit) {
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return out;
|
|
195
|
+
}
|
|
196
|
+
/** cap on wildcard-search hits, so a `* *` search cannot exhaust memory */
|
|
197
|
+
const MaxMatches = 500;
|
|
198
|
+
/** a compact view for a wildcard search hit (signature/call-graph omitted; the JSON dump carries those per name) */
|
|
199
|
+
function compactMatch(pkg, fn, version, base, cran) {
|
|
200
|
+
const doc = rdrrDocUrl(pkg, fn.name, { base, cran });
|
|
201
|
+
return {
|
|
202
|
+
package: pkg,
|
|
203
|
+
name: fn.name,
|
|
204
|
+
exported: fn.exported,
|
|
205
|
+
...(version !== undefined ? { version } : {}),
|
|
206
|
+
...(fn.file ? { file: fn.file } : {}),
|
|
207
|
+
...(fn.line >= 0 ? { line: fn.line } : {}),
|
|
208
|
+
...(cran && !base && fn.file ? { sourceUrl: cranMirrorSourceUrl(pkg, version, fn.file, fn.line) } : {}),
|
|
209
|
+
...(doc ? { docUrl: doc } : {})
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
/** the versions of a package across every loaded source that holds it (current + history + any mounted extra) */
|
|
213
|
+
function allAvailableVersions(sources, pkg) {
|
|
214
|
+
const set = new Set();
|
|
215
|
+
for (const s of sources) {
|
|
216
|
+
if (s.has(pkg)) {
|
|
217
|
+
for (const v of availableVersions(s, pkg)) {
|
|
218
|
+
set.add(v);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return [...set].sort((a, b) => r_version_1.RVersion.compare(a, b));
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* The owning source that actually carries `version` -- `current` is checked before `history`, so a
|
|
226
|
+
* latest-version query never decompresses the (large) history shard. Returns the first owner when no version
|
|
227
|
+
* was asked, or `undefined` when an explicit version is carried by none of them.
|
|
228
|
+
*/
|
|
229
|
+
function sourceForVersion(owning, pkg, version) {
|
|
230
|
+
if (version === undefined) {
|
|
231
|
+
return owning[0];
|
|
232
|
+
}
|
|
233
|
+
return owning.find(s => availableVersions(s, pkg).includes(version));
|
|
234
|
+
}
|
|
235
|
+
/** the message shown when a known package has no release matching the requested version, listing what is available */
|
|
236
|
+
function versionNotFoundMessage(pkg, lead, avail, base) {
|
|
237
|
+
// only nudge towards a full-history bundle when one is *not* already mounted (a single known version)
|
|
238
|
+
const hint = !base && avail.length <= 1
|
|
239
|
+
? ' Only the latest CRAN version is loaded; download the full history with `:signature download` (or mount one with `:signature add <path>`).'
|
|
240
|
+
: '';
|
|
241
|
+
return `${lead}${avail.length ? ` Available: ${avail.join(', ')}.` : ''}${hint}`;
|
|
242
|
+
}
|
|
243
|
+
/** run a wildcard search across the loaded sources: matching packages (no function), or matching functions */
|
|
244
|
+
function searchSources(sources, allNames, q) {
|
|
245
|
+
const cap = MaxMatches;
|
|
246
|
+
const pkgMatch = nameMatcher(q.package);
|
|
247
|
+
const matchedPkgs = [...allNames].filter(pkgMatch).sort();
|
|
248
|
+
const verMatch = q.version ? versionMatcher(q.version) : undefined;
|
|
249
|
+
// every source holding a package (its latest lives in `current`, its older releases in `history`)
|
|
250
|
+
const owningOf = (pkg) => sources.filter(s => s.has(pkg));
|
|
251
|
+
// the versions of `pkg` matching `m`, unioned across all owning sources (so a `3.*` filter reaches history)
|
|
252
|
+
const matchingVersions = (owners, pkg, m) => [...new Set(owners.flatMap(s => availableVersions(s, pkg).filter(m)))];
|
|
253
|
+
if (!q.function) {
|
|
254
|
+
const packages = [];
|
|
255
|
+
let truncated = false;
|
|
256
|
+
for (const pkg of matchedPkgs) {
|
|
257
|
+
const owners = owningOf(pkg);
|
|
258
|
+
if (owners.length === 0) {
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
261
|
+
const base = owners[0].isBaseR(pkg);
|
|
262
|
+
// with a version filter, union the matching versions across all sources (so a `3.*` reaches history)
|
|
263
|
+
const versions = verMatch
|
|
264
|
+
? matchingVersions(owners, pkg, verMatch).sort((a, b) => r_version_1.RVersion.compare(a, b))
|
|
265
|
+
: undefined;
|
|
266
|
+
if (versions !== undefined && versions.length === 0) {
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
269
|
+
if (packages.length >= cap) {
|
|
270
|
+
truncated = true;
|
|
271
|
+
break;
|
|
272
|
+
}
|
|
273
|
+
const cran = (owners[0].lookup(pkg)?.cran ?? false) && !base;
|
|
274
|
+
const latest = owners[0].latestVersion(pkg)?.str;
|
|
275
|
+
packages.push({ name: pkg, base, cran, ...(latest ? { latest } : {}), ...(versions ? { versions } : {}), ...(cran ? { cranPage: cranPageUrl(pkg) } : {}) });
|
|
276
|
+
}
|
|
277
|
+
return { packages, truncated };
|
|
278
|
+
}
|
|
279
|
+
const fnMatch = nameMatcher(q.function);
|
|
280
|
+
const matches = [];
|
|
281
|
+
let truncated = false;
|
|
282
|
+
for (const pkg of matchedPkgs) {
|
|
283
|
+
const owners = owningOf(pkg);
|
|
284
|
+
if (owners.length === 0) {
|
|
285
|
+
continue;
|
|
286
|
+
}
|
|
287
|
+
const base = owners[0].isBaseR(pkg);
|
|
288
|
+
// versions to scan: with a filter, the union of matching releases across all sources (so `3.*` reaches
|
|
289
|
+
// history); without one, just the latest. Each version is scanned in a single source (the first that has
|
|
290
|
+
// it), so a release present in more than one source is not double-counted
|
|
291
|
+
const versionsToScan = verMatch
|
|
292
|
+
? matchingVersions(owners, pkg, verMatch)
|
|
293
|
+
: [undefined];
|
|
294
|
+
for (const v of versionsToScan) {
|
|
295
|
+
const s = v === undefined ? owners[0] : owners.find(o => availableVersions(o, pkg).includes(v)) ?? owners[0];
|
|
296
|
+
const exports = s.lookup(pkg, v) ?? s.lookup(pkg);
|
|
297
|
+
const cran = (exports?.cran ?? false) && !base;
|
|
298
|
+
for (const fn of s.functions(pkg, v) ?? s.functions(pkg) ?? []) {
|
|
299
|
+
if (fnMatch(fn.name)) {
|
|
300
|
+
if (matches.length >= cap) {
|
|
301
|
+
truncated = true;
|
|
302
|
+
break;
|
|
303
|
+
}
|
|
304
|
+
matches.push(compactMatch(pkg, fn, exports?.version, base, cran));
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
if (truncated) {
|
|
308
|
+
break;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
if (truncated) {
|
|
312
|
+
break;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
return { matches, matchCount: matches.length, truncated };
|
|
316
|
+
}
|
|
317
|
+
/** the discoverable bundle sources for Tab completion (process-wide cached; opening the manifest reads no shard) */
|
|
318
|
+
function completionSources() {
|
|
319
|
+
if (typeof process !== 'undefined' && process.env?.FLOWR_DISABLE_DEFAULT_SIGDB) {
|
|
320
|
+
return [];
|
|
321
|
+
}
|
|
322
|
+
const out = [];
|
|
323
|
+
for (const p of (0, manifest_1.defaultSigDbPaths)()) {
|
|
324
|
+
const src = (0, reader_1.getSharedSigSourceSync)(p);
|
|
325
|
+
if (src) {
|
|
326
|
+
out.push(src);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
return out;
|
|
330
|
+
}
|
|
331
|
+
/** the package part of a spec token, dropping any `@version` and `::function` suffix */
|
|
332
|
+
function packageOf(spec) {
|
|
333
|
+
return spec.split('::')[0].split('@')[0];
|
|
334
|
+
}
|
|
335
|
+
/** cap on offered names, so an empty fragment does not dump the whole 24k-package set at the terminal */
|
|
336
|
+
const MaxCompletions = 200;
|
|
337
|
+
/**
|
|
338
|
+
* Tab-completer for `:query \@signature` / `:signature query`: package names in the first position, a package's
|
|
339
|
+
* function names in the second (and after `pkg::`). Version specs and flags are left alone. Enumerating functions
|
|
340
|
+
* decompresses the package's shard once (then cached); enumerating packages reads only the manifest.
|
|
341
|
+
*/
|
|
342
|
+
function signatureQueryCompleter(line, startingNewArg) {
|
|
343
|
+
const sources = completionSources();
|
|
344
|
+
if (sources.length === 0) {
|
|
345
|
+
return { completions: [] };
|
|
346
|
+
}
|
|
347
|
+
const capped = (names, prefix, decorate) => {
|
|
348
|
+
const all = [];
|
|
349
|
+
for (const n of names) {
|
|
350
|
+
const d = decorate(n); // filter on the offered text (e.g. `pkg::fn`), not the bare name
|
|
351
|
+
if (d.startsWith(prefix)) {
|
|
352
|
+
all.push(d);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
if (all.length <= MaxCompletions) {
|
|
356
|
+
return all;
|
|
357
|
+
}
|
|
358
|
+
// too many to show: sample evenly across the sorted set so the offered names span the alphabet, not just
|
|
359
|
+
// its head; index 0 stays first so the ghost hint still previews the true best (alphabetically first) match
|
|
360
|
+
const stride = all.length / MaxCompletions;
|
|
361
|
+
return Array.from({ length: MaxCompletions }, (_, i) => all[Math.floor(i * stride)]);
|
|
362
|
+
};
|
|
363
|
+
const packageNames = () => [...new Set(sources.flatMap(s => s.packageNames()))].sort();
|
|
364
|
+
const functionsOf = (pkg) => {
|
|
365
|
+
const src = sources.find(s => s.has(pkg));
|
|
366
|
+
return src ? [...new Set((src.functions(pkg) ?? []).map(f => f.name))].sort() : [];
|
|
367
|
+
};
|
|
368
|
+
// first token: a package spec (`pkg`, `pkg::fn`, `pkg@ver`)
|
|
369
|
+
if (line.length === 0 || (line.length === 1 && !startingNewArg)) {
|
|
370
|
+
const token = line[0] ?? '';
|
|
371
|
+
const dbl = token.indexOf('::');
|
|
372
|
+
if (dbl >= 0) {
|
|
373
|
+
const pkg = packageOf(token), frag = token.slice(0, dbl + 2);
|
|
374
|
+
return { completions: capped(functionsOf(pkg), token, fn => `${frag}${fn} `), argumentPart: token };
|
|
375
|
+
}
|
|
376
|
+
if (token.includes('@')) {
|
|
377
|
+
return { completions: [] }; // typing a version, nothing to offer
|
|
378
|
+
}
|
|
379
|
+
return { completions: capped(packageNames(), token, p => `${p} `), argumentPart: token };
|
|
380
|
+
}
|
|
381
|
+
// second token: the function within the first token's package
|
|
382
|
+
if ((line.length === 1 && startingNewArg) || (line.length === 2 && !startingNewArg)) {
|
|
383
|
+
const frag = line.length === 2 ? line[1] : '';
|
|
384
|
+
return { completions: capped(functionsOf(packageOf(line[0])), frag, fn => `${fn} `), argumentPart: frag };
|
|
385
|
+
}
|
|
386
|
+
return { completions: [] };
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Executes the signature query. With no `package` it summarizes the loaded databases. A glob in `package`/`function`
|
|
390
|
+
* or a multi-version `version` triggers a wildcard search (matching packages or functions). Otherwise a single
|
|
391
|
+
* exact package (optionally at an exact `version`) yields its full view, or the detailed function view.
|
|
392
|
+
*/
|
|
393
|
+
// eslint-disable-next-line @typescript-eslint/require-await -- executor contract returns a Promise; the work is synchronous
|
|
394
|
+
async function executeSignatureQuery({ analyzer }, queries) {
|
|
395
|
+
const start = Date.now();
|
|
396
|
+
const q = queries[queries.length - 1] ?? { type: 'signature' };
|
|
397
|
+
const deps = analyzer.inspectContext().deps;
|
|
398
|
+
const databases = deps.loadedPackageDatabases()
|
|
399
|
+
.map(d => ({ scope: d.scope, version: d.version, date: d.date }));
|
|
400
|
+
// the plugin's loaded sources (bundled default + $FLOWR_SIGDB + anything added at runtime), so the query
|
|
401
|
+
// reflects dynamically-mounted sources
|
|
402
|
+
const sources = deps.signatureSources();
|
|
403
|
+
const packages = new Set();
|
|
404
|
+
for (const s of sources) {
|
|
405
|
+
for (const n of s.packageNames()) {
|
|
406
|
+
packages.add(n);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
const meta = () => ({ '.meta': { timing: Date.now() - start }, databases, packageCount: packages.size, sourceCount: sources.length });
|
|
410
|
+
if (!q.package) {
|
|
411
|
+
return meta();
|
|
412
|
+
}
|
|
413
|
+
// wildcard search: a glob in the package/function name, or a version spec matching more than one release
|
|
414
|
+
if (hasGlob(q.package) || (q.function !== undefined && hasGlob(q.function)) || (q.version !== undefined && isMultiVersion(q.version))) {
|
|
415
|
+
const found = searchSources(sources, packages, q);
|
|
416
|
+
// a version glob against a single concrete, known package that matched no release: point at the available versions
|
|
417
|
+
// (the same guidance the exact-version path gives) instead of a bare "0 matched"
|
|
418
|
+
if ((found.matchCount === 0 || found.packages?.length === 0) && !hasGlob(q.package) && q.version !== undefined) {
|
|
419
|
+
const owning = sources.filter(s => s.has(q.package));
|
|
420
|
+
if (owning.length > 0) {
|
|
421
|
+
const avail = allAvailableVersions(owning, q.package);
|
|
422
|
+
return { ...meta(), message: versionNotFoundMessage(q.package, `no release of '${q.package}' matches '${q.version}'.`, avail, owning[0].isBaseR(q.package)) };
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
return { ...meta(), ...found };
|
|
426
|
+
}
|
|
427
|
+
// every source holding the package: `current` keeps the latest, `history` the older releases, so the resolved
|
|
428
|
+
// version must be looked up in whichever source actually has it (not just the first one found)
|
|
429
|
+
const owning = sources.filter(s => s.has(q.package));
|
|
430
|
+
if (owning.length === 0) {
|
|
431
|
+
return { ...meta(), message: `The signature database does not know the package '${q.package}'.`, suggestions: suggest(packages, q.package) };
|
|
432
|
+
}
|
|
433
|
+
// the version to resolve against: an explicit `@version`, else the version flowR inferred for the script's
|
|
434
|
+
// dependency (which may be an older release that only `history` carries)
|
|
435
|
+
const version = q.version ?? deps.getDependency(q.package)?.resolvedVersion;
|
|
436
|
+
const src = sourceForVersion(owning, q.package, version);
|
|
437
|
+
if (q.version !== undefined && src === undefined) {
|
|
438
|
+
const avail = allAvailableVersions(owning, q.package);
|
|
439
|
+
return { ...meta(), message: versionNotFoundMessage(q.package, `'${q.package}@${q.version}' is not in the loaded database.`, avail, owning[0].isBaseR(q.package)) };
|
|
440
|
+
}
|
|
441
|
+
const resolvedSrc = src ?? owning[0];
|
|
442
|
+
if (q.function) {
|
|
443
|
+
const fn = signatureFunctionInfo(resolvedSrc, q.package, q.function, version);
|
|
444
|
+
if (fn) {
|
|
445
|
+
return { ...meta(), function: fn };
|
|
446
|
+
}
|
|
447
|
+
const exports = resolvedSrc.lookup(q.package, version) ?? resolvedSrc.lookup(q.package);
|
|
448
|
+
const universe = new Set([
|
|
449
|
+
...(exports?.exported ?? []),
|
|
450
|
+
...(resolvedSrc.functions(q.package, version) ?? resolvedSrc.functions(q.package) ?? []).map(f => f.name)
|
|
451
|
+
]);
|
|
452
|
+
return {
|
|
453
|
+
...meta(),
|
|
454
|
+
package: signaturePackageInfo(resolvedSrc, q.package, version),
|
|
455
|
+
message: `'${q.package}' does not define '${q.function}'.`,
|
|
456
|
+
suggestions: suggest(universe, q.function)
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
return { ...meta(), package: signaturePackageInfo(resolvedSrc, q.package, version) };
|
|
460
|
+
}
|
|
461
|
+
//# sourceMappingURL=signature-query-executor.js.map
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import type { BaseQueryFormat, BaseQueryResult } from '../../base-query-format';
|
|
2
|
+
import Joi from 'joi';
|
|
3
|
+
import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
4
|
+
import type { ParsedQueryLine } from '../../query';
|
|
5
|
+
import type { ReplOutput } from '../../../cli/repl/commands/repl-main';
|
|
6
|
+
import type { FlowrConfig } from '../../../config';
|
|
7
|
+
import { executeSignatureQuery, signatureQueryCompleter } from './signature-query-executor';
|
|
8
|
+
/**
|
|
9
|
+
* Inspects the loaded signature database(s) (see the {@link https://github.com/flowr-analysis/flowr/wiki/Package-Database|Package Database wiki}).
|
|
10
|
+
* The `package` and `function` fields accept glob wildcards (`*`, `?`), and `version` accepts an exact version,
|
|
11
|
+
* a glob (`3.*`), or a semver range (`>=3.0.0`, `3.x`). With no `package` it summarizes the loaded databases;
|
|
12
|
+
* a single exact package/function yields the full view (signature, definition location, CRAN-mirror source link,
|
|
13
|
+
* rdrr.io docs); a wildcard yields the matching set.
|
|
14
|
+
*/
|
|
15
|
+
export interface SignatureQuery extends BaseQueryFormat {
|
|
16
|
+
readonly type: 'signature';
|
|
17
|
+
/** the package to inspect (glob wildcards allowed); omit for a summary of the loaded databases */
|
|
18
|
+
readonly package?: string;
|
|
19
|
+
/** the function/symbol within {@link package} to inspect (glob wildcards allowed) */
|
|
20
|
+
readonly function?: string;
|
|
21
|
+
/** a version spec: an exact version, a glob (`3.*`), or a semver range (`>=3.0.0`, `3.x`) */
|
|
22
|
+
readonly version?: string;
|
|
23
|
+
}
|
|
24
|
+
/** one parameter of a function signature */
|
|
25
|
+
export interface SignatureParameterView {
|
|
26
|
+
readonly name: string;
|
|
27
|
+
readonly required: boolean;
|
|
28
|
+
readonly forced: boolean;
|
|
29
|
+
readonly default?: string;
|
|
30
|
+
}
|
|
31
|
+
/** the detailed view of a single function within a package */
|
|
32
|
+
export interface SignatureFunctionView {
|
|
33
|
+
readonly name: string;
|
|
34
|
+
readonly package: string;
|
|
35
|
+
readonly version?: string;
|
|
36
|
+
readonly exported: boolean;
|
|
37
|
+
readonly properties: readonly string[];
|
|
38
|
+
readonly parameters: readonly SignatureParameterView[];
|
|
39
|
+
readonly callees: readonly string[];
|
|
40
|
+
readonly file?: string;
|
|
41
|
+
readonly line?: number;
|
|
42
|
+
/** deep link into the read-only CRAN GitHub mirror, when the definition location + a CRAN version are known */
|
|
43
|
+
readonly sourceUrl?: string;
|
|
44
|
+
/** rdrr.io documentation link for the function, when it maps to a documentable topic */
|
|
45
|
+
readonly docUrl?: string;
|
|
46
|
+
/** whether the function looks like an S3 generic (has `<generic>.<class>` dispatch targets in the same package) */
|
|
47
|
+
readonly s3generic?: boolean;
|
|
48
|
+
/** the `<generic>.<class>` dispatch targets found in the same package */
|
|
49
|
+
readonly s3methods?: readonly string[];
|
|
50
|
+
}
|
|
51
|
+
/** one declared dependency of a package */
|
|
52
|
+
export interface SignatureDependencyView {
|
|
53
|
+
readonly type: string;
|
|
54
|
+
readonly name: string;
|
|
55
|
+
readonly constraint?: string;
|
|
56
|
+
}
|
|
57
|
+
/** the full view of a package as stored in the signature database */
|
|
58
|
+
export interface SignaturePackageView {
|
|
59
|
+
readonly name: string;
|
|
60
|
+
readonly version: string;
|
|
61
|
+
/** the version the analyzer resolved the package to, if it differs from {@link version} */
|
|
62
|
+
readonly resolved?: string;
|
|
63
|
+
readonly base: boolean;
|
|
64
|
+
readonly cran: boolean;
|
|
65
|
+
/** the CRAN source tarball url, when known */
|
|
66
|
+
readonly cranUrl?: string;
|
|
67
|
+
/** the CRAN package landing page (`cran.r-project.org/package=<pkg>`), for CRAN packages */
|
|
68
|
+
readonly cranPage?: string;
|
|
69
|
+
/** the package's read-only CRAN GitHub mirror (`github.com/cran/<pkg>`), for CRAN packages */
|
|
70
|
+
readonly repoUrl?: string;
|
|
71
|
+
readonly releaseDate?: string;
|
|
72
|
+
readonly exportsTotal: number;
|
|
73
|
+
readonly functionCount: number;
|
|
74
|
+
readonly constants: readonly string[];
|
|
75
|
+
readonly internalCount: number;
|
|
76
|
+
readonly deprecated: readonly string[];
|
|
77
|
+
/** for a base package: the R releases it was part of core, ascending */
|
|
78
|
+
readonly coreVersions?: readonly string[];
|
|
79
|
+
readonly dependencies: readonly SignatureDependencyView[];
|
|
80
|
+
readonly functions: readonly SignatureFunctionView[];
|
|
81
|
+
}
|
|
82
|
+
/** a compact hit from a wildcard function search */
|
|
83
|
+
export interface SignatureMatchView {
|
|
84
|
+
readonly package: string;
|
|
85
|
+
readonly name: string;
|
|
86
|
+
readonly exported: boolean;
|
|
87
|
+
readonly version?: string;
|
|
88
|
+
readonly file?: string;
|
|
89
|
+
readonly line?: number;
|
|
90
|
+
readonly sourceUrl?: string;
|
|
91
|
+
readonly docUrl?: string;
|
|
92
|
+
}
|
|
93
|
+
/** a hit from a wildcard package search */
|
|
94
|
+
export interface SignaturePackageMatch {
|
|
95
|
+
readonly name: string;
|
|
96
|
+
readonly base: boolean;
|
|
97
|
+
readonly cran: boolean;
|
|
98
|
+
readonly latest?: string;
|
|
99
|
+
/** the versions matching the version spec (present only for a versioned search) */
|
|
100
|
+
readonly versions?: readonly string[];
|
|
101
|
+
readonly cranPage?: string;
|
|
102
|
+
}
|
|
103
|
+
/** metadata of one loaded signature database */
|
|
104
|
+
export interface SignatureDatabaseView {
|
|
105
|
+
readonly scope: string;
|
|
106
|
+
readonly version: number;
|
|
107
|
+
readonly date: string;
|
|
108
|
+
}
|
|
109
|
+
export interface SignatureQueryResult extends BaseQueryResult {
|
|
110
|
+
readonly databases: readonly SignatureDatabaseView[];
|
|
111
|
+
readonly packageCount: number;
|
|
112
|
+
readonly sourceCount: number;
|
|
113
|
+
/** set when a single package was requested and found */
|
|
114
|
+
readonly package?: SignaturePackageView;
|
|
115
|
+
/** set when a single function was requested and found */
|
|
116
|
+
readonly function?: SignatureFunctionView;
|
|
117
|
+
/** function hits from a wildcard search */
|
|
118
|
+
readonly matches?: readonly SignatureMatchView[];
|
|
119
|
+
readonly matchCount?: number;
|
|
120
|
+
/** package hits from a wildcard package search (no function given) */
|
|
121
|
+
readonly packages?: readonly SignaturePackageMatch[];
|
|
122
|
+
/** whether the match list was capped */
|
|
123
|
+
readonly truncated?: boolean;
|
|
124
|
+
/** a not-found / disabled note, with optional near-match suggestions */
|
|
125
|
+
readonly message?: string;
|
|
126
|
+
readonly suggestions?: readonly string[];
|
|
127
|
+
}
|
|
128
|
+
/** parse a signature-query repl line into a query: `pkg`, `pkg fn`, `pkg::fn`, `pkg@ver`, globs */
|
|
129
|
+
declare function signatureQueryLineParser(output: ReplOutput, line: readonly string[], _config: FlowrConfig): ParsedQueryLine<'signature'>;
|
|
130
|
+
export declare const SignatureQueryDefinition: {
|
|
131
|
+
readonly executor: typeof executeSignatureQuery;
|
|
132
|
+
readonly asciiSummarizer: (formatter: import("../../../util/text/ansi").OutputFormatter, _analyzer: import("../../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider<import("../../../r-bridge/parser").KnownParser>, queryResults: BaseQueryResult, result: string[], _query: readonly import("../../query").Query[]) => true;
|
|
133
|
+
readonly fromLine: typeof signatureQueryLineParser;
|
|
134
|
+
readonly completer: typeof signatureQueryCompleter;
|
|
135
|
+
readonly schema: Joi.ObjectSchema<any>;
|
|
136
|
+
readonly flattenInvolvedNodes: () => NodeId[];
|
|
137
|
+
};
|
|
138
|
+
export {};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SignatureQueryDefinition = void 0;
|
|
7
|
+
const joi_1 = __importDefault(require("joi"));
|
|
8
|
+
const ansi_1 = require("../../../util/text/ansi");
|
|
9
|
+
const time_1 = require("../../../util/text/time");
|
|
10
|
+
const signature_query_executor_1 = require("./signature-query-executor");
|
|
11
|
+
const signature_query_render_1 = require("./signature-query-render");
|
|
12
|
+
/** parse a signature-query repl line into a query: `pkg`, `pkg fn`, `pkg::fn`, `pkg@ver`, globs */
|
|
13
|
+
function signatureQueryLineParser(output, line, _config) {
|
|
14
|
+
const positional = line.filter(t => t.length > 0 && !t.startsWith('--'));
|
|
15
|
+
if (positional[0] === 'help' || line.includes('--help') || line.includes('-h')) {
|
|
16
|
+
(0, signature_query_render_1.printSignatureHelp)(output);
|
|
17
|
+
return { query: [] };
|
|
18
|
+
}
|
|
19
|
+
const [first, second] = positional;
|
|
20
|
+
if (!first) {
|
|
21
|
+
return { query: [{ type: 'signature' }] };
|
|
22
|
+
}
|
|
23
|
+
// `pkg::fn` shorthand, then `pkg@version`
|
|
24
|
+
const dbl = first.indexOf('::');
|
|
25
|
+
const left = dbl >= 0 ? first.slice(0, dbl) : first;
|
|
26
|
+
const fnFromColon = dbl >= 0 ? first.slice(dbl + 2) : undefined;
|
|
27
|
+
const at = left.indexOf('@');
|
|
28
|
+
const pkg = at >= 0 ? left.slice(0, at) : left;
|
|
29
|
+
const version = at >= 0 ? left.slice(at + 1) : undefined;
|
|
30
|
+
const fn = second ?? fnFromColon;
|
|
31
|
+
return {
|
|
32
|
+
query: [{
|
|
33
|
+
type: 'signature',
|
|
34
|
+
...(pkg ? { package: pkg } : {}),
|
|
35
|
+
...(fn ? { function: fn } : {}),
|
|
36
|
+
...(version ? { version } : {})
|
|
37
|
+
}]
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
exports.SignatureQueryDefinition = {
|
|
41
|
+
executor: signature_query_executor_1.executeSignatureQuery,
|
|
42
|
+
asciiSummarizer: (formatter, _analyzer, queryResults, result, _query) => {
|
|
43
|
+
const out = queryResults;
|
|
44
|
+
result.push(`Query: ${(0, ansi_1.bold)('signature', formatter)} (${(0, time_1.printAsMs)(out['.meta'].timing, 0)})`);
|
|
45
|
+
if (out.function) {
|
|
46
|
+
(0, signature_query_render_1.pushFunction)(result, formatter, out.function);
|
|
47
|
+
}
|
|
48
|
+
else if (out.package) {
|
|
49
|
+
(0, signature_query_render_1.pushPackage)(result, formatter, out.package);
|
|
50
|
+
}
|
|
51
|
+
else if (out.matches) {
|
|
52
|
+
(0, signature_query_render_1.pushMatches)(result, formatter, out);
|
|
53
|
+
}
|
|
54
|
+
else if (out.packages) {
|
|
55
|
+
(0, signature_query_render_1.pushPackages)(result, formatter, out);
|
|
56
|
+
}
|
|
57
|
+
else if (!out.message) {
|
|
58
|
+
(0, signature_query_render_1.pushSummary)(result, formatter, out);
|
|
59
|
+
}
|
|
60
|
+
if (out.message) {
|
|
61
|
+
const hint = out.suggestions?.length ? ` ${(0, ansi_1.italic)('Did you mean:', formatter)} ${out.suggestions.join(', ')}?` : '';
|
|
62
|
+
result.push(` ╰ ${(0, ansi_1.color)(out.message, 1 /* Colors.Red */, formatter)}${hint}`);
|
|
63
|
+
}
|
|
64
|
+
return true;
|
|
65
|
+
},
|
|
66
|
+
fromLine: signatureQueryLineParser,
|
|
67
|
+
completer: signature_query_executor_1.signatureQueryCompleter,
|
|
68
|
+
schema: joi_1.default.object({
|
|
69
|
+
type: joi_1.default.string().valid('signature').required().description('The type of the query.'),
|
|
70
|
+
package: joi_1.default.string().optional().description('The package to inspect (glob wildcards allowed); omit for a summary of the loaded databases.'),
|
|
71
|
+
function: joi_1.default.string().optional().description('A function/symbol to inspect (glob wildcards allowed).'),
|
|
72
|
+
version: joi_1.default.string().optional().description('A version spec: an exact version, a glob (3.*), or a semver range (>=3.0.0, 3.x).')
|
|
73
|
+
}).description('Inspects the loaded signature database(s): loaded databases, a package, a function, or wildcard matches.'),
|
|
74
|
+
flattenInvolvedNodes: () => []
|
|
75
|
+
};
|
|
76
|
+
//# sourceMappingURL=signature-query-format.js.map
|