@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
@@ -575,18 +575,22 @@ function readOptions(res, args, rootId, data, effect, keys) {
575
575
  }
576
576
  /** what every access of a file reads to find it: the working directory a relative path starts from and the directories the path leads through */
577
577
  const FileSystemReads = [ambient_state_name_1.AmbientStateName.workingDirectory, ambient_state_name_1.AmbientStateName.directories];
578
- /** What reading or writing the files the call names does, see {@link fileStems}. */
578
+ /** What reading or writing the files the call names does, see {@link fileNames}. */
579
579
  function fileAccess(res, rootId, data, effect) {
580
- const stems = fileStems(res, rootId, data, effect);
581
- if (stems?.length === 0) {
580
+ const names = fileNames(res, rootId, data, effect);
581
+ if (names?.length === 0) {
582
582
  return res;
583
583
  }
584
584
  if (effect.access === ambient_effect_1.AmbientVerb.Reads) {
585
585
  /* a read through a connection the program holds moves its position, so the next read depends on this one */
586
- const moves = readsThroughHandle(res, rootId, data, effect.sig) ? stems === undefined ? [ambient_state_name_1.AmbientStateName.anyFile, ambient_state_name_1.AmbientStateName.files] : stems.map(ambient_state_name_1.AmbientStateName.file) : [];
587
- return withAccess(res, rootId, data, [...FileSystemReads, ...stems === undefined ? [ambient_state_name_1.AmbientStateName.files] : [...stems.map(ambient_state_name_1.AmbientStateName.file), ambient_state_name_1.AmbientStateName.anyFile]], moves);
586
+ const moves = readsThroughHandle(res, rootId, data, effect.sig) ? names === undefined ? [ambient_state_name_1.AmbientStateName.anyFile, ambient_state_name_1.AmbientStateName.files] : names.map(ambient_state_name_1.AmbientStateName.file) : [];
587
+ return withAccess(res, rootId, data, [...FileSystemReads, ...names === undefined ? [ambient_state_name_1.AmbientStateName.files] : [...names.map(ambient_state_name_1.AmbientStateName.file), ambient_state_name_1.AmbientStateName.anyFile]], moves);
588
588
  }
589
- return withAccess(res, rootId, data, FileSystemReads, [...stems === undefined ? [ambient_state_name_1.AmbientStateName.anyFile] : stems.map(ambient_state_name_1.AmbientStateName.file), ambient_state_name_1.AmbientStateName.files]);
589
+ /* removing a file (`unlink`) leaves nothing of what was written to it */
590
+ if (effect.access === ambient_effect_1.AmbientVerb.Kills) {
591
+ return withAccess(res, rootId, data, FileSystemReads, [ambient_state_name_1.AmbientStateName.files], names?.map(ambient_state_name_1.AmbientStateName.file) ?? []);
592
+ }
593
+ return withAccess(res, rootId, data, FileSystemReads, [...names === undefined ? [ambient_state_name_1.AmbientStateName.anyFile] : names.map(ambient_state_name_1.AmbientStateName.file), ambient_state_name_1.AmbientStateName.files]);
590
594
  }
591
595
  /** `gc()` may run every registered finalizer whose object is released. */
592
596
  function runFinalizers(res, rootId, data) {
@@ -703,8 +707,8 @@ function namesNoFile(id, data) {
703
707
  const values = boundValues(id, data);
704
708
  return values.length > 0 && values.every(v => (r_string_1.RString.is(v) && v.content.str === '') || (r_symbol_1.RSymbol.is(v) && v.content === convert_values_1.RNull) || callsTagged(v, data, built_in_props_1.SemanticCallTag.Console));
705
709
  }
706
- /** The stems of the files the call names, `undefined` unless every file argument is a known path to a file with an extension (a device's `plot%03d.png` or a directory may stand for others). */
707
- function fileStems(res, rootId, data, { sig, numbered }) {
710
+ /** The names of the files the call names (`data.csv` for `out/data.csv`), `undefined` unless every file argument is a known path to a file with an extension (a device's `plot%03d.png` or a directory may stand for others). */
711
+ function fileNames(res, rootId, data, { sig, numbered }) {
708
712
  const call = res.graph.getVertex(rootId);
709
713
  if (sig === undefined || !vertex_1.DfgVertex.isFunctionCall(call)) {
710
714
  return undefined;
@@ -715,7 +719,7 @@ function fileStems(res, rootId, data, { sig, numbered }) {
715
719
  : named.length < resources.filter(([n, p]) => n !== '...' && (p & (built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Optional)) === built_in_props_1.ArgProp.Forced).length) {
716
720
  return undefined;
717
721
  }
718
- const stems = [];
722
+ const names = [];
719
723
  for (const id of named) {
720
724
  if (namesNoFile(id, data)) {
721
725
  continue;
@@ -723,19 +727,19 @@ function fileStems(res, rootId, data, { sig, numbered }) {
723
727
  /* every `tempfile()` names a file no other call names */
724
728
  const fresh = boundValues(id, data);
725
729
  if (fresh.length > 0 && fresh.every(v => callsTagged(v, data, built_in_props_1.SemanticCallTag.TempFile))) {
726
- stems.push(...fresh.map(v => `tmp-${v.info.id}`));
730
+ names.push(...fresh.map(v => `tmp-${v.info.id}`));
727
731
  continue;
728
732
  }
729
733
  const paths = node_value_1.NodeValue.stringsOf(id, data);
730
734
  for (const path of paths?.length ? paths : ['']) {
731
- const [stem, ...extension] = path.split(/[/\\]/).at(-1)?.split('.') ?? [];
732
- if (!stem || extension.length === 0 || /[*?[]/.test(path) || (numbered && path.includes('%'))) {
735
+ const name = path.split(/[/\\]/).at(-1) ?? '';
736
+ if (!/^[^.]+\../.test(name) || /[*?[]/.test(path) || (numbered && path.includes('%'))) {
733
737
  return undefined;
734
738
  }
735
- stems.push(stem);
739
+ names.push(name);
736
740
  }
737
741
  }
738
- return stems;
742
+ return names;
739
743
  }
740
744
  /** What printing `value` reads: the printing `keys` for a plain value, all options for an unknown one (a tibble reads the pillar options). */
741
745
  function printingReads(value, dispatches, keys, data) {
@@ -1,4 +1,4 @@
1
- import type { DataflowProcessorInformation } from '../../../../../processor';
1
+ import { type DataflowProcessorInformation } from '../../../../../processor';
2
2
  import type { DataflowInformation } from '../../../../../info';
3
3
  import { type PotentiallyEmptyRArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
4
4
  import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
@@ -3,10 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.resolveFunctionArgument = resolveFunctionArgument;
4
4
  exports.processApply = processApply;
5
5
  exports.callNamedFunction = callNamedFunction;
6
+ const processor_1 = require("../../../../../processor");
7
+ const control_flow_1 = require("../../../../control-flow");
6
8
  const built_in_expression_list_1 = require("./built-in-expression-list");
7
9
  const function_semantics_1 = require("../../../../../fn/function-semantics");
8
10
  const known_call_handling_1 = require("../known-call-handling");
9
11
  const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
12
+ const type_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/type");
13
+ const named_call_handling_1 = require("../named-call-handling");
10
14
  const built_in_get_1 = require("./built-in-get");
11
15
  const r_symbol_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
12
16
  const node_id_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id");
@@ -51,6 +55,14 @@ function resolveFunctionArgument(val, data, opts) {
51
55
  /** Process an apply call like `vapply` or `mapply`. */
52
56
  function processApply(name, args, rootId, data, config) {
53
57
  const { indexOfFunction = 1, nameOfFunctionArgument, unquoteFunction, resolveInEnvironment, resolveValue, hasUnknownSideEffects, isTheCall, folds, sig } = config;
58
+ const direct = isTheCall ? directCallOf(args, data) : undefined;
59
+ if (direct !== undefined) {
60
+ /* the name is still evaluated first */
61
+ const named = (0, processor_1.processDataflowFor)(args[0], data);
62
+ const call = (0, named_call_handling_1.processNamedCall)(direct.name, direct.args, rootId, { ...data, environment: named.environment });
63
+ call.graph.mergeWith(named.graph);
64
+ return { ...call, in: [...named.in, ...call.in], unknownReferences: [...named.unknownReferences, ...call.unknownReferences], cfgEntry: control_flow_1.ControlFlow.inSequence(call.graph, [named, call]) };
65
+ }
54
66
  /* the length is one-based and the argument mapping zero-based, so the function sits at `indexOfFunction` */
55
67
  const resFn = (0, known_call_handling_1.processKnownFunctionCall)({
56
68
  name, args, rootId, data, sig: function_semantics_1.FunctionSemantics.call.signature.only(indexOfFunction, nameOfFunctionArgument ?? 'FUN'), origin: built_in_proc_name_1.BuiltInProcName.Apply
@@ -175,6 +187,23 @@ function processApply(name, args, rootId, data, config) {
175
187
  unknownReferences: information.unknownReferences.filter(ref => ref.nodeId !== functionId)
176
188
  };
177
189
  }
190
+ /**
191
+ * The call `do.call(what, args)` makes, when `what` is a literal naming built-ins only that bind or remove names (`"assign"`) and `args` a literal `list(...)`:
192
+ * processed as that call (`assign("x", 1)`), its processor sees the arguments it needs to know which names it binds.
193
+ */
194
+ function directCallOf(args, data) {
195
+ const [what, list] = args.map(r_argument_1.RArgument.valueOf);
196
+ if (args.length !== 2 || args.some(a => a === r_function_call_1.EmptyArgument || (a.name !== undefined && a.name.content !== (a === args[0] ? 'what' : 'args')))
197
+ || !(r_string_1.RString.is(what) || r_symbol_1.RSymbol.is(what)) || !r_function_call_1.RFunctionCall.isNamed(list, identifier_1.Identifier.make('list'))) {
198
+ return undefined;
199
+ }
200
+ const content = r_string_1.RString.is(what) ? identifier_1.Identifier.make(what.content.str) : what.content;
201
+ const builtIn = (name, binds) => {
202
+ const targets = resolve_helper_1.Resolve.byNameAndType(name, data.environment, identifier_1.ReferenceType.Function) ?? [];
203
+ return targets.length > 0 && targets.every(t => t.type === identifier_1.ReferenceType.BuiltInFunction && (!binds || built_in_props_1.CallProps.hasAny(t.config, built_in_props_1.CallProp.Scope) && !built_in_props_1.CallProps.hasAny(t.config, built_in_props_1.SemanticCallTag.LoadsPackage)));
204
+ };
205
+ return builtIn(content, true) && builtIn(list.functionName.content, false) ? { name: { ...what, type: type_1.RType.Symbol, content, lexeme: identifier_1.Identifier.toString(content) }, args: list.arguments } : undefined;
206
+ }
178
207
  /** Makes the node naming a function (`resolved`) the call of that function with `args`, as `do.call` does or evaluating a constructed call (`eval(call("f", x))`); a computed name gets a call of its own (`functionId`) that reads it. */
179
208
  function callNamedFunction(information, resolved, args, rootId, data, resolveInEnvironment, functionId = resolved.computed ? `${resolved.functionId}-call` : resolved.functionId) {
180
209
  const { functionName, asString } = resolved;
@@ -79,7 +79,8 @@ function yieldsEnvironment(node, graph, data) {
79
79
  }
80
80
  function tryReplacement(rootId, functionName, data, superAssignment, args, beforeDefine) {
81
81
  const resolved = resolve_helper_1.Resolve.byNameAndType(functionName.content, data.environment, identifier_1.ReferenceType.Function) ?? [];
82
- const builtIn = resolved.length === 1 && resolved[0].type === identifier_1.ReferenceType.BuiltInFunction ? resolved[0] : undefined;
82
+ /* an export named like a primitive (lubridate's `$<-`) is a method for it, which carries what flowR states about the primitive along, as the primitive still runs the call */
83
+ const builtIn = resolved.length === 1 && (resolved[0].type === identifier_1.ReferenceType.BuiltInFunction || 'processor' in resolved[0]) ? resolved[0] : undefined;
83
84
  /* every replacement function rebinds its target, no matter whether we ship a built-in for it or the user wrote it; a user-defined one is only ever bound under its `<-` name, the `<<-` form stays in the configuration */
84
85
  const name = builtIn ? functionName.content : identifier_1.Identifier.mapName(functionName.content, n => superAssignment ? n.slice(0, -'<<-'.length) + '<-' : n);
85
86
  const replacementConfig = builtIn ? builtIn.config : { readIndices: true, assignmentOperator: superAssignment ? '<<-' : '<-' };
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.processAttach = processAttach;
4
4
  exports.processDetach = processDetach;
5
+ const r_function_definition_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
5
6
  const r_argument_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
6
7
  const known_call_handling_1 = require("../known-call-handling");
7
8
  const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
@@ -43,7 +44,7 @@ _config = {}) {
43
44
  const injected = [];
44
45
  for (const entry of listed ?? []) {
45
46
  const at = entry.value.info.id;
46
- injected.push({ nodeId: at, name: entry.name?.content, type: identifier_1.ReferenceType.Variable, definedAt: rootId, cds: data.cds ? [...data.cds] : undefined });
47
+ injected.push({ nodeId: at, name: entry.name?.content, type: r_function_definition_1.RFunctionDefinition.is(entry.value) ? identifier_1.ReferenceType.Function : identifier_1.ReferenceType.Variable, definedAt: rootId, cds: data.cds ? [...data.cds] : undefined });
47
48
  result.graph.addEdge(at, rootId, edge_1.EdgeType.Reads);
48
49
  }
49
50
  for (const column of dataset?.columns ?? []) {
@@ -1,8 +1,19 @@
1
1
  import { type DataflowProcessorInformation } from '../../../../../processor';
2
2
  import { type DataflowInformation } from '../../../../../info';
3
- import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
3
+ import type { AstIdMap, ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
4
4
  import type { PotentiallyEmptyRArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
5
5
  import type { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
6
6
  import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
7
+ import type { ResolveInfo } from '../../../../../eval/resolve/alias-tracking';
8
+ import type { DataflowGraph } from '../../../../../graph/graph';
9
+ import type { RForLoop } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-for-loop';
10
+ /**
11
+ * Whether the for loop certainly runs its body to the end once, as {@link processForLoop} defines what the body defines as definitely
12
+ * as the code around the loop: it iterates over a vector with an element, and no `break` or `next` of its own cuts the first iteration short.
13
+ */
14
+ export declare function runsBodyOnce(loop: RForLoop<ParentInformation>, info: ResolveInfo & {
15
+ readonly idMap: AstIdMap;
16
+ readonly graph: DataflowGraph;
17
+ }): boolean;
7
18
  /** Processes a for-loop call: `for(<variable> in <vector>) <body>` desugared as a call of `for` with the three as arguments. */
8
19
  export declare function processForLoop<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): DataflowInformation;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runsBodyOnce = runsBodyOnce;
3
4
  exports.processForLoop = processForLoop;
4
5
  const hooks_1 = require("../../../../../hooks");
5
6
  const r_argument_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
@@ -18,6 +19,10 @@ const apply_kill_1 = require("../../../../../environments/apply-kill");
18
19
  const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
19
20
  const built_in_ambient_state_1 = require("./built-in-ambient-state");
20
21
  const node_value_1 = require("../../../../../eval/resolve/node-value");
22
+ const model_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/model");
23
+ const r_break_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-break");
24
+ const r_next_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-next");
25
+ const r_function_definition_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
21
26
  const r_binary_op_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-binary-op");
22
27
  const vertex_1 = require("../../../../../graph/vertex");
23
28
  const environment_1 = require("../../../../../environments/environment");
@@ -27,19 +32,32 @@ function hasElement(value) {
27
32
  return value.type === 'vector' ? Array.isArray(value.elements) && value.elements.length > 0 : ScalarTypes.has(value.type);
28
33
  }
29
34
  /** whether the node certainly holds a value and every value it may hold satisfies `holds` */
30
- function alwaysHolds(node, data, holds) {
31
- const values = node_value_1.NodeValue.setOf(node.info.id, data)?.elements;
35
+ function alwaysHolds(node, against, holds) {
36
+ const values = node_value_1.NodeValue.setOf(node.info.id, against)?.elements;
32
37
  return values !== undefined && values.length > 0 && values.every(holds);
33
38
  }
34
39
  /** `a:b` always has an element or fails, unless both sides are factors, which a plain value is not */
35
- function isNonEmptyRange(vector, entry, data) {
40
+ function isNonEmptyRange(vector, graph, against) {
36
41
  if (!r_binary_op_1.RBinaryOp.is(vector) || vector.operator !== ':') {
37
42
  return false;
38
43
  }
39
- if (!vertex_1.DfgVertex.hasOrigin(entry.graph.getVertex(vector.info.id), built_in_proc_name_1.BuiltInProcName.Default)) {
44
+ if (!vertex_1.DfgVertex.hasOrigin(graph.getVertex(vector.info.id), built_in_proc_name_1.BuiltInProcName.Default)) {
40
45
  return false;
41
46
  }
42
- return [vector.lhs, vector.rhs].some(side => alwaysHolds(side, data, v => v.type !== 'vector' && hasElement(v)));
47
+ return [vector.lhs, vector.rhs].some(side => alwaysHolds(side, against, v => v.type !== 'vector' && hasElement(v)));
48
+ }
49
+ /** whether the loop iterates over a vector with an element, so it runs its body at least once */
50
+ const iterates = (vector, graph, against) => isNonEmptyRange(vector, graph, against) || alwaysHolds(vector, against, hasElement);
51
+ /**
52
+ * Whether the for loop certainly runs its body to the end once, as {@link processForLoop} defines what the body defines as definitely
53
+ * as the code around the loop: it iterates over a vector with an element, and no `break` or `next` of its own cuts the first iteration short.
54
+ */
55
+ function runsBodyOnce(loop, info) {
56
+ const cuts = [...model_1.RNode.collectAllIds(loop.body)].some(id => {
57
+ const node = info.idMap.get(id);
58
+ return (r_break_1.RBreak.is(node) || r_next_1.RNext.is(node)) && model_1.RNode.findEnclosing(id, info.idMap, n => r_function_definition_1.RFunctionDefinition.is(n) || model_1.RLoopConstructs.is(n)) === loop.info.id;
59
+ });
60
+ return !cuts && iterates(loop.vector, info.graph, info);
43
61
  }
44
62
  /** Processes a for-loop call: `for(<variable> in <vector>) <body>` desugared as a call of `for` with the three as arguments. */
45
63
  function processForLoop(name, args, rootId, data) {
@@ -57,7 +75,7 @@ function processForLoop(name, args, rootId, data) {
57
75
  return vector;
58
76
  }
59
77
  /* resolved before the loop variable is bound, as it may share the name of what the vector reads */
60
- const nonEmpty = isNonEmptyRange(vectorArg, vector, data) || alwaysHolds(vectorArg, data, hasElement);
78
+ const nonEmpty = iterates(vectorArg, vector.graph, data);
61
79
  const variable = (0, processor_1.processDataflowFor)(variableArg, data);
62
80
  let headEnvironments = environment_1.REnvironment.overwrite(vector.environment, variable.environment);
63
81
  /* only the vector's references and entry point are read past this, its graph is not */
@@ -8,7 +8,7 @@ import { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing
8
8
  import { type BrandedIdentifier, type BrandedNamespace } from '../../../../../environments/identifier';
9
9
  import type { BuiltInFnInfo } from '../../../../../environments/built-in-props';
10
10
  import { type REnvironmentInformation } from '../../../../../environments/environment';
11
- import type { FlowrAnalyzerContext } from '../../../../../../project/context/flowr-analyzer-context';
11
+ import type { ReadOnlyFlowrAnalyzerContext } from '../../../../../../project/context/flowr-analyzer-context';
12
12
  import { Package } from '../../../../../../project/plugins/package-version-plugins/package';
13
13
  /** Controls how {@link processLibrary} brings a package into scope. */
14
14
  export interface LibraryProcessorConfig extends BuiltInFnInfo {
@@ -46,12 +46,12 @@ export interface AttachSpec {
46
46
  /** Process a library call like `library` or `require` */
47
47
  export declare function processLibrary<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, config?: LibraryProcessorConfig): DataflowInformation;
48
48
  /** Materialize the empty built-in function-definition vertex for a package export (idempotent). */
49
- export declare function attachExportVertex(graph: DataflowGraph, builtInId: NodeId, environment: REnvironmentInformation, ctx: FlowrAnalyzerContext, cds?: readonly ControlDependency[]): void;
49
+ export declare function attachExportVertex(graph: DataflowGraph, builtInId: NodeId, environment: REnvironmentInformation, ctx: ReadOnlyFlowrAnalyzerContext, cds?: readonly ControlDependency[]): void;
50
50
  /**
51
51
  * Attaches `pack` as `library(pack)` does: its resolved exports, else what flowR states about it, else a bare
52
52
  * {@link EnvType.LoadedNamespace} recording the load. The `library()` processor and `Dataflow.library` both use this.
53
53
  */
54
- export declare function attachLibrary(pack: BrandedNamespace, dependency: Package | undefined, envInfo: REnvironmentInformation, ctx: FlowrAnalyzerContext, spec?: AttachSpec, loadedAt?: NodeId, cds?: readonly ControlDependency[]): REnvironmentInformation;
54
+ export declare function attachLibrary(pack: BrandedNamespace, dependency: Readonly<Package> | undefined, envInfo: REnvironmentInformation, ctx: ReadOnlyFlowrAnalyzerContext, spec?: AttachSpec, loadedAt?: NodeId, cds?: readonly ControlDependency[]): REnvironmentInformation;
55
55
  /**
56
56
  * The load calls (`library()`/`require()`) that brought package `pack` (any package if not given) into scope without a
57
57
  * database, collected from the {@link libraryLoadMarker} of every matching {@link EnvType.LoadedNamespace} layer below the
@@ -72,29 +72,29 @@ export declare function processPrefer<OtherInfo>(name: RSymbol<OtherInfo & Paren
72
72
  * Attaches `dependency`'s exports at `spec`'s {@link AttachSpec#pos|search position} (below global by default) and
73
73
  * returns the enriched environment (graph untouched). Used by `library()`, `import::from`, `box::use`, `requireNamespace`, and transitive side-effect propagation.
74
74
  */
75
- export declare function attachDependencyToEnvironment(dependency: Package, envInfo: REnvironmentInformation, ctx: FlowrAnalyzerContext, spec?: AttachSpec, definedAt?: NodeId): REnvironmentInformation;
75
+ export declare function attachDependencyToEnvironment(dependency: Readonly<Package>, envInfo: REnvironmentInformation, ctx: ReadOnlyFlowrAnalyzerContext, spec?: AttachSpec, definedAt?: NodeId): REnvironmentInformation;
76
76
  /**
77
77
  * Attach the {@link baseRPackages|base-R} exports below the global so bare base calls resolve without `library()`.
78
78
  * No-op when no database resolves a base package; the built layer is cached per {@link baseNamespaceCacheKey}.
79
79
  */
80
- export declare function attachBaseRNamespaces(env: REnvironmentInformation, ctx: FlowrAnalyzerContext): REnvironmentInformation;
80
+ export declare function attachBaseRNamespaces(env: REnvironmentInformation, ctx: ReadOnlyFlowrAnalyzerContext): REnvironmentInformation;
81
81
  /**
82
82
  * Attach the project's declared `DESCRIPTION` dependencies below the global, mirroring base-R auto-attach, so their bare
83
83
  * calls resolve without an explicit `library()`; skips a dependency no database resolves, no-ops via {@link isAttached}.
84
84
  */
85
- export declare function attachDeclaredDependencies(env: REnvironmentInformation, ctx: FlowrAnalyzerContext): REnvironmentInformation;
85
+ export declare function attachDeclaredDependencies(env: REnvironmentInformation, ctx: ReadOnlyFlowrAnalyzerContext): REnvironmentInformation;
86
86
  /** attach the analyzed package's own `NAMESPACE importFrom(...)` symbols (by their bare name) below the global, so a bare imported call resolves to its source package */
87
- export declare function attachProjectImports(env: REnvironmentInformation, ctx: FlowrAnalyzerContext): REnvironmentInformation;
87
+ export declare function attachProjectImports(env: REnvironmentInformation, ctx: ReadOnlyFlowrAnalyzerContext): REnvironmentInformation;
88
88
  /**
89
89
  * Attaches the packages `solver.assumeAttachedPackages` names as if the code had called `library()` on them.
90
90
  * Covers the case where such a call is simply not part of what is being analyzed (a snippet, a chunk, a cell).
91
91
  */
92
- export declare function attachAssumedPackages(env: REnvironmentInformation, ctx: FlowrAnalyzerContext): REnvironmentInformation;
92
+ export declare function attachAssumedPackages(env: REnvironmentInformation, ctx: ReadOnlyFlowrAnalyzerContext): REnvironmentInformation;
93
93
  /**
94
94
  * Defines the objects `R/sysdata.rda` lazy-loads into the package namespace: internal, not exported, available
95
95
  * to the package's own code without a call bringing them in. Modelled on the global env for R's resolution order.
96
96
  * @see https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Data-in-packages
97
97
  */
98
- export declare function defineProjectSysdata(env: REnvironmentInformation, ctx: FlowrAnalyzerContext): REnvironmentInformation;
98
+ export declare function defineProjectSysdata(env: REnvironmentInformation, ctx: ReadOnlyFlowrAnalyzerContext): REnvironmentInformation;
99
99
  /** attach every project-level environment layer in order: base R namespaces, the project's own `importFrom` symbols, its declared dependencies, whatever the configuration assumes attached, then the package's own system data */
100
- export declare function attachProject(env: REnvironmentInformation, ctx: FlowrAnalyzerContext): REnvironmentInformation;
100
+ export declare function attachProject(env: REnvironmentInformation, ctx: ReadOnlyFlowrAnalyzerContext): REnvironmentInformation;
@@ -105,8 +105,8 @@ function savedInto(paths, data) {
105
105
  const names = new Set();
106
106
  let complete = true;
107
107
  for (const path of paths) {
108
- const stem = r_string_1.RString.unquote(path).split(/[/\\]/).at(-1)?.split('.')[0];
109
- const writers = stem ? resolve_helper_1.Resolve.byName(ambient_state_name_1.AmbientStateName.file(stem), data.environment) : undefined;
108
+ const name = r_string_1.RString.unquote(path).split(/[/\\]/).at(-1);
109
+ const writers = name ? resolve_helper_1.Resolve.byName(ambient_state_name_1.AmbientStateName.file(name), data.environment) : undefined;
110
110
  if (writers === undefined || writers.length === 0) {
111
111
  return undefined;
112
112
  }
@@ -173,7 +173,6 @@ The following showcases the dependency view of the ${ctx.linkPage('flowr:vscode'
173
173
  ${(0, doc_playground_1.tryInPlayground)({
174
174
  code: playgroundSample,
175
175
  marks: ['lint:unused-definitions'],
176
- collapsed: [playground_link_1.PlaygroundBox.Deps],
177
176
  at: '10@unused_total'
178
177
  }, 'the linter example')}
179
178
 
@@ -200,7 +199,7 @@ ${res}
200
199
  * 🍕 **program slicing**\\
201
200
  Given a point of interest like the visualization of a plot, _flowR_ reduces the program to just the parts which are relevant
202
201
  for the computation of the point of interest.
203
- ${(0, doc_playground_1.tryInPlayground)({ code: example, marks: [playground_link_1.PlaygroundBox.Slice], collapsed: [playground_link_1.PlaygroundBox.Deps], at: '11@sum' }, 'the slicing example')}
202
+ ${(0, doc_playground_1.tryInPlayground)({ code: example, marks: [playground_link_1.PlaygroundBox.Slice], at: '11@sum' }, 'the slicing example')}
204
203
 
205
204
 
206
205
  ${(0, doc_general_1.prefixLines)((0, doc_structure_1.details)('Example: Slicing with flowR', `
@@ -22,7 +22,7 @@ export interface ShowQueryOptions {
22
22
  readonly prepare?: (builder: FlowrAnalyzerBuilder) => void;
23
23
  }
24
24
  /** Visualizes a query and its results in markdown format. */
25
- export declare function showQuery<Base extends SupportedQueryTypes, VirtualArguments extends VirtualCompoundConstraint<Base> = VirtualCompoundConstraint<Base>>(parser: KnownParser, code: string, queries: Queries<Base, VirtualArguments>, { showCode, collapseResult, withJson, shorthand, ctx, files, prepare }?: ShowQueryOptions): Promise<string>;
25
+ export declare function showQuery<Base extends SupportedQueryTypes, VirtualArguments extends VirtualCompoundConstraint<Base> = VirtualCompoundConstraint<Base>>(parser: KnownParser, code: string | readonly string[], queries: Queries<Base, VirtualArguments>, { showCode, collapseResult, withJson, shorthand, ctx, files, prepare }?: ShowQueryOptions): Promise<string>;
26
26
  export interface QueryDocumentation {
27
27
  /** only for virtual queries, active ones carry their {@link SupportedQuery.title} */
28
28
  readonly name?: string;
@@ -40,7 +40,9 @@ async function showQuery(parser, code, queries, { showCode, collapseResult, with
40
40
  analyzer.addFile(new flowr_file_1.FlowrInlineTextFile(file.name, file.content));
41
41
  }
42
42
  /* code naming one of the files above analyzes that file, as a package's code is analyzed */
43
- analyzer.addRequest(files?.some(f => `${retriever_1.fileProtocol}${f.name}` === code) ? (0, retriever_1.requestFromInput)(code) : code);
43
+ for (const c of typeof code === 'string' ? [code] : code) {
44
+ analyzer.addRequest(files?.some(f => `${retriever_1.fileProtocol}${f.name}` === c) ? (0, retriever_1.requestFromInput)(c) : c);
45
+ }
44
46
  const results = await analyzer.query(queries);
45
47
  const duration = performance.now() - now;
46
48
  const metaInfo = `
@@ -80,7 +82,7 @@ ${(0, doc_code_1.jsonWithLimit)(results)}
80
82
  ${showCode ? `
81
83
  <details> <summary style="color:gray">Original Code</summary>
82
84
 
83
- ${(0, doc_code_1.codeBlock)('r', code)}
85
+ ${(0, doc_code_1.codeBlock)('r', typeof code === 'string' ? code : code.join('\n'))}
84
86
 
85
87
  </details>
86
88
  ` : ''}
@@ -4,6 +4,8 @@ import { type DocMakerArgs, DocMaker } from './wiki-mk/doc-maker';
4
4
  export interface PackageExample {
5
5
  readonly code: string;
6
6
  readonly files: Readonly<Record<string, string>>;
7
+ /** files of {@link PackageExample#files} analyzed after the code, as a project analyzes all of its scripts */
8
+ readonly requests?: readonly string[];
7
9
  }
8
10
  /** what the wiki shows for each linting rule: its configuration and implementation types, its tests, and an example with findings */
9
11
  export declare const LintingRuleExamples: Readonly<Record<LintingRuleNames, {
@@ -262,6 +262,12 @@ server <- function(input, output, session) {
262
262
  },
263
263
  'autoload-files': {
264
264
  example: { code: 'f <- function() 1', files: { '.RProfile': 'system("rm -rf /")' } }
265
+ },
266
+ 'notebook-cell-order': {
267
+ example: '# %%\nprint(total)\n# %%\ntotal <- 1 + 2'
268
+ },
269
+ 'project-entry-point': {
270
+ example: { code: 'print(total)', files: { 'R/setup.R': 'total <- 1 + 2' }, requests: ['R/setup.R'] }
265
271
  }
266
272
  };
267
273
  /** the kinds of issue a rule finds, each rule carries at most one */
@@ -347,7 +353,7 @@ More examples are the test cases in ${(0, doc_files_1.linkFlowRSourceFile)(`test
347
353
  async function exampleQuery(parser, name, example, config = {}) {
348
354
  const queries = [{ type: 'linter', rules: [{ name, config: config }] }];
349
355
  const shown = typeof example === 'string' ? await (0, doc_query_1.showQuery)(parser, example, queries, { withJson: false })
350
- : await (0, doc_query_1.showQuery)(parser, `${retriever_1.fileProtocol}${ExampleRoot}/R/code.R`, queries, {
356
+ : await (0, doc_query_1.showQuery)(parser, [`${retriever_1.fileProtocol}${ExampleRoot}/R/code.R`, ...(example.requests ?? []).map(f => `${retriever_1.fileProtocol}${ExampleRoot}/${f}`)], queries, {
351
357
  withJson: false,
352
358
  files: [['R/code.R', example.code], ...Object.entries(example.files)].map(([file, content]) => ({ name: `${ExampleRoot}/${file}`, content }))
353
359
  });
@@ -973,6 +973,34 @@ ${await (0, doc_query_1.showQuery)(shell, '', [{ type: 'function-info', name: 'g
973
973
  ${(0, doc_structure_1.block)('NOTE', `To find out what a script _uses_, reach for the ${(0, doc_query_1.linkToQueryOfName)('dependencies')}; to inspect a specific
974
974
  package/version in the database directly, reach for the ${(0, doc_query_1.linkToQueryOfName)('signature')}. In the REPL, \`:signature info <name>\` is a shorthand for this query.`)}
975
975
  `);
976
+ (0, doc_query_1.registerQueryDocumentation)('cell-order', {
977
+ type: 'active',
978
+ shortDescription: 'Checks in which orders the cells of a notebook run.',
979
+ buildExplanation: async (shell, _) => {
980
+ const exampleCode = '# %%\nprint(total)\n# %%\ntotal <- 1 + 2';
981
+ return `
982
+ The cells are the chunks of an R Markdown or Quarto document, the code cells of a Jupyter notebook, or the \`# %%\` cells of a script, numbered from 0.
983
+ The query checks the given \`order\` (top to bottom by default), lists up to \`orders\` working orders, and with \`changed\` names the cells that may have to run again after these cells ran again or were edited.
984
+ ${await (0, doc_query_1.showQuery)(shell, exampleCode, [{ type: 'cell-order', orders: 3, changed: [1] }])}
985
+ `;
986
+ }
987
+ });
988
+ (0, doc_query_1.registerQueryDocumentation)('aliases', {
989
+ type: 'active',
990
+ shortDescription: 'Returns all aliases of a given identifier.',
991
+ buildExplanation: async (shell, _) => {
992
+ const exampleCode = 'x <- 1\ng <- x\nh <- g';
993
+ const criteria = ['1@x'];
994
+ const id = [3];
995
+ return `
996
+ If the identifier is given as a NodeId the aliases will be returned as NodeId as well. If the identifier uses a slicing criterion the location of the corresponding aliases will be returned.
997
+ The following example uses both functionalities:
998
+ Given the code ${(0, doc_code_1.codeBlock)('r', exampleCode)}. Here '2@g' resolves to NodeId 3.
999
+ Then the following query will return the location of the aliases of x and the NodeIds of the aliases of g.
1000
+ ${await (0, doc_query_1.showQuery)(shell, exampleCode, [{ type: 'aliases', criteria: criteria, id: id }])}
1001
+ `;
1002
+ }
1003
+ });
976
1004
  /** https://github.com/flowr-analysis/flowr/wiki/Query-API */
977
1005
  class WikiQuery extends doc_maker_1.DocMaker {
978
1006
  constructor() {
@@ -100,13 +100,17 @@ export declare const LintQuickFix: {
100
100
  * Every kind of fix is named here, so a new one cannot quietly inherit the behaviour of another.
101
101
  */
102
102
  readonly inserted: (this: void, fix: LintQuickFix) => string;
103
+ /** The fixes a finding offers to choose from: its {@link LintingResult#quickFix} first, then its {@link LintingResult#alternatives}, each a list of edits carried out together. */
104
+ readonly choices: (this: void, result: Pick<LintingResult, "quickFix" | "alternatives">) => readonly (readonly LintQuickFix[])[];
103
105
  };
104
106
  /** A linting result for a single linting rule match. */
105
107
  export interface LintingResult {
106
108
  /** The certainty of the linting result. */
107
109
  readonly certainty: LintingResultCertainty;
108
- /** If available, what to do to fix the linting result. */
110
+ /** If available, what to do to fix the linting result: the edits of one fix, which are carried out together. */
109
111
  readonly quickFix?: LintQuickFix[];
112
+ /** Other fixes to choose from instead of the {@link LintingResult#quickFix}, each again the edits carried out together, see {@link LintQuickFix.choices}. */
113
+ readonly alternatives?: readonly (readonly LintQuickFix[])[];
110
114
  /** The node ID or IDs involved in this linting result, if applicable. */
111
115
  readonly involvedId: NodeId | NodeId[] | undefined;
112
116
  /** The source location where this linting result occurs */
@@ -33,6 +33,10 @@ exports.LintQuickFix = {
33
33
  default:
34
34
  (0, assert_1.assertUnreachable)(fix);
35
35
  }
36
+ },
37
+ /** The fixes a finding offers to choose from: its {@link LintingResult#quickFix} first, then its {@link LintingResult#alternatives}, each a list of edits carried out together. */
38
+ choices(result) {
39
+ return [result.quickFix ?? [], ...result.alternatives ?? []].filter(fix => fix.length > 0);
36
40
  }
37
41
  };
38
42
  /**
@@ -30,14 +30,14 @@ function findings(results) {
30
30
  const perRule = perRuleResults;
31
31
  /* staying silent about a rule that threw would claim it passed */
32
32
  if (linter_format_1.LintingResults.isError(perRule)) {
33
- return [{ rule, message: `the linting rule failed: ${linter_format_1.LintingResults.stringifyError(perRule)}`, level: 'error', loc: undefined, quickFix: [] }];
33
+ return [{ rule, message: `the linting rule failed: ${linter_format_1.LintingResults.stringifyError(perRule)}`, level: 'error', loc: undefined, fixes: [] }];
34
34
  }
35
35
  return perRule.results.map(result => ({
36
36
  rule,
37
37
  message: linter_rules_1.LintingRules[rule].prettyPrint[linter_format_1.LintingPrettyPrintContext.Query](result, perRule['.meta']),
38
38
  level: (result.certainty === linter_format_1.LintingResultCertainty.Certain ? 'warning' : 'note'),
39
39
  loc: result.loc,
40
- quickFix: result.quickFix ?? []
40
+ fixes: linter_format_1.LintQuickFix.choices(result)
41
41
  }));
42
42
  });
43
43
  }
@@ -58,28 +58,30 @@ function sarifLocation(loc) {
58
58
  }];
59
59
  }
60
60
  /**
61
- * The quick fixes of one finding as SARIF `fixes`. A fix needs a file and a span to change, so the ones flowR cannot
62
- * place are left out rather than reported against no artifact or an invalid region.
61
+ * The fixes to choose from of one finding as SARIF `fixes`, the edits of each as the changes it makes. A fix needs a file and
62
+ * a span for each edit, so one flowR cannot place is left out rather than reported against no artifact or an invalid region.
63
63
  */
64
- function sarifFixes(fixes) {
65
- return fixes.flatMap(fix => {
66
- const file = range_1.SourceLocation.getFile(fix.loc);
67
- if (file === undefined || !linter_format_1.LintQuickFix.isPlaced(fix)) {
64
+ function sarifFixes(choices) {
65
+ return choices.flatMap(fix => {
66
+ if (fix.some(edit => range_1.SourceLocation.getFile(edit.loc) === undefined || !linter_format_1.LintQuickFix.isPlaced(edit))) {
68
67
  return [];
69
68
  }
70
- const [startLine, startColumn, endLine, endColumn] = range_1.SourceLocation.getRange(fix.loc);
71
69
  return [{
72
- description: { text: fix.description },
73
- artifactChanges: [{
74
- artifactLocation: { uri: reportedPath(file) },
70
+ description: { text: describeFix(fix) },
71
+ artifactChanges: fix.map(edit => {
72
+ const [startLine, startColumn, endLine, endColumn] = range_1.SourceLocation.getRange(edit.loc);
73
+ return {
74
+ artifactLocation: { uri: reportedPath(range_1.SourceLocation.getFile(edit.loc)) },
75
75
  replacements: [{
76
76
  deletedRegion: { startLine, startColumn, endLine, endColumn },
77
- insertedContent: { text: linter_format_1.LintQuickFix.inserted(fix) }
77
+ insertedContent: { text: linter_format_1.LintQuickFix.inserted(edit) }
78
78
  }]
79
- }]
79
+ };
80
+ })
80
81
  }];
81
82
  });
82
83
  }
84
+ const describeFix = (fix) => (0, arrays_1.uniqueArray)(fix.map(edit => edit.description)).join('; ');
83
85
  /**
84
86
  * Renders the linting results as SARIF 2.1.0, the format code scanners (e.g. GitHub's) ingest, on a single line.
85
87
  * Only the rules that produced a finding are described, as SARIF requires every reported rule to be declared.
@@ -105,7 +107,7 @@ function lintsToSarif(results, flowrVersion) {
105
107
  }
106
108
  },
107
109
  results: flat.map(f => {
108
- const fixes = sarifFixes(f.quickFix);
110
+ const fixes = sarifFixes(f.fixes);
109
111
  return {
110
112
  ruleId: f.rule,
111
113
  level: f.level,
@@ -129,7 +131,7 @@ function lintsToGithub(results) {
129
131
  const loc = f.loc !== undefined && f.loc[4] !== undefined ? f.loc : undefined;
130
132
  const where = loc === undefined ? '' : ` file=${escapeGithubData(reportedPath(loc[4]))},line=${loc[0]},col=${loc[1]},endLine=${loc[2]},endColumn=${loc[3]},`;
131
133
  // github annotations carry no fix of their own, so the offer goes into the message
132
- const fixes = f.quickFix.length === 0 ? '' : ` [quick fix: ${f.quickFix.map(fix => fix.description).join('; ')}]`;
134
+ const fixes = f.fixes.length === 0 ? '' : ` [quick fix: ${f.fixes.map(describeFix).join(' or ')}]`;
133
135
  return `::${githubCommand[f.level]}${where}${loc === undefined ? ' ' : ''}title=${escapeGithubData(f.rule)}::${escapeGithubData(f.message + fixes)}`;
134
136
  }).join('\n');
135
137
  }