@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
@@ -7,6 +7,7 @@ import { type NoInfo, RNode } from '../r-bridge/lang-4.x/ast/model/model';
7
7
  import type { NormalizedAst, ParentInformation } from '../r-bridge/lang-4.x/ast/model/processing/decorate';
8
8
  import type { NodeId } from '../r-bridge/lang-4.x/ast/model/processing/node-id';
9
9
  import type { AnyStateDomain, ValueDomain } from './domains/state-domain-like';
10
+ export type DomainOfVisitor<AbsintVisitor extends AbstractInterpretationVisitor<AnyStateDomain>> = AbsintVisitor extends AbstractInterpretationVisitor<infer StateDomain> ? StateDomain : never;
10
11
  export type AbsintVisitorConfiguration = Omit<SemanticCfgGuidedVisitorConfiguration<NoInfo, ControlFlowInformation, NormalizedAst>, 'defaultVisitingOrder' | 'defaultVisitingType'>;
11
12
  /**
12
13
  * A control flow graph visitor to perform abstract interpretation.
@@ -56,7 +56,13 @@ function filterValidNames(colnames, checkNames, noDupNames, noEmptyNames, collap
56
56
  colnames = colnames?.map(entry => isValidColName(entry) ? entry : undefined);
57
57
  }
58
58
  if (noDupNames) { // map all duplicate column names to top
59
- colnames = colnames?.map((entry, _, list) => entry !== undefined && list.filter(other => other === entry).length === 1 ? entry : undefined);
59
+ const counts = new Map();
60
+ for (const entry of colnames ?? []) {
61
+ if (entry !== undefined) {
62
+ counts.set(entry, (counts.get(entry) ?? 0) + 1);
63
+ }
64
+ }
65
+ colnames = colnames?.map(entry => entry !== undefined && counts.get(entry) === 1 ? entry : undefined);
60
66
  }
61
67
  if (noEmptyNames) { // map all empty column names to top
62
68
  colnames = colnames?.map(entry => entry?.length === 0 ? undefined : entry);
@@ -316,11 +316,11 @@ class SetRangeDomain extends abstract_domain_1.AbstractDomain {
316
316
  return SetRangeDomain.abstract(concrete, this.limit);
317
317
  }
318
318
  satisfies(set, comparator = satisfiable_domain_1.SetComparator.Equal) {
319
- const value = new this.setType(set);
320
319
  const lower = this.lower(), upper = this.upper();
321
320
  if (lower === lattice_1.Bottom || upper === lattice_1.Bottom) {
322
321
  return logic_1.Ternary.Never;
323
322
  }
323
+ const value = new this.setType(set);
324
324
  switch (comparator) {
325
325
  case satisfiable_domain_1.SetComparator.Equal: {
326
326
  if (lower.isSubsetOf(value) && (upper === lattice_1.Top || value.isSubsetOf(upper))) {
@@ -148,16 +148,20 @@ class SetUpperBoundDomain extends abstract_domain_1.AbstractDomain {
148
148
  return SetUpperBoundDomain.abstract(concrete, this.limit, this.setType);
149
149
  }
150
150
  satisfies(set, comparator = satisfiable_domain_1.SetComparator.Equal) {
151
+ if (this.isTop()) {
152
+ return logic_1.Ternary.Maybe;
153
+ }
154
+ const values = [...set];
151
155
  switch (comparator) {
152
156
  case satisfiable_domain_1.SetComparator.Equal:
153
157
  case satisfiable_domain_1.SetComparator.SubsetOrEqual: {
154
- if (this.isTop() || (this.isValue() && [...set].length <= this.value.size && [...set].every(value => this.value.has(value)))) {
158
+ if (this.isValue() && values.length <= this.value.size && values.every(value => this.value.has(value))) {
155
159
  return logic_1.Ternary.Maybe;
156
160
  }
157
161
  return logic_1.Ternary.Never;
158
162
  }
159
163
  case satisfiable_domain_1.SetComparator.Subset: {
160
- if (this.isTop() || (this.isValue() && [...set].length < this.value.size && [...set].every(value => this.value.has(value)))) {
164
+ if (this.isValue() && values.length < this.value.size && values.every(value => this.value.has(value))) {
161
165
  return logic_1.Ternary.Maybe;
162
166
  }
163
167
  return logic_1.Ternary.Never;
@@ -73,7 +73,7 @@ export declare class BenchmarkSlicer {
73
73
  * Initialize the slicer on the given request.
74
74
  * Can only be called once for each instance.
75
75
  */
76
- init(request: RParseRequestFromFile | RParseRequestFromText, config: FlowrConfig, autoSelectIf?: AutoSelectPredicate, threshold?: number): Promise<void>;
76
+ init(request: RParseRequestFromFile | RParseRequestFromText, config: FlowrConfig, autoSelectIf?: AutoSelectPredicate, threshold?: number, inlineSources?: boolean, includeCallees?: boolean): Promise<void>;
77
77
  private calculateStatsAfterInit;
78
78
  /**
79
79
  * Slice for the given {@link SlicingCriteria}.
@@ -62,7 +62,7 @@ class BenchmarkSlicer {
62
62
  * Initialize the slicer on the given request.
63
63
  * Can only be called once for each instance.
64
64
  */
65
- async init(request, config, autoSelectIf, threshold) {
65
+ async init(request, config, autoSelectIf, threshold, inlineSources, includeCallees) {
66
66
  (0, assert_1.guard)(this.stats === undefined, 'cannot initialize the slicer twice');
67
67
  // we know these are in sync so we just cast to one of them
68
68
  this.parser = await this.commonMeasurements.measure('initialize R session', async () => {
@@ -80,6 +80,8 @@ class BenchmarkSlicer {
80
80
  criterion: [],
81
81
  autoSelectIf,
82
82
  threshold,
83
+ inlineSources,
84
+ includeCallees,
83
85
  });
84
86
  this.loadedXml = (await this.measureCommonStep('parse', 'retrieve AST from R code')).files.map(p => p.parsed);
85
87
  this.normalizedAst = await this.measureCommonStep('normalize', 'normalize R AST');
@@ -29,6 +29,11 @@ function writeGraphOutput(ultimate, outputGraphPath) {
29
29
  });
30
30
  }
31
31
  }
32
+ data.push({
33
+ name: 'number of files',
34
+ unit: '#',
35
+ value: ultimate.totalRequests
36
+ });
32
37
  data.push({
33
38
  name: 'failed to reconstruct/re-parse',
34
39
  unit: '#',
@@ -277,6 +277,14 @@ export declare const slicerOptions: [{
277
277
  readonly alias: "m";
278
278
  readonly type: BooleanConstructor;
279
279
  readonly description: "Disable the effects of magic comments which force lines to be included.";
280
+ }, {
281
+ readonly name: "inline";
282
+ readonly type: BooleanConstructor;
283
+ readonly description: "Inline resolvable {italic source()} calls into the reconstruction so the slice is a single self-contained R text.";
284
+ }, {
285
+ readonly name: "include-callees";
286
+ readonly type: BooleanConstructor;
287
+ readonly description: "If slicing backward, continue past a function-definition boundary, also including the definition's binding and call sites.";
280
288
  }, {
281
289
  readonly name: "api";
282
290
  readonly type: BooleanConstructor;
@@ -63,6 +63,8 @@ exports.slicerOptions = [
63
63
  { name: 'stats', alias: 's', type: Boolean, description: 'Print stats and write them to {italic <output>.stats} (runtimes etc.)', multiple: false },
64
64
  { name: 'output', alias: 'o', type: String, description: 'File to write all the generated quads to (defaults to the commandline)', typeLabel: '{underline file}' },
65
65
  { name: 'no-magic-comments', alias: 'm', type: Boolean, description: 'Disable the effects of magic comments which force lines to be included.' },
66
+ { name: 'inline', type: Boolean, description: 'Inline resolvable {italic source()} calls into the reconstruction so the slice is a single self-contained R text.' },
67
+ { name: 'include-callees', type: Boolean, description: 'If slicing backward, continue past a function-definition boundary, also including the definition\'s binding and call sites.' },
66
68
  { name: 'api', type: Boolean, description: 'Instead of human-readable output, dump a lot of json with the results of all intermediate steps.' },
67
69
  ];
68
70
  exports.summarizerOptions = [
@@ -83,6 +83,14 @@ declare const _scripts: {
83
83
  readonly alias: "m";
84
84
  readonly type: BooleanConstructor;
85
85
  readonly description: "Disable the effects of magic comments which force lines to be included.";
86
+ }, {
87
+ readonly name: "inline";
88
+ readonly type: BooleanConstructor;
89
+ readonly description: "Inline resolvable {italic source()} calls into the reconstruction so the slice is a single self-contained R text.";
90
+ }, {
91
+ readonly name: "include-callees";
92
+ readonly type: BooleanConstructor;
93
+ readonly description: "If slicing backward, continue past a function-definition boundary, also including the definition's binding and call sites.";
86
94
  }, {
87
95
  readonly name: "api";
88
96
  readonly type: BooleanConstructor;
@@ -25,6 +25,7 @@ declare const _commands: {
25
25
  readonly 'controlflowbb*': ReplCodeCommand;
26
26
  readonly query: ReplCodeCommand;
27
27
  readonly 'query*': ReplCodeCommand;
28
+ readonly signature: ReplCodeCommand;
28
29
  };
29
30
  export type ReplCommandNames = keyof typeof _commands | keyof typeof scripts;
30
31
  /**
@@ -21,29 +21,76 @@ const args_1 = require("../../../util/text/args");
21
21
  const assert_1 = require("../../../util/assert");
22
22
  const scripts_info_1 = require("../../common/scripts-info");
23
23
  const repl_query_1 = require("./repl-query");
24
+ const repl_signature_1 = require("./repl-signature");
25
+ const version_1 = require("../../../util/version");
24
26
  const cmd = (name, f) => (0, ansi_1.color)(name, 6 /* Colors.Cyan */, f, { style: 1 /* FontStyles.Bold */ });
27
+ const ansiSgr = new RegExp(String.fromCharCode(27) + '\\[[0-9;]*m', 'g');
28
+ const visibleLength = (s) => s.replace(ansiSgr, '').length;
29
+ /** Appends `content` after `prefix`, word-wrapping to the terminal width with a hanging indent. */
30
+ function wrapAfter(prefix, content) {
31
+ const width = process.stdout.isTTY ? (process.stdout.columns ?? 80) : Infinity;
32
+ const indent = visibleLength(prefix);
33
+ const pad = ' '.repeat(indent);
34
+ const lines = [];
35
+ let line = '';
36
+ let lineLength = indent;
37
+ for (const word of content.split(' ')) {
38
+ const wordLength = visibleLength(word);
39
+ if (line !== '' && lineLength + 1 + wordLength > width) {
40
+ lines.push(line);
41
+ line = word;
42
+ lineLength = indent + wordLength;
43
+ }
44
+ else {
45
+ line = line === '' ? word : `${line} ${word}`;
46
+ lineLength = line === word ? indent + wordLength : lineLength + 1 + wordLength;
47
+ }
48
+ }
49
+ if (line !== '') {
50
+ lines.push(line);
51
+ }
52
+ return prefix + lines.map((l, i) => i === 0 ? l : pad + l).join('\n');
53
+ }
25
54
  function printHelpForScript(script, f, starredVersion) {
26
- let base = ` ${cmd(padCmd(':' + script[0] + (starredVersion ? '[*]' : '')), f)}${script[1].description}`;
55
+ let content = script[1].description;
27
56
  if (starredVersion) {
28
- base += ` ${(0, ansi_1.italic)(`(star: ${starredVersion.description})`, f)}`;
29
- }
30
- if (script[1].aliases.length === 0) {
31
- return base;
57
+ content += ` ${(0, ansi_1.italic)(`(star: ${starredVersion.description})`, f)}`;
32
58
  }
33
59
  const aliases = script[1].aliases;
34
- return `${base} ${(0, ansi_1.italic)(`(alias${aliases.length > 1 ? 'es' : ''}:`, f)} ${aliases.map(a => cmd(':' + a, f)).join(', ')}${(0, ansi_1.italic)(')', f)}`;
60
+ if (aliases.length > 0) {
61
+ content += ` ${(0, ansi_1.italic)(`(alias${aliases.length > 1 ? 'es' : ''}:`, f)} ${aliases.map(a => cmd(':' + a, f)).join(', ')}${(0, ansi_1.italic)(')', f)}`;
62
+ }
63
+ return wrapAfter(` ${cmd(padCmd(':' + script[0] + (starredVersion ? '[*]' : '')), f)}`, content);
64
+ }
65
+ function printFamilyVariants(children, cmds, f) {
66
+ const variant = (name) => {
67
+ const aliases = cmds[name].aliases;
68
+ const suffix = aliases.length > 0 ? ' ' + (0, ansi_1.italic)(`(${aliases.map(a => ':' + a).join(', ')})`, f) : '';
69
+ return cmd(':' + name + (cmds[name + '*'] ? '[*]' : ''), f) + suffix;
70
+ };
71
+ return wrapAfter(` ${(0, ansi_1.italic)('variants:', f)} `, children.map(variant).join(', '));
35
72
  }
36
73
  function printCommandHelp(formatter) {
37
- const scriptHelp = [];
38
74
  const cmds = getReplCommands();
39
- for (const c of Object.entries(cmds)) {
40
- if (c[1].script || c[0].endsWith('*')) {
41
- continue;
75
+ const bases = Object.entries(cmds).filter(([name, c]) => !c.script && !name.endsWith('*'));
76
+ const names = bases.map(([name]) => name);
77
+ const shortestPrefixCommand = (name) => names.filter(n => name.startsWith(n)).reduce((a, b) => a.length <= b.length ? a : b);
78
+ const children = new Map();
79
+ for (const name of names) {
80
+ const root = shortestPrefixCommand(name);
81
+ if (root !== name) {
82
+ children.set(root, [...children.get(root) ?? [], name]);
42
83
  }
43
- const starred = cmds[c[0] + '*'];
44
- scriptHelp.push(printHelpForScript(c, formatter, starred));
45
84
  }
46
- return scriptHelp.sort().join('\n');
85
+ const lines = [];
86
+ for (const entry of bases.filter(([name]) => shortestPrefixCommand(name) === name).sort((a, b) => a[0].localeCompare(b[0]))) {
87
+ lines.push(printHelpForScript(entry, formatter, cmds[entry[0] + '*']));
88
+ const variants = children.get(entry[0]);
89
+ if (variants) {
90
+ lines.push(printFamilyVariants(variants.sort(), cmds, formatter));
91
+ }
92
+ }
93
+ return lines.join('\n');
47
94
  }
48
95
  exports.helpCommand = {
49
96
  description: 'Show help information',
@@ -63,7 +110,7 @@ There are the following basic commands:
63
110
  ${printCommandHelp(output.formatter)}
64
111
 
65
112
  Furthermore, you can directly call the following scripts which accept arguments. If you are unsure, try to add ${(0, ansi_1.italic)('--help', output.formatter)} after the command.
66
- ${Array.from(Object.entries(getReplCommands())).filter(([, { script }]) => script).map(([command, { description }]) => ` ${cmd(padCmd(':' + command), output.formatter)}${description}`).sort().join('\n')}
113
+ ${Array.from(Object.entries(getReplCommands())).filter(([, { script }]) => script).map(([command, { description }]) => wrapAfter(` ${cmd(padCmd(':' + command), output.formatter)}`, description)).sort().join('\n')}
67
114
 
68
115
  You can combine commands by separating them with a semicolon ${(0, ansi_1.bold)(';', output.formatter)}.
69
116
 
@@ -71,6 +118,9 @@ Commands that accept a file path support two path prefixes:
71
118
  ${(0, ansi_1.color)('file://<path>', 2 /* Colors.Green */, output.formatter, { style: 1 /* FontStyles.Bold */ })} run the command once on the given file or folder
72
119
  ${(0, ansi_1.color)('watch://<path>', 3 /* Colors.Yellow */, output.formatter, { style: 1 /* FontStyles.Bold */ })} re-run the command whenever the file (or any file in the folder) changes
73
120
  Press Ctrl+C or enter any other command to leave watch mode.
121
+
122
+ You are running flowR ${(0, ansi_1.bold)('v' + (0, version_1.flowrVersion)().toString(), output.formatter)} (use ${(0, ansi_1.bold)(':version', output.formatter)} for details). Check for newer releases and per-install upgrade steps (Docker, npm, source) at:
123
+ ${(0, ansi_1.color)('https://github.com/flowr-analysis/flowr/releases', 6 /* Colors.Cyan */, output.formatter, { style: 1 /* FontStyles.Bold */ })}
74
124
  `);
75
125
  }
76
126
  };
@@ -97,7 +147,8 @@ const _commands = {
97
147
  'controlflowbb': repl_cfg_1.controlflowBbCommand,
98
148
  'controlflowbb*': repl_cfg_1.controlflowBbStarCommand,
99
149
  'query': repl_query_1.queryCommand,
100
- 'query*': repl_query_1.queryStarCommand
150
+ 'query*': repl_query_1.queryStarCommand,
151
+ 'signature': repl_signature_1.signatureCommand
101
152
  };
102
153
  let commandsInitialized = false;
103
154
  function hasModule(path) {
@@ -39,9 +39,46 @@ const core_1 = require("../core");
39
39
  const vertex_1 = require("../../../dataflow/graph/vertex");
40
40
  const dfg_ascii_1 = require("../../../util/simple-df/dfg-ascii");
41
41
  const df_helper_1 = require("../../../dataflow/graph/df-helper");
42
+ const config_1 = require("../../../config");
43
+ const identifier_1 = require("../../../dataflow/environments/identifier");
44
+ const range_1 = require("../../../util/range");
42
45
  function formatInfo(out, type, meta) {
43
46
  return out.formatter.format(`Copied ${type} to clipboard (dataflow: ${meta['.meta'].timing + 'ms'}).`, { color: 7 /* Colors.White */, effect: ansi_1.ColorEffect.Foreground, style: 3 /* FontStyles.Italic */ });
44
47
  }
48
+ function formatReference(output, ref, idMap) {
49
+ const id = output.formatter.format(`$${ref.nodeId}`, { color: 6 /* Colors.Cyan */, effect: ansi_1.ColorEffect.Foreground });
50
+ const name = ref.name === undefined ? '<anonymous>' : identifier_1.Identifier.toString(ref.name);
51
+ const node = idMap.get(ref.nodeId);
52
+ const sl = range_1.SourceLocation.fromNode(node);
53
+ const loc = sl ? ` [${range_1.SourceLocation.format(sl)}]` : '';
54
+ const detail = node ? ` "${node.lexeme ?? name}"${loc}` : '';
55
+ return `${id} ${name} (${identifier_1.ReferenceType[ref.type]})${detail}`;
56
+ }
57
+ /** Formats a single {@link KillReference}, which unlike a plain reference may kill the whole (or an unknown part of the) scope */
58
+ function formatKill(output, kill, idMap) {
59
+ switch (kill.kind) {
60
+ case 'named': return formatReference(output, kill.reference, idMap);
61
+ case 'all': return 'kills entire scope';
62
+ case 'unknown': return 'kills unknown, not statically resolvable references';
63
+ }
64
+ }
65
+ /**
66
+ * Prints the reference sets, listing each non-empty one and collapsing all empty ones into a single trailing
67
+ * line, as a screen full of `(0):` headers says nothing.
68
+ */
69
+ function printReferenceSections(output, sections) {
70
+ const count = (n) => output.formatter.format(String(n), { color: 6 /* Colors.Cyan */, effect: ansi_1.ColorEffect.Foreground });
71
+ for (const { title, lines } of sections.filter(s => s.lines.length > 0)) {
72
+ output.stdout(`${title} (${count(lines.length)}):`);
73
+ for (const line of lines) {
74
+ output.stdout(' - ' + line);
75
+ }
76
+ }
77
+ const empty = sections.filter(s => s.lines.length === 0);
78
+ if (empty.length > 0) {
79
+ output.stdout(output.formatter.format('Empty: ', { style: 3 /* FontStyles.Italic */ }) + `${empty.map(s => `${s.title} (${count(0)})`).join(', ')}`);
80
+ }
81
+ }
45
82
  exports.dataflowCommand = {
46
83
  description: 'Get mermaid code for the dataflow graph',
47
84
  isCodeCommand: true,
@@ -51,7 +88,7 @@ exports.dataflowCommand = {
51
88
  argsParser: (args) => (0, core_1.handleString)(args),
52
89
  fn: async ({ output, analyzer }) => {
53
90
  const result = await analyzer.dataflow();
54
- const mermaid = df_helper_1.Dataflow.visualize.mermaid.convert({ graph: result.graph, includeEnvironments: false }).string;
91
+ const mermaid = df_helper_1.Dataflow.visualize.mermaid.convert({ graph: result.graph, includeEnvironments: false, qualifyBaseR: (0, config_1.isSigDbEnabled)(analyzer.flowrConfig) }).string;
55
92
  output.stdout(mermaid);
56
93
  if (output.allowClipboard !== false) {
57
94
  try {
@@ -73,7 +110,7 @@ exports.dataflowStarCommand = {
73
110
  argsParser: (args) => (0, core_1.handleString)(args),
74
111
  fn: async ({ output, analyzer }) => {
75
112
  const result = await analyzer.dataflow();
76
- const mermaid = df_helper_1.Dataflow.visualize.mermaid.url(result.graph, false);
113
+ const mermaid = df_helper_1.Dataflow.visualize.mermaid.url(result.graph, false, undefined, false, (0, config_1.isSigDbEnabled)(analyzer.flowrConfig));
77
114
  output.stdout(mermaid);
78
115
  if (output.allowClipboard !== false) {
79
116
  try {
@@ -118,6 +155,13 @@ exports.dataflowSilentCommand = {
118
155
  const longVertexName = Object.entries(vertex_1.VertexType).find(([, v]) => v === vertType)?.[0] ?? vertType;
119
156
  output.stdout(` - ${(longVertexName + ':').padEnd(longestVertexType + 1)} ` + output.formatter.format(`${String(vertsOfType.length).padStart(8)}`, { color: 6 /* Colors.Cyan */, effect: ansi_1.ColorEffect.Foreground }).padStart(9, ' '));
120
157
  }
158
+ const { idMap } = await analyzer.normalize();
159
+ printReferenceSections(output, [
160
+ { title: 'In', lines: result.in.map(r => formatReference(output, r, idMap)) },
161
+ { title: 'Out', lines: result.out.map(r => formatReference(output, r, idMap)) },
162
+ { title: 'Unknown References', lines: result.unknownReferences.map(r => formatReference(output, r, idMap)) },
163
+ { title: 'Kill', lines: (result.kill ?? []).map(k => formatKill(output, k, idMap)) }
164
+ ]);
121
165
  }
122
166
  };
123
167
  exports.dataflowSimplifiedCommand = {
@@ -129,7 +173,7 @@ exports.dataflowSimplifiedCommand = {
129
173
  argsParser: (args) => (0, core_1.handleString)(args),
130
174
  fn: async ({ output, analyzer }) => {
131
175
  const result = await analyzer.dataflow();
132
- const mermaid = df_helper_1.Dataflow.visualize.mermaid.convert({ graph: result.graph, includeEnvironments: false, simplified: true }).string;
176
+ const mermaid = df_helper_1.Dataflow.visualize.mermaid.convert({ graph: result.graph, includeEnvironments: false, simplified: true, qualifyBaseR: (0, config_1.isSigDbEnabled)(analyzer.flowrConfig) }).string;
133
177
  output.stdout(mermaid);
134
178
  if (output.allowClipboard !== false) {
135
179
  try {
@@ -150,7 +194,7 @@ exports.dataflowSimpleStarCommand = {
150
194
  argsParser: (args) => (0, core_1.handleString)(args),
151
195
  fn: async ({ output, analyzer }) => {
152
196
  const result = await analyzer.dataflow();
153
- const mermaid = df_helper_1.Dataflow.visualize.mermaid.url(result.graph, false, undefined, true);
197
+ const mermaid = df_helper_1.Dataflow.visualize.mermaid.url(result.graph, false, undefined, true, (0, config_1.isSigDbEnabled)(analyzer.flowrConfig));
154
198
  output.stdout(mermaid);
155
199
  if (output.allowClipboard !== false) {
156
200
  try {
@@ -55,6 +55,8 @@ export interface ReplBaseCommand {
55
55
  /** Example of how to use the command, for example `:slicer --help` */
56
56
  usageExample: string;
57
57
  }
58
+ /** Prints the given command's usage example; the reusable way for any command to show how it should be invoked. */
59
+ export declare function printUsage(output: ReplOutput, command: ReplBaseCommand): void;
58
60
  export interface ReplCommand extends ReplBaseCommand {
59
61
  isCodeCommand: false;
60
62
  /**
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.standardReplOutput = void 0;
4
+ exports.printUsage = printUsage;
4
5
  const ansi_1 = require("../../../util/text/ansi");
5
6
  /**
6
7
  * Default repl output that redirects everything to the stdout and stderror channels (linked to `console`).
@@ -11,4 +12,8 @@ exports.standardReplOutput = {
11
12
  stdout: console.log,
12
13
  stderr: console.error
13
14
  };
15
+ /** Prints the given command's usage example; the reusable way for any command to show how it should be invoked. */
16
+ function printUsage(output, command) {
17
+ output.stderr(`Usage: ${(0, ansi_1.italic)(command.usageExample, output.formatter)}`);
18
+ }
14
19
  //# sourceMappingURL=repl-main.js.map
@@ -1,3 +1,6 @@
1
- import type { ReplCodeCommand } from './repl-main';
1
+ import type { ReplCodeCommand, ReplOutput } from './repl-main';
2
+ import { type Query } from '../../../queries/query';
3
+ /** Validates each query against its own type's schema and, on failure, prints a template for that type. */
4
+ export declare function validateQueries(output: ReplOutput, queries: readonly Query[]): boolean;
2
5
  export declare const queryCommand: ReplCodeCommand;
3
6
  export declare const queryStarCommand: ReplCodeCommand;
@@ -1,12 +1,40 @@
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.queryStarCommand = exports.queryCommand = void 0;
7
+ exports.validateQueries = validateQueries;
4
8
  const ansi_1 = require("../../../util/text/ansi");
5
9
  const query_1 = require("../../../queries/query");
10
+ const virtual_queries_1 = require("../../../queries/virtual-query/virtual-queries");
6
11
  const query_print_1 = require("../../../queries/query-print");
7
12
  const json_1 = require("../../../util/json");
8
13
  const args_1 = require("../../../util/text/args");
9
14
  const record_1 = require("../../../util/record");
15
+ const retriever_1 = require("../../../r-bridge/retriever");
16
+ const core_1 = require("../core");
17
+ const fs_1 = __importDefault(require("fs"));
18
+ /** Whether `s` looks like a filesystem path the user likely meant to load via {@link fileProtocol}. */
19
+ function looksLikePath(s) {
20
+ if (s.startsWith(retriever_1.fileProtocol) || s.startsWith(core_1.watchProtocol)) {
21
+ return false;
22
+ }
23
+ if (/^(~|\.{0,2}\/|[a-zA-Z]:[\\/])/.test(s)) {
24
+ return true;
25
+ }
26
+ // a single path-like token (a separator, no R-code punctuation) that actually exists on disk
27
+ return /^[^\s()]+\/[^\s()]+$/.test(s) && fs_1.default.existsSync(s);
28
+ }
29
+ /**
30
+ * Whether the analyzer already holds exactly `input` as its sole request, so a prior analysis (e.g. a
31
+ * dataflow computed via `:df#`) can be reused instead of being discarded by a reset.
32
+ */
33
+ function analyzerHasTarget(analyzer, input) {
34
+ const requested = (0, retriever_1.requestFromInput)(input);
35
+ const current = analyzer.inspectContext().files.loadingOrder.getUnorderedRequests();
36
+ return current.length === 1 && current[0].request === requested.request && current[0].content === requested.content;
37
+ }
10
38
  function printHelp(output) {
11
39
  output.stderr(`Format: ${(0, ansi_1.italic)(':query <query> <code>', output.formatter)}`);
12
40
  output.stdout('Queries starting with \'@<type>\' are interpreted as a query of the given type.');
@@ -16,6 +44,40 @@ function printHelp(output) {
16
44
  output.stdout((0, ansi_1.ansiInfo)('The example') + (0, ansi_1.italic)(String.raw `:query "[{\"type\": \"call-context\", \"callName\": \"mean\" }]" mean(1:10)`, output.formatter, { color: 7 /* Colors.White */, effect: ansi_1.ColorEffect.Foreground }) + (0, ansi_1.ansiInfo)('would return the call context of the mean function.'));
17
45
  output.stdout('Please have a look at the wiki for more info: https://github.com/flowr-analysis/flowr/wiki/Query-API');
18
46
  }
47
+ /** A copy-pasteable JSON template for a query type: its `type` plus each required field as a placeholder. */
48
+ function queryTemplate(type, schema) {
49
+ const keys = schema.describe().keys ?? {};
50
+ const fields = [`\\"type\\": \\"${type}\\"`];
51
+ for (const [key, value] of Object.entries(keys)) {
52
+ if (key !== 'type' && value.flags?.presence === 'required') {
53
+ fields.push(`\\"${key}\\": <${key}>`);
54
+ }
55
+ }
56
+ return `:query "[{ ${fields.join(', ')} }]" <code | file://path>`;
57
+ }
58
+ /** Validates each query against its own type's schema and, on failure, prints a template for that type. */
59
+ function validateQueries(output, queries) {
60
+ for (const q of queries) {
61
+ const type = q?.type;
62
+ if (typeof type !== 'string' || (!Object.hasOwn(query_1.SupportedQueries, type) && !Object.hasOwn(virtual_queries_1.SupportedVirtualQueries, type))) {
63
+ output.stderr(`Unknown query type ${(0, ansi_1.italic)(JSON.stringify(type), output.formatter)}, use ${(0, ansi_1.bold)(':query help', output.formatter)} for the list of queries.`);
64
+ return false;
65
+ }
66
+ const def = Object.hasOwn(query_1.SupportedQueries, type) ? query_1.SupportedQueries[type] : undefined;
67
+ const { error } = (def?.schema ?? (0, query_1.VirtualQuerySchema)()).validate(q);
68
+ if (error) {
69
+ output.stderr(`Invalid ${(0, ansi_1.bold)('@' + type, output.formatter)} query:`);
70
+ for (const detail of error.details) {
71
+ output.stderr(` - ${detail.message}`);
72
+ }
73
+ if (def) {
74
+ output.stderr(` Template: ${(0, ansi_1.italic)(queryTemplate(type, def.schema), output.formatter)}`);
75
+ }
76
+ return false;
77
+ }
78
+ }
79
+ return true;
80
+ }
19
81
  async function processQueryArgs(output, analyzer, remainingArgs) {
20
82
  const query = remainingArgs.shift();
21
83
  if (!query) {
@@ -41,31 +103,13 @@ async function processQueryArgs(output, analyzer, remainingArgs) {
41
103
  parsedQuery = [{ type: query.slice(1) }];
42
104
  input = remainingArgs.join(' ').trim();
43
105
  }
44
- const validationResult = (0, query_1.QueriesSchema)().validate(parsedQuery);
45
- if (validationResult.error) {
46
- output.stderr(`Invalid query: "${output.formatter.format(JSON.stringify(parsedQuery), { style: 3 /* FontStyles.Italic */, color: 3 /* Colors.Yellow */, effect: ansi_1.ColorEffect.Foreground })}"`);
47
- for (const line of validationResult.error.details) {
48
- const value = line.context?.value ? JSON.stringify(line.context.value) : undefined;
49
- output.stderr(` - ${line.message} ${value ? '(' + (0, ansi_1.italic)(value, output.formatter) + ')' : ''}`);
50
- const ctx = line.context;
51
- for (const detail of ctx?.details?.slice(0, ctx.details.length - 1) ?? []) {
52
- if ('context' in detail && 'message' in detail.context) {
53
- const lines = detail.context.message.split('. ');
54
- for (const l of lines) {
55
- output.stderr(` - ${l.trim()}`);
56
- }
57
- }
58
- }
59
- }
106
+ if (!validateQueries(output, parsedQuery)) {
60
107
  return;
61
108
  }
62
109
  }
63
110
  else if (query.startsWith('[')) {
64
111
  parsedQuery = JSON.parse(query);
65
- const validationResult = (0, query_1.QueriesSchema)().validate(parsedQuery);
66
- if (validationResult.error) {
67
- output.stderr(`Invalid query: ${validationResult.error.message}`);
68
- printHelp(output);
112
+ if (!validateQueries(output, parsedQuery)) {
69
113
  return;
70
114
  }
71
115
  input = remainingArgs.join(' ').trim();
@@ -74,8 +118,14 @@ async function processQueryArgs(output, analyzer, remainingArgs) {
74
118
  parsedQuery = [{ type: 'call-context', callName: query }];
75
119
  }
76
120
  if (input) {
77
- analyzer.reset();
78
- analyzer.addRequest(input);
121
+ if (looksLikePath(input)) {
122
+ output.stdout((0, ansi_1.ansiInfo)(`'${input}' looks like a path. To analyze it, use ${(0, ansi_1.bold)(retriever_1.fileProtocol + input, output.formatter)} (or ${(0, ansi_1.bold)(core_1.watchProtocol + input, output.formatter)} to re-run on changes). Use ${(0, ansi_1.bold)(':help', output.formatter)} for more.`));
123
+ }
124
+ // reuse a prior analysis (e.g. a dataflow from :df#) when the target is unchanged
125
+ if (!analyzerHasTarget(analyzer, input)) {
126
+ analyzer.reset();
127
+ analyzer.addRequest(input);
128
+ }
79
129
  }
80
130
  return {
81
131
  query: await (0, query_1.executeQueries)({
@@ -0,0 +1,7 @@
1
+ import type { ReplCodeCommand } from './repl-main';
2
+ import type { CommandCompletions } from '../core';
3
+ /** the `:signature` subcommand names, offered as completions for its first argument */
4
+ export declare const signatureSubcommandNames: string[];
5
+ /** completes `:signature`: its subcommands, then a file path for `add` (query args are freeform names) */
6
+ export declare function replSignatureCompleter(splitLine: readonly string[], startingNewArg: boolean): CommandCompletions;
7
+ export declare const signatureCommand: ReplCodeCommand;