@eagleoutice/flowr 2.17.9 → 2.17.11
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/cli/repl/core.js +4 -0
- package/config.d.ts +10 -0
- package/config.js +8 -1
- package/control-flow/control-flow-graph.js +11 -1
- package/dataflow/environments/default-builtin-config/guards-primitive-lang.js +1 -1
- package/dataflow/environments/default-builtin-config/guards.js +6 -1
- package/dataflow/environments/default-builtin-config/index.d.ts +1 -1
- package/dataflow/environments/default-builtin-config/network-access.d.ts +1 -1
- package/dataflow/environments/default-builtin-config/network-access.js +2 -0
- package/dataflow/environments/environment.d.ts +2 -0
- package/dataflow/environments/environment.js +5 -0
- package/dataflow/environments/frame-memory.d.ts +9 -0
- package/dataflow/environments/frame-memory.js +37 -0
- package/dataflow/environments/group-generics.d.ts +2 -0
- package/dataflow/environments/group-generics.js +7 -0
- package/dataflow/environments/identifier.d.ts +2 -0
- package/dataflow/environments/identifier.js +16 -0
- package/dataflow/environments/pkg-name.d.ts +1 -0
- package/dataflow/environments/query-fn-props.d.ts +4 -0
- package/dataflow/environments/query-fn-props.js +21 -4
- package/dataflow/environments/resolve-by-name.js +5 -3
- package/dataflow/extractor.js +26 -4
- package/dataflow/fn/argument-roles.js +17 -4
- package/dataflow/fn/guards/call-contracts.js +8 -4
- package/dataflow/fn/guards/function-guards.d.ts +13 -4
- package/dataflow/fn/guards/function-guards.js +147 -52
- package/dataflow/fn/guards/guard-term.d.ts +6 -3
- package/dataflow/fn/guards/guard-term.js +12 -6
- package/dataflow/fn/strict-function.js +6 -2
- package/dataflow/graph/df-helper.d.ts +5 -0
- package/dataflow/graph/df-helper.js +22 -0
- package/dataflow/graph/graph.d.ts +2 -0
- package/dataflow/graph/graph.js +9 -5
- package/dataflow/internal/dispatch-linking.d.ts +6 -0
- package/dataflow/internal/dispatch-linking.js +25 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.d.ts +32 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +52 -21
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +28 -19
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +75 -0
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +20 -6
- package/dataflow/processor.d.ts +3 -0
- package/documentation/data/faq/faqs.js +4 -0
- package/documentation/wiki-analyzer.js +13 -2
- package/documentation/wiki-interface.js +1 -0
- package/documentation/wiki-linter.js +3 -0
- package/linter/linter-executor.js +4 -1
- package/linter/linter-format.d.ts +5 -5
- package/linter/linter-rules.d.ts +47 -13
- package/linter/linter-rules.js +3 -1
- package/linter/rules/absolute-file-paths.js +1 -1
- package/linter/rules/autoload-files.d.ts +33 -0
- package/linter/rules/autoload-files.js +94 -0
- package/linter/rules/cmd-check/description-metadata.d.ts +2 -2
- package/linter/rules/cmd-check/description-metadata.js +1 -1
- package/linter/rules/cmd-check/documentation-mismatch.d.ts +2 -2
- package/linter/rules/cmd-check/documentation-mismatch.js +1 -1
- package/linter/rules/cmd-check/file-checks.d.ts +6 -11
- package/linter/rules/cmd-check/file-checks.js +8 -3
- package/linter/rules/cmd-check/package-data.d.ts +2 -2
- package/linter/rules/cmd-check/package-data.js +1 -1
- package/linter/rules/cmd-check/package-metafiles.js +1 -1
- package/linter/rules/cmd-check/package-structure.d.ts +2 -2
- package/linter/rules/cmd-check/package-structure.js +1 -1
- package/linter/rules/cmd-check/rd-files.js +1 -1
- package/linter/rules/naming-convention.d.ts +9 -2
- package/linter/rules/process-state-in-session.js +4 -1
- package/linter/rules/software-has-license.d.ts +2 -2
- package/linter/rules/software-has-license.js +1 -2
- package/linter/rules/stop-call.d.ts +8 -3
- package/linter/rules/useless-loop.d.ts +1 -1
- package/package.json +1 -1
- package/project/cache/flowr-analyzer-cache.d.ts +3 -0
- package/project/cache/flowr-analyzer-cache.js +9 -0
- package/project/context/flowr-analyzer-context.d.ts +4 -3
- package/project/context/flowr-analyzer-context.js +18 -6
- package/project/context/flowr-analyzer-dependencies-context.d.ts +9 -0
- package/project/context/flowr-analyzer-dependencies-context.js +35 -6
- package/project/context/flowr-analyzer-environment-context.d.ts +1 -0
- package/project/context/flowr-analyzer-environment-context.js +1 -0
- package/project/context/flowr-analyzer-files-context.d.ts +4 -0
- package/project/context/flowr-analyzer-files-context.js +24 -0
- package/project/context/flowr-analyzer-functions-context.d.ts +1 -0
- package/project/context/flowr-analyzer-functions-context.js +6 -0
- package/project/context/flowr-analyzer-gas-context.d.ts +1 -0
- package/project/context/flowr-analyzer-gas-context.js +1 -0
- package/project/context/flowr-analyzer-incremental-analysis-context.d.ts +24 -0
- package/project/context/flowr-analyzer-incremental-analysis-context.js +54 -0
- package/project/context/flowr-analyzer-loading-order-context.d.ts +1 -0
- package/project/context/flowr-analyzer-loading-order-context.js +14 -0
- package/project/context/flowr-analyzer-meta-context.d.ts +1 -0
- package/project/context/flowr-analyzer-meta-context.js +11 -0
- package/project/context/flowr-file.d.ts +2 -1
- package/project/context/flowr-file.js +5 -2
- package/project/flowr-analyzer.d.ts +22 -3
- package/project/flowr-analyzer.js +36 -0
- package/project/incremental/incremental-dataflow/incremental-dataflow.d.ts +142 -0
- package/project/incremental/incremental-dataflow/incremental-dataflow.js +330 -0
- package/project/plugins/flowr-analyzer-plugin.d.ts +22 -2
- package/project/plugins/flowr-analyzer-plugin.js +16 -1
- package/project/plugins/incremental/incremental-dataflow/flowr-analyzer-incremental-dataflow-heuristic-plugin.d.ts +52 -0
- package/project/plugins/incremental/incremental-dataflow/flowr-analyzer-incremental-dataflow-heuristic-plugin.js +50 -0
- package/project/plugins/incremental/incremental-dataflow/flowr-analyzer-incremental-dataflow-update-type-plugin.d.ts +77 -0
- package/project/plugins/incremental/incremental-dataflow/flowr-analyzer-incremental-dataflow-update-type-plugin.js +151 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.d.ts +2 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.js +4 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +1 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +3 -0
- package/project/plugins/plugin-registry.d.ts +3 -1
- package/project/plugins/plugin-registry.js +6 -1
- package/project/sigdb/decode.js +4 -1
- package/project/sigdb/dict.d.ts +7 -4
- package/project/sigdb/dict.js +20 -6
- package/project/sigdb/guarded-source.js +10 -0
- package/project/sigdb/reader.d.ts +8 -2
- package/project/sigdb/reader.js +44 -30
- package/queries/catalog/input-sources-query/simple-input-classifier.js +84 -10
- package/util/flowr-version.d.ts +1 -1
- package/util/flowr-version.js +2 -2
- package/util/objects.d.ts +14 -0
- package/util/objects.js +100 -0
|
@@ -2,7 +2,7 @@ import type { BrandedIdentifier } from '../../dataflow/environments/identifier';
|
|
|
2
2
|
import { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
3
3
|
import type { DataflowGraph } from '../../dataflow/graph/graph';
|
|
4
4
|
import type { MergeableRecord } from '../../util/objects';
|
|
5
|
-
import { type LintingResult, type LintQuickFixReplacement, LintingRuleCertainty } from '../linter-format';
|
|
5
|
+
import { type LintingResult, type LintQuickFixReplacement, LintingResultCertainty, LintingRuleCertainty } from '../linter-format';
|
|
6
6
|
import { LintingRuleTag } from '../linter-tags';
|
|
7
7
|
export declare enum CasingConvention {
|
|
8
8
|
CamelCase = "camelCase",
|
|
@@ -50,7 +50,14 @@ export declare function createNamingConventionQuickFixes(graph: DataflowGraph, n
|
|
|
50
50
|
export declare const NAMING_CONVENTION: {
|
|
51
51
|
readonly createSearch: () => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter"], import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, Promise<import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, [] | import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>>;
|
|
52
52
|
readonly processSearchResult: (elements: import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>, config: NamingConventionConfig, data: import("../..").ReadonlyFlowrAnalysisProvider<import("../..").KnownParser>) => Promise<{
|
|
53
|
-
results:
|
|
53
|
+
results: {
|
|
54
|
+
involvedId: NodeId;
|
|
55
|
+
quickFix: LintQuickFixReplacement[] | undefined;
|
|
56
|
+
certainty: LintingResultCertainty;
|
|
57
|
+
detectedCasing: CasingConvention;
|
|
58
|
+
name: string;
|
|
59
|
+
loc: readonly [startLine: import("../../util/range").Line, startColumn: import("../../util/range").Column, endLine: import("../../util/range").Line, endColumn: import("../../util/range").Column, f?: string | undefined] | undefined;
|
|
60
|
+
}[];
|
|
54
61
|
'.meta': {
|
|
55
62
|
numMatches: number;
|
|
56
63
|
numBreak: number;
|
|
@@ -239,7 +239,10 @@ exports.PROCESS_STATE_IN_SESSION = {
|
|
|
239
239
|
add(node, ProcessStateChange.CacheKey, write.name, write.fix.replace('%s', missing.join(', ')));
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
|
-
return {
|
|
242
|
+
return {
|
|
243
|
+
results: results.toSorted((a, b) => range_1.SourceLocation.compare(a.loc, b.loc)),
|
|
244
|
+
'.meta': { sessionFunctions: sessions.length }
|
|
245
|
+
};
|
|
243
246
|
},
|
|
244
247
|
prettyPrint: (0, linter_format_1.prettyPrint)(result => `${result.change} by ${result.name} at ${range_1.SourceLocation.format(result.loc)}`, result => `${result.name} changes the state all sessions share (${result.change}) at ${range_1.SourceLocation.format(result.loc)}; instead, use ${result.suggestion}`),
|
|
245
248
|
info: {
|
|
@@ -10,8 +10,8 @@ export interface SoftwareHasLicenseConfig extends MergeableRecord {
|
|
|
10
10
|
}
|
|
11
11
|
export type SoftwareHasLicenseMetadata = MergeableRecord;
|
|
12
12
|
export declare const SOFTWARE_HAS_LICENSE: {
|
|
13
|
-
readonly createSearch: () =>
|
|
14
|
-
readonly processSearchResult: (_elements:
|
|
13
|
+
readonly createSearch: () => never;
|
|
14
|
+
readonly processSearchResult: (_elements: never, config: SoftwareHasLicenseConfig, data: import("../..").ReadonlyFlowrAnalysisProvider<import("../..").KnownParser>) => {
|
|
15
15
|
results: SoftwareHasLicenseResult[];
|
|
16
16
|
'.meta': {};
|
|
17
17
|
};
|
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SOFTWARE_HAS_LICENSE = void 0;
|
|
4
4
|
const linter_format_1 = require("../linter-format");
|
|
5
|
-
const flowr_search_builder_1 = require("../../search/flowr-search-builder");
|
|
6
5
|
const range_1 = require("../../util/range");
|
|
7
6
|
const linter_tags_1 = require("../linter-tags");
|
|
8
7
|
const flowr_file_1 = require("../../project/context/flowr-file");
|
|
9
8
|
const flowr_description_file_1 = require("../../project/plugins/file-plugins/files/flowr-description-file");
|
|
10
9
|
exports.SOFTWARE_HAS_LICENSE = {
|
|
11
|
-
createSearch: () =>
|
|
10
|
+
createSearch: () => undefined,
|
|
12
11
|
processSearchResult: (_elements, config, data) => {
|
|
13
12
|
const ctx = data.inspectContext();
|
|
14
13
|
const licenseFiles = ctx.files.getFilesByRole(flowr_file_1.FileRole.License);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { type LintingResult, LintingRuleCertainty } from '../linter-format';
|
|
1
|
+
import { type LintingResult, LintingResultCertainty, LintingRuleCertainty, type LintQuickFixReplacement } from '../linter-format';
|
|
2
2
|
import type { MergeableRecord } from '../../util/objects';
|
|
3
3
|
import { LintingRuleTag } from '../linter-tags';
|
|
4
|
-
import type { Writable } from 'ts-essentials';
|
|
5
4
|
import type { ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
6
5
|
import type { ReadonlyFlowrAnalysisProvider } from '../../project/flowr-analyzer';
|
|
6
|
+
import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
7
7
|
export type StopCallResult = LintingResult;
|
|
8
8
|
export type StopCallConfig = MergeableRecord;
|
|
9
9
|
export interface StopCallMetadata extends MergeableRecord {
|
|
@@ -12,7 +12,12 @@ export interface StopCallMetadata extends MergeableRecord {
|
|
|
12
12
|
export declare const STOP_CALL: {
|
|
13
13
|
readonly createSearch: () => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter"], ParentInformation, Promise<import("../../search/flowr-search").FlowrSearchElements<ParentInformation, [] | import("../../search/flowr-search").FlowrSearchElement<ParentInformation>[]>>>;
|
|
14
14
|
readonly processSearchResult: (elements: import("../../search/flowr-search").FlowrSearchElements<ParentInformation, import("../../search/flowr-search").FlowrSearchElement<ParentInformation>[]>, _config: MergeableRecord, data: ReadonlyFlowrAnalysisProvider<import("../..").KnownParser>) => Promise<{
|
|
15
|
-
results:
|
|
15
|
+
results: {
|
|
16
|
+
certainty: LintingResultCertainty;
|
|
17
|
+
involvedId: NodeId;
|
|
18
|
+
loc: readonly [startLine: import("../../util/range").Line, startColumn: import("../../util/range").Column, endLine: import("../../util/range").Line, endColumn: import("../../util/range").Column, f?: string | undefined] | undefined;
|
|
19
|
+
quickFix: LintQuickFixReplacement[] | undefined;
|
|
20
|
+
}[];
|
|
16
21
|
'.meta': StopCallMetadata;
|
|
17
22
|
}>;
|
|
18
23
|
readonly prettyPrint: {
|
|
@@ -18,7 +18,7 @@ export declare const USELESS_LOOP: {
|
|
|
18
18
|
readonly processSearchResult: (elements: import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>, useLessLoopConfig: UselessLoopConfig, data: import("../..").ReadonlyFlowrAnalysisProvider<import("../..").KnownParser>) => Promise<{
|
|
19
19
|
results: {
|
|
20
20
|
name: string;
|
|
21
|
-
loc: SourceLocation;
|
|
21
|
+
loc: SourceLocation | undefined;
|
|
22
22
|
certainty: import("../linter-format").LintingResultCertainty;
|
|
23
23
|
involvedId: import("../..").NodeId | import("../..").NodeId[] | undefined;
|
|
24
24
|
}[];
|
package/package.json
CHANGED
|
@@ -9,6 +9,7 @@ import type { CfgSimplificationPassName } from '../../control-flow/cfg-simplific
|
|
|
9
9
|
import type { ControlFlowInformation } from '../../control-flow/control-flow-graph';
|
|
10
10
|
import type { FlowrAnalyzerContext } from '../context/flowr-analyzer-context';
|
|
11
11
|
import { CallGraph } from '../../dataflow/graph/call-graph';
|
|
12
|
+
import type { ForkOptions } from '../flowr-analyzer';
|
|
12
13
|
interface FlowrAnalyzerCacheOptions<Parser extends KnownParser> {
|
|
13
14
|
parser: Parser;
|
|
14
15
|
context: FlowrAnalyzerContext;
|
|
@@ -75,6 +76,8 @@ export declare class FlowrAnalyzerCache<Parser extends KnownParser> extends Flow
|
|
|
75
76
|
* @see {@link FlowrAnalyzerCache#dataflow} - to get the dataflow graph, computing if necessary.
|
|
76
77
|
*/
|
|
77
78
|
peekDataflow(): NonNullable<AnalyzerCacheType<Parser>['dataflow']> | undefined;
|
|
79
|
+
/** Reuse cached results from the source cache according to the given fork options. */
|
|
80
|
+
fork(source: FlowrAnalyzerCache<KnownParser>, options?: ForkOptions): void;
|
|
78
81
|
/**
|
|
79
82
|
* Get the control flow graph (CFG) for the request, computing if necessary.
|
|
80
83
|
* @param force - Do not use the cache, instead force new analyses.
|
|
@@ -157,6 +157,15 @@ class FlowrAnalyzerCache extends flowr_cache_1.FlowrCache {
|
|
|
157
157
|
peekDataflow() {
|
|
158
158
|
return this.get()?.dataflow;
|
|
159
159
|
}
|
|
160
|
+
/** Reuse cached results from the source cache according to the given fork options. */
|
|
161
|
+
fork(source, options) {
|
|
162
|
+
const target = this.get();
|
|
163
|
+
target.normalize = source.peekNormalize();
|
|
164
|
+
target.parse = source.peekParse();
|
|
165
|
+
if (options?.forkDataflow ?? true) {
|
|
166
|
+
target.dataflow = source.peekDataflow();
|
|
167
|
+
}
|
|
168
|
+
}
|
|
160
169
|
/**
|
|
161
170
|
* Get the control flow graph (CFG) for the request, computing if necessary.
|
|
162
171
|
* @param force - Do not use the cache, instead force new analyses.
|
|
@@ -9,7 +9,7 @@ import type { DeepPartial } from 'ts-essentials';
|
|
|
9
9
|
import { type FileRole, type FlowrFileProvider } from './flowr-file';
|
|
10
10
|
import { type ReadOnlyFlowrAnalyzerEnvironmentContext, FlowrAnalyzerEnvironmentContext } from './flowr-analyzer-environment-context';
|
|
11
11
|
import { type ReadOnlyFlowrAnalyzerMetaContext, FlowrAnalyzerMetaContext } from './flowr-analyzer-meta-context';
|
|
12
|
-
import type { FlowrAnalyzer } from '../flowr-analyzer';
|
|
12
|
+
import type { FlowrAnalyzer, ForkOptions } from '../flowr-analyzer';
|
|
13
13
|
import { type ReadOnlyFlowrAnalyzerIncrementalAnalysisContext, FlowrAnalyzerIncrementalAnalysisContext } from './flowr-analyzer-incremental-analysis-context';
|
|
14
14
|
import { type InvalidationEvent, type InvalidationEventReceiver } from '../cache/flowr-cache';
|
|
15
15
|
import { FlowrAnalyzerGasContext, type ReadOnlyFlowrAnalyzerGasContext } from './flowr-analyzer-gas-context';
|
|
@@ -92,8 +92,7 @@ export declare class FlowrAnalyzerContext implements ReadOnlyFlowrAnalyzerContex
|
|
|
92
92
|
readonly activatedPlugins: Set<string>;
|
|
93
93
|
readonly gas: FlowrAnalyzerGasContext;
|
|
94
94
|
private _analyzer;
|
|
95
|
-
|
|
96
|
-
private _detectedR;
|
|
95
|
+
readonly plugins: ReadonlyMap<PluginType, readonly FlowrAnalyzerPlugin[]>;
|
|
97
96
|
/** the configuration as given, i.e. before {@link FlowrConfig.specializeConfig} is applied */
|
|
98
97
|
readonly baseConfig: FlowrConfig;
|
|
99
98
|
/** {@link baseConfig}, specialized for {@link _configKind} */
|
|
@@ -136,6 +135,8 @@ export declare class FlowrAnalyzerContext implements ReadOnlyFlowrAnalyzerContex
|
|
|
136
135
|
* @param plugins - The plugins to run, either already grouped by their {@link PluginType} or as a plain list.
|
|
137
136
|
*/
|
|
138
137
|
constructor(config: FlowrConfig, plugins?: ReadonlyMap<PluginType, readonly FlowrAnalyzerPlugin[]> | readonly FlowrAnalyzerPlugin[]);
|
|
138
|
+
/** Clone state from the source context into this context */
|
|
139
|
+
fork(source: FlowrAnalyzerContext, options?: ForkOptions): void;
|
|
139
140
|
/**
|
|
140
141
|
* Provides the analyzer associated with this context, if any.
|
|
141
142
|
* This is usually set when the context is used within an analyzer instance.
|
|
@@ -42,8 +42,7 @@ class FlowrAnalyzerContext {
|
|
|
42
42
|
activatedPlugins = new Set();
|
|
43
43
|
gas;
|
|
44
44
|
_analyzer;
|
|
45
|
-
|
|
46
|
-
_detectedR;
|
|
45
|
+
plugins;
|
|
47
46
|
/** the configuration as given, i.e. before {@link FlowrConfig.specializeConfig} is applied */
|
|
48
47
|
baseConfig;
|
|
49
48
|
/** {@link baseConfig}, specialized for {@link _configKind} */
|
|
@@ -145,18 +144,31 @@ class FlowrAnalyzerContext {
|
|
|
145
144
|
constructor(config, plugins = []) {
|
|
146
145
|
const byType = Array.isArray(plugins) ? (0, arrays_1.arraysGroupBy)(plugins, p => p.type)
|
|
147
146
|
: plugins;
|
|
147
|
+
this.plugins = byType;
|
|
148
148
|
this.baseConfig = config;
|
|
149
149
|
this._config = config;
|
|
150
150
|
const loadingOrder = new flowr_analyzer_loading_order_context_1.FlowrAnalyzerLoadingOrderContext(this, byType.get(flowr_analyzer_plugin_1.PluginType.LoadingOrder));
|
|
151
151
|
this.files = new flowr_analyzer_files_context_1.FlowrAnalyzerFilesContext(this, loadingOrder, (byType.get(flowr_analyzer_plugin_1.PluginType.ProjectDiscovery) ?? []), (byType.get(flowr_analyzer_plugin_1.PluginType.FileLoad) ?? []));
|
|
152
152
|
this.env = new flowr_analyzer_environment_context_1.FlowrAnalyzerEnvironmentContext(this);
|
|
153
|
-
this.inc = new flowr_analyzer_incremental_analysis_context_1.FlowrAnalyzerIncrementalAnalysisContext();
|
|
153
|
+
this.inc = new flowr_analyzer_incremental_analysis_context_1.FlowrAnalyzerIncrementalAnalysisContext((byType.get(flowr_analyzer_plugin_1.PluginType.IncrementalDataflowUpdateType) ?? []), (byType.get(flowr_analyzer_plugin_1.PluginType.IncrementalDataflowHeuristic) ?? []));
|
|
154
154
|
const functions = new flowr_analyzer_functions_context_1.FlowrAnalyzerFunctionsContext(this);
|
|
155
155
|
this.deps = new flowr_analyzer_dependencies_context_1.FlowrAnalyzerDependenciesContext(functions, (byType.get(flowr_analyzer_plugin_1.PluginType.DependencyIdentification) ?? []));
|
|
156
156
|
// the plugins contributing the metadata are the ones the dependency context runs on demand
|
|
157
157
|
this.meta = new flowr_analyzer_meta_context_1.FlowrAnalyzerMetaContext(() => this.deps.ensureStaticsLoaded());
|
|
158
158
|
this.gas = new flowr_analyzer_gas_context_1.FlowrAnalyzerGasContext(this, config.gas, (byType.get(flowr_analyzer_plugin_1.PluginType.Gas) ?? []));
|
|
159
159
|
}
|
|
160
|
+
/** Clone state from the source context into this context */
|
|
161
|
+
fork(source, options) {
|
|
162
|
+
for (const plugin of source.activatedPlugins) {
|
|
163
|
+
this.activatedPlugins.add(plugin);
|
|
164
|
+
}
|
|
165
|
+
this.files.fork(source.files, options);
|
|
166
|
+
this.inc.fork(source.inc);
|
|
167
|
+
this.gas.fork(source.gas);
|
|
168
|
+
this.deps.fork(source.deps);
|
|
169
|
+
this.env.fork(source.env);
|
|
170
|
+
this.meta.fork(source.meta);
|
|
171
|
+
}
|
|
160
172
|
/**
|
|
161
173
|
* Provides the analyzer associated with this context, if any.
|
|
162
174
|
* This is usually set when the context is used within an analyzer instance.
|
|
@@ -170,11 +182,11 @@ class FlowrAnalyzerContext {
|
|
|
170
182
|
}
|
|
171
183
|
/** Record the engine's auto-detected R version (used when `solver.sigdb.assumedRVersion` is `"auto"`). */
|
|
172
184
|
setDetectedRVersion(version) {
|
|
173
|
-
this.
|
|
185
|
+
this.deps.setDetectedRVersion(version);
|
|
174
186
|
}
|
|
175
187
|
/** The R version analysis assumes when resolving versioned (base-R) exports (see {@link resolveAssumedRVersion}). */
|
|
176
188
|
get resolvedRVersion() {
|
|
177
|
-
return (0, config_1.resolveAssumedRVersion)(this.config, this.
|
|
189
|
+
return (0, config_1.resolveAssumedRVersion)(this.config, this.deps.getDetectedRVersion());
|
|
178
190
|
}
|
|
179
191
|
/** Whether {@link resolvedRVersion} is a genuine signal (a config pin, project metadata, or engine detection) rather than the fallback default. */
|
|
180
192
|
get rVersionKnown() {
|
|
@@ -189,7 +201,7 @@ class FlowrAnalyzerContext {
|
|
|
189
201
|
else if (this.meta.getRVersion() !== undefined) {
|
|
190
202
|
return "metadata" /* RVersionOrigin.Metadata */;
|
|
191
203
|
}
|
|
192
|
-
else if (this.
|
|
204
|
+
else if (this.deps.getDetectedRVersion() !== undefined && this.deps.getDetectedRVersion() !== 'none' && this.deps.getDetectedRVersion() !== 'unknown') {
|
|
193
205
|
return "engine" /* RVersionOrigin.Engine */;
|
|
194
206
|
}
|
|
195
207
|
return "default" /* RVersionOrigin.Default */;
|
|
@@ -39,6 +39,8 @@ export interface ReadOnlyFlowrAnalyzerDependenciesContext {
|
|
|
39
39
|
inferredRange(name: BrandedNamespace): Range | undefined;
|
|
40
40
|
/** Get all dependencies known to this context. */
|
|
41
41
|
getDependencies(): readonly Readonly<Package>[];
|
|
42
|
+
/** Counts the changes of {@link getDependencies}, so that what was derived from them can tell whether it still holds. */
|
|
43
|
+
readonly dependenciesChanged: number;
|
|
42
44
|
/**
|
|
43
45
|
* Every package name the project *declares* (`Depends`/`Imports`/`Suggests`/`LinkingTo`/`Enhances`), whether or
|
|
44
46
|
* not it became a loadable dependency here. `Suggests` do not, yet they still name packages the project may install.
|
|
@@ -98,13 +100,19 @@ export declare class FlowrAnalyzerDependenciesContext extends AbstractFlowrAnaly
|
|
|
98
100
|
readonly name = "flowr-analyzer-dependencies-context";
|
|
99
101
|
readonly functionsContext: FlowrAnalyzerFunctionsContext;
|
|
100
102
|
private dependencies;
|
|
103
|
+
dependenciesChanged: number;
|
|
101
104
|
/** what {@link getDependency} resolved for a package the project does not depend on, so a lookup never makes it one */
|
|
102
105
|
private resolvedOnly;
|
|
103
106
|
private staticsLoaded;
|
|
104
107
|
/** resolvers consulted lazily to fill in exports; `existing` carries version info from other plugins */
|
|
105
108
|
private lazyResolvers;
|
|
106
109
|
private resolvedMisses;
|
|
110
|
+
/** R version reported by the analysis engine, used when no project or config version is available */
|
|
111
|
+
private detectedR;
|
|
107
112
|
reset(): void;
|
|
113
|
+
fork(source: FlowrAnalyzerDependenciesContext): void;
|
|
114
|
+
setDetectedRVersion(version: string): void;
|
|
115
|
+
getDetectedRVersion(): string | undefined;
|
|
108
116
|
/** Register a resolver consulted by {@link getDependency} to fill in a package's exports lazily. */
|
|
109
117
|
addLazyResolver(resolver: (name: BrandedNamespace, existing?: Package) => Package | undefined): void;
|
|
110
118
|
loadedSignatureDatabases(): SigDbLoadedInfo[];
|
|
@@ -137,6 +145,7 @@ export declare class FlowrAnalyzerDependenciesContext extends AbstractFlowrAnaly
|
|
|
137
145
|
*/
|
|
138
146
|
addDeclaredDependency(pkg: Package): this;
|
|
139
147
|
addDependency(pkg: Package): this;
|
|
148
|
+
private mergeDependency;
|
|
140
149
|
getDependency(name: BrandedNamespace, version?: string | Range): Package | undefined;
|
|
141
150
|
/** Like {@link getDependency}, but for a package the code pulls in (`library(p)`): the result joins the project's {@link getDependencies|dependencies}. */
|
|
142
151
|
loadDependency(name: BrandedNamespace): Package | undefined;
|
|
@@ -16,19 +16,41 @@ class FlowrAnalyzerDependenciesContext extends abstract_flowr_analyzer_context_1
|
|
|
16
16
|
name = 'flowr-analyzer-dependencies-context';
|
|
17
17
|
functionsContext;
|
|
18
18
|
dependencies = new Map();
|
|
19
|
+
dependenciesChanged = 0;
|
|
19
20
|
/** what {@link getDependency} resolved for a package the project does not depend on, so a lookup never makes it one */
|
|
20
21
|
resolvedOnly = new Map();
|
|
21
22
|
staticsLoaded = false;
|
|
22
23
|
/** resolvers consulted lazily to fill in exports; `existing` carries version info from other plugins */
|
|
23
24
|
lazyResolvers = [];
|
|
24
25
|
resolvedMisses = new Set();
|
|
26
|
+
/** R version reported by the analysis engine, used when no project or config version is available */
|
|
27
|
+
detectedR;
|
|
25
28
|
reset() {
|
|
26
29
|
this.dependencies = new Map();
|
|
30
|
+
this.dependenciesChanged++;
|
|
27
31
|
this.resolvedOnly = new Map();
|
|
28
32
|
this.staticsLoaded = false;
|
|
29
33
|
this.lazyResolvers = [];
|
|
30
34
|
this.resolvedMisses = new Set();
|
|
31
35
|
}
|
|
36
|
+
fork(source) {
|
|
37
|
+
this.dependencies = new Map(source.dependencies);
|
|
38
|
+
this.dependenciesChanged++;
|
|
39
|
+
this.resolvedOnly = new Map(source.resolvedOnly);
|
|
40
|
+
this.staticsLoaded = source.staticsLoaded;
|
|
41
|
+
this.lazyResolvers = source.lazyResolvers.slice();
|
|
42
|
+
this.resolvedMisses = new Set(source.resolvedMisses);
|
|
43
|
+
if (source.detectedR !== undefined) {
|
|
44
|
+
this.setDetectedRVersion(source.detectedR);
|
|
45
|
+
}
|
|
46
|
+
this.functionsContext.fork(source.functionsContext);
|
|
47
|
+
}
|
|
48
|
+
setDetectedRVersion(version) {
|
|
49
|
+
this.detectedR = version;
|
|
50
|
+
}
|
|
51
|
+
getDetectedRVersion() {
|
|
52
|
+
return this.detectedR;
|
|
53
|
+
}
|
|
32
54
|
/** Register a resolver consulted by {@link getDependency} to fill in a package's exports lazily. */
|
|
33
55
|
addLazyResolver(resolver) {
|
|
34
56
|
this.lazyResolvers.push(resolver);
|
|
@@ -43,7 +65,7 @@ class FlowrAnalyzerDependenciesContext extends abstract_flowr_analyzer_context_1
|
|
|
43
65
|
return (0, arrays_1.uniqueArray)(this.loadedSignatureDatabases().map(d => d.scope));
|
|
44
66
|
}
|
|
45
67
|
hasSignatureDatabase() {
|
|
46
|
-
return (0, config_1.isSigDbEnabled)(this.ctx.config) && this.plugins.some(p => p.
|
|
68
|
+
return (0, config_1.isSigDbEnabled)(this.ctx.config) && this.plugins.some(p => p.hasLoadedDatabase());
|
|
47
69
|
}
|
|
48
70
|
packagesExporting(name) {
|
|
49
71
|
if (!(0, config_1.isSigDbEnabled)(this.ctx.config)) {
|
|
@@ -136,9 +158,13 @@ class FlowrAnalyzerDependenciesContext extends abstract_flowr_analyzer_context_1
|
|
|
136
158
|
return this.addDependency(pkg);
|
|
137
159
|
}
|
|
138
160
|
addDependency(pkg) {
|
|
139
|
-
|
|
161
|
+
this.mergeDependency(pkg);
|
|
140
162
|
return this;
|
|
141
163
|
}
|
|
164
|
+
mergeDependency(pkg) {
|
|
165
|
+
mergeIntoMap(this.dependencies, pkg);
|
|
166
|
+
this.dependenciesChanged++;
|
|
167
|
+
}
|
|
142
168
|
getDependency(name, version) {
|
|
143
169
|
this.ensureStaticsLoaded();
|
|
144
170
|
if (version !== undefined) {
|
|
@@ -154,9 +180,12 @@ class FlowrAnalyzerDependenciesContext extends abstract_flowr_analyzer_context_1
|
|
|
154
180
|
const resolved = resolve(name, existing);
|
|
155
181
|
if (resolved) {
|
|
156
182
|
// merges exports into any existing version info, of a dependency or of a mere lookup
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
183
|
+
if (this.dependencies.has(name)) {
|
|
184
|
+
this.mergeDependency(resolved);
|
|
185
|
+
return this.dependencies.get(name);
|
|
186
|
+
}
|
|
187
|
+
mergeIntoMap(this.resolvedOnly, resolved);
|
|
188
|
+
return this.resolvedOnly.get(name);
|
|
160
189
|
}
|
|
161
190
|
}
|
|
162
191
|
this.resolvedMisses.add(name);
|
|
@@ -169,7 +198,7 @@ class FlowrAnalyzerDependenciesContext extends abstract_flowr_analyzer_context_1
|
|
|
169
198
|
const cached = this.resolvedOnly.get(name);
|
|
170
199
|
if (cached !== undefined) {
|
|
171
200
|
this.resolvedOnly.delete(name);
|
|
172
|
-
|
|
201
|
+
this.mergeDependency(cached);
|
|
173
202
|
}
|
|
174
203
|
return this.dependencies.get(name) ?? found;
|
|
175
204
|
}
|
|
@@ -72,6 +72,7 @@ export declare class FlowrAnalyzerEnvironmentContext implements ReadOnlyFlowrAna
|
|
|
72
72
|
/** {@link stated} by bare name across all packages, for {@link statedDefinitionsOf}; built on first use */
|
|
73
73
|
private statedByName;
|
|
74
74
|
constructor(ctx: FlowrAnalyzerContext);
|
|
75
|
+
fork(_source: FlowrAnalyzerEnvironmentContext): void;
|
|
75
76
|
get builtInIndex(): BuiltInIndex;
|
|
76
77
|
derive<A, T>(compute: (from: A) => T, from?: A): T;
|
|
77
78
|
deriveFromIndex<T>(compute: (index: BuiltInIndex) => T): T;
|
|
@@ -34,6 +34,7 @@ class FlowrAnalyzerEnvironmentContext {
|
|
|
34
34
|
/* `pkg::fn` resolves whether or not the package is attached, so the built-in env answers for it */
|
|
35
35
|
this.builtInEnv.namespaces = builtIns.packageMemory;
|
|
36
36
|
}
|
|
37
|
+
fork(_source) { }
|
|
37
38
|
get builtInIndex() {
|
|
38
39
|
return this.index ??= query_fn_props_1.BuiltInIndex.of(this.builtInDefinitions);
|
|
39
40
|
}
|
|
@@ -12,6 +12,7 @@ import type { FlowrManifestFile } from '../plugins/file-plugins/files/flowr-mani
|
|
|
12
12
|
import { type FlowrRdFile, type FlowrRdIndexFile, type FlowrRdMacroFile, type FlowrRdMetaFile, type FlowrRdTopicIndexFile, type RdIndex, FlowrDataListFile } from '../plugins/file-plugins/files/flowr-rd-file';
|
|
13
13
|
import { type SysdataObject, FlowrSysdataFile } from '../plugins/file-plugins/files/flowr-sysdata-file';
|
|
14
14
|
import type { ProjectKind } from './project-kind';
|
|
15
|
+
import type { ForkOptions } from '../flowr-analyzer';
|
|
15
16
|
import type { FlowrAnalyzerContext } from './flowr-analyzer-context';
|
|
16
17
|
import { type InvalidationEvent, type InvalidationEventReceiver } from '../cache/flowr-cache';
|
|
17
18
|
/** This is a request to process a folder as a project, which will be expanded by the registered {@link FlowrAnalyzerProjectDiscoveryPlugin}s. */
|
|
@@ -170,6 +171,7 @@ export declare class FlowrAnalyzerFilesContext extends AbstractFlowrAnalyzerCont
|
|
|
170
171
|
constructor(context: FlowrAnalyzerContext, loadingOrder: FlowrAnalyzerLoadingOrderContext, plugins: readonly FlowrAnalyzerProjectDiscoveryPlugin[], fileLoaders: readonly FlowrAnalyzerFilePlugin[]);
|
|
171
172
|
reset(): void;
|
|
172
173
|
private addRoot;
|
|
174
|
+
fork(source: FlowrAnalyzerFilesContext, options?: ForkOptions): void;
|
|
173
175
|
/** The directory the analysis was asked about: a `project`'s folder, or the one holding the requested file(s). */
|
|
174
176
|
root(): string | undefined;
|
|
175
177
|
/** The path of `filePath` seen from the {@link root}, see {@link relativeTo}. */
|
|
@@ -177,6 +179,8 @@ export declare class FlowrAnalyzerFilesContext extends AbstractFlowrAnalyzerCont
|
|
|
177
179
|
receive(event: InvalidationEvent): void;
|
|
178
180
|
/** Record that a file has been considered during dataflow analysis. */
|
|
179
181
|
addConsideredFile(path: string): void;
|
|
182
|
+
/** Forget the files an earlier dataflow analysis considered, as the next one considers its own, see {@link consideredFilesList}. */
|
|
183
|
+
forgetConsideredFiles(): void;
|
|
180
184
|
/** Get all files that have been considered during dataflow analysis. */
|
|
181
185
|
consideredFilesList(): readonly string[];
|
|
182
186
|
projectKind(): ProjectKind;
|
|
@@ -88,6 +88,25 @@ class FlowrAnalyzerFilesContext extends abstract_flowr_analyzer_context_1.Abstra
|
|
|
88
88
|
this.requestedRoots.push(root);
|
|
89
89
|
this.rootResolved = false;
|
|
90
90
|
}
|
|
91
|
+
fork(source, options) {
|
|
92
|
+
const decoupleFiles = options?.decoupleFiles ?? false;
|
|
93
|
+
for (const file of source.getAllFiles()) {
|
|
94
|
+
if (decoupleFiles && file instanceof flowr_file_1.FlowrInlineTextFile) {
|
|
95
|
+
this.addFile(file.copy(), file.roles);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
this.addFile(file);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
for (const consideredFile of source.consideredFilesList()) {
|
|
102
|
+
this.addConsideredFile(consideredFile);
|
|
103
|
+
}
|
|
104
|
+
this.loadingOrder.fork(source.loadingOrder);
|
|
105
|
+
this.requestedRoots = source.requestedRoots.slice();
|
|
106
|
+
this.implicitSourceDirs = new Set(source.implicitSourceDirs);
|
|
107
|
+
this.rootCache = source.rootCache;
|
|
108
|
+
this.rootResolved = source.rootResolved;
|
|
109
|
+
}
|
|
91
110
|
/** The directory the analysis was asked about: a `project`'s folder, or the one holding the requested file(s). */
|
|
92
111
|
root() {
|
|
93
112
|
if (!this.rootResolved) {
|
|
@@ -110,6 +129,11 @@ class FlowrAnalyzerFilesContext extends abstract_flowr_analyzer_context_1.Abstra
|
|
|
110
129
|
this.consideredFiles.push(path);
|
|
111
130
|
this.projectKindCache = undefined;
|
|
112
131
|
}
|
|
132
|
+
/** Forget the files an earlier dataflow analysis considered, as the next one considers its own, see {@link consideredFilesList}. */
|
|
133
|
+
forgetConsideredFiles() {
|
|
134
|
+
this.consideredFiles.length = 0;
|
|
135
|
+
this.projectKindCache = undefined;
|
|
136
|
+
}
|
|
113
137
|
/** Get all files that have been considered during dataflow analysis. */
|
|
114
138
|
consideredFilesList() {
|
|
115
139
|
return this.consideredFiles;
|
|
@@ -48,4 +48,5 @@ export declare class FlowrAnalyzerFunctionsContext extends AbstractFlowrAnalyzer
|
|
|
48
48
|
private mergeFunctionInfo;
|
|
49
49
|
getFunctionInfo(pkg: BrandedNamespace, name: BrandedIdentifier, s3TypeDispatch?: string): FunctionInfo | FunctionInfo[] | undefined;
|
|
50
50
|
reset(): void;
|
|
51
|
+
fork(source: FlowrAnalyzerFunctionsContext): void;
|
|
51
52
|
}
|
|
@@ -66,6 +66,12 @@ class FlowrAnalyzerFunctionsContext extends abstract_flowr_analyzer_context_1.Ab
|
|
|
66
66
|
reset() {
|
|
67
67
|
this.byName = new Map();
|
|
68
68
|
}
|
|
69
|
+
fork(source) {
|
|
70
|
+
this.byName = new Map();
|
|
71
|
+
source.byName.forEach((infos, name) => {
|
|
72
|
+
this.byName.set(name, infos.map(info => ({ ...info })));
|
|
73
|
+
});
|
|
74
|
+
}
|
|
69
75
|
}
|
|
70
76
|
exports.FlowrAnalyzerFunctionsContext = FlowrAnalyzerFunctionsContext;
|
|
71
77
|
//# sourceMappingURL=flowr-analyzer-functions-context.js.map
|
|
@@ -66,6 +66,7 @@ export declare class FlowrAnalyzerGasContext implements WriteableFlowrAnalyzerGa
|
|
|
66
66
|
* guard bounding it.
|
|
67
67
|
*/
|
|
68
68
|
reset(): void;
|
|
69
|
+
fork(_source: FlowrAnalyzerGasContext): void;
|
|
69
70
|
/** A new analysis makes the spent contingent irrelevant. */
|
|
70
71
|
receive(_event: InvalidationEvent): void;
|
|
71
72
|
/**
|
|
@@ -3,11 +3,17 @@ import { type InvalidationEvent, type InvalidationEventReceiver } from '../cache
|
|
|
3
3
|
import type { FlowrAnalyzerContext } from './flowr-analyzer-context';
|
|
4
4
|
import type { FilePath } from './flowr-file';
|
|
5
5
|
import type { ParseStepOutput } from '../../r-bridge/parser';
|
|
6
|
+
import type { NormalizedAst } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
7
|
+
import { type AnalyzedFile, type IncrementalUpdateResult, FlowrAnalyzerIncrementalDataflowUpdateTypePlugin } from '../plugins/incremental/incremental-dataflow/flowr-analyzer-incremental-dataflow-update-type-plugin';
|
|
8
|
+
import type { DataflowSnapshot } from '../incremental/incremental-dataflow/incremental-dataflow';
|
|
9
|
+
import { type IncrementalDataflowPlan, FlowrAnalyzerIncrementalDataflowHeuristicPlugin } from '../plugins/incremental/incremental-dataflow/flowr-analyzer-incremental-dataflow-heuristic-plugin';
|
|
6
10
|
export interface ReadOnlyFlowrAnalyzerIncrementalAnalysisContext {
|
|
7
11
|
/** The name of this context. */
|
|
8
12
|
readonly name: string;
|
|
9
13
|
getOldParseResultOf(filePath: FilePath): Parser.Tree | undefined;
|
|
10
14
|
getOldContentOf(filePath: FilePath): string | undefined;
|
|
15
|
+
/** How the last incremental dataflow analysis classified the change, and whether it reused anything for it. */
|
|
16
|
+
getLastAppliedIncrementalUpdate(): IncrementalUpdateResult | undefined;
|
|
11
17
|
}
|
|
12
18
|
/** Information to carry over for future incremental builds */
|
|
13
19
|
export declare class FlowrAnalyzerIncrementalAnalysisContext implements ReadOnlyFlowrAnalyzerIncrementalAnalysisContext, InvalidationEventReceiver {
|
|
@@ -15,14 +21,32 @@ export declare class FlowrAnalyzerIncrementalAnalysisContext implements ReadOnly
|
|
|
15
21
|
/** The files that have been changed since the last analysis mapping to their old content. */
|
|
16
22
|
private changedFilesWithOldContent;
|
|
17
23
|
private oldParseResults;
|
|
24
|
+
/** what the last dataflow analysis kept for the next one, a single snapshot whose size the checkpoint configuration bounds */
|
|
25
|
+
private dataflowSnapshot;
|
|
18
26
|
private readonly lastKnownMtime;
|
|
27
|
+
private lastAppliedIncrementalUpdate;
|
|
28
|
+
private readonly updateTypePlugin;
|
|
29
|
+
private readonly heuristicPlugin;
|
|
30
|
+
/** how many dataflow analyses this context planned, see {@link planDataflow} */
|
|
31
|
+
private dataflowAnalyses;
|
|
32
|
+
constructor(updateTypePlugins?: readonly FlowrAnalyzerIncrementalDataflowUpdateTypePlugin[], heuristicPlugins?: readonly FlowrAnalyzerIncrementalDataflowHeuristicPlugin[]);
|
|
33
|
+
/** Plans how the next dataflow analysis builds on the one before, which its files differ from by `update`, using whichever {@link FlowrAnalyzerIncrementalDataflowHeuristicPlugin} is active. */
|
|
34
|
+
planDataflow(ctx: FlowrAnalyzerContext, update: IncrementalUpdateResult | undefined): IncrementalDataflowPlan;
|
|
19
35
|
reset(): void;
|
|
36
|
+
fork(source: FlowrAnalyzerIncrementalAnalysisContext): void;
|
|
20
37
|
handleFileInvalidate(filePath: FilePath, oldContent: string | undefined): void;
|
|
21
38
|
handleShouldReparse(filePath: FilePath, ctx: FlowrAnalyzerContext): boolean;
|
|
39
|
+
/** Classifies how the files of `current` differ from the `previous` ones, using whichever {@link FlowrAnalyzerIncrementalDataflowUpdateTypePlugin} is active. */
|
|
40
|
+
determineUpdateTypes(previous: readonly AnalyzedFile[], current: NormalizedAst, ctx: FlowrAnalyzerContext): IncrementalUpdateResult;
|
|
41
|
+
/** Hands out what the last dataflow analysis kept, which the caller continues in place. */
|
|
42
|
+
takeDataflowSnapshot(): DataflowSnapshot | undefined;
|
|
43
|
+
storeDataflowSnapshot(snapshot: DataflowSnapshot): void;
|
|
22
44
|
receive(event: InvalidationEvent): void;
|
|
23
45
|
storeOldParseResults(parseStepOutput: ParseStepOutput<Parser.Tree>): void;
|
|
24
46
|
getOldParseResultOf(filePath: FilePath): Parser.Tree | undefined;
|
|
25
47
|
getOldContentOf(filePath: FilePath): string | undefined;
|
|
48
|
+
storeAppliedIncrementalUpdate(update: IncrementalUpdateResult): void;
|
|
49
|
+
getLastAppliedIncrementalUpdate(): IncrementalUpdateResult | undefined;
|
|
26
50
|
deleteOldContentOf(filePath: FilePath): void;
|
|
27
51
|
getLastKnownMtime(filePath: FilePath): number | undefined;
|
|
28
52
|
setLastKnownMtime(filePath: FilePath, mtimeMs: number): void;
|
|
@@ -6,16 +6,51 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.FlowrAnalyzerIncrementalAnalysisContext = void 0;
|
|
7
7
|
const assert_1 = require("../../util/assert");
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const flowr_analyzer_incremental_dataflow_update_type_plugin_1 = require("../plugins/incremental/incremental-dataflow/flowr-analyzer-incremental-dataflow-update-type-plugin");
|
|
10
|
+
const flowr_analyzer_incremental_dataflow_heuristic_plugin_1 = require("../plugins/incremental/incremental-dataflow/flowr-analyzer-incremental-dataflow-heuristic-plugin");
|
|
9
11
|
/** Information to carry over for future incremental builds */
|
|
10
12
|
class FlowrAnalyzerIncrementalAnalysisContext {
|
|
11
13
|
name = 'flowr-analyzer-incremental-analysis-context';
|
|
12
14
|
/** The files that have been changed since the last analysis mapping to their old content. */
|
|
13
15
|
changedFilesWithOldContent = new Map();
|
|
14
16
|
oldParseResults = new Map();
|
|
17
|
+
/** what the last dataflow analysis kept for the next one, a single snapshot whose size the checkpoint configuration bounds */
|
|
18
|
+
dataflowSnapshot = undefined;
|
|
15
19
|
lastKnownMtime = new Map();
|
|
20
|
+
lastAppliedIncrementalUpdate = undefined;
|
|
21
|
+
updateTypePlugin;
|
|
22
|
+
heuristicPlugin;
|
|
23
|
+
/** how many dataflow analyses this context planned, see {@link planDataflow} */
|
|
24
|
+
dataflowAnalyses = 0;
|
|
25
|
+
constructor(updateTypePlugins = [], heuristicPlugins = []) {
|
|
26
|
+
(0, assert_1.guard)(updateTypePlugins.length <= 1, () => `at most one incremental-dataflow-update-type plugin may be registered, got ${updateTypePlugins.length}`);
|
|
27
|
+
(0, assert_1.guard)(heuristicPlugins.length <= 1, () => `at most one incremental-dataflow-heuristic plugin may be registered, got ${heuristicPlugins.length}`);
|
|
28
|
+
this.updateTypePlugin = updateTypePlugins[0] ?? flowr_analyzer_incremental_dataflow_update_type_plugin_1.FlowrAnalyzerIncrementalDataflowUpdateTypePlugin.defaultPlugin();
|
|
29
|
+
this.heuristicPlugin = heuristicPlugins[0] ?? flowr_analyzer_incremental_dataflow_heuristic_plugin_1.FlowrAnalyzerIncrementalDataflowHeuristicPlugin.defaultPlugin();
|
|
30
|
+
}
|
|
31
|
+
/** Plans how the next dataflow analysis builds on the one before, which its files differ from by `update`, using whichever {@link FlowrAnalyzerIncrementalDataflowHeuristicPlugin} is active. */
|
|
32
|
+
planDataflow(ctx, update) {
|
|
33
|
+
const plan = this.heuristicPlugin.processor(ctx, { analyses: this.dataflowAnalyses, lastUpdate: this.lastAppliedIncrementalUpdate, update });
|
|
34
|
+
this.dataflowAnalyses++;
|
|
35
|
+
return plan;
|
|
36
|
+
}
|
|
16
37
|
reset() {
|
|
17
38
|
this.changedFilesWithOldContent = new Map();
|
|
18
39
|
this.oldParseResults = new Map();
|
|
40
|
+
this.dataflowSnapshot = undefined;
|
|
41
|
+
this.lastAppliedIncrementalUpdate = undefined;
|
|
42
|
+
}
|
|
43
|
+
fork(source) {
|
|
44
|
+
for (const [path, content] of source.changedFilesWithOldContent) {
|
|
45
|
+
this.changedFilesWithOldContent.set(path, content);
|
|
46
|
+
}
|
|
47
|
+
for (const [path, tree] of source.oldParseResults) {
|
|
48
|
+
this.oldParseResults.set(path, tree);
|
|
49
|
+
}
|
|
50
|
+
for (const [path, mtime] of source.lastKnownMtime) {
|
|
51
|
+
this.lastKnownMtime.set(path, mtime);
|
|
52
|
+
}
|
|
53
|
+
/* the dataflow snapshot is continued in place, so a fork starts its dataflow analysis from scratch */
|
|
19
54
|
}
|
|
20
55
|
handleFileInvalidate(filePath, oldContent) {
|
|
21
56
|
if (this.changedFilesWithOldContent.has(filePath)) {
|
|
@@ -82,6 +117,19 @@ class FlowrAnalyzerIncrementalAnalysisContext {
|
|
|
82
117
|
? true
|
|
83
118
|
: checks.every(check => check(filePath, ctx));
|
|
84
119
|
}
|
|
120
|
+
/** Classifies how the files of `current` differ from the `previous` ones, using whichever {@link FlowrAnalyzerIncrementalDataflowUpdateTypePlugin} is active. */
|
|
121
|
+
determineUpdateTypes(previous, current, ctx) {
|
|
122
|
+
return this.updateTypePlugin.processor(ctx, { previous, current });
|
|
123
|
+
}
|
|
124
|
+
/** Hands out what the last dataflow analysis kept, which the caller continues in place. */
|
|
125
|
+
takeDataflowSnapshot() {
|
|
126
|
+
const snapshot = this.dataflowSnapshot;
|
|
127
|
+
this.dataflowSnapshot = undefined;
|
|
128
|
+
return snapshot;
|
|
129
|
+
}
|
|
130
|
+
storeDataflowSnapshot(snapshot) {
|
|
131
|
+
this.dataflowSnapshot = snapshot;
|
|
132
|
+
}
|
|
85
133
|
receive(event) {
|
|
86
134
|
const type = event.type;
|
|
87
135
|
switch (type) {
|
|
@@ -110,6 +158,12 @@ class FlowrAnalyzerIncrementalAnalysisContext {
|
|
|
110
158
|
getOldContentOf(filePath) {
|
|
111
159
|
return this.changedFilesWithOldContent.get(filePath);
|
|
112
160
|
}
|
|
161
|
+
storeAppliedIncrementalUpdate(update) {
|
|
162
|
+
this.lastAppliedIncrementalUpdate = update;
|
|
163
|
+
}
|
|
164
|
+
getLastAppliedIncrementalUpdate() {
|
|
165
|
+
return this.lastAppliedIncrementalUpdate;
|
|
166
|
+
}
|
|
113
167
|
deleteOldContentOf(filePath) {
|
|
114
168
|
this.changedFilesWithOldContent.delete(filePath);
|
|
115
169
|
}
|