@eagleoutice/flowr 2.11.1 → 2.12.1

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 (264) hide show
  1. package/README.md +187 -257
  2. package/abstract-interpretation/absint-visitor.d.ts +1 -0
  3. package/abstract-interpretation/data-frame/mappers/arguments.js +7 -1
  4. package/abstract-interpretation/domains/set-range-domain.js +1 -1
  5. package/abstract-interpretation/domains/set-upper-bound-domain.js +6 -2
  6. package/benchmark/slicer.d.ts +1 -1
  7. package/benchmark/slicer.js +3 -1
  8. package/benchmark/summarizer/second-phase/graph.js +5 -0
  9. package/cli/common/options.d.ts +8 -0
  10. package/cli/common/options.js +2 -0
  11. package/cli/common/scripts-info.d.ts +8 -0
  12. package/cli/repl/commands/repl-commands.d.ts +1 -0
  13. package/cli/repl/commands/repl-commands.js +66 -15
  14. package/cli/repl/commands/repl-dataflow.js +48 -4
  15. package/cli/repl/commands/repl-main.d.ts +2 -0
  16. package/cli/repl/commands/repl-main.js +5 -0
  17. package/cli/repl/commands/repl-query.d.ts +4 -1
  18. package/cli/repl/commands/repl-query.js +72 -22
  19. package/cli/repl/commands/repl-signature.d.ts +7 -0
  20. package/cli/repl/commands/repl-signature.js +119 -0
  21. package/cli/repl/core.d.ts +8 -1
  22. package/cli/repl/core.js +46 -6
  23. package/cli/repl/ghost-hint.d.ts +37 -0
  24. package/cli/repl/ghost-hint.js +72 -0
  25. package/cli/repl/parser/slice-query-parser.d.ts +11 -1
  26. package/cli/repl/parser/slice-query-parser.js +45 -16
  27. package/cli/repl/print-version.d.ts +2 -4
  28. package/cli/repl/print-version.js +41 -23
  29. package/cli/repl/server/connection.js +19 -17
  30. package/cli/slicer-app.d.ts +2 -0
  31. package/cli/slicer-app.js +3 -3
  32. package/cli/wiki.d.ts +2 -2
  33. package/cli/wiki.js +2 -2
  34. package/config.d.ts +63 -2
  35. package/config.js +64 -8
  36. package/control-flow/cfg-dead-code.js +0 -1
  37. package/control-flow/control-flow-graph.js +6 -6
  38. package/control-flow/diff-cfg.js +2 -2
  39. package/control-flow/semantic-cfg-guided-visitor.js +2 -0
  40. package/core/print/slice-diff-ansi.js +8 -8
  41. package/core/steps/all/core/20-dataflow.d.ts +2 -2
  42. package/core/steps/all/static-slicing/00-slice.d.ts +5 -0
  43. package/core/steps/all/static-slicing/00-slice.js +1 -1
  44. package/core/steps/all/static-slicing/10-reconstruct.d.ts +7 -0
  45. package/core/steps/all/static-slicing/10-reconstruct.js +6 -2
  46. package/core/steps/pipeline/default-pipelines.d.ts +20 -16
  47. package/data/r-base-packages.generated.d.ts +44 -0
  48. package/data/r-base-packages.generated.js +32 -0
  49. package/data/r-base-primitives.generated.d.ts +1 -0
  50. package/data/r-base-primitives.generated.js +15 -0
  51. package/data/sigdb/sigdb.remote.json +112 -0
  52. package/dataflow/environments/built-in-proc-name.d.ts +4 -0
  53. package/dataflow/environments/built-in-proc-name.js +4 -0
  54. package/dataflow/environments/built-in.d.ts +14 -4
  55. package/dataflow/environments/built-in.js +13 -2
  56. package/dataflow/environments/data-masking-functions.d.ts +12 -0
  57. package/dataflow/environments/data-masking-functions.js +46 -0
  58. package/dataflow/environments/default-builtin-config.d.ts +72 -19
  59. package/dataflow/environments/default-builtin-config.js +48 -14
  60. package/dataflow/environments/diff.js +1 -1
  61. package/dataflow/environments/environment.js +1 -2
  62. package/dataflow/environments/identifier.d.ts +11 -4
  63. package/dataflow/environments/identifier.js +28 -10
  64. package/dataflow/environments/resolve-by-name.js +16 -2
  65. package/dataflow/extractor.js +6 -3
  66. package/dataflow/graph/call-graph.d.ts +2 -2
  67. package/dataflow/graph/df-helper.d.ts +4 -4
  68. package/dataflow/graph/diff-dataflow-graph.js +2 -2
  69. package/dataflow/graph/edge.d.ts +3 -3
  70. package/dataflow/graph/edge.js +3 -3
  71. package/dataflow/graph/graph-helper.d.ts +2 -2
  72. package/dataflow/internal/linker.js +1 -1
  73. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +7 -0
  74. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +20 -0
  75. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +1 -0
  76. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +2 -49
  77. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +6 -1
  78. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +7 -1
  79. package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +19 -0
  80. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +111 -6
  81. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +13 -0
  82. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +2 -3
  83. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +9 -0
  84. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +19 -0
  85. package/dataflow/internal/process/functions/call/built-in/built-in-with.js +12 -4
  86. package/dataflow/internal/process/functions/call/common.js +8 -1
  87. package/dataflow/internal/process/functions/call/default-call-handling.js +6 -0
  88. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +17 -0
  89. package/dataflow/internal/process/functions/call/known-call-handling.js +32 -0
  90. package/dataflow/internal/process/functions/call/named-call-handling.js +29 -7
  91. package/dataflow/internal/process/functions/process-argument.js +12 -1
  92. package/dataflow/internal/process/process-named-call.d.ts +18 -1
  93. package/dataflow/internal/process/process-named-call.js +94 -0
  94. package/dataflow/processor.d.ts +18 -0
  95. package/documentation/data/faq/faqs.js +5 -1
  96. package/documentation/doc-capabilities.js +1 -1
  97. package/documentation/doc-util/doc-cli-option.d.ts +10 -0
  98. package/documentation/doc-util/doc-cli-option.js +23 -0
  99. package/documentation/doc-util/doc-dfg.js +2 -1
  100. package/documentation/doc-util/doc-query.d.ts +9 -3
  101. package/documentation/doc-util/doc-query.js +9 -4
  102. package/documentation/wiki-dataflow-graph.js +8 -5
  103. package/documentation/wiki-interface.js +4 -2
  104. package/documentation/wiki-linter.js +1 -1
  105. package/documentation/wiki-linting-and-testing.js +4 -1
  106. package/documentation/wiki-mk/doc-context.d.ts +14 -0
  107. package/documentation/wiki-mk/doc-context.js +3 -0
  108. package/documentation/wiki-mk/doc-maker.js +3 -1
  109. package/documentation/wiki-query.js +36 -15
  110. package/documentation/wiki-setup.js +10 -7
  111. package/documentation/wiki-signature-database.d.ts +16 -0
  112. package/documentation/wiki-signature-database.js +293 -0
  113. package/linter/linter-format.d.ts +7 -0
  114. package/linter/linter-rules.d.ts +10 -9
  115. package/linter/rules/naming-convention.d.ts +1 -0
  116. package/linter/rules/naming-convention.js +2 -0
  117. package/linter/rules/no-leaked-credentials.js +1 -2
  118. package/linter/rules/roxygen-arguments.js +18 -5
  119. package/linter/rules/stop-with-call-arg.js +2 -2
  120. package/linter/rules/undefined-symbol-util.d.ts +36 -0
  121. package/linter/rules/undefined-symbol-util.js +149 -0
  122. package/linter/rules/undefined-symbol.d.ts +58 -17
  123. package/linter/rules/undefined-symbol.js +143 -33
  124. package/linter/rules/unused-definition.d.ts +8 -1
  125. package/linter/rules/unused-definition.js +126 -1
  126. package/package.json +22 -10
  127. package/project/context/abstract-flowr-analyzer-context.js +7 -1
  128. package/project/context/flowr-analyzer-context.d.ts +8 -0
  129. package/project/context/flowr-analyzer-context.js +10 -0
  130. package/project/context/flowr-analyzer-dependencies-context.d.ts +28 -4
  131. package/project/context/flowr-analyzer-dependencies-context.js +51 -2
  132. package/project/context/flowr-analyzer-files-context.d.ts +1 -0
  133. package/project/context/flowr-analyzer-files-context.js +2 -1
  134. package/project/context/flowr-analyzer-functions-context.js +1 -1
  135. package/project/context/flowr-file.d.ts +5 -0
  136. package/project/context/flowr-file.js +5 -0
  137. package/project/flowr-analyzer-builder.js +12 -2
  138. package/project/plugins/file-plugins/files/flowr-description-file.js +6 -3
  139. package/project/plugins/file-plugins/files/flowr-namespace-file.js +9 -3
  140. package/project/plugins/file-plugins/files/flowr-news-file.js +1 -3
  141. package/project/plugins/file-plugins/flowr-analyzer-inst-file-plugin.d.ts +26 -0
  142. package/project/plugins/file-plugins/flowr-analyzer-inst-file-plugin.js +39 -0
  143. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.js +1 -1
  144. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +2 -2
  145. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-namespace-file-plugin.js +1 -0
  146. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.d.ts +18 -2
  147. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.js +19 -0
  148. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +120 -0
  149. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +518 -0
  150. package/project/plugins/package-version-plugins/package.d.ts +5 -3
  151. package/project/plugins/package-version-plugins/package.js +27 -25
  152. package/project/plugins/plugin-registry.d.ts +3 -2
  153. package/project/plugins/plugin-registry.js +4 -2
  154. package/project/plugins/project-discovery/flowr-analyzer-gitignore-project-discovery-plugin.js +7 -2
  155. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +3 -1
  156. package/project/sigdb/build.d.ts +131 -0
  157. package/project/sigdb/build.js +628 -0
  158. package/project/sigdb/codec.d.ts +51 -0
  159. package/project/sigdb/codec.js +122 -0
  160. package/project/sigdb/decode.d.ts +58 -0
  161. package/project/sigdb/decode.js +129 -0
  162. package/project/sigdb/decompress.d.ts +44 -0
  163. package/project/sigdb/decompress.js +176 -0
  164. package/project/sigdb/hash.d.ts +9 -0
  165. package/project/sigdb/hash.js +54 -0
  166. package/project/sigdb/index-format.d.ts +40 -0
  167. package/project/sigdb/index-format.js +28 -0
  168. package/project/sigdb/manifest.d.ts +68 -0
  169. package/project/sigdb/manifest.js +146 -0
  170. package/project/sigdb/reader.d.ts +250 -0
  171. package/project/sigdb/reader.js +692 -0
  172. package/project/sigdb/schema.d.ts +196 -0
  173. package/project/sigdb/schema.js +33 -0
  174. package/project/sigdb/sigdb-download.d.ts +65 -0
  175. package/project/sigdb/sigdb-download.js +237 -0
  176. package/project/sigdb/signature-match.d.ts +26 -0
  177. package/project/sigdb/signature-match.js +40 -0
  178. package/project/sigdb/version.d.ts +20 -0
  179. package/project/sigdb/version.js +55 -0
  180. package/queries/catalog/absint-query/absint-query-executor.d.ts +6 -0
  181. package/queries/catalog/absint-query/absint-query-executor.js +63 -0
  182. package/queries/catalog/absint-query/absint-query-format.d.ts +37 -0
  183. package/queries/catalog/absint-query/absint-query-format.js +102 -0
  184. package/queries/catalog/call-context-query/call-context-query-executor.js +1 -3
  185. package/queries/catalog/config-query/config-query-format.d.ts +3 -1
  186. package/queries/catalog/config-query/config-query-format.js +68 -9
  187. package/queries/catalog/dataflow-query/dataflow-query-format.js +11 -1
  188. package/queries/catalog/dependencies-query/dependencies-query-executor.js +1 -1
  189. package/queries/catalog/linter-query/linter-query-executor.d.ts +2 -0
  190. package/queries/catalog/linter-query/linter-query-executor.js +6 -1
  191. package/queries/catalog/linter-query/linter-query-format.d.ts +2 -1
  192. package/queries/catalog/linter-query/linter-query-format.js +40 -8
  193. package/queries/catalog/project-query/project-query-executor.d.ts +15 -0
  194. package/queries/catalog/project-query/project-query-executor.js +96 -4
  195. package/queries/catalog/project-query/project-query-format.d.ts +44 -0
  196. package/queries/catalog/project-query/project-query-format.js +33 -2
  197. package/queries/catalog/signature-query/signature-query-executor.d.ts +29 -0
  198. package/queries/catalog/signature-query/signature-query-executor.js +461 -0
  199. package/queries/catalog/signature-query/signature-query-format.d.ts +138 -0
  200. package/queries/catalog/signature-query/signature-query-format.js +76 -0
  201. package/queries/catalog/signature-query/signature-query-render.d.ts +15 -0
  202. package/queries/catalog/signature-query/signature-query-render.js +155 -0
  203. package/queries/catalog/static-slice-query/static-slice-query-executor.js +9 -3
  204. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +10 -0
  205. package/queries/catalog/static-slice-query/static-slice-query-format.js +19 -1
  206. package/queries/query-print.js +5 -0
  207. package/queries/query.d.ts +15 -5
  208. package/queries/query.js +7 -4
  209. package/r-bridge/init.js +5 -1
  210. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +10 -0
  211. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +55 -0
  212. package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +16 -0
  213. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +27 -0
  214. package/r-bridge/lang-4.x/ast/parser/json/format.js +89 -2
  215. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-expressions.js +2 -4
  216. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +2 -1
  217. package/r-bridge/parser.d.ts +2 -0
  218. package/r-bridge/retriever.js +4 -1
  219. package/r-bridge/roxygen2/documentation-provider.js +2 -1
  220. package/r-bridge/shell.d.ts +5 -0
  221. package/r-bridge/shell.js +17 -1
  222. package/reconstruct/inline/source-inline-map.d.ts +48 -0
  223. package/reconstruct/inline/source-inline-map.js +94 -0
  224. package/reconstruct/reconstruct.d.ts +19 -2
  225. package/reconstruct/reconstruct.js +79 -16
  226. package/search/search-executor/search-generators.js +5 -22
  227. package/search/search-executor/search-transformer.js +10 -6
  228. package/slicing/criterion/parse.d.ts +28 -4
  229. package/slicing/criterion/parse.js +133 -18
  230. package/slicing/static/slice-call.d.ts +24 -1
  231. package/slicing/static/slice-call.js +90 -0
  232. package/slicing/static/static-slicer.d.ts +7 -0
  233. package/slicing/static/static-slicer.js +38 -3
  234. package/util/collections/arrays.d.ts +4 -5
  235. package/util/collections/arrays.js +7 -18
  236. package/util/hash.d.ts +14 -0
  237. package/util/hash.js +31 -0
  238. package/util/mermaid/dfg.d.ts +7 -2
  239. package/util/mermaid/dfg.js +53 -13
  240. package/util/r-base-packages.d.ts +19 -0
  241. package/util/r-base-packages.js +72 -0
  242. package/util/r-license.js +2 -10
  243. package/util/r-version.d.ts +45 -15
  244. package/util/r-version.js +97 -36
  245. package/util/range.d.ts +15 -0
  246. package/util/range.js +39 -0
  247. package/util/schema.d.ts +10 -0
  248. package/util/schema.js +22 -0
  249. package/util/text/ansi.d.ts +3 -0
  250. package/util/text/ansi.js +10 -0
  251. package/util/text/args.js +1 -2
  252. package/util/version.js +28 -8
  253. package/data/pkgdb/pkgdb-latest.json.br +0 -0
  254. package/data/pkgdb/pkgdb-tiny.json.br +0 -0
  255. package/documentation/wiki-package-database.d.ts +0 -9
  256. package/documentation/wiki-package-database.js +0 -63
  257. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin.d.ts +0 -63
  258. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin.js +0 -176
  259. package/project/plugins/package-version-plugins/pkgdb.d.ts +0 -133
  260. package/project/plugins/package-version-plugins/pkgdb.js +0 -370
  261. package/queries/catalog/df-shape-query/df-shape-query-executor.d.ts +0 -6
  262. package/queries/catalog/df-shape-query/df-shape-query-executor.js +0 -58
  263. package/queries/catalog/df-shape-query/df-shape-query-format.d.ts +0 -27
  264. package/queries/catalog/df-shape-query/df-shape-query-format.js +0 -56
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dayToMillis = dayToMillis;
4
+ exports.releasesOf = releasesOf;
5
+ exports.newestVersion = newestVersion;
6
+ exports.resolveVersion = resolveVersion;
7
+ /**
8
+ * Version/date resolution over a {@link PkgBlob}: parsing stored version strings into comparable
9
+ * {@link RVersion}s, decoding the day-granularity release dates, and picking the effective version for a query.
10
+ * Split out of `../sigdb` so the reader/writer there stays focused on the byte format.
11
+ */
12
+ const r_version_1 = require("../../util/r-version");
13
+ /** milliseconds since the Unix epoch for a stored day count (dates are stored at day granularity to save space) */
14
+ function dayToMillis(day) {
15
+ return day * 86_400_000;
16
+ }
17
+ /** the known releases of a blob, ascending by R-version order (empty when no dates were stored) */
18
+ function releasesOf(blob) {
19
+ if (!blob) {
20
+ return [];
21
+ }
22
+ return Object.entries(blob.dates)
23
+ .map(([ver, day]) => ({ version: r_version_1.RVersion.parseOrZero(ver), date: new Date(dayToMillis(day)) }))
24
+ .sort((a, b) => r_version_1.RVersion.compare(a.version.str, b.version.str));
25
+ }
26
+ /** the version with the newest release date (falling back to `latest`, then the highest by R-version order) */
27
+ function newestVersion(blob, latest) {
28
+ let best;
29
+ let bestDay = -Infinity;
30
+ for (const [ver, day] of Object.entries(blob.dates)) {
31
+ if (day > bestDay) {
32
+ bestDay = day;
33
+ best = ver;
34
+ }
35
+ }
36
+ if (best !== undefined) {
37
+ return best;
38
+ }
39
+ if (blob.versions[latest]) {
40
+ return latest;
41
+ }
42
+ // no dates and no recorded latest: pick the highest by R's numeric-version order (not string order)
43
+ return r_version_1.RVersion.highest(Object.keys(blob.versions));
44
+ }
45
+ /** pick the version tuple: requested, else the package's latest, else the highest present by R-version order */
46
+ function resolveVersion(blob, latest, version) {
47
+ if (version && blob.versions[version]) {
48
+ return version;
49
+ }
50
+ if (blob.versions[latest]) {
51
+ return latest;
52
+ }
53
+ return r_version_1.RVersion.highest(Object.keys(blob.versions));
54
+ }
55
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1,6 @@
1
+ import type { BasicQueryData } from '../../base-query-format';
2
+ import { type AbsintQuery, type AbsintQueryResult, type AbsintQueryType } from './absint-query-format';
3
+ /**
4
+ * Executes the given abstract interpretation queries using the provided analyzer.
5
+ */
6
+ export declare function executeAbsintQuery<AbsintType extends AbsintQueryType>({ analyzer }: BasicQueryData, queries: readonly AbsintQuery<AbsintType>[]): Promise<AbsintQueryResult<AbsintType>>;
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.executeAbsintQuery = executeAbsintQuery;
4
+ const cfg_kind_1 = require("../../../project/cfg-kind");
5
+ const parse_1 = require("../../../slicing/criterion/parse");
6
+ const log_1 = require("../../../util/log");
7
+ const absint_query_format_1 = require("./absint-query-format");
8
+ /**
9
+ * Executes the given abstract interpretation queries using the provided analyzer.
10
+ */
11
+ async function executeAbsintQuery({ analyzer }, queries) {
12
+ if (queries.length === 0 || queries.some(query => query.inference !== queries[0].inference)) {
13
+ throw new Error('The inference types of bundled abstract interpretation queries must be the same.');
14
+ }
15
+ if (queries.length > 1 && queries.some(query => query.criteria === undefined)) {
16
+ log_1.log.warn('The abstract interpretation query expects only up to one query without slicing criteria, but got', queries.length);
17
+ queries = [{ type: 'absint', inference: queries[0].inference }];
18
+ }
19
+ const inference = absint_query_format_1.AbsintQueryInferences[queries[0].inference];
20
+ const ast = await analyzer.normalize();
21
+ const dfg = (await analyzer.dataflow()).graph;
22
+ const cfg = await analyzer.controlflow(undefined, cfg_kind_1.CfgKind.NoFunctionDefs);
23
+ const start = Date.now();
24
+ const visitor = inference({ controlFlow: cfg, dfg, normalizedAst: ast, ctx: analyzer.inspectContext() });
25
+ visitor.start();
26
+ const endState = visitor.getEndState();
27
+ if (queries.length === 1 && queries[0].criteria === undefined) {
28
+ return {
29
+ '.meta': {
30
+ timing: Date.now() - start
31
+ },
32
+ result: endState
33
+ };
34
+ }
35
+ const result = new Map();
36
+ for (const query of queries) {
37
+ if (query.criteria === undefined) {
38
+ log_1.log.warn('Missing criterion in abstract interpretation query');
39
+ continue;
40
+ }
41
+ for (const criterion of query.criteria) {
42
+ if (result.has(criterion)) {
43
+ log_1.log.warn('Duplicate criterion in abstract interpretation query:', query.criteria);
44
+ continue;
45
+ }
46
+ try {
47
+ const nodeId = parse_1.SlicingCriterion.parse(criterion, ast.idMap);
48
+ const value = visitor.getAbstractValue(nodeId);
49
+ result.set(criterion, value);
50
+ }
51
+ catch (err) {
52
+ console.error(err instanceof Error ? err.message : err);
53
+ }
54
+ }
55
+ }
56
+ return {
57
+ '.meta': {
58
+ timing: Date.now() - start
59
+ },
60
+ result: result
61
+ };
62
+ }
63
+ //# sourceMappingURL=absint-query-executor.js.map
@@ -0,0 +1,37 @@
1
+ import Joi from 'joi';
2
+ import type { AbsintVisitorConfiguration, DomainOfVisitor } from '../../../abstract-interpretation/absint-visitor';
3
+ import { DataFrameShapeInferenceVisitor } from '../../../abstract-interpretation/data-frame/shape-inference';
4
+ import type { ValueDomain } from '../../../abstract-interpretation/domains/state-domain-like';
5
+ import type { ReplOutput } from '../../../cli/repl/commands/repl-main';
6
+ import type { CommandCompletions } from '../../../cli/repl/core';
7
+ import type { FlowrConfig } from '../../../config';
8
+ import { SlicingCriterion, type SlicingCriteria } from '../../../slicing/criterion/parse';
9
+ import type { BaseQueryFormat, BaseQueryResult } from '../../base-query-format';
10
+ import type { ParsedQueryLine } from '../../query';
11
+ import { executeAbsintQuery } from './absint-query-executor';
12
+ export interface AbsintQuery<AbsintType extends AbsintQueryType = AbsintQueryType> extends BaseQueryFormat {
13
+ readonly type: 'absint';
14
+ readonly inference: AbsintType;
15
+ readonly criteria?: SlicingCriteria;
16
+ }
17
+ export interface AbsintQueryResult<AbsintType extends AbsintQueryType = AbsintQueryType> extends BaseQueryResult {
18
+ result: AbsintQueryStateDomain<AbsintType> | Map<SlicingCriterion, AbsintQueryDomain<AbsintType> | undefined>;
19
+ }
20
+ export declare const AbsintQueryInferences: {
21
+ 'df-shape': (config: AbsintVisitorConfiguration) => DataFrameShapeInferenceVisitor;
22
+ };
23
+ export type AbsintQueryType = keyof typeof AbsintQueryInferences;
24
+ export type AbsintQueryStateDomain<AbsintType extends AbsintQueryType = AbsintQueryType> = DomainOfVisitor<ReturnType<typeof AbsintQueryInferences[AbsintType]>>;
25
+ export type AbsintQueryDomain<AbsintType extends AbsintQueryType = AbsintQueryType> = ValueDomain<AbsintQueryStateDomain<AbsintType>>;
26
+ declare function absintQueryCompleter(line: readonly string[], startingNewArg: boolean, _config: FlowrConfig): CommandCompletions;
27
+ declare function absintQueryLineParser(output: ReplOutput, line: readonly string[], _config: FlowrConfig): ParsedQueryLine<'absint'>;
28
+ export declare const AbsintQueryDefinition: {
29
+ readonly executor: typeof executeAbsintQuery;
30
+ readonly asciiSummarizer: (formatter: import("../../../util/text/ansi").OutputFormatter, _analyzer: import("../../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider<import("../../../r-bridge/parser").KnownParser>, queryResults: BaseQueryResult, result: string[]) => true;
31
+ readonly jsonFormatter: (queryResults: BaseQueryResult) => object;
32
+ readonly completer: typeof absintQueryCompleter;
33
+ readonly fromLine: typeof absintQueryLineParser;
34
+ readonly schema: Joi.ObjectSchema<any>;
35
+ readonly flattenInvolvedNodes: () => never[];
36
+ };
37
+ export {};
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.AbsintQueryDefinition = exports.AbsintQueryInferences = void 0;
7
+ const joi_1 = __importDefault(require("joi"));
8
+ const shape_inference_1 = require("../../../abstract-interpretation/data-frame/shape-inference");
9
+ const abstract_domain_1 = require("../../../abstract-interpretation/domains/abstract-domain");
10
+ const lattice_1 = require("../../../abstract-interpretation/domains/lattice");
11
+ const slice_query_parser_1 = require("../../../cli/repl/parser/slice-query-parser");
12
+ const retriever_1 = require("../../../r-bridge/retriever");
13
+ const parse_1 = require("../../../slicing/criterion/parse");
14
+ const record_1 = require("../../../util/record");
15
+ const ansi_1 = require("../../../util/text/ansi");
16
+ const time_1 = require("../../../util/text/time");
17
+ const absint_query_executor_1 = require("./absint-query-executor");
18
+ exports.AbsintQueryInferences = {
19
+ 'df-shape': config => new shape_inference_1.DataFrameShapeInferenceVisitor(config)
20
+ };
21
+ function absintQueryCompleter(line, startingNewArg, _config) {
22
+ if (line.length === 0 || (line.length === 1 && !startingNewArg)) {
23
+ return { completions: record_1.Record.keys(exports.AbsintQueryInferences).map(type => `${type} `) };
24
+ }
25
+ else if ((line.length === 1 && startingNewArg) || (line.length === 2 && line[1].length === 0)) {
26
+ return { completions: ['(', '""', retriever_1.fileProtocol] };
27
+ }
28
+ else if (line.length === 2 && !startingNewArg && line[1].startsWith('(') && !line[1].endsWith(')') && !line[1].endsWith(';')) {
29
+ const criteria = (0, slice_query_parser_1.sliceCriteriaParser)(line[1] + ')');
30
+ if (criteria !== undefined && criteria.length > 0 && criteria.every(parse_1.SlicingCriterion.isValid)) {
31
+ return { completions: [';', ') '], argumentPart: '' };
32
+ }
33
+ }
34
+ else if ((line.length === 2 && startingNewArg) || (line.length === 3 && line[2].length === 0)) {
35
+ return { completions: ['""', retriever_1.fileProtocol] };
36
+ }
37
+ else if ((line.length === 2 && retriever_1.fileProtocol.startsWith(line[1])) || (line.length === 3 && retriever_1.fileProtocol.startsWith(line[2]))) {
38
+ return { completions: [retriever_1.fileProtocol] };
39
+ }
40
+ return { completions: [] };
41
+ }
42
+ function absintQueryLineParser(output, line, _config) {
43
+ const type = line[0].toLowerCase();
44
+ if (!Object.hasOwn(exports.AbsintQueryInferences, type)) {
45
+ output.stderr(output.formatter.format(`Invalid inference type "${type}", must be one of ${record_1.Record.keys(exports.AbsintQueryInferences).map(type => `"${type}"`).join(', ')}`, { color: 1 /* Colors.Red */, effect: ansi_1.ColorEffect.Foreground, style: 1 /* FontStyles.Bold */ }));
46
+ return { query: [] };
47
+ }
48
+ const criteria = (0, slice_query_parser_1.sliceCriteriaParser)(line[1]);
49
+ if (criteria !== undefined && !criteria.every(parse_1.SlicingCriterion.isValid)) {
50
+ output.stderr(output.formatter.format(`Invalid slicing criteria "${line[1]}"`, { color: 1 /* Colors.Red */, effect: ansi_1.ColorEffect.Foreground, style: 1 /* FontStyles.Bold */ }));
51
+ return { query: [] };
52
+ }
53
+ const code = criteria ? line[2] : line[1];
54
+ return {
55
+ query: {
56
+ type: 'absint',
57
+ inference: type,
58
+ criteria: criteria
59
+ },
60
+ rCode: code
61
+ };
62
+ }
63
+ exports.AbsintQueryDefinition = {
64
+ executor: absint_query_executor_1.executeAbsintQuery,
65
+ asciiSummarizer: (formatter, _analyzer, queryResults, result) => {
66
+ const out = queryResults;
67
+ const domains = out.result instanceof abstract_domain_1.AbstractDomain ? out.result.value : out.result;
68
+ result.push(`Query: ${(0, ansi_1.bold)('absint', formatter)} (${(0, time_1.printAsMs)(out['.meta'].timing, 0)})`);
69
+ if (domains === lattice_1.Bottom) {
70
+ result.push(` ╰ state: ${lattice_1.BottomSymbol}`);
71
+ return true;
72
+ }
73
+ else if (out.result instanceof abstract_domain_1.AbstractDomain && out.result.isTop()) {
74
+ result.push(` ╰ state: ${lattice_1.TopSymbol}`);
75
+ return true;
76
+ }
77
+ result.push(...domains.entries().take(20).map(([key, domain]) => {
78
+ const criterion = parse_1.SlicingCriterion.isValid(key) ? key : parse_1.SlicingCriterion.fromId(key);
79
+ return ` ╰ ${criterion}: ${domain?.toString()}`;
80
+ }));
81
+ if (domains.size > 20) {
82
+ result.push(' ╰ ... (see JSON)');
83
+ }
84
+ return true;
85
+ },
86
+ jsonFormatter: (queryResults) => {
87
+ const { result: domains, ...out } = queryResults;
88
+ const state = domains instanceof abstract_domain_1.AbstractDomain ? domains.value : domains;
89
+ const json = state === lattice_1.Bottom ? state.description : Object.fromEntries(state.entries().map(([key, domain]) => [key, domain?.toJSON() ?? null]));
90
+ const result = { domains: json, ...out };
91
+ return result;
92
+ },
93
+ completer: absintQueryCompleter,
94
+ fromLine: absintQueryLineParser,
95
+ schema: joi_1.default.object({
96
+ type: joi_1.default.string().valid('absint').required().description('The type of the query.'),
97
+ inference: joi_1.default.string().valid(...record_1.Record.keys(exports.AbsintQueryInferences)).required().description('The type of abstract interpretation inference.'),
98
+ criteria: joi_1.default.array().items(joi_1.default.string()).optional().description('The slicing criteria of the nodes to get the inferred abstract values for.')
99
+ }).description('The abstract interpretation query retrieves inferred abstract values'),
100
+ flattenInvolvedNodes: () => []
101
+ };
102
+ //# sourceMappingURL=absint-query-format.js.map
@@ -30,7 +30,6 @@ function makeReport(collector) {
30
30
  if (!Array.isArray(subkinds[subkind])) {
31
31
  subkinds[subkind] = [];
32
32
  }
33
- subkinds[subkind] ??= [];
34
33
  const collectIn = subkinds[subkind];
35
34
  for (const value of values) {
36
35
  collectIn.push(value);
@@ -288,8 +287,7 @@ async function executeCallContextQueries({ analyzer }, queries) {
288
287
  }
289
288
  }
290
289
  if (query.callTargetNamespace !== undefined) {
291
- // the resolved package (a loaded-library export) or the call's explicit namespace
292
- const pkg = identifier_1.Identifier.getNamespace(identifier_1.Identifier.toQualified((0, dfg_get_origin_1.getOriginInDfg)(dataflow.graph, nodeId)) ?? info.name);
290
+ const pkg = identifier_1.Identifier.getNamespace(identifier_1.Identifier.toQualified((0, dfg_get_origin_1.getOriginInDfg)(dataflow.graph, nodeId), info.name) ?? info.name);
293
291
  if (pkg !== query.callTargetNamespace) {
294
292
  continue;
295
293
  }
@@ -2,7 +2,7 @@ import type { BaseQueryFormat, BaseQueryResult } from '../../base-query-format';
2
2
  import { executeConfigQuery } from './config-query-executor';
3
3
  import { type OutputFormatter } from '../../../util/text/ansi';
4
4
  import Joi from 'joi';
5
- import type { FlowrConfig } from '../../../config';
5
+ import { FlowrConfig } from '../../../config';
6
6
  import type { DeepPartial } from 'ts-essentials';
7
7
  import type { ParsedQueryLine, Query } from '../../query';
8
8
  import type { ReplOutput } from '../../../cli/repl/commands/repl-main';
@@ -10,6 +10,8 @@ import type { CommandCompletions } from '../../../cli/repl/core';
10
10
  export interface ConfigQuery extends BaseQueryFormat {
11
11
  readonly type: 'config';
12
12
  readonly update?: DeepPartial<FlowrConfig>;
13
+ /** a `.`-separated path to inspect (read) a single config value instead of dumping the whole config (repl: `?path`) */
14
+ readonly inspect?: readonly string[];
13
15
  }
14
16
  export interface ConfigQueryResult extends BaseQueryResult {
15
17
  readonly config: FlowrConfig;
@@ -8,19 +8,32 @@ const config_query_executor_1 = require("./config-query-executor");
8
8
  const ansi_1 = require("../../../util/text/ansi");
9
9
  const time_1 = require("../../../util/text/time");
10
10
  const joi_1 = __importDefault(require("joi"));
11
+ const config_1 = require("../../../config");
11
12
  const json_1 = require("../../../util/json");
13
+ const schema_1 = require("../../../util/schema");
12
14
  function configReplCompleter(partialLine, _startingNewArg, config) {
13
15
  if (partialLine.length === 0) {
14
- // update specific fields
15
- return { completions: ['+'] };
16
+ // `+` updates a field, `?` inspects (reads) one
17
+ return { completions: ['+', '?'] };
16
18
  }
17
- else if (partialLine.length === 1 && partialLine[0].startsWith('+')) {
18
- const path = partialLine[0].slice(1).split('.').filter(p => p.length > 0);
19
+ else if (partialLine.length === 1 && (partialLine[0].startsWith('+') || partialLine[0].startsWith('?'))) {
20
+ const inspect = partialLine[0].startsWith('?'); // a read: complete the key path, but never append `=`
21
+ const raw = partialLine[0].slice(1);
22
+ // once a value is being assigned (`key=...`), the path is fixed: complete the value (its type), not more keys
23
+ if (raw.includes('=')) {
24
+ if (inspect) {
25
+ return { completions: [] }; // `?` reads a value, it never assigns one
26
+ }
27
+ const eq = raw.indexOf('=');
28
+ const keyPath = raw.slice(0, eq).split('.').filter(p => p.length > 0);
29
+ const valuePart = raw.slice(eq + 1);
30
+ const prefix = `${partialLine[0].slice(0, 1)}${raw.slice(0, eq)}=`;
31
+ const values = configValueHints(configSchemaInfo(keyPath)).filter(v => v.startsWith(valuePart) && v !== valuePart);
32
+ return { completions: values.map(v => prefix + v) };
33
+ }
34
+ const path = raw.split('.').filter(p => p.length > 0);
19
35
  const fullPath = path.slice();
20
36
  const lastPath = partialLine[0].endsWith('.') ? '' : path.pop() ?? '';
21
- if (lastPath.endsWith('=')) {
22
- return { completions: [] };
23
- }
24
37
  const subConfig = path.reduce((obj, key) => (obj && obj[key] !== undefined && typeof obj[key] === 'object') ? obj[key] : obj, config);
25
38
  if (subConfig && !(subConfig[lastPath] !== undefined && typeof subConfig[lastPath] !== 'object')) {
26
39
  const have = Object.keys(subConfig)
@@ -33,11 +46,28 @@ function configReplCompleter(partialLine, _startingNewArg, config) {
33
46
  return { completions: [`${partialLine[0].slice(0, 1)}${fullPath.join('.')}.`] };
34
47
  }
35
48
  }
36
- return { completions: [`${partialLine[0].slice(0, 1)}${fullPath.join('.')}=`] };
49
+ const leaf = `${partialLine[0].slice(0, 1)}${fullPath.join('.')}`;
50
+ if (!inspect) {
51
+ const values = configValueHints(configSchemaInfo(fullPath)); // a boolean/enum offers its values, others a `<type>` hint
52
+ if (values.length > 0) {
53
+ return { completions: values.map(v => `${leaf}=${v}`) };
54
+ }
55
+ }
56
+ return { completions: [`${leaf}${inspect ? '' : '='}`] };
37
57
  }
38
58
  return { completions: [] };
39
59
  }
40
60
  function configQueryLineParser(output, line, _config) {
61
+ if (line.length > 0 && line[0].startsWith('?')) {
62
+ // inspect a single key, e.g. `?solver.sigdb.enabled`
63
+ const path = line[0].slice(1).split('.').filter(p => p.length > 0);
64
+ if (path.length === 0) {
65
+ output.stdout(`Invalid config inspect syntax, must be of the form ${(0, ansi_1.bold)('?path.to.field', output.formatter)}`);
66
+ }
67
+ else {
68
+ return { query: [{ type: 'config', inspect: path }] };
69
+ }
70
+ }
41
71
  if (line.length > 0 && line[0].startsWith('+')) {
42
72
  const [pathPart, ...valueParts] = line[0].slice(1).split('=');
43
73
  // build the update object
@@ -100,12 +130,29 @@ function getValueAtPath(obj, path) {
100
130
  }
101
131
  return current;
102
132
  }
133
+ let configSchemaDescription;
134
+ /** the Joi-schema type + description of a config path (from {@link FlowrConfig.Schema}), used to document a `?key` inspection */
135
+ function configSchemaInfo(path) {
136
+ configSchemaDescription ??= config_1.FlowrConfig.Schema.describe();
137
+ return (0, schema_1.descriptionPathInfo)(configSchemaDescription, path);
138
+ }
139
+ /** value completions for a config leaf: both booleans, an enum's members, or a compact `<type>` hint */
140
+ function configValueHints(info) {
141
+ if (info.type === 'boolean') {
142
+ return ['true', 'false'];
143
+ }
144
+ if (info.valids && info.valids.length > 0) {
145
+ return info.valids.map(v => JSON.stringify(v));
146
+ }
147
+ return info.type ? [`<${info.type}>`] : [];
148
+ }
103
149
  exports.ConfigQueryDefinition = {
104
150
  executor: config_query_executor_1.executeConfigQuery,
105
151
  asciiSummarizer: (formatter, _analyzer, queryResults, result, queries) => {
106
152
  const out = queryResults;
107
153
  result.push(`Query: ${(0, ansi_1.bold)('config', formatter)} (${(0, time_1.printAsMs)(out['.meta'].timing, 0)})`);
108
154
  const configQueries = queries.filter(q => q.type === 'config');
155
+ const inspects = configQueries.filter(q => q.inspect).map(q => q.inspect);
109
156
  if (configQueries.some(q => q.update)) {
110
157
  const updatedKeys = configQueries.flatMap(q => q.update ? collectKeysFromUpdate(q.update) : []);
111
158
  result.push(' ╰ Updated configuration:');
@@ -115,6 +162,17 @@ exports.ConfigQueryDefinition = {
115
162
  result.push(` - ${key}: ${JSON.stringify(newValue, json_1.jsonReplacer)}`);
116
163
  }
117
164
  }
165
+ else if (inspects.length > 0) {
166
+ result.push(' ╰ Config:');
167
+ for (const path of inspects) {
168
+ const info = configSchemaInfo(path);
169
+ const value = JSON.stringify(getValueAtPath(out.config, [...path]), json_1.jsonReplacer);
170
+ result.push(` - ${path.join('.')}${info.type ? ` ${(0, ansi_1.italic)(`(${info.type})`, formatter)}` : ''}: ${value}`);
171
+ if (info.description) {
172
+ result.push(` ${(0, ansi_1.italic)(info.description, formatter)}`);
173
+ }
174
+ }
175
+ }
118
176
  else {
119
177
  result.push(` ╰ Config:\n${JSON.stringify(out.config, json_1.jsonReplacer, 4)}`);
120
178
  }
@@ -124,7 +182,8 @@ exports.ConfigQueryDefinition = {
124
182
  fromLine: configQueryLineParser,
125
183
  schema: joi_1.default.object({
126
184
  type: joi_1.default.string().valid('config').required().description('The type of the query.'),
127
- update: joi_1.default.object().optional().description('An optional partial configuration to update the current configuration with before returning it. Only the provided fields will be updated, all other fields will remain unchanged.')
185
+ update: joi_1.default.object().optional().description('An optional partial configuration to update the current configuration with before returning it. Only the provided fields will be updated, all other fields will remain unchanged.'),
186
+ inspect: joi_1.default.array().items(joi_1.default.string()).optional().description('An optional `.`-separated path (as a string array) to read a single configuration value instead of returning the whole configuration.')
128
187
  }).description('The config query retrieves the current configuration of the flowR instance and optionally also updates it.'),
129
188
  flattenInvolvedNodes: () => []
130
189
  };
@@ -9,12 +9,22 @@ const ansi_1 = require("../../../util/text/ansi");
9
9
  const time_1 = require("../../../util/text/time");
10
10
  const joi_1 = __importDefault(require("joi"));
11
11
  const df_helper_1 = require("../../../dataflow/graph/df-helper");
12
+ /** Above this many characters, the mermaid.live link is dropped from the REPL output (large graphs produce megabyte-sized base64 urls). */
13
+ const MaxMermaidUrlLength = 8000;
12
14
  exports.DataflowQueryDefinition = {
13
15
  executor: dataflow_query_executor_1.executeDataflowQuery,
14
16
  asciiSummarizer: (formatter, _analyzer, queryResults, result) => {
15
17
  const out = queryResults;
16
18
  result.push(`Query: ${(0, ansi_1.bold)('dataflow', formatter)} (${(0, time_1.printAsMs)(out['.meta'].timing, 0)})`);
17
- result.push(` ╰ [Dataflow Graph](${df_helper_1.Dataflow.visualize.mermaid.url(out.graph)})`);
19
+ const url = df_helper_1.Dataflow.visualize.mermaid.url(out.graph);
20
+ if (url.length <= MaxMermaidUrlLength) {
21
+ result.push(` ╰ [Dataflow Graph](${url})`);
22
+ }
23
+ else {
24
+ const vertices = Array.from(out.graph.vertices(true)).length;
25
+ const edges = Array.from(out.graph.edges()).length;
26
+ result.push(` ╰ Dataflow Graph too large to link (${vertices} vertices, ${edges} edges, url would be ${url.length} chars); use ':df#' for more detail.`);
27
+ }
18
28
  return true;
19
29
  },
20
30
  schema: joi_1.default.object({
@@ -51,7 +51,7 @@ async function executeDependenciesQuery({ analyzer, }, queries) {
51
51
  functions.set(category, getFunctionsToCheck(undefined, category, undefined, false, value.functions));
52
52
  }
53
53
  }
54
- const queryResults = functions.values().toArray().flat().length === 0 ? { kinds: {}, '.meta': { timing: 0 } } :
54
+ const queryResults = !functions.values().toArray().some(f => f.length > 0) ? { kinds: {}, '.meta': { timing: 0 } } :
55
55
  await (0, query_1.executeQueriesOfSameType)(data, functions.entries().flatMap(makeCallContextQuery).toArray());
56
56
  const g = (0, dependencies_query_format_1.getAllCategories)(queries);
57
57
  const enabled = query.enabledCategories;
@@ -2,6 +2,8 @@ import type { BasicQueryData } from '../../base-query-format';
2
2
  import type { LinterQuery, LinterQueryResult } from './linter-query-format';
3
3
  /**
4
4
  * Executes the given linter queries using the provided analyzer.
5
+ * A query without an explicit rule list runs only the rules that are active by default.
5
6
  * @see {@link executeLintingRule}
7
+ * @see {@link LinterRuleInformation#activeByDefault} - opts a rule out of the default rule set
6
8
  */
7
9
  export declare function executeLinterQuery({ analyzer }: BasicQueryData, queries: readonly LinterQuery[]): Promise<LinterQueryResult>;
@@ -7,10 +7,15 @@ const linter_executor_1 = require("../../../linter/linter-executor");
7
7
  const gas_1 = require("../../../gas");
8
8
  /**
9
9
  * Executes the given linter queries using the provided analyzer.
10
+ * A query without an explicit rule list runs only the rules that are active by default.
10
11
  * @see {@link executeLintingRule}
12
+ * @see {@link LinterRuleInformation#activeByDefault} - opts a rule out of the default rule set
11
13
  */
12
14
  async function executeLinterQuery({ analyzer }, queries) {
13
- const flattened = queries.flatMap(q => q.rules ?? Object.keys(linter_rules_1.LintingRules));
15
+ // no explicit rules: run only the rules that opt in via activeByDefault (default true)
16
+ const defaultRules = Object.keys(linter_rules_1.LintingRules)
17
+ .filter((name) => linter_rules_1.LintingRules[name].info.activeByDefault !== false);
18
+ const flattened = queries.flatMap(q => q.rules ?? defaultRules);
14
19
  const distinct = new Set(flattened);
15
20
  if (distinct.size !== flattened.length) {
16
21
  const pretty = [...distinct].filter(r => flattened.indexOf(r) !== flattened.lastIndexOf(r)).map(r => typeof r === 'string' ? r : r.name).join(', ');
@@ -4,6 +4,7 @@ import Joi from 'joi';
4
4
  import { executeLinterQuery } from './linter-query-executor';
5
5
  import { type LintingRuleNames } from '../../../linter/linter-rules';
6
6
  import { type ConfiguredLintingRule, LintingResultCertainty, LintingResults } from '../../../linter/linter-format';
7
+ import { type OutputFormatter } from '../../../util/text/ansi';
7
8
  import type { FlowrConfig } from '../../../config';
8
9
  import type { ReplOutput } from '../../../cli/repl/commands/repl-main';
9
10
  import type { CommandCompletions } from '../../../cli/repl/core';
@@ -27,7 +28,7 @@ declare function linterQueryLineParser(output: ReplOutput, line: readonly string
27
28
  declare function linterQueryCompleter(line: readonly string[], startingNewArg: boolean, _config: FlowrConfig): CommandCompletions;
28
29
  export declare const LinterQueryDefinition: {
29
30
  readonly executor: typeof executeLinterQuery;
30
- readonly asciiSummarizer: (formatter: import("../../../util/text/ansi").OutputFormatter, analyzer: import("../../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider<import("../../../r-bridge/parser").KnownParser>, queryResults: BaseQueryResult, result: string[]) => true;
31
+ readonly asciiSummarizer: (formatter: OutputFormatter, analyzer: import("../../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider<import("../../../r-bridge/parser").KnownParser>, queryResults: BaseQueryResult, result: string[]) => true;
31
32
  readonly completer: typeof linterQueryCompleter;
32
33
  readonly fromLine: typeof linterQueryLineParser;
33
34
  readonly schema: Joi.ObjectSchema<any>;
@@ -10,7 +10,6 @@ const linter_rules_1 = require("../../../linter/linter-rules");
10
10
  const linter_format_1 = require("../../../linter/linter-format");
11
11
  const ansi_1 = require("../../../util/text/ansi");
12
12
  const time_1 = require("../../../util/text/time");
13
- const doc_code_1 = require("../../../documentation/doc-util/doc-code");
14
13
  const retriever_1 = require("../../../r-bridge/retriever");
15
14
  const assert_1 = require("../../../util/assert");
16
15
  function rulesFromInput(output, rulesPart) {
@@ -101,7 +100,7 @@ exports.LinterQueryDefinition = {
101
100
  return true;
102
101
  }
103
102
  for (const [ruleName, results] of Object.entries(out.results)) {
104
- addLintingRuleResult(ruleName, results, result);
103
+ addLintingRuleResult(ruleName, results, result, formatter);
105
104
  }
106
105
  return true;
107
106
  },
@@ -125,27 +124,60 @@ exports.LinterQueryDefinition = {
125
124
  }).filter(assert_1.isNotUndefined);
126
125
  }
127
126
  };
128
- function addLintingRuleResult(ruleName, results, result) {
127
+ /** cap on findings shown per certainty before collapsing to a `+N more` line; the full set is in `:query*` JSON */
128
+ const MaxFindingsShown = 10;
129
+ function addLintingRuleResult(ruleName, results, result, formatter) {
129
130
  const rule = linter_rules_1.LintingRules[ruleName];
130
- result.push(` ╰ **${rule.info.name}** (${ruleName}):`);
131
+ const header = `${(0, ansi_1.bold)(rule.info.name, formatter)} (${ruleName})`;
131
132
  if (linter_format_1.LintingResults.isError(results)) {
132
133
  const error = linter_format_1.LintingResults.stringifyError(results).includes('At least one request must be set') ? 'No requests to lint for were found in the analysis.' : 'Error during execution of rule: ' + linter_format_1.LintingResults.stringifyError(results);
134
+ result.push(` ╰ ${header}:`);
133
135
  result.push(` ╰ ${error}`);
134
136
  return;
135
137
  }
138
+ // a rule with no findings collapses to a single line (no per-certainty block, no metadata)
139
+ if (results.results.length === 0) {
140
+ result.push(` ╰ ${header}: ${(0, ansi_1.italic)('no findings', formatter)}`);
141
+ return;
142
+ }
143
+ result.push(` ╰ ${header}:`);
136
144
  for (const certainty of [linter_format_1.LintingResultCertainty.Certain, linter_format_1.LintingResultCertainty.Uncertain]) {
137
145
  const certaintyResults = results.results.filter(r => r.certainty === certainty);
138
146
  if (certaintyResults.length) {
139
147
  result.push(` ╰ ${certainty}:`);
140
- for (const res of certaintyResults) {
148
+ for (const res of certaintyResults.slice(0, MaxFindingsShown)) {
141
149
  const pretty = rule.prettyPrint[linter_format_1.LintingPrettyPrintContext.Query](res, results['.meta']);
142
- result.push(` ╰ ${pretty}${res.quickFix ? ` (${res.quickFix.length} quick fix(es) available)` : ''}`);
150
+ result.push(` ╰ ${hyperlinkLocations(pretty, formatter)}${res.quickFix ? ` (${res.quickFix.length} quick fix(es) available)` : ''}`);
151
+ }
152
+ if (certaintyResults.length > MaxFindingsShown) {
153
+ result.push(` ╰ ${(0, ansi_1.italic)(`… +${certaintyResults.length - MaxFindingsShown} more (:query* for the full JSON)`, formatter)}`);
143
154
  }
144
155
  }
145
156
  }
146
- result.push(` ╰ _Metadata_: ${(0, doc_code_1.codeInline)(renderMetaData(results['.meta']))}`);
157
+ result.push(` ╰ ${(0, ansi_1.italic)('Metadata', formatter)}: ${renderMetaData(results['.meta'])}`);
158
+ }
159
+ /**
160
+ * Matches an absolute file path (POSIX `/...` or Windows `X:\...`) with an extension, followed by `:` and a flowR
161
+ * position `<line>(.<col>)?(-<endline>.<endcol>)?`. Used to turn linting finding locations into clickable links.
162
+ */
163
+ const locationPattern = /((?:[A-Za-z]:\\|\/)[^\s:]*\.[A-Za-z]+):(\d+(?:\.\d+)?(?:-\d+(?:\.\d+)?)?)/g;
164
+ /** Wrap every `path:loc` location in the given pretty string in a `file://path:line:col` hyperlink via the formatter. */
165
+ function hyperlinkLocations(pretty, formatter) {
166
+ return pretty.replace(locationPattern, (match, path, position) => {
167
+ const [line, col] = position.split('-')[0].split('.');
168
+ const url = `file://${path}:${line}${col ? `:${col}` : ''}`;
169
+ return formatter.hyperlink(match, url);
170
+ });
147
171
  }
148
172
  function renderMetaData(metadata) {
149
- return Object.entries(metadata).map(r => `${r[0]}: ${JSON.stringify(r[1])}`).join(', ');
173
+ return Object.entries(metadata).map(([k, v]) => `${k}: ${renderMetaValue(v)}`).join(', ');
174
+ }
175
+ /** Render a metadata value; a nested object (e.g. suppression counts) becomes `(key=value, ...)`, omitting zero counts (`0` if all zero). */
176
+ function renderMetaValue(value) {
177
+ if (value !== null && typeof value === 'object' && !Array.isArray(value)) {
178
+ const nonZero = Object.entries(value).filter(([, v]) => v !== 0);
179
+ return nonZero.length === 0 ? '0' : `(${nonZero.map(([k, v]) => `${k}=${renderMetaValue(v)}`).join(', ')})`;
180
+ }
181
+ return JSON.stringify(value);
150
182
  }
151
183
  //# sourceMappingURL=linter-query-format.js.map
@@ -1,5 +1,20 @@
1
1
  import type { ProjectQuery, ProjectQueryResult } from './project-query-format';
2
+ import { ProjectKind } from './project-query-format';
2
3
  import type { BasicQueryData } from '../../base-query-format';
4
+ import type { ReadOnlyFlowrAnalyzerFilesContext } from '../../../project/context/flowr-analyzer-files-context';
5
+ /**
6
+ * Classifies the {@link ProjectKind} of the given files context.
7
+ *
8
+ * A `DESCRIPTION` file unambiguously marks an R {@link ProjectKind.Package | package} and is available as soon
9
+ * as the project is loaded. The finer distinctions ({@link ProjectKind.ShinyApp | shiny app},
10
+ * {@link ProjectKind.Notebook | notebook}, {@link ProjectKind.Script | script} vs.
11
+ * {@link ProjectKind.Project | multi-file project}) rely on the project's source files, which are only known
12
+ * once the dataflow analysis has run; before that a non-package project reports {@link ProjectKind.Unknown}.
13
+ *
14
+ * This is a pure inspection of the files context and can be used standalone, independently of the project query.
15
+ * @param files - the (read-only) files context of an analyzer to classify
16
+ */
17
+ export declare function classifyProject(files: ReadOnlyFlowrAnalyzerFilesContext): ProjectKind;
3
18
  /**
4
19
  * Executes the given project queries.
5
20
  */