@eagleoutice/flowr 2.7.6 → 2.8.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 +67 -64
- package/cli/wiki.js +1 -1
- package/control-flow/extract-cfg.js +3 -3
- package/control-flow/useless-loop.d.ts +1 -1
- package/control-flow/useless-loop.js +2 -2
- package/dataflow/cluster.js +3 -3
- package/dataflow/environments/built-in-config.d.ts +8 -4
- package/dataflow/environments/built-in.d.ts +27 -14
- package/dataflow/environments/built-in.js +27 -12
- package/dataflow/environments/default-builtin-config.d.ts +614 -3
- package/dataflow/environments/default-builtin-config.js +50 -15
- package/dataflow/environments/environment.js +3 -2
- package/dataflow/environments/identifier.d.ts +5 -1
- package/dataflow/environments/reference-to-maybe.d.ts +2 -2
- package/dataflow/environments/reference-to-maybe.js +23 -14
- package/dataflow/environments/resolve-by-name.d.ts +6 -2
- package/dataflow/environments/resolve-by-name.js +5 -1
- package/dataflow/environments/scoping.js +1 -3
- package/dataflow/eval/resolve/alias-tracking.js +5 -1
- package/dataflow/extractor.js +3 -3
- package/dataflow/fn/exceptions-of-function.d.ts +13 -0
- package/dataflow/fn/exceptions-of-function.js +47 -0
- package/dataflow/fn/higher-order-function.d.ts +1 -1
- package/dataflow/fn/higher-order-function.js +3 -3
- package/dataflow/fn/recursive-function.d.ts +6 -0
- package/dataflow/fn/recursive-function.js +32 -0
- package/dataflow/graph/call-graph.d.ts +10 -0
- package/dataflow/graph/call-graph.js +209 -0
- package/dataflow/graph/dataflowgraph-builder.d.ts +7 -2
- package/dataflow/graph/dataflowgraph-builder.js +14 -9
- package/dataflow/graph/diff-dataflow-graph.js +96 -2
- package/dataflow/graph/graph.d.ts +10 -7
- package/dataflow/graph/graph.js +7 -8
- package/dataflow/graph/vertex.d.ts +6 -3
- package/dataflow/hooks.d.ts +30 -0
- package/dataflow/hooks.js +38 -0
- package/dataflow/info.d.ts +28 -5
- package/dataflow/info.js +66 -31
- package/dataflow/internal/linker.d.ts +13 -3
- package/dataflow/internal/linker.js +155 -53
- package/dataflow/internal/process/functions/call/argument/unpack-argument.d.ts +4 -0
- package/dataflow/internal/process/functions/call/argument/unpack-argument.js +7 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +19 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +14 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +30 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +24 -17
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +5 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +59 -21
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +4 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.d.ts +34 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.js +92 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +1 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-stop-if-not.d.ts +21 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-stop-if-not.js +129 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +16 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +127 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +5 -3
- package/dataflow/internal/process/functions/call/common.d.ts +13 -1
- package/dataflow/internal/process/functions/call/common.js +33 -2
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +13 -1
- package/dataflow/internal/process/functions/call/known-call-handling.js +29 -3
- package/dataflow/internal/process/functions/call/named-call-handling.js +2 -1
- package/dataflow/internal/process/functions/call/unnamed-call-handling.js +6 -4
- package/dataflow/internal/process/functions/process-argument.js +7 -6
- package/dataflow/internal/process/functions/process-parameter.js +2 -1
- package/dataflow/internal/process/process-named-call.d.ts +2 -2
- package/dataflow/internal/process/process-symbol.js +3 -2
- package/dataflow/internal/process/process-value.d.ts +3 -2
- package/dataflow/internal/process/process-value.js +8 -6
- package/dataflow/origin/dfg-get-origin.js +2 -1
- package/dataflow/origin/dfg-get-symbol-refs.js +1 -1
- package/documentation/doc-readme.d.ts +1 -1
- package/documentation/doc-readme.js +6 -6
- package/documentation/doc-util/doc-code.js +1 -1
- package/documentation/doc-util/doc-dfg.d.ts +1 -0
- package/documentation/doc-util/doc-dfg.js +7 -4
- package/documentation/doc-util/doc-query.d.ts +1 -0
- package/documentation/doc-util/doc-query.js +1 -1
- package/documentation/doc-util/doc-repl.d.ts +2 -1
- package/documentation/doc-util/doc-repl.js +11 -3
- package/documentation/wiki-analyzer.js +2 -0
- package/documentation/wiki-dataflow-graph.js +59 -16
- package/documentation/wiki-interface.js +33 -5
- package/documentation/wiki-mk/doc-context.d.ts +2 -1
- package/documentation/wiki-mk/doc-context.js +2 -2
- package/documentation/wiki-mk/doc-maker.js +4 -3
- package/documentation/wiki-normalized-ast.js +6 -0
- package/documentation/wiki-query.js +109 -1
- package/linter/linter-rules.d.ts +1 -1
- package/linter/rules/seeded-randomness.js +17 -12
- package/linter/rules/useless-loop.d.ts +1 -1
- package/package.json +9 -9
- package/project/cache/flowr-analyzer-cache.d.ts +11 -0
- package/project/cache/flowr-analyzer-cache.js +19 -0
- package/project/context/flowr-analyzer-dependencies-context.d.ts +6 -1
- package/project/context/flowr-analyzer-dependencies-context.js +6 -0
- package/project/context/flowr-analyzer-files-context.d.ts +5 -2
- package/project/context/flowr-analyzer-files-context.js +24 -17
- package/project/context/flowr-file.d.ts +9 -4
- package/project/context/flowr-file.js +20 -6
- package/project/flowr-analyzer.d.ts +11 -0
- package/project/flowr-analyzer.js +6 -0
- package/project/plugins/file-plugins/files/flowr-description-file.d.ts +8 -0
- package/project/plugins/file-plugins/files/flowr-description-file.js +36 -3
- package/project/plugins/file-plugins/files/flowr-jupyter-file.js +1 -1
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +1 -1
- package/project/plugins/file-plugins/files/flowr-news-file.js +1 -1
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.js +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-file-plugin.d.ts +4 -1
- package/project/plugins/file-plugins/flowr-analyzer-file-plugin.js +3 -0
- package/project/plugins/file-plugins/{flowr-analyzer-namespace-file-plugin.d.ts → flowr-analyzer-namespace-files-plugin.d.ts} +1 -1
- package/project/plugins/file-plugins/{flowr-analyzer-namespace-file-plugin.js → flowr-analyzer-namespace-files-plugin.js} +4 -4
- package/project/plugins/file-plugins/flowr-analyzer-test-file-plugin.d.ts +26 -0
- package/project/plugins/file-plugins/flowr-analyzer-test-file-plugin.js +39 -0
- package/project/plugins/file-plugins/flowr-analyzer-vignette-file-plugin.d.ts +26 -0
- package/project/plugins/file-plugins/flowr-analyzer-vignette-file-plugin.js +39 -0
- package/project/plugins/flowr-analyzer-plugin-defaults.js +6 -2
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.js +3 -13
- package/project/plugins/package-version-plugins/package.d.ts +1 -1
- package/project/plugins/package-version-plugins/package.js +3 -3
- package/project/plugins/plugin-registry.d.ts +4 -2
- package/project/plugins/plugin-registry.js +6 -2
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.d.ts +11 -0
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +5 -2
- package/queries/catalog/call-context-query/call-context-query-format.d.ts +4 -12
- package/queries/catalog/call-graph-query/call-graph-query-executor.d.ts +6 -0
- package/queries/catalog/call-graph-query/call-graph-query-executor.js +21 -0
- package/queries/catalog/call-graph-query/call-graph-query-format.d.ts +21 -0
- package/queries/catalog/call-graph-query/call-graph-query-format.js +32 -0
- package/queries/catalog/dataflow-query/dataflow-query-executor.js +4 -3
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +29 -3
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +1 -0
- package/queries/catalog/dependencies-query/function-info/function-info.d.ts +8 -1
- package/queries/catalog/dependencies-query/function-info/write-functions.js +13 -0
- package/queries/catalog/does-call-query/does-call-query-executor.d.ts +6 -0
- package/queries/catalog/does-call-query/does-call-query-executor.js +100 -0
- package/queries/catalog/does-call-query/does-call-query-format.d.ts +51 -0
- package/queries/catalog/does-call-query/does-call-query-format.js +102 -0
- package/queries/catalog/files-query/files-query-executor.js +4 -4
- package/queries/catalog/files-query/files-query-format.d.ts +2 -1
- package/queries/catalog/files-query/files-query-format.js +18 -2
- package/queries/catalog/id-map-query/id-map-query-executor.js +4 -3
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.d.ts +18 -0
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.js +56 -0
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.d.ts +34 -0
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +54 -0
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +3 -28
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +6 -0
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +12 -0
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.d.ts +6 -0
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.js +23 -0
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.d.ts +28 -0
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.js +44 -0
- package/queries/catalog/linter-query/linter-query-format.js +4 -1
- package/queries/catalog/location-map-query/location-map-query-executor.js +1 -1
- package/queries/catalog/normalized-ast-query/normalized-ast-query-executor.js +4 -3
- package/queries/catalog/project-query/project-query-executor.js +9 -3
- package/queries/catalog/project-query/project-query-format.d.ts +6 -1
- package/queries/catalog/project-query/project-query-format.js +35 -9
- package/queries/query.d.ts +34 -2
- package/queries/query.js +9 -0
- package/r-bridge/data/data.d.ts +10 -5
- package/r-bridge/data/data.js +11 -5
- package/r-bridge/lang-4.x/ast/model/model.d.ts +7 -7
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +2 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +2 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +2 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +5 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.js +8 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +2 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +2 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +2 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +2 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +2 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +2 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +2 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +2 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +2 -2
- package/r-bridge/lang-4.x/ast/parser/main/internal/other/normalize-comment.js +0 -1
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +0 -2
- package/r-bridge/roxygen2/roxygen-ast.d.ts +218 -0
- package/r-bridge/roxygen2/roxygen-ast.js +82 -0
- package/r-bridge/roxygen2/roxygen-parse.d.ts +24 -0
- package/r-bridge/roxygen2/roxygen-parse.js +214 -0
- package/reconstruct/auto-select/magic-comments.js +4 -4
- package/slicing/static/slice-call.js +3 -4
- package/slicing/static/static-slicer.js +2 -2
- package/statistics/features/supported/defined-functions/defined-functions.js +1 -1
- package/util/collections/defaultmap.d.ts +3 -3
- package/util/mermaid/dfg.js +5 -5
- package/util/objects.js +1 -1
- package/util/r-author.d.ts +5 -0
- package/util/r-author.js +110 -0
- package/util/r-license.d.ts +10 -1
- package/util/r-license.js +27 -6
- package/util/r-version.d.ts +19 -0
- package/util/r-version.js +106 -0
- package/util/range.d.ts +6 -0
- package/util/range.js +7 -0
- package/util/simple-df/dfg-ascii.js +2 -2
- package/util/text/args.d.ts +9 -0
- package/util/text/args.js +65 -0
- package/util/version.js +1 -1
package/util/r-license.js
CHANGED
|
@@ -1,16 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseRLicense = parseRLicense;
|
|
4
|
-
|
|
4
|
+
exports.stringifyRLicense = stringifyRLicense;
|
|
5
5
|
const assert_1 = require("./assert");
|
|
6
6
|
const objects_1 = require("./objects");
|
|
7
|
+
const r_version_1 = require("./r-version");
|
|
7
8
|
/**
|
|
8
9
|
* Parses an R license string into its structured representation.
|
|
9
10
|
*/
|
|
10
11
|
function parseRLicense(licenseString) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
return parseLicenseInfo(skipWhitespace({ position: 0, remInput: licenseString })).element;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Stringifies an R license element back into its string representation.
|
|
16
|
+
*/
|
|
17
|
+
function stringifyRLicense(license) {
|
|
18
|
+
const t = license.type;
|
|
19
|
+
switch (t) {
|
|
20
|
+
case 'no-license':
|
|
21
|
+
return 'NO LICENSE';
|
|
22
|
+
case 'license':
|
|
23
|
+
return license.versionConstraint ? `${license.license} (${license.versionConstraint.raw})` : license.license;
|
|
24
|
+
case 'exception':
|
|
25
|
+
return `with ${license.exception}`;
|
|
26
|
+
case 'combination': {
|
|
27
|
+
const left = stringifyRLicense(license.elements[0]);
|
|
28
|
+
const right = stringifyRLicense(license.elements[1]);
|
|
29
|
+
const leftStr = license.elements[0].type === 'combination' ? `(${left})` : left;
|
|
30
|
+
const rightStr = license.elements[1].type === 'combination' ? `(${right})` : right;
|
|
31
|
+
return `${leftStr} ${license.combination} ${rightStr}`;
|
|
32
|
+
}
|
|
33
|
+
default:
|
|
34
|
+
(0, assert_1.assertUnreachable)(t);
|
|
35
|
+
}
|
|
14
36
|
}
|
|
15
37
|
function parseLicenseInfo(info) {
|
|
16
38
|
info = skipWhitespace(info);
|
|
@@ -72,8 +94,7 @@ function consumeLicenseName(info) {
|
|
|
72
94
|
}
|
|
73
95
|
function makeRange(rangeStr) {
|
|
74
96
|
try {
|
|
75
|
-
|
|
76
|
-
return new semver_1.Range(rangeStr);
|
|
97
|
+
return (0, r_version_1.parseRRange)(rangeStr);
|
|
77
98
|
}
|
|
78
99
|
catch {
|
|
79
100
|
return undefined;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Range, SemVer } from 'semver';
|
|
2
|
+
/**
|
|
3
|
+
* This parses an R version string and returns a SemVer object.
|
|
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 & {
|
|
9
|
+
str: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* This parses an R version range string and returns a SemVer Range object.
|
|
13
|
+
* In contrast to just using `new Range(range)`, this function also tries to
|
|
14
|
+
* normalize R's much free-er versioning scheme into valid SemVer ranges.
|
|
15
|
+
* You can always access the original range string via the `str` property on the returned object.
|
|
16
|
+
*/
|
|
17
|
+
export declare function parseRRange(range: string): Range & {
|
|
18
|
+
str: string;
|
|
19
|
+
};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseRVersion = parseRVersion;
|
|
4
|
+
exports.parseRRange = parseRRange;
|
|
5
|
+
const semver_1 = require("semver");
|
|
6
|
+
const assert_1 = require("./assert");
|
|
7
|
+
function makeVersion(version, original) {
|
|
8
|
+
const semver = new semver_1.SemVer(version);
|
|
9
|
+
semver.str = original;
|
|
10
|
+
return semver;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Additionally, this transforms `a-b.c` into `a.0.0-b.c` and `a.b-c.d` into `a.b.0-c.d` to
|
|
14
|
+
* ensure valid SemVer format.
|
|
15
|
+
*/
|
|
16
|
+
function normalizeTooShortVersions(versions) {
|
|
17
|
+
const TooShortVersionRegex = /(^|(?<=[^\d.-]))(?<major>\d+)(\.(?<minor>\d+))?\.?-(?<prerelease>[0-9A-Za-z-.]+)(\s|$)/g;
|
|
18
|
+
let newVersions = '';
|
|
19
|
+
let match;
|
|
20
|
+
while ((match = TooShortVersionRegex.exec(versions)) !== null) {
|
|
21
|
+
const { major, minor, prerelease } = match.groups;
|
|
22
|
+
const prefix = versions.slice(0, match.index);
|
|
23
|
+
let newVersion = '';
|
|
24
|
+
if (minor === undefined) {
|
|
25
|
+
// only major version present
|
|
26
|
+
newVersion = `${major}.0.0-${prerelease}`;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
// major and minor version present, but dot before prerelease
|
|
30
|
+
newVersion = `${major}.${minor}.0-${prerelease}`;
|
|
31
|
+
}
|
|
32
|
+
newVersions += `${prefix}${newVersion}`;
|
|
33
|
+
versions = versions.slice(match.index + match[0].length);
|
|
34
|
+
}
|
|
35
|
+
newVersions += versions; // append any remaining part
|
|
36
|
+
return newVersions;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* For every version `a.b.c.d.e...` converts it to `a.b.c-d.e...`
|
|
40
|
+
* If the version already contains a prerelease part, it is appended:
|
|
41
|
+
* `a.b.c.d.e-prerelease...` becomes `a.b.c-d.e-prerelease...`
|
|
42
|
+
*/
|
|
43
|
+
function normalizeAdditionalVersionsToPrerelease(version) {
|
|
44
|
+
version = normalizeTooShortVersions(version);
|
|
45
|
+
const AdditionalVersionRegex = /(\d+\.\d+\.\d+)(?<additional>(\.\d+)+)(-(?<prerelease>[0-9A-Za-z-.]+))?/g;
|
|
46
|
+
let match;
|
|
47
|
+
let newVersion = '';
|
|
48
|
+
// repeat until no more matches
|
|
49
|
+
while ((match = AdditionalVersionRegex.exec(version)) !== null) {
|
|
50
|
+
// append to new version, first take over anything before the match
|
|
51
|
+
const prefix = version.slice(0, match.index);
|
|
52
|
+
const { additional, prerelease } = match.groups;
|
|
53
|
+
const additionalParts = additional.slice(1).split('.'); // remove leading dot and split
|
|
54
|
+
if (additionalParts.length === 0) {
|
|
55
|
+
continue; // nothing to do
|
|
56
|
+
}
|
|
57
|
+
let newPrerelease = additionalParts.join('.');
|
|
58
|
+
if (prerelease) {
|
|
59
|
+
newPrerelease = `${newPrerelease}-${prerelease}`;
|
|
60
|
+
}
|
|
61
|
+
newVersion = `${prefix}${match[1]}-${newPrerelease}`;
|
|
62
|
+
version = version.slice(match.index + match[0].length);
|
|
63
|
+
}
|
|
64
|
+
newVersion += version; // append any remaining part
|
|
65
|
+
return newVersion;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* This parses an R version string and returns a SemVer object.
|
|
69
|
+
* In contrast to just using `new SemVer(version)`, this function also tries to
|
|
70
|
+
* normalize R's much free-er versioning scheme into valid SemVer versions.
|
|
71
|
+
* You can always access the original version string via the `str` property on the returned object.
|
|
72
|
+
*/
|
|
73
|
+
function parseRVersion(version) {
|
|
74
|
+
try {
|
|
75
|
+
return makeVersion(version, version);
|
|
76
|
+
}
|
|
77
|
+
catch { /* do nothing */ }
|
|
78
|
+
try {
|
|
79
|
+
const normalized = normalizeAdditionalVersionsToPrerelease(version);
|
|
80
|
+
return makeVersion(normalized, version);
|
|
81
|
+
}
|
|
82
|
+
catch { /* do nothing */ }
|
|
83
|
+
const coerced = (0, semver_1.coerce)(version, { loose: true, includePrerelease: true });
|
|
84
|
+
(0, assert_1.guard)(coerced !== null, `Could not coerce R version "${version}" to SemVer`);
|
|
85
|
+
return makeVersion(coerced.version, version);
|
|
86
|
+
}
|
|
87
|
+
function makeRange(range, original) {
|
|
88
|
+
const semverRange = new semver_1.Range(range);
|
|
89
|
+
semverRange.str = original;
|
|
90
|
+
return semverRange;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* This parses an R version range string and returns a SemVer Range object.
|
|
94
|
+
* In contrast to just using `new Range(range)`, this function also tries to
|
|
95
|
+
* normalize R's much free-er versioning scheme into valid SemVer ranges.
|
|
96
|
+
* You can always access the original range string via the `str` property on the returned object.
|
|
97
|
+
*/
|
|
98
|
+
function parseRRange(range) {
|
|
99
|
+
try {
|
|
100
|
+
return makeRange(range, range);
|
|
101
|
+
}
|
|
102
|
+
catch { /* try to normalize R range to SemVer */ }
|
|
103
|
+
const normalized = normalizeAdditionalVersionsToPrerelease(range);
|
|
104
|
+
return makeRange(normalized.replace(/==/g, '='), range);
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=r-version.js.map
|
package/util/range.d.ts
CHANGED
|
@@ -43,6 +43,10 @@ export declare function getRangeEnd(p: SourceRange | undefined): SourcePosition
|
|
|
43
43
|
* @param ec - end column
|
|
44
44
|
*/
|
|
45
45
|
export declare function rangeFrom(sl: number | string, sc: number | string, el: number | string, ec: number | string): SourceRange;
|
|
46
|
+
/**
|
|
47
|
+
* @returns an invalid source range
|
|
48
|
+
*/
|
|
49
|
+
export declare function invalidRange(): SourceRange;
|
|
46
50
|
/**
|
|
47
51
|
* Merges multiple source ranges into a single source range that spans from the earliest start to the latest end.
|
|
48
52
|
* If you are interested in combining overlapping ranges into a minimal set of ranges, see {@link combineRanges}.
|
|
@@ -75,3 +79,5 @@ export declare function rangeIsSubsetOf([r1sl, r1sc, r1el, r1ec]: SourceRange, [
|
|
|
75
79
|
* If you are interested in merging overlapping ranges, see {@link mergeRanges}.
|
|
76
80
|
*/
|
|
77
81
|
export declare function combineRanges(...ranges: SourceRange[]): SourceRange[];
|
|
82
|
+
/** A source location consisting of a source range and an optional file name. */
|
|
83
|
+
export type SourceLocation = [...r: SourceRange, f?: string];
|
package/util/range.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getRangeStart = getRangeStart;
|
|
4
4
|
exports.getRangeEnd = getRangeEnd;
|
|
5
5
|
exports.rangeFrom = rangeFrom;
|
|
6
|
+
exports.invalidRange = invalidRange;
|
|
6
7
|
exports.mergeRanges = mergeRanges;
|
|
7
8
|
exports.rangeStartsCompletelyBefore = rangeStartsCompletelyBefore;
|
|
8
9
|
exports.rangesOverlap = rangesOverlap;
|
|
@@ -33,6 +34,12 @@ function getRangeEnd(p) {
|
|
|
33
34
|
function rangeFrom(sl, sc, el, ec) {
|
|
34
35
|
return [Number(sl), Number(sc), Number(el), Number(ec)];
|
|
35
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* @returns an invalid source range
|
|
39
|
+
*/
|
|
40
|
+
function invalidRange() {
|
|
41
|
+
return [-1, -1, -1, -1];
|
|
42
|
+
}
|
|
36
43
|
/**
|
|
37
44
|
* Merges multiple source ranges into a single source range that spans from the earliest start to the latest end.
|
|
38
45
|
* If you are interested in combining overlapping ranges into a minimal set of ranges, see {@link combineRanges}.
|
package/util/text/args.d.ts
CHANGED
|
@@ -14,3 +14,12 @@
|
|
|
14
14
|
* @param split - The character or character sequence to split on (can not be backslash or quote!)
|
|
15
15
|
*/
|
|
16
16
|
export declare function splitAtEscapeSensitive(inputString: string, escapeQuote?: boolean, split?: RegExp | string): string[];
|
|
17
|
+
/**
|
|
18
|
+
* Splits the given string on 'and', but only if not nested inside `<>`, `[]`, `()`, or quotes.
|
|
19
|
+
* This also handles escaped quotes.
|
|
20
|
+
* @param str - The string to split
|
|
21
|
+
* @param splitOn - The string to split on (default: 'and')
|
|
22
|
+
* @param closes - The matching of closing characters for nesting, structures with different open and close characters only can be nested
|
|
23
|
+
* of each other, while those with the same open and close character (like quotes) can not be nested inside themselves.
|
|
24
|
+
*/
|
|
25
|
+
export declare function splitOnNestingSensitive(str: string, splitOn?: string, closes?: Record<string, string>): string[];
|
package/util/text/args.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.splitAtEscapeSensitive = splitAtEscapeSensitive;
|
|
8
|
+
exports.splitOnNestingSensitive = splitOnNestingSensitive;
|
|
8
9
|
/**
|
|
9
10
|
* This splits an input string on the given split string (e.g., ` `), but checks if the string is quoted or escaped.
|
|
10
11
|
*
|
|
@@ -81,4 +82,68 @@ function splitAtEscapeSensitive(inputString, escapeQuote = true, split = ' ') {
|
|
|
81
82
|
}
|
|
82
83
|
return args;
|
|
83
84
|
}
|
|
85
|
+
const MatchingClose = {
|
|
86
|
+
'<': '>',
|
|
87
|
+
'[': ']',
|
|
88
|
+
'(': ')',
|
|
89
|
+
'"': '"',
|
|
90
|
+
"'": "'"
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Splits the given string on 'and', but only if not nested inside `<>`, `[]`, `()`, or quotes.
|
|
94
|
+
* This also handles escaped quotes.
|
|
95
|
+
* @param str - The string to split
|
|
96
|
+
* @param splitOn - The string to split on (default: 'and')
|
|
97
|
+
* @param closes - The matching of closing characters for nesting, structures with different open and close characters only can be nested
|
|
98
|
+
* of each other, while those with the same open and close character (like quotes) can not be nested inside themselves.
|
|
99
|
+
*/
|
|
100
|
+
function splitOnNestingSensitive(str, splitOn = 'and', closes = MatchingClose) {
|
|
101
|
+
const result = [];
|
|
102
|
+
const openCloseSame = new Set(Object.entries(closes).filter(([open, close]) => open === close).map(([open]) => open));
|
|
103
|
+
let current = '';
|
|
104
|
+
const nestStack = [];
|
|
105
|
+
for (let i = 0; i < str.length; i++) {
|
|
106
|
+
const c = str[i];
|
|
107
|
+
if (c === '\\' && i + 1 < str.length) {
|
|
108
|
+
// skip escaped characters
|
|
109
|
+
current += c + str[i + 1];
|
|
110
|
+
i++;
|
|
111
|
+
}
|
|
112
|
+
else if (nestStack.length > 0) {
|
|
113
|
+
if (!openCloseSame.has(c) && c in closes) {
|
|
114
|
+
// opening a new nest
|
|
115
|
+
nestStack.push(c);
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
const top = nestStack[nestStack.length - 1];
|
|
119
|
+
if (c === closes[top]) {
|
|
120
|
+
nestStack.pop();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
current += c;
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
if (c in closes) {
|
|
127
|
+
nestStack.push(c);
|
|
128
|
+
current += c;
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
// check for 'and' split
|
|
132
|
+
if (str.slice(i, i + splitOn.length) === splitOn &&
|
|
133
|
+
(i === 0 || /\s/.test(str[i - 1])) &&
|
|
134
|
+
(i + splitOn.length >= str.length || /\s/.test(str[i + splitOn.length]))) {
|
|
135
|
+
// split here
|
|
136
|
+
result.push(current.trim());
|
|
137
|
+
current = '';
|
|
138
|
+
i += splitOn.length - 1;
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
current += c;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (current.trim().length > 0) {
|
|
145
|
+
result.push(current.trim());
|
|
146
|
+
}
|
|
147
|
+
return result;
|
|
148
|
+
}
|
|
84
149
|
//# sourceMappingURL=args.js.map
|
package/util/version.js
CHANGED
|
@@ -6,7 +6,7 @@ exports.printVersionInformation = printVersionInformation;
|
|
|
6
6
|
const semver_1 = require("semver");
|
|
7
7
|
const assert_1 = require("./assert");
|
|
8
8
|
// this is automatically replaced with the current version by release-it
|
|
9
|
-
const version = '2.
|
|
9
|
+
const version = '2.8.0';
|
|
10
10
|
/**
|
|
11
11
|
* Retrieves the current flowR version as a new {@link SemVer} object.
|
|
12
12
|
*/
|