@eagleoutice/flowr 1.4.1 → 1.5.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 +3 -3
- package/abstract-interpretation/processor.js +9 -3
- package/config.d.ts +16 -0
- package/config.js +75 -0
- package/core/input.d.ts +1 -1
- package/core/output.d.ts +1 -2
- package/core/print/parse-printer.d.ts +1 -2
- package/core/print/parse-printer.js +6 -4
- package/core/print/slice-diff-ansi.js +7 -7
- package/core/slicer.js +4 -8
- package/core/steps.d.ts +355 -31
- package/core/steps.js +7 -14
- package/dataflow/environments/environment.js +8 -0
- package/dataflow/environments/register.js +1 -0
- package/dataflow/extractor.d.ts +2 -2
- package/dataflow/extractor.js +10 -2
- package/dataflow/internal/process/functions/function-call.js +7 -1
- package/dataflow/internal/process/functions/source.d.ts +8 -0
- package/dataflow/internal/process/functions/source.js +81 -0
- package/dataflow/processor.d.ts +10 -1
- package/index.d.ts +0 -2
- package/index.js +0 -2
- package/package.json +75 -202
- package/r-bridge/lang-4.x/ast/index.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/index.js +3 -0
- package/r-bridge/lang-4.x/ast/model/processing/decorate.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/processing/decorate.js +6 -1
- package/r-bridge/lang-4.x/ast/parser/json/format.d.ts +14 -0
- package/r-bridge/lang-4.x/ast/parser/json/format.js +26 -0
- package/r-bridge/lang-4.x/ast/parser/json/parser.d.ts +7 -0
- package/r-bridge/lang-4.x/ast/parser/json/parser.js +57 -0
- package/r-bridge/lang-4.x/ast/parser/xml/data.d.ts +0 -3
- package/r-bridge/lang-4.x/ast/parser/xml/index.d.ts +0 -2
- package/r-bridge/lang-4.x/ast/parser/xml/index.js +0 -2
- package/r-bridge/lang-4.x/ast/parser/xml/input-format.d.ts +5 -1
- package/r-bridge/lang-4.x/ast/parser/xml/input-format.js +7 -10
- package/r-bridge/lang-4.x/ast/parser/xml/internal/access.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/control/if-then-else.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/xml/internal/control/if-then.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/expression/expression.js +4 -4
- package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/argument.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/call.js +4 -4
- package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/definition.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/parameter.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/index.d.ts +0 -1
- package/r-bridge/lang-4.x/ast/parser/xml/internal/index.js +0 -1
- package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/break.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/for.js +3 -6
- package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/next.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/repeat.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/while.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/meta.d.ts +6 -11
- package/r-bridge/lang-4.x/ast/parser/xml/internal/meta.js +15 -23
- package/r-bridge/lang-4.x/ast/parser/xml/internal/operators/binary.js +6 -6
- package/r-bridge/lang-4.x/ast/parser/xml/internal/operators/unary.js +3 -3
- package/r-bridge/lang-4.x/ast/parser/xml/internal/other/comment.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/other/line-directive.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/elements.js +3 -3
- package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/root.js +3 -4
- package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/single-element.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/values/number.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/values/string.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/xml/internal/values/symbol.js +4 -4
- package/r-bridge/lang-4.x/values.d.ts +0 -1
- package/r-bridge/lang-4.x/values.js +14 -6
- package/r-bridge/retriever.d.ts +25 -21
- package/r-bridge/retriever.js +73 -23
- package/r-bridge/shell-executor.d.ts +3 -17
- package/r-bridge/shell-executor.js +9 -78
- package/r-bridge/shell.d.ts +5 -27
- package/r-bridge/shell.js +31 -92
- package/{statistics/output → util}/ansi.js +1 -1
- package/util/args.d.ts +8 -4
- package/util/args.js +11 -4
- package/util/cfg/visitor.js +1 -1
- package/util/files.d.ts +6 -0
- package/util/files.js +11 -1
- package/util/log.js +3 -0
- package/util/{summarizer/summarizer.d.ts → summarizer.d.ts} +15 -1
- package/util/summarizer.js +37 -0
- package/util/version.d.ts +2 -0
- package/util/version.js +10 -0
- package/benchmark/index.d.ts +0 -3
- package/benchmark/index.js +0 -20
- package/benchmark/slicer.d.ts +0 -101
- package/benchmark/slicer.js +0 -225
- package/benchmark/stats/index.d.ts +0 -10
- package/benchmark/stats/index.js +0 -27
- package/benchmark/stats/print.d.ts +0 -7
- package/benchmark/stats/print.js +0 -157
- package/benchmark/stats/stats.d.ts +0 -41
- package/benchmark/stats/stats.js +0 -6
- package/benchmark/stopwatch.d.ts +0 -35
- package/benchmark/stopwatch.js +0 -79
- package/cli/benchmark-app.d.ts +0 -9
- package/cli/benchmark-app.js +0 -52
- package/cli/benchmark-helper-app.d.ts +0 -7
- package/cli/benchmark-helper-app.js +0 -60
- package/cli/common/features.d.ts +0 -3
- package/cli/common/features.js +0 -30
- package/cli/common/index.d.ts +0 -2
- package/cli/common/index.js +0 -19
- package/cli/common/options.d.ts +0 -20
- package/cli/common/options.js +0 -82
- package/cli/common/script.d.ts +0 -21
- package/cli/common/script.js +0 -61
- package/cli/common/scripts-info.d.ts +0 -24
- package/cli/common/scripts-info.js +0 -69
- package/cli/export-quads-app.d.ts +0 -7
- package/cli/export-quads-app.js +0 -46
- package/cli/repl/commands/cfg.d.ts +0 -3
- package/cli/repl/commands/cfg.js +0 -37
- package/cli/repl/commands/commands.d.ts +0 -11
- package/cli/repl/commands/commands.js +0 -103
- package/cli/repl/commands/dataflow.d.ts +0 -3
- package/cli/repl/commands/dataflow.js +0 -34
- package/cli/repl/commands/execute.d.ts +0 -4
- package/cli/repl/commands/execute.js +0 -27
- package/cli/repl/commands/index.d.ts +0 -2
- package/cli/repl/commands/index.js +0 -19
- package/cli/repl/commands/main.d.ts +0 -39
- package/cli/repl/commands/main.js +0 -14
- package/cli/repl/commands/normalize.d.ts +0 -3
- package/cli/repl/commands/normalize.js +0 -34
- package/cli/repl/commands/parse.d.ts +0 -2
- package/cli/repl/commands/parse.js +0 -109
- package/cli/repl/commands/quit.d.ts +0 -2
- package/cli/repl/commands/quit.js +0 -12
- package/cli/repl/commands/version.d.ts +0 -16
- package/cli/repl/commands/version.js +0 -33
- package/cli/repl/core.d.ts +0 -39
- package/cli/repl/core.js +0 -116
- package/cli/repl/execute.d.ts +0 -28
- package/cli/repl/execute.js +0 -79
- package/cli/repl/index.d.ts +0 -5
- package/cli/repl/index.js +0 -22
- package/cli/repl/prompt.d.ts +0 -2
- package/cli/repl/prompt.js +0 -9
- package/cli/repl/server/connection.d.ts +0 -21
- package/cli/repl/server/connection.js +0 -218
- package/cli/repl/server/messages/analysis.d.ts +0 -71
- package/cli/repl/server/messages/analysis.js +0 -21
- package/cli/repl/server/messages/error.d.ts +0 -11
- package/cli/repl/server/messages/error.js +0 -3
- package/cli/repl/server/messages/hello.d.ts +0 -20
- package/cli/repl/server/messages/hello.js +0 -3
- package/cli/repl/server/messages/index.d.ts +0 -1
- package/cli/repl/server/messages/index.js +0 -3
- package/cli/repl/server/messages/messages.d.ts +0 -35
- package/cli/repl/server/messages/messages.js +0 -40
- package/cli/repl/server/messages/repl.d.ts +0 -33
- package/cli/repl/server/messages/repl.js +0 -37
- package/cli/repl/server/messages/slice.d.ts +0 -25
- package/cli/repl/server/messages/slice.js +0 -37
- package/cli/repl/server/net.d.ts +0 -49
- package/cli/repl/server/net.js +0 -63
- package/cli/repl/server/send.d.ts +0 -4
- package/cli/repl/server/send.js +0 -18
- package/cli/repl/server/server.d.ts +0 -20
- package/cli/repl/server/server.js +0 -66
- package/cli/repl/server/validate.d.ts +0 -15
- package/cli/repl/server/validate.js +0 -34
- package/cli/slicer-app.d.ts +0 -11
- package/cli/slicer-app.js +0 -81
- package/cli/statistics-app.d.ts +0 -11
- package/cli/statistics-app.js +0 -98
- package/cli/statistics-helper-app.d.ts +0 -11
- package/cli/statistics-helper-app.js +0 -83
- package/cli/summarizer-app.d.ts +0 -18
- package/cli/summarizer-app.js +0 -67
- package/flowr.d.ts +0 -27
- package/flowr.js +0 -137
- package/r-bridge/lang-4.x/ast/parser/xml/config.d.ts +0 -25
- package/r-bridge/lang-4.x/ast/parser/xml/config.js +0 -16
- package/r-bridge/lang-4.x/ast/parser/xml/internal/xml-to-json.d.ts +0 -9
- package/r-bridge/lang-4.x/ast/parser/xml/internal/xml-to-json.js +0 -51
- package/r-bridge/lang-4.x/ast/parser/xml/parser.d.ts +0 -17
- package/r-bridge/lang-4.x/ast/parser/xml/parser.js +0 -30
- package/statistics/features/common-syntax-probability.d.ts +0 -31
- package/statistics/features/common-syntax-probability.js +0 -156
- package/statistics/features/feature.d.ts +0 -175
- package/statistics/features/feature.js +0 -30
- package/statistics/features/index.d.ts +0 -1
- package/statistics/features/index.js +0 -18
- package/statistics/features/post-processing.d.ts +0 -12
- package/statistics/features/post-processing.js +0 -21
- package/statistics/features/supported/assignments/assignments.d.ts +0 -11
- package/statistics/features/supported/assignments/assignments.js +0 -53
- package/statistics/features/supported/assignments/index.d.ts +0 -1
- package/statistics/features/supported/assignments/index.js +0 -6
- package/statistics/features/supported/assignments/post-process.d.ts +0 -3
- package/statistics/features/supported/assignments/post-process.js +0 -125
- package/statistics/features/supported/comments/comments.d.ts +0 -18
- package/statistics/features/supported/comments/comments.js +0 -133
- package/statistics/features/supported/comments/index.d.ts +0 -1
- package/statistics/features/supported/comments/index.js +0 -6
- package/statistics/features/supported/comments/post-process.d.ts +0 -3
- package/statistics/features/supported/comments/post-process.js +0 -50
- package/statistics/features/supported/control-flow/control-flow.d.ts +0 -17
- package/statistics/features/supported/control-flow/control-flow.js +0 -67
- package/statistics/features/supported/control-flow/index.d.ts +0 -1
- package/statistics/features/supported/control-flow/index.js +0 -6
- package/statistics/features/supported/control-flow/post-process.d.ts +0 -3
- package/statistics/features/supported/control-flow/post-process.js +0 -65
- package/statistics/features/supported/data-access/data-access.d.ts +0 -15
- package/statistics/features/supported/data-access/data-access.js +0 -118
- package/statistics/features/supported/data-access/index.d.ts +0 -1
- package/statistics/features/supported/data-access/index.js +0 -6
- package/statistics/features/supported/data-access/post-process.d.ts +0 -3
- package/statistics/features/supported/data-access/post-process.js +0 -107
- package/statistics/features/supported/defined-functions/defined-functions.d.ts +0 -35
- package/statistics/features/supported/defined-functions/defined-functions.js +0 -139
- package/statistics/features/supported/defined-functions/index.d.ts +0 -1
- package/statistics/features/supported/defined-functions/index.js +0 -6
- package/statistics/features/supported/defined-functions/post-process.d.ts +0 -6
- package/statistics/features/supported/defined-functions/post-process.js +0 -177
- package/statistics/features/supported/expression-list/expression-list.d.ts +0 -9
- package/statistics/features/supported/expression-list/expression-list.js +0 -36
- package/statistics/features/supported/expression-list/index.d.ts +0 -1
- package/statistics/features/supported/expression-list/index.js +0 -6
- package/statistics/features/supported/expression-list/post-process.d.ts +0 -3
- package/statistics/features/supported/expression-list/post-process.js +0 -44
- package/statistics/features/supported/index.d.ts +0 -10
- package/statistics/features/supported/index.js +0 -27
- package/statistics/features/supported/loops/index.d.ts +0 -1
- package/statistics/features/supported/loops/index.js +0 -6
- package/statistics/features/supported/loops/loops.d.ts +0 -20
- package/statistics/features/supported/loops/loops.js +0 -79
- package/statistics/features/supported/loops/post-process.d.ts +0 -3
- package/statistics/features/supported/loops/post-process.js +0 -72
- package/statistics/features/supported/used-functions/index.d.ts +0 -1
- package/statistics/features/supported/used-functions/index.js +0 -6
- package/statistics/features/supported/used-functions/post-process.d.ts +0 -6
- package/statistics/features/supported/used-functions/post-process.js +0 -179
- package/statistics/features/supported/used-functions/used-functions.d.ts +0 -24
- package/statistics/features/supported/used-functions/used-functions.js +0 -95
- package/statistics/features/supported/used-packages/index.d.ts +0 -1
- package/statistics/features/supported/used-packages/index.js +0 -6
- package/statistics/features/supported/used-packages/post-process.d.ts +0 -3
- package/statistics/features/supported/used-packages/post-process.js +0 -121
- package/statistics/features/supported/used-packages/used-packages.d.ts +0 -16
- package/statistics/features/supported/used-packages/used-packages.js +0 -130
- package/statistics/features/supported/values/index.d.ts +0 -1
- package/statistics/features/supported/values/index.js +0 -6
- package/statistics/features/supported/values/post-process.d.ts +0 -3
- package/statistics/features/supported/values/post-process.js +0 -72
- package/statistics/features/supported/values/values.d.ts +0 -14
- package/statistics/features/supported/values/values.js +0 -101
- package/statistics/features/supported/variables/index.d.ts +0 -1
- package/statistics/features/supported/variables/index.js +0 -6
- package/statistics/features/supported/variables/post-process.d.ts +0 -9
- package/statistics/features/supported/variables/post-process.js +0 -122
- package/statistics/features/supported/variables/variables.d.ts +0 -15
- package/statistics/features/supported/variables/variables.js +0 -70
- package/statistics/index.d.ts +0 -6
- package/statistics/index.js +0 -24
- package/statistics/meta-statistics.d.ts +0 -33
- package/statistics/meta-statistics.js +0 -17
- package/statistics/output/file-provider.d.ts +0 -37
- package/statistics/output/file-provider.js +0 -97
- package/statistics/output/index.d.ts +0 -4
- package/statistics/output/index.js +0 -21
- package/statistics/output/print-stats.d.ts +0 -17
- package/statistics/output/print-stats.js +0 -69
- package/statistics/output/statistics-file.d.ts +0 -37
- package/statistics/output/statistics-file.js +0 -69
- package/statistics/statistics.d.ts +0 -24
- package/statistics/statistics.js +0 -109
- package/util/summarizer/auto-detect.d.ts +0 -2
- package/util/summarizer/auto-detect.js +0 -32
- package/util/summarizer/benchmark/data.d.ts +0 -66
- package/util/summarizer/benchmark/data.js +0 -13
- package/util/summarizer/benchmark/first-phase/input.d.ts +0 -2
- package/util/summarizer/benchmark/first-phase/input.js +0 -59
- package/util/summarizer/benchmark/first-phase/process.d.ts +0 -10
- package/util/summarizer/benchmark/first-phase/process.js +0 -208
- package/util/summarizer/benchmark/second-phase/graph.d.ts +0 -2
- package/util/summarizer/benchmark/second-phase/graph.js +0 -54
- package/util/summarizer/benchmark/second-phase/process.d.ts +0 -4
- package/util/summarizer/benchmark/second-phase/process.js +0 -89
- package/util/summarizer/benchmark/summarizer.d.ts +0 -35
- package/util/summarizer/benchmark/summarizer.js +0 -49
- package/util/summarizer/statistics/first-phase/process.d.ts +0 -6
- package/util/summarizer/statistics/first-phase/process.js +0 -81
- package/util/summarizer/statistics/post-process/clusterer.d.ts +0 -26
- package/util/summarizer/statistics/post-process/clusterer.js +0 -43
- package/util/summarizer/statistics/post-process/file-based-count.d.ts +0 -17
- package/util/summarizer/statistics/post-process/file-based-count.js +0 -49
- package/util/summarizer/statistics/post-process/histogram.d.ts +0 -59
- package/util/summarizer/statistics/post-process/histogram.js +0 -128
- package/util/summarizer/statistics/post-process/index.d.ts +0 -4
- package/util/summarizer/statistics/post-process/index.js +0 -21
- package/util/summarizer/statistics/post-process/post-process-output.d.ts +0 -16
- package/util/summarizer/statistics/post-process/post-process-output.js +0 -104
- package/util/summarizer/statistics/second-phase/process.d.ts +0 -11
- package/util/summarizer/statistics/second-phase/process.js +0 -117
- package/util/summarizer/statistics/summarizer.d.ts +0 -35
- package/util/summarizer/statistics/summarizer.js +0 -135
- package/util/summarizer/summarizer.js +0 -13
- /package/{statistics/output → util}/ansi.d.ts +0 -0
package/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
[](https://github.com/Code-Inspect/flowr/wiki)\
|
|
2
|
-
[](https://github.com/Code-Inspect/flowr/actions/workflows/qa.yaml) [](https://codecov.io/gh/Code-Inspect/flowr) [](https://hub.docker.com/r/eagleoutice/flowr) [](https://github.com/Code-Inspect/flowr/releases/latest)
|
|
2
|
+
[](https://github.com/Code-Inspect/flowr/actions/workflows/qa.yaml) [](https://codecov.io/gh/Code-Inspect/flowr) [](https://hub.docker.com/r/eagleoutice/flowr) [](https://github.com/Code-Inspect/flowr/releases/latest) [](https://marketplace.visualstudio.com/items?itemName=code-inspect.vscode-flowr)
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
*flowR* is a static [dataflow analyzer](https://en.wikipedia.org/wiki/Data-flow_analysis) and [program slicer](https://github.com/Code-Inspect/flowr/wiki/Terminology#program-slice) for the [*R*](https://www.r-project.org/) programming language (currently tested for versions `4.x`).
|
|
5
|
+
*flowR* is a static [dataflow analyzer](https://en.wikipedia.org/wiki/Data-flow_analysis) and [program slicer](https://github.com/Code-Inspect/flowr/wiki/Terminology#program-slice) for the [*R*](https://www.r-project.org/) programming language (currently tested for versions `4.x`). It is available as a [Visual Studio Code extension](https://marketplace.visualstudio.com/items?itemName=code-inspect.vscode-flowr) and as a [docker image](https://hub.docker.com/r/eagleoutice/flowr).
|
|
6
6
|
|
|
7
7
|
## ⭐ Getting Started
|
|
8
8
|
|
|
9
|
-
To get started with _flowR_, please check out the [Overview](https://github.com/Code-Inspect/flowr/wiki/Overview). The [Setup](https://github.com/Code-Inspect/flowr/wiki/Setup) wiki page explains how you can download and setup _flowR_ on your system. With docker 🐳️, the following line should be enough (and drop you directly into the REPL):
|
|
9
|
+
To get started with _flowR_, please check out the [Overview](https://github.com/Code-Inspect/flowr/wiki/Overview). The [Setup](https://github.com/Code-Inspect/flowr/wiki/Setup) wiki page explains how you can download and setup _flowR_ on your system. For Visual Studio Code, please see the [marketplace entry](https://marketplace.visualstudio.com/items?itemName=code-inspect.vscode-flowr). With docker 🐳️, the following line should be enough (and drop you directly into the REPL):
|
|
10
10
|
|
|
11
11
|
```shell
|
|
12
12
|
docker run -it --rm eagleoutice/flowr
|
|
@@ -11,9 +11,15 @@ const log_1 = require("../util/log");
|
|
|
11
11
|
exports.aiLogger = log_1.log.getSubLogger({ name: 'abstract-interpretation' });
|
|
12
12
|
class Stack {
|
|
13
13
|
backingStore = [];
|
|
14
|
-
size() {
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
size() {
|
|
15
|
+
return this.backingStore.length;
|
|
16
|
+
}
|
|
17
|
+
peek() {
|
|
18
|
+
return this.backingStore[this.size() - 1];
|
|
19
|
+
}
|
|
20
|
+
pop() {
|
|
21
|
+
return this.backingStore.pop();
|
|
22
|
+
}
|
|
17
23
|
push(item) {
|
|
18
24
|
this.backingStore.push(item);
|
|
19
25
|
return item;
|
package/config.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { MergeableRecord } from './util/objects';
|
|
2
|
+
export interface FlowrConfigOptions extends MergeableRecord {
|
|
3
|
+
/**
|
|
4
|
+
* Whether source calls should be ignored, causing {@link processSourceCall}'s behavior to be skipped
|
|
5
|
+
*/
|
|
6
|
+
ignoreSourceCalls: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* The path to the R executable to use. If this is undefined, {@link DEFAULT_R_PATH} will be used.
|
|
9
|
+
*/
|
|
10
|
+
rPath: string | undefined;
|
|
11
|
+
}
|
|
12
|
+
export declare const defaultConfigOptions: FlowrConfigOptions;
|
|
13
|
+
export declare const defaultConfigFile = "flowr.json";
|
|
14
|
+
export declare function setConfigFile(workingDirectory?: string, file?: string, forceLoad?: boolean): void;
|
|
15
|
+
export declare function setConfig(config: FlowrConfigOptions): void;
|
|
16
|
+
export declare function getConfig(): FlowrConfigOptions;
|
package/config.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
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.getConfig = exports.setConfig = exports.setConfigFile = exports.defaultConfigFile = exports.defaultConfigOptions = void 0;
|
|
7
|
+
const objects_1 = require("./util/objects");
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const fs_1 = __importDefault(require("fs"));
|
|
10
|
+
const log_1 = require("./util/log");
|
|
11
|
+
const files_1 = require("./util/files");
|
|
12
|
+
const joi_1 = __importDefault(require("joi"));
|
|
13
|
+
exports.defaultConfigOptions = {
|
|
14
|
+
ignoreSourceCalls: false,
|
|
15
|
+
rPath: undefined
|
|
16
|
+
};
|
|
17
|
+
exports.defaultConfigFile = 'flowr.json';
|
|
18
|
+
const schema = joi_1.default.object({
|
|
19
|
+
ignoreSourceCalls: joi_1.default.boolean().optional()
|
|
20
|
+
});
|
|
21
|
+
let configWorkingDirectory = process.cwd();
|
|
22
|
+
let configFile = exports.defaultConfigFile;
|
|
23
|
+
let currentConfig;
|
|
24
|
+
function setConfigFile(workingDirectory = process.cwd(), file = exports.defaultConfigFile, forceLoad = false) {
|
|
25
|
+
configWorkingDirectory = workingDirectory;
|
|
26
|
+
configFile = file;
|
|
27
|
+
// reset the config so it gets reloaded
|
|
28
|
+
currentConfig = undefined;
|
|
29
|
+
if (forceLoad) {
|
|
30
|
+
getConfig();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.setConfigFile = setConfigFile;
|
|
34
|
+
function setConfig(config) {
|
|
35
|
+
currentConfig = config;
|
|
36
|
+
}
|
|
37
|
+
exports.setConfig = setConfig;
|
|
38
|
+
function getConfig() {
|
|
39
|
+
// lazy-load the config based on the current settings
|
|
40
|
+
if (currentConfig === undefined) {
|
|
41
|
+
setConfig(parseConfigOptions(configWorkingDirectory, configFile));
|
|
42
|
+
}
|
|
43
|
+
return currentConfig;
|
|
44
|
+
}
|
|
45
|
+
exports.getConfig = getConfig;
|
|
46
|
+
function parseConfigOptions(workingDirectory, configFile) {
|
|
47
|
+
let searchPath = path_1.default.resolve(workingDirectory);
|
|
48
|
+
do {
|
|
49
|
+
const configPath = path_1.default.join(searchPath, configFile);
|
|
50
|
+
if (fs_1.default.existsSync(configPath)) {
|
|
51
|
+
try {
|
|
52
|
+
const text = fs_1.default.readFileSync(configPath, { encoding: 'utf-8' });
|
|
53
|
+
const parsed = JSON.parse(text);
|
|
54
|
+
const validate = schema.validate(parsed);
|
|
55
|
+
if (!validate.error) {
|
|
56
|
+
// assign default values to all config options except for the specified ones
|
|
57
|
+
const ret = (0, objects_1.deepMergeObject)(exports.defaultConfigOptions, parsed);
|
|
58
|
+
log_1.log.info(`Using config ${JSON.stringify(ret)} from ${configPath}`);
|
|
59
|
+
return ret;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
log_1.log.error(`Failed to validate config file at ${configPath}: ${validate.error.message}`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
catch (e) {
|
|
66
|
+
log_1.log.error(`Failed to parse config file at ${configPath}: ${e.message}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// move up to parent directory
|
|
70
|
+
searchPath = (0, files_1.getParentDirectory)(searchPath);
|
|
71
|
+
} while (fs_1.default.existsSync(searchPath));
|
|
72
|
+
log_1.log.info(`Using default config ${JSON.stringify(exports.defaultConfigOptions)}`);
|
|
73
|
+
return exports.defaultConfigOptions;
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=config.js.map
|
package/core/input.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ interface BaseSteppingSlicerInput<InterestedIn extends StepName | undefined> ext
|
|
|
27
27
|
/** If you want to auto-select something in the reconstruction add it here, otherwise, it will use the default defined alongside {@link reconstructToCode}*/
|
|
28
28
|
autoSelectIf?: AutoSelectPredicate;
|
|
29
29
|
}
|
|
30
|
-
interface NormalizeSteppingSlicerInput<InterestedIn extends '
|
|
30
|
+
interface NormalizeSteppingSlicerInput<InterestedIn extends 'dataflow' | 'normalize'> extends BaseSteppingSlicerInput<InterestedIn> {
|
|
31
31
|
stepOfInterest: InterestedIn;
|
|
32
32
|
}
|
|
33
33
|
interface SliceSteppingSlicerInput<InterestedIn extends 'reconstruct' | 'slice' | undefined> extends BaseSteppingSlicerInput<InterestedIn> {
|
package/core/output.d.ts
CHANGED
|
@@ -9,8 +9,7 @@ type StepResultsHelper<InterestedIn extends StepName> = {
|
|
|
9
9
|
'parse': Out<'parse'>;
|
|
10
10
|
'normalize': StepResultsHelper<'parse'> & Out<'normalize'>;
|
|
11
11
|
'dataflow': StepResultsHelper<'normalize'> & Out<'dataflow'>;
|
|
12
|
-
'
|
|
13
|
-
'slice': StepResultsHelper<'ai'> & Out<'slice'>;
|
|
12
|
+
'slice': StepResultsHelper<'dataflow'> & Out<'slice'>;
|
|
14
13
|
'reconstruct': StepResultsHelper<'slice'> & Out<'reconstruct'>;
|
|
15
14
|
}[InterestedIn];
|
|
16
15
|
export {};
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
import type { QuadSerializationConfiguration } from '../../util/quads';
|
|
2
|
-
|
|
3
|
-
export declare function parseToQuads(code: string, config: QuadSerializationConfiguration, parseConfig: XmlParserConfig): Promise<string>;
|
|
2
|
+
export declare function parseToQuads(code: string, config: QuadSerializationConfiguration): string;
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseToQuads = void 0;
|
|
4
4
|
const quads_1 = require("../../util/quads");
|
|
5
|
-
const
|
|
5
|
+
const r_bridge_1 = require("../../r-bridge");
|
|
6
|
+
const format_1 = require("../../r-bridge/lang-4.x/ast/parser/json/format");
|
|
7
|
+
const parser_1 = require("../../r-bridge/lang-4.x/ast/parser/json/parser");
|
|
6
8
|
function filterObject(obj, keys) {
|
|
7
9
|
if (typeof obj !== 'object') {
|
|
8
10
|
return obj;
|
|
@@ -20,10 +22,10 @@ function filterObject(obj, keys) {
|
|
|
20
22
|
.map(([k, v]) => [k, filterObject(v, keys)]));
|
|
21
23
|
}
|
|
22
24
|
}
|
|
23
|
-
|
|
24
|
-
const obj =
|
|
25
|
+
function parseToQuads(code, config) {
|
|
26
|
+
const obj = (0, parser_1.convertPreparedParsedData)((0, format_1.prepareParsedData)(code));
|
|
25
27
|
// recursively filter so that if the object contains one of the keys 'a', 'b' or 'c', all other keys are ignored
|
|
26
|
-
return (0, quads_1.serialize2quads)(filterObject(obj, new Set([
|
|
28
|
+
return (0, quads_1.serialize2quads)(filterObject(obj, new Set([r_bridge_1.attributesKey, r_bridge_1.childrenKey, r_bridge_1.contentKey])), config);
|
|
27
29
|
}
|
|
28
30
|
exports.parseToQuads = parseToQuads;
|
|
29
31
|
//# sourceMappingURL=parse-printer.js.map
|
|
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.sliceDiffAnsi = void 0;
|
|
4
4
|
const range_1 = require("../../util/range");
|
|
5
5
|
const assert_1 = require("../../util/assert");
|
|
6
|
-
const
|
|
6
|
+
const ansi_1 = require("../../../src/util/ansi");
|
|
7
7
|
function grayOut() {
|
|
8
|
-
return
|
|
8
|
+
return ansi_1.ansiFormatter.getFormatString({ color: 7 /* Colors.White */, effect: ansi_1.ColorEffect.Foreground, style: 2 /* FontStyles.Faint */ });
|
|
9
9
|
}
|
|
10
10
|
function mergeJointRangesInSorted(loc) {
|
|
11
11
|
return loc.reduce((acc, curr) => {
|
|
@@ -23,15 +23,15 @@ function mergeJointRangesInSorted(loc) {
|
|
|
23
23
|
}, [loc[0]]);
|
|
24
24
|
}
|
|
25
25
|
function highlight(s, selected) {
|
|
26
|
-
const primary =
|
|
27
|
-
return selected ?
|
|
26
|
+
const primary = ansi_1.ansiFormatter.format(s, { color: 3 /* Colors.Yellow */, effect: ansi_1.ColorEffect.Foreground, style: 1 /* FontStyles.Bold */ });
|
|
27
|
+
return selected ? ansi_1.ansiFormatter.format(primary, { style: 4 /* FontStyles.Underline */ }) : primary;
|
|
28
28
|
}
|
|
29
29
|
function sliceDiffAnsi(slice, normalized, criteriaIds, originalCode) {
|
|
30
30
|
let importantLocations = Array.from(normalized.idMap.entries())
|
|
31
31
|
.filter(([id, { location }]) => slice.has(id) && (0, assert_1.isNotUndefined)(location))
|
|
32
32
|
.map(([id, { location }]) => ({ selected: criteriaIds.has(id), location: location }));
|
|
33
33
|
if (importantLocations.length === 0) {
|
|
34
|
-
return `${grayOut()}${originalCode}${
|
|
34
|
+
return `${grayOut()}${originalCode}${ansi_1.ansiFormatter.reset()}`;
|
|
35
35
|
}
|
|
36
36
|
// we sort all locations from back to front so that replacements do not screw up the indices
|
|
37
37
|
importantLocations.sort((a, b) => -(0, range_1.rangeCompare)(a.location, b.location));
|
|
@@ -41,9 +41,9 @@ function sliceDiffAnsi(slice, normalized, criteriaIds, originalCode) {
|
|
|
41
41
|
for (const { selected, location } of importantLocations) {
|
|
42
42
|
const { start, end } = location;
|
|
43
43
|
const line = lines[start.line - 1];
|
|
44
|
-
lines[start.line - 1] = `${line.substring(0, start.column - 1)}${
|
|
44
|
+
lines[start.line - 1] = `${line.substring(0, start.column - 1)}${ansi_1.ansiFormatter.reset()}${highlight(line.substring(start.column - 1, end.column), selected)}${grayOut()}${line.substring(end.column)}`;
|
|
45
45
|
}
|
|
46
|
-
return `${grayOut()}${lines.join('\n')}${
|
|
46
|
+
return `${grayOut()}${lines.join('\n')}${ansi_1.ansiFormatter.reset()}`;
|
|
47
47
|
}
|
|
48
48
|
exports.sliceDiffAnsi = sliceDiffAnsi;
|
|
49
49
|
//# sourceMappingURL=slice-diff-ansi.js.map
|
package/core/slicer.js
CHANGED
|
@@ -162,22 +162,18 @@ class SteppingSlicer {
|
|
|
162
162
|
break;
|
|
163
163
|
case 1:
|
|
164
164
|
step = guardStep('normalize');
|
|
165
|
-
result =
|
|
165
|
+
result = (0, steps_1.executeSingleSubStep)(step, this.results.parse, this.hooks, this.getId);
|
|
166
166
|
break;
|
|
167
167
|
case 2:
|
|
168
168
|
step = guardStep('dataflow');
|
|
169
|
-
result = (0, steps_1.executeSingleSubStep)(step, this.results.normalize);
|
|
169
|
+
result = (0, steps_1.executeSingleSubStep)(step, this.request, this.results.normalize);
|
|
170
170
|
break;
|
|
171
171
|
case 3:
|
|
172
|
-
step = guardStep('ai');
|
|
173
|
-
result = (0, steps_1.executeSingleSubStep)(step, this.results.normalize, this.results.dataflow);
|
|
174
|
-
break;
|
|
175
|
-
case 4:
|
|
176
172
|
(0, assert_1.guard)(this.criterion !== undefined, 'Cannot decode criteria without a criterion');
|
|
177
173
|
step = guardStep('slice');
|
|
178
|
-
result = (0, steps_1.executeSingleSubStep)(step, this.results.
|
|
174
|
+
result = (0, steps_1.executeSingleSubStep)(step, this.results.dataflow.graph, this.results.normalize, this.criterion);
|
|
179
175
|
break;
|
|
180
|
-
case
|
|
176
|
+
case 4:
|
|
181
177
|
step = guardStep('reconstruct');
|
|
182
178
|
result = (0, steps_1.executeSingleSubStep)(step, this.results.normalize, this.results.slice.result);
|
|
183
179
|
break;
|