@eagleoutice/flowr 2.13.2 → 2.13.3
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 +46 -44
- package/abstract-interpretation/data-frame/mappers/access-mapper.js +1 -0
- 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/domains/state-domain-like.d.ts +1 -1
- package/config.d.ts +8 -0
- package/config.js +9 -1
- package/control-flow/control-flow-graph.js +2 -1
- package/control-flow/semantic-cfg-guided-visitor.d.ts +1 -1
- package/core/steps/all/core/11-normalize-tree-sitter.d.ts +1 -1
- package/dataflow/environments/append.d.ts +1 -1
- package/dataflow/environments/clone.d.ts +1 -1
- package/dataflow/environments/environment.d.ts +28 -4
- package/dataflow/environments/environment.js +66 -11
- package/dataflow/environments/overwrite.d.ts +1 -1
- package/dataflow/eval/resolve/alias-tracking.d.ts +1 -1
- package/dataflow/graph/dataflowgraph-builder.d.ts +1 -1
- 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-attach.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +7 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +51 -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 +1 -1
- 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-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 +1 -1
- 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-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 +7 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +9 -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 +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-vector.d.ts +1 -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/dataframe-access-validation.d.ts +1 -1
- package/linter/rules/undefined-symbol-util.js +3 -1
- package/linter/rules/undefined-symbol.js +3 -4
- 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/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/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 +13 -0
- package/queries/catalog/input-sources-query/input-source-functions.js +96 -1
- package/queries/catalog/input-sources-query/input-sources-query-executor.js +40 -4
- package/queries/catalog/input-sources-query/input-sources-query-format.js +21 -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 +62 -52
- package/queries/catalog/input-sources-query/simple-input-classifier.js +334 -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/lang-4.x/ast/parser/json/format.js +1 -1
- package/r-bridge/retriever.d.ts +1 -1
- package/search/flowr-search-printer.js +10 -8
- package/slicing/static/static-slicer.d.ts +2 -2
- 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
|
@@ -6,6 +6,7 @@ exports.resolveArgToEnvir = resolveArgToEnvir;
|
|
|
6
6
|
exports.resolveEnvirArg = resolveEnvirArg;
|
|
7
7
|
exports.resolveSymbolToEnvir = resolveSymbolToEnvir;
|
|
8
8
|
exports.routeWrittenToCustomEnv = routeWrittenToCustomEnv;
|
|
9
|
+
exports.resolveAttachPosition = resolveAttachPosition;
|
|
9
10
|
const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
10
11
|
const type_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/type");
|
|
11
12
|
const unpack_argument_1 = require("../argument/unpack-argument");
|
|
@@ -13,8 +14,12 @@ const decode_1 = require("../../../../../../project/sigdb/decode");
|
|
|
13
14
|
const resolve_by_name_1 = require("../../../../../environments/resolve-by-name");
|
|
14
15
|
const identifier_1 = require("../../../../../environments/identifier");
|
|
15
16
|
const define_1 = require("../../../../../environments/define");
|
|
17
|
+
const environment_1 = require("../../../../../environments/environment");
|
|
16
18
|
const prefix_1 = require("../../../../../../util/prefix");
|
|
17
19
|
const built_in_stack_env_1 = require("./built-in-stack-env");
|
|
20
|
+
const alias_tracking_1 = require("../../../../../eval/resolve/alias-tracking");
|
|
21
|
+
const general_1 = require("../../../../../eval/values/general");
|
|
22
|
+
const logger_1 = require("../../../../../logger");
|
|
18
23
|
/** A tracked env is a real stack environment (not a private custom env) when its current layer is the global or the built-in/base env. */
|
|
19
24
|
function isStackEnvState(envState) {
|
|
20
25
|
return envState.current.globalEnv === true || envState.current.builtInEnv === true;
|
|
@@ -142,4 +147,50 @@ function routeWrittenToCustomEnv(result, envDef, newDefAt, definedAt) {
|
|
|
142
147
|
const newEnvironment = (0, define_1.define)({ ...envDef, definedAt: newDefAt, envState: newEnvState }, false, { current: result.environment.current.removeAll(namesToRemove), level: result.environment.level });
|
|
143
148
|
return { ...result, environment: newEnvironment };
|
|
144
149
|
}
|
|
150
|
+
/** A `search()` position must be an integer and may never displace the global environment (R rejects `pos = 1`). */
|
|
151
|
+
function clampAttachPosition(pos) {
|
|
152
|
+
return Number.isFinite(pos) ? Math.max(environment_1.DefaultAttachPosition, Math.trunc(pos)) : undefined;
|
|
153
|
+
}
|
|
154
|
+
/** The number a value denotes, directly or as the single point of an interval (how a numeric literal resolves). */
|
|
155
|
+
function scalarNumber(value) {
|
|
156
|
+
if (value.type === 'number') {
|
|
157
|
+
return 'num' in value.value ? value.value.num : undefined;
|
|
158
|
+
}
|
|
159
|
+
if (value.type === 'interval' && value.startInclusive && value.endInclusive
|
|
160
|
+
&& value.start.type === 'number' && 'num' in value.start.value
|
|
161
|
+
&& value.end.type === 'number' && 'num' in value.end.value
|
|
162
|
+
&& value.start.value.num === value.end.value.num) {
|
|
163
|
+
return value.start.value.num;
|
|
164
|
+
}
|
|
165
|
+
return undefined;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* The `search()` position the `pos` argument of a `library()` call requests, either given as a number or as the name of
|
|
169
|
+
* an existing entry (`pos = "package:base"`). Returns `undefined` when there is no such argument, its value is unknown
|
|
170
|
+
* or ambiguous, or it names an entry that is not on the search path; callers then attach at {@link DefaultAttachPosition}
|
|
171
|
+
* (as R does, which warns in the last case).
|
|
172
|
+
*/
|
|
173
|
+
function resolveAttachPosition(posId, data) {
|
|
174
|
+
if (posId === undefined) {
|
|
175
|
+
return undefined;
|
|
176
|
+
}
|
|
177
|
+
const values = (0, general_1.valueSetGuard)((0, alias_tracking_1.resolveIdToValue)(posId, { environment: data.environment, idMap: data.completeAst.idMap, resolve: data.ctx.config.solver.variables, ctx: data.ctx }));
|
|
178
|
+
if (values?.type !== 'set' || values.elements.length !== 1) {
|
|
179
|
+
return undefined;
|
|
180
|
+
}
|
|
181
|
+
const element = values.elements[0];
|
|
182
|
+
const asNumber = scalarNumber(element);
|
|
183
|
+
if (asNumber !== undefined) {
|
|
184
|
+
return clampAttachPosition(asNumber);
|
|
185
|
+
}
|
|
186
|
+
if (element.type === 'string' && 'str' in element.value) {
|
|
187
|
+
const found = environment_1.REnvironment.searchPosition(data.environment.current, element.value.str);
|
|
188
|
+
if (found === undefined) {
|
|
189
|
+
logger_1.dataflowLogger.warn(`search-path entry '${element.value.str}' does not exist, attaching at the default position`);
|
|
190
|
+
return undefined;
|
|
191
|
+
}
|
|
192
|
+
return clampAttachPosition(found);
|
|
193
|
+
}
|
|
194
|
+
return undefined;
|
|
195
|
+
}
|
|
145
196
|
//# sourceMappingURL=built-in-envir-utils.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { DataflowProcessorInformation } from '../../../../../processor';
|
|
2
2
|
import { DataflowInformation } from '../../../../../info';
|
|
3
3
|
import { type ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
4
4
|
import { type PotentiallyEmptyRArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
@@ -57,7 +57,7 @@ function linkReadNameToWriteIfPossible(read, environments, listEnvironments, rem
|
|
|
57
57
|
tag: vertex_1.VertexType.Value,
|
|
58
58
|
id: tid,
|
|
59
59
|
cds: undefined,
|
|
60
|
-
value: (0, general_1.valueFromTsValue)(target.value)
|
|
60
|
+
value: (0, general_1.valueFromTsValue)((target).value)
|
|
61
61
|
}, environments, false);
|
|
62
62
|
}
|
|
63
63
|
}
|
|
@@ -5,7 +5,7 @@ import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/node
|
|
|
5
5
|
import { type PotentiallyEmptyRArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
6
6
|
import { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
7
7
|
import { DataflowGraph } from '../../../../../graph/graph';
|
|
8
|
-
import {
|
|
8
|
+
import type { REnvironmentInformation } from '../../../../../environments/environment';
|
|
9
9
|
import type { ReadOnlyFlowrAnalyzerContext, FlowrAnalyzerContext } from '../../../../../../project/context/flowr-analyzer-context';
|
|
10
10
|
/**
|
|
11
11
|
* Process a function definition, i.e., `function(a, b) { ... }`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { DataflowProcessorInformation } from '../../../../../processor';
|
|
2
2
|
import type { DataflowInformation, ControlDependency } from '../../../../../info';
|
|
3
3
|
import type { DataflowGraph } from '../../../../../graph/graph';
|
|
4
4
|
import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
@@ -28,6 +28,8 @@ interface AttachSpec {
|
|
|
28
28
|
readonly exclude?: ReadonlySet<string>;
|
|
29
29
|
/** attach every export (`import::from` `.all`, `box::use(pkg[...])`) */
|
|
30
30
|
readonly all?: boolean;
|
|
31
|
+
/** `library(pkg, pos = 3)`: the `search()` position to attach at, {@link DefaultAttachPosition} if unset */
|
|
32
|
+
readonly pos?: number;
|
|
31
33
|
}
|
|
32
34
|
/**
|
|
33
35
|
* Process a library call like `library` or `require`
|
|
@@ -41,7 +43,8 @@ export declare function attachExportVertex(graph: DataflowGraph, builtInId: Node
|
|
|
41
43
|
*/
|
|
42
44
|
export declare function loadNodesForNamespace(env: REnvironmentInformation, pack: string): NodeId[];
|
|
43
45
|
/**
|
|
44
|
-
* Attaches `dependency`'s exports
|
|
46
|
+
* Attaches `dependency`'s exports at `spec`'s {@link AttachSpec#pos|search position} (below the global environment by
|
|
47
|
+
* default, see {@link REnvironment.attachAt|attachPackageAt}) and returns the
|
|
45
48
|
* enriched environment (the graph is untouched). Used by `library()`, `import::from`, `box::use`, `requireNamespace`,
|
|
46
49
|
* and the transitive side-effect propagation.
|
|
47
50
|
*/
|
|
@@ -30,6 +30,7 @@ const common_1 = require("../common");
|
|
|
30
30
|
const linker_1 = require("../../../../linker");
|
|
31
31
|
const vertex_1 = require("../../../../../graph/vertex");
|
|
32
32
|
const r_base_packages_1 = require("../../../../../../util/r-base-packages");
|
|
33
|
+
const built_in_envir_utils_1 = require("./built-in-envir-utils");
|
|
33
34
|
/**
|
|
34
35
|
* Process a library call like `library` or `require`
|
|
35
36
|
*/
|
|
@@ -42,15 +43,19 @@ function processLibrary(name, args, rootId, data, config = {}) {
|
|
|
42
43
|
return processUse(name, args, rootId, data);
|
|
43
44
|
}
|
|
44
45
|
/* parse the import selection before the library flow rewrites `args` below */
|
|
45
|
-
const
|
|
46
|
+
const parsedSpec = config.fromImports ? parseFromSpec(args) : { namespaceOnly: config.namespaceOnly };
|
|
46
47
|
const params = {
|
|
47
48
|
'package': 'pkg',
|
|
48
|
-
'character.only': 'char'
|
|
49
|
+
'character.only': 'char',
|
|
50
|
+
/* last, so the positional fallback keeps its previous order */
|
|
51
|
+
'pos': 'pos'
|
|
49
52
|
};
|
|
50
53
|
const resolveArgs = { environment: data.environment, idMap: data.completeAst.idMap, resolve: data.ctx.config.solver.variables, ctx: data.ctx };
|
|
51
54
|
const argMaps = (0, linker_1.pMatch)((0, common_1.convertFnArguments)(args), params);
|
|
52
55
|
const packageId = Array.from(new Set(argMaps.get('pkg')));
|
|
53
56
|
const charId = Array.from(new Set(argMaps.get('char')));
|
|
57
|
+
/* `import::from` has no `pos`; its extra arguments name exports */
|
|
58
|
+
const spec = { ...parsedSpec, pos: config.fromImports ? undefined : (0, built_in_envir_utils_1.resolveAttachPosition)(argMaps.get('pos')?.[0], data) };
|
|
54
59
|
let namesToLoad = packageId.map(v => r_argument_1.RArgument.getValue(args, v));
|
|
55
60
|
//check if library name provided
|
|
56
61
|
namesToLoad = namesToLoad.filter(v => v !== undefined && (v.type === type_1.RType.Symbol || v.type === type_1.RType.String));
|
|
@@ -160,7 +165,7 @@ function processLibrary(name, args, rootId, data, config = {}) {
|
|
|
160
165
|
// `p::fn` can still link back to this call. requireNamespace/loadNamespace are recorded too, since
|
|
161
166
|
// they equally make `p::fn` valid.
|
|
162
167
|
if (info.environment.level >= 0) {
|
|
163
|
-
info.environment = recordUnresolvedLibraryLoad(info.environment, p, rootId, data.cds);
|
|
168
|
+
info.environment = recordUnresolvedLibraryLoad(info.environment, p, rootId, spec.pos, data.cds);
|
|
164
169
|
}
|
|
165
170
|
}
|
|
166
171
|
}
|
|
@@ -311,7 +316,7 @@ const libraryLoadMarker = ' library-load';
|
|
|
311
316
|
* `definedAt` is the load call. This lets an explicit `pack::fn` link back via {@link loadNodesForNamespace}
|
|
312
317
|
* even without a signature database.
|
|
313
318
|
*/
|
|
314
|
-
function recordUnresolvedLibraryLoad(envInfo, pack, rootId, cds) {
|
|
319
|
+
function recordUnresolvedLibraryLoad(envInfo, pack, rootId, pos, cds) {
|
|
315
320
|
const layer = new environment_1.Environment(envInfo.current).asLibrary(pack, environment_1.EnvType.LoadedNamespace).define({
|
|
316
321
|
name: identifier_1.Identifier.make(libraryLoadMarker, pack),
|
|
317
322
|
type: identifier_1.ReferenceType.Function,
|
|
@@ -319,7 +324,7 @@ function recordUnresolvedLibraryLoad(envInfo, pack, rootId, cds) {
|
|
|
319
324
|
definedAt: rootId,
|
|
320
325
|
cds: cds?.slice()
|
|
321
326
|
});
|
|
322
|
-
return { level: envInfo.level, current: environment_1.REnvironment.
|
|
327
|
+
return { level: envInfo.level, current: environment_1.REnvironment.attachAt(envInfo.current, layer, layer, pos) };
|
|
323
328
|
}
|
|
324
329
|
/**
|
|
325
330
|
* The load calls (`library()`/`require()`) that brought package `pack` into scope without a database, collected from
|
|
@@ -382,7 +387,8 @@ function isSubsetAttach(spec) {
|
|
|
382
387
|
return spec.include !== undefined && !spec.all;
|
|
383
388
|
}
|
|
384
389
|
/**
|
|
385
|
-
* Attaches `dependency`'s exports
|
|
390
|
+
* Attaches `dependency`'s exports at `spec`'s {@link AttachSpec#pos|search position} (below the global environment by
|
|
391
|
+
* default, see {@link REnvironment.attachAt|attachPackageAt}) and returns the
|
|
386
392
|
* enriched environment (the graph is untouched). Used by `library()`, `import::from`, `box::use`, `requireNamespace`,
|
|
387
393
|
* and the transitive side-effect propagation.
|
|
388
394
|
*/
|
|
@@ -396,14 +402,14 @@ function attachDependencyToEnvironment(dependency, envInfo, ctx, spec = {}, defi
|
|
|
396
402
|
const layerType = spec.namespaceOnly ? environment_1.EnvType.LoadedNamespace : environment_1.EnvType.Namespace;
|
|
397
403
|
const layer = new environment_1.Environment(envInfo.current).asLibrary(pack, layerType)
|
|
398
404
|
.defineAll(exports.map(exp => exportDefinition(pack, exp, definedAt)));
|
|
399
|
-
return { level: envInfo.level, current: environment_1.REnvironment.
|
|
405
|
+
return { level: envInfo.level, current: environment_1.REnvironment.attachAt(envInfo.current, layer, layer, spec.pos) };
|
|
400
406
|
}
|
|
401
407
|
// full attach: imports layer at the bottom, namespace (exports) layer on top
|
|
402
408
|
let importsEnv = new environment_1.Environment(envInfo.current).asLibrary(pack, environment_1.EnvType.Imports);
|
|
403
409
|
importsEnv = recImports(importsEnv, dependency.namespaceInfo, ctx, new Set());
|
|
404
410
|
const namespaceEnv = new environment_1.Environment(importsEnv).asLibrary(pack, environment_1.EnvType.Namespace)
|
|
405
411
|
.defineAll(exports.map(exp => exportDefinition(pack, exp, definedAt)));
|
|
406
|
-
return { level: envInfo.level, current: environment_1.REnvironment.
|
|
412
|
+
return { level: envInfo.level, current: environment_1.REnvironment.attachAt(envInfo.current, namespaceEnv, importsEnv, spec.pos) };
|
|
407
413
|
}
|
|
408
414
|
/** A namespace-only load is subsumed by any layer for `pack`; a full attach ignores a mere {@link EnvType.LoadedNamespace}. */
|
|
409
415
|
function blocksAttach(layer, namespaceOnly) {
|
|
@@ -513,7 +519,7 @@ function attachProjectImports(env, ctx) {
|
|
|
513
519
|
return env;
|
|
514
520
|
}
|
|
515
521
|
const layer = new environment_1.Environment(env.current).asLibrary(layerNamespace, environment_1.EnvType.Imports).defineAll(toDefine);
|
|
516
|
-
return { level: env.level, current: environment_1.REnvironment.
|
|
522
|
+
return { level: env.level, current: environment_1.REnvironment.attachAt(env.current, layer, layer) };
|
|
517
523
|
}
|
|
518
524
|
/** attach every project-level environment layer in order: base R namespaces, the project's own `importFrom` symbols, then its declared dependencies */
|
|
519
525
|
function attachProject(env, ctx) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { PotentiallyEmptyRArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
2
2
|
import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
|
|
3
3
|
import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
4
4
|
import type { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { DataflowProcessorInformation } from '../../../../../processor';
|
|
2
2
|
import type { DataflowInformation } from '../../../../../info';
|
|
3
3
|
import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
4
4
|
import type { PotentiallyEmptyRArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { DataflowProcessorInformation } from '../../../../../processor';
|
|
2
2
|
import type { DataflowInformation } from '../../../../../info';
|
|
3
3
|
import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
4
4
|
import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { DataflowProcessorInformation } from '../../../../../processor';
|
|
2
2
|
import type { DataflowInformation } from '../../../../../info';
|
|
3
3
|
import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
4
|
-
import {
|
|
4
|
+
import type { PotentiallyEmptyRArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
5
5
|
import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
|
|
6
6
|
import type { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
7
7
|
/** Used to separate S7 dispatch info in identifiers */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { DataflowProcessorInformation } from '../../../../../processor';
|
|
2
2
|
import type { DataflowInformation } from '../../../../../info';
|
|
3
3
|
import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
4
|
-
import {
|
|
4
|
+
import type { PotentiallyEmptyRArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
5
5
|
import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
|
|
6
6
|
import type { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
7
7
|
/** e.g. new_generic(name, dispatch_args, fun=NULL) */
|
|
@@ -25,4 +25,10 @@ export declare function processS7NewGeneric<OtherInfo>(name: RSymbol<OtherInfo &
|
|
|
25
25
|
export declare function processMakeConstructor<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, config?: {
|
|
26
26
|
readonly mode?: readonly ('s7' | 's3' | 's4')[];
|
|
27
27
|
}): DataflowInformation;
|
|
28
|
+
/**
|
|
29
|
+
* Node-id suffix of the `fun = function(...) S7_dispatch()` argument flowR synthesizes for S7 calls that do not
|
|
30
|
+
* carry one (`new_class`, `new_generic`, ...). It stands for no argument in the source, so consumers that reason
|
|
31
|
+
* about how the *code* calls a function (e.g. matching a call against a package's signature history) must skip it.
|
|
32
|
+
*/
|
|
33
|
+
export declare const S7SyntheticFunArgSuffix = "-s7-new-generic-fun-arg";
|
|
28
34
|
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.S7SyntheticFunArgSuffix = void 0;
|
|
3
4
|
exports.processS7NewGeneric = processS7NewGeneric;
|
|
4
5
|
exports.processMakeConstructor = processMakeConstructor;
|
|
5
6
|
const known_call_handling_1 = require("../known-call-handling");
|
|
@@ -88,6 +89,12 @@ function processMakeConstructor(name, args, rootId, data, config) {
|
|
|
88
89
|
}
|
|
89
90
|
return info;
|
|
90
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* Node-id suffix of the `fun = function(...) S7_dispatch()` argument flowR synthesizes for S7 calls that do not
|
|
94
|
+
* carry one (`new_class`, `new_generic`, ...). It stands for no argument in the source, so consumers that reason
|
|
95
|
+
* about how the *code* calls a function (e.g. matching a call against a package's signature history) must skip it.
|
|
96
|
+
*/
|
|
97
|
+
exports.S7SyntheticFunArgSuffix = '-s7-new-generic-fun-arg';
|
|
91
98
|
// 'function([dispatch_args],...) S7_dispatch()'; returns the value id
|
|
92
99
|
function makeS7DispatchFDef(name, names, rootId, args, idMap) {
|
|
93
100
|
const argNameId = rootId + '-s7-new-generic-fun-arg-name';
|
|
@@ -124,7 +131,7 @@ function makeS7DispatchFDef(name, names, rootId, args, idMap) {
|
|
|
124
131
|
index: 0
|
|
125
132
|
},
|
|
126
133
|
location: r,
|
|
127
|
-
content: identifier_1.Identifier.make('S7_dispatch', '
|
|
134
|
+
content: identifier_1.Identifier.make('S7_dispatch', 'S7'),
|
|
128
135
|
};
|
|
129
136
|
const funcBody = {
|
|
130
137
|
type: type_1.RType.FunctionCall,
|
|
@@ -205,7 +212,7 @@ function makeS7DispatchFDef(name, names, rootId, args, idMap) {
|
|
|
205
212
|
idMap.set(funcNameId, funcName);
|
|
206
213
|
idMap.set(funcBody.info.id, funcBody);
|
|
207
214
|
idMap.set(fdefId, argValue);
|
|
208
|
-
const argId = rootId +
|
|
215
|
+
const argId = rootId + exports.S7SyntheticFunArgSuffix;
|
|
209
216
|
const argument = {
|
|
210
217
|
type: type_1.RType.Argument,
|
|
211
218
|
lexeme: 'fun',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { DataflowProcessorInformation } from '../../../../../processor';
|
|
2
2
|
import { DataflowInformation } from '../../../../../info';
|
|
3
3
|
import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
4
|
-
import {
|
|
4
|
+
import type { PotentiallyEmptyRArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
5
5
|
import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
|
|
6
6
|
import type { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
7
7
|
/** e.g. UseMethod(generic, object) */
|
|
@@ -73,8 +73,8 @@ function asSearchPathEnv(name, data) {
|
|
|
73
73
|
if (fixed !== undefined) {
|
|
74
74
|
return fixed;
|
|
75
75
|
}
|
|
76
|
-
if (name.startsWith(
|
|
77
|
-
const pkg = name.slice(
|
|
76
|
+
if (name.startsWith(environment_1.SearchPathPackagePrefix)) {
|
|
77
|
+
const pkg = name.slice(environment_1.SearchPathPackagePrefix.length);
|
|
78
78
|
for (let env = environment_1.REnvironment.findGlobal(data.environment.current).parent; env !== undefined && !env.builtInEnv; env = env.parent) {
|
|
79
79
|
if (env.n === pkg && env.t === environment_1.EnvType.Namespace) {
|
|
80
80
|
return { current: env, level: 0 };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { PotentiallyEmptyRArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
2
2
|
import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
|
|
3
3
|
import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
4
4
|
import type { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
@@ -147,6 +147,20 @@ available for ${ctx.linkPage('flowr:vscode', 'VSCode')}, ${ctx.linkPage('flowr:p
|
|
|
147
147
|
and ${ctx.linkPage('flowr:docker', 'Docker')}.
|
|
148
148
|
It offers a wide variety of features, for example:
|
|
149
149
|
|
|
150
|
+
* 📚 **dependency analysis**\\
|
|
151
|
+
Given your analysis project, flowR offers a plethora of so-called ${ctx.linkPage('wiki/Query API', 'queries')} to get more information about your code.
|
|
152
|
+
An important query is the ${(0, doc_query_1.linkToQueryOfName)('dependencies', 'dependencies query')}, which shows you the library your project needs,
|
|
153
|
+
the data files it reads, the scripts it sources, and the data it outputs.
|
|
154
|
+
Building on it, the ${(0, doc_query_1.linkToQueryOfName)('guess-dep-versions', 'guess dependency versions query')} narrows down the version range each
|
|
155
|
+
of these libraries has to have, by combining the constraints your project declares with the functions your code actually calls.
|
|
156
|
+
|
|
157
|
+
${(0, doc_general_1.prefixLines)((0, doc_structure_1.details)('Example: Dependency Analysis with flowR', `
|
|
158
|
+
The following showcases the dependency view of the ${ctx.linkPage('flowr:vscode', 'Visual Studio Code extension')}:
|
|
159
|
+
|
|
160
|
+

|
|
161
|
+
|
|
162
|
+
`), ' ')}
|
|
163
|
+
|
|
150
164
|
* 🐞 **code linting**\\
|
|
151
165
|
Analyze your R scripts for common issues and potential bugs (see the ${ctx.linkPage('wiki/Linter', 'wiki page')} for more information on the currently supported linters).
|
|
152
166
|
|
|
@@ -193,18 +207,6 @@ ${await (0, doc_repl_1.documentReplSession)(treeSitter, [{
|
|
|
193
207
|
|
|
194
208
|
`), ' ')}
|
|
195
209
|
|
|
196
|
-
* 📚 **dependency analysis**\\
|
|
197
|
-
Given your analysis project, flowR offers a plethora of so-called ${ctx.linkPage('wiki/Query API', 'queries')} to get more information about your code.
|
|
198
|
-
An important query is the ${(0, doc_query_1.linkToQueryOfName)('dependencies', 'dependencies query')}, which shows you the library your project needs,
|
|
199
|
-
the data files it reads, the scripts it sources, and the data it outputs.
|
|
200
|
-
|
|
201
|
-
${(0, doc_general_1.prefixLines)((0, doc_structure_1.details)('Example: Dependency Analysis with flowR', `
|
|
202
|
-
The following showcases the dependency view of the ${ctx.linkPage('flowr:vscode', 'Visual Studio Code extension')}:
|
|
203
|
-
|
|
204
|
-

|
|
205
|
-
|
|
206
|
-
`), ' ')}
|
|
207
|
-
|
|
208
210
|
* 🚀 **fast call-graph, data-, and control-flow graphs**\\
|
|
209
211
|
Within just [${'<i>' + (0, html_hover_over_1.textWithTooltip)((0, numbers_1.roundToDecimals)(await (0, doc_benchmarks_1.getLatestDfAnalysisTime)('"social-science" Benchmark Suite (tree-sitter)'), 1) + ' ms', 'This measurement is automatically fetched from the latest benchmark!') + '</i>'} (as of ${new Date(await (0, doc_benchmarks_1.getLastBenchmarkUpdate)()).toLocaleDateString('en-US', dateOptions)})](${doc_files_1.FlowrSiteBaseRef}/wiki/stats/benchmark),
|
|
210
212
|
_flowR_ can analyze the data- and control-flow of the average real-world R script. See the ${ctx.linkPage('flowr:benchmarks', 'benchmarks')} for more information,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ParentInformation, RNodeWithParent } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
2
2
|
import type { KnownParser } from '../../r-bridge/parser';
|
|
3
3
|
import type { GeneralDocContext } from '../wiki-mk/doc-context';
|
|
4
4
|
import type { RProject } from '../../r-bridge/lang-4.x/ast/model/nodes/r-project';
|
|
@@ -1000,30 +1000,10 @@ Additionally, we get the information that the node with the id 2 was responsible
|
|
|
1000
1000
|
Calling \`library(pkg)\` (or \`require\`) attaches a package to the search path.
|
|
1001
1001
|
Mirroring R's \`search()\`, _flowR_ inserts the package's namespace and imports environments *below* the global environment (\`.GlobalEnv\`), so resolution walks **current scope -> enclosing scopes -> global -> attached packages -> built-ins**.
|
|
1002
1002
|
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
library(stats) # stats also exports filter()
|
|
1008
|
-
filter(1) # -> resolves to YOUR filter, not stats::filter
|
|
1009
|
-
\`\`\`
|
|
1010
|
-
|
|
1011
|
-
**Most recently attached is nearest, and re-attaching is a no-op:**
|
|
1012
|
-
|
|
1013
|
-
\`\`\`r
|
|
1014
|
-
library(A) # search path (top-down): A
|
|
1015
|
-
library(B) # B, A
|
|
1016
|
-
library(A) # no-op B, A (A is not moved or duplicated)
|
|
1017
|
-
\`\`\`
|
|
1018
|
-
|
|
1019
|
-
**Attaching inside a function propagates to the caller** (R attaches globally), and across branches every possibly-attached package is kept (a sound over-approximation of R's single runtime path):
|
|
1020
|
-
|
|
1021
|
-
\`\`\`r
|
|
1022
|
-
f <- function() library(A) # attaches A when called
|
|
1023
|
-
f()
|
|
1024
|
-
someExportOfA() # -> resolves against A
|
|
1025
|
-
if (cond) library(B) # B is kept (may be attached)
|
|
1026
|
-
\`\`\`
|
|
1003
|
+
A global binding shadows a package export of the same name, exactly as in R.
|
|
1004
|
+
The most recently attached package is the nearest one, and re-attaching neither moves nor duplicates it.
|
|
1005
|
+
The \`pos\` argument attaches further down the search path instead, given either as a position or as the name of an existing entry (an unknown position or name falls back to the default of 2, directly below the global environment).
|
|
1006
|
+
Attaching inside a function propagates to the caller (R attaches globally), and across branches every possibly-attached package is kept (a sound over-approximation of R's single runtime path).
|
|
1027
1007
|
|
|
1028
1008
|
Last but not least, the information contains the single **entry point** (${JSON.stringify(result.entryPoint)}) and a set of **exit points** (${JSON.stringify(result.exitPoints.map(e => e.nodeId))}).
|
|
1029
1009
|
Besides marking potential exits, the exit points also provide information about why the exit occurs and which control dependencies affect the exit.
|
|
@@ -640,6 +640,11 @@ f <- function(x) {
|
|
|
640
640
|
print(x)
|
|
641
641
|
}`.trim();
|
|
642
642
|
const criterion = '3@print';
|
|
643
|
+
const shinyCode = `
|
|
644
|
+
server <- function(input, output, session) {
|
|
645
|
+
system(paste("convert", input$file))
|
|
646
|
+
}`.trim();
|
|
647
|
+
const shinyCriterion = '2@system';
|
|
643
648
|
return `
|
|
644
649
|
Given a [slicing criterion](${doc_files_1.FlowrWikiBaseRef}/Terminology#slicing-criterion) to
|
|
645
650
|
something like a function call, flowR classifies the types of all input sources (e.g., arguments).
|
|
@@ -652,6 +657,37 @@ ${await (0, doc_query_1.showQuery)(shell, exampleCode, [{
|
|
|
652
657
|
type: 'input-sources',
|
|
653
658
|
criterion
|
|
654
659
|
}], { showCode: false, shorthand: (0, doc_query_1.sliceQueryShorthand)([criterion], (0, doc_escape_1.escapeNewline)(exampleCode)), ctx })}
|
|
660
|
+
|
|
661
|
+
Some objects are handed to the code by a framework rather than defined in it, like the \`input\` of a shiny
|
|
662
|
+
server function. The ${ctx.link('InputClassifierConfig::linkedObjects')} configuration lists them, so that reads
|
|
663
|
+
of such an object (and of its fields) classify as user input instead of stopping at a ${ctx.link('InputType::Parameter')}:
|
|
664
|
+
${(0, doc_code_1.codeBlock)('r', shinyCode)}
|
|
665
|
+
|
|
666
|
+
${await (0, doc_query_1.showQuery)(shell, shinyCode, [{
|
|
667
|
+
type: 'input-sources',
|
|
668
|
+
criterion: shinyCriterion
|
|
669
|
+
}], { showCode: false, shorthand: (0, doc_query_1.sliceQueryShorthand)([shinyCriterion], (0, doc_escape_1.escapeNewline)(shinyCode)), ctx })}
|
|
670
|
+
|
|
671
|
+
Every ${ctx.link('LinkedInputObject')} names the object, the ${ctx.link('InputType')} to use for it, and optionally
|
|
672
|
+
the parameters the binding function has to declare as well (${ctx.link('LinkedInputObject::withParams')}) - shiny's
|
|
673
|
+
\`input\` only counts as such if the function also takes an \`output\`, so that an ordinary function with a
|
|
674
|
+
parameter named \`input\` is left alone. Where the framework is handed the function instead of the code naming it,
|
|
675
|
+
a ${ctx.link('LinkedInputEntryPoint')} is exact: it says which object goes to which parameter *by position*, just
|
|
676
|
+
like R does, so \`shinyApp(ui, function(i, o, s))\` works no matter what those parameters are called.
|
|
677
|
+
With ${ctx.link('LinkedInputObject::declaredBy')} a read even links back to its definition - the \`textInput("n", …)\`
|
|
678
|
+
behind an \`input$n\` shows up as ${ctx.link('InputSource::declaredAt')}.
|
|
679
|
+
|
|
680
|
+
You do not have to pass any of this per query: the ${ctx.linkConfig('inputSources', true)} section of flowR's
|
|
681
|
+
${ctx.linkPage('wiki/Interface', 'configuration file')} carries the same shape and is *added* to what flowR already
|
|
682
|
+
knows, so your framework joins shiny instead of replacing it (and \`specializeConfig\` can scope it to one
|
|
683
|
+
${ctx.link('ProjectKind')}). Functions may be written as plain \`fn\` or namespaced \`pkg::fn\` strings; a bare call
|
|
684
|
+
only counts as the namespaced one while that package is attached, exactly as R would resolve it.
|
|
685
|
+
|
|
686
|
+
${(0, doc_code_1.codeBlock)('json', JSON.stringify({ inputSources: {
|
|
687
|
+
user: ['myframework::read_form'],
|
|
688
|
+
linkedObjects: [{ name: 'ctx', type: 'user', declaredBy: { calls: ['myframework::field'], argName: 'id', argIdx: 0 } }],
|
|
689
|
+
linkedEntryPoints: [{ call: 'myframework::serve', argName: 'handler', argIdx: 0, params: ['ctx', null] }]
|
|
690
|
+
} }, undefined, 2))}
|
|
655
691
|
`;
|
|
656
692
|
}
|
|
657
693
|
});
|
|
@@ -981,6 +1017,17 @@ The guess can be narrowed further:
|
|
|
981
1017
|
Packages can also be tied to one shared version (the base/R packages always are), and ${ctx.linkConfig('solver.versionManagement.linkedVersionGroups', true)}
|
|
982
1018
|
declares further groups. Such a package reports its partners in \`linkedWith\`, because its range is then no longer independent of theirs.
|
|
983
1019
|
|
|
1020
|
+
What one dependency requires of another (\`transitive\` evidence) is read from *every* version of it still in play:
|
|
1021
|
+
|
|
1022
|
+
* all of them require it: the guess is narrowed, by the weakest of their bounds,
|
|
1023
|
+
* only some do: the evidence carries \`partial: true\` and never narrows, as another version avoids it.
|
|
1024
|
+
|
|
1025
|
+
A partial requirement still ties the two together. \`A 0.2.5\` needing \`B 0.2.1\` and \`A 0.3.0\` needing \`B 0.3.2\`
|
|
1026
|
+
shrinks neither range, yet the versions are not free. Each package lists its \`coupledWith\` partners, and
|
|
1027
|
+
\`runnableCombinations\` counts the tuples those couplings admit, against the plain product \`possibleCombinations\`
|
|
1028
|
+
and, where the project declares constraints, against \`declaredCombinations\` (what those alone leave, so the share
|
|
1029
|
+
says how much the guess added).
|
|
1030
|
+
|
|
984
1031
|
${(0, doc_structure_1.block)({
|
|
985
1032
|
type: 'NOTE',
|
|
986
1033
|
content: `This query needs the ${ctx.linkPage('wiki/Signature Database', 'signature database')}, and specifically a database carrying the _history_ of a package,
|
|
@@ -139,7 +139,7 @@ function measureLoad(file) {
|
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
/**
|
|
142
|
-
* A table of the databases the default bundle actually ships, read
|
|
142
|
+
* A table of the databases the default bundle actually ships, read at generation time, never hardcoded,
|
|
143
143
|
* from the manifests. Each shard becomes a row (contents, retained history, package and version counts, its
|
|
144
144
|
* on-disk size, and the measured cost of decompressing it on first touch). Every bundled manifest is unioned
|
|
145
145
|
* (deduped by shard/dictionary id), so the separate `history` manifest's shards show up alongside `current`,
|
|
@@ -234,10 +234,11 @@ Every function is a ${ctx.link('DecodedFunction')}:
|
|
|
234
234
|
|
|
235
235
|
Per version the source also answers declared dependencies (${ctx.link('ResolvedDependency')}), release dates, the plain export view (${ctx.link('LibraryExports')}), and the versions it carries (${ctx.link('AvailableVersion')}).
|
|
236
236
|
|
|
237
|
-
Beyond the flags above, ${ctx.link('DecodedFunction::props')} also carry ${ctx.linkE('FnProp', 'NoDoc')} (a documented package has no help page for this name), ${ctx.linkE('FnProp', 'S3Method')} (a registered S3 method, from the package NAMESPACE or base R's method table), and ${ctx.linkE('FnProp', 'S3Owner')} (an exported constructor for an S3 class this package OWNS: it also registers at least one S3 method for that class). The owned classes of a version are ${ctx.link('LibraryExports::s3Classes')}, and ${ctx.linkM(reader_1.SigDatabase, 'classOwner')} answers, for a class name, which package owns it (backed by a reverse index built once). This lets ${ctx.linkPage('wiki/Query API', 'version guessing')} mark a package used when the analyzed project's own NAMESPACE registers an S3 method for a class it owns, even with no direct call
|
|
237
|
+
Beyond the flags above, ${ctx.link('DecodedFunction::props')} also carry ${ctx.linkE('FnProp', 'NoDoc')} (a documented package has no help page for this name), ${ctx.linkE('FnProp', 'S3Method')} (a registered S3 method, from the package NAMESPACE or base R's method table), and ${ctx.linkE('FnProp', 'S3Owner')} (an exported constructor for an S3 class this package OWNS: it also registers at least one S3 method for that class). The owned classes of a version are ${ctx.link('LibraryExports::s3Classes')}, and ${ctx.linkM(reader_1.SigDatabase, 'classOwner')} answers, for a class name, which package owns it (backed by a reverse index built once). This lets ${ctx.linkPage('wiki/Query API', 'version guessing')} mark a package used when the analyzed project's own NAMESPACE registers an S3 method for a class it owns, even with no direct call, e.g. tseries's \`S3method("as.irts","zoo")\` marks \`zoo\` used.
|
|
238
238
|
|
|
239
239
|
These are derived on demand by the ${ctx.linkPage('wiki/Query API', 'signature query')}, not stored:
|
|
240
240
|
- the rdrr.io documentation link ${ctx.link('SignatureFunctionView::docUrl')} (base R \`/r/<pkg>/<topic>\`, CRAN \`/cran/<pkg>/man/<topic>\`), omitted for a ${ctx.linkE('FnProp', 'NoDoc')} function
|
|
241
|
+
- ${ctx.link('SignatureFunctionView::sourceUrl')} and ${ctx.link('SignatureFunctionView::manUrl')}: the definition and its \`.Rd\` help page at the queried version, on \`github.com/cran/<pkg>\` (CRAN) or \`github.com/wch/r-source\` (base R)
|
|
241
242
|
- the S3 method to generic backlink ${ctx.link('SignatureFunctionView::s3method')}, for a ${ctx.linkE('FnProp', 'S3Method')} function, resolving its generic
|
|
242
243
|
- the transitive call graph ${ctx.linkM(reader_1.SigDatabase, 'transitiveCallees')}, expanding the stored local callees inside one version
|
|
243
244
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
2
2
|
import type { FlowrSearchElements } from '../../search/flowr-search';
|
|
3
|
-
import {
|
|
3
|
+
import type { MergeableRecord } from '../../util/objects';
|
|
4
4
|
import { LintingRuleCertainty, type LintingResult } from '../linter-format';
|
|
5
5
|
import { LintingRuleTag } from '../linter-tags';
|
|
6
6
|
export interface DataFrameAccessValidationResult extends LintingResult {
|
|
@@ -117,7 +117,9 @@ function collectScopeDefinedNames(graph) {
|
|
|
117
117
|
if (!unconditional) {
|
|
118
118
|
continue;
|
|
119
119
|
}
|
|
120
|
-
|
|
120
|
+
const names = byScope.get(scope) ?? new Set();
|
|
121
|
+
names.add(name);
|
|
122
|
+
byScope.set(scope, names);
|
|
121
123
|
}
|
|
122
124
|
return byScope;
|
|
123
125
|
}
|
|
@@ -18,13 +18,12 @@ const undefined_symbol_util_1 = require("./undefined-symbol-util");
|
|
|
18
18
|
/** calls that load a package; an unresolved one means we cannot enumerate all exports in scope */
|
|
19
19
|
const LibraryLoadFunctions = new Set(['library', 'require', 'requireNamespace', 'loadNamespace', 'attachNamespace', 'load_all', 'use', 'p_load']);
|
|
20
20
|
// standard packages attached by default; exports are in scope without library()
|
|
21
|
-
const AttachedBasePackages = ['base', 'stats', 'graphics', 'grDevices', 'utils', 'datasets', 'methods'];
|
|
22
21
|
/** test frameworks whose namespace a test file runs under implicitly (e.g. `tests/testthat/test-*.R` sees testthat's exports without a `library()`) */
|
|
23
22
|
const ImplicitTestFrameworks = new Set(['testthat', 'tinytest', 'RUnit']);
|
|
24
23
|
/** whether name is an export of a default-attached base package (needs no library()) */
|
|
25
24
|
function isAttachedBaseName(name) {
|
|
26
25
|
const owner = (0, r_base_packages_1.baseRExportOwner)(name);
|
|
27
|
-
return owner !== undefined && AttachedBasePackages.includes(owner);
|
|
26
|
+
return owner !== undefined && r_base_packages_1.AttachedBasePackages.includes(owner);
|
|
28
27
|
}
|
|
29
28
|
/** upper bound on the number of packages named in a "did you forget to load it" hint */
|
|
30
29
|
const MaxHintPackages = 5;
|
|
@@ -74,10 +73,10 @@ exports.UNDEFINED_SYMBOL = {
|
|
|
74
73
|
// packages, each resolved (exports enriched) from the package database via getDependency
|
|
75
74
|
const loadedPackages = [
|
|
76
75
|
...deps.getDependencies().map(p => deps.getDependency(p.name) ?? p),
|
|
77
|
-
...AttachedBasePackages.map(n => deps.getDependency(n)).filter(assert_1.isNotUndefined)
|
|
76
|
+
...r_base_packages_1.AttachedBasePackages.map(n => deps.getDependency(n)).filter(assert_1.isNotUndefined)
|
|
78
77
|
];
|
|
79
78
|
// hint an unloaded package that exports `name` (e.g. `ggplot` -> `ggplot2`), from the package database
|
|
80
|
-
const attached = new Set(AttachedBasePackages);
|
|
79
|
+
const attached = new Set(r_base_packages_1.AttachedBasePackages);
|
|
81
80
|
const hintPackagesFor = (name) => deps.packagesExporting(name).filter(p => !attached.has(p)).slice(0, MaxHintPackages);
|
|
82
81
|
const results = elements.getElements().map(element => {
|
|
83
82
|
const id = element.node.info.id;
|