@eagleoutice/flowr 2.1.3 → 2.1.4
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/benchmark/slicer.js +1 -1
- package/cli/repl/commands/repl-parse.js +1 -1
- package/cli/repl/commands/repl-query.js +4 -5
- package/cli/repl/server/connection.js +6 -1
- package/cli/repl/server/messages/message-query.js +2 -2
- package/cli/repl/server/net.js +1 -1
- package/cli/repl/server/send.js +3 -6
- package/cli/repl/server/server.d.ts +2 -2
- package/cli/repl/server/server.js +1 -1
- package/config.js +1 -1
- package/core/pipeline-executor.js +2 -1
- package/core/steps/all/core/00-parse.d.ts +11 -4
- package/core/steps/all/core/00-parse.js +5 -5
- package/core/steps/all/core/10-normalize.d.ts +2 -1
- package/core/steps/all/core/20-dataflow.d.ts +2 -2
- package/core/steps/all/core/20-dataflow.js +2 -2
- package/core/steps/pipeline/default-pipelines.d.ts +41 -23
- package/core/steps/pipeline/pipeline.d.ts +15 -3
- package/core/steps/pipeline/pipeline.js +2 -2
- package/dataflow/environments/built-in.d.ts +8 -6
- package/dataflow/environments/built-in.js +6 -1
- package/dataflow/environments/default-builtin-config.js +21 -5
- package/dataflow/environments/environment.d.ts +1 -0
- package/dataflow/environments/environment.js +5 -5
- package/dataflow/extractor.js +23 -0
- package/dataflow/graph/dataflowgraph-builder.d.ts +2 -0
- package/dataflow/graph/dataflowgraph-builder.js +9 -0
- package/dataflow/graph/diff.js +1 -1
- package/dataflow/graph/graph.d.ts +7 -2
- package/dataflow/graph/graph.js +10 -2
- package/dataflow/internal/process/functions/call/argument/unpack-argument.d.ts +1 -1
- package/dataflow/internal/process/functions/call/argument/unpack-argument.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +13 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +1 -1
- package/dataflow/internal/process/functions/call/named-call-handling.js +1 -1
- package/dataflow/processor.d.ts +3 -3
- package/documentation/data/server/doc-data-server-messages.js +8 -14
- package/documentation/doc-util/doc-cli-option.js +4 -4
- package/documentation/doc-util/doc-query.d.ts +4 -6
- package/documentation/doc-util/doc-query.js +16 -156
- package/documentation/doc-util/doc-repl.js +2 -2
- package/documentation/print-dataflow-graph-wiki.js +2 -1
- package/documentation/print-interface-wiki.js +8 -3
- package/documentation/print-query-wiki.js +107 -16
- package/package.json +1 -1
- package/queries/base-query-format.d.ts +6 -0
- 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 +26 -80
- package/queries/catalog/call-context-query/call-context-query-format.d.ts +14 -13
- package/queries/catalog/call-context-query/call-context-query-format.js +32 -14
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.d.ts +17 -0
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +99 -0
- package/queries/catalog/cluster-query/cluster-query-executor.d.ts +1 -1
- package/queries/catalog/cluster-query/cluster-query-format.d.ts +59 -0
- package/queries/catalog/cluster-query/cluster-query-format.js +29 -0
- package/queries/catalog/dataflow-query/dataflow-query-executor.d.ts +1 -1
- package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +59 -0
- package/queries/catalog/dataflow-query/dataflow-query-format.js +21 -0
- package/queries/catalog/dependencies-query/dependencies-query-executor.d.ts +3 -0
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +144 -0
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +102 -0
- package/queries/catalog/dependencies-query/dependencies-query-format.js +187 -0
- package/queries/catalog/id-map-query/id-map-query-executor.d.ts +1 -1
- package/queries/catalog/id-map-query/id-map-query-format.d.ts +59 -0
- package/queries/catalog/id-map-query/id-map-query-format.js +21 -0
- package/queries/catalog/lineage-query/lineage-query-executor.d.ts +1 -1
- package/queries/catalog/lineage-query/lineage-query-format.d.ts +59 -0
- package/queries/catalog/lineage-query/lineage-query-format.js +24 -0
- package/queries/catalog/location-map-query/location-map-query-executor.d.ts +3 -0
- package/queries/catalog/location-map-query/location-map-query-executor.js +21 -0
- package/queries/catalog/location-map-query/location-map-query-format.d.ts +17 -0
- package/queries/catalog/location-map-query/location-map-query-format.js +24 -0
- package/queries/catalog/normalized-ast-query/normalized-ast-query-executor.d.ts +1 -1
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +59 -0
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.js +21 -0
- 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 +8 -3
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +59 -0
- package/queries/catalog/static-slice-query/static-slice-query-format.js +40 -0
- package/queries/query-print.d.ts +8 -0
- package/queries/query-print.js +94 -0
- package/queries/query.d.ts +431 -26
- package/queries/query.js +36 -18
- package/r-bridge/lang-4.x/ast/parser/json/parser.d.ts +2 -1
- package/r-bridge/lang-4.x/ast/parser/json/parser.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-argument.js +2 -1
- package/r-bridge/retriever.js +1 -1
- package/r-bridge/shell-executor.js +1 -1
- package/r-bridge/shell.d.ts +1 -2
- package/r-bridge/shell.js +22 -18
- package/slicing/static/static-slicer.js +3 -1
- package/statistics/features/supported/used-functions/used-functions.js +1 -1
- package/{documentation/doc-util/doc-hover-over.js → util/html-hover-over.js} +1 -1
- package/util/json.d.ts +2 -1
- package/util/json.js +101 -3
- package/util/objects.d.ts +2 -1
- package/util/objects.js +3 -0
- package/util/version.js +1 -1
- package/queries/query-schema.d.ts +0 -13
- package/queries/query-schema.js +0 -54
- /package/{documentation/doc-util/doc-hover-over.d.ts → util/html-hover-over.d.ts} +0 -0
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { LocationMapQuery, LocationMapQueryResult } from './location-map-query-format';
|
|
2
|
+
import type { BasicQueryData } from '../../base-query-format';
|
|
3
|
+
export declare function executeLocationMapQuery({ ast }: BasicQueryData, queries: readonly LocationMapQuery[]): LocationMapQueryResult;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.executeLocationMapQuery = executeLocationMapQuery;
|
|
4
|
+
const log_1 = require("../../../util/log");
|
|
5
|
+
function executeLocationMapQuery({ ast }, queries) {
|
|
6
|
+
if (queries.length !== 1) {
|
|
7
|
+
log_1.log.warn('Id-Map query expects only up to one query, but got', queries.length);
|
|
8
|
+
}
|
|
9
|
+
const start = Date.now();
|
|
10
|
+
const locationMap = {};
|
|
11
|
+
for (const [id, node] of ast.idMap.entries()) {
|
|
12
|
+
locationMap[id] = node.location;
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
'.meta': {
|
|
16
|
+
timing: Date.now() - start
|
|
17
|
+
},
|
|
18
|
+
map: locationMap
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=location-map-query-executor.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { BaseQueryFormat, BaseQueryResult } from '../../base-query-format';
|
|
2
|
+
import { executeLocationMapQuery } from './location-map-query-executor';
|
|
3
|
+
import { type OutputFormatter } from '../../../util/ansi';
|
|
4
|
+
import Joi from 'joi';
|
|
5
|
+
import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
6
|
+
import type { SourceRange } from '../../../util/range';
|
|
7
|
+
export interface LocationMapQuery extends BaseQueryFormat {
|
|
8
|
+
readonly type: 'location-map';
|
|
9
|
+
}
|
|
10
|
+
export interface LocationMapQueryResult extends BaseQueryResult {
|
|
11
|
+
readonly map: Record<NodeId, SourceRange | undefined>;
|
|
12
|
+
}
|
|
13
|
+
export declare const LocationMapQueryDefinition: {
|
|
14
|
+
readonly executor: typeof executeLocationMapQuery;
|
|
15
|
+
readonly asciiSummarizer: (formatter: OutputFormatter, _processed: unknown, queryResults: BaseQueryResult, result: string[]) => boolean;
|
|
16
|
+
readonly schema: Joi.ObjectSchema<any>;
|
|
17
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
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.LocationMapQueryDefinition = void 0;
|
|
7
|
+
const location_map_query_executor_1 = require("./location-map-query-executor");
|
|
8
|
+
const ansi_1 = require("../../../util/ansi");
|
|
9
|
+
const time_1 = require("../../../util/time");
|
|
10
|
+
const joi_1 = __importDefault(require("joi"));
|
|
11
|
+
const query_print_1 = require("../../query-print");
|
|
12
|
+
exports.LocationMapQueryDefinition = {
|
|
13
|
+
executor: location_map_query_executor_1.executeLocationMapQuery,
|
|
14
|
+
asciiSummarizer: (formatter, _processed, queryResults, result) => {
|
|
15
|
+
const out = queryResults;
|
|
16
|
+
result.push(`Query: ${(0, ansi_1.bold)('location-map', formatter)} (${(0, time_1.printAsMs)(out['.meta'].timing, 0)})`);
|
|
17
|
+
result.push(` ╰ Id List: {${(0, query_print_1.summarizeIdsIfTooLong)(formatter, [...Object.keys(out.map)])}}`);
|
|
18
|
+
return true;
|
|
19
|
+
},
|
|
20
|
+
schema: joi_1.default.object({
|
|
21
|
+
type: joi_1.default.string().valid('location-map').required().description('The type of the query.'),
|
|
22
|
+
}).description('The id map query retrieves the location of every id in the ast.')
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=location-map-query-format.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { BasicQueryData } from '../../query';
|
|
2
1
|
import type { NormalizedAstQuery, NormalizedAstQueryResult } from './normalized-ast-query-format';
|
|
2
|
+
import type { BasicQueryData } from '../../base-query-format';
|
|
3
3
|
export declare function executeNormalizedAstQuery({ ast }: BasicQueryData, queries: readonly NormalizedAstQuery[]): NormalizedAstQueryResult;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { BaseQueryFormat, BaseQueryResult } from '../../base-query-format';
|
|
2
2
|
import type { NormalizedAst } from '../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
3
|
+
import { executeNormalizedAstQuery } from './normalized-ast-query-executor';
|
|
4
|
+
import Joi from 'joi';
|
|
3
5
|
/**
|
|
4
6
|
* Simple re-returns the normalized AST of the analysis.
|
|
5
7
|
*/
|
|
@@ -9,3 +11,60 @@ export interface NormalizedAstQuery extends BaseQueryFormat {
|
|
|
9
11
|
export interface NormalizedAstQueryResult extends BaseQueryResult {
|
|
10
12
|
readonly normalized: NormalizedAst;
|
|
11
13
|
}
|
|
14
|
+
export declare const NormalizedAstQueryDefinition: {
|
|
15
|
+
readonly executor: typeof executeNormalizedAstQuery;
|
|
16
|
+
readonly asciiSummarizer: (formatter: import("../../../util/ansi").OutputFormatter, _processed: import("../../../core/steps/pipeline/pipeline").PipelineOutput<import("../../../core/steps/pipeline/pipeline").Pipeline<{
|
|
17
|
+
readonly name: "parse";
|
|
18
|
+
readonly humanReadableName: "parse with R shell";
|
|
19
|
+
readonly description: "Parse the given R code into an AST";
|
|
20
|
+
readonly processor: (_results: unknown, input: Partial<import("../../../core/steps/all/core/00-parse").ParseRequiredInput>) => Promise<import("../../../core/steps/all/core/00-parse").ParseStepOutput>;
|
|
21
|
+
readonly executed: import("../../../core/steps/pipeline-step").PipelineStepStage.OncePerFile;
|
|
22
|
+
readonly printer: {
|
|
23
|
+
readonly 0: typeof import("../../../core/print/print").internalPrinter;
|
|
24
|
+
readonly 2: {
|
|
25
|
+
(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string;
|
|
26
|
+
(value: any, replacer?: (number | string)[] | null, space?: string | number): string;
|
|
27
|
+
};
|
|
28
|
+
readonly 5: ({ parsed }: import("../../../core/steps/all/core/00-parse").ParseStepOutput, config: import("../../../util/quads").QuadSerializationConfiguration) => string;
|
|
29
|
+
};
|
|
30
|
+
readonly dependencies: readonly [];
|
|
31
|
+
readonly requiredInput: import("../../../core/steps/all/core/00-parse").ParseRequiredInput;
|
|
32
|
+
} | {
|
|
33
|
+
readonly name: "normalize";
|
|
34
|
+
readonly humanReadableName: "normalize";
|
|
35
|
+
readonly description: "Normalize the AST to flowR's AST";
|
|
36
|
+
readonly processor: (results: {
|
|
37
|
+
parse?: import("../../../core/steps/all/core/00-parse").ParseStepOutput;
|
|
38
|
+
}, input: Partial<import("../../../core/steps/all/core/10-normalize").NormalizeRequiredInput>) => NormalizedAst<import("../../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../../../r-bridge/lang-4.x/ast/model/model").RNode<import("../../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>>;
|
|
39
|
+
readonly executed: import("../../../core/steps/pipeline-step").PipelineStepStage.OncePerFile;
|
|
40
|
+
readonly printer: {
|
|
41
|
+
readonly 0: typeof import("../../../core/print/print").internalPrinter;
|
|
42
|
+
readonly 2: typeof import("../../../core/print/normalize-printer").normalizedAstToJson;
|
|
43
|
+
readonly 5: typeof import("../../../core/print/normalize-printer").normalizedAstToQuads;
|
|
44
|
+
readonly 3: typeof import("../../../core/print/normalize-printer").printNormalizedAstToMermaid;
|
|
45
|
+
readonly 4: typeof import("../../../core/print/normalize-printer").printNormalizedAstToMermaidUrl;
|
|
46
|
+
};
|
|
47
|
+
readonly dependencies: readonly ["parse"];
|
|
48
|
+
readonly requiredInput: import("../../../core/steps/all/core/10-normalize").NormalizeRequiredInput;
|
|
49
|
+
} | {
|
|
50
|
+
readonly humanReadableName: "dataflow";
|
|
51
|
+
readonly processor: (results: {
|
|
52
|
+
normalize?: NormalizedAst;
|
|
53
|
+
}, input: {
|
|
54
|
+
request?: import("../../../r-bridge/retriever").RParseRequests;
|
|
55
|
+
}) => import("../../../dataflow/info").DataflowInformation;
|
|
56
|
+
readonly requiredInput: {};
|
|
57
|
+
readonly name: "dataflow";
|
|
58
|
+
readonly description: "Construct the dataflow graph";
|
|
59
|
+
readonly executed: import("../../../core/steps/pipeline-step").PipelineStepStage.OncePerFile;
|
|
60
|
+
readonly printer: {
|
|
61
|
+
readonly 0: typeof import("../../../core/print/print").internalPrinter;
|
|
62
|
+
readonly 2: typeof import("../../../core/print/dataflow-printer").dataflowGraphToJson;
|
|
63
|
+
readonly 5: typeof import("../../../core/print/dataflow-printer").dataflowGraphToQuads;
|
|
64
|
+
readonly 3: typeof import("../../../core/print/dataflow-printer").dataflowGraphToMermaid;
|
|
65
|
+
readonly 4: typeof import("../../../core/print/dataflow-printer").dataflowGraphToMermaidUrl;
|
|
66
|
+
};
|
|
67
|
+
readonly dependencies: readonly ["normalize"];
|
|
68
|
+
}>>, queryResults: BaseQueryResult, result: string[]) => true;
|
|
69
|
+
readonly schema: Joi.ObjectSchema<any>;
|
|
70
|
+
};
|
|
@@ -1,3 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.NormalizedAstQueryDefinition = void 0;
|
|
7
|
+
const normalized_ast_query_executor_1 = require("./normalized-ast-query-executor");
|
|
8
|
+
const ansi_1 = require("../../../util/ansi");
|
|
9
|
+
const time_1 = require("../../../util/time");
|
|
10
|
+
const ast_1 = require("../../../util/mermaid/ast");
|
|
11
|
+
const joi_1 = __importDefault(require("joi"));
|
|
12
|
+
exports.NormalizedAstQueryDefinition = {
|
|
13
|
+
executor: normalized_ast_query_executor_1.executeNormalizedAstQuery,
|
|
14
|
+
asciiSummarizer: (formatter, _processed, queryResults, result) => {
|
|
15
|
+
const out = queryResults;
|
|
16
|
+
result.push(`Query: ${(0, ansi_1.bold)('normalized-ast', formatter)} (${(0, time_1.printAsMs)(out['.meta'].timing, 0)})`);
|
|
17
|
+
result.push(` ╰ [Normalized AST](${(0, ast_1.normalizedAstToMermaidUrl)(out.normalized.ast)})`);
|
|
18
|
+
return true;
|
|
19
|
+
},
|
|
20
|
+
schema: joi_1.default.object({
|
|
21
|
+
type: joi_1.default.string().valid('normalized-ast').required().description('The type of the query.'),
|
|
22
|
+
}).description('The normalized AST query simply returns the normalized AST, there is no need to pass it multiple times!')
|
|
23
|
+
};
|
|
3
24
|
//# sourceMappingURL=normalized-ast-query-format.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BasicQueryData } from '../../query';
|
|
2
1
|
import type { StaticSliceQuery, StaticSliceQueryResult } from './static-slice-query-format';
|
|
2
|
+
import type { BasicQueryData } from '../../base-query-format';
|
|
3
3
|
export declare function fingerPrintOfQuery(query: StaticSliceQuery): string;
|
|
4
4
|
export declare function executeStaticSliceClusterQuery({ graph, ast }: BasicQueryData, queries: readonly StaticSliceQuery[]): StaticSliceQueryResult;
|
|
@@ -19,14 +19,19 @@ function executeStaticSliceClusterQuery({ graph, ast }, queries) {
|
|
|
19
19
|
log_1.log.warn(`Duplicate Key for slicing-query: ${key}, skipping...`);
|
|
20
20
|
}
|
|
21
21
|
const { criteria, noReconstruction, noMagicComments } = query;
|
|
22
|
+
const sliceStart = Date.now();
|
|
22
23
|
const slice = (0, static_slicer_1.staticSlicing)(graph, ast, criteria);
|
|
24
|
+
const sliceEnd = Date.now();
|
|
23
25
|
if (noReconstruction) {
|
|
24
|
-
results[key] = { slice };
|
|
26
|
+
results[key] = { slice: { ...slice, '.meta': { timing: sliceEnd - sliceStart } } };
|
|
25
27
|
}
|
|
26
28
|
else {
|
|
29
|
+
const reconstructStart = Date.now();
|
|
30
|
+
const reconstruct = (0, reconstruct_1.reconstructToCode)(ast, slice.result, noMagicComments ? auto_select_defaults_1.doNotAutoSelect : (0, magic_comments_1.makeMagicCommentHandler)(auto_select_defaults_1.doNotAutoSelect));
|
|
31
|
+
const reconstructEnd = Date.now();
|
|
27
32
|
results[key] = {
|
|
28
|
-
slice,
|
|
29
|
-
reconstruct:
|
|
33
|
+
slice: { ...slice, '.meta': { timing: sliceEnd - sliceStart } },
|
|
34
|
+
reconstruct: { ...reconstruct, '.meta': { timing: reconstructEnd - reconstructStart } }
|
|
30
35
|
};
|
|
31
36
|
}
|
|
32
37
|
}
|
|
@@ -2,6 +2,8 @@ import type { BaseQueryFormat, BaseQueryResult } from '../../base-query-format';
|
|
|
2
2
|
import type { PipelineOutput } from '../../../core/steps/pipeline/pipeline';
|
|
3
3
|
import type { DEFAULT_DATAFLOW_PIPELINE, DEFAULT_SLICE_WITHOUT_RECONSTRUCT_PIPELINE, DEFAULT_SLICING_PIPELINE } from '../../../core/steps/pipeline/default-pipelines';
|
|
4
4
|
import type { SlicingCriteria } from '../../../slicing/criterion/parse';
|
|
5
|
+
import Joi from 'joi';
|
|
6
|
+
import { executeStaticSliceClusterQuery } from './static-slice-query-executor';
|
|
5
7
|
/** Calculates and returns all clusters encountered in the dataflow graph. */
|
|
6
8
|
export interface StaticSliceQuery extends BaseQueryFormat {
|
|
7
9
|
readonly type: 'static-slice';
|
|
@@ -22,3 +24,60 @@ export interface StaticSliceQueryResult extends BaseQueryResult {
|
|
|
22
24
|
*/
|
|
23
25
|
results: Record<string, Omit<PipelineOutput<typeof DEFAULT_SLICING_PIPELINE>, keyof PipelineOutput<typeof DEFAULT_DATAFLOW_PIPELINE>> | Omit<PipelineOutput<typeof DEFAULT_SLICE_WITHOUT_RECONSTRUCT_PIPELINE>, keyof PipelineOutput<typeof DEFAULT_DATAFLOW_PIPELINE>>>;
|
|
24
26
|
}
|
|
27
|
+
export declare const StaticSliceQueryDefinition: {
|
|
28
|
+
readonly executor: typeof executeStaticSliceClusterQuery;
|
|
29
|
+
readonly asciiSummarizer: (formatter: import("../../../util/ansi").OutputFormatter, _processed: PipelineOutput<import("../../../core/steps/pipeline/pipeline").Pipeline<{
|
|
30
|
+
readonly name: "parse";
|
|
31
|
+
readonly humanReadableName: "parse with R shell";
|
|
32
|
+
readonly description: "Parse the given R code into an AST";
|
|
33
|
+
readonly processor: (_results: unknown, input: Partial<import("../../../core/steps/all/core/00-parse").ParseRequiredInput>) => Promise<import("../../../core/steps/all/core/00-parse").ParseStepOutput>;
|
|
34
|
+
readonly executed: import("../../../core/steps/pipeline-step").PipelineStepStage.OncePerFile;
|
|
35
|
+
readonly printer: {
|
|
36
|
+
readonly 0: typeof import("../../../core/print/print").internalPrinter;
|
|
37
|
+
readonly 2: {
|
|
38
|
+
(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string;
|
|
39
|
+
(value: any, replacer?: (number | string)[] | null, space?: string | number): string;
|
|
40
|
+
};
|
|
41
|
+
readonly 5: ({ parsed }: import("../../../core/steps/all/core/00-parse").ParseStepOutput, config: import("../../../util/quads").QuadSerializationConfiguration) => string;
|
|
42
|
+
};
|
|
43
|
+
readonly dependencies: readonly [];
|
|
44
|
+
readonly requiredInput: import("../../../core/steps/all/core/00-parse").ParseRequiredInput;
|
|
45
|
+
} | {
|
|
46
|
+
readonly name: "normalize";
|
|
47
|
+
readonly humanReadableName: "normalize";
|
|
48
|
+
readonly description: "Normalize the AST to flowR's AST";
|
|
49
|
+
readonly processor: (results: {
|
|
50
|
+
parse?: import("../../../core/steps/all/core/00-parse").ParseStepOutput;
|
|
51
|
+
}, input: Partial<import("../../../core/steps/all/core/10-normalize").NormalizeRequiredInput>) => import("../../../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst<import("../../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../../../r-bridge/lang-4.x/ast/model/model").RNode<import("../../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>>;
|
|
52
|
+
readonly executed: import("../../../core/steps/pipeline-step").PipelineStepStage.OncePerFile;
|
|
53
|
+
readonly printer: {
|
|
54
|
+
readonly 0: typeof import("../../../core/print/print").internalPrinter;
|
|
55
|
+
readonly 2: typeof import("../../../core/print/normalize-printer").normalizedAstToJson;
|
|
56
|
+
readonly 5: typeof import("../../../core/print/normalize-printer").normalizedAstToQuads;
|
|
57
|
+
readonly 3: typeof import("../../../core/print/normalize-printer").printNormalizedAstToMermaid;
|
|
58
|
+
readonly 4: typeof import("../../../core/print/normalize-printer").printNormalizedAstToMermaidUrl;
|
|
59
|
+
};
|
|
60
|
+
readonly dependencies: readonly ["parse"];
|
|
61
|
+
readonly requiredInput: import("../../../core/steps/all/core/10-normalize").NormalizeRequiredInput;
|
|
62
|
+
} | {
|
|
63
|
+
readonly humanReadableName: "dataflow";
|
|
64
|
+
readonly processor: (results: {
|
|
65
|
+
normalize?: import("../../../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
|
|
66
|
+
}, input: {
|
|
67
|
+
request?: import("../../../r-bridge/retriever").RParseRequests;
|
|
68
|
+
}) => import("../../../dataflow/info").DataflowInformation;
|
|
69
|
+
readonly requiredInput: {};
|
|
70
|
+
readonly name: "dataflow";
|
|
71
|
+
readonly description: "Construct the dataflow graph";
|
|
72
|
+
readonly executed: import("../../../core/steps/pipeline-step").PipelineStepStage.OncePerFile;
|
|
73
|
+
readonly printer: {
|
|
74
|
+
readonly 0: typeof import("../../../core/print/print").internalPrinter;
|
|
75
|
+
readonly 2: typeof import("../../../core/print/dataflow-printer").dataflowGraphToJson;
|
|
76
|
+
readonly 5: typeof import("../../../core/print/dataflow-printer").dataflowGraphToQuads;
|
|
77
|
+
readonly 3: typeof import("../../../core/print/dataflow-printer").dataflowGraphToMermaid;
|
|
78
|
+
readonly 4: typeof import("../../../core/print/dataflow-printer").dataflowGraphToMermaidUrl;
|
|
79
|
+
};
|
|
80
|
+
readonly dependencies: readonly ["normalize"];
|
|
81
|
+
}>>, queryResults: BaseQueryResult, result: string[]) => true;
|
|
82
|
+
readonly schema: Joi.ObjectSchema<any>;
|
|
83
|
+
};
|
|
@@ -1,3 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.StaticSliceQueryDefinition = void 0;
|
|
7
|
+
const ansi_1 = require("../../../util/ansi");
|
|
8
|
+
const time_1 = require("../../../util/time");
|
|
9
|
+
const joi_1 = __importDefault(require("joi"));
|
|
10
|
+
const static_slice_query_executor_1 = require("./static-slice-query-executor");
|
|
11
|
+
const query_print_1 = require("../../query-print");
|
|
12
|
+
exports.StaticSliceQueryDefinition = {
|
|
13
|
+
executor: static_slice_query_executor_1.executeStaticSliceClusterQuery,
|
|
14
|
+
asciiSummarizer: (formatter, _processed, queryResults, result) => {
|
|
15
|
+
const out = queryResults;
|
|
16
|
+
result.push(`Query: ${(0, ansi_1.bold)('static-slice', formatter)} (${(0, time_1.printAsMs)(out['.meta'].timing, 0)})`);
|
|
17
|
+
for (const [fingerprint, obj] of Object.entries(out.results)) {
|
|
18
|
+
const { criteria, noMagicComments, noReconstruction } = JSON.parse(fingerprint);
|
|
19
|
+
const addons = [];
|
|
20
|
+
if (noReconstruction) {
|
|
21
|
+
addons.push('no reconstruction');
|
|
22
|
+
}
|
|
23
|
+
if (noMagicComments) {
|
|
24
|
+
addons.push('no magic comments');
|
|
25
|
+
}
|
|
26
|
+
result.push(` ╰ Slice for {${criteria.join(', ')}} ${addons.join(', ')}`);
|
|
27
|
+
if ('reconstruct' in obj) {
|
|
28
|
+
result.push(' ╰ Code (newline as <code>\n</code>): <code>' + obj.reconstruct.code.split('\n').join('\\n') + '</code>');
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
result.push(` ╰ Id List: {${(0, query_print_1.summarizeIdsIfTooLong)(formatter, [...obj.slice.result])}}`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return true;
|
|
35
|
+
},
|
|
36
|
+
schema: joi_1.default.object({
|
|
37
|
+
type: joi_1.default.string().valid('static-slice').required().description('The type of the query.'),
|
|
38
|
+
criteria: joi_1.default.array().items(joi_1.default.string()).min(0).required().description('The slicing criteria to use.'),
|
|
39
|
+
noReconstruction: joi_1.default.boolean().optional().description('Do not reconstruct the slice into readable code.'),
|
|
40
|
+
noMagicComments: joi_1.default.boolean().optional().description('Should the magic comments (force-including lines within the slice) be ignored?')
|
|
41
|
+
}).description('Slice query used to slice the dataflow graph')
|
|
42
|
+
};
|
|
3
43
|
//# sourceMappingURL=static-slice-query-format.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { OutputFormatter } from '../util/ansi';
|
|
2
|
+
import type { QueryResults, SupportedQueryTypes } from './query';
|
|
3
|
+
import type { PipelineOutput } from '../core/steps/pipeline/pipeline';
|
|
4
|
+
import type { DEFAULT_DATAFLOW_PIPELINE } from '../core/steps/pipeline/default-pipelines';
|
|
5
|
+
import type { NodeId } from '../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
6
|
+
export declare function asciiCallContext(formatter: OutputFormatter, results: QueryResults<'call-context'>['call-context'], processed: PipelineOutput<typeof DEFAULT_DATAFLOW_PIPELINE>): string;
|
|
7
|
+
export declare function summarizeIdsIfTooLong(formatter: OutputFormatter, ids: readonly NodeId[]): string;
|
|
8
|
+
export declare function asciiSummaryOfQueryResult(formatter: OutputFormatter, totalInMs: number, results: QueryResults<SupportedQueryTypes>, processed: PipelineOutput<typeof DEFAULT_DATAFLOW_PIPELINE>): string;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.asciiCallContext = asciiCallContext;
|
|
4
|
+
exports.summarizeIdsIfTooLong = summarizeIdsIfTooLong;
|
|
5
|
+
exports.asciiSummaryOfQueryResult = asciiSummaryOfQueryResult;
|
|
6
|
+
const ansi_1 = require("../util/ansi");
|
|
7
|
+
const query_1 = require("./query");
|
|
8
|
+
const html_hover_over_1 = require("../util/html-hover-over");
|
|
9
|
+
const time_1 = require("../util/time");
|
|
10
|
+
const built_in_1 = require("../dataflow/environments/built-in");
|
|
11
|
+
function nodeString(id, formatter, processed) {
|
|
12
|
+
if (id === built_in_1.BuiltIn) {
|
|
13
|
+
return (0, ansi_1.italic)('built-in', formatter);
|
|
14
|
+
}
|
|
15
|
+
const node = processed.normalize.idMap.get(id);
|
|
16
|
+
if (node === undefined) {
|
|
17
|
+
return `UNKNOWN: ${id}`;
|
|
18
|
+
}
|
|
19
|
+
return `${(0, ansi_1.italic)('`' + (node.lexeme ?? node.info.fullLexeme ?? 'UNKNOWN') + '`', formatter)} (L.${node.location?.[0]})`;
|
|
20
|
+
}
|
|
21
|
+
function asciiCallContextSubHit(formatter, results, processed) {
|
|
22
|
+
const result = [];
|
|
23
|
+
for (const { id, calls = [], linkedIds = [], aliasRoots = [] } of results) {
|
|
24
|
+
const node = processed.normalize.idMap.get(id);
|
|
25
|
+
if (node === undefined) {
|
|
26
|
+
result.push(` ${(0, ansi_1.bold)('UNKNOWN: ' + JSON.stringify({ calls, linkedIds }))}`);
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
let line = nodeString(id, formatter, processed);
|
|
30
|
+
if (calls.length > 0) {
|
|
31
|
+
line += ` with ${calls.length} call${calls.length > 1 ? 's' : ''} (${calls.map(c => nodeString(c, formatter, processed)).join(', ')})`;
|
|
32
|
+
}
|
|
33
|
+
if (linkedIds.length > 0) {
|
|
34
|
+
line += ` with ${linkedIds.length} link${linkedIds.length > 1 ? 's' : ''} (${linkedIds.map(c => nodeString(c, formatter, processed)).join(', ')})`;
|
|
35
|
+
}
|
|
36
|
+
if (aliasRoots.length > 0) {
|
|
37
|
+
line += ` with ${aliasRoots.length} alias root${aliasRoots.length > 1 ? 's' : ''} (${aliasRoots.map(c => nodeString(c, formatter, processed)).join(', ')})`;
|
|
38
|
+
}
|
|
39
|
+
result.push(line);
|
|
40
|
+
}
|
|
41
|
+
return result.join(', ');
|
|
42
|
+
}
|
|
43
|
+
function asciiCallContext(formatter, results, processed) {
|
|
44
|
+
/* traverse over 'kinds' and within them 'subkinds' */
|
|
45
|
+
const result = [];
|
|
46
|
+
for (const [kind, { subkinds }] of Object.entries(results['kinds'])) {
|
|
47
|
+
result.push(` ╰ ${(0, ansi_1.bold)(kind, formatter)}`);
|
|
48
|
+
for (const [subkind, values] of Object.entries(subkinds)) {
|
|
49
|
+
result.push(` ╰ ${(0, ansi_1.bold)(subkind, formatter)}: ${asciiCallContextSubHit(formatter, values, processed)}`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return result.join('\n');
|
|
53
|
+
}
|
|
54
|
+
function summarizeIdsIfTooLong(formatter, ids) {
|
|
55
|
+
const naive = ids.join(', ');
|
|
56
|
+
if (naive.length <= 20) {
|
|
57
|
+
return naive;
|
|
58
|
+
}
|
|
59
|
+
let acc = '';
|
|
60
|
+
let i = 0;
|
|
61
|
+
while (acc.length <= 20) {
|
|
62
|
+
acc += ids[i++] + ', ';
|
|
63
|
+
}
|
|
64
|
+
if (i < ids.length) {
|
|
65
|
+
acc += '... (see JSON)';
|
|
66
|
+
}
|
|
67
|
+
return formatter === ansi_1.markdownFormatter ? (0, html_hover_over_1.textWithTooltip)(acc, JSON.stringify(ids)) : acc;
|
|
68
|
+
}
|
|
69
|
+
function asciiSummaryOfQueryResult(formatter, totalInMs, results, processed) {
|
|
70
|
+
const result = [];
|
|
71
|
+
for (const [query, queryResults] of Object.entries(results)) {
|
|
72
|
+
if (query === '.meta') {
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
const queryType = query_1.SupportedQueries[query];
|
|
76
|
+
if (queryType.asciiSummarizer(formatter, processed, queryResults, result)) {
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
result.push(`Query: ${(0, ansi_1.bold)(query, formatter)}`);
|
|
80
|
+
let timing = -1;
|
|
81
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
82
|
+
for (const [key, value] of Object.entries(queryResults)) {
|
|
83
|
+
if (key === '.meta') {
|
|
84
|
+
timing = value.timing;
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
result.push(` ╰ ${key}: ${JSON.stringify(value)}`);
|
|
88
|
+
}
|
|
89
|
+
result.push(` - Took ${(0, time_1.printAsMs)(timing, 0)}`);
|
|
90
|
+
}
|
|
91
|
+
result.push((0, ansi_1.italic)(`All queries together required ≈${(0, time_1.printAsMs)(results['.meta'].timing, 0)} (1ms accuracy, total ${(0, time_1.printAsMs)(totalInMs, 0)})`, formatter));
|
|
92
|
+
return formatter.format(result.join('\n'));
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=query-print.js.map
|