@eagleoutice/flowr 2.11.0 → 2.12.0
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 +190 -260
- 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/flowr.js +1 -1
- package/cli/repl/commands/repl-commands.d.ts +1 -0
- package/cli/repl/commands/repl-commands.js +69 -17
- 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 +70 -13
- package/config.js +65 -7
- 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 +3 -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 +19 -1
- 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 +23 -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 +53 -1
- 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/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 +10 -1
- package/queries/query.js +5 -2
- 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 +22 -4
- package/slicing/criterion/parse.js +125 -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 +13 -1
- package/util/text/ansi.js +27 -4
- 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 -174
- package/project/plugins/package-version-plugins/pkgdb.d.ts +0 -133
- package/project/plugins/package-version-plugins/pkgdb.js +0 -370
|
@@ -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
|
|
@@ -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,6 +17,7 @@ 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';
|
|
@@ -40,7 +41,7 @@ import { type DiceQuery } from './catalog/dice-query/dice-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 | DfShapeQuery | NormalizedAstQuery | IdMapQuery | DataflowClusterQuery | StaticSliceQuery | DependenciesQuery | LocationMapQuery | HappensBeforeQuery | InspectExceptionQuery | InspectHigherOrderQuery | InspectRecursionQuery | ResolveValueQuery | ProjectQuery | OriginQuery | LinterQuery | ProvenanceQuery | InputSourcesQuery | DiceQuery;
|
|
44
|
+
export type Query = CallContextQuery | ConfigQuery | SearchQuery | DataflowQuery | DoesCallQuery | CallGraphQuery | ControlFlowQuery | DataflowLensQuery | FilesQuery | DfShapeQuery | 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
|
};
|
|
@@ -240,6 +241,14 @@ export declare const SupportedQueries: {
|
|
|
240
241
|
readonly schema: Joi.ObjectSchema<any>;
|
|
241
242
|
readonly flattenInvolvedNodes: () => never[];
|
|
242
243
|
};
|
|
244
|
+
readonly signature: {
|
|
245
|
+
readonly executor: typeof import("./catalog/signature-query/signature-query-executor").executeSignatureQuery;
|
|
246
|
+
readonly asciiSummarizer: (formatter: OutputFormatter, _analyzer: ReadonlyFlowrAnalysisProvider<import("../r-bridge/parser").KnownParser>, queryResults: BaseQueryResult, result: string[], _query: readonly Query[]) => true;
|
|
247
|
+
readonly fromLine: (output: ReplOutput, line: readonly string[], _config: FlowrConfig) => ParsedQueryLine<"signature">;
|
|
248
|
+
readonly completer: typeof import("./catalog/signature-query/signature-query-executor").signatureQueryCompleter;
|
|
249
|
+
readonly schema: Joi.ObjectSchema<any>;
|
|
250
|
+
readonly flattenInvolvedNodes: () => NodeId[];
|
|
251
|
+
};
|
|
243
252
|
readonly origin: {
|
|
244
253
|
readonly executor: typeof import("./catalog/origin-query/origin-query-executor").executeResolveValueQuery;
|
|
245
254
|
readonly asciiSummarizer: (formatter: OutputFormatter, _analyzer: ReadonlyFlowrAnalysisProvider<import("../r-bridge/parser").KnownParser>, queryResults: BaseQueryResult, result: string[]) => true;
|
package/queries/query.js
CHANGED
|
@@ -29,6 +29,7 @@ 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");
|
|
@@ -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;
|