@eagleoutice/flowr 2.13.9 → 2.13.11

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 (181) hide show
  1. package/README.md +40 -40
  2. package/config.d.ts +50 -2
  3. package/config.js +37 -6
  4. package/dataflow/environments/apply-kill.js +4 -4
  5. package/dataflow/environments/built-in-props.d.ts +28 -4
  6. package/dataflow/environments/built-in-props.js +31 -8
  7. package/dataflow/environments/built-in.d.ts +7 -2
  8. package/dataflow/environments/built-in.js +10 -12
  9. package/dataflow/environments/default-builtin-config.d.ts +46 -6
  10. package/dataflow/environments/default-builtin-config.js +30 -16
  11. package/dataflow/environments/environment.d.ts +16 -0
  12. package/dataflow/environments/environment.js +114 -26
  13. package/dataflow/environments/identifier.d.ts +6 -0
  14. package/dataflow/environments/identifier.js +18 -5
  15. package/dataflow/environments/query-fn-props.js +34 -2
  16. package/dataflow/environments/reference-to-maybe.js +1 -1
  17. package/dataflow/environments/resolve-by-name.js +16 -6
  18. package/dataflow/environments/resolve-helper.d.ts +43 -0
  19. package/dataflow/environments/resolve-helper.js +47 -0
  20. package/dataflow/eval/resolve/alias-tracking.js +45 -1
  21. package/dataflow/eval/resolve/resolve-argument.js +25 -17
  22. package/dataflow/eval/resolve/resolve-strings.d.ts +17 -0
  23. package/dataflow/eval/resolve/resolve-strings.js +16 -9
  24. package/dataflow/eval/resolve/resolve.js +3 -1
  25. package/dataflow/graph/call-graph.d.ts +7 -0
  26. package/dataflow/graph/call-graph.js +103 -0
  27. package/dataflow/graph/df-helper.d.ts +50 -1
  28. package/dataflow/graph/df-helper.js +63 -0
  29. package/dataflow/graph/graph.d.ts +5 -8
  30. package/dataflow/graph/graph.js +24 -13
  31. package/dataflow/internal/linker.d.ts +5 -5
  32. package/dataflow/internal/linker.js +31 -92
  33. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +2 -2
  34. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +3 -9
  35. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +4 -30
  36. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +2 -1
  37. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +1 -1
  38. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +7 -1
  39. package/dataflow/internal/process/functions/call/built-in/built-in-load.js +3 -3
  40. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.d.ts +1 -1
  41. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +5 -1
  42. package/dataflow/internal/process/functions/call/built-in/built-in-with.d.ts +2 -2
  43. package/dataflow/internal/process/functions/call/built-in/built-in-with.js +5 -6
  44. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +32 -14
  45. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +16 -4
  46. package/dataflow/internal/process/functions/call/known-call-handling.js +29 -8
  47. package/documentation/data/faq/faqs.js +1 -1
  48. package/documentation/data/faq/wiki-faq-store.js +3 -2
  49. package/documentation/data/server/doc-data-server-messages.js +1 -1
  50. package/documentation/doc-readme.js +1 -1
  51. package/documentation/doc-util/doc-files.d.ts +5 -0
  52. package/documentation/doc-util/doc-files.js +13 -3
  53. package/documentation/doc-util/doc-sigdb.d.ts +9 -0
  54. package/documentation/doc-util/doc-sigdb.js +32 -0
  55. package/documentation/wiki-analyzer.js +10 -10
  56. package/documentation/wiki-core.js +1 -1
  57. package/documentation/wiki-dataflow-graph.js +3 -3
  58. package/documentation/wiki-interface.js +13 -2
  59. package/documentation/wiki-linting-and-testing.js +13 -13
  60. package/documentation/wiki-mk/doc-context.d.ts +1 -1
  61. package/documentation/wiki-mk/doc-context.js +9 -5
  62. package/documentation/wiki-normalized-ast.js +1 -1
  63. package/documentation/wiki-overview.js +2 -2
  64. package/documentation/wiki-query.js +4 -1
  65. package/documentation/wiki-setup.js +3 -3
  66. package/documentation/wiki-signature-database.js +2 -5
  67. package/gas.d.ts +6 -0
  68. package/gas.js +7 -1
  69. package/linter/linter-rules.d.ts +1 -1
  70. package/linter/rules/syntactically-valid.d.ts +12 -1
  71. package/linter/rules/syntactically-valid.js +88 -17
  72. package/package.json +7 -8
  73. package/project/attached-packages.d.ts +13 -0
  74. package/project/attached-packages.js +30 -0
  75. package/project/context/flowr-analyzer-context.d.ts +15 -0
  76. package/project/context/flowr-analyzer-context.js +14 -3
  77. package/project/context/flowr-analyzer-files-context.d.ts +11 -0
  78. package/project/context/flowr-analyzer-files-context.js +3 -0
  79. package/project/context/flowr-analyzer-incremental-analysis-context.d.ts +4 -0
  80. package/project/context/flowr-analyzer-incremental-analysis-context.js +69 -0
  81. package/project/context/flowr-analyzer-loading-order-context.d.ts +8 -0
  82. package/project/context/flowr-analyzer-loading-order-context.js +23 -2
  83. package/project/dependency-version-space.d.ts +33 -11
  84. package/project/dependency-version-space.js +58 -32
  85. package/project/plugins/file-plugins/files/flowr-namespace-file.js +52 -24
  86. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-library-plugin.d.ts +22 -0
  87. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-library-plugin.js +101 -0
  88. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +30 -11
  89. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +79 -37
  90. package/project/plugins/plugin-registry.d.ts +2 -1
  91. package/project/plugins/plugin-registry.js +2 -0
  92. package/project/sigdb/manifest.js +9 -5
  93. package/project/sigdb/reader.d.ts +20 -0
  94. package/project/sigdb/reader.js +93 -10
  95. package/project/sigdb/signature-match.d.ts +5 -18
  96. package/project/sigdb/signature-match.js +5 -18
  97. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +1 -1
  98. package/queries/catalog/call-graph-query/call-graph-query-executor.js +3 -1
  99. package/queries/catalog/call-graph-query/call-graph-query-format.d.ts +4 -0
  100. package/queries/catalog/call-graph-query/call-graph-query-format.js +4 -0
  101. package/queries/catalog/dependencies-query/dependencies-query-executor.js +11 -3
  102. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +25 -1
  103. package/queries/catalog/dependencies-query/dependencies-query-format.js +22 -2
  104. package/queries/catalog/dependencies-query/function-info/library-functions.js +7 -1
  105. package/queries/catalog/dependencies-query/function-info/read-functions.js +5 -5
  106. package/queries/catalog/dependencies-query/function-info/remote-functions.d.ts +18 -0
  107. package/queries/catalog/dependencies-query/function-info/remote-functions.js +46 -0
  108. package/queries/catalog/dependencies-query/function-info/visualize-functions.js +52 -2
  109. package/queries/catalog/dependencies-query/function-info/write-functions.js +8 -4
  110. package/queries/catalog/dependencies-query/link-devices.d.ts +16 -0
  111. package/queries/catalog/dependencies-query/link-devices.js +104 -0
  112. package/queries/catalog/dice-query/dice-query-format.d.ts +2 -0
  113. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +25 -6
  114. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +37 -6
  115. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +17 -4
  116. package/queries/catalog/happens-before-query/happens-before-query-executor.js +2 -1
  117. package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +14 -0
  118. package/queries/catalog/happens-before-query/happens-before-query-format.js +18 -2
  119. package/queries/catalog/input-sources-query/input-sources-query-format.js +4 -0
  120. package/queries/catalog/input-sources-query/input-types.d.ts +10 -0
  121. package/queries/catalog/input-sources-query/input-types.js +10 -0
  122. package/queries/catalog/location-map-query/location-map-query-executor.js +16 -6
  123. package/queries/catalog/location-map-query/location-map-query-format.d.ts +15 -1
  124. package/queries/catalog/location-map-query/location-map-query-format.js +22 -5
  125. package/queries/catalog/signature-query/signature-query-executor.js +3 -0
  126. package/queries/catalog/signature-query/signature-query-format.d.ts +5 -0
  127. package/queries/catalog/slice-query-options.d.ts +11 -1
  128. package/queries/catalog/slice-query-options.js +8 -4
  129. package/queries/catalog/static-slice-query/static-slice-query-executor.js +4 -1
  130. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +5 -1
  131. package/queries/query.d.ts +1 -1
  132. package/r-bridge/lang-4.x/ast/model/model.d.ts +23 -2
  133. package/r-bridge/lang-4.x/ast/model/model.js +44 -0
  134. package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +3 -0
  135. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +3 -0
  136. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +3 -0
  137. package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +3 -0
  138. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +3 -0
  139. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +3 -0
  140. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +3 -0
  141. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +8 -8
  142. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +9 -46
  143. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +3 -0
  144. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +3 -0
  145. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +3 -0
  146. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +3 -0
  147. package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +3 -0
  148. package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +3 -0
  149. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +3 -0
  150. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +3 -0
  151. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +3 -0
  152. package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +3 -0
  153. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +3 -0
  154. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +3 -0
  155. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +3 -0
  156. package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +0 -5
  157. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +6 -3
  158. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +1 -1
  159. package/reconstruct/reconstruct.d.ts +9 -0
  160. package/reconstruct/reconstruct.js +1 -0
  161. package/search/flowr-search-filters.d.ts +25 -1
  162. package/search/flowr-search-filters.js +42 -7
  163. package/search/search-executor/search-generators.js +7 -2
  164. package/search/search-executor/search-transformer.js +4 -1
  165. package/slicing/criterion/parse.d.ts +5 -25
  166. package/slicing/criterion/parse.js +15 -20
  167. package/slicing/static/fingerprint.js +18 -6
  168. package/slicing/static/slice-call.js +2 -2
  169. package/slicing/static/slicer-types.d.ts +10 -0
  170. package/slicing/static/static-slicer.d.ts +1 -1
  171. package/slicing/static/static-slicer.js +29 -6
  172. package/slicing/static/visiting-queue.d.ts +12 -2
  173. package/slicing/static/visiting-queue.js +28 -3
  174. package/util/arg-matching.d.ts +18 -0
  175. package/util/arg-matching.js +70 -0
  176. package/util/collections/bimap.d.ts +21 -1
  177. package/util/collections/bimap.js +43 -7
  178. package/util/r-regex.js +19 -1
  179. package/util/range.d.ts +7 -8
  180. package/util/range.js +10 -11
  181. package/util/version.js +1 -1
@@ -9,13 +9,20 @@ const DelimiterInsert = new Map([[')', ')'], ['}', '}'], [']', ']'], [']]', ']]'
9
9
  const KeywordInsert = new Map([['in', ' in '], ['else', ' else ']]);
10
10
  const OperatorToken = /^([-+*/^:~!<>=&|@$]+|<-|<<-|->|->>|\|>|%[^%]*%)$/;
11
11
  const KnownOperators = ['%%', '%/%', '%*%', '%o%', '%x%', '%in%', '%>%', '%<>%', '%+%', '%||%'];
12
+ /** Typographic quotes, as a word processor or a PDF leaves behind. */
13
+ const SmartQuote = new Map([['\u201C', '"'], ['\u201D', '"'], ['\u201E', '"'], ['\u2018', '\''], ['\u2019', '\'']]);
14
+ /** Closing brackets and whitespace only, so nothing there is worth keeping. */
15
+ const OnlyClosers = /^[)\]}\s]+$/;
16
+ /** How R prefixes printed values, never how a statement begins. */
17
+ const ConsoleOutput = /^\s*\[{1,2}\d+\]{1,2}(\s|$)/;
12
18
  // tree-sitter is 0-based with an exclusive end column (matching flowR), so only the 1-based start shifts
13
19
  const point = (p) => [p.row + 1, p.column + 1, p.row + 1, p.column];
14
20
  const span = (n) => [n.startPosition.row + 1, n.startPosition.column + 1, n.endPosition.row + 1, n.endPosition.column];
15
21
  const isDanglingOperator = (n) => !!n && !n.isNamed && OperatorToken.test(n.type);
16
- /** The closing delimiters an unbalanced error region is missing, innermost first (skips strings/comments; `({` needs `})`). */
17
- function bracketDeficit(text) {
22
+ /** Read an error region: what it leaves open, and where its operators sit. */
23
+ function scanRegion(text) {
18
24
  const stack = [];
25
+ const percentAt = [];
19
26
  let quote;
20
27
  for (let i = 0; i < text.length; i++) {
21
28
  const c = text[i];
@@ -35,6 +42,9 @@ function bracketDeficit(text) {
35
42
  i++;
36
43
  }
37
44
  }
45
+ else if (c === '%') {
46
+ percentAt.push(i);
47
+ }
38
48
  else if (c === '(') {
39
49
  stack.push(')');
40
50
  }
@@ -56,12 +66,12 @@ function bracketDeficit(text) {
56
66
  }
57
67
  }
58
68
  }
59
- return stack.reverse();
69
+ return { closers: stack.reverse(), percentAt };
60
70
  }
61
- /** Fuzzy-complete the unfinished `%...` operator in an error region to the nearest known operator (else just close it). */
62
- function operatorCompletion(node) {
63
- const at = node.text.lastIndexOf('%');
64
- const fragment = /^%[A-Za-z0-9]*/.exec(node.text.slice(at))?.[0] ?? '%';
71
+ /** Fuzzy-complete the `%...` operator at `at` to the nearest known one (else just close it). */
72
+ function operatorCompletion(node, at) {
73
+ // R allows anything between the percents; matching letters alone read `%>` as `%` and completed it to `%%`
74
+ const fragment = /^%[^%\s()[\]{},]*/.exec(node.text.slice(at))?.[0] ?? '%';
65
75
  const full = KnownOperators.find(op => op !== fragment && op.startsWith(fragment)) ?? fragment + '%';
66
76
  const column = node.startPosition.column + at;
67
77
  return { range: [node.startPosition.row + 1, column + 1, node.startPosition.row + 1, column + fragment.length], full };
@@ -69,6 +79,20 @@ function operatorCompletion(node) {
69
79
  const isMissingExpression = (f) => f.kind === 'missing' && !DelimiterInsert.has(f.node.type) && !KeywordInsert.has(f.node.type);
70
80
  /** The built-in auto-fix patterns; append a {@link SyntaxErrorFixPattern} to add repairs. */
71
81
  exports.SyntaxErrorFixPatterns = [
82
+ // first, because it judges the whole line: `[1] 1 2 3` errors on both `[` and `]`, and repairing those as
83
+ // brackets balances output text into the program instead of dropping it
84
+ {
85
+ name: 'comment-out-console-output',
86
+ description: 'Comment out a line of pasted R console output, which is missing its `#`.',
87
+ direction: 'comment',
88
+ appliesTo: f => f.kind === 'error' && ConsoleOutput.test(f.line),
89
+ quickFix: (f, file) => ({
90
+ type: 'replace',
91
+ loc: range_1.SourceLocation.from(point({ row: f.node.startPosition.row, column: 0 }), file),
92
+ description: 'Comment out the pasted console output',
93
+ replacement: '# '
94
+ })
95
+ },
72
96
  {
73
97
  name: 'insert-missing-token',
74
98
  description: 'Insert a delimiter, quote, or keyword the parser expected but did not find.',
@@ -99,9 +123,9 @@ exports.SyntaxErrorFixPatterns = [
99
123
  name: 'balance-brackets',
100
124
  description: 'Close an unbalanced region by appending the brackets that were left open.',
101
125
  direction: 'add',
102
- appliesTo: f => f.kind === 'error' && bracketDeficit(f.node.text).length > 0,
126
+ appliesTo: f => f.kind === 'error' && f.scan.closers.length > 0,
103
127
  quickFix: (f, file) => {
104
- const closers = bracketDeficit(f.node.text).join('');
128
+ const closers = f.scan.closers.join('');
105
129
  return { type: 'replace', loc: range_1.SourceLocation.from(point(f.node.endPosition), file), description: `Add missing closing \`${closers}\``, replacement: closers };
106
130
  }
107
131
  },
@@ -109,12 +133,42 @@ exports.SyntaxErrorFixPatterns = [
109
133
  name: 'complete-operator',
110
134
  description: 'Complete an unfinished `%...%` operator to the nearest known one.',
111
135
  direction: 'add',
112
- appliesTo: f => f.kind === 'error' && !f.node.text.includes('\n') && (f.node.text.match(/%/g)?.length ?? 0) % 2 === 1,
136
+ // single-line only: the completion derives its column from the offset within the region
137
+ appliesTo: f => f.kind === 'error' && !f.node.text.includes('\n') && f.scan.percentAt.length % 2 === 1,
113
138
  quickFix: (f, file) => {
114
- const { range, full } = operatorCompletion(f.node);
139
+ const { range, full } = operatorCompletion(f.node, f.scan.percentAt.at(-1));
115
140
  return { type: 'replace', loc: range_1.SourceLocation.from(range, file), description: `Complete operator to \`${full}\``, replacement: full };
116
141
  }
117
142
  },
143
+ {
144
+ name: 'replace-smart-quote',
145
+ description: 'Turn a typographic quote back into the straight quote R can read.',
146
+ direction: 'add',
147
+ appliesTo: f => f.kind === 'error' && SmartQuote.has(f.node.text),
148
+ quickFix: (f, file) => ({
149
+ type: 'replace',
150
+ loc: range_1.SourceLocation.from(span(f.node), file),
151
+ description: 'Replace the typographic quote with a straight one',
152
+ replacement: SmartQuote.get(f.node.text)
153
+ })
154
+ },
155
+ {
156
+ name: 'remove-repl-prompt',
157
+ description: 'Drop a `>` prompt copied in front of a line taken from the R console.',
158
+ direction: 'remove',
159
+ // must open the line: `a > b` parses, and a leading `>=` is a different token
160
+ appliesTo: f => f.kind === 'error' && f.node.text === '>'
161
+ && f.line.slice(0, f.node.startPosition.column).trim() === '',
162
+ quickFix: (f, file) => ({ type: 'remove', loc: range_1.SourceLocation.from(span(f.node), file), description: 'Remove the copied `>` prompt' })
163
+ },
164
+ {
165
+ name: 'remove-stray-closer',
166
+ description: 'Drop closing brackets that close nothing, as a partial copy leaves behind.',
167
+ direction: 'remove',
168
+ // the `]` of `[1]` is a closer too, but there the line goes, not the bracket
169
+ appliesTo: f => f.kind === 'error' && OnlyClosers.test(f.node.text) && !ConsoleOutput.test(f.line),
170
+ quickFix: (f, file) => ({ type: 'remove', loc: range_1.SourceLocation.from(span(f.node), file), description: `Remove the stray \`${f.node.text.replace(/\s+/g, '')}\`` })
171
+ },
118
172
  {
119
173
  name: 'comment-out',
120
174
  description: 'Comment out an un-parseable region so the rest of the file still parses.',
@@ -124,16 +178,27 @@ exports.SyntaxErrorFixPatterns = [
124
178
  }
125
179
  ];
126
180
  /** Collect the outermost `missing`/`error` nodes, pruning subtrees the parser reports as clean. */
127
- function collectFindings(node, out = []) {
181
+ function finding(kind, node, lines) {
182
+ let scan;
183
+ return {
184
+ kind, node,
185
+ line: lines[node.startPosition.row] ?? '',
186
+ // on demand and once: a `missing` node has no text, and two patterns want the same scan
187
+ get scan() {
188
+ return scan ??= scanRegion(node.text);
189
+ }
190
+ };
191
+ }
192
+ function collectFindings(node, lines, out = []) {
128
193
  if (node.isMissing) {
129
- out.push({ kind: 'missing', node });
194
+ out.push(finding('missing', node, lines));
130
195
  }
131
196
  else if (node.isError) {
132
- out.push({ kind: 'error', node });
197
+ out.push(finding('error', node, lines));
133
198
  }
134
199
  else if (node.hasError) {
135
200
  for (const child of node.children) {
136
- collectFindings(child, out);
201
+ collectFindings(child, lines, out);
137
202
  }
138
203
  }
139
204
  return out;
@@ -146,7 +211,8 @@ function describe(finding) {
146
211
  return `Unexpected \`${text.length > 30 ? text.slice(0, 27) + '...' : text}\``;
147
212
  }
148
213
  exports.SYNTACTICALLY_VALID = {
149
- createSearch: () => flowr_search_builder_1.Q.all(),
214
+ // reads the parse tree, not the normalized AST, so `Q.all()` would enumerate every node for nothing
215
+ createSearch: () => flowr_search_builder_1.Q.from([]),
150
216
  processSearchResult: async (_elements, config, data) => {
151
217
  const parser = data.parserInformation().name;
152
218
  const results = [];
@@ -158,7 +224,9 @@ exports.SYNTACTICALLY_VALID = {
158
224
  if (!root.hasError) {
159
225
  continue;
160
226
  }
161
- for (const finding of collectFindings(root)) {
227
+ // the root spans the file verbatim, so its rows index these lines
228
+ const lines = root.text.split('\n');
229
+ for (const finding of collectFindings(root, lines)) {
162
230
  // a single fix per error, favouring the preferred direction (alternatives are never emitted together)
163
231
  let fix;
164
232
  let best = 2;
@@ -167,6 +235,9 @@ exports.SYNTACTICALLY_VALID = {
167
235
  if (rank < best && p.appliesTo(finding)) {
168
236
  fix = p.quickFix(finding, file.filePath);
169
237
  best = rank;
238
+ if (best === 0) {
239
+ break;
240
+ }
170
241
  }
171
242
  }
172
243
  results.push({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eagleoutice/flowr",
3
- "version": "2.13.9",
3
+ "version": "2.13.11",
4
4
  "description": "Static Dataflow Analyzer and Program Slicer for the R Programming Language",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "repository": {
@@ -41,7 +41,7 @@
41
41
  "lint-local": "npm run typecheck && npx eslint --version && npx eslint src/ test/ scripts/ --concurrency=auto --cache --cache-location node_modules/.cache/eslint-local --rule \"no-warning-comments: off\"",
42
42
  "lint": "npm run license-compat -- --summary && npm run typecheck && npx eslint --version && npx eslint src/ test/ scripts/ --concurrency=auto --cache --cache-location node_modules/.cache/eslint",
43
43
  "license-compat": "license-checker-rseidelsohn --onlyAllow 'MIT;MPL-2.0;MIT OR X11;GPLv2;LGPL;GNUGPL;ISC;Apache-2.0;FreeBSD;BSD-2-Clause;clearbsd;ModifiedBSD;BSD-3-Clause;Python-2.0;Unlicense;WTFPL;BlueOak-1.0.0;CC-BY-4.0;CC-BY-3.0;CC0-1.0;0BSD' --clarificationsFile license-clarifications.json",
44
- "doc": "typedoc",
44
+ "doc": "node --max-old-space-size=8192 node_modules/typedoc/dist/cli.js",
45
45
  "test": "vitest --exclude \"test/system-tests/**\" --config test/vitest.config.mts",
46
46
  "test:verbose": "FLOWR_VERBOSE=true vitest --exclude \"test/system-tests/**\" --config test/vitest.config.mts",
47
47
  "test:system": "vitest --dir test/system-tests --config test/system-tests/vitest.config.mts",
@@ -69,8 +69,7 @@
69
69
  "includeVersion": true,
70
70
  "plugin": [
71
71
  "typedoc-umlclass",
72
- "typedoc-plugin-missing-exports",
73
- "typedoc-theme-hierarchy"
72
+ "typedoc-plugin-missing-exports"
74
73
  ],
75
74
  "entryPoints": [
76
75
  "src",
@@ -94,18 +93,19 @@
94
93
  "typescript",
95
94
  "r"
96
95
  ],
97
- "theme": "hierarchy",
98
96
  "out": "doc",
99
97
  "readme": "README.md",
100
98
  "umlClassDiagram": {
101
99
  "type": "detailed",
102
- "location": "embed",
100
+ "location": "local",
103
101
  "format": "svg",
104
102
  "position": "below",
105
103
  "legendType": "none",
106
- "hideEmptyMembers": false,
104
+ "hideEmptyMembers": true,
107
105
  "generatorProcessCount": 4
108
106
  },
107
+ "maxTypeConversionDepth": 4,
108
+ "skipErrorChecking": true,
109
109
  "lightHighlightTheme": "light-plus",
110
110
  "darkHighlightTheme": "dark-plus",
111
111
  "hideGenerator": false,
@@ -213,7 +213,6 @@
213
213
  "ts-node": "^10.9.2",
214
214
  "typedoc": "^0.28.17",
215
215
  "typedoc-plugin-missing-exports": "^4.1.2",
216
- "typedoc-theme-hierarchy": "^6.0.0",
217
216
  "typedoc-umlclass": "^0.10.2",
218
217
  "typescript": "^5.9.3",
219
218
  "vitest": "^4.1.8"
@@ -0,0 +1,13 @@
1
+ import type { PackageSignatureSource } from './sigdb/reader';
2
+ /**
3
+ * Packages that attach further packages from their `.onAttach` hook, which no package metadata records: their core
4
+ * set sits in `Imports`, indistinguishable from the packages they merely use. Whoever loads one of them gets the
5
+ * whole set on the search path, so `library(tidyverse)` has to resolve `ggplot()`.
6
+ * `Depends` is handled generally by {@link attachedAlongside} and hence not repeated here.
7
+ */
8
+ export declare const MetaPackageCores: ReadonlyMap<string, readonly string[]>;
9
+ /**
10
+ * The packages that end up on the search path alongside `pack` when it is attached: everything it `Depends` on
11
+ * (which R attaches with it) and, for a {@link MetaPackageCores|meta-package}, the core set it attaches itself.
12
+ */
13
+ export declare function attachedAlongside(pack: string, sources: readonly PackageSignatureSource[], version?: string): readonly string[];
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MetaPackageCores = void 0;
4
+ exports.attachedAlongside = attachedAlongside;
5
+ /**
6
+ * Packages that attach further packages from their `.onAttach` hook, which no package metadata records: their core
7
+ * set sits in `Imports`, indistinguishable from the packages they merely use. Whoever loads one of them gets the
8
+ * whole set on the search path, so `library(tidyverse)` has to resolve `ggplot()`.
9
+ * `Depends` is handled generally by {@link attachedAlongside} and hence not repeated here.
10
+ */
11
+ exports.MetaPackageCores = new Map([
12
+ ['tidyverse', ['ggplot2', 'tibble', 'tidyr', 'readr', 'purrr', 'dplyr', 'stringr', 'forcats', 'lubridate']],
13
+ ['tidymodels', ['broom', 'dials', 'dplyr', 'ggplot2', 'infer', 'modeldata', 'parsnip', 'purrr', 'recipes',
14
+ 'rsample', 'tailor', 'tibble', 'tidyr', 'tune', 'workflows', 'workflowsets', 'yardstick']],
15
+ ['easystats', ['bayestestR', 'correlation', 'datawizard', 'effectsize', 'insight', 'modelbased', 'parameters',
16
+ 'performance', 'report', 'see']],
17
+ ['fpp3', ['tibble', 'dplyr', 'tidyr', 'lubridate', 'ggplot2', 'tsibble', 'tsibbledata', 'ggtime', 'feasts', 'fable']]
18
+ ]);
19
+ /**
20
+ * The packages that end up on the search path alongside `pack` when it is attached: everything it `Depends` on
21
+ * (which R attaches with it) and, for a {@link MetaPackageCores|meta-package}, the core set it attaches itself.
22
+ */
23
+ function attachedAlongside(pack, sources, version) {
24
+ const depends = sources
25
+ .flatMap(src => src.dependencies(pack, version) ?? [])
26
+ .filter(d => d.type === 0 /* DepType.Depends */ && d.name !== 'R')
27
+ .map(d => d.name);
28
+ return [...new Set([...depends, ...exports.MetaPackageCores.get(pack) ?? []])];
29
+ }
30
+ //# sourceMappingURL=attached-packages.js.map
@@ -45,6 +45,8 @@ export interface ReadOnlyFlowrAnalyzerContext {
45
45
  readonly resolvedRVersion: string;
46
46
  /** Whether {@link resolvedRVersion} is a genuine signal (a config pin, project metadata, or an engine-detected version) rather than the fallback default. */
47
47
  readonly rVersionKnown: boolean;
48
+ /** Where {@link resolvedRVersion} comes from, as only {@link RVersionOrigin.Config} and {@link RVersionOrigin.Metadata} say anything about the analyzed code. */
49
+ readonly rVersionOrigin: RVersionOrigin;
48
50
  /** Classify the {@link ProjectKind} of the project, see {@link ReadOnlyFlowrAnalyzerFilesContext#projectKind}. */
49
51
  projectKind(): ProjectKind;
50
52
  /** The versions a dependency can possibly have, see {@link ReadOnlyFlowrAnalyzerDependenciesContext#inferredRange}. */
@@ -57,6 +59,17 @@ export interface ReadOnlyFlowrAnalyzerContext {
57
59
  */
58
60
  readonly gas: ReadOnlyFlowrAnalyzerGasContext;
59
61
  }
62
+ /** Where the R version an analysis assumes comes from, see {@link ReadOnlyFlowrAnalyzerContext.rVersionOrigin}. */
63
+ export declare const enum RVersionOrigin {
64
+ /** pinned via `solver.sigdb.assumedRVersion` */
65
+ Config = "config",
66
+ /** stated by the project itself (e.g. a `DESCRIPTION` `Depends: R (>= x)`) */
67
+ Metadata = "metadata",
68
+ /** detected from the R installation running the analysis, which says nothing about the analyzed code */
69
+ Engine = "engine",
70
+ /** nothing said anything, so the fallback default is used */
71
+ Default = "default"
72
+ }
60
73
  /**
61
74
  * This summarizes the other context layers used by the {@link FlowrAnalyzer}.
62
75
  * Have a look at the attributes and layers listed below (e.g., {@link files} and {@link deps})
@@ -131,6 +144,8 @@ export declare class FlowrAnalyzerContext implements ReadOnlyFlowrAnalyzerContex
131
144
  get resolvedRVersion(): string;
132
145
  /** Whether {@link resolvedRVersion} is a genuine signal (a config pin, project metadata, or engine detection) rather than the fallback default. */
133
146
  get rVersionKnown(): boolean;
147
+ /** Where {@link resolvedRVersion} comes from, which decides what it says about the analyzed code. */
148
+ get rVersionOrigin(): RVersionOrigin;
134
149
  /** Classify the {@link ProjectKind} of the project (delegates to the cached {@link FlowrAnalyzerFilesContext#projectKind}). */
135
150
  projectKind(): ProjectKind;
136
151
  /** The versions a dependency can possibly have (delegates to {@link FlowrAnalyzerDependenciesContext#inferredRange}). */
@@ -175,10 +175,21 @@ class FlowrAnalyzerContext {
175
175
  }
176
176
  /** Whether {@link resolvedRVersion} is a genuine signal (a config pin, project metadata, or engine detection) rather than the fallback default. */
177
177
  get rVersionKnown() {
178
+ return this.rVersionOrigin !== "default" /* RVersionOrigin.Default */;
179
+ }
180
+ /** Where {@link resolvedRVersion} comes from, which decides what it says about the analyzed code. */
181
+ get rVersionOrigin() {
178
182
  const setting = this.config.solver.sigdb.assumedRVersion;
179
- return (setting !== undefined && setting !== 'auto')
180
- || this.meta.getRVersion() !== undefined
181
- || (this._detectedR !== undefined && this._detectedR !== 'none' && this._detectedR !== 'unknown');
183
+ if (setting !== undefined && setting !== 'auto') {
184
+ return "config" /* RVersionOrigin.Config */;
185
+ }
186
+ else if (this.meta.getRVersion() !== undefined) {
187
+ return "metadata" /* RVersionOrigin.Metadata */;
188
+ }
189
+ else if (this._detectedR !== undefined && this._detectedR !== 'none' && this._detectedR !== 'unknown') {
190
+ return "engine" /* RVersionOrigin.Engine */;
191
+ }
192
+ return "default" /* RVersionOrigin.Default */;
182
193
  }
183
194
  /** Classify the {@link ProjectKind} of the project (delegates to the cached {@link FlowrAnalyzerFilesContext#projectKind}). */
184
195
  projectKind() {
@@ -122,6 +122,16 @@ export interface ReadOnlyFlowrAnalyzerFilesContext {
122
122
  * folder for a single-file request. Useful to report back which inputs did not resolve to anything.
123
123
  */
124
124
  getRequestedRoots(): readonly string[];
125
+ /**
126
+ * The total number of files known to this context (every file added via {@link addFile}, both disk-backed and inline).
127
+ *
128
+ * This is unrelated to {@link getFilesByRole}: A file counted here may have no role, one role, or several
129
+ * (summing `getFilesByRole(role).length` over all roles can both over-count (multi-role files) and under-count (roleless files) relative to this method).
130
+ *
131
+ * Files that were merely considered during dataflow analysis (see {@link consideredFilesList}) but never actually added to the context are not included.
132
+ * @returns The number of files currently held by this context.
133
+ */
134
+ getFileCount(): number;
125
135
  }
126
136
  /**
127
137
  * This is the analyzer file context to be modified by all plugins that affect the files.
@@ -210,4 +220,5 @@ export declare class FlowrAnalyzerFilesContext extends AbstractFlowrAnalyzerCont
210
220
  getFilesByRole<Role extends FileRole>(role: Role): RoleBasedFiles[Role];
211
221
  getAllFiles(): FlowrFileProvider[];
212
222
  getFileByPath(path: string): FlowrFileProvider | undefined;
223
+ getFileCount(): number;
213
224
  }
@@ -379,6 +379,9 @@ class FlowrAnalyzerFilesContext extends abstract_flowr_analyzer_context_1.Abstra
379
379
  getFileByPath(path) {
380
380
  return this.files.get(path) ?? this.inlineFiles.find(f => f.path() === path);
381
381
  }
382
+ getFileCount() {
383
+ return this.files.size + this.inlineFiles.length;
384
+ }
382
385
  }
383
386
  exports.FlowrAnalyzerFilesContext = FlowrAnalyzerFilesContext;
384
387
  //# sourceMappingURL=flowr-analyzer-files-context.js.map
@@ -22,12 +22,16 @@ export declare class FlowrAnalyzerIncrementalAnalysisContext implements ReadOnly
22
22
  */
23
23
  private changedFilesWithOldContent;
24
24
  private oldParseResults;
25
+ private readonly lastKnownMtime;
25
26
  constructor(context: FlowrAnalyzerContext);
26
27
  reset(): void;
27
28
  handleFileInvalidate(filePath: FilePath, oldContent: string | undefined): void;
29
+ handleShouldReparse(filePath: FilePath, ctx: FlowrAnalyzerContext): boolean;
28
30
  receive(event: InvalidationEvent): void;
29
31
  storeOldParseResults(parseStepOutput: ParseStepOutput<Parser.Tree>): void;
30
32
  getOldParseResultOf(filePath: FilePath): Parser.Tree | undefined;
31
33
  getOldContentOf(filePath: FilePath): string | undefined;
32
34
  deleteOldContentOf(filePath: FilePath): void;
35
+ getLastKnownMtime(filePath: FilePath): number | undefined;
36
+ setLastKnownMtime(filePath: FilePath, mtimeMs: number): void;
33
37
  }
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.FlowrAnalyzerIncrementalAnalysisContext = void 0;
4
7
  const assert_1 = require("../../util/assert");
8
+ const fs_1 = __importDefault(require("fs"));
5
9
  /**
6
10
  * Information to carry over for future incremental builds
7
11
  */
@@ -13,6 +17,7 @@ class FlowrAnalyzerIncrementalAnalysisContext {
13
17
  */
14
18
  changedFilesWithOldContent = new Map();
15
19
  oldParseResults = new Map();
20
+ lastKnownMtime = new Map();
16
21
  constructor(context) {
17
22
  this.context = context;
18
23
  }
@@ -27,6 +32,64 @@ class FlowrAnalyzerIncrementalAnalysisContext {
27
32
  }
28
33
  this.changedFilesWithOldContent.set(filePath, oldContent);
29
34
  }
35
+ handleShouldReparse(filePath, ctx) {
36
+ if (ctx.config.incremental.alwaysIncremental) {
37
+ return true;
38
+ }
39
+ if (!ctx.config.incremental.parsing.activated) {
40
+ return false;
41
+ }
42
+ const heuristics = ctx.config.incremental.parsing.heuristics;
43
+ if (!heuristics.activated || heuristics.alwaysWithEdits) {
44
+ return true;
45
+ }
46
+ const checks = [];
47
+ if (heuristics.mtime) {
48
+ checks.push((filePath, ctx) => {
49
+ let currentMtime;
50
+ try {
51
+ currentMtime = fs_1.default.statSync(filePath).mtimeMs;
52
+ }
53
+ catch {
54
+ return true;
55
+ }
56
+ const lastMtime = ctx.inc.getLastKnownMtime(filePath);
57
+ const mtimeChanged = !(lastMtime !== undefined && lastMtime === currentMtime);
58
+ if (mtimeChanged) {
59
+ ctx.inc.setLastKnownMtime(filePath, currentMtime);
60
+ }
61
+ return mtimeChanged;
62
+ });
63
+ }
64
+ if (heuristics.linesFrom !== undefined) {
65
+ checks.push((filePath, ctx) => {
66
+ const content = ctx.files.getFileByPath(filePath)?.content();
67
+ if (typeof content !== 'string') {
68
+ return false;
69
+ }
70
+ const lineCount = content.split('\n').length;
71
+ return lineCount >= heuristics.linesFrom;
72
+ });
73
+ }
74
+ if (heuristics.bytesFrom) {
75
+ checks.push((filePath) => {
76
+ try {
77
+ return fs_1.default.statSync(filePath).size >= heuristics.bytesFrom;
78
+ }
79
+ catch {
80
+ return true;
81
+ }
82
+ });
83
+ }
84
+ if (heuristics.minFiles !== undefined) {
85
+ checks.push((_filePath, ctx) => {
86
+ return ctx.files.getFileCount() >= heuristics.minFiles;
87
+ });
88
+ }
89
+ return checks.length === 0
90
+ ? true
91
+ : checks.every(check => check(filePath, ctx));
92
+ }
30
93
  receive(event) {
31
94
  const type = event.type;
32
95
  switch (type) {
@@ -58,6 +121,12 @@ class FlowrAnalyzerIncrementalAnalysisContext {
58
121
  deleteOldContentOf(filePath) {
59
122
  this.changedFilesWithOldContent.delete(filePath);
60
123
  }
124
+ getLastKnownMtime(filePath) {
125
+ return this.lastKnownMtime.get(filePath);
126
+ }
127
+ setLastKnownMtime(filePath, mtimeMs) {
128
+ this.lastKnownMtime.set(filePath, mtimeMs);
129
+ }
61
130
  }
62
131
  exports.FlowrAnalyzerIncrementalAnalysisContext = FlowrAnalyzerIncrementalAnalysisContext;
63
132
  //# sourceMappingURL=flowr-analyzer-incremental-analysis-context.js.map
@@ -49,7 +49,15 @@ export declare class FlowrAnalyzerLoadingOrderContext extends AbstractFlowrAnaly
49
49
  private readonly guesses;
50
50
  /** just the base collection of requests we know nothing about the order! */
51
51
  private readonly unordered;
52
+ /** what {@link unordered} already holds, so the same file is never analyzed (and reconstructed) twice */
53
+ private readonly seen;
52
54
  reset(): void;
55
+ /**
56
+ * Registers `request` as unordered unless the same one is already there, reporting whether it was new.
57
+ * Project discovery and the implicit-source scan reach the same file from both ends, so a file otherwise
58
+ * lands in the loading order more than once and every later step repeats it.
59
+ */
60
+ private register;
53
61
  /**
54
62
  * Add one or multiple requests to the context.
55
63
  * These are considered unordered (i.e., ordered implicitly by the order of addition) until a plugin provides either a guess or a known order.
@@ -23,12 +23,29 @@ class FlowrAnalyzerLoadingOrderContext extends abstract_flowr_analyzer_context_1
23
23
  guesses = [];
24
24
  /** just the base collection of requests we know nothing about the order! */
25
25
  unordered = [];
26
+ /** what {@link unordered} already holds, so the same file is never analyzed (and reconstructed) twice */
27
+ seen = new Set();
26
28
  reset() {
27
29
  this.knownOrder = undefined;
28
30
  this.guesses.length = 0;
29
31
  this.unordered.length = 0;
32
+ this.seen.clear();
30
33
  this.rerunRequired = this.plugins.length > 0;
31
34
  }
35
+ /**
36
+ * Registers `request` as unordered unless the same one is already there, reporting whether it was new.
37
+ * Project discovery and the implicit-source scan reach the same file from both ends, so a file otherwise
38
+ * lands in the loading order more than once and every later step repeats it.
39
+ */
40
+ register(request) {
41
+ const key = `${request.request}\u0000${request.content}`;
42
+ if (this.seen.has(key)) {
43
+ return false;
44
+ }
45
+ this.seen.add(key);
46
+ this.unordered.push(request);
47
+ return true;
48
+ }
32
49
  /**
33
50
  * Add one or multiple requests to the context.
34
51
  * These are considered unordered (i.e., ordered implicitly by the order of addition) until a plugin provides either a guess or a known order.
@@ -36,7 +53,9 @@ class FlowrAnalyzerLoadingOrderContext extends abstract_flowr_analyzer_context_1
36
53
  * This is a batched version of {@link addRequest}.
37
54
  */
38
55
  addRequests(requests) {
39
- this.unordered.push(...requests);
56
+ if (!requests.map(r => this.register(r)).some(Boolean)) {
57
+ return;
58
+ }
40
59
  if (this.knownOrder || this.guesses.length > 0) {
41
60
  loadingOrderLog.warn(`Adding requests ${requests.map(r => r.request).join(', ')} after known order!`);
42
61
  this.rerunRequired = true;
@@ -49,7 +68,9 @@ class FlowrAnalyzerLoadingOrderContext extends abstract_flowr_analyzer_context_1
49
68
  * If you want to add multiple requests, consider using {@link addRequests} instead for efficiency.
50
69
  */
51
70
  addRequest(request) {
52
- this.unordered.push(request);
71
+ if (!this.register(request)) {
72
+ return;
73
+ }
53
74
  if (this.knownOrder || this.guesses.length > 0) {
54
75
  loadingOrderLog.warn(`Adding request ${request.request} ${request.content} after known order!`);
55
76
  this.rerunRequired = true;