@eagleoutice/flowr 2.7.5 → 2.8.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 +68 -65
- package/cli/wiki.js +1 -1
- package/control-flow/extract-cfg.js +3 -3
- package/control-flow/useless-loop.d.ts +1 -1
- package/control-flow/useless-loop.js +2 -2
- package/dataflow/cluster.js +3 -3
- package/dataflow/environments/built-in-config.d.ts +8 -4
- package/dataflow/environments/built-in.d.ts +27 -14
- package/dataflow/environments/built-in.js +27 -12
- package/dataflow/environments/default-builtin-config.d.ts +614 -3
- package/dataflow/environments/default-builtin-config.js +50 -15
- package/dataflow/environments/environment.js +3 -2
- package/dataflow/environments/identifier.d.ts +5 -1
- package/dataflow/environments/reference-to-maybe.d.ts +2 -2
- package/dataflow/environments/reference-to-maybe.js +23 -14
- package/dataflow/environments/resolve-by-name.d.ts +6 -2
- package/dataflow/environments/resolve-by-name.js +5 -1
- package/dataflow/environments/scoping.js +1 -3
- package/dataflow/eval/resolve/alias-tracking.js +5 -1
- package/dataflow/extractor.js +3 -3
- package/dataflow/fn/exceptions-of-function.d.ts +13 -0
- package/dataflow/fn/exceptions-of-function.js +47 -0
- package/dataflow/fn/higher-order-function.d.ts +1 -1
- package/dataflow/fn/higher-order-function.js +3 -3
- package/dataflow/fn/recursive-function.d.ts +6 -0
- package/dataflow/fn/recursive-function.js +32 -0
- package/dataflow/graph/call-graph.d.ts +10 -0
- package/dataflow/graph/call-graph.js +209 -0
- package/dataflow/graph/dataflowgraph-builder.d.ts +7 -2
- package/dataflow/graph/dataflowgraph-builder.js +14 -9
- package/dataflow/graph/diff-dataflow-graph.js +96 -2
- package/dataflow/graph/graph.d.ts +10 -7
- package/dataflow/graph/graph.js +7 -8
- package/dataflow/graph/vertex.d.ts +6 -3
- package/dataflow/hooks.d.ts +30 -0
- package/dataflow/hooks.js +38 -0
- package/dataflow/info.d.ts +28 -5
- package/dataflow/info.js +66 -31
- package/dataflow/internal/linker.d.ts +13 -3
- package/dataflow/internal/linker.js +155 -53
- package/dataflow/internal/process/functions/call/argument/unpack-argument.d.ts +4 -0
- package/dataflow/internal/process/functions/call/argument/unpack-argument.js +7 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +19 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +14 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +30 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +24 -17
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +5 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +59 -21
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +4 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.d.ts +34 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.js +92 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +1 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-stop-if-not.d.ts +21 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-stop-if-not.js +129 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +16 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +127 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +5 -3
- package/dataflow/internal/process/functions/call/common.d.ts +13 -1
- package/dataflow/internal/process/functions/call/common.js +33 -2
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +13 -1
- package/dataflow/internal/process/functions/call/known-call-handling.js +29 -3
- package/dataflow/internal/process/functions/call/named-call-handling.js +2 -1
- package/dataflow/internal/process/functions/call/unnamed-call-handling.js +6 -4
- package/dataflow/internal/process/functions/process-argument.js +7 -6
- package/dataflow/internal/process/functions/process-parameter.js +2 -1
- package/dataflow/internal/process/process-named-call.d.ts +2 -2
- package/dataflow/internal/process/process-symbol.js +3 -2
- package/dataflow/internal/process/process-value.d.ts +3 -2
- package/dataflow/internal/process/process-value.js +8 -6
- package/dataflow/origin/dfg-get-origin.js +2 -1
- package/dataflow/origin/dfg-get-symbol-refs.js +1 -1
- package/documentation/doc-readme.d.ts +1 -1
- package/documentation/doc-readme.js +6 -6
- package/documentation/doc-util/doc-code.js +1 -1
- package/documentation/doc-util/doc-dfg.d.ts +1 -0
- package/documentation/doc-util/doc-dfg.js +7 -4
- package/documentation/doc-util/doc-query.d.ts +1 -0
- package/documentation/doc-util/doc-query.js +1 -1
- package/documentation/doc-util/doc-repl.d.ts +2 -1
- package/documentation/doc-util/doc-repl.js +11 -3
- package/documentation/wiki-analyzer.js +2 -0
- package/documentation/wiki-dataflow-graph.js +59 -16
- package/documentation/wiki-interface.js +33 -5
- package/documentation/wiki-mk/doc-context.d.ts +2 -1
- package/documentation/wiki-mk/doc-context.js +2 -2
- package/documentation/wiki-mk/doc-maker.js +4 -3
- package/documentation/wiki-normalized-ast.js +6 -0
- package/documentation/wiki-query.js +109 -1
- package/linter/linter-rules.d.ts +1 -1
- package/linter/rules/seeded-randomness.js +17 -12
- package/linter/rules/useless-loop.d.ts +1 -1
- package/package.json +9 -11
- package/project/cache/flowr-analyzer-cache.d.ts +11 -0
- package/project/cache/flowr-analyzer-cache.js +19 -0
- package/project/context/flowr-analyzer-dependencies-context.d.ts +6 -1
- package/project/context/flowr-analyzer-dependencies-context.js +6 -0
- package/project/context/flowr-analyzer-files-context.d.ts +5 -2
- package/project/context/flowr-analyzer-files-context.js +24 -17
- package/project/context/flowr-file.d.ts +9 -4
- package/project/context/flowr-file.js +20 -6
- package/project/flowr-analyzer.d.ts +11 -0
- package/project/flowr-analyzer.js +6 -0
- package/project/plugins/file-plugins/files/flowr-description-file.d.ts +11 -3
- package/project/plugins/file-plugins/files/flowr-description-file.js +38 -28
- package/project/plugins/file-plugins/files/flowr-jupyter-file.js +1 -1
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +1 -1
- package/project/plugins/file-plugins/files/flowr-news-file.js +1 -1
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.js +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-file-plugin.d.ts +4 -1
- package/project/plugins/file-plugins/flowr-analyzer-file-plugin.js +3 -0
- package/project/plugins/file-plugins/{flowr-analyzer-namespace-file-plugin.d.ts → flowr-analyzer-namespace-files-plugin.d.ts} +1 -1
- package/project/plugins/file-plugins/{flowr-analyzer-namespace-file-plugin.js → flowr-analyzer-namespace-files-plugin.js} +4 -4
- package/project/plugins/file-plugins/flowr-analyzer-test-file-plugin.d.ts +26 -0
- package/project/plugins/file-plugins/flowr-analyzer-test-file-plugin.js +39 -0
- package/project/plugins/file-plugins/flowr-analyzer-vignette-file-plugin.d.ts +26 -0
- package/project/plugins/file-plugins/flowr-analyzer-vignette-file-plugin.js +39 -0
- package/project/plugins/flowr-analyzer-plugin-defaults.js +6 -2
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.js +3 -13
- package/project/plugins/package-version-plugins/package.d.ts +1 -1
- package/project/plugins/package-version-plugins/package.js +3 -3
- package/project/plugins/plugin-registry.d.ts +4 -2
- package/project/plugins/plugin-registry.js +6 -2
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.d.ts +11 -0
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +5 -2
- package/queries/catalog/call-context-query/call-context-query-format.d.ts +4 -12
- package/queries/catalog/call-graph-query/call-graph-query-executor.d.ts +6 -0
- package/queries/catalog/call-graph-query/call-graph-query-executor.js +21 -0
- package/queries/catalog/call-graph-query/call-graph-query-format.d.ts +21 -0
- package/queries/catalog/call-graph-query/call-graph-query-format.js +32 -0
- package/queries/catalog/dataflow-query/dataflow-query-executor.js +4 -3
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +29 -3
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +1 -0
- package/queries/catalog/dependencies-query/function-info/function-info.d.ts +8 -1
- package/queries/catalog/dependencies-query/function-info/write-functions.js +13 -0
- package/queries/catalog/does-call-query/does-call-query-executor.d.ts +6 -0
- package/queries/catalog/does-call-query/does-call-query-executor.js +100 -0
- package/queries/catalog/does-call-query/does-call-query-format.d.ts +51 -0
- package/queries/catalog/does-call-query/does-call-query-format.js +102 -0
- package/queries/catalog/files-query/files-query-executor.js +4 -4
- package/queries/catalog/files-query/files-query-format.d.ts +2 -1
- package/queries/catalog/files-query/files-query-format.js +18 -2
- package/queries/catalog/id-map-query/id-map-query-executor.js +4 -3
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.d.ts +18 -0
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.js +56 -0
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.d.ts +34 -0
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +54 -0
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +3 -28
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +6 -0
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +12 -0
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.d.ts +6 -0
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.js +23 -0
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.d.ts +28 -0
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.js +44 -0
- package/queries/catalog/linter-query/linter-query-format.js +4 -1
- package/queries/catalog/location-map-query/location-map-query-executor.js +1 -1
- package/queries/catalog/normalized-ast-query/normalized-ast-query-executor.js +4 -3
- package/queries/catalog/project-query/project-query-executor.js +9 -3
- package/queries/catalog/project-query/project-query-format.d.ts +8 -3
- package/queries/catalog/project-query/project-query-format.js +35 -9
- package/queries/query.d.ts +34 -2
- package/queries/query.js +9 -0
- package/r-bridge/data/data.d.ts +10 -5
- package/r-bridge/data/data.js +11 -5
- package/r-bridge/lang-4.x/ast/model/model.d.ts +7 -7
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +2 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +2 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +2 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +5 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.js +8 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +2 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +2 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +3 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +2 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +2 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +2 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +2 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +2 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +2 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +2 -2
- package/r-bridge/lang-4.x/ast/parser/main/internal/other/normalize-comment.js +0 -1
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +0 -2
- package/r-bridge/roxygen2/roxygen-ast.d.ts +218 -0
- package/r-bridge/roxygen2/roxygen-ast.js +82 -0
- package/r-bridge/roxygen2/roxygen-parse.d.ts +24 -0
- package/r-bridge/roxygen2/roxygen-parse.js +214 -0
- package/reconstruct/auto-select/magic-comments.js +4 -4
- package/slicing/static/slice-call.js +3 -4
- package/slicing/static/static-slicer.js +2 -2
- package/statistics/features/supported/defined-functions/defined-functions.js +1 -1
- package/util/collections/defaultmap.d.ts +3 -3
- package/util/mermaid/dfg.js +5 -5
- package/util/objects.js +1 -1
- package/util/r-author.d.ts +5 -0
- package/util/r-author.js +110 -0
- package/util/r-license.d.ts +32 -0
- package/util/r-license.js +217 -0
- package/util/r-version.d.ts +19 -0
- package/util/r-version.js +106 -0
- package/util/range.d.ts +6 -0
- package/util/range.js +7 -0
- package/util/simple-df/dfg-ascii.js +2 -2
- package/util/text/args.d.ts +9 -0
- package/util/text/args.js +65 -0
- package/util/version.js +1 -1
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getFunctionsToConsiderInCallGraph = getFunctionsToConsiderInCallGraph;
|
|
4
|
+
exports.executeExceptionQuery = executeExceptionQuery;
|
|
5
|
+
const parse_1 = require("../../../slicing/criterion/parse");
|
|
6
|
+
const vertex_1 = require("../../../dataflow/graph/vertex");
|
|
7
|
+
const exceptions_of_function_1 = require("../../../dataflow/fn/exceptions-of-function");
|
|
8
|
+
/**
|
|
9
|
+
* Get the functions to consider in the call graph based on the given queries.
|
|
10
|
+
*/
|
|
11
|
+
async function getFunctionsToConsiderInCallGraph(queries, analyzer, onlyDefinitions = true) {
|
|
12
|
+
let filters = undefined;
|
|
13
|
+
// filter will remain undefined if at least one of the queries wants all functions
|
|
14
|
+
for (const q of queries) {
|
|
15
|
+
if (q.filter === undefined) {
|
|
16
|
+
filters = undefined;
|
|
17
|
+
break;
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
filters ??= [];
|
|
21
|
+
filters = filters.concat(q.filter);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const ast = await analyzer.normalize();
|
|
25
|
+
const filterFor = new Set();
|
|
26
|
+
if (filters) {
|
|
27
|
+
for (const f of filters) {
|
|
28
|
+
const i = (0, parse_1.tryResolveSliceCriterionToId)(f, ast.idMap);
|
|
29
|
+
if (i !== undefined) {
|
|
30
|
+
filterFor.add(i);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const cg = await analyzer.callGraph();
|
|
35
|
+
const fns = (onlyDefinitions || filterFor.size === 0 ? cg.verticesOfType(vertex_1.VertexType.FunctionDefinition) : cg.vertices(true))
|
|
36
|
+
.filter(([, v]) => filterFor.size === 0 || filterFor.has(v.id));
|
|
37
|
+
return { cg, fns };
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Execute exception function inspection queries on the given analyzer.
|
|
41
|
+
*/
|
|
42
|
+
async function executeExceptionQuery({ analyzer }, queries) {
|
|
43
|
+
const start = Date.now();
|
|
44
|
+
const { cg, fns } = await getFunctionsToConsiderInCallGraph(queries, analyzer);
|
|
45
|
+
const result = {};
|
|
46
|
+
for (const [id,] of fns) {
|
|
47
|
+
result[id] = (0, exceptions_of_function_1.calculateExceptionsOfFunction)(id, cg);
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
'.meta': {
|
|
51
|
+
timing: Date.now() - start
|
|
52
|
+
},
|
|
53
|
+
exceptions: result
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=inspect-exception-query-executor.js.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { BaseQueryFormat, BaseQueryResult } from '../../base-query-format';
|
|
2
|
+
import Joi from 'joi';
|
|
3
|
+
import type { ParsedQueryLine } from '../../query';
|
|
4
|
+
import { executeExceptionQuery } from './inspect-exception-query-executor';
|
|
5
|
+
import { type NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
6
|
+
import type { ReplOutput } from '../../../cli/repl/commands/repl-main';
|
|
7
|
+
import type { FlowrConfigOptions } from '../../../config';
|
|
8
|
+
import type { ExceptionPoint } from '../../../dataflow/fn/exceptions-of-function';
|
|
9
|
+
import type { SingleSlicingCriterion } from '../../../slicing/criterion/parse';
|
|
10
|
+
/**
|
|
11
|
+
* Either returns all function definitions alongside exception information,
|
|
12
|
+
* or just those matching the filters.
|
|
13
|
+
*/
|
|
14
|
+
export interface InspectExceptionQuery extends BaseQueryFormat {
|
|
15
|
+
readonly type: 'inspect-exception';
|
|
16
|
+
/** If given, only function definitions that match one of the given slicing criteria are considered. */
|
|
17
|
+
readonly filter?: SingleSlicingCriterion[];
|
|
18
|
+
}
|
|
19
|
+
export interface InspectExceptionQueryResult extends BaseQueryResult {
|
|
20
|
+
/**
|
|
21
|
+
* If a function throws exceptions, the Ids of the throwing functions (at least the functions flowr knows about).
|
|
22
|
+
* An empty array means the function does not throw any exceptions.
|
|
23
|
+
*/
|
|
24
|
+
readonly exceptions: Record<NodeId, ExceptionPoint[]>;
|
|
25
|
+
}
|
|
26
|
+
declare function inspectExceptionLineParser(_output: ReplOutput, line: readonly string[], _config: FlowrConfigOptions): ParsedQueryLine<'inspect-exception'>;
|
|
27
|
+
export declare const InspectExceptionQueryDefinition: {
|
|
28
|
+
readonly executor: typeof executeExceptionQuery;
|
|
29
|
+
readonly asciiSummarizer: (formatter: import("../../../util/text/ansi").OutputFormatter, processed: import("../../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider<import("../../../r-bridge/parser").KnownParser>, queryResults: BaseQueryResult, result: string[]) => Promise<boolean>;
|
|
30
|
+
readonly fromLine: typeof inspectExceptionLineParser;
|
|
31
|
+
readonly schema: Joi.ObjectSchema<any>;
|
|
32
|
+
readonly flattenInvolvedNodes: (queryResults: BaseQueryResult) => NodeId[];
|
|
33
|
+
};
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
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.InspectExceptionQueryDefinition = void 0;
|
|
7
|
+
const ansi_1 = require("../../../util/text/ansi");
|
|
8
|
+
const joi_1 = __importDefault(require("joi"));
|
|
9
|
+
const inspect_exception_query_executor_1 = require("./inspect-exception-query-executor");
|
|
10
|
+
const node_id_1 = require("../../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
11
|
+
const dfg_1 = require("../../../util/mermaid/dfg");
|
|
12
|
+
const slice_query_parser_1 = require("../../../cli/repl/parser/slice-query-parser");
|
|
13
|
+
const info_1 = require("../../../dataflow/info");
|
|
14
|
+
function inspectExceptionLineParser(_output, line, _config) {
|
|
15
|
+
const criteria = (0, slice_query_parser_1.sliceCriteriaParser)(line[0]);
|
|
16
|
+
return {
|
|
17
|
+
query: {
|
|
18
|
+
type: 'inspect-exception',
|
|
19
|
+
filter: criteria
|
|
20
|
+
},
|
|
21
|
+
rCode: criteria ? line[1] : line[0]
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
exports.InspectExceptionQueryDefinition = {
|
|
25
|
+
executor: inspect_exception_query_executor_1.executeExceptionQuery,
|
|
26
|
+
asciiSummarizer: async (formatter, processed, queryResults, result) => {
|
|
27
|
+
const out = queryResults;
|
|
28
|
+
result.push(`Query: ${(0, ansi_1.bold)('inspect-exception', formatter)} (${out['.meta'].timing.toFixed(0)}ms)`);
|
|
29
|
+
const n = await processed.normalize();
|
|
30
|
+
function getLoc(r) {
|
|
31
|
+
return n.idMap.get((0, node_id_1.normalizeIdToNumberIfPossible)(r))?.location ?? undefined;
|
|
32
|
+
}
|
|
33
|
+
function getLexeme(r) {
|
|
34
|
+
return n.idMap.get((0, node_id_1.normalizeIdToNumberIfPossible)(r))?.lexeme ?? String(r);
|
|
35
|
+
}
|
|
36
|
+
for (const [r, v] of Object.entries(out.exceptions)) {
|
|
37
|
+
result.push(` - Function ${(0, ansi_1.bold)(r, formatter)} (${(0, dfg_1.formatRange)(getLoc(r))}) ${v.length > 0 ? 'throws exceptions:' : 'does not throw exceptions.'}`);
|
|
38
|
+
for (const { id: ex, cds } of v) {
|
|
39
|
+
result.push(` - Exception ${(0, info_1.happensInEveryBranch)(cds) ? 'always ' : 'maybe '}thrown at id ${(0, ansi_1.bold)(String(ex), formatter)} "${getLexeme(ex)}" (${(0, dfg_1.formatRange)(getLoc(ex))}, cds: ${cds?.map(c => c.when + ':' + (0, dfg_1.formatRange)(getLoc(c.id))).join(', ') ?? 'none'})`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return true;
|
|
43
|
+
},
|
|
44
|
+
fromLine: inspectExceptionLineParser,
|
|
45
|
+
schema: joi_1.default.object({
|
|
46
|
+
type: joi_1.default.string().valid('inspect-exception').required().description('The type of the query.'),
|
|
47
|
+
filter: joi_1.default.array().items(joi_1.default.string().required()).optional().description('If given, only function definitions that match one of the given slicing criteria are considered. Each criterion can be either `line:column`, `line@variable-name`, or `$id`, where the latter directly specifies the node id of the function definition to be considered.'),
|
|
48
|
+
}).description('Query to inspect which functions throw exceptions.'),
|
|
49
|
+
flattenInvolvedNodes: (queryResults) => {
|
|
50
|
+
const out = queryResults;
|
|
51
|
+
return Object.keys(out.exceptions).filter(id => out.exceptions[id].length > 0);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=inspect-exception-query-format.js.map
|
|
@@ -1,42 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.executeHigherOrderQuery = executeHigherOrderQuery;
|
|
4
|
-
const parse_1 = require("../../../slicing/criterion/parse");
|
|
5
|
-
const vertex_1 = require("../../../dataflow/graph/vertex");
|
|
6
4
|
const higher_order_function_1 = require("../../../dataflow/fn/higher-order-function");
|
|
5
|
+
const inspect_exception_query_executor_1 = require("../inspect-exceptions-query/inspect-exception-query-executor");
|
|
7
6
|
/**
|
|
8
7
|
* Execute higher-order function inspection queries on the given analyzer.
|
|
9
8
|
*/
|
|
10
9
|
async function executeHigherOrderQuery({ analyzer }, queries) {
|
|
11
10
|
const start = Date.now();
|
|
12
|
-
|
|
13
|
-
// filter will remain undefined if at least one of the queries wants all functions
|
|
14
|
-
for (const q of queries) {
|
|
15
|
-
if (q.filter === undefined) {
|
|
16
|
-
filters = undefined;
|
|
17
|
-
break;
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
filters ??= [];
|
|
21
|
-
filters = filters.concat(filters);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
const ast = await analyzer.normalize();
|
|
25
|
-
const filterFor = new Set();
|
|
26
|
-
if (filters) {
|
|
27
|
-
for (const f of filters) {
|
|
28
|
-
const i = (0, parse_1.tryResolveSliceCriterionToId)(f, ast.idMap);
|
|
29
|
-
if (i !== undefined) {
|
|
30
|
-
filterFor.add(i);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
const graph = (await analyzer.dataflow()).graph;
|
|
35
|
-
const fns = graph.verticesOfType(vertex_1.VertexType.FunctionDefinition)
|
|
36
|
-
.filter(([, v]) => filterFor.size === 0 || filterFor.has(v.id));
|
|
11
|
+
const { cg, fns } = await (0, inspect_exception_query_executor_1.getFunctionsToConsiderInCallGraph)(queries, analyzer);
|
|
37
12
|
const result = {};
|
|
38
13
|
for (const [id,] of fns) {
|
|
39
|
-
result[id] = (0, higher_order_function_1.
|
|
14
|
+
result[id] = (0, higher_order_function_1.isFunctionHigherOrder)(id, cg, analyzer.inspectContext());
|
|
40
15
|
}
|
|
41
16
|
return {
|
|
42
17
|
'.meta': {
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type { BaseQueryFormat, BaseQueryResult } from '../../base-query-format';
|
|
2
2
|
import Joi from 'joi';
|
|
3
|
+
import type { ParsedQueryLine } from '../../query';
|
|
3
4
|
import { executeHigherOrderQuery } from './inspect-higher-order-query-executor';
|
|
4
5
|
import { type NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
5
6
|
import type { SingleSlicingCriterion } from '../../../slicing/criterion/parse';
|
|
7
|
+
import type { ReplOutput } from '../../../cli/repl/commands/repl-main';
|
|
8
|
+
import type { FlowrConfigOptions } from '../../../config';
|
|
6
9
|
/**
|
|
7
10
|
* Either returns all function definitions alongside whether they are higher-order functions,
|
|
8
11
|
* or just those matching the filters.
|
|
@@ -14,9 +17,12 @@ export interface InspectHigherOrderQuery extends BaseQueryFormat {
|
|
|
14
17
|
export interface InspectHigherOrderQueryResult extends BaseQueryResult {
|
|
15
18
|
readonly higherOrder: Record<NodeId, boolean>;
|
|
16
19
|
}
|
|
20
|
+
declare function inspectHoLineParser(output: ReplOutput, line: readonly string[], _config: FlowrConfigOptions): ParsedQueryLine<'inspect-higher-order'>;
|
|
17
21
|
export declare const InspectHigherOrderQueryDefinition: {
|
|
18
22
|
readonly executor: typeof executeHigherOrderQuery;
|
|
19
23
|
readonly asciiSummarizer: (formatter: import("../../../util/text/ansi").OutputFormatter, processed: import("../../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider<import("../../../r-bridge/parser").KnownParser>, queryResults: BaseQueryResult, result: string[]) => Promise<boolean>;
|
|
24
|
+
readonly fromLine: typeof inspectHoLineParser;
|
|
20
25
|
readonly schema: Joi.ObjectSchema<any>;
|
|
21
26
|
readonly flattenInvolvedNodes: (queryResults: BaseQueryResult) => NodeId[];
|
|
22
27
|
};
|
|
28
|
+
export {};
|
|
@@ -9,6 +9,17 @@ const joi_1 = __importDefault(require("joi"));
|
|
|
9
9
|
const inspect_higher_order_query_executor_1 = require("./inspect-higher-order-query-executor");
|
|
10
10
|
const node_id_1 = require("../../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
11
11
|
const dfg_1 = require("../../../util/mermaid/dfg");
|
|
12
|
+
const slice_query_parser_1 = require("../../../cli/repl/parser/slice-query-parser");
|
|
13
|
+
function inspectHoLineParser(output, line, _config) {
|
|
14
|
+
const criteria = (0, slice_query_parser_1.sliceCriteriaParser)(line[0]);
|
|
15
|
+
return {
|
|
16
|
+
query: {
|
|
17
|
+
type: 'inspect-higher-order',
|
|
18
|
+
filter: criteria
|
|
19
|
+
},
|
|
20
|
+
rCode: criteria ? line[1] : line[0]
|
|
21
|
+
};
|
|
22
|
+
}
|
|
12
23
|
exports.InspectHigherOrderQueryDefinition = {
|
|
13
24
|
executor: inspect_higher_order_query_executor_1.executeHigherOrderQuery,
|
|
14
25
|
asciiSummarizer: async (formatter, processed, queryResults, result) => {
|
|
@@ -20,6 +31,7 @@ exports.InspectHigherOrderQueryDefinition = {
|
|
|
20
31
|
}
|
|
21
32
|
return true;
|
|
22
33
|
},
|
|
34
|
+
fromLine: inspectHoLineParser,
|
|
23
35
|
schema: joi_1.default.object({
|
|
24
36
|
type: joi_1.default.string().valid('inspect-higher-order').required().description('The type of the query.'),
|
|
25
37
|
filter: joi_1.default.array().items(joi_1.default.string().required()).optional().description('If given, only function definitions that match one of the given slicing criteria are considered. Each criterion can be either `line:column`, `line@variable-name`, or `$id`, where the latter directly specifies the node id of the function definition to be considered.')
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { InspectRecursionQuery, InspectRecursionQueryResult } from './inspect-recursion-query-format';
|
|
2
|
+
import type { BasicQueryData } from '../../base-query-format';
|
|
3
|
+
/**
|
|
4
|
+
* Execute recursion function inspection queries on the given analyzer.
|
|
5
|
+
*/
|
|
6
|
+
export declare function executeRecursionQuery({ analyzer }: BasicQueryData, queries: readonly InspectRecursionQuery[]): Promise<InspectRecursionQueryResult>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.executeRecursionQuery = executeRecursionQuery;
|
|
4
|
+
const recursive_function_1 = require("../../../dataflow/fn/recursive-function");
|
|
5
|
+
const inspect_exception_query_executor_1 = require("../inspect-exceptions-query/inspect-exception-query-executor");
|
|
6
|
+
/**
|
|
7
|
+
* Execute recursion function inspection queries on the given analyzer.
|
|
8
|
+
*/
|
|
9
|
+
async function executeRecursionQuery({ analyzer }, queries) {
|
|
10
|
+
const start = Date.now();
|
|
11
|
+
const { cg, fns } = await (0, inspect_exception_query_executor_1.getFunctionsToConsiderInCallGraph)(queries, analyzer);
|
|
12
|
+
const result = {};
|
|
13
|
+
for (const [id,] of fns) {
|
|
14
|
+
result[id] = (0, recursive_function_1.isFunctionRecursive)(id, cg);
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
'.meta': {
|
|
18
|
+
timing: Date.now() - start
|
|
19
|
+
},
|
|
20
|
+
recursive: result
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=inspect-recursion-query-executor.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { BaseQueryFormat, BaseQueryResult } from '../../base-query-format';
|
|
2
|
+
import Joi from 'joi';
|
|
3
|
+
import type { ParsedQueryLine } from '../../query';
|
|
4
|
+
import { executeRecursionQuery } from './inspect-recursion-query-executor';
|
|
5
|
+
import { type NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
6
|
+
import type { SingleSlicingCriterion } from '../../../slicing/criterion/parse';
|
|
7
|
+
import type { ReplOutput } from '../../../cli/repl/commands/repl-main';
|
|
8
|
+
import type { FlowrConfigOptions } from '../../../config';
|
|
9
|
+
/**
|
|
10
|
+
* Either returns all function definitions alongside whether they are recursive,
|
|
11
|
+
* or just those matching the filters.
|
|
12
|
+
*/
|
|
13
|
+
export interface InspectRecursionQuery extends BaseQueryFormat {
|
|
14
|
+
readonly type: 'inspect-recursion';
|
|
15
|
+
readonly filter?: SingleSlicingCriterion[];
|
|
16
|
+
}
|
|
17
|
+
export interface InspectRecursionQueryResult extends BaseQueryResult {
|
|
18
|
+
readonly recursive: Record<NodeId, boolean>;
|
|
19
|
+
}
|
|
20
|
+
declare function inspectRecLineParser(output: ReplOutput, line: readonly string[], _config: FlowrConfigOptions): ParsedQueryLine<'inspect-recursion'>;
|
|
21
|
+
export declare const InspectRecursionQueryDefinition: {
|
|
22
|
+
readonly executor: typeof executeRecursionQuery;
|
|
23
|
+
readonly asciiSummarizer: (formatter: import("../../../util/text/ansi").OutputFormatter, processed: import("../../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider<import("../../../r-bridge/parser").KnownParser>, queryResults: BaseQueryResult, result: string[]) => Promise<boolean>;
|
|
24
|
+
readonly fromLine: typeof inspectRecLineParser;
|
|
25
|
+
readonly schema: Joi.ObjectSchema<any>;
|
|
26
|
+
readonly flattenInvolvedNodes: (queryResults: BaseQueryResult) => NodeId[];
|
|
27
|
+
};
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
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.InspectRecursionQueryDefinition = void 0;
|
|
7
|
+
const ansi_1 = require("../../../util/text/ansi");
|
|
8
|
+
const joi_1 = __importDefault(require("joi"));
|
|
9
|
+
const inspect_recursion_query_executor_1 = require("./inspect-recursion-query-executor");
|
|
10
|
+
const node_id_1 = require("../../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
11
|
+
const dfg_1 = require("../../../util/mermaid/dfg");
|
|
12
|
+
const slice_query_parser_1 = require("../../../cli/repl/parser/slice-query-parser");
|
|
13
|
+
function inspectRecLineParser(output, line, _config) {
|
|
14
|
+
const criteria = (0, slice_query_parser_1.sliceCriteriaParser)(line[0]);
|
|
15
|
+
return {
|
|
16
|
+
query: {
|
|
17
|
+
type: 'inspect-recursion',
|
|
18
|
+
filter: criteria
|
|
19
|
+
},
|
|
20
|
+
rCode: criteria ? line[1] : line[0]
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
exports.InspectRecursionQueryDefinition = {
|
|
24
|
+
executor: inspect_recursion_query_executor_1.executeRecursionQuery,
|
|
25
|
+
asciiSummarizer: async (formatter, processed, queryResults, result) => {
|
|
26
|
+
const out = queryResults;
|
|
27
|
+
result.push(`Query: ${(0, ansi_1.bold)('inspect-recursion', formatter)} (${out['.meta'].timing.toFixed(0)}ms)`);
|
|
28
|
+
for (const [r, v] of Object.entries(out.recursive)) {
|
|
29
|
+
const loc = (await processed.normalize()).idMap.get((0, node_id_1.normalizeIdToNumberIfPossible)(r))?.location ?? undefined;
|
|
30
|
+
result.push(` - Function ${(0, ansi_1.bold)(r, formatter)} (${(0, dfg_1.formatRange)(loc)}) is ${v ? '' : 'not '}recursive`);
|
|
31
|
+
}
|
|
32
|
+
return true;
|
|
33
|
+
},
|
|
34
|
+
fromLine: inspectRecLineParser,
|
|
35
|
+
schema: joi_1.default.object({
|
|
36
|
+
type: joi_1.default.string().valid('inspect-recursion').required().description('The type of the query.'),
|
|
37
|
+
filter: joi_1.default.array().items(joi_1.default.string().required()).optional().description('If given, only function definitions that match one of the given slicing criteria are considered. Each criterion can be either `line:column`, `line@variable-name`, or `$id`, where the latter directly specifies the node id of the function definition to be considered.')
|
|
38
|
+
}).description('Either returns all function definitions alongside whether they are recursive, or just those matching the filters.'),
|
|
39
|
+
flattenInvolvedNodes: (queryResults) => {
|
|
40
|
+
const out = queryResults;
|
|
41
|
+
return Object.keys(out.recursive).filter(id => out.recursive[id]);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=inspect-recursion-query-format.js.map
|
|
@@ -125,6 +125,9 @@ function addLintingRuleResult(ruleName, results, result) {
|
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
|
-
result.push(` ╰ _Metadata_: ${(0, doc_code_1.codeInline)(
|
|
128
|
+
result.push(` ╰ _Metadata_: ${(0, doc_code_1.codeInline)(renderMetaData(results['.meta']))}`);
|
|
129
|
+
}
|
|
130
|
+
function renderMetaData(metadata) {
|
|
131
|
+
return Object.entries(metadata).map(r => `${r[0]}: ${JSON.stringify(r[1])}`).join(', ');
|
|
129
132
|
}
|
|
130
133
|
//# sourceMappingURL=linter-query-format.js.map
|
|
@@ -9,12 +9,13 @@ async function executeNormalizedAstQuery({ analyzer }, queries) {
|
|
|
9
9
|
if (queries.length !== 1) {
|
|
10
10
|
log_1.log.warn('Normalized-Ast query expects only up to one query, but got', queries.length);
|
|
11
11
|
}
|
|
12
|
+
const startTime = Date.now();
|
|
13
|
+
const normalized = await analyzer.normalize();
|
|
12
14
|
return {
|
|
13
15
|
'.meta': {
|
|
14
|
-
|
|
15
|
-
timing: 0
|
|
16
|
+
timing: Date.now() - startTime
|
|
16
17
|
},
|
|
17
|
-
normalized
|
|
18
|
+
normalized
|
|
18
19
|
};
|
|
19
20
|
}
|
|
20
21
|
//# sourceMappingURL=normalized-ast-query-executor.js.map
|
|
@@ -10,6 +10,7 @@ async function executeProjectQuery({ analyzer }, queries) {
|
|
|
10
10
|
if (queries.length !== 1) {
|
|
11
11
|
log_1.log.warn('Project query expects only up to one query, but got', queries.length);
|
|
12
12
|
}
|
|
13
|
+
const startTime = Date.now();
|
|
13
14
|
const withDf = queries.some(q => q.withDf);
|
|
14
15
|
// we need to know what is considered by the analyzer
|
|
15
16
|
if (withDf) {
|
|
@@ -17,16 +18,21 @@ async function executeProjectQuery({ analyzer }, queries) {
|
|
|
17
18
|
}
|
|
18
19
|
const descFile = analyzer.inspectContext().files.getFilesByRole(flowr_file_1.FileRole.Description);
|
|
19
20
|
const desc = descFile[0];
|
|
21
|
+
const roleCounts = {};
|
|
22
|
+
for (const file of Object.values(flowr_file_1.FileRole)) {
|
|
23
|
+
roleCounts[file] = analyzer.inspectContext().files.getFilesByRole(file).length;
|
|
24
|
+
}
|
|
20
25
|
return {
|
|
21
26
|
'.meta': {
|
|
22
|
-
|
|
23
|
-
timing: 0
|
|
27
|
+
timing: Date.now() - startTime
|
|
24
28
|
},
|
|
29
|
+
name: desc?.content().get('Package')?.[0] ?? desc?.content()?.get('Title')?.[0],
|
|
25
30
|
files: Array.from(analyzer.inspectContext().files.consideredFilesList()),
|
|
26
31
|
authors: desc?.authors(),
|
|
27
32
|
encoding: desc?.content().get('Encoding')?.[0],
|
|
28
33
|
version: desc?.content().get('Version')?.[0],
|
|
29
|
-
licenses: desc?.license()
|
|
34
|
+
licenses: desc?.license(),
|
|
35
|
+
roleCounts: roleCounts
|
|
30
36
|
};
|
|
31
37
|
}
|
|
32
38
|
//# sourceMappingURL=project-query-executor.js.map
|
|
@@ -2,19 +2,24 @@ import type { BaseQueryFormat, BaseQueryResult } from '../../base-query-format';
|
|
|
2
2
|
import { executeProjectQuery } from './project-query-executor';
|
|
3
3
|
import Joi from 'joi';
|
|
4
4
|
import type { RAuthorInfo } from '../../../util/r-author';
|
|
5
|
-
import type {
|
|
5
|
+
import type { RLicenseElementInfo } from '../../../util/r-license';
|
|
6
|
+
import type { FileRole } from '../../../project/context/flowr-file';
|
|
6
7
|
export interface ProjectQuery extends BaseQueryFormat {
|
|
7
8
|
readonly type: 'project';
|
|
8
9
|
/** Whether to include Dataflow information in the result. */
|
|
9
10
|
readonly withDf?: boolean;
|
|
10
11
|
}
|
|
11
12
|
export interface ProjectQueryResult extends BaseQueryResult {
|
|
13
|
+
/** The name of the project, if available. */
|
|
14
|
+
readonly name?: string;
|
|
12
15
|
/** The authors of the project. */
|
|
13
16
|
readonly authors?: RAuthorInfo[];
|
|
14
17
|
/** The files considered part of the project. */
|
|
15
18
|
readonly files: (string | '<inline>')[];
|
|
19
|
+
/** The counts of files by their role in the project. */
|
|
20
|
+
readonly roleCounts?: Record<FileRole, number>;
|
|
16
21
|
/** The licenses of the project. */
|
|
17
|
-
readonly licenses?:
|
|
22
|
+
readonly licenses?: RLicenseElementInfo[];
|
|
18
23
|
/** The encoding of the project files. */
|
|
19
24
|
readonly encoding?: string;
|
|
20
25
|
/** The version of the project, if available. */
|
|
@@ -22,7 +27,7 @@ export interface ProjectQueryResult extends BaseQueryResult {
|
|
|
22
27
|
}
|
|
23
28
|
export declare const ProjectQueryDefinition: {
|
|
24
29
|
readonly executor: typeof executeProjectQuery;
|
|
25
|
-
readonly asciiSummarizer: (formatter: import("../../../util/text/ansi").OutputFormatter,
|
|
30
|
+
readonly asciiSummarizer: (formatter: import("../../../util/text/ansi").OutputFormatter, analyzer: import("../../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider<import("../../../r-bridge/parser").KnownParser>, queryResults: BaseQueryResult, result: string[]) => true;
|
|
26
31
|
readonly schema: Joi.ObjectSchema<any>;
|
|
27
32
|
readonly flattenInvolvedNodes: () => never[];
|
|
28
33
|
};
|
|
@@ -9,11 +9,18 @@ const ansi_1 = require("../../../util/text/ansi");
|
|
|
9
9
|
const time_1 = require("../../../util/text/time");
|
|
10
10
|
const joi_1 = __importDefault(require("joi"));
|
|
11
11
|
const r_author_1 = require("../../../util/r-author");
|
|
12
|
+
const r_license_1 = require("../../../util/r-license");
|
|
13
|
+
function addSuffix(count, singular = '', plural = 's') {
|
|
14
|
+
return `${count === 1 ? singular : plural}`;
|
|
15
|
+
}
|
|
12
16
|
exports.ProjectQueryDefinition = {
|
|
13
17
|
executor: project_query_executor_1.executeProjectQuery,
|
|
14
|
-
asciiSummarizer: (formatter,
|
|
18
|
+
asciiSummarizer: (formatter, analyzer, queryResults, result) => {
|
|
15
19
|
const out = queryResults;
|
|
16
20
|
result.push(`Query: ${(0, ansi_1.bold)('project', formatter)} (${(0, time_1.printAsMs)(out['.meta'].timing, 0)})`);
|
|
21
|
+
if (out.name) {
|
|
22
|
+
result.push(` ╰ Project Name: ${out.name}`);
|
|
23
|
+
}
|
|
17
24
|
if (out.version) {
|
|
18
25
|
result.push(` ╰ Version: ${out.version}`);
|
|
19
26
|
}
|
|
@@ -21,23 +28,42 @@ exports.ProjectQueryDefinition = {
|
|
|
21
28
|
result.push(` ╰ Encoding: ${out.encoding}`);
|
|
22
29
|
}
|
|
23
30
|
if (out.authors && out.authors.length > 0) {
|
|
24
|
-
result.push(
|
|
31
|
+
result.push(` ╰ Author${addSuffix(out.authors.length)}:`);
|
|
25
32
|
for (const author of out.authors) {
|
|
26
33
|
result.push(` ╰ ${(0, r_author_1.rAuthorInfoToReadable)(author)}`);
|
|
27
34
|
}
|
|
28
35
|
}
|
|
29
36
|
if (out.licenses && out.licenses.length > 0) {
|
|
30
|
-
result.push(
|
|
37
|
+
result.push(` ╰ License${addSuffix(out.licenses.length)}:`);
|
|
31
38
|
for (const license of out.licenses) {
|
|
32
|
-
result.push(` ╰ ${
|
|
39
|
+
result.push(` ╰ ${(0, r_license_1.stringifyRLicense)(license)}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (out.roleCounts) {
|
|
43
|
+
const entries = Object.entries(out.roleCounts).filter(([, count]) => count > 0);
|
|
44
|
+
if (entries.length > 0) {
|
|
45
|
+
result.push(' ╰ File Role Counts:');
|
|
46
|
+
const longestRole = Math.max(...entries.map(([r]) => r.length));
|
|
47
|
+
const longestCount = Math.max(...entries.map(([, c]) => String(c).length));
|
|
48
|
+
for (const [role, count] of entries) {
|
|
49
|
+
result.push(` ╰ ${(role + ':').padEnd(longestRole + 1, ' ')} ${formatter.format(String(count).padStart(longestCount, ' '), {
|
|
50
|
+
effect: ansi_1.ColorEffect.Foreground,
|
|
51
|
+
color: 6 /* Colors.Cyan */
|
|
52
|
+
})}`);
|
|
53
|
+
}
|
|
33
54
|
}
|
|
34
55
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
result.push(` ╰ \`${file}\``);
|
|
56
|
+
if (analyzer.peekDataflow() === undefined) {
|
|
57
|
+
result.push(formatter.format(' ╰ Dataflow Analysis not performed', { color: 7 /* Colors.White */, effect: ansi_1.ColorEffect.Foreground }));
|
|
38
58
|
}
|
|
39
|
-
|
|
40
|
-
result.push(`
|
|
59
|
+
else {
|
|
60
|
+
result.push(` ╰ Dataflow Analysis considered ${out.files.length} file${out.files.length === 1 ? '' : 's'}`);
|
|
61
|
+
for (const file of out.files.slice(0, 20)) {
|
|
62
|
+
result.push(` ╰ \`${file}\``);
|
|
63
|
+
}
|
|
64
|
+
if (out.files.length > 20) {
|
|
65
|
+
result.push(` ╰ ... and ${out.files.length - 20} more files`);
|
|
66
|
+
}
|
|
41
67
|
}
|
|
42
68
|
return true;
|
|
43
69
|
},
|
package/queries/query.d.ts
CHANGED
|
@@ -29,10 +29,14 @@ import type { ReadonlyFlowrAnalysisProvider } from '../project/flowr-analyzer';
|
|
|
29
29
|
import type { ReplOutput } from '../cli/repl/commands/repl-main';
|
|
30
30
|
import type { CommandCompletions } from '../cli/repl/core';
|
|
31
31
|
import type { FilesQuery } from './catalog/files-query/files-query-format';
|
|
32
|
+
import type { CallGraphQuery } from './catalog/call-graph-query/call-graph-query-format';
|
|
33
|
+
import type { InspectRecursionQuery } from './catalog/inspect-recursion-query/inspect-recursion-query-format';
|
|
34
|
+
import type { DoesCallQuery } from './catalog/does-call-query/does-call-query-format';
|
|
35
|
+
import type { InspectExceptionQuery } from './catalog/inspect-exceptions-query/inspect-exception-query-format';
|
|
32
36
|
/**
|
|
33
37
|
* These are all queries that can be executed from within flowR
|
|
34
38
|
*/
|
|
35
|
-
export type Query = CallContextQuery | ConfigQuery | SearchQuery | DataflowQuery | ControlFlowQuery | DataflowLensQuery | FilesQuery | DfShapeQuery | NormalizedAstQuery | IdMapQuery | DataflowClusterQuery | StaticSliceQuery | DependenciesQuery | LocationMapQuery | HappensBeforeQuery | InspectHigherOrderQuery | ResolveValueQuery | ProjectQuery | OriginQuery | LinterQuery;
|
|
39
|
+
export type Query = CallContextQuery | ConfigQuery | SearchQuery | DataflowQuery | DoesCallQuery | CallGraphQuery | ControlFlowQuery | DataflowLensQuery | FilesQuery | DfShapeQuery | NormalizedAstQuery | IdMapQuery | DataflowClusterQuery | StaticSliceQuery | DependenciesQuery | LocationMapQuery | HappensBeforeQuery | InspectExceptionQuery | InspectHigherOrderQuery | InspectRecursionQuery | ResolveValueQuery | ProjectQuery | OriginQuery | LinterQuery;
|
|
36
40
|
export type QueryArgumentsWithType<QueryType extends BaseQueryFormat['type']> = Query & {
|
|
37
41
|
type: QueryType;
|
|
38
42
|
};
|
|
@@ -86,12 +90,25 @@ export declare const SupportedQueries: {
|
|
|
86
90
|
readonly schema: Joi.ObjectSchema<any>;
|
|
87
91
|
readonly flattenInvolvedNodes: (queryResults: BaseQueryResult) => NodeId[];
|
|
88
92
|
};
|
|
93
|
+
readonly 'call-graph': {
|
|
94
|
+
readonly executor: typeof import("./catalog/call-graph-query/call-graph-query-executor").executeCallGraphQuery;
|
|
95
|
+
readonly asciiSummarizer: (formatter: OutputFormatter, _analyzer: ReadonlyFlowrAnalysisProvider<import("../r-bridge/parser").KnownParser>, queryResults: BaseQueryResult, result: string[]) => true;
|
|
96
|
+
readonly schema: Joi.ObjectSchema<any>;
|
|
97
|
+
readonly flattenInvolvedNodes: (queryResults: BaseQueryResult) => NodeId[];
|
|
98
|
+
};
|
|
89
99
|
readonly dataflow: {
|
|
90
100
|
readonly executor: typeof import("./catalog/dataflow-query/dataflow-query-executor").executeDataflowQuery;
|
|
91
101
|
readonly asciiSummarizer: (formatter: OutputFormatter, _analyzer: ReadonlyFlowrAnalysisProvider<import("../r-bridge/parser").KnownParser>, queryResults: BaseQueryResult, result: string[]) => true;
|
|
92
102
|
readonly schema: Joi.ObjectSchema<any>;
|
|
93
103
|
readonly flattenInvolvedNodes: (queryResults: BaseQueryResult) => NodeId[];
|
|
94
104
|
};
|
|
105
|
+
readonly 'does-call': {
|
|
106
|
+
readonly executor: typeof import("./catalog/does-call-query/does-call-query-executor").executeDoesCallQuery;
|
|
107
|
+
readonly asciiSummarizer: (formatter: OutputFormatter, processed: ReadonlyFlowrAnalysisProvider<import("../r-bridge/parser").KnownParser>, queryResults: BaseQueryResult, result: string[]) => Promise<boolean>;
|
|
108
|
+
readonly fromLine: (output: ReplOutput, line: readonly string[], _config: FlowrConfigOptions) => ParsedQueryLine<"does-call">;
|
|
109
|
+
readonly schema: Joi.ObjectSchema<any>;
|
|
110
|
+
readonly flattenInvolvedNodes: (queryResults: BaseQueryResult) => NodeId[];
|
|
111
|
+
};
|
|
95
112
|
readonly 'dataflow-lens': {
|
|
96
113
|
readonly executor: typeof import("./catalog/dataflow-lens-query/dataflow-lens-query-executor").executeDataflowLensQuery;
|
|
97
114
|
readonly asciiSummarizer: (formatter: OutputFormatter, _analyzer: ReadonlyFlowrAnalysisProvider<import("../r-bridge/parser").KnownParser>, queryResults: BaseQueryResult, result: string[]) => true;
|
|
@@ -164,9 +181,24 @@ export declare const SupportedQueries: {
|
|
|
164
181
|
readonly schema: Joi.ObjectSchema<any>;
|
|
165
182
|
readonly flattenInvolvedNodes: () => never[];
|
|
166
183
|
};
|
|
184
|
+
readonly 'inspect-exception': {
|
|
185
|
+
readonly executor: typeof import("./catalog/inspect-exceptions-query/inspect-exception-query-executor").executeExceptionQuery;
|
|
186
|
+
readonly asciiSummarizer: (formatter: OutputFormatter, processed: ReadonlyFlowrAnalysisProvider<import("../r-bridge/parser").KnownParser>, queryResults: BaseQueryResult, result: string[]) => Promise<boolean>;
|
|
187
|
+
readonly fromLine: (_output: ReplOutput, line: readonly string[], _config: FlowrConfigOptions) => ParsedQueryLine<"inspect-exception">;
|
|
188
|
+
readonly schema: Joi.ObjectSchema<any>;
|
|
189
|
+
readonly flattenInvolvedNodes: (queryResults: BaseQueryResult) => NodeId[];
|
|
190
|
+
};
|
|
167
191
|
readonly 'inspect-higher-order': {
|
|
168
192
|
readonly executor: typeof import("./catalog/inspect-higher-order-query/inspect-higher-order-query-executor").executeHigherOrderQuery;
|
|
169
193
|
readonly asciiSummarizer: (formatter: OutputFormatter, processed: ReadonlyFlowrAnalysisProvider<import("../r-bridge/parser").KnownParser>, queryResults: BaseQueryResult, result: string[]) => Promise<boolean>;
|
|
194
|
+
readonly fromLine: (output: ReplOutput, line: readonly string[], _config: FlowrConfigOptions) => ParsedQueryLine<"inspect-higher-order">;
|
|
195
|
+
readonly schema: Joi.ObjectSchema<any>;
|
|
196
|
+
readonly flattenInvolvedNodes: (queryResults: BaseQueryResult) => NodeId[];
|
|
197
|
+
};
|
|
198
|
+
readonly 'inspect-recursion': {
|
|
199
|
+
readonly executor: typeof import("./catalog/inspect-recursion-query/inspect-recursion-query-executor").executeRecursionQuery;
|
|
200
|
+
readonly asciiSummarizer: (formatter: OutputFormatter, processed: ReadonlyFlowrAnalysisProvider<import("../r-bridge/parser").KnownParser>, queryResults: BaseQueryResult, result: string[]) => Promise<boolean>;
|
|
201
|
+
readonly fromLine: (output: ReplOutput, line: readonly string[], _config: FlowrConfigOptions) => ParsedQueryLine<"inspect-recursion">;
|
|
170
202
|
readonly schema: Joi.ObjectSchema<any>;
|
|
171
203
|
readonly flattenInvolvedNodes: (queryResults: BaseQueryResult) => NodeId[];
|
|
172
204
|
};
|
|
@@ -179,7 +211,7 @@ export declare const SupportedQueries: {
|
|
|
179
211
|
};
|
|
180
212
|
readonly project: {
|
|
181
213
|
readonly executor: typeof import("./catalog/project-query/project-query-executor").executeProjectQuery;
|
|
182
|
-
readonly asciiSummarizer: (formatter: OutputFormatter,
|
|
214
|
+
readonly asciiSummarizer: (formatter: OutputFormatter, analyzer: ReadonlyFlowrAnalysisProvider<import("../r-bridge/parser").KnownParser>, queryResults: BaseQueryResult, result: string[]) => true;
|
|
183
215
|
readonly schema: Joi.ObjectSchema<any>;
|
|
184
216
|
readonly flattenInvolvedNodes: () => never[];
|
|
185
217
|
};
|