@eagleoutice/flowr 2.13.4 → 2.13.5
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 +31 -31
- 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 +1046 -93
- package/dataflow/environments/default-builtin-config.js +485 -213
- 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.js +4 -1
- 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-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 +65 -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 +17 -9
- package/package.json +3 -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 +4 -2
- package/project/context/flowr-analyzer-dependencies-context.js +15 -1
- 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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eagleoutice/flowr",
|
|
3
|
-
"version": "2.13.
|
|
3
|
+
"version": "2.13.5",
|
|
4
4
|
"description": "Static Dataflow Analyzer and Program Slicer for the R Programming Language",
|
|
5
5
|
"types": "dist/src/index.d.ts",
|
|
6
6
|
"repository": {
|
|
@@ -182,7 +182,7 @@
|
|
|
182
182
|
"devDependencies": {
|
|
183
183
|
"@commitlint/cli": "^20.5.0",
|
|
184
184
|
"@commitlint/config-angular": "^20.5.0",
|
|
185
|
-
"@eagleoutice/eslint-config-flowr": "^2.0.
|
|
185
|
+
"@eagleoutice/eslint-config-flowr": "^2.0.2",
|
|
186
186
|
"@j-ulrich/release-it-regex-bumper": "^5.4.0",
|
|
187
187
|
"@stylistic/eslint-plugin": "^5.10.0",
|
|
188
188
|
"@types/command-line-args": "^5.2.3",
|
|
@@ -227,6 +227,7 @@
|
|
|
227
227
|
"command-line-usage": "^7.0.3",
|
|
228
228
|
"commonmark": "^0.31.2",
|
|
229
229
|
"dagre": "^0.8.5",
|
|
230
|
+
"diff": "^8.0.3",
|
|
230
231
|
"gray-matter": "^4.0.3",
|
|
231
232
|
"ignore": "^5.3.2",
|
|
232
233
|
"joi": "^18.0.1",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { KnownParser } from '../../r-bridge/parser';
|
|
2
|
-
import { type
|
|
2
|
+
import { FlowrCache, type InvalidationEvent } from './flowr-cache';
|
|
3
3
|
import { type DEFAULT_DATAFLOW_PIPELINE, type TREE_SITTER_DATAFLOW_PIPELINE } from '../../core/steps/pipeline/default-pipelines';
|
|
4
4
|
import type { IdGenerator } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
5
5
|
import type { NoInfo } from '../../r-bridge/lang-4.x/ast/model/model';
|
|
@@ -27,13 +27,14 @@ export declare class FlowrAnalyzerCache<Parser extends KnownParser> extends Flow
|
|
|
27
27
|
private callGraphCache;
|
|
28
28
|
protected constructor(args: FlowrAnalyzerCacheOptions<Parser>);
|
|
29
29
|
private initCacheProviders;
|
|
30
|
+
static create<Parser extends KnownParser>(data: FlowrAnalyzerCacheOptions<Parser>): FlowrAnalyzerCache<Parser>;
|
|
30
31
|
/** Free the current parse trees: tree-sitter trees live on the WASM heap, which the GC does not reclaim. */
|
|
31
32
|
private disposeParse;
|
|
32
|
-
|
|
33
|
-
receive(event: CacheInvalidationEvent): void;
|
|
33
|
+
receive(event: InvalidationEvent): void;
|
|
34
34
|
private get;
|
|
35
35
|
reset(): void;
|
|
36
36
|
private runTapeUntil;
|
|
37
|
+
private storeIncrementalSnapshotIfAvailable;
|
|
37
38
|
/**
|
|
38
39
|
* Get the parse output for the request, parsing if necessary.
|
|
39
40
|
* @param force - Do not use the cache, instead force a new parse.
|
|
@@ -6,6 +6,10 @@ const default_pipelines_1 = require("../../core/steps/pipeline/default-pipelines
|
|
|
6
6
|
const assert_1 = require("../../util/assert");
|
|
7
7
|
const flowr_analyzer_controlflow_cache_1 = require("./flowr-analyzer-controlflow-cache");
|
|
8
8
|
const call_graph_1 = require("../../dataflow/graph/call-graph");
|
|
9
|
+
function isTreeSitterParse(parse) {
|
|
10
|
+
return typeof parse === 'object' && parse !== null && 'files' in parse
|
|
11
|
+
&& parse.files.every(f => typeof f.parsed === 'object' && f.parsed !== null && 'rootNode' in f.parsed);
|
|
12
|
+
}
|
|
9
13
|
/**
|
|
10
14
|
* This provides the full analyzer caching layer, please avoid using this directly
|
|
11
15
|
* and prefer the {@link FlowrAnalyzer}.
|
|
@@ -27,6 +31,10 @@ class FlowrAnalyzerCache extends flowr_cache_1.FlowrCache {
|
|
|
27
31
|
});
|
|
28
32
|
this.controlFlowCache = new flowr_analyzer_controlflow_cache_1.FlowrAnalyzerControlFlowCache();
|
|
29
33
|
this.callGraphCache = undefined;
|
|
34
|
+
this.computeIfAbsent(true, () => this.pipeline?.getResults(true));
|
|
35
|
+
}
|
|
36
|
+
static create(data) {
|
|
37
|
+
return new FlowrAnalyzerCache(data);
|
|
30
38
|
}
|
|
31
39
|
/** Free the current parse trees: tree-sitter trees live on the WASM heap, which the GC does not reclaim. */
|
|
32
40
|
disposeParse() {
|
|
@@ -35,26 +43,27 @@ class FlowrAnalyzerCache extends flowr_cache_1.FlowrCache {
|
|
|
35
43
|
file.parsed?.delete?.();
|
|
36
44
|
}
|
|
37
45
|
}
|
|
38
|
-
static create(data) {
|
|
39
|
-
return new FlowrAnalyzerCache(data);
|
|
40
|
-
}
|
|
41
46
|
receive(event) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
47
|
+
super.receive(event);
|
|
48
|
+
const type = event.type;
|
|
49
|
+
if (type === "full" /* InvalidationEventType.Full */) {
|
|
50
|
+
this.disposeParse();
|
|
51
|
+
}
|
|
52
|
+
switch (type) {
|
|
53
|
+
case "full" /* InvalidationEventType.Full */:
|
|
54
|
+
case "single-file-invalidate" /* InvalidationEventType.SingleFileInvalidate */:
|
|
46
55
|
this.initCacheProviders();
|
|
47
56
|
break;
|
|
48
57
|
default:
|
|
49
|
-
(0, assert_1.assertUnreachable)(
|
|
58
|
+
(0, assert_1.assertUnreachable)(type);
|
|
50
59
|
}
|
|
51
60
|
}
|
|
52
61
|
get() {
|
|
53
62
|
/* this will do a ref assignment, so indirect force */
|
|
54
|
-
return this.computeIfAbsent(false, () => this.pipeline
|
|
63
|
+
return this.computeIfAbsent(false, () => this.pipeline?.getResults(true));
|
|
55
64
|
}
|
|
56
65
|
reset() {
|
|
57
|
-
this.receive({ type: "full" /*
|
|
66
|
+
this.receive({ type: "full" /* InvalidationEventType.Full */ });
|
|
58
67
|
}
|
|
59
68
|
async runTapeUntil(force, until) {
|
|
60
69
|
(0, assert_1.guard)(this.args.context.files.loadingOrder.getUnorderedRequests().length > 0, 'At least one request must be set to run the analysis pipeline');
|
|
@@ -65,9 +74,19 @@ class FlowrAnalyzerCache extends flowr_cache_1.FlowrCache {
|
|
|
65
74
|
while ((g = until()) === undefined && this.pipeline.hasNextStep()) {
|
|
66
75
|
await this.pipeline.nextStep();
|
|
67
76
|
}
|
|
77
|
+
this.storeIncrementalSnapshotIfAvailable();
|
|
68
78
|
(0, assert_1.guard)(g !== undefined, 'Could not reach the desired pipeline step, invalid cache state(?)');
|
|
69
79
|
return g;
|
|
70
80
|
}
|
|
81
|
+
storeIncrementalSnapshotIfAvailable() {
|
|
82
|
+
if (this.args.parser.name !== 'tree-sitter') {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const parse = this.peekParse();
|
|
86
|
+
if (isTreeSitterParse(parse)) {
|
|
87
|
+
this.args.context.inc.storeOldParseResults(parse);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
71
90
|
/**
|
|
72
91
|
* Get the parse output for the request, parsing if necessary.
|
|
73
92
|
* @param force - Do not use the cache, instead force a new parse.
|
|
@@ -83,7 +102,7 @@ class FlowrAnalyzerCache extends flowr_cache_1.FlowrCache {
|
|
|
83
102
|
* @see {@link FlowrAnalyzerCache#parse} - to get the parse output, parsing if necessary.
|
|
84
103
|
*/
|
|
85
104
|
peekParse() {
|
|
86
|
-
return this.get()
|
|
105
|
+
return this.get()?.parse;
|
|
87
106
|
}
|
|
88
107
|
/**
|
|
89
108
|
* Get the normalized abstract syntax tree for the request, normalizing if necessary.
|
|
@@ -100,7 +119,7 @@ class FlowrAnalyzerCache extends flowr_cache_1.FlowrCache {
|
|
|
100
119
|
* @see {@link FlowrAnalyzerCache#normalize} - to get the normalized AST, normalizing if necessary.
|
|
101
120
|
*/
|
|
102
121
|
peekNormalize() {
|
|
103
|
-
return this.get()
|
|
122
|
+
return this.get()?.normalize;
|
|
104
123
|
}
|
|
105
124
|
/**
|
|
106
125
|
* Get the dataflow graph for the request, computing if necessary.
|
|
@@ -117,7 +136,7 @@ class FlowrAnalyzerCache extends flowr_cache_1.FlowrCache {
|
|
|
117
136
|
* @see {@link FlowrAnalyzerCache#dataflow} - to get the dataflow graph, computing if necessary.
|
|
118
137
|
*/
|
|
119
138
|
peekDataflow() {
|
|
120
|
-
return this.get()
|
|
139
|
+
return this.get()?.dataflow;
|
|
121
140
|
}
|
|
122
141
|
/**
|
|
123
142
|
* Get the control flow graph (CFG) for the request, computing if necessary.
|
|
@@ -1,25 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import type { StringableContent } from '../context/flowr-file';
|
|
2
|
+
/**
|
|
3
|
+
* Invalidation events describe how the cached analyzer state became stale.
|
|
4
|
+
*
|
|
5
|
+
* The current codebase triggers these events in two main ways:
|
|
6
|
+
* - {@link InvalidationEventType.Full}: emitted by explicit reset flows such as
|
|
7
|
+
* {@link FlowrAnalyzerContext#reset} or {@link FlowrAnalyzerCache#reset}. Use this
|
|
8
|
+
* when the whole project state should be treated as stale.
|
|
9
|
+
* - {@link InvalidationEventType.SingleFileInvalidate}: emitted by
|
|
10
|
+
* {@link FlowrFile#invalidate}, including {@link FlowrInlineTextFile#updateInlineContent},
|
|
11
|
+
* when one known file changed.
|
|
12
|
+
*/
|
|
13
|
+
export declare const enum InvalidationEventType {
|
|
14
|
+
Full = "full",
|
|
15
|
+
SingleFileInvalidate = "single-file-invalidate"
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Invalidation event for a single file identified by {@link filePath}.
|
|
19
|
+
*
|
|
20
|
+
* {@link oldContent} contains the file content from immediately before the
|
|
21
|
+
* change that triggered this event. In other words, it is the pre-change content
|
|
22
|
+
* for this invalidation, not necessarily the content from the last completed
|
|
23
|
+
* analysis run.
|
|
24
|
+
*/
|
|
25
|
+
export interface SingleFileInvalidationEvent<Content extends StringableContent = StringableContent> {
|
|
26
|
+
readonly type: InvalidationEventType.SingleFileInvalidate;
|
|
27
|
+
readonly oldContent: Content | undefined;
|
|
28
|
+
readonly filePath: string;
|
|
3
29
|
}
|
|
4
|
-
export type
|
|
5
|
-
type:
|
|
6
|
-
}
|
|
7
|
-
export
|
|
8
|
-
|
|
30
|
+
export type InvalidationEvent<Content extends StringableContent = StringableContent> = {
|
|
31
|
+
type: InvalidationEventType.Full;
|
|
32
|
+
} | SingleFileInvalidationEvent<Content>;
|
|
33
|
+
export type InvalidationEventHandler<Content extends StringableContent = StringableContent> = (event: InvalidationEvent<Content>) => void;
|
|
34
|
+
export interface InvalidationEventReceiver<Content extends StringableContent = StringableContent> {
|
|
35
|
+
receive: InvalidationEventHandler<Content>;
|
|
9
36
|
}
|
|
10
37
|
/**
|
|
11
38
|
* Central class for caching analysis results in FlowR.
|
|
12
39
|
*/
|
|
13
|
-
export declare abstract class FlowrCache<Cache> implements
|
|
40
|
+
export declare abstract class FlowrCache<Cache> implements InvalidationEventReceiver {
|
|
14
41
|
private value;
|
|
15
42
|
private dependents;
|
|
16
|
-
registerDependent(dependent:
|
|
17
|
-
removeDependent(dependent:
|
|
18
|
-
receive(event:
|
|
43
|
+
registerDependent(dependent: InvalidationEventReceiver): void;
|
|
44
|
+
removeDependent(dependent: InvalidationEventReceiver): void;
|
|
45
|
+
receive(event: InvalidationEvent): void;
|
|
19
46
|
/**
|
|
20
47
|
* Notify all dependents of a cache invalidation event.
|
|
21
48
|
*/
|
|
22
|
-
notifyDependents(event:
|
|
49
|
+
notifyDependents(event: InvalidationEvent): void;
|
|
23
50
|
/**
|
|
24
51
|
* Get the cached value or compute it if not present.
|
|
25
52
|
* This will, by default, not trigger any {@link notifyDependents} calls, as this is only a cache retrieval.
|
|
@@ -15,13 +15,15 @@ class FlowrCache {
|
|
|
15
15
|
this.dependents = this.dependents.filter(d => d !== dependent);
|
|
16
16
|
}
|
|
17
17
|
receive(event) {
|
|
18
|
+
const type = event.type;
|
|
18
19
|
/* we will update this as soon as we support incremental update patterns */
|
|
19
|
-
switch (
|
|
20
|
-
case "full" /*
|
|
20
|
+
switch (type) {
|
|
21
|
+
case "full" /* InvalidationEventType.Full */:
|
|
22
|
+
case "single-file-invalidate" /* InvalidationEventType.SingleFileInvalidate */:
|
|
21
23
|
this.value = undefined;
|
|
22
24
|
break;
|
|
23
25
|
default:
|
|
24
|
-
(0, assert_1.assertUnreachable)(
|
|
26
|
+
(0, assert_1.assertUnreachable)(type);
|
|
25
27
|
}
|
|
26
28
|
/* in the future we want to defer this *after* the dataflow is re-computed, then all receivers can decide whether they need to update */
|
|
27
29
|
this.notifyDependents(event);
|
|
@@ -12,6 +12,9 @@ import { FlowrAnalyzerEnvironmentContext } from './flowr-analyzer-environment-co
|
|
|
12
12
|
import type { ReadOnlyFlowrAnalyzerMetaContext } from './flowr-analyzer-meta-context';
|
|
13
13
|
import { FlowrAnalyzerMetaContext } from './flowr-analyzer-meta-context';
|
|
14
14
|
import type { FlowrAnalyzer } from '../flowr-analyzer';
|
|
15
|
+
import type { ReadOnlyFlowrAnalyzerIncrementalAnalysisContext } from './flowr-analyzer-incremental-analysis-context';
|
|
16
|
+
import { FlowrAnalyzerIncrementalAnalysisContext } from './flowr-analyzer-incremental-analysis-context';
|
|
17
|
+
import type { InvalidationEvent, InvalidationEventReceiver } from '../cache/flowr-cache';
|
|
15
18
|
import { FlowrAnalyzerGasContext, type ReadOnlyFlowrAnalyzerGasContext } from './flowr-analyzer-gas-context';
|
|
16
19
|
/**
|
|
17
20
|
* This is a read-only interface to the {@link FlowrAnalyzerContext}.
|
|
@@ -27,6 +30,8 @@ export interface ReadOnlyFlowrAnalyzerContext {
|
|
|
27
30
|
readonly deps: ReadOnlyFlowrAnalyzerDependenciesContext;
|
|
28
31
|
/** Environment information used during analysis. */
|
|
29
32
|
readonly env: ReadOnlyFlowrAnalyzerEnvironmentContext;
|
|
33
|
+
/** The incremental context provides potential information for the next incremental analysis run */
|
|
34
|
+
readonly inc: ReadOnlyFlowrAnalyzerIncrementalAnalysisContext;
|
|
30
35
|
/** The configuration options used by the analyzer. */
|
|
31
36
|
readonly config: FlowrConfig;
|
|
32
37
|
/** class names of plugins that activated (produced a result) since the last reset; only filled when `config.repl.showPlugins` is set */
|
|
@@ -63,11 +68,12 @@ export interface ReadOnlyFlowrAnalyzerContext {
|
|
|
63
68
|
* {@link deps.getDependency}.
|
|
64
69
|
* If you are just interested in inspecting the context, you can use {@link ReadOnlyFlowrAnalyzerContext} instead (e.g., via {@link inspect}).
|
|
65
70
|
*/
|
|
66
|
-
export declare class FlowrAnalyzerContext implements ReadOnlyFlowrAnalyzerContext {
|
|
71
|
+
export declare class FlowrAnalyzerContext implements ReadOnlyFlowrAnalyzerContext, InvalidationEventReceiver {
|
|
67
72
|
readonly meta: FlowrAnalyzerMetaContext;
|
|
68
73
|
readonly files: FlowrAnalyzerFilesContext;
|
|
69
74
|
readonly deps: FlowrAnalyzerDependenciesContext;
|
|
70
75
|
readonly env: FlowrAnalyzerEnvironmentContext;
|
|
76
|
+
readonly inc: FlowrAnalyzerIncrementalAnalysisContext;
|
|
71
77
|
/** class names of plugins that activated since the last reset; only filled when `config.repl.showPlugins` is set */
|
|
72
78
|
readonly activatedPlugins: Set<string>;
|
|
73
79
|
readonly gas: FlowrAnalyzerGasContext;
|
|
@@ -143,6 +149,7 @@ export declare class FlowrAnalyzerContext implements ReadOnlyFlowrAnalyzerContex
|
|
|
143
149
|
* Reset the context to its initial state, e.g., removing all files, dependencies, and loading orders.
|
|
144
150
|
*/
|
|
145
151
|
reset(): void;
|
|
152
|
+
receive(event: InvalidationEvent): void;
|
|
146
153
|
}
|
|
147
154
|
/**
|
|
148
155
|
* Lifting {@link requestFromInput} to create a full {@link FlowrAnalyzerContext} from input requests.
|
|
@@ -16,6 +16,7 @@ const log_1 = require("../../util/log");
|
|
|
16
16
|
const flowr_file_1 = require("./flowr-file");
|
|
17
17
|
const flowr_analyzer_environment_context_1 = require("./flowr-analyzer-environment-context");
|
|
18
18
|
const flowr_analyzer_meta_context_1 = require("./flowr-analyzer-meta-context");
|
|
19
|
+
const flowr_analyzer_incremental_analysis_context_1 = require("./flowr-analyzer-incremental-analysis-context");
|
|
19
20
|
const flowr_analyzer_gas_context_1 = require("./flowr-analyzer-gas-context");
|
|
20
21
|
/**
|
|
21
22
|
* This summarizes the other context layers used by the {@link FlowrAnalyzer}.
|
|
@@ -33,6 +34,7 @@ class FlowrAnalyzerContext {
|
|
|
33
34
|
files;
|
|
34
35
|
deps;
|
|
35
36
|
env;
|
|
37
|
+
inc;
|
|
36
38
|
/** class names of plugins that activated since the last reset; only filled when `config.repl.showPlugins` is set */
|
|
37
39
|
activatedPlugins = new Set();
|
|
38
40
|
gas;
|
|
@@ -143,8 +145,9 @@ class FlowrAnalyzerContext {
|
|
|
143
145
|
this.baseConfig = config;
|
|
144
146
|
this._config = config;
|
|
145
147
|
const loadingOrder = new flowr_analyzer_loading_order_context_1.FlowrAnalyzerLoadingOrderContext(this, plugins.get(flowr_analyzer_plugin_1.PluginType.LoadingOrder));
|
|
146
|
-
this.files = new flowr_analyzer_files_context_1.FlowrAnalyzerFilesContext(loadingOrder, (plugins.get(flowr_analyzer_plugin_1.PluginType.ProjectDiscovery) ?? []), (plugins.get(flowr_analyzer_plugin_1.PluginType.FileLoad) ?? []));
|
|
148
|
+
this.files = new flowr_analyzer_files_context_1.FlowrAnalyzerFilesContext(this, loadingOrder, (plugins.get(flowr_analyzer_plugin_1.PluginType.ProjectDiscovery) ?? []), (plugins.get(flowr_analyzer_plugin_1.PluginType.FileLoad) ?? []));
|
|
147
149
|
this.env = new flowr_analyzer_environment_context_1.FlowrAnalyzerEnvironmentContext(this);
|
|
150
|
+
this.inc = new flowr_analyzer_incremental_analysis_context_1.FlowrAnalyzerIncrementalAnalysisContext(this);
|
|
148
151
|
const functions = new flowr_analyzer_functions_context_1.FlowrAnalyzerFunctionsContext(this);
|
|
149
152
|
this.deps = new flowr_analyzer_dependencies_context_1.FlowrAnalyzerDependenciesContext(functions, (plugins.get(flowr_analyzer_plugin_1.PluginType.DependencyIdentification) ?? []));
|
|
150
153
|
// the plugins contributing the metadata are the ones the dependency context runs on demand
|
|
@@ -212,6 +215,13 @@ class FlowrAnalyzerContext {
|
|
|
212
215
|
this.meta.reset();
|
|
213
216
|
this.gas.reset();
|
|
214
217
|
this.activatedPlugins.clear();
|
|
218
|
+
this.receive({ type: "full" /* InvalidationEventType.Full */ });
|
|
219
|
+
}
|
|
220
|
+
receive(event) {
|
|
221
|
+
this.meta.receive(event);
|
|
222
|
+
this.files.receive(event);
|
|
223
|
+
this.deps.receive(event);
|
|
224
|
+
this.inc.receive(event);
|
|
215
225
|
}
|
|
216
226
|
}
|
|
217
227
|
exports.FlowrAnalyzerContext = FlowrAnalyzerContext;
|
|
@@ -6,6 +6,7 @@ import { Identifier } from '../../dataflow/environments/identifier';
|
|
|
6
6
|
import type { DecodedFunction } from '../sigdb/decode';
|
|
7
7
|
import type { Range } from 'semver';
|
|
8
8
|
import type { FlowrAnalyzerFunctionsContext, ReadOnlyFlowrAnalyzerFunctionsContext } from './flowr-analyzer-functions-context';
|
|
9
|
+
import type { InvalidationEvent, InvalidationEventReceiver } from '../cache/flowr-cache';
|
|
9
10
|
/**
|
|
10
11
|
* Read-only interface to the {@link FlowrAnalyzerDependenciesContext} for inspecting dependencies without modifying them.
|
|
11
12
|
*/
|
|
@@ -84,7 +85,7 @@ export interface ReadOnlyFlowrAnalyzerDependenciesContext {
|
|
|
84
85
|
/**
|
|
85
86
|
* Manages the project's dependencies, their versions, and their interplay with {@link FlowrAnalyzerPackageVersionsPlugin}s.
|
|
86
87
|
*/
|
|
87
|
-
export declare class FlowrAnalyzerDependenciesContext extends AbstractFlowrAnalyzerContext<undefined, void, FlowrAnalyzerPackageVersionsPlugin> implements ReadOnlyFlowrAnalyzerDependenciesContext {
|
|
88
|
+
export declare class FlowrAnalyzerDependenciesContext extends AbstractFlowrAnalyzerContext<undefined, void, FlowrAnalyzerPackageVersionsPlugin> implements ReadOnlyFlowrAnalyzerDependenciesContext, InvalidationEventReceiver {
|
|
88
89
|
readonly name = "flowr-analyzer-dependencies-context";
|
|
89
90
|
readonly functionsContext: FlowrAnalyzerFunctionsContext;
|
|
90
91
|
private dependencies;
|
|
@@ -109,12 +110,13 @@ export declare class FlowrAnalyzerDependenciesContext extends AbstractFlowrAnaly
|
|
|
109
110
|
addDatabaseSource(source: string): Promise<void>;
|
|
110
111
|
/** Eagerly mount every version plugin's signature database up front (see `solver.sigdb.eagerlyLoad`). */
|
|
111
112
|
eagerlyLoadSignatureDatabases(): void;
|
|
113
|
+
receive(event: InvalidationEvent): void;
|
|
112
114
|
constructor(functionsContext: FlowrAnalyzerFunctionsContext, plugins?: readonly FlowrAnalyzerPackageVersionsPlugin[]);
|
|
113
115
|
resolveStaticDependencies(): void;
|
|
114
116
|
/** Runs the static plugins once. They fill this context and the project metadata, so both gate their reads on it. */
|
|
115
117
|
ensureStaticsLoaded(): void;
|
|
116
118
|
/**
|
|
117
|
-
* Register a dependency declared by a project metadata file (`DESCRIPTION`, `renv.lock`, `rv.lock`). Gated by
|
|
119
|
+
* Register a dependency declared by a project metadata file (`DESCRIPTION`, `renv.lock`, `rv.lock`, `uvr.lock`). Gated by
|
|
118
120
|
* `solver.sigdb.loadProjectDependencies`: when project-dependency loading is disabled this is a no-op, so the
|
|
119
121
|
* declared deps never enter the context (unlike {@link addDependency}, used for on-demand signature-database
|
|
120
122
|
* resolution).
|
|
@@ -5,6 +5,7 @@ const abstract_flowr_analyzer_context_1 = require("./abstract-flowr-analyzer-con
|
|
|
5
5
|
const flowr_analyzer_package_versions_plugin_1 = require("../plugins/package-version-plugins/flowr-analyzer-package-versions-plugin");
|
|
6
6
|
const package_1 = require("../plugins/package-version-plugins/package");
|
|
7
7
|
const identifier_1 = require("../../dataflow/environments/identifier");
|
|
8
|
+
const assert_1 = require("../../util/assert");
|
|
8
9
|
const config_1 = require("../../config");
|
|
9
10
|
const r_version_1 = require("../../util/r-version");
|
|
10
11
|
/**
|
|
@@ -101,6 +102,19 @@ class FlowrAnalyzerDependenciesContext extends abstract_flowr_analyzer_context_1
|
|
|
101
102
|
p.preloadDatabasesSync();
|
|
102
103
|
}
|
|
103
104
|
}
|
|
105
|
+
receive(event) {
|
|
106
|
+
const type = event.type;
|
|
107
|
+
switch (type) {
|
|
108
|
+
case "full" /* InvalidationEventType.Full */:
|
|
109
|
+
this.reset();
|
|
110
|
+
break;
|
|
111
|
+
case "single-file-invalidate" /* InvalidationEventType.SingleFileInvalidate */:
|
|
112
|
+
// nothing to do
|
|
113
|
+
break;
|
|
114
|
+
default:
|
|
115
|
+
(0, assert_1.assertUnreachable)(type);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
104
118
|
constructor(functionsContext, plugins) {
|
|
105
119
|
super(functionsContext.getAttachedContext(), flowr_analyzer_package_versions_plugin_1.FlowrAnalyzerPackageVersionsPlugin.defaultPlugin(), plugins);
|
|
106
120
|
this.functionsContext = functionsContext;
|
|
@@ -116,7 +130,7 @@ class FlowrAnalyzerDependenciesContext extends abstract_flowr_analyzer_context_1
|
|
|
116
130
|
}
|
|
117
131
|
}
|
|
118
132
|
/**
|
|
119
|
-
* Register a dependency declared by a project metadata file (`DESCRIPTION`, `renv.lock`, `rv.lock`). Gated by
|
|
133
|
+
* Register a dependency declared by a project metadata file (`DESCRIPTION`, `renv.lock`, `rv.lock`, `uvr.lock`). Gated by
|
|
120
134
|
* `solver.sigdb.loadProjectDependencies`: when project-dependency loading is disabled this is a no-op, so the
|
|
121
135
|
* declared deps never enter the context (unlike {@link addDependency}, used for on-demand signature-database
|
|
122
136
|
* resolution).
|
|
@@ -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.
|