@eagleoutice/flowr 2.4.8 → 2.6.0
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 +66 -45
- package/benchmark/slicer.js +1 -1
- package/benchmark/summarizer/second-phase/graph.js +2 -2
- package/cli/flowr.js +3 -29
- package/cli/repl/commands/repl-cfg.d.ts +5 -5
- package/cli/repl/commands/repl-cfg.js +21 -22
- package/cli/repl/commands/repl-commands.d.ts +3 -3
- package/cli/repl/commands/repl-commands.js +2 -0
- package/cli/repl/commands/repl-dataflow.d.ts +5 -5
- package/cli/repl/commands/repl-dataflow.js +27 -30
- package/cli/repl/commands/repl-execute.js +1 -0
- package/cli/repl/commands/repl-lineage.js +1 -0
- package/cli/repl/commands/repl-main.d.ts +34 -3
- package/cli/repl/commands/repl-normalize.d.ts +3 -3
- package/cli/repl/commands/repl-normalize.js +15 -19
- package/cli/repl/commands/repl-parse.d.ts +2 -2
- package/cli/repl/commands/repl-parse.js +13 -8
- package/cli/repl/commands/repl-query.d.ts +3 -3
- package/cli/repl/commands/repl-query.js +29 -19
- package/cli/repl/commands/repl-quit.js +1 -0
- package/cli/repl/commands/repl-version.js +1 -0
- package/cli/repl/core.d.ts +4 -1
- package/cli/repl/core.js +21 -1
- package/cli/repl/server/connection.d.ts +7 -3
- package/cli/repl/server/connection.js +40 -48
- package/cli/repl/server/messages/message-slice.d.ts +1 -1
- package/cli/slicer-app.js +8 -3
- package/config.d.ts +1 -1
- package/config.js +4 -1
- package/control-flow/extract-cfg.d.ts +1 -1
- package/control-flow/extract-cfg.js +1 -1
- package/core/pipeline-executor.d.ts +5 -0
- package/core/pipeline-executor.js +5 -0
- package/core/steps/pipeline/create-pipeline.js +1 -1
- package/core/steps/pipeline/default-pipelines.d.ts +42 -42
- package/core/steps/pipeline/default-pipelines.js +4 -1
- package/dataflow/graph/dataflowgraph-builder.d.ts +11 -12
- package/dataflow/graph/dataflowgraph-builder.js +6 -6
- package/documentation/doc-util/doc-query.d.ts +3 -6
- package/documentation/doc-util/doc-query.js +5 -17
- package/documentation/doc-util/doc-search.js +7 -10
- package/documentation/doc-util/doc-structure.d.ts +4 -0
- package/documentation/doc-util/doc-structure.js +28 -0
- package/documentation/doc-util/doc-types.d.ts +5 -1
- package/documentation/doc-util/doc-types.js +29 -3
- package/documentation/print-analyzer-wiki.d.ts +1 -0
- package/documentation/print-analyzer-wiki.js +137 -0
- package/documentation/print-core-wiki.d.ts +2 -1
- package/documentation/print-core-wiki.js +58 -4
- package/documentation/print-dataflow-graph-wiki.js +15 -22
- package/documentation/print-interface-wiki.js +18 -1
- package/documentation/print-linter-wiki.js +5 -1
- package/documentation/print-linting-and-testing-wiki.js +4 -0
- package/documentation/print-normalized-ast-wiki.js +6 -8
- package/documentation/print-readme.js +6 -0
- package/engines.d.ts +9 -0
- package/engines.js +38 -0
- package/linter/linter-executor.d.ts +2 -8
- package/linter/linter-executor.js +9 -4
- package/linter/linter-format.d.ts +8 -9
- package/linter/linter-rules.d.ts +57 -15
- package/linter/linter-rules.js +2 -0
- package/linter/rules/absolute-path.d.ts +1 -0
- package/linter/rules/dataframe-access-validation.d.ts +4 -3
- package/linter/rules/dataframe-access-validation.js +7 -4
- package/linter/rules/dead-code.d.ts +2 -1
- package/linter/rules/deprecated-functions.d.ts +15 -28
- package/linter/rules/deprecated-functions.js +5 -43
- package/linter/rules/file-path-validity.d.ts +2 -1
- package/linter/rules/file-path-validity.js +1 -1
- package/linter/rules/function-finder-util.d.ts +51 -0
- package/linter/rules/function-finder-util.js +77 -0
- package/linter/rules/naming-convention.d.ts +2 -1
- package/linter/rules/network-functions.d.ts +40 -0
- package/linter/rules/network-functions.js +24 -0
- package/linter/rules/seeded-randomness.d.ts +2 -1
- package/linter/rules/unused-definition.d.ts +2 -1
- package/linter/rules/useless-loop.d.ts +3 -2
- package/linter/rules/useless-loop.js +4 -6
- package/package.json +5 -1
- package/project/cache/flowr-analyzer-cache.d.ts +93 -0
- package/project/cache/flowr-analyzer-cache.js +156 -0
- package/project/cache/flowr-cache.d.ts +28 -0
- package/project/cache/flowr-cache.js +49 -0
- package/project/context/abstract-flowr-analyzer-context.d.ts +35 -0
- package/project/context/abstract-flowr-analyzer-context.js +46 -0
- package/project/context/flowr-analyzer-context.d.ts +48 -0
- package/project/context/flowr-analyzer-context.js +47 -0
- package/project/context/flowr-analyzer-dependencies-context.d.ts +38 -0
- package/project/context/flowr-analyzer-dependencies-context.js +39 -0
- package/project/context/flowr-analyzer-files-context.d.ts +86 -0
- package/project/context/flowr-analyzer-files-context.js +130 -0
- package/project/context/flowr-analyzer-loading-order-context.d.ts +76 -0
- package/project/context/flowr-analyzer-loading-order-context.js +90 -0
- package/project/context/flowr-file.d.ts +89 -0
- package/project/context/flowr-file.js +78 -0
- package/project/flowr-analyzer-builder.d.ts +106 -0
- package/project/flowr-analyzer-builder.js +197 -0
- package/project/flowr-analyzer.d.ts +125 -0
- package/project/flowr-analyzer.js +81 -0
- package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.d.ts +17 -0
- package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.js +28 -0
- package/project/plugins/file-plugins/flowr-analyzer-file-plugin.d.ts +21 -0
- package/project/plugins/file-plugins/flowr-analyzer-file-plugin.js +34 -0
- package/project/plugins/file-plugins/flowr-description-file.d.ts +24 -0
- package/project/plugins/file-plugins/flowr-description-file.js +38 -0
- package/project/plugins/flowr-analyzer-plugin.d.ts +90 -0
- package/project/plugins/flowr-analyzer-plugin.js +82 -0
- package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-description-file-plugin.d.ts +14 -0
- package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-description-file-plugin.js +56 -0
- package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-plugin.d.ts +13 -0
- package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-plugin.js +33 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.d.ts +14 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.js +41 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.d.ts +10 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.js +29 -0
- package/project/plugins/package-version-plugins/package.d.ts +15 -0
- package/project/plugins/package-version-plugins/package.js +56 -0
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.d.ts +15 -0
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +44 -0
- package/queries/base-query-format.d.ts +2 -8
- package/queries/catalog/call-context-query/call-context-query-executor.d.ts +1 -1
- package/queries/catalog/call-context-query/call-context-query-executor.js +20 -13
- package/queries/catalog/call-context-query/call-context-query-format.d.ts +2 -3
- package/queries/catalog/call-context-query/call-context-query-format.js +2 -2
- package/queries/catalog/cluster-query/cluster-query-executor.d.ts +1 -1
- package/queries/catalog/cluster-query/cluster-query-executor.js +2 -2
- package/queries/catalog/cluster-query/cluster-query-format.d.ts +1 -54
- package/queries/catalog/cluster-query/cluster-query-format.js +2 -2
- package/queries/catalog/config-query/config-query-executor.d.ts +1 -1
- package/queries/catalog/config-query/config-query-executor.js +5 -5
- package/queries/catalog/config-query/config-query-format.d.ts +1 -1
- package/queries/catalog/config-query/config-query-format.js +1 -1
- package/queries/catalog/control-flow-query/control-flow-query-executor.d.ts +1 -1
- package/queries/catalog/control-flow-query/control-flow-query-executor.js +2 -3
- package/queries/catalog/control-flow-query/control-flow-query-format.d.ts +1 -54
- package/queries/catalog/control-flow-query/control-flow-query-format.js +2 -2
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.d.ts +1 -1
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.js +2 -2
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.d.ts +1 -54
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.js +1 -1
- package/queries/catalog/dataflow-query/dataflow-query-executor.d.ts +1 -1
- package/queries/catalog/dataflow-query/dataflow-query-executor.js +2 -2
- package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +1 -54
- package/queries/catalog/dataflow-query/dataflow-query-format.js +1 -1
- package/queries/catalog/dependencies-query/dependencies-query-executor.d.ts +1 -1
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +19 -12
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +7 -56
- package/queries/catalog/dependencies-query/dependencies-query-format.js +7 -4
- package/queries/catalog/df-shape-query/df-shape-query-executor.d.ts +1 -1
- package/queries/catalog/df-shape-query/df-shape-query-executor.js +4 -4
- package/queries/catalog/df-shape-query/df-shape-query-format.d.ts +1 -54
- package/queries/catalog/df-shape-query/df-shape-query-format.js +1 -1
- package/queries/catalog/happens-before-query/happens-before-query-executor.d.ts +1 -1
- package/queries/catalog/happens-before-query/happens-before-query-executor.js +2 -1
- package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +1 -54
- package/queries/catalog/happens-before-query/happens-before-query-format.js +1 -1
- package/queries/catalog/id-map-query/id-map-query-executor.d.ts +1 -1
- package/queries/catalog/id-map-query/id-map-query-executor.js +2 -2
- package/queries/catalog/id-map-query/id-map-query-format.d.ts +1 -54
- package/queries/catalog/id-map-query/id-map-query-format.js +2 -2
- package/queries/catalog/lineage-query/lineage-query-executor.d.ts +1 -1
- package/queries/catalog/lineage-query/lineage-query-executor.js +2 -2
- package/queries/catalog/lineage-query/lineage-query-format.d.ts +1 -54
- package/queries/catalog/lineage-query/lineage-query-format.js +1 -1
- package/queries/catalog/linter-query/linter-query-executor.d.ts +1 -1
- package/queries/catalog/linter-query/linter-query-executor.js +2 -3
- package/queries/catalog/linter-query/linter-query-format.d.ts +1 -54
- package/queries/catalog/linter-query/linter-query-format.js +1 -1
- package/queries/catalog/location-map-query/location-map-query-executor.d.ts +1 -1
- package/queries/catalog/location-map-query/location-map-query-executor.js +3 -2
- package/queries/catalog/location-map-query/location-map-query-format.d.ts +1 -1
- package/queries/catalog/location-map-query/location-map-query-format.js +1 -1
- package/queries/catalog/normalized-ast-query/normalized-ast-query-executor.d.ts +1 -1
- package/queries/catalog/normalized-ast-query/normalized-ast-query-executor.js +2 -2
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +1 -54
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.js +1 -1
- package/queries/catalog/origin-query/origin-query-executor.d.ts +2 -2
- package/queries/catalog/origin-query/origin-query-executor.js +3 -3
- package/queries/catalog/origin-query/origin-query-format.d.ts +1 -54
- package/queries/catalog/origin-query/origin-query-format.js +1 -1
- package/queries/catalog/project-query/project-query-executor.d.ts +1 -1
- package/queries/catalog/project-query/project-query-executor.js +2 -2
- package/queries/catalog/project-query/project-query-format.d.ts +1 -54
- package/queries/catalog/project-query/project-query-format.js +1 -1
- package/queries/catalog/resolve-value-query/resolve-value-query-executor.d.ts +1 -1
- package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +4 -2
- package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +1 -54
- package/queries/catalog/resolve-value-query/resolve-value-query-format.js +1 -1
- package/queries/catalog/search-query/search-query-executor.d.ts +1 -1
- package/queries/catalog/search-query/search-query-executor.js +3 -3
- package/queries/catalog/search-query/search-query-format.d.ts +1 -54
- package/queries/catalog/search-query/search-query-format.js +1 -1
- package/queries/catalog/static-slice-query/static-slice-query-executor.d.ts +1 -1
- package/queries/catalog/static-slice-query/static-slice-query-executor.js +3 -3
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +1 -54
- package/queries/catalog/static-slice-query/static-slice-query-format.js +1 -1
- package/queries/query-print.d.ts +4 -4
- package/queries/query-print.js +12 -12
- package/queries/query.d.ts +29 -885
- package/queries/query.js +1 -1
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +1 -1
- package/r-bridge/retriever.d.ts +15 -2
- package/r-bridge/retriever.js +15 -5
- package/search/flowr-search-executor.d.ts +3 -5
- package/search/flowr-search-executor.js +6 -4
- package/search/flowr-search-filters.d.ts +12 -6
- package/search/flowr-search-filters.js +1 -1
- package/search/flowr-search.d.ts +5 -16
- package/search/flowr-search.js +14 -5
- package/search/search-executor/search-enrichers.d.ts +37 -36
- package/search/search-executor/search-enrichers.js +4 -4
- package/search/search-executor/search-generators.d.ts +12 -12
- package/search/search-executor/search-generators.js +27 -19
- package/search/search-executor/search-mappers.d.ts +5 -5
- package/search/search-executor/search-transformer.d.ts +17 -17
- package/search/search-executor/search-transformer.js +14 -7
- package/util/collections/arrays.d.ts +1 -0
- package/util/collections/arrays.js +15 -0
- package/util/collections/objectmap.d.ts +17 -0
- package/util/collections/objectmap.js +28 -0
- package/util/containers.d.ts +0 -1
- package/util/containers.js +0 -1
- package/util/files.d.ts +17 -0
- package/util/files.js +65 -0
- package/util/formats/adapter-format.d.ts +6 -0
- package/util/formats/adapter-format.js +3 -0
- package/util/formats/adapter.d.ts +18 -0
- package/util/formats/adapter.js +49 -0
- package/util/formats/adapters/r-adapter.d.ts +4 -0
- package/util/formats/adapters/r-adapter.js +7 -0
- package/util/formats/adapters/rmd-adapter.d.ts +26 -0
- package/util/formats/adapters/rmd-adapter.js +91 -0
- package/util/version.js +1 -1
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FlowrAnalyzerCache = void 0;
|
|
4
|
+
const flowr_cache_1 = require("./flowr-cache");
|
|
5
|
+
const default_pipelines_1 = require("../../core/steps/pipeline/default-pipelines");
|
|
6
|
+
const assert_1 = require("../../util/assert");
|
|
7
|
+
const objectmap_1 = require("../../util/collections/objectmap");
|
|
8
|
+
const extract_cfg_1 = require("../../control-flow/extract-cfg");
|
|
9
|
+
/**
|
|
10
|
+
* This provides the full analyzer caching layer, please avoid using this directly
|
|
11
|
+
* and prefer the {@link FlowrAnalyzer}.
|
|
12
|
+
*/
|
|
13
|
+
class FlowrAnalyzerCache extends flowr_cache_1.FlowrCache {
|
|
14
|
+
args;
|
|
15
|
+
pipeline = undefined;
|
|
16
|
+
controlFlowCache = undefined;
|
|
17
|
+
constructor(args) {
|
|
18
|
+
super();
|
|
19
|
+
this.args = args;
|
|
20
|
+
this.initCacheProviders();
|
|
21
|
+
}
|
|
22
|
+
initCacheProviders() {
|
|
23
|
+
this.pipeline = (0, default_pipelines_1.createDataflowPipeline)(this.args.parser, {
|
|
24
|
+
request: this.args.request,
|
|
25
|
+
getId: this.args.getId,
|
|
26
|
+
overwriteFilePath: this.args.overwriteFilePath
|
|
27
|
+
}, this.args.config);
|
|
28
|
+
this.controlFlowCache = {
|
|
29
|
+
simplified: new objectmap_1.ObjectMap(),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
static create(data) {
|
|
33
|
+
return new FlowrAnalyzerCache(data);
|
|
34
|
+
}
|
|
35
|
+
receive(event) {
|
|
36
|
+
super.receive(event);
|
|
37
|
+
switch (event.type) {
|
|
38
|
+
case "full" /* CacheInvalidationEventType.Full */:
|
|
39
|
+
this.initCacheProviders();
|
|
40
|
+
break;
|
|
41
|
+
default:
|
|
42
|
+
(0, assert_1.assertUnreachable)(event.type);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
get() {
|
|
46
|
+
/* this will do a ref assignment, so indirect force */
|
|
47
|
+
return this.computeIfAbsent(false, () => this.pipeline.getResults(true));
|
|
48
|
+
}
|
|
49
|
+
reset() {
|
|
50
|
+
this.receive({ type: "full" /* CacheInvalidationEventType.Full */ });
|
|
51
|
+
}
|
|
52
|
+
async runTapeUntil(force, until) {
|
|
53
|
+
if (force) {
|
|
54
|
+
this.reset();
|
|
55
|
+
}
|
|
56
|
+
let g;
|
|
57
|
+
while ((g = until()) === undefined && this.pipeline.hasNextStep()) {
|
|
58
|
+
await this.pipeline.nextStep();
|
|
59
|
+
}
|
|
60
|
+
(0, assert_1.guard)(g !== undefined, 'Could not reach the desired pipeline step, invalid cache state(?)');
|
|
61
|
+
return g;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Get the parse output for the request, parsing if necessary.
|
|
65
|
+
* @param force - Do not use the cache, instead force a new parse.
|
|
66
|
+
*
|
|
67
|
+
* @see {@link FlowrAnalyzerCache#peekParse} - to get the parse output if already available without triggering a new parse.
|
|
68
|
+
*/
|
|
69
|
+
async parse(force) {
|
|
70
|
+
const d = this.get();
|
|
71
|
+
return this.runTapeUntil(force, () => d.parse);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Get the parse output for the request if already available, otherwise return `undefined`.
|
|
75
|
+
* This will not trigger a new parse.
|
|
76
|
+
*
|
|
77
|
+
* @see {@link FlowrAnalyzerCache#parse} - to get the parse output, parsing if necessary.
|
|
78
|
+
*/
|
|
79
|
+
peekParse() {
|
|
80
|
+
return this.get().parse;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Get the normalized abstract syntax tree for the request, normalizing if necessary.
|
|
84
|
+
* @param force - Do not use the cache, instead force new analyses.
|
|
85
|
+
* @see {@link FlowrAnalyzerCache#peekNormalize} - to get the normalized AST if already available without triggering a new normalization.
|
|
86
|
+
*/
|
|
87
|
+
async normalize(force) {
|
|
88
|
+
const d = this.get();
|
|
89
|
+
return this.runTapeUntil(force, () => d.normalize);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Get the normalized abstract syntax tree for the request if already available, otherwise return `undefined`.
|
|
93
|
+
* This will not trigger a new normalization.
|
|
94
|
+
*
|
|
95
|
+
* @see {@link FlowrAnalyzerCache#normalize} - to get the normalized AST, normalizing if necessary.
|
|
96
|
+
*/
|
|
97
|
+
peekNormalize() {
|
|
98
|
+
return this.get().normalize;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Get the dataflow graph for the request, computing if necessary.
|
|
102
|
+
* @param force - Do not use the cache, instead force new analyses.
|
|
103
|
+
*
|
|
104
|
+
* @see {@link FlowrAnalyzerCache#peekDataflow} - to get the dataflow graph if already available without triggering a new computation.
|
|
105
|
+
*/
|
|
106
|
+
async dataflow(force) {
|
|
107
|
+
const d = this.get();
|
|
108
|
+
return this.runTapeUntil(force, () => d.dataflow);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Get the dataflow graph for the request if already available, otherwise return `undefined`.
|
|
112
|
+
* This will not trigger a new computation.
|
|
113
|
+
*
|
|
114
|
+
* @see {@link FlowrAnalyzerCache#dataflow} - to get the dataflow graph, computing if necessary.
|
|
115
|
+
*/
|
|
116
|
+
peekDataflow() {
|
|
117
|
+
return this.get().dataflow;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Get the control flow graph (CFG) for the request, computing if necessary.
|
|
121
|
+
* @param force - Do not use the cache, instead force new analyses.
|
|
122
|
+
* @param useDataflow - Whether to use the dataflow graph for the creation of the CFG.
|
|
123
|
+
* @param simplifications - Simplification passes to be applied to the CFG.
|
|
124
|
+
*/
|
|
125
|
+
async controlflow(force, useDataflow, simplifications) {
|
|
126
|
+
simplifications ??= [];
|
|
127
|
+
if (!force) {
|
|
128
|
+
const value = this.controlFlowCache.simplified.get([simplifications, useDataflow]);
|
|
129
|
+
if (value !== undefined) {
|
|
130
|
+
return value;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
const normalized = await this.normalize(force);
|
|
134
|
+
let dataflow = undefined;
|
|
135
|
+
if (useDataflow) {
|
|
136
|
+
/* if force is active, it will have triggered with normalize */
|
|
137
|
+
dataflow = await this.dataflow();
|
|
138
|
+
}
|
|
139
|
+
const result = simplifications.length === 0 && !useDataflow ? (0, extract_cfg_1.extractCfgQuick)(normalized) :
|
|
140
|
+
(0, extract_cfg_1.extractCfg)(normalized, this.args.config, dataflow?.graph, simplifications);
|
|
141
|
+
this.controlFlowCache.simplified.set([simplifications, useDataflow], result);
|
|
142
|
+
return result;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Get the control flow graph (CFG) for the request if already available, otherwise return `undefined`.
|
|
146
|
+
* @param useDataflow - Whether to use the dataflow graph for the creation of the CFG.
|
|
147
|
+
* @param simplifications - Simplification passes to be applied to the CFG.
|
|
148
|
+
*
|
|
149
|
+
* @see {@link FlowrAnalyzerCache#controlflow} - to get the control flow graph, computing if necessary.
|
|
150
|
+
*/
|
|
151
|
+
peekControlflow(useDataflow, simplifications) {
|
|
152
|
+
return this.controlFlowCache.simplified.get([simplifications ?? [], useDataflow]);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
exports.FlowrAnalyzerCache = FlowrAnalyzerCache;
|
|
156
|
+
//# sourceMappingURL=flowr-analyzer-cache.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare const enum CacheInvalidationEventType {
|
|
2
|
+
Full = "full"
|
|
3
|
+
}
|
|
4
|
+
export type CacheInvalidationEvent = {
|
|
5
|
+
type: CacheInvalidationEventType.Full;
|
|
6
|
+
};
|
|
7
|
+
export interface CacheInvalidationEventReceiver {
|
|
8
|
+
receive(event: CacheInvalidationEvent): void;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Central class for caching analysis results in FlowR.
|
|
12
|
+
*/
|
|
13
|
+
export declare abstract class FlowrCache<Cache> implements CacheInvalidationEventReceiver {
|
|
14
|
+
private value;
|
|
15
|
+
private dependents;
|
|
16
|
+
registerDependent(dependent: CacheInvalidationEventReceiver): void;
|
|
17
|
+
removeDependent(dependent: CacheInvalidationEventReceiver): void;
|
|
18
|
+
receive(event: CacheInvalidationEvent): void;
|
|
19
|
+
/**
|
|
20
|
+
* Notify all dependents of a cache invalidation event.
|
|
21
|
+
*/
|
|
22
|
+
notifyDependents(event: CacheInvalidationEvent): void;
|
|
23
|
+
/**
|
|
24
|
+
* Get the cached value or compute it if not present.
|
|
25
|
+
* This will, by default, not trigger any {@link notifyDependents} calls, as this is only a cache retrieval.
|
|
26
|
+
*/
|
|
27
|
+
protected computeIfAbsent(force: boolean | undefined, compute: () => Cache): Cache;
|
|
28
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FlowrCache = void 0;
|
|
4
|
+
const assert_1 = require("../../util/assert");
|
|
5
|
+
/**
|
|
6
|
+
* Central class for caching analysis results in FlowR.
|
|
7
|
+
*/
|
|
8
|
+
class FlowrCache {
|
|
9
|
+
value = undefined;
|
|
10
|
+
dependents = [];
|
|
11
|
+
registerDependent(dependent) {
|
|
12
|
+
this.dependents.push(dependent);
|
|
13
|
+
}
|
|
14
|
+
removeDependent(dependent) {
|
|
15
|
+
this.dependents = this.dependents.filter(d => d !== dependent);
|
|
16
|
+
}
|
|
17
|
+
receive(event) {
|
|
18
|
+
/* we will update this as soon as we support incremental update patterns */
|
|
19
|
+
switch (event.type) {
|
|
20
|
+
case "full" /* CacheInvalidationEventType.Full */:
|
|
21
|
+
this.value = undefined;
|
|
22
|
+
break;
|
|
23
|
+
default:
|
|
24
|
+
(0, assert_1.assertUnreachable)(event.type);
|
|
25
|
+
}
|
|
26
|
+
/* 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
|
+
this.notifyDependents(event);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Notify all dependents of a cache invalidation event.
|
|
31
|
+
*/
|
|
32
|
+
notifyDependents(event) {
|
|
33
|
+
for (const dependent of this.dependents) {
|
|
34
|
+
dependent.receive(event);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Get the cached value or compute it if not present.
|
|
39
|
+
* This will, by default, not trigger any {@link notifyDependents} calls, as this is only a cache retrieval.
|
|
40
|
+
*/
|
|
41
|
+
computeIfAbsent(force, compute) {
|
|
42
|
+
if (this.value === undefined || force) {
|
|
43
|
+
this.value = compute();
|
|
44
|
+
}
|
|
45
|
+
return this.value;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.FlowrCache = FlowrCache;
|
|
49
|
+
//# sourceMappingURL=flowr-cache.js.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { FlowrAnalyzerPlugin } from '../plugins/flowr-analyzer-plugin';
|
|
2
|
+
import type { FlowrAnalyzerContext } from './flowr-analyzer-context';
|
|
3
|
+
/**
|
|
4
|
+
* Abstract class representing the context, a context may be modified and enriched by plugins (see {@link FlowrAnalyzerPlugin}).
|
|
5
|
+
*
|
|
6
|
+
* Please use the specialized contexts like {@link FlowrAnalyzerFilesContext} or {@link FlowrAnalyzerLoadingOrderContext} to work with flowR and
|
|
7
|
+
* in general, use the {@link FlowrAnalyzerContext} to access the full project context.
|
|
8
|
+
*/
|
|
9
|
+
export declare abstract class AbstractFlowrAnalyzerContext<In, Out, Plugin extends FlowrAnalyzerPlugin<In, Out>> {
|
|
10
|
+
/**
|
|
11
|
+
* A human-readable name of the context. Try to make it unique to avoid confusion in the logs.
|
|
12
|
+
*/
|
|
13
|
+
abstract readonly name: string;
|
|
14
|
+
/**
|
|
15
|
+
* The plugins registered for this context. These build the foundation for {@link applyPlugins}.
|
|
16
|
+
*/
|
|
17
|
+
protected readonly plugins: readonly Plugin[];
|
|
18
|
+
/**
|
|
19
|
+
* The linked full project context, allowing plugins to modify and access it.
|
|
20
|
+
*/
|
|
21
|
+
protected readonly ctx: FlowrAnalyzerContext;
|
|
22
|
+
/**
|
|
23
|
+
* Creates a new context with the given project context, a default plugin (to be used when no other is registered)
|
|
24
|
+
*/
|
|
25
|
+
protected constructor(ctx: FlowrAnalyzerContext, defaultPlugin: Plugin, plugins?: readonly Plugin[]);
|
|
26
|
+
/**
|
|
27
|
+
* Run all registered plugins on the given args, please be aware that if they are async, it is up to you to
|
|
28
|
+
* await them.
|
|
29
|
+
*/
|
|
30
|
+
protected applyPlugins(args: Parameters<Plugin['processor']>[1]): Out[];
|
|
31
|
+
/**
|
|
32
|
+
* Returns the project context this sub-context is attached to
|
|
33
|
+
*/
|
|
34
|
+
getAttachedContext(): FlowrAnalyzerContext;
|
|
35
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AbstractFlowrAnalyzerContext = void 0;
|
|
4
|
+
const assert_1 = require("../../util/assert");
|
|
5
|
+
/**
|
|
6
|
+
* Abstract class representing the context, a context may be modified and enriched by plugins (see {@link FlowrAnalyzerPlugin}).
|
|
7
|
+
*
|
|
8
|
+
* Please use the specialized contexts like {@link FlowrAnalyzerFilesContext} or {@link FlowrAnalyzerLoadingOrderContext} to work with flowR and
|
|
9
|
+
* in general, use the {@link FlowrAnalyzerContext} to access the full project context.
|
|
10
|
+
*/
|
|
11
|
+
class AbstractFlowrAnalyzerContext {
|
|
12
|
+
/**
|
|
13
|
+
* The plugins registered for this context. These build the foundation for {@link applyPlugins}.
|
|
14
|
+
*/
|
|
15
|
+
plugins;
|
|
16
|
+
/**
|
|
17
|
+
* The linked full project context, allowing plugins to modify and access it.
|
|
18
|
+
*/
|
|
19
|
+
ctx;
|
|
20
|
+
/**
|
|
21
|
+
* Creates a new context with the given project context, a default plugin (to be used when no other is registered)
|
|
22
|
+
*/
|
|
23
|
+
constructor(ctx, defaultPlugin, plugins) {
|
|
24
|
+
this.plugins = [...plugins ?? [], defaultPlugin];
|
|
25
|
+
this.ctx = ctx;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Run all registered plugins on the given args, please be aware that if they are async, it is up to you to
|
|
29
|
+
* await them.
|
|
30
|
+
*/
|
|
31
|
+
applyPlugins(args) {
|
|
32
|
+
const res = [];
|
|
33
|
+
for (const plugin of this.plugins) {
|
|
34
|
+
res.push(plugin.processor(this.ctx, args));
|
|
35
|
+
}
|
|
36
|
+
return res.filter(assert_1.isNotUndefined);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Returns the project context this sub-context is attached to
|
|
40
|
+
*/
|
|
41
|
+
getAttachedContext() {
|
|
42
|
+
return this.ctx;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.AbstractFlowrAnalyzerContext = AbstractFlowrAnalyzerContext;
|
|
46
|
+
//# sourceMappingURL=abstract-flowr-analyzer-context.js.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { RAnalysisRequest, ReadOnlyFlowrAnalyzerFilesContext } from './flowr-analyzer-files-context';
|
|
2
|
+
import { FlowrAnalyzerFilesContext } from './flowr-analyzer-files-context';
|
|
3
|
+
import type { ReadOnlyFlowrAnalyzerDependenciesContext } from './flowr-analyzer-dependencies-context';
|
|
4
|
+
import { FlowrAnalyzerDependenciesContext } from './flowr-analyzer-dependencies-context';
|
|
5
|
+
import type { FlowrAnalyzerPlugin } from '../plugins/flowr-analyzer-plugin';
|
|
6
|
+
import { PluginType } from '../plugins/flowr-analyzer-plugin';
|
|
7
|
+
/**
|
|
8
|
+
* This is a read-only interface to the {@link FlowrAnalyzerContext}.
|
|
9
|
+
* It prevents you from modifying the context, but allows you to inspect it (which is probably what you want when using the {@link FlowrAnalyzer}).
|
|
10
|
+
* If you are a {@link FlowrAnalyzerPlugin} and want to modify the context, you can use the {@link FlowrAnalyzerContext} directly.
|
|
11
|
+
*/
|
|
12
|
+
export interface ReadOnlyFlowrAnalyzerContext {
|
|
13
|
+
/**
|
|
14
|
+
* The files context provides access to the files to be analyzed and their loading order.
|
|
15
|
+
*/
|
|
16
|
+
readonly files: ReadOnlyFlowrAnalyzerFilesContext;
|
|
17
|
+
/**
|
|
18
|
+
* The dependencies context provides access to the identified dependencies and their versions.
|
|
19
|
+
*/
|
|
20
|
+
readonly deps: ReadOnlyFlowrAnalyzerDependenciesContext;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* This summarizes the other context layers used by the {@link FlowrAnalyzer}.
|
|
24
|
+
* Have a look at the attributes and layers listed below (e.g., {@link files} and {@link deps})
|
|
25
|
+
* to get an idea of the capabilities provided by this context.
|
|
26
|
+
* Besides these, this layer only orchestrates the different steps and layers, providing a collection of convenience methods alongside the
|
|
27
|
+
* {@link resolvePreAnalysis} method that conducts all the steps that can be done before the main analysis run.
|
|
28
|
+
* In general, you do not have to worry about these details, as the {@link FlowrAnalyzerBuilder} and {@link FlowrAnalyzer} take care of them.
|
|
29
|
+
*
|
|
30
|
+
* To inspect, e.g., the loading order, you can do so via {@link files.loadingOrder.getLoadingOrder}. To get information on a specific library, use
|
|
31
|
+
* {@link deps.getDependency}.
|
|
32
|
+
* If you are just interested in inspecting the context, you can use {@link ReadOnlyFlowrAnalyzerContext} instead (e.g., via {@link inspect}).
|
|
33
|
+
*/
|
|
34
|
+
export declare class FlowrAnalyzerContext implements ReadOnlyFlowrAnalyzerContext {
|
|
35
|
+
readonly files: FlowrAnalyzerFilesContext;
|
|
36
|
+
readonly deps: FlowrAnalyzerDependenciesContext;
|
|
37
|
+
constructor(plugins: ReadonlyMap<PluginType, readonly FlowrAnalyzerPlugin[]>);
|
|
38
|
+
/** delegate request addition */
|
|
39
|
+
addRequests(requests: readonly RAnalysisRequest[]): void;
|
|
40
|
+
/** this conducts all the step that can be done before the main analysis run */
|
|
41
|
+
resolvePreAnalysis(): void;
|
|
42
|
+
/**
|
|
43
|
+
* Get a read-only version of this context.
|
|
44
|
+
* This is useful if you want to pass the context to a place where you do not want it to be modified or just to reduce
|
|
45
|
+
* the available methods.
|
|
46
|
+
*/
|
|
47
|
+
inspect(): ReadOnlyFlowrAnalyzerContext;
|
|
48
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FlowrAnalyzerContext = void 0;
|
|
4
|
+
const flowr_analyzer_files_context_1 = require("./flowr-analyzer-files-context");
|
|
5
|
+
const flowr_analyzer_dependencies_context_1 = require("./flowr-analyzer-dependencies-context");
|
|
6
|
+
const flowr_analyzer_plugin_1 = require("../plugins/flowr-analyzer-plugin");
|
|
7
|
+
const flowr_analyzer_loading_order_context_1 = require("./flowr-analyzer-loading-order-context");
|
|
8
|
+
/**
|
|
9
|
+
* This summarizes the other context layers used by the {@link FlowrAnalyzer}.
|
|
10
|
+
* Have a look at the attributes and layers listed below (e.g., {@link files} and {@link deps})
|
|
11
|
+
* to get an idea of the capabilities provided by this context.
|
|
12
|
+
* Besides these, this layer only orchestrates the different steps and layers, providing a collection of convenience methods alongside the
|
|
13
|
+
* {@link resolvePreAnalysis} method that conducts all the steps that can be done before the main analysis run.
|
|
14
|
+
* In general, you do not have to worry about these details, as the {@link FlowrAnalyzerBuilder} and {@link FlowrAnalyzer} take care of them.
|
|
15
|
+
*
|
|
16
|
+
* To inspect, e.g., the loading order, you can do so via {@link files.loadingOrder.getLoadingOrder}. To get information on a specific library, use
|
|
17
|
+
* {@link deps.getDependency}.
|
|
18
|
+
* If you are just interested in inspecting the context, you can use {@link ReadOnlyFlowrAnalyzerContext} instead (e.g., via {@link inspect}).
|
|
19
|
+
*/
|
|
20
|
+
class FlowrAnalyzerContext {
|
|
21
|
+
files;
|
|
22
|
+
deps;
|
|
23
|
+
constructor(plugins) {
|
|
24
|
+
const loadingOrder = new flowr_analyzer_loading_order_context_1.FlowrAnalyzerLoadingOrderContext(this, plugins.get(flowr_analyzer_plugin_1.PluginType.LoadingOrder));
|
|
25
|
+
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) ?? []));
|
|
26
|
+
this.deps = new flowr_analyzer_dependencies_context_1.FlowrAnalyzerDependenciesContext(this, (plugins.get(flowr_analyzer_plugin_1.PluginType.DependencyIdentification) ?? []));
|
|
27
|
+
}
|
|
28
|
+
/** delegate request addition */
|
|
29
|
+
addRequests(requests) {
|
|
30
|
+
this.files.addRequests(requests);
|
|
31
|
+
}
|
|
32
|
+
/** this conducts all the step that can be done before the main analysis run */
|
|
33
|
+
resolvePreAnalysis() {
|
|
34
|
+
this.files.computeLoadingOrder();
|
|
35
|
+
this.deps.resolveStaticDependencies();
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Get a read-only version of this context.
|
|
39
|
+
* This is useful if you want to pass the context to a place where you do not want it to be modified or just to reduce
|
|
40
|
+
* the available methods.
|
|
41
|
+
*/
|
|
42
|
+
inspect() {
|
|
43
|
+
return this;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.FlowrAnalyzerContext = FlowrAnalyzerContext;
|
|
47
|
+
//# sourceMappingURL=flowr-analyzer-context.js.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { AbstractFlowrAnalyzerContext } from './abstract-flowr-analyzer-context';
|
|
2
|
+
import { FlowrAnalyzerPackageVersionsPlugin } from '../plugins/package-version-plugins/flowr-analyzer-package-versions-plugin';
|
|
3
|
+
import type { Package } from '../plugins/package-version-plugins/package';
|
|
4
|
+
import type { FlowrAnalyzerContext } from './flowr-analyzer-context';
|
|
5
|
+
/**
|
|
6
|
+
* This is a read-only interface to the {@link FlowrAnalyzerDependenciesContext}.
|
|
7
|
+
* It prevents you from modifying the dependencies, but allows you to inspect them (which is probably what you want when using the {@link FlowrAnalyzer}).
|
|
8
|
+
* If you are a {@link FlowrAnalyzerPackageVersionsPlugin} and want to modify the dependencies, you can use the {@link FlowrAnalyzerDependenciesContext} directly.
|
|
9
|
+
*/
|
|
10
|
+
export interface ReadOnlyFlowrAnalyzerDependenciesContext {
|
|
11
|
+
/**
|
|
12
|
+
* The name of this context.
|
|
13
|
+
*/
|
|
14
|
+
readonly name: string;
|
|
15
|
+
/**
|
|
16
|
+
* Get the dependency with the given name, if it exists.
|
|
17
|
+
*
|
|
18
|
+
* If the static dependencies have not yet been loaded, this may trigger a resolution step.
|
|
19
|
+
*
|
|
20
|
+
* @param name - The name of the dependency to get.
|
|
21
|
+
* @returns The dependency with the given name, or undefined if it does not exist.
|
|
22
|
+
*/
|
|
23
|
+
getDependency(name: string): Package | undefined;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* This context is responsible for managing the dependencies of the project, including their versions and interplays with {@link FlowrAnalyzerPackageVersionsPlugin}s.
|
|
27
|
+
*
|
|
28
|
+
* If you are interested in inspecting these dependencies, refer to {@link ReadOnlyFlowrAnalyzerDependenciesContext}.
|
|
29
|
+
*/
|
|
30
|
+
export declare class FlowrAnalyzerDependenciesContext extends AbstractFlowrAnalyzerContext<undefined, void, FlowrAnalyzerPackageVersionsPlugin> implements ReadOnlyFlowrAnalyzerDependenciesContext {
|
|
31
|
+
readonly name = "flowr-analyzer-dependencies-context";
|
|
32
|
+
private dependencies;
|
|
33
|
+
private staticsLoaded;
|
|
34
|
+
constructor(ctx: FlowrAnalyzerContext, plugins?: readonly FlowrAnalyzerPackageVersionsPlugin[]);
|
|
35
|
+
resolveStaticDependencies(): void;
|
|
36
|
+
addDependency(pkg: Package): void;
|
|
37
|
+
getDependency(name: string): Package | undefined;
|
|
38
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FlowrAnalyzerDependenciesContext = void 0;
|
|
4
|
+
const abstract_flowr_analyzer_context_1 = require("./abstract-flowr-analyzer-context");
|
|
5
|
+
const flowr_analyzer_package_versions_plugin_1 = require("../plugins/package-version-plugins/flowr-analyzer-package-versions-plugin");
|
|
6
|
+
/**
|
|
7
|
+
* This context is responsible for managing the dependencies of the project, including their versions and interplays with {@link FlowrAnalyzerPackageVersionsPlugin}s.
|
|
8
|
+
*
|
|
9
|
+
* If you are interested in inspecting these dependencies, refer to {@link ReadOnlyFlowrAnalyzerDependenciesContext}.
|
|
10
|
+
*/
|
|
11
|
+
class FlowrAnalyzerDependenciesContext extends abstract_flowr_analyzer_context_1.AbstractFlowrAnalyzerContext {
|
|
12
|
+
name = 'flowr-analyzer-dependencies-context';
|
|
13
|
+
dependencies = new Map();
|
|
14
|
+
staticsLoaded = false;
|
|
15
|
+
constructor(ctx, plugins) {
|
|
16
|
+
super(ctx, flowr_analyzer_package_versions_plugin_1.FlowrAnalyzerPackageVersionsPlugin.defaultPlugin(), plugins);
|
|
17
|
+
}
|
|
18
|
+
resolveStaticDependencies() {
|
|
19
|
+
this.applyPlugins(undefined);
|
|
20
|
+
this.staticsLoaded = true;
|
|
21
|
+
}
|
|
22
|
+
addDependency(pkg) {
|
|
23
|
+
const p = this.dependencies.get(pkg.name);
|
|
24
|
+
if (p) {
|
|
25
|
+
p.mergeInPlace(pkg);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
this.dependencies.set(pkg.name, pkg);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
getDependency(name) {
|
|
32
|
+
if (!this.staticsLoaded) {
|
|
33
|
+
this.resolveStaticDependencies();
|
|
34
|
+
}
|
|
35
|
+
return this.dependencies.get(name);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.FlowrAnalyzerDependenciesContext = FlowrAnalyzerDependenciesContext;
|
|
39
|
+
//# sourceMappingURL=flowr-analyzer-dependencies-context.js.map
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { AbstractFlowrAnalyzerContext } from './abstract-flowr-analyzer-context';
|
|
2
|
+
import type { RParseRequest, RParseRequestFromFile } from '../../r-bridge/retriever';
|
|
3
|
+
import type { FlowrAnalyzerLoadingOrderContext, ReadOnlyFlowrAnalyzerLoadingOrderContext } from './flowr-analyzer-loading-order-context';
|
|
4
|
+
import { FlowrAnalyzerProjectDiscoveryPlugin } from '../plugins/project-discovery/flowr-analyzer-project-discovery-plugin';
|
|
5
|
+
import { FlowrAnalyzerFilePlugin } from '../plugins/file-plugins/flowr-analyzer-file-plugin';
|
|
6
|
+
import type { FlowrFile, FlowrFileProvider } from './flowr-file';
|
|
7
|
+
import { SpecialFileRole } from './flowr-file';
|
|
8
|
+
import type { FlowrDescriptionFile } from '../plugins/file-plugins/flowr-description-file';
|
|
9
|
+
/**
|
|
10
|
+
* This is a request to process a folder as a project, which will be expanded by the registered {@link FlowrAnalyzerProjectDiscoveryPlugin}s.
|
|
11
|
+
*/
|
|
12
|
+
export interface RProjectAnalysisRequest {
|
|
13
|
+
readonly request: 'project';
|
|
14
|
+
/**
|
|
15
|
+
* The path to the root folder (an absolute path is probably best here).
|
|
16
|
+
*/
|
|
17
|
+
readonly content: string;
|
|
18
|
+
}
|
|
19
|
+
export type RAnalysisRequest = RParseRequest | RProjectAnalysisRequest;
|
|
20
|
+
export type SpecialFiles = {
|
|
21
|
+
[SpecialFileRole.Description]: FlowrDescriptionFile[];
|
|
22
|
+
[SpecialFileRole.Namespace]: FlowrFileProvider[];
|
|
23
|
+
[SpecialFileRole.Data]: FlowrFileProvider[];
|
|
24
|
+
[SpecialFileRole.Other]: FlowrFileProvider[];
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* This is the read-only interface for the files context, which is used to manage all files known to the {@link FlowrAnalyzer}.
|
|
28
|
+
* It prevents you from modifying the available files, but allows you to inspect them (which is probably what you want when using the {@link FlowrAnalyzer}).
|
|
29
|
+
* If you are a {@link FlowrAnalyzerProjectDiscoveryPlugin} and want to modify the available files, you can use the {@link FlowrAnalyzerFilesContext} directly.
|
|
30
|
+
*/
|
|
31
|
+
export interface ReadOnlyFlowrAnalyzerFilesContext {
|
|
32
|
+
/**
|
|
33
|
+
* The name of this context.
|
|
34
|
+
*/
|
|
35
|
+
readonly name: string;
|
|
36
|
+
/**
|
|
37
|
+
* The loading order context provides access to the loading order of script files in the project.
|
|
38
|
+
*/
|
|
39
|
+
readonly loadingOrder: ReadOnlyFlowrAnalyzerLoadingOrderContext;
|
|
40
|
+
/**
|
|
41
|
+
* Get all requests that have been added to this context.
|
|
42
|
+
*
|
|
43
|
+
* @example If you want to obtain all description files, use
|
|
44
|
+
* ```ts
|
|
45
|
+
* getFilesByRole(SpecialFileRole.Description)
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
getFilesByRole<Role extends SpecialFileRole>(role: Role): SpecialFiles[Role];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* This is the analyzer file context to be modified by all plugins that affect the files.
|
|
52
|
+
* If you are interested in inspecting these files, refer to {@link ReadOnlyFlowrAnalyzerFilesContext}.
|
|
53
|
+
* Plugins, however, can use this context directly to modify files.
|
|
54
|
+
*/
|
|
55
|
+
export declare class FlowrAnalyzerFilesContext extends AbstractFlowrAnalyzerContext<RProjectAnalysisRequest, (RParseRequest | FlowrFile<string>)[], FlowrAnalyzerProjectDiscoveryPlugin> implements ReadOnlyFlowrAnalyzerFilesContext {
|
|
56
|
+
readonly name = "flowr-analyzer-files-context";
|
|
57
|
+
readonly loadingOrder: FlowrAnalyzerLoadingOrderContext;
|
|
58
|
+
private files;
|
|
59
|
+
private readonly fileLoaders;
|
|
60
|
+
private specialFiles;
|
|
61
|
+
constructor(loadingOrder: FlowrAnalyzerLoadingOrderContext, plugins: readonly FlowrAnalyzerProjectDiscoveryPlugin[], fileLoaders: readonly FlowrAnalyzerFilePlugin[]);
|
|
62
|
+
/**
|
|
63
|
+
* Add multiple requests to the context. This is just a convenience method that calls {@link addRequest} for each request.
|
|
64
|
+
*/
|
|
65
|
+
addRequests(requests: readonly RAnalysisRequest[]): void;
|
|
66
|
+
/**
|
|
67
|
+
* Add a request to the context. If the request is of type `project`, it will be expanded using the registered {@link FlowrAnalyzerProjectDiscoveryPlugin}s.
|
|
68
|
+
*/
|
|
69
|
+
addRequest(request: RAnalysisRequest): void;
|
|
70
|
+
/**
|
|
71
|
+
* Add multiple files to the context. This is just a convenience method that calls {@link addFile} for each file.
|
|
72
|
+
*/
|
|
73
|
+
addFiles(...files: (string | FlowrFileProvider<string> | RParseRequestFromFile)[]): void;
|
|
74
|
+
/**
|
|
75
|
+
* Add a file to the context. If the file has a special role, it will be added to the corresponding list of special files.
|
|
76
|
+
* This method also applies any registered {@link FlowrAnalyzerFilePlugin}s to the file before adding it to the context.
|
|
77
|
+
*/
|
|
78
|
+
addFile(file: string | FlowrFileProvider<string> | RParseRequestFromFile, role?: SpecialFileRole): void;
|
|
79
|
+
private fileLoadPlugins;
|
|
80
|
+
/**
|
|
81
|
+
* Get all requests that have been added to this context.
|
|
82
|
+
* This is a convenience method that calls {@link FlowrAnalyzerLoadingOrderContext.getLoadingOrder}.
|
|
83
|
+
*/
|
|
84
|
+
computeLoadingOrder(): readonly RParseRequest[];
|
|
85
|
+
getFilesByRole<Role extends SpecialFileRole>(role: Role): SpecialFiles[Role];
|
|
86
|
+
}
|