@eagleoutice/flowr 2.13.9 → 2.13.10
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/config.d.ts +50 -2
- package/config.js +37 -6
- package/dataflow/environments/apply-kill.js +4 -4
- package/dataflow/environments/built-in-props.d.ts +28 -4
- package/dataflow/environments/built-in-props.js +31 -8
- package/dataflow/environments/built-in.d.ts +7 -2
- package/dataflow/environments/built-in.js +10 -12
- package/dataflow/environments/default-builtin-config.d.ts +46 -6
- package/dataflow/environments/default-builtin-config.js +30 -16
- package/dataflow/environments/environment.d.ts +16 -0
- package/dataflow/environments/environment.js +70 -18
- package/dataflow/environments/identifier.d.ts +6 -0
- package/dataflow/environments/identifier.js +18 -5
- package/dataflow/environments/query-fn-props.js +34 -2
- package/dataflow/environments/reference-to-maybe.js +1 -1
- package/dataflow/eval/resolve/alias-tracking.js +45 -1
- package/dataflow/eval/resolve/resolve-argument.js +25 -17
- package/dataflow/eval/resolve/resolve-strings.d.ts +17 -0
- package/dataflow/eval/resolve/resolve-strings.js +16 -9
- package/dataflow/eval/resolve/resolve.js +3 -1
- package/dataflow/graph/call-graph.d.ts +7 -0
- package/dataflow/graph/call-graph.js +103 -0
- package/dataflow/graph/df-helper.d.ts +2 -0
- package/dataflow/graph/graph.d.ts +5 -8
- package/dataflow/internal/linker.d.ts +5 -5
- package/dataflow/internal/linker.js +31 -92
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +3 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +4 -30
- 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.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +7 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-load.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +5 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-with.d.ts +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +5 -6
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +32 -14
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +16 -4
- package/dataflow/internal/process/functions/call/known-call-handling.js +29 -8
- package/documentation/doc-util/doc-sigdb.d.ts +9 -0
- package/documentation/doc-util/doc-sigdb.js +32 -0
- package/documentation/wiki-interface.js +13 -2
- package/documentation/wiki-query.js +3 -0
- package/documentation/wiki-signature-database.js +2 -5
- package/gas.d.ts +6 -0
- package/gas.js +7 -1
- package/package.json +1 -1
- package/project/attached-packages.d.ts +13 -0
- package/project/attached-packages.js +30 -0
- package/project/context/flowr-analyzer-context.d.ts +15 -0
- package/project/context/flowr-analyzer-context.js +14 -3
- package/project/context/flowr-analyzer-files-context.d.ts +11 -0
- package/project/context/flowr-analyzer-files-context.js +3 -0
- package/project/context/flowr-analyzer-incremental-analysis-context.d.ts +4 -0
- package/project/context/flowr-analyzer-incremental-analysis-context.js +69 -0
- package/project/dependency-version-space.d.ts +33 -11
- package/project/dependency-version-space.js +58 -32
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +52 -24
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-library-plugin.d.ts +22 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-library-plugin.js +101 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +30 -11
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +79 -37
- package/project/plugins/plugin-registry.d.ts +2 -1
- package/project/plugins/plugin-registry.js +2 -0
- package/project/sigdb/manifest.js +9 -5
- package/project/sigdb/signature-match.d.ts +5 -18
- package/project/sigdb/signature-match.js +5 -18
- package/queries/catalog/call-graph-query/call-graph-query-executor.js +3 -1
- package/queries/catalog/call-graph-query/call-graph-query-format.d.ts +4 -0
- package/queries/catalog/call-graph-query/call-graph-query-format.js +4 -0
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +10 -3
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +19 -1
- package/queries/catalog/dependencies-query/dependencies-query-format.js +22 -2
- package/queries/catalog/dependencies-query/function-info/library-functions.js +7 -1
- package/queries/catalog/dependencies-query/function-info/read-functions.js +5 -5
- package/queries/catalog/dependencies-query/function-info/remote-functions.d.ts +18 -0
- package/queries/catalog/dependencies-query/function-info/remote-functions.js +46 -0
- package/queries/catalog/dependencies-query/function-info/visualize-functions.js +52 -2
- package/queries/catalog/dependencies-query/function-info/write-functions.js +8 -4
- package/queries/catalog/dependencies-query/link-devices.d.ts +12 -0
- package/queries/catalog/dependencies-query/link-devices.js +58 -0
- package/queries/catalog/dice-query/dice-query-format.d.ts +2 -0
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +25 -6
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +37 -6
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +17 -4
- package/queries/catalog/input-sources-query/input-sources-query-format.js +4 -0
- package/queries/catalog/input-sources-query/input-types.d.ts +10 -0
- package/queries/catalog/input-sources-query/input-types.js +10 -0
- package/queries/catalog/location-map-query/location-map-query-executor.js +16 -6
- package/queries/catalog/location-map-query/location-map-query-format.d.ts +15 -1
- package/queries/catalog/location-map-query/location-map-query-format.js +22 -5
- package/queries/catalog/signature-query/signature-query-executor.js +3 -0
- package/queries/catalog/signature-query/signature-query-format.d.ts +5 -0
- package/queries/query.d.ts +1 -1
- package/r-bridge/lang-4.x/ast/model/model.d.ts +14 -2
- package/r-bridge/lang-4.x/ast/model/model.js +32 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +7 -8
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +9 -46
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +0 -5
- package/r-bridge/lang-4.x/ast/model/processing/node-id.js +6 -3
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +1 -1
- package/search/flowr-search-filters.d.ts +17 -1
- package/search/flowr-search-filters.js +23 -0
- package/slicing/criterion/parse.d.ts +5 -25
- package/slicing/criterion/parse.js +15 -20
- package/slicing/static/fingerprint.js +18 -6
- package/slicing/static/slicer-types.d.ts +10 -0
- package/slicing/static/static-slicer.d.ts +1 -1
- package/slicing/static/static-slicer.js +29 -6
- package/slicing/static/visiting-queue.d.ts +12 -2
- package/slicing/static/visiting-queue.js +28 -3
- package/util/arg-matching.d.ts +18 -0
- package/util/arg-matching.js +70 -0
- package/util/r-regex.js +19 -1
- package/util/range.d.ts +7 -8
- package/util/range.js +10 -11
- package/util/version.js +1 -1
|
@@ -187,7 +187,11 @@ function compareBounds(a, b) {
|
|
|
187
187
|
}
|
|
188
188
|
/** whether a dependency's version is actually narrowed (not every database version survives); a fully redundant one is unconstrained */
|
|
189
189
|
function isConstrained(dep) {
|
|
190
|
-
return dep.
|
|
190
|
+
return dep.constrained !== false;
|
|
191
|
+
}
|
|
192
|
+
/** the assumed R version with where it came from, as a detected one bounds the guess without describing the code */
|
|
193
|
+
function rVersionText(out, formatter) {
|
|
194
|
+
return (0, ansi_1.italic)(out.rVersion, formatter) + (out.rVersionOrigin ? ' ' + (0, ansi_1.faint)(`(${out.rVersionOrigin})`, formatter) : '');
|
|
191
195
|
}
|
|
192
196
|
/** a version-combination count with thousands separators (exponential only past a trillion, where digits stop being useful) */
|
|
193
197
|
function formatCombinations(n) {
|
|
@@ -228,10 +232,10 @@ exports.GuessDepVersionsQueryDefinition = {
|
|
|
228
232
|
const out = queryResults;
|
|
229
233
|
result.push(`Query: ${(0, ansi_1.bold)('guess-dep-versions', formatter)} (${(0, time_1.printAsMs)(out['.meta'].timing, 0)})`);
|
|
230
234
|
if (out.dateCutoff) {
|
|
231
|
-
result.push(` ╰ up to ${(0, ansi_1.italic)(out.dateCutoff, formatter)}${out.rVersion ? `, R ${(
|
|
235
|
+
result.push(` ╰ up to ${(0, ansi_1.italic)(out.dateCutoff, formatter)}${out.rVersion ? `, R ${rVersionText(out, formatter)}` : ''}`);
|
|
232
236
|
}
|
|
233
237
|
else if (out.rVersion) {
|
|
234
|
-
result.push(` ╰ R ${(
|
|
238
|
+
result.push(` ╰ R ${rVersionText(out, formatter)}`);
|
|
235
239
|
}
|
|
236
240
|
if (out.dependencies.some(d => d.evidence.length > 0)) {
|
|
237
241
|
const legend = Object.keys(evidenceLetter).map(s => `${(0, ansi_1.color)(evidenceLetter[s], evidenceColor[s], formatter)} ${s}`).join(' ');
|
|
@@ -290,6 +294,13 @@ exports.GuessDepVersionsQueryDefinition = {
|
|
|
290
294
|
const dbGe = versionBound(tightestBound(avail, '>='))?.ver, dbLe = versionBound(tightestBound(avail, '<='))?.ver;
|
|
291
295
|
const dbRange = dbGe !== undefined && dbLe !== undefined ? `, db ${dbGe} - ${dbLe}` : '';
|
|
292
296
|
result.push(` ${(0, ansi_1.bold)('━ ' + dep.package, formatter)}${tag} ${range} ${(0, ansi_1.faint)('(' + count + dbRange + ')', formatter)}`);
|
|
297
|
+
for (const o of dep.orphanEvidence ?? []) {
|
|
298
|
+
// why the package is inferred at all: the call is undefined without it, plus why it beat another exporter
|
|
299
|
+
const where = o.location ? ` at ${o.location}` : '';
|
|
300
|
+
const why = o.reason === 'sole exporter' ? ` ${(0, ansi_1.faint)(`(only ${dep.package})`, formatter)}`
|
|
301
|
+
: o.reason === 'most downloaded' ? ` ${(0, ansi_1.faint)(`(most downloaded of ${o.exporters})`, formatter)}` : '';
|
|
302
|
+
result.push(` ${(0, ansi_1.color)('!', 3 /* Colors.Yellow */, formatter)} ${o.function}()${where} resolves to no definition${why}`);
|
|
303
|
+
}
|
|
293
304
|
if (dep.orphanAlternatives?.length) {
|
|
294
305
|
// attributing an orphan is a guess, so name the exporters it beat and what each of them would fit
|
|
295
306
|
const alts = dep.orphanAlternatives.map(a => `${a.package} ${a.range}`);
|
|
@@ -333,7 +344,9 @@ exports.GuessDepVersionsQueryDefinition = {
|
|
|
333
344
|
const ge = tightestBound(evs, '>='), le = tightestBound(evs, '<=');
|
|
334
345
|
const geVer = versionBound(ge)?.ver, leVer = versionBound(le)?.ver;
|
|
335
346
|
const params = [...new Set(evs.map(e => e.parameter).filter((pm) => pm !== undefined))];
|
|
336
|
-
const
|
|
347
|
+
const at = evs.find(e => e.location)?.location;
|
|
348
|
+
const reasons = [evs.some(e => !e.parameter) ? 'new' : undefined, params.length > 0 ? `params: [${truncatedList(params)}]` : undefined,
|
|
349
|
+
at ? `at ${at}` : undefined].filter(Boolean).join(', ');
|
|
337
350
|
const name = identifier_1.Identifier.getName(identifier_1.Identifier.parse(fn));
|
|
338
351
|
const url = (0, signature_query_executor_1.rdrrDocUrl)(dep.package, name, { base: dep.base, cran: !dep.base });
|
|
339
352
|
const label = (url ? formatter.hyperlink(name, url, true) : name) + (reasons ? ` (${reasons})` : '');
|
|
@@ -37,12 +37,14 @@ exports.DefaultInputClassifierConfig = {
|
|
|
37
37
|
[simple_input_classifier_1.InputTraceType.Pure]: builtIns.without(built_in_props_1.InputProps),
|
|
38
38
|
[simple_input_classifier_1.InputType.File]: [...read_functions_1.ReadFunctions.map(readFunction => readFunction.name), ...builtIns.withAll(built_in_props_1.FileInputProps)],
|
|
39
39
|
[simple_input_classifier_1.InputType.TempFile]: builtIns.with(built_in_props_1.CallProp.TempFile),
|
|
40
|
+
[simple_input_classifier_1.InputType.Glob]: builtIns.with(built_in_props_1.CallProp.Glob),
|
|
40
41
|
[simple_input_classifier_1.InputType.Network]: flowr_search_builder_1.Q.fromQuery({ type: 'linter', rules: ['network-functions'] }, linter_format_1.LintingResultCertainty.Certain),
|
|
41
42
|
[simple_input_classifier_1.InputType.Random]: flowr_search_builder_1.Q.fromQuery({ type: 'linter', rules: ['seeded-randomness'] }),
|
|
42
43
|
[simple_input_classifier_1.InputType.System]: builtIns.with(built_in_props_1.CallProp.Process),
|
|
43
44
|
[simple_input_classifier_1.InputType.Ffi]: builtIns.with(built_in_props_1.CallProp.Ffi),
|
|
44
45
|
[simple_input_classifier_1.InputType.Lang]: builtIns.with(built_in_props_1.CallProp.Lang),
|
|
45
46
|
[simple_input_classifier_1.InputType.Options]: builtIns.with(built_in_props_1.CallProp.Ambient),
|
|
47
|
+
[simple_input_classifier_1.InputType.CommandLine]: builtIns.with(built_in_props_1.CallProp.CommandLine),
|
|
46
48
|
[simple_input_classifier_1.InputType.User]: builtIns.with(built_in_props_1.CallProp.User),
|
|
47
49
|
linkedObjects: input_source_functions_1.LinkedInputObjects,
|
|
48
50
|
linkedEntryPoints: input_source_functions_1.LinkedInputEntryPoints,
|
|
@@ -92,12 +94,14 @@ exports.InputSourcesDefinition = {
|
|
|
92
94
|
[simple_input_classifier_1.InputTraceType.Pure]: joi_1.default.array().items(joi_1.default.string()).optional().description('Deterministic/pure functions: functions that preserve constantness of their inputs (e.g., arithmetic, parse).'),
|
|
93
95
|
[simple_input_classifier_1.InputType.File]: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that read from the filesystem and produce data (e.g., read.csv, readRDS).'),
|
|
94
96
|
[simple_input_classifier_1.InputType.TempFile]: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that produce a temporary file path, which on its own touches no file system (e.g., tempfile, tempdir).'),
|
|
97
|
+
[simple_input_classifier_1.InputType.Glob]: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that answer with the paths they match at run time (e.g., list.files, Sys.glob).'),
|
|
95
98
|
[simple_input_classifier_1.InputType.Network]: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that fetch data from the network (e.g., download.file, url connections).'),
|
|
96
99
|
[simple_input_classifier_1.InputType.Random]: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that produce randomness (e.g., runif, rnorm).'),
|
|
97
100
|
[simple_input_classifier_1.InputType.System]: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that execute system commands (e.g., system, system2, shell, pipe).'),
|
|
98
101
|
[simple_input_classifier_1.InputType.Ffi]: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that call native code via the R FFI (.C, .Call, .Fortran, .External, dyn.load).'),
|
|
99
102
|
[simple_input_classifier_1.InputType.Lang]: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that produce language objects (e.g., substitute, quote, bquote, expression).'),
|
|
100
103
|
[simple_input_classifier_1.InputType.Options]: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that access or set global options (e.g., options, getOption).'),
|
|
104
|
+
[simple_input_classifier_1.InputType.CommandLine]: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that hand back what the program was invoked with (e.g., commandArgs).'),
|
|
101
105
|
[simple_input_classifier_1.InputType.User]: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that read interactive user input (e.g., file.choose, readline, menu, askYesNo).'),
|
|
102
106
|
linkedObjects: joi_1.default.array().items(joi_1.default.object({
|
|
103
107
|
name: joi_1.default.string().required().description('Name of the object, e.g. input.'),
|
|
@@ -27,6 +27,11 @@ export declare enum InputType {
|
|
|
27
27
|
File = "file",
|
|
28
28
|
/** Temporary file paths produced by tempfile()/tempdir() and equivalents; a sub-type of {@link File} */
|
|
29
29
|
TempFile = "tempfile",
|
|
30
|
+
/**
|
|
31
|
+
* Paths matched on disk at run time by list.files()/Sys.glob() and equivalents; a sub-type of {@link File}.
|
|
32
|
+
* Such a read finds no missing input, only an empty answer.
|
|
33
|
+
*/
|
|
34
|
+
Glob = "glob",
|
|
30
35
|
Network = "net",
|
|
31
36
|
Random = "rand",
|
|
32
37
|
/** Calls to system/system2 and similar */
|
|
@@ -37,6 +42,11 @@ export declare enum InputType {
|
|
|
37
42
|
Lang = "lang",
|
|
38
43
|
/** Global options / option accessors (options, getOption) */
|
|
39
44
|
Options = "options",
|
|
45
|
+
/**
|
|
46
|
+
* What the program was invoked with (commandArgs and equivalents): neither missing nor resolvable, it is
|
|
47
|
+
* chosen when the program is called. Carries {@link Options} too, the command line being ambient state.
|
|
48
|
+
*/
|
|
49
|
+
CommandLine = "cmdline",
|
|
40
50
|
/** Interactive user input (file choosers, prompts, dialogs, menu selections) */
|
|
41
51
|
User = "user",
|
|
42
52
|
Constant = "const",
|
|
@@ -31,6 +31,11 @@ var InputType;
|
|
|
31
31
|
InputType["File"] = "file";
|
|
32
32
|
/** Temporary file paths produced by tempfile()/tempdir() and equivalents; a sub-type of {@link File} */
|
|
33
33
|
InputType["TempFile"] = "tempfile";
|
|
34
|
+
/**
|
|
35
|
+
* Paths matched on disk at run time by list.files()/Sys.glob() and equivalents; a sub-type of {@link File}.
|
|
36
|
+
* Such a read finds no missing input, only an empty answer.
|
|
37
|
+
*/
|
|
38
|
+
InputType["Glob"] = "glob";
|
|
34
39
|
InputType["Network"] = "net";
|
|
35
40
|
InputType["Random"] = "rand";
|
|
36
41
|
/** Calls to system/system2 and similar */
|
|
@@ -41,6 +46,11 @@ var InputType;
|
|
|
41
46
|
InputType["Lang"] = "lang";
|
|
42
47
|
/** Global options / option accessors (options, getOption) */
|
|
43
48
|
InputType["Options"] = "options";
|
|
49
|
+
/**
|
|
50
|
+
* What the program was invoked with (commandArgs and equivalents): neither missing nor resolvable, it is
|
|
51
|
+
* chosen when the program is called. Carries {@link Options} too, the command line being ambient state.
|
|
52
|
+
*/
|
|
53
|
+
InputType["CommandLine"] = "cmdline";
|
|
44
54
|
/** Interactive user input (file choosers, prompts, dialogs, menu selections) */
|
|
45
55
|
InputType["User"] = "user";
|
|
46
56
|
InputType["Constant"] = "const";
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.executeLocationMapQuery = executeLocationMapQuery;
|
|
4
|
+
const location_map_query_format_1 = require("./location-map-query-format");
|
|
5
|
+
const model_1 = require("../../../r-bridge/lang-4.x/ast/model/model");
|
|
4
6
|
const assert_1 = require("../../../util/assert");
|
|
5
7
|
const parse_1 = require("../../../slicing/criterion/parse");
|
|
6
8
|
const fileIdRegex = /^(?<file>.*(\.[rR]))-/;
|
|
@@ -22,6 +24,14 @@ function fuzzyFindFile(node, idMap) {
|
|
|
22
24
|
}
|
|
23
25
|
return '@inline';
|
|
24
26
|
}
|
|
27
|
+
/** The range reported for a node under the requested {@link LocationMapSpan}, falling back to its own location. */
|
|
28
|
+
function rangeOf(node, idMap, span) {
|
|
29
|
+
if (span === location_map_query_format_1.LocationMapSpan.Token) {
|
|
30
|
+
return node.location;
|
|
31
|
+
}
|
|
32
|
+
const of = span === location_map_query_format_1.LocationMapSpan.Statement ? model_1.RNode.topLevelStatement(node, idMap) : node;
|
|
33
|
+
return model_1.RNode.span(of) ?? node.location;
|
|
34
|
+
}
|
|
25
35
|
/**
|
|
26
36
|
* Executes a location map query
|
|
27
37
|
* @see {@link LocationMapQuery}
|
|
@@ -29,10 +39,8 @@ function fuzzyFindFile(node, idMap) {
|
|
|
29
39
|
async function executeLocationMapQuery({ analyzer }, queries) {
|
|
30
40
|
const ast = await analyzer.normalize();
|
|
31
41
|
const start = Date.now();
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
.map(c => parse_1.SlicingCriterion.tryParse(c, ast.idMap))
|
|
35
|
-
.filter(assert_1.isNotUndefined));
|
|
42
|
+
const requested = queries.flatMap(q => q.ids ?? []);
|
|
43
|
+
const criteriaOfInterest = new Set(requested.map(c => parse_1.SlicingCriterion.tryParse(c, ast.idMap)).filter(assert_1.isNotUndefined));
|
|
36
44
|
const locationMap = {
|
|
37
45
|
files: {},
|
|
38
46
|
ids: {}
|
|
@@ -45,12 +53,14 @@ async function executeLocationMapQuery({ analyzer }, queries) {
|
|
|
45
53
|
inverseMap.set(file, count);
|
|
46
54
|
count++;
|
|
47
55
|
}
|
|
56
|
+
const span = queries.find(q => q.span !== undefined)?.span ?? location_map_query_format_1.LocationMapSpan.Token;
|
|
48
57
|
for (const [id, node] of ast.idMap.entries()) {
|
|
49
|
-
|
|
58
|
+
/* asking for ids none of which resolve yields nothing, not everything */
|
|
59
|
+
if (node.location && (requested.length === 0 || criteriaOfInterest.has(id))) {
|
|
50
60
|
const file = fuzzyFindFile(node, ast.idMap);
|
|
51
61
|
locationMap.ids[id] = [
|
|
52
62
|
inverseMap.get(file) ?? -1,
|
|
53
|
-
node.
|
|
63
|
+
rangeOf(node, ast.idMap, span)
|
|
54
64
|
];
|
|
55
65
|
}
|
|
56
66
|
}
|
|
@@ -9,10 +9,24 @@ import type { ReplOutput } from '../../../cli/repl/commands/repl-main';
|
|
|
9
9
|
import type { FlowrConfig } from '../../../config';
|
|
10
10
|
import type { ParsedQueryLine } from '../../query';
|
|
11
11
|
import { criteriaQueryCompleter } from '../../../cli/repl/parser/slice-query-parser';
|
|
12
|
+
/**
|
|
13
|
+
* How much of the source an entry of the {@link LocationMapQueryResult} covers: the `<-` of a multi-line
|
|
14
|
+
* assignment is a single `token`, while its subtree (`full`) is the whole assignment.
|
|
15
|
+
*/
|
|
16
|
+
export declare enum LocationMapSpan {
|
|
17
|
+
/** the location of the node itself, which for an operator or a call name is just that token */
|
|
18
|
+
Token = "token",
|
|
19
|
+
/** the range the whole subtree of the node covers, see {@link RNode.span} */
|
|
20
|
+
Full = "full",
|
|
21
|
+
/** the {@link Full} range of the top-level statement the node belongs to, see {@link RNode.topLevelStatement} */
|
|
22
|
+
Statement = "statement"
|
|
23
|
+
}
|
|
12
24
|
export interface LocationMapQuery extends BaseQueryFormat {
|
|
13
25
|
readonly type: 'location-map';
|
|
14
26
|
/** Optional list of ids to filter the results by. If not provided, all ids will be included. */
|
|
15
27
|
readonly ids?: readonly SlicingCriterion[];
|
|
28
|
+
/** How much of the source the reported range covers, {@link LocationMapSpan.Token} by default. */
|
|
29
|
+
readonly span?: LocationMapSpan;
|
|
16
30
|
}
|
|
17
31
|
export type FileId = number & {
|
|
18
32
|
readonly __fileId?: unique symbol;
|
|
@@ -33,7 +47,7 @@ export declare const LocationMapQueryDefinition: {
|
|
|
33
47
|
readonly asciiSummarizer: (formatter: OutputFormatter, _analyzer: unknown, queryResults: BaseQueryResult, result: string[]) => true;
|
|
34
48
|
readonly fromLine: typeof locationMapLineParser;
|
|
35
49
|
readonly completer: typeof criteriaQueryCompleter;
|
|
36
|
-
readonly syntax: "@location-map [(<crit>;...)] <code | file://path>";
|
|
50
|
+
readonly syntax: "@location-map [(<crit>;...)] [token|full|statement] <code | file://path>";
|
|
37
51
|
readonly schema: Joi.ObjectSchema<any>;
|
|
38
52
|
readonly flattenInvolvedNodes: () => never[];
|
|
39
53
|
};
|
|
@@ -3,21 +3,37 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.LocationMapQueryDefinition = void 0;
|
|
6
|
+
exports.LocationMapQueryDefinition = exports.LocationMapSpan = void 0;
|
|
7
7
|
const location_map_query_executor_1 = require("./location-map-query-executor");
|
|
8
8
|
const ansi_1 = require("../../../util/text/ansi");
|
|
9
9
|
const time_1 = require("../../../util/text/time");
|
|
10
10
|
const joi_1 = __importDefault(require("joi"));
|
|
11
11
|
const query_print_1 = require("../../query-print");
|
|
12
12
|
const slice_query_parser_1 = require("../../../cli/repl/parser/slice-query-parser");
|
|
13
|
+
/**
|
|
14
|
+
* How much of the source an entry of the {@link LocationMapQueryResult} covers: the `<-` of a multi-line
|
|
15
|
+
* assignment is a single `token`, while its subtree (`full`) is the whole assignment.
|
|
16
|
+
*/
|
|
17
|
+
var LocationMapSpan;
|
|
18
|
+
(function (LocationMapSpan) {
|
|
19
|
+
/** the location of the node itself, which for an operator or a call name is just that token */
|
|
20
|
+
LocationMapSpan["Token"] = "token";
|
|
21
|
+
/** the range the whole subtree of the node covers, see {@link RNode.span} */
|
|
22
|
+
LocationMapSpan["Full"] = "full";
|
|
23
|
+
/** the {@link Full} range of the top-level statement the node belongs to, see {@link RNode.topLevelStatement} */
|
|
24
|
+
LocationMapSpan["Statement"] = "statement";
|
|
25
|
+
})(LocationMapSpan || (exports.LocationMapSpan = LocationMapSpan = {}));
|
|
13
26
|
function locationMapLineParser(_output, line, _config) {
|
|
14
27
|
const criteria = (0, slice_query_parser_1.sliceCriteriaParser)(line[0]);
|
|
28
|
+
const rest = criteria ? line.slice(1) : line;
|
|
29
|
+
const span = Object.values(LocationMapSpan).includes(rest[0]) ? rest[0] : undefined;
|
|
15
30
|
return {
|
|
16
31
|
query: {
|
|
17
32
|
type: 'location-map',
|
|
18
|
-
ids: criteria
|
|
33
|
+
ids: criteria,
|
|
34
|
+
...(span ? { span } : {})
|
|
19
35
|
},
|
|
20
|
-
rCode:
|
|
36
|
+
rCode: span ? rest[1] : rest[0]
|
|
21
37
|
};
|
|
22
38
|
}
|
|
23
39
|
exports.LocationMapQueryDefinition = {
|
|
@@ -35,10 +51,11 @@ exports.LocationMapQueryDefinition = {
|
|
|
35
51
|
},
|
|
36
52
|
fromLine: locationMapLineParser,
|
|
37
53
|
completer: slice_query_parser_1.criteriaQueryCompleter,
|
|
38
|
-
syntax: '@location-map [(<crit>;...)] <code | file://path>',
|
|
54
|
+
syntax: '@location-map [(<crit>;...)] [token|full|statement] <code | file://path>',
|
|
39
55
|
schema: joi_1.default.object({
|
|
40
56
|
type: joi_1.default.string().valid('location-map').required().description('The type of the query.'),
|
|
41
|
-
ids: joi_1.default.array().items(joi_1.default.string()).optional().description('Optional list of ids to filter the results by.')
|
|
57
|
+
ids: joi_1.default.array().items(joi_1.default.string()).optional().description('Optional list of ids to filter the results by.'),
|
|
58
|
+
span: joi_1.default.string().valid(...Object.values(LocationMapSpan)).optional().description('How much of the source the reported range covers: the token itself (default), the whole subtree of the node, or the top-level statement it belongs to.')
|
|
42
59
|
}).description('The location map query retrieves the location of every id in the ast.'),
|
|
43
60
|
flattenInvolvedNodes: () => []
|
|
44
61
|
};
|
|
@@ -12,6 +12,7 @@ const semver_1 = require("semver");
|
|
|
12
12
|
const reader_1 = require("../../../project/sigdb/reader");
|
|
13
13
|
const sigdb_version_1 = require("../../../project/sigdb/sigdb-version");
|
|
14
14
|
const schema_1 = require("../../../project/sigdb/schema");
|
|
15
|
+
const attached_packages_1 = require("../../../project/attached-packages");
|
|
15
16
|
const manifest_1 = require("../../../project/sigdb/manifest");
|
|
16
17
|
const query_fn_props_1 = require("../../../dataflow/environments/query-fn-props");
|
|
17
18
|
const resolve_by_name_1 = require("../../../dataflow/environments/resolve-by-name");
|
|
@@ -441,6 +442,7 @@ function signaturePackageInfo(src, pkg, resolved) {
|
|
|
441
442
|
const deps = (src.dependencies(pkg, resolved) ?? src.dependencies(pkg) ?? [])
|
|
442
443
|
.map(d => ({ type: schema_1.DepTypeNames[d.type], name: d.name, ...(d.constraint ? { constraint: d.constraint } : {}) }));
|
|
443
444
|
const release = src.releaseDate(pkg, resolved);
|
|
445
|
+
const attaches = (0, attached_packages_1.attachedAlongside)(pkg, [src], resolved);
|
|
444
446
|
return {
|
|
445
447
|
name: pkg,
|
|
446
448
|
version: exports.version,
|
|
@@ -457,6 +459,7 @@ function signaturePackageInfo(src, pkg, resolved) {
|
|
|
457
459
|
deprecated: exports.deprecated,
|
|
458
460
|
...(base && src.coreVersions(pkg) ? { coreVersions: src.coreVersions(pkg)?.map(v => v.str) } : {}),
|
|
459
461
|
dependencies: deps,
|
|
462
|
+
...(attaches.length > 0 ? { attaches } : {}),
|
|
460
463
|
functions: fns.map(f => decodedToView(pkg, f, exports.version, { cran: exports.cran, base }))
|
|
461
464
|
};
|
|
462
465
|
}
|
|
@@ -124,6 +124,11 @@ export interface SignaturePackageView {
|
|
|
124
124
|
/** for a base package: the R releases it was part of core, ascending */
|
|
125
125
|
readonly coreVersions?: readonly string[];
|
|
126
126
|
readonly dependencies: readonly SignatureDependencyView[];
|
|
127
|
+
/**
|
|
128
|
+
* The packages that end up on the search path together with this one, so that {@link exportsTotal} is not
|
|
129
|
+
* mistaken for everything `library(<name>)` brings into scope (see `attachedAlongside`).
|
|
130
|
+
*/
|
|
131
|
+
readonly attaches?: readonly string[];
|
|
127
132
|
readonly functions: readonly SignatureFunctionView[];
|
|
128
133
|
}
|
|
129
134
|
/** a compact hit from a wildcard function search */
|
package/queries/query.d.ts
CHANGED
|
@@ -219,7 +219,7 @@ export declare const SupportedQueries: {
|
|
|
219
219
|
readonly asciiSummarizer: (formatter: OutputFormatter, _analyzer: unknown, queryResults: BaseQueryResult, result: string[]) => true;
|
|
220
220
|
readonly fromLine: (_output: ReplOutput, line: readonly string[], _config: FlowrConfig) => ParsedQueryLine<"location-map">;
|
|
221
221
|
readonly completer: typeof import("../cli/repl/parser/slice-query-parser").criteriaQueryCompleter;
|
|
222
|
-
readonly syntax: "@location-map [(<crit>;...)] <code | file://path>";
|
|
222
|
+
readonly syntax: "@location-map [(<crit>;...)] [token|full|statement] <code | file://path>";
|
|
223
223
|
readonly schema: Joi.ObjectSchema<any>;
|
|
224
224
|
readonly flattenInvolvedNodes: () => never[];
|
|
225
225
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { SourceLocation } from '../../../../util/range';
|
|
1
|
+
import { SourceLocation, SourceRange } from '../../../../util/range';
|
|
3
2
|
import { RType } from './type';
|
|
4
3
|
import type { MergeableRecord } from '../../../../util/objects';
|
|
5
4
|
import type { RNumber } from './nodes/r-number';
|
|
@@ -235,6 +234,19 @@ export declare const RNode: {
|
|
|
235
234
|
* A helper function to retrieve the id of a given node, if available.
|
|
236
235
|
*/
|
|
237
236
|
readonly getId: (this: void, node: RNode<ParentInformation>) => NodeId;
|
|
237
|
+
/**
|
|
238
|
+
* The source range the whole subtree of `node` covers, from the first position any of its nodes starts at to
|
|
239
|
+
* the last one any of them ends at. Unlike {@link SourceRange.fromNode} this does not stop at what the node
|
|
240
|
+
* itself is written as: the span of the `<-` in a multi-line assignment is the whole assignment.
|
|
241
|
+
* `undefined` if neither the node nor anything below it carries a location.
|
|
242
|
+
* @see {@link RNode.topLevelStatement} - for the node to ask this of when the whole statement is wanted
|
|
243
|
+
*/
|
|
244
|
+
readonly span: <OtherInfo>(this: void, node: RNode<OtherInfo> | undefined) => SourceRange | undefined;
|
|
245
|
+
/**
|
|
246
|
+
* The top-level statement `node` belongs to: the ancestor that is a direct child of the root of its file
|
|
247
|
+
* (`node` itself if it already is one). A node with no parent is its own statement.
|
|
248
|
+
*/
|
|
249
|
+
readonly topLevelStatement: <OtherInfo>(this: void, node: RNode<OtherInfo & ParentInformation>, idMap: AstIdMap<OtherInfo & ParentInformation>) => RNode<OtherInfo & ParentInformation>;
|
|
238
250
|
/**
|
|
239
251
|
* A helper function to retrieve the type of a given node.
|
|
240
252
|
*/
|
|
@@ -139,6 +139,38 @@ exports.RNode = {
|
|
|
139
139
|
getId(node) {
|
|
140
140
|
return node.info.id;
|
|
141
141
|
},
|
|
142
|
+
/**
|
|
143
|
+
* The source range the whole subtree of `node` covers, from the first position any of its nodes starts at to
|
|
144
|
+
* the last one any of them ends at. Unlike {@link SourceRange.fromNode} this does not stop at what the node
|
|
145
|
+
* itself is written as: the span of the `<-` in a multi-line assignment is the whole assignment.
|
|
146
|
+
* `undefined` if neither the node nor anything below it carries a location.
|
|
147
|
+
* @see {@link RNode.topLevelStatement} - for the node to ask this of when the whole statement is wanted
|
|
148
|
+
*/
|
|
149
|
+
span(node) {
|
|
150
|
+
const ranges = [];
|
|
151
|
+
exports.RNode.visitAst(node, n => {
|
|
152
|
+
const range = range_1.SourceRange.fromNode(n);
|
|
153
|
+
if (range !== undefined) {
|
|
154
|
+
ranges.push(range);
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
return ranges.length > 0 ? range_1.SourceRange.merge(ranges) : undefined;
|
|
158
|
+
},
|
|
159
|
+
/**
|
|
160
|
+
* The top-level statement `node` belongs to: the ancestor that is a direct child of the root of its file
|
|
161
|
+
* (`node` itself if it already is one). A node with no parent is its own statement.
|
|
162
|
+
*/
|
|
163
|
+
topLevelStatement(node, idMap) {
|
|
164
|
+
let current = node;
|
|
165
|
+
for (;;) {
|
|
166
|
+
const parent = current.info.parent === undefined ? undefined : idMap.get(current.info.parent);
|
|
167
|
+
/* the root of a file has no parent of its own, so the node below it is the statement */
|
|
168
|
+
if (parent?.info.parent === undefined) {
|
|
169
|
+
return current;
|
|
170
|
+
}
|
|
171
|
+
current = parent;
|
|
172
|
+
}
|
|
173
|
+
},
|
|
142
174
|
/**
|
|
143
175
|
* A helper function to retrieve the type of a given node.
|
|
144
176
|
*/
|
|
@@ -45,6 +45,8 @@ export declare const RAccess: {
|
|
|
45
45
|
readonly isIndex: <Info = object>(this: void, node: RNode<Info> | undefined) => node is RIndexAccess<Info>;
|
|
46
46
|
readonly getLocation: (this: void, node: RNode) => import("../../../../../util/range").SourceLocation | undefined;
|
|
47
47
|
readonly getId: (this: void, node: RNode<import("../processing/decorate").ParentInformation>) => import("../processing/node-id").NodeId;
|
|
48
|
+
readonly span: <OtherInfo>(this: void, node: RNode<OtherInfo> | undefined) => import("../../../../../util/range").SourceRange | undefined;
|
|
49
|
+
readonly topLevelStatement: <OtherInfo>(this: void, node: RNode<OtherInfo & import("../processing/decorate").ParentInformation>, idMap: import("../processing/decorate").AstIdMap<OtherInfo & import("../processing/decorate").ParentInformation>) => RNode<OtherInfo & import("../processing/decorate").ParentInformation>;
|
|
48
50
|
readonly getType: (this: void, node: RNode) => RType;
|
|
49
51
|
readonly visitAst: <OtherInfo = object>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo>>, onVisit?: import("../processing/visitor").OnEnter<OtherInfo>, onExit?: import("../processing/visitor").OnExit<OtherInfo>) => void;
|
|
50
52
|
readonly collectAllIds: <OtherInfo>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo & import("../processing/decorate").ParentInformation>>) => Set<import("../processing/node-id").NodeId>;
|
|
@@ -64,6 +64,8 @@ export declare const RArgument: {
|
|
|
64
64
|
readonly getValue: <OtherInfo>(args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], id: NodeId | undefined) => RNode<OtherInfo> | undefined;
|
|
65
65
|
readonly getLocation: (this: void, node: RNode) => import("../../../../../util/range").SourceLocation | undefined;
|
|
66
66
|
readonly getId: (this: void, node: RNode<ParentInformation>) => NodeId;
|
|
67
|
+
readonly span: <OtherInfo>(this: void, node: RNode<OtherInfo> | undefined) => import("../../../../../util/range").SourceRange | undefined;
|
|
68
|
+
readonly topLevelStatement: <OtherInfo>(this: void, node: RNode<OtherInfo & ParentInformation>, idMap: import("../processing/decorate").AstIdMap<OtherInfo & ParentInformation>) => RNode<OtherInfo & ParentInformation>;
|
|
67
69
|
readonly getType: (this: void, node: RNode) => RType;
|
|
68
70
|
readonly visitAst: <OtherInfo = object>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo>>, onVisit?: import("../processing/visitor").OnEnter<OtherInfo>, onExit?: import("../processing/visitor").OnExit<OtherInfo>) => void;
|
|
69
71
|
readonly collectAllIds: <OtherInfo>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo & ParentInformation>>) => Set<NodeId>;
|
|
@@ -26,6 +26,8 @@ export declare const RBinaryOp: {
|
|
|
26
26
|
readonly getOperatorInfo: <Info = object>(node: RBinaryOp<Info>) => OperatorInformationValue | undefined;
|
|
27
27
|
readonly getLocation: (this: void, node: RNode) => import("../../../../../util/range").SourceLocation | undefined;
|
|
28
28
|
readonly getId: (this: void, node: RNode<import("../processing/decorate").ParentInformation>) => import("../processing/node-id").NodeId;
|
|
29
|
+
readonly span: <OtherInfo>(this: void, node: RNode<OtherInfo> | undefined) => import("../../../../../util/range").SourceRange | undefined;
|
|
30
|
+
readonly topLevelStatement: <OtherInfo>(this: void, node: RNode<OtherInfo & import("../processing/decorate").ParentInformation>, idMap: import("../processing/decorate").AstIdMap<OtherInfo & import("../processing/decorate").ParentInformation>) => RNode<OtherInfo & import("../processing/decorate").ParentInformation>;
|
|
29
31
|
readonly getType: (this: void, node: RNode) => RType;
|
|
30
32
|
readonly visitAst: <OtherInfo = object>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo>>, onVisit?: import("../processing/visitor").OnEnter<OtherInfo>, onExit?: import("../processing/visitor").OnExit<OtherInfo>) => void;
|
|
31
33
|
readonly collectAllIds: <OtherInfo>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo & import("../processing/decorate").ParentInformation>>) => Set<import("../processing/node-id").NodeId>;
|
|
@@ -18,6 +18,8 @@ export declare const RBreak: {
|
|
|
18
18
|
readonly is: <Info = object>(this: void, node: unknown) => node is RBreak<Info>;
|
|
19
19
|
readonly getLocation: (this: void, node: RNode) => import("../../../../../util/range").SourceLocation | undefined;
|
|
20
20
|
readonly getId: (this: void, node: RNode<import("../processing/decorate").ParentInformation>) => import("../processing/node-id").NodeId;
|
|
21
|
+
readonly span: <OtherInfo>(this: void, node: RNode<OtherInfo> | undefined) => import("../../../../../util/range").SourceRange | undefined;
|
|
22
|
+
readonly topLevelStatement: <OtherInfo>(this: void, node: RNode<OtherInfo & import("../processing/decorate").ParentInformation>, idMap: import("../processing/decorate").AstIdMap<OtherInfo & import("../processing/decorate").ParentInformation>) => RNode<OtherInfo & import("../processing/decorate").ParentInformation>;
|
|
21
23
|
readonly getType: (this: void, node: RNode) => RType;
|
|
22
24
|
readonly visitAst: <OtherInfo = object>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo>>, onVisit?: import("../processing/visitor").OnEnter<OtherInfo>, onExit?: import("../processing/visitor").OnExit<OtherInfo>) => void;
|
|
23
25
|
readonly collectAllIds: <OtherInfo>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo & import("../processing/decorate").ParentInformation>>) => Set<import("../processing/node-id").NodeId>;
|
|
@@ -20,6 +20,8 @@ export declare const RComment: {
|
|
|
20
20
|
readonly is: <Info = object>(this: void, node: unknown) => node is RComment<Info>;
|
|
21
21
|
readonly getLocation: (this: void, node: RNode) => import("../../../../../util/range").SourceLocation | undefined;
|
|
22
22
|
readonly getId: (this: void, node: RNode<import("../processing/decorate").ParentInformation>) => import("../processing/node-id").NodeId;
|
|
23
|
+
readonly span: <OtherInfo>(this: void, node: RNode<OtherInfo> | undefined) => import("../../../../../util/range").SourceRange | undefined;
|
|
24
|
+
readonly topLevelStatement: <OtherInfo>(this: void, node: RNode<OtherInfo & import("../processing/decorate").ParentInformation>, idMap: import("../processing/decorate").AstIdMap<OtherInfo & import("../processing/decorate").ParentInformation>) => RNode<OtherInfo & import("../processing/decorate").ParentInformation>;
|
|
23
25
|
readonly getType: (this: void, node: RNode) => RType;
|
|
24
26
|
readonly visitAst: <OtherInfo = object>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo>>, onVisit?: import("../processing/visitor").OnEnter<OtherInfo>, onExit?: import("../processing/visitor").OnExit<OtherInfo>) => void;
|
|
25
27
|
readonly collectAllIds: <OtherInfo>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo & import("../processing/decorate").ParentInformation>>) => Set<import("../processing/node-id").NodeId>;
|
|
@@ -34,6 +34,8 @@ export declare const RExpressionList: {
|
|
|
34
34
|
readonly groupEnd: <Info = object>(this: void, node: RExpressionList<Info>) => RSymbol<Info> | undefined;
|
|
35
35
|
readonly getLocation: (this: void, node: RNode) => import("../../../../../util/range").SourceLocation | undefined;
|
|
36
36
|
readonly getId: (this: void, node: RNode<import("../processing/decorate").ParentInformation>) => import("../processing/node-id").NodeId;
|
|
37
|
+
readonly span: <OtherInfo>(this: void, node: RNode<OtherInfo> | undefined) => import("../../../../../util/range").SourceRange | undefined;
|
|
38
|
+
readonly topLevelStatement: <OtherInfo>(this: void, node: RNode<OtherInfo & import("../processing/decorate").ParentInformation>, idMap: import("../processing/decorate").AstIdMap<OtherInfo & import("../processing/decorate").ParentInformation>) => RNode<OtherInfo & import("../processing/decorate").ParentInformation>;
|
|
37
39
|
readonly getType: (this: void, node: RNode) => RType;
|
|
38
40
|
readonly visitAst: <OtherInfo = object>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo>>, onVisit?: import("../processing/visitor").OnEnter<OtherInfo>, onExit?: import("../processing/visitor").OnExit<OtherInfo>) => void;
|
|
39
41
|
readonly collectAllIds: <OtherInfo>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo & import("../processing/decorate").ParentInformation>>) => Set<import("../processing/node-id").NodeId>;
|
|
@@ -28,6 +28,8 @@ export declare const RForLoop: {
|
|
|
28
28
|
readonly is: <Info = object>(this: void, node: RNode<Info> | undefined) => node is RForLoop<Info>;
|
|
29
29
|
readonly getLocation: (this: void, node: RNode) => import("../../../../../util/range").SourceLocation | undefined;
|
|
30
30
|
readonly getId: (this: void, node: RNode<import("../processing/decorate").ParentInformation>) => import("../processing/node-id").NodeId;
|
|
31
|
+
readonly span: <OtherInfo>(this: void, node: RNode<OtherInfo> | undefined) => import("../../../../../util/range").SourceRange | undefined;
|
|
32
|
+
readonly topLevelStatement: <OtherInfo>(this: void, node: RNode<OtherInfo & import("../processing/decorate").ParentInformation>, idMap: import("../processing/decorate").AstIdMap<OtherInfo & import("../processing/decorate").ParentInformation>) => RNode<OtherInfo & import("../processing/decorate").ParentInformation>;
|
|
31
33
|
readonly getType: (this: void, node: RNode) => RType;
|
|
32
34
|
readonly visitAst: <OtherInfo = object>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo>>, onVisit?: import("../processing/visitor").OnEnter<OtherInfo>, onExit?: import("../processing/visitor").OnExit<OtherInfo>) => void;
|
|
33
35
|
readonly collectAllIds: <OtherInfo>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo & import("../processing/decorate").ParentInformation>>) => Set<import("../processing/node-id").NodeId>;
|
|
@@ -48,17 +48,16 @@ export declare const RFunctionCall: {
|
|
|
48
48
|
*/
|
|
49
49
|
readonly isUnnamed: <Info = object>(this: void, node: RNode<Info> | undefined) => node is RUnnamedFunctionCall<Info>;
|
|
50
50
|
/**
|
|
51
|
-
* Bind a call's `arguments` to the formal `paramNames`
|
|
52
|
-
*
|
|
53
|
-
* (
|
|
54
|
-
*
|
|
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).
|
|
51
|
+
* Bind a call's `arguments` to the formal `paramNames` with {@link matchArgumentsToParameters}, R's argument
|
|
52
|
+
* matching. Returns a map from parameter name to the argument bound to it, so
|
|
53
|
+
* `matchArgsToParams(call.arguments, names).get('X')` answers "which argument is mapped to parameter `X`".
|
|
54
|
+
* An empty argument (`f(1, ,3)`) takes its formal but never appears in the map, as there is nothing to bind.
|
|
58
55
|
*/
|
|
59
|
-
readonly matchArgsToParams: <Info = object>(this: void, args: readonly PotentiallyEmptyRArgument<Info>[], paramNames: readonly string[]) => ReadonlyMap<string,
|
|
56
|
+
readonly matchArgsToParams: <Info = object>(this: void, args: readonly PotentiallyEmptyRArgument<Info>[], paramNames: readonly string[]) => ReadonlyMap<string, RArgument<Info>>;
|
|
60
57
|
readonly getLocation: (this: void, node: RNode) => import("../../../../../util/range").SourceLocation | undefined;
|
|
61
58
|
readonly getId: (this: void, node: RNode<import("../processing/decorate").ParentInformation>) => import("../processing/node-id").NodeId;
|
|
59
|
+
readonly span: <OtherInfo>(this: void, node: RNode<OtherInfo> | undefined) => import("../../../../../util/range").SourceRange | undefined;
|
|
60
|
+
readonly topLevelStatement: <OtherInfo>(this: void, node: RNode<OtherInfo & import("../processing/decorate").ParentInformation>, idMap: import("../processing/decorate").AstIdMap<OtherInfo & import("../processing/decorate").ParentInformation>) => RNode<OtherInfo & import("../processing/decorate").ParentInformation>;
|
|
62
61
|
readonly getType: (this: void, node: RNode) => RType;
|
|
63
62
|
readonly visitAst: <OtherInfo = object>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo>>, onVisit?: import("../processing/visitor").OnEnter<OtherInfo>, onExit?: import("../processing/visitor").OnExit<OtherInfo>) => void;
|
|
64
63
|
readonly collectAllIds: <OtherInfo>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo & import("../processing/decorate").ParentInformation>>) => Set<import("../processing/node-id").NodeId>;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.RFunctionCall = exports.EmptyArgument = void 0;
|
|
4
4
|
const model_1 = require("../model");
|
|
5
5
|
const type_1 = require("../type");
|
|
6
|
-
const
|
|
6
|
+
const arg_matching_1 = require("../../../../../util/arg-matching");
|
|
7
7
|
exports.EmptyArgument = '<>';
|
|
8
8
|
/**
|
|
9
9
|
* Helper for working with {@link RFunctionCall} AST nodes.
|
|
@@ -30,55 +30,18 @@ exports.RFunctionCall = {
|
|
|
30
30
|
return exports.RFunctionCall.is(node) && !node.named;
|
|
31
31
|
},
|
|
32
32
|
/**
|
|
33
|
-
* Bind a call's `arguments` to the formal `paramNames`
|
|
34
|
-
*
|
|
35
|
-
* (
|
|
36
|
-
*
|
|
37
|
-
* `matchArgumentsToParameters(call.arguments, names).get('X')` answers "which argument is mapped to
|
|
38
|
-
* parameter `X`". Pass `paramNames` as the full formal list **excluding `...`** so ambiguous prefixes are
|
|
39
|
-
* rejected; this makes it exact when the signature is known (e.g. from the signature database).
|
|
33
|
+
* Bind a call's `arguments` to the formal `paramNames` with {@link matchArgumentsToParameters}, R's argument
|
|
34
|
+
* matching. Returns a map from parameter name to the argument bound to it, so
|
|
35
|
+
* `matchArgsToParams(call.arguments, names).get('X')` answers "which argument is mapped to parameter `X`".
|
|
36
|
+
* An empty argument (`f(1, ,3)`) takes its formal but never appears in the map, as there is nothing to bind.
|
|
40
37
|
*/
|
|
41
38
|
matchArgsToParams(args, paramNames) {
|
|
39
|
+
const matched = (0, arg_matching_1.matchArgumentsToParameters)(args.map(a => a === exports.EmptyArgument ? undefined : a.name?.content), paramNames);
|
|
42
40
|
const bound = new Map();
|
|
43
|
-
const used = new Set();
|
|
44
|
-
// pass 1: exact name matches
|
|
45
41
|
for (let i = 0; i < args.length; i++) {
|
|
46
|
-
const arg = args[i];
|
|
47
|
-
if (arg
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
const n = arg.name.content;
|
|
51
|
-
if (paramNames.includes(n) && !bound.has(n)) {
|
|
52
|
-
bound.set(n, arg);
|
|
53
|
-
used.add(i);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
// pass 2: partial (pmatch) name matches on the still-unbound named arguments
|
|
57
|
-
for (let i = 0; i < args.length; i++) {
|
|
58
|
-
const arg = args[i];
|
|
59
|
-
if (used.has(i) || arg === exports.EmptyArgument || arg.name === undefined) {
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
const matched = (0, prefix_1.findByPrefixIfUnique)(arg.name.content, paramNames);
|
|
63
|
-
if (matched !== undefined && !bound.has(matched)) {
|
|
64
|
-
bound.set(matched, arg);
|
|
65
|
-
used.add(i);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
// pass 3: remaining unnamed args fill the remaining formals left-to-right
|
|
69
|
-
let formalIdx = 0;
|
|
70
|
-
for (let i = 0; i < args.length; i++) {
|
|
71
|
-
const arg = args[i];
|
|
72
|
-
if (used.has(i) || arg === exports.EmptyArgument || arg.name !== undefined) {
|
|
73
|
-
continue;
|
|
74
|
-
}
|
|
75
|
-
while (formalIdx < paramNames.length && bound.has(paramNames[formalIdx])) {
|
|
76
|
-
formalIdx++;
|
|
77
|
-
}
|
|
78
|
-
if (formalIdx < paramNames.length) {
|
|
79
|
-
bound.set(paramNames[formalIdx], arg);
|
|
80
|
-
used.add(i);
|
|
81
|
-
formalIdx++;
|
|
42
|
+
const arg = args[i], param = matched[i];
|
|
43
|
+
if (arg !== exports.EmptyArgument && param !== undefined) {
|
|
44
|
+
bound.set(paramNames[param], arg);
|
|
82
45
|
}
|
|
83
46
|
}
|
|
84
47
|
return bound;
|
|
@@ -41,6 +41,8 @@ export declare const RFunctionDefinition: {
|
|
|
41
41
|
readonly rootFunctionDefinition: <Info = object>(this: void, n: RNode<ParentInformation & Info> | undefined, idMap: AstIdMap<ParentInformation & Info>) => RFunctionDefinition<ParentInformation & Info> | undefined;
|
|
42
42
|
readonly getLocation: (this: void, node: RNode) => import("../../../../../util/range").SourceLocation | undefined;
|
|
43
43
|
readonly getId: (this: void, node: RNode<ParentInformation>) => import("../processing/node-id").NodeId;
|
|
44
|
+
readonly span: <OtherInfo>(this: void, node: RNode<OtherInfo> | undefined) => import("../../../../../util/range").SourceRange | undefined;
|
|
45
|
+
readonly topLevelStatement: <OtherInfo>(this: void, node: RNode<OtherInfo & ParentInformation>, idMap: AstIdMap<OtherInfo & ParentInformation>) => RNode<OtherInfo & ParentInformation>;
|
|
44
46
|
readonly getType: (this: void, node: RNode) => RType;
|
|
45
47
|
readonly visitAst: <OtherInfo = object>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo>>, onVisit?: import("../processing/visitor").OnEnter<OtherInfo>, onExit?: import("../processing/visitor").OnExit<OtherInfo>) => void;
|
|
46
48
|
readonly collectAllIds: <OtherInfo>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo & ParentInformation>>) => Set<import("../processing/node-id").NodeId>;
|
|
@@ -24,6 +24,8 @@ export declare const RIfThenElse: {
|
|
|
24
24
|
readonly is: <Info = object>(this: void, node: RNode<Info> | undefined) => node is RIfThenElse<Info>;
|
|
25
25
|
readonly getLocation: (this: void, node: RNode) => import("../../../../../util/range").SourceLocation | undefined;
|
|
26
26
|
readonly getId: (this: void, node: RNode<import("../processing/decorate").ParentInformation>) => import("../processing/node-id").NodeId;
|
|
27
|
+
readonly span: <OtherInfo>(this: void, node: RNode<OtherInfo> | undefined) => import("../../../../../util/range").SourceRange | undefined;
|
|
28
|
+
readonly topLevelStatement: <OtherInfo>(this: void, node: RNode<OtherInfo & import("../processing/decorate").ParentInformation>, idMap: import("../processing/decorate").AstIdMap<OtherInfo & import("../processing/decorate").ParentInformation>) => RNode<OtherInfo & import("../processing/decorate").ParentInformation>;
|
|
27
29
|
readonly getType: (this: void, node: RNode) => RType;
|
|
28
30
|
readonly visitAst: <OtherInfo = object>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo>>, onVisit?: import("../processing/visitor").OnEnter<OtherInfo>, onExit?: import("../processing/visitor").OnExit<OtherInfo>) => void;
|
|
29
31
|
readonly collectAllIds: <OtherInfo>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo & import("../processing/decorate").ParentInformation>>) => Set<import("../processing/node-id").NodeId>;
|