@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
package/util/mermaid/dfg.d.ts
CHANGED
|
@@ -19,6 +19,8 @@ export interface MermaidGraph {
|
|
|
19
19
|
rootGraph: DataflowGraph;
|
|
20
20
|
/** if given, the dataflow graph will only focus on the "important" parts */
|
|
21
21
|
simplified?: boolean;
|
|
22
|
+
/** show the edge-free base-R qualification (`acf` as `stats::acf`); `false` when the signature database is disabled */
|
|
23
|
+
qualifyBaseR?: boolean;
|
|
22
24
|
}
|
|
23
25
|
/**
|
|
24
26
|
* Translates a vertex tag to the corresponding mermaid node brackets.
|
|
@@ -42,6 +44,8 @@ export interface MermaidGraphConfiguration {
|
|
|
42
44
|
presentEdges?: Set<string>;
|
|
43
45
|
simplified?: boolean;
|
|
44
46
|
includeOnlyIds?: ReadonlySet<NodeId>;
|
|
47
|
+
/** show the edge-free base-R package qualification (`acf` as `stats::acf`); pass `false` when the signature database is disabled. Default `true`. */
|
|
48
|
+
qualifyBaseR?: boolean;
|
|
45
49
|
}
|
|
46
50
|
export interface LabeledDiffGraph {
|
|
47
51
|
label: string;
|
|
@@ -70,7 +74,7 @@ export declare const DataflowMermaid: {
|
|
|
70
74
|
/**
|
|
71
75
|
* This is a simplified version of {@link DataflowMermaid.convert}
|
|
72
76
|
*/
|
|
73
|
-
readonly raw: (this: void, graph: DataflowGraph | DataflowInformation, includeEnvironments?: boolean, mark?: ReadonlySet<NodeId>, simplified?: boolean) => string;
|
|
77
|
+
readonly raw: (this: void, graph: DataflowGraph | DataflowInformation, includeEnvironments?: boolean, mark?: ReadonlySet<NodeId>, simplified?: boolean, qualifyBaseR?: boolean) => string;
|
|
74
78
|
/**
|
|
75
79
|
* Converts a dataflow graph to a mermaid url that visualizes the graph.
|
|
76
80
|
* This is basically a combination of {@link DataflowMermaid.raw} and {@link Mermaid.codeToUrl}.
|
|
@@ -78,6 +82,7 @@ export declare const DataflowMermaid: {
|
|
|
78
82
|
* @param includeEnvironments - whether to include the environment content in the output
|
|
79
83
|
* @param mark - which vertices to highlight in the visualization
|
|
80
84
|
* @param simplified - whether to show a simplified use of the graph with fewer details on the vertices and edges
|
|
85
|
+
* @param qualifyBaseR - show the edge-free base-R qualification (`stats::acf`); `false` when the signature database is disabled
|
|
81
86
|
*/
|
|
82
|
-
readonly url: (this: void, graph: DataflowGraph | DataflowInformation, includeEnvironments?: boolean, mark?: ReadonlySet<NodeId>, simplified?: boolean) => string;
|
|
87
|
+
readonly url: (this: void, graph: DataflowGraph | DataflowInformation, includeEnvironments?: boolean, mark?: ReadonlySet<NodeId>, simplified?: boolean, qualifyBaseR?: boolean) => string;
|
|
83
88
|
};
|
package/util/mermaid/dfg.js
CHANGED
|
@@ -12,6 +12,7 @@ const identifier_1 = require("../../dataflow/environments/identifier");
|
|
|
12
12
|
const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
13
13
|
const edge_1 = require("../../dataflow/graph/edge");
|
|
14
14
|
const vertex_1 = require("../../dataflow/graph/vertex");
|
|
15
|
+
const dfg_get_origin_1 = require("../../dataflow/origin/dfg-get-origin");
|
|
15
16
|
const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
|
|
16
17
|
const info_1 = require("./info");
|
|
17
18
|
const range_1 = require("../range");
|
|
@@ -40,7 +41,8 @@ function subflowToMermaid(nodeId, subflow, mermaid, idPrefix = '') {
|
|
|
40
41
|
includeEnvironments: mermaid.includeEnvironments,
|
|
41
42
|
mark: mermaid.mark,
|
|
42
43
|
prefix: null,
|
|
43
|
-
simplified: mermaid.simplified
|
|
44
|
+
simplified: mermaid.simplified,
|
|
45
|
+
qualifyBaseR: mermaid.qualifyBaseR
|
|
44
46
|
});
|
|
45
47
|
mermaid.nodeLines.push(...subgraph.nodeLines);
|
|
46
48
|
mermaid.edgeLines.push(...subgraph.edgeLines);
|
|
@@ -85,11 +87,24 @@ function displayFunctionArgMapping(argMapping) {
|
|
|
85
87
|
for (const arg of argMapping) {
|
|
86
88
|
result.push(mermaid_1.Mermaid.escape(printArg(arg)));
|
|
87
89
|
}
|
|
88
|
-
return result.length === 0 ? '' : `\n (${result.join(', ')})`;
|
|
90
|
+
return result.length === 0 ? '' : `\n arg: (${result.join(', ')})`;
|
|
89
91
|
}
|
|
90
92
|
function encodeEdge(from, to, types) {
|
|
91
93
|
return `${from}->${to}["${Array.from(types).join(':')}"]`;
|
|
92
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* Renders the (mermaid-escaped) node name with only the *lexeme* -- what the source actually wrote -- in bold.
|
|
97
|
+
* When the displayed name was extended by package qualification (e.g. the code wrote `acf` but we show
|
|
98
|
+
* `stats::acf`), the added `stats::` prefix stays non-bold so it is visually distinct from the written token. A
|
|
99
|
+
* namespace written in the source (`stats::acf` verbatim) is part of the lexeme and is therefore bold as a whole.
|
|
100
|
+
*/
|
|
101
|
+
function boldLexeme(lexeme, display) {
|
|
102
|
+
if (display !== lexeme && display.endsWith(lexeme)) {
|
|
103
|
+
const addedPrefix = display.slice(0, display.length - lexeme.length); // the qualification we added, e.g. `stats::`
|
|
104
|
+
return `${mermaid_1.Mermaid.escape(addedPrefix)}**${mermaid_1.Mermaid.escape(lexeme)}**`;
|
|
105
|
+
}
|
|
106
|
+
return `**${mermaid_1.Mermaid.escape(display)}**`;
|
|
107
|
+
}
|
|
93
108
|
/**
|
|
94
109
|
* Translates a vertex tag to the corresponding mermaid node brackets.
|
|
95
110
|
*/
|
|
@@ -135,11 +150,27 @@ function printEnvironmentToLines(env) {
|
|
|
135
150
|
}
|
|
136
151
|
return lines;
|
|
137
152
|
}
|
|
153
|
+
/** label a built-in node: a package export shows as `pkg::fn` (`built-in:stats:acf` becomes `stats::acf`), everything else as its bare name */
|
|
154
|
+
function builtInDisplayName(builtInId) {
|
|
155
|
+
const pkgFn = node_id_1.NodeId.toPkgFn(builtInId);
|
|
156
|
+
return pkgFn ? `${pkgFn[0]}::${pkgFn[1]}` : String(builtInId).replace('built-in:', '');
|
|
157
|
+
}
|
|
138
158
|
function vertexToMermaid(info, mermaid, id, idPrefix, mark, includeOnlyIds) {
|
|
139
159
|
const fCall = info.tag === vertex_1.VertexType.FunctionCall;
|
|
140
160
|
const { open, close } = mermaidNodeBrackets(info.tag);
|
|
141
161
|
const origId = id;
|
|
142
162
|
id = mermaid_1.Mermaid.escapeId(id);
|
|
163
|
+
// a vertex with a built-in id (e.g. a base-R export attached via `linkBaseR`) has no AST node, so it would
|
|
164
|
+
// otherwise render as a bogus `?? *??-??* (id: built-in:...)` box; draw it as the gray Built-In placeholder
|
|
165
|
+
// instead -- the same node an edge to it produces, which also dedups the two renderings
|
|
166
|
+
if (node_id_1.NodeId.isBuiltIn(origId)) {
|
|
167
|
+
if (!mermaid.presentVertices.has(id)) {
|
|
168
|
+
mermaid.nodeLines.push(` ${idPrefix}${id}["\`Built-In:\n${mermaid_1.Mermaid.escape(builtInDisplayName(origId))}\`"]`);
|
|
169
|
+
mermaid.nodeLines.push(` style ${idPrefix}${id} stroke:gray,fill:gray,stroke-width:2px,opacity:.8;`);
|
|
170
|
+
mermaid.presentVertices.add(id);
|
|
171
|
+
}
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
143
174
|
if (info.environment && mermaid.includeEnvironments) {
|
|
144
175
|
if (info.environment.level > 0 || info.environment.current.memory.size !== 0) {
|
|
145
176
|
mermaid.nodeLines.push(` %% Environment of ${id} [level: ${info.environment.level}]:`, printEnvironmentToLines(info.environment.current).map(x => ` %% ${x}`).join('\n'));
|
|
@@ -147,18 +178,26 @@ function vertexToMermaid(info, mermaid, id, idPrefix, mark, includeOnlyIds) {
|
|
|
147
178
|
}
|
|
148
179
|
const node = mermaid.rootGraph.idMap?.get(info.id);
|
|
149
180
|
const lexeme = node?.lexeme ?? (node?.type === type_1.RType.ExpressionList ? node?.grouping?.[0]?.lexeme : '') ?? '??';
|
|
181
|
+
let display = lexeme;
|
|
182
|
+
if (fCall && (0, vertex_1.isFunctionCallVertex)(info)) {
|
|
183
|
+
const q = identifier_1.Identifier.toQualified((0, dfg_get_origin_1.getOriginInDfg)(mermaid.rootGraph, origId), mermaid.qualifyBaseR === false ? undefined : info.name);
|
|
184
|
+
const qs = q !== undefined ? identifier_1.Identifier.toString(q) : undefined;
|
|
185
|
+
if (qs !== undefined && qs !== lexeme) {
|
|
186
|
+
display = qs;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
150
189
|
if (mermaid.simplified) {
|
|
151
190
|
const location = node?.location?.[0] ? ` (L. ${node?.location?.[0]})` : '';
|
|
152
|
-
const escapedName =
|
|
191
|
+
const escapedName = (node ? boldLexeme(lexeme, display) : '**??**') + location + (node ? `\n*${node.type}*` : '');
|
|
153
192
|
mermaid.nodeLines.push(` ${idPrefix}${id}${open}"\`${escapedName}\`"${close}`);
|
|
154
193
|
}
|
|
155
194
|
else {
|
|
156
|
-
const escapedName = mermaid_1.Mermaid.escape(
|
|
195
|
+
const escapedName = node ? `*${mermaid_1.Mermaid.escape(`[${node.type}]`)}* ${boldLexeme(lexeme, display)}` : '??';
|
|
157
196
|
const deps = info.cds ? ', :may:' + info.cds.map(c => c.id + (c.when ? '+' : '-')).join(',') : '';
|
|
158
197
|
const lnks = info.link?.origin ? ', :links:' + info.link.origin.join(',') : '';
|
|
159
|
-
const sources = info.source ? ',
|
|
198
|
+
const sources = info.source ? ', v: ' + JSON.stringify(info.source) : '';
|
|
160
199
|
const n = node?.info.fullRange ?? node?.location ?? (node?.type === type_1.RType.ExpressionList ? node?.grouping?.[0].location : undefined);
|
|
161
|
-
mermaid.nodeLines.push(` ${idPrefix}${id}${open}"\`${escapedName}
|
|
200
|
+
mermaid.nodeLines.push(` ${idPrefix}${id}${open}"\`${escapedName}\n *${range_1.SourceRange.format(n)}* (**id: ${id}**${deps}${lnks}${sources})${fCall ? displayFunctionArgMapping(info.args) : '' + (info.tag === vertex_1.VertexType.FunctionDefinition && info.mode && info.mode.length > 0 ? mermaid_1.Mermaid.escape(JSON.stringify(info.mode)) : '')}\`"${close}`);
|
|
162
201
|
}
|
|
163
202
|
if (mark?.has(id)) {
|
|
164
203
|
mermaid.nodeLines.push(` style ${idPrefix}${id} ${mermaid.markStyle.vertex} `);
|
|
@@ -198,7 +237,7 @@ function vertexToMermaid(info, mermaid, id, idPrefix, mark, includeOnlyIds) {
|
|
|
198
237
|
if (node_id_1.NodeId.isBuiltIn(target)) {
|
|
199
238
|
mermaid.edgeLines.push(` linkStyle ${mermaid.presentEdges.size - 1} stroke:gray;`);
|
|
200
239
|
if (!mermaid.presentVertices.has(target)) {
|
|
201
|
-
mermaid.nodeLines.push(` ${idPrefix}${target}["\`Built-In:\n${mermaid_1.Mermaid.escape(
|
|
240
|
+
mermaid.nodeLines.push(` ${idPrefix}${target}["\`Built-In:\n${mermaid_1.Mermaid.escape(builtInDisplayName(originalTarget))}\`"]`);
|
|
202
241
|
mermaid.nodeLines.push(` style ${idPrefix}${target} stroke:gray,fill:gray,stroke-width:2px,opacity:.8;`);
|
|
203
242
|
mermaid.presentVertices.add(target);
|
|
204
243
|
}
|
|
@@ -207,8 +246,8 @@ function vertexToMermaid(info, mermaid, id, idPrefix, mark, includeOnlyIds) {
|
|
|
207
246
|
}
|
|
208
247
|
}
|
|
209
248
|
// make the passing of root ids more performant again
|
|
210
|
-
function graphToMermaidGraph(rootIds, { simplified, graph, prefix = 'flowchart BT', idPrefix = '', includeEnvironments = !simplified, mark, rootGraph, presentEdges = new Set(), markStyle = info_1.MermaidDefaultMarkStyle, includeOnlyIds }) {
|
|
211
|
-
const mermaid = { nodeLines: prefix === null ? [] : [prefix], edgeLines: [], presentEdges, presentVertices: new Set(), mark, rootGraph: rootGraph ?? graph, includeEnvironments, markStyle, simplified };
|
|
249
|
+
function graphToMermaidGraph(rootIds, { simplified, graph, prefix = 'flowchart BT', idPrefix = '', includeEnvironments = !simplified, mark, rootGraph, presentEdges = new Set(), markStyle = info_1.MermaidDefaultMarkStyle, includeOnlyIds, qualifyBaseR = true }) {
|
|
250
|
+
const mermaid = { nodeLines: prefix === null ? [] : [prefix], edgeLines: [], presentEdges, presentVertices: new Set(), mark, rootGraph: rootGraph ?? graph, includeEnvironments, markStyle, simplified, qualifyBaseR };
|
|
212
251
|
for (const [id, info] of graph.vertices(true)) {
|
|
213
252
|
if (rootIds.has(id)) {
|
|
214
253
|
vertexToMermaid(info, mermaid, id, idPrefix, mark, includeOnlyIds);
|
|
@@ -245,9 +284,9 @@ exports.DataflowMermaid = {
|
|
|
245
284
|
/**
|
|
246
285
|
* This is a simplified version of {@link DataflowMermaid.convert}
|
|
247
286
|
*/
|
|
248
|
-
raw(graph, includeEnvironments, mark, simplified = false) {
|
|
287
|
+
raw(graph, includeEnvironments, mark, simplified = false, qualifyBaseR = true) {
|
|
249
288
|
graph = info_2.DataflowInformation.is(graph) ? graph.graph : graph;
|
|
250
|
-
return exports.DataflowMermaid.convert({ graph, includeEnvironments, mark, simplified }).string;
|
|
289
|
+
return exports.DataflowMermaid.convert({ graph, includeEnvironments, mark, simplified, qualifyBaseR }).string;
|
|
251
290
|
},
|
|
252
291
|
/**
|
|
253
292
|
* Converts a dataflow graph to a mermaid url that visualizes the graph.
|
|
@@ -256,9 +295,10 @@ exports.DataflowMermaid = {
|
|
|
256
295
|
* @param includeEnvironments - whether to include the environment content in the output
|
|
257
296
|
* @param mark - which vertices to highlight in the visualization
|
|
258
297
|
* @param simplified - whether to show a simplified use of the graph with fewer details on the vertices and edges
|
|
298
|
+
* @param qualifyBaseR - show the edge-free base-R qualification (`stats::acf`); `false` when the signature database is disabled
|
|
259
299
|
*/
|
|
260
|
-
url(graph, includeEnvironments, mark, simplified = false) {
|
|
261
|
-
return mermaid_1.Mermaid.codeToUrl(exports.DataflowMermaid.raw(graph, includeEnvironments, mark, simplified));
|
|
300
|
+
url(graph, includeEnvironments, mark, simplified = false, qualifyBaseR = true) {
|
|
301
|
+
return mermaid_1.Mermaid.codeToUrl(exports.DataflowMermaid.raw(graph, includeEnvironments, mark, simplified, qualifyBaseR));
|
|
262
302
|
}
|
|
263
303
|
};
|
|
264
304
|
//# sourceMappingURL=dfg.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The base packages available at the assumed R version (all of them if omitted). A package counts as
|
|
3
|
+
* available when that R release lies within the range it was part of core; e.g. `parallel` (added in R
|
|
4
|
+
* 2.14.0) is absent for an assumed R 2.10, and long-merged packages like `ctest` are absent for modern R.
|
|
5
|
+
*
|
|
6
|
+
* The newest release is served from the precomputed {@link RBasePackageStore.current} array.
|
|
7
|
+
* Every other version is computed once and memoized, so this never recomputes on repeated calls.
|
|
8
|
+
*/
|
|
9
|
+
export declare function baseRPackages(rVersion?: string): readonly string[];
|
|
10
|
+
/**
|
|
11
|
+
* The base-R package that exports `name` (e.g. `sd` yields `stats`, `plot` yields `base`), or `undefined`.
|
|
12
|
+
* Backed by the bundle-time store, so it needs no loaded database and no runtime resolution: the
|
|
13
|
+
* export-to-package index is inverted from {@link RBasePackageStore.exportsByPackage} once on first use.
|
|
14
|
+
* Base primitives/internals and base data constants (`is.na`, `.Machine`, ...) are not in the sigdb
|
|
15
|
+
* export list, so they are answered from {@link RBasePrimitives} and owned by `base`.
|
|
16
|
+
*/
|
|
17
|
+
export declare function baseRExportOwner(name: string): string | undefined;
|
|
18
|
+
/** whether `name` is an R-core / base package at the assumed R version (see {@link baseRPackages}). */
|
|
19
|
+
export declare function isBaseRPackage(name: string, rVersion?: string): boolean;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.baseRPackages = baseRPackages;
|
|
4
|
+
exports.baseRExportOwner = baseRExportOwner;
|
|
5
|
+
exports.isBaseRPackage = isBaseRPackage;
|
|
6
|
+
const r_base_packages_generated_1 = require("../data/r-base-packages.generated");
|
|
7
|
+
const r_base_primitives_generated_1 = require("../data/r-base-primitives.generated");
|
|
8
|
+
const r_version_1 = require("./r-version");
|
|
9
|
+
/** clamp `rVersion` to the newest R release the store knows about (so a future R version stays answerable) */
|
|
10
|
+
function effective(rVersion) {
|
|
11
|
+
return r_version_1.RVersion.compare(rVersion, r_base_packages_generated_1.RBasePackageStore.newestRVersion) > 0 ? r_base_packages_generated_1.RBasePackageStore.newestRVersion : rVersion;
|
|
12
|
+
}
|
|
13
|
+
/** memoized results per assumed R version, so the list is computed at most once per version (never per lookup) */
|
|
14
|
+
const cache = new Map();
|
|
15
|
+
/**
|
|
16
|
+
* The base packages available at the assumed R version (all of them if omitted). A package counts as
|
|
17
|
+
* available when that R release lies within the range it was part of core; e.g. `parallel` (added in R
|
|
18
|
+
* 2.14.0) is absent for an assumed R 2.10, and long-merged packages like `ctest` are absent for modern R.
|
|
19
|
+
*
|
|
20
|
+
* The newest release is served from the precomputed {@link RBasePackageStore.current} array.
|
|
21
|
+
* Every other version is computed once and memoized, so this never recomputes on repeated calls.
|
|
22
|
+
*/
|
|
23
|
+
function baseRPackages(rVersion) {
|
|
24
|
+
// fast path: no version, or the exact newest-release string, avoids the (regex-based) version compare entirely
|
|
25
|
+
if (rVersion === undefined || rVersion === r_base_packages_generated_1.RBasePackageStore.newestRVersion || r_version_1.RVersion.compare(rVersion, r_base_packages_generated_1.RBasePackageStore.newestRVersion) >= 0) {
|
|
26
|
+
return r_base_packages_generated_1.RBasePackageStore.current; // the current base set, precomputed at bundle time
|
|
27
|
+
}
|
|
28
|
+
const cached = cache.get(rVersion);
|
|
29
|
+
if (cached !== undefined) {
|
|
30
|
+
return cached;
|
|
31
|
+
}
|
|
32
|
+
const eff = effective(rVersion);
|
|
33
|
+
const result = Object.entries(r_base_packages_generated_1.RBasePackageStore.packages)
|
|
34
|
+
.filter(([, [first, last]]) => r_version_1.RVersion.compare(first, eff) <= 0 && r_version_1.RVersion.compare(last, eff) >= 0)
|
|
35
|
+
.map(([name]) => name);
|
|
36
|
+
cache.set(rVersion, result);
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
/** the base export to owning-package map, materialised once from the grouped store (never per lookup) */
|
|
40
|
+
let exportOwners;
|
|
41
|
+
/**
|
|
42
|
+
* The base-R package that exports `name` (e.g. `sd` yields `stats`, `plot` yields `base`), or `undefined`.
|
|
43
|
+
* Backed by the bundle-time store, so it needs no loaded database and no runtime resolution: the
|
|
44
|
+
* export-to-package index is inverted from {@link RBasePackageStore.exportsByPackage} once on first use.
|
|
45
|
+
* Base primitives/internals and base data constants (`is.na`, `.Machine`, ...) are not in the sigdb
|
|
46
|
+
* export list, so they are answered from {@link RBasePrimitives} and owned by `base`.
|
|
47
|
+
*/
|
|
48
|
+
function baseRExportOwner(name) {
|
|
49
|
+
if (exportOwners === undefined) {
|
|
50
|
+
exportOwners = new Map();
|
|
51
|
+
for (const [pkg, names] of Object.entries(r_base_packages_generated_1.RBasePackageStore.exportsByPackage)) {
|
|
52
|
+
for (const exported of names) {
|
|
53
|
+
exportOwners.set(exported, pkg);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return exportOwners.get(name) ?? (r_base_primitives_generated_1.RBasePrimitives.has(name) ? 'base' : undefined);
|
|
58
|
+
}
|
|
59
|
+
/** whether `name` is an R-core / base package at the assumed R version (see {@link baseRPackages}). */
|
|
60
|
+
function isBaseRPackage(name, rVersion) {
|
|
61
|
+
// the store is `as const`, so it carries no string index signature; read it as a record for the dynamic lookup
|
|
62
|
+
const range = r_base_packages_generated_1.RBasePackageStore.packages[name];
|
|
63
|
+
if (range === undefined) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
if (rVersion === undefined) {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
const eff = effective(rVersion);
|
|
70
|
+
return r_version_1.RVersion.compare(range[0], eff) <= 0 && r_version_1.RVersion.compare(range[1], eff) >= 0;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=r-base-packages.js.map
|
package/util/r-license.js
CHANGED
|
@@ -92,14 +92,6 @@ function consumeLicenseName(info) {
|
|
|
92
92
|
}
|
|
93
93
|
return { ...newInfo, element: licenseName?.trim() ?? '' };
|
|
94
94
|
}
|
|
95
|
-
function makeRange(rangeStr) {
|
|
96
|
-
try {
|
|
97
|
-
return (0, r_version_1.parseRRange)(rangeStr);
|
|
98
|
-
}
|
|
99
|
-
catch {
|
|
100
|
-
return undefined;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
95
|
function parseLicenseElement(info) {
|
|
104
96
|
const licenseName = consumeLicenseName(info);
|
|
105
97
|
info = skipWhitespace(licenseName);
|
|
@@ -113,7 +105,7 @@ function parseLicenseElement(info) {
|
|
|
113
105
|
info = skipWhitespace(openParen);
|
|
114
106
|
// consume until closing parenthesis
|
|
115
107
|
const versionStr = consumeUntilString(info, ')');
|
|
116
|
-
versionConstraint =
|
|
108
|
+
versionConstraint = r_version_1.RRange.parse(versionStr.element);
|
|
117
109
|
const closeParen = consumeString(versionStr, ')');
|
|
118
110
|
(0, assert_1.guard)(closeParen.element, `Expected ), but found ${versionStr.remInput[0]} at position ${versionStr.position}`);
|
|
119
111
|
info = skipWhitespace(closeParen);
|
|
@@ -121,7 +113,7 @@ function parseLicenseElement(info) {
|
|
|
121
113
|
else {
|
|
122
114
|
// consume until whitespace or special character
|
|
123
115
|
const versionStr = consumeRegexp(info, /^[\d<>=!~.\s]+/);
|
|
124
|
-
versionConstraint = versionStr.element ?
|
|
116
|
+
versionConstraint = versionStr.element ? r_version_1.RRange.parse(versionStr.element) : undefined;
|
|
125
117
|
info = skipWhitespace(versionStr);
|
|
126
118
|
}
|
|
127
119
|
}
|
package/util/r-version.d.ts
CHANGED
|
@@ -1,19 +1,49 @@
|
|
|
1
1
|
import { Range, SemVer } from 'semver';
|
|
2
|
-
/**
|
|
3
|
-
|
|
4
|
-
* In contrast to just using `new SemVer(version)`, this function also tries to
|
|
5
|
-
* normalize R's much free-er versioning scheme into valid SemVer versions.
|
|
6
|
-
* You can always access the original version string via the `str` property on the returned object.
|
|
7
|
-
*/
|
|
8
|
-
export declare function parseRVersion(version: string): SemVer & {
|
|
2
|
+
/** A parsed R package version: a comparable {@link SemVer} that also keeps its original string as `.str`. */
|
|
3
|
+
export type RVersion = SemVer & {
|
|
9
4
|
str: string;
|
|
10
5
|
};
|
|
11
|
-
/**
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
6
|
+
/** Helpers for R package versions (`1.2-3` style), which are freer than SemVer. */
|
|
7
|
+
export declare const RVersion: {
|
|
8
|
+
/**
|
|
9
|
+
* Parse an R version string into a {@link SemVer}, normalizing R's freer scheme (e.g. `0.4-9`). Unlike
|
|
10
|
+
* `new SemVer(version)` this coerces where needed; the original string is available via `.str`. Returns
|
|
11
|
+
* undefined (never throws) when the string cannot be coerced to a version at all.
|
|
12
|
+
* @see {@link RVersion.parseOrZero}
|
|
13
|
+
*/
|
|
14
|
+
readonly parse: (this: void, version: string) => RVersion | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Compare two R version strings following R's `numeric_version` scheme: split on `.` and `-`, compare
|
|
17
|
+
* numerically, shorter versions padded with zeros (`0.4-9 < 0.4.10 < 1.0`). Negative/zero/positive for
|
|
18
|
+
* `a` less than/equal to/greater than `b`.
|
|
19
|
+
*/
|
|
20
|
+
readonly compare: (this: void, a: string, b: string) => number;
|
|
21
|
+
/**
|
|
22
|
+
* Like {@link parse} but never undefined: a truly un-coercible version sorts as `0.0.0` while keeping its
|
|
23
|
+
* original string as `.str`, so it stays usable as a sort key.
|
|
24
|
+
* @see {@link RVersion.parse}
|
|
25
|
+
*/
|
|
26
|
+
readonly parseOrZero: (this: void, version: string) => RVersion;
|
|
27
|
+
/** The highest of some version strings by R's `numeric_version` order (`0.9.0 < 0.10.0`); undefined if none. */
|
|
28
|
+
readonly highest: (this: void, versions: Iterable<string>) => string | undefined;
|
|
29
|
+
};
|
|
30
|
+
/** Helpers for R package version ranges (DESCRIPTION constraints like `>= 0.4-9`). */
|
|
31
|
+
export declare const RRange: {
|
|
32
|
+
/**
|
|
33
|
+
* Parse an R version range string into a {@link Range}, normalizing R's freer scheme. The original range
|
|
34
|
+
* string is available via `.str`.
|
|
35
|
+
*
|
|
36
|
+
* This never throws: an unparseable constraint (e.g. `>= abc`, or a git/URL "version" from a lockfile) yields
|
|
37
|
+
* `undefined` rather than aborting the caller, so a malformed constraint is *detectable* and simply contributes
|
|
38
|
+
* no version bound. Parsing is attempted first verbatim, then after normalizing R's scheme to SemVer.
|
|
39
|
+
*/
|
|
40
|
+
readonly parse: (this: void, range: string) => (Range & {
|
|
41
|
+
str: string;
|
|
42
|
+
}) | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Whether an R version string satisfies a range constraint, normalizing R's freer scheme on both sides.
|
|
45
|
+
* `range` may be a parsed {@link Range} or a raw constraint string. Returns `false` if either is unparseable
|
|
46
|
+
* (never throws), so a malformed version/constraint simply does not match.
|
|
47
|
+
*/
|
|
48
|
+
readonly satisfies: (this: void, version: string, range: Range | string) => boolean;
|
|
19
49
|
};
|
package/util/r-version.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.parseRRange = parseRRange;
|
|
3
|
+
exports.RRange = exports.RVersion = void 0;
|
|
5
4
|
const semver_1 = require("semver");
|
|
6
|
-
const assert_1 = require("./assert");
|
|
7
5
|
function makeVersion(version, original) {
|
|
8
6
|
const semver = new semver_1.SemVer(version);
|
|
9
7
|
semver.str = original;
|
|
@@ -67,43 +65,106 @@ function normalizeVersions(versions) {
|
|
|
67
65
|
}
|
|
68
66
|
return parts.join('');
|
|
69
67
|
}
|
|
70
|
-
/**
|
|
71
|
-
* This parses an R version string and returns a SemVer object.
|
|
72
|
-
* In contrast to just using `new SemVer(version)`, this function also tries to
|
|
73
|
-
* normalize R's much free-er versioning scheme into valid SemVer versions.
|
|
74
|
-
* You can always access the original version string via the `str` property on the returned object.
|
|
75
|
-
*/
|
|
76
|
-
function parseRVersion(version) {
|
|
77
|
-
try {
|
|
78
|
-
return makeVersion(version, version);
|
|
79
|
-
}
|
|
80
|
-
catch { /* do nothing */ }
|
|
81
|
-
try {
|
|
82
|
-
const normalized = normalizeVersions(version);
|
|
83
|
-
return makeVersion(normalized, version);
|
|
84
|
-
}
|
|
85
|
-
catch { /* do nothing */ }
|
|
86
|
-
const coerced = (0, semver_1.coerce)(version, { loose: true, includePrerelease: true });
|
|
87
|
-
(0, assert_1.guard)(coerced !== null, `Could not coerce R version "${version}" to SemVer`);
|
|
88
|
-
return makeVersion(coerced.version, version);
|
|
89
|
-
}
|
|
90
68
|
function makeRange(range, original) {
|
|
91
69
|
const semverRange = new semver_1.Range(range);
|
|
92
70
|
semverRange.str = original;
|
|
93
71
|
return semverRange;
|
|
94
72
|
}
|
|
95
|
-
/**
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
73
|
+
/** Helpers for R package versions (`1.2-3` style), which are freer than SemVer. */
|
|
74
|
+
exports.RVersion = {
|
|
75
|
+
/**
|
|
76
|
+
* Parse an R version string into a {@link SemVer}, normalizing R's freer scheme (e.g. `0.4-9`). Unlike
|
|
77
|
+
* `new SemVer(version)` this coerces where needed; the original string is available via `.str`. Returns
|
|
78
|
+
* undefined (never throws) when the string cannot be coerced to a version at all.
|
|
79
|
+
* @see {@link RVersion.parseOrZero}
|
|
80
|
+
*/
|
|
81
|
+
parse(version) {
|
|
82
|
+
try {
|
|
83
|
+
return makeVersion(version, version);
|
|
84
|
+
}
|
|
85
|
+
catch { /* try to normalize */ }
|
|
86
|
+
try {
|
|
87
|
+
return makeVersion(normalizeVersions(version), version);
|
|
88
|
+
}
|
|
89
|
+
catch { /* fall back to coercion */ }
|
|
90
|
+
// like {@link RRange.parse}, this never throws: a truly un-coercible version (e.g. an empty `Version:`
|
|
91
|
+
// field or pure text) yields undefined so the caller can detect it rather than crashing
|
|
92
|
+
const coerced = (0, semver_1.coerce)(version, { loose: true, includePrerelease: true });
|
|
93
|
+
return coerced === null ? undefined : makeVersion(coerced.version, version);
|
|
94
|
+
},
|
|
95
|
+
/**
|
|
96
|
+
* Compare two R version strings following R's `numeric_version` scheme: split on `.` and `-`, compare
|
|
97
|
+
* numerically, shorter versions padded with zeros (`0.4-9 < 0.4.10 < 1.0`). Negative/zero/positive for
|
|
98
|
+
* `a` less than/equal to/greater than `b`.
|
|
99
|
+
*/
|
|
100
|
+
compare(a, b) {
|
|
101
|
+
const pa = a.split(/[.-]/), pb = b.split(/[.-]/);
|
|
102
|
+
for (let i = 0; i < Math.max(pa.length, pb.length); i++) {
|
|
103
|
+
const x = Number(pa[i] ?? 0) || 0, y = Number(pb[i] ?? 0) || 0;
|
|
104
|
+
if (x !== y) {
|
|
105
|
+
return x - y;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return 0;
|
|
109
|
+
},
|
|
110
|
+
/**
|
|
111
|
+
* Like {@link parse} but never undefined: a truly un-coercible version sorts as `0.0.0` while keeping its
|
|
112
|
+
* original string as `.str`, so it stays usable as a sort key.
|
|
113
|
+
* @see {@link RVersion.parse}
|
|
114
|
+
*/
|
|
115
|
+
parseOrZero(version) {
|
|
116
|
+
const parsed = exports.RVersion.parse(version);
|
|
117
|
+
if (parsed !== undefined) {
|
|
118
|
+
return parsed;
|
|
119
|
+
}
|
|
120
|
+
const fallback = exports.RVersion.parse('0.0.0'); // `0.0.0` always parses
|
|
121
|
+
fallback.str = version;
|
|
122
|
+
return fallback;
|
|
123
|
+
},
|
|
124
|
+
/** The highest of some version strings by R's `numeric_version` order (`0.9.0 < 0.10.0`); undefined if none. */
|
|
125
|
+
highest(versions) {
|
|
126
|
+
let best;
|
|
127
|
+
for (const v of versions) {
|
|
128
|
+
if (best === undefined || exports.RVersion.compare(v, best) > 0) {
|
|
129
|
+
best = v;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return best;
|
|
104
133
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
134
|
+
};
|
|
135
|
+
/** Helpers for R package version ranges (DESCRIPTION constraints like `>= 0.4-9`). */
|
|
136
|
+
exports.RRange = {
|
|
137
|
+
/**
|
|
138
|
+
* Parse an R version range string into a {@link Range}, normalizing R's freer scheme. The original range
|
|
139
|
+
* string is available via `.str`.
|
|
140
|
+
*
|
|
141
|
+
* This never throws: an unparseable constraint (e.g. `>= abc`, or a git/URL "version" from a lockfile) yields
|
|
142
|
+
* `undefined` rather than aborting the caller, so a malformed constraint is *detectable* and simply contributes
|
|
143
|
+
* no version bound. Parsing is attempted first verbatim, then after normalizing R's scheme to SemVer.
|
|
144
|
+
*/
|
|
145
|
+
parse(range) {
|
|
146
|
+
try {
|
|
147
|
+
return makeRange(range, range);
|
|
148
|
+
}
|
|
149
|
+
catch { /* try to normalize R range to SemVer */ }
|
|
150
|
+
try {
|
|
151
|
+
return makeRange(normalizeVersions(range), range);
|
|
152
|
+
}
|
|
153
|
+
catch { /* unparseable even after normalization -> report as "no constraint" */ }
|
|
154
|
+
return undefined;
|
|
155
|
+
},
|
|
156
|
+
/**
|
|
157
|
+
* Whether an R version string satisfies a range constraint, normalizing R's freer scheme on both sides.
|
|
158
|
+
* `range` may be a parsed {@link Range} or a raw constraint string. Returns `false` if either is unparseable
|
|
159
|
+
* (never throws), so a malformed version/constraint simply does not match.
|
|
160
|
+
*/
|
|
161
|
+
satisfies(version, range) {
|
|
162
|
+
const v = exports.RVersion.parse(version);
|
|
163
|
+
if (v === undefined) {
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
const r = typeof range === 'string' ? exports.RRange.parse(range) : range;
|
|
167
|
+
return r !== undefined && (0, semver_1.satisfies)(v, r, { loose: true, includePrerelease: true });
|
|
168
|
+
}
|
|
169
|
+
};
|
|
109
170
|
//# sourceMappingURL=r-version.js.map
|
package/util/range.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { RNode } from '../r-bridge/lang-4.x/ast/model/model';
|
|
2
|
+
import type { RNodeWithParent } from '../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
2
3
|
/**
|
|
3
4
|
* A source position in a file.
|
|
4
5
|
*
|
|
@@ -135,6 +136,20 @@ export declare const SourceRange: {
|
|
|
135
136
|
*/
|
|
136
137
|
readonly combineRanges: (this: void, ...ranges: SourceRange[]) => SourceRange[];
|
|
137
138
|
readonly fromNode: <OtherInfo>(this: void, node: RNode<OtherInfo> | undefined) => SourceRange | undefined;
|
|
139
|
+
/**
|
|
140
|
+
* "Fuzzy" position match, as opposed to requiring a node to *start* exactly at the position.
|
|
141
|
+
* @see {@link SourceRange.innermostNodes} to narrow the result down to the deepest matches
|
|
142
|
+
*/
|
|
143
|
+
readonly nodesContaining: <OtherInfo>(this: void, nodes: readonly RNodeWithParent<OtherInfo>[], line: number, column?: number) => RNodeWithParent<OtherInfo>[];
|
|
144
|
+
/**
|
|
145
|
+
* Collects all nodes satisfying the innermost condition: those containing no other of the given nodes.
|
|
146
|
+
*
|
|
147
|
+
* Nodes may share a range (a function call and the symbol naming it do), so `treatChildAsInner` decides that
|
|
148
|
+
* tie: with it, a node sharing its parent's range counts as the inner one and the parent drops out; without
|
|
149
|
+
* it, both are kept and the caller may pick between them (e.g. by node type).
|
|
150
|
+
* @see {@link SourceRange.nodesContaining} which this usually narrows down
|
|
151
|
+
*/
|
|
152
|
+
readonly innermostNodes: <OtherInfo>(this: void, nodes: readonly RNodeWithParent<OtherInfo>[], treatChildAsInner?: boolean) => RNodeWithParent<OtherInfo>[];
|
|
138
153
|
};
|
|
139
154
|
/**
|
|
140
155
|
* A source location consisting of a source range and an optional file name.
|
package/util/range.js
CHANGED
|
@@ -195,6 +195,45 @@ exports.SourceRange = {
|
|
|
195
195
|
},
|
|
196
196
|
fromNode(node) {
|
|
197
197
|
return node?.info.fullRange ?? node?.location;
|
|
198
|
+
},
|
|
199
|
+
/**
|
|
200
|
+
* "Fuzzy" position match, as opposed to requiring a node to *start* exactly at the position.
|
|
201
|
+
* @see {@link SourceRange.innermostNodes} to narrow the result down to the deepest matches
|
|
202
|
+
*/
|
|
203
|
+
nodesContaining(nodes, line, column) {
|
|
204
|
+
return nodes.filter(node => {
|
|
205
|
+
const range = exports.SourceRange.fromNode(node);
|
|
206
|
+
if (range === undefined) {
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
return column === undefined ? range[0] <= line && line <= range[2] : exports.SourceRange.containsPosition(range, line, column);
|
|
210
|
+
});
|
|
211
|
+
},
|
|
212
|
+
/**
|
|
213
|
+
* Collects all nodes satisfying the innermost condition: those containing no other of the given nodes.
|
|
214
|
+
*
|
|
215
|
+
* Nodes may share a range (a function call and the symbol naming it do), so `treatChildAsInner` decides that
|
|
216
|
+
* tie: with it, a node sharing its parent's range counts as the inner one and the parent drops out; without
|
|
217
|
+
* it, both are kept and the caller may pick between them (e.g. by node type).
|
|
218
|
+
* @see {@link SourceRange.nodesContaining} which this usually narrows down
|
|
219
|
+
*/
|
|
220
|
+
innermostNodes(nodes, treatChildAsInner = true) {
|
|
221
|
+
if (nodes.length <= 1) {
|
|
222
|
+
return [...nodes];
|
|
223
|
+
}
|
|
224
|
+
return nodes.filter(node => {
|
|
225
|
+
const range = exports.SourceRange.fromNode(node);
|
|
226
|
+
return range !== undefined && !nodes.some(other => {
|
|
227
|
+
if (other === node) {
|
|
228
|
+
return false;
|
|
229
|
+
}
|
|
230
|
+
else if (treatChildAsInner && other.info.parent === node.info.id) {
|
|
231
|
+
return true;
|
|
232
|
+
}
|
|
233
|
+
const otherRange = exports.SourceRange.fromNode(other);
|
|
234
|
+
return otherRange !== undefined && exports.SourceRange.isStrictSubsetOf(otherRange, range);
|
|
235
|
+
});
|
|
236
|
+
});
|
|
198
237
|
}
|
|
199
238
|
};
|
|
200
239
|
/**
|
package/util/schema.d.ts
CHANGED
|
@@ -4,6 +4,16 @@ interface SchemaLine {
|
|
|
4
4
|
level: number;
|
|
5
5
|
text: string;
|
|
6
6
|
}
|
|
7
|
+
/** the leaf type, description, and any enumerated valid values of a schema path */
|
|
8
|
+
export interface SchemaPathInfo {
|
|
9
|
+
readonly type?: string;
|
|
10
|
+
readonly description?: string;
|
|
11
|
+
readonly valids?: readonly unknown[];
|
|
12
|
+
}
|
|
13
|
+
/** walk a Joi schema {@link Joi.Description|description} down a key path, returning the leaf's {@link SchemaPathInfo} (empty if the path does not exist) */
|
|
14
|
+
export declare function descriptionPathInfo(description: Joi.Description, path: readonly string[]): SchemaPathInfo;
|
|
15
|
+
/** {@link descriptionPathInfo} straight from a schema (describes it once per call) */
|
|
16
|
+
export declare function schemaPathInfo(schema: Joi.Schema, path: readonly string[]): SchemaPathInfo;
|
|
7
17
|
/**
|
|
8
18
|
* Describes a Joi schema in a human-readable way.
|
|
9
19
|
*/
|
package/util/schema.js
CHANGED
|
@@ -1,10 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.descriptionPathInfo = descriptionPathInfo;
|
|
4
|
+
exports.schemaPathInfo = schemaPathInfo;
|
|
3
5
|
exports.describeSchema = describeSchema;
|
|
4
6
|
exports.genericDescription = genericDescription;
|
|
5
7
|
exports.headerLine = headerLine;
|
|
6
8
|
exports.describeObject = describeObject;
|
|
7
9
|
const ansi_1 = require("./text/ansi");
|
|
10
|
+
/** walk a Joi schema {@link Joi.Description|description} down a key path, returning the leaf's {@link SchemaPathInfo} (empty if the path does not exist) */
|
|
11
|
+
function descriptionPathInfo(description, path) {
|
|
12
|
+
let node = description;
|
|
13
|
+
for (const key of path) {
|
|
14
|
+
node = node?.keys?.[key];
|
|
15
|
+
if (node === undefined) {
|
|
16
|
+
return {};
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const allow = node.allow;
|
|
20
|
+
return {
|
|
21
|
+
type: node.type,
|
|
22
|
+
description: node.flags?.description,
|
|
23
|
+
valids: allow && allow.length > 0 ? allow : undefined
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/** {@link descriptionPathInfo} straight from a schema (describes it once per call) */
|
|
27
|
+
function schemaPathInfo(schema, path) {
|
|
28
|
+
return descriptionPathInfo(schema.describe(), path);
|
|
29
|
+
}
|
|
8
30
|
/**
|
|
9
31
|
* Describes a Joi schema in a human-readable way.
|
|
10
32
|
*/
|