@eagleoutice/flowr 2.2.15 → 2.2.16

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 (212) hide show
  1. package/README.md +210 -6
  2. package/benchmark/slicer.d.ts +3 -1
  3. package/benchmark/slicer.js +8 -5
  4. package/benchmark/summarizer/first-phase/process.d.ts +2 -1
  5. package/benchmark/summarizer/first-phase/process.js +2 -2
  6. package/cli/benchmark-app.d.ts +1 -0
  7. package/cli/benchmark-app.js +4 -1
  8. package/cli/benchmark-helper-app.d.ts +1 -0
  9. package/cli/benchmark-helper-app.js +7 -8
  10. package/cli/common/options.js +2 -0
  11. package/cli/export-quads-app.js +2 -1
  12. package/cli/flowr.js +58 -57
  13. package/cli/repl/commands/repl-cfg.js +13 -13
  14. package/cli/repl/commands/repl-commands.js +2 -2
  15. package/cli/repl/commands/repl-dataflow.js +10 -10
  16. package/cli/repl/commands/repl-execute.d.ts +2 -3
  17. package/cli/repl/commands/repl-execute.js +4 -4
  18. package/cli/repl/commands/repl-lineage.js +4 -4
  19. package/cli/repl/commands/repl-main.d.ts +12 -1
  20. package/cli/repl/commands/repl-normalize.js +6 -6
  21. package/cli/repl/commands/repl-parse.js +2 -2
  22. package/cli/repl/commands/repl-query.js +9 -9
  23. package/cli/repl/commands/repl-version.js +1 -1
  24. package/cli/repl/core.d.ts +5 -2
  25. package/cli/repl/core.js +10 -8
  26. package/cli/repl/server/connection.d.ts +3 -1
  27. package/cli/repl/server/connection.js +7 -5
  28. package/cli/repl/server/server.d.ts +3 -2
  29. package/cli/repl/server/server.js +4 -2
  30. package/cli/script-core/statistics-core.d.ts +2 -1
  31. package/cli/script-core/statistics-core.js +2 -2
  32. package/cli/script-core/statistics-helper-core.d.ts +2 -1
  33. package/cli/script-core/statistics-helper-core.js +5 -4
  34. package/cli/slicer-app.js +4 -2
  35. package/cli/statistics-app.js +2 -1
  36. package/cli/statistics-helper-app.js +2 -1
  37. package/config.d.ts +12 -10
  38. package/config.js +26 -42
  39. package/control-flow/cfg-dead-code.js +45 -2
  40. package/control-flow/cfg-simplification.d.ts +2 -0
  41. package/control-flow/control-flow-graph.d.ts +1 -0
  42. package/control-flow/control-flow-graph.js +4 -0
  43. package/control-flow/dfg-cfg-guided-visitor.d.ts +5 -3
  44. package/control-flow/dfg-cfg-guided-visitor.js +15 -4
  45. package/control-flow/extract-cfg.d.ts +4 -2
  46. package/control-flow/extract-cfg.js +4 -3
  47. package/control-flow/semantic-cfg-guided-visitor.d.ts +19 -1
  48. package/control-flow/semantic-cfg-guided-visitor.js +23 -3
  49. package/core/pipeline-executor.d.ts +4 -1
  50. package/core/pipeline-executor.js +6 -5
  51. package/core/steps/all/core/10-normalize.d.ts +2 -0
  52. package/core/steps/all/core/10-normalize.js +1 -1
  53. package/core/steps/all/core/11-normalize-tree-sitter.d.ts +2 -1
  54. package/core/steps/all/core/11-normalize-tree-sitter.js +2 -2
  55. package/core/steps/all/core/20-dataflow.d.ts +2 -1
  56. package/core/steps/all/core/20-dataflow.js +2 -2
  57. package/core/steps/all/static-slicing/00-slice.d.ts +2 -1
  58. package/core/steps/all/static-slicing/00-slice.js +2 -2
  59. package/core/steps/pipeline/default-pipelines.d.ts +32 -31
  60. package/core/steps/pipeline/default-pipelines.js +8 -8
  61. package/core/steps/pipeline-step.d.ts +2 -1
  62. package/dataflow/environments/built-in-config.d.ts +3 -3
  63. package/dataflow/environments/built-in.d.ts +7 -1
  64. package/dataflow/environments/built-in.js +2 -2
  65. package/dataflow/environments/default-builtin-config.js +4 -2
  66. package/dataflow/environments/define.d.ts +2 -1
  67. package/dataflow/environments/define.js +4 -5
  68. package/dataflow/environments/remove.d.ts +6 -0
  69. package/dataflow/environments/remove.js +29 -0
  70. package/dataflow/eval/resolve/alias-tracking.d.ts +7 -2
  71. package/dataflow/eval/resolve/alias-tracking.js +9 -6
  72. package/dataflow/eval/resolve/resolve-argument.d.ts +8 -0
  73. package/dataflow/eval/resolve/resolve-argument.js +118 -0
  74. package/dataflow/eval/resolve/resolve.d.ts +18 -15
  75. package/dataflow/eval/resolve/resolve.js +20 -18
  76. package/dataflow/eval/values/string/string-constants.d.ts +1 -1
  77. package/dataflow/eval/values/string/string-constants.js +7 -2
  78. package/dataflow/extractor.d.ts +2 -1
  79. package/dataflow/extractor.js +2 -1
  80. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +5 -6
  81. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +1 -1
  82. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +4 -2
  83. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +11 -11
  84. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +10 -11
  85. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +7 -2
  86. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +2 -3
  87. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +1 -1
  88. package/dataflow/internal/process/functions/call/built-in/built-in-list.js +2 -2
  89. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +2 -3
  90. package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +5 -3
  91. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +15 -15
  92. package/dataflow/internal/process/functions/call/built-in/built-in-vector.js +2 -2
  93. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +1 -1
  94. package/dataflow/internal/process/functions/call/common.js +1 -1
  95. package/dataflow/internal/process/functions/process-parameter.js +1 -1
  96. package/dataflow/origin/dfg-get-symbol-refs.d.ts +21 -0
  97. package/dataflow/origin/dfg-get-symbol-refs.js +50 -0
  98. package/dataflow/processor.d.ts +5 -0
  99. package/documentation/doc-util/doc-cfg.js +4 -3
  100. package/documentation/doc-util/doc-code.d.ts +1 -1
  101. package/documentation/doc-util/doc-dfg.js +3 -2
  102. package/documentation/doc-util/doc-functions.d.ts +24 -0
  103. package/documentation/doc-util/doc-functions.js +65 -0
  104. package/documentation/doc-util/doc-normalized-ast.js +3 -2
  105. package/documentation/doc-util/doc-print.d.ts +5 -0
  106. package/documentation/doc-util/doc-print.js +36 -0
  107. package/documentation/doc-util/doc-query.js +3 -2
  108. package/documentation/doc-util/doc-repl.js +2 -1
  109. package/documentation/doc-util/doc-search.js +3 -2
  110. package/documentation/doc-util/doc-types.d.ts +28 -6
  111. package/documentation/doc-util/doc-types.js +89 -45
  112. package/documentation/print-cfg-wiki.js +6 -7
  113. package/documentation/print-core-wiki.js +5 -5
  114. package/documentation/print-dataflow-graph-wiki.js +10 -10
  115. package/documentation/print-engines-wiki.js +1 -2
  116. package/documentation/print-faq-wiki.js +8 -2
  117. package/documentation/print-interface-wiki.js +1 -2
  118. package/documentation/print-linter-issue.d.ts +1 -0
  119. package/documentation/print-linter-issue.js +71 -0
  120. package/documentation/print-linter-wiki.js +219 -34
  121. package/documentation/print-linting-and-testing-wiki.js +2 -4
  122. package/documentation/print-normalized-ast-wiki.js +3 -3
  123. package/documentation/print-query-wiki.js +1 -2
  124. package/documentation/print-readme.js +24 -1
  125. package/documentation/print-search-wiki.js +1 -2
  126. package/linter/linter-executor.d.ts +3 -1
  127. package/linter/linter-executor.js +3 -2
  128. package/linter/linter-format.d.ts +67 -7
  129. package/linter/linter-format.js +12 -1
  130. package/linter/linter-rules.d.ts +155 -16
  131. package/linter/linter-rules.js +12 -4
  132. package/linter/linter-tags.d.ts +80 -0
  133. package/linter/linter-tags.js +85 -0
  134. package/linter/rules/absolute-path.d.ts +71 -0
  135. package/linter/rules/absolute-path.js +177 -0
  136. package/linter/rules/deprecated-functions.d.ts +43 -0
  137. package/linter/rules/deprecated-functions.js +58 -0
  138. package/linter/rules/{2-file-path-validity.d.ts → file-path-validity.d.ts} +16 -6
  139. package/linter/rules/{2-file-path-validity.js → file-path-validity.js} +21 -13
  140. package/linter/rules/naming-convention.d.ts +71 -0
  141. package/linter/rules/naming-convention.js +164 -0
  142. package/linter/rules/seeded-randomness.d.ts +65 -0
  143. package/linter/rules/seeded-randomness.js +122 -0
  144. package/linter/rules/unused-definition.d.ts +41 -0
  145. package/linter/rules/unused-definition.js +105 -0
  146. package/package.json +4 -1
  147. package/queries/base-query-format.d.ts +2 -0
  148. package/queries/catalog/call-context-query/call-context-query-executor.d.ts +1 -1
  149. package/queries/catalog/call-context-query/call-context-query-executor.js +2 -2
  150. package/queries/catalog/cluster-query/cluster-query-format.d.ts +1 -1
  151. package/queries/catalog/config-query/config-query-executor.d.ts +1 -1
  152. package/queries/catalog/config-query/config-query-executor.js +2 -3
  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 +2 -2
  155. package/queries/catalog/control-flow-query/control-flow-query-format.d.ts +1 -1
  156. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.d.ts +1 -1
  157. package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +1 -1
  158. package/queries/catalog/dependencies-query/dependencies-query-executor.js +4 -116
  159. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +1 -1
  160. package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +1 -1
  161. package/queries/catalog/id-map-query/id-map-query-format.d.ts +1 -1
  162. package/queries/catalog/lineage-query/lineage-query-format.d.ts +1 -1
  163. package/queries/catalog/linter-query/linter-query-executor.d.ts +1 -1
  164. package/queries/catalog/linter-query/linter-query-executor.js +2 -2
  165. package/queries/catalog/linter-query/linter-query-format.d.ts +1 -1
  166. package/queries/catalog/linter-query/linter-query-format.js +16 -12
  167. package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +1 -1
  168. package/queries/catalog/origin-query/origin-query-format.d.ts +1 -1
  169. package/queries/catalog/project-query/project-query-format.d.ts +1 -1
  170. package/queries/catalog/resolve-value-query/resolve-value-query-executor.d.ts +1 -1
  171. package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +2 -2
  172. package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +1 -1
  173. package/queries/catalog/search-query/search-query-executor.d.ts +1 -1
  174. package/queries/catalog/search-query/search-query-executor.js +2 -2
  175. package/queries/catalog/search-query/search-query-format.d.ts +1 -1
  176. package/queries/catalog/static-slice-query/static-slice-query-executor.d.ts +1 -1
  177. package/queries/catalog/static-slice-query/static-slice-query-executor.js +2 -2
  178. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +1 -1
  179. package/queries/query.d.ts +15 -15
  180. package/r-bridge/lang-4.x/ast/parser/json/parser.d.ts +2 -1
  181. package/r-bridge/lang-4.x/ast/parser/json/parser.js +4 -2
  182. package/r-bridge/lang-4.x/convert-values.js +2 -1
  183. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.d.ts +3 -1
  184. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +4 -4
  185. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.d.ts +1 -1
  186. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +7 -5
  187. package/r-bridge/shell.d.ts +3 -2
  188. package/r-bridge/shell.js +4 -5
  189. package/search/flowr-search-builder.d.ts +6 -2
  190. package/search/flowr-search-builder.js +7 -0
  191. package/search/flowr-search-filters.d.ts +32 -8
  192. package/search/flowr-search-filters.js +42 -15
  193. package/search/flowr-search.d.ts +4 -0
  194. package/search/search-executor/search-enrichers.d.ts +7 -3
  195. package/search/search-executor/search-enrichers.js +29 -20
  196. package/search/search-executor/search-generators.js +1 -1
  197. package/search/search-executor/search-transformer.d.ts +2 -0
  198. package/search/search-executor/search-transformer.js +10 -1
  199. package/slicing/static/static-slicer.d.ts +1 -1
  200. package/slicing/static/static-slicer.js +2 -3
  201. package/statistics/statistics.d.ts +3 -1
  202. package/statistics/statistics.js +5 -4
  203. package/util/containers.d.ts +12 -9
  204. package/util/containers.js +12 -9
  205. package/util/objects.d.ts +5 -4
  206. package/util/range.d.ts +5 -1
  207. package/util/range.js +11 -3
  208. package/util/text/strings.d.ts +6 -0
  209. package/util/text/strings.js +35 -0
  210. package/util/version.js +1 -1
  211. package/linter/rules/1-deprecated-functions.d.ts +0 -34
  212. package/linter/rules/1-deprecated-functions.js +0 -54
@@ -4,6 +4,7 @@ import type { PipelineOutput } from '../core/steps/pipeline/pipeline';
4
4
  import { DEFAULT_DATAFLOW_PIPELINE } from '../core/steps/pipeline/default-pipelines';
5
5
  import type { RShell } from '../r-bridge/shell';
6
6
  import type { FeatureSelection, FeatureStatistics } from './features/feature';
7
+ import type { FlowrConfigOptions } from '../config';
7
8
  /**
8
9
  * By default, {@link extractUsageStatistics} requires a generator, but sometimes you already know all the files
9
10
  * that you want to process. This function simply reps your requests as a generator.
@@ -14,13 +15,14 @@ type DataflowResult = PipelineOutput<typeof DEFAULT_DATAFLOW_PIPELINE>;
14
15
  * Extract all wanted statistic information from a set of requests using the presented R session.
15
16
  *
16
17
  * @param shell - The R session to use
18
+ * @param config - The flowr config
17
19
  * @param onRequest - A callback that is called at the beginning of each request, this may be used to debug the requests.
18
20
  * @param features - The features to extract (see {@link allFeatureNames}).
19
21
  * @param requests - The requests to extract the features from. May generate them on demand (e.g., by traversing a folder).
20
22
  * If your request is statically known, you can use {@link staticRequests} to create this generator.
21
23
  * @param rootPath - The root path to the project, this is used to relativize the file paths in the statistics.
22
24
  */
23
- export declare function extractUsageStatistics<T extends RParseRequestFromText | RParseRequestFromFile>(shell: RShell, onRequest: (request: T) => void, features: FeatureSelection, requests: AsyncGenerator<T>, rootPath?: string): Promise<{
25
+ export declare function extractUsageStatistics<T extends RParseRequestFromText | RParseRequestFromFile>(shell: RShell, config: FlowrConfigOptions, onRequest: (request: T) => void, features: FeatureSelection, requests: AsyncGenerator<T>, rootPath?: string): Promise<{
24
26
  features: FeatureStatistics;
25
27
  meta: MetaStatistics;
26
28
  outputs: Map<T, DataflowResult>;
@@ -30,13 +30,14 @@ function staticRequests(...requests) {
30
30
  * Extract all wanted statistic information from a set of requests using the presented R session.
31
31
  *
32
32
  * @param shell - The R session to use
33
+ * @param config - The flowr config
33
34
  * @param onRequest - A callback that is called at the beginning of each request, this may be used to debug the requests.
34
35
  * @param features - The features to extract (see {@link allFeatureNames}).
35
36
  * @param requests - The requests to extract the features from. May generate them on demand (e.g., by traversing a folder).
36
37
  * If your request is statically known, you can use {@link staticRequests} to create this generator.
37
38
  * @param rootPath - The root path to the project, this is used to relativize the file paths in the statistics.
38
39
  */
39
- async function extractUsageStatistics(shell, onRequest, features, requests, rootPath) {
40
+ async function extractUsageStatistics(shell, config, onRequest, features, requests, rootPath) {
40
41
  let result = initializeFeatureStatistics();
41
42
  const meta = (0, meta_statistics_1.initialMetaStatistics)();
42
43
  const outputs = new Map();
@@ -46,7 +47,7 @@ async function extractUsageStatistics(shell, onRequest, features, requests, root
46
47
  const suffix = request.request === 'file' ? request.content.replace(new RegExp('^' + (rootPath ?? '')), '') : undefined;
47
48
  try {
48
49
  let output;
49
- ({ stats: result, output } = await extractSingle(result, shell, request, features, suffix));
50
+ ({ stats: result, output } = await extractSingle(result, shell, request, features, suffix, config));
50
51
  outputs.set(request, output);
51
52
  processMetaOnSuccessful(meta, request);
52
53
  meta.numberOfNormalizedNodes.push(output.normalize.idMap.size);
@@ -80,10 +81,10 @@ function processMetaOnSuccessful(meta, request) {
80
81
  }
81
82
  }
82
83
  const parser = new xmldom_1.DOMParser();
83
- async function extractSingle(result, shell, request, features, suffixFilePath) {
84
+ async function extractSingle(result, shell, request, features, suffixFilePath, config) {
84
85
  const slicerOutput = await new pipeline_executor_1.PipelineExecutor(default_pipelines_1.DEFAULT_DATAFLOW_PIPELINE, {
85
86
  request, parser: shell
86
- }).allRemainingSteps();
87
+ }, config).allRemainingSteps();
87
88
  // retrieve parsed xml through (legacy) xmlparsedata
88
89
  const suffix = request.request === 'file' ? ', encoding="utf-8"' : '';
89
90
  shell.sendCommands(`try(flowr_parsed<-parse(${request.request}=${JSON.stringify(request.content)},keep.source=TRUE${suffix}),silent=FALSE)`, 'try(flowr_output<-xmlparsedata::xml_parse_data(flowr_parsed,includeText=TRUE,pretty=FALSE),silent=FALSE)');
@@ -13,7 +13,7 @@ export declare function getAccessOperands<OtherInfo>(args: readonly RFunctionArg
13
13
  accessArg: RArgument<OtherInfo & ParentInformation> | undefined;
14
14
  };
15
15
  /**
16
- * Resolves the passed name in the passed environment and returns the indicesCollection of the resolved definitions.
16
+ * Resolves the passed name within the passed environment and returns the indicesCollection of the resolved definitions.
17
17
  *
18
18
  * @param name - Name to resolve
19
19
  * @param environment - Environment in which name is resolved
@@ -25,9 +25,10 @@ export declare function resolveIndicesByName(name: Identifier, environment: REnv
25
25
  *
26
26
  * If no indices could be found that match the `accessArg`, the original indices are returned as overapproximation.
27
27
  *
28
- * @param accessedArg - The argument to resolve
29
- * @param accessArg - The argument which is used to filter the indices
30
- * @param environment - The environment in which {@link accessedArg} is resolved
28
+ * @param accessedArg - The argument to resolve
29
+ * @param accessArg - The argument which is used to filter the indices
30
+ * @param environment - The environment in which {@link accessedArg} is resolved
31
+ * @param isIndexBasedAccess - Whether the access is index-based (e.g. `x[1]`) or name-based (e.g. `x$name`)
31
32
  * @returns The filtered {@link ContainerIndicesCollection} of the resolved {@link accessedArg}
32
33
  */
33
34
  export declare function resolveSingleIndex(accessedArg: {
@@ -38,8 +39,9 @@ export declare function resolveSingleIndex(accessedArg: {
38
39
  /**
39
40
  * Filters the single indices of the {@link indicesCollection} according to the lexeme of the {@link accessArg}.
40
41
  *
41
- * @param indicesCollection - The {@link ContainerIndicesCollection} to filter
42
- * @param accessArg - The argument which is used to filter {@link indicesCollection}
42
+ * @param indicesCollection - The {@link ContainerIndicesCollection} to filter
43
+ * @param accessArg - The argument which is used to filter {@link indicesCollection}
44
+ * @param isIndexBasedAccess - Whether the access is index-based (e.g. `x[1]`) or name-based (e.g. `x$name`)
43
45
  * @returns The filtered copy of {@link indicesCollection}
44
46
  */
45
47
  export declare function filterIndices(indicesCollection: ContainerIndicesCollection, accessArg: {
@@ -54,8 +56,9 @@ export declare function filterIndices(indicesCollection: ContainerIndicesCollect
54
56
  * ```
55
57
  * would result in a list with the index `credentials`, which has the subIndex `username`.
56
58
  *
57
- * @param accessedArg - The top level argument that is accessed
58
- * @param leafIndices - The index at the end of the nested access i.e. `c` in `a$b$c`.
59
+ * @param accessedArg - The top level argument that is accessed
60
+ * @param leafIndices - The index at the end of the nested access i.e. `c` in `a$b$c`.
61
+ * @param constructIdentifier - A function that constructs the identifier for the index from the argument
59
62
  * @returns The constructed nested access
60
63
  */
61
64
  export declare function constructNestedAccess<OtherInfo>(accessedArg: RAccess<OtherInfo & ParentInformation>, leafIndices: ContainerIndices, constructIdentifier: (arg: RArgument<OtherInfo & ParentInformation>) => IndexIdentifier): ContainerIndices[];
@@ -63,6 +66,6 @@ export declare function constructNestedAccess<OtherInfo>(accessedArg: RAccess<Ot
63
66
  * Adds the passed list of {@link leafSubIndices} to the leaf (sub-)indices of {@link indicesCollection}.
64
67
  *
65
68
  * @param indicesCollection - Indices where to add the sub indices.
66
- * @param leafSubIndices - Indices that are added to the leaf indices.
69
+ * @param leafSubIndices - Indices that are added to the leaf indices.
67
70
  */
68
71
  export declare function addSubIndicesToLeafIndices(indicesCollection: ContainerIndices[], leafSubIndices: ContainerIndices[]): ContainerIndices[];
@@ -20,7 +20,7 @@ function getAccessOperands(args) {
20
20
  return { accessedArg, accessArg };
21
21
  }
22
22
  /**
23
- * Resolves the passed name in the passed environment and returns the indicesCollection of the resolved definitions.
23
+ * Resolves the passed name within the passed environment and returns the indicesCollection of the resolved definitions.
24
24
  *
25
25
  * @param name - Name to resolve
26
26
  * @param environment - Environment in which name is resolved
@@ -35,9 +35,10 @@ function resolveIndicesByName(name, environment) {
35
35
  *
36
36
  * If no indices could be found that match the `accessArg`, the original indices are returned as overapproximation.
37
37
  *
38
- * @param accessedArg - The argument to resolve
39
- * @param accessArg - The argument which is used to filter the indices
40
- * @param environment - The environment in which {@link accessedArg} is resolved
38
+ * @param accessedArg - The argument to resolve
39
+ * @param accessArg - The argument which is used to filter the indices
40
+ * @param environment - The environment in which {@link accessedArg} is resolved
41
+ * @param isIndexBasedAccess - Whether the access is index-based (e.g. `x[1]`) or name-based (e.g. `x$name`)
41
42
  * @returns The filtered {@link ContainerIndicesCollection} of the resolved {@link accessedArg}
42
43
  */
43
44
  function resolveSingleIndex(accessedArg, accessArg, environment, isIndexBasedAccess) {
@@ -55,8 +56,9 @@ function resolveSingleIndex(accessedArg, accessArg, environment, isIndexBasedAcc
55
56
  /**
56
57
  * Filters the single indices of the {@link indicesCollection} according to the lexeme of the {@link accessArg}.
57
58
  *
58
- * @param indicesCollection - The {@link ContainerIndicesCollection} to filter
59
- * @param accessArg - The argument which is used to filter {@link indicesCollection}
59
+ * @param indicesCollection - The {@link ContainerIndicesCollection} to filter
60
+ * @param accessArg - The argument which is used to filter {@link indicesCollection}
61
+ * @param isIndexBasedAccess - Whether the access is index-based (e.g. `x[1]`) or name-based (e.g. `x$name`)
60
62
  * @returns The filtered copy of {@link indicesCollection}
61
63
  */
62
64
  function filterIndices(indicesCollection, accessArg, isIndexBasedAccess) {
@@ -83,8 +85,9 @@ function filterIndices(indicesCollection, accessArg, isIndexBasedAccess) {
83
85
  * ```
84
86
  * would result in a list with the index `credentials`, which has the subIndex `username`.
85
87
  *
86
- * @param accessedArg - The top level argument that is accessed
87
- * @param leafIndices - The index at the end of the nested access i.e. `c` in `a$b$c`.
88
+ * @param accessedArg - The top level argument that is accessed
89
+ * @param leafIndices - The index at the end of the nested access i.e. `c` in `a$b$c`.
90
+ * @param constructIdentifier - A function that constructs the identifier for the index from the argument
88
91
  * @returns The constructed nested access
89
92
  */
90
93
  function constructNestedAccess(accessedArg, leafIndices, constructIdentifier) {
@@ -116,7 +119,7 @@ function constructNestedAccess(accessedArg, leafIndices, constructIdentifier) {
116
119
  * Adds the passed list of {@link leafSubIndices} to the leaf (sub-)indices of {@link indicesCollection}.
117
120
  *
118
121
  * @param indicesCollection - Indices where to add the sub indices.
119
- * @param leafSubIndices - Indices that are added to the leaf indices.
122
+ * @param leafSubIndices - Indices that are added to the leaf indices.
120
123
  */
121
124
  function addSubIndicesToLeafIndices(indicesCollection, leafSubIndices) {
122
125
  const result = [];
package/util/objects.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { DeepPartial, DeepRequired } from 'ts-essentials';
1
+ import type { DeepPartial, DeepReadonly, DeepRequired } from 'ts-essentials';
2
2
  /**
3
3
  * checks if `item` is an object (it may be an array, ...)
4
4
  */
@@ -6,13 +6,14 @@ export declare function isObjectOrArray(item: unknown): boolean;
6
6
  export type MergeableRecord = Record<string, unknown>;
7
7
  export type MergeableArray = unknown[];
8
8
  export type Mergeable = MergeableRecord | MergeableArray;
9
+ type OrReadonly<T> = T | Readonly<T> | DeepReadonly<T>;
9
10
  /**
10
11
  * Given two objects deeply merges them, if an object is an array it will merge the array values!
11
12
  * Guarantees some type safety by requiring objects to merge to be from the same type (allows undefined)
12
13
  */
13
- export declare function deepMergeObject<T extends Mergeable>(base: Required<T>, addon?: T | DeepPartial<T> | Partial<T>): Required<T>;
14
- export declare function deepMergeObject<T extends Mergeable>(base: DeepRequired<T>, addon?: T | DeepPartial<T> | Partial<T>): DeepRequired<T>;
15
- export declare function deepMergeObject<T extends Mergeable>(base: T, addon?: DeepPartial<T> | Partial<T>): T;
14
+ export declare function deepMergeObject<T extends Mergeable>(base: Required<OrReadonly<T>>, addon?: T | DeepPartial<T> | Partial<T>): Required<T>;
15
+ export declare function deepMergeObject<T extends Mergeable>(base: DeepRequired<OrReadonly<T>>, addon?: T | DeepPartial<T> | Partial<T>): DeepRequired<T>;
16
+ export declare function deepMergeObject<T extends Mergeable>(base: OrReadonly<T>, addon?: DeepPartial<T> | Partial<T>): T;
16
17
  export declare function deepMergeObject(base: Mergeable, addon: Mergeable): Mergeable;
17
18
  export declare function deepMergeObject(base?: Mergeable, addon?: Mergeable): Mergeable | undefined;
18
19
  type Defined<T> = Exclude<T, undefined>;
package/util/range.d.ts CHANGED
@@ -45,7 +45,7 @@ export declare function getRangeEnd(p: SourceRange | undefined): SourcePosition
45
45
  * @param ec - end column
46
46
  */
47
47
  export declare function rangeFrom(sl: number | string, sc: number | string, el: number | string, ec: number | string): SourceRange;
48
- export declare function mergeRanges(...rs: SourceRange[]): SourceRange;
48
+ export declare function mergeRanges(...rs: (SourceRange | undefined)[]): SourceRange;
49
49
  /**
50
50
  * @returns true iff `r1` starts and ends before `r2` starts (i.e., if `r1` and `r2` do not overlap and `r1` comes before `r2`
51
51
  */
@@ -64,3 +64,7 @@ export declare function addRanges([r1sl, r1sc, r1el, r1ec]: SourceRange, [r2sl,
64
64
  * @returns a positive number if `r1` comes after `r2`, a negative number if `r1` comes before `r2`, and `0` if they are equal
65
65
  */
66
66
  export declare function rangeCompare([r1sl, r1sc, ,]: SourceRange, [r2sl, r2sc, ,]: SourceRange): number;
67
+ /**
68
+ * Checks if the first range is a subset of the second range.
69
+ */
70
+ export declare function rangeIsSubsetOf([r1sl, r1sc, r1el, r1ec]: SourceRange, [r2sl, r2sc, r2el, r2ec]: SourceRange): boolean;
package/util/range.js CHANGED
@@ -8,6 +8,7 @@ exports.rangeStartsCompletelyBefore = rangeStartsCompletelyBefore;
8
8
  exports.rangesOverlap = rangesOverlap;
9
9
  exports.addRanges = addRanges;
10
10
  exports.rangeCompare = rangeCompare;
11
+ exports.rangeIsSubsetOf = rangeIsSubsetOf;
11
12
  const assert_1 = require("./assert");
12
13
  function getRangeStart(p) {
13
14
  return p === undefined ? undefined : [p[0], p[1]];
@@ -27,11 +28,12 @@ function rangeFrom(sl, sc, el, ec) {
27
28
  return [Number(sl), Number(sc), Number(el), Number(ec)];
28
29
  }
29
30
  function mergeRanges(...rs) {
30
- (0, assert_1.guard)(rs.length > 0, 'Cannot merge no ranges');
31
- return rs.reduce(([sl, sc, el, ec], [nsl, nsc, nel, nec]) => [
31
+ const rsSafe = rs.filter(assert_1.isNotUndefined);
32
+ (0, assert_1.guard)(rsSafe.length > 0, 'Cannot merge no ranges');
33
+ return rsSafe.reduce(([sl, sc, el, ec], [nsl, nsc, nel, nec]) => [
32
34
  ...(sl < nsl || (sl === nsl && sc < nsc) ? [sl, sc] : [nsl, nsc]),
33
35
  ...(el > nel || (el === nel && ec > nec) ? [el, ec] : [nel, nec])
34
- ], rs[0]);
36
+ ], rsSafe[0]);
35
37
  }
36
38
  /**
37
39
  * @returns true iff `r1` starts and ends before `r2` starts (i.e., if `r1` and `r2` do not overlap and `r1` comes before `r2`
@@ -64,4 +66,10 @@ function rangeCompare([r1sl, r1sc, ,], [r2sl, r2sc, ,]) {
64
66
  return r1sl - r2sl;
65
67
  }
66
68
  }
69
+ /**
70
+ * Checks if the first range is a subset of the second range.
71
+ */
72
+ function rangeIsSubsetOf([r1sl, r1sc, r1el, r1ec], [r2sl, r2sc, r2el, r2ec]) {
73
+ return r1sl >= r2sl && r1sc >= r2sc && r1el <= r2el && r1ec <= r2ec;
74
+ }
67
75
  //# sourceMappingURL=range.js.map
@@ -19,3 +19,9 @@ export declare function joinWithLast(strs: readonly string[], { join, last, join
19
19
  last?: string;
20
20
  joinTwo?: string;
21
21
  }): string;
22
+ /**
23
+ * Check if the given path is an absolute path.
24
+ */
25
+ export declare function isAbsolutePath(p: string, regex: RegExp | undefined): boolean;
26
+ /** collect '-' at the start until '[' or '(' is reached, then drop the same from the end if present otherwise return the value as is */
27
+ export declare function dropRawStringSurround(value: string): string;
@@ -1,9 +1,15 @@
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.startAndEndsWith = startAndEndsWith;
4
7
  exports.withoutWhitespace = withoutWhitespace;
5
8
  exports.longestCommonPrefix = longestCommonPrefix;
6
9
  exports.joinWithLast = joinWithLast;
10
+ exports.isAbsolutePath = isAbsolutePath;
11
+ exports.dropRawStringSurround = dropRawStringSurround;
12
+ const path_1 = __importDefault(require("path"));
7
13
  /**
8
14
  * Check if the given string starts and ends with the given letter
9
15
  */
@@ -51,4 +57,33 @@ function joinWithLast(strs, { join = ', ', last = ', and ', joinTwo = ' and ' }
51
57
  }
52
58
  return strs.slice(0, -1).join(join) + last + strs[strs.length - 1];
53
59
  }
60
+ /**
61
+ * Check if the given path is an absolute path.
62
+ */
63
+ function isAbsolutePath(p, regex) {
64
+ return regex?.test(p) || p.startsWith('/') || p.startsWith('\\') ||
65
+ /[a-zA-Z]:[\\/]/.test(p) || // Windows absolute path
66
+ path_1.default.normalize(p + '/') === path_1.default.normalize(path_1.default.resolve(p) + '/');
67
+ }
68
+ const CorrespondingClose = {
69
+ '(': ')',
70
+ '[': ']',
71
+ '{': '}'
72
+ };
73
+ /** collect '-' at the start until '[' or '(' is reached, then drop the same from the end if present otherwise return the value as is */
74
+ function dropRawStringSurround(value) {
75
+ const dashCount = value.match(/^-*/)?.[0].length ?? 0;
76
+ const open = value[dashCount];
77
+ if (open === '[' || open === '(' || open === '{') {
78
+ // if the value starts with a dash and then a bracket, we drop the dashes at the end
79
+ const end = value.endsWith(CorrespondingClose[open] + '-'.repeat(dashCount)) ? dashCount : undefined;
80
+ if (end !== undefined) {
81
+ return value.slice(dashCount + 1, -end - 1);
82
+ }
83
+ else {
84
+ return value;
85
+ }
86
+ }
87
+ return value;
88
+ }
54
89
  //# sourceMappingURL=strings.js.map
package/util/version.js CHANGED
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.flowrVersion = flowrVersion;
4
4
  const semver_1 = require("semver");
5
5
  // this is automatically replaced with the current version by release-it
6
- const version = '2.2.15';
6
+ const version = '2.2.16';
7
7
  function flowrVersion() {
8
8
  return new semver_1.SemVer(version);
9
9
  }
@@ -1,34 +0,0 @@
1
- import type { LintingResult } from '../linter-format';
2
- import { LintingCertainty } from '../linter-format';
3
- import type { MergeableRecord } from '../../util/objects';
4
- import type { SourceRange } from '../../util/range';
5
- import type { Identifier } from '../../dataflow/environments/identifier';
6
- export interface DeprecatedFunctionsResult extends LintingResult {
7
- function: string;
8
- range: SourceRange;
9
- }
10
- export interface DeprecatedFunctionsConfig extends MergeableRecord {
11
- /**
12
- * The list of function names that should be marked as deprecated.
13
- */
14
- deprecatedFunctions: string[];
15
- }
16
- export interface DeprecatedFunctionsMetadata extends MergeableRecord {
17
- totalRelevant: number;
18
- totalNotDeprecated: number;
19
- }
20
- export declare const R1_DEPRECATED_FUNCTIONS: {
21
- readonly createSearch: (_config: DeprecatedFunctionsConfig) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["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/search-executor/search-enrichers").EnrichedFlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>;
22
- 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: DeprecatedFunctionsConfig) => {
23
- results: {
24
- certainty: LintingCertainty.Definitely;
25
- function: Identifier;
26
- range: SourceRange;
27
- }[];
28
- '.meta': DeprecatedFunctionsMetadata;
29
- };
30
- readonly prettyPrint: (result: DeprecatedFunctionsResult) => string;
31
- readonly defaultConfig: {
32
- readonly deprecatedFunctions: ["all_equal", "arrange_all", "distinct_all", "filter_all", "group_by_all", "summarise_all", "mutate_all", "select_all", "vars", "all_vars", "id", "failwith", "select_vars", "rename_vars", "select_var", "current_vars", "bench_tbls", "compare_tbls", "compare_tbls2", "eval_tbls", "eval_tbls2", "location", "changes", "combine", "do", "funs", "add_count_", "add_tally_", "arrange_", "count_", "distinct_", "do_", "filter_", "funs_", "group_by_", "group_indices_", "mutate_", "tally_", "transmute_", "rename_", "rename_vars_", "select_", "select_vars_", "slice_", "summarise_", "summarize_", "summarise_each", "src_local", "tbl_df", "add_rownames", "group_nest", "group_split", "with_groups", "nest_by", "progress_estimated", "recode", "sample_n", "top_n", "transmute", "fct_explicit_na", "aes_", "aes_auto", "annotation_logticks", "is.Coord", "coord_flip", "coord_map", "is.facet", "fortify", "is.ggproto", "guide_train", "is.ggplot", "qplot", "is.theme", "gg_dep", "liply", "isplit2", "list_along", "cross", "invoke", "at_depth", "prepend", "rerun", "splice", "`%@%`", "rbernoulli", "rdunif", "when", "update_list", "map_raw", "accumulate", "reduce_right", "flatten", "map_dfr", "as_vector", "transpose", "melt_delim", "melt_fwf", "melt_table", "read_table2", "str_interp", "as_tibble", "data_frame", "tibble_", "data_frame_", "lst_", "as_data_frame", "as.tibble", "frame_data", "trunc_mat", "is.tibble", "tidy_names", "set_tidy_names", "repair_names", "extract_numeric", "complete_", "drop_na_", "expand_", "crossing_", "nesting_", "extract_", "fill_", "gather_", "nest_", "separate_rows_", "separate_", "spread_", "unite_", "unnest_", "extract", "gather", "nest_legacy", "separate_rows", "separate", "spread"];
33
- };
34
- };
@@ -1,54 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.R1_DEPRECATED_FUNCTIONS = void 0;
4
- const linter_format_1 = require("../linter-format");
5
- const flowr_search_builder_1 = require("../../search/flowr-search-builder");
6
- const dfg_1 = require("../../util/mermaid/dfg");
7
- const search_enrichers_1 = require("../../search/search-executor/search-enrichers");
8
- exports.R1_DEPRECATED_FUNCTIONS = {
9
- createSearch: (_config) => flowr_search_builder_1.Q.all().with(search_enrichers_1.Enrichment.CallTargets),
10
- processSearchResult: (elements, config) => {
11
- const metadata = {
12
- totalRelevant: 0,
13
- totalNotDeprecated: 0
14
- };
15
- return {
16
- results: elements.getElements()
17
- .flatMap(element => {
18
- const targets = (0, search_enrichers_1.enrichmentContent)(element, search_enrichers_1.Enrichment.CallTargets).targets;
19
- // if there is a call target that is not built-in (ie a custom function), we don't want to mark it as deprecated
20
- // eventually we'd want to solve this with an argument to the CallTargets enrichment like satisfiesCallTargets does!
21
- if (targets.some(t => typeof t !== 'string')) {
22
- return [];
23
- }
24
- return targets.map(target => {
25
- metadata.totalRelevant++;
26
- return {
27
- range: element.node.info.fullRange,
28
- target: target
29
- };
30
- });
31
- })
32
- .filter(element => {
33
- if (config.deprecatedFunctions.includes(element.target)) {
34
- return true;
35
- }
36
- else {
37
- metadata.totalNotDeprecated++;
38
- return false;
39
- }
40
- })
41
- .map(element => ({
42
- certainty: linter_format_1.LintingCertainty.Definitely,
43
- function: element.target,
44
- range: element.range
45
- })),
46
- '.meta': metadata
47
- };
48
- },
49
- prettyPrint: result => `Function \`${result.function}\` at ${(0, dfg_1.formatRange)(result.range)}`,
50
- defaultConfig: {
51
- deprecatedFunctions: ['all_equal', 'arrange_all', 'distinct_all', 'filter_all', 'group_by_all', 'summarise_all', 'mutate_all', 'select_all', 'vars', 'all_vars', 'id', 'failwith', 'select_vars', 'rename_vars', 'select_var', 'current_vars', 'bench_tbls', 'compare_tbls', 'compare_tbls2', 'eval_tbls', 'eval_tbls2', 'location', 'changes', 'combine', 'do', 'funs', 'add_count_', 'add_tally_', 'arrange_', 'count_', 'distinct_', 'do_', 'filter_', 'funs_', 'group_by_', 'group_indices_', 'mutate_', 'tally_', 'transmute_', 'rename_', 'rename_vars_', 'select_', 'select_vars_', 'slice_', 'summarise_', 'summarize_', 'summarise_each', 'src_local', 'tbl_df', 'add_rownames', 'group_nest', 'group_split', 'with_groups', 'nest_by', 'progress_estimated', 'recode', 'sample_n', 'top_n', 'transmute', 'fct_explicit_na', 'aes_', 'aes_auto', 'annotation_logticks', 'is.Coord', 'coord_flip', 'coord_map', 'is.facet', 'fortify', 'is.ggproto', 'guide_train', 'is.ggplot', 'qplot', 'is.theme', 'gg_dep', 'liply', 'isplit2', 'list_along', 'cross', 'invoke', 'at_depth', 'prepend', 'rerun', 'splice', '`%@%`', 'rbernoulli', 'rdunif', 'when', 'update_list', 'map_raw', 'accumulate', 'reduce_right', 'flatten', 'map_dfr', 'as_vector', 'transpose', 'melt_delim', 'melt_fwf', 'melt_table', 'read_table2', 'str_interp', 'as_tibble', 'data_frame', 'tibble_', 'data_frame_', 'lst_', 'as_data_frame', 'as.tibble', 'frame_data', 'trunc_mat', 'is.tibble', 'tidy_names', 'set_tidy_names', 'repair_names', 'extract_numeric', 'complete_', 'drop_na_', 'expand_', 'crossing_', 'nesting_', 'extract_', 'fill_', 'gather_', 'nest_', 'separate_rows_', 'separate_', 'spread_', 'unite_', 'unnest_', 'extract', 'gather', 'nest_legacy', 'separate_rows', 'separate', 'spread',]
52
- }
53
- };
54
- //# sourceMappingURL=1-deprecated-functions.js.map