@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,15 @@
|
|
|
1
|
+
import type { OutputFormatter } from '../../../util/text/ansi';
|
|
2
|
+
import type { ReplOutput } from '../../../cli/repl/commands/repl-main';
|
|
3
|
+
import type { SignatureFunctionView, SignaturePackageView, SignatureQueryResult } from './signature-query-format';
|
|
4
|
+
/** print an in-repl usage guide for the signature query */
|
|
5
|
+
export declare function printSignatureHelp(output: ReplOutput): void;
|
|
6
|
+
/** render the full view of a single function into `result` */
|
|
7
|
+
export declare function pushFunction(result: string[], f: OutputFormatter, fn: SignatureFunctionView): void;
|
|
8
|
+
/** render the full view of a single package into `result` */
|
|
9
|
+
export declare function pushPackage(result: string[], f: OutputFormatter, p: SignaturePackageView): void;
|
|
10
|
+
/** render the function hits of a wildcard search into `result` */
|
|
11
|
+
export declare function pushMatches(result: string[], f: OutputFormatter, out: SignatureQueryResult): void;
|
|
12
|
+
/** render the package hits of a wildcard package search into `result` */
|
|
13
|
+
export declare function pushPackages(result: string[], f: OutputFormatter, out: SignatureQueryResult): void;
|
|
14
|
+
/** render the summary of the loaded databases into `result` */
|
|
15
|
+
export declare function pushSummary(result: string[], f: OutputFormatter, out: SignatureQueryResult): void;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.printSignatureHelp = printSignatureHelp;
|
|
4
|
+
exports.pushFunction = pushFunction;
|
|
5
|
+
exports.pushPackage = pushPackage;
|
|
6
|
+
exports.pushMatches = pushMatches;
|
|
7
|
+
exports.pushPackages = pushPackages;
|
|
8
|
+
exports.pushSummary = pushSummary;
|
|
9
|
+
const ansi_1 = require("../../../util/text/ansi");
|
|
10
|
+
const signature_query_executor_1 = require("./signature-query-executor");
|
|
11
|
+
const r_base_packages_1 = require("../../../util/r-base-packages");
|
|
12
|
+
/** print an in-repl usage guide for the signature query */
|
|
13
|
+
function printSignatureHelp(output) {
|
|
14
|
+
const f = output.formatter;
|
|
15
|
+
const ex = (cmd, desc) => output.stdout(` ${(0, ansi_1.bold)(cmd, f)}\n ${(0, ansi_1.italic)(desc, f)}`);
|
|
16
|
+
output.stdout((0, ansi_1.bold)('Signature Database Query', f) + (0, ansi_1.italic)(' (inspects the databases that resolve library()/`::` calls)', f));
|
|
17
|
+
output.stdout('');
|
|
18
|
+
output.stdout(`${(0, ansi_1.bold)('Usage', f)} :query @signature [<package>[@<version>][::<function>] [<function>]]`);
|
|
19
|
+
output.stdout('');
|
|
20
|
+
output.stdout((0, ansi_1.bold)('Examples', f));
|
|
21
|
+
ex(':query @signature', 'summarize the loaded databases');
|
|
22
|
+
ex(':query @signature ggplot2', 'a package: version, exports, dependencies, links');
|
|
23
|
+
ex(':query @signature ggplot2::aes', 'one function (or `ggplot2 aes`, `ggplot2@3.5.0 aes`)');
|
|
24
|
+
ex(':query @signature gg* geom_*', 'glob search (versions also take ranges: >=4.0.0, 4.x)');
|
|
25
|
+
output.stdout('');
|
|
26
|
+
output.stdout((0, ansi_1.italic)(':query* dumps the full JSON (every function, the whole match set).', f));
|
|
27
|
+
}
|
|
28
|
+
/** how many names to show inline before an `+N more`: a short sample for a package's functions, more for lists */
|
|
29
|
+
const SampleFns = 5;
|
|
30
|
+
const MaxList = 25;
|
|
31
|
+
const baseSet = new Set((0, r_base_packages_1.baseRPackages)());
|
|
32
|
+
/** a package name linked to its CRAN page (unless it is base R / the `R` language pseudo-package) */
|
|
33
|
+
function linkPackage(name, f) {
|
|
34
|
+
return name === 'R' || baseSet.has(name) ? name : f.hyperlink(name, (0, signature_query_executor_1.cranPageUrl)(name));
|
|
35
|
+
}
|
|
36
|
+
/** a `file:line` location, linked to its source when a url is known */
|
|
37
|
+
function linkLocation(file, line, url, f) {
|
|
38
|
+
const text = `${file}${line !== undefined ? `:${line}` : ''}`;
|
|
39
|
+
return url ? f.hyperlink(text, url) : text;
|
|
40
|
+
}
|
|
41
|
+
/** render a function signature as `name(a, b = default, ...)` with defaults dimmed */
|
|
42
|
+
function renderSignature(f, fn) {
|
|
43
|
+
const params = fn.parameters.map(p => p.default !== undefined ? `${p.name} = ${(0, ansi_1.italic)(p.default, f)}` : p.name).join(', ');
|
|
44
|
+
return `${(0, ansi_1.bold)(fn.name, f)}(${params})`;
|
|
45
|
+
}
|
|
46
|
+
/** render the full view of a single function into `result` */
|
|
47
|
+
function pushFunction(result, f, fn) {
|
|
48
|
+
const generic = fn.s3generic ? ` ${(0, ansi_1.color)('S3 generic', 5 /* Colors.Magenta */, f, { style: 1 /* FontStyles.Bold */ })}` : '';
|
|
49
|
+
result.push(` ╰ ${(0, ansi_1.color)(fn.package, 6 /* Colors.Cyan */, f, { style: 1 /* FontStyles.Bold */ })}::${(0, ansi_1.bold)(fn.name, f)}${fn.version ? ` ${(0, ansi_1.color)('v' + fn.version, 2 /* Colors.Green */, f)}` : ''}${generic}`);
|
|
50
|
+
result.push(` ╰ ${renderSignature(f, fn)}`);
|
|
51
|
+
const tags = [fn.exported ? (0, ansi_1.color)('exported', 2 /* Colors.Green */, f) : (0, ansi_1.color)('internal', 3 /* Colors.Yellow */, f),
|
|
52
|
+
...fn.properties.filter(p => p !== 'exported').map(p => (0, ansi_1.italic)(p, f))];
|
|
53
|
+
result.push(` ╰ ${tags.join(' ')}`);
|
|
54
|
+
if (fn.file) {
|
|
55
|
+
const loc = `${fn.file}${fn.line !== undefined ? `:${fn.line}` : ''}`;
|
|
56
|
+
result.push(` ╰ ${(0, ansi_1.italic)('source', f)} ${fn.sourceUrl ? `${loc} ${f.hyperlink(fn.sourceUrl, fn.sourceUrl)}` : loc}`);
|
|
57
|
+
}
|
|
58
|
+
if (fn.docUrl) {
|
|
59
|
+
result.push(` ╰ ${(0, ansi_1.italic)('docs', f)} ${f.hyperlink(fn.docUrl, fn.docUrl)}`);
|
|
60
|
+
}
|
|
61
|
+
const listLine = (label, items, max) => {
|
|
62
|
+
if (!items.length) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const more = items.length > max ? (0, ansi_1.italic)(` (+${items.length - max} more)`, f) : '';
|
|
66
|
+
result.push(` ╰ ${(0, ansi_1.italic)(label, f)} (${items.length}): ${items.slice(0, max).join(', ')}${more}`);
|
|
67
|
+
};
|
|
68
|
+
listLine('dispatches to', fn.s3methods ?? [], MaxList);
|
|
69
|
+
listLine('calls', fn.callees, MaxList);
|
|
70
|
+
}
|
|
71
|
+
/** render the full view of a single package into `result` */
|
|
72
|
+
function pushPackage(result, f, p) {
|
|
73
|
+
const kind = p.base ? (0, ansi_1.color)(' base R', 3 /* Colors.Yellow */, f, { style: 1 /* FontStyles.Bold */ })
|
|
74
|
+
: p.cran ? (0, ansi_1.color)(' CRAN', 4 /* Colors.Blue */, f, { style: 1 /* FontStyles.Bold */ }) : '';
|
|
75
|
+
result.push(` ╰ ${(0, ansi_1.color)(p.name, 6 /* Colors.Cyan */, f, { style: 1 /* FontStyles.Bold */ })} ${(0, ansi_1.color)('v' + p.version, 2 /* Colors.Green */, f)}${p.resolved ? (0, ansi_1.italic)(` (analyzer resolved ${p.resolved})`, f) : ''}${kind}`);
|
|
76
|
+
if (p.releaseDate) {
|
|
77
|
+
result.push(` ╰ ${(0, ansi_1.italic)(`released ${p.releaseDate}`, f)}`);
|
|
78
|
+
}
|
|
79
|
+
if (p.cranPage) {
|
|
80
|
+
result.push(` ╰ ${(0, ansi_1.italic)('docs', f)} ${f.hyperlink(p.cranPage, p.cranPage)}`);
|
|
81
|
+
}
|
|
82
|
+
const links = [];
|
|
83
|
+
if (p.repoUrl) {
|
|
84
|
+
links.push(f.hyperlink('mirror', p.repoUrl));
|
|
85
|
+
}
|
|
86
|
+
if (p.cranUrl) {
|
|
87
|
+
links.push(f.hyperlink('tarball', p.cranUrl));
|
|
88
|
+
}
|
|
89
|
+
if (links.length) {
|
|
90
|
+
result.push(` ╰ ${links.join(' ')}`);
|
|
91
|
+
}
|
|
92
|
+
if (p.coreVersions?.length) {
|
|
93
|
+
const first = p.coreVersions[0], last = p.coreVersions[p.coreVersions.length - 1];
|
|
94
|
+
result.push(` ╰ ${(0, ansi_1.italic)('in R versions', f)}: ${first === last ? first : `${first} to ${last}`} (${p.coreVersions.length})`);
|
|
95
|
+
}
|
|
96
|
+
result.push(` ╰ ${(0, ansi_1.italic)('exports', f)} (${p.exportsTotal}): ${p.functionCount} functions, ${p.constants.length} constants, ${p.internalCount} internal, ${p.deprecated.length} deprecated`);
|
|
97
|
+
if (p.constants.length) {
|
|
98
|
+
const shown = p.constants.slice(0, MaxList);
|
|
99
|
+
const more = p.constants.length > shown.length ? (0, ansi_1.italic)(` … +${p.constants.length - shown.length} more`, f) : '';
|
|
100
|
+
result.push(` ╰ ${(0, ansi_1.italic)('constants', f)}: ${shown.join(', ')}${more}`);
|
|
101
|
+
}
|
|
102
|
+
if (p.dependencies.length) {
|
|
103
|
+
const byType = new Map();
|
|
104
|
+
for (const d of p.dependencies) {
|
|
105
|
+
const list = byType.get(d.type) ?? [];
|
|
106
|
+
list.push(`${linkPackage(d.name, f)}${d.constraint ? (0, ansi_1.italic)(` ${d.constraint}`, f) : ''}`);
|
|
107
|
+
byType.set(d.type, list);
|
|
108
|
+
}
|
|
109
|
+
result.push(` ╰ ${(0, ansi_1.italic)('dependencies', f)} (${p.dependencies.length})`);
|
|
110
|
+
for (const [type, list] of byType) {
|
|
111
|
+
result.push(` ╰ ${(0, ansi_1.italic)(type, f)}: ${list.join(', ')}`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (p.functions.length) {
|
|
115
|
+
result.push(` ╰ ${(0, ansi_1.italic)('functions', f)} (${p.functions.length})`);
|
|
116
|
+
const sample = p.functions.slice(0, SampleFns).map(fn => (0, ansi_1.bold)(fn.name, f)).join(', ');
|
|
117
|
+
const more = p.functions.length > SampleFns ? (0, ansi_1.italic)(` … +${p.functions.length - SampleFns} more (:query* for the full JSON)`, f) : '';
|
|
118
|
+
result.push(` ╰ ${(0, ansi_1.italic)('e.g.', f)} ${sample}${more}`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/** render the function hits of a wildcard search into `result` */
|
|
122
|
+
function pushMatches(result, f, out) {
|
|
123
|
+
const matches = out.matches ?? [];
|
|
124
|
+
const cap = out.truncated ? (0, ansi_1.italic)(` (capped at ${matches.length})`, f) : '';
|
|
125
|
+
result.push(` ╰ ${(0, ansi_1.bold)(String(out.matchCount ?? matches.length), f)} function${matches.length === 1 ? '' : 's'} matched${cap}`);
|
|
126
|
+
for (const m of matches) {
|
|
127
|
+
const loc = m.file ? ` ${linkLocation(m.file, m.line, m.sourceUrl, f)}` : '';
|
|
128
|
+
const doc = m.docUrl ? ` ${f.hyperlink('docs', m.docUrl)}` : '';
|
|
129
|
+
result.push(` ╰ ${(0, ansi_1.color)(m.package, 6 /* Colors.Cyan */, f)}::${(0, ansi_1.bold)(m.name, f)}${m.version ? (0, ansi_1.italic)(` v${m.version}`, f) : ''}${loc}${doc}`);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/** render the package hits of a wildcard package search into `result` */
|
|
133
|
+
function pushPackages(result, f, out) {
|
|
134
|
+
const packages = out.packages ?? [];
|
|
135
|
+
const cap = out.truncated ? (0, ansi_1.italic)(` (capped at ${packages.length})`, f) : '';
|
|
136
|
+
result.push(` ╰ ${(0, ansi_1.bold)(String(packages.length), f)} package${packages.length === 1 ? '' : 's'} matched${cap}`);
|
|
137
|
+
for (const pm of packages) {
|
|
138
|
+
const name = pm.cranPage ? f.hyperlink((0, ansi_1.color)(pm.name, 6 /* Colors.Cyan */, f), pm.cranPage) : (0, ansi_1.color)(pm.name, 6 /* Colors.Cyan */, f);
|
|
139
|
+
const kind = pm.base ? (0, ansi_1.italic)(' base R', f) : pm.cran ? (0, ansi_1.italic)(' CRAN', f) : '';
|
|
140
|
+
const vers = pm.versions ? `: ${pm.versions.join(', ')}` : pm.latest ? ` ${(0, ansi_1.color)('v' + pm.latest, 2 /* Colors.Green */, f)}` : '';
|
|
141
|
+
result.push(` ╰ ${name}${vers}${kind}`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/** render the summary of the loaded databases into `result` */
|
|
145
|
+
function pushSummary(result, f, out) {
|
|
146
|
+
if (out.databases.length === 0 && out.sourceCount === 0) {
|
|
147
|
+
result.push(` ╰ ${(0, ansi_1.italic)('No signature databases are loaded (the solver may be disabled or no bundle was found).', f)}`);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
result.push(` ╰ ${(0, ansi_1.bold)(String(out.packageCount), f)} packages across ${out.sourceCount} source${out.sourceCount === 1 ? '' : 's'}`);
|
|
151
|
+
for (const db of out.databases) {
|
|
152
|
+
result.push(` ╰ ${(0, ansi_1.color)(db.scope, 6 /* Colors.Cyan */, f)}${db.version ? ` v${db.version}` : ''}${db.date ? (0, ansi_1.italic)(` (${db.date})`, f) : ''}`);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=signature-query-render.js.map
|
|
@@ -4,6 +4,7 @@ exports.fingerPrintOfQuery = fingerPrintOfQuery;
|
|
|
4
4
|
exports.executeStaticSliceQuery = executeStaticSliceQuery;
|
|
5
5
|
const static_slicer_1 = require("../../../slicing/static/static-slicer");
|
|
6
6
|
const reconstruct_1 = require("../../../reconstruct/reconstruct");
|
|
7
|
+
const source_inline_map_1 = require("../../../reconstruct/inline/source-inline-map");
|
|
7
8
|
const auto_select_defaults_1 = require("../../../reconstruct/auto-select/auto-select-defaults");
|
|
8
9
|
const magic_comments_1 = require("../../../reconstruct/auto-select/magic-comments");
|
|
9
10
|
const log_1 = require("../../../util/log");
|
|
@@ -29,17 +30,22 @@ async function executeStaticSliceQuery({ analyzer }, queries) {
|
|
|
29
30
|
if (results[key]) {
|
|
30
31
|
log_1.log.warn(`Duplicate Key for slicing-query: ${key}, skipping...`);
|
|
31
32
|
}
|
|
32
|
-
const { criteria, noReconstruction, noMagicComments } = query;
|
|
33
|
+
const { criteria, noReconstruction, noMagicComments, inlineSources, includeCallees } = query;
|
|
33
34
|
const sliceStart = Date.now();
|
|
34
35
|
const n = await analyzer.normalize();
|
|
35
|
-
const
|
|
36
|
+
const df = await analyzer.dataflow();
|
|
37
|
+
const slice = (0, static_slicer_1.staticSlice)({ ctx: analyzer.inspectContext(), info: df, ast: n, ids: parse_1.SlicingCriteria.convertAll(criteria, n.idMap), direction: query.direction ?? slice_direction_1.SliceDirection.Backward, threshold: analyzer.flowrConfig.solver.slicer?.threshold, includeCallees });
|
|
36
38
|
const sliceEnd = Date.now();
|
|
37
39
|
if (noReconstruction) {
|
|
38
40
|
results[key] = { slice: { ...slice, '.meta': { timing: sliceEnd - sliceStart } } };
|
|
39
41
|
}
|
|
40
42
|
else {
|
|
41
43
|
const reconstructStart = Date.now();
|
|
42
|
-
const reconstruct = (0, reconstruct_1.reconstructToCode)(
|
|
44
|
+
const reconstruct = (0, reconstruct_1.reconstructToCode)(n, {
|
|
45
|
+
nodes: slice.result,
|
|
46
|
+
inlineSources: inlineSources,
|
|
47
|
+
sourceMap: inlineSources ? source_inline_map_1.SourceInlineMap.build(n, df.graph) : undefined
|
|
48
|
+
}, noMagicComments ? auto_select_defaults_1.doNotAutoSelect : (0, magic_comments_1.makeMagicCommentHandler)(auto_select_defaults_1.doNotAutoSelect));
|
|
43
49
|
const reconstructEnd = Date.now();
|
|
44
50
|
results[key] = {
|
|
45
51
|
slice: { ...slice, '.meta': { timing: sliceEnd - sliceStart } },
|
|
@@ -21,6 +21,16 @@ export interface StaticSliceQuery extends BaseQueryFormat {
|
|
|
21
21
|
readonly noMagicComments?: boolean;
|
|
22
22
|
/** The direction to slice in. Defaults to backward slicing if unset. */
|
|
23
23
|
readonly direction?: SliceDirection;
|
|
24
|
+
/**
|
|
25
|
+
* Inline resolvable `source()` calls into the reconstruction so the result is a single self-contained R text.
|
|
26
|
+
* Cyclic and unresolvable `source()` calls are kept verbatim and reported via `reconstruct.inlineWarnings`.
|
|
27
|
+
*/
|
|
28
|
+
readonly inlineSources?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* If set (and slicing backward), continue the slice past a function-definition boundary, also including
|
|
31
|
+
* the definition's binding and call sites. Defaults to `false`.
|
|
32
|
+
*/
|
|
33
|
+
readonly includeCallees?: boolean;
|
|
24
34
|
}
|
|
25
35
|
export interface StaticSliceQueryResult extends BaseQueryResult {
|
|
26
36
|
/**
|
|
@@ -11,11 +11,25 @@ const static_slice_query_executor_1 = require("./static-slice-query-executor");
|
|
|
11
11
|
const query_print_1 = require("../../query-print");
|
|
12
12
|
const slice_query_parser_1 = require("../../../cli/repl/parser/slice-query-parser");
|
|
13
13
|
const slice_direction_1 = require("../../../util/slice-direction");
|
|
14
|
+
const SliceCriterionHelp = [
|
|
15
|
+
'Each criterion picks one element of the program, separate multiple ones with ";":',
|
|
16
|
+
' <line>@<name> <name> in line <line>, preferring a call over the symbol (e.g. 2@x)',
|
|
17
|
+
' <line>@[<n>]<name> the n-th occurrence of <name> in line <line> (e.g. 2@[2]x, 2@[-1]x)',
|
|
18
|
+
' <line>:<col> the element starting at line <line>, column <col> (e.g. 2:5)',
|
|
19
|
+
' <line>~<col> the innermost element containing line <line>, column <col> (e.g. 2~5)',
|
|
20
|
+
' $<id> the normalized node with the id <id> (e.g. $42)',
|
|
21
|
+
'A negative <line> counts from the end; a trailing (file-regex) restricts to a file (e.g. 2@x(tmp/.*)).',
|
|
22
|
+
'Append flags after the ")": f (slice forward), i (inline sources), c (include callees).',
|
|
23
|
+
'Example: :query @static-slice (2@x;3:1)fc'
|
|
24
|
+
].join('\n');
|
|
14
25
|
function sliceQueryLineParser(output, line, _config) {
|
|
15
26
|
const criteria = (0, slice_query_parser_1.sliceCriteriaParser)(line[0]);
|
|
16
27
|
const direction = (0, slice_query_parser_1.sliceDirectionParser)(line[0]);
|
|
28
|
+
const inlineSources = (0, slice_query_parser_1.sliceInlineParser)(line[0]);
|
|
29
|
+
const includeCallees = (0, slice_query_parser_1.sliceIncludeCalleesParser)(line[0]);
|
|
17
30
|
if (!criteria || criteria.length === 0) {
|
|
18
31
|
output.stderr(output.formatter.format('Invalid static-slice query format, slicing criteria must be given in the form "(criterion1;criterion2;...)"', { color: 1 /* Colors.Red */, effect: ansi_1.ColorEffect.Foreground, style: 1 /* FontStyles.Bold */ }));
|
|
32
|
+
output.stderr(SliceCriterionHelp);
|
|
19
33
|
return { query: [] };
|
|
20
34
|
}
|
|
21
35
|
return { query: [
|
|
@@ -23,6 +37,8 @@ function sliceQueryLineParser(output, line, _config) {
|
|
|
23
37
|
type: 'static-slice',
|
|
24
38
|
criteria: criteria,
|
|
25
39
|
direction: direction,
|
|
40
|
+
...(inlineSources ? { inlineSources: true } : {}),
|
|
41
|
+
...(includeCallees ? { includeCallees: true } : {})
|
|
26
42
|
}
|
|
27
43
|
], rCode: line[1] };
|
|
28
44
|
}
|
|
@@ -69,7 +85,9 @@ exports.StaticSliceQueryDefinition = {
|
|
|
69
85
|
criteria: joi_1.default.array().items(joi_1.default.string()).min(0).required().description('The slicing criteria to use.'),
|
|
70
86
|
noReconstruction: joi_1.default.boolean().optional().description('Do not reconstruct the slice into readable code.'),
|
|
71
87
|
noMagicComments: joi_1.default.boolean().optional().description('Should the magic comments (force-including lines within the slice) be ignored?'),
|
|
72
|
-
direction: joi_1.default.string().valid(...Object.values(slice_direction_1.SliceDirection)).optional().description('The direction to slice in. Defaults to backward slicing if unset.')
|
|
88
|
+
direction: joi_1.default.string().valid(...Object.values(slice_direction_1.SliceDirection)).optional().description('The direction to slice in. Defaults to backward slicing if unset.'),
|
|
89
|
+
inlineSources: joi_1.default.boolean().optional().description('Inline resolvable source() calls into the reconstruction so the result is a single self-contained R text.'),
|
|
90
|
+
includeCallees: joi_1.default.boolean().optional().description('If set (and slicing backward), continue the slice past a function-definition boundary, also including the definition\'s binding and call sites.')
|
|
73
91
|
}).description('Slice query used to slice the dataflow graph'),
|
|
74
92
|
flattenInvolvedNodes: (queryResults) => {
|
|
75
93
|
const flattened = [];
|
package/queries/query-print.js
CHANGED
|
@@ -97,6 +97,11 @@ async function asciiSummaryOfQueryResult(formatter, totalInMs, results, analyzer
|
|
|
97
97
|
if (query === '.meta') {
|
|
98
98
|
continue;
|
|
99
99
|
}
|
|
100
|
+
if (queryResults === undefined || (typeof queryResults === 'object' && queryResults !== null && 'error' in queryResults)) {
|
|
101
|
+
const message = queryResults?.error ?? 'unknown error';
|
|
102
|
+
result.push(`Query: ${(0, ansi_1.bold)(query, formatter)} ${(0, ansi_1.bold)('failed', formatter)}: ${message}`);
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
100
105
|
const queryType = query_1.SupportedQueries[query];
|
|
101
106
|
const relevantQueries = queries.filter(q => q.type === query);
|
|
102
107
|
if (await queryType.asciiSummarizer(formatter, analyzer, queryResults, result, relevantQueries)) {
|
package/queries/query.d.ts
CHANGED
|
@@ -17,11 +17,11 @@ import { type HappensBeforeQuery } from './catalog/happens-before-query/happens-
|
|
|
17
17
|
import { type ResolveValueQuery } from './catalog/resolve-value-query/resolve-value-query-format';
|
|
18
18
|
import { type DataflowLensQuery } from './catalog/dataflow-lens-query/dataflow-lens-query-format';
|
|
19
19
|
import { type ProjectQuery } from './catalog/project-query/project-query-format';
|
|
20
|
+
import { type SignatureQuery } from './catalog/signature-query/signature-query-format';
|
|
20
21
|
import { type OriginQuery } from './catalog/origin-query/origin-query-format';
|
|
21
22
|
import { type LinterQuery } from './catalog/linter-query/linter-query-format';
|
|
22
23
|
import type { NodeId } from '../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
23
24
|
import { type ControlFlowQuery } from './catalog/control-flow-query/control-flow-query-format';
|
|
24
|
-
import { type DfShapeQuery } from './catalog/df-shape-query/df-shape-query-format';
|
|
25
25
|
import type { AsyncOrSync } from 'ts-essentials';
|
|
26
26
|
import type { FlowrConfig } from '../config';
|
|
27
27
|
import { type InspectHigherOrderQuery } from './catalog/inspect-higher-order-query/inspect-higher-order-query-format';
|
|
@@ -37,10 +37,11 @@ import type { InputSourcesQuery } from './catalog/input-sources-query/input-sour
|
|
|
37
37
|
import type { ProvenanceQuery } from './catalog/provenance-query/provenance-query-format';
|
|
38
38
|
import type { LintingResultCertainty } from '../linter/linter-format';
|
|
39
39
|
import { type DiceQuery } from './catalog/dice-query/dice-query-format';
|
|
40
|
+
import { type AbsintQuery } from './catalog/absint-query/absint-query-format';
|
|
40
41
|
/**
|
|
41
42
|
* These are all queries that can be executed from within flowR
|
|
42
43
|
*/
|
|
43
|
-
export type Query = CallContextQuery | ConfigQuery | SearchQuery | DataflowQuery | DoesCallQuery | CallGraphQuery | ControlFlowQuery | DataflowLensQuery | FilesQuery |
|
|
44
|
+
export type Query = CallContextQuery | ConfigQuery | SearchQuery | DataflowQuery | DoesCallQuery | CallGraphQuery | ControlFlowQuery | DataflowLensQuery | FilesQuery | AbsintQuery | NormalizedAstQuery | IdMapQuery | DataflowClusterQuery | StaticSliceQuery | DependenciesQuery | LocationMapQuery | HappensBeforeQuery | InspectExceptionQuery | InspectHigherOrderQuery | InspectRecursionQuery | ResolveValueQuery | ProjectQuery | SignatureQuery | OriginQuery | LinterQuery | ProvenanceQuery | InputSourcesQuery | DiceQuery;
|
|
44
45
|
export type QueryArgumentsWithType<QueryType extends BaseQueryFormat['type']> = Query & {
|
|
45
46
|
type: QueryType;
|
|
46
47
|
};
|
|
@@ -119,11 +120,12 @@ export declare const SupportedQueries: {
|
|
|
119
120
|
readonly schema: Joi.ObjectSchema<any>;
|
|
120
121
|
readonly flattenInvolvedNodes: () => never[];
|
|
121
122
|
};
|
|
122
|
-
readonly
|
|
123
|
-
readonly executor: typeof import("./catalog/
|
|
123
|
+
readonly absint: {
|
|
124
|
+
readonly executor: typeof import("./catalog/absint-query/absint-query-executor").executeAbsintQuery;
|
|
124
125
|
readonly asciiSummarizer: (formatter: OutputFormatter, _analyzer: ReadonlyFlowrAnalysisProvider<import("../r-bridge/parser").KnownParser>, queryResults: BaseQueryResult, result: string[]) => true;
|
|
125
126
|
readonly jsonFormatter: (queryResults: BaseQueryResult) => object;
|
|
126
|
-
readonly
|
|
127
|
+
readonly completer: (line: readonly string[], startingNewArg: boolean, _config: FlowrConfig) => CommandCompletions;
|
|
128
|
+
readonly fromLine: (output: ReplOutput, line: readonly string[], _config: FlowrConfig) => ParsedQueryLine<"absint">;
|
|
127
129
|
readonly schema: Joi.ObjectSchema<any>;
|
|
128
130
|
readonly flattenInvolvedNodes: () => never[];
|
|
129
131
|
};
|
|
@@ -240,6 +242,14 @@ export declare const SupportedQueries: {
|
|
|
240
242
|
readonly schema: Joi.ObjectSchema<any>;
|
|
241
243
|
readonly flattenInvolvedNodes: () => never[];
|
|
242
244
|
};
|
|
245
|
+
readonly signature: {
|
|
246
|
+
readonly executor: typeof import("./catalog/signature-query/signature-query-executor").executeSignatureQuery;
|
|
247
|
+
readonly asciiSummarizer: (formatter: OutputFormatter, _analyzer: ReadonlyFlowrAnalysisProvider<import("../r-bridge/parser").KnownParser>, queryResults: BaseQueryResult, result: string[], _query: readonly Query[]) => true;
|
|
248
|
+
readonly fromLine: (output: ReplOutput, line: readonly string[], _config: FlowrConfig) => ParsedQueryLine<"signature">;
|
|
249
|
+
readonly completer: typeof import("./catalog/signature-query/signature-query-executor").signatureQueryCompleter;
|
|
250
|
+
readonly schema: Joi.ObjectSchema<any>;
|
|
251
|
+
readonly flattenInvolvedNodes: () => NodeId[];
|
|
252
|
+
};
|
|
243
253
|
readonly origin: {
|
|
244
254
|
readonly executor: typeof import("./catalog/origin-query/origin-query-executor").executeResolveValueQuery;
|
|
245
255
|
readonly asciiSummarizer: (formatter: OutputFormatter, _analyzer: ReadonlyFlowrAnalysisProvider<import("../r-bridge/parser").KnownParser>, queryResults: BaseQueryResult, result: string[]) => true;
|
package/queries/query.js
CHANGED
|
@@ -29,10 +29,10 @@ const happens_before_query_format_1 = require("./catalog/happens-before-query/ha
|
|
|
29
29
|
const resolve_value_query_format_1 = require("./catalog/resolve-value-query/resolve-value-query-format");
|
|
30
30
|
const dataflow_lens_query_format_1 = require("./catalog/dataflow-lens-query/dataflow-lens-query-format");
|
|
31
31
|
const project_query_format_1 = require("./catalog/project-query/project-query-format");
|
|
32
|
+
const signature_query_format_1 = require("./catalog/signature-query/signature-query-format");
|
|
32
33
|
const origin_query_format_1 = require("./catalog/origin-query/origin-query-format");
|
|
33
34
|
const linter_query_format_1 = require("./catalog/linter-query/linter-query-format");
|
|
34
35
|
const control_flow_query_format_1 = require("./catalog/control-flow-query/control-flow-query-format");
|
|
35
|
-
const df_shape_query_format_1 = require("./catalog/df-shape-query/df-shape-query-format");
|
|
36
36
|
const inspect_higher_order_query_format_1 = require("./catalog/inspect-higher-order-query/inspect-higher-order-query-format");
|
|
37
37
|
const log_1 = require("../util/log");
|
|
38
38
|
const files_query_format_1 = require("./catalog/files-query/files-query-format");
|
|
@@ -43,6 +43,7 @@ const inspect_exception_query_format_1 = require("./catalog/inspect-exceptions-q
|
|
|
43
43
|
const input_sources_query_format_1 = require("./catalog/input-sources-query/input-sources-query-format");
|
|
44
44
|
const provenance_query_format_1 = require("./catalog/provenance-query/provenance-query-format");
|
|
45
45
|
const dice_query_format_1 = require("./catalog/dice-query/dice-query-format");
|
|
46
|
+
const absint_query_format_1 = require("./catalog/absint-query/absint-query-format");
|
|
46
47
|
exports.SupportedQueries = {
|
|
47
48
|
'call-context': call_context_query_format_1.CallContextQueryDefinition,
|
|
48
49
|
'config': config_query_format_1.ConfigQueryDefinition,
|
|
@@ -51,7 +52,7 @@ exports.SupportedQueries = {
|
|
|
51
52
|
'dataflow': dataflow_query_format_1.DataflowQueryDefinition,
|
|
52
53
|
'does-call': does_call_query_format_1.DoesCallQueryDefinition,
|
|
53
54
|
'dataflow-lens': dataflow_lens_query_format_1.DataflowLensQueryDefinition,
|
|
54
|
-
'
|
|
55
|
+
'absint': absint_query_format_1.AbsintQueryDefinition,
|
|
55
56
|
'files': files_query_format_1.FilesQueryDefinition,
|
|
56
57
|
'id-map': id_map_query_format_1.IdMapQueryDefinition,
|
|
57
58
|
'normalized-ast': normalized_ast_query_format_1.NormalizedAstQueryDefinition,
|
|
@@ -68,6 +69,7 @@ exports.SupportedQueries = {
|
|
|
68
69
|
'inspect-recursion': inspect_recursion_query_format_1.InspectRecursionQueryDefinition,
|
|
69
70
|
'resolve-value': resolve_value_query_format_1.ResolveValueQueryDefinition,
|
|
70
71
|
'project': project_query_format_1.ProjectQueryDefinition,
|
|
72
|
+
'signature': signature_query_format_1.SignatureQueryDefinition,
|
|
71
73
|
'origin': origin_query_format_1.OriginQueryDefinition,
|
|
72
74
|
'linter': linter_query_format_1.LinterQueryDefinition,
|
|
73
75
|
'dice': dice_query_format_1.DiceQueryDefinition
|
|
@@ -124,8 +126,9 @@ async function executeQueries(data, queries) {
|
|
|
124
126
|
results.push([type, result]);
|
|
125
127
|
}
|
|
126
128
|
catch (e) {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
130
|
+
log_1.log.error(`query of type '${type}' failed: ${message}`, e);
|
|
131
|
+
results.push([type, { '.meta': { timing: 0 }, error: message }]);
|
|
129
132
|
}
|
|
130
133
|
}
|
|
131
134
|
const r = Object.fromEntries(results);
|
package/r-bridge/init.js
CHANGED
|
@@ -10,7 +10,11 @@ function initCommand(eol) {
|
|
|
10
10
|
* furthermore, we compile for performance reasons
|
|
11
11
|
* Please note that we add a `flowr_output` assignment before to avoid issues with earlier R versions
|
|
12
12
|
*/
|
|
13
|
-
|
|
13
|
+
/* Force a UTF-8 character type so `getParseData`'s `encodeString` emits raw UTF-8 rather than locale-dependent
|
|
14
|
+
* octal escapes (e.g. `\303\264`), which are not valid JSON and would break parsing of non-ASCII R sources on
|
|
15
|
+
* hosts running in a non-UTF-8 locale (a common CI setup). Falls back silently if no UTF-8 locale is available. */
|
|
16
|
+
return 'invisible(suppressWarnings(local(for(.l in c("C.UTF-8","en_US.UTF-8","UTF-8")) if(nzchar(Sys.setlocale("LC_CTYPE",.l))) break)));'
|
|
17
|
+
+ 'flowr_output<-NULL;flowr_get_ast<-compiler::cmpfun(function(...){tryCatch({'
|
|
14
18
|
/* the actual code to parse the R code, ... allows us to keep the old 'file=path' and 'text=content' semantics. we define flowr_output using the super assignment to persist it in the env! */
|
|
15
19
|
+ 'flowr_output<<-getParseData(parse(...,keep.source=TRUE),includeText=TRUE);'
|
|
16
20
|
/* json conversion of the output, dataframe="values" allows us to receive a list of lists (which is more compact)!
|
|
@@ -47,6 +47,16 @@ export declare const RFunctionCall: {
|
|
|
47
47
|
* Type guard for {@link RUnnamedFunctionCall} nodes.
|
|
48
48
|
*/
|
|
49
49
|
readonly isUnnamed: <Info = object>(this: void, node: RNode<Info> | undefined) => node is RUnnamedFunctionCall<Info>;
|
|
50
|
+
/**
|
|
51
|
+
* Bind a call's `arguments` to the formal `paramNames` using R's argument matching rules
|
|
52
|
+
* (see https://cran.r-project.org/doc/manuals/R-lang.html#Argument-matching): exact name, then partial
|
|
53
|
+
* (`pmatch`, unique-prefix) name, then the remaining unnamed arguments filling the remaining formals
|
|
54
|
+
* left-to-right. Returns a map from parameter name to the argument bound to it, so
|
|
55
|
+
* `matchArgumentsToParameters(call.arguments, names).get('X')` answers "which argument is mapped to
|
|
56
|
+
* parameter `X`". Pass `paramNames` as the full formal list **excluding `...`** so ambiguous prefixes are
|
|
57
|
+
* rejected; this makes it exact when the signature is known (e.g. from the signature database).
|
|
58
|
+
*/
|
|
59
|
+
readonly matchArgsToParams: <Info = object>(this: void, args: readonly PotentiallyEmptyRArgument<Info>[], paramNames: readonly string[]) => ReadonlyMap<string, PotentiallyEmptyRArgument<Info>>;
|
|
50
60
|
readonly getLocation: (this: void, node: RNode) => import("../../../../../util/range").SourceLocation | undefined;
|
|
51
61
|
readonly getId: (this: void, node: RNode<import("../processing/decorate").ParentInformation>) => import("../processing/node-id").NodeId;
|
|
52
62
|
readonly getType: (this: void, node: RNode) => RType;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.RFunctionCall = exports.EmptyArgument = void 0;
|
|
4
4
|
const model_1 = require("../model");
|
|
5
5
|
const type_1 = require("../type");
|
|
6
|
+
const prefix_1 = require("../../../../../util/prefix");
|
|
6
7
|
exports.EmptyArgument = '<>';
|
|
7
8
|
/**
|
|
8
9
|
* Helper for working with {@link RFunctionCall} AST nodes.
|
|
@@ -27,6 +28,60 @@ exports.RFunctionCall = {
|
|
|
27
28
|
*/
|
|
28
29
|
isUnnamed(node) {
|
|
29
30
|
return exports.RFunctionCall.is(node) && !node.named;
|
|
31
|
+
},
|
|
32
|
+
/**
|
|
33
|
+
* Bind a call's `arguments` to the formal `paramNames` using R's argument matching rules
|
|
34
|
+
* (see https://cran.r-project.org/doc/manuals/R-lang.html#Argument-matching): exact name, then partial
|
|
35
|
+
* (`pmatch`, unique-prefix) name, then the remaining unnamed arguments filling the remaining formals
|
|
36
|
+
* left-to-right. Returns a map from parameter name to the argument bound to it, so
|
|
37
|
+
* `matchArgumentsToParameters(call.arguments, names).get('X')` answers "which argument is mapped to
|
|
38
|
+
* parameter `X`". Pass `paramNames` as the full formal list **excluding `...`** so ambiguous prefixes are
|
|
39
|
+
* rejected; this makes it exact when the signature is known (e.g. from the signature database).
|
|
40
|
+
*/
|
|
41
|
+
matchArgsToParams(args, paramNames) {
|
|
42
|
+
const bound = new Map();
|
|
43
|
+
const used = new Set();
|
|
44
|
+
// pass 1: exact name matches
|
|
45
|
+
for (let i = 0; i < args.length; i++) {
|
|
46
|
+
const arg = args[i];
|
|
47
|
+
if (arg === exports.EmptyArgument || arg.name === undefined) {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
const n = arg.name.content;
|
|
51
|
+
if (paramNames.includes(n) && !bound.has(n)) {
|
|
52
|
+
bound.set(n, arg);
|
|
53
|
+
used.add(i);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
// pass 2: partial (pmatch) name matches on the still-unbound named arguments
|
|
57
|
+
for (let i = 0; i < args.length; i++) {
|
|
58
|
+
const arg = args[i];
|
|
59
|
+
if (used.has(i) || arg === exports.EmptyArgument || arg.name === undefined) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
const matched = (0, prefix_1.findByPrefixIfUnique)(arg.name.content, paramNames);
|
|
63
|
+
if (matched !== undefined && !bound.has(matched)) {
|
|
64
|
+
bound.set(matched, arg);
|
|
65
|
+
used.add(i);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
// pass 3: remaining unnamed args fill the remaining formals left-to-right
|
|
69
|
+
let formalIdx = 0;
|
|
70
|
+
for (let i = 0; i < args.length; i++) {
|
|
71
|
+
const arg = args[i];
|
|
72
|
+
if (used.has(i) || arg === exports.EmptyArgument || arg.name !== undefined) {
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
while (formalIdx < paramNames.length && bound.has(paramNames[formalIdx])) {
|
|
76
|
+
formalIdx++;
|
|
77
|
+
}
|
|
78
|
+
if (formalIdx < paramNames.length) {
|
|
79
|
+
bound.set(paramNames[formalIdx], arg);
|
|
80
|
+
used.add(i);
|
|
81
|
+
formalIdx++;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return bound;
|
|
30
85
|
}
|
|
31
86
|
};
|
|
32
87
|
//# sourceMappingURL=r-function-call.js.map
|
|
@@ -37,6 +37,22 @@ export declare const NodeId: {
|
|
|
37
37
|
* @see {@link fromBuiltIn} - to recover the built-in function or operator name from a built-in id
|
|
38
38
|
*/
|
|
39
39
|
readonly toBuiltIn: <T extends string>(this: void, name: T) => BuiltIn<T>;
|
|
40
|
+
/**
|
|
41
|
+
* The canonical `pkg:fn` identifier of a package's exported function (e.g. `ggplot2:ggplot`). The single
|
|
42
|
+
* source of this form: `Package.functionIdentifier` delegates here, and {@link fromPkgFn} wraps it.
|
|
43
|
+
*/
|
|
44
|
+
readonly pkgFnName: <P extends string, F extends string>(this: void, pkg: P, fn: F) => `${P}:${F}`;
|
|
45
|
+
/**
|
|
46
|
+
* The built-in id of a package's exported function, e.g. `fromPkgFn('ggplot2', 'ggplot')` yields
|
|
47
|
+
* `built-in:ggplot2:ggplot` -- {@link toBuiltIn} over the {@link pkgFnName} `pkg:fn` form.
|
|
48
|
+
*/
|
|
49
|
+
readonly fromPkgFn: <P extends string, F extends string>(this: void, pkg: P, fn: F) => BuiltIn<`${P}:${F}`>;
|
|
50
|
+
/**
|
|
51
|
+
* Inverse of {@link fromPkgFn}: split a package-function built-in id (`built-in:pkg:fn`) into its `[pkg, fn]`
|
|
52
|
+
* parts, or `undefined` when `id` is not one (a non-builtin id, or a bare builtin without a package such as
|
|
53
|
+
* `built-in:print`). A package name never contains a `:`, so the first one separates it from the function.
|
|
54
|
+
*/
|
|
55
|
+
readonly toPkgFn: (this: void, id: BuiltIn | NodeId | undefined) => readonly [pkg: string, fn: string] | undefined;
|
|
40
56
|
/**
|
|
41
57
|
* Converts a built-in function or operator name or id to a built-in id by prefixing it with the built-in prefix if it is not already a built-in id.
|
|
42
58
|
* This allows us to accept both built-in names and ids in contexts where we want to work with built-in ids.
|
|
@@ -48,6 +48,33 @@ exports.NodeId = {
|
|
|
48
48
|
toBuiltIn(name) {
|
|
49
49
|
return `built-in:${name}`;
|
|
50
50
|
},
|
|
51
|
+
/**
|
|
52
|
+
* The canonical `pkg:fn` identifier of a package's exported function (e.g. `ggplot2:ggplot`). The single
|
|
53
|
+
* source of this form: `Package.functionIdentifier` delegates here, and {@link fromPkgFn} wraps it.
|
|
54
|
+
*/
|
|
55
|
+
pkgFnName(pkg, fn) {
|
|
56
|
+
return `${pkg}:${fn}`;
|
|
57
|
+
},
|
|
58
|
+
/**
|
|
59
|
+
* The built-in id of a package's exported function, e.g. `fromPkgFn('ggplot2', 'ggplot')` yields
|
|
60
|
+
* `built-in:ggplot2:ggplot` -- {@link toBuiltIn} over the {@link pkgFnName} `pkg:fn` form.
|
|
61
|
+
*/
|
|
62
|
+
fromPkgFn(pkg, fn) {
|
|
63
|
+
return exports.NodeId.toBuiltIn(exports.NodeId.pkgFnName(pkg, fn));
|
|
64
|
+
},
|
|
65
|
+
/**
|
|
66
|
+
* Inverse of {@link fromPkgFn}: split a package-function built-in id (`built-in:pkg:fn`) into its `[pkg, fn]`
|
|
67
|
+
* parts, or `undefined` when `id` is not one (a non-builtin id, or a bare builtin without a package such as
|
|
68
|
+
* `built-in:print`). A package name never contains a `:`, so the first one separates it from the function.
|
|
69
|
+
*/
|
|
70
|
+
toPkgFn(id) {
|
|
71
|
+
if (!exports.NodeId.isBuiltIn(id)) {
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
const rest = exports.NodeId.fromBuiltIn(id);
|
|
75
|
+
const sep = rest.indexOf(':');
|
|
76
|
+
return sep > 0 ? [rest.slice(0, sep), rest.slice(sep + 1)] : undefined;
|
|
77
|
+
},
|
|
51
78
|
/**
|
|
52
79
|
* Converts a built-in function or operator name or id to a built-in id by prefixing it with the built-in prefix if it is not already a built-in id.
|
|
53
80
|
* This allows us to accept both built-in names and ids in contexts where we want to work with built-in ids.
|