@eagleoutice/flowr 2.13.8 → 2.13.10

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 (152) hide show
  1. package/config.d.ts +50 -2
  2. package/config.js +37 -6
  3. package/dataflow/cluster.js +48 -24
  4. package/dataflow/environments/apply-kill.js +4 -4
  5. package/dataflow/environments/built-in-props.d.ts +28 -4
  6. package/dataflow/environments/built-in-props.js +31 -8
  7. package/dataflow/environments/built-in.d.ts +7 -2
  8. package/dataflow/environments/built-in.js +10 -12
  9. package/dataflow/environments/default-builtin-config.d.ts +76 -6
  10. package/dataflow/environments/default-builtin-config.js +39 -16
  11. package/dataflow/environments/environment.d.ts +16 -0
  12. package/dataflow/environments/environment.js +70 -18
  13. package/dataflow/environments/identifier.d.ts +6 -0
  14. package/dataflow/environments/identifier.js +18 -5
  15. package/dataflow/environments/query-fn-props.js +34 -2
  16. package/dataflow/environments/reference-to-maybe.js +1 -1
  17. package/dataflow/eval/resolve/alias-tracking.js +45 -1
  18. package/dataflow/eval/resolve/resolve-argument.js +25 -17
  19. package/dataflow/eval/resolve/resolve-strings.d.ts +17 -0
  20. package/dataflow/eval/resolve/resolve-strings.js +16 -9
  21. package/dataflow/eval/resolve/resolve.js +3 -1
  22. package/dataflow/graph/call-graph.d.ts +7 -0
  23. package/dataflow/graph/call-graph.js +103 -0
  24. package/dataflow/graph/df-helper.d.ts +2 -0
  25. package/dataflow/graph/graph.d.ts +6 -8
  26. package/dataflow/graph/graph.js +21 -6
  27. package/dataflow/internal/linker.d.ts +5 -5
  28. package/dataflow/internal/linker.js +31 -92
  29. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +2 -2
  30. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +3 -9
  31. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +4 -30
  32. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +2 -1
  33. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +1 -1
  34. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +7 -1
  35. package/dataflow/internal/process/functions/call/built-in/built-in-load.js +3 -3
  36. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.d.ts +1 -1
  37. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +5 -1
  38. package/dataflow/internal/process/functions/call/built-in/built-in-with.d.ts +2 -2
  39. package/dataflow/internal/process/functions/call/built-in/built-in-with.js +5 -6
  40. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +32 -14
  41. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +16 -4
  42. package/dataflow/internal/process/functions/call/known-call-handling.js +29 -8
  43. package/documentation/doc-util/doc-sigdb.d.ts +9 -0
  44. package/documentation/doc-util/doc-sigdb.js +32 -0
  45. package/documentation/wiki-interface.js +13 -2
  46. package/documentation/wiki-query.js +3 -0
  47. package/documentation/wiki-signature-database.js +2 -5
  48. package/gas.d.ts +6 -0
  49. package/gas.js +7 -1
  50. package/package.json +2 -2
  51. package/project/attached-packages.d.ts +13 -0
  52. package/project/attached-packages.js +30 -0
  53. package/project/context/flowr-analyzer-context.d.ts +15 -0
  54. package/project/context/flowr-analyzer-context.js +14 -3
  55. package/project/context/flowr-analyzer-files-context.d.ts +11 -0
  56. package/project/context/flowr-analyzer-files-context.js +3 -0
  57. package/project/context/flowr-analyzer-incremental-analysis-context.d.ts +4 -0
  58. package/project/context/flowr-analyzer-incremental-analysis-context.js +69 -0
  59. package/project/dependency-version-space.d.ts +45 -8
  60. package/project/dependency-version-space.js +86 -26
  61. package/project/plugins/file-plugins/files/flowr-namespace-file.js +52 -24
  62. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-library-plugin.d.ts +22 -0
  63. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-library-plugin.js +101 -0
  64. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +30 -11
  65. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +79 -37
  66. package/project/plugins/package-version-plugins/package.d.ts +2 -0
  67. package/project/plugins/package-version-plugins/package.js +4 -0
  68. package/project/plugins/plugin-registry.d.ts +2 -1
  69. package/project/plugins/plugin-registry.js +2 -0
  70. package/project/sigdb/manifest.js +9 -5
  71. package/project/sigdb/signature-match.d.ts +5 -18
  72. package/project/sigdb/signature-match.js +5 -18
  73. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.d.ts +4 -2
  74. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +25 -0
  75. package/queries/catalog/call-graph-query/call-graph-query-executor.js +3 -1
  76. package/queries/catalog/call-graph-query/call-graph-query-format.d.ts +4 -0
  77. package/queries/catalog/call-graph-query/call-graph-query-format.js +4 -0
  78. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.js +11 -1
  79. package/queries/catalog/dependencies-query/dependencies-query-executor.js +13 -5
  80. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +27 -1
  81. package/queries/catalog/dependencies-query/dependencies-query-format.js +69 -7
  82. package/queries/catalog/dependencies-query/function-info/library-functions.js +9 -2
  83. package/queries/catalog/dependencies-query/function-info/read-functions.js +31 -5
  84. package/queries/catalog/dependencies-query/function-info/remote-functions.d.ts +18 -0
  85. package/queries/catalog/dependencies-query/function-info/remote-functions.js +46 -0
  86. package/queries/catalog/dependencies-query/function-info/test-functions.d.ts +2 -0
  87. package/queries/catalog/dependencies-query/function-info/test-functions.js +33 -31
  88. package/queries/catalog/dependencies-query/function-info/visualize-functions.js +52 -2
  89. package/queries/catalog/dependencies-query/function-info/write-functions.js +28 -5
  90. package/queries/catalog/dependencies-query/link-devices.d.ts +12 -0
  91. package/queries/catalog/dependencies-query/link-devices.js +58 -0
  92. package/queries/catalog/dice-query/dice-query-format.d.ts +2 -0
  93. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +25 -6
  94. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +38 -7
  95. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +18 -5
  96. package/queries/catalog/happens-before-query/happens-before-query-format.js +3 -2
  97. package/queries/catalog/input-sources-query/input-sources-query-format.js +4 -0
  98. package/queries/catalog/input-sources-query/input-types.d.ts +10 -0
  99. package/queries/catalog/input-sources-query/input-types.js +10 -0
  100. package/queries/catalog/location-map-query/location-map-query-executor.js +16 -6
  101. package/queries/catalog/location-map-query/location-map-query-format.d.ts +15 -1
  102. package/queries/catalog/location-map-query/location-map-query-format.js +22 -5
  103. package/queries/catalog/signature-query/signature-query-executor.js +3 -0
  104. package/queries/catalog/signature-query/signature-query-format.d.ts +5 -0
  105. package/queries/catalog/static-slice-query/static-slice-query-format.js +1 -0
  106. package/queries/query.d.ts +1 -1
  107. package/r-bridge/data/data.d.ts +1 -1
  108. package/r-bridge/data/data.js +1 -1
  109. package/r-bridge/lang-4.x/ast/model/model.d.ts +14 -2
  110. package/r-bridge/lang-4.x/ast/model/model.js +32 -0
  111. package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +2 -0
  112. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +2 -0
  113. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +2 -0
  114. package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +2 -0
  115. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +2 -0
  116. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +2 -0
  117. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +2 -0
  118. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +7 -8
  119. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +9 -46
  120. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +2 -0
  121. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +2 -0
  122. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +2 -0
  123. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +2 -0
  124. package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +2 -0
  125. package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +2 -0
  126. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +2 -0
  127. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +2 -0
  128. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +2 -0
  129. package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +2 -0
  130. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +2 -0
  131. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +2 -0
  132. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +2 -0
  133. package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +0 -5
  134. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +6 -3
  135. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +1 -1
  136. package/search/flowr-search-filters.d.ts +17 -1
  137. package/search/flowr-search-filters.js +23 -0
  138. package/slicing/criterion/parse.d.ts +6 -25
  139. package/slicing/criterion/parse.js +50 -19
  140. package/slicing/static/fingerprint.d.ts +1 -1
  141. package/slicing/static/fingerprint.js +52 -8
  142. package/slicing/static/slicer-types.d.ts +10 -0
  143. package/slicing/static/static-slicer.d.ts +1 -1
  144. package/slicing/static/static-slicer.js +29 -6
  145. package/slicing/static/visiting-queue.d.ts +15 -3
  146. package/slicing/static/visiting-queue.js +37 -3
  147. package/util/arg-matching.d.ts +18 -0
  148. package/util/arg-matching.js +70 -0
  149. package/util/r-regex.js +19 -1
  150. package/util/range.d.ts +7 -8
  151. package/util/range.js +10 -11
  152. package/util/version.js +1 -1
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RFunctionCall = exports.EmptyArgument = void 0;
4
4
  const model_1 = require("../model");
5
5
  const type_1 = require("../type");
6
- const prefix_1 = require("../../../../../util/prefix");
6
+ const arg_matching_1 = require("../../../../../util/arg-matching");
7
7
  exports.EmptyArgument = '<>';
8
8
  /**
9
9
  * Helper for working with {@link RFunctionCall} AST nodes.
@@ -30,55 +30,18 @@ exports.RFunctionCall = {
30
30
  return exports.RFunctionCall.is(node) && !node.named;
31
31
  },
32
32
  /**
33
- * Bind a call's `arguments` to the formal `paramNames` using R's argument matching rules
34
- * (see https://cran.r-project.org/doc/manuals/R-lang.html#Argument-matching): exact name, then partial
35
- * (`pmatch`, unique-prefix) name, then the remaining unnamed arguments filling the remaining formals
36
- * left-to-right. Returns a map from parameter name to the argument bound to it, so
37
- * `matchArgumentsToParameters(call.arguments, names).get('X')` answers "which argument is mapped to
38
- * parameter `X`". Pass `paramNames` as the full formal list **excluding `...`** so ambiguous prefixes are
39
- * rejected; this makes it exact when the signature is known (e.g. from the signature database).
33
+ * Bind a call's `arguments` to the formal `paramNames` with {@link matchArgumentsToParameters}, R's argument
34
+ * matching. Returns a map from parameter name to the argument bound to it, so
35
+ * `matchArgsToParams(call.arguments, names).get('X')` answers "which argument is mapped to parameter `X`".
36
+ * An empty argument (`f(1, ,3)`) takes its formal but never appears in the map, as there is nothing to bind.
40
37
  */
41
38
  matchArgsToParams(args, paramNames) {
39
+ const matched = (0, arg_matching_1.matchArgumentsToParameters)(args.map(a => a === exports.EmptyArgument ? undefined : a.name?.content), paramNames);
42
40
  const bound = new Map();
43
- const used = new Set();
44
- // pass 1: exact name matches
45
41
  for (let i = 0; i < args.length; i++) {
46
- const arg = args[i];
47
- if (arg === exports.EmptyArgument || arg.name === undefined) {
48
- continue;
49
- }
50
- const n = arg.name.content;
51
- if (paramNames.includes(n) && !bound.has(n)) {
52
- bound.set(n, arg);
53
- used.add(i);
54
- }
55
- }
56
- // pass 2: partial (pmatch) name matches on the still-unbound named arguments
57
- for (let i = 0; i < args.length; i++) {
58
- const arg = args[i];
59
- if (used.has(i) || arg === exports.EmptyArgument || arg.name === undefined) {
60
- continue;
61
- }
62
- const matched = (0, prefix_1.findByPrefixIfUnique)(arg.name.content, paramNames);
63
- if (matched !== undefined && !bound.has(matched)) {
64
- bound.set(matched, arg);
65
- used.add(i);
66
- }
67
- }
68
- // pass 3: remaining unnamed args fill the remaining formals left-to-right
69
- let formalIdx = 0;
70
- for (let i = 0; i < args.length; i++) {
71
- const arg = args[i];
72
- if (used.has(i) || arg === exports.EmptyArgument || arg.name !== undefined) {
73
- continue;
74
- }
75
- while (formalIdx < paramNames.length && bound.has(paramNames[formalIdx])) {
76
- formalIdx++;
77
- }
78
- if (formalIdx < paramNames.length) {
79
- bound.set(paramNames[formalIdx], arg);
80
- used.add(i);
81
- formalIdx++;
42
+ const arg = args[i], param = matched[i];
43
+ if (arg !== exports.EmptyArgument && param !== undefined) {
44
+ bound.set(paramNames[param], arg);
82
45
  }
83
46
  }
84
47
  return bound;
@@ -41,6 +41,8 @@ export declare const RFunctionDefinition: {
41
41
  readonly rootFunctionDefinition: <Info = object>(this: void, n: RNode<ParentInformation & Info> | undefined, idMap: AstIdMap<ParentInformation & Info>) => RFunctionDefinition<ParentInformation & Info> | undefined;
42
42
  readonly getLocation: (this: void, node: RNode) => import("../../../../../util/range").SourceLocation | undefined;
43
43
  readonly getId: (this: void, node: RNode<ParentInformation>) => import("../processing/node-id").NodeId;
44
+ readonly span: <OtherInfo>(this: void, node: RNode<OtherInfo> | undefined) => import("../../../../../util/range").SourceRange | undefined;
45
+ readonly topLevelStatement: <OtherInfo>(this: void, node: RNode<OtherInfo & ParentInformation>, idMap: AstIdMap<OtherInfo & ParentInformation>) => RNode<OtherInfo & ParentInformation>;
44
46
  readonly getType: (this: void, node: RNode) => RType;
45
47
  readonly visitAst: <OtherInfo = object>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo>>, onVisit?: import("../processing/visitor").OnEnter<OtherInfo>, onExit?: import("../processing/visitor").OnExit<OtherInfo>) => void;
46
48
  readonly collectAllIds: <OtherInfo>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo & ParentInformation>>) => Set<import("../processing/node-id").NodeId>;
@@ -24,6 +24,8 @@ export declare const RIfThenElse: {
24
24
  readonly is: <Info = object>(this: void, node: RNode<Info> | undefined) => node is RIfThenElse<Info>;
25
25
  readonly getLocation: (this: void, node: RNode) => import("../../../../../util/range").SourceLocation | undefined;
26
26
  readonly getId: (this: void, node: RNode<import("../processing/decorate").ParentInformation>) => import("../processing/node-id").NodeId;
27
+ readonly span: <OtherInfo>(this: void, node: RNode<OtherInfo> | undefined) => import("../../../../../util/range").SourceRange | undefined;
28
+ readonly topLevelStatement: <OtherInfo>(this: void, node: RNode<OtherInfo & import("../processing/decorate").ParentInformation>, idMap: import("../processing/decorate").AstIdMap<OtherInfo & import("../processing/decorate").ParentInformation>) => RNode<OtherInfo & import("../processing/decorate").ParentInformation>;
27
29
  readonly getType: (this: void, node: RNode) => RType;
28
30
  readonly visitAst: <OtherInfo = object>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo>>, onVisit?: import("../processing/visitor").OnEnter<OtherInfo>, onExit?: import("../processing/visitor").OnExit<OtherInfo>) => void;
29
31
  readonly collectAllIds: <OtherInfo>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo & import("../processing/decorate").ParentInformation>>) => Set<import("../processing/node-id").NodeId>;
@@ -20,6 +20,8 @@ export declare const RLineDirective: {
20
20
  readonly is: <Info = object>(this: void, node: RNode<Info> | undefined) => node is RLineDirective<Info>;
21
21
  readonly getLocation: (this: void, node: RNode) => import("../../../../../util/range").SourceLocation | undefined;
22
22
  readonly getId: (this: void, node: RNode<import("../processing/decorate").ParentInformation>) => import("../processing/node-id").NodeId;
23
+ readonly span: <OtherInfo>(this: void, node: RNode<OtherInfo> | undefined) => import("../../../../../util/range").SourceRange | undefined;
24
+ readonly topLevelStatement: <OtherInfo>(this: void, node: RNode<OtherInfo & import("../processing/decorate").ParentInformation>, idMap: import("../processing/decorate").AstIdMap<OtherInfo & import("../processing/decorate").ParentInformation>) => RNode<OtherInfo & import("../processing/decorate").ParentInformation>;
23
25
  readonly getType: (this: void, node: RNode) => RType;
24
26
  readonly visitAst: <OtherInfo = object>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo>>, onVisit?: import("../processing/visitor").OnEnter<OtherInfo>, onExit?: import("../processing/visitor").OnExit<OtherInfo>) => void;
25
27
  readonly collectAllIds: <OtherInfo>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo & import("../processing/decorate").ParentInformation>>) => Set<import("../processing/node-id").NodeId>;
@@ -28,6 +28,8 @@ export declare const RLogical: {
28
28
  readonly isFalse: <Info = object>(this: void, node: RNode<Info> | undefined) => boolean;
29
29
  readonly getLocation: (this: void, node: RNode) => import("../../../../../util/range").SourceLocation | undefined;
30
30
  readonly getId: (this: void, node: RNode<import("../processing/decorate").ParentInformation>) => import("../processing/node-id").NodeId;
31
+ readonly span: <OtherInfo>(this: void, node: RNode<OtherInfo> | undefined) => import("../../../../../util/range").SourceRange | undefined;
32
+ readonly topLevelStatement: <OtherInfo>(this: void, node: RNode<OtherInfo & import("../processing/decorate").ParentInformation>, idMap: import("../processing/decorate").AstIdMap<OtherInfo & import("../processing/decorate").ParentInformation>) => RNode<OtherInfo & import("../processing/decorate").ParentInformation>;
31
33
  readonly getType: (this: void, node: RNode) => RType;
32
34
  readonly visitAst: <OtherInfo = object>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo>>, onVisit?: import("../processing/visitor").OnEnter<OtherInfo>, onExit?: import("../processing/visitor").OnExit<OtherInfo>) => void;
33
35
  readonly collectAllIds: <OtherInfo>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo & import("../processing/decorate").ParentInformation>>) => Set<import("../processing/node-id").NodeId>;
@@ -18,6 +18,8 @@ export declare const RNext: {
18
18
  readonly is: <Info = object>(this: void, node: RNode<Info> | undefined) => node is RNext<Info>;
19
19
  readonly getLocation: (this: void, node: RNode) => import("../../../../../util/range").SourceLocation | undefined;
20
20
  readonly getId: (this: void, node: RNode<import("../processing/decorate").ParentInformation>) => import("../processing/node-id").NodeId;
21
+ readonly span: <OtherInfo>(this: void, node: RNode<OtherInfo> | undefined) => import("../../../../../util/range").SourceRange | undefined;
22
+ readonly topLevelStatement: <OtherInfo>(this: void, node: RNode<OtherInfo & import("../processing/decorate").ParentInformation>, idMap: import("../processing/decorate").AstIdMap<OtherInfo & import("../processing/decorate").ParentInformation>) => RNode<OtherInfo & import("../processing/decorate").ParentInformation>;
21
23
  readonly getType: (this: void, node: RNode) => RType;
22
24
  readonly visitAst: <OtherInfo = object>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo>>, onVisit?: import("../processing/visitor").OnEnter<OtherInfo>, onExit?: import("../processing/visitor").OnExit<OtherInfo>) => void;
23
25
  readonly collectAllIds: <OtherInfo>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo & import("../processing/decorate").ParentInformation>>) => Set<import("../processing/node-id").NodeId>;
@@ -22,6 +22,8 @@ export declare const RNumber: {
22
22
  readonly is: <Info = object>(this: void, node: RNode<Info> | undefined) => node is RNumber<Info>;
23
23
  readonly getLocation: (this: void, node: RNode) => import("../../../../../util/range").SourceLocation | undefined;
24
24
  readonly getId: (this: void, node: RNode<import("../processing/decorate").ParentInformation>) => import("../processing/node-id").NodeId;
25
+ readonly span: <OtherInfo>(this: void, node: RNode<OtherInfo> | undefined) => import("../../../../../util/range").SourceRange | undefined;
26
+ readonly topLevelStatement: <OtherInfo>(this: void, node: RNode<OtherInfo & import("../processing/decorate").ParentInformation>, idMap: import("../processing/decorate").AstIdMap<OtherInfo & import("../processing/decorate").ParentInformation>) => RNode<OtherInfo & import("../processing/decorate").ParentInformation>;
25
27
  readonly getType: (this: void, node: RNode) => RType;
26
28
  readonly visitAst: <OtherInfo = object>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo>>, onVisit?: import("../processing/visitor").OnEnter<OtherInfo>, onExit?: import("../processing/visitor").OnExit<OtherInfo>) => void;
27
29
  readonly collectAllIds: <OtherInfo>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo & import("../processing/decorate").ParentInformation>>) => Set<import("../processing/node-id").NodeId>;
@@ -30,6 +30,8 @@ export declare const RParameter: {
30
30
  readonly isDotDotDotDot: <Info = object>(this: void, node: RNode<Info> | undefined) => node is RParameter<Info>;
31
31
  readonly getLocation: (this: void, node: RNode) => import("../../../../../util/range").SourceLocation | undefined;
32
32
  readonly getId: (this: void, node: RNode<import("../processing/decorate").ParentInformation>) => import("../processing/node-id").NodeId;
33
+ readonly span: <OtherInfo>(this: void, node: RNode<OtherInfo> | undefined) => import("../../../../../util/range").SourceRange | undefined;
34
+ readonly topLevelStatement: <OtherInfo>(this: void, node: RNode<OtherInfo & import("../processing/decorate").ParentInformation>, idMap: import("../processing/decorate").AstIdMap<OtherInfo & import("../processing/decorate").ParentInformation>) => RNode<OtherInfo & import("../processing/decorate").ParentInformation>;
33
35
  readonly getType: (this: void, node: RNode) => RType;
34
36
  readonly visitAst: <OtherInfo = object>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo>>, onVisit?: import("../processing/visitor").OnEnter<OtherInfo>, onExit?: import("../processing/visitor").OnExit<OtherInfo>) => void;
35
37
  readonly collectAllIds: <OtherInfo>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo & import("../processing/decorate").ParentInformation>>) => Set<import("../processing/node-id").NodeId>;
@@ -34,6 +34,8 @@ export declare const RPipe: {
34
34
  readonly hasAccessPlaceHolderFromRVersion: (this: void) => SemVer;
35
35
  readonly getLocation: (this: void, node: RNode) => import("../../../../../util/range").SourceLocation | undefined;
36
36
  readonly getId: (this: void, node: RNode<import("../processing/decorate").ParentInformation>) => import("../processing/node-id").NodeId;
37
+ readonly span: <OtherInfo>(this: void, node: RNode<OtherInfo> | undefined) => import("../../../../../util/range").SourceRange | undefined;
38
+ readonly topLevelStatement: <OtherInfo>(this: void, node: RNode<OtherInfo & import("../processing/decorate").ParentInformation>, idMap: import("../processing/decorate").AstIdMap<OtherInfo & import("../processing/decorate").ParentInformation>) => RNode<OtherInfo & import("../processing/decorate").ParentInformation>;
37
39
  readonly getType: (this: void, node: RNode) => RType;
38
40
  readonly visitAst: <OtherInfo = object>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo>>, onVisit?: import("../processing/visitor").OnEnter<OtherInfo>, onExit?: import("../processing/visitor").OnExit<OtherInfo>) => void;
39
41
  readonly collectAllIds: <OtherInfo>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo & import("../processing/decorate").ParentInformation>>) => Set<import("../processing/node-id").NodeId>;
@@ -22,6 +22,8 @@ export declare const RRepeatLoop: {
22
22
  readonly is: <Info = object>(this: void, node: RNode<Info> | undefined) => node is RRepeatLoop<Info>;
23
23
  readonly getLocation: (this: void, node: RNode) => import("../../../../../util/range").SourceLocation | undefined;
24
24
  readonly getId: (this: void, node: RNode<import("../processing/decorate").ParentInformation>) => import("../processing/node-id").NodeId;
25
+ readonly span: <OtherInfo>(this: void, node: RNode<OtherInfo> | undefined) => import("../../../../../util/range").SourceRange | undefined;
26
+ readonly topLevelStatement: <OtherInfo>(this: void, node: RNode<OtherInfo & import("../processing/decorate").ParentInformation>, idMap: import("../processing/decorate").AstIdMap<OtherInfo & import("../processing/decorate").ParentInformation>) => RNode<OtherInfo & import("../processing/decorate").ParentInformation>;
25
27
  readonly getType: (this: void, node: RNode) => RType;
26
28
  readonly visitAst: <OtherInfo = object>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo>>, onVisit?: import("../processing/visitor").OnEnter<OtherInfo>, onExit?: import("../processing/visitor").OnExit<OtherInfo>) => void;
27
29
  readonly collectAllIds: <OtherInfo>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo & import("../processing/decorate").ParentInformation>>) => Set<import("../processing/node-id").NodeId>;
@@ -27,6 +27,8 @@ export declare const RString: {
27
27
  rawStringAvailableFromRVersion(): SemVer;
28
28
  getLocation: (this: void, node: RNode) => import("../../../../../util/range").SourceLocation | undefined;
29
29
  getId: (this: void, node: RNode<import("../processing/decorate").ParentInformation>) => import("../processing/node-id").NodeId;
30
+ span: <OtherInfo>(this: void, node: RNode<OtherInfo> | undefined) => import("../../../../../util/range").SourceRange | undefined;
31
+ topLevelStatement: <OtherInfo>(this: void, node: RNode<OtherInfo & import("../processing/decorate").ParentInformation>, idMap: import("../processing/decorate").AstIdMap<OtherInfo & import("../processing/decorate").ParentInformation>) => RNode<OtherInfo & import("../processing/decorate").ParentInformation>;
30
32
  getType: (this: void, node: RNode) => RType;
31
33
  visitAst: <OtherInfo = object>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo>>, onVisit?: import("../processing/visitor").OnEnter<OtherInfo>, onExit?: import("../processing/visitor").OnExit<OtherInfo>) => void;
32
34
  collectAllIds: <OtherInfo>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo & import("../processing/decorate").ParentInformation>>) => Set<import("../processing/node-id").NodeId>;
@@ -32,6 +32,8 @@ export declare const RSymbol: {
32
32
  readonly isSpecial: <OtherInfo = object>(this: void, node: RNode<OtherInfo> | undefined) => node is RSymbol<OtherInfo, typeof RNull | typeof RNa>;
33
33
  readonly getLocation: (this: void, node: RNode) => import("../../../../../util/range").SourceLocation | undefined;
34
34
  readonly getId: (this: void, node: RNode<import("../processing/decorate").ParentInformation>) => import("../processing/node-id").NodeId;
35
+ readonly span: <OtherInfo>(this: void, node: RNode<OtherInfo> | undefined) => import("../../../../../util/range").SourceRange | undefined;
36
+ readonly topLevelStatement: <OtherInfo>(this: void, node: RNode<OtherInfo & import("../processing/decorate").ParentInformation>, idMap: import("../processing/decorate").AstIdMap<OtherInfo & import("../processing/decorate").ParentInformation>) => RNode<OtherInfo & import("../processing/decorate").ParentInformation>;
35
37
  readonly getType: (this: void, node: RNode) => RType;
36
38
  readonly visitAst: <OtherInfo = object>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo>>, onVisit?: import("../processing/visitor").OnEnter<OtherInfo>, onExit?: import("../processing/visitor").OnExit<OtherInfo>) => void;
37
39
  readonly collectAllIds: <OtherInfo>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo & import("../processing/decorate").ParentInformation>>) => Set<import("../processing/node-id").NodeId>;
@@ -25,6 +25,8 @@ export declare const RUnaryOp: {
25
25
  readonly getOperatorInfo: <Info = object>(node: RUnaryOp<Info>) => OperatorInformationValue | undefined;
26
26
  readonly getLocation: (this: void, node: RNode) => import("../../../../../util/range").SourceLocation | undefined;
27
27
  readonly getId: (this: void, node: RNode<import("../processing/decorate").ParentInformation>) => import("../processing/node-id").NodeId;
28
+ readonly span: <OtherInfo>(this: void, node: RNode<OtherInfo> | undefined) => import("../../../../../util/range").SourceRange | undefined;
29
+ readonly topLevelStatement: <OtherInfo>(this: void, node: RNode<OtherInfo & import("../processing/decorate").ParentInformation>, idMap: import("../processing/decorate").AstIdMap<OtherInfo & import("../processing/decorate").ParentInformation>) => RNode<OtherInfo & import("../processing/decorate").ParentInformation>;
28
30
  readonly getType: (this: void, node: RNode) => RType;
29
31
  readonly visitAst: <OtherInfo = object>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo>>, onVisit?: import("../processing/visitor").OnEnter<OtherInfo>, onExit?: import("../processing/visitor").OnExit<OtherInfo>) => void;
30
32
  readonly collectAllIds: <OtherInfo>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo & import("../processing/decorate").ParentInformation>>) => Set<import("../processing/node-id").NodeId>;
@@ -23,6 +23,8 @@ export declare const RWhileLoop: {
23
23
  readonly is: <Info = object>(this: void, node: RNode<Info> | undefined) => node is RWhileLoop<Info>;
24
24
  readonly getLocation: (this: void, node: RNode) => import("../../../../../util/range").SourceLocation | undefined;
25
25
  readonly getId: (this: void, node: RNode<import("../processing/decorate").ParentInformation>) => import("../processing/node-id").NodeId;
26
+ readonly span: <OtherInfo>(this: void, node: RNode<OtherInfo> | undefined) => import("../../../../../util/range").SourceRange | undefined;
27
+ readonly topLevelStatement: <OtherInfo>(this: void, node: RNode<OtherInfo & import("../processing/decorate").ParentInformation>, idMap: import("../processing/decorate").AstIdMap<OtherInfo & import("../processing/decorate").ParentInformation>) => RNode<OtherInfo & import("../processing/decorate").ParentInformation>;
26
28
  readonly getType: (this: void, node: RNode) => RType;
27
29
  readonly visitAst: <OtherInfo = object>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo>>, onVisit?: import("../processing/visitor").OnEnter<OtherInfo>, onExit?: import("../processing/visitor").OnExit<OtherInfo>) => void;
28
30
  readonly collectAllIds: <OtherInfo>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo & import("../processing/decorate").ParentInformation>>) => Set<import("../processing/node-id").NodeId>;
@@ -9,11 +9,6 @@ export type NodeId<T extends string | number = string | number> = T & {
9
9
  * A variant of {@link NodeId} that represents built-in functions or operators. The string is prefixed with `built-in:` to avoid confusion with other node ids.
10
10
  */
11
11
  export type BuiltIn<T extends string = string> = `built-in:${T}`;
12
- /**
13
- * The type of the id assigned to each node. Branded to avoid problematic usages with other string or numeric types.
14
- * The default ids are numeric, but we use a branded type to avoid confusion with other numeric types.
15
- * Custom ids or scoped ids can be strings, but they will be normalized to numbers if they are numeric strings.
16
- */
17
12
  export declare const NodeId: {
18
13
  readonly name: "NodeId";
19
14
  /**
@@ -11,6 +11,11 @@ const identifier_1 = require("../../../../../dataflow/environments/identifier");
11
11
  * The default ids are numeric, but we use a branded type to avoid confusion with other numeric types.
12
12
  * Custom ids or scoped ids can be strings, but they will be normalized to numbers if they are numeric strings.
13
13
  */
14
+ /** whether the id starts as a number does, which `+id` alone does not tell: it turns a blank string into `0` */
15
+ function startsNumeric(id) {
16
+ const c = id.charCodeAt(0);
17
+ return c >= 48 && c <= 57 /* 0-9 */ || c === 45 /* - */ || c === 43 /* + */ || c === 46 /* . */;
18
+ }
14
19
  exports.NodeId = {
15
20
  name: 'NodeId',
16
21
  /**
@@ -18,9 +23,7 @@ exports.NodeId = {
18
23
  * This allows us to use numeric ids without storing them as strings, while still allowing custom string ids if needed.
19
24
  */
20
25
  normalize(id) {
21
- // check if string is number
22
- if (typeof id === 'string') {
23
- /* typescript is a beautiful converter */
26
+ if (typeof id === 'string' && startsNumeric(id)) {
24
27
  const num = +id;
25
28
  if (!Number.isNaN(num)) {
26
29
  return num;
@@ -70,7 +70,7 @@ class TreeSitterExecutor {
70
70
  else {
71
71
  sourceCode = request.content;
72
72
  }
73
- if (request.filePath === undefined || !ctx.config.incrementalParsing.activated) {
73
+ if (request.filePath === undefined || !ctx.inc.handleShouldReparse(request.filePath, ctx)) {
74
74
  return this.parser.parse(sourceCode);
75
75
  }
76
76
  const reparseInfo = (0, incremental_parse_1.computeReparseInfo)(ctx, request.filePath);
@@ -6,6 +6,7 @@ import type { Enrichment } from './search-executor/search-enrichers';
6
6
  import type { DataflowInformation } from '../dataflow/info';
7
7
  import type { BuiltInProcName } from '../dataflow/environments/built-in-proc-name';
8
8
  import type { RoleInParent } from '../r-bridge/lang-4.x/ast/model/processing/role';
9
+ import type { CallProps } from '../dataflow/environments/built-in-props';
9
10
  export type FlowrFilterName = keyof typeof FlowrFilters;
10
11
  interface FlowrFilterWithArgs<Filter extends FlowrFilterName, Args extends FlowrFilterArgs<Filter>> {
11
12
  name: Filter;
@@ -37,7 +38,13 @@ export declare enum FlowrFilter {
37
38
  * Only returns search elements whose file path matches the given regular expression.
38
39
  * This filter accepts {@link FilePathFilterArgs}, which includes the file path regex to test against.
39
40
  */
40
- FilePathFilter = "file-path-filter"
41
+ FilePathFilter = "file-path-filter",
42
+ /**
43
+ * Only returns function calls whose {@link CallProp} bits match the given mask, so that _every call that asks
44
+ * the user_ or _every call that closes a device_ can be searched for without naming a single function.
45
+ * This filter accepts {@link CallPropsArgs}.
46
+ */
47
+ CallProps = "call-props"
41
48
  }
42
49
  export type FlowrFilterFunction<T> = (e: FlowrSearchElement<ParentInformation>, args: T, data: {
43
50
  dataflow: DataflowInformation;
@@ -56,6 +63,9 @@ export declare const FlowrFilters: {
56
63
  roleInParent: RoleInParent;
57
64
  }) => boolean;
58
65
  readonly "file-path-filter": (e: FlowrSearchElement<ParentInformation>, args: FilePathFilterArgs) => boolean;
66
+ readonly "call-props": (e: FlowrSearchElement<ParentInformation>, args: CallPropsArgs, data: {
67
+ dataflow: DataflowInformation;
68
+ }) => boolean;
59
69
  };
60
70
  export type FlowrFilterArgs<F extends FlowrFilter> = typeof FlowrFilters[F] extends FlowrFilterFunction<infer Args> ? Args : never;
61
71
  export interface MatchesEnrichmentArgs<E extends Enrichment> {
@@ -77,6 +87,12 @@ export interface OriginKindArgs {
77
87
  export interface FilePathFilterArgs {
78
88
  filePathRegex: string | RegExp;
79
89
  }
90
+ export interface CallPropsArgs {
91
+ /** the {@link CallProp} bits to look for, e.g. `CallProp.User | CallProp.Closes` */
92
+ props: CallProps;
93
+ /** whether a call has to carry every bit of {@link props} or just one of them (the default) */
94
+ matchType?: 'some' | 'every';
95
+ }
80
96
  type ValidFilterTypes<F extends FlowrFilter = FlowrFilter> = FlowrFilterName | FlowrFilterWithArgs<F, FlowrFilterArgs<F>> | RType | VertexType;
81
97
  /**
82
98
  * By default, we provide filter for every {@link RType} and {@link VertexType}.
@@ -9,6 +9,9 @@ const vertex_1 = require("../dataflow/graph/vertex");
9
9
  const search_enrichers_1 = require("./search-executor/search-enrichers");
10
10
  const objects_1 = require("../util/objects");
11
11
  const search_generators_1 = require("./search-executor/search-generators");
12
+ const query_fn_props_1 = require("../dataflow/environments/query-fn-props");
13
+ const df_helper_1 = require("../dataflow/graph/df-helper");
14
+ const environment_1 = require("../dataflow/environments/environment");
12
15
  var FlowrFilter;
13
16
  (function (FlowrFilter) {
14
17
  /**
@@ -37,6 +40,12 @@ var FlowrFilter;
37
40
  * This filter accepts {@link FilePathFilterArgs}, which includes the file path regex to test against.
38
41
  */
39
42
  FlowrFilter["FilePathFilter"] = "file-path-filter";
43
+ /**
44
+ * Only returns function calls whose {@link CallProp} bits match the given mask, so that _every call that asks
45
+ * the user_ or _every call that closes a device_ can be searched for without naming a single function.
46
+ * This filter accepts {@link CallPropsArgs}.
47
+ */
48
+ FlowrFilter["CallProps"] = "call-props";
40
49
  })(FlowrFilter || (exports.FlowrFilter = FlowrFilter = {}));
41
50
  exports.ValidFlowrFilters = new Set(Object.values(FlowrFilter));
42
51
  exports.ValidFlowrFiltersReverse = Object.fromEntries(Object.entries(FlowrFilter).map(([k, v]) => [v, k]));
@@ -66,6 +75,20 @@ exports.FlowrFilters = {
66
75
  const file = e.node.info.file;
67
76
  const rx = args.filePathRegex instanceof RegExp ? args.filePathRegex : new RegExp(args.filePathRegex);
68
77
  return rx.test(file ?? '');
78
+ }),
79
+ [FlowrFilter.CallProps]: ((e, args, data) => {
80
+ const graph = data.dataflow.graph;
81
+ const vertex = graph.getVertex(e.node.info.id);
82
+ if (vertex?.tag !== vertex_1.VertexType.FunctionCall) {
83
+ return false;
84
+ }
85
+ /* what the call resolved to decides, as a definition in the analyzed code shadows the built-in; a call
86
+ * flowR settled on the built-ins keeps no environment, and a later redefinition must not speak for it */
87
+ const known = vertex.environment ?? data.dataflow.environment;
88
+ const environment = vertex.onlyBuiltin ? { level: 0, current: environment_1.REnvironment.findBuiltIn(known.current) } : known;
89
+ const name = df_helper_1.Dataflow.qualify(e.node.info.id, graph, false) ?? vertex.name;
90
+ const props = (0, query_fn_props_1.queryFnProps)(name, { environment })?.props ?? 0;
91
+ return args.matchType === 'every' ? (props & args.props) === args.props : (props & args.props) !== 0;
69
92
  })
70
93
  };
71
94
  /**
@@ -2,11 +2,8 @@ import { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
2
2
  import type { AstIdMap } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
3
3
  /** An optional `(file-regex)` suffix restricting a criterion to nodes stemming from a matching file. */
4
4
  type FileFilterSuffix = '' | `(${string})`;
5
- /**
6
- * Either `line:column`, `line~column`, `line@variable-name`, or `$id`; all but `$id` accept a trailing
7
- * `(file-regex)`. See {@link SlicingCriterion.tryParse} for what each of them resolves to.
8
- */
9
- export type SlicingCriterion = `${number}:${number}${FileFilterSuffix}` | `${number}~${number}${FileFilterSuffix}` | `${number}@${string}` | `$${NodeId | number}`;
5
+ /** see {@link SlicingCriterion.tryParse} for what each of these formats resolves to */
6
+ export type SlicingCriterion = `${number}:${number}${FileFilterSuffix}` | `${number}~${number}${FileFilterSuffix}` | `${number}^${FileFilterSuffix}` | `${number}@${string}` | `$${NodeId | number}`;
10
7
  /**
11
8
  * The helper object associated with {@link SlicingCriterion} which makes it easy
12
9
  * to parse, validate and resolve slicing criteria.
@@ -20,27 +17,14 @@ export declare const SlicingCriterion: {
20
17
  */
21
18
  readonly isValid: (this: void, criterion: unknown) => criterion is SlicingCriterion;
22
19
  /**
23
- * Takes a criterion in the form of `line:column`, `line~column`, or `line@variable-name` and returns the corresponding node id
20
+ * Resolves a slicing criterion to the corresponding node id.
24
21
  * @see {@link SlicingCriterion.tryParse} for a version that does not throw an error
25
22
  */
26
23
  readonly parse: (this: void, criterion: SlicingCriterion, idMap: AstIdMap) => NodeId;
27
24
  /**
28
25
  * Tries to resolve a slicing criterion to an id, but does not throw an error if it fails.
29
- *
30
- * | Criterion | Resolves to |
31
- * | --------- | ----------- |
32
- * | `2@x` | `x` in line 2, preferring a call over the symbol it refers to |
33
- * | `2@[3]x` | the 3rd occurrence of `x` in line 2 (by column); `[-1]` for the last |
34
- * | `2:5` | the element *starting* at line 2, column 5 |
35
- * | `2~5` | the innermost element *containing* line 2, column 5 |
36
- * | `$42` | the node with the normalized id 42 |
37
- *
38
- * A negative line counts from the end of the input (`-1` being the last line). Every criterion but `$id`
39
- * accepts a trailing `(file-regex)` (e.g. `2@x(tmp/.*)`) restricting it to a matching file.
40
- *
41
- * Lines, columns, and the `[n]` occurrence are all *1-based*, so a `0` anywhere (`2:0`, `0@x`, `2@[0]x`)
42
- * addresses nothing and resolves to `undefined` -- it is not a wildcard for the whole line. A criterion
43
- * always denotes at most a single node; use one criterion per node to select several.
26
+ * The formats and what each of them resolves to are documented in the
27
+ * {@link https://github.com/flowr-analysis/flowr/wiki/Terminology#slicing-criterion|wiki}.
44
28
  * @see {@link SlicingCriterion.parse} for the version that throws an error
45
29
  */
46
30
  readonly tryParse: (this: void, criterion: SlicingCriterion | NodeId, idMap: AstIdMap) => NodeId | undefined;
@@ -49,10 +33,7 @@ export declare const SlicingCriterion: {
49
33
  */
50
34
  readonly fromId: (this: void, id: NodeId) => SlicingCriterion;
51
35
  };
52
- /**
53
- * A slicing criterion is a list of single slicing criteria, which can be in the form of `line:column`,
54
- * `line~column`, `line@variable-name`, or `$id`.
55
- */
36
+ /** several {@link SlicingCriterion}s, all of which are sliced for at once */
56
37
  export type SlicingCriteria = SlicingCriterion[];
57
38
  export interface DecodedCriterion {
58
39
  criterion: SlicingCriterion;
@@ -18,10 +18,18 @@ exports.SlicingCriterion = {
18
18
  * @see {@link SlicingCriterion.parse} to parse a slicing criterion to a node ID
19
19
  */
20
20
  isValid(criterion) {
21
- return typeof criterion === 'string' && criterion.match(/^\d+:\d+|\d+@.+|\$.+$/) !== null;
21
+ if (typeof criterion !== 'string') {
22
+ return false;
23
+ }
24
+ else if (criterion.startsWith('$')) {
25
+ return criterion.length > 1;
26
+ }
27
+ /* the file filter is optional on every form, so validate what remains once it is split off */
28
+ const split = splitFileFilter(criterion);
29
+ return split !== undefined && /^-?\d+([:~]\d+|\^|@.+)$/.test(split.rest);
22
30
  },
23
31
  /**
24
- * Takes a criterion in the form of `line:column`, `line~column`, or `line@variable-name` and returns the corresponding node id
32
+ * Resolves a slicing criterion to the corresponding node id.
25
33
  * @see {@link SlicingCriterion.tryParse} for a version that does not throw an error
26
34
  */
27
35
  parse(criterion, idMap) {
@@ -33,21 +41,8 @@ exports.SlicingCriterion = {
33
41
  },
34
42
  /**
35
43
  * Tries to resolve a slicing criterion to an id, but does not throw an error if it fails.
36
- *
37
- * | Criterion | Resolves to |
38
- * | --------- | ----------- |
39
- * | `2@x` | `x` in line 2, preferring a call over the symbol it refers to |
40
- * | `2@[3]x` | the 3rd occurrence of `x` in line 2 (by column); `[-1]` for the last |
41
- * | `2:5` | the element *starting* at line 2, column 5 |
42
- * | `2~5` | the innermost element *containing* line 2, column 5 |
43
- * | `$42` | the node with the normalized id 42 |
44
- *
45
- * A negative line counts from the end of the input (`-1` being the last line). Every criterion but `$id`
46
- * accepts a trailing `(file-regex)` (e.g. `2@x(tmp/.*)`) restricting it to a matching file.
47
- *
48
- * Lines, columns, and the `[n]` occurrence are all *1-based*, so a `0` anywhere (`2:0`, `0@x`, `2@[0]x`)
49
- * addresses nothing and resolves to `undefined` -- it is not a wildcard for the whole line. A criterion
50
- * always denotes at most a single node; use one criterion per node to select several.
44
+ * The formats and what each of them resolves to are documented in the
45
+ * {@link https://github.com/flowr-analysis/flowr/wiki/Terminology#slicing-criterion|wiki}.
51
46
  * @see {@link SlicingCriterion.parse} for the version that throws an error
52
47
  */
53
48
  tryParse(criterion, idMap) {
@@ -81,6 +76,10 @@ exports.SlicingCriterion = {
81
76
  const location = parseLocation(base, '~', idMap, file);
82
77
  return location && fuzzyLocationToId(location, idMap, file);
83
78
  }
79
+ else if (base.endsWith('^')) {
80
+ const line = parseLineNumber(base.slice(0, -1), idMap, file);
81
+ return line === undefined ? undefined : topLevelStatementToId(line, idMap, file);
82
+ }
84
83
  },
85
84
  /**
86
85
  * Converts a node id to a slicing criterion in the form of `$id`
@@ -149,12 +148,44 @@ function fuzzyLocationToId(location, dataflowIdMap, file) {
149
148
  // prefer the call over the symbol it refers to, exactly as locationToId does
150
149
  return (candidates.find(n => n.type === type_1.RType.FunctionCall) ?? candidates[0])?.info.id;
151
150
  }
151
+ /** Walks up to the statement `node` belongs to: the outermost node still below the root of its file. */
152
+ function enclosingTopLevelStatement(node, idMap) {
153
+ let current = node;
154
+ for (;;) {
155
+ const parent = current.info.parent !== undefined ? idMap.get(current.info.parent) : undefined;
156
+ if (parent === undefined || parent.info.parent === undefined) {
157
+ return current;
158
+ }
159
+ current = parent;
160
+ }
161
+ }
162
+ /**
163
+ * Resolves a `line^` criterion: the top-level statement covering the line, which is what has to be excised to
164
+ * remove that line from the program. Unlike {@link fuzzyLocationToId} this widens rather than narrows, so an
165
+ * inner sub-expression on the line never stands in for the statement carrying it.
166
+ */
167
+ function topLevelStatementToId(line, idMap, file) {
168
+ const potentials = [...idMap.values()].filter(nodeInfo => matchesFile(nodeInfo, file));
169
+ let best;
170
+ let bestRange;
171
+ for (const node of range_1.SourceRange.nodesContaining(potentials, line)) {
172
+ const statement = enclosingTopLevelStatement(node, idMap);
173
+ const range = range_1.SourceRange.fromNode(statement);
174
+ /* several statements may cover the line (`a <- 1; b <- 2`), the one starting first wins */
175
+ if (range !== undefined && (bestRange === undefined || range_1.SourceRange.compare(range, bestRange) < 0)) {
176
+ best = statement;
177
+ bestRange = range;
178
+ }
179
+ }
180
+ return best?.info.id;
181
+ }
152
182
  /**
153
183
  * Splits the optional trailing `(file-regex)` off a criterion (e.g. `2@x(tmp/.*)`), which restricts it to nodes
154
- * originating from a matching file. Returns `undefined` if the regex is malformed.
184
+ * originating from a matching file. The regex may contain escaped parentheses (`3^(a\(b\)\.R)`).
185
+ * Returns `undefined` if the regex is malformed.
155
186
  */
156
187
  function splitFileFilter(criterion) {
157
- const match = /^(.*)\(([^()]*)\)$/.exec(criterion);
188
+ const match = /^([^()]*)\(((?:\\.|[^()])*)\)$/.exec(criterion);
158
189
  if (match === null) {
159
190
  return { rest: criterion, file: undefined };
160
191
  }
@@ -1,4 +1,4 @@
1
- import { type REnvironmentInformation } from '../../dataflow/environments/environment';
1
+ import type { REnvironmentInformation } from '../../dataflow/environments/environment';
2
2
  import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
3
3
  export type Fingerprint = string;
4
4
  /**
@@ -7,19 +7,63 @@ exports.envFingerprint = envFingerprint;
7
7
  exports.fingerprint = fingerprint;
8
8
  const object_hash_1 = __importDefault(require("object-hash"));
9
9
  const environment_1 = require("../../dataflow/environments/environment");
10
+ const HashOptions = {
11
+ algorithm: 'md5',
12
+ excludeKeys: (key) => key === 'id' || key === 'value',
13
+ respectFunctionProperties: false,
14
+ respectFunctionNames: false,
15
+ ignoreUnknown: true,
16
+ replacer: (v) => (0, environment_1.isDefaultBuiltInEnvironment)(v) ? undefined : v
17
+ };
18
+ /* definitions, definition maps and frames are shared across the environments a slice builds, and a definition may
19
+ * hold a whole environment of its own (`envState`), so each is hashed once instead of on every fingerprint. The
20
+ * map is keyed separately from the frame because cloning a frame shares its definitions until one side writes
21
+ * (see {@link Environment#clone}): the graph holds many frames per distinct set of definitions, and hashing that
22
+ * set is what costs. */
23
+ const definitionHashes = new WeakMap();
24
+ const memoryHashes = new WeakMap();
25
+ const frameHashes = new WeakMap();
26
+ function definitionHash(definition) {
27
+ let hash = definitionHashes.get(definition);
28
+ if (hash === undefined) {
29
+ hash = (0, object_hash_1.default)(definition, HashOptions);
30
+ definitionHashes.set(definition, hash);
31
+ }
32
+ return hash;
33
+ }
34
+ function memoryHash(memory) {
35
+ let hash = memoryHashes.get(memory);
36
+ if (hash === undefined) {
37
+ const entries = [];
38
+ for (const [name, definitions] of memory) {
39
+ entries.push(`${String(name)}=${definitions.map(definitionHash).join(',')}`);
40
+ }
41
+ entries.sort();
42
+ hash = (0, object_hash_1.default)(entries, HashOptions);
43
+ memoryHashes.set(memory, hash);
44
+ }
45
+ return hash;
46
+ }
47
+ function frameHash(frame) {
48
+ let hash = frameHashes.get(frame);
49
+ if (hash === undefined) {
50
+ hash = (0, object_hash_1.default)([frame.n, frame.t, frame.closure, frame.globalEnv === true, memoryHash(frame.memory)], HashOptions);
51
+ frameHashes.set(frame, hash);
52
+ }
53
+ return hash;
54
+ }
10
55
  /**
11
56
  * Calculate a fingerprint for the given R environment information
12
57
  * @see {@link fingerprint}
13
58
  */
14
59
  function envFingerprint(env) {
15
- return (0, object_hash_1.default)(env, {
16
- algorithm: 'md5',
17
- excludeKeys: key => key === 'id' || key === 'value',
18
- respectFunctionProperties: false,
19
- respectFunctionNames: false,
20
- ignoreUnknown: true,
21
- replacer: (v) => (0, environment_1.isDefaultBuiltInEnvironment)(v) ? undefined : v
22
- });
60
+ const parts = [String(env.level)];
61
+ let frame = env.current;
62
+ while (frame !== undefined && !frame.builtInEnv) {
63
+ parts.push(frameHash(frame));
64
+ frame = frame.parent;
65
+ }
66
+ return parts.join('|');
23
67
  }
24
68
  /**
25
69
  * Calculate a fingerprint for the given node id and environment fingerprint
@@ -31,4 +31,14 @@ export interface SliceResult {
31
31
  * The ids of the nodes in the normalized ast that were used as seed ids for slicing. This is a subset of {@link result}.
32
32
  */
33
33
  readonly slicedFor: readonly NodeId[];
34
+ /**
35
+ * Set when the {@link GasFeatureKey.Slicer|gas guard} stopped the traversal before the queue drained, so
36
+ * {@link result} is what was reached until then and not the complete slice.
37
+ */
38
+ readonly stoppedEarly?: boolean;
39
+ /**
40
+ * The names the slice reads without defining them, so running it on its own would fail with
41
+ * `object 'x' not found`. Empty when the slice is closed under the names it uses.
42
+ */
43
+ readonly freeNames?: readonly string[];
34
44
  }