@eagleoutice/flowr 2.13.4 → 2.13.6
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 +29 -29
- package/cli/repl/core.js +10 -2
- package/config.d.ts +4 -1
- package/config.js +10 -1
- package/control-flow/cfg-dead-code.js +19 -4
- package/control-flow/extract-cfg.js +12 -4
- package/dataflow/environments/built-in-config.d.ts +6 -3
- package/dataflow/environments/built-in-eval-name.d.ts +20 -0
- package/dataflow/environments/built-in-eval-name.js +25 -0
- package/dataflow/environments/built-in-props.d.ts +175 -0
- package/dataflow/environments/built-in-props.js +207 -0
- package/dataflow/environments/built-in.d.ts +26 -22
- package/dataflow/environments/built-in.js +37 -10
- package/dataflow/environments/default-builtin-config.d.ts +1068 -95
- package/dataflow/environments/default-builtin-config.js +549 -216
- package/dataflow/environments/identifier.d.ts +24 -1
- package/dataflow/environments/identifier.js +24 -2
- package/dataflow/environments/query-fn-props.d.ts +102 -0
- package/dataflow/environments/query-fn-props.js +188 -0
- package/dataflow/eval/resolve/alias-tracking.d.ts +6 -5
- package/dataflow/eval/resolve/alias-tracking.js +45 -12
- package/dataflow/eval/resolve/match-arguments.d.ts +15 -0
- package/dataflow/eval/resolve/match-arguments.js +77 -0
- package/dataflow/eval/resolve/resolve-numbers.d.ts +202 -0
- package/dataflow/eval/resolve/resolve-numbers.js +163 -0
- package/dataflow/eval/resolve/resolve-operators.d.ts +60 -0
- package/dataflow/eval/resolve/resolve-operators.js +115 -0
- package/dataflow/eval/resolve/resolve-strings.d.ts +98 -0
- package/dataflow/eval/resolve/resolve-strings.js +116 -0
- package/dataflow/eval/resolve/resolve.d.ts +5 -37
- package/dataflow/eval/resolve/resolve.js +56 -134
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +5 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +1 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +1 -1
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +2 -1
- package/dataflow/internal/process/functions/call/known-call-handling.js +2 -1
- package/documentation/data/faq/faqs.js +11 -0
- package/documentation/doc-util/doc-types.js +1 -1
- package/documentation/wiki-analyzer.js +75 -0
- package/documentation/wiki-core.js +81 -16
- package/documentation/wiki-interface.js +3 -0
- package/linter/linter-rules.d.ts +10 -11
- package/linter/rules/deprecated-functions.js +5 -3
- package/linter/rules/function-finder-util.d.ts +2 -2
- package/linter/rules/function-finder-util.js +10 -3
- package/linter/rules/network-functions.d.ts +25 -5
- package/linter/rules/network-functions.js +51 -11
- package/linter/rules/problematic-inputs.d.ts +1 -1
- package/linter/rules/problematic-inputs.js +7 -1
- package/linter/rules/seeded-randomness.d.ts +5 -8
- package/linter/rules/seeded-randomness.js +18 -10
- package/linter/rules/unused-definition.js +29 -17
- package/package.json +4 -2
- package/project/cache/flowr-analyzer-cache.d.ts +4 -3
- package/project/cache/flowr-analyzer-cache.js +32 -13
- package/project/cache/flowr-cache.d.ts +39 -12
- package/project/cache/flowr-cache.js +5 -3
- package/project/context/flowr-analyzer-context.d.ts +8 -1
- package/project/context/flowr-analyzer-context.js +11 -1
- package/project/context/flowr-analyzer-dependencies-context.d.ts +8 -2
- package/project/context/flowr-analyzer-dependencies-context.js +43 -11
- package/project/context/flowr-analyzer-files-context.d.ts +8 -4
- package/project/context/flowr-analyzer-files-context.js +20 -1
- package/project/context/flowr-analyzer-incremental-analysis-context.d.ts +33 -0
- package/project/context/flowr-analyzer-incremental-analysis-context.js +63 -0
- package/project/context/flowr-analyzer-meta-context.d.ts +3 -1
- package/project/context/flowr-analyzer-meta-context.js +14 -0
- package/project/context/flowr-file.d.ts +25 -3
- package/project/context/flowr-file.js +24 -2
- package/project/dependency-version-space.d.ts +37 -0
- package/project/dependency-version-space.js +118 -26
- package/project/flowr-analyzer.d.ts +6 -0
- package/project/flowr-analyzer.js +6 -2
- package/project/incremental/incremental-parse/edit-computation.d.ts +7 -0
- package/project/incremental/incremental-parse/edit-computation.js +61 -0
- package/project/incremental/incremental-parse/incremental-parse.d.ts +12 -0
- package/project/incremental/incremental-parse/incremental-parse.js +37 -0
- package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +1 -1
- package/project/plugins/file-plugins/files/flowr-manifest-files.d.ts +57 -0
- package/project/plugins/file-plugins/files/flowr-manifest-files.js +121 -0
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +2 -2
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +2 -2
- package/project/plugins/file-plugins/files/flowr-sweave-file.d.ts +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.d.ts +33 -0
- package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.js +53 -0
- package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.js +3 -3
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-manifest-file-plugin.d.ts +27 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-manifest-file-plugin.js +47 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.d.ts +7 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +31 -3
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +10 -4
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +17 -4
- package/project/plugins/plugin-registry.d.ts +4 -4
- package/project/plugins/plugin-registry.js +7 -4
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +4 -4
- package/project/sigdb/reader.d.ts +7 -0
- package/project/sigdb/reader.js +12 -0
- package/queries/catalog/dependencies-query/function-info/derived-functions.d.ts +10 -0
- package/queries/catalog/dependencies-query/function-info/derived-functions.js +41 -0
- package/queries/catalog/dependencies-query/function-info/read-functions.js +13 -12
- package/queries/catalog/dependencies-query/function-info/write-functions.js +16 -23
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +33 -3
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +31 -0
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +9 -2
- package/queries/catalog/input-sources-query/input-source-functions.d.ts +8 -10
- package/queries/catalog/input-sources-query/input-source-functions.js +23 -388
- package/queries/catalog/input-sources-query/input-sources-query-format.d.ts +7 -0
- package/queries/catalog/input-sources-query/input-sources-query-format.js +27 -10
- package/queries/catalog/signature-query/signature-query-executor.d.ts +2 -1
- package/queries/catalog/signature-query/signature-query-executor.js +79 -3
- package/queries/catalog/signature-query/signature-query-format.d.ts +27 -0
- package/queries/catalog/signature-query/signature-query-render.js +21 -3
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.d.ts +6 -2
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +21 -2
- package/r-bridge/parser.d.ts +11 -1
- package/r-bridge/parser.js +7 -4
- package/r-bridge/shell-executor.d.ts +1 -0
- package/r-bridge/shell-executor.js +1 -0
- package/r-bridge/shell.d.ts +1 -0
- package/r-bridge/shell.js +1 -0
- package/search/flowr-search-filters.d.ts +1 -6
- package/search/flowr-search-filters.js +1 -8
- package/search/search-executor/search-enrichers.d.ts +2 -0
- package/search/search-executor/search-enrichers.js +29 -12
- package/util/version.js +1 -1
- package/project/plugins/file-plugins/files/flowr-rproject-file.d.ts +0 -31
- package/project/plugins/file-plugins/files/flowr-rproject-file.js +0 -66
- package/project/plugins/file-plugins/flowr-analyzer-rproject-file-plugin.d.ts +0 -22
- package/project/plugins/file-plugins/flowr-analyzer-rproject-file-plugin.js +0 -36
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-rproject-file-plugin.d.ts +0 -13
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-rproject-file-plugin.js +0 -32
|
@@ -7,8 +7,10 @@ import { FlowrFile, type FlowrFileProvider, FileRole } from './flowr-file';
|
|
|
7
7
|
import type { FlowrDescriptionFile } from '../plugins/file-plugins/files/flowr-description-file';
|
|
8
8
|
import type { FlowrNewsFile } from '../plugins/file-plugins/files/flowr-news-file';
|
|
9
9
|
import type { FlowrNamespaceFile } from '../plugins/file-plugins/files/flowr-namespace-file';
|
|
10
|
-
import type {
|
|
10
|
+
import type { FlowrManifestFile } from '../plugins/file-plugins/files/flowr-manifest-files';
|
|
11
11
|
import type { ProjectKind } from './project-kind';
|
|
12
|
+
import type { FlowrAnalyzerContext } from './flowr-analyzer-context';
|
|
13
|
+
import type { InvalidationEvent, InvalidationEventReceiver } from '../cache/flowr-cache';
|
|
12
14
|
/**
|
|
13
15
|
* This is a request to process a folder as a project, which will be expanded by the registered {@link FlowrAnalyzerProjectDiscoveryPlugin}s.
|
|
14
16
|
*/
|
|
@@ -24,7 +26,7 @@ export type RoleBasedFiles = {
|
|
|
24
26
|
[FileRole.Description]: FlowrDescriptionFile[];
|
|
25
27
|
[FileRole.News]: FlowrNewsFile[];
|
|
26
28
|
[FileRole.Namespace]: FlowrNamespaceFile[];
|
|
27
|
-
[FileRole.Manifest]:
|
|
29
|
+
[FileRole.Manifest]: FlowrManifestFile[];
|
|
28
30
|
[FileRole.Vignette]: FlowrFileProvider[];
|
|
29
31
|
[FileRole.Test]: FlowrFileProvider[];
|
|
30
32
|
[FileRole.Install]: FlowrFileProvider[];
|
|
@@ -126,12 +128,13 @@ export interface ReadOnlyFlowrAnalyzerFilesContext {
|
|
|
126
128
|
* If you are interested in inspecting these files, refer to {@link ReadOnlyFlowrAnalyzerFilesContext}.
|
|
127
129
|
* Plugins, however, can use this context directly to modify files.
|
|
128
130
|
*/
|
|
129
|
-
export declare class FlowrAnalyzerFilesContext extends AbstractFlowrAnalyzerContext<RProjectAnalysisRequest, (RParseRequest | FlowrFile<string>)[], FlowrAnalyzerProjectDiscoveryPlugin> implements ReadOnlyFlowrAnalyzerFilesContext {
|
|
131
|
+
export declare class FlowrAnalyzerFilesContext extends AbstractFlowrAnalyzerContext<RProjectAnalysisRequest, (RParseRequest | FlowrFile<string>)[], FlowrAnalyzerProjectDiscoveryPlugin> implements ReadOnlyFlowrAnalyzerFilesContext, InvalidationEventReceiver {
|
|
130
132
|
readonly name = "flowr-analyzer-files-context";
|
|
131
133
|
readonly loadingOrder: FlowrAnalyzerLoadingOrderContext;
|
|
132
134
|
private files;
|
|
133
135
|
private inlineFiles;
|
|
134
136
|
private readonly fileLoaders;
|
|
137
|
+
private readonly context;
|
|
135
138
|
/** these are all the paths of files that have been considered by the dataflow graph (even if not added) */
|
|
136
139
|
private readonly consideredFiles;
|
|
137
140
|
/** User-registered project discovery plugins; if non-empty, they replace the default. */
|
|
@@ -145,12 +148,13 @@ export declare class FlowrAnalyzerFilesContext extends AbstractFlowrAnalyzerCont
|
|
|
145
148
|
/** cached {@link root}, fixed on first use as the ids built from it have to stay stable */
|
|
146
149
|
private rootCache;
|
|
147
150
|
private rootResolved;
|
|
148
|
-
constructor(loadingOrder: FlowrAnalyzerLoadingOrderContext, plugins: readonly FlowrAnalyzerProjectDiscoveryPlugin[], fileLoaders: readonly FlowrAnalyzerFilePlugin[]);
|
|
151
|
+
constructor(context: FlowrAnalyzerContext, loadingOrder: FlowrAnalyzerLoadingOrderContext, plugins: readonly FlowrAnalyzerProjectDiscoveryPlugin[], fileLoaders: readonly FlowrAnalyzerFilePlugin[]);
|
|
149
152
|
reset(): void;
|
|
150
153
|
/** The directory the analysis was asked about: a `project`'s folder, or the one holding the requested file(s). */
|
|
151
154
|
root(): string | undefined;
|
|
152
155
|
/** The path of `filePath` seen from the {@link root}, see {@link relativeTo}. */
|
|
153
156
|
relativePath(filePath: string): string;
|
|
157
|
+
receive(event: InvalidationEvent): void;
|
|
154
158
|
/**
|
|
155
159
|
* Record that a file has been considered during dataflow analysis.
|
|
156
160
|
*/
|
|
@@ -40,6 +40,7 @@ class FlowrAnalyzerFilesContext extends abstract_flowr_analyzer_context_1.Abstra
|
|
|
40
40
|
files = new Map();
|
|
41
41
|
inlineFiles = [];
|
|
42
42
|
fileLoaders;
|
|
43
|
+
context;
|
|
43
44
|
/** these are all the paths of files that have been considered by the dataflow graph (even if not added) */
|
|
44
45
|
consideredFiles = [];
|
|
45
46
|
/** User-registered project discovery plugins; if non-empty, they replace the default. */
|
|
@@ -54,9 +55,10 @@ class FlowrAnalyzerFilesContext extends abstract_flowr_analyzer_context_1.Abstra
|
|
|
54
55
|
/** cached {@link root}, fixed on first use as the ids built from it have to stay stable */
|
|
55
56
|
rootCache = undefined;
|
|
56
57
|
rootResolved = false;
|
|
57
|
-
constructor(loadingOrder, plugins, fileLoaders) {
|
|
58
|
+
constructor(context, loadingOrder, plugins, fileLoaders) {
|
|
58
59
|
super(loadingOrder.getAttachedContext(), flowr_analyzer_project_discovery_plugin_1.FlowrAnalyzerProjectDiscoveryPlugin.defaultPlugin(), []);
|
|
59
60
|
this.discoveryPlugins = plugins;
|
|
61
|
+
this.context = context;
|
|
60
62
|
this.fileLoaders = [...fileLoaders, flowr_analyzer_file_plugin_1.FlowrAnalyzerFilePlugin.defaultPlugin()];
|
|
61
63
|
this.loadingOrder = loadingOrder;
|
|
62
64
|
}
|
|
@@ -84,6 +86,20 @@ class FlowrAnalyzerFilesContext extends abstract_flowr_analyzer_context_1.Abstra
|
|
|
84
86
|
const root = this.root();
|
|
85
87
|
return root === undefined ? filePath : (0, files_1.relativeTo)(root, filePath);
|
|
86
88
|
}
|
|
89
|
+
receive(event) {
|
|
90
|
+
const type = event.type;
|
|
91
|
+
switch (type) {
|
|
92
|
+
case "full" /* InvalidationEventType.Full */:
|
|
93
|
+
this.reset();
|
|
94
|
+
break;
|
|
95
|
+
case "single-file-invalidate" /* InvalidationEventType.SingleFileInvalidate */:
|
|
96
|
+
// only the content of a known file changed, so the file set stays valid -> nothing to do.
|
|
97
|
+
// revisit once we add dedicated FileAdded / FileRemoved events.
|
|
98
|
+
break;
|
|
99
|
+
default:
|
|
100
|
+
(0, assert_1.assertUnreachable)(type);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
87
103
|
/**
|
|
88
104
|
* Record that a file has been considered during dataflow analysis.
|
|
89
105
|
*/
|
|
@@ -225,6 +241,9 @@ class FlowrAnalyzerFilesContext extends abstract_flowr_analyzer_context_1.Abstra
|
|
|
225
241
|
*/
|
|
226
242
|
addFile(file, roles) {
|
|
227
243
|
const f = this.fileLoadPlugins(wrapFile(file, roles));
|
|
244
|
+
f.addOnInvalidate(c => {
|
|
245
|
+
this.context.analyzer?.receive(c);
|
|
246
|
+
});
|
|
228
247
|
if (f.path() === flowr_file_1.FlowrFile.INLINE_PATH) {
|
|
229
248
|
this.inlineFiles.push(f);
|
|
230
249
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type Parser from 'web-tree-sitter';
|
|
2
|
+
import type { InvalidationEvent, InvalidationEventReceiver } from '../cache/flowr-cache';
|
|
3
|
+
import type { FlowrAnalyzerContext } from './flowr-analyzer-context';
|
|
4
|
+
import type { FilePath } from './flowr-file';
|
|
5
|
+
import type { ParseStepOutput } from '../../r-bridge/parser';
|
|
6
|
+
export interface ReadOnlyFlowrAnalyzerIncrementalAnalysisContext {
|
|
7
|
+
/**
|
|
8
|
+
* The name of this context.
|
|
9
|
+
*/
|
|
10
|
+
readonly name: string;
|
|
11
|
+
getOldParseResultOf(filePath: FilePath): Parser.Tree | undefined;
|
|
12
|
+
getOldContentOf(filePath: FilePath): string | undefined;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Information to carry over for future incremental builds
|
|
16
|
+
*/
|
|
17
|
+
export declare class FlowrAnalyzerIncrementalAnalysisContext implements ReadOnlyFlowrAnalyzerIncrementalAnalysisContext, InvalidationEventReceiver {
|
|
18
|
+
readonly name = "flowr-analyzer-incremental-analysis-context";
|
|
19
|
+
private readonly context;
|
|
20
|
+
/**
|
|
21
|
+
* The files that have been changed since the last analysis mapping to their old content.
|
|
22
|
+
*/
|
|
23
|
+
private changedFilesWithOldContent;
|
|
24
|
+
private oldParseResults;
|
|
25
|
+
constructor(context: FlowrAnalyzerContext);
|
|
26
|
+
reset(): void;
|
|
27
|
+
handleFileInvalidate(filePath: FilePath, oldContent: string | undefined): void;
|
|
28
|
+
receive(event: InvalidationEvent): void;
|
|
29
|
+
storeOldParseResults(parseStepOutput: ParseStepOutput<Parser.Tree>): void;
|
|
30
|
+
getOldParseResultOf(filePath: FilePath): Parser.Tree | undefined;
|
|
31
|
+
getOldContentOf(filePath: FilePath): string | undefined;
|
|
32
|
+
deleteOldContentOf(filePath: FilePath): void;
|
|
33
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FlowrAnalyzerIncrementalAnalysisContext = void 0;
|
|
4
|
+
const assert_1 = require("../../util/assert");
|
|
5
|
+
/**
|
|
6
|
+
* Information to carry over for future incremental builds
|
|
7
|
+
*/
|
|
8
|
+
class FlowrAnalyzerIncrementalAnalysisContext {
|
|
9
|
+
name = 'flowr-analyzer-incremental-analysis-context';
|
|
10
|
+
context;
|
|
11
|
+
/**
|
|
12
|
+
* The files that have been changed since the last analysis mapping to their old content.
|
|
13
|
+
*/
|
|
14
|
+
changedFilesWithOldContent = new Map();
|
|
15
|
+
oldParseResults = new Map();
|
|
16
|
+
constructor(context) {
|
|
17
|
+
this.context = context;
|
|
18
|
+
}
|
|
19
|
+
reset() {
|
|
20
|
+
this.changedFilesWithOldContent = new Map();
|
|
21
|
+
this.oldParseResults = new Map();
|
|
22
|
+
}
|
|
23
|
+
handleFileInvalidate(filePath, oldContent) {
|
|
24
|
+
if (this.changedFilesWithOldContent.has(filePath)) {
|
|
25
|
+
// If a file is changed multiple times since the last analysis, we only want to store the original old content as the old analysis results were computed with that.
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
this.changedFilesWithOldContent.set(filePath, oldContent);
|
|
29
|
+
}
|
|
30
|
+
receive(event) {
|
|
31
|
+
const type = event.type;
|
|
32
|
+
switch (type) {
|
|
33
|
+
case "full" /* InvalidationEventType.Full */:
|
|
34
|
+
this.reset();
|
|
35
|
+
break;
|
|
36
|
+
case "single-file-invalidate" /* InvalidationEventType.SingleFileInvalidate */:
|
|
37
|
+
this.handleFileInvalidate(event.filePath, event.oldContent?.toString());
|
|
38
|
+
break;
|
|
39
|
+
default:
|
|
40
|
+
(0, assert_1.assertUnreachable)(type);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
storeOldParseResults(parseStepOutput) {
|
|
44
|
+
for (const parsedStepSingleOutput of parseStepOutput.files) {
|
|
45
|
+
if (parsedStepSingleOutput.filePath === undefined) {
|
|
46
|
+
// there could be multiple files without a file path, making a distinction impossible
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
this.oldParseResults.set(parsedStepSingleOutput.filePath, parsedStepSingleOutput.parsed);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
getOldParseResultOf(filePath) {
|
|
53
|
+
return this.oldParseResults.get(filePath);
|
|
54
|
+
}
|
|
55
|
+
getOldContentOf(filePath) {
|
|
56
|
+
return this.changedFilesWithOldContent.get(filePath);
|
|
57
|
+
}
|
|
58
|
+
deleteOldContentOf(filePath) {
|
|
59
|
+
this.changedFilesWithOldContent.delete(filePath);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.FlowrAnalyzerIncrementalAnalysisContext = FlowrAnalyzerIncrementalAnalysisContext;
|
|
63
|
+
//# sourceMappingURL=flowr-analyzer-incremental-analysis-context.js.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { SemVer } from 'semver';
|
|
2
|
+
import type { InvalidationEvent, InvalidationEventReceiver } from '../cache/flowr-cache';
|
|
2
3
|
import type { RAuthorInfo } from '../../util/r-author';
|
|
3
4
|
import type { RLicenseElementInfo } from '../../util/r-license';
|
|
4
5
|
import type { Package } from '../plugins/package-version-plugins/package';
|
|
@@ -105,13 +106,14 @@ export interface ReadOnlyFlowrAnalyzerMetaContext {
|
|
|
105
106
|
*
|
|
106
107
|
* If you are interested in inspecting this metadata, refer to {@link ReadOnlyFlowrAnalyzerMetaContext}.
|
|
107
108
|
*/
|
|
108
|
-
export declare class FlowrAnalyzerMetaContext implements ReadOnlyFlowrAnalyzerMetaContext {
|
|
109
|
+
export declare class FlowrAnalyzerMetaContext implements ReadOnlyFlowrAnalyzerMetaContext, InvalidationEventReceiver {
|
|
109
110
|
readonly name = "flowr-analyzer-meta-context";
|
|
110
111
|
private readonly fields;
|
|
111
112
|
/** runs the plugins that contribute the metadata, as they only do so on demand */
|
|
112
113
|
private readonly ensureContributed;
|
|
113
114
|
constructor(ensureContributed?: () => void);
|
|
114
115
|
reset(): void;
|
|
116
|
+
receive(event: InvalidationEvent): void;
|
|
115
117
|
/**
|
|
116
118
|
* Contribute what a source declares about the project; `undefined` fields are ignored, so a plugin can pass
|
|
117
119
|
* whatever it happens to know.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FlowrAnalyzerMetaContext = exports.MetaPriority = void 0;
|
|
4
|
+
const assert_1 = require("../../util/assert");
|
|
4
5
|
/**
|
|
5
6
|
* How much a {@link ProjectMetaFields | contribution} is trusted, in case several sources disagree.
|
|
6
7
|
* A higher value wins; among equal values the first contribution stays.
|
|
@@ -34,6 +35,19 @@ class FlowrAnalyzerMetaContext {
|
|
|
34
35
|
reset() {
|
|
35
36
|
this.fields.clear();
|
|
36
37
|
}
|
|
38
|
+
receive(event) {
|
|
39
|
+
const type = event.type;
|
|
40
|
+
switch (type) {
|
|
41
|
+
case "full" /* InvalidationEventType.Full */:
|
|
42
|
+
this.reset();
|
|
43
|
+
break;
|
|
44
|
+
case "single-file-invalidate" /* InvalidationEventType.SingleFileInvalidate */:
|
|
45
|
+
// nothing to do
|
|
46
|
+
break;
|
|
47
|
+
default:
|
|
48
|
+
(0, assert_1.assertUnreachable)(type);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
37
51
|
/**
|
|
38
52
|
* Contribute what a source declares about the project; `undefined` fields are ignored, so a plugin can pass
|
|
39
53
|
* whatever it happens to know.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { PathLike } from 'fs';
|
|
2
2
|
import type { RParseRequest } from '../../r-bridge/retriever';
|
|
3
|
+
import type { InvalidationEventHandler } from '../cache/flowr-cache';
|
|
3
4
|
/**
|
|
4
5
|
* Just a readable alias for file paths, mostly for documentation purposes.
|
|
5
6
|
* We separate {@link PathLike} types from string paths that are used for project paths.
|
|
@@ -30,9 +31,9 @@ export declare enum FileRole {
|
|
|
30
31
|
Data = "data",
|
|
31
32
|
/** Signals separate license files, but please note, that DESCRIPTION files may contain license info too */
|
|
32
33
|
License = "license",
|
|
33
|
-
/** Files describing a project's virtual/pinned package environment, e.g., `renv.lock` or `
|
|
34
|
+
/** Files describing a project's virtual/pinned package environment, e.g., `renv.lock`, `rv.lock` or `uvr.lock`. */
|
|
34
35
|
VirtualEnv = "virtual-env",
|
|
35
|
-
/** A project manifest that is no `DESCRIPTION`, e.g. the `rproject.toml` of an rv project. */
|
|
36
|
+
/** A project manifest that is no `DESCRIPTION`, e.g. the `rproject.toml` of an rv project or the `uvr.toml` of a uvr project. */
|
|
36
37
|
Manifest = "manifest",
|
|
37
38
|
/**
|
|
38
39
|
* R sources evaluated at startup, before any project code (`.Rprofile`, `Rprofile.site`).
|
|
@@ -96,6 +97,18 @@ export interface FlowrFileProvider<Content extends {
|
|
|
96
97
|
* **Do not call this method yourself unless you are a file-loader plugin and/or really know what you are doing, this may break plugin assumptions!**
|
|
97
98
|
*/
|
|
98
99
|
assignRole(role: FileRole): void;
|
|
100
|
+
/**
|
|
101
|
+
* Set the appropriate callback to trigger updates in case of an 'invalidate'
|
|
102
|
+
*/
|
|
103
|
+
addOnInvalidate(callback: InvalidationEventHandler<Content>): void;
|
|
104
|
+
/**
|
|
105
|
+
* Remove a previously added callback
|
|
106
|
+
*/
|
|
107
|
+
removeOnInvalidate(callback: InvalidationEventHandler<Content>): void;
|
|
108
|
+
/**
|
|
109
|
+
* Reload the file content because something has changed.
|
|
110
|
+
*/
|
|
111
|
+
invalidate(): void;
|
|
99
112
|
}
|
|
100
113
|
/**
|
|
101
114
|
* A basic implementation of the {@link FlowrFileProvider} interface that caches the content after the first load (i.e., updates on disk are ignored).
|
|
@@ -106,6 +119,7 @@ export declare abstract class FlowrFile<Content extends StringableContent = Stri
|
|
|
106
119
|
private contentCache;
|
|
107
120
|
protected filePath: PathLike;
|
|
108
121
|
private _roles?;
|
|
122
|
+
private onInvalidate;
|
|
109
123
|
static readonly INLINE_PATH = "@inline";
|
|
110
124
|
constructor(filePath: PathLike, roles?: readonly FileRole[]);
|
|
111
125
|
get roles(): readonly FileRole[] | undefined;
|
|
@@ -124,6 +138,9 @@ export declare abstract class FlowrFile<Content extends StringableContent = Stri
|
|
|
124
138
|
* @see {@link FlowrInlineTextFile}
|
|
125
139
|
*/
|
|
126
140
|
static fromRequest(request: RParseRequest): FlowrFile<string>;
|
|
141
|
+
addOnInvalidate(callback: InvalidationEventHandler<Content>): void;
|
|
142
|
+
removeOnInvalidate(callback: InvalidationEventHandler<Content>): void;
|
|
143
|
+
invalidate(): void;
|
|
127
144
|
}
|
|
128
145
|
/**
|
|
129
146
|
* A basic implementation of the {@link FlowrFileProvider} interface for text files that caches the content after the first load (i.e., updates on disk are ignored).
|
|
@@ -137,7 +154,12 @@ export declare class FlowrTextFile extends FlowrFile<string> {
|
|
|
137
154
|
* These will be handled by the {@link FlowrAnalyzerDescriptionFilePlugin} (e.g., by using the {@link FlowrDescriptionFile#from} method decorator).
|
|
138
155
|
*/
|
|
139
156
|
export declare class FlowrInlineTextFile extends FlowrFile<string> {
|
|
140
|
-
private
|
|
157
|
+
private contentStr;
|
|
141
158
|
constructor(path: PathLike, content: string);
|
|
142
159
|
protected loadContent(): string;
|
|
160
|
+
/**
|
|
161
|
+
* Update the content of this inline file and invalidate the cache to trigger updates in the analysis.
|
|
162
|
+
* @see {@link FlowrFile#invalidate}
|
|
163
|
+
*/
|
|
164
|
+
updateInlineContent(newContent: string): void;
|
|
143
165
|
}
|
|
@@ -31,9 +31,9 @@ var FileRole;
|
|
|
31
31
|
FileRole["Data"] = "data";
|
|
32
32
|
/** Signals separate license files, but please note, that DESCRIPTION files may contain license info too */
|
|
33
33
|
FileRole["License"] = "license";
|
|
34
|
-
/** Files describing a project's virtual/pinned package environment, e.g., `renv.lock` or `
|
|
34
|
+
/** Files describing a project's virtual/pinned package environment, e.g., `renv.lock`, `rv.lock` or `uvr.lock`. */
|
|
35
35
|
FileRole["VirtualEnv"] = "virtual-env";
|
|
36
|
-
/** A project manifest that is no `DESCRIPTION`, e.g. the `rproject.toml` of an rv project. */
|
|
36
|
+
/** A project manifest that is no `DESCRIPTION`, e.g. the `rproject.toml` of an rv project or the `uvr.toml` of a uvr project. */
|
|
37
37
|
FileRole["Manifest"] = "manifest";
|
|
38
38
|
/**
|
|
39
39
|
* R sources evaluated at startup, before any project code (`.Rprofile`, `Rprofile.site`).
|
|
@@ -64,6 +64,7 @@ class FlowrFile {
|
|
|
64
64
|
contentCache;
|
|
65
65
|
filePath;
|
|
66
66
|
_roles;
|
|
67
|
+
onInvalidate = [];
|
|
67
68
|
static INLINE_PATH = '@inline';
|
|
68
69
|
constructor(filePath, roles) {
|
|
69
70
|
this.filePath = filePath;
|
|
@@ -113,6 +114,19 @@ class FlowrFile {
|
|
|
113
114
|
return new FlowrInlineTextFile(FlowrFile.INLINE_PATH, request.content);
|
|
114
115
|
}
|
|
115
116
|
}
|
|
117
|
+
addOnInvalidate(callback) {
|
|
118
|
+
this.onInvalidate.push(callback);
|
|
119
|
+
}
|
|
120
|
+
removeOnInvalidate(callback) {
|
|
121
|
+
this.onInvalidate = this.onInvalidate.filter(cb => cb !== callback);
|
|
122
|
+
}
|
|
123
|
+
invalidate() {
|
|
124
|
+
const oldContent = this.contentCache;
|
|
125
|
+
this.contentCache = undefined;
|
|
126
|
+
for (const invalidator of this.onInvalidate) {
|
|
127
|
+
invalidator({ type: "single-file-invalidate" /* InvalidationEventType.SingleFileInvalidate */, oldContent, filePath: this.path() });
|
|
128
|
+
}
|
|
129
|
+
}
|
|
116
130
|
}
|
|
117
131
|
exports.FlowrFile = FlowrFile;
|
|
118
132
|
/**
|
|
@@ -138,6 +152,14 @@ class FlowrInlineTextFile extends FlowrFile {
|
|
|
138
152
|
loadContent() {
|
|
139
153
|
return this.contentStr;
|
|
140
154
|
}
|
|
155
|
+
/**
|
|
156
|
+
* Update the content of this inline file and invalidate the cache to trigger updates in the analysis.
|
|
157
|
+
* @see {@link FlowrFile#invalidate}
|
|
158
|
+
*/
|
|
159
|
+
updateInlineContent(newContent) {
|
|
160
|
+
this.contentStr = newContent;
|
|
161
|
+
this.invalidate();
|
|
162
|
+
}
|
|
141
163
|
}
|
|
142
164
|
exports.FlowrInlineTextFile = FlowrInlineTextFile;
|
|
143
165
|
//# sourceMappingURL=flowr-file.js.map
|
|
@@ -90,6 +90,8 @@ export interface SurvivingEntries {
|
|
|
90
90
|
readonly unsatisfiable: boolean;
|
|
91
91
|
/** the total number of versions the database carries for the package (the full history the candidates are drawn from) */
|
|
92
92
|
readonly total: number;
|
|
93
|
+
/** whether the database carries the package at all: `false` means "no record", not "no constraint" */
|
|
94
|
+
readonly known: boolean;
|
|
93
95
|
/** how many of those versions the *declared* constraints alone allow, the baseline the guess narrows down from */
|
|
94
96
|
readonly declared: number;
|
|
95
97
|
}
|
|
@@ -123,6 +125,41 @@ export declare function dateCutoff(spec: string): Date | undefined;
|
|
|
123
125
|
export declare function isoDay(date: Date): string;
|
|
124
126
|
/** scan the dataflow graph for every call that resolves (via {@link Dataflow.qualify}) to a package export */
|
|
125
127
|
export declare function collectUsage(graph: DataflowGraph, deps?: ReadOnlyFlowrAnalyzerDependenciesContext): Map<string, PackageUsage>;
|
|
128
|
+
/**
|
|
129
|
+
* What the orphan calls of one analyzed program implicated, as {@link collectOrphanUsage} reports it.
|
|
130
|
+
*/
|
|
131
|
+
export interface OrphanUsage {
|
|
132
|
+
/** per package the project does not already know: the orphan function names that pointed at it */
|
|
133
|
+
readonly attributed: Map<string, Set<string>>;
|
|
134
|
+
/** per such package: the other exporters of those names that lost the pick, most downloaded first */
|
|
135
|
+
readonly alternatives: Map<string, string[]>;
|
|
136
|
+
/** the same calls recorded against every alternative, so a caller can ask which of its versions would fit */
|
|
137
|
+
readonly alternativeUsage: Map<string, PackageUsage>;
|
|
138
|
+
}
|
|
139
|
+
/** options for {@link collectOrphanUsage} */
|
|
140
|
+
export interface OrphanUsageOptions {
|
|
141
|
+
/** the analyzed project's own namespace, never inferred as one of its own orphan dependencies */
|
|
142
|
+
readonly self?: string;
|
|
143
|
+
/** flowR's curated map of a builtin-modeled library function to its package (e.g. `ggplot` to `ggplot2`), the authoritative disambiguator when several packages export the name */
|
|
144
|
+
readonly builtinLibraryOf?: (name: string) => string | undefined;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Fold the analyzed code's *orphan* calls into `usage` and report which functions implicated each **unknown**
|
|
148
|
+
* package. An orphan is a bare call (`ggplot()`) whose name is not bound to a local/parameter/closure/import
|
|
149
|
+
* definition and is not a default-attached base export, but is exported by exactly one signature-database package.
|
|
150
|
+
* Such a call never qualifies to `pkg::fn`, so {@link collectUsage} is blind to it (even when flowR models the
|
|
151
|
+
* function as a builtin, as it does for `ggplot`), yet it pins the package's version just as a qualified call
|
|
152
|
+
* would; folding it into `usage` makes the package a guess target. The returned map lists, per package the project
|
|
153
|
+
* does not already declare or load (`isKnown` is `false`), the orphan function names that pointed at it (e.g.
|
|
154
|
+
* `ggplot2` from `ggplot()`) -- a note for a downstream handler to attach the library, since the symbol would be
|
|
155
|
+
* undefined were the package not loaded. Disambiguation is `options.builtinLibraryOf` (flowR's curated map, e.g.
|
|
156
|
+
* `ggplot` to `ggplot2`, authoritative even when several packages re-export the name), then a package the project
|
|
157
|
+
* already declares or loads, and finally the most downloaded of at most {@link MaxOrphanProviders} exporters; a
|
|
158
|
+
* name beyond that many packages export says nothing about which one is meant and is skipped, as are quoted (NSE)
|
|
159
|
+
* uses and forward-referenced closures. The exporters that lost the pick are kept as
|
|
160
|
+
* {@link OrphanUsage.alternatives}, since the guess is exactly that -- a guess.
|
|
161
|
+
*/
|
|
162
|
+
export declare function collectOrphanUsage(graph: DataflowGraph, deps: ReadOnlyFlowrAnalyzerDependenciesContext, usage: Map<string, PackageUsage>, isKnown: (pkg: string) => boolean, options?: OrphanUsageOptions): OrphanUsage;
|
|
126
163
|
/** intersection of multiple survivor sets: versions that survive in every set */
|
|
127
164
|
export declare function intersectSurvivors(survivorSets: readonly (readonly TimelineEntry[])[]): TimelineEntry[];
|
|
128
165
|
/**
|
|
@@ -4,6 +4,7 @@ exports.NoDisabledSources = exports.VersionSpace = exports.DefaultFixpointIterat
|
|
|
4
4
|
exports.dateCutoff = dateCutoff;
|
|
5
5
|
exports.isoDay = isoDay;
|
|
6
6
|
exports.collectUsage = collectUsage;
|
|
7
|
+
exports.collectOrphanUsage = collectOrphanUsage;
|
|
7
8
|
exports.intersectSurvivors = intersectSurvivors;
|
|
8
9
|
exports.collectTransitiveConstraints = collectTransitiveConstraints;
|
|
9
10
|
exports.iterateToFixpoint = iterateToFixpoint;
|
|
@@ -33,6 +34,9 @@ const identifier_1 = require("../dataflow/environments/identifier");
|
|
|
33
34
|
const vertex_1 = require("../dataflow/graph/vertex");
|
|
34
35
|
const graph_1 = require("../dataflow/graph/graph");
|
|
35
36
|
const df_helper_1 = require("../dataflow/graph/df-helper");
|
|
37
|
+
const dfg_get_origin_1 = require("../dataflow/origin/dfg-get-origin");
|
|
38
|
+
const r_base_packages_1 = require("../util/r-base-packages");
|
|
39
|
+
const undefined_symbol_util_1 = require("../linter/rules/undefined-symbol-util");
|
|
36
40
|
const type_1 = require("../r-bridge/lang-4.x/ast/model/type");
|
|
37
41
|
const built_in_s_seven_new_generic_1 = require("../dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic");
|
|
38
42
|
/** the pseudo-package standing for the analyzed project itself, never one of its own dependencies */
|
|
@@ -171,6 +175,31 @@ function addClassOwnershipUsage(usage, deps, graph) {
|
|
|
171
175
|
function isSyntheticArgument(arg) {
|
|
172
176
|
return !graph_1.FunctionArgument.isEmpty(arg) && String(arg.nodeId).endsWith(built_in_s_seven_new_generic_1.S7SyntheticFunArgSuffix);
|
|
173
177
|
}
|
|
178
|
+
/** record one call of `fn` into `pkgUsage`: union its named argument names and keep one representative per call shape */
|
|
179
|
+
function recordCallUsage(pkgUsage, fn, rawArgs) {
|
|
180
|
+
let entry = pkgUsage.get(fn);
|
|
181
|
+
if (entry === undefined) {
|
|
182
|
+
entry = { named: new Set(), calls: new Map() };
|
|
183
|
+
pkgUsage.set(fn, entry);
|
|
184
|
+
}
|
|
185
|
+
const args = rawArgs.some(isSyntheticArgument) ? rawArgs.filter(a => !isSyntheticArgument(a)) : rawArgs;
|
|
186
|
+
const named = [];
|
|
187
|
+
let positional = 0;
|
|
188
|
+
for (const arg of args) {
|
|
189
|
+
if (graph_1.FunctionArgument.isNamed(arg)) {
|
|
190
|
+
entry.named.add(arg.name);
|
|
191
|
+
named.push(arg.name);
|
|
192
|
+
}
|
|
193
|
+
else if (graph_1.FunctionArgument.isPositional(arg)) {
|
|
194
|
+
positional++;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
// dedupe by call shape: named names + positional count
|
|
198
|
+
const key = named.sort().join(',') + '#' + positional;
|
|
199
|
+
if (!entry.calls.has(key)) {
|
|
200
|
+
entry.calls.set(key, [...args]);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
174
203
|
/** scan the dataflow graph for every call that resolves (via {@link Dataflow.qualify}) to a package export */
|
|
175
204
|
function collectUsage(graph, deps) {
|
|
176
205
|
const usage = new Map();
|
|
@@ -184,40 +213,102 @@ function collectUsage(graph, deps) {
|
|
|
184
213
|
if (pkg === undefined) {
|
|
185
214
|
continue;
|
|
186
215
|
}
|
|
187
|
-
const fn = identifier_1.Identifier.getName(qualified);
|
|
188
216
|
let pkgUsage = usage.get(pkg);
|
|
189
217
|
if (pkgUsage === undefined) {
|
|
190
218
|
pkgUsage = new Map();
|
|
191
219
|
usage.set(pkg, pkgUsage);
|
|
192
220
|
}
|
|
193
|
-
|
|
194
|
-
if (entry === undefined) {
|
|
195
|
-
entry = { named: new Set(), calls: new Map() };
|
|
196
|
-
pkgUsage.set(fn, entry);
|
|
197
|
-
}
|
|
198
|
-
const args = vertex.args.some(isSyntheticArgument) ? vertex.args.filter(a => !isSyntheticArgument(a)) : vertex.args;
|
|
199
|
-
const named = [];
|
|
200
|
-
let positional = 0;
|
|
201
|
-
for (const arg of args) {
|
|
202
|
-
if (graph_1.FunctionArgument.isNamed(arg)) {
|
|
203
|
-
entry.named.add(arg.name);
|
|
204
|
-
named.push(arg.name);
|
|
205
|
-
}
|
|
206
|
-
else if (graph_1.FunctionArgument.isPositional(arg)) {
|
|
207
|
-
positional++;
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
// dedupe by call shape: named names + positional count
|
|
211
|
-
const key = named.sort().join(',') + '#' + positional;
|
|
212
|
-
if (!entry.calls.has(key)) {
|
|
213
|
-
entry.calls.set(key, [...args]);
|
|
214
|
-
}
|
|
221
|
+
recordCallUsage(pkgUsage, identifier_1.Identifier.getName(qualified), vertex.args);
|
|
215
222
|
}
|
|
216
223
|
if (deps) {
|
|
217
224
|
addClassOwnershipUsage(usage, deps, graph);
|
|
218
225
|
}
|
|
219
226
|
return usage;
|
|
220
227
|
}
|
|
228
|
+
/**
|
|
229
|
+
* How many packages may export an orphan's name before it is dropped as too generic. Up to this many, the most
|
|
230
|
+
* downloaded one is taken (see {@link collectOrphanUsage}); beyond it the name carries no information.
|
|
231
|
+
*/
|
|
232
|
+
const MaxOrphanProviders = 5;
|
|
233
|
+
/**
|
|
234
|
+
* Fold the analyzed code's *orphan* calls into `usage` and report which functions implicated each **unknown**
|
|
235
|
+
* package. An orphan is a bare call (`ggplot()`) whose name is not bound to a local/parameter/closure/import
|
|
236
|
+
* definition and is not a default-attached base export, but is exported by exactly one signature-database package.
|
|
237
|
+
* Such a call never qualifies to `pkg::fn`, so {@link collectUsage} is blind to it (even when flowR models the
|
|
238
|
+
* function as a builtin, as it does for `ggplot`), yet it pins the package's version just as a qualified call
|
|
239
|
+
* would; folding it into `usage` makes the package a guess target. The returned map lists, per package the project
|
|
240
|
+
* does not already declare or load (`isKnown` is `false`), the orphan function names that pointed at it (e.g.
|
|
241
|
+
* `ggplot2` from `ggplot()`) -- a note for a downstream handler to attach the library, since the symbol would be
|
|
242
|
+
* undefined were the package not loaded. Disambiguation is `options.builtinLibraryOf` (flowR's curated map, e.g.
|
|
243
|
+
* `ggplot` to `ggplot2`, authoritative even when several packages re-export the name), then a package the project
|
|
244
|
+
* already declares or loads, and finally the most downloaded of at most {@link MaxOrphanProviders} exporters; a
|
|
245
|
+
* name beyond that many packages export says nothing about which one is meant and is skipped, as are quoted (NSE)
|
|
246
|
+
* uses and forward-referenced closures. The exporters that lost the pick are kept as
|
|
247
|
+
* {@link OrphanUsage.alternatives}, since the guess is exactly that -- a guess.
|
|
248
|
+
*/
|
|
249
|
+
function collectOrphanUsage(graph, deps, usage, isKnown, options = {}) {
|
|
250
|
+
const { self, builtinLibraryOf } = options;
|
|
251
|
+
const attributed = new Map();
|
|
252
|
+
const alternatives = new Map();
|
|
253
|
+
const alternativeUsage = new Map();
|
|
254
|
+
const scopeDefined = (0, undefined_symbol_util_1.collectScopeDefinedNames)(graph);
|
|
255
|
+
for (const [id, vertex] of graph.verticesOfType(vertex_1.VertexType.FunctionCall)) {
|
|
256
|
+
// an anonymous callee, or an already-qualified `pkg::fn` (handled by collectUsage)
|
|
257
|
+
if (vertex.origin === 'unnamed' || identifier_1.Identifier.getNamespace(vertex.name) !== undefined) {
|
|
258
|
+
continue;
|
|
259
|
+
}
|
|
260
|
+
const name = identifier_1.Identifier.getName(vertex.name);
|
|
261
|
+
// a call bound to a real definition (local, parameter, closure, or import) *is* that definition, not a package
|
|
262
|
+
// export; only an unresolved or builtin-modeled call can be an orphan (flowR models e.g. `ggplot` as a builtin)
|
|
263
|
+
if ((0, dfg_get_origin_1.getOriginInDfg)(graph, id)?.some(o => o.type === 2 /* OriginType.FunctionCallOrigin */) === true) {
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
266
|
+
// a bare name from a default-attached base package (or a base primitive) is defined without a library() call
|
|
267
|
+
const baseOwner = (0, r_base_packages_1.baseRExportOwner)(name);
|
|
268
|
+
if (baseOwner !== undefined && r_base_packages_1.AttachedBasePackages.includes(baseOwner)) {
|
|
269
|
+
continue;
|
|
270
|
+
}
|
|
271
|
+
// a quoted use, or a forward-referenced closure binding flowR did not statically link, is not a real orphan call
|
|
272
|
+
if ((0, undefined_symbol_util_1.isNonStandardEvaluated)(graph, id) || (0, undefined_symbol_util_1.isDefinedInEnclosingScope)(graph, scopeDefined, id, name)) {
|
|
273
|
+
continue;
|
|
274
|
+
}
|
|
275
|
+
// flowR's curated map disambiguates a name several packages export (ggplot to ggplot2); failing that, a
|
|
276
|
+
// package the project already declares or loads explains the call and needs no library attached (dplyr
|
|
277
|
+
// re-exports tidyselect's `everything`); failing that the most downloaded exporter wins, as
|
|
278
|
+
// `packagesExporting` hands them over in that order and a script calling a bare name almost always means
|
|
279
|
+
// the popular package. A name half of CRAN exports says nothing, so it is skipped.
|
|
280
|
+
const mapped = builtinLibraryOf?.(name);
|
|
281
|
+
const providers = deps.packagesExporting(name).filter(p => p !== self);
|
|
282
|
+
const known = providers.filter(isKnown);
|
|
283
|
+
const pkg = mapped !== undefined && mapped !== self ? mapped
|
|
284
|
+
: known.length === 1 ? known[0]
|
|
285
|
+
: known.length === 0 && providers.length > 0 && providers.length <= MaxOrphanProviders ? providers[0] : undefined;
|
|
286
|
+
if (pkg === undefined) {
|
|
287
|
+
continue;
|
|
288
|
+
}
|
|
289
|
+
recordCallUsage(atKey(usage, pkg, () => new Map()), name, vertex.args);
|
|
290
|
+
// a package the project already declares or loads is a normal target, not an orphan needing attachment
|
|
291
|
+
if (isKnown(pkg)) {
|
|
292
|
+
continue;
|
|
293
|
+
}
|
|
294
|
+
atKey(attributed, pkg, () => new Set()).add(name);
|
|
295
|
+
// the exporters that lost, with the same calls recorded, so the guess can report what each of them would fit
|
|
296
|
+
const losers = providers.filter(p => p !== pkg);
|
|
297
|
+
alternatives.set(pkg, [...new Set([...alternatives.get(pkg) ?? [], ...losers])]);
|
|
298
|
+
for (const alt of losers) {
|
|
299
|
+
recordCallUsage(atKey(alternativeUsage, alt, () => new Map()), name, vertex.args);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
return { attributed, alternatives, alternativeUsage };
|
|
303
|
+
}
|
|
304
|
+
/** the entry of `key`, inserting what `make` builds when the map has none yet */
|
|
305
|
+
function atKey(map, key, make) {
|
|
306
|
+
let found = map.get(key);
|
|
307
|
+
if (found === undefined) {
|
|
308
|
+
map.set(key, found = make());
|
|
309
|
+
}
|
|
310
|
+
return found;
|
|
311
|
+
}
|
|
221
312
|
/** the dated releases + base-R core releases + latest of a package, ascending by R-version order */
|
|
222
313
|
function versionTimeline(src, pkg) {
|
|
223
314
|
return (0, reader_1.availableVersionEntries)(src, pkg).map(e => ({ ver: e.version, ...(e.date ? { date: e.date } : {}) }));
|
|
@@ -704,10 +795,11 @@ function survivingEntries(space, name, transitive, observe) {
|
|
|
704
795
|
// contradiction is a constraint property, not an empty database
|
|
705
796
|
const unsatisfiable = constraintsContradict(declaredConstraints, declaredRange, effectiveTransitive);
|
|
706
797
|
if (!src) {
|
|
707
|
-
return { survivors: [], preSignature: [], getFn, declaredRange, declaredConstraints, base: false, unsatisfiable, total: 0, declared: 0 };
|
|
798
|
+
return { survivors: [], preSignature: [], getFn, declaredRange, declaredConstraints, base: false, unsatisfiable, total: 0, declared: 0, known: false };
|
|
708
799
|
}
|
|
709
800
|
const base = src.isBaseR(packageKey);
|
|
710
801
|
const total = timeline.length;
|
|
802
|
+
const known = total > 0;
|
|
711
803
|
const declared = declaredRange ? timeline.filter(e => r_version_1.RRange.satisfies(e.ver, declaredRange)).length : total;
|
|
712
804
|
// emit database coverage envelope as outer bounds
|
|
713
805
|
if (observe && timeline.length > 0 && !disabled.has('available')) {
|
|
@@ -716,13 +808,13 @@ function survivingEntries(space, name, transitive, observe) {
|
|
|
716
808
|
}
|
|
717
809
|
const preSignature = applyConstraints(space, name, timeline, { declaredRange, declaredConstraints, transitive: effectiveTransitive, base }, observe);
|
|
718
810
|
if (!usage || disabled.has('signature')) {
|
|
719
|
-
return { survivors: preSignature, preSignature, getFn, declaredRange, declaredConstraints, base, unsatisfiable, total, declared };
|
|
811
|
+
return { survivors: preSignature, preSignature, getFn, declaredRange, declaredConstraints, base, unsatisfiable, total, declared, known };
|
|
720
812
|
}
|
|
721
813
|
if (observe) {
|
|
722
814
|
addSignatureEvidence(observe, src, getFn, packageKey, usage, preSignature);
|
|
723
815
|
}
|
|
724
816
|
const survivors = preSignature.filter(e => signatureOk(e.ver));
|
|
725
|
-
return { survivors, preSignature, getFn, declaredRange, declaredConstraints, base, unsatisfiable, total, declared };
|
|
817
|
+
return { survivors, preSignature, getFn, declaredRange, declaredConstraints, base, unsatisfiable, total, declared, known };
|
|
726
818
|
}
|
|
727
819
|
/** the sigdb package a target's version history is drawn from: `R` reuses `base` (their releases coincide), everything else is itself */
|
|
728
820
|
function timelinePackageKey(name, sources) {
|
|
@@ -18,6 +18,7 @@ import { fileProtocol } from '../r-bridge/retriever';
|
|
|
18
18
|
import type { FlowrFileProvider } from './context/flowr-file';
|
|
19
19
|
import type { Tree } from 'web-tree-sitter';
|
|
20
20
|
import type { CallGraph } from '../dataflow/graph/call-graph';
|
|
21
|
+
import type { InvalidationEvent } from './cache/flowr-cache';
|
|
21
22
|
/**
|
|
22
23
|
* Extends the {@link ReadonlyFlowrAnalysisProvider} with methods that allow modifying the analyzer state.
|
|
23
24
|
*/
|
|
@@ -45,6 +46,10 @@ export interface FlowrAnalysisProvider<Parser extends KnownParser = KnownParser>
|
|
|
45
46
|
* Reset the analyzer state, including the context and the cache.
|
|
46
47
|
*/
|
|
47
48
|
reset(): void;
|
|
49
|
+
/**
|
|
50
|
+
* Receive cache invalidation events from the cache and propagate them to the context and other relevant components.
|
|
51
|
+
*/
|
|
52
|
+
receive(event: InvalidationEvent): void;
|
|
48
53
|
}
|
|
49
54
|
/**
|
|
50
55
|
* Exposes the central analyses and information provided by the {@link FlowrAnalyzer} to the linter, search, and query APIs.
|
|
@@ -175,6 +180,7 @@ export declare class FlowrAnalyzer<Parser extends KnownParser = KnownParser> imp
|
|
|
175
180
|
parserInformation(): KnownParserInformation;
|
|
176
181
|
inspectContext(): ReadOnlyFlowrAnalyzerContext;
|
|
177
182
|
reset(): void;
|
|
183
|
+
receive(event: InvalidationEvent): void;
|
|
178
184
|
updateConfig(update: DeepPartial<FlowrConfig>): void;
|
|
179
185
|
resetConfig(): void;
|
|
180
186
|
parseStandalone(data: `${typeof fileProtocol}${string}` | string | RParseRequest): Tree;
|