@eagleoutice/flowr 2.16.3 → 2.16.5

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 (148) hide show
  1. package/README.md +14 -14
  2. package/cli/repl/core.js +13 -2
  3. package/cli/repl/parser/slice-query-parser.d.ts +21 -5
  4. package/cli/repl/parser/slice-query-parser.js +33 -13
  5. package/core/steps/all/static-slicing/10-reconstruct.d.ts +2 -2
  6. package/dataflow/environments/built-in.d.ts +2 -0
  7. package/dataflow/environments/built-in.js +10 -2
  8. package/dataflow/environments/data-masking-functions.js +2 -1
  9. package/dataflow/environments/default-builtin-config.d.ts +31 -5
  10. package/dataflow/environments/default-builtin-config.js +12 -15
  11. package/dataflow/environments/query-fn-props.js +2 -1
  12. package/dataflow/eval/resolve/alias-tracking.js +5 -2
  13. package/dataflow/eval/resolve/node-value.js +1 -1
  14. package/dataflow/eval/resolve/resolve-argument.js +2 -0
  15. package/dataflow/eval/resolve/resolve-strings.d.ts +10 -0
  16. package/dataflow/eval/resolve/resolve-strings.js +79 -12
  17. package/dataflow/eval/resolve/resolve.js +2 -6
  18. package/dataflow/extractor.js +11 -4
  19. package/dataflow/graph/applied-arguments.d.ts +5 -0
  20. package/dataflow/graph/applied-arguments.js +17 -0
  21. package/dataflow/graph/df-helper.js +2 -2
  22. package/dataflow/graph/graph.d.ts +5 -0
  23. package/dataflow/graph/graph.js +5 -0
  24. package/dataflow/info.js +8 -1
  25. package/dataflow/internal/linker.js +35 -13
  26. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +9 -1
  27. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +32 -12
  28. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +8 -1
  29. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +7 -4
  30. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +11 -1
  31. package/dataflow/internal/process/functions/call/named-call-handling.js +4 -2
  32. package/dataflow/internal/process/functions/call/quoted.js +3 -3
  33. package/dataflow/internal/program-order.js +7 -1
  34. package/dataflow/processor.d.ts +2 -0
  35. package/documentation/doc-util/doc-query.d.ts +1 -1
  36. package/documentation/doc-util/doc-query.js +3 -1
  37. package/documentation/doc-util/doc-timings.js +3 -2
  38. package/documentation/doc-util/doc-types.js +4 -0
  39. package/documentation/wiki-create-linting-rules.js +1 -1
  40. package/documentation/wiki-linter.d.ts +14 -0
  41. package/documentation/wiki-linter.js +341 -126
  42. package/linter/linter-executor.js +7 -0
  43. package/linter/linter-rules.d.ts +47 -47
  44. package/linter/rules/absolute-path.d.ts +1 -1
  45. package/linter/rules/absolute-path.js +6 -4
  46. package/linter/rules/cmd-check/call-arguments.d.ts +1 -1
  47. package/linter/rules/cmd-check/call-arguments.js +10 -5
  48. package/linter/rules/cmd-check/compiled-code.d.ts +1 -1
  49. package/linter/rules/cmd-check/compiled-code.js +1 -1
  50. package/linter/rules/cmd-check/conformance.d.ts +5 -1
  51. package/linter/rules/cmd-check/conformance.js +64 -64
  52. package/linter/rules/cmd-check/description-metadata.d.ts +1 -1
  53. package/linter/rules/cmd-check/description-metadata.js +1 -1
  54. package/linter/rules/cmd-check/documentation-mismatch.d.ts +6 -0
  55. package/linter/rules/cmd-check/foreign-function-calls.d.ts +1 -1
  56. package/linter/rules/cmd-check/foreign-function-calls.js +1 -1
  57. package/linter/rules/cmd-check/namespace-tampering.d.ts +1 -1
  58. package/linter/rules/cmd-check/namespace-tampering.js +1 -1
  59. package/linter/rules/cmd-check/non-ascii-code.d.ts +1 -1
  60. package/linter/rules/cmd-check/non-ascii-code.js +1 -1
  61. package/linter/rules/cmd-check/package-data.d.ts +3 -1
  62. package/linter/rules/cmd-check/package-data.js +1 -1
  63. package/linter/rules/cmd-check/package-hooks.d.ts +2 -2
  64. package/linter/rules/cmd-check/package-hooks.js +13 -5
  65. package/linter/rules/cmd-check/package-metafiles.d.ts +1 -1
  66. package/linter/rules/cmd-check/package-metafiles.js +1 -1
  67. package/linter/rules/cmd-check/package-structure.d.ts +1 -1
  68. package/linter/rules/cmd-check/package-structure.js +1 -1
  69. package/linter/rules/cmd-check/rd-files.d.ts +17 -1
  70. package/linter/rules/cmd-check/rd-files.js +1 -1
  71. package/linter/rules/cmd-check/true-false-abbreviation.d.ts +1 -1
  72. package/linter/rules/cmd-check/true-false-abbreviation.js +1 -1
  73. package/linter/rules/dataframe-access-validation.d.ts +1 -1
  74. package/linter/rules/dataframe-access-validation.js +1 -1
  75. package/linter/rules/dead-code.d.ts +4 -4
  76. package/linter/rules/dead-code.js +19 -4
  77. package/linter/rules/deprecated-functions.d.ts +1 -1
  78. package/linter/rules/deprecated-functions.js +1 -1
  79. package/linter/rules/file-path-validity.d.ts +6 -2
  80. package/linter/rules/file-path-validity.js +7 -3
  81. package/linter/rules/namespace-access.d.ts +3 -3
  82. package/linter/rules/namespace-access.js +12 -3
  83. package/linter/rules/naming-convention.d.ts +1 -1
  84. package/linter/rules/naming-convention.js +1 -1
  85. package/linter/rules/network-functions.d.ts +1 -1
  86. package/linter/rules/network-functions.js +1 -1
  87. package/linter/rules/no-leaked-credentials.d.ts +1 -1
  88. package/linter/rules/no-leaked-credentials.js +1 -1
  89. package/linter/rules/problematic-inputs.d.ts +2 -2
  90. package/linter/rules/problematic-inputs.js +4 -4
  91. package/linter/rules/roxygen-arguments.d.ts +2 -2
  92. package/linter/rules/roxygen-arguments.js +2 -2
  93. package/linter/rules/seeded-randomness.d.ts +2 -2
  94. package/linter/rules/seeded-randomness.js +2 -2
  95. package/linter/rules/software-has-license.d.ts +2 -2
  96. package/linter/rules/software-has-license.js +2 -2
  97. package/linter/rules/software-has-tests.d.ts +2 -2
  98. package/linter/rules/software-has-tests.js +2 -2
  99. package/linter/rules/stop-with-call-arg.d.ts +3 -3
  100. package/linter/rules/stop-with-call-arg.js +22 -5
  101. package/linter/rules/syntactically-valid.d.ts +1 -1
  102. package/linter/rules/syntactically-valid.js +1 -1
  103. package/linter/rules/unclosed-connection.d.ts +2 -2
  104. package/linter/rules/unclosed-connection.js +2 -2
  105. package/linter/rules/undefined-symbol.d.ts +1 -1
  106. package/linter/rules/undefined-symbol.js +27 -4
  107. package/linter/rules/unescaped-arguments.d.ts +1 -1
  108. package/linter/rules/unescaped-arguments.js +1 -1
  109. package/linter/rules/unused-definition.d.ts +1 -1
  110. package/linter/rules/unused-definition.js +21 -2
  111. package/linter/rules/unused-import.d.ts +1 -1
  112. package/linter/rules/unused-import.js +1 -1
  113. package/linter/rules/useless-loop.d.ts +1 -1
  114. package/linter/rules/useless-loop.js +1 -1
  115. package/package.json +1 -1
  116. package/project/context/flowr-analyzer-environment-context.d.ts +1 -1
  117. package/project/context/flowr-analyzer-environment-context.js +2 -1
  118. package/project/context/flowr-analyzer-files-context.js +12 -11
  119. package/project/dependency-version-space.js +4 -6
  120. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +2 -0
  121. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +9 -8
  122. package/project/plugins/file-plugins/flowr-analyzer-test-file-plugin.js +1 -1
  123. package/project/plugins/file-plugins/flowr-analyzer-vignette-file-plugin.js +1 -1
  124. package/queries/catalog/dependencies-query/data-flow.d.ts +2 -0
  125. package/queries/catalog/dependencies-query/data-flow.js +6 -0
  126. package/queries/catalog/dependencies-query/dependencies-query-executor.js +31 -0
  127. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +5 -0
  128. package/queries/catalog/dependencies-query/implicit-echo.js +29 -30
  129. package/queries/catalog/dependencies-query/plot-objects.js +6 -2
  130. package/queries/catalog/dice-query/dice-query-format.d.ts +1 -1
  131. package/queries/catalog/dice-query/dice-query-format.js +1 -1
  132. package/queries/catalog/slice-query-options.d.ts +3 -3
  133. package/queries/catalog/slice-query-options.js +1 -1
  134. package/queries/catalog/static-slice-query/static-slice-query-executor.js +12 -1
  135. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +7 -1
  136. package/queries/catalog/static-slice-query/static-slice-query-format.js +4 -2
  137. package/queries/query.d.ts +2 -2
  138. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +19 -56
  139. package/reconstruct/inline/source-inline-map.d.ts +1 -1
  140. package/reconstruct/inline/source-inline-map.js +5 -3
  141. package/reconstruct/reconstruct.d.ts +8 -1
  142. package/reconstruct/reconstruct.js +12 -3
  143. package/slicing/static/removal-slice.d.ts +19 -0
  144. package/slicing/static/removal-slice.js +165 -0
  145. package/slicing/static/static-slicer.js +10 -5
  146. package/util/text/playground-link.d.ts +24 -1
  147. package/util/text/playground-link.js +16 -1
  148. package/util/version.js +2 -2
@@ -42,6 +42,7 @@ const match_args_1 = require("../../../../../graph/match-args");
42
42
  const known_call_handling_1 = require("../known-call-handling");
43
43
  const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
44
44
  const node_value_1 = require("../../../../../eval/resolve/node-value");
45
+ const applied_arguments_1 = require("../../../../../graph/applied-arguments");
45
46
  const unknown_side_effect_1 = require("../../../../../graph/unknown-side-effect");
46
47
  const edge_1 = require("../../../../../graph/edge");
47
48
  const assert_1 = require("../../../../../../util/assert");
@@ -68,6 +69,8 @@ exports.AmbientStateName = {
68
69
  files: '#files',
69
70
  /** written by a call writing a file we cannot name, which every call reading a file reads */
70
71
  anyFile: '#file:*',
72
+ /** the working directory `setwd` changes, which every call accessing a file reads to resolve a relative path */
73
+ workingDirectory: '#wd',
71
74
  /** the state of the random number generator, which `set.seed` sets and every draw advances */
72
75
  rng: '#rng',
73
76
  /** the kind of generator, which `set.seed` keeps unless it is given one */
@@ -337,15 +340,24 @@ function applyAmbientStateAccess(res, args, rootId, data, access) {
337
340
  writes.push(exports.AmbientStateName.rng);
338
341
  break;
339
342
  case "read-files" /* AmbientStateAccessType.ReadFiles */: {
340
- const stems = fileStems(res, rootId, data, access.sig);
341
- reads.push(...stems === undefined ? [exports.AmbientStateName.files] : [...stems.map(exports.AmbientStateName.file), exports.AmbientStateName.anyFile]);
343
+ const stems = fileStems(res, rootId, data, access);
344
+ reads.push(exports.AmbientStateName.workingDirectory, ...stems === undefined ? [exports.AmbientStateName.files] : [...stems.map(exports.AmbientStateName.file), exports.AmbientStateName.anyFile]);
342
345
  break;
343
346
  }
344
347
  case "write-files" /* AmbientStateAccessType.WriteFiles */: {
345
- const stems = fileStems(res, rootId, data, access.sig);
348
+ const stems = fileStems(res, rootId, data, access);
349
+ reads.push(exports.AmbientStateName.workingDirectory);
346
350
  writes.push(...stems === undefined ? [exports.AmbientStateName.anyFile] : stems.map(exports.AmbientStateName.file), exports.AmbientStateName.files);
347
351
  break;
348
352
  }
353
+ case "set-working-directory" /* AmbientStateAccessType.SetWorkingDirectory */:
354
+ /* a relative `dir` resolves against the current one, which the call also returns */
355
+ reads.push(exports.AmbientStateName.workingDirectory);
356
+ writes.push(exports.AmbientStateName.workingDirectory);
357
+ break;
358
+ case "get-working-directory" /* AmbientStateAccessType.GetWorkingDirectory */:
359
+ reads.push(exports.AmbientStateName.workingDirectory);
360
+ break;
349
361
  case "open-text-connection" /* AmbientStateAccessType.OpenTextConnection */:
350
362
  return openTextConnection(res, args, rootId, data);
351
363
  case "register-finalizer" /* AmbientStateAccessType.RegisterFinalizer */:
@@ -398,14 +410,14 @@ function openTextConnection(res, args, rootId, data) {
398
410
  markForcing(environment);
399
411
  return withAccess({ ...res, environment }, rootId, data, [], names.map(exports.AmbientStateName.textConnection));
400
412
  }
401
- /** The stems of the files the call names, `undefined` unless every file argument is a known path to a file with an extension (`plot%03d.png` or a directory may stand for others). */
402
- function fileStems(res, rootId, data, sig) {
413
+ /** 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). */
414
+ function fileStems(res, rootId, data, { sig, numbered }) {
403
415
  const call = res.graph.getVertex(rootId);
404
416
  if (sig === undefined || !vertex_1.DfgVertex.isFunctionCall(call)) {
405
417
  return undefined;
406
418
  }
407
- const named = match_args_1.MatchArgs.findWithProps(call.args, sig, built_in_props_1.ArgProp.Resource);
408
- if (named.length === 0 || named.length < sig.filter(([n, p]) => n !== '...' && (p & built_in_props_1.ArgProp.Resource) !== 0).length) {
419
+ const named = match_args_1.MatchArgs.findWithProps((0, applied_arguments_1.appliedArguments)(res.graph, call, data.completeAst.idMap).args, sig, built_in_props_1.ArgProp.Resource);
420
+ if (named.length === 0 || named.length < sig.filter(([n, p]) => n !== '...' && (p & built_in_props_1.ArgProp.Resource) !== 0 && (p & built_in_props_1.ArgProp.Forced) !== 0).length) {
409
421
  return undefined;
410
422
  }
411
423
  const stems = [];
@@ -413,7 +425,7 @@ function fileStems(res, rootId, data, sig) {
413
425
  const paths = node_value_1.NodeValue.stringsOf(id, data);
414
426
  for (const path of paths?.length ? paths : ['']) {
415
427
  const [stem, ...extension] = path.split(/[/\\]/).at(-1)?.split('.') ?? [];
416
- if (!stem || extension.length === 0 || /[%*?[]/.test(path)) {
428
+ if (!stem || extension.length === 0 || /[*?[]/.test(path) || (numbered && path.includes('%'))) {
417
429
  return undefined;
418
430
  }
419
431
  stems.push(stem);
@@ -441,8 +453,11 @@ function applyWithUnknownArguments(res, rootId, data, access) {
441
453
  switch (access.type) {
442
454
  case "close-device" /* AmbientStateAccessType.CloseDevice */:
443
455
  return deviceAccess(res, rootId, data, access.all ? 'close-all' : 'switch');
456
+ /* the arguments handed on (`do.call(readLines, list("a.txt"))`, `lapply(files, readLines)`) may still name the files */
444
457
  case "open-device" /* AmbientStateAccessType.OpenDevice */:
445
458
  case "switch-device" /* AmbientStateAccessType.SwitchDevice */:
459
+ case "read-files" /* AmbientStateAccessType.ReadFiles */:
460
+ case "write-files" /* AmbientStateAccessType.WriteFiles */:
446
461
  return applyAmbientStateAccess(res, [], rootId, data, access);
447
462
  case "set-options" /* AmbientStateAccessType.SetOptions */:
448
463
  /* like `options(op)`: it may set anything */
@@ -466,8 +481,10 @@ const UnknownArgumentAccess = {
466
481
  ["evaluate-quoted" /* AmbientStateAccessType.EvaluateQuoted */]: Quoted,
467
482
  ["set-rng" /* AmbientStateAccessType.SetRng */]: { reads: [exports.AmbientStateName.rngKind], writes: [exports.AmbientStateName.rng, exports.AmbientStateName.rngKind] },
468
483
  ["draw-rng" /* AmbientStateAccessType.DrawRng */]: { reads: [exports.AmbientStateName.rng], writes: [exports.AmbientStateName.rng] },
469
- ["read-files" /* AmbientStateAccessType.ReadFiles */]: { reads: [exports.AmbientStateName.files], writes: [] },
470
- ["write-files" /* AmbientStateAccessType.WriteFiles */]: { reads: [], writes: [exports.AmbientStateName.anyFile, exports.AmbientStateName.files] },
484
+ ["read-files" /* AmbientStateAccessType.ReadFiles */]: { reads: [exports.AmbientStateName.workingDirectory, exports.AmbientStateName.files], writes: [] },
485
+ ["write-files" /* AmbientStateAccessType.WriteFiles */]: { reads: [exports.AmbientStateName.workingDirectory], writes: [exports.AmbientStateName.anyFile, exports.AmbientStateName.files] },
486
+ ["set-working-directory" /* AmbientStateAccessType.SetWorkingDirectory */]: { reads: [exports.AmbientStateName.workingDirectory], writes: [exports.AmbientStateName.workingDirectory] },
487
+ ["get-working-directory" /* AmbientStateAccessType.GetWorkingDirectory */]: { reads: [exports.AmbientStateName.workingDirectory], writes: [] },
471
488
  ["open-text-connection" /* AmbientStateAccessType.OpenTextConnection */]: { reads: [], writes: [] },
472
489
  ["register-finalizer" /* AmbientStateAccessType.RegisterFinalizer */]: { reads: [], writes: [exports.AmbientStateName.finalizers] },
473
490
  ["run-finalizers" /* AmbientStateAccessType.RunFinalizers */]: { reads: [exports.AmbientStateName.finalizers], writes: [] }
@@ -482,8 +499,10 @@ function unknownArgumentAccess(access) {
482
499
  function deviceAccess(res, rootId, data, kind) {
483
500
  /* only a switch reads the state; what a closed device holds reaches its file through the plots on it (see LinkToLastPlot) */
484
501
  const reads = kind === 'switch' ? [exports.AmbientStateName.graphics] : [];
502
+ /* closing writes the file of the device, which its opening names unless we do not know the device closed */
503
+ const unnamedFile = kind === 'open' ? [] : [exports.AmbientStateName.anyFile, exports.AmbientStateName.files];
485
504
  if (data.environment.level > 0) {
486
- return withAccess(res, rootId, data, reads, [exports.AmbientStateName.graphics]);
505
+ return withAccess(res, rootId, data, reads, [exports.AmbientStateName.graphics, ...unnamedFile]);
487
506
  }
488
507
  const cds = data.cds ? [...data.cds] : undefined;
489
508
  const lookup = (name) => resolve_helper_1.Resolve.byName(name, res.environment) ?? [];
@@ -525,7 +544,8 @@ function deviceAccess(res, rootId, data, kind) {
525
544
  environment = setAmbient(environment, exports.AmbientStateName.otherDevicesOpenedBy, opener, true);
526
545
  break;
527
546
  }
528
- return withAccess({ ...res, environment }, rootId, data, reads, []);
547
+ const known = kind === 'close' ? opener.length > 0 : kind === 'close-all' && opener.length + otherOpeners.length > 0;
548
+ return withAccess({ ...res, environment }, rootId, data, reads, kind === 'open' || known ? [] : unnamedFile);
529
549
  }
530
550
  /** A call to `fn` made on our behalf (`do.call(fn, args)`, `sapply(x, fn)`): it accesses the state as `fn` does, or reads all of it if `fn` is opaque. */
531
551
  function applyAmbientStateOfCallee(res, callId, fn, data) {
@@ -135,7 +135,6 @@ function processApply(name, args, rootId, data, config) {
135
135
  }
136
136
  }
137
137
  else {
138
- information = (0, built_in_ambient_state_1.applyAmbientStateOfCallee)(information, functionId, functionName, data);
139
138
  /* a callee binding names (`do.call("assign", ...)`) does so with arguments we cannot see here; loading a package is handled on its own */
140
139
  if (resolve_helper_1.Resolve.byNameAndType(functionName, data.environment, identifier_1.ReferenceType.Function)?.some(t => t.type === identifier_1.ReferenceType.BuiltInFunction
141
140
  && 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))) {
@@ -151,6 +150,14 @@ function processApply(name, args, rootId, data, config) {
151
150
  cds: data.cds,
152
151
  origin: [built_in_proc_name_1.BuiltInProcName.Function]
153
152
  });
153
+ /* once the call has its arguments, which may name the files it accesses */
154
+ information = (0, built_in_ambient_state_1.applyAmbientStateOfCallee)(information, functionId, functionName, data);
155
+ /* `do.call(new.env, list())` creates an environment just like `new.env()` does */
156
+ const call = information.graph.getVertex(rootId);
157
+ if (vertex_1.DfgVertex.isFunctionCall(call) && resolve_helper_1.Resolve.byNameAndType(functionName, data.environment, identifier_1.ReferenceType.Function)
158
+ ?.some(t => t.type === identifier_1.ReferenceType.BuiltInFunction && t.processorName === built_in_proc_name_1.BuiltInProcName.NewEnv)) {
159
+ call.origin = [...Array.isArray(call.origin) ? call.origin : [], built_in_proc_name_1.BuiltInProcName.NewEnv];
160
+ }
154
161
  }
155
162
  for (const [i, arg] of processedArguments.entries()) {
156
163
  if (arg && !(anonymous && i === index)) {
@@ -486,12 +486,15 @@ function processAssignmentToSymbol(config) {
486
486
  envId = copied === undefined ? undefined : copied.envId ?? copied.nodeId;
487
487
  }
488
488
  else {
489
- const entryVertex = sourceArg.graph.getVertex(sourceArg.entryPoint);
489
+ /* `(list(...))` and `{ mk() }` hand on the value of what they hold */
490
+ const entry = valueEntry ?? sourceArg.entryPoint;
491
+ const value = data.completeAst.idMap.get(entry) ?? source;
492
+ const entryVertex = sourceArg.graph.getVertex(entry);
490
493
  if (vertex_1.DfgVertex.hasOrigin(entryVertex, built_in_proc_name_1.BuiltInProcName.List)) {
491
- envState = (0, built_in_list_1.resolveListToEnvState)(source, data);
494
+ envState = (0, built_in_list_1.resolveListToEnvState)(value, data);
492
495
  }
493
496
  else if (vertex_1.DfgVertex.hasOrigin(entryVertex, built_in_proc_name_1.BuiltInProcName.ClassGenerator)) {
494
- returnsEnvState = (0, built_in_class_generator_1.resolveClassMethodsToEnvState)(source, data);
497
+ returnsEnvState = (0, built_in_class_generator_1.resolveClassMethodsToEnvState)(value, data);
495
498
  }
496
499
  else if (vertex_1.DfgVertex.isFunctionDefinition(entryVertex) && entryVertex.returnEnvState !== undefined) {
497
500
  returnsEnvState = entryVertex.returnEnvState;
@@ -499,7 +502,7 @@ function processAssignmentToSymbol(config) {
499
502
  else if (vertex_1.DfgVertex.isFunctionCall(entryVertex) && entryVertex.name) {
500
503
  envState = (0, built_in_envir_utils_1.findReturnsEnvState)(resolve_helper_1.Resolve.byNameAndType(entryVertex.name, data.environment, identifier_1.ReferenceType.Function));
501
504
  }
502
- envState ??= (0, built_in_class_generator_1.resolveConstructorInstanceEnvState)(source, data);
505
+ envState ??= (0, built_in_class_generator_1.resolveConstructorInstanceEnvState)(value, data);
503
506
  }
504
507
  }
505
508
  const forces = quoteSource ? (0, built_in_ambient_state_1.ambientWritesBetween)(sourceArg.environment, data.environment) : [];
@@ -293,7 +293,8 @@ function processExpressionList(name, args, rootId, data) {
293
293
  const processedExpressions = [];
294
294
  let defaultReturnExpr;
295
295
  /* R prints what the top level of the analyzed script leaves visible, but not what a sourced file does */
296
- const autoPrint = data.referenceChain.length <= 1 && data.environment.level === 0 && data.completeAst.ast.files.some(f => f.root.info.id === rootId);
296
+ const fileRoot = data.completeAst.ast.files.some(f => f.root.info.id === rootId);
297
+ const autoPrint = data.referenceChain.length <= 1 && data.environment.level === 0 && fileRoot;
297
298
  let initialState;
298
299
  const hooks = [];
299
300
  for (const arg of args) {
@@ -303,7 +304,16 @@ function processExpressionList(name, args, rootId, data) {
303
304
  continue;
304
305
  }
305
306
  data.environment = environment;
307
+ /* a statement runs first where it is first analyzed, a file sourced again later does not move it */
308
+ const order = fileRoot && !data.statementOrder?.has(expression.info.id) ? data.statementOrder : undefined;
309
+ const span = order === undefined ? undefined : [order.size, Infinity];
310
+ if (span !== undefined) {
311
+ order?.set(expression.info.id, span);
312
+ }
306
313
  let processed = (0, processor_1.processDataflowFor)(expression, data);
314
+ if (span !== undefined) {
315
+ span[1] = order?.size ?? Infinity;
316
+ }
307
317
  const printed = autoPrint && (0, built_in_ambient_state_1.autoPrints)(expression, processed, data);
308
318
  if (printed) {
309
319
  processed = (0, built_in_ambient_state_1.readsOfAutoPrint)(processed, expression, data);
@@ -27,6 +27,7 @@ const assert_1 = require("../../../../../util/assert");
27
27
  const built_in_props_1 = require("../../../../environments/built-in-props");
28
28
  const query_fn_props_1 = require("../../../../environments/query-fn-props");
29
29
  const environment_1 = require("../../../../environments/environment");
30
+ const default_builtin_config_1 = require("../../../../environments/default-builtin-config");
30
31
  function mergeInformation(info, newInfo) {
31
32
  if (info === undefined) {
32
33
  return newInfo;
@@ -177,8 +178,9 @@ function processNamedCall(name, callArguments, rootId, data) {
177
178
  for (const own of toRun) {
178
179
  alternatives.push(own.processor(name, args, rootId, data));
179
180
  const pkg = own.name === undefined ? undefined : identifier_1.Identifier.getNamespace(own.name);
180
- /* unless flowR states how it accesses the state, as for `withr::with_options` */
181
- packageFn ||= pkg !== undefined && !(own.config !== undefined && ('ambient' in own.config || 'scope' in own.config)) && !(0, r_base_packages_1.isBaseRPackage)(String(pkg));
181
+ /* unless flowR states how it accesses the state, as for `withr::with_options`, or the export is a method the primitive dispatches to (lubridate's `rep`) */
182
+ packageFn ||= pkg !== undefined && !(own.config !== undefined && ('ambient' in own.config || 'scope' in own.config)) && !(0, r_base_packages_1.isBaseRPackage)(String(pkg))
183
+ && !default_builtin_config_1.InternalGenerics.has(identifier_1.Identifier.getName(own.name));
182
184
  }
183
185
  if (defaultProcessor && !shadowable) {
184
186
  processDefault();
@@ -110,7 +110,7 @@ exports.Quoted = {
110
110
  const reachOf = (sites) => reaches.get(sites.join('\0'));
111
111
  let enclosing;
112
112
  /* every call of a function lists the arguments of all its calls, so each is linked once per forces it meets */
113
- const linkedWith = new Map();
113
+ const linkedWith = new defaultmap_1.DefaultMap(() => new Set());
114
114
  for (const [id, vertex] of graph.verticesOfType(vertex_1.VertexType.FunctionCall)) {
115
115
  const masks = nse_1.Nse.dropResolvedMask(graph, id, vertex.name);
116
116
  if (masks !== undefined) {
@@ -163,8 +163,8 @@ exports.Quoted = {
163
163
  for (const argument of df_helper_1.Dataflow.argumentsBoundTo(graph, parameter)) {
164
164
  const index = namesOnce();
165
165
  const forces = forcesOf(graph, parameter, flow, forcing, reachOf);
166
- if (forces !== undefined && linkedWith.get(argument) !== forces) {
167
- linkedWith.set(argument, forces);
166
+ if (forces !== undefined && !linkedWith.get(argument).has(forces)) {
167
+ linkedWith.get(argument).add(forces);
168
168
  deferred_1.Deferred.link(graph, argument, index, idMap, forces);
169
169
  }
170
170
  }
@@ -44,6 +44,12 @@ function statementsAfter(id, statement, graph) {
44
44
  return 0;
45
45
  }
46
46
  const other = model_1.RNode.topLevelStatement(node, idMap);
47
- return other.info.parent === statement.info.parent ? other.info.index - statement.info.index : 0;
47
+ if (other.info.parent === statement.info.parent) {
48
+ return other.info.index - statement.info.index;
49
+ }
50
+ /* in another file, a statement is after one only if it starts once that one is done, and before only if it is done before that one starts */
51
+ const [start, end] = graph.statementOrder?.get(other.info.id) ?? [];
52
+ const [from, to] = graph.statementOrder?.get(statement.info.id) ?? [];
53
+ return start === undefined || end === undefined || from === undefined || to === undefined ? 0 : start >= to ? 1 : end <= from ? -1 : 0;
48
54
  }
49
55
  //# sourceMappingURL=program-order.js.map
@@ -70,6 +70,8 @@ export interface DataflowProcessorInformation<OtherInfo> {
70
70
  readonly rootId: NodeId;
71
71
  readonly argument: RArgument<OtherInfo & ParentInformation>;
72
72
  };
73
+ /** Where the top-level statements of every file start and end running, see {@link DataflowGraph#statementOrder} */
74
+ readonly statementOrder?: Map<NodeId, [start: number, end: number]>;
73
75
  }
74
76
  export type DataflowProcessor<OtherInfo, NodeType extends RNodeWithParent<OtherInfo>> = (node: NodeType, data: DataflowProcessorInformation<OtherInfo>) => DataflowInformation;
75
77
  type NodeWithKey<OtherInfo, Key> = RNode<OtherInfo & ParentInformation> & {
@@ -12,7 +12,7 @@ export interface ShowQueryOptions {
12
12
  readonly collapseQuery?: boolean;
13
13
  readonly shorthand?: string;
14
14
  readonly ctx?: GeneralDocContext;
15
- /** additional in-memory files registered before the request, e.g. the targets of `source(...)` calls */
15
+ /** additional in-memory files registered before the request, e.g. the targets of `source(...)` calls; a `code` of `file://<name>` analyzes one of them */
16
16
  readonly files?: readonly {
17
17
  readonly name: string;
18
18
  readonly content: string;
@@ -29,6 +29,7 @@ const query_print_1 = require("../../queries/query-print");
29
29
  const flowr_analyzer_builder_1 = require("../../project/flowr-analyzer-builder");
30
30
  const flowr_file_1 = require("../../project/context/flowr-file");
31
31
  const doc_cli_option_1 = require("./doc-cli-option");
32
+ const retriever_1 = require("../../r-bridge/retriever");
32
33
  const QueryDocFile = 'src/documentation/wiki-query.ts';
33
34
  /**
34
35
  * Visualizes a query and its results in markdown format.
@@ -41,7 +42,8 @@ async function showQuery(parser, code, queries, { showCode, collapseResult, coll
41
42
  for (const file of files ?? []) {
42
43
  analyzer.addFile(new flowr_file_1.FlowrInlineTextFile(file.name, file.content));
43
44
  }
44
- analyzer.addRequest(code);
45
+ /* code naming one of the files above analyzes that file, as a package's code is analyzed */
46
+ analyzer.addRequest(files?.some(f => `${retriever_1.fileProtocol}${f.name}` === code) ? (0, retriever_1.requestFromInput)(code) : code);
45
47
  const results = await analyzer.query(queries);
46
48
  const duration = performance.now() - now;
47
49
  const metaInfo = `
@@ -22,7 +22,7 @@ function docTook(ms) {
22
22
  return exports.ShowDocTimings ? ` required _${(0, time_1.printAsMs)(ms)}_ and` : '';
23
23
  }
24
24
  const TimingPatterns = [
25
- [/^(Query: [^\n(]*?) \([\d.]+ ?[a-zµ]+\)$/gm, '$1'],
25
+ [/^(Query: [^\n(]*?) \([\d.]+ ?[a-zµ]+\)(\\?)$/gm, '$1$2'],
26
26
  [/^[^\n]*\bTook [\d.]+ ?[a-zµ]+[^\n]*\n?/gm, ''],
27
27
  [/^_?All queries together required [^\n]*\n?/gm, ''],
28
28
  [/^[^\n]*(?:searchTimeMs|processTimeMs): [\d.]+[^\n]*\n?/gm, ''],
@@ -39,6 +39,7 @@ function withoutTimings(text) {
39
39
  if (exports.ShowDocTimings) {
40
40
  return text;
41
41
  }
42
- return TimingPatterns.reduce((t, [pattern, replacement]) => t.replace(pattern, replacement), text);
42
+ /* a removed line leaves the markdown line break before it with no line to break to */
43
+ return TimingPatterns.reduce((t, [pattern, replacement]) => t.replace(pattern, replacement), text).replace(/\\(?=\n[ \t]*(?:\n|$))/g, '');
43
44
  }
44
45
  //# sourceMappingURL=doc-timings.js.map
@@ -629,6 +629,10 @@ function retrieveNode(name, hierarchy, fuzzy = false, type = undefined) {
629
629
  return undefined;
630
630
  }
631
631
  }
632
+ if (!container) {
633
+ /* a bare name means the declaration itself, not a member that happens to share it (like the `Dataflow` gas key of `GasFeatureKey`) */
634
+ node = [...node.filter(n => n.extends.length === 0), ...node.filter(n => n.extends.length > 0)];
635
+ }
632
636
  return [container, name, node[0]];
633
637
  }
634
638
  /**
@@ -80,7 +80,7 @@ After implementing the rule, register it by adding it to ${ctx.link('LintingRule
80
80
 
81
81
  ## Step 5: Add the rule to the linter wiki generation
82
82
 
83
- After registering the rule, add a corresponding \`rule\` entry to the linter wiki generation in ${ctx.link('WikiLinter')}. These entries are used to generate the linter overview and the individual wiki pages for linting rules, which can then be inspected through ${ctx.linkPage('wiki/Linter')}.
83
+ After registering the rule, add its entry to ${ctx.link('LintingRuleExamples')}: the names of its configuration and implementation types, its test file, and an example that produces a finding (and a quick fix, if the rule offers one). The compiler asks for an entry for every rule, and a test runs every example to check that it shows what it should. These entries generate the linter overview and the individual wiki pages for linting rules, which can then be inspected through ${ctx.linkPage('wiki/Linter')}.
84
84
 
85
85
  ## Step 6: Add tests for the rule
86
86
 
@@ -1,5 +1,19 @@
1
+ import { type LintingRuleNames } from '../linter/linter-rules';
1
2
  import type { DocMakerArgs } from './wiki-mk/doc-maker';
2
3
  import { DocMaker } from './wiki-mk/doc-maker';
4
+ /** an example that needs files besides its code shows them as a project, its code in `R/code.R` */
5
+ export interface PackageExample {
6
+ readonly code: string;
7
+ readonly files: Readonly<Record<string, string>>;
8
+ }
9
+ /** what the wiki shows for each linting rule: its configuration and implementation types, its tests, and an example with findings */
10
+ export declare const LintingRuleExamples: Readonly<Record<LintingRuleNames, {
11
+ readonly configType: string;
12
+ readonly ruleType: string;
13
+ readonly testfile: string;
14
+ readonly example: string | PackageExample;
15
+ readonly config?: object;
16
+ }>>;
3
17
  /**
4
18
  * https://github.com/flowr-analysis/flowr/wiki/Linter
5
19
  */