@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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { OutputFormatter } from '../../../util/text/ansi';
|
|
2
2
|
import type { KnownParser } from '../../../r-bridge/parser';
|
|
3
3
|
import type { FlowrConfigOptions } from '../../../config';
|
|
4
|
+
import type { FlowrAnalysisProvider } from '../../../project/flowr-analyzer';
|
|
4
5
|
/**
|
|
5
6
|
* Defines the main interface for output of the repl.
|
|
6
7
|
* This allows us to redirect it (e.g., in the case of a server connection or tests).
|
|
@@ -20,20 +21,29 @@ export interface ReplOutput {
|
|
|
20
21
|
*/
|
|
21
22
|
export declare const standardReplOutput: ReplOutput;
|
|
22
23
|
/**
|
|
23
|
-
* Information passed to each
|
|
24
|
+
* Information passed to each {@link ReplCommand#fn}.
|
|
24
25
|
*/
|
|
25
26
|
export interface ReplCommandInformation {
|
|
26
27
|
output: ReplOutput;
|
|
28
|
+
allowRSessionAccess: boolean;
|
|
27
29
|
parser: KnownParser;
|
|
28
30
|
remainingLine: string;
|
|
29
|
-
allowRSessionAccess: boolean;
|
|
30
31
|
config: FlowrConfigOptions;
|
|
31
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Information passed to each {@link ReplCodeCommand#fn}.
|
|
35
|
+
* The {@link analyzer} has the {@link RParseRequest}.
|
|
36
|
+
*/
|
|
37
|
+
export interface ReplCodeCommandInformation {
|
|
38
|
+
output: ReplOutput;
|
|
39
|
+
analyzer: FlowrAnalysisProvider;
|
|
40
|
+
remainingArgs: string[];
|
|
41
|
+
}
|
|
32
42
|
/**
|
|
33
43
|
* Content of a single command in the repl.
|
|
34
44
|
* The command may execute an external script or simply call *flowR* functions.
|
|
35
45
|
*/
|
|
36
|
-
export interface
|
|
46
|
+
export interface ReplBaseCommand {
|
|
37
47
|
/** Aliases of the command (without the leading colon), every alias must be unique (this is checked at runtime) */
|
|
38
48
|
aliases: string[];
|
|
39
49
|
/** A human-readable description of what the command does */
|
|
@@ -42,9 +52,30 @@ export interface ReplCommand {
|
|
|
42
52
|
script: boolean;
|
|
43
53
|
/** Example of how to use the command, for example `:slicer --help` */
|
|
44
54
|
usageExample: string;
|
|
55
|
+
}
|
|
56
|
+
export interface ReplCommand extends ReplBaseCommand {
|
|
57
|
+
usesAnalyzer: false;
|
|
45
58
|
/**
|
|
46
59
|
* Function to execute when the command is invoked, it must not write to the command line but instead use the output handler.
|
|
47
60
|
* Furthermore, it has to obey the formatter defined in the {@link ReplOutput}.
|
|
48
61
|
*/
|
|
49
62
|
fn: (info: ReplCommandInformation) => Promise<void> | void;
|
|
50
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Repl command that uses the {@link FlowrAnalyzer}
|
|
66
|
+
*/
|
|
67
|
+
export interface ReplCodeCommand extends ReplBaseCommand {
|
|
68
|
+
usesAnalyzer: true;
|
|
69
|
+
/**
|
|
70
|
+
* Function to execute when the command is invoked, it must not write to the command line but instead use the output handler.
|
|
71
|
+
* Furthermore, it has to obey the formatter defined in the {@link ReplOutput}.
|
|
72
|
+
*/
|
|
73
|
+
fn: (info: ReplCodeCommandInformation) => Promise<void> | void;
|
|
74
|
+
/**
|
|
75
|
+
* Argument parser function which handles the input given after the repl command
|
|
76
|
+
*/
|
|
77
|
+
argsParser: (remainingLine: string) => {
|
|
78
|
+
input: string;
|
|
79
|
+
remaining: string[];
|
|
80
|
+
};
|
|
81
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const normalizeCommand:
|
|
3
|
-
export declare const normalizeStarCommand:
|
|
1
|
+
import type { ReplCodeCommand } from './repl-main';
|
|
2
|
+
export declare const normalizeCommand: ReplCodeCommand;
|
|
3
|
+
export declare const normalizeStarCommand: ReplCodeCommand;
|
|
@@ -34,51 +34,47 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.normalizeStarCommand = exports.normalizeCommand = void 0;
|
|
37
|
-
const default_pipelines_1 = require("../../../core/steps/pipeline/default-pipelines");
|
|
38
37
|
const retriever_1 = require("../../../r-bridge/retriever");
|
|
39
38
|
const ast_1 = require("../../../util/mermaid/ast");
|
|
40
39
|
const ansi_1 = require("../../../util/text/ansi");
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}, config).allRemainingSteps();
|
|
45
|
-
}
|
|
46
|
-
function handleString(code) {
|
|
47
|
-
return code.startsWith('"') ? JSON.parse(code) : code;
|
|
48
|
-
}
|
|
49
|
-
function formatInfo(out, type, timing) {
|
|
50
|
-
return out.formatter.format(`Copied ${type} to clipboard (normalize: ${timing}ms).`, { color: 7 /* Colors.White */, effect: ansi_1.ColorEffect.Foreground, style: 3 /* FontStyles.Italic */ });
|
|
40
|
+
const core_1 = require("../core");
|
|
41
|
+
function formatInfo(out, type, meta) {
|
|
42
|
+
return out.formatter.format(`Copied ${type} to clipboard (normalize: ${meta['.meta'].timing + 'ms'}).`, { color: 7 /* Colors.White */, effect: ansi_1.ColorEffect.Foreground, style: 3 /* FontStyles.Italic */ });
|
|
51
43
|
}
|
|
52
44
|
exports.normalizeCommand = {
|
|
53
45
|
description: `Get mermaid code for the normalized AST of R code, start with '${retriever_1.fileProtocol}' to indicate a file`,
|
|
46
|
+
usesAnalyzer: true,
|
|
54
47
|
usageExample: ':normalize',
|
|
55
48
|
aliases: ['n'],
|
|
56
49
|
script: false,
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const
|
|
50
|
+
argsParser: (args) => (0, core_1.handleString)(args),
|
|
51
|
+
fn: async ({ output, analyzer }) => {
|
|
52
|
+
const result = await analyzer.normalize();
|
|
53
|
+
const mermaid = (0, ast_1.normalizedAstToMermaid)(result.ast);
|
|
60
54
|
output.stdout(mermaid);
|
|
61
55
|
try {
|
|
62
56
|
const clipboard = await Promise.resolve().then(() => __importStar(require('clipboardy')));
|
|
63
57
|
clipboard.default.writeSync(mermaid);
|
|
64
|
-
output.stdout(formatInfo(output, 'mermaid url', result
|
|
58
|
+
output.stdout(formatInfo(output, 'mermaid url', result));
|
|
65
59
|
}
|
|
66
60
|
catch { /* do nothing this is a service thing */ }
|
|
67
61
|
}
|
|
68
62
|
};
|
|
69
63
|
exports.normalizeStarCommand = {
|
|
70
64
|
description: 'Returns the URL to mermaid.live',
|
|
65
|
+
usesAnalyzer: true,
|
|
71
66
|
usageExample: ':normalize*',
|
|
72
67
|
aliases: ['n*'],
|
|
73
68
|
script: false,
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const
|
|
69
|
+
argsParser: (args) => (0, core_1.handleString)(args),
|
|
70
|
+
fn: async ({ output, analyzer }) => {
|
|
71
|
+
const result = await analyzer.normalize();
|
|
72
|
+
const mermaid = (0, ast_1.normalizedAstToMermaidUrl)(result.ast);
|
|
77
73
|
output.stdout(mermaid);
|
|
78
74
|
try {
|
|
79
75
|
const clipboard = await Promise.resolve().then(() => __importStar(require('clipboardy')));
|
|
80
76
|
clipboard.default.writeSync(mermaid);
|
|
81
|
-
output.stdout(formatInfo(output, 'mermaid url', result
|
|
77
|
+
output.stdout(formatInfo(output, 'mermaid url', result));
|
|
82
78
|
}
|
|
83
79
|
catch { /* do nothing this is a service thing */ }
|
|
84
80
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const parseCommand:
|
|
1
|
+
import type { ReplCodeCommand } from './repl-main';
|
|
2
|
+
export declare const parseCommand: ReplCodeCommand;
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.parseCommand = void 0;
|
|
4
4
|
const format_1 = require("../../../r-bridge/lang-4.x/ast/parser/json/format");
|
|
5
5
|
const normalize_meta_1 = require("../../../r-bridge/lang-4.x/ast/parser/main/normalize-meta");
|
|
6
|
-
const default_pipelines_1 = require("../../../core/steps/pipeline/default-pipelines");
|
|
7
6
|
const retriever_1 = require("../../../r-bridge/retriever");
|
|
8
7
|
function toDepthMap(entry) {
|
|
9
8
|
const visit = [{ depth: 0, node: entry }];
|
|
@@ -127,20 +126,26 @@ function depthListToTextTree(list, f) {
|
|
|
127
126
|
}
|
|
128
127
|
exports.parseCommand = {
|
|
129
128
|
description: `Prints ASCII Art of the parsed, unmodified AST, start with '${retriever_1.fileProtocol}' to indicate a file`,
|
|
129
|
+
usesAnalyzer: true,
|
|
130
130
|
usageExample: ':parse',
|
|
131
131
|
aliases: ['p'],
|
|
132
132
|
script: false,
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
133
|
+
argsParser: (line) => {
|
|
134
|
+
return {
|
|
135
|
+
// Threat the whole input line as R code
|
|
136
|
+
input: (0, retriever_1.removeRQuotes)(line.trim()),
|
|
137
|
+
remaining: []
|
|
138
|
+
};
|
|
139
|
+
},
|
|
140
|
+
fn: async ({ output, analyzer }) => {
|
|
141
|
+
const result = await analyzer.parse();
|
|
142
|
+
if (analyzer.parserName() === 'r-shell') {
|
|
143
|
+
const object = (0, format_1.convertPreparedParsedData)((0, format_1.prepareParsedData)(result.parsed));
|
|
139
144
|
output.stdout(depthListToTextTree(toDepthMap(object), output.formatter));
|
|
140
145
|
}
|
|
141
146
|
else {
|
|
142
147
|
// print the tree-sitter ast
|
|
143
|
-
output.stdout(depthListToTextTree(treeSitterToDepthList(result.
|
|
148
|
+
output.stdout(depthListToTextTree(treeSitterToDepthList(result.parsed.rootNode), output.formatter));
|
|
144
149
|
}
|
|
145
150
|
}
|
|
146
151
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const queryCommand:
|
|
3
|
-
export declare const queryStarCommand:
|
|
1
|
+
import type { ReplCodeCommand } from './repl-main';
|
|
2
|
+
export declare const queryCommand: ReplCodeCommand;
|
|
3
|
+
export declare const queryStarCommand: ReplCodeCommand;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.queryStarCommand = exports.queryCommand = void 0;
|
|
4
|
-
const default_pipelines_1 = require("../../../core/steps/pipeline/default-pipelines");
|
|
5
4
|
const retriever_1 = require("../../../r-bridge/retriever");
|
|
6
5
|
const args_1 = require("../../../util/text/args");
|
|
7
6
|
const ansi_1 = require("../../../util/text/ansi");
|
|
@@ -9,11 +8,6 @@ const schema_1 = require("../../../util/schema");
|
|
|
9
8
|
const query_1 = require("../../../queries/query");
|
|
10
9
|
const json_1 = require("../../../util/json");
|
|
11
10
|
const query_print_1 = require("../../../queries/query-print");
|
|
12
|
-
async function getDataflow(config, parser, remainingLine) {
|
|
13
|
-
return await (0, default_pipelines_1.createDataflowPipeline)(parser, {
|
|
14
|
-
request: (0, retriever_1.requestFromInput)(remainingLine.trim())
|
|
15
|
-
}, config).allRemainingSteps();
|
|
16
|
-
}
|
|
17
11
|
function printHelp(output) {
|
|
18
12
|
output.stderr(`Format: ${(0, ansi_1.italic)(':query "<query>" <code>', output.formatter)}`);
|
|
19
13
|
output.stdout('The query is an array of query objects to represent multiple queries. Each query object may have the following properties:');
|
|
@@ -24,9 +18,8 @@ function printHelp(output) {
|
|
|
24
18
|
output.stdout('Similarly, \'@<type>\' is interpreted as a query of the given type.');
|
|
25
19
|
output.stdout(`With this, ${(0, ansi_1.italic)(':query @config', output.formatter)} prints the result of the config query.`);
|
|
26
20
|
}
|
|
27
|
-
async function processQueryArgs(
|
|
28
|
-
const
|
|
29
|
-
const query = args.shift();
|
|
21
|
+
async function processQueryArgs(output, analyzer, remainingArgs) {
|
|
22
|
+
const query = remainingArgs.shift();
|
|
30
23
|
if (!query) {
|
|
31
24
|
output.stderr('No query provided, use \':query help\' to get more information.');
|
|
32
25
|
return;
|
|
@@ -35,12 +28,12 @@ async function processQueryArgs(line, parser, output, config) {
|
|
|
35
28
|
printHelp(output);
|
|
36
29
|
return;
|
|
37
30
|
}
|
|
38
|
-
let parsedQuery
|
|
31
|
+
let parsedQuery;
|
|
39
32
|
if (query.startsWith('@')) {
|
|
40
33
|
const queryName = query.slice(1);
|
|
41
34
|
const queryObj = query_1.SupportedQueries[queryName];
|
|
42
35
|
if (queryObj?.fromLine) {
|
|
43
|
-
const q = queryObj.fromLine(
|
|
36
|
+
const q = queryObj.fromLine(remainingArgs, analyzer.flowrConfig);
|
|
44
37
|
parsedQuery = q ? (Array.isArray(q) ? q : [q]) : [];
|
|
45
38
|
}
|
|
46
39
|
else {
|
|
@@ -65,34 +58,51 @@ async function processQueryArgs(line, parser, output, config) {
|
|
|
65
58
|
else {
|
|
66
59
|
parsedQuery = [{ type: 'call-context', callName: query }];
|
|
67
60
|
}
|
|
68
|
-
const processed = await getDataflow(config, parser, args.join(' '));
|
|
69
61
|
return {
|
|
62
|
+
query: await (0, query_1.executeQueries)({
|
|
63
|
+
analyzer,
|
|
64
|
+
}, parsedQuery),
|
|
70
65
|
parsedQuery,
|
|
71
|
-
|
|
72
|
-
|
|
66
|
+
analyzer
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Function for splitting the input line.
|
|
71
|
+
* The first token is the query command.
|
|
72
|
+
* The rest of the line is treated as input code.
|
|
73
|
+
*/
|
|
74
|
+
function parseArgs(line) {
|
|
75
|
+
const args = (0, args_1.splitAtEscapeSensitive)(line);
|
|
76
|
+
return {
|
|
77
|
+
input: args.join(' ').trim(),
|
|
78
|
+
remaining: args
|
|
73
79
|
};
|
|
74
80
|
}
|
|
75
81
|
exports.queryCommand = {
|
|
76
82
|
description: `Query the given R code, start with '${retriever_1.fileProtocol}' to indicate a file. The query is to be a valid query in json format (use 'help' to get more information).`,
|
|
83
|
+
usesAnalyzer: true,
|
|
77
84
|
usageExample: ':query "<query>" <code>',
|
|
78
85
|
aliases: [],
|
|
79
86
|
script: false,
|
|
80
|
-
|
|
87
|
+
argsParser: parseArgs,
|
|
88
|
+
fn: async ({ output, analyzer, remainingArgs }) => {
|
|
81
89
|
const totalStart = Date.now();
|
|
82
|
-
const results = await processQueryArgs(
|
|
90
|
+
const results = await processQueryArgs(output, analyzer, remainingArgs);
|
|
83
91
|
const totalEnd = Date.now();
|
|
84
92
|
if (results) {
|
|
85
|
-
output.stdout((0, query_print_1.asciiSummaryOfQueryResult)(ansi_1.ansiFormatter, totalEnd - totalStart, results.query, results.
|
|
93
|
+
output.stdout(await (0, query_print_1.asciiSummaryOfQueryResult)(ansi_1.ansiFormatter, totalEnd - totalStart, results.query, results.analyzer, results.parsedQuery));
|
|
86
94
|
}
|
|
87
95
|
}
|
|
88
96
|
};
|
|
89
97
|
exports.queryStarCommand = {
|
|
90
98
|
description: 'Similar to query, but returns the output in json format.',
|
|
99
|
+
usesAnalyzer: true,
|
|
91
100
|
usageExample: ':query* <query> <code>',
|
|
92
101
|
aliases: [],
|
|
93
102
|
script: false,
|
|
94
|
-
|
|
95
|
-
|
|
103
|
+
argsParser: parseArgs,
|
|
104
|
+
fn: async ({ output, analyzer, remainingArgs }) => {
|
|
105
|
+
const results = await processQueryArgs(output, analyzer, remainingArgs);
|
|
96
106
|
if (results) {
|
|
97
107
|
output.stdout(JSON.stringify(results.query, json_1.jsonReplacer));
|
|
98
108
|
}
|
package/cli/repl/core.d.ts
CHANGED
|
@@ -8,6 +8,10 @@ import type { FlowrConfigOptions } from '../../config';
|
|
|
8
8
|
*/
|
|
9
9
|
export declare function replCompleter(line: string, config: FlowrConfigOptions): [string[], string];
|
|
10
10
|
export declare function makeDefaultReplReadline(config: FlowrConfigOptions): readline.ReadLineOptions;
|
|
11
|
+
export declare function handleString(code: string): {
|
|
12
|
+
input: string;
|
|
13
|
+
remaining: never[];
|
|
14
|
+
};
|
|
11
15
|
/**
|
|
12
16
|
* This function interprets the given `expr` as a REPL command (see {@link repl} for more on the semantics).
|
|
13
17
|
*
|
|
@@ -27,7 +31,6 @@ export interface FlowrReplOptions extends MergeableRecord {
|
|
|
27
31
|
/**
|
|
28
32
|
* A potentially customized readline interface to be used for the repl to *read* from the user, we write the output with the {@link ReplOutput | `output` } interface.
|
|
29
33
|
* If you want to provide a custom one but use the same `completer`, refer to {@link replCompleter}.
|
|
30
|
-
* For the default arguments, see {@link DEFAULT_REPL_READLINE_CONFIGURATION}.
|
|
31
34
|
*/
|
|
32
35
|
readonly rl?: readline.Interface;
|
|
33
36
|
/** Defines two methods that every function in the repl uses to output its data. */
|
package/cli/repl/core.js
CHANGED
|
@@ -38,6 +38,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.replCompleter = replCompleter;
|
|
40
40
|
exports.makeDefaultReplReadline = makeDefaultReplReadline;
|
|
41
|
+
exports.handleString = handleString;
|
|
41
42
|
exports.replProcessAnswer = replProcessAnswer;
|
|
42
43
|
exports.repl = repl;
|
|
43
44
|
exports.loadReplHistory = loadReplHistory;
|
|
@@ -61,6 +62,7 @@ const shell_1 = require("../../r-bridge/shell");
|
|
|
61
62
|
const log_1 = require("../../util/log");
|
|
62
63
|
const config_1 = require("../../config");
|
|
63
64
|
const query_1 = require("../../queries/query");
|
|
65
|
+
const flowr_analyzer_builder_1 = require("../../project/flowr-analyzer-builder");
|
|
64
66
|
let _replCompleterKeywords = undefined;
|
|
65
67
|
function replCompleterKeywords() {
|
|
66
68
|
if (_replCompleterKeywords === undefined) {
|
|
@@ -129,6 +131,12 @@ function makeDefaultReplReadline(config) {
|
|
|
129
131
|
completer: (c) => replCompleter(c, config)
|
|
130
132
|
};
|
|
131
133
|
}
|
|
134
|
+
function handleString(code) {
|
|
135
|
+
return {
|
|
136
|
+
input: code.startsWith('"') ? JSON.parse(code) : code,
|
|
137
|
+
remaining: []
|
|
138
|
+
};
|
|
139
|
+
}
|
|
132
140
|
async function replProcessStatement(output, statement, parser, allowRSessionAccess, config) {
|
|
133
141
|
if (statement.startsWith(':')) {
|
|
134
142
|
const command = statement.slice(1).split(' ')[0].toLowerCase();
|
|
@@ -136,7 +144,19 @@ async function replProcessStatement(output, statement, parser, allowRSessionAcce
|
|
|
136
144
|
const bold = (s) => output.formatter.format(s, { style: 1 /* FontStyles.Bold */ });
|
|
137
145
|
if (processor) {
|
|
138
146
|
try {
|
|
139
|
-
|
|
147
|
+
const remainingLine = statement.slice(command.length + 2).trim();
|
|
148
|
+
if (processor.usesAnalyzer) {
|
|
149
|
+
const args = processor.argsParser(remainingLine);
|
|
150
|
+
const request = (0, retriever_1.requestFromInput)(args.input);
|
|
151
|
+
const analyzer = await new flowr_analyzer_builder_1.FlowrAnalyzerBuilder(request)
|
|
152
|
+
.setConfig(config)
|
|
153
|
+
.setParser(parser)
|
|
154
|
+
.build();
|
|
155
|
+
await processor.fn({ output, analyzer, remainingArgs: args.remaining });
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
await processor.fn({ output, parser, remainingLine, allowRSessionAccess, config });
|
|
159
|
+
}
|
|
140
160
|
}
|
|
141
161
|
catch (e) {
|
|
142
162
|
output.stdout(`${bold(`Failed to execute command ${command}`)}: ${e?.message}. Using the ${bold('--verbose')} flag on startup may provide additional information.\n`);
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import type { Socket } from './net';
|
|
2
|
+
import type { TREE_SITTER_DATAFLOW_PIPELINE } from '../../../core/steps/pipeline/default-pipelines';
|
|
2
3
|
import { DEFAULT_SLICING_PIPELINE } from '../../../core/steps/pipeline/default-pipelines';
|
|
3
4
|
import type { PipelineOutput } from '../../../core/steps/pipeline/pipeline';
|
|
4
5
|
import type { DeepPartial } from 'ts-essentials';
|
|
5
|
-
import type { KnownParser } from '../../../r-bridge/parser';
|
|
6
|
+
import type { KnownParser, ParseStepOutput } from '../../../r-bridge/parser';
|
|
6
7
|
import type { FlowrConfigOptions } from '../../../config';
|
|
8
|
+
import type { NormalizedAst } from '../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
9
|
+
import type { DataflowInformation } from '../../../dataflow/info';
|
|
10
|
+
import type { Tree } from 'web-tree-sitter';
|
|
7
11
|
/**
|
|
8
12
|
* Each connection handles a single client, answering to its requests.
|
|
9
13
|
* There is no need to construct this class manually, {@link FlowRServer} will do it for you.
|
|
@@ -21,10 +25,10 @@ export declare class FlowRServerConnection {
|
|
|
21
25
|
private handleData;
|
|
22
26
|
private handleFileAnalysisRequest;
|
|
23
27
|
private sendFileAnalysisResponse;
|
|
24
|
-
private
|
|
28
|
+
private createAnalyzerForRequest;
|
|
25
29
|
private handleSliceRequest;
|
|
26
30
|
private handleRepl;
|
|
27
31
|
private handleLineageRequest;
|
|
28
32
|
private handleQueryRequest;
|
|
29
33
|
}
|
|
30
|
-
export declare function sanitizeAnalysisResults(
|
|
34
|
+
export declare function sanitizeAnalysisResults(parse: ParseStepOutput<string | Tree>, normalize: NormalizedAst, dataflow: DataflowInformation): DeepPartial<PipelineOutput<typeof DEFAULT_SLICING_PIPELINE | typeof TREE_SITTER_DATAFLOW_PIPELINE>>;
|
|
@@ -48,20 +48,20 @@ const core_1 = require("../core");
|
|
|
48
48
|
const extract_cfg_1 = require("../../../control-flow/extract-cfg");
|
|
49
49
|
const quads_1 = require("../../../util/quads");
|
|
50
50
|
const print_1 = require("../../../core/print/print");
|
|
51
|
+
const _00_parse_1 = require("../../../core/steps/all/core/00-parse");
|
|
52
|
+
const _10_normalize_1 = require("../../../core/steps/all/core/10-normalize");
|
|
53
|
+
const _20_dataflow_1 = require("../../../core/steps/all/core/20-dataflow");
|
|
51
54
|
const ansi_1 = require("../../../util/text/ansi");
|
|
52
55
|
const default_pipelines_1 = require("../../../core/steps/pipeline/default-pipelines");
|
|
53
56
|
const graph_1 = require("../../../dataflow/graph/graph");
|
|
54
57
|
const tmp = __importStar(require("tmp"));
|
|
55
58
|
const fs_1 = __importDefault(require("fs"));
|
|
56
|
-
const magic_comments_1 = require("../../../reconstruct/auto-select/magic-comments");
|
|
57
59
|
const message_lineage_1 = require("./messages/message-lineage");
|
|
58
60
|
const repl_lineage_1 = require("../commands/repl-lineage");
|
|
59
|
-
const assert_1 = require("../../../util/assert");
|
|
60
|
-
const auto_select_defaults_1 = require("../../../reconstruct/auto-select/auto-select-defaults");
|
|
61
61
|
const message_query_1 = require("./messages/message-query");
|
|
62
|
-
const query_1 = require("../../../queries/query");
|
|
63
62
|
const compact_1 = require("./compact");
|
|
64
63
|
const _00_slice_1 = require("../../../core/steps/all/static-slicing/00-slice");
|
|
64
|
+
const flowr_analyzer_builder_1 = require("../../../project/flowr-analyzer-builder");
|
|
65
65
|
/**
|
|
66
66
|
* Each connection handles a single client, answering to its requests.
|
|
67
67
|
* There is no need to construct this class manually, {@link FlowRServer} will do it for you.
|
|
@@ -117,7 +117,7 @@ class FlowRServerConnection {
|
|
|
117
117
|
this.handleRepl(request.message);
|
|
118
118
|
break;
|
|
119
119
|
case 'request-lineage':
|
|
120
|
-
this.handleLineageRequest(request.message);
|
|
120
|
+
void this.handleLineageRequest(request.message);
|
|
121
121
|
break;
|
|
122
122
|
case 'request-query':
|
|
123
123
|
this.handleQueryRequest(request.message);
|
|
@@ -146,9 +146,11 @@ class FlowRServerConnection {
|
|
|
146
146
|
this.fileMap.delete(message.filetoken);
|
|
147
147
|
}
|
|
148
148
|
const tempFile = tmp.fileSync({ postfix: '.R' });
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
.
|
|
149
|
+
const analyzer = await this.createAnalyzerForRequest(message, tempFile.name);
|
|
150
|
+
try {
|
|
151
|
+
await this.sendFileAnalysisResponse(analyzer, message);
|
|
152
|
+
}
|
|
153
|
+
catch (e) {
|
|
152
154
|
this.logger.error(`[${this.name}] Error while analyzing file ${message.filename ?? 'unknown file'}: ${String(e)}`);
|
|
153
155
|
(0, send_1.sendMessage)(this.socket, {
|
|
154
156
|
id: message.id,
|
|
@@ -156,22 +158,17 @@ class FlowRServerConnection {
|
|
|
156
158
|
fatal: false,
|
|
157
159
|
reason: `Error while analyzing file ${message.filename ?? 'unknown file'}: ${String(e)}`
|
|
158
160
|
});
|
|
159
|
-
}
|
|
161
|
+
}
|
|
160
162
|
// this is an interestingly named function that means "I am a callback that removes a file" - so this deletes the file
|
|
161
163
|
tempFile.removeCallback();
|
|
162
164
|
}
|
|
163
|
-
async sendFileAnalysisResponse(
|
|
165
|
+
async sendFileAnalysisResponse(analyzer, message) {
|
|
164
166
|
let cfg = undefined;
|
|
165
167
|
if (message.cfg) {
|
|
166
|
-
cfg =
|
|
168
|
+
cfg = await analyzer.controlflow();
|
|
167
169
|
}
|
|
168
170
|
const config = () => ({ context: message.filename ?? 'unknown', getId: (0, quads_1.defaultQuadIdGenerator)() });
|
|
169
|
-
const sanitizedResults = sanitizeAnalysisResults(
|
|
170
|
-
const pipeline = slicer.getPipeline();
|
|
171
|
-
const parseStep = pipeline.steps.get('parse');
|
|
172
|
-
const normalizedStep = pipeline.steps.get('normalize');
|
|
173
|
-
const dataflowStep = pipeline.steps.get('dataflow');
|
|
174
|
-
(0, assert_1.guard)(parseStep !== undefined && normalizedStep !== undefined && dataflowStep !== undefined, 'All steps must be present');
|
|
171
|
+
const sanitizedResults = sanitizeAnalysisResults(await analyzer.parse(), await analyzer.normalize(), await analyzer.dataflow());
|
|
175
172
|
if (message.format === 'n-quads') {
|
|
176
173
|
(0, send_1.sendMessage)(this.socket, {
|
|
177
174
|
type: 'response-file-analysis',
|
|
@@ -179,9 +176,9 @@ class FlowRServerConnection {
|
|
|
179
176
|
id: message.id,
|
|
180
177
|
cfg: cfg ? (0, extract_cfg_1.cfg2quads)(cfg, config()) : undefined,
|
|
181
178
|
results: {
|
|
182
|
-
parse: await (0, print_1.printStepResult)(
|
|
183
|
-
normalize: await (0, print_1.printStepResult)(
|
|
184
|
-
dataflow: await (0, print_1.printStepResult)(
|
|
179
|
+
parse: await (0, print_1.printStepResult)(_00_parse_1.PARSE_WITH_R_SHELL_STEP, await analyzer.parse(), 5 /* StepOutputFormat.RdfQuads */, config()),
|
|
180
|
+
normalize: await (0, print_1.printStepResult)(_10_normalize_1.NORMALIZE, await analyzer.normalize(), 5 /* StepOutputFormat.RdfQuads */, config()),
|
|
181
|
+
dataflow: await (0, print_1.printStepResult)(_20_dataflow_1.STATIC_DATAFLOW, await analyzer.dataflow(), 5 /* StepOutputFormat.RdfQuads */, config())
|
|
185
182
|
}
|
|
186
183
|
});
|
|
187
184
|
}
|
|
@@ -204,7 +201,7 @@ class FlowRServerConnection {
|
|
|
204
201
|
});
|
|
205
202
|
}
|
|
206
203
|
}
|
|
207
|
-
|
|
204
|
+
async createAnalyzerForRequest(message, tempFile) {
|
|
208
205
|
let request;
|
|
209
206
|
if (message.content !== undefined) {
|
|
210
207
|
// we store the code in a temporary file in case it's too big for the shell to handle
|
|
@@ -222,18 +219,18 @@ class FlowRServerConnection {
|
|
|
222
219
|
else {
|
|
223
220
|
throw new Error('Either content or filepath must be defined.');
|
|
224
221
|
}
|
|
225
|
-
const
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
222
|
+
const analyzer = await new flowr_analyzer_builder_1.FlowrAnalyzerBuilder(request)
|
|
223
|
+
.setConfig(this.config)
|
|
224
|
+
.setParser(this.parser)
|
|
225
|
+
.build();
|
|
229
226
|
if (message.filetoken) {
|
|
230
227
|
this.logger.info(`Storing file token ${message.filetoken}`);
|
|
231
228
|
this.fileMap.set(message.filetoken, {
|
|
232
229
|
filename: message.filename,
|
|
233
|
-
|
|
230
|
+
analyzer: analyzer
|
|
234
231
|
});
|
|
235
232
|
}
|
|
236
|
-
return
|
|
233
|
+
return analyzer;
|
|
237
234
|
}
|
|
238
235
|
handleSliceRequest(base) {
|
|
239
236
|
const requestResult = (0, validate_1.validateMessage)(base, message_slice_1.requestSliceMessage);
|
|
@@ -253,16 +250,16 @@ class FlowRServerConnection {
|
|
|
253
250
|
});
|
|
254
251
|
return;
|
|
255
252
|
}
|
|
256
|
-
fileInformation.
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
253
|
+
void fileInformation.analyzer.query([{
|
|
254
|
+
type: 'static-slice',
|
|
255
|
+
criteria: request.criterion,
|
|
256
|
+
noMagicComments: request.noMagicComments,
|
|
257
|
+
direction: request.direction
|
|
258
|
+
}]).then(result => {
|
|
262
259
|
(0, send_1.sendMessage)(this.socket, {
|
|
263
260
|
type: 'response-slice',
|
|
264
261
|
id: request.id,
|
|
265
|
-
results: Object.fromEntries(Object.entries(
|
|
262
|
+
results: Object.fromEntries(Object.entries(result)
|
|
266
263
|
.filter(([k,]) => default_pipelines_1.DEFAULT_SLICING_PIPELINE.steps.get(k)?.executed === 1 /* PipelineStepStage.OncePerRequest */))
|
|
267
264
|
});
|
|
268
265
|
}).catch(e => {
|
|
@@ -301,7 +298,7 @@ class FlowRServerConnection {
|
|
|
301
298
|
});
|
|
302
299
|
});
|
|
303
300
|
}
|
|
304
|
-
handleLineageRequest(base) {
|
|
301
|
+
async handleLineageRequest(base) {
|
|
305
302
|
const requestResult = (0, validate_1.validateMessage)(base, message_lineage_1.requestLineageMessage);
|
|
306
303
|
if (requestResult.type === 'error') {
|
|
307
304
|
(0, validate_1.answerForValidationError)(this.socket, requestResult, base.id);
|
|
@@ -319,10 +316,8 @@ class FlowRServerConnection {
|
|
|
319
316
|
});
|
|
320
317
|
return;
|
|
321
318
|
}
|
|
322
|
-
const
|
|
323
|
-
(0,
|
|
324
|
-
(0, assert_1.guard)(ast !== undefined, `AST must be present (request: ${request.filetoken})`);
|
|
325
|
-
const lineageIds = (0, repl_lineage_1.getLineage)(request.criterion, dfg.graph, ast.idMap);
|
|
319
|
+
const analyzer = fileInformation.analyzer;
|
|
320
|
+
const lineageIds = (0, repl_lineage_1.getLineage)(request.criterion, (await analyzer.dataflow()).graph, (await analyzer.normalize()).idMap);
|
|
326
321
|
(0, send_1.sendMessage)(this.socket, {
|
|
327
322
|
type: 'response-lineage',
|
|
328
323
|
id: request.id,
|
|
@@ -347,10 +342,7 @@ class FlowRServerConnection {
|
|
|
347
342
|
});
|
|
348
343
|
return;
|
|
349
344
|
}
|
|
350
|
-
|
|
351
|
-
(0, assert_1.guard)(dfg !== undefined, `Dataflow graph must be present (request: ${request.filetoken})`);
|
|
352
|
-
(0, assert_1.guard)(ast !== undefined, `AST must be present (request: ${request.filetoken})`);
|
|
353
|
-
void Promise.resolve((0, query_1.executeQueries)({ dataflow: dfg, ast, config: this.config }, request.query)).then(results => {
|
|
345
|
+
void Promise.resolve(fileInformation.analyzer.query(request.query)).then(results => {
|
|
354
346
|
(0, send_1.sendMessage)(this.socket, {
|
|
355
347
|
type: 'response-query',
|
|
356
348
|
id: request.id,
|
|
@@ -368,17 +360,17 @@ class FlowRServerConnection {
|
|
|
368
360
|
}
|
|
369
361
|
}
|
|
370
362
|
exports.FlowRServerConnection = FlowRServerConnection;
|
|
371
|
-
function sanitizeAnalysisResults(
|
|
363
|
+
function sanitizeAnalysisResults(parse, normalize, dataflow) {
|
|
372
364
|
return {
|
|
373
|
-
|
|
365
|
+
parse: parse,
|
|
374
366
|
normalize: {
|
|
375
|
-
...
|
|
367
|
+
...normalize,
|
|
376
368
|
idMap: undefined
|
|
377
369
|
},
|
|
378
370
|
dataflow: {
|
|
379
|
-
...
|
|
371
|
+
...dataflow,
|
|
380
372
|
// we want to keep the DataflowGraph type information, but not the idMap
|
|
381
|
-
graph: new graph_1.DataflowGraph(undefined).mergeWith(
|
|
373
|
+
graph: new graph_1.DataflowGraph(undefined).mergeWith(dataflow?.graph)
|
|
382
374
|
}
|
|
383
375
|
};
|
|
384
376
|
}
|
|
@@ -17,7 +17,7 @@ export interface SliceRequestMessage extends IdMessageBase {
|
|
|
17
17
|
/** The direction to slice in. Defaults to backward slicing if unset. */
|
|
18
18
|
direction?: SliceDirection;
|
|
19
19
|
/**
|
|
20
|
-
* Should the magic comments (force-including lines within the slice) be
|
|
20
|
+
* Should the magic comments (force-including lines within the slice) be ignored?
|
|
21
21
|
*/
|
|
22
22
|
noMagicComments?: boolean;
|
|
23
23
|
}
|