@eagleoutice/flowr 2.17.9 → 2.17.10

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 (116) hide show
  1. package/cli/repl/core.js +4 -0
  2. package/config.d.ts +10 -0
  3. package/config.js +8 -1
  4. package/control-flow/control-flow-graph.js +11 -1
  5. package/dataflow/environments/default-builtin-config/guards-primitive-lang.js +1 -1
  6. package/dataflow/environments/default-builtin-config/guards.js +6 -1
  7. package/dataflow/environments/default-builtin-config/index.d.ts +1 -1
  8. package/dataflow/environments/default-builtin-config/network-access.d.ts +1 -1
  9. package/dataflow/environments/default-builtin-config/network-access.js +2 -0
  10. package/dataflow/environments/environment.d.ts +2 -0
  11. package/dataflow/environments/environment.js +5 -0
  12. package/dataflow/environments/frame-memory.d.ts +9 -0
  13. package/dataflow/environments/frame-memory.js +37 -0
  14. package/dataflow/environments/group-generics.d.ts +2 -0
  15. package/dataflow/environments/group-generics.js +7 -0
  16. package/dataflow/environments/identifier.d.ts +2 -0
  17. package/dataflow/environments/identifier.js +16 -0
  18. package/dataflow/environments/pkg-name.d.ts +1 -0
  19. package/dataflow/environments/query-fn-props.d.ts +4 -0
  20. package/dataflow/environments/query-fn-props.js +21 -4
  21. package/dataflow/environments/resolve-by-name.js +5 -3
  22. package/dataflow/extractor.js +26 -4
  23. package/dataflow/fn/guards/call-contracts.js +8 -4
  24. package/dataflow/fn/guards/function-guards.d.ts +13 -4
  25. package/dataflow/fn/guards/function-guards.js +147 -52
  26. package/dataflow/fn/guards/guard-term.d.ts +6 -3
  27. package/dataflow/fn/guards/guard-term.js +12 -6
  28. package/dataflow/graph/graph.d.ts +2 -0
  29. package/dataflow/graph/graph.js +9 -5
  30. package/dataflow/internal/dispatch-linking.d.ts +6 -0
  31. package/dataflow/internal/dispatch-linking.js +25 -0
  32. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.d.ts +32 -2
  33. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +52 -21
  34. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +28 -19
  35. package/dataflow/internal/process/functions/call/built-in/built-in-with.js +75 -0
  36. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +20 -6
  37. package/dataflow/processor.d.ts +3 -0
  38. package/documentation/data/faq/faqs.js +4 -0
  39. package/documentation/wiki-analyzer.js +13 -2
  40. package/documentation/wiki-interface.js +1 -0
  41. package/documentation/wiki-linter.js +3 -0
  42. package/linter/linter-executor.js +4 -1
  43. package/linter/linter-format.d.ts +5 -5
  44. package/linter/linter-rules.d.ts +47 -13
  45. package/linter/linter-rules.js +3 -1
  46. package/linter/rules/absolute-file-paths.js +1 -1
  47. package/linter/rules/autoload-files.d.ts +33 -0
  48. package/linter/rules/autoload-files.js +94 -0
  49. package/linter/rules/cmd-check/description-metadata.d.ts +2 -2
  50. package/linter/rules/cmd-check/description-metadata.js +1 -1
  51. package/linter/rules/cmd-check/documentation-mismatch.d.ts +2 -2
  52. package/linter/rules/cmd-check/documentation-mismatch.js +1 -1
  53. package/linter/rules/cmd-check/file-checks.d.ts +6 -11
  54. package/linter/rules/cmd-check/file-checks.js +8 -3
  55. package/linter/rules/cmd-check/package-data.d.ts +2 -2
  56. package/linter/rules/cmd-check/package-data.js +1 -1
  57. package/linter/rules/cmd-check/package-metafiles.js +1 -1
  58. package/linter/rules/cmd-check/package-structure.d.ts +2 -2
  59. package/linter/rules/cmd-check/package-structure.js +1 -1
  60. package/linter/rules/cmd-check/rd-files.js +1 -1
  61. package/linter/rules/naming-convention.d.ts +9 -2
  62. package/linter/rules/process-state-in-session.js +4 -1
  63. package/linter/rules/software-has-license.d.ts +2 -2
  64. package/linter/rules/software-has-license.js +1 -2
  65. package/linter/rules/stop-call.d.ts +8 -3
  66. package/linter/rules/useless-loop.d.ts +1 -1
  67. package/package.json +1 -1
  68. package/project/cache/flowr-analyzer-cache.d.ts +3 -0
  69. package/project/cache/flowr-analyzer-cache.js +9 -0
  70. package/project/context/flowr-analyzer-context.d.ts +4 -3
  71. package/project/context/flowr-analyzer-context.js +18 -6
  72. package/project/context/flowr-analyzer-dependencies-context.d.ts +9 -0
  73. package/project/context/flowr-analyzer-dependencies-context.js +35 -6
  74. package/project/context/flowr-analyzer-environment-context.d.ts +1 -0
  75. package/project/context/flowr-analyzer-environment-context.js +1 -0
  76. package/project/context/flowr-analyzer-files-context.d.ts +4 -0
  77. package/project/context/flowr-analyzer-files-context.js +24 -0
  78. package/project/context/flowr-analyzer-functions-context.d.ts +1 -0
  79. package/project/context/flowr-analyzer-functions-context.js +6 -0
  80. package/project/context/flowr-analyzer-gas-context.d.ts +1 -0
  81. package/project/context/flowr-analyzer-gas-context.js +1 -0
  82. package/project/context/flowr-analyzer-incremental-analysis-context.d.ts +24 -0
  83. package/project/context/flowr-analyzer-incremental-analysis-context.js +54 -0
  84. package/project/context/flowr-analyzer-loading-order-context.d.ts +1 -0
  85. package/project/context/flowr-analyzer-loading-order-context.js +14 -0
  86. package/project/context/flowr-analyzer-meta-context.d.ts +1 -0
  87. package/project/context/flowr-analyzer-meta-context.js +11 -0
  88. package/project/context/flowr-file.d.ts +2 -1
  89. package/project/context/flowr-file.js +5 -2
  90. package/project/flowr-analyzer.d.ts +22 -3
  91. package/project/flowr-analyzer.js +36 -0
  92. package/project/incremental/incremental-dataflow/incremental-dataflow.d.ts +142 -0
  93. package/project/incremental/incremental-dataflow/incremental-dataflow.js +330 -0
  94. package/project/plugins/flowr-analyzer-plugin.d.ts +22 -2
  95. package/project/plugins/flowr-analyzer-plugin.js +16 -1
  96. package/project/plugins/incremental/incremental-dataflow/flowr-analyzer-incremental-dataflow-heuristic-plugin.d.ts +52 -0
  97. package/project/plugins/incremental/incremental-dataflow/flowr-analyzer-incremental-dataflow-heuristic-plugin.js +50 -0
  98. package/project/plugins/incremental/incremental-dataflow/flowr-analyzer-incremental-dataflow-update-type-plugin.d.ts +77 -0
  99. package/project/plugins/incremental/incremental-dataflow/flowr-analyzer-incremental-dataflow-update-type-plugin.js +151 -0
  100. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.d.ts +2 -0
  101. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.js +4 -0
  102. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +1 -0
  103. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +3 -0
  104. package/project/plugins/plugin-registry.d.ts +3 -1
  105. package/project/plugins/plugin-registry.js +6 -1
  106. package/project/sigdb/decode.js +4 -1
  107. package/project/sigdb/dict.d.ts +7 -4
  108. package/project/sigdb/dict.js +20 -6
  109. package/project/sigdb/guarded-source.js +10 -0
  110. package/project/sigdb/reader.d.ts +8 -2
  111. package/project/sigdb/reader.js +44 -30
  112. package/queries/catalog/input-sources-query/simple-input-classifier.js +84 -10
  113. package/util/flowr-version.d.ts +1 -1
  114. package/util/flowr-version.js +2 -2
  115. package/util/objects.d.ts +14 -0
  116. package/util/objects.js +100 -0
@@ -52,6 +52,19 @@ var PluginType;
52
52
  * @see {@link FlowrAnalyzerGasPlugin} - for the base class to implement such a plugin.
53
53
  */
54
54
  PluginType["Gas"] = "gas";
55
+ /**
56
+ * Plugins that classifies the {@link IncrementalUpdateType}, so the dataflow analysis can be
57
+ * patched incrementally instead of fully recomputed. At most one may be registered; the default
58
+ * plugin runs otherwise.
59
+ * @see {@link FlowrAnalyzerIncrementalDataflowUpdateTypePlugin} - for the base class to implement such a plugin.
60
+ */
61
+ PluginType["IncrementalDataflowUpdateType"] = "incremental-dataflow-update-type";
62
+ /**
63
+ * Plugins that plan how a dataflow analysis builds on the one before (reuse it, resume from checkpoints, or start over).
64
+ * At most one may be registered; the plugin following the configuration runs otherwise.
65
+ * @see {@link FlowrAnalyzerIncrementalDataflowHeuristicPlugin} - for the base class to implement such a plugin.
66
+ */
67
+ PluginType["IncrementalDataflowHeuristic"] = "incremental-dataflow-heuristic";
55
68
  })(PluginType || (exports.PluginType = PluginType = {}));
56
69
  const generalPluginLog = log_1.log.getSubLogger({ name: 'plugins' });
57
70
  /**
@@ -67,7 +80,9 @@ class FlowrAnalyzerPlugin {
67
80
  static defaultPlugin() {
68
81
  throw new Error('This is to be implemented by every Plugin Layer');
69
82
  }
70
- /** Run the plugin with the given context and arguments. */
83
+ /**
84
+ * Run the plugin with the given context and arguments.
85
+ */
71
86
  processor(context, args) {
72
87
  const now = Date.now();
73
88
  try {
@@ -0,0 +1,52 @@
1
+ import { SemVer } from 'semver';
2
+ import { FlowrAnalyzerPlugin, PluginType } from '../../flowr-analyzer-plugin';
3
+ import type { FlowrAnalyzerContext } from '../../../context/flowr-analyzer-context';
4
+ import { type IncrementalUpdateResult } from './flowr-analyzer-incremental-dataflow-update-type-plugin';
5
+ /** How a dataflow analysis builds on the one before, see {@link FlowrAnalyzerIncrementalDataflowHeuristicPlugin}. */
6
+ export interface IncrementalDataflowPlan {
7
+ /** hand out the analysis before again if only comments changed, see `incremental.dataflow.reuse` */
8
+ readonly reuse: boolean;
9
+ /** after how many of the last top-level statements to keep a checkpoint to resume from, `0` resumes nothing, see `incremental.dataflow.checkpoints` */
10
+ readonly checkpoints: number;
11
+ /** the number of top-level statements the checkpoints end at, so that a change after them resumes; the end of the file by default */
12
+ readonly after?: number;
13
+ /** keep checkpoints only for files with at least this many top-level statements, see `incremental.dataflow.minStatements` */
14
+ readonly minStatements: number;
15
+ }
16
+ /** What a {@link FlowrAnalyzerIncrementalDataflowHeuristicPlugin} decides on. */
17
+ export interface IncrementalDataflowHeuristicInformation {
18
+ /** how many dataflow analyses the context ran before this one */
19
+ readonly analyses: number;
20
+ /** how the analysis before classified its change, and whether it reused anything */
21
+ readonly lastUpdate: IncrementalUpdateResult | undefined;
22
+ /** how the files of this analysis differ from those of the analysis before, if that kept them */
23
+ readonly update: IncrementalUpdateResult | undefined;
24
+ }
25
+ /**
26
+ * Base class for plugins that plan how a dataflow analysis builds on the one before, see {@link IncrementalDataflowPlan}.
27
+ * At most one may be registered, {@link AdaptiveFlowrAnalyzerIncrementalDataflowHeuristicPlugin} runs otherwise.
28
+ */
29
+ export declare abstract class FlowrAnalyzerIncrementalDataflowHeuristicPlugin extends FlowrAnalyzerPlugin<IncrementalDataflowHeuristicInformation, IncrementalDataflowPlan> {
30
+ readonly type = PluginType.IncrementalDataflowHeuristic;
31
+ static defaultPlugin(): FlowrAnalyzerIncrementalDataflowHeuristicPlugin;
32
+ }
33
+ /** Plans as {@link FlowrConfig.incremental.dataflow} states, checkpoints only if `activated`. */
34
+ export declare class ConfiguredFlowrAnalyzerIncrementalDataflowHeuristicPlugin extends FlowrAnalyzerIncrementalDataflowHeuristicPlugin {
35
+ readonly name = "configured-incremental-dataflow-heuristic-plugin";
36
+ readonly description = "Plans the incremental dataflow analysis as the incremental.dataflow configuration states.";
37
+ readonly version: SemVer;
38
+ protected process(ctx: FlowrAnalyzerContext): IncrementalDataflowPlan;
39
+ }
40
+ /**
41
+ * With `activated`, resumes only once a context analyzes its files again, as an editor or a watch does, and where it pays:
42
+ * the first analysis keeps no checkpoint, so an analysis that stays the only one costs nothing.
43
+ * Every later one keeps a single checkpoint, after the statements its change left as they were, as the next change likely happens where this one did.
44
+ * So changing a statement again resumes right before it, however far from the end of the file it is, at the cost of one copy of the analysis up to there,
45
+ * and a change that leaves nothing to resume from (e.g., of the first statement, or of one of multiple files) keeps no checkpoint at all.
46
+ */
47
+ export declare class AdaptiveFlowrAnalyzerIncrementalDataflowHeuristicPlugin extends FlowrAnalyzerIncrementalDataflowHeuristicPlugin {
48
+ readonly name = "adaptive-incremental-dataflow-heuristic-plugin";
49
+ readonly description = "Keeps a checkpoint for the incremental dataflow analysis only once the files are analyzed again, where the last change happened.";
50
+ readonly version: SemVer;
51
+ protected process(ctx: FlowrAnalyzerContext, { analyses, update }: IncrementalDataflowHeuristicInformation): IncrementalDataflowPlan;
52
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AdaptiveFlowrAnalyzerIncrementalDataflowHeuristicPlugin = exports.ConfiguredFlowrAnalyzerIncrementalDataflowHeuristicPlugin = exports.FlowrAnalyzerIncrementalDataflowHeuristicPlugin = void 0;
4
+ const semver_1 = require("semver");
5
+ const flowr_analyzer_plugin_1 = require("../../flowr-analyzer-plugin");
6
+ const flowr_analyzer_incremental_dataflow_update_type_plugin_1 = require("./flowr-analyzer-incremental-dataflow-update-type-plugin");
7
+ /**
8
+ * Base class for plugins that plan how a dataflow analysis builds on the one before, see {@link IncrementalDataflowPlan}.
9
+ * At most one may be registered, {@link AdaptiveFlowrAnalyzerIncrementalDataflowHeuristicPlugin} runs otherwise.
10
+ */
11
+ class FlowrAnalyzerIncrementalDataflowHeuristicPlugin extends flowr_analyzer_plugin_1.FlowrAnalyzerPlugin {
12
+ type = flowr_analyzer_plugin_1.PluginType.IncrementalDataflowHeuristic;
13
+ static defaultPlugin() {
14
+ return new AdaptiveFlowrAnalyzerIncrementalDataflowHeuristicPlugin();
15
+ }
16
+ }
17
+ exports.FlowrAnalyzerIncrementalDataflowHeuristicPlugin = FlowrAnalyzerIncrementalDataflowHeuristicPlugin;
18
+ /** Plans as {@link FlowrConfig.incremental.dataflow} states, checkpoints only if `activated`. */
19
+ class ConfiguredFlowrAnalyzerIncrementalDataflowHeuristicPlugin extends FlowrAnalyzerIncrementalDataflowHeuristicPlugin {
20
+ name = 'configured-incremental-dataflow-heuristic-plugin';
21
+ description = 'Plans the incremental dataflow analysis as the incremental.dataflow configuration states.';
22
+ version = new semver_1.SemVer('0.1.0');
23
+ process(ctx) {
24
+ const { reuse, activated, checkpoints, minStatements } = ctx.config.incremental.dataflow;
25
+ return { reuse, checkpoints: activated ? checkpoints : 0, minStatements };
26
+ }
27
+ }
28
+ exports.ConfiguredFlowrAnalyzerIncrementalDataflowHeuristicPlugin = ConfiguredFlowrAnalyzerIncrementalDataflowHeuristicPlugin;
29
+ /**
30
+ * With `activated`, resumes only once a context analyzes its files again, as an editor or a watch does, and where it pays:
31
+ * the first analysis keeps no checkpoint, so an analysis that stays the only one costs nothing.
32
+ * Every later one keeps a single checkpoint, after the statements its change left as they were, as the next change likely happens where this one did.
33
+ * So changing a statement again resumes right before it, however far from the end of the file it is, at the cost of one copy of the analysis up to there,
34
+ * and a change that leaves nothing to resume from (e.g., of the first statement, or of one of multiple files) keeps no checkpoint at all.
35
+ */
36
+ class AdaptiveFlowrAnalyzerIncrementalDataflowHeuristicPlugin extends FlowrAnalyzerIncrementalDataflowHeuristicPlugin {
37
+ name = 'adaptive-incremental-dataflow-heuristic-plugin';
38
+ description = 'Keeps a checkpoint for the incremental dataflow analysis only once the files are analyzed again, where the last change happened.';
39
+ version = new semver_1.SemVer('0.2.0');
40
+ process(ctx, { analyses, update }) {
41
+ const { reuse, activated, checkpoints, minStatements } = ctx.config.incremental.dataflow;
42
+ return { reuse, checkpoints: activated && analyses > 0 && mayResumeAfter(update) ? Math.min(checkpoints, 1) : 0, after: update?.commonPrefix, minStatements };
43
+ }
44
+ }
45
+ exports.AdaptiveFlowrAnalyzerIncrementalDataflowHeuristicPlugin = AdaptiveFlowrAnalyzerIncrementalDataflowHeuristicPlugin;
46
+ /** Whether an analysis may resume after a change like `update`: one that kept part of the analysis before, or an unknown one. */
47
+ function mayResumeAfter(update) {
48
+ return update === undefined || update.commonPrefix !== undefined || flowr_analyzer_incremental_dataflow_update_type_plugin_1.IncrementalUpdate.unchanged(update) || flowr_analyzer_incremental_dataflow_update_type_plugin_1.IncrementalUpdate.is(update, flowr_analyzer_incremental_dataflow_update_type_plugin_1.IncrementalUpdateType.NewFileAtEnd);
49
+ }
50
+ //# sourceMappingURL=flowr-analyzer-incremental-dataflow-heuristic-plugin.js.map
@@ -0,0 +1,77 @@
1
+ import { SemVer } from 'semver';
2
+ import { FlowrAnalyzerPlugin, PluginType } from '../../flowr-analyzer-plugin';
3
+ import type { FlowrAnalyzerContext } from '../../../context/flowr-analyzer-context';
4
+ import type { FilePath } from '../../../context/flowr-file';
5
+ import type { NormalizedAst, ParentInformation } from '../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
6
+ import type { RExpressionList } from '../../../../r-bridge/lang-4.x/ast/model/nodes/r-expression-list';
7
+ /** How the files of an analysis differ from those of the analysis before, see {@link FlowrAnalyzerIncrementalDataflowUpdateTypePlugin}. */
8
+ export declare enum IncrementalUpdateType {
9
+ /** Anything else, the dataflow is analyzed again from scratch. */
10
+ Full = "Full",
11
+ /** The single file got statements appended. */
12
+ AddedAtEnd = "AddedAtEnd",
13
+ /** The single file lost statements at its end. */
14
+ RemovedAtEnd = "RemovedAtEnd",
15
+ /** The single file changed after its first {@link IncrementalUpdateResult#commonPrefix|commonPrefix} statements. */
16
+ ChangedAtEnd = "ChangedAtEnd",
17
+ /** A file was added after all the files analyzed before. */
18
+ NewFileAtEnd = "NewFileAtEnd",
19
+ /** The last file analyzed before was removed. */
20
+ RemovedFileAtEnd = "RemovedFileAtEnd",
21
+ /** Only the source locations changed, which nodes created during the analysis copy, so this is analyzed again from the first statement that moved. */
22
+ Location = "Location",
23
+ /** Only comments changed, which the dataflow analysis does not read. */
24
+ Comment = "Comment",
25
+ /** Nothing changed. */
26
+ Nothing = "Nothing"
27
+ }
28
+ /**
29
+ * What a {@link FlowrAnalyzerIncrementalDataflowUpdateTypePlugin} classified, plus whether the incremental dataflow
30
+ * analysis actually reused the earlier analysis for it.
31
+ */
32
+ export interface IncrementalUpdateResult {
33
+ readonly types: readonly IncrementalUpdateType[];
34
+ /** The file the change happened in, if it is a single one. */
35
+ readonly filePath?: FilePath;
36
+ /** For a change within a single file, how many of its top-level statements stayed the same, locations included. */
37
+ readonly commonPrefix?: number;
38
+ /** Whether the incremental analysis reused anything for this change. */
39
+ readonly applied?: boolean;
40
+ }
41
+ /** Helper functions to ask an {@link IncrementalUpdateResult} what kind of change it is. */
42
+ export declare const IncrementalUpdate: {
43
+ readonly name: "IncrementalUpdate";
44
+ /** Whether the files changed in nothing the dataflow analysis reads, i.e., at most in their comments. */
45
+ readonly unchanged: (this: void, update: IncrementalUpdateResult) => boolean;
46
+ /** Whether `type` is the only kind of change. */
47
+ readonly is: (this: void, update: IncrementalUpdateResult, type: IncrementalUpdateType) => boolean;
48
+ };
49
+ /** A file as an analysis saw it before the dataflow analysis added the files it sourced. */
50
+ export interface AnalyzedFile {
51
+ readonly filePath: FilePath | undefined;
52
+ readonly root: RExpressionList<ParentInformation>;
53
+ }
54
+ /** What a {@link FlowrAnalyzerIncrementalDataflowUpdateTypePlugin} compares. */
55
+ export interface IncrementalDataflowUpdateTypeInformation {
56
+ readonly previous: readonly AnalyzedFile[];
57
+ readonly current: NormalizedAst;
58
+ }
59
+ /**
60
+ * Base class for plugins that classify how the files of an analysis changed since the analysis before,
61
+ * producing an {@link IncrementalUpdateResult} the incremental dataflow analysis acts on.
62
+ * At most one may be registered, {@link DefaultFlowrAnalyzerIncrementalDataflowUpdateTypePlugin} runs otherwise.
63
+ */
64
+ export declare abstract class FlowrAnalyzerIncrementalDataflowUpdateTypePlugin extends FlowrAnalyzerPlugin<IncrementalDataflowUpdateTypeInformation, IncrementalUpdateResult> {
65
+ readonly type = PluginType.IncrementalDataflowUpdateType;
66
+ static defaultPlugin(): FlowrAnalyzerIncrementalDataflowUpdateTypePlugin;
67
+ }
68
+ /**
69
+ * The default classifier, comparing the ASTs structurally.
70
+ * Node ids take part in the comparison, as the dataflow graph refers to the nodes by them.
71
+ */
72
+ export declare class DefaultFlowrAnalyzerIncrementalDataflowUpdateTypePlugin extends FlowrAnalyzerIncrementalDataflowUpdateTypePlugin {
73
+ readonly name = "default-incremental-dataflow-update-type-plugin";
74
+ readonly description = "Classifies changes by comparing the top-level statements of the analyzed files.";
75
+ readonly version: SemVer;
76
+ protected process(_ctx: FlowrAnalyzerContext, { previous, current }: IncrementalDataflowUpdateTypeInformation): IncrementalUpdateResult;
77
+ }
@@ -0,0 +1,151 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DefaultFlowrAnalyzerIncrementalDataflowUpdateTypePlugin = exports.FlowrAnalyzerIncrementalDataflowUpdateTypePlugin = exports.IncrementalUpdate = exports.IncrementalUpdateType = void 0;
4
+ const semver_1 = require("semver");
5
+ const flowr_analyzer_plugin_1 = require("../../flowr-analyzer-plugin");
6
+ const range_1 = require("../../../../util/range");
7
+ /** How the files of an analysis differ from those of the analysis before, see {@link FlowrAnalyzerIncrementalDataflowUpdateTypePlugin}. */
8
+ var IncrementalUpdateType;
9
+ (function (IncrementalUpdateType) {
10
+ /** Anything else, the dataflow is analyzed again from scratch. */
11
+ IncrementalUpdateType["Full"] = "Full";
12
+ /** The single file got statements appended. */
13
+ IncrementalUpdateType["AddedAtEnd"] = "AddedAtEnd";
14
+ /** The single file lost statements at its end. */
15
+ IncrementalUpdateType["RemovedAtEnd"] = "RemovedAtEnd";
16
+ /** The single file changed after its first {@link IncrementalUpdateResult#commonPrefix|commonPrefix} statements. */
17
+ IncrementalUpdateType["ChangedAtEnd"] = "ChangedAtEnd";
18
+ /** A file was added after all the files analyzed before. */
19
+ IncrementalUpdateType["NewFileAtEnd"] = "NewFileAtEnd";
20
+ /** The last file analyzed before was removed. */
21
+ IncrementalUpdateType["RemovedFileAtEnd"] = "RemovedFileAtEnd";
22
+ /** Only the source locations changed, which nodes created during the analysis copy, so this is analyzed again from the first statement that moved. */
23
+ IncrementalUpdateType["Location"] = "Location";
24
+ /** Only comments changed, which the dataflow analysis does not read. */
25
+ IncrementalUpdateType["Comment"] = "Comment";
26
+ /** Nothing changed. */
27
+ IncrementalUpdateType["Nothing"] = "Nothing";
28
+ })(IncrementalUpdateType || (exports.IncrementalUpdateType = IncrementalUpdateType = {}));
29
+ const UnchangedTypes = new Set([IncrementalUpdateType.Nothing, IncrementalUpdateType.Comment]);
30
+ /** Helper functions to ask an {@link IncrementalUpdateResult} what kind of change it is. */
31
+ exports.IncrementalUpdate = {
32
+ name: 'IncrementalUpdate',
33
+ /** Whether the files changed in nothing the dataflow analysis reads, i.e., at most in their comments. */
34
+ unchanged(update) {
35
+ return update.types.every(t => UnchangedTypes.has(t));
36
+ },
37
+ /** Whether `type` is the only kind of change. */
38
+ is(update, type) {
39
+ return update.types.length === 1 && update.types[0] === type;
40
+ }
41
+ };
42
+ /**
43
+ * Base class for plugins that classify how the files of an analysis changed since the analysis before,
44
+ * producing an {@link IncrementalUpdateResult} the incremental dataflow analysis acts on.
45
+ * At most one may be registered, {@link DefaultFlowrAnalyzerIncrementalDataflowUpdateTypePlugin} runs otherwise.
46
+ */
47
+ class FlowrAnalyzerIncrementalDataflowUpdateTypePlugin extends flowr_analyzer_plugin_1.FlowrAnalyzerPlugin {
48
+ type = flowr_analyzer_plugin_1.PluginType.IncrementalDataflowUpdateType;
49
+ static defaultPlugin() {
50
+ return new DefaultFlowrAnalyzerIncrementalDataflowUpdateTypePlugin();
51
+ }
52
+ }
53
+ exports.FlowrAnalyzerIncrementalDataflowUpdateTypePlugin = FlowrAnalyzerIncrementalDataflowUpdateTypePlugin;
54
+ /**
55
+ * The default classifier, comparing the ASTs structurally.
56
+ * Node ids take part in the comparison, as the dataflow graph refers to the nodes by them.
57
+ */
58
+ class DefaultFlowrAnalyzerIncrementalDataflowUpdateTypePlugin extends FlowrAnalyzerIncrementalDataflowUpdateTypePlugin {
59
+ name = 'default-incremental-dataflow-update-type-plugin';
60
+ description = 'Classifies changes by comparing the top-level statements of the analyzed files.';
61
+ version = new semver_1.SemVer('0.2.0');
62
+ process(_ctx, { previous, current }) {
63
+ const files = current.ast.files;
64
+ const shared = Math.min(previous.length, files.length);
65
+ for (let i = 0; i < shared; i++) {
66
+ if (previous[i].filePath !== files[i].filePath) {
67
+ return { types: [IncrementalUpdateType.Full] };
68
+ }
69
+ }
70
+ const differences = Array.from({ length: shared }, (_, i) => compareFiles(previous[i].root, files[i].root));
71
+ const unchanged = differences.every((d, i) => d.prefix === previous[i].root.children.length && d.prefix === files[i].root.children.length);
72
+ const moved = differences.every((d, i) => d.locations || d.prefix === previous[i].root.children.length) && differences.some(d => d.locations);
73
+ if (files.length === previous.length + 1 && unchanged) {
74
+ return { types: [IncrementalUpdateType.NewFileAtEnd], filePath: files[files.length - 1].filePath };
75
+ }
76
+ else if (files.length + 1 === previous.length && unchanged) {
77
+ return { types: [IncrementalUpdateType.RemovedFileAtEnd], filePath: previous[previous.length - 1].filePath };
78
+ }
79
+ else if (files.length !== previous.length) {
80
+ return { types: [IncrementalUpdateType.Full] };
81
+ }
82
+ if (moved) {
83
+ return files.length === 1 ? { types: [IncrementalUpdateType.Location], filePath: files[0].filePath, commonPrefix: differences[0].prefix } : { types: [IncrementalUpdateType.Location] };
84
+ }
85
+ else if (unchanged) {
86
+ return { types: [differences.some(d => d.comments) ? IncrementalUpdateType.Comment : IncrementalUpdateType.Nothing] };
87
+ }
88
+ if (files.length !== 1) {
89
+ return { types: [IncrementalUpdateType.Full] };
90
+ }
91
+ const [{ prefix }] = differences;
92
+ const before = previous[0].root.children.length;
93
+ const after = files[0].root.children.length;
94
+ const type = prefix === before ? IncrementalUpdateType.AddedAtEnd : prefix === after ? IncrementalUpdateType.RemovedAtEnd : IncrementalUpdateType.ChangedAtEnd;
95
+ return { types: [type], filePath: files[0].filePath, commonPrefix: prefix };
96
+ }
97
+ }
98
+ exports.DefaultFlowrAnalyzerIncrementalDataflowUpdateTypePlugin = DefaultFlowrAnalyzerIncrementalDataflowUpdateTypePlugin;
99
+ /** Keys that hold no information of their own: the parent follows from the structure, and tree-sitter ids are per parse. */
100
+ const IgnoredKeys = new Set(['parent', 'tsId']);
101
+ const LocationKeys = new Set(['location', 'fullRange']);
102
+ const CommentKeys = new Set(['adToks']);
103
+ function compareFiles(before, after) {
104
+ const shared = Math.min(before.children.length, after.children.length);
105
+ let prefix = 0;
106
+ let comments = !sameNode(before.info.adToks, after.info.adToks, NoKey);
107
+ /* a statement is the same if it is, besides its comments, as the dataflow graph keeps the locations of what it creates */
108
+ for (; prefix < shared; prefix++) {
109
+ const [a, b] = [before.children[prefix], after.children[prefix]];
110
+ if (sameText(a, b)) {
111
+ comments ||= !sameNode(a.info.adToks, b.info.adToks, NoKey);
112
+ }
113
+ else if (sameNode(a, b, key => CommentKeys.has(key))) {
114
+ comments = true;
115
+ }
116
+ else {
117
+ break;
118
+ }
119
+ }
120
+ const complete = prefix === before.children.length && prefix === after.children.length;
121
+ /* the statements of the prefix are the same already, so only those after it may have moved */
122
+ const locations = !complete && before.children.length === after.children.length
123
+ && before.children.every((c, i) => i < prefix || sameNode(c, after.children[i], key => LocationKeys.has(key) || CommentKeys.has(key)));
124
+ return { prefix, locations, comments: complete && comments };
125
+ }
126
+ const NoKey = () => false;
127
+ /** Whether the two statements have the same id, range, and text, which, as the ids count the nodes before, makes them the same statement. */
128
+ function sameText(a, b) {
129
+ const [ra, rb] = [range_1.SourceRange.fromNode(a), range_1.SourceRange.fromNode(b)];
130
+ return a.info.id === b.info.id && a.info.fullLexeme !== undefined && a.info.fullLexeme === b.info.fullLexeme
131
+ && ra !== undefined && rb !== undefined && ra.every((v, i) => v === rb[i]);
132
+ }
133
+ /**
134
+ * Whether the two (sub)trees are the same, besides what `skip` names.
135
+ * Lexemes are compared as they are, as a change of the whitespace within them moves the locations of what follows.
136
+ */
137
+ function sameNode(a, b, skip) {
138
+ if (a === b) {
139
+ return true;
140
+ }
141
+ else if (typeof a !== 'object' || typeof b !== 'object' || a === null || b === null) {
142
+ return false;
143
+ }
144
+ else if (Array.isArray(a)) {
145
+ return Array.isArray(b) && a.length === b.length && a.every((v, i) => sameNode(v, b[i], skip));
146
+ }
147
+ const keysA = Object.keys(a).filter(k => !IgnoredKeys.has(k) && !skip(k) && a[k] !== undefined);
148
+ const keysB = Object.keys(b).filter(k => !IgnoredKeys.has(k) && !skip(k) && b[k] !== undefined);
149
+ return keysA.length === keysB.length && keysA.every(k => sameNode(a[k], b[k], skip));
150
+ }
151
+ //# sourceMappingURL=flowr-analyzer-incremental-dataflow-update-type-plugin.js.map
@@ -23,6 +23,8 @@ export declare abstract class FlowrAnalyzerPackageVersionsPlugin extends FlowrAn
23
23
  static defaultPlugin(): FlowrAnalyzerPackageVersionsPlugin;
24
24
  /** metadata of the databases this plugin currently has loaded (empty for plugins without any) */
25
25
  loadedDatabases(): SigDbLoadedInfo[];
26
+ /** Whether this plugin has a database loaded, without describing it as {@link loadedDatabases} does. */
27
+ hasLoadedDatabase(): boolean;
26
28
  /** Packages known to this plugin that export `name` (empty for plugins without a database). */
27
29
  packagesExporting(_name: BrandedIdentifier): readonly BrandedNamespace[];
28
30
  /** The signature sources this plugin currently has loaded (empty for plugins without any). `config` lets a query resolve config-driven sources before any analysis has set the plugin's context. */
@@ -17,6 +17,10 @@ class FlowrAnalyzerPackageVersionsPlugin extends flowr_analyzer_plugin_1.FlowrAn
17
17
  loadedDatabases() {
18
18
  return [];
19
19
  }
20
+ /** Whether this plugin has a database loaded, without describing it as {@link loadedDatabases} does. */
21
+ hasLoadedDatabase() {
22
+ return this.loadedDatabases().length > 0;
23
+ }
20
24
  /** Packages known to this plugin that export `name` (empty for plugins without a database). */
21
25
  packagesExporting(_name) {
22
26
  return [];
@@ -69,6 +69,7 @@ export declare class FlowrAnalyzerPackageVersionsSigDbPlugin extends FlowrAnalyz
69
69
  providesBaseRPackages(): boolean;
70
70
  signatureSources(config?: FlowrConfig): readonly PackageSignatureSource[];
71
71
  loadedDatabases(): SigDbLoadedInfo[];
72
+ hasLoadedDatabase(): boolean;
72
73
  /**
73
74
  * Packages in the loaded sources exporting `name`, self-package excluded, most downloaded first (so picking
74
75
  * the first is the package a script most likely means); backed by the per-source memo in {@link exportOwnersBySource}, filtered here rather than there so the memo stays analyzer-independent.
@@ -259,6 +259,9 @@ class FlowrAnalyzerPackageVersionsSigDbPlugin extends flowr_analyzer_package_ver
259
259
  loadedDatabases() {
260
260
  return this.loadSources().map(describeLoadedDatabase);
261
261
  }
262
+ hasLoadedDatabase() {
263
+ return this.loadSources().length > 0;
264
+ }
262
265
  /**
263
266
  * Packages in the loaded sources exporting `name`, self-package excluded, most downloaded first (so picking
264
267
  * the first is the package a script most likely means); backed by the per-source memo in {@link exportOwnersBySource}, filtered here rather than there so the memo stays analyzer-independent.
@@ -32,8 +32,10 @@ import { FlowrAnalyzerLoadingOrderRprofilePlugin } from './loading-order-plugins
32
32
  import { FlowrAnalyzerPackageVersionsLibraryPlugin } from './package-version-plugins/flowr-analyzer-package-versions-library-plugin';
33
33
  import { FlowrAnalyzerPackageVersionsOnDemandPlugin } from './package-version-plugins/flowr-analyzer-package-versions-on-demand-plugin';
34
34
  import { FlowrAnalyzerLoadingOrderIncludedFilesPlugin } from './loading-order-plugins/flowr-analyzer-loading-order-included-files-plugin';
35
+ import { DefaultFlowrAnalyzerIncrementalDataflowUpdateTypePlugin } from './incremental/incremental-dataflow/flowr-analyzer-incremental-dataflow-update-type-plugin';
36
+ import { AdaptiveFlowrAnalyzerIncrementalDataflowHeuristicPlugin, ConfiguredFlowrAnalyzerIncrementalDataflowHeuristicPlugin } from './incremental/incremental-dataflow/flowr-analyzer-incremental-dataflow-heuristic-plugin';
35
37
  /** The built-in Flowr Analyzer plugins that are always available. */
36
- export declare const BuiltInPlugins: [["file:description", typeof FlowrAnalyzerDescriptionFilePlugin], ["versions:description", typeof FlowrAnalyzerPackageVersionsDescriptionFilePlugin], ["versions:sigdb", typeof FlowrAnalyzerPackageVersionsSigDbPlugin], ["versions:library", typeof FlowrAnalyzerPackageVersionsLibraryPlugin], ["versions:on-demand", typeof FlowrAnalyzerPackageVersionsOnDemandPlugin], ["versions:renv", typeof FlowrAnalyzerPackageVersionsRenvPlugin], ["versions:rv", typeof FlowrAnalyzerPackageVersionsRvPlugin], ["versions:uvr", typeof FlowrAnalyzerPackageVersionsUvrPlugin], ["versions:rig", typeof FlowrAnalyzerPackageVersionsRigPlugin], ["versions:packrat", typeof FlowrAnalyzerPackageVersionsPackratPlugin], ["versions:session-info", typeof FlowrAnalyzerPackageVersionsSessionInfoPlugin], ["loading-order:description", typeof FlowrAnalyzerLoadingOrderDescriptionFilePlugin], ["loading-order:implicit-sources", typeof FlowrAnalyzerLoadingOrderImplicitSourcesPlugin], ["loading-order:rprofile", typeof FlowrAnalyzerLoadingOrderRprofilePlugin], ["loading-order:included-files", typeof FlowrAnalyzerLoadingOrderIncludedFilesPlugin], ["meta:description", typeof FlowrAnalyzerMetaDescriptionFilePlugin], ["meta:rproject", typeof FlowrAnalyzerMetaRProjectFilePlugin], ["meta:uvr", typeof FlowrAnalyzerMetaUvrManifestFilePlugin], ["meta:rig", typeof FlowrAnalyzerMetaRigProjectFilePlugin], ["meta:rig-script", typeof FlowrAnalyzerMetaRigScriptPlugin], ["file-roles:vignette", typeof FlowrAnalyzerMetaVignetteFilesPlugin], ["file-roles:test", typeof FlowrAnalyzerMetaTestFilesPlugin], ["file-roles:inst", typeof FlowrAnalyzerMetaInstFilesPlugin], ["file:rmd", typeof FlowrAnalyzerRmdFilePlugin], ["file:qmd", typeof FlowrAnalyzerQmdFilePlugin], ["file:rnw", typeof FlowrAnalyzerSweaveFilePlugin], ["file:ipynb", typeof FlowrAnalyzerJupyterFilePlugin], ["file:rout", typeof FlowrAnalyzerRSessionFilePlugin], ["file:namespace", typeof FlowrAnalyzerNamespaceFilesPlugin], ["versions:namespace", typeof FlowrAnalyzerPackageVersionsNamespaceFilePlugin], ["file:news", typeof FlowrAnalyzerNewsFilePlugin], ["file:rd-macros", typeof FlowrAnalyzerRdMacroFilePlugin], ["file:rd", typeof FlowrAnalyzerRdFilePlugin], ["file:rd-index", typeof FlowrAnalyzerRdIndexFilePlugin], ["file:rd-topics", typeof FlowrAnalyzerRdTopicIndexFilePlugin], ["file:rd-meta", typeof FlowrAnalyzerRdMetaFilePlugin], ["file:datalist", typeof FlowrAnalyzerDataListFilePlugin], ["file:sysdata", typeof FlowrAnalyzerSysdataFilePlugin], ["file:rda", typeof FlowrAnalyzerRdaFilePlugin], ["file:license", typeof FlowrAnalyzerLicenseFilePlugin], ["file:virtualenv", typeof FlowrAnalyzerVirtualEnvFilePlugin], ["file:rproject", typeof FlowrAnalyzerRProjectFilePlugin], ["file:uvr", typeof FlowrAnalyzerUvrManifestFilePlugin], ["file:rig", typeof FlowrAnalyzerRigProjectFilePlugin], ["file:rprofile", typeof FlowrAnalyzerRprofileFilePlugin], ["project-discovery:gitignore", typeof FlowrAnalyzerGitignoreProjectDiscoveryPlugin], ["project-discovery:rbuildignore", typeof FlowrAnalyzerRbuildignoreProjectDiscoveryPlugin], ["project-discovery:ignore-files", typeof FlowrAnalyzerIgnoreFileProjectDiscoveryPlugin], ["project-discovery:default", typeof FlowrAnalyzerDefaultProjectDiscoveryPlugin], ["project-discovery:full", typeof FlowrAnalyzerFullProjectDiscoveryPlugin]];
38
+ export declare const BuiltInPlugins: [["file:description", typeof FlowrAnalyzerDescriptionFilePlugin], ["versions:description", typeof FlowrAnalyzerPackageVersionsDescriptionFilePlugin], ["versions:sigdb", typeof FlowrAnalyzerPackageVersionsSigDbPlugin], ["versions:library", typeof FlowrAnalyzerPackageVersionsLibraryPlugin], ["versions:on-demand", typeof FlowrAnalyzerPackageVersionsOnDemandPlugin], ["versions:renv", typeof FlowrAnalyzerPackageVersionsRenvPlugin], ["versions:rv", typeof FlowrAnalyzerPackageVersionsRvPlugin], ["versions:uvr", typeof FlowrAnalyzerPackageVersionsUvrPlugin], ["versions:rig", typeof FlowrAnalyzerPackageVersionsRigPlugin], ["versions:packrat", typeof FlowrAnalyzerPackageVersionsPackratPlugin], ["versions:session-info", typeof FlowrAnalyzerPackageVersionsSessionInfoPlugin], ["loading-order:description", typeof FlowrAnalyzerLoadingOrderDescriptionFilePlugin], ["loading-order:implicit-sources", typeof FlowrAnalyzerLoadingOrderImplicitSourcesPlugin], ["loading-order:rprofile", typeof FlowrAnalyzerLoadingOrderRprofilePlugin], ["loading-order:included-files", typeof FlowrAnalyzerLoadingOrderIncludedFilesPlugin], ["meta:description", typeof FlowrAnalyzerMetaDescriptionFilePlugin], ["meta:rproject", typeof FlowrAnalyzerMetaRProjectFilePlugin], ["meta:uvr", typeof FlowrAnalyzerMetaUvrManifestFilePlugin], ["meta:rig", typeof FlowrAnalyzerMetaRigProjectFilePlugin], ["meta:rig-script", typeof FlowrAnalyzerMetaRigScriptPlugin], ["file-roles:vignette", typeof FlowrAnalyzerMetaVignetteFilesPlugin], ["file-roles:test", typeof FlowrAnalyzerMetaTestFilesPlugin], ["file-roles:inst", typeof FlowrAnalyzerMetaInstFilesPlugin], ["file:rmd", typeof FlowrAnalyzerRmdFilePlugin], ["file:qmd", typeof FlowrAnalyzerQmdFilePlugin], ["file:rnw", typeof FlowrAnalyzerSweaveFilePlugin], ["file:ipynb", typeof FlowrAnalyzerJupyterFilePlugin], ["file:rout", typeof FlowrAnalyzerRSessionFilePlugin], ["file:namespace", typeof FlowrAnalyzerNamespaceFilesPlugin], ["versions:namespace", typeof FlowrAnalyzerPackageVersionsNamespaceFilePlugin], ["file:news", typeof FlowrAnalyzerNewsFilePlugin], ["file:rd-macros", typeof FlowrAnalyzerRdMacroFilePlugin], ["file:rd", typeof FlowrAnalyzerRdFilePlugin], ["file:rd-index", typeof FlowrAnalyzerRdIndexFilePlugin], ["file:rd-topics", typeof FlowrAnalyzerRdTopicIndexFilePlugin], ["file:rd-meta", typeof FlowrAnalyzerRdMetaFilePlugin], ["file:datalist", typeof FlowrAnalyzerDataListFilePlugin], ["file:sysdata", typeof FlowrAnalyzerSysdataFilePlugin], ["file:rda", typeof FlowrAnalyzerRdaFilePlugin], ["file:license", typeof FlowrAnalyzerLicenseFilePlugin], ["file:virtualenv", typeof FlowrAnalyzerVirtualEnvFilePlugin], ["file:rproject", typeof FlowrAnalyzerRProjectFilePlugin], ["file:uvr", typeof FlowrAnalyzerUvrManifestFilePlugin], ["file:rig", typeof FlowrAnalyzerRigProjectFilePlugin], ["file:rprofile", typeof FlowrAnalyzerRprofileFilePlugin], ["project-discovery:gitignore", typeof FlowrAnalyzerGitignoreProjectDiscoveryPlugin], ["project-discovery:rbuildignore", typeof FlowrAnalyzerRbuildignoreProjectDiscoveryPlugin], ["project-discovery:ignore-files", typeof FlowrAnalyzerIgnoreFileProjectDiscoveryPlugin], ["project-discovery:default", typeof FlowrAnalyzerDefaultProjectDiscoveryPlugin], ["project-discovery:full", typeof FlowrAnalyzerFullProjectDiscoveryPlugin], ["incremental-dataflow-update-type:default", typeof DefaultFlowrAnalyzerIncrementalDataflowUpdateTypePlugin], ["incremental-dataflow-heuristic:configured", typeof ConfiguredFlowrAnalyzerIncrementalDataflowHeuristicPlugin], ["incremental-dataflow-heuristic:adaptive", typeof AdaptiveFlowrAnalyzerIncrementalDataflowHeuristicPlugin]];
37
39
  export type BuiltInFlowrPluginName = typeof BuiltInPlugins[number][0];
38
40
  export type BuiltInFlowrPluginArgs<N extends BuiltInFlowrPluginName> = N extends typeof BuiltInPlugins[number][0] ? ConstructorParameters<Extract<typeof BuiltInPlugins[number], [N, PluginProducer]>[1]> : never;
39
41
  type PluginProducer = new (...args: never[]) => FlowrAnalyzerPlugin;
@@ -38,6 +38,8 @@ const flowr_analyzer_loading_order_rprofile_plugin_1 = require("./loading-order-
38
38
  const flowr_analyzer_package_versions_library_plugin_1 = require("./package-version-plugins/flowr-analyzer-package-versions-library-plugin");
39
39
  const flowr_analyzer_package_versions_on_demand_plugin_1 = require("./package-version-plugins/flowr-analyzer-package-versions-on-demand-plugin");
40
40
  const flowr_analyzer_loading_order_included_files_plugin_1 = require("./loading-order-plugins/flowr-analyzer-loading-order-included-files-plugin");
41
+ const flowr_analyzer_incremental_dataflow_update_type_plugin_1 = require("./incremental/incremental-dataflow/flowr-analyzer-incremental-dataflow-update-type-plugin");
42
+ const flowr_analyzer_incremental_dataflow_heuristic_plugin_1 = require("./incremental/incremental-dataflow/flowr-analyzer-incremental-dataflow-heuristic-plugin");
41
43
  /** The built-in Flowr Analyzer plugins that are always available. */
42
44
  exports.BuiltInPlugins = [
43
45
  ['file:description', flowr_analyzer_description_file_plugin_1.FlowrAnalyzerDescriptionFilePlugin],
@@ -91,7 +93,10 @@ exports.BuiltInPlugins = [
91
93
  ['project-discovery:rbuildignore', flowr_analyzer_ignore_file_project_discovery_plugin_1.FlowrAnalyzerRbuildignoreProjectDiscoveryPlugin],
92
94
  ['project-discovery:ignore-files', flowr_analyzer_ignore_file_project_discovery_plugin_1.FlowrAnalyzerIgnoreFileProjectDiscoveryPlugin],
93
95
  ['project-discovery:default', flowr_analyzer_project_discovery_plugin_1.FlowrAnalyzerDefaultProjectDiscoveryPlugin],
94
- ['project-discovery:full', flowr_analyzer_project_discovery_plugin_1.FlowrAnalyzerFullProjectDiscoveryPlugin]
96
+ ['project-discovery:full', flowr_analyzer_project_discovery_plugin_1.FlowrAnalyzerFullProjectDiscoveryPlugin],
97
+ ['incremental-dataflow-update-type:default', flowr_analyzer_incremental_dataflow_update_type_plugin_1.DefaultFlowrAnalyzerIncrementalDataflowUpdateTypePlugin],
98
+ ['incremental-dataflow-heuristic:configured', flowr_analyzer_incremental_dataflow_heuristic_plugin_1.ConfiguredFlowrAnalyzerIncrementalDataflowHeuristicPlugin],
99
+ ['incremental-dataflow-heuristic:adaptive', flowr_analyzer_incremental_dataflow_heuristic_plugin_1.AdaptiveFlowrAnalyzerIncrementalDataflowHeuristicPlugin]
95
100
  ];
96
101
  /**
97
102
  * The registry of built-in and user-registered Flowr Analyzer plugins.
@@ -13,6 +13,7 @@ exports.deriveLibraryExports = deriveLibraryExports;
13
13
  const schema_1 = require("./schema");
14
14
  const sigdb_version_1 = require("./sigdb-version");
15
15
  const objects_1 = require("../../util/objects");
16
+ const defaultmap_1 = require("../../util/collections/defaultmap");
16
17
  const r_primitives_generated_1 = require("../../data/r-primitives.generated");
17
18
  /**
18
19
  * Reconstruct the CRAN source blob link which is the newest non-archived version lives under `src/contrib`,
@@ -222,6 +223,8 @@ function deriveLibraryExports(strings, blob, meta, pkg, version, cranBase = sche
222
223
  const s4Classes = [];
223
224
  const locations = new Map();
224
225
  const reexports = new Map();
226
+ /* the functions of a package share a few files, so each of their names is built once */
227
+ const files = new defaultmap_1.DefaultMap(idx => strings.at(idx));
225
228
  for (const i of idxs) {
226
229
  const [nameIdx, , , bits, fileIdx, line, , reexportIdx] = blob.fns[i];
227
230
  const name = strings.at(nameIdx);
@@ -236,7 +239,7 @@ function deriveLibraryExports(strings, blob, meta, pkg, version, cranBase = sche
236
239
  s4Classes.push(name);
237
240
  }
238
241
  if (fileIdx >= 0) {
239
- locations.set(name, { file: strings.at(fileIdx), line });
242
+ locations.set(name, { file: files.get(fileIdx), line });
240
243
  }
241
244
  if (reexportIdx !== undefined) {
242
245
  reexports.set(name, strings.at(reexportIdx));
@@ -1,4 +1,3 @@
1
- import type { BrandedIdentifier } from '../../dataflow/environments/identifier';
2
1
  /**
3
2
  * A bundle's string dictionary, held as the bytes of its names rather than as an array of strings.
4
3
  * Split apart, a dictionary of 1.4 million names cost a slice object per name and kept the text alive
@@ -8,6 +7,8 @@ import type { BrandedIdentifier } from '../../dataflow/environments/identifier';
8
7
  */
9
8
  /** A dictionary's names by id. Ids are positions, so {@link SigDict.at} is what `strings[id]` used to be. */
10
9
  export declare class SigDict implements Iterable<string> {
10
+ /** how many groups {@link SigDict.groupOf} tells apart */
11
+ static readonly Groups: number;
11
12
  /** every name in utf8, separated by newlines, so a name never carries one */
12
13
  private readonly bytes;
13
14
  /** where each name ends in {@link bytes}; the next one starts one past that */
@@ -25,10 +26,12 @@ export declare class SigDict implements Iterable<string> {
25
26
  get length(): number;
26
27
  /** The name with the given id, `''` for an id the dictionary does not hold. */
27
28
  at(id: number): string;
28
- /** The group the name with the given id belongs to, as {@link SigDict.keyOf} groups one in hand. */
29
+ /** The group the name with the given id belongs to, as {@link SigDict.groupOfBytes} groups one in hand. */
29
30
  groupOf(id: number): number;
30
- /** The group `name` would be in, so a lookup only compares the names that could match it. */
31
- static keyOf(name: BrandedIdentifier): number;
31
+ /** The group a name spelled `bytes` in utf8 would be in, so a lookup only compares the names that could match it. */
32
+ static groupOfBytes(bytes: Uint8Array): number;
33
+ /** Whether the name with the given id is spelled `bytes` in utf8, without building the name to compare it. */
34
+ spells(id: number, bytes: Uint8Array): boolean;
32
35
  private startOf;
33
36
  [Symbol.iterator](): Iterator<string>;
34
37
  }
@@ -1,6 +1,4 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SigDict = void 0;
4
2
  /**
5
3
  * A bundle's string dictionary, held as the bytes of its names rather than as an array of strings.
6
4
  * Split apart, a dictionary of 1.4 million names cost a slice object per name and kept the text alive
@@ -8,8 +6,12 @@ exports.SigDict = void 0;
8
6
  * `--max-old-space-size` bounds, and a name is built only when something asks for it.
9
7
  * @module
10
8
  */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.SigDict = void 0;
11
11
  /** A dictionary's names by id. Ids are positions, so {@link SigDict.at} is what `strings[id]` used to be. */
12
12
  class SigDict {
13
+ /** how many groups {@link SigDict.groupOf} tells apart */
14
+ static Groups = 1 << 16;
13
15
  /** every name in utf8, separated by newlines, so a name never carries one */
14
16
  bytes;
15
17
  /** where each name ends in {@link bytes}; the next one starts one past that */
@@ -64,16 +66,28 @@ class SigDict {
64
66
  at(id) {
65
67
  return id < 0 || id >= this.ends.length ? '' : this.bytes.toString('utf8', this.startOf(id), this.ends[id]);
66
68
  }
67
- /** The group the name with the given id belongs to, as {@link SigDict.keyOf} groups one in hand. */
69
+ /** The group the name with the given id belongs to, as {@link SigDict.groupOfBytes} groups one in hand. */
68
70
  groupOf(id) {
69
71
  const start = this.startOf(id);
70
72
  return group(this.ends[id] - start, this.bytes[start]);
71
73
  }
72
- /** The group `name` would be in, so a lookup only compares the names that could match it. */
73
- static keyOf(name) {
74
- const bytes = Buffer.from(name, 'utf8');
74
+ /** The group a name spelled `bytes` in utf8 would be in, so a lookup only compares the names that could match it. */
75
+ static groupOfBytes(bytes) {
75
76
  return group(bytes.length, bytes[0]);
76
77
  }
78
+ /** Whether the name with the given id is spelled `bytes` in utf8, without building the name to compare it. */
79
+ spells(id, bytes) {
80
+ const start = this.startOf(id);
81
+ if (this.ends[id] - start !== bytes.length) {
82
+ return false;
83
+ }
84
+ for (let i = 0; i < bytes.length; i++) {
85
+ if (this.bytes[start + i] !== bytes[i]) {
86
+ return false;
87
+ }
88
+ }
89
+ return true;
90
+ }
77
91
  startOf(id) {
78
92
  return id === 0 ? 0 : this.ends[id - 1] + 1;
79
93
  }
@@ -7,6 +7,16 @@ const built_in_guards_1 = require("../../dataflow/fn/guards/built-in-guards");
7
7
  * base package where the source itself records none, so a reader sees them the same way whichever source they come from.
8
8
  */
9
9
  function withGuards(source) {
10
+ let view = guarded.get(source);
11
+ if (view === undefined) {
12
+ view = guardedView(source);
13
+ guarded.set(source, view);
14
+ }
15
+ return view;
16
+ }
17
+ /** the view {@link withGuards} answers with per source, as it is asked for one with every lookup */
18
+ const guarded = new WeakMap();
19
+ function guardedView(source) {
10
20
  function add(pkg, fn) {
11
21
  const guards = fn === undefined || fn.guards !== undefined || !source.isBaseR(pkg) ? undefined : (0, built_in_guards_1.builtInGuards)(fn.name, pkg);
12
22
  return guards === undefined ? fn : { ...fn, guards };
@@ -143,7 +143,8 @@ export interface SigDbOpenOptions {
143
143
  /** a caller-supplied index/dictionary for {@link SigDatabase.openSync} (both derived from the source otherwise) */
144
144
  export interface OpenSyncOptions {
145
145
  index?: SigDbIndex;
146
- strings?: SigDict;
146
+ /** the dictionary, or how to load it once the first name is asked for */
147
+ strings?: SigDict | (() => SigDict);
147
148
  }
148
149
  /** {@link SigDatabase.openSyncFrom} options: cache settings plus an optional precomputed hash/index/dictionary */
149
150
  export interface OpenSyncFromOptions extends SigDbOpenOptions, OpenSyncOptions {
@@ -199,7 +200,8 @@ export declare class SigDatabase extends HistorySource implements PackageSignatu
199
200
  */
200
201
  private readonly outlines;
201
202
  private readonly fd;
202
- readonly strings: SigDict;
203
+ /** the dictionary, or how to load it: a bundle asked only for the versions it holds never needs its names */
204
+ private dictionary;
203
205
  readonly index: SigDbIndex;
204
206
  readonly content: SigDbContent | undefined;
205
207
  private readonly cranBase;
@@ -218,6 +220,7 @@ export declare class SigDatabase extends HistorySource implements PackageSignatu
218
220
  * is compressed. Pass `strings` for a blob-only shard that shares an already-loaded dictionary.
219
221
  */
220
222
  static openSyncFrom(source: string, opts: OpenSyncFromOptions): SigDatabase;
223
+ get strings(): SigDict;
221
224
  has(pkg: BrandedNamespace): boolean;
222
225
  packageNames(): BrandedNamespace[];
223
226
  /** load a single package's blob by seeking to its line (undefined if absent); cached by blob index */
@@ -311,6 +314,8 @@ export declare class SigDatabaseSet extends HistorySource implements PackageSign
311
314
  /** package name to shard indices, ordered by preference (current before full) */
312
315
  private readonly routes;
313
316
  private readonly cacheDir?;
317
+ /** the latest version per package asked for, as every name resolved asks for it and parsing it costs more than the lookup; at most one per package of the set */
318
+ private readonly latest;
314
319
  private constructor();
315
320
  /** read + validate a manifest and apply the include/exclude shard filter */
316
321
  private static prepManifest;
@@ -372,6 +377,7 @@ export declare class SigDatabaseSet extends HistorySource implements PackageSign
372
377
  /** whether the latest version of the package is CRAN-archived (see {@link SigDatabase.archived}); O(1) via the hoisted metadata */
373
378
  archived(pkg: BrandedNamespace): boolean;
374
379
  protected recordedLatest(pkg: BrandedNamespace): string;
380
+ latestVersion(pkg: BrandedNamespace): RVersion | undefined;
375
381
  /**
376
382
  * Close every opened shard's file descriptor and drop the in-memory caches (opened shards + shared
377
383
  * dictionaries), so the (potentially large) dictionary strings can be reclaimed by the GC. Idempotent.