@eagleoutice/flowr 2.5.0 → 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 +57 -42
- 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 +1 -1
- 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-normalized-ast-wiki.js +6 -8
- 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 +2 -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/retriever.d.ts +6 -5
- package/r-bridge/retriever.js +9 -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.d.ts +4 -2
- package/util/formats/adapter.js +11 -4
- package/util/version.js +1 -1
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.FlowrInlineTextFile = exports.FlowrTextFile = exports.FlowrFile = exports.SpecialFileRole = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const assert_1 = require("../../util/assert");
|
|
9
|
+
/**
|
|
10
|
+
* Some files have a special meaning in R projects, e.g., the `DESCRIPTION` file in R packages.
|
|
11
|
+
* This list may be extended in the future and reflects files that the {@link FlowrAnalyzer} can do something interesting with.
|
|
12
|
+
* If you add an interesting file that is only part of your plugin infrastructure, please use the `other` role.
|
|
13
|
+
*/
|
|
14
|
+
var SpecialFileRole;
|
|
15
|
+
(function (SpecialFileRole) {
|
|
16
|
+
/** The `DESCRIPTION` file in R packages, this is the only currently supported special file. */
|
|
17
|
+
SpecialFileRole["Description"] = "description";
|
|
18
|
+
/** The `NAMESPACE` file in R packages, currently not specially supported. */
|
|
19
|
+
SpecialFileRole["Namespace"] = "namespace";
|
|
20
|
+
/** Data files, e.g., `R/sysdata.rda`, currently not specially supported. */
|
|
21
|
+
SpecialFileRole["Data"] = "data";
|
|
22
|
+
/** Other special files that are not specifically supported by flowR but may be interesting for some analyses. */
|
|
23
|
+
SpecialFileRole["Other"] = "other";
|
|
24
|
+
})(SpecialFileRole || (exports.SpecialFileRole = SpecialFileRole = {}));
|
|
25
|
+
/**
|
|
26
|
+
* A basic implementation of the {@link FlowrFileProvider} interface that caches the content after the first load (i.e., updates on disk are ignored).
|
|
27
|
+
*
|
|
28
|
+
* See {@link FlowrTextFile} for a text-file specific implementation and {@link FlowrInlineTextFile} for inline text files.
|
|
29
|
+
*/
|
|
30
|
+
class FlowrFile {
|
|
31
|
+
contentCache;
|
|
32
|
+
filePath;
|
|
33
|
+
role;
|
|
34
|
+
constructor(filePath, role) {
|
|
35
|
+
this.filePath = filePath;
|
|
36
|
+
this.role = role;
|
|
37
|
+
}
|
|
38
|
+
path() {
|
|
39
|
+
return this.filePath;
|
|
40
|
+
}
|
|
41
|
+
content() {
|
|
42
|
+
if (this.contentCache === undefined) {
|
|
43
|
+
this.contentCache = this.loadContent();
|
|
44
|
+
}
|
|
45
|
+
return this.contentCache;
|
|
46
|
+
}
|
|
47
|
+
assignRole(role) {
|
|
48
|
+
(0, assert_1.guard)(this.role === undefined || this.role === role, `File ${this.filePath.toString()} already has a role assigned: ${this.role}`);
|
|
49
|
+
this.role = role;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.FlowrFile = FlowrFile;
|
|
53
|
+
/**
|
|
54
|
+
* A basic implementation of the {@link FlowrFileProvider} interface for text files that caches the content after the first load (i.e., updates on disk are ignored).
|
|
55
|
+
*/
|
|
56
|
+
class FlowrTextFile extends FlowrFile {
|
|
57
|
+
loadContent() {
|
|
58
|
+
return fs_1.default.readFileSync(this.filePath, 'utf8');
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.FlowrTextFile = FlowrTextFile;
|
|
62
|
+
/**
|
|
63
|
+
* A basic implementation of the {@link FlowrFileProvider} interface for (constant) inline text files.
|
|
64
|
+
* This is also useful for "special" files like the `DESCRIPTION` file in R packages that you want to pass in directly.
|
|
65
|
+
* These will be handled by the {@link FlowrAnalyzerDescriptionFilePlugin} (e.g., by using the {@link FlowrDescriptionFile#from} method decorator).
|
|
66
|
+
*/
|
|
67
|
+
class FlowrInlineTextFile extends FlowrFile {
|
|
68
|
+
contentStr;
|
|
69
|
+
constructor(path, content) {
|
|
70
|
+
super(path);
|
|
71
|
+
this.contentStr = content;
|
|
72
|
+
}
|
|
73
|
+
loadContent() {
|
|
74
|
+
return this.contentStr;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.FlowrInlineTextFile = FlowrInlineTextFile;
|
|
78
|
+
//# sourceMappingURL=flowr-file.js.map
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { EngineConfig, FlowrConfigOptions } from '../config';
|
|
2
|
+
import type { DeepWritable } from 'ts-essentials';
|
|
3
|
+
import { fileProtocol, requestFromInput } from '../r-bridge/retriever';
|
|
4
|
+
import { FlowrAnalyzer } from './flowr-analyzer';
|
|
5
|
+
import type { KnownParser } from '../r-bridge/parser';
|
|
6
|
+
import type { FlowrAnalyzerPlugin } from './plugins/flowr-analyzer-plugin';
|
|
7
|
+
import type { NormalizeRequiredInput } from '../core/steps/all/core/10-normalize';
|
|
8
|
+
import type { RAnalysisRequest } from './context/flowr-analyzer-files-context';
|
|
9
|
+
/**
|
|
10
|
+
* Builder for the {@link FlowrAnalyzer}, use it to configure all analysis aspects before creating the analyzer instance
|
|
11
|
+
* with {@link FlowrAnalyzerBuilder#build|`.build()`} or {@link FlowrAnalyzerBuilder#buildSync|`.buildSync()`}.
|
|
12
|
+
*
|
|
13
|
+
* You can add new files and folders to analyze using the constructor or the {@link FlowrAnalyzerBuilder#add|`.add()`} method.
|
|
14
|
+
*
|
|
15
|
+
* @example Let's create an analyzer for a single R script file:
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* const analyzer = new FlowrAnalyzerBuilder()
|
|
19
|
+
* .add('file:///path/to/script.R')
|
|
20
|
+
* .setParser(new TreeSitterExecutor())
|
|
21
|
+
* .buildSync();
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* If you now want to get the dataflow information for the file, you can do this:
|
|
25
|
+
*
|
|
26
|
+
* ```ts
|
|
27
|
+
* const dfInfo = await analyzer.dataflow();
|
|
28
|
+
* console.log(dfInfo);
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare class FlowrAnalyzerBuilder {
|
|
32
|
+
private flowrConfig;
|
|
33
|
+
private parser?;
|
|
34
|
+
private request;
|
|
35
|
+
private input?;
|
|
36
|
+
private plugins;
|
|
37
|
+
/**
|
|
38
|
+
* Create a new builder instance.
|
|
39
|
+
* @param request - The code to analyze
|
|
40
|
+
*/
|
|
41
|
+
constructor(request?: RAnalysisRequest | readonly RAnalysisRequest[]);
|
|
42
|
+
/**
|
|
43
|
+
* Add one or multiple requests to analyze.
|
|
44
|
+
* This is a convenience method that uses {@link addRequest} and {@link addRequestFromInput} internally.
|
|
45
|
+
* @param request - One or multiple requests or a file path (with the `file://` protocol). If you just enter a string, it will be interpreted as R code.
|
|
46
|
+
*/
|
|
47
|
+
add(request: RAnalysisRequest | readonly RAnalysisRequest[] | `${typeof fileProtocol}${string}` | string): this;
|
|
48
|
+
/**
|
|
49
|
+
* Add one or multiple requests to analyze the builder.
|
|
50
|
+
*/
|
|
51
|
+
addRequest(request: RAnalysisRequest | readonly RAnalysisRequest[]): this;
|
|
52
|
+
/**
|
|
53
|
+
* Add a request created from the given input.
|
|
54
|
+
* This is a convenience method that uses {@link requestFromInput} internally.
|
|
55
|
+
*/
|
|
56
|
+
addRequestFromInput(input: Parameters<typeof requestFromInput>[0]): this;
|
|
57
|
+
/**
|
|
58
|
+
* Apply an amendment to the configuration the builder currently holds.
|
|
59
|
+
* Per default, the {@link defaultConfigOptions} are used.
|
|
60
|
+
* @param func - Receives the current configuration of the builder and allows for amendment.
|
|
61
|
+
*/
|
|
62
|
+
amendConfig(func: (config: DeepWritable<FlowrConfigOptions>) => FlowrConfigOptions | void): this;
|
|
63
|
+
/**
|
|
64
|
+
* Overwrite the configuration used by the resulting analyzer.
|
|
65
|
+
* @param config - The new configuration.
|
|
66
|
+
*/
|
|
67
|
+
setConfig(config: FlowrConfigOptions): this;
|
|
68
|
+
/**
|
|
69
|
+
* Set the parser instance used by the analyzer.
|
|
70
|
+
* This is an alternative to {@link FlowrAnalyzerBuilder#setEngine} if you already have a parser instance.
|
|
71
|
+
* Please be aware, that if you want to parallelize multiple analyzers, there should be separate parser instances.
|
|
72
|
+
*/
|
|
73
|
+
setParser(parser: KnownParser): this;
|
|
74
|
+
/**
|
|
75
|
+
* Set the engine and hence the parser that will be used by the analyzer.
|
|
76
|
+
* This is an alternative to {@link FlowrAnalyzerBuilder#setParser} if you do not have a parser instance at hand.
|
|
77
|
+
*/
|
|
78
|
+
setEngine(engine: EngineConfig['type']): this;
|
|
79
|
+
/**
|
|
80
|
+
* Additional parameters for the analyses.
|
|
81
|
+
* @param input - The input.
|
|
82
|
+
*/
|
|
83
|
+
setInput(input: Omit<NormalizeRequiredInput, 'request'>): this;
|
|
84
|
+
/**
|
|
85
|
+
* Register one or multiple additional plugins.
|
|
86
|
+
*
|
|
87
|
+
* @see {@link FlowrAnalyzerBuilder#unregisterPlugins} to remove plugins.
|
|
88
|
+
*/
|
|
89
|
+
registerPlugins(...plugin: readonly FlowrAnalyzerPlugin[]): this;
|
|
90
|
+
/**
|
|
91
|
+
* Remove one or multiple plugins.
|
|
92
|
+
*/
|
|
93
|
+
unregisterPlugins(...plugin: readonly FlowrAnalyzerPlugin[]): this;
|
|
94
|
+
/**
|
|
95
|
+
* Create the {@link FlowrAnalyzer} instance using the given information.
|
|
96
|
+
* Please note that the only reason this is `async` is that if no parser is set,
|
|
97
|
+
* we need to retrieve the default engine instance which is an async operation.
|
|
98
|
+
* If you set the parser using {@link FlowrAnalyzerBuilder#setParser},
|
|
99
|
+
*/
|
|
100
|
+
build(): Promise<FlowrAnalyzer>;
|
|
101
|
+
/**
|
|
102
|
+
* Synchronous version of {@link FlowrAnalyzerBuilder#build}, please only use this if you have set the parser using
|
|
103
|
+
* {@link FlowrAnalyzerBuilder#setParser} before, otherwise an error will be thrown.
|
|
104
|
+
*/
|
|
105
|
+
buildSync(): FlowrAnalyzer;
|
|
106
|
+
}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FlowrAnalyzerBuilder = void 0;
|
|
4
|
+
const config_1 = require("../config");
|
|
5
|
+
const retriever_1 = require("../r-bridge/retriever");
|
|
6
|
+
const flowr_analyzer_1 = require("./flowr-analyzer");
|
|
7
|
+
const engines_1 = require("../engines");
|
|
8
|
+
const assert_1 = require("../util/assert");
|
|
9
|
+
const files_1 = require("../util/files");
|
|
10
|
+
const flowr_analyzer_context_1 = require("./context/flowr-analyzer-context");
|
|
11
|
+
const flowr_analyzer_cache_1 = require("./cache/flowr-analyzer-cache");
|
|
12
|
+
/**
|
|
13
|
+
* Builder for the {@link FlowrAnalyzer}, use it to configure all analysis aspects before creating the analyzer instance
|
|
14
|
+
* with {@link FlowrAnalyzerBuilder#build|`.build()`} or {@link FlowrAnalyzerBuilder#buildSync|`.buildSync()`}.
|
|
15
|
+
*
|
|
16
|
+
* You can add new files and folders to analyze using the constructor or the {@link FlowrAnalyzerBuilder#add|`.add()`} method.
|
|
17
|
+
*
|
|
18
|
+
* @example Let's create an analyzer for a single R script file:
|
|
19
|
+
*
|
|
20
|
+
* ```ts
|
|
21
|
+
* const analyzer = new FlowrAnalyzerBuilder()
|
|
22
|
+
* .add('file:///path/to/script.R')
|
|
23
|
+
* .setParser(new TreeSitterExecutor())
|
|
24
|
+
* .buildSync();
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* If you now want to get the dataflow information for the file, you can do this:
|
|
28
|
+
*
|
|
29
|
+
* ```ts
|
|
30
|
+
* const dfInfo = await analyzer.dataflow();
|
|
31
|
+
* console.log(dfInfo);
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
class FlowrAnalyzerBuilder {
|
|
35
|
+
flowrConfig = (0, config_1.cloneConfig)(config_1.defaultConfigOptions);
|
|
36
|
+
parser;
|
|
37
|
+
request;
|
|
38
|
+
input;
|
|
39
|
+
plugins = new Map();
|
|
40
|
+
/**
|
|
41
|
+
* Create a new builder instance.
|
|
42
|
+
* @param request - The code to analyze
|
|
43
|
+
*/
|
|
44
|
+
constructor(request) {
|
|
45
|
+
this.addRequest(request ?? []);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Add one or multiple requests to analyze.
|
|
49
|
+
* This is a convenience method that uses {@link addRequest} and {@link addRequestFromInput} internally.
|
|
50
|
+
* @param request - One or multiple requests or a file path (with the `file://` protocol). If you just enter a string, it will be interpreted as R code.
|
|
51
|
+
*/
|
|
52
|
+
add(request) {
|
|
53
|
+
if (Array.isArray(request) || (0, retriever_1.isParseRequest)(request)) {
|
|
54
|
+
this.addRequest(request);
|
|
55
|
+
}
|
|
56
|
+
else if (typeof request === 'string') {
|
|
57
|
+
const trimmed = request.substring(retriever_1.fileProtocol.length);
|
|
58
|
+
if (request.startsWith(retriever_1.fileProtocol) && !(0, files_1.isFilePath)(trimmed)) {
|
|
59
|
+
this.addRequest({ request: 'project', content: trimmed });
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
this.addRequestFromInput(request);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
this.addRequest(request);
|
|
67
|
+
}
|
|
68
|
+
return this;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Add one or multiple requests to analyze the builder.
|
|
72
|
+
*/
|
|
73
|
+
addRequest(request) {
|
|
74
|
+
const r = Array.isArray(request) ? request : [request];
|
|
75
|
+
if (this.request) {
|
|
76
|
+
this.request = this.request.concat(request);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
this.request = r;
|
|
80
|
+
}
|
|
81
|
+
return this;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Add a request created from the given input.
|
|
85
|
+
* This is a convenience method that uses {@link requestFromInput} internally.
|
|
86
|
+
*/
|
|
87
|
+
addRequestFromInput(input) {
|
|
88
|
+
this.addRequest((0, retriever_1.requestFromInput)(input));
|
|
89
|
+
return this;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Apply an amendment to the configuration the builder currently holds.
|
|
93
|
+
* Per default, the {@link defaultConfigOptions} are used.
|
|
94
|
+
* @param func - Receives the current configuration of the builder and allows for amendment.
|
|
95
|
+
*/
|
|
96
|
+
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
|
|
97
|
+
amendConfig(func) {
|
|
98
|
+
this.flowrConfig = (0, config_1.amendConfig)(this.flowrConfig, func);
|
|
99
|
+
return this;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Overwrite the configuration used by the resulting analyzer.
|
|
103
|
+
* @param config - The new configuration.
|
|
104
|
+
*/
|
|
105
|
+
setConfig(config) {
|
|
106
|
+
this.flowrConfig = config;
|
|
107
|
+
return this;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Set the parser instance used by the analyzer.
|
|
111
|
+
* This is an alternative to {@link FlowrAnalyzerBuilder#setEngine} if you already have a parser instance.
|
|
112
|
+
* Please be aware, that if you want to parallelize multiple analyzers, there should be separate parser instances.
|
|
113
|
+
*/
|
|
114
|
+
setParser(parser) {
|
|
115
|
+
this.parser = parser;
|
|
116
|
+
return this;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Set the engine and hence the parser that will be used by the analyzer.
|
|
120
|
+
* This is an alternative to {@link FlowrAnalyzerBuilder#setParser} if you do not have a parser instance at hand.
|
|
121
|
+
*/
|
|
122
|
+
setEngine(engine) {
|
|
123
|
+
this.flowrConfig.defaultEngine = engine;
|
|
124
|
+
return this;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Additional parameters for the analyses.
|
|
128
|
+
* @param input - The input.
|
|
129
|
+
*/
|
|
130
|
+
setInput(input) {
|
|
131
|
+
this.input = input;
|
|
132
|
+
return this;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Register one or multiple additional plugins.
|
|
136
|
+
*
|
|
137
|
+
* @see {@link FlowrAnalyzerBuilder#unregisterPlugins} to remove plugins.
|
|
138
|
+
*/
|
|
139
|
+
registerPlugins(...plugin) {
|
|
140
|
+
for (const p of plugin) {
|
|
141
|
+
const g = this.plugins.get(p.type);
|
|
142
|
+
if (g === undefined) {
|
|
143
|
+
this.plugins.set(p.type, [p]);
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
g.push(p);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return this;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Remove one or multiple plugins.
|
|
153
|
+
*/
|
|
154
|
+
unregisterPlugins(...plugin) {
|
|
155
|
+
for (const p of plugin) {
|
|
156
|
+
const g = this.plugins.get(p.type);
|
|
157
|
+
if (g !== undefined) {
|
|
158
|
+
this.plugins.set(p.type, g.filter(x => x !== p));
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return this;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Create the {@link FlowrAnalyzer} instance using the given information.
|
|
165
|
+
* Please note that the only reason this is `async` is that if no parser is set,
|
|
166
|
+
* we need to retrieve the default engine instance which is an async operation.
|
|
167
|
+
* If you set the parser using {@link FlowrAnalyzerBuilder#setParser},
|
|
168
|
+
*/
|
|
169
|
+
async build() {
|
|
170
|
+
if (!this.parser) {
|
|
171
|
+
const engines = await (0, engines_1.retrieveEngineInstances)(this.flowrConfig, true);
|
|
172
|
+
this.parser = engines.engines[engines.default];
|
|
173
|
+
}
|
|
174
|
+
return this.buildSync();
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Synchronous version of {@link FlowrAnalyzerBuilder#build}, please only use this if you have set the parser using
|
|
178
|
+
* {@link FlowrAnalyzerBuilder#setParser} before, otherwise an error will be thrown.
|
|
179
|
+
*/
|
|
180
|
+
buildSync() {
|
|
181
|
+
(0, assert_1.guard)(this.parser !== undefined, 'No parser set, please use the setParser or setEngine method to set a parser before building the analyzer');
|
|
182
|
+
(0, assert_1.guard)(this.request !== undefined, 'Currently we require at least one request to build an analyzer, please provide one using the constructor or the addRequest method');
|
|
183
|
+
const context = new flowr_analyzer_context_1.FlowrAnalyzerContext(this.plugins);
|
|
184
|
+
context.addRequests(this.request);
|
|
185
|
+
// we do it here to save time later if the analyzer is to be duplicated
|
|
186
|
+
context.resolvePreAnalysis();
|
|
187
|
+
const cache = flowr_analyzer_cache_1.FlowrAnalyzerCache.create({
|
|
188
|
+
parser: this.parser,
|
|
189
|
+
config: this.flowrConfig,
|
|
190
|
+
request: context.files.computeLoadingOrder(),
|
|
191
|
+
...(this.input ?? {})
|
|
192
|
+
});
|
|
193
|
+
return new flowr_analyzer_1.FlowrAnalyzer(this.flowrConfig, this.parser, context, cache);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
exports.FlowrAnalyzerBuilder = FlowrAnalyzerBuilder;
|
|
197
|
+
//# sourceMappingURL=flowr-analyzer-builder.js.map
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import type { FlowrConfigOptions } from '../config';
|
|
2
|
+
import type { KnownParser, KnownParserName, ParseStepOutput } from '../r-bridge/parser';
|
|
3
|
+
import type { Queries, QueryResults, SupportedQueryTypes } from '../queries/query';
|
|
4
|
+
import type { ControlFlowInformation } from '../control-flow/control-flow-graph';
|
|
5
|
+
import type { NormalizedAst } from '../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
6
|
+
import type { DataflowInformation } from '../dataflow/info';
|
|
7
|
+
import type { CfgSimplificationPassName } from '../control-flow/cfg-simplification';
|
|
8
|
+
import type { PipelinePerStepMetaInformation } from '../core/steps/pipeline/pipeline';
|
|
9
|
+
import type { FlowrAnalyzerCache } from './cache/flowr-analyzer-cache';
|
|
10
|
+
import type { FlowrSearchLike, SearchOutput } from '../search/flowr-search-builder';
|
|
11
|
+
import type { GetSearchElements } from '../search/flowr-search-executor';
|
|
12
|
+
import type { FlowrAnalyzerContext, ReadOnlyFlowrAnalyzerContext } from './context/flowr-analyzer-context';
|
|
13
|
+
/**
|
|
14
|
+
* Exposes the central analyses and information provided by the {@link FlowrAnalyzer} to the linter, search, and query APIs.
|
|
15
|
+
* This allows us to exchange the underlying implementation of the analyzer without affecting the APIs.
|
|
16
|
+
*/
|
|
17
|
+
export interface FlowrAnalysisProvider {
|
|
18
|
+
/**
|
|
19
|
+
* Get the name of the parser used by the analyzer.
|
|
20
|
+
*/
|
|
21
|
+
parserName(): string;
|
|
22
|
+
/**
|
|
23
|
+
* Returns project context information.
|
|
24
|
+
* If you are a user that wants to inspect the context, prefer {@link inspectContext} instead.
|
|
25
|
+
* Please be aware that modifications to the context may break analyzer assumptions.
|
|
26
|
+
*/
|
|
27
|
+
context(): FlowrAnalyzerContext;
|
|
28
|
+
/**
|
|
29
|
+
* Returns a read-only version of the project context information.
|
|
30
|
+
* This is the preferred method for users that want to inspect the context.
|
|
31
|
+
*/
|
|
32
|
+
inspectContext(): ReadOnlyFlowrAnalyzerContext;
|
|
33
|
+
/**
|
|
34
|
+
* Get the parse output for the request.
|
|
35
|
+
*
|
|
36
|
+
* The parse result type depends on the {@link KnownParser} used by the analyzer.
|
|
37
|
+
* @param force - Do not use the cache, instead force a new parse.
|
|
38
|
+
*/
|
|
39
|
+
parse(force?: boolean): Promise<ParseStepOutput<Awaited<ReturnType<KnownParser['parse']>>> & PipelinePerStepMetaInformation>;
|
|
40
|
+
/**
|
|
41
|
+
* Get the normalized abstract syntax tree for the request.
|
|
42
|
+
* @param force - Do not use the cache, instead force new analyses.
|
|
43
|
+
*/
|
|
44
|
+
normalize(force?: boolean): Promise<NormalizedAst & PipelinePerStepMetaInformation>;
|
|
45
|
+
/**
|
|
46
|
+
* Get the dataflow graph for the request.
|
|
47
|
+
* @param force - Do not use the cache, instead force new analyses.
|
|
48
|
+
*/
|
|
49
|
+
dataflow(force?: boolean): Promise<DataflowInformation & PipelinePerStepMetaInformation>;
|
|
50
|
+
/**
|
|
51
|
+
* Get the control flow graph (CFG) for the request.
|
|
52
|
+
* @param simplifications - Simplification passes to be applied to the CFG.
|
|
53
|
+
* @param useDataflow - Whether to use the dataflow graph for the creation of the CFG.
|
|
54
|
+
* @param force - Do not use the cache, instead force new analyses.
|
|
55
|
+
*/
|
|
56
|
+
controlflow(simplifications?: readonly CfgSimplificationPassName[], useDataflow?: boolean, force?: boolean): Promise<ControlFlowInformation>;
|
|
57
|
+
/**
|
|
58
|
+
* Get a quick and dirty control flow graph (CFG) for the request.
|
|
59
|
+
* This does not use the dataflow information and does not apply any simplifications.
|
|
60
|
+
*
|
|
61
|
+
* @param force - Do not use the cache, instead force new analyses.
|
|
62
|
+
*/
|
|
63
|
+
controlflowQuick(force?: boolean): Promise<ControlFlowInformation>;
|
|
64
|
+
/**
|
|
65
|
+
* Access the query API for the request.
|
|
66
|
+
* @param query - The list of queries.
|
|
67
|
+
*/
|
|
68
|
+
query<Types extends SupportedQueryTypes = SupportedQueryTypes>(query: Queries<Types>): Promise<QueryResults<Types>>;
|
|
69
|
+
/**
|
|
70
|
+
* Run a search on the current analysis.
|
|
71
|
+
*/
|
|
72
|
+
runSearch<Search extends FlowrSearchLike>(search: Search): Promise<GetSearchElements<SearchOutput<Search>>>;
|
|
73
|
+
/**
|
|
74
|
+
* This executes all steps of the core analysis (parse, normalize, dataflow).
|
|
75
|
+
*/
|
|
76
|
+
runFull(force?: boolean): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Reset all caches used by the analyzer and effectively force all analyses to be redone.
|
|
79
|
+
*/
|
|
80
|
+
reset(): void;
|
|
81
|
+
/** This is the config used for the analyzer */
|
|
82
|
+
flowrConfig: FlowrConfigOptions;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Central class for conducting analyses with FlowR.
|
|
86
|
+
* Use the {@link FlowrAnalyzerBuilder} to create a new instance.
|
|
87
|
+
*
|
|
88
|
+
* If you want the original pattern of creating a pipeline and running all steps, you can still do this with {@link FlowrAnalyzer#runFull}.
|
|
89
|
+
*
|
|
90
|
+
* To inspect the context of the analyzer, use {@link FlowrAnalyzer#inspectContext} (if you are a plugin and need to modify it, use {@link FlowrAnalyzer#context} instead).
|
|
91
|
+
*/
|
|
92
|
+
export declare class FlowrAnalyzer<Parser extends KnownParser = KnownParser> implements FlowrAnalysisProvider {
|
|
93
|
+
readonly flowrConfig: FlowrConfigOptions;
|
|
94
|
+
/** The parser and engine backend */
|
|
95
|
+
private readonly parser;
|
|
96
|
+
/** The cache used for storing analysis results */
|
|
97
|
+
private readonly cache;
|
|
98
|
+
private readonly ctx;
|
|
99
|
+
/**
|
|
100
|
+
* Create a new analyzer instance.
|
|
101
|
+
* **Prefer the use of the {@link FlowrAnalyzerBuilder} instead of calling this constructor directly.**
|
|
102
|
+
*
|
|
103
|
+
* @param config - The FlowR config to use for the analyses
|
|
104
|
+
* @param parser - The parser to use for parsing the given request.
|
|
105
|
+
* @param ctx - The context to use for the analyses.
|
|
106
|
+
* @param cache - The caching layer to use for storing analysis results.
|
|
107
|
+
*/
|
|
108
|
+
constructor(config: FlowrConfigOptions, parser: Parser, ctx: FlowrAnalyzerContext, cache: FlowrAnalyzerCache<Parser>);
|
|
109
|
+
context(): FlowrAnalyzerContext;
|
|
110
|
+
inspectContext(): ReadOnlyFlowrAnalyzerContext;
|
|
111
|
+
reset(): void;
|
|
112
|
+
parserName(): KnownParserName;
|
|
113
|
+
parse(force?: boolean): ReturnType<typeof this.cache.parse>;
|
|
114
|
+
normalize(force?: boolean): ReturnType<typeof this.cache.normalize>;
|
|
115
|
+
dataflow(force?: boolean): ReturnType<typeof this.cache.dataflow>;
|
|
116
|
+
runFull(force?: boolean): Promise<void>;
|
|
117
|
+
controlflow(simplifications?: readonly CfgSimplificationPassName[], useDataflow?: boolean, force?: boolean): Promise<ControlFlowInformation>;
|
|
118
|
+
controlflowQuick(force?: boolean): Promise<ControlFlowInformation>;
|
|
119
|
+
query<Types extends SupportedQueryTypes = SupportedQueryTypes>(query: Queries<Types>): Promise<QueryResults<Types>>;
|
|
120
|
+
runSearch<Search extends FlowrSearchLike>(search: Search): Promise<GetSearchElements<SearchOutput<Search>>>;
|
|
121
|
+
/**
|
|
122
|
+
* Close the parser if it was created by this builder. This is only required if you rely on an RShell/remote engine.
|
|
123
|
+
*/
|
|
124
|
+
close(): boolean | void;
|
|
125
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FlowrAnalyzer = void 0;
|
|
4
|
+
const query_1 = require("../queries/query");
|
|
5
|
+
const flowr_search_executor_1 = require("../search/flowr-search-executor");
|
|
6
|
+
/**
|
|
7
|
+
* Central class for conducting analyses with FlowR.
|
|
8
|
+
* Use the {@link FlowrAnalyzerBuilder} to create a new instance.
|
|
9
|
+
*
|
|
10
|
+
* If you want the original pattern of creating a pipeline and running all steps, you can still do this with {@link FlowrAnalyzer#runFull}.
|
|
11
|
+
*
|
|
12
|
+
* To inspect the context of the analyzer, use {@link FlowrAnalyzer#inspectContext} (if you are a plugin and need to modify it, use {@link FlowrAnalyzer#context} instead).
|
|
13
|
+
*/
|
|
14
|
+
class FlowrAnalyzer {
|
|
15
|
+
flowrConfig;
|
|
16
|
+
/** The parser and engine backend */
|
|
17
|
+
parser;
|
|
18
|
+
/** The cache used for storing analysis results */
|
|
19
|
+
cache;
|
|
20
|
+
ctx;
|
|
21
|
+
/**
|
|
22
|
+
* Create a new analyzer instance.
|
|
23
|
+
* **Prefer the use of the {@link FlowrAnalyzerBuilder} instead of calling this constructor directly.**
|
|
24
|
+
*
|
|
25
|
+
* @param config - The FlowR config to use for the analyses
|
|
26
|
+
* @param parser - The parser to use for parsing the given request.
|
|
27
|
+
* @param ctx - The context to use for the analyses.
|
|
28
|
+
* @param cache - The caching layer to use for storing analysis results.
|
|
29
|
+
*/
|
|
30
|
+
constructor(config, parser, ctx, cache) {
|
|
31
|
+
this.flowrConfig = config;
|
|
32
|
+
this.parser = parser;
|
|
33
|
+
this.ctx = ctx;
|
|
34
|
+
this.cache = cache;
|
|
35
|
+
}
|
|
36
|
+
context() {
|
|
37
|
+
return this.ctx;
|
|
38
|
+
}
|
|
39
|
+
inspectContext() {
|
|
40
|
+
return this.ctx.inspect();
|
|
41
|
+
}
|
|
42
|
+
reset() {
|
|
43
|
+
this.cache.reset();
|
|
44
|
+
}
|
|
45
|
+
parserName() {
|
|
46
|
+
return this.parser.name;
|
|
47
|
+
}
|
|
48
|
+
async parse(force) {
|
|
49
|
+
return this.cache.parse(force);
|
|
50
|
+
}
|
|
51
|
+
async normalize(force) {
|
|
52
|
+
return this.cache.normalize(force);
|
|
53
|
+
}
|
|
54
|
+
async dataflow(force) {
|
|
55
|
+
return this.cache.dataflow(force);
|
|
56
|
+
}
|
|
57
|
+
async runFull(force) {
|
|
58
|
+
await this.dataflow(force);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
async controlflow(simplifications, useDataflow, force) {
|
|
62
|
+
return this.cache.controlflow(force, useDataflow ?? false, simplifications);
|
|
63
|
+
}
|
|
64
|
+
async controlflowQuick(force) {
|
|
65
|
+
return this.controlflow(undefined, false, force);
|
|
66
|
+
}
|
|
67
|
+
async query(query) {
|
|
68
|
+
return (0, query_1.executeQueries)({ analyzer: this }, query);
|
|
69
|
+
}
|
|
70
|
+
async runSearch(search) {
|
|
71
|
+
return (0, flowr_search_executor_1.runSearch)(search, this);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Close the parser if it was created by this builder. This is only required if you rely on an RShell/remote engine.
|
|
75
|
+
*/
|
|
76
|
+
close() {
|
|
77
|
+
return this.parser?.close();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.FlowrAnalyzer = FlowrAnalyzer;
|
|
81
|
+
//# sourceMappingURL=flowr-analyzer.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { FlowrAnalyzerFilePlugin } from './flowr-analyzer-file-plugin';
|
|
2
|
+
import { SemVer } from 'semver';
|
|
3
|
+
import type { PathLike } from 'fs';
|
|
4
|
+
import type { FlowrAnalyzerContext } from '../../context/flowr-analyzer-context';
|
|
5
|
+
import { FlowrDescriptionFile } from './flowr-description-file';
|
|
6
|
+
import type { FlowrFileProvider } from '../../context/flowr-file';
|
|
7
|
+
export declare const descriptionFileLog: import("tslog").Logger<import("tslog").ILogObj>;
|
|
8
|
+
/**
|
|
9
|
+
* This plugin provides support for R `DESCRIPTION` files.
|
|
10
|
+
*/
|
|
11
|
+
export declare class FlowrAnalyzerDescriptionFilePlugin extends FlowrAnalyzerFilePlugin {
|
|
12
|
+
readonly name = "flowr-analyzer-description-file-plugin";
|
|
13
|
+
readonly description = "This plugin provides support for DESCRIPTION files and extracts their content into key-value(s) pairs.";
|
|
14
|
+
readonly version: SemVer;
|
|
15
|
+
applies(file: PathLike): boolean;
|
|
16
|
+
process(_ctx: FlowrAnalyzerContext, file: FlowrFileProvider<string>): FlowrDescriptionFile;
|
|
17
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FlowrAnalyzerDescriptionFilePlugin = exports.descriptionFileLog = void 0;
|
|
4
|
+
const flowr_analyzer_file_plugin_1 = require("./flowr-analyzer-file-plugin");
|
|
5
|
+
const semver_1 = require("semver");
|
|
6
|
+
const log_1 = require("../../../util/log");
|
|
7
|
+
const flowr_description_file_1 = require("./flowr-description-file");
|
|
8
|
+
const flowr_file_1 = require("../../context/flowr-file");
|
|
9
|
+
exports.descriptionFileLog = log_1.log.getSubLogger({ name: 'flowr-analyzer-loading-order-description-file-plugin' });
|
|
10
|
+
/**
|
|
11
|
+
* This plugin provides support for R `DESCRIPTION` files.
|
|
12
|
+
*/
|
|
13
|
+
class FlowrAnalyzerDescriptionFilePlugin extends flowr_analyzer_file_plugin_1.FlowrAnalyzerFilePlugin {
|
|
14
|
+
name = 'flowr-analyzer-description-file-plugin';
|
|
15
|
+
description = 'This plugin provides support for DESCRIPTION files and extracts their content into key-value(s) pairs.';
|
|
16
|
+
version = new semver_1.SemVer('0.1.0');
|
|
17
|
+
applies(file) {
|
|
18
|
+
return /^(DESCRIPTION|DESCRIPTION\.txt)$/i.test(file.toString().split(/[/\\]/).pop() ?? '');
|
|
19
|
+
}
|
|
20
|
+
process(_ctx, file) {
|
|
21
|
+
const f = flowr_description_file_1.FlowrDescriptionFile.from(file, flowr_file_1.SpecialFileRole.Description);
|
|
22
|
+
// already load it here
|
|
23
|
+
f.content();
|
|
24
|
+
return f;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.FlowrAnalyzerDescriptionFilePlugin = FlowrAnalyzerDescriptionFilePlugin;
|
|
28
|
+
//# sourceMappingURL=flowr-analyzer-description-file-plugin.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { FlowrAnalyzerPlugin, PluginType } from '../flowr-analyzer-plugin';
|
|
2
|
+
import type { PathLike } from 'fs';
|
|
3
|
+
import type { FlowrFileProvider } from '../../context/flowr-file';
|
|
4
|
+
/**
|
|
5
|
+
* This is the base class for all plugins that load and possibly transform files when they are loaded.
|
|
6
|
+
* Different from other plugins, these plugins trigger for each file that is loaded (if they {@link applies} to the file).
|
|
7
|
+
* See the {@link FlowrAnalyzerFilesContext.addFile} for more information on how files are loaded and managed.
|
|
8
|
+
*
|
|
9
|
+
* It is upt to the construction to ensure that no two file plugins {@link applies} to the same file, otherwise, the loading order
|
|
10
|
+
* of these plugins will determine which plugin gets to process the file.
|
|
11
|
+
*
|
|
12
|
+
* See {@link DefaultFlowrAnalyzerFilePlugin} for the no-op default implementation.
|
|
13
|
+
*/
|
|
14
|
+
export declare abstract class FlowrAnalyzerFilePlugin extends FlowrAnalyzerPlugin<FlowrFileProvider<string>, FlowrFileProvider> {
|
|
15
|
+
readonly type = PluginType.FileLoad;
|
|
16
|
+
/**
|
|
17
|
+
* Determine whether this plugin applies to the given file.
|
|
18
|
+
*/
|
|
19
|
+
abstract applies(file: PathLike): boolean;
|
|
20
|
+
static defaultPlugin(): FlowrAnalyzerFilePlugin;
|
|
21
|
+
}
|