@eagleoutice/flowr 2.5.0 → 2.6.1
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 +46 -35
- package/abstract-interpretation/data-frame/absint-visitor.d.ts +1 -1
- package/abstract-interpretation/data-frame/absint-visitor.js +1 -1
- package/cli/flowr.js +11 -33
- 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.d.ts +1 -1
- package/cli/repl/commands/repl-execute.js +8 -7
- package/cli/repl/commands/repl-lineage.d.ts +2 -2
- package/cli/repl/commands/repl-lineage.js +11 -11
- package/cli/repl/commands/repl-main.d.ts +35 -7
- 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 +14 -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.d.ts +1 -16
- package/cli/repl/commands/repl-version.js +2 -18
- package/cli/repl/core.d.ts +12 -9
- package/cli/repl/core.js +26 -12
- package/cli/repl/print-version.js +2 -2
- package/cli/repl/server/connection.d.ts +7 -3
- package/cli/repl/server/connection.js +46 -50
- package/cli/repl/server/messages/message-hello.d.ts +1 -1
- package/cli/repl/server/messages/message-slice.d.ts +1 -1
- package/cli/repl/server/server.js +2 -2
- 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/all/core/20-dataflow.d.ts +3 -1
- package/core/steps/pipeline/create-pipeline.js +1 -1
- package/core/steps/pipeline/default-pipelines.d.ts +24 -8
- package/core/steps/pipeline/default-pipelines.js +4 -1
- package/dataflow/environments/default-builtin-config.js +8 -0
- package/dataflow/eval/resolve/alias-tracking.js +2 -0
- package/dataflow/eval/resolve/resolve.js +3 -0
- package/dataflow/eval/values/r-value.d.ts +4 -1
- package/dataflow/eval/values/r-value.js +2 -0
- package/dataflow/extractor.d.ts +4 -1
- package/dataflow/extractor.js +7 -5
- package/dataflow/fn/higher-order-function.d.ts +9 -0
- package/dataflow/fn/higher-order-function.js +75 -0
- 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-repl.js +5 -2
- 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 +16 -23
- 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/documentation/print-query-wiki.js +20 -0
- package/documentation/print-readme.js +1 -1
- 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 +94 -0
- package/project/cache/flowr-analyzer-cache.js +164 -0
- package/project/cache/flowr-cache.d.ts +28 -0
- package/project/cache/flowr-cache.js +49 -0
- package/project/cfg-kind.d.ts +17 -0
- package/project/cfg-kind.js +22 -0
- package/project/context/abstract-flowr-analyzer-context.d.ts +39 -0
- package/project/context/abstract-flowr-analyzer-context.js +46 -0
- package/project/context/flowr-analyzer-context.d.ts +54 -0
- package/project/context/flowr-analyzer-context.js +58 -0
- package/project/context/flowr-analyzer-dependencies-context.d.ts +39 -0
- package/project/context/flowr-analyzer-dependencies-context.js +43 -0
- package/project/context/flowr-analyzer-files-context.d.ts +87 -0
- package/project/context/flowr-analyzer-files-context.js +134 -0
- package/project/context/flowr-analyzer-loading-order-context.d.ts +77 -0
- package/project/context/flowr-analyzer-loading-order-context.js +96 -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 +126 -0
- package/project/flowr-analyzer.js +88 -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 +21 -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 +3 -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/inspect-higher-order-query/inspect-higher-order-query-executor.d.ts +3 -0
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +45 -0
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +22 -0
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +32 -0
- 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 +37 -885
- package/queries/query.js +3 -1
- package/r-bridge/parser.d.ts +7 -0
- 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 +5 -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/r-value.d.ts +1 -1
- package/util/r-value.js +2 -0
- package/util/version.d.ts +17 -0
- package/util/version.js +28 -1
|
@@ -0,0 +1,88 @@
|
|
|
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
|
+
const cfg_kind_1 = require("./cfg-kind");
|
|
7
|
+
const shell_1 = require("../r-bridge/shell");
|
|
8
|
+
const assert_1 = require("../util/assert");
|
|
9
|
+
/**
|
|
10
|
+
* Central class for conducting analyses with FlowR.
|
|
11
|
+
* Use the {@link FlowrAnalyzerBuilder} to create a new instance.
|
|
12
|
+
*
|
|
13
|
+
* If you want the original pattern of creating a pipeline and running all steps, you can still do this with {@link FlowrAnalyzer#runFull}.
|
|
14
|
+
*
|
|
15
|
+
* 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).
|
|
16
|
+
*/
|
|
17
|
+
class FlowrAnalyzer {
|
|
18
|
+
flowrConfig;
|
|
19
|
+
/** The parser and engine backend */
|
|
20
|
+
parser;
|
|
21
|
+
/** The cache used for storing analysis results */
|
|
22
|
+
cache;
|
|
23
|
+
ctx;
|
|
24
|
+
/**
|
|
25
|
+
* Create a new analyzer instance.
|
|
26
|
+
* **Prefer the use of the {@link FlowrAnalyzerBuilder} instead of calling this constructor directly.**
|
|
27
|
+
*
|
|
28
|
+
* @param config - The FlowR config to use for the analyses
|
|
29
|
+
* @param parser - The parser to use for parsing the given request.
|
|
30
|
+
* @param ctx - The context to use for the analyses.
|
|
31
|
+
* @param cache - The caching layer to use for storing analysis results.
|
|
32
|
+
*/
|
|
33
|
+
constructor(config, parser, ctx, cache) {
|
|
34
|
+
this.flowrConfig = config;
|
|
35
|
+
this.parser = parser;
|
|
36
|
+
this.ctx = ctx;
|
|
37
|
+
this.cache = cache;
|
|
38
|
+
}
|
|
39
|
+
context() {
|
|
40
|
+
return this.ctx;
|
|
41
|
+
}
|
|
42
|
+
async parserInformation() {
|
|
43
|
+
return this.parser.name === 'r-shell' ?
|
|
44
|
+
{ name: 'r-shell', rVersion: await this.parser.rVersion() }
|
|
45
|
+
: { name: 'tree-sitter' };
|
|
46
|
+
}
|
|
47
|
+
async sendCommandWithOutput(command, addonConfig) {
|
|
48
|
+
(0, assert_1.guard)(this.parser instanceof shell_1.RShell, 'sendCommandWithOutput can only be used with RShell parsers!');
|
|
49
|
+
return this.parser.sendCommandWithOutput(command, addonConfig);
|
|
50
|
+
}
|
|
51
|
+
inspectContext() {
|
|
52
|
+
return this.ctx.inspect();
|
|
53
|
+
}
|
|
54
|
+
reset() {
|
|
55
|
+
this.ctx.reset();
|
|
56
|
+
this.cache.reset();
|
|
57
|
+
}
|
|
58
|
+
async parse(force) {
|
|
59
|
+
return this.cache.parse(force);
|
|
60
|
+
}
|
|
61
|
+
async normalize(force) {
|
|
62
|
+
return this.cache.normalize(force);
|
|
63
|
+
}
|
|
64
|
+
async dataflow(force) {
|
|
65
|
+
return this.cache.dataflow(force);
|
|
66
|
+
}
|
|
67
|
+
async runFull(force) {
|
|
68
|
+
await this.dataflow(force);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
async controlflow(simplifications, kind, force) {
|
|
72
|
+
return this.cache.controlflow(force, kind ?? cfg_kind_1.CfgKind.NoDataflow, simplifications);
|
|
73
|
+
}
|
|
74
|
+
async query(query) {
|
|
75
|
+
return (0, query_1.executeQueries)({ analyzer: this }, query);
|
|
76
|
+
}
|
|
77
|
+
async runSearch(search) {
|
|
78
|
+
return (0, flowr_search_executor_1.runSearch)(search, this);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Close the parser if it was created by this builder. This is only required if you rely on an RShell/remote engine.
|
|
82
|
+
*/
|
|
83
|
+
close() {
|
|
84
|
+
return this.parser?.close();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
exports.FlowrAnalyzer = FlowrAnalyzer;
|
|
88
|
+
//# 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
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FlowrAnalyzerFilePlugin = void 0;
|
|
4
|
+
const flowr_analyzer_plugin_1 = require("../flowr-analyzer-plugin");
|
|
5
|
+
const semver_1 = require("semver");
|
|
6
|
+
/**
|
|
7
|
+
* This is the base class for all plugins that load and possibly transform files when they are loaded.
|
|
8
|
+
* Different from other plugins, these plugins trigger for each file that is loaded (if they {@link applies} to the file).
|
|
9
|
+
* See the {@link FlowrAnalyzerFilesContext.addFile} for more information on how files are loaded and managed.
|
|
10
|
+
*
|
|
11
|
+
* It is upt to the construction to ensure that no two file plugins {@link applies} to the same file, otherwise, the loading order
|
|
12
|
+
* of these plugins will determine which plugin gets to process the file.
|
|
13
|
+
*
|
|
14
|
+
* See {@link DefaultFlowrAnalyzerFilePlugin} for the no-op default implementation.
|
|
15
|
+
*/
|
|
16
|
+
class FlowrAnalyzerFilePlugin extends flowr_analyzer_plugin_1.FlowrAnalyzerPlugin {
|
|
17
|
+
type = flowr_analyzer_plugin_1.PluginType.FileLoad;
|
|
18
|
+
static defaultPlugin() {
|
|
19
|
+
return new DefaultFlowrAnalyzerFilePlugin();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.FlowrAnalyzerFilePlugin = FlowrAnalyzerFilePlugin;
|
|
23
|
+
class DefaultFlowrAnalyzerFilePlugin extends FlowrAnalyzerFilePlugin {
|
|
24
|
+
name = 'default-file-plugin';
|
|
25
|
+
description = 'This is the default file plugin that does nothing.';
|
|
26
|
+
version = new semver_1.SemVer('0.0.0');
|
|
27
|
+
applies() {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
process(_context, args) {
|
|
31
|
+
return args;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=flowr-analyzer-file-plugin.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { FlowrFileProvider, SpecialFileRole } from '../../context/flowr-file';
|
|
2
|
+
import { FlowrFile } from '../../context/flowr-file';
|
|
3
|
+
export type DCF = Map<string, string[]>;
|
|
4
|
+
/**
|
|
5
|
+
* This decorates a text file and provides access to its content as a DCF (Debian Control File)-like structure.
|
|
6
|
+
*/
|
|
7
|
+
export declare class FlowrDescriptionFile extends FlowrFile<DCF> {
|
|
8
|
+
private readonly wrapped;
|
|
9
|
+
/**
|
|
10
|
+
* Prefer the static {@link FlowrDescriptionFile.from} method to create instances of this class as it will not re-create if already a description file
|
|
11
|
+
* and handle role assignments.
|
|
12
|
+
*/
|
|
13
|
+
constructor(file: FlowrFileProvider<string>);
|
|
14
|
+
/**
|
|
15
|
+
* Loads and parses the content of the wrapped file as a DCF structure.
|
|
16
|
+
*
|
|
17
|
+
* @see {@link parseDCF} for details on the parsing logic.
|
|
18
|
+
*/
|
|
19
|
+
protected loadContent(): DCF;
|
|
20
|
+
/**
|
|
21
|
+
* Description file lifter, this does not re-create if already a description file
|
|
22
|
+
*/
|
|
23
|
+
static from(file: FlowrFileProvider<string> | FlowrDescriptionFile, role?: SpecialFileRole): FlowrDescriptionFile;
|
|
24
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FlowrDescriptionFile = void 0;
|
|
4
|
+
const flowr_file_1 = require("../../context/flowr-file");
|
|
5
|
+
const files_1 = require("../../../util/files");
|
|
6
|
+
/**
|
|
7
|
+
* This decorates a text file and provides access to its content as a DCF (Debian Control File)-like structure.
|
|
8
|
+
*/
|
|
9
|
+
class FlowrDescriptionFile extends flowr_file_1.FlowrFile {
|
|
10
|
+
wrapped;
|
|
11
|
+
/**
|
|
12
|
+
* Prefer the static {@link FlowrDescriptionFile.from} method to create instances of this class as it will not re-create if already a description file
|
|
13
|
+
* and handle role assignments.
|
|
14
|
+
*/
|
|
15
|
+
constructor(file) {
|
|
16
|
+
super(file.path(), file.role);
|
|
17
|
+
this.wrapped = file;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Loads and parses the content of the wrapped file as a DCF structure.
|
|
21
|
+
*
|
|
22
|
+
* @see {@link parseDCF} for details on the parsing logic.
|
|
23
|
+
*/
|
|
24
|
+
loadContent() {
|
|
25
|
+
return (0, files_1.parseDCF)(this.wrapped);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Description file lifter, this does not re-create if already a description file
|
|
29
|
+
*/
|
|
30
|
+
static from(file, role) {
|
|
31
|
+
if (role) {
|
|
32
|
+
file.assignRole(role);
|
|
33
|
+
}
|
|
34
|
+
return file instanceof FlowrDescriptionFile ? file : new FlowrDescriptionFile(file);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.FlowrDescriptionFile = FlowrDescriptionFile;
|
|
38
|
+
//# sourceMappingURL=flowr-description-file.js.map
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { SemVer } from 'semver';
|
|
2
|
+
import type { AsyncOrSync } from 'ts-essentials';
|
|
3
|
+
import type { FlowrAnalyzerContext } from '../context/flowr-analyzer-context';
|
|
4
|
+
/**
|
|
5
|
+
* Based on *when* and *what-for* the plugin is applied during the analysis,
|
|
6
|
+
* plugins are categorized into different types.
|
|
7
|
+
*
|
|
8
|
+
* Consult this diagram for an overview of orders and (implicit or explicit) dependencies:
|
|
9
|
+
*
|
|
10
|
+
* ```text
|
|
11
|
+
* ┌───────────┐ ┌───────────────────┐ ┌─────────────┐ ┌───────────────┐ ┌───────┐
|
|
12
|
+
* │ │ │ │ │ │ │ │ │ │
|
|
13
|
+
* │ *Builder* ├──▶│ Project Discovery ├──▶│ File Loader ├──▶│ Dependencies ├──▶│ *DFA* │
|
|
14
|
+
* │ │ │ (if necessary) │ │ │ │ (static) │ │ │
|
|
15
|
+
* └───────────┘ └───────────────────┘ └──────┬──────┘ └───────────────┘ └───────┘
|
|
16
|
+
* │ ▲
|
|
17
|
+
* │ ┌───────────────┐ │
|
|
18
|
+
* │ │ │ │
|
|
19
|
+
* └─────────▶│ Loading Order ├───────┘
|
|
20
|
+
* │ │
|
|
21
|
+
* └───────────────┘
|
|
22
|
+
*```
|
|
23
|
+
*
|
|
24
|
+
*/
|
|
25
|
+
export declare enum PluginType {
|
|
26
|
+
/**
|
|
27
|
+
* Plugins that are applied right after the builder has been created and before any analysis is done.
|
|
28
|
+
* @see {@link FlowrAnalyzerPackageVersionsPlugin} - for the base class to implement such a plugin.
|
|
29
|
+
*/
|
|
30
|
+
DependencyIdentification = "package-versions",
|
|
31
|
+
/**
|
|
32
|
+
* Plugins that are used to determine the order in which files are loaded and analyzed.
|
|
33
|
+
* @see {@link FlowrAnalyzerLoadingOrderPlugin} - for the base class to implement such a plugin.
|
|
34
|
+
*/
|
|
35
|
+
LoadingOrder = "loading-order",
|
|
36
|
+
/**
|
|
37
|
+
* Plugins that are applied to discover the project structure, files, and folders to analyze.
|
|
38
|
+
* @see {@link FlowrAnalyzerProjectDiscoveryPlugin} - for the base class to implement such a plugin.
|
|
39
|
+
*/
|
|
40
|
+
ProjectDiscovery = "project-discovery",
|
|
41
|
+
/**
|
|
42
|
+
* Plugins that are applied to load and parse files.
|
|
43
|
+
* @see {@link FlowrAnalyzerFilePlugin} - for the base class to implement such a plugin.
|
|
44
|
+
*/
|
|
45
|
+
FileLoad = "file-load"
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* This is the main interface that every plugin to be used with the {@link FlowrAnalyzer} must comply with.
|
|
49
|
+
*
|
|
50
|
+
* One of the most important decisions for the generics is also the {@link PluginType}, as this determines
|
|
51
|
+
* at which stage of the analysis the plugin is applied and what it is expected to do.
|
|
52
|
+
* Do yourself a favor and do not implement a corresponding class yourself but use the classes referenced alongside
|
|
53
|
+
* the {@link PluginType} values, as these already provide the correct generic restrictions, additional capabilities, and the `type` property.
|
|
54
|
+
*/
|
|
55
|
+
export interface FlowrAnalyzerPluginInterface<In = unknown, Out = In> {
|
|
56
|
+
/** A unique, human-readable name of the plugin. */
|
|
57
|
+
readonly name: string;
|
|
58
|
+
/** A short description of what the plugin does. */
|
|
59
|
+
readonly description: string;
|
|
60
|
+
/** The version of the plugin, ideally following [semver](https://semver.org/). */
|
|
61
|
+
readonly version: SemVer;
|
|
62
|
+
/** The type of the plugin, determining when and for what purpose it is applied during the analysis. */
|
|
63
|
+
readonly type: PluginType;
|
|
64
|
+
/**
|
|
65
|
+
* The main implementation of the plugin, receiving the current analysis context and the input arguments,
|
|
66
|
+
* The plugin is (based on the restrictions of its {@link PluginType}) allowed to modify the context.
|
|
67
|
+
*/
|
|
68
|
+
processor(analyzer: FlowrAnalyzerContext, args: In): Out;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The base class every plugin to be used with the {@link FlowrAnalyzer} must extend.
|
|
72
|
+
* **Please do not create plugins directly based on this class, but use the classes referenced alongside the {@link PluginType} values!**
|
|
73
|
+
* For example, if you want to create a plugin that determines the loading order of files, extend {@link FlowrAnalyzerLoadingOrderPlugin} instead.
|
|
74
|
+
* These classes also provide sensible overrides of {@link FlowrAnalyzerPlugin.defaultPlugin} to be used when no plugin of this type is registered or triggered.
|
|
75
|
+
*/
|
|
76
|
+
export declare abstract class FlowrAnalyzerPlugin<In = unknown, Out extends AsyncOrSync<unknown> = In> implements FlowrAnalyzerPluginInterface<In, Out> {
|
|
77
|
+
abstract readonly name: string;
|
|
78
|
+
abstract readonly description: string;
|
|
79
|
+
abstract readonly version: SemVer;
|
|
80
|
+
abstract readonly type: PluginType;
|
|
81
|
+
/**
|
|
82
|
+
* Returns a default/dummy implementation to be used when no plugin of this type is registered or triggered.
|
|
83
|
+
*/
|
|
84
|
+
static defaultPlugin(): FlowrAnalyzerPlugin<unknown, unknown>;
|
|
85
|
+
/**
|
|
86
|
+
* Run the plugin with the given context and arguments.
|
|
87
|
+
*/
|
|
88
|
+
processor(context: FlowrAnalyzerContext, args: In): Out;
|
|
89
|
+
protected abstract process(analyzer: FlowrAnalyzerContext, args: In): Out;
|
|
90
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FlowrAnalyzerPlugin = exports.PluginType = void 0;
|
|
4
|
+
const log_1 = require("../../util/log");
|
|
5
|
+
/**
|
|
6
|
+
* Based on *when* and *what-for* the plugin is applied during the analysis,
|
|
7
|
+
* plugins are categorized into different types.
|
|
8
|
+
*
|
|
9
|
+
* Consult this diagram for an overview of orders and (implicit or explicit) dependencies:
|
|
10
|
+
*
|
|
11
|
+
* ```text
|
|
12
|
+
* ┌───────────┐ ┌───────────────────┐ ┌─────────────┐ ┌───────────────┐ ┌───────┐
|
|
13
|
+
* │ │ │ │ │ │ │ │ │ │
|
|
14
|
+
* │ *Builder* ├──▶│ Project Discovery ├──▶│ File Loader ├──▶│ Dependencies ├──▶│ *DFA* │
|
|
15
|
+
* │ │ │ (if necessary) │ │ │ │ (static) │ │ │
|
|
16
|
+
* └───────────┘ └───────────────────┘ └──────┬──────┘ └───────────────┘ └───────┘
|
|
17
|
+
* │ ▲
|
|
18
|
+
* │ ┌───────────────┐ │
|
|
19
|
+
* │ │ │ │
|
|
20
|
+
* └─────────▶│ Loading Order ├───────┘
|
|
21
|
+
* │ │
|
|
22
|
+
* └───────────────┘
|
|
23
|
+
*```
|
|
24
|
+
*
|
|
25
|
+
*/
|
|
26
|
+
var PluginType;
|
|
27
|
+
(function (PluginType) {
|
|
28
|
+
/**
|
|
29
|
+
* Plugins that are applied right after the builder has been created and before any analysis is done.
|
|
30
|
+
* @see {@link FlowrAnalyzerPackageVersionsPlugin} - for the base class to implement such a plugin.
|
|
31
|
+
*/
|
|
32
|
+
PluginType["DependencyIdentification"] = "package-versions";
|
|
33
|
+
/**
|
|
34
|
+
* Plugins that are used to determine the order in which files are loaded and analyzed.
|
|
35
|
+
* @see {@link FlowrAnalyzerLoadingOrderPlugin} - for the base class to implement such a plugin.
|
|
36
|
+
*/
|
|
37
|
+
PluginType["LoadingOrder"] = "loading-order";
|
|
38
|
+
/**
|
|
39
|
+
* Plugins that are applied to discover the project structure, files, and folders to analyze.
|
|
40
|
+
* @see {@link FlowrAnalyzerProjectDiscoveryPlugin} - for the base class to implement such a plugin.
|
|
41
|
+
*/
|
|
42
|
+
PluginType["ProjectDiscovery"] = "project-discovery";
|
|
43
|
+
/**
|
|
44
|
+
* Plugins that are applied to load and parse files.
|
|
45
|
+
* @see {@link FlowrAnalyzerFilePlugin} - for the base class to implement such a plugin.
|
|
46
|
+
*/
|
|
47
|
+
PluginType["FileLoad"] = "file-load";
|
|
48
|
+
})(PluginType || (exports.PluginType = PluginType = {}));
|
|
49
|
+
const generalPluginLog = log_1.log.getSubLogger({ name: 'plugins' });
|
|
50
|
+
/**
|
|
51
|
+
* The base class every plugin to be used with the {@link FlowrAnalyzer} must extend.
|
|
52
|
+
* **Please do not create plugins directly based on this class, but use the classes referenced alongside the {@link PluginType} values!**
|
|
53
|
+
* For example, if you want to create a plugin that determines the loading order of files, extend {@link FlowrAnalyzerLoadingOrderPlugin} instead.
|
|
54
|
+
* These classes also provide sensible overrides of {@link FlowrAnalyzerPlugin.defaultPlugin} to be used when no plugin of this type is registered or triggered.
|
|
55
|
+
*/
|
|
56
|
+
class FlowrAnalyzerPlugin {
|
|
57
|
+
/**
|
|
58
|
+
* Returns a default/dummy implementation to be used when no plugin of this type is registered or triggered.
|
|
59
|
+
*/
|
|
60
|
+
static defaultPlugin() {
|
|
61
|
+
throw new Error('This is to be implemented by every Plugin Layer');
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Run the plugin with the given context and arguments.
|
|
65
|
+
*/
|
|
66
|
+
processor(context, args) {
|
|
67
|
+
const now = Date.now();
|
|
68
|
+
try {
|
|
69
|
+
const result = this.process(context, args);
|
|
70
|
+
const duration = Date.now() - now;
|
|
71
|
+
(0, log_1.expensiveTrace)(generalPluginLog, () => `Plugin ${this.name} (v${this.version.format()}, ${this.type}) executed in ${duration}ms.`);
|
|
72
|
+
return result;
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
const duration = Date.now() - now;
|
|
76
|
+
generalPluginLog.error(`Plugin ${this.name} (v${this.version.format()}, {this.type}) failed after ${duration}ms. Error: ${error.message}`);
|
|
77
|
+
throw error;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.FlowrAnalyzerPlugin = FlowrAnalyzerPlugin;
|
|
82
|
+
//# sourceMappingURL=flowr-analyzer-plugin.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SemVer } from 'semver';
|
|
2
|
+
import { FlowrAnalyzerLoadingOrderPlugin } from './flowr-analyzer-loading-order-plugin';
|
|
3
|
+
import type { FlowrAnalyzerContext } from '../../context/flowr-analyzer-context';
|
|
4
|
+
/**
|
|
5
|
+
* This plugin extracts loading order information from R `DESCRIPTION` files.
|
|
6
|
+
* It looks at the `Collate` field to determine the order in which files should be loaded.
|
|
7
|
+
* If no `Collate` field is present, it does nothing.
|
|
8
|
+
*/
|
|
9
|
+
export declare class FlowrAnalyzerLoadingOrderDescriptionFilePlugin extends FlowrAnalyzerLoadingOrderPlugin {
|
|
10
|
+
readonly name = "flowr-analyzer-package-version-description-file-plugin";
|
|
11
|
+
readonly description = "This plugin determines loading order based on the Collate field in DESCRIPTION files.";
|
|
12
|
+
readonly version: SemVer;
|
|
13
|
+
process(ctx: FlowrAnalyzerContext): void;
|
|
14
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FlowrAnalyzerLoadingOrderDescriptionFilePlugin = void 0;
|
|
4
|
+
const flowr_analyzer_description_file_plugin_1 = require("../file-plugins/flowr-analyzer-description-file-plugin");
|
|
5
|
+
const semver_1 = require("semver");
|
|
6
|
+
const flowr_analyzer_loading_order_plugin_1 = require("./flowr-analyzer-loading-order-plugin");
|
|
7
|
+
const flowr_file_1 = require("../../context/flowr-file");
|
|
8
|
+
/**
|
|
9
|
+
* This plugin extracts loading order information from R `DESCRIPTION` files.
|
|
10
|
+
* It looks at the `Collate` field to determine the order in which files should be loaded.
|
|
11
|
+
* If no `Collate` field is present, it does nothing.
|
|
12
|
+
*/
|
|
13
|
+
class FlowrAnalyzerLoadingOrderDescriptionFilePlugin extends flowr_analyzer_loading_order_plugin_1.FlowrAnalyzerLoadingOrderPlugin {
|
|
14
|
+
name = 'flowr-analyzer-package-version-description-file-plugin';
|
|
15
|
+
description = 'This plugin determines loading order based on the Collate field in DESCRIPTION files.';
|
|
16
|
+
version = new semver_1.SemVer('0.1.0');
|
|
17
|
+
process(ctx) {
|
|
18
|
+
const descFiles = ctx.files.getFilesByRole(flowr_file_1.SpecialFileRole.Description);
|
|
19
|
+
if (descFiles.length !== 1) {
|
|
20
|
+
flowr_analyzer_description_file_plugin_1.descriptionFileLog.warn(`Supporting only exactly one DESCRIPTION file, found ${descFiles.length}`);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
/** this will do the caching etc. for me */
|
|
24
|
+
const deps = descFiles[0].content();
|
|
25
|
+
if (deps.has('Collate')) {
|
|
26
|
+
const collate = deps.get('Collate') ?? [];
|
|
27
|
+
/* we probably have to do some more guesswork here */
|
|
28
|
+
const unordered = ctx.files.loadingOrder.getUnorderedRequests();
|
|
29
|
+
// sort them by their path index in the Collate field
|
|
30
|
+
const sorted = unordered.slice().sort((a, b) => {
|
|
31
|
+
const aPath = a.request === 'file' ? a.content : undefined;
|
|
32
|
+
const bPath = b.request === 'file' ? b.content : undefined;
|
|
33
|
+
const aIndex = aPath ? collate.findIndex(c => aPath.endsWith(c.trim())) : -1;
|
|
34
|
+
const bIndex = bPath ? collate.findIndex(c => bPath.endsWith(c.trim())) : -1;
|
|
35
|
+
if (aIndex === -1 && bIndex === -1) {
|
|
36
|
+
return 0; // both not found, keep original order
|
|
37
|
+
}
|
|
38
|
+
else if (aIndex === -1) {
|
|
39
|
+
return 1; // a not found, b found -> a after b
|
|
40
|
+
}
|
|
41
|
+
else if (bIndex === -1) {
|
|
42
|
+
return -1; // b not found, a found -> a before b
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
return aIndex - bIndex; // both found, sort by index
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
ctx.files.loadingOrder.addGuess(sorted, true);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
flowr_analyzer_description_file_plugin_1.descriptionFileLog.info(`No Collate field in DESCRIPTION file ${descFiles[0].path().toString()}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.FlowrAnalyzerLoadingOrderDescriptionFilePlugin = FlowrAnalyzerLoadingOrderDescriptionFilePlugin;
|
|
56
|
+
//# sourceMappingURL=flowr-analyzer-loading-order-description-file-plugin.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FlowrAnalyzerPlugin, PluginType } from '../flowr-analyzer-plugin';
|
|
2
|
+
/**
|
|
3
|
+
* This is the base class for all plugins that determine the loading order of files in a project.
|
|
4
|
+
* These plugins interplay with the {@link FlowrAnalyzerFilesContext} to gather information about the files in the project and determine their loading order.
|
|
5
|
+
* See {@link DefaultFlowrAnalyzerLoadingOrderPlugin} for the dummy default implementation.
|
|
6
|
+
*
|
|
7
|
+
* In general, these plugins only trigger for a full project analysis after all files have been discovered and loaded.
|
|
8
|
+
* Otherwise, they may trigger multiple times (if for some reason, discovery reveals new files during the analysis).
|
|
9
|
+
*/
|
|
10
|
+
export declare abstract class FlowrAnalyzerLoadingOrderPlugin extends FlowrAnalyzerPlugin<undefined, void> {
|
|
11
|
+
readonly type = PluginType.LoadingOrder;
|
|
12
|
+
static defaultPlugin(): FlowrAnalyzerLoadingOrderPlugin;
|
|
13
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FlowrAnalyzerLoadingOrderPlugin = void 0;
|
|
4
|
+
const flowr_analyzer_plugin_1 = require("../flowr-analyzer-plugin");
|
|
5
|
+
const semver_1 = require("semver");
|
|
6
|
+
/**
|
|
7
|
+
* This is the base class for all plugins that determine the loading order of files in a project.
|
|
8
|
+
* These plugins interplay with the {@link FlowrAnalyzerFilesContext} to gather information about the files in the project and determine their loading order.
|
|
9
|
+
* See {@link DefaultFlowrAnalyzerLoadingOrderPlugin} for the dummy default implementation.
|
|
10
|
+
*
|
|
11
|
+
* In general, these plugins only trigger for a full project analysis after all files have been discovered and loaded.
|
|
12
|
+
* Otherwise, they may trigger multiple times (if for some reason, discovery reveals new files during the analysis).
|
|
13
|
+
*/
|
|
14
|
+
class FlowrAnalyzerLoadingOrderPlugin extends flowr_analyzer_plugin_1.FlowrAnalyzerPlugin {
|
|
15
|
+
type = flowr_analyzer_plugin_1.PluginType.LoadingOrder;
|
|
16
|
+
static defaultPlugin() {
|
|
17
|
+
return new DefaultFlowrAnalyzerLoadingOrderPlugin();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.FlowrAnalyzerLoadingOrderPlugin = FlowrAnalyzerLoadingOrderPlugin;
|
|
21
|
+
/**
|
|
22
|
+
* This is the default dummy implementation of the {@link FlowrAnalyzerLoadingOrderPlugin}.
|
|
23
|
+
* It does nothing and relies on the chronological order of file discovery.
|
|
24
|
+
*/
|
|
25
|
+
class DefaultFlowrAnalyzerLoadingOrderPlugin extends FlowrAnalyzerLoadingOrderPlugin {
|
|
26
|
+
name = 'default-loading-order-plugin';
|
|
27
|
+
description = 'This is the default loading order plugin that does nothing.';
|
|
28
|
+
version = new semver_1.SemVer('0.0.0');
|
|
29
|
+
process() {
|
|
30
|
+
/* we always *have* to have a loading order, this plugin does not have to guess to rely on chronological order */
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=flowr-analyzer-loading-order-plugin.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FlowrAnalyzerPackageVersionsPlugin } from './flowr-analyzer-package-versions-plugin';
|
|
2
|
+
import { SemVer } from 'semver';
|
|
3
|
+
import type { FlowrAnalyzerContext } from '../../context/flowr-analyzer-context';
|
|
4
|
+
/**
|
|
5
|
+
* This plugin extracts package versions from R `DESCRIPTION` files.
|
|
6
|
+
* It looks at the `Depends` and `Imports` fields to find package names and their version constraints.
|
|
7
|
+
*/
|
|
8
|
+
export declare class FlowrAnalyzerPackageVersionsDescriptionFilePlugin extends FlowrAnalyzerPackageVersionsPlugin {
|
|
9
|
+
readonly name = "flowr-analyzer-package-version-description-file-plugin";
|
|
10
|
+
readonly description = "This plugin does...";
|
|
11
|
+
readonly version: SemVer;
|
|
12
|
+
process(ctx: FlowrAnalyzerContext): void;
|
|
13
|
+
private retrieveVersionsFromField;
|
|
14
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FlowrAnalyzerPackageVersionsDescriptionFilePlugin = void 0;
|
|
4
|
+
const flowr_analyzer_package_versions_plugin_1 = require("./flowr-analyzer-package-versions-plugin");
|
|
5
|
+
const flowr_analyzer_description_file_plugin_1 = require("../file-plugins/flowr-analyzer-description-file-plugin");
|
|
6
|
+
const semver_1 = require("semver");
|
|
7
|
+
const package_1 = require("./package");
|
|
8
|
+
const flowr_file_1 = require("../../context/flowr-file");
|
|
9
|
+
const VersionRegex = /^([a-zA-Z0-9.]+)(?:\s*\(([><=~!]+)\s*([\d.]+)\))?$/;
|
|
10
|
+
/**
|
|
11
|
+
* This plugin extracts package versions from R `DESCRIPTION` files.
|
|
12
|
+
* It looks at the `Depends` and `Imports` fields to find package names and their version constraints.
|
|
13
|
+
*/
|
|
14
|
+
class FlowrAnalyzerPackageVersionsDescriptionFilePlugin extends flowr_analyzer_package_versions_plugin_1.FlowrAnalyzerPackageVersionsPlugin {
|
|
15
|
+
name = 'flowr-analyzer-package-version-description-file-plugin';
|
|
16
|
+
description = 'This plugin does...';
|
|
17
|
+
version = new semver_1.SemVer('0.1.0');
|
|
18
|
+
process(ctx) {
|
|
19
|
+
const descFiles = ctx.files.getFilesByRole(flowr_file_1.SpecialFileRole.Description);
|
|
20
|
+
if (descFiles.length !== 1) {
|
|
21
|
+
flowr_analyzer_description_file_plugin_1.descriptionFileLog.warn(`Supporting only exactly one DESCRIPTION file, found ${descFiles.length}`);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
/** this will do the caching etc. for me */
|
|
25
|
+
const deps = descFiles[0].content();
|
|
26
|
+
this.retrieveVersionsFromField(ctx, deps, 'Depends', 'r');
|
|
27
|
+
this.retrieveVersionsFromField(ctx, deps, 'Imports', 'package');
|
|
28
|
+
}
|
|
29
|
+
retrieveVersionsFromField(ctx, file, field, type) {
|
|
30
|
+
for (const entry of file.get(field) ?? []) {
|
|
31
|
+
const match = VersionRegex.exec(entry);
|
|
32
|
+
if (match) {
|
|
33
|
+
const [, name, operator, version] = match;
|
|
34
|
+
const range = package_1.Package.parsePackageVersionRange(operator, version);
|
|
35
|
+
ctx.deps.addDependency(new package_1.Package(name, type, undefined, range));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.FlowrAnalyzerPackageVersionsDescriptionFilePlugin = FlowrAnalyzerPackageVersionsDescriptionFilePlugin;
|
|
41
|
+
//# sourceMappingURL=flowr-analyzer-package-versions-description-file-plugin.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FlowrAnalyzerPlugin, PluginType } from '../flowr-analyzer-plugin';
|
|
2
|
+
/**
|
|
3
|
+
* This is the base class for all plugins that identify package and dependency versions used in the project.
|
|
4
|
+
* These plugins interplay with the {@link FlowrAnalyzerDependenciesContext} to gather information about the packages used in the project.
|
|
5
|
+
* See {@link DefaultFlowrAnalyzerPackageVersionsPlugin} for the no-op default implementation.
|
|
6
|
+
*/
|
|
7
|
+
export declare abstract class FlowrAnalyzerPackageVersionsPlugin extends FlowrAnalyzerPlugin<undefined, void> {
|
|
8
|
+
readonly type = PluginType.DependencyIdentification;
|
|
9
|
+
static defaultPlugin(): FlowrAnalyzerPackageVersionsPlugin;
|
|
10
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FlowrAnalyzerPackageVersionsPlugin = void 0;
|
|
4
|
+
const flowr_analyzer_plugin_1 = require("../flowr-analyzer-plugin");
|
|
5
|
+
const semver_1 = require("semver");
|
|
6
|
+
/**
|
|
7
|
+
* This is the base class for all plugins that identify package and dependency versions used in the project.
|
|
8
|
+
* These plugins interplay with the {@link FlowrAnalyzerDependenciesContext} to gather information about the packages used in the project.
|
|
9
|
+
* See {@link DefaultFlowrAnalyzerPackageVersionsPlugin} for the no-op default implementation.
|
|
10
|
+
*/
|
|
11
|
+
class FlowrAnalyzerPackageVersionsPlugin extends flowr_analyzer_plugin_1.FlowrAnalyzerPlugin {
|
|
12
|
+
type = flowr_analyzer_plugin_1.PluginType.DependencyIdentification;
|
|
13
|
+
static defaultPlugin() {
|
|
14
|
+
return new DefaultFlowrAnalyzerPackageVersionsPlugin();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.FlowrAnalyzerPackageVersionsPlugin = FlowrAnalyzerPackageVersionsPlugin;
|
|
18
|
+
/**
|
|
19
|
+
* This is the default no-op implementation of the {@link FlowrAnalyzerPackageVersionsPlugin}.
|
|
20
|
+
*/
|
|
21
|
+
class DefaultFlowrAnalyzerPackageVersionsPlugin extends FlowrAnalyzerPackageVersionsPlugin {
|
|
22
|
+
name = 'default-package-versions-plugin';
|
|
23
|
+
description = 'This is the default package versions plugin that does nothing.';
|
|
24
|
+
version = new semver_1.SemVer('0.0.0');
|
|
25
|
+
process() {
|
|
26
|
+
/* we do not need package versions for the analysis to do things! */
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=flowr-analyzer-package-versions-plugin.js.map
|