@eagleoutice/flowr 2.5.0 → 2.6.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 (254) hide show
  1. package/README.md +46 -35
  2. package/abstract-interpretation/data-frame/absint-visitor.d.ts +1 -1
  3. package/abstract-interpretation/data-frame/absint-visitor.js +1 -1
  4. package/cli/flowr.js +11 -33
  5. package/cli/repl/commands/repl-cfg.d.ts +5 -5
  6. package/cli/repl/commands/repl-cfg.js +21 -22
  7. package/cli/repl/commands/repl-commands.d.ts +3 -3
  8. package/cli/repl/commands/repl-commands.js +2 -0
  9. package/cli/repl/commands/repl-dataflow.d.ts +5 -5
  10. package/cli/repl/commands/repl-dataflow.js +27 -30
  11. package/cli/repl/commands/repl-execute.d.ts +1 -1
  12. package/cli/repl/commands/repl-execute.js +8 -7
  13. package/cli/repl/commands/repl-lineage.d.ts +2 -2
  14. package/cli/repl/commands/repl-lineage.js +11 -11
  15. package/cli/repl/commands/repl-main.d.ts +35 -7
  16. package/cli/repl/commands/repl-normalize.d.ts +3 -3
  17. package/cli/repl/commands/repl-normalize.js +15 -19
  18. package/cli/repl/commands/repl-parse.d.ts +2 -2
  19. package/cli/repl/commands/repl-parse.js +14 -8
  20. package/cli/repl/commands/repl-query.d.ts +3 -3
  21. package/cli/repl/commands/repl-query.js +29 -19
  22. package/cli/repl/commands/repl-quit.js +1 -0
  23. package/cli/repl/commands/repl-version.d.ts +1 -16
  24. package/cli/repl/commands/repl-version.js +2 -18
  25. package/cli/repl/core.d.ts +12 -9
  26. package/cli/repl/core.js +26 -12
  27. package/cli/repl/print-version.js +2 -2
  28. package/cli/repl/server/connection.d.ts +7 -3
  29. package/cli/repl/server/connection.js +46 -50
  30. package/cli/repl/server/messages/message-hello.d.ts +1 -1
  31. package/cli/repl/server/messages/message-slice.d.ts +1 -1
  32. package/cli/repl/server/server.js +2 -2
  33. package/cli/slicer-app.js +1 -1
  34. package/config.d.ts +1 -1
  35. package/config.js +4 -1
  36. package/control-flow/extract-cfg.d.ts +1 -1
  37. package/control-flow/extract-cfg.js +1 -1
  38. package/core/pipeline-executor.d.ts +5 -0
  39. package/core/pipeline-executor.js +5 -0
  40. package/core/steps/all/core/20-dataflow.d.ts +3 -1
  41. package/core/steps/pipeline/create-pipeline.js +1 -1
  42. package/core/steps/pipeline/default-pipelines.d.ts +24 -8
  43. package/core/steps/pipeline/default-pipelines.js +4 -1
  44. package/dataflow/environments/default-builtin-config.js +8 -0
  45. package/dataflow/eval/resolve/alias-tracking.js +2 -0
  46. package/dataflow/eval/resolve/resolve.js +3 -0
  47. package/dataflow/eval/values/r-value.d.ts +4 -1
  48. package/dataflow/eval/values/r-value.js +2 -0
  49. package/dataflow/extractor.d.ts +4 -1
  50. package/dataflow/extractor.js +7 -5
  51. package/dataflow/fn/higher-order-function.d.ts +9 -0
  52. package/dataflow/fn/higher-order-function.js +75 -0
  53. package/dataflow/graph/dataflowgraph-builder.d.ts +11 -12
  54. package/dataflow/graph/dataflowgraph-builder.js +6 -6
  55. package/documentation/doc-util/doc-query.d.ts +3 -6
  56. package/documentation/doc-util/doc-query.js +5 -17
  57. package/documentation/doc-util/doc-repl.js +5 -2
  58. package/documentation/doc-util/doc-search.js +7 -10
  59. package/documentation/doc-util/doc-structure.d.ts +4 -0
  60. package/documentation/doc-util/doc-structure.js +28 -0
  61. package/documentation/doc-util/doc-types.d.ts +5 -1
  62. package/documentation/doc-util/doc-types.js +29 -3
  63. package/documentation/print-analyzer-wiki.d.ts +1 -0
  64. package/documentation/print-analyzer-wiki.js +137 -0
  65. package/documentation/print-core-wiki.d.ts +2 -1
  66. package/documentation/print-core-wiki.js +58 -4
  67. package/documentation/print-dataflow-graph-wiki.js +16 -23
  68. package/documentation/print-interface-wiki.js +18 -1
  69. package/documentation/print-linter-wiki.js +5 -1
  70. package/documentation/print-normalized-ast-wiki.js +6 -8
  71. package/documentation/print-query-wiki.js +20 -0
  72. package/documentation/print-readme.js +1 -1
  73. package/engines.d.ts +9 -0
  74. package/engines.js +38 -0
  75. package/linter/linter-executor.d.ts +2 -8
  76. package/linter/linter-executor.js +9 -4
  77. package/linter/linter-format.d.ts +8 -9
  78. package/linter/linter-rules.d.ts +57 -15
  79. package/linter/linter-rules.js +2 -0
  80. package/linter/rules/absolute-path.d.ts +1 -0
  81. package/linter/rules/dataframe-access-validation.d.ts +4 -3
  82. package/linter/rules/dataframe-access-validation.js +7 -4
  83. package/linter/rules/dead-code.d.ts +2 -1
  84. package/linter/rules/deprecated-functions.d.ts +15 -28
  85. package/linter/rules/deprecated-functions.js +5 -43
  86. package/linter/rules/file-path-validity.d.ts +2 -1
  87. package/linter/rules/file-path-validity.js +1 -1
  88. package/linter/rules/function-finder-util.d.ts +51 -0
  89. package/linter/rules/function-finder-util.js +77 -0
  90. package/linter/rules/naming-convention.d.ts +2 -1
  91. package/linter/rules/network-functions.d.ts +40 -0
  92. package/linter/rules/network-functions.js +24 -0
  93. package/linter/rules/seeded-randomness.d.ts +2 -1
  94. package/linter/rules/unused-definition.d.ts +2 -1
  95. package/linter/rules/useless-loop.d.ts +3 -2
  96. package/linter/rules/useless-loop.js +4 -6
  97. package/package.json +2 -1
  98. package/project/cache/flowr-analyzer-cache.d.ts +94 -0
  99. package/project/cache/flowr-analyzer-cache.js +164 -0
  100. package/project/cache/flowr-cache.d.ts +28 -0
  101. package/project/cache/flowr-cache.js +49 -0
  102. package/project/cfg-kind.d.ts +17 -0
  103. package/project/cfg-kind.js +22 -0
  104. package/project/context/abstract-flowr-analyzer-context.d.ts +39 -0
  105. package/project/context/abstract-flowr-analyzer-context.js +46 -0
  106. package/project/context/flowr-analyzer-context.d.ts +54 -0
  107. package/project/context/flowr-analyzer-context.js +58 -0
  108. package/project/context/flowr-analyzer-dependencies-context.d.ts +39 -0
  109. package/project/context/flowr-analyzer-dependencies-context.js +43 -0
  110. package/project/context/flowr-analyzer-files-context.d.ts +87 -0
  111. package/project/context/flowr-analyzer-files-context.js +134 -0
  112. package/project/context/flowr-analyzer-loading-order-context.d.ts +77 -0
  113. package/project/context/flowr-analyzer-loading-order-context.js +96 -0
  114. package/project/context/flowr-file.d.ts +89 -0
  115. package/project/context/flowr-file.js +78 -0
  116. package/project/flowr-analyzer-builder.d.ts +106 -0
  117. package/project/flowr-analyzer-builder.js +197 -0
  118. package/project/flowr-analyzer.d.ts +126 -0
  119. package/project/flowr-analyzer.js +88 -0
  120. package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.d.ts +17 -0
  121. package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.js +28 -0
  122. package/project/plugins/file-plugins/flowr-analyzer-file-plugin.d.ts +21 -0
  123. package/project/plugins/file-plugins/flowr-analyzer-file-plugin.js +34 -0
  124. package/project/plugins/file-plugins/flowr-description-file.d.ts +24 -0
  125. package/project/plugins/file-plugins/flowr-description-file.js +38 -0
  126. package/project/plugins/flowr-analyzer-plugin.d.ts +90 -0
  127. package/project/plugins/flowr-analyzer-plugin.js +82 -0
  128. package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-description-file-plugin.d.ts +14 -0
  129. package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-description-file-plugin.js +56 -0
  130. package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-plugin.d.ts +13 -0
  131. package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-plugin.js +33 -0
  132. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.d.ts +14 -0
  133. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.js +41 -0
  134. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.d.ts +10 -0
  135. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.js +29 -0
  136. package/project/plugins/package-version-plugins/package.d.ts +15 -0
  137. package/project/plugins/package-version-plugins/package.js +56 -0
  138. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.d.ts +15 -0
  139. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +44 -0
  140. package/queries/base-query-format.d.ts +2 -8
  141. package/queries/catalog/call-context-query/call-context-query-executor.d.ts +1 -1
  142. package/queries/catalog/call-context-query/call-context-query-executor.js +21 -13
  143. package/queries/catalog/call-context-query/call-context-query-format.d.ts +2 -3
  144. package/queries/catalog/call-context-query/call-context-query-format.js +2 -2
  145. package/queries/catalog/cluster-query/cluster-query-executor.d.ts +1 -1
  146. package/queries/catalog/cluster-query/cluster-query-executor.js +2 -2
  147. package/queries/catalog/cluster-query/cluster-query-format.d.ts +1 -54
  148. package/queries/catalog/cluster-query/cluster-query-format.js +2 -2
  149. package/queries/catalog/config-query/config-query-executor.d.ts +1 -1
  150. package/queries/catalog/config-query/config-query-executor.js +5 -5
  151. package/queries/catalog/config-query/config-query-format.d.ts +1 -1
  152. package/queries/catalog/config-query/config-query-format.js +1 -1
  153. package/queries/catalog/control-flow-query/control-flow-query-executor.d.ts +1 -1
  154. package/queries/catalog/control-flow-query/control-flow-query-executor.js +3 -3
  155. package/queries/catalog/control-flow-query/control-flow-query-format.d.ts +1 -54
  156. package/queries/catalog/control-flow-query/control-flow-query-format.js +2 -2
  157. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.d.ts +1 -1
  158. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.js +2 -2
  159. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.d.ts +1 -54
  160. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.js +1 -1
  161. package/queries/catalog/dataflow-query/dataflow-query-executor.d.ts +1 -1
  162. package/queries/catalog/dataflow-query/dataflow-query-executor.js +2 -2
  163. package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +1 -54
  164. package/queries/catalog/dataflow-query/dataflow-query-format.js +1 -1
  165. package/queries/catalog/dependencies-query/dependencies-query-executor.d.ts +1 -1
  166. package/queries/catalog/dependencies-query/dependencies-query-executor.js +19 -12
  167. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +7 -56
  168. package/queries/catalog/dependencies-query/dependencies-query-format.js +7 -4
  169. package/queries/catalog/df-shape-query/df-shape-query-executor.d.ts +1 -1
  170. package/queries/catalog/df-shape-query/df-shape-query-executor.js +4 -4
  171. package/queries/catalog/df-shape-query/df-shape-query-format.d.ts +1 -54
  172. package/queries/catalog/df-shape-query/df-shape-query-format.js +1 -1
  173. package/queries/catalog/happens-before-query/happens-before-query-executor.d.ts +1 -1
  174. package/queries/catalog/happens-before-query/happens-before-query-executor.js +2 -1
  175. package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +1 -54
  176. package/queries/catalog/happens-before-query/happens-before-query-format.js +1 -1
  177. package/queries/catalog/id-map-query/id-map-query-executor.d.ts +1 -1
  178. package/queries/catalog/id-map-query/id-map-query-executor.js +2 -2
  179. package/queries/catalog/id-map-query/id-map-query-format.d.ts +1 -54
  180. package/queries/catalog/id-map-query/id-map-query-format.js +2 -2
  181. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.d.ts +3 -0
  182. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +45 -0
  183. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +22 -0
  184. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +32 -0
  185. package/queries/catalog/lineage-query/lineage-query-executor.d.ts +1 -1
  186. package/queries/catalog/lineage-query/lineage-query-executor.js +2 -2
  187. package/queries/catalog/lineage-query/lineage-query-format.d.ts +1 -54
  188. package/queries/catalog/lineage-query/lineage-query-format.js +1 -1
  189. package/queries/catalog/linter-query/linter-query-executor.d.ts +1 -1
  190. package/queries/catalog/linter-query/linter-query-executor.js +2 -3
  191. package/queries/catalog/linter-query/linter-query-format.d.ts +1 -54
  192. package/queries/catalog/linter-query/linter-query-format.js +1 -1
  193. package/queries/catalog/location-map-query/location-map-query-executor.d.ts +1 -1
  194. package/queries/catalog/location-map-query/location-map-query-executor.js +3 -2
  195. package/queries/catalog/location-map-query/location-map-query-format.d.ts +1 -1
  196. package/queries/catalog/location-map-query/location-map-query-format.js +1 -1
  197. package/queries/catalog/normalized-ast-query/normalized-ast-query-executor.d.ts +1 -1
  198. package/queries/catalog/normalized-ast-query/normalized-ast-query-executor.js +2 -2
  199. package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +1 -54
  200. package/queries/catalog/normalized-ast-query/normalized-ast-query-format.js +1 -1
  201. package/queries/catalog/origin-query/origin-query-executor.d.ts +2 -2
  202. package/queries/catalog/origin-query/origin-query-executor.js +3 -3
  203. package/queries/catalog/origin-query/origin-query-format.d.ts +1 -54
  204. package/queries/catalog/origin-query/origin-query-format.js +1 -1
  205. package/queries/catalog/project-query/project-query-executor.d.ts +1 -1
  206. package/queries/catalog/project-query/project-query-executor.js +2 -2
  207. package/queries/catalog/project-query/project-query-format.d.ts +1 -54
  208. package/queries/catalog/project-query/project-query-format.js +1 -1
  209. package/queries/catalog/resolve-value-query/resolve-value-query-executor.d.ts +1 -1
  210. package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +4 -2
  211. package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +1 -54
  212. package/queries/catalog/resolve-value-query/resolve-value-query-format.js +1 -1
  213. package/queries/catalog/search-query/search-query-executor.d.ts +1 -1
  214. package/queries/catalog/search-query/search-query-executor.js +3 -3
  215. package/queries/catalog/search-query/search-query-format.d.ts +1 -54
  216. package/queries/catalog/search-query/search-query-format.js +1 -1
  217. package/queries/catalog/static-slice-query/static-slice-query-executor.d.ts +1 -1
  218. package/queries/catalog/static-slice-query/static-slice-query-executor.js +3 -3
  219. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +1 -54
  220. package/queries/catalog/static-slice-query/static-slice-query-format.js +1 -1
  221. package/queries/query-print.d.ts +4 -4
  222. package/queries/query-print.js +12 -12
  223. package/queries/query.d.ts +37 -885
  224. package/queries/query.js +3 -1
  225. package/r-bridge/parser.d.ts +7 -0
  226. package/r-bridge/retriever.d.ts +6 -5
  227. package/r-bridge/retriever.js +9 -5
  228. package/search/flowr-search-executor.d.ts +3 -5
  229. package/search/flowr-search-executor.js +6 -4
  230. package/search/flowr-search-filters.d.ts +12 -6
  231. package/search/flowr-search-filters.js +1 -1
  232. package/search/flowr-search.d.ts +5 -16
  233. package/search/flowr-search.js +14 -5
  234. package/search/search-executor/search-enrichers.d.ts +37 -36
  235. package/search/search-executor/search-enrichers.js +5 -4
  236. package/search/search-executor/search-generators.d.ts +12 -12
  237. package/search/search-executor/search-generators.js +27 -19
  238. package/search/search-executor/search-mappers.d.ts +5 -5
  239. package/search/search-executor/search-transformer.d.ts +17 -17
  240. package/search/search-executor/search-transformer.js +14 -7
  241. package/util/collections/arrays.d.ts +1 -0
  242. package/util/collections/arrays.js +15 -0
  243. package/util/collections/objectmap.d.ts +17 -0
  244. package/util/collections/objectmap.js +28 -0
  245. package/util/containers.d.ts +0 -1
  246. package/util/containers.js +0 -1
  247. package/util/files.d.ts +17 -0
  248. package/util/files.js +65 -0
  249. package/util/formats/adapter.d.ts +4 -2
  250. package/util/formats/adapter.js +11 -4
  251. package/util/r-value.d.ts +1 -1
  252. package/util/r-value.js +2 -0
  253. package/util/version.d.ts +17 -0
  254. package/util/version.js +28 -1
@@ -41,10 +41,11 @@ export declare function getMostUsedCasing(symbols: {
41
41
  export declare function fixCasing(identifier: string, convention: CasingConvention): string | undefined;
42
42
  export declare function createNamingConventionQuickFixes(graph: DataflowGraph, nodeId: NodeId, replacement: string, conv: CasingConvention): LintQuickFixReplacement[] | undefined;
43
43
  export declare const NAMING_CONVENTION: {
44
- readonly createSearch: (_config: NamingConventionConfig) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter"], import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, [] | import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>;
44
+ readonly createSearch: (_config: NamingConventionConfig) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter"], import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, Promise<import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, [] | import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>>;
45
45
  readonly processSearchResult: (elements: import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>, config: NamingConventionConfig, data: {
46
46
  normalize: import("../../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
47
47
  dataflow: import("../../dataflow/info").DataflowInformation;
48
+ cfg: import("../../control-flow/control-flow-graph").ControlFlowInformation;
48
49
  config: import("../../config").FlowrConfigOptions;
49
50
  }) => {
50
51
  results: {
@@ -0,0 +1,40 @@
1
+ import { LintingRuleCertainty } from '../linter-format';
2
+ import type { FunctionsMetadata, FunctionsResult } from './function-finder-util';
3
+ import { LintingRuleTag } from '../linter-tags';
4
+ import type { MergeableRecord } from '../../util/objects';
5
+ export interface NetworkFunctionsConfig extends MergeableRecord {
6
+ /** The list of function names that should be marked in the given context if their arguments match. */
7
+ fns: readonly string[];
8
+ /** only trigger if the function's read argument is linked to a value that matches this pattern */
9
+ onlyTriggerWithArgument?: RegExp | string;
10
+ }
11
+ export declare const NETWORK_FUNCTIONS: {
12
+ readonly createSearch: (config: NetworkFunctionsConfig) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["with", "filter"], import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, Promise<import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, [] | import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>>;
13
+ readonly processSearchResult: (e: import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>, c: NetworkFunctionsConfig, d: {
14
+ normalize: import("../../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
15
+ dataflow: import("../../dataflow/info").DataflowInformation;
16
+ cfg: import("../../control-flow/control-flow-graph").ControlFlowInformation;
17
+ config: import("../../config").FlowrConfigOptions;
18
+ }) => {
19
+ results: {
20
+ certainty: import("../linter-format").LintingResultCertainty;
21
+ function: import("../../dataflow/environments/identifier").Identifier;
22
+ range: import("../../util/range").SourceRange;
23
+ }[];
24
+ '.meta': FunctionsMetadata;
25
+ };
26
+ readonly prettyPrint: {
27
+ query: (result: FunctionsResult) => string;
28
+ full: (result: FunctionsResult) => string;
29
+ };
30
+ readonly info: {
31
+ readonly name: "Network Functions";
32
+ readonly tags: readonly [LintingRuleTag.Reproducibility, LintingRuleTag.Security, LintingRuleTag.Performance, LintingRuleTag.Smell];
33
+ readonly certainty: LintingRuleCertainty.BestEffort;
34
+ readonly description: "Marks network functions that execute network operations, such as downloading files or making HTTP requests.";
35
+ readonly defaultConfig: {
36
+ readonly fns: readonly ["read.table", "read.csv", "read.csv2", "read.delim", "read.delim2", "readRDS", "download.file", "url", "GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "content", "handle", "get_callback", "VERB", "fread", "gzcon", "readlines", "source", "load", "curl_download", "curl_fetch_memory", "getURL", "getForm", "read_html", "html_nodes", "html_text", "fromJSON", "read.xlsx", "drive_download", "drive_get", "s3read_using", "s3write_using", "storage_download", "AnnotationHub", "ExperimentHub"];
37
+ readonly onlyTriggerWithArgument: RegExp;
38
+ };
39
+ };
40
+ };
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NETWORK_FUNCTIONS = void 0;
4
+ const linter_format_1 = require("../linter-format");
5
+ const function_finder_util_1 = require("./function-finder-util");
6
+ const linter_tags_1 = require("../linter-tags");
7
+ const read_functions_1 = require("../../queries/catalog/dependencies-query/function-info/read-functions");
8
+ exports.NETWORK_FUNCTIONS = {
9
+ createSearch: (config) => function_finder_util_1.functionFinderUtil.createSearch(config.fns),
10
+ processSearchResult: (e, c, d) => function_finder_util_1.functionFinderUtil.processSearchResult(e, c, d, es => es.filter(e => function_finder_util_1.functionFinderUtil.requireArgumentValue(e, read_functions_1.ReadFunctions, d, c.onlyTriggerWithArgument))),
11
+ prettyPrint: function_finder_util_1.functionFinderUtil.prettyPrint('network operations'),
12
+ info: {
13
+ name: 'Network Functions',
14
+ tags: [linter_tags_1.LintingRuleTag.Reproducibility, linter_tags_1.LintingRuleTag.Security, linter_tags_1.LintingRuleTag.Performance, linter_tags_1.LintingRuleTag.Smell],
15
+ // ensures all network functions found are actually network functions through its limited config, but doesn't find all network functions since the config is pre-crawled, and the DFG may be over-approximated
16
+ certainty: linter_format_1.LintingRuleCertainty.BestEffort,
17
+ description: 'Marks network functions that execute network operations, such as downloading files or making HTTP requests.',
18
+ defaultConfig: {
19
+ fns: ['read.table', 'read.csv', 'read.csv2', 'read.delim', 'read.delim2', 'readRDS', 'download.file', 'url', 'GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'content', 'handle', 'get_callback', 'VERB', 'fread', 'gzcon', 'readlines', 'source', 'load', 'curl_download', 'curl_fetch_memory', 'getURL', 'getForm', 'read_html', 'html_nodes', 'html_text', 'fromJSON', 'read.xlsx', 'drive_download', 'drive_get', 's3read_using', 's3write_using', 'storage_download', 'AnnotationHub', 'ExperimentHub'],
20
+ onlyTriggerWithArgument: /^(https?|ftps?|file):\/\//
21
+ }
22
+ }
23
+ };
24
+ //# sourceMappingURL=network-functions.js.map
@@ -30,10 +30,11 @@ export interface SeededRandomnessMeta extends MergeableRecord {
30
30
  callsWithNonConstantProducers: number;
31
31
  }
32
32
  export declare const SEEDED_RANDOMNESS: {
33
- readonly createSearch: (config: SeededRandomnessConfig) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["with", "filter", "with"], import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>;
33
+ readonly createSearch: (config: SeededRandomnessConfig) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["with", "filter", "with"], import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, Promise<import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>>;
34
34
  readonly processSearchResult: (elements: import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>, config: SeededRandomnessConfig, { dataflow }: {
35
35
  normalize: import("../../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
36
36
  dataflow: import("../../dataflow/info").DataflowInformation;
37
+ cfg: import("../../control-flow/control-flow-graph").ControlFlowInformation;
37
38
  config: import("../../config").FlowrConfigOptions;
38
39
  }) => {
39
40
  results: {
@@ -18,10 +18,11 @@ export interface UnusedDefinitionMetadata extends MergeableRecord {
18
18
  totalConsidered: number;
19
19
  }
20
20
  export declare const UNUSED_DEFINITION: {
21
- readonly createSearch: (config: UnusedDefinitionConfig) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter"], ParentInformation, import("../../search/flowr-search").FlowrSearchElements<ParentInformation, [] | import("../../search/flowr-search").FlowrSearchElement<ParentInformation>[]>>;
21
+ readonly createSearch: (config: UnusedDefinitionConfig) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter"], ParentInformation, Promise<import("../../search/flowr-search").FlowrSearchElements<ParentInformation, [] | import("../../search/flowr-search").FlowrSearchElement<ParentInformation>[]>>>;
22
22
  readonly processSearchResult: (elements: import("../../search/flowr-search").FlowrSearchElements<ParentInformation, import("../../search/flowr-search").FlowrSearchElement<ParentInformation>[]>, config: UnusedDefinitionConfig, data: {
23
23
  normalize: NormalizedAst;
24
24
  dataflow: import("../../dataflow/info").DataflowInformation;
25
+ cfg: import("../../control-flow/control-flow-graph").ControlFlowInformation;
25
26
  config: import("../../config").FlowrConfigOptions;
26
27
  }) => {
27
28
  results: UnusedDefinitionResult[];
@@ -16,10 +16,11 @@ export interface UselessLoopMetadata extends MergeableRecord {
16
16
  numOfUselessLoops: number;
17
17
  }
18
18
  export declare const USELESS_LOOP: {
19
- readonly createSearch: () => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter"], import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, [] | import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>;
20
- readonly processSearchResult: (elements: import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>, config: UselessLoopConfig, data: {
19
+ readonly createSearch: () => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter"], import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, Promise<import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, [] | import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>>;
20
+ readonly processSearchResult: (elements: import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>, useLessLoopConfig: UselessLoopConfig, { config, dataflow, normalize, cfg }: {
21
21
  normalize: import("../../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
22
22
  dataflow: import("../../dataflow/info").DataflowInformation;
23
+ cfg: import("../../control-flow/control-flow-graph").ControlFlowInformation;
23
24
  config: import("../../config").FlowrConfigOptions;
24
25
  }) => {
25
26
  results: {
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.USELESS_LOOP = void 0;
4
- const extract_cfg_1 = require("../../control-flow/extract-cfg");
5
4
  const useless_loop_1 = require("../../control-flow/useless-loop");
6
5
  const vertex_1 = require("../../dataflow/graph/vertex");
7
6
  const flowr_search_builder_1 = require("../../search/flowr-search-builder");
@@ -10,15 +9,14 @@ const linter_format_1 = require("../linter-format");
10
9
  const linter_tags_1 = require("../linter-tags");
11
10
  exports.USELESS_LOOP = {
12
11
  createSearch: () => flowr_search_builder_1.Q.all().filter(vertex_1.VertexType.FunctionCall),
13
- processSearchResult: (elements, config, data) => {
14
- const cfg = (0, extract_cfg_1.extractCfg)(data.normalize, data.config, data.dataflow.graph);
12
+ processSearchResult: (elements, useLessLoopConfig, { config, dataflow, normalize, cfg }) => {
15
13
  const results = elements.getElements().filter(e => {
16
- const vertex = data.dataflow.graph.getVertex(e.node.info.id);
14
+ const vertex = dataflow.graph.getVertex(e.node.info.id);
17
15
  return vertex
18
16
  && (0, vertex_1.isFunctionCallVertex)(vertex)
19
17
  && vertex.origin !== 'unnamed'
20
- && config.loopyFunctions.has(vertex.origin[0]);
21
- }).filter(loop => (0, useless_loop_1.onlyLoopsOnce)(loop.node.info.id, data.dataflow.graph, cfg, data.normalize, data.config)).map(res => ({
18
+ && useLessLoopConfig.loopyFunctions.has(vertex.origin[0]);
19
+ }).filter(loop => (0, useless_loop_1.onlyLoopsOnce)(loop.node.info.id, dataflow.graph, cfg, normalize, config)).map(res => ({
22
20
  certainty: linter_format_1.LintingResultCertainty.Certain,
23
21
  name: res.node.lexeme,
24
22
  range: res.node.info.fullRange
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eagleoutice/flowr",
3
- "version": "2.5.0",
3
+ "version": "2.6.1",
4
4
  "description": "Static Dataflow Analyzer and Program Slicer for the R Programming Language",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "repository": {
@@ -30,6 +30,7 @@
30
30
  "wiki:normalized-ast": "ts-node src/documentation/print-normalized-ast-wiki.ts",
31
31
  "wiki:query-api": "ts-node src/documentation/print-query-wiki.ts",
32
32
  "wiki:core": "ts-node src/documentation/print-core-wiki.ts",
33
+ "wiki:analyzer": "ts-node src/documentation/print-analyzer-wiki.ts",
33
34
  "wiki:engines": "ts-node src/documentation/print-engines-wiki.ts",
34
35
  "wiki:search-api": "ts-node src/documentation/print-search-wiki.ts",
35
36
  "wiki:linting-and-testing": "ts-node src/documentation/print-linting-and-testing-wiki.ts",
@@ -0,0 +1,94 @@
1
+ import type { KnownParser } from '../../r-bridge/parser';
2
+ import type { CacheInvalidationEvent } from './flowr-cache';
3
+ import { FlowrCache } from './flowr-cache';
4
+ import type { DEFAULT_DATAFLOW_PIPELINE, TREE_SITTER_DATAFLOW_PIPELINE } from '../../core/steps/pipeline/default-pipelines';
5
+ import type { FlowrConfigOptions } from '../../config';
6
+ import type { RParseRequests } from '../../r-bridge/retriever';
7
+ import type { IdGenerator } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
8
+ import type { NoInfo } from '../../r-bridge/lang-4.x/ast/model/model';
9
+ import type { TreeSitterExecutor } from '../../r-bridge/lang-4.x/tree-sitter/tree-sitter-executor';
10
+ import type { PipelineOutput } from '../../core/steps/pipeline/pipeline';
11
+ import type { CfgSimplificationPassName } from '../../control-flow/cfg-simplification';
12
+ import type { ControlFlowInformation } from '../../control-flow/control-flow-graph';
13
+ import { CfgKind } from '../cfg-kind';
14
+ interface FlowrAnalyzerCacheOptions<Parser extends KnownParser> {
15
+ parser: Parser;
16
+ config: FlowrConfigOptions;
17
+ request: RParseRequests;
18
+ getId?: IdGenerator<NoInfo>;
19
+ overwriteFilePath?: string;
20
+ }
21
+ export type AnalyzerCacheType<Parser extends KnownParser> = Parser extends TreeSitterExecutor ? Partial<PipelineOutput<typeof TREE_SITTER_DATAFLOW_PIPELINE>> : Partial<PipelineOutput<typeof DEFAULT_DATAFLOW_PIPELINE>>;
22
+ /**
23
+ * This provides the full analyzer caching layer, please avoid using this directly
24
+ * and prefer the {@link FlowrAnalyzer}.
25
+ */
26
+ export declare class FlowrAnalyzerCache<Parser extends KnownParser> extends FlowrCache<AnalyzerCacheType<Parser>> {
27
+ private args;
28
+ private pipeline;
29
+ private controlFlowCache;
30
+ protected constructor(args: FlowrAnalyzerCacheOptions<Parser>);
31
+ private initCacheProviders;
32
+ static create<Parser extends KnownParser>(data: FlowrAnalyzerCacheOptions<Parser>): FlowrAnalyzerCache<Parser>;
33
+ receive(event: CacheInvalidationEvent): void;
34
+ private get;
35
+ reset(): void;
36
+ private runTapeUntil;
37
+ /**
38
+ * Get the parse output for the request, parsing if necessary.
39
+ * @param force - Do not use the cache, instead force a new parse.
40
+ *
41
+ * @see {@link FlowrAnalyzerCache#peekParse} - to get the parse output if already available without triggering a new parse.
42
+ */
43
+ parse(force?: boolean): Promise<NonNullable<AnalyzerCacheType<Parser>['parse']>>;
44
+ /**
45
+ * Get the parse output for the request if already available, otherwise return `undefined`.
46
+ * This will not trigger a new parse.
47
+ *
48
+ * @see {@link FlowrAnalyzerCache#parse} - to get the parse output, parsing if necessary.
49
+ */
50
+ peekParse(): NonNullable<AnalyzerCacheType<Parser>['parse']> | undefined;
51
+ /**
52
+ * Get the normalized abstract syntax tree for the request, normalizing if necessary.
53
+ * @param force - Do not use the cache, instead force new analyses.
54
+ * @see {@link FlowrAnalyzerCache#peekNormalize} - to get the normalized AST if already available without triggering a new normalization.
55
+ */
56
+ normalize(force?: boolean): Promise<NonNullable<AnalyzerCacheType<Parser>['normalize']>>;
57
+ /**
58
+ * Get the normalized abstract syntax tree for the request if already available, otherwise return `undefined`.
59
+ * This will not trigger a new normalization.
60
+ *
61
+ * @see {@link FlowrAnalyzerCache#normalize} - to get the normalized AST, normalizing if necessary.
62
+ */
63
+ peekNormalize(): NonNullable<AnalyzerCacheType<Parser>['normalize']> | undefined;
64
+ /**
65
+ * Get the dataflow graph for the request, computing if necessary.
66
+ * @param force - Do not use the cache, instead force new analyses.
67
+ *
68
+ * @see {@link FlowrAnalyzerCache#peekDataflow} - to get the dataflow graph if already available without triggering a new computation.
69
+ */
70
+ dataflow(force?: boolean): Promise<NonNullable<AnalyzerCacheType<Parser>['dataflow']>>;
71
+ /**
72
+ * Get the dataflow graph for the request if already available, otherwise return `undefined`.
73
+ * This will not trigger a new computation.
74
+ *
75
+ * @see {@link FlowrAnalyzerCache#dataflow} - to get the dataflow graph, computing if necessary.
76
+ */
77
+ peekDataflow(): NonNullable<AnalyzerCacheType<Parser>['dataflow']> | undefined;
78
+ /**
79
+ * Get the control flow graph (CFG) for the request, computing if necessary.
80
+ * @param force - Do not use the cache, instead force new analyses.
81
+ * @param kind - The kind of CFG that is requested.
82
+ * @param simplifications - Simplification passes to be applied to the CFG.
83
+ */
84
+ controlflow(force: boolean | undefined, kind: CfgKind, simplifications: readonly CfgSimplificationPassName[] | undefined): Promise<ControlFlowInformation>;
85
+ /**
86
+ * Get the control flow graph (CFG) for the request if already available, otherwise return `undefined`.
87
+ * @param kind - The kind of CFG that is requested.
88
+ * @param simplifications - Simplification passes to be applied to the CFG.
89
+ *
90
+ * @see {@link FlowrAnalyzerCache#controlflow} - to get the control flow graph, computing if necessary.
91
+ */
92
+ peekControlflow(kind: CfgKind, simplifications: readonly CfgSimplificationPassName[] | undefined): ControlFlowInformation | undefined;
93
+ }
94
+ export {};
@@ -0,0 +1,164 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FlowrAnalyzerCache = void 0;
4
+ const flowr_cache_1 = require("./flowr-cache");
5
+ const default_pipelines_1 = require("../../core/steps/pipeline/default-pipelines");
6
+ const assert_1 = require("../../util/assert");
7
+ const objectmap_1 = require("../../util/collections/objectmap");
8
+ const extract_cfg_1 = require("../../control-flow/extract-cfg");
9
+ const cfg_kind_1 = require("../cfg-kind");
10
+ /**
11
+ * This provides the full analyzer caching layer, please avoid using this directly
12
+ * and prefer the {@link FlowrAnalyzer}.
13
+ */
14
+ class FlowrAnalyzerCache extends flowr_cache_1.FlowrCache {
15
+ args;
16
+ pipeline = undefined;
17
+ controlFlowCache = undefined;
18
+ constructor(args) {
19
+ super();
20
+ this.args = args;
21
+ this.initCacheProviders();
22
+ }
23
+ initCacheProviders() {
24
+ this.pipeline = (0, default_pipelines_1.createDataflowPipeline)(this.args.parser, {
25
+ request: this.args.request,
26
+ getId: this.args.getId,
27
+ overwriteFilePath: this.args.overwriteFilePath
28
+ }, this.args.config);
29
+ this.controlFlowCache = {
30
+ simplified: new objectmap_1.ObjectMap(),
31
+ };
32
+ }
33
+ static create(data) {
34
+ return new FlowrAnalyzerCache(data);
35
+ }
36
+ receive(event) {
37
+ super.receive(event);
38
+ switch (event.type) {
39
+ case "full" /* CacheInvalidationEventType.Full */:
40
+ this.initCacheProviders();
41
+ break;
42
+ default:
43
+ (0, assert_1.assertUnreachable)(event.type);
44
+ }
45
+ }
46
+ get() {
47
+ /* this will do a ref assignment, so indirect force */
48
+ return this.computeIfAbsent(false, () => this.pipeline.getResults(true));
49
+ }
50
+ reset() {
51
+ this.receive({ type: "full" /* CacheInvalidationEventType.Full */ });
52
+ }
53
+ async runTapeUntil(force, until) {
54
+ (0, assert_1.guard)(this.args.request && (Array.isArray(this.args.request) ? this.args.request.length > 0 : true), 'At least one request must be set to run the analysis pipeline');
55
+ if (force) {
56
+ this.reset();
57
+ }
58
+ let g;
59
+ while ((g = until()) === undefined && this.pipeline.hasNextStep()) {
60
+ await this.pipeline.nextStep();
61
+ }
62
+ (0, assert_1.guard)(g !== undefined, 'Could not reach the desired pipeline step, invalid cache state(?)');
63
+ return g;
64
+ }
65
+ /**
66
+ * Get the parse output for the request, parsing if necessary.
67
+ * @param force - Do not use the cache, instead force a new parse.
68
+ *
69
+ * @see {@link FlowrAnalyzerCache#peekParse} - to get the parse output if already available without triggering a new parse.
70
+ */
71
+ async parse(force) {
72
+ const d = this.get();
73
+ return this.runTapeUntil(force, () => d.parse);
74
+ }
75
+ /**
76
+ * Get the parse output for the request if already available, otherwise return `undefined`.
77
+ * This will not trigger a new parse.
78
+ *
79
+ * @see {@link FlowrAnalyzerCache#parse} - to get the parse output, parsing if necessary.
80
+ */
81
+ peekParse() {
82
+ return this.get().parse;
83
+ }
84
+ /**
85
+ * Get the normalized abstract syntax tree for the request, normalizing if necessary.
86
+ * @param force - Do not use the cache, instead force new analyses.
87
+ * @see {@link FlowrAnalyzerCache#peekNormalize} - to get the normalized AST if already available without triggering a new normalization.
88
+ */
89
+ async normalize(force) {
90
+ const d = this.get();
91
+ return this.runTapeUntil(force, () => d.normalize);
92
+ }
93
+ /**
94
+ * Get the normalized abstract syntax tree for the request if already available, otherwise return `undefined`.
95
+ * This will not trigger a new normalization.
96
+ *
97
+ * @see {@link FlowrAnalyzerCache#normalize} - to get the normalized AST, normalizing if necessary.
98
+ */
99
+ peekNormalize() {
100
+ return this.get().normalize;
101
+ }
102
+ /**
103
+ * Get the dataflow graph for the request, computing if necessary.
104
+ * @param force - Do not use the cache, instead force new analyses.
105
+ *
106
+ * @see {@link FlowrAnalyzerCache#peekDataflow} - to get the dataflow graph if already available without triggering a new computation.
107
+ */
108
+ async dataflow(force) {
109
+ const d = this.get();
110
+ return this.runTapeUntil(force, () => d.dataflow);
111
+ }
112
+ /**
113
+ * Get the dataflow graph for the request if already available, otherwise return `undefined`.
114
+ * This will not trigger a new computation.
115
+ *
116
+ * @see {@link FlowrAnalyzerCache#dataflow} - to get the dataflow graph, computing if necessary.
117
+ */
118
+ peekDataflow() {
119
+ return this.get().dataflow;
120
+ }
121
+ /**
122
+ * Get the control flow graph (CFG) for the request, computing if necessary.
123
+ * @param force - Do not use the cache, instead force new analyses.
124
+ * @param kind - The kind of CFG that is requested.
125
+ * @param simplifications - Simplification passes to be applied to the CFG.
126
+ */
127
+ async controlflow(force, kind, simplifications) {
128
+ (0, assert_1.guard)(kind === cfg_kind_1.CfgKind.Quick ? simplifications === undefined : true, 'Cannot apply simplifications to quick CFG');
129
+ simplifications ??= [];
130
+ if (!force) {
131
+ const value = this.controlFlowCache.simplified.get([simplifications, kind]);
132
+ if (value !== undefined) {
133
+ return value;
134
+ }
135
+ }
136
+ const normalized = await this.normalize(force);
137
+ let result;
138
+ switch (kind) {
139
+ case cfg_kind_1.CfgKind.WithDataflow:
140
+ result = (0, extract_cfg_1.extractCfg)(normalized, this.args.config, (await this.dataflow()).graph, simplifications);
141
+ break;
142
+ case cfg_kind_1.CfgKind.NoDataflow:
143
+ result = (0, extract_cfg_1.extractCfg)(normalized, this.args.config, undefined, simplifications);
144
+ break;
145
+ case cfg_kind_1.CfgKind.Quick:
146
+ result = this.peekDataflow()?.cfgQuick ?? (0, extract_cfg_1.extractCfgQuick)(normalized);
147
+ break;
148
+ }
149
+ this.controlFlowCache.simplified.set([simplifications, kind], result);
150
+ return result;
151
+ }
152
+ /**
153
+ * Get the control flow graph (CFG) for the request if already available, otherwise return `undefined`.
154
+ * @param kind - The kind of CFG that is requested.
155
+ * @param simplifications - Simplification passes to be applied to the CFG.
156
+ *
157
+ * @see {@link FlowrAnalyzerCache#controlflow} - to get the control flow graph, computing if necessary.
158
+ */
159
+ peekControlflow(kind, simplifications) {
160
+ return this.controlFlowCache.simplified.get([simplifications ?? [], kind]);
161
+ }
162
+ }
163
+ exports.FlowrAnalyzerCache = FlowrAnalyzerCache;
164
+ //# sourceMappingURL=flowr-analyzer-cache.js.map
@@ -0,0 +1,28 @@
1
+ export declare const enum CacheInvalidationEventType {
2
+ Full = "full"
3
+ }
4
+ export type CacheInvalidationEvent = {
5
+ type: CacheInvalidationEventType.Full;
6
+ };
7
+ export interface CacheInvalidationEventReceiver {
8
+ receive(event: CacheInvalidationEvent): void;
9
+ }
10
+ /**
11
+ * Central class for caching analysis results in FlowR.
12
+ */
13
+ export declare abstract class FlowrCache<Cache> implements CacheInvalidationEventReceiver {
14
+ private value;
15
+ private dependents;
16
+ registerDependent(dependent: CacheInvalidationEventReceiver): void;
17
+ removeDependent(dependent: CacheInvalidationEventReceiver): void;
18
+ receive(event: CacheInvalidationEvent): void;
19
+ /**
20
+ * Notify all dependents of a cache invalidation event.
21
+ */
22
+ notifyDependents(event: CacheInvalidationEvent): void;
23
+ /**
24
+ * Get the cached value or compute it if not present.
25
+ * This will, by default, not trigger any {@link notifyDependents} calls, as this is only a cache retrieval.
26
+ */
27
+ protected computeIfAbsent(force: boolean | undefined, compute: () => Cache): Cache;
28
+ }
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FlowrCache = void 0;
4
+ const assert_1 = require("../../util/assert");
5
+ /**
6
+ * Central class for caching analysis results in FlowR.
7
+ */
8
+ class FlowrCache {
9
+ value = undefined;
10
+ dependents = [];
11
+ registerDependent(dependent) {
12
+ this.dependents.push(dependent);
13
+ }
14
+ removeDependent(dependent) {
15
+ this.dependents = this.dependents.filter(d => d !== dependent);
16
+ }
17
+ receive(event) {
18
+ /* we will update this as soon as we support incremental update patterns */
19
+ switch (event.type) {
20
+ case "full" /* CacheInvalidationEventType.Full */:
21
+ this.value = undefined;
22
+ break;
23
+ default:
24
+ (0, assert_1.assertUnreachable)(event.type);
25
+ }
26
+ /* in the future we want to defer this *after* the dataflow is re-computed, then all receivers can decide whether they need to update */
27
+ this.notifyDependents(event);
28
+ }
29
+ /**
30
+ * Notify all dependents of a cache invalidation event.
31
+ */
32
+ notifyDependents(event) {
33
+ for (const dependent of this.dependents) {
34
+ dependent.receive(event);
35
+ }
36
+ }
37
+ /**
38
+ * Get the cached value or compute it if not present.
39
+ * This will, by default, not trigger any {@link notifyDependents} calls, as this is only a cache retrieval.
40
+ */
41
+ computeIfAbsent(force, compute) {
42
+ if (this.value === undefined || force) {
43
+ this.value = compute();
44
+ }
45
+ return this.value;
46
+ }
47
+ }
48
+ exports.FlowrCache = FlowrCache;
49
+ //# sourceMappingURL=flowr-cache.js.map
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Denotes the kind of control flow graph (CFG).
3
+ */
4
+ export declare enum CfgKind {
5
+ /**
6
+ * CFG with dataflow information.
7
+ */
8
+ WithDataflow = 0,
9
+ /**
10
+ * CFG without dataflow information.
11
+ */
12
+ NoDataflow = 1,
13
+ /**
14
+ * A CFG version that is much quicker and does not apply any simplifications or dataflow information.
15
+ */
16
+ Quick = 2
17
+ }
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CfgKind = void 0;
4
+ /**
5
+ * Denotes the kind of control flow graph (CFG).
6
+ */
7
+ var CfgKind;
8
+ (function (CfgKind) {
9
+ /**
10
+ * CFG with dataflow information.
11
+ */
12
+ CfgKind[CfgKind["WithDataflow"] = 0] = "WithDataflow";
13
+ /**
14
+ * CFG without dataflow information.
15
+ */
16
+ CfgKind[CfgKind["NoDataflow"] = 1] = "NoDataflow";
17
+ /**
18
+ * A CFG version that is much quicker and does not apply any simplifications or dataflow information.
19
+ */
20
+ CfgKind[CfgKind["Quick"] = 2] = "Quick";
21
+ })(CfgKind || (exports.CfgKind = CfgKind = {}));
22
+ //# sourceMappingURL=cfg-kind.js.map
@@ -0,0 +1,39 @@
1
+ import type { FlowrAnalyzerPlugin } from '../plugins/flowr-analyzer-plugin';
2
+ import type { FlowrAnalyzerContext } from './flowr-analyzer-context';
3
+ /**
4
+ * Abstract class representing the context, a context may be modified and enriched by plugins (see {@link FlowrAnalyzerPlugin}).
5
+ *
6
+ * Please use the specialized contexts like {@link FlowrAnalyzerFilesContext} or {@link FlowrAnalyzerLoadingOrderContext} to work with flowR and
7
+ * in general, use the {@link FlowrAnalyzerContext} to access the full project context.
8
+ */
9
+ export declare abstract class AbstractFlowrAnalyzerContext<In, Out, Plugin extends FlowrAnalyzerPlugin<In, Out>> {
10
+ /**
11
+ * A human-readable name of the context. Try to make it unique to avoid confusion in the logs.
12
+ */
13
+ abstract readonly name: string;
14
+ /**
15
+ * The plugins registered for this context. These build the foundation for {@link applyPlugins}.
16
+ */
17
+ protected readonly plugins: readonly Plugin[];
18
+ /**
19
+ * The linked full project context, allowing plugins to modify and access it.
20
+ */
21
+ protected readonly ctx: FlowrAnalyzerContext;
22
+ /**
23
+ * Creates a new context with the given project context, a default plugin (to be used when no other is registered)
24
+ */
25
+ protected constructor(ctx: FlowrAnalyzerContext, defaultPlugin: Plugin, plugins?: readonly Plugin[]);
26
+ /**
27
+ * Run all registered plugins on the given args, please be aware that if they are async, it is up to you to
28
+ * await them.
29
+ */
30
+ protected applyPlugins(args: Parameters<Plugin['processor']>[1]): Out[];
31
+ /**
32
+ * Returns the project context this sub-context is attached to
33
+ */
34
+ getAttachedContext(): FlowrAnalyzerContext;
35
+ /**
36
+ * Reset the context to its initial state.
37
+ */
38
+ abstract reset(): void;
39
+ }
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AbstractFlowrAnalyzerContext = void 0;
4
+ const assert_1 = require("../../util/assert");
5
+ /**
6
+ * Abstract class representing the context, a context may be modified and enriched by plugins (see {@link FlowrAnalyzerPlugin}).
7
+ *
8
+ * Please use the specialized contexts like {@link FlowrAnalyzerFilesContext} or {@link FlowrAnalyzerLoadingOrderContext} to work with flowR and
9
+ * in general, use the {@link FlowrAnalyzerContext} to access the full project context.
10
+ */
11
+ class AbstractFlowrAnalyzerContext {
12
+ /**
13
+ * The plugins registered for this context. These build the foundation for {@link applyPlugins}.
14
+ */
15
+ plugins;
16
+ /**
17
+ * The linked full project context, allowing plugins to modify and access it.
18
+ */
19
+ ctx;
20
+ /**
21
+ * Creates a new context with the given project context, a default plugin (to be used when no other is registered)
22
+ */
23
+ constructor(ctx, defaultPlugin, plugins) {
24
+ this.plugins = [...plugins ?? [], defaultPlugin];
25
+ this.ctx = ctx;
26
+ }
27
+ /**
28
+ * Run all registered plugins on the given args, please be aware that if they are async, it is up to you to
29
+ * await them.
30
+ */
31
+ applyPlugins(args) {
32
+ const res = [];
33
+ for (const plugin of this.plugins) {
34
+ res.push(plugin.processor(this.ctx, args));
35
+ }
36
+ return res.filter(assert_1.isNotUndefined);
37
+ }
38
+ /**
39
+ * Returns the project context this sub-context is attached to
40
+ */
41
+ getAttachedContext() {
42
+ return this.ctx;
43
+ }
44
+ }
45
+ exports.AbstractFlowrAnalyzerContext = AbstractFlowrAnalyzerContext;
46
+ //# sourceMappingURL=abstract-flowr-analyzer-context.js.map