@eagleoutice/flowr 2.17.13 → 2.17.14

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.
Files changed (92) hide show
  1. package/README.md +15 -15
  2. package/cli/repl/core.js +9 -27
  3. package/data/r-datasets.generated.js +2 -2
  4. package/dataflow/environments/ambient-effect.d.ts +4 -0
  5. package/dataflow/environments/ambient-effect.js +5 -4
  6. package/dataflow/environments/ambient-state-name.d.ts +2 -2
  7. package/dataflow/environments/ambient-state-name.js +3 -3
  8. package/dataflow/environments/built-in-props.d.ts +5 -0
  9. package/dataflow/environments/default-builtin-config/base-functions.d.ts +1 -1
  10. package/dataflow/environments/default-builtin-config/base-functions.js +4 -2
  11. package/dataflow/environments/default-builtin-config/base-language.d.ts +12 -1
  12. package/dataflow/environments/default-builtin-config/base-language.js +3 -2
  13. package/dataflow/environments/default-builtin-config/index.d.ts +12 -2
  14. package/dataflow/environments/default-builtin-config/misc-packages.d.ts +1 -1
  15. package/dataflow/environments/default-builtin-config/misc-packages.js +2 -0
  16. package/dataflow/environments/default-builtin-config/shared-configs.d.ts +24 -0
  17. package/dataflow/environments/default-builtin-config/shared-configs.js +8 -6
  18. package/dataflow/environments/pkg-name.d.ts +1 -0
  19. package/dataflow/eval/resolve/alias-tracking.js +11 -12
  20. package/dataflow/graph/df-helper.d.ts +6 -6
  21. package/dataflow/graph/df-helper.js +1 -1
  22. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +18 -14
  23. package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +1 -1
  24. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +29 -0
  25. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +2 -1
  26. package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +2 -1
  27. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.d.ts +12 -1
  28. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +24 -6
  29. package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +10 -10
  30. package/dataflow/internal/process/functions/call/built-in/built-in-load.js +2 -2
  31. package/documentation/doc-readme.js +1 -2
  32. package/documentation/doc-util/doc-query.d.ts +1 -1
  33. package/documentation/doc-util/doc-query.js +4 -2
  34. package/documentation/wiki-linter.d.ts +2 -0
  35. package/documentation/wiki-linter.js +7 -1
  36. package/documentation/wiki-query.js +28 -0
  37. package/linter/linter-format.d.ts +5 -1
  38. package/linter/linter-format.js +4 -0
  39. package/linter/linter-output.js +18 -16
  40. package/linter/linter-rules.d.ts +50 -0
  41. package/linter/linter-rules.js +5 -1
  42. package/linter/rules/notebook-cell-order.d.ts +43 -0
  43. package/linter/rules/notebook-cell-order.js +97 -0
  44. package/linter/rules/project-entry-point.d.ts +53 -0
  45. package/linter/rules/project-entry-point.js +62 -0
  46. package/linter/rules/undefined-symbol.d.ts +2 -0
  47. package/linter/rules/undefined-symbol.js +6 -1
  48. package/notebook/cell-graph.d.ts +23 -0
  49. package/notebook/cell-graph.js +48 -0
  50. package/notebook/cell-order-mermaid.d.ts +16 -0
  51. package/notebook/cell-order-mermaid.js +51 -0
  52. package/notebook/cell-order.d.ts +270 -0
  53. package/notebook/cell-order.js +1452 -0
  54. package/notebook/cell-split.d.ts +27 -0
  55. package/notebook/cell-split.js +99 -0
  56. package/package.json +1 -1
  57. package/project/context/flowr-analyzer-dependencies-context.d.ts +4 -0
  58. package/project/context/flowr-analyzer-files-context.d.ts +2 -0
  59. package/project/flowr-analyzer.js +5 -1
  60. package/project/plugins/file-plugins/files/cell-runner.d.ts +22 -0
  61. package/project/plugins/file-plugins/files/cell-runner.js +32 -0
  62. package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +4 -0
  63. package/project/plugins/file-plugins/files/flowr-jupyter-file.js +22 -6
  64. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +22 -0
  65. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +63 -7
  66. package/project/plugins/file-plugins/files/flowr-rsession-file.d.ts +2 -0
  67. package/project/plugins/file-plugins/files/flowr-rsession-file.js +2 -0
  68. package/project/plugins/file-plugins/files/flowr-sweave-file.d.ts +3 -5
  69. package/project/plugins/file-plugins/files/flowr-sweave-file.js +6 -0
  70. package/project/plugins/file-plugins/files/recorded-runs.d.ts +2 -0
  71. package/queries/catalog/aliases-query/aliases-query-executor.d.ts +6 -0
  72. package/queries/catalog/aliases-query/aliases-query-executor.js +108 -0
  73. package/queries/catalog/aliases-query/aliases-query-format.d.ts +21 -0
  74. package/queries/catalog/aliases-query/aliases-query-format.js +34 -0
  75. package/queries/catalog/cell-order-query/cell-order-query-format.d.ts +81 -0
  76. package/queries/catalog/cell-order-query/cell-order-query-format.js +82 -0
  77. package/queries/catalog/linter-query/linter-query-format.js +2 -1
  78. package/queries/query.d.ts +17 -2
  79. package/queries/query.js +6 -2
  80. package/queries/virtual-query/compound-query.d.ts +1 -1
  81. package/util/flowr-version.d.ts +1 -1
  82. package/util/flowr-version.js +2 -2
  83. package/util/mermaid/ast.js +4 -11
  84. package/util/mermaid/cfg.js +1 -2
  85. package/util/mermaid/dfg.d.ts +5 -0
  86. package/util/mermaid/dfg.js +23 -4
  87. package/util/mermaid/mermaid.d.ts +5 -0
  88. package/util/mermaid/mermaid.js +8 -0
  89. package/util/r-datasets.d.ts +2 -0
  90. package/util/r-datasets.js +3 -0
  91. package/util/text/playground-link.d.ts +2 -2
  92. package/util/text/playground-link.js +2 -2
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.executeAliasesQuery = executeAliasesQuery;
4
+ const edge_1 = require("../../../dataflow/graph/edge");
5
+ const vertex_1 = require("../../../dataflow/graph/vertex");
6
+ const parse_1 = require("../../../slicing/criterion/parse");
7
+ const assert_1 = require("../../../util/assert");
8
+ const range_1 = require("../../../util/range");
9
+ const query_meta_1 = require("../../query-meta");
10
+ function getAlias(source, dfg) {
11
+ const alreadyVisited = new Set();
12
+ //search for whether source node is/defines a function?
13
+ let srcIsFunc = false;
14
+ const searchSrcDef = [source];
15
+ while (searchSrcDef.length !== 0) {
16
+ const id = searchSrcDef.pop();
17
+ if ((0, assert_1.isUndefined)(id) || alreadyVisited.has(id)) {
18
+ continue;
19
+ }
20
+ const vertex = dfg.getVertex(id);
21
+ if (vertex_1.DfgVertex.isFunctionDefinition(vertex)) {
22
+ srcIsFunc = true;
23
+ break;
24
+ }
25
+ for (const [neighbor, edge] of dfg.edgesFrom(id)) {
26
+ if (edge_1.DfEdge.isOnlyType({ types: edge_1.EdgeType.Reads }, edge.types) || edge_1.DfEdge.isOnlyType({ types: edge_1.EdgeType.DefinedBy }, edge.types) || edge_1.DfEdge.isOnlyType({ types: edge_1.EdgeType.DefinedByOnCall }, edge.types)) {
27
+ searchSrcDef.push(neighbor);
28
+ }
29
+ }
30
+ alreadyVisited.add(id);
31
+ }
32
+ //search for all aliases of source
33
+ alreadyVisited.clear();
34
+ const resultIds = new Set();
35
+ //isResult is used to make sure that we only return nodes that are actual aliases and not just different "mentions" of the source throughout the code
36
+ //there needs to be a DefinedBy/DefinedOnCall edge on the path between the source node and a possible result node for the result node to be a true alias of the source
37
+ const toSearch = [{
38
+ vertex: source,
39
+ isResult: false
40
+ }];
41
+ while (toSearch.length !== 0) {
42
+ const next = toSearch.pop();
43
+ if ((0, assert_1.isUndefined)(next)) {
44
+ continue;
45
+ }
46
+ const { vertex, isResult } = next;
47
+ if (alreadyVisited.has(vertex)) {
48
+ continue;
49
+ }
50
+ for (const [neighbor, edge] of dfg.edgesTo(vertex)) {
51
+ if (edge_1.DfEdge.isOnlyType({ types: edge_1.EdgeType.Reads }, edge.types) || edge_1.DfEdge.isOnlyType({ types: edge_1.EdgeType.DefinedBy }, edge.types) || edge_1.DfEdge.isOnlyType({ types: edge_1.EdgeType.DefinedByOnCall }, edge.types)) {
52
+ if ((isResult || edge_1.DfEdge.isOnlyType({ types: edge_1.EdgeType.DefinedBy }, edge.types)) && !alreadyVisited.has(neighbor)) {
53
+ //edge case: if the possible result node is a function call, but the source doesn't define a function, the possible result node is actually defined
54
+ if (vertex_1.DfgVertex.isFunctionCall(dfg.getVertex(neighbor)) && !srcIsFunc) {
55
+ continue;
56
+ }
57
+ toSearch.push({ vertex: neighbor, isResult: true });
58
+ resultIds.add(neighbor);
59
+ }
60
+ else {
61
+ toSearch.push({ vertex: neighbor, isResult: next.isResult });
62
+ }
63
+ }
64
+ }
65
+ for (const [neighbor, edge] of dfg.edgesFrom(vertex)) {
66
+ if (edge_1.DfEdge.isOnlyType({ types: edge_1.EdgeType.DefinesOnCall }, edge.types)) {
67
+ toSearch.push({ vertex: neighbor, isResult: true });
68
+ resultIds.add(neighbor);
69
+ }
70
+ }
71
+ alreadyVisited.add(vertex);
72
+ }
73
+ return resultIds;
74
+ }
75
+ /**
76
+ * Executes the given alias queries using the provided analyzer.
77
+ */
78
+ async function executeAliasesQuery({ analyzer }, queries) {
79
+ const ast = await analyzer.normalize();
80
+ const idMap = ast.idMap;
81
+ const dataflow = await analyzer.dataflow();
82
+ const dfg = dataflow.graph;
83
+ const start = Date.now();
84
+ const result = [];
85
+ for (const query of queries) {
86
+ if ((0, assert_1.isNotUndefined)(query.criteria)) {
87
+ for (const criterion of query.criteria) {
88
+ const nodeId = parse_1.SlicingCriterion.parse(criterion, idMap);
89
+ const aliases = Array.from(getAlias(nodeId, dfg));
90
+ const aliasesLocation = aliases.map(nodeId => {
91
+ return range_1.SourceLocation.fromNode(idMap.get(nodeId));
92
+ }).filter(element => (0, assert_1.isNotUndefined)(element));
93
+ result.push([criterion, aliasesLocation]);
94
+ }
95
+ }
96
+ if ((0, assert_1.isNotUndefined)(query.id)) {
97
+ for (const nodeId of query.id) {
98
+ const aliases = Array.from(getAlias(nodeId, dfg));
99
+ result.push([nodeId, aliases]);
100
+ }
101
+ }
102
+ }
103
+ return {
104
+ ...(0, query_meta_1.metaSince)(start),
105
+ result: result
106
+ };
107
+ }
108
+ //# sourceMappingURL=aliases-query-executor.js.map
@@ -0,0 +1,21 @@
1
+ import Joi from 'joi';
2
+ import type { BaseQueryFormat, BaseQueryResult } from '../../base-query-format';
3
+ import { executeAliasesQuery } from './aliases-query-executor';
4
+ import type { SlicingCriteria, SlicingCriterion } from '../../../slicing/criterion/parse';
5
+ import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
6
+ import type { SourceLocation } from '../../../util/range';
7
+ export interface AliasesQuery extends BaseQueryFormat {
8
+ readonly type: 'aliases';
9
+ readonly criteria?: SlicingCriteria;
10
+ readonly id?: NodeId[];
11
+ }
12
+ export interface AliasesQueryResult extends BaseQueryResult {
13
+ readonly result: ([SlicingCriterion, SourceLocation[]] | [NodeId, NodeId[]])[];
14
+ }
15
+ export declare const AliasesQueryDefinition: {
16
+ readonly title: "Aliases Query";
17
+ readonly executor: typeof executeAliasesQuery;
18
+ readonly asciiSummarizer: (formatter: import("../../../util/text/ansi").OutputFormatter, _: import("../../..").ReadonlyFlowrAnalysisProvider<import("../../..").KnownParser>, queryResults: BaseQueryResult, result: string[]) => true;
19
+ readonly schema: Joi.ObjectSchema<any>;
20
+ readonly flattenInvolvedNodes: (queryResults: BaseQueryResult) => NodeId[];
21
+ };
@@ -0,0 +1,34 @@
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.AliasesQueryDefinition = void 0;
7
+ const joi_1 = __importDefault(require("joi"));
8
+ const ansi_1 = require("../../../util/text/ansi");
9
+ const aliases_query_executor_1 = require("./aliases-query-executor");
10
+ exports.AliasesQueryDefinition = {
11
+ title: 'Aliases Query',
12
+ executor: aliases_query_executor_1.executeAliasesQuery,
13
+ asciiSummarizer: (formatter, _, queryResults, result) => {
14
+ const out = queryResults;
15
+ result.push(`Query: ${(0, ansi_1.bold)('aliases', formatter)} (${out['.meta'].timing.toFixed(0)}ms)`);
16
+ for (const criterion of out.result) {
17
+ const aliases = criterion[1].length === 0 ? ' ╰ has no aliases.' : ` ╰ has aliases ${criterion[1].map(elem => {
18
+ return `[${elem.toString()}]`;
19
+ }).join(', ')}`;
20
+ result.push(criterion[0].toString(), aliases);
21
+ }
22
+ return true;
23
+ },
24
+ schema: joi_1.default.object({
25
+ type: joi_1.default.string().valid('aliases').required().description('The type of the query.'),
26
+ criteria: joi_1.default.array().items(joi_1.default.string()).optional().description('The slicing criteria of the nodes we want to find the alias for.'),
27
+ id: joi_1.default.array().items(joi_1.default.number()).optional().description('The NodeId of the nodes we want to find the alias for.')
28
+ }).description('The alias query returns all aliases of the identifiers given as slicing criteria or node ids.'),
29
+ flattenInvolvedNodes: (queryResults) => {
30
+ const out = queryResults;
31
+ return out.result.flatMap(([, aliases]) => aliases.filter((alias) => !Array.isArray(alias)));
32
+ }
33
+ };
34
+ //# sourceMappingURL=aliases-query-format.js.map
@@ -0,0 +1,81 @@
1
+ import Joi from 'joi';
2
+ import type { BaseQueryFormat, BaseQueryResult, BasicQueryData } from '../../base-query-format';
3
+ import { CellGraph } from '../../../notebook/cell-graph';
4
+ import { type CellSplit } from '../../../notebook/cell-split';
5
+ import { type CellRunState, type OrderHazard, type RunStateText, type CellFacts, type CellIndex, type NotebookCell, type OrderFailure } from '../../../notebook/cell-order';
6
+ /**
7
+ * Asks in which orders the code cells of a notebook can run. Cells are numbered from 0 in the order of the document.
8
+ */
9
+ export interface CellOrderQuery extends BaseQueryFormat {
10
+ readonly type: 'cell-order';
11
+ /** the order to check, top to bottom if omitted */
12
+ readonly order?: readonly CellIndex[];
13
+ /** how many working orders to list, none if omitted */
14
+ readonly orders?: number;
15
+ /** the cells in the order a session ran them (a cell as often as it ran), to ask what this means for each cell */
16
+ readonly session?: readonly CellIndex[];
17
+ /** cells whose code changed since they last ran in the session */
18
+ readonly edited?: readonly CellIndex[];
19
+ /** cells that ran again or changed, to ask which other cells this affects */
20
+ readonly changed?: readonly CellIndex[];
21
+ /** the cells as line ranges, if not those of the analyzed notebook */
22
+ readonly cells?: readonly NotebookCell[];
23
+ /** whether to return the {@link CellGraph} of the cells */
24
+ readonly graph?: boolean;
25
+ /** whether the units are the files of the project rather than the cells of a notebook, see {@link projectFiles}; `every` makes each file a unit, also those another file sources */
26
+ readonly files?: boolean | 'every';
27
+ /** what to call the cells, to have the answer in words as well */
28
+ readonly names?: readonly string[];
29
+ }
30
+ /** The answer in words, the cells called by the names of the query. */
31
+ export interface CellOrderTexts {
32
+ /** for each cell of the order that lacks something */
33
+ readonly failures: readonly string[];
34
+ readonly hazards: readonly string[];
35
+ /** for each cell that reads what others provide */
36
+ readonly links: readonly string[];
37
+ /** for each cell of the session that is not up to date */
38
+ readonly states: readonly (RunStateText & {
39
+ readonly cell: CellIndex;
40
+ })[];
41
+ }
42
+ export interface CellOrderAnswer {
43
+ /** each cell with what it needs from the others and what it does */
44
+ readonly cells: readonly CellFacts[];
45
+ readonly order: readonly CellIndex[];
46
+ /** the cells of {@link CellOrderAnswer#order} that need something no cell before them provides */
47
+ readonly failures: readonly OrderFailure[];
48
+ /** reads whose value depends on how often and in which order cells ran: a cell building on its own result, or a name several cells bind */
49
+ readonly hazards: readonly OrderHazard[];
50
+ /** the working orders, each running as many cells as it can */
51
+ readonly orders?: readonly (readonly CellIndex[])[];
52
+ /** the first order that runs all cells, preferring the order of the notebook, if one of the first few does */
53
+ readonly firstOrder?: readonly CellIndex[];
54
+ /** whether there are more working orders than listed */
55
+ readonly more?: boolean;
56
+ readonly affected?: readonly CellIndex[];
57
+ /** for a session: what its runs mean for each cell that ran */
58
+ readonly states?: readonly CellRunState[];
59
+ readonly graph?: CellGraph;
60
+ readonly texts?: CellOrderTexts;
61
+ /** how many orders run all cells, counting the first {@link CountedOrders} */
62
+ readonly count: number;
63
+ /** the cells that need each other so that no order runs them, and the move of one statement that mends it, if one does */
64
+ readonly cycle?: {
65
+ readonly cells: readonly CellIndex[];
66
+ readonly split?: CellSplit;
67
+ };
68
+ /** for the files of a project: the file that says in which order they run, if there is one */
69
+ readonly entry?: string;
70
+ }
71
+ export interface CellOrderQueryResult extends BaseQueryResult {
72
+ readonly results: readonly CellOrderAnswer[];
73
+ }
74
+ declare function executeCellOrderQuery({ analyzer }: BasicQueryData, queries: readonly CellOrderQuery[]): Promise<CellOrderQueryResult>;
75
+ export declare const CellOrderQueryDefinition: {
76
+ readonly title: "Cell Order Query";
77
+ readonly executor: typeof executeCellOrderQuery;
78
+ readonly asciiSummarizer: (formatter: import("../../../util/text/ansi").OutputFormatter, _analyzer: import("../../..").ReadonlyFlowrAnalysisProvider<import("../../..").KnownParser>, queryResults: BaseQueryResult, result: string[]) => true;
79
+ readonly schema: Joi.ObjectSchema<any>;
80
+ };
81
+ export {};
@@ -0,0 +1,82 @@
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.CellOrderQueryDefinition = void 0;
7
+ const joi_1 = __importDefault(require("joi"));
8
+ const query_print_1 = require("../../query-print");
9
+ const query_meta_1 = require("../../query-meta");
10
+ const cell_graph_1 = require("../../../notebook/cell-graph");
11
+ const cell_split_1 = require("../../../notebook/cell-split");
12
+ const cell_order_1 = require("../../../notebook/cell-order");
13
+ /** how many orders the answer counts at most */
14
+ const CountedOrders = 256;
15
+ async function executeCellOrderQuery({ analyzer }, queries) {
16
+ const start = Date.now();
17
+ const results = await Promise.all(queries.map(async (q) => {
18
+ const facts = q.files ? await (0, cell_order_1.analyzeProject)(analyzer, q.files === 'every') : await (0, cell_order_1.analyzeNotebook)(analyzer, q.cells);
19
+ const order = q.order ?? facts.map((_, i) => i);
20
+ const orders = q.orders ? (0, cell_order_1.workingOrders)(facts).take(q.orders + 1).toArray() : undefined;
21
+ const failures = (0, cell_order_1.checkOrder)(facts, order);
22
+ const hazards = (0, cell_order_1.orderHazards)(facts);
23
+ const states = q.session === undefined ? undefined : (0, cell_order_1.runStates)(facts, q.session, new Set(q.edited));
24
+ /* a file goes by its name, a cell is a cell */
25
+ const name = (i) => q.files ? q.names?.[i] ?? facts[i].cell.file ?? `file ${i + 1}` : `cell ${q.names?.[i] ?? i + 1}`;
26
+ const first = (0, cell_order_1.firstWorkingOrder)(facts);
27
+ const cycle = first === undefined ? (0, cell_split_1.cellsInCycle)(facts) : [];
28
+ return {
29
+ cells: facts,
30
+ order,
31
+ failures,
32
+ hazards,
33
+ orders: orders?.slice(0, q.orders),
34
+ firstOrder: first,
35
+ count: (0, cell_order_1.workingOrders)(facts).take(CountedOrders).filter(o => o.length === facts.length).toArray().length,
36
+ cycle: cycle.length === 0 ? undefined : { cells: cycle, split: q.files ? undefined : await (0, cell_split_1.splitForCycle)(analyzer) },
37
+ entry: q.files ? (0, cell_order_1.projectEntry)(analyzer) : undefined,
38
+ more: orders === undefined ? undefined : orders.length > (q.orders ?? 0),
39
+ affected: q.changed === undefined ? undefined : (0, cell_order_1.affectedCells)(facts, q.changed),
40
+ states,
41
+ graph: q.graph ? cell_graph_1.CellGraph.compute((await analyzer.dataflow()).graph, facts) : undefined,
42
+ texts: q.names === undefined ? undefined : {
43
+ failures: failures.flatMap(f => (0, cell_order_1.describeFailure)(f, name) ?? []),
44
+ hazards: hazards.map(h => (0, cell_order_1.describeHazard)(h, name)),
45
+ links: (0, cell_order_1.describeLinks)(facts, name),
46
+ states: [...(0, cell_order_1.describeRunStates)(facts, states ?? [], name)].map(([cell, text]) => ({ cell, ...text }))
47
+ }
48
+ };
49
+ }));
50
+ return { ...(0, query_meta_1.metaSince)(start), results };
51
+ }
52
+ exports.CellOrderQueryDefinition = {
53
+ title: 'Cell Order Query',
54
+ executor: executeCellOrderQuery,
55
+ asciiSummarizer: (formatter, _analyzer, queryResults, result) => {
56
+ const out = queryResults;
57
+ result.push((0, query_print_1.queryHeader)('cell-order', formatter, out['.meta'].timing));
58
+ for (const r of out.results) {
59
+ result.push(` ╰ ${r.order.join(' -> ')} ${r.failures.length === 0 ? 'works' : `fails at ${r.failures.map(f => `cell ${f.cell} (needs ${f.missing.map(cell_order_1.describeNeed).join(', ')})`).join(', ')}`}`);
60
+ r.hazards.forEach(h => result.push(` ╰ cell ${h.cell} ${h.kind} on \`${h.need.name}\` (cells ${h.providers.join(', ')})`));
61
+ r.orders?.forEach(o => result.push(` ╰ works: ${o.join(' -> ')}`));
62
+ r.states?.forEach(s => result.push(` ╰ cell ${s.cell}: ${s.state}`));
63
+ if (r.affected) {
64
+ result.push(` ╰ affected: ${r.affected.join(', ')}`);
65
+ }
66
+ }
67
+ return true;
68
+ },
69
+ schema: joi_1.default.object({
70
+ type: joi_1.default.string().valid('cell-order').required().description('The type of the query.'),
71
+ order: joi_1.default.array().items(joi_1.default.number().integer().min(0)).optional().description('The order of the cells to check, top to bottom if omitted.'),
72
+ orders: joi_1.default.number().integer().min(0).optional().description('How many working orders to list.'),
73
+ session: joi_1.default.array().items(joi_1.default.number().integer().min(0)).optional().description('The cells in the order a session ran them, to find which cells are stale, out of order, or lacked something.'),
74
+ edited: joi_1.default.array().items(joi_1.default.number().integer().min(0)).optional().description('Cells whose code changed since they last ran in the session.'),
75
+ changed: joi_1.default.array().items(joi_1.default.number().integer().min(0)).optional().description('Cells that ran again or changed, to find which cells this affects.'),
76
+ cells: joi_1.default.array().items(joi_1.default.object({ from: joi_1.default.number().required(), to: joi_1.default.number().required(), head: joi_1.default.number().optional(), tail: joi_1.default.number().optional(), file: joi_1.default.string().optional(), runner: joi_1.default.string().optional(), sets: joi_1.default.array().items(joi_1.default.string()).optional() })).optional().description('The cells as line ranges, if not those of the analyzed notebook.'),
77
+ graph: joi_1.default.boolean().optional().description('Whether to return the cell graph: the dataflow graph of what the cells read of each other.'),
78
+ files: joi_1.default.alternatives(joi_1.default.boolean(), joi_1.default.valid('every')).optional().description('Whether the units are the files of the project (each notebook as one) rather than the cells of a notebook; every makes each file a unit, also those another file sources.'),
79
+ names: joi_1.default.array().items(joi_1.default.string()).optional().description('What to call the cells, to have the answer in words as well.')
80
+ }).description('Checks whether the cells of a notebook run in a given order, lists the orders they run in, and which cells a change affects.')
81
+ };
82
+ //# sourceMappingURL=cell-order-query-format.js.map
@@ -236,7 +236,8 @@ function addLintingRuleResult(ruleName, results, result, formatter) {
236
236
  result.push(` ╰ ${certainty}:`);
237
237
  for (const res of certaintyResults.slice(0, MaxFindingsShown)) {
238
238
  const pretty = rule.prettyPrint[linter_format_1.LintingPrettyPrintContext.Query](res, results['.meta']);
239
- result.push(` ╰ ${hyperlinkLocations(pretty, formatter)}${res.quickFix ? ` (${res.quickFix.length} quick fix(es) available)` : ''}`);
239
+ const fixes = linter_format_1.LintQuickFix.choices(res).length;
240
+ result.push(` ╰ ${hyperlinkLocations(pretty, formatter)}${fixes > 0 ? ` (${fixes} quick fix(es) available)` : ''}`);
240
241
  }
241
242
  if (certaintyResults.length > MaxFindingsShown) {
242
243
  result.push(` ╰ ${(0, ansi_1.italic)(`… +${certaintyResults.length - MaxFindingsShown} more (:query* for the full JSON)`, formatter)}`);
@@ -43,11 +43,13 @@ import type { LintingResult, LintingResultCertainty } from '../linter/linter-for
43
43
  import { type DiceQuery } from './catalog/dice-query/dice-query-format';
44
44
  import { type GuessDepVersionsQuery } from './catalog/guess-dep-versions-query/guess-dep-versions-query-format';
45
45
  import { type AbsintQuery } from './catalog/absint-query/absint-query-format';
46
+ import { type FunctionInfoQuery } from './catalog/function-info-query/function-info-query-format';
47
+ import { type AliasesQuery } from './catalog/aliases-query/aliases-query-format';
46
48
  import { type CodeClonesQuery } from './catalog/code-clones-query/code-clones-query-format';
47
49
  import { type DataColumnsQuery } from './catalog/data-columns-query/data-columns-query-format';
48
- import { type FunctionInfoQuery } from './catalog/function-info-query/function-info-query-format';
50
+ import { type CellOrderQuery } from './catalog/cell-order-query/cell-order-query-format';
49
51
  /** These are all queries that can be executed from within flowR */
50
- export type Query = CallContextQuery | ConfigQuery | SearchQuery | DataflowQuery | DoesCallQuery | CallGraphQuery | ControlFlowQuery | DataflowLensQuery | FilesQuery | AbsintQuery | NormalizedAstQuery | IdMapQuery | DataflowClusterQuery | StaticSliceQuery | DependenciesQuery | LocationMapQuery | HappensBeforeQuery | InspectExceptionQuery | InspectHigherOrderQuery | InspectRecursionQuery | InspectFnPropsQuery | InspectFnGuardsQuery | AmbientAccessQuery | ResolveValueQuery | ProjectQuery | SignatureQuery | OriginQuery | LinterQuery | ProvenanceQuery | InputSourcesQuery | TaintQuery | DiceQuery | GuessDepVersionsQuery | FunctionInfoQuery | CodeClonesQuery | DataColumnsQuery;
52
+ export type Query = CallContextQuery | ConfigQuery | SearchQuery | DataflowQuery | DoesCallQuery | CallGraphQuery | ControlFlowQuery | DataflowLensQuery | FilesQuery | AbsintQuery | NormalizedAstQuery | IdMapQuery | DataflowClusterQuery | StaticSliceQuery | DependenciesQuery | LocationMapQuery | HappensBeforeQuery | InspectExceptionQuery | InspectHigherOrderQuery | InspectRecursionQuery | InspectFnPropsQuery | InspectFnGuardsQuery | AmbientAccessQuery | ResolveValueQuery | ProjectQuery | SignatureQuery | OriginQuery | LinterQuery | ProvenanceQuery | InputSourcesQuery | TaintQuery | DiceQuery | GuessDepVersionsQuery | FunctionInfoQuery | CodeClonesQuery | DataColumnsQuery | AliasesQuery | CellOrderQuery;
51
53
  export type QueryArgumentsWithType<QueryType extends BaseQueryFormat['type']> = Query & {
52
54
  type: QueryType;
53
55
  };
@@ -409,6 +411,19 @@ export declare const SupportedQueries: {
409
411
  readonly schema: Joi.ObjectSchema<any>;
410
412
  readonly flattenInvolvedNodes: (queryResults: BaseQueryResult) => NodeId[];
411
413
  };
414
+ readonly aliases: {
415
+ readonly title: "Aliases Query";
416
+ readonly executor: typeof import("./catalog/aliases-query/aliases-query-executor").executeAliasesQuery;
417
+ readonly asciiSummarizer: (formatter: OutputFormatter, _: ReadonlyFlowrAnalysisProvider<import("..").KnownParser>, queryResults: BaseQueryResult, result: string[]) => true;
418
+ readonly schema: Joi.ObjectSchema<any>;
419
+ readonly flattenInvolvedNodes: (queryResults: BaseQueryResult) => NodeId[];
420
+ };
421
+ readonly 'cell-order': {
422
+ readonly title: "Cell Order Query";
423
+ readonly executor: ({ analyzer }: BasicQueryData, queries: readonly CellOrderQuery[]) => Promise<import("./catalog/cell-order-query/cell-order-query-format").CellOrderQueryResult>;
424
+ readonly asciiSummarizer: (formatter: OutputFormatter, _analyzer: ReadonlyFlowrAnalysisProvider<import("..").KnownParser>, queryResults: BaseQueryResult, result: string[]) => true;
425
+ readonly schema: Joi.ObjectSchema<any>;
426
+ };
412
427
  };
413
428
  export type SupportedQueryTypes = keyof typeof SupportedQueries;
414
429
  /** The wiki page documenting a query, derived from its {@link SupportedQuery.title}. */
package/queries/query.js CHANGED
@@ -54,9 +54,11 @@ const taint_query_format_1 = require("./catalog/taint-query/taint-query-format")
54
54
  const dice_query_format_1 = require("./catalog/dice-query/dice-query-format");
55
55
  const guess_dep_versions_query_format_1 = require("./catalog/guess-dep-versions-query/guess-dep-versions-query-format");
56
56
  const absint_query_format_1 = require("./catalog/absint-query/absint-query-format");
57
+ const function_info_query_format_1 = require("./catalog/function-info-query/function-info-query-format");
58
+ const aliases_query_format_1 = require("./catalog/aliases-query/aliases-query-format");
57
59
  const code_clones_query_format_1 = require("./catalog/code-clones-query/code-clones-query-format");
58
60
  const data_columns_query_format_1 = require("./catalog/data-columns-query/data-columns-query-format");
59
- const function_info_query_format_1 = require("./catalog/function-info-query/function-info-query-format");
61
+ const cell_order_query_format_1 = require("./catalog/cell-order-query/cell-order-query-format");
60
62
  exports.SupportedQueries = {
61
63
  'call-context': call_context_query_format_1.CallContextQueryDefinition,
62
64
  'config': config_query_format_1.ConfigQueryDefinition,
@@ -93,7 +95,9 @@ exports.SupportedQueries = {
93
95
  'guess-dep-versions': guess_dep_versions_query_format_1.GuessDepVersionsQueryDefinition,
94
96
  'function-info': function_info_query_format_1.FunctionInfoQueryDefinition,
95
97
  'code-clones': code_clones_query_format_1.CodeClonesQueryDefinition,
96
- 'data-columns': data_columns_query_format_1.DataColumnsQueryDefinition
98
+ 'data-columns': data_columns_query_format_1.DataColumnsQueryDefinition,
99
+ 'aliases': aliases_query_format_1.AliasesQueryDefinition,
100
+ 'cell-order': cell_order_query_format_1.CellOrderQueryDefinition
97
101
  };
98
102
  /** The wiki page documenting a query, derived from its {@link SupportedQuery.title}. */
99
103
  function queryWikiPage(title) {
@@ -13,7 +13,7 @@ export interface CompoundQueryFormat<SubQueryType extends SupportedQueryTypes, C
13
13
  * You do not have to re-state the type, this is automatically filled with the type for 'query'
14
14
  * Additionally all arguments given in `commonArguments` are now enforced optional.
15
15
  */
16
- readonly arguments: ReadonlyArray<StrictOmit<StrictOmit<QueryArgumentsWithType<SubQueryType>, 'type'>, CommonArguments> & Partial<QueryArgumentsWithType<SubQueryType>>>;
16
+ readonly arguments: ReadonlyArray<Omit<QueryArgumentsWithType<SubQueryType>, 'type' | CommonArguments> & Partial<QueryArgumentsWithType<SubQueryType>>>;
17
17
  }
18
18
  /** Execute a single, virtual compound query in terms of unfolding the contained queries. */
19
19
  export declare function executeCompoundQueries<SubQueryType extends SupportedQueryTypes, CommonArguments extends VirtualCompoundConstraint<SubQueryType> = VirtualCompoundConstraint<SubQueryType>>(query: CompoundQueryFormat<SubQueryType, CommonArguments>): QueryArgumentsWithType<SubQueryType>[];
@@ -3,6 +3,6 @@
3
3
  * @module
4
4
  */
5
5
  import { SemVer } from 'semver';
6
- export declare const versionDate = "2026-11-25T20:19:23Z";
6
+ export declare const versionDate = "2026-11-28T22:01:59Z";
7
7
  /** Retrieves the current flowR version as a new {@link SemVer} object. */
8
8
  export declare function flowrVersion(): SemVer;
@@ -8,9 +8,9 @@ exports.flowrVersion = flowrVersion;
8
8
  */
9
9
  const semver_1 = require("semver");
10
10
  // this is automatically replaced with the current version by release-it
11
- const version = '2.17.13';
11
+ const version = '2.17.14';
12
12
  // this is automatically replaced with the release date by release-it (scripts/bump-version.ts)
13
- exports.versionDate = '2026-11-25T20:19:23Z';
13
+ exports.versionDate = '2026-11-28T22:01:59Z';
14
14
  /** Retrieves the current flowR version as a new {@link SemVer} object. */
15
15
  function flowrVersion() {
16
16
  return new semver_1.SemVer(version);
@@ -9,13 +9,6 @@ const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
9
9
  const mermaid_1 = require("./mermaid");
10
10
  const r_expression_list_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-expression-list");
11
11
  const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
12
- function identifyMermaidDirection(prefix) {
13
- const directionMatch = prefix.match(/flowchart (TD|LR|RL|BT)/);
14
- if (directionMatch) {
15
- return directionMatch[1];
16
- }
17
- return 'TD';
18
- }
19
12
  /** Serialize the normalized AST to mermaid format */
20
13
  function normalizedAstToMermaid(ast, { prefix = 'flowchart TD\n', markStyle = info_1.MermaidDefaultMarkStyle, includeOnlyIds, mark } = {}) {
21
14
  let output = prefix;
@@ -52,11 +45,11 @@ function normalizedAstToMermaid(ast, { prefix = 'flowchart TD\n', markStyle = in
52
45
  });
53
46
  }
54
47
  if (r_project_1.RProject.is(ast)) {
55
- for (const f of ast.files) {
56
- // add a subgraph for each file
48
+ for (const [at, f] of ast.files.entries()) {
49
+ // add a subgraph for each file, with an id of its own and the path as its label
57
50
  if (ast.files.length !== 1 || (f.filePath && f.filePath !== flowr_file_1.FlowrFile.INLINE_PATH)) {
58
- const direction = identifyMermaidDirection(prefix);
59
- output += ` subgraph "File: ${mermaid_1.Mermaid.escape(f.filePath ?? flowr_file_1.FlowrFile.INLINE_PATH)}"\n`;
51
+ const direction = mermaid_1.Mermaid.subgraphDirection(prefix);
52
+ output += ` subgraph file${at} ["File: ${mermaid_1.Mermaid.escape(f.filePath ?? flowr_file_1.FlowrFile.INLINE_PATH)}"]\n`;
60
53
  output += ` direction ${direction}\n`;
61
54
  showAst(f.root);
62
55
  output += ' end\n';
@@ -29,7 +29,6 @@ function cfgOfNode(vert, normalizedVertex, id, output) {
29
29
  }
30
30
  return output;
31
31
  }
32
- const getDirRegex = /flowchart\s+([A-Za-z]+)/;
33
32
  /**
34
33
  * The vertices that make up each function body, keyed by the definition that holds it.
35
34
  * Nothing flows into such a region, so it is reachable only from the entry the definition points at.
@@ -139,7 +138,7 @@ function cfgToMermaid(cfg, normalizedAst, { prefix = 'flowchart TD\n', simplify
139
138
  }
140
139
  includeOnlyIds = completed;
141
140
  }
142
- const dirIs = getDirRegex.exec(prefix)?.at(1) ?? 'LR';
141
+ const dirIs = mermaid_1.Mermaid.subgraphDirection(prefix, 'LR');
143
142
  const diagramIncludedIds = new Set();
144
143
  /* a function body runs when the function is called, so it is drawn as a region of its own instead of floating free */
145
144
  const bodies = cfg.graph.mayHaveBasicBlocks() ? new Map() : collectBodies(cfg.graph);
@@ -40,6 +40,11 @@ export interface MermaidGraphConfiguration {
40
40
  includeOnlyIds?: ReadonlySet<NodeId>;
41
41
  /** show the edge-free base-R package qualification (`acf` as `stats::acf`); pass `false` when the signature database is disabled. Default `true`. */
42
42
  qualifyBaseR?: boolean;
43
+ /** vertices to draw boxed together under a label, as the cells of a notebook; a vertex of no group is drawn outside of all */
44
+ groups?: readonly {
45
+ readonly label: string;
46
+ readonly ids: ReadonlySet<NodeId>;
47
+ }[];
43
48
  }
44
49
  export interface LabeledDiffGraph {
45
50
  label: string;
@@ -278,13 +278,32 @@ function edgeName(type) {
278
278
  }
279
279
  }
280
280
  // make the passing of root ids more performant again
281
- function graphToMermaidGraph(rootIds, { simplified, graph, prefix = 'flowchart TD', idPrefix = '', includeEnvironments = !simplified, mark, rootGraph, presentEdges = new Set(), markStyle = info_1.MermaidDefaultMarkStyle, includeOnlyIds, qualifyBaseR = true }) {
281
+ function graphToMermaidGraph(rootIds, { simplified, graph, prefix = 'flowchart TD', idPrefix = '', includeEnvironments = !simplified, mark, rootGraph, presentEdges = new Set(), markStyle = info_1.MermaidDefaultMarkStyle, includeOnlyIds, qualifyBaseR = true, groups = [] }) {
282
282
  const mermaid = { nodeLines: prefix === null ? [] : [prefix], edgeLines: [], presentEdges, presentVertices: new Set(), mark, rootGraph: rootGraph ?? graph, includeEnvironments, markStyle, simplified, qualifyBaseR };
283
- for (const [id, info] of graph.vertices(true)) {
284
- if (rootIds.has(id)) {
285
- vertexToMermaid(info, mermaid, id, idPrefix, mark, includeOnlyIds);
283
+ const grouped = new Set(groups.flatMap(g => [...g.ids]));
284
+ const draw = (keep) => {
285
+ for (const [id, info] of graph.vertices(true)) {
286
+ if (rootIds.has(id) && keep(id)) {
287
+ vertexToMermaid(info, mermaid, id, idPrefix, mark, includeOnlyIds);
288
+ }
289
+ }
290
+ };
291
+ for (const [at, { label, ids }] of groups.entries()) {
292
+ /* an empty subgraph would show as a box of its own */
293
+ if (ids.size === 0) {
294
+ continue;
286
295
  }
296
+ mermaid.nodeLines.push(`\nsubgraph "${idPrefix}group-${at}" ["${mermaid_1.Mermaid.escape(label)}"]`);
297
+ draw(id => ids.has(id));
298
+ mermaid.nodeLines.push('end');
299
+ }
300
+ /* the groups stand one below the other in their order, as the cells of a notebook do, rather than side by side */
301
+ const shown = groups.flatMap((g, at) => g.ids.size > 0 ? [`${idPrefix}group-${at}`] : []);
302
+ const upwards = /flowchart\s+BT/.test(prefix ?? '');
303
+ for (let at = 1; at < shown.length; at++) {
304
+ mermaid.edgeLines.push(upwards ? `${shown[at]} ~~~ ${shown[at - 1]}` : `${shown[at - 1]} ~~~ ${shown[at]}`);
287
305
  }
306
+ draw(id => !grouped.has(id));
288
307
  return mermaid;
289
308
  }
290
309
  /** uses same id map but ensures, it is different from the rhs so that mermaid can work with that */
@@ -5,6 +5,11 @@ import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-i
5
5
  */
6
6
  export declare const Mermaid: {
7
7
  readonly name: "Mermaid";
8
+ /**
9
+ * The direction a subgraph of a flowchart with the header `prefix` lays out in, `fallback` without one.
10
+ * A subgraph knows `TB` but not its alias `TD`, which a header may use.
11
+ */
12
+ readonly subgraphDirection: (this: void, prefix: string, fallback?: string) => string;
8
13
  /** Replacements applied by escape functions! */
9
14
  readonly replacements: {
10
15
  readonly '\\n': "\n";
@@ -11,6 +11,14 @@ function charCode(c) {
11
11
  */
12
12
  exports.Mermaid = {
13
13
  name: 'Mermaid',
14
+ /**
15
+ * The direction a subgraph of a flowchart with the header `prefix` lays out in, `fallback` without one.
16
+ * A subgraph knows `TB` but not its alias `TD`, which a header may use.
17
+ */
18
+ subgraphDirection(prefix, fallback = 'TB') {
19
+ const header = /flowchart\s+([A-Za-z]+)/.exec(prefix)?.[1] ?? fallback;
20
+ return header === 'TD' ? 'TB' : header;
21
+ },
14
22
  /** Replacements applied by escape functions! */
15
23
  replacements: {
16
24
  // keep newlines
@@ -1,4 +1,6 @@
1
1
  import type { BrandedIdentifier, BrandedNamespace } from '../dataflow/environments/identifier';
2
+ /** a data set with more columns than this keeps only the first ones, a completion list longer than that helps no one */
3
+ export declare const MaxDatasetColumns = 200;
2
4
  /** The shape of a data set a package ships as a data frame, like `penguins` of `datasets` or `starwars` of `dplyr`. */
3
5
  export interface DatasetShape {
4
6
  /** the package shipping the data set */
@@ -1,9 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MaxDatasetColumns = void 0;
3
4
  exports.datasetShape = datasetShape;
4
5
  exports.datasetsOf = datasetsOf;
5
6
  const r_datasets_generated_1 = require("../data/r-datasets.generated");
6
7
  const r_base_packages_1 = require("./r-base-packages");
8
+ /** a data set with more columns than this keeps only the first ones, a completion list longer than that helps no one */
9
+ exports.MaxDatasetColumns = 200;
7
10
  /** the packages shipping a data set of each name, to look up a name that names no package */
8
11
  let byName;
9
12
  function packagesWith(name) {
@@ -37,8 +37,8 @@ export interface PlaygroundLinkParts {
37
37
  }[];
38
38
  /** what the page marks when it opens, and what alt-click toggles from there on */
39
39
  readonly marks?: readonly PlaygroundMark[];
40
- /** the boxes that open folded away, for whatever the example is not about */
41
- readonly collapsed?: readonly PlaygroundBox[];
40
+ /** the tab of the panel the page opens on, else that of the first box a mark names */
41
+ readonly tab?: PlaygroundBox;
42
42
  /** where the cursor lands, as a slicing criterion (`12@sum`, `12:5`) or a bare line */
43
43
  readonly at?: string;
44
44
  /** slice forward from the criterion rather than backward */
@@ -123,7 +123,7 @@ exports.Playground = {
123
123
  * sits, and how the page is laid out.
124
124
  */
125
125
  link(parts) {
126
- const { code, name, files = [], marks = [], collapsed = [], at, forward, dim, replOpen, wholeSlice, config = [], split, repl } = parts;
126
+ const { code, name, files = [], marks = [], tab, at, forward, dim, replOpen, wholeSlice, config = [], split, repl } = parts;
127
127
  const base = parts.base ?? exports.Playground.BaseRef;
128
128
  /* one field for everything about the layout, with the trailing empty parts dropped */
129
129
  const view = [
@@ -143,7 +143,7 @@ exports.Playground = {
143
143
  ['o', files.length > 0 ? (0, url_encoding_1.packForUrl)(JSON.stringify(files.map(f => [f.name, f.code]))) : ''],
144
144
  ['k', config.length > 0 ? exports.Playground.packConfig(config) : ''],
145
145
  ['h', Mark.compress(marks).join(',')],
146
- ['f', (0, arrays_1.uniqueArray)(collapsed).filter(box => Object.values(PlaygroundBox).includes(box)).join(',')],
146
+ ['t', tab ?? ''],
147
147
  ['v', view.join(',')],
148
148
  ['p', position ?? '']
149
149
  ]);