@eagleoutice/flowr 2.13.2 → 2.13.4
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 +45 -43
- package/abstract-interpretation/absint-visitor.js +2 -2
- package/abstract-interpretation/data-frame/mappers/access-mapper.js +1 -0
- package/abstract-interpretation/data-frame/mappers/arguments.js +2 -2
- package/abstract-interpretation/data-frame/mappers/function-mapper.d.ts +1 -1
- package/abstract-interpretation/data-frame/mappers/function-mapper.js +3 -0
- package/abstract-interpretation/data-frame/mappers/replacement-mapper.js +1 -1
- package/abstract-interpretation/domains/state-domain-like.d.ts +1 -1
- package/abstract-interpretation/unsupported-functions.js +1 -1
- package/config.d.ts +8 -0
- package/config.js +9 -1
- package/control-flow/cfg-dead-code.js +72 -11
- package/control-flow/control-flow-graph.js +2 -1
- package/control-flow/extract-cfg.js +85 -8
- package/control-flow/semantic-cfg-guided-visitor.d.ts +1 -1
- package/control-flow/semantic-cfg-guided-visitor.js +2 -0
- package/core/steps/all/core/11-normalize-tree-sitter.d.ts +1 -1
- package/dataflow/environments/append.d.ts +1 -1
- 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 +5 -1
- package/dataflow/environments/built-in.js +5 -1
- package/dataflow/environments/clone.d.ts +1 -1
- package/dataflow/environments/default-builtin-config.d.ts +59 -4
- package/dataflow/environments/default-builtin-config.js +23 -11
- package/dataflow/environments/environment.d.ts +28 -4
- package/dataflow/environments/environment.js +66 -11
- package/dataflow/environments/identifier.d.ts +1 -0
- package/dataflow/environments/overwrite.d.ts +1 -1
- package/dataflow/eval/resolve/alias-tracking.d.ts +3 -1
- package/dataflow/eval/resolve/alias-tracking.js +8 -1
- package/dataflow/eval/resolve/resolve.d.ts +14 -0
- package/dataflow/eval/resolve/resolve.js +47 -0
- package/dataflow/fn/higher-order-function.js +3 -3
- package/dataflow/fn/recursive-function.js +1 -1
- package/dataflow/graph/dataflowgraph-builder.d.ts +1 -1
- package/dataflow/graph/df-helper.js +1 -1
- package/dataflow/graph/vertex.d.ts +32 -25
- package/dataflow/graph/vertex.js +40 -36
- package/dataflow/internal/process/functions/call/built-in/built-in-access.d.ts +1 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +7 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +14 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +28 -29
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +41 -48
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.d.ts +14 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +45 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +14 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +80 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +63 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +63 -16
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +29 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +5 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +15 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-list.d.ts +4 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-list.js +35 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-new-env.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-recall.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-dispatch.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +9 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +55 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +5 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-vector.d.ts +1 -1
- package/dataflow/internal/process/functions/call/unnamed-call-handling.js +24 -0
- package/dataflow/internal/process/functions/process-parameter.js +2 -1
- package/documentation/doc-readme.js +14 -12
- package/documentation/doc-util/doc-normalized-ast.d.ts +1 -1
- package/documentation/wiki-dataflow-graph.js +4 -24
- package/documentation/wiki-query.js +47 -0
- package/documentation/wiki-signature-database.js +3 -2
- package/linter/rules/absolute-path.js +1 -1
- package/linter/rules/dataframe-access-validation.d.ts +1 -1
- package/linter/rules/function-finder-util.js +1 -1
- package/linter/rules/no-leaked-credentials.js +1 -1
- package/linter/rules/undefined-symbol-util.js +3 -1
- package/linter/rules/undefined-symbol.js +4 -5
- package/linter/rules/unused-definition.js +15 -10
- package/linter/rules/useless-loop.js +1 -1
- package/package.json +21 -9
- package/project/context/flowr-analyzer-context.d.ts +4 -4
- package/project/context/flowr-analyzer-context.js +3 -3
- package/project/context/flowr-analyzer-dependencies-context.d.ts +11 -5
- package/project/context/flowr-analyzer-dependencies-context.js +8 -3
- package/project/context/flowr-analyzer-meta-context.d.ts +1 -0
- package/project/dependency-version-space.d.ts +118 -26
- package/project/dependency-version-space.js +343 -87
- package/project/plugins/file-plugins/files/flowr-description-file.d.ts +4 -0
- package/project/plugins/file-plugins/files/flowr-description-file.js +8 -1
- package/project/plugins/file-plugins/files/flowr-rda-file.js +27 -25
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-sweave-file-plugin.d.ts +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-description-file-plugin.js +2 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +4 -4
- package/project/plugins/package-version-plugins/package.d.ts +27 -10
- package/project/plugins/package-version-plugins/package.js +50 -25
- package/project/sigdb/reader.d.ts +26 -16
- package/project/sigdb/reader.js +52 -21
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +1 -1
- package/queries/catalog/call-context-query/identify-link-to-nested-call-relation.js +1 -1
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +1 -1
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +2 -2
- package/queries/catalog/dependencies-query/dependencies-query-format.js +2 -2
- package/queries/catalog/dependencies-query/function-info/read-functions.js +1 -1
- package/queries/catalog/dependencies-query/function-info/write-functions.js +23 -24
- package/queries/catalog/does-call-query/does-call-query-format.d.ts +1 -1
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +39 -77
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +12 -0
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +53 -23
- package/queries/catalog/input-sources-query/input-source-functions.d.ts +14 -0
- package/queries/catalog/input-sources-query/input-source-functions.js +109 -20
- package/queries/catalog/input-sources-query/input-sources-query-executor.js +45 -4
- package/queries/catalog/input-sources-query/input-sources-query-format.js +22 -3
- package/queries/catalog/input-sources-query/input-types.d.ts +58 -0
- package/queries/catalog/input-sources-query/input-types.js +64 -0
- package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +76 -53
- package/queries/catalog/input-sources-query/simple-input-classifier.js +358 -101
- package/queries/catalog/project-query/project-query-executor.js +1 -1
- package/queries/catalog/signature-query/signature-query-executor.d.ts +7 -1
- package/queries/catalog/signature-query/signature-query-executor.js +112 -39
- package/queries/catalog/signature-query/signature-query-format.d.ts +5 -1
- package/queries/catalog/signature-query/signature-query-format.js +1 -1
- package/queries/catalog/signature-query/signature-query-render.js +8 -3
- package/r-bridge/data/data.d.ts +2 -2
- package/r-bridge/data/data.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/json/format.js +1 -1
- package/r-bridge/retriever.d.ts +1 -1
- package/reconstruct/inline/source-inline-map.js +1 -1
- package/search/flowr-search-printer.js +10 -8
- package/slicing/static/static-slicer.d.ts +2 -2
- package/util/mermaid/dfg.js +1 -1
- package/util/objects.js +6 -4
- package/util/r-base-packages.d.ts +2 -0
- package/util/r-base-packages.js +3 -0
- package/util/r-license.js +1 -4
- package/util/r-version.d.ts +12 -0
- package/util/r-version.js +16 -0
- package/util/range.d.ts +6 -2
- package/util/range.js +33 -15
- package/util/version.js +1 -1
|
@@ -29,7 +29,7 @@ function guessDepVersionsLineParser(_output, line, _config) {
|
|
|
29
29
|
const prefer = {};
|
|
30
30
|
const disabled = new Set();
|
|
31
31
|
// an optional parenthesised clause `(clean)`, `(<=2025)`, or `(clean:<=2025)`: `clean` drops declared constraints, a (`<=`-prefixed) date caps the window
|
|
32
|
-
const tokens =
|
|
32
|
+
const tokens = line.slice();
|
|
33
33
|
const open = tokens.findIndex(t => t.startsWith('('));
|
|
34
34
|
const close = open < 0 ? -1 : tokens.findIndex((t, i) => i >= open && t.endsWith(')'));
|
|
35
35
|
if (open >= 0 && close >= open) {
|
|
@@ -88,8 +88,8 @@ function guessDepVersionsLineParser(_output, line, _config) {
|
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
else if (!tok.startsWith('--')) {
|
|
91
|
-
// every bare token is the code to analyse (a `file://`/`watch://` target, a bare path
|
|
92
|
-
// `file://`
|
|
91
|
+
// every bare token is the code to analyse (a `file://`/`watch://` target, a bare path the repl
|
|
92
|
+
// auto-prepends `file://` to, or inline R code); package filters are the explicit `--only` flag, so nothing is guessed
|
|
93
93
|
codeParts.push(tok);
|
|
94
94
|
}
|
|
95
95
|
}
|
|
@@ -168,6 +168,23 @@ function versionBound(bound) {
|
|
|
168
168
|
}
|
|
169
169
|
return { op: m[1] === '>=' ? '>=' : '<=', ver: m[2] };
|
|
170
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* Order the bounds the way they are read: enforced before partial (which narrow nothing), lower bounds before upper
|
|
173
|
+
* ones, and the tightest of each first, so the bound that actually decides the range heads its group.
|
|
174
|
+
*/
|
|
175
|
+
function compareBounds(a, b) {
|
|
176
|
+
if (Boolean(a.partial) !== Boolean(b.partial)) {
|
|
177
|
+
return a.partial ? 1 : -1;
|
|
178
|
+
}
|
|
179
|
+
const va = versionBound(a.bound), vb = versionBound(b.bound);
|
|
180
|
+
if (va === undefined || vb === undefined) {
|
|
181
|
+
return va === vb ? 0 : va === undefined ? 1 : -1; // a non-version bound (a date, `*`) sorts last
|
|
182
|
+
}
|
|
183
|
+
if (va.op !== vb.op) {
|
|
184
|
+
return va.op === '>=' ? -1 : 1;
|
|
185
|
+
}
|
|
186
|
+
return va.op === '>=' ? r_version_1.RVersion.compare(vb.ver, va.ver) : r_version_1.RVersion.compare(va.ver, vb.ver);
|
|
187
|
+
}
|
|
171
188
|
/** whether a dependency's version is actually narrowed (not every database version survives); a fully redundant one is unconstrained */
|
|
172
189
|
function isConstrained(dep) {
|
|
173
190
|
return dep.totalVersions !== undefined && dep.candidateCount !== dep.totalVersions;
|
|
@@ -176,21 +193,22 @@ function isConstrained(dep) {
|
|
|
176
193
|
function formatCombinations(n) {
|
|
177
194
|
return n >= 1e12 ? n.toExponential(1) : String(Math.round(n)).replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
|
178
195
|
}
|
|
179
|
-
/** a
|
|
180
|
-
function
|
|
181
|
-
|
|
182
|
-
return params.length > shown ? `${params.slice(0, shown).join(', ')} (+${params.length - shown})` : params.join(', ');
|
|
196
|
+
/** a list, truncated with a `(+n)` tail once it gets long, so it stays on one readable line */
|
|
197
|
+
function truncatedList(items, shown = 4) {
|
|
198
|
+
return items.length > shown ? `${items.slice(0, shown).join(', ')} (+${items.length - shown})` : items.join(', ');
|
|
183
199
|
}
|
|
184
200
|
/** a short, readable phrase for one non-signature bound, its origin(s) folded in (so several packages sharing a bound collapse to one line) */
|
|
185
|
-
function nonSignaturePhrase(
|
|
186
|
-
const b = bound ? bound.replace(/([<>]=?)\s+/g, '$1') + ' ' : '';
|
|
187
|
-
|
|
201
|
+
function nonSignaturePhrase(ev, origins) {
|
|
202
|
+
const b = ev.bound ? ev.bound.replace(/([<>]=?)\s+/g, '$1') + ' ' : '';
|
|
203
|
+
// a partial bound holds for only some versions of its origin, so it never narrows: say so instead of implying it did
|
|
204
|
+
const some = ev.partial ? 'some ' : '', not = ev.partial ? ' (not applied)' : '';
|
|
205
|
+
switch (ev.source) {
|
|
188
206
|
case 'declared': return `${b}declared`;
|
|
189
|
-
case 'transitive': return `${b}required by ${origins.join(', ')}`;
|
|
207
|
+
case 'transitive': return `${b}required by ${some}${origins.join(', ')}${ev.partial ? ' versions' : ''}${not}`;
|
|
190
208
|
case 'date': return `releases up to ${origins[0]}`;
|
|
191
209
|
case 'base-r': return `${b}bounded by ${origins[0]}`;
|
|
192
210
|
case 'available': return `${b}available in database`;
|
|
193
|
-
case 'indirect': return `${b}via ${origins.join(', ')}`;
|
|
211
|
+
case 'indirect': return `${b}via ${origins.join(', ')}${not}`;
|
|
194
212
|
default: return b.trim();
|
|
195
213
|
}
|
|
196
214
|
}
|
|
@@ -241,8 +259,14 @@ exports.GuessDepVersionsQueryDefinition = {
|
|
|
241
259
|
result.push(` ${(0, ansi_1.color)('▶', 2 /* Colors.Green */, formatter)} ${(0, ansi_1.bold)('sample', formatter)} ${(0, ansi_1.faint)(`(${selection})`, formatter)}: ${sample.join(', ')}${latestSuffix}`);
|
|
242
260
|
const runnable = out.runnableCombinations, possible = out.possibleCombinations;
|
|
243
261
|
if (runnable !== undefined && possible !== undefined && possible > 0) {
|
|
244
|
-
const
|
|
245
|
-
|
|
262
|
+
const share = (of) => {
|
|
263
|
+
const pct = runnable / of * 100;
|
|
264
|
+
return pct < 10 ? pct.toFixed(1) : String(Math.round(pct));
|
|
265
|
+
};
|
|
266
|
+
// against the whole database, and against what the project already declares (so: what the guess added)
|
|
267
|
+
const declared = out.declaredCombinations;
|
|
268
|
+
const ofDeclared = declared !== undefined && declared > 0 ? `, ${share(declared)}% of declared` : '';
|
|
269
|
+
result.push(` ${(0, ansi_1.italic)('runnable combinations', formatter)}: ${(0, ansi_1.bold)(formatCombinations(runnable), formatter)} ${(0, ansi_1.faint)(`(${share(possible)}%${ofDeclared})`, formatter)}`);
|
|
246
270
|
}
|
|
247
271
|
}
|
|
248
272
|
// the packages locked to one shared version
|
|
@@ -251,9 +275,12 @@ exports.GuessDepVersionsQueryDefinition = {
|
|
|
251
275
|
result.push(` ${(0, ansi_1.italic)('linked', formatter)}: ${group.join(' + ')}${rep?.maxVersion ? (0, ansi_1.faint)(' @ ' + rep.maxVersion, formatter) : ''}`);
|
|
252
276
|
}
|
|
253
277
|
for (const dep of out.dependencies) {
|
|
254
|
-
const
|
|
255
|
-
|
|
256
|
-
|
|
278
|
+
const coupled = dep.coupledWith ?? [];
|
|
279
|
+
const groupTag = (dep.base ? ' ' + (0, ansi_1.italic)('[base]', formatter)
|
|
280
|
+
: dep.linkedWith ? ' ' + (0, ansi_1.italic)(`[linked: ${dep.linkedWith.join(', ')}]`, formatter) : '')
|
|
281
|
+
+ (coupled.length > 0 ? ' ' + (0, ansi_1.italic)(`[coupled: ${truncatedList(coupled, 3)}]`, formatter) : '');
|
|
282
|
+
const anyVersion = coupled.length > 0 ? '(any version on its own)' : '(any version)';
|
|
283
|
+
const note = dep.base ? '' : dep.used === false ? ' ' + (0, ansi_1.faint)('(not called)', formatter) : !isConstrained(dep) && dep.totalVersions ? ' ' + (0, ansi_1.faint)(anyVersion, formatter) : '';
|
|
257
284
|
const tag = groupTag + note;
|
|
258
285
|
const range = dep.unsatisfiable ? (0, ansi_1.color)('unsatisfiable', 1 /* Colors.Red */, formatter) : (0, ansi_1.bold)(dep.range, formatter);
|
|
259
286
|
const count = dep.totalVersions !== undefined ? `${dep.candidateCount}/${dep.totalVersions} versions` : `${dep.candidateCount} candidate${dep.candidateCount === 1 ? '' : 's'}`;
|
|
@@ -261,11 +288,14 @@ exports.GuessDepVersionsQueryDefinition = {
|
|
|
261
288
|
const dbGe = versionBound(tightestBound(avail, '>='))?.ver, dbLe = versionBound(tightestBound(avail, '<='))?.ver;
|
|
262
289
|
const dbRange = dbGe !== undefined && dbLe !== undefined ? `, db ${dbGe} - ${dbLe}` : '';
|
|
263
290
|
result.push(` ${(0, ansi_1.bold)('━ ' + dep.package, formatter)}${tag} ${range} ${(0, ansi_1.faint)('(' + count + dbRange + ')', formatter)}`);
|
|
264
|
-
|
|
265
|
-
const
|
|
291
|
+
// only enforced evidence sets the tightest bound; a partial one narrows nothing and must not hide a real bound
|
|
292
|
+
const enforced = dep.evidence.filter(e => !e.partial);
|
|
293
|
+
const tightestGe = versionBound(tightestBound(enforced, '>='))?.ver;
|
|
294
|
+
const tightestLe = versionBound(tightestBound(enforced.filter(e => versionBound(e.bound)), '<='))?.ver;
|
|
266
295
|
const active = [], dominated = [];
|
|
267
|
-
const nonSig = [...(0, arrays_1.arraysGroupBy)(dep.evidence.filter(e => e.source !== 'signature' && e.source !== 'available'), e => `${e.source}|${e.bound ?? ''}`)]
|
|
268
|
-
.map(([, evs]) => ({ ev: evs[0], origins: [...new Set(evs.map(e => e.origin))] }))
|
|
296
|
+
const nonSig = [...(0, arrays_1.arraysGroupBy)(dep.evidence.filter(e => e.source !== 'signature' && e.source !== 'available'), e => `${e.source}|${e.bound ?? ''}|${e.partial ? 'p' : ''}`)]
|
|
297
|
+
.map(([, evs]) => ({ ev: evs[0], origins: [...new Set(evs.map(e => e.origin))] }))
|
|
298
|
+
.sort((x, y) => compareBounds(x.ev, y.ev));
|
|
269
299
|
const bestRankByBound = new Map();
|
|
270
300
|
for (const { ev } of nonSig) {
|
|
271
301
|
const vb = versionBound(ev.bound);
|
|
@@ -279,7 +309,7 @@ exports.GuessDepVersionsQueryDefinition = {
|
|
|
279
309
|
}
|
|
280
310
|
}
|
|
281
311
|
for (const { ev, origins } of nonSig) {
|
|
282
|
-
const phrase = nonSignaturePhrase(ev
|
|
312
|
+
const phrase = nonSignaturePhrase(ev, origins);
|
|
283
313
|
const vb = versionBound(ev.bound);
|
|
284
314
|
const best = vb === undefined ? undefined : bestRankByBound.get(vb.op + vb.ver);
|
|
285
315
|
const redundant = best !== undefined && sourceRank[ev.source] > best;
|
|
@@ -296,7 +326,7 @@ exports.GuessDepVersionsQueryDefinition = {
|
|
|
296
326
|
const ge = tightestBound(evs, '>='), le = tightestBound(evs, '<=');
|
|
297
327
|
const geVer = versionBound(ge)?.ver, leVer = versionBound(le)?.ver;
|
|
298
328
|
const params = [...new Set(evs.map(e => e.parameter).filter((pm) => pm !== undefined))];
|
|
299
|
-
const reasons = [evs.some(e => !e.parameter) ? 'new' : undefined, params.length > 0 ? `params: [${
|
|
329
|
+
const reasons = [evs.some(e => !e.parameter) ? 'new' : undefined, params.length > 0 ? `params: [${truncatedList(params)}]` : undefined].filter(Boolean).join(', ');
|
|
300
330
|
const name = identifier_1.Identifier.getName(identifier_1.Identifier.parse(fn));
|
|
301
331
|
const url = (0, signature_query_executor_1.rdrrDocUrl)(dep.package, name, { base: dep.base, cran: !dep.base });
|
|
302
332
|
const label = (url ? formatter.hyperlink(name, url, true) : name) + (reasons ? ` (${reasons})` : '');
|
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
import { Identifier } from '../../../dataflow/environments/identifier';
|
|
2
|
+
import type { LinkedInputEntryPoint, LinkedInputObject, NarrowingFunction } from './simple-input-classifier';
|
|
3
|
+
/**
|
|
4
|
+
* Objects that a framework binds for its users, without a definition visible in the code.
|
|
5
|
+
* The `withParams` and `requires` guards keep ordinary functions that happen to have a parameter of the same
|
|
6
|
+
* name out of this; where the framework is handed the function, {@link LinkedInputEntryPoints} is exact instead.
|
|
7
|
+
* @see {@link LinkedInputObject}
|
|
8
|
+
*/
|
|
9
|
+
export declare const LinkedInputObjects: readonly LinkedInputObject[];
|
|
10
|
+
export declare const NarrowingFunctions: readonly NarrowingFunction[];
|
|
11
|
+
/**
|
|
12
|
+
* Calls that hand a function to a framework which binds its parameters by position.
|
|
13
|
+
* @see {@link LinkedInputEntryPoint}
|
|
14
|
+
*/
|
|
15
|
+
export declare const LinkedInputEntryPoints: readonly LinkedInputEntryPoint[];
|
|
2
16
|
export declare const PureFunctions: Identifier[];
|
|
3
17
|
export declare const SystemFunctions: Identifier[];
|
|
4
18
|
export declare const FfiFunctions: Identifier[];
|
|
@@ -1,7 +1,54 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TempFileFunctions = exports.UserFunctions = exports.OptionsFunctions = exports.LangFunctions = exports.FfiFunctions = exports.SystemFunctions = exports.PureFunctions = void 0;
|
|
3
|
+
exports.TempFileFunctions = exports.UserFunctions = exports.OptionsFunctions = exports.LangFunctions = exports.FfiFunctions = exports.SystemFunctions = exports.PureFunctions = exports.LinkedInputEntryPoints = exports.NarrowingFunctions = exports.LinkedInputObjects = void 0;
|
|
4
4
|
const identifier_1 = require("../../../dataflow/environments/identifier");
|
|
5
|
+
const simple_input_classifier_1 = require("./simple-input-classifier");
|
|
6
|
+
/** shiny's ui-side control widgets, all taking the id of the `input` entry they feed as their first argument */
|
|
7
|
+
const ShinyInputWidgets = {
|
|
8
|
+
argName: 'inputId',
|
|
9
|
+
argIdx: 0,
|
|
10
|
+
calls: [
|
|
11
|
+
'actionButton', 'actionLink', 'checkboxInput', 'checkboxGroupInput', 'dateInput', 'dateRangeInput',
|
|
12
|
+
'fileInput', 'numericInput', 'passwordInput', 'radioButtons', 'selectInput', 'selectizeInput',
|
|
13
|
+
'sliderInput', 'submitButton', 'textAreaInput', 'textInput', 'varSelectInput', 'varSelectizeInput'
|
|
14
|
+
].map(n => identifier_1.Identifier.make(n, 'shiny'))
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Objects that a framework binds for its users, without a definition visible in the code.
|
|
18
|
+
* The `withParams` and `requires` guards keep ordinary functions that happen to have a parameter of the same
|
|
19
|
+
* name out of this; where the framework is handed the function, {@link LinkedInputEntryPoints} is exact instead.
|
|
20
|
+
* @see {@link LinkedInputObject}
|
|
21
|
+
*/
|
|
22
|
+
exports.LinkedInputObjects = [
|
|
23
|
+
/* shiny hands the server function its reactive `input` and `session` objects */
|
|
24
|
+
{ name: 'input', type: simple_input_classifier_1.InputType.User, withParams: ['output'], requires: 'shiny', declaredBy: ShinyInputWidgets },
|
|
25
|
+
/* of the session only what the browser sends is user input, `userData` and `token` are the app's own */
|
|
26
|
+
{ name: 'session', type: simple_input_classifier_1.InputType.User, withParams: ['input', 'output'], requires: 'shiny', fields: ['clientData', 'request'] }
|
|
27
|
+
];
|
|
28
|
+
exports.NarrowingFunctions = [
|
|
29
|
+
/* bounded by an argument: the result is one element of that argument */
|
|
30
|
+
{ call: identifier_1.Identifier.make('match.arg', 'base'), argName: 'choices', argIdx: 1 },
|
|
31
|
+
/* bounded content-independent results (counts, indices, logicals): the subject's taint cannot flow through */
|
|
32
|
+
...[
|
|
33
|
+
'nchar', 'length', 'lengths', 'nrow', 'ncol', 'NROW', 'NCOL',
|
|
34
|
+
'which', 'which.max', 'which.min', 'match', 'pmatch', 'charmatch',
|
|
35
|
+
'seq_along', 'seq_len',
|
|
36
|
+
'is.na', 'is.null', 'is.numeric', 'is.character', 'is.logical', 'is.function', 'is.list', 'is.element',
|
|
37
|
+
'nzchar', 'grepl', 'startsWith', 'endsWith'
|
|
38
|
+
].map(name => ({ call: identifier_1.Identifier.make(name, 'base') }))
|
|
39
|
+
];
|
|
40
|
+
/** shiny binds `input`, `output`, and `session` positionally, so their names are up to whoever writes the server */
|
|
41
|
+
const ShinyServerParams = ['input', undefined, 'session'];
|
|
42
|
+
/**
|
|
43
|
+
* Calls that hand a function to a framework which binds its parameters by position.
|
|
44
|
+
* @see {@link LinkedInputEntryPoint}
|
|
45
|
+
*/
|
|
46
|
+
exports.LinkedInputEntryPoints = [
|
|
47
|
+
{ call: identifier_1.Identifier.make('shinyApp', 'shiny'), argName: 'server', argIdx: 1, params: ShinyServerParams },
|
|
48
|
+
{ call: identifier_1.Identifier.make('shinyServer', 'shiny'), argName: 'func', argIdx: 0, params: ShinyServerParams },
|
|
49
|
+
{ call: identifier_1.Identifier.make('moduleServer', 'shiny'), argName: 'module', argIdx: 1, params: ShinyServerParams },
|
|
50
|
+
{ call: identifier_1.Identifier.make('callModule', 'shiny'), argName: 'module', argIdx: 0, params: ShinyServerParams }
|
|
51
|
+
];
|
|
5
52
|
exports.PureFunctions = [
|
|
6
53
|
/* operators - syntax elements, impossible to call with :: in practice */
|
|
7
54
|
'+', '-', '*', '/', '^', '%%', '%/%',
|
|
@@ -16,22 +63,19 @@ exports.PureFunctions = [
|
|
|
16
63
|
identifier_1.Identifier.make('substr', 'base'),
|
|
17
64
|
identifier_1.Identifier.make('substring', 'base'),
|
|
18
65
|
identifier_1.Identifier.make('strsplit', 'base'),
|
|
19
|
-
identifier_1.Identifier.make('startsWith', 'base'),
|
|
20
|
-
identifier_1.Identifier.make('endsWith', 'base'),
|
|
21
66
|
identifier_1.Identifier.make('strrep', 'base'),
|
|
22
67
|
identifier_1.Identifier.make('chartr', 'base'),
|
|
23
68
|
identifier_1.Identifier.make('strtoi', 'base'),
|
|
24
69
|
identifier_1.Identifier.make('tolower', 'base'),
|
|
25
70
|
identifier_1.Identifier.make('toupper', 'base'),
|
|
26
|
-
identifier_1.Identifier.make('nchar', 'base'),
|
|
27
71
|
identifier_1.Identifier.make('trimws', 'base'),
|
|
28
72
|
identifier_1.Identifier.make('grep', 'base'),
|
|
29
|
-
identifier_1.Identifier.make('grepl', 'base'),
|
|
30
73
|
identifier_1.Identifier.make('sub', 'base'),
|
|
31
74
|
identifier_1.Identifier.make('gsub', 'base'),
|
|
32
75
|
identifier_1.Identifier.make('regexpr', 'base'),
|
|
33
76
|
identifier_1.Identifier.make('gregexpr', 'base'),
|
|
34
77
|
identifier_1.Identifier.make('regexec', 'base'),
|
|
78
|
+
// regmatches yields a substring of x, so x's taint propagates soundly - kept pure deliberately
|
|
35
79
|
identifier_1.Identifier.make('regmatches', 'base'),
|
|
36
80
|
identifier_1.Identifier.make('format', 'base'),
|
|
37
81
|
identifier_1.Identifier.make('sprintf', 'base'),
|
|
@@ -88,18 +132,12 @@ exports.PureFunctions = [
|
|
|
88
132
|
identifier_1.Identifier.make('diff', 'base'),
|
|
89
133
|
identifier_1.Identifier.make('pmin', 'base'),
|
|
90
134
|
identifier_1.Identifier.make('pmax', 'base'),
|
|
91
|
-
identifier_1.Identifier.make('which', 'base'),
|
|
92
|
-
identifier_1.Identifier.make('which.min', 'base'),
|
|
93
|
-
identifier_1.Identifier.make('which.max', 'base'),
|
|
94
|
-
identifier_1.Identifier.make('match', 'base'),
|
|
95
135
|
identifier_1.Identifier.make('order', 'base'),
|
|
96
136
|
identifier_1.Identifier.make('sort', 'base'),
|
|
97
137
|
identifier_1.Identifier.make('unique', 'base'),
|
|
98
138
|
identifier_1.Identifier.make('duplicated', 'base'),
|
|
99
139
|
identifier_1.Identifier.make('seq', 'base'),
|
|
100
140
|
identifier_1.Identifier.make('rep', 'base'),
|
|
101
|
-
identifier_1.Identifier.make('seq_len', 'base'),
|
|
102
|
-
identifier_1.Identifier.make('seq_along', 'base'),
|
|
103
141
|
identifier_1.Identifier.make('rep.int', 'base'),
|
|
104
142
|
/* base - data structures */
|
|
105
143
|
identifier_1.Identifier.make('c', 'base'),
|
|
@@ -121,10 +159,7 @@ exports.PureFunctions = [
|
|
|
121
159
|
identifier_1.Identifier.make('prop.table', 'base'),
|
|
122
160
|
identifier_1.Identifier.make('rownames', 'base'),
|
|
123
161
|
identifier_1.Identifier.make('colnames', 'base'),
|
|
124
|
-
identifier_1.Identifier.make('length', 'base'),
|
|
125
162
|
identifier_1.Identifier.make('dim', 'base'),
|
|
126
|
-
identifier_1.Identifier.make('nrow', 'base'),
|
|
127
|
-
identifier_1.Identifier.make('ncol', 'base'),
|
|
128
163
|
identifier_1.Identifier.make('colSums', 'base'),
|
|
129
164
|
identifier_1.Identifier.make('rowSums', 'base'),
|
|
130
165
|
identifier_1.Identifier.make('colMeans', 'base'),
|
|
@@ -172,15 +207,10 @@ exports.PureFunctions = [
|
|
|
172
207
|
identifier_1.Identifier.make('raw', 'base'),
|
|
173
208
|
identifier_1.Identifier.make('complex', 'base'),
|
|
174
209
|
/* base - type predicates */
|
|
175
|
-
identifier_1.Identifier.make('is.na', 'base'),
|
|
176
|
-
identifier_1.Identifier.make('is.null', 'base'),
|
|
177
|
-
identifier_1.Identifier.make('is.numeric', 'base'),
|
|
178
|
-
identifier_1.Identifier.make('is.character', 'base'),
|
|
179
210
|
identifier_1.Identifier.make('is.finite', 'base'),
|
|
180
211
|
identifier_1.Identifier.make('is.infinite', 'base'),
|
|
181
212
|
identifier_1.Identifier.make('is.nan', 'base'),
|
|
182
213
|
identifier_1.Identifier.make('is.factor', 'base'),
|
|
183
|
-
identifier_1.Identifier.make('is.logical', 'base'),
|
|
184
214
|
identifier_1.Identifier.make('is.vector', 'base'),
|
|
185
215
|
identifier_1.Identifier.make('is.matrix', 'base'),
|
|
186
216
|
identifier_1.Identifier.make('is.data.frame', 'base'),
|
|
@@ -192,7 +222,6 @@ exports.PureFunctions = [
|
|
|
192
222
|
identifier_1.Identifier.make('return', 'base'),
|
|
193
223
|
identifier_1.Identifier.make('force', 'base'),
|
|
194
224
|
identifier_1.Identifier.make('missing', 'base'),
|
|
195
|
-
identifier_1.Identifier.make('match.arg', 'base'),
|
|
196
225
|
identifier_1.Identifier.make('print', 'base'),
|
|
197
226
|
identifier_1.Identifier.make('cat', 'base'),
|
|
198
227
|
identifier_1.Identifier.make('message', 'base'),
|
|
@@ -212,6 +241,40 @@ exports.PureFunctions = [
|
|
|
212
241
|
identifier_1.Identifier.make('cov', 'stats'),
|
|
213
242
|
identifier_1.Identifier.make('na.omit', 'stats'),
|
|
214
243
|
identifier_1.Identifier.make('xtabs', 'stats'),
|
|
244
|
+
/* shiny - wrappers that hand their expression on; the reactives among them do so through a call (`r()`).
|
|
245
|
+
`observe`/`observeEvent`/`render*` are left out on purpose: they return an observer or render handle,
|
|
246
|
+
not the value of their expression. */
|
|
247
|
+
identifier_1.Identifier.make('reactive', 'shiny'),
|
|
248
|
+
identifier_1.Identifier.make('eventReactive', 'shiny'),
|
|
249
|
+
identifier_1.Identifier.make('bindEvent', 'shiny'),
|
|
250
|
+
identifier_1.Identifier.make('bindCache', 'shiny'),
|
|
251
|
+
identifier_1.Identifier.make('isolate', 'shiny'),
|
|
252
|
+
identifier_1.Identifier.make('req', 'shiny'),
|
|
253
|
+
identifier_1.Identifier.make('debounce', 'shiny'),
|
|
254
|
+
identifier_1.Identifier.make('throttle', 'shiny'),
|
|
255
|
+
identifier_1.Identifier.make('reactiveVal', 'shiny'),
|
|
256
|
+
identifier_1.Identifier.make('reactiveValues', 'shiny'),
|
|
257
|
+
identifier_1.Identifier.make('reactiveValuesToList', 'shiny'),
|
|
258
|
+
identifier_1.Identifier.make('freezeReactiveVal', 'shiny'),
|
|
259
|
+
/* cohortBuilder - assembling a cohort keeps the data of its source */
|
|
260
|
+
identifier_1.Identifier.make('cohort', 'cohortBuilder'),
|
|
261
|
+
identifier_1.Identifier.make('set_source', 'cohortBuilder'),
|
|
262
|
+
identifier_1.Identifier.make('add_source', 'cohortBuilder'),
|
|
263
|
+
identifier_1.Identifier.make('update_source', 'cohortBuilder'),
|
|
264
|
+
identifier_1.Identifier.make('add_filter', 'cohortBuilder'),
|
|
265
|
+
identifier_1.Identifier.make('update_filter', 'cohortBuilder'),
|
|
266
|
+
identifier_1.Identifier.make('rm_filter', 'cohortBuilder'),
|
|
267
|
+
identifier_1.Identifier.make('bind_key', 'cohortBuilder'),
|
|
268
|
+
identifier_1.Identifier.make('bind_keys', 'cohortBuilder'),
|
|
269
|
+
identifier_1.Identifier.make('as.tblist', 'cohortBuilder'),
|
|
270
|
+
identifier_1.Identifier.make('tblist', 'cohortBuilder'),
|
|
271
|
+
/* generic names, only matched bare while cohortBuilder is attached */
|
|
272
|
+
identifier_1.Identifier.make('filter', 'cohortBuilder'),
|
|
273
|
+
identifier_1.Identifier.make('step', 'cohortBuilder'),
|
|
274
|
+
identifier_1.Identifier.make('add_step', 'cohortBuilder'),
|
|
275
|
+
identifier_1.Identifier.make('rm_step', 'cohortBuilder'),
|
|
276
|
+
identifier_1.Identifier.make('run', 'cohortBuilder'),
|
|
277
|
+
identifier_1.Identifier.make('restore', 'cohortBuilder'),
|
|
215
278
|
];
|
|
216
279
|
exports.SystemFunctions = [
|
|
217
280
|
/* base */
|
|
@@ -321,6 +384,32 @@ exports.UserFunctions = [
|
|
|
321
384
|
/* tcltk */
|
|
322
385
|
identifier_1.Identifier.make('tk_choose.files', 'tcltk'),
|
|
323
386
|
identifier_1.Identifier.make('tk_choose.dir', 'tcltk'),
|
|
387
|
+
/* shiny - everything the browser sends along with a request */
|
|
388
|
+
identifier_1.Identifier.make('parseQueryString', 'shiny'),
|
|
389
|
+
identifier_1.Identifier.make('getQueryString', 'shiny'),
|
|
390
|
+
identifier_1.Identifier.make('getUrlHash', 'shiny'),
|
|
391
|
+
identifier_1.Identifier.make('restoreInput', 'shiny'),
|
|
392
|
+
/* shinyFiles - paths the user picks in the browser */
|
|
393
|
+
identifier_1.Identifier.make('parseFilePaths', 'shinyFiles'),
|
|
394
|
+
identifier_1.Identifier.make('parseDirPath', 'shinyFiles'),
|
|
395
|
+
identifier_1.Identifier.make('parseSavePath', 'shinyFiles'),
|
|
396
|
+
identifier_1.Identifier.make('shinyFileChoose', 'shinyFiles'),
|
|
397
|
+
identifier_1.Identifier.make('shinyDirChoose', 'shinyFiles'),
|
|
398
|
+
identifier_1.Identifier.make('shinyFileSave', 'shinyFiles'),
|
|
399
|
+
/* cohortBuilder - the data that comes out of a cohort depends on the filters the user set */
|
|
400
|
+
identifier_1.Identifier.make('get_data', 'cohortBuilder'),
|
|
401
|
+
identifier_1.Identifier.make('sum_up', 'cohortBuilder'),
|
|
402
|
+
identifier_1.Identifier.make('attrition', 'cohortBuilder'),
|
|
403
|
+
identifier_1.Identifier.make('get_state', 'cohortBuilder'),
|
|
404
|
+
identifier_1.Identifier.make('code', 'cohortBuilder'),
|
|
405
|
+
identifier_1.Identifier.make('stat', 'cohortBuilder'),
|
|
406
|
+
/* shinyCohortBuilder - the gui that lets the user set those filters */
|
|
407
|
+
identifier_1.Identifier.make('cb_server', 'shinyCohortBuilder'),
|
|
408
|
+
identifier_1.Identifier.make('cb_ui', 'shinyCohortBuilder'),
|
|
409
|
+
identifier_1.Identifier.make('cb_chat_server', 'shinyCohortBuilder'),
|
|
410
|
+
identifier_1.Identifier.make('cb_chat_ui', 'shinyCohortBuilder'),
|
|
411
|
+
identifier_1.Identifier.make('gui', 'shinyCohortBuilder'),
|
|
412
|
+
identifier_1.Identifier.make('demo_app', 'shinyCohortBuilder'),
|
|
324
413
|
];
|
|
325
414
|
/** R functions that produce temporary file/directory paths (sub-type of {@link InputType.File}). */
|
|
326
415
|
exports.TempFileFunctions = [
|
|
@@ -10,6 +10,9 @@ const df_helper_1 = require("../../../dataflow/graph/df-helper");
|
|
|
10
10
|
const simple_input_classifier_1 = require("./simple-input-classifier");
|
|
11
11
|
const flowr_search_executor_1 = require("../../../search/flowr-search-executor");
|
|
12
12
|
const record_1 = require("../../../util/record");
|
|
13
|
+
const identifier_1 = require("../../../dataflow/environments/identifier");
|
|
14
|
+
const r_base_packages_1 = require("../../../util/r-base-packages");
|
|
15
|
+
const environment_1 = require("../../../dataflow/environments/environment");
|
|
13
16
|
/**
|
|
14
17
|
* Execute an input sources query
|
|
15
18
|
*/
|
|
@@ -18,7 +21,9 @@ async function executeInputSourcesQuery({ analyzer }, queries) {
|
|
|
18
21
|
const results = {};
|
|
19
22
|
const nast = await analyzer.normalize();
|
|
20
23
|
const df = await analyzer.dataflow();
|
|
21
|
-
|
|
24
|
+
// flowR's defaults, extended by whatever the (possibly project-kind specialized) configuration adds
|
|
25
|
+
const defaultConfig = addAll(await resolveSearches(analyzer, input_sources_query_format_1.DefaultInputClassifierConfig), await resolveSearches(analyzer, analyzer.inspectContext().config.inputSources ?? {}));
|
|
26
|
+
const packages = attachedPackages(analyzer, df.environment);
|
|
22
27
|
for (const query of queries) {
|
|
23
28
|
const criteria = Array.isArray(query.criterion)
|
|
24
29
|
? query.criterion
|
|
@@ -33,7 +38,7 @@ async function executeInputSourcesQuery({ analyzer }, queries) {
|
|
|
33
38
|
const provenanceNode = nast.idMap.get(criterionId);
|
|
34
39
|
const fdef = r_function_definition_1.RFunctionDefinition.rootFunctionDefinition(provenanceNode, nast.idMap);
|
|
35
40
|
const provenance = df_helper_1.Dataflow.provenanceGraph(criterionId, df.graph, fdef ? model_1.RNode.collectAllIds(fdef) : undefined);
|
|
36
|
-
results[criterion] = (0, simple_input_classifier_1.classifyInput)(criterionId, provenance, config, df.graph);
|
|
41
|
+
results[criterion] = (0, simple_input_classifier_1.classifyInput)(criterionId, provenance, config, df.graph, packages);
|
|
37
42
|
}
|
|
38
43
|
}
|
|
39
44
|
return {
|
|
@@ -43,11 +48,47 @@ async function executeInputSourcesQuery({ analyzer }, queries) {
|
|
|
43
48
|
results
|
|
44
49
|
};
|
|
45
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* The packages whose exports are usable without a namespace: those R has on its search path at the end of the
|
|
53
|
+
* program, the ones the project declares, and the base packages R attaches on startup.
|
|
54
|
+
*/
|
|
55
|
+
function attachedPackages(analyzer, environment) {
|
|
56
|
+
return new Set([
|
|
57
|
+
...environment_1.REnvironment.attachedPackages(environment.current),
|
|
58
|
+
...analyzer.inspectContext().deps.getDependencies().map(d => d.name),
|
|
59
|
+
...r_base_packages_1.AttachedBasePackages
|
|
60
|
+
]);
|
|
61
|
+
}
|
|
62
|
+
/** every entry of `extra` appended to the matching list of `base`, so configured entries extend the defaults instead of replacing them */
|
|
63
|
+
function addAll(base, extra) {
|
|
64
|
+
const result = { ...base };
|
|
65
|
+
for (const [key, value] of record_1.Record.entries(extra)) {
|
|
66
|
+
if (value !== undefined) {
|
|
67
|
+
result[key] = [...(base[key] ?? []), ...value];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
72
|
+
/** Config fields that hold structured values (not function searches) and are carried over verbatim. */
|
|
73
|
+
const StructuredConfigKeys = ['linkedObjects', 'linkedEntryPoints', 'narrowing'];
|
|
74
|
+
function isStructuredConfigKey(key) {
|
|
75
|
+
return StructuredConfigKeys.includes(key);
|
|
76
|
+
}
|
|
46
77
|
async function resolveSearches(analyzer, config) {
|
|
78
|
+
/* structured (non-search) fields are carried over as-is; everything else is a resolvable function search */
|
|
47
79
|
const result = {};
|
|
80
|
+
for (const key of StructuredConfigKeys) {
|
|
81
|
+
if (config[key] !== undefined) {
|
|
82
|
+
result[key] = config[key];
|
|
83
|
+
}
|
|
84
|
+
}
|
|
48
85
|
for (const [key, value] of record_1.Record.entries(config)) {
|
|
49
|
-
if (
|
|
50
|
-
|
|
86
|
+
if (isStructuredConfigKey(key)) {
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
else if (value === undefined || Array.isArray(value)) {
|
|
90
|
+
// entries may be written as `pkg::fn` strings in the configuration, which only mean the namespaced function once parsed
|
|
91
|
+
result[key] = value?.map(e => typeof e === 'string' ? identifier_1.Identifier.parse(e) : e);
|
|
51
92
|
}
|
|
52
93
|
else {
|
|
53
94
|
const searchResult = await (0, flowr_search_executor_1.runSearch)(value, analyzer);
|
|
@@ -13,6 +13,7 @@ const input_sources_query_executor_1 = require("./input-sources-query-executor")
|
|
|
13
13
|
const range_1 = require("../../../util/range");
|
|
14
14
|
const flowr_search_builder_1 = require("../../../search/flowr-search-builder");
|
|
15
15
|
const linter_format_1 = require("../../../linter/linter-format");
|
|
16
|
+
const record_1 = require("../../../util/record");
|
|
16
17
|
const read_functions_1 = require("../dependencies-query/function-info/read-functions");
|
|
17
18
|
const input_source_functions_1 = require("./input-source-functions");
|
|
18
19
|
exports.DefaultInputClassifierConfig = {
|
|
@@ -25,7 +26,10 @@ exports.DefaultInputClassifierConfig = {
|
|
|
25
26
|
[simple_input_classifier_1.InputType.Ffi]: input_source_functions_1.FfiFunctions,
|
|
26
27
|
[simple_input_classifier_1.InputType.Lang]: input_source_functions_1.LangFunctions,
|
|
27
28
|
[simple_input_classifier_1.InputType.Options]: input_source_functions_1.OptionsFunctions,
|
|
28
|
-
[simple_input_classifier_1.InputType.User]: input_source_functions_1.UserFunctions
|
|
29
|
+
[simple_input_classifier_1.InputType.User]: input_source_functions_1.UserFunctions,
|
|
30
|
+
linkedObjects: input_source_functions_1.LinkedInputObjects,
|
|
31
|
+
linkedEntryPoints: input_source_functions_1.LinkedInputEntryPoints,
|
|
32
|
+
narrowing: input_source_functions_1.NarrowingFunctions
|
|
29
33
|
};
|
|
30
34
|
function inputSourcesQueryLineParser(output, line, _config) {
|
|
31
35
|
const criterion = (0, slice_query_parser_1.sliceCriteriaParser)(line[0]);
|
|
@@ -47,12 +51,16 @@ exports.InputSourcesDefinition = {
|
|
|
47
51
|
const nast = (await analyzer.normalize()).idMap;
|
|
48
52
|
for (const [key, sources] of Object.entries(out.results)) {
|
|
49
53
|
result.push(` ╰ Input Sources for ${key}`);
|
|
50
|
-
for (const { id, trace, types, name, value } of sources) {
|
|
54
|
+
for (const { id, trace, types, name, value, declaredAt } of sources) {
|
|
51
55
|
const kNode = nast.get(id);
|
|
52
56
|
const kLoc = kNode ? range_1.SourceLocation.format(range_1.SourceLocation.fromNode(kNode)) : 'unknown location';
|
|
53
57
|
const nameStr = name !== undefined ? `, name: ${name}` : '';
|
|
54
58
|
const valueStr = value !== undefined ? `, value: ${JSON.stringify(value)}` : '';
|
|
55
|
-
|
|
59
|
+
const declStr = declaredAt ? `, declared at: ${declaredAt.map(d => {
|
|
60
|
+
const dNode = nast.get(d);
|
|
61
|
+
return dNode ? range_1.SourceLocation.format(range_1.SourceLocation.fromNode(dNode)) : String(d);
|
|
62
|
+
}).join(', ')}` : '';
|
|
63
|
+
result.push(` ╰ ${kLoc} (id: ${id}), type: ${JSON.stringify(types)}, trace: ${trace}${nameStr}${valueStr}${declStr}`);
|
|
56
64
|
}
|
|
57
65
|
}
|
|
58
66
|
return true;
|
|
@@ -74,6 +82,17 @@ exports.InputSourcesDefinition = {
|
|
|
74
82
|
[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).'),
|
|
75
83
|
[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).'),
|
|
76
84
|
[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).'),
|
|
85
|
+
linkedObjects: joi_1.default.array().items(joi_1.default.object({
|
|
86
|
+
name: joi_1.default.string().required().description('Name of the object, e.g. input.'),
|
|
87
|
+
type: joi_1.default.string().valid(...record_1.Record.values(simple_input_classifier_1.InputType)).required().description('How reads of the object (or of its fields) are classified.'),
|
|
88
|
+
withParams: joi_1.default.array().items(joi_1.default.string()).optional().description('Only link the object if the function binding it declares all of these parameters as well.')
|
|
89
|
+
})).optional().description('Objects a framework provides without a definition in the code, e.g. shiny\'s input.'),
|
|
90
|
+
linkedEntryPoints: joi_1.default.array().items(joi_1.default.object({
|
|
91
|
+
call: joi_1.default.string().required().description('The call taking the function, e.g. shiny::shinyApp.'),
|
|
92
|
+
argName: joi_1.default.string().required().description('Name of the argument holding the function.'),
|
|
93
|
+
argIdx: joi_1.default.number().required().description('Index of that argument when it is passed positionally.'),
|
|
94
|
+
params: joi_1.default.array().items(joi_1.default.string().allow(null)).required().description('Which linkedObject the framework binds to each parameter, by position.')
|
|
95
|
+
})).optional().description('Calls that hand a function to a framework, which binds its objects to the parameters by position.')
|
|
77
96
|
}).optional()
|
|
78
97
|
}).description('Input Sources query definition'),
|
|
79
98
|
flattenInvolvedNodes: (queryResults) => {
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The classification lattice of the {@link InputSourcesQuery|input-sources} analysis, kept free of any imports so
|
|
3
|
+
* that the configuration can name its members without pulling the analysis in.
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Lattice flattening until we have a taint engine :)
|
|
8
|
+
* Please note that the classifier considers this basis with a set-lift,
|
|
9
|
+
* joining differing lattice elements.
|
|
10
|
+
*
|
|
11
|
+
*```
|
|
12
|
+
* [ Unknown ]
|
|
13
|
+
* |
|
|
14
|
+
* [Param] [File] [Net] [User], ...
|
|
15
|
+
* | | | |
|
|
16
|
+
* | [TempFile] | |
|
|
17
|
+
* +---------+------+------+- ...
|
|
18
|
+
* |
|
|
19
|
+
* [ DerivedConstant ]
|
|
20
|
+
* |
|
|
21
|
+
* [ Constant ]
|
|
22
|
+
*```
|
|
23
|
+
*
|
|
24
|
+
*/
|
|
25
|
+
export declare enum InputType {
|
|
26
|
+
Parameter = "param",
|
|
27
|
+
File = "file",
|
|
28
|
+
/** Temporary file paths produced by tempfile()/tempdir() and equivalents; a sub-type of {@link File} */
|
|
29
|
+
TempFile = "tempfile",
|
|
30
|
+
Network = "net",
|
|
31
|
+
Random = "rand",
|
|
32
|
+
/** Calls to system/system2 and similar */
|
|
33
|
+
System = "system",
|
|
34
|
+
/** Calls to .C / Fortran interfaces (foreign function interfaces) */
|
|
35
|
+
Ffi = "ffi",
|
|
36
|
+
/** Language objects (quote/substitute/etc.) */
|
|
37
|
+
Lang = "lang",
|
|
38
|
+
/** Global options / option accessors (options, getOption) */
|
|
39
|
+
Options = "options",
|
|
40
|
+
/** Interactive user input (file choosers, prompts, dialogs, menu selections) */
|
|
41
|
+
User = "user",
|
|
42
|
+
Constant = "const",
|
|
43
|
+
/** Read from environment/call scope */
|
|
44
|
+
Scope = "scope",
|
|
45
|
+
/** Pure calculations from constants that lead to a constant */
|
|
46
|
+
DerivedConstant = "dconst",
|
|
47
|
+
Unknown = "unknown"
|
|
48
|
+
}
|
|
49
|
+
export declare enum InputTraceType {
|
|
50
|
+
/** Derived only from aliasing */
|
|
51
|
+
Alias = "alias",
|
|
52
|
+
/** Derived from pure function chains */
|
|
53
|
+
Pure = "pure",
|
|
54
|
+
/** Derived from known but not necessarily all pure function chains */
|
|
55
|
+
Known = "known",
|
|
56
|
+
/** Not fully known origin */
|
|
57
|
+
Unknown = "unknown"
|
|
58
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The classification lattice of the {@link InputSourcesQuery|input-sources} analysis, kept free of any imports so
|
|
4
|
+
* that the configuration can name its members without pulling the analysis in.
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.InputTraceType = exports.InputType = void 0;
|
|
9
|
+
/**
|
|
10
|
+
* Lattice flattening until we have a taint engine :)
|
|
11
|
+
* Please note that the classifier considers this basis with a set-lift,
|
|
12
|
+
* joining differing lattice elements.
|
|
13
|
+
*
|
|
14
|
+
*```
|
|
15
|
+
* [ Unknown ]
|
|
16
|
+
* |
|
|
17
|
+
* [Param] [File] [Net] [User], ...
|
|
18
|
+
* | | | |
|
|
19
|
+
* | [TempFile] | |
|
|
20
|
+
* +---------+------+------+- ...
|
|
21
|
+
* |
|
|
22
|
+
* [ DerivedConstant ]
|
|
23
|
+
* |
|
|
24
|
+
* [ Constant ]
|
|
25
|
+
*```
|
|
26
|
+
*
|
|
27
|
+
*/
|
|
28
|
+
var InputType;
|
|
29
|
+
(function (InputType) {
|
|
30
|
+
InputType["Parameter"] = "param";
|
|
31
|
+
InputType["File"] = "file";
|
|
32
|
+
/** Temporary file paths produced by tempfile()/tempdir() and equivalents; a sub-type of {@link File} */
|
|
33
|
+
InputType["TempFile"] = "tempfile";
|
|
34
|
+
InputType["Network"] = "net";
|
|
35
|
+
InputType["Random"] = "rand";
|
|
36
|
+
/** Calls to system/system2 and similar */
|
|
37
|
+
InputType["System"] = "system";
|
|
38
|
+
/** Calls to .C / Fortran interfaces (foreign function interfaces) */
|
|
39
|
+
InputType["Ffi"] = "ffi";
|
|
40
|
+
/** Language objects (quote/substitute/etc.) */
|
|
41
|
+
InputType["Lang"] = "lang";
|
|
42
|
+
/** Global options / option accessors (options, getOption) */
|
|
43
|
+
InputType["Options"] = "options";
|
|
44
|
+
/** Interactive user input (file choosers, prompts, dialogs, menu selections) */
|
|
45
|
+
InputType["User"] = "user";
|
|
46
|
+
InputType["Constant"] = "const";
|
|
47
|
+
/** Read from environment/call scope */
|
|
48
|
+
InputType["Scope"] = "scope";
|
|
49
|
+
/** Pure calculations from constants that lead to a constant */
|
|
50
|
+
InputType["DerivedConstant"] = "dconst";
|
|
51
|
+
InputType["Unknown"] = "unknown";
|
|
52
|
+
})(InputType || (exports.InputType = InputType = {}));
|
|
53
|
+
var InputTraceType;
|
|
54
|
+
(function (InputTraceType) {
|
|
55
|
+
/** Derived only from aliasing */
|
|
56
|
+
InputTraceType["Alias"] = "alias";
|
|
57
|
+
/** Derived from pure function chains */
|
|
58
|
+
InputTraceType["Pure"] = "pure";
|
|
59
|
+
/** Derived from known but not necessarily all pure function chains */
|
|
60
|
+
InputTraceType["Known"] = "known";
|
|
61
|
+
/** Not fully known origin */
|
|
62
|
+
InputTraceType["Unknown"] = "unknown";
|
|
63
|
+
})(InputTraceType || (exports.InputTraceType = InputTraceType = {}));
|
|
64
|
+
//# sourceMappingURL=input-types.js.map
|