@eagleoutice/flowr 2.2.16 → 2.3.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 +35 -19
- package/abstract-interpretation/data-frame/absint-info.d.ts +109 -0
- package/abstract-interpretation/data-frame/absint-info.js +31 -0
- package/abstract-interpretation/data-frame/absint-visitor.d.ts +59 -0
- package/abstract-interpretation/data-frame/absint-visitor.js +173 -0
- package/abstract-interpretation/data-frame/domain.d.ts +107 -0
- package/abstract-interpretation/data-frame/domain.js +315 -0
- package/abstract-interpretation/data-frame/mappers/access-mapper.d.ts +17 -0
- package/abstract-interpretation/data-frame/mappers/access-mapper.js +166 -0
- package/abstract-interpretation/data-frame/mappers/arguments.d.ts +117 -0
- package/abstract-interpretation/data-frame/mappers/arguments.js +188 -0
- package/abstract-interpretation/data-frame/mappers/assignment-mapper.d.ts +20 -0
- package/abstract-interpretation/data-frame/mappers/assignment-mapper.js +34 -0
- package/abstract-interpretation/data-frame/mappers/function-mapper.d.ts +261 -0
- package/abstract-interpretation/data-frame/mappers/function-mapper.js +1219 -0
- package/abstract-interpretation/data-frame/mappers/replacement-mapper.d.ts +12 -0
- package/abstract-interpretation/data-frame/mappers/replacement-mapper.js +206 -0
- package/abstract-interpretation/data-frame/resolve-args.d.ts +42 -0
- package/abstract-interpretation/data-frame/resolve-args.js +118 -0
- package/abstract-interpretation/data-frame/semantics.d.ts +213 -0
- package/abstract-interpretation/data-frame/semantics.js +366 -0
- package/abstract-interpretation/data-frame/shape-inference.d.ts +38 -0
- package/abstract-interpretation/data-frame/shape-inference.js +117 -0
- package/benchmark/slicer.d.ts +15 -1
- package/benchmark/slicer.js +135 -0
- package/benchmark/stats/print.js +123 -45
- package/benchmark/stats/size-of.d.ts +7 -0
- package/benchmark/stats/size-of.js +1 -0
- package/benchmark/stats/stats.d.ts +30 -1
- package/benchmark/stats/stats.js +4 -2
- package/benchmark/summarizer/data.d.ts +33 -2
- package/benchmark/summarizer/first-phase/input.js +5 -1
- package/benchmark/summarizer/first-phase/process.js +47 -1
- package/benchmark/summarizer/second-phase/process.js +101 -3
- package/cli/benchmark-app.d.ts +1 -0
- package/cli/benchmark-app.js +1 -0
- package/cli/benchmark-helper-app.d.ts +1 -0
- package/cli/benchmark-helper-app.js +8 -2
- package/cli/common/options.js +2 -0
- package/config.d.ts +31 -0
- package/config.js +21 -1
- package/control-flow/control-flow-graph.d.ts +1 -0
- package/control-flow/control-flow-graph.js +4 -0
- package/control-flow/dfg-cfg-guided-visitor.js +1 -1
- package/control-flow/semantic-cfg-guided-visitor.d.ts +1 -1
- package/control-flow/semantic-cfg-guided-visitor.js +1 -1
- package/dataflow/environments/built-in.d.ts +5 -3
- package/dataflow/environments/built-in.js +3 -1
- package/dataflow/eval/resolve/alias-tracking.js +2 -2
- package/dataflow/eval/resolve/resolve.d.ts +53 -9
- package/dataflow/eval/resolve/resolve.js +132 -38
- package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +1 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +4 -0
- package/documentation/doc-util/doc-query.js +10 -0
- package/documentation/print-interface-wiki.js +11 -0
- package/documentation/print-linter-wiki.js +4 -0
- package/documentation/print-query-wiki.js +17 -0
- package/linter/linter-rules.d.ts +25 -2
- package/linter/linter-rules.js +3 -1
- package/linter/rules/absolute-path.d.ts +1 -1
- package/linter/rules/dataframe-access-validation.d.ts +53 -0
- package/linter/rules/dataframe-access-validation.js +116 -0
- package/linter/rules/naming-convention.d.ts +1 -1
- package/linter/rules/naming-convention.js +5 -1
- package/package.json +2 -2
- package/queries/catalog/df-shape-query/df-shape-query-executor.d.ts +3 -0
- package/queries/catalog/df-shape-query/df-shape-query-executor.js +46 -0
- package/queries/catalog/df-shape-query/df-shape-query-format.d.ts +72 -0
- package/queries/catalog/df-shape-query/df-shape-query-format.js +31 -0
- package/queries/query.d.ts +61 -1
- package/queries/query.js +2 -0
- package/util/files.d.ts +8 -2
- package/util/files.js +22 -4
- package/util/r-value.d.ts +23 -0
- package/util/r-value.js +113 -0
- package/util/version.js +1 -1
- package/util/cfg/cfg.d.ts +0 -0
- package/util/cfg/cfg.js +0 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eagleoutice/flowr",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Static Dataflow Analyzer and Program Slicer for the R Programming Language",
|
|
5
5
|
"types": "dist/src/index.d.ts",
|
|
6
6
|
"repository": {
|
|
@@ -176,7 +176,7 @@
|
|
|
176
176
|
"devDependencies": {
|
|
177
177
|
"@commitlint/cli": "^19.7.1",
|
|
178
178
|
"@commitlint/config-angular": "^19.7.1",
|
|
179
|
-
"@eagleoutice/eslint-config-flowr": "^1.0.
|
|
179
|
+
"@eagleoutice/eslint-config-flowr": "^1.0.19",
|
|
180
180
|
"@eslint/eslintrc": "^3.2.0",
|
|
181
181
|
"@eslint/js": "^9.20.0",
|
|
182
182
|
"@j-ulrich/release-it-regex-bumper": "^5.3.0",
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { DfShapeQuery, DfShapeQueryResult } from './df-shape-query-format';
|
|
2
|
+
import type { BasicQueryData } from '../../base-query-format';
|
|
3
|
+
export declare function executeDfShapeQuery({ dataflow: { graph }, ast, config }: BasicQueryData, queries: readonly DfShapeQuery[]): DfShapeQueryResult;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.executeDfShapeQuery = executeDfShapeQuery;
|
|
4
|
+
const log_1 = require("../../../util/log");
|
|
5
|
+
const extract_cfg_1 = require("../../../control-flow/extract-cfg");
|
|
6
|
+
const shape_inference_1 = require("../../../abstract-interpretation/data-frame/shape-inference");
|
|
7
|
+
const parse_1 = require("../../../slicing/criterion/parse");
|
|
8
|
+
function executeDfShapeQuery({ dataflow: { graph }, ast, config }, queries) {
|
|
9
|
+
if (queries.length !== 1 && queries.some(query => query.criterion === undefined)) {
|
|
10
|
+
log_1.log.warn('The dataframe shape query expects only up to one query without slicing criterion, but got', queries.length);
|
|
11
|
+
queries = [{ type: 'df-shape' }];
|
|
12
|
+
}
|
|
13
|
+
const start = Date.now();
|
|
14
|
+
const cfg = (0, extract_cfg_1.extractCfg)(ast, config, graph);
|
|
15
|
+
const domains = (0, shape_inference_1.inferDataFrameShapes)(cfg, graph, ast, config);
|
|
16
|
+
if (queries.length === 1 && queries[0].criterion === undefined) {
|
|
17
|
+
return {
|
|
18
|
+
'.meta': {
|
|
19
|
+
timing: Date.now() - start
|
|
20
|
+
},
|
|
21
|
+
domains: domains
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
const result = new Map();
|
|
25
|
+
for (const query of queries) {
|
|
26
|
+
if (query.criterion === undefined) {
|
|
27
|
+
log_1.log.warn('Missing criterion in dataframe shape query');
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
else if (result.has(query.criterion)) {
|
|
31
|
+
log_1.log.warn('Duplicate criterion in dataframe shape query:', query.criterion);
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
const nodeId = (0, parse_1.slicingCriterionToId)(query.criterion, ast.idMap);
|
|
35
|
+
const node = ast.idMap.get(nodeId);
|
|
36
|
+
const value = (0, shape_inference_1.resolveIdToDataFrameShape)(node?.info.id, graph);
|
|
37
|
+
result.set(query.criterion, value);
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
'.meta': {
|
|
41
|
+
timing: Date.now() - start
|
|
42
|
+
},
|
|
43
|
+
domains: result
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=df-shape-query-executor.js.map
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { BaseQueryFormat, BaseQueryResult } from '../../base-query-format';
|
|
2
|
+
import Joi from 'joi';
|
|
3
|
+
import type { DataFrameDomain, DataFrameStateDomain } from '../../../abstract-interpretation/data-frame/domain';
|
|
4
|
+
import { executeDfShapeQuery } from './df-shape-query-executor';
|
|
5
|
+
import type { SingleSlicingCriterion } from '../../../slicing/criterion/parse';
|
|
6
|
+
/** Infer the shape of data frames using abstract interpretation. */
|
|
7
|
+
export interface DfShapeQuery extends BaseQueryFormat {
|
|
8
|
+
readonly type: 'df-shape';
|
|
9
|
+
readonly criterion?: SingleSlicingCriterion;
|
|
10
|
+
}
|
|
11
|
+
export interface DfShapeQueryResult extends BaseQueryResult {
|
|
12
|
+
domains: DataFrameStateDomain | Map<SingleSlicingCriterion, DataFrameDomain | undefined>;
|
|
13
|
+
}
|
|
14
|
+
export declare const DfShapeQueryDefinition: {
|
|
15
|
+
readonly executor: typeof executeDfShapeQuery;
|
|
16
|
+
readonly asciiSummarizer: (formatter: import("../../../util/text/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("../../../r-bridge/parser").ParseRequiredInput<string>>) => Promise<import("../../../r-bridge/parser").ParseStepOutput<string>>;
|
|
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("../../../r-bridge/parser").ParseStepOutput<string>, config: import("../../../util/quads").QuadSerializationConfiguration) => string;
|
|
29
|
+
};
|
|
30
|
+
readonly dependencies: readonly [];
|
|
31
|
+
readonly requiredInput: import("../../../r-bridge/parser").ParseRequiredInput<string>;
|
|
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("../../../r-bridge/parser").ParseStepOutput<string>;
|
|
38
|
+
}, 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>>;
|
|
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?: import("../../../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
|
|
53
|
+
}, input: {
|
|
54
|
+
request?: import("../../../r-bridge/retriever").RParseRequests;
|
|
55
|
+
parser?: import("../../../r-bridge/parser").Parser<import("../../../r-bridge/parser").KnownParserType>;
|
|
56
|
+
}, config: import("../../../config").FlowrConfigOptions) => import("../../../dataflow/info").DataflowInformation;
|
|
57
|
+
readonly requiredInput: {};
|
|
58
|
+
readonly name: "dataflow";
|
|
59
|
+
readonly description: "Construct the dataflow graph";
|
|
60
|
+
readonly executed: import("../../../core/steps/pipeline-step").PipelineStepStage.OncePerFile;
|
|
61
|
+
readonly printer: {
|
|
62
|
+
readonly 0: typeof import("../../../core/print/print").internalPrinter;
|
|
63
|
+
readonly 2: typeof import("../../../core/print/dataflow-printer").dataflowGraphToJson;
|
|
64
|
+
readonly 5: typeof import("../../../core/print/dataflow-printer").dataflowGraphToQuads;
|
|
65
|
+
readonly 3: typeof import("../../../core/print/dataflow-printer").dataflowGraphToMermaid;
|
|
66
|
+
readonly 4: typeof import("../../../core/print/dataflow-printer").dataflowGraphToMermaidUrl;
|
|
67
|
+
};
|
|
68
|
+
readonly dependencies: readonly ["normalize"];
|
|
69
|
+
}>>, queryResults: BaseQueryResult, result: string[]) => true;
|
|
70
|
+
readonly schema: Joi.ObjectSchema<any>;
|
|
71
|
+
readonly flattenInvolvedNodes: () => never[];
|
|
72
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
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.DfShapeQueryDefinition = void 0;
|
|
7
|
+
const ansi_1 = require("../../../util/text/ansi");
|
|
8
|
+
const time_1 = require("../../../util/text/time");
|
|
9
|
+
const joi_1 = __importDefault(require("joi"));
|
|
10
|
+
const df_shape_query_executor_1 = require("./df-shape-query-executor");
|
|
11
|
+
const json_1 = require("../../../util/json");
|
|
12
|
+
exports.DfShapeQueryDefinition = {
|
|
13
|
+
executor: df_shape_query_executor_1.executeDfShapeQuery,
|
|
14
|
+
asciiSummarizer: (formatter, _processed, queryResults, result) => {
|
|
15
|
+
const out = queryResults;
|
|
16
|
+
result.push(`Query: ${(0, ansi_1.bold)('df-shape', formatter)} (${(0, time_1.printAsMs)(out['.meta'].timing, 0)})`);
|
|
17
|
+
result.push(...out.domains.entries().take(20).map(([key, domain]) => {
|
|
18
|
+
return ` ╰ ${key}: ${JSON.stringify(domain, json_1.jsonReplacer)}`;
|
|
19
|
+
}));
|
|
20
|
+
if (out.domains.size > 20) {
|
|
21
|
+
result.push(' ╰ ... (see JSON)');
|
|
22
|
+
}
|
|
23
|
+
return true;
|
|
24
|
+
},
|
|
25
|
+
schema: joi_1.default.object({
|
|
26
|
+
type: joi_1.default.string().valid('df-shape').required().description('The type of the query.'),
|
|
27
|
+
criterion: joi_1.default.string().optional().description('The slicing criterion of the node to get the dataframe shape for.')
|
|
28
|
+
}).description('The df-shape query retrieves information on the shape of dataframes'),
|
|
29
|
+
flattenInvolvedNodes: () => []
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=df-shape-query-format.js.map
|
package/queries/query.d.ts
CHANGED
|
@@ -24,7 +24,8 @@ import type { OriginQuery } from './catalog/origin-query/origin-query-format';
|
|
|
24
24
|
import type { LinterQuery } from './catalog/linter-query/linter-query-format';
|
|
25
25
|
import type { NodeId } from '../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
26
26
|
import type { ControlFlowQuery } from './catalog/control-flow-query/control-flow-query-format';
|
|
27
|
-
|
|
27
|
+
import type { DfShapeQuery } from './catalog/df-shape-query/df-shape-query-format';
|
|
28
|
+
export type Query = CallContextQuery | ConfigQuery | SearchQuery | DataflowQuery | ControlFlowQuery | DataflowLensQuery | DfShapeQuery | NormalizedAstQuery | IdMapQuery | DataflowClusterQuery | StaticSliceQuery | LineageQuery | DependenciesQuery | LocationMapQuery | HappensBeforeQuery | ResolveValueQuery | ProjectQuery | OriginQuery | LinterQuery;
|
|
28
29
|
export type QueryArgumentsWithType<QueryType extends BaseQueryFormat['type']> = Query & {
|
|
29
30
|
type: QueryType;
|
|
30
31
|
};
|
|
@@ -232,6 +233,65 @@ export declare const SupportedQueries: {
|
|
|
232
233
|
readonly schema: Joi.ObjectSchema<any>;
|
|
233
234
|
readonly flattenInvolvedNodes: () => never[];
|
|
234
235
|
};
|
|
236
|
+
readonly 'df-shape': {
|
|
237
|
+
readonly executor: typeof import("./catalog/df-shape-query/df-shape-query-executor").executeDfShapeQuery;
|
|
238
|
+
readonly asciiSummarizer: (formatter: OutputFormatter, _processed: PipelineOutput<import("../core/steps/pipeline/pipeline").Pipeline<{
|
|
239
|
+
readonly name: "parse";
|
|
240
|
+
readonly humanReadableName: "parse with R shell";
|
|
241
|
+
readonly description: "Parse the given R code into an AST";
|
|
242
|
+
readonly processor: (_results: unknown, input: Partial<import("../r-bridge/parser").ParseRequiredInput<string>>) => Promise<import("../r-bridge/parser").ParseStepOutput<string>>;
|
|
243
|
+
readonly executed: import("../core/steps/pipeline-step").PipelineStepStage.OncePerFile;
|
|
244
|
+
readonly printer: {
|
|
245
|
+
readonly 0: typeof import("../core/print/print").internalPrinter;
|
|
246
|
+
readonly 2: {
|
|
247
|
+
(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string;
|
|
248
|
+
(value: any, replacer?: (number | string)[] | null, space?: string | number): string;
|
|
249
|
+
};
|
|
250
|
+
readonly 5: ({ parsed }: import("../r-bridge/parser").ParseStepOutput<string>, config: import("../util/quads").QuadSerializationConfiguration) => string;
|
|
251
|
+
};
|
|
252
|
+
readonly dependencies: readonly [];
|
|
253
|
+
readonly requiredInput: import("../r-bridge/parser").ParseRequiredInput<string>;
|
|
254
|
+
} | {
|
|
255
|
+
readonly name: "normalize";
|
|
256
|
+
readonly humanReadableName: "normalize";
|
|
257
|
+
readonly description: "Normalize the AST to flowR's AST";
|
|
258
|
+
readonly processor: (results: {
|
|
259
|
+
parse?: import("../r-bridge/parser").ParseStepOutput<string>;
|
|
260
|
+
}, 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>>;
|
|
261
|
+
readonly executed: import("../core/steps/pipeline-step").PipelineStepStage.OncePerFile;
|
|
262
|
+
readonly printer: {
|
|
263
|
+
readonly 0: typeof import("../core/print/print").internalPrinter;
|
|
264
|
+
readonly 2: typeof import("../core/print/normalize-printer").normalizedAstToJson;
|
|
265
|
+
readonly 5: typeof import("../core/print/normalize-printer").normalizedAstToQuads;
|
|
266
|
+
readonly 3: typeof import("../core/print/normalize-printer").printNormalizedAstToMermaid;
|
|
267
|
+
readonly 4: typeof import("../core/print/normalize-printer").printNormalizedAstToMermaidUrl;
|
|
268
|
+
};
|
|
269
|
+
readonly dependencies: readonly ["parse"];
|
|
270
|
+
readonly requiredInput: import("../core/steps/all/core/10-normalize").NormalizeRequiredInput;
|
|
271
|
+
} | {
|
|
272
|
+
readonly humanReadableName: "dataflow";
|
|
273
|
+
readonly processor: (results: {
|
|
274
|
+
normalize?: import("../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
|
|
275
|
+
}, input: {
|
|
276
|
+
request?: import("../r-bridge/retriever").RParseRequests;
|
|
277
|
+
parser?: import("../r-bridge/parser").Parser<import("../r-bridge/parser").KnownParserType>;
|
|
278
|
+
}, config: import("../config").FlowrConfigOptions) => import("../dataflow/info").DataflowInformation;
|
|
279
|
+
readonly requiredInput: {};
|
|
280
|
+
readonly name: "dataflow";
|
|
281
|
+
readonly description: "Construct the dataflow graph";
|
|
282
|
+
readonly executed: import("../core/steps/pipeline-step").PipelineStepStage.OncePerFile;
|
|
283
|
+
readonly printer: {
|
|
284
|
+
readonly 0: typeof import("../core/print/print").internalPrinter;
|
|
285
|
+
readonly 2: typeof import("../core/print/dataflow-printer").dataflowGraphToJson;
|
|
286
|
+
readonly 5: typeof import("../core/print/dataflow-printer").dataflowGraphToQuads;
|
|
287
|
+
readonly 3: typeof import("../core/print/dataflow-printer").dataflowGraphToMermaid;
|
|
288
|
+
readonly 4: typeof import("../core/print/dataflow-printer").dataflowGraphToMermaidUrl;
|
|
289
|
+
};
|
|
290
|
+
readonly dependencies: readonly ["normalize"];
|
|
291
|
+
}>>, queryResults: BaseQueryResult, result: string[]) => true;
|
|
292
|
+
readonly schema: Joi.ObjectSchema<any>;
|
|
293
|
+
readonly flattenInvolvedNodes: () => never[];
|
|
294
|
+
};
|
|
235
295
|
readonly 'id-map': {
|
|
236
296
|
readonly executor: typeof import("./catalog/id-map-query/id-map-query-executor").executeIdMapQuery;
|
|
237
297
|
readonly asciiSummarizer: (formatter: OutputFormatter, _processed: PipelineOutput<import("../core/steps/pipeline/pipeline").Pipeline<{
|
package/queries/query.js
CHANGED
|
@@ -31,12 +31,14 @@ const project_query_format_1 = require("./catalog/project-query/project-query-fo
|
|
|
31
31
|
const origin_query_format_1 = require("./catalog/origin-query/origin-query-format");
|
|
32
32
|
const linter_query_format_1 = require("./catalog/linter-query/linter-query-format");
|
|
33
33
|
const control_flow_query_format_1 = require("./catalog/control-flow-query/control-flow-query-format");
|
|
34
|
+
const df_shape_query_format_1 = require("./catalog/df-shape-query/df-shape-query-format");
|
|
34
35
|
exports.SupportedQueries = {
|
|
35
36
|
'call-context': call_context_query_format_1.CallContextQueryDefinition,
|
|
36
37
|
'config': config_query_format_1.ConfigQueryDefinition,
|
|
37
38
|
'control-flow': control_flow_query_format_1.ControlFlowQueryDefinition,
|
|
38
39
|
'dataflow': dataflow_query_format_1.DataflowQueryDefinition,
|
|
39
40
|
'dataflow-lens': dataflow_lens_query_format_1.DataflowLensQueryDefinition,
|
|
41
|
+
'df-shape': df_shape_query_format_1.DfShapeQueryDefinition,
|
|
40
42
|
'id-map': id_map_query_format_1.IdMapQueryDefinition,
|
|
41
43
|
'normalized-ast': normalized_ast_query_format_1.NormalizedAstQueryDefinition,
|
|
42
44
|
'dataflow-cluster': cluster_query_format_1.ClusterQueryDefinition,
|
package/util/files.d.ts
CHANGED
|
@@ -40,17 +40,23 @@ export declare function writeTableAsCsv(table: Table, file: string, sep?: string
|
|
|
40
40
|
/**
|
|
41
41
|
* Reads a file line by line and calls the given function for each line.
|
|
42
42
|
* The `lineNumber` starts at `0`.
|
|
43
|
+
* The `maxLines` option limits the maximum number of read lines and is `Infinity` by default.
|
|
44
|
+
*
|
|
45
|
+
* @returns Whether all lines have been successfully read (`false` if `maxLines` was reached)
|
|
43
46
|
*
|
|
44
47
|
* See {@link readLineByLineSync} for a synchronous version.
|
|
45
48
|
*/
|
|
46
|
-
export declare function readLineByLine(filePath: string, onLine: (line: Buffer, lineNumber: number) => Promise<void
|
|
49
|
+
export declare function readLineByLine(filePath: string, onLine: (line: Buffer, lineNumber: number) => Promise<void>, maxLines?: number): Promise<boolean>;
|
|
47
50
|
/**
|
|
48
51
|
* Reads a file line by line and calls the given function for each line.
|
|
49
52
|
* The `lineNumber` starts at `0`.
|
|
53
|
+
* The `maxLines` option limits the maximum number of read lines and is `Infinity` by default.
|
|
54
|
+
*
|
|
55
|
+
* @returns Whether the file exists and all lines have been successfully read (`false` if `maxLines` was reached)
|
|
50
56
|
*
|
|
51
57
|
* See {@link readLineByLine} for an asynchronous version.
|
|
52
58
|
*/
|
|
53
|
-
export declare function readLineByLineSync(filePath: string, onLine: (line: Buffer, lineNumber: number) => void):
|
|
59
|
+
export declare function readLineByLineSync(filePath: string, onLine: (line: Buffer, lineNumber: number) => void, maxLines?: number): boolean;
|
|
54
60
|
/**
|
|
55
61
|
* Chops off the last part of the given directory path after a path separator, essentially returning the path's parent directory.
|
|
56
62
|
* If an absolute path is passed, the returned path is also absolute.
|
package/util/files.js
CHANGED
|
@@ -124,36 +124,54 @@ function writeTableAsCsv(table, file, sep = ',', newline = '\n') {
|
|
|
124
124
|
/**
|
|
125
125
|
* Reads a file line by line and calls the given function for each line.
|
|
126
126
|
* The `lineNumber` starts at `0`.
|
|
127
|
+
* The `maxLines` option limits the maximum number of read lines and is `Infinity` by default.
|
|
128
|
+
*
|
|
129
|
+
* @returns Whether all lines have been successfully read (`false` if `maxLines` was reached)
|
|
127
130
|
*
|
|
128
131
|
* See {@link readLineByLineSync} for a synchronous version.
|
|
129
132
|
*/
|
|
130
|
-
async function readLineByLine(filePath, onLine) {
|
|
133
|
+
async function readLineByLine(filePath, onLine, maxLines = Infinity) {
|
|
134
|
+
if (!(await fs_1.default.promises.stat(filePath).catch(() => { }))?.isFile()) {
|
|
135
|
+
log_1.log.warn(`File ${filePath} does not exist`);
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
131
138
|
const reader = new n_readlines_1.default(filePath);
|
|
132
139
|
let line;
|
|
133
140
|
let counter = 0;
|
|
134
141
|
// eslint-disable-next-line no-cond-assign
|
|
135
142
|
while (line = reader.next()) {
|
|
143
|
+
if (counter >= maxLines) {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
136
146
|
await onLine(line, counter++);
|
|
137
147
|
}
|
|
148
|
+
return true;
|
|
138
149
|
}
|
|
139
150
|
/**
|
|
140
151
|
* Reads a file line by line and calls the given function for each line.
|
|
141
152
|
* The `lineNumber` starts at `0`.
|
|
153
|
+
* The `maxLines` option limits the maximum number of read lines and is `Infinity` by default.
|
|
154
|
+
*
|
|
155
|
+
* @returns Whether the file exists and all lines have been successfully read (`false` if `maxLines` was reached)
|
|
142
156
|
*
|
|
143
157
|
* See {@link readLineByLine} for an asynchronous version.
|
|
144
158
|
*/
|
|
145
|
-
function readLineByLineSync(filePath, onLine) {
|
|
146
|
-
if (!fs_1.default.
|
|
159
|
+
function readLineByLineSync(filePath, onLine, maxLines = Infinity) {
|
|
160
|
+
if (!fs_1.default.statSync(filePath, { throwIfNoEntry: false })?.isFile()) {
|
|
147
161
|
log_1.log.warn(`File ${filePath} does not exist`);
|
|
148
|
-
return;
|
|
162
|
+
return false;
|
|
149
163
|
}
|
|
150
164
|
const reader = new n_readlines_1.default(filePath);
|
|
151
165
|
let line;
|
|
152
166
|
let counter = 0;
|
|
153
167
|
// eslint-disable-next-line no-cond-assign
|
|
154
168
|
while (line = reader.next()) {
|
|
169
|
+
if (counter >= maxLines) {
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
155
172
|
onLine(line, counter++);
|
|
156
173
|
}
|
|
174
|
+
return true;
|
|
157
175
|
}
|
|
158
176
|
/**
|
|
159
177
|
* Chops off the last part of the given directory path after a path separator, essentially returning the path's parent directory.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Value, ValueInterval, ValueLogical, ValueNumber, ValueString, ValueVector } from '../dataflow/eval/values/r-value';
|
|
2
|
+
import type { RLogicalValue } from '../r-bridge/lang-4.x/ast/model/nodes/r-logical';
|
|
3
|
+
import { type RNumberValue, type RStringValue } from '../r-bridge/lang-4.x/convert-values';
|
|
4
|
+
export declare function isRStringValue(value: unknown): value is RStringValue;
|
|
5
|
+
export declare function isRNumberValue(value: unknown): value is RNumberValue;
|
|
6
|
+
export declare function isRLogicalValue(value: unknown): value is RLogicalValue;
|
|
7
|
+
export declare function unwrapRValue(value: RStringValue | string): string;
|
|
8
|
+
export declare function unwrapRValue(value: RNumberValue | number): number;
|
|
9
|
+
export declare function unwrapRValue(value: RLogicalValue): boolean;
|
|
10
|
+
export declare function unwrapRValue(value: RStringValue | RNumberValue | RLogicalValue | string | number): string | number | boolean;
|
|
11
|
+
export declare function unwrapRValue(value: unknown): string | number | boolean | undefined;
|
|
12
|
+
export declare function unwrapRVector(value: RStringValue[] | string[]): string[];
|
|
13
|
+
export declare function unwrapRVector(value: RNumberValue[] | number[]): number[];
|
|
14
|
+
export declare function unwrapRVector(value: RLogicalValue[]): boolean[];
|
|
15
|
+
export declare function unwrapRVector(value: RStringValue[] | RNumberValue[] | RLogicalValue[] | string[] | number[]): string[] | number[] | boolean[];
|
|
16
|
+
export declare function unwrapRVector(value: unknown): string[] | number[] | boolean[] | (string | number | boolean)[] | undefined;
|
|
17
|
+
export declare function unwrapRValueToString(value: RStringValue | RNumberValue | RLogicalValue | string | number): string;
|
|
18
|
+
export declare function unwrapRValueToString(value: unknown): string | undefined;
|
|
19
|
+
export declare function unliftRValue(value: ValueString): RStringValue | undefined;
|
|
20
|
+
export declare function unliftRValue(value: ValueNumber | ValueInterval): RNumberValue | undefined;
|
|
21
|
+
export declare function unliftRValue(value: ValueLogical): RLogicalValue | undefined;
|
|
22
|
+
export declare function unliftRValue(value: ValueVector): (RStringValue | RNumberValue | RLogicalValue)[] | undefined;
|
|
23
|
+
export declare function unliftRValue(value: Value): RStringValue | RNumberValue | boolean | (RStringValue | RNumberValue | RLogicalValue)[] | undefined;
|
package/util/r-value.js
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isRStringValue = isRStringValue;
|
|
4
|
+
exports.isRNumberValue = isRNumberValue;
|
|
5
|
+
exports.isRLogicalValue = isRLogicalValue;
|
|
6
|
+
exports.unwrapRValue = unwrapRValue;
|
|
7
|
+
exports.unwrapRVector = unwrapRVector;
|
|
8
|
+
exports.unwrapRValueToString = unwrapRValueToString;
|
|
9
|
+
exports.unliftRValue = unliftRValue;
|
|
10
|
+
const r_value_1 = require("../dataflow/eval/values/r-value");
|
|
11
|
+
const convert_values_1 = require("../r-bridge/lang-4.x/convert-values");
|
|
12
|
+
const assert_1 = require("./assert");
|
|
13
|
+
function isRValue(value) {
|
|
14
|
+
return isRStringValue(value) || isRNumberValue(value) || isRLogicalValue(value) || typeof value === 'string' || typeof value === 'number';
|
|
15
|
+
}
|
|
16
|
+
function isRStringValue(value) {
|
|
17
|
+
return typeof value === 'object' && value !== null && 'str' in value && typeof value.str === 'string';
|
|
18
|
+
}
|
|
19
|
+
function isRNumberValue(value) {
|
|
20
|
+
return typeof value === 'object' && value !== null && 'num' in value && typeof value.num === 'number';
|
|
21
|
+
}
|
|
22
|
+
function isRLogicalValue(value) {
|
|
23
|
+
return typeof value === 'boolean';
|
|
24
|
+
}
|
|
25
|
+
function unwrapRValue(value) {
|
|
26
|
+
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
27
|
+
return value;
|
|
28
|
+
}
|
|
29
|
+
else if (isRStringValue(value)) {
|
|
30
|
+
return value.str;
|
|
31
|
+
}
|
|
32
|
+
else if (isRNumberValue(value)) {
|
|
33
|
+
return value.num;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function unwrapRVector(value) {
|
|
40
|
+
if (!Array.isArray(value)) {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
else if (value.every(entry => typeof entry === 'string') || value.every(entry => typeof entry === 'number') || value.every(entry => typeof entry === 'boolean')) {
|
|
44
|
+
return value;
|
|
45
|
+
}
|
|
46
|
+
else if (value.every(isRStringValue)) {
|
|
47
|
+
return value.map(entry => unwrapRValue(entry));
|
|
48
|
+
}
|
|
49
|
+
else if (value.every(isRNumberValue)) {
|
|
50
|
+
return value.map(entry => unwrapRValue(entry));
|
|
51
|
+
}
|
|
52
|
+
else if (value.every(isRValue)) {
|
|
53
|
+
return value.map(entry => unwrapRValue(entry));
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function unwrapRValueToString(value) {
|
|
60
|
+
if (typeof value === 'string') {
|
|
61
|
+
return value;
|
|
62
|
+
}
|
|
63
|
+
else if (typeof value === 'number') {
|
|
64
|
+
return value.toString();
|
|
65
|
+
}
|
|
66
|
+
else if (typeof value === 'boolean') {
|
|
67
|
+
return value ? convert_values_1.RTrue : convert_values_1.RFalse;
|
|
68
|
+
}
|
|
69
|
+
else if (isRStringValue(value)) {
|
|
70
|
+
return value.str;
|
|
71
|
+
}
|
|
72
|
+
else if (isRNumberValue(value)) {
|
|
73
|
+
return value.num.toString();
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function unliftRValue(value) {
|
|
80
|
+
if (!(0, r_value_1.isValue)(value)) {
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
const type = value.type;
|
|
84
|
+
switch (type) {
|
|
85
|
+
case 'string': {
|
|
86
|
+
return (0, r_value_1.isValue)(value.value) ? value.value : undefined;
|
|
87
|
+
}
|
|
88
|
+
case 'number': {
|
|
89
|
+
return (0, r_value_1.isValue)(value.value) ? value.value : undefined;
|
|
90
|
+
}
|
|
91
|
+
case 'logical': {
|
|
92
|
+
return (0, r_value_1.isValue)(value.value) && typeof value.value === 'boolean' ? value.value : undefined;
|
|
93
|
+
}
|
|
94
|
+
case 'interval': {
|
|
95
|
+
const start = unliftRValue(value.start);
|
|
96
|
+
const end = unliftRValue(value.end);
|
|
97
|
+
return start !== undefined && end !== undefined && start.num === end.num ? start : undefined;
|
|
98
|
+
}
|
|
99
|
+
case 'vector': {
|
|
100
|
+
const values = (0, r_value_1.isValue)(value.elements) ? value.elements.map(unliftRValue) : undefined;
|
|
101
|
+
return values?.every(assert_1.isNotUndefined) ? values.flat() : undefined;
|
|
102
|
+
}
|
|
103
|
+
case 'set': {
|
|
104
|
+
return (0, r_value_1.isValue)(value.elements) && value.elements.length === 1 ? unliftRValue(value.elements[0]) : undefined;
|
|
105
|
+
}
|
|
106
|
+
case 'missing': {
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
109
|
+
default:
|
|
110
|
+
(0, assert_1.assertUnreachable)(type);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=r-value.js.map
|
package/util/version.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.flowrVersion = flowrVersion;
|
|
4
4
|
const semver_1 = require("semver");
|
|
5
5
|
// this is automatically replaced with the current version by release-it
|
|
6
|
-
const version = '2.
|
|
6
|
+
const version = '2.3.0';
|
|
7
7
|
function flowrVersion() {
|
|
8
8
|
return new semver_1.SemVer(version);
|
|
9
9
|
}
|
package/util/cfg/cfg.d.ts
DELETED
|
File without changes
|
package/util/cfg/cfg.js
DELETED