@eagleoutice/flowr 2.10.6 → 2.10.8

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 (78) hide show
  1. package/README.md +9 -9
  2. package/abstract-interpretation/domains/multi-value-state-domain.d.ts +4 -10
  3. package/abstract-interpretation/domains/multi-value-state-domain.js +1 -6
  4. package/abstract-interpretation/domains/partial-product-domain.d.ts +6 -2
  5. package/abstract-interpretation/domains/partial-product-domain.js +7 -3
  6. package/control-flow/semantic-cfg-guided-visitor.js +1 -0
  7. package/dataflow/environments/built-in-proc-name.d.ts +22 -20
  8. package/dataflow/environments/built-in-proc-name.js +22 -20
  9. package/dataflow/environments/built-in.d.ts +19 -19
  10. package/dataflow/environments/identifier.d.ts +5 -0
  11. package/dataflow/environments/reference-to-maybe.js +32 -6
  12. package/dataflow/eval/resolve/alias-tracking.js +5 -0
  13. package/dataflow/graph/graph.js +51 -30
  14. package/dataflow/graph/vertex.d.ts +12 -11
  15. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +49 -12
  16. package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +4 -2
  17. package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +12 -6
  18. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +22 -8
  19. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +57 -1
  20. package/dataflow/internal/process/functions/call/built-in/built-in-new-env.d.ts +1 -1
  21. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +7 -7
  22. package/documentation/wiki-linting-and-testing.js +1 -1
  23. package/documentation/wiki-mk/doc-context.d.ts +21 -1
  24. package/documentation/wiki-mk/doc-context.js +9 -0
  25. package/documentation/wiki-search.js +13 -2
  26. package/linter/linter-format.d.ts +4 -0
  27. package/linter/linter-rules.d.ts +9 -7
  28. package/linter/rules/absolute-path.d.ts +3 -2
  29. package/linter/rules/absolute-path.js +37 -12
  30. package/linter/rules/dataframe-access-validation.d.ts +4 -7
  31. package/linter/rules/dataframe-access-validation.js +3 -3
  32. package/linter/rules/dead-code.d.ts +4 -7
  33. package/linter/rules/file-path-validity.d.ts +9 -4
  34. package/linter/rules/file-path-validity.js +83 -36
  35. package/linter/rules/function-finder-util.d.ts +1 -3
  36. package/linter/rules/function-finder-util.js +2 -2
  37. package/linter/rules/naming-convention.d.ts +0 -2
  38. package/linter/rules/network-functions.js +4 -1
  39. package/linter/rules/problematic-inputs.d.ts +0 -2
  40. package/linter/rules/problematic-inputs.js +4 -1
  41. package/linter/rules/roxygen-arguments.d.ts +0 -2
  42. package/linter/rules/seeded-randomness.d.ts +0 -2
  43. package/linter/rules/stop-with-call-arg.d.ts +3 -6
  44. package/linter/rules/unused-definition.d.ts +0 -2
  45. package/linter/rules/useless-loop.d.ts +0 -2
  46. package/package.json +7 -6
  47. package/queries/catalog/dependencies-query/dependencies-query-executor.js +6 -2
  48. package/queries/catalog/dependencies-query/function-info/function-info.d.ts +2 -0
  49. package/queries/catalog/dependencies-query/function-info/read-functions.js +21 -1
  50. package/queries/catalog/dependencies-query/function-info/source-functions.js +1 -1
  51. package/queries/catalog/dependencies-query/function-info/write-functions.js +18 -1
  52. package/queries/catalog/input-sources-query/input-source-functions.d.ts +3 -1
  53. package/queries/catalog/input-sources-query/input-source-functions.js +322 -46
  54. package/queries/catalog/input-sources-query/input-sources-query-executor.js +14 -9
  55. package/queries/catalog/input-sources-query/input-sources-query-format.d.ts +4 -2
  56. package/queries/catalog/input-sources-query/input-sources-query-format.js +8 -4
  57. package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +13 -6
  58. package/queries/catalog/input-sources-query/simple-input-classifier.js +33 -8
  59. package/queries/catalog/linter-query/linter-query-format.d.ts +2 -2
  60. package/queries/catalog/linter-query/linter-query-format.js +9 -3
  61. package/queries/query.d.ts +3 -2
  62. package/r-bridge/lang-4.x/ast/model/processing/decorate.d.ts +1 -1
  63. package/r-bridge/lang-4.x/ast/model/processing/decorate.js +16 -16
  64. package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +6 -0
  65. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +8 -0
  66. package/search/flowr-search-builder.d.ts +64 -16
  67. package/search/flowr-search-builder.js +41 -16
  68. package/search/flowr-search-filters.d.ts +10 -1
  69. package/search/flowr-search-filters.js +10 -0
  70. package/search/flowr-search.d.ts +17 -3
  71. package/search/search-executor/search-generators.d.ts +3 -1
  72. package/search/search-executor/search-generators.js +30 -4
  73. package/slicing/static/static-slicer.js +2 -2
  74. package/util/range.d.ts +13 -1
  75. package/util/range.js +32 -2
  76. package/util/text/strings.d.ts +7 -0
  77. package/util/text/strings.js +23 -0
  78. package/util/version.js +1 -1
@@ -112,11 +112,17 @@ exports.LinterQueryDefinition = {
112
112
  rules: joi_1.default.array().items(joi_1.default.string().valid(...Object.keys(linter_rules_1.LintingRules)), joi_1.default.object({
113
113
  name: joi_1.default.string().valid(...Object.keys(linter_rules_1.LintingRules)).required(),
114
114
  config: joi_1.default.object()
115
- })).description('The rules to lint for. If unset, all rules will be included.')
115
+ })).description('The rules to lint for. If unset, all rules will be included.'),
116
116
  }).description('The linter query lints for the given set of rules and returns the result.'),
117
- flattenInvolvedNodes: (queryResults) => {
117
+ flattenInvolvedNodes: (queryResults, _queries, certainty) => {
118
118
  const out = queryResults;
119
- return Object.values(out.results).flatMap(v => Array.from(linter_format_1.LintingResults.allInvolvedIds(v))).filter(assert_1.isNotUndefined);
119
+ return Object.values(out.results).flatMap(v => {
120
+ if (linter_format_1.LintingResults.isError(v)) {
121
+ return [];
122
+ }
123
+ const rows = certainty !== undefined ? v.results.filter(r => r.certainty === certainty) : v.results;
124
+ return rows.flatMap(r => r.involvedId);
125
+ }).filter(assert_1.isNotUndefined);
120
126
  }
121
127
  };
122
128
  function addLintingRuleResult(ruleName, results, result) {
@@ -35,6 +35,7 @@ import type { DoesCallQuery } from './catalog/does-call-query/does-call-query-fo
35
35
  import type { InspectExceptionQuery } from './catalog/inspect-exceptions-query/inspect-exception-query-format';
36
36
  import type { InputSourcesQuery } from './catalog/input-sources-query/input-sources-query-format';
37
37
  import type { ProvenanceQuery } from './catalog/provenance-query/provenance-query-format';
38
+ import type { LintingResultCertainty } from '../linter/linter-format';
38
39
  /**
39
40
  * These are all queries that can be executed from within flowR
40
41
  */
@@ -69,7 +70,7 @@ export interface SupportedQuery<QueryType extends BaseQueryFormat['type'] = Base
69
70
  * Flattens the involved query nodes to be added to a flowR search when the {@link fromQuery} function is used based on the given result after this query is executed.
70
71
  * If this query does not involve any nodes, an empty array can be returned.
71
72
  */
72
- flattenInvolvedNodes: (queryResults: BaseQueryResult, query: readonly Query[]) => NodeId[];
73
+ flattenInvolvedNodes: (queryResults: BaseQueryResult, query: readonly Query[], certainty?: LintingResultCertainty) => NodeId[];
73
74
  }
74
75
  export declare const SupportedQueries: {
75
76
  readonly 'call-context': {
@@ -244,7 +245,7 @@ export declare const SupportedQueries: {
244
245
  readonly completer: (line: readonly string[], startingNewArg: boolean, _config: FlowrConfig) => CommandCompletions;
245
246
  readonly fromLine: (output: ReplOutput, line: readonly string[], _config: FlowrConfig) => ParsedQueryLine<"linter">;
246
247
  readonly schema: Joi.ObjectSchema<any>;
247
- readonly flattenInvolvedNodes: (queryResults: BaseQueryResult) => ((string & {
248
+ readonly flattenInvolvedNodes: (queryResults: BaseQueryResult, _queries: readonly Query[], certainty: LintingResultCertainty | undefined) => ((string & {
248
249
  __brand?: "node-id";
249
250
  }) | (number & {
250
251
  __brand?: "node-id";
@@ -52,7 +52,7 @@ export interface ParentContextInfo extends MergeableRecord {
52
52
  *
53
53
  * The root node has a nesting of 0, contexts listed in ${@link nestForElement} will increase the nesting
54
54
  */
55
- nesting: number;
55
+ nest: number;
56
56
  /**
57
57
  * 0-based index of the child in the parent (code semantics, e.g., for an if-then-else, the condition will be 0, the then-case will be 1, ...)
58
58
  *
@@ -154,7 +154,7 @@ function createFoldForLeaf(info) {
154
154
  id,
155
155
  parent: undefined,
156
156
  ...defaultParentContext,
157
- nesting
157
+ nest: nesting
158
158
  }
159
159
  };
160
160
  decorated.info.file = info.file;
@@ -163,9 +163,9 @@ function createFoldForLeaf(info) {
163
163
  };
164
164
  }
165
165
  function createFoldForBinaryOp(info) {
166
- return (data, lhs, rhs, nesting) => {
166
+ return (data, lhs, rhs, nest) => {
167
167
  const id = info.getId(data);
168
- const decorated = { ...data, info: { ...data.info, id, parent: undefined, nesting }, lhs, rhs };
168
+ const decorated = { ...data, info: { ...data.info, id, parent: undefined, nest }, lhs, rhs };
169
169
  info.idMap.set(id, decorated);
170
170
  const lhsInfo = lhs.info;
171
171
  lhsInfo.parent = id;
@@ -185,9 +185,9 @@ function createFoldForBinaryOp(info) {
185
185
  };
186
186
  }
187
187
  function createFoldForUnaryOp(info) {
188
- return (data, operand, nesting) => {
188
+ return (data, operand, nest) => {
189
189
  const id = info.getId(data);
190
- const decorated = { ...data, info: { ...data.info, id, parent: undefined, nesting }, operand };
190
+ const decorated = { ...data, info: { ...data.info, id, parent: undefined, nest }, operand };
191
191
  info.idMap.set(id, decorated);
192
192
  const opInfo = operand.info;
193
193
  opInfo.parent = id;
@@ -199,7 +199,7 @@ function createFoldForUnaryOp(info) {
199
199
  function createFoldForAccess(info) {
200
200
  return (data, accessed, access, nesting) => {
201
201
  const id = info.getId(data);
202
- const decorated = { ...data, info: { ...data.info, id, parent: undefined, nesting }, accessed, access };
202
+ const decorated = { ...data, info: { ...data.info, id, parent: undefined, nest: nesting }, accessed, access };
203
203
  info.idMap.set(id, decorated);
204
204
  const accessedInfo = accessed.info;
205
205
  accessedInfo.parent = id;
@@ -223,7 +223,7 @@ function createFoldForAccess(info) {
223
223
  function createFoldForForLoop(info) {
224
224
  return (data, variable, vector, body, nesting) => {
225
225
  const id = info.getId(data);
226
- const decorated = { ...data, info: { ...data.info, id, parent: undefined, nesting }, variable, vector, body };
226
+ const decorated = { ...data, info: { ...data.info, id, parent: undefined, nest: nesting }, variable, vector, body };
227
227
  info.idMap.set(id, decorated);
228
228
  const varInfo = variable.info;
229
229
  varInfo.parent = id;
@@ -243,7 +243,7 @@ function createFoldForForLoop(info) {
243
243
  function createFoldForRepeatLoop(info) {
244
244
  return (data, body, nesting) => {
245
245
  const id = info.getId(data);
246
- const decorated = { ...data, info: { ...data.info, id, parent: undefined, nesting }, body };
246
+ const decorated = { ...data, info: { ...data.info, id, parent: undefined, nest: nesting }, body };
247
247
  info.idMap.set(id, decorated);
248
248
  const bodyInfo = body.info;
249
249
  bodyInfo.parent = id;
@@ -255,7 +255,7 @@ function createFoldForRepeatLoop(info) {
255
255
  function createFoldForWhileLoop(info) {
256
256
  return (data, condition, body, nesting) => {
257
257
  const id = info.getId(data);
258
- const decorated = { ...data, info: { ...data.info, id, parent: undefined, nesting }, condition, body };
258
+ const decorated = { ...data, info: { ...data.info, id, parent: undefined, nest: nesting }, condition, body };
259
259
  info.idMap.set(id, decorated);
260
260
  const condInfo = condition.info;
261
261
  condInfo.parent = id;
@@ -271,7 +271,7 @@ function createFoldForWhileLoop(info) {
271
271
  function createFoldForIfThenElse(info) {
272
272
  return (data, condition, then, otherwise, nesting) => {
273
273
  const id = info.getId(data);
274
- const decorated = { ...data, info: { ...data.info, id, parent: undefined, nesting }, condition, then, otherwise };
274
+ const decorated = { ...data, info: { ...data.info, id, parent: undefined, nest: nesting }, condition, then, otherwise };
275
275
  info.idMap.set(id, decorated);
276
276
  const condInfo = condition.info;
277
277
  condInfo.parent = id;
@@ -293,7 +293,7 @@ function createFoldForIfThenElse(info) {
293
293
  function createFoldForExprList(info) {
294
294
  return (data, grouping, children, nesting) => {
295
295
  const id = info.getId(data);
296
- const decorated = { ...data, info: { ...data.info, id, parent: undefined, nesting }, grouping, children };
296
+ const decorated = { ...data, info: { ...data.info, id, parent: undefined, nest: nesting }, grouping, children };
297
297
  info.idMap.set(id, decorated);
298
298
  let i = 0;
299
299
  for (const child of children) {
@@ -317,10 +317,10 @@ function createFoldForFunctionCall(info) {
317
317
  const id = info.getId(data);
318
318
  let decorated;
319
319
  if (data.named) {
320
- decorated = { ...data, info: { ...data.info, id, parent: undefined, nesting }, functionName, arguments: args };
320
+ decorated = { ...data, info: { ...data.info, id, parent: undefined, nest: nesting }, functionName, arguments: args };
321
321
  }
322
322
  else {
323
- decorated = { ...data, info: { ...data.info, id, parent: undefined, nesting }, calledFunction: functionName, arguments: args };
323
+ decorated = { ...data, info: { ...data.info, id, parent: undefined, nest: nesting }, calledFunction: functionName, arguments: args };
324
324
  }
325
325
  info.idMap.set(id, decorated);
326
326
  const funcInfo = functionName.info;
@@ -343,7 +343,7 @@ function createFoldForFunctionCall(info) {
343
343
  function createFoldForFunctionDefinition(info) {
344
344
  return (data, params, body, nesting) => {
345
345
  const id = info.getId(data);
346
- const decorated = { ...data, info: { ...data.info, id, parent: undefined, nesting }, parameters: params, body };
346
+ const decorated = { ...data, info: { ...data.info, id, parent: undefined, nest: nesting }, parameters: params, body };
347
347
  info.idMap.set(id, decorated);
348
348
  let idx = 0;
349
349
  for (const param of params) {
@@ -363,7 +363,7 @@ function createFoldForFunctionDefinition(info) {
363
363
  function createFoldForFunctionParameter(info) {
364
364
  return (data, name, defaultValue, nesting) => {
365
365
  const id = info.getId(data);
366
- const decorated = { ...data, info: { ...data.info, id, parent: undefined, nesting }, name, defaultValue };
366
+ const decorated = { ...data, info: { ...data.info, id, parent: undefined, nest: nesting }, name, defaultValue };
367
367
  info.idMap.set(id, decorated);
368
368
  const nameInfo = name.info;
369
369
  nameInfo.parent = id;
@@ -381,7 +381,7 @@ function createFoldForFunctionParameter(info) {
381
381
  function createFoldForFunctionArgument(info) {
382
382
  return (data, name, value, nesting) => {
383
383
  const id = info.getId(data);
384
- const decorated = { ...data, info: { ...data.info, id, parent: undefined, nesting }, name, value };
384
+ const decorated = { ...data, info: { ...data.info, id, parent: undefined, nest: nesting }, name, value };
385
385
  info.idMap.set(id, decorated);
386
386
  let idx = 0;
387
387
  if (name) {
@@ -1,5 +1,6 @@
1
1
  import type { AstIdMap } from './decorate';
2
2
  import type { DataflowGraph } from '../../../../../dataflow/graph/graph';
3
+ import type { BuiltInProcName } from '../../../../../dataflow/environments/built-in-proc-name';
3
4
  /** The type of the id assigned to each node. Branded to avoid problematic usages with other string or numeric types. */
4
5
  export type NodeId<T extends string | number = string | number> = T & {
5
6
  __brand?: 'node-id';
@@ -36,6 +37,11 @@ export declare const NodeId: {
36
37
  * @see {@link fromBuiltIn} - to recover the built-in function or operator name from a built-in id
37
38
  */
38
39
  readonly toBuiltIn: <T extends string>(this: void, name: T) => BuiltIn<T>;
40
+ /**
41
+ * Converts a built-in function or operator name or id to a built-in id by prefixing it with the built-in prefix if it is not already a built-in id.
42
+ * This allows us to accept both built-in names and ids in contexts where we want to work with built-in ids.
43
+ */
44
+ readonly mapBuiltInProc: <T extends BuiltInProcName>(this: void, proc: T) => T extends `builtin:${infer S}` ? BuiltIn<S> : BuiltIn<T>;
39
45
  /**
40
46
  * Recovers the built-in function or operator name from a built-in id by removing the built-in prefix.
41
47
  * @see {@link isBuiltIn} - to check if a given node id is a built-in function or operator id
@@ -48,6 +48,14 @@ exports.NodeId = {
48
48
  toBuiltIn(name) {
49
49
  return `built-in:${name}`;
50
50
  },
51
+ /**
52
+ * Converts a built-in function or operator name or id to a built-in id by prefixing it with the built-in prefix if it is not already a built-in id.
53
+ * This allows us to accept both built-in names and ids in contexts where we want to work with built-in ids.
54
+ */
55
+ mapBuiltInProc(proc) {
56
+ const bi = 'builtin:';
57
+ return exports.NodeId.toBuiltIn(proc.startsWith(bi) ? proc.substring(bi.length) : proc);
58
+ },
51
59
  /**
52
60
  * Recovers the built-in function or operator name from a built-in id by removing the built-in prefix.
53
61
  * @see {@link isBuiltIn} - to check if a given node id is a built-in function or operator id
@@ -8,15 +8,26 @@ import type { ParentInformation } from '../r-bridge/lang-4.x/ast/model/processin
8
8
  import type { Enrichment, EnrichmentElementArguments } from './search-executor/search-enrichers';
9
9
  import { type MapperArguments, Mapper } from './search-executor/search-mappers';
10
10
  import type { Query } from '../queries/query';
11
+ import type { LintingResultCertainty } from '../linter/linter-format';
11
12
  import type TreeSitter from 'web-tree-sitter';
12
13
  type FlowrCriteriaReturn<C extends SlicingCriteria> = FlowrSearchElements<ParentInformation, C extends [] ? never : C extends [infer _] ? [
13
14
  FlowrSearchElement<ParentInformation>
14
15
  ] : FlowrSearchElement<ParentInformation>[]>;
16
+ /**
17
+ * Returns all elements (nodes/dataflow vertices) from the given data without any filters.
18
+ */
19
+ declare function all(): FlowrSearchBuilder<'all'>;
20
+ /**
21
+ * Returns all elements (nodes/dataflow vertices) that match the given file path regex.
22
+ * This internally uses {@link get} to filter by file path.
23
+ */
24
+ declare function all(filePathRegex: string): FlowrSearchBuilder<'get'>;
15
25
  /**
16
26
  * This object holds all the methods to generate search queries.
17
27
  * For compatibility, please use the {@link Q} identifier object to access these methods.
18
28
  */
19
29
  export declare const FlowrSearchGenerator: {
30
+ readonly name: "FlowrSearchGenerator";
20
31
  /**
21
32
  * Initialize a search query with the given elements.
22
33
  * <b>This is not intended to serialize well</b> wrt. the nodes,
@@ -28,16 +39,16 @@ export declare const FlowrSearchGenerator: {
28
39
  * Internally, the {@link SupportedQuery#flattenInvolvedNodes} function is used to flatten the resulting nodes of the query.
29
40
  * Please note that, due to the fact that not every query involves dataflow nodes, the search may not contain any elements at all for certain queries.
30
41
  */
31
- readonly fromQuery: (...from: readonly Query[]) => FlowrSearchBuilder<"from-query", [], ParentInformation, FlowrSearchElements<ParentInformation, FlowrSearchElement<ParentInformation>[]>>;
42
+ readonly fromQuery: (from: Query | readonly Query[], certainty?: LintingResultCertainty) => FlowrSearchBuilder<"from-query", [], ParentInformation, FlowrSearchElements<ParentInformation, FlowrSearchElement<ParentInformation>[]>>;
32
43
  /**
33
44
  * Initializes a new search query based on the results of the given tree-sitter syntax query.
34
45
  * Please note that this search generator is incompatible with the {@link RShell} parser and only works when using flowR with the {@link TreeSitterExecutor}.
35
46
  */
36
47
  readonly syntax: (source: TreeSitter.Query | string, ...captures: readonly string[]) => FlowrSearchBuilder<"from-query", [], ParentInformation, FlowrSearchElements<ParentInformation, FlowrSearchElement<ParentInformation>[]>>;
37
48
  /**
38
- * Returns all elements (nodes/dataflow vertices) from the given data.
49
+ * Returns all elements (nodes/dataflow vertices) from the given data without any (or with a filename filter).
39
50
  */
40
- readonly all: () => FlowrSearchBuilder<"all">;
51
+ readonly all: typeof all;
41
52
  /**
42
53
  * Returns all elements that match the given {@link FlowrSearchGetFilters|filters}.
43
54
  * You may pass a negative line number to count from the back.
@@ -54,24 +65,42 @@ export declare const FlowrSearchGenerator: {
54
65
  /**
55
66
  * Short form of {@link get} with only the
56
67
  * {@link FlowrSearchGetFilters#line|line} and {@link FlowrSearchGetFilters#column|column} filters:
57
- * `get({line, column})`.
68
+ * `get({line, column})`. Please use {@link FlowrSearchGenerator#locFuzzy|locFuzzy} for a fuzzy location search.
69
+ * @param line - the line number to search in
70
+ * @param column - the column number to search in
71
+ * @param filePathRegex - optional regex to filter by file path
58
72
  */
59
- readonly loc: (line?: number, column?: number) => FlowrSearchBuilder<"get">;
73
+ readonly loc: (line?: number, column?: number, filePathRegex?: string) => FlowrSearchBuilder<"get">;
74
+ /**
75
+ * Fuzzy variant of {@link loc} that matches any node whose source range contains the given position.
76
+ * @param line - the line number to search in (required for fuzzy matching)
77
+ * @param column - the column number to search in
78
+ * @param innermostOnly - if true, return only the deepest (innermost) matching nodes in the AST
79
+ * @param filePathRegex - optional regex to filter by file path
80
+ */
81
+ readonly locFuzzy: (line: number, column?: number, innermostOnly?: boolean, filePathRegex?: string) => FlowrSearchBuilder<"get">;
60
82
  /**
61
83
  * Short form of {@link get} with only the {@link FlowrSearchGetFilters#name|name} and {@link FlowrSearchGetFilters#line|line} filters:
62
84
  * `get({name, line})`.
85
+ * @param name - the variable name to search for
86
+ * @param line - the line number to search in
87
+ * @param filePathRegex - optional regex to filter by file path
63
88
  */
64
- readonly varInLine: (name: string, line: number) => FlowrSearchBuilder<"get">;
89
+ readonly varInLine: (name: string, line: number, filePathRegex?: string) => FlowrSearchBuilder<"get">;
65
90
  /**
66
91
  * Short form of {@link get} with only the {@link FlowrSearchGetFilters#name|name} filter:
67
92
  * `get({name})`.
93
+ * @param name - the variable name to search for
94
+ * @param filePathRegex - optional regex to filter by file path
68
95
  */
69
- readonly var: (name: string) => FlowrSearchBuilder<"get">;
96
+ readonly var: (name: string, filePathRegex?: string) => FlowrSearchBuilder<"get">;
70
97
  /**
71
98
  * Short form of {@link get} with only the {@link FlowrSearchGetFilters#id|id} filter:
72
99
  * `get({id})`.
100
+ * @param id - the node id to search for
101
+ * @param filePathRegex - optional regex to filter by file path
73
102
  */
74
- readonly id: (id: NodeId) => FlowrSearchBuilder<"get">;
103
+ readonly id: (id: NodeId, filePathRegex?: string) => FlowrSearchBuilder<"get">;
75
104
  };
76
105
  /**
77
106
  * This is the root object to use for creating searches.
@@ -80,6 +109,7 @@ export declare const FlowrSearchGenerator: {
80
109
  * you can use what is provided by the {@link FlowrSearchBuilder} to further refine the search.
81
110
  */
82
111
  export declare const Q: {
112
+ readonly name: "FlowrSearchGenerator";
83
113
  /**
84
114
  * Initialize a search query with the given elements.
85
115
  * <b>This is not intended to serialize well</b> wrt. the nodes,
@@ -91,16 +121,16 @@ export declare const Q: {
91
121
  * Internally, the {@link SupportedQuery#flattenInvolvedNodes} function is used to flatten the resulting nodes of the query.
92
122
  * Please note that, due to the fact that not every query involves dataflow nodes, the search may not contain any elements at all for certain queries.
93
123
  */
94
- readonly fromQuery: (...from: readonly Query[]) => FlowrSearchBuilder<"from-query", [], ParentInformation, FlowrSearchElements<ParentInformation, FlowrSearchElement<ParentInformation>[]>>;
124
+ readonly fromQuery: (from: Query | readonly Query[], certainty?: LintingResultCertainty) => FlowrSearchBuilder<"from-query", [], ParentInformation, FlowrSearchElements<ParentInformation, FlowrSearchElement<ParentInformation>[]>>;
95
125
  /**
96
126
  * Initializes a new search query based on the results of the given tree-sitter syntax query.
97
127
  * Please note that this search generator is incompatible with the {@link RShell} parser and only works when using flowR with the {@link TreeSitterExecutor}.
98
128
  */
99
129
  readonly syntax: (source: TreeSitter.Query | string, ...captures: readonly string[]) => FlowrSearchBuilder<"from-query", [], ParentInformation, FlowrSearchElements<ParentInformation, FlowrSearchElement<ParentInformation>[]>>;
100
130
  /**
101
- * Returns all elements (nodes/dataflow vertices) from the given data.
131
+ * Returns all elements (nodes/dataflow vertices) from the given data without any (or with a filename filter).
102
132
  */
103
- readonly all: () => FlowrSearchBuilder<"all">;
133
+ readonly all: typeof all;
104
134
  /**
105
135
  * Returns all elements that match the given {@link FlowrSearchGetFilters|filters}.
106
136
  * You may pass a negative line number to count from the back.
@@ -117,24 +147,42 @@ export declare const Q: {
117
147
  /**
118
148
  * Short form of {@link get} with only the
119
149
  * {@link FlowrSearchGetFilters#line|line} and {@link FlowrSearchGetFilters#column|column} filters:
120
- * `get({line, column})`.
150
+ * `get({line, column})`. Please use {@link FlowrSearchGenerator#locFuzzy|locFuzzy} for a fuzzy location search.
151
+ * @param line - the line number to search in
152
+ * @param column - the column number to search in
153
+ * @param filePathRegex - optional regex to filter by file path
154
+ */
155
+ readonly loc: (line?: number, column?: number, filePathRegex?: string) => FlowrSearchBuilder<"get">;
156
+ /**
157
+ * Fuzzy variant of {@link loc} that matches any node whose source range contains the given position.
158
+ * @param line - the line number to search in (required for fuzzy matching)
159
+ * @param column - the column number to search in
160
+ * @param innermostOnly - if true, return only the deepest (innermost) matching nodes in the AST
161
+ * @param filePathRegex - optional regex to filter by file path
121
162
  */
122
- readonly loc: (line?: number, column?: number) => FlowrSearchBuilder<"get">;
163
+ readonly locFuzzy: (line: number, column?: number, innermostOnly?: boolean, filePathRegex?: string) => FlowrSearchBuilder<"get">;
123
164
  /**
124
165
  * Short form of {@link get} with only the {@link FlowrSearchGetFilters#name|name} and {@link FlowrSearchGetFilters#line|line} filters:
125
166
  * `get({name, line})`.
167
+ * @param name - the variable name to search for
168
+ * @param line - the line number to search in
169
+ * @param filePathRegex - optional regex to filter by file path
126
170
  */
127
- readonly varInLine: (name: string, line: number) => FlowrSearchBuilder<"get">;
171
+ readonly varInLine: (name: string, line: number, filePathRegex?: string) => FlowrSearchBuilder<"get">;
128
172
  /**
129
173
  * Short form of {@link get} with only the {@link FlowrSearchGetFilters#name|name} filter:
130
174
  * `get({name})`.
175
+ * @param name - the variable name to search for
176
+ * @param filePathRegex - optional regex to filter by file path
131
177
  */
132
- readonly var: (name: string) => FlowrSearchBuilder<"get">;
178
+ readonly var: (name: string, filePathRegex?: string) => FlowrSearchBuilder<"get">;
133
179
  /**
134
180
  * Short form of {@link get} with only the {@link FlowrSearchGetFilters#id|id} filter:
135
181
  * `get({id})`.
182
+ * @param id - the node id to search for
183
+ * @param filePathRegex - optional regex to filter by file path
136
184
  */
137
- readonly id: (id: NodeId) => FlowrSearchBuilder<"get">;
185
+ readonly id: (id: NodeId, filePathRegex?: string) => FlowrSearchBuilder<"get">;
138
186
  };
139
187
  export type FlowrSearchBuilderType<Generator extends GeneratorNames = GeneratorNames, Transformers extends TransformerNames[] = TransformerNames[], Info = ParentInformation, ElementType = FlowrSearchElements<Info, FlowrSearchElement<Info>[]>> = FlowrSearchBuilder<Generator, Transformers, Info, ElementType>;
140
188
  /**
@@ -5,12 +5,18 @@ exports.getFlowrSearch = getFlowrSearch;
5
5
  const search_optimizer_1 = require("./search-optimizer/search-optimizer");
6
6
  const assert_1 = require("../util/assert");
7
7
  const search_mappers_1 = require("./search-executor/search-mappers");
8
- const AllGeneratorObj = { type: 'generator', name: 'all', args: undefined };
8
+ function all(filePathRegex) {
9
+ if (!filePathRegex) {
10
+ return new FlowrSearchBuilder({ type: 'generator', name: 'all', args: undefined });
11
+ }
12
+ return exports.FlowrSearchGenerator.get({ filePathRegex });
13
+ }
9
14
  /**
10
15
  * This object holds all the methods to generate search queries.
11
16
  * For compatibility, please use the {@link Q} identifier object to access these methods.
12
17
  */
13
18
  exports.FlowrSearchGenerator = {
19
+ name: 'FlowrSearchGenerator',
14
20
  /**
15
21
  * Initialize a search query with the given elements.
16
22
  * <b>This is not intended to serialize well</b> wrt. the nodes,
@@ -24,8 +30,9 @@ exports.FlowrSearchGenerator = {
24
30
  * Internally, the {@link SupportedQuery#flattenInvolvedNodes} function is used to flatten the resulting nodes of the query.
25
31
  * Please note that, due to the fact that not every query involves dataflow nodes, the search may not contain any elements at all for certain queries.
26
32
  */
27
- fromQuery(...from) {
28
- return new FlowrSearchBuilder({ type: 'generator', name: 'from-query', args: { from } });
33
+ fromQuery(from, certainty) {
34
+ const queries = Array.isArray(from) ? from : [from];
35
+ return new FlowrSearchBuilder({ type: 'generator', name: 'from-query', args: { from: queries, certainty } });
29
36
  },
30
37
  /**
31
38
  * Initializes a new search query based on the results of the given tree-sitter syntax query.
@@ -35,11 +42,9 @@ exports.FlowrSearchGenerator = {
35
42
  return new FlowrSearchBuilder({ type: 'generator', name: 'syntax', args: { source, captures } });
36
43
  },
37
44
  /**
38
- * Returns all elements (nodes/dataflow vertices) from the given data.
45
+ * Returns all elements (nodes/dataflow vertices) from the given data without any (or with a filename filter).
39
46
  */
40
- all() {
41
- return new FlowrSearchBuilder(AllGeneratorObj);
42
- },
47
+ all: all,
43
48
  /**
44
49
  * Returns all elements that match the given {@link FlowrSearchGetFilters|filters}.
45
50
  * You may pass a negative line number to count from the back.
@@ -64,31 +69,51 @@ exports.FlowrSearchGenerator = {
64
69
  /**
65
70
  * Short form of {@link get} with only the
66
71
  * {@link FlowrSearchGetFilters#line|line} and {@link FlowrSearchGetFilters#column|column} filters:
67
- * `get({line, column})`.
72
+ * `get({line, column})`. Please use {@link FlowrSearchGenerator#locFuzzy|locFuzzy} for a fuzzy location search.
73
+ * @param line - the line number to search in
74
+ * @param column - the column number to search in
75
+ * @param filePathRegex - optional regex to filter by file path
76
+ */
77
+ loc(line, column, filePathRegex) {
78
+ return exports.FlowrSearchGenerator.get({ line, column, filePathRegex });
79
+ },
80
+ /**
81
+ * Fuzzy variant of {@link loc} that matches any node whose source range contains the given position.
82
+ * @param line - the line number to search in (required for fuzzy matching)
83
+ * @param column - the column number to search in
84
+ * @param innermostOnly - if true, return only the deepest (innermost) matching nodes in the AST
85
+ * @param filePathRegex - optional regex to filter by file path
68
86
  */
69
- loc(line, column) {
70
- return exports.FlowrSearchGenerator.get({ line, column });
87
+ locFuzzy(line, column, innermostOnly, filePathRegex) {
88
+ return exports.FlowrSearchGenerator.get({ line, column, fuzzy: true, innermostOnly: innermostOnly ?? false, filePathRegex });
71
89
  },
72
90
  /**
73
91
  * Short form of {@link get} with only the {@link FlowrSearchGetFilters#name|name} and {@link FlowrSearchGetFilters#line|line} filters:
74
92
  * `get({name, line})`.
93
+ * @param name - the variable name to search for
94
+ * @param line - the line number to search in
95
+ * @param filePathRegex - optional regex to filter by file path
75
96
  */
76
- varInLine(name, line) {
77
- return exports.FlowrSearchGenerator.get({ name, line });
97
+ varInLine(name, line, filePathRegex) {
98
+ return exports.FlowrSearchGenerator.get({ name, line, filePathRegex });
78
99
  },
79
100
  /**
80
101
  * Short form of {@link get} with only the {@link FlowrSearchGetFilters#name|name} filter:
81
102
  * `get({name})`.
103
+ * @param name - the variable name to search for
104
+ * @param filePathRegex - optional regex to filter by file path
82
105
  */
83
- var(name) {
84
- return exports.FlowrSearchGenerator.get({ name });
106
+ var(name, filePathRegex) {
107
+ return exports.FlowrSearchGenerator.get({ name, filePathRegex });
85
108
  },
86
109
  /**
87
110
  * Short form of {@link get} with only the {@link FlowrSearchGetFilters#id|id} filter:
88
111
  * `get({id})`.
112
+ * @param id - the node id to search for
113
+ * @param filePathRegex - optional regex to filter by file path
89
114
  */
90
- id(id) {
91
- return exports.FlowrSearchGenerator.get({ id });
115
+ id(id, filePathRegex) {
116
+ return exports.FlowrSearchGenerator.get({ id, filePathRegex });
92
117
  }
93
118
  };
94
119
  /**
@@ -26,7 +26,12 @@ export declare enum FlowrFilter {
26
26
  * Only returns search elements whose {@link FunctionOriginInformation} match a given pattern or value.
27
27
  * This filter accepts {@link OriginKindArgs}, which includes the {@link DataflowGraphVertexFunctionCall.origin} to match for, whether to match for every or some origins, and whether to include non-function-calls in the filtered query.
28
28
  */
29
- OriginKind = "origin-kind"
29
+ OriginKind = "origin-kind",
30
+ /**
31
+ * Only returns search elements whose file path matches the given regular expression.
32
+ * This filter accepts {@link FilePathFilterArgs}, which includes the file path regex to test against.
33
+ */
34
+ FilePathFilter = "file-path-filter"
30
35
  }
31
36
  export type FlowrFilterFunction<T> = (e: FlowrSearchElement<ParentInformation>, args: T, data: {
32
37
  dataflow: DataflowInformation;
@@ -41,6 +46,7 @@ export declare const FlowrFilters: {
41
46
  readonly "origin-kind": (e: FlowrSearchElement<ParentInformation>, args: OriginKindArgs, data: {
42
47
  dataflow: DataflowInformation;
43
48
  }) => boolean;
49
+ readonly "file-path-filter": (e: FlowrSearchElement<ParentInformation>, args: FilePathFilterArgs) => boolean;
44
50
  };
45
51
  export type FlowrFilterArgs<F extends FlowrFilter> = typeof FlowrFilters[F] extends FlowrFilterFunction<infer Args> ? Args : never;
46
52
  export interface MatchesEnrichmentArgs<E extends Enrichment> {
@@ -52,6 +58,9 @@ export interface OriginKindArgs {
52
58
  matchType?: 'some' | 'every';
53
59
  keepNonFunctionCalls?: boolean;
54
60
  }
61
+ export interface FilePathFilterArgs {
62
+ filePathRegex: string | RegExp;
63
+ }
55
64
  /**
56
65
  * Helper to create a regular expression that matches function names, ignoring their package.
57
66
  */
@@ -27,6 +27,11 @@ var FlowrFilter;
27
27
  * This filter accepts {@link OriginKindArgs}, which includes the {@link DataflowGraphVertexFunctionCall.origin} to match for, whether to match for every or some origins, and whether to include non-function-calls in the filtered query.
28
28
  */
29
29
  FlowrFilter["OriginKind"] = "origin-kind";
30
+ /**
31
+ * Only returns search elements whose file path matches the given regular expression.
32
+ * This filter accepts {@link FilePathFilterArgs}, which includes the file path regex to test against.
33
+ */
34
+ FlowrFilter["FilePathFilter"] = "file-path-filter";
30
35
  })(FlowrFilter || (exports.FlowrFilter = FlowrFilter = {}));
31
36
  exports.ValidFlowrFilters = new Set(Object.values(FlowrFilter));
32
37
  exports.ValidFlowrFiltersReverse = Object.fromEntries(Object.entries(FlowrFilter).map(([k, v]) => [v, k]));
@@ -65,6 +70,11 @@ exports.FlowrFilters = {
65
70
  (origin) => args.origin.test(origin);
66
71
  const origins = Array.isArray(dfgNode.origin) ? dfgNode.origin : [dfgNode.origin];
67
72
  return args.matchType === 'every' ? origins.every(match) : origins.some(match);
73
+ }),
74
+ [FlowrFilter.FilePathFilter]: ((e, args) => {
75
+ const file = e.node.info.file;
76
+ const rx = args.filePathRegex instanceof RegExp ? args.filePathRegex : new RegExp(args.filePathRegex);
77
+ return rx.test(file ?? '');
68
78
  })
69
79
  };
70
80
  /**
@@ -42,17 +42,31 @@ export interface FlowrSearchGetFilter extends Record<string, unknown> {
42
42
  */
43
43
  readonly id?: NodeId;
44
44
  /**
45
- * The node must stem form a file with the given path matching the regex
45
+ * The node must stem from a file with the given path matching the regex.
46
+ * Inline code (code without a file path) is treated as having an empty path `""`.
46
47
  * Please note that you can address the full path!
47
48
  * @example
48
49
  * ```ts
49
50
  * // matches all files in any 'tests' folder
50
- * filePath: '.*\\tests\\.*'
51
+ * filePathRegex: '.*\\tests\\.*'
51
52
  * // matches all files named 'myfile.R' in any folder
52
- * filePath: '.*\\/myfile\\.R$'
53
+ * filePathRegex: '.*\\/myfile\\.R$'
54
+ * // matches only inline code
55
+ * filePathRegex: '^$'
56
+ * // matches inline code or .R files
57
+ * filePathRegex: '^$|.*\\.R$'
53
58
  * ```
54
59
  */
55
60
  readonly filePathRegex?: string;
61
+ /**
62
+ * If true, match any node whose source range contains the given line/column (fuzzy position match).
63
+ * Requires `line` to be provided.
64
+ */
65
+ readonly fuzzy?: boolean;
66
+ /**
67
+ * If true (and `fuzzy` is true), return only the innermost (deepest in the AST) matching node(s).
68
+ */
69
+ readonly innermostOnly?: boolean;
56
70
  }
57
71
  /** Intentionally, we abstract away from an array to avoid the use of conventional typescript operations */
58
72
  export declare class FlowrSearchElements<Info = NoInfo, Elements extends FlowrSearchElement<Info>[] = FlowrSearchElement<Info>[]> {
@@ -3,6 +3,7 @@ import type { TailTypesOrUndefined } from '../../util/collections/arrays';
3
3
  import type { ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
4
4
  import { type SlicingCriteria } from '../../slicing/criterion/parse';
5
5
  import { type Query } from '../../queries/query';
6
+ import type { LintingResultCertainty } from '../../linter/linter-format';
6
7
  import type { ReadonlyFlowrAnalysisProvider } from '../../project/flowr-analyzer';
7
8
  import type TreeSitter from 'web-tree-sitter';
8
9
  export declare const searchLogger: import("tslog").Logger<import("tslog").ILogObj>;
@@ -28,7 +29,7 @@ export declare const generators: {
28
29
  readonly syntax: typeof generateSyntax;
29
30
  };
30
31
  declare function generateAll(data: ReadonlyFlowrAnalysisProvider): Promise<FlowrSearchElements<ParentInformation>>;
31
- declare function generateGet(input: ReadonlyFlowrAnalysisProvider, { filter: { line, column, id, name, nameIsRegex, filePathRegex } }: {
32
+ declare function generateGet(input: ReadonlyFlowrAnalysisProvider, { filter: { line, column, id, name, nameIsRegex, filePathRegex, fuzzy, innermostOnly } }: {
32
33
  filter: FlowrSearchGetFilter;
33
34
  }): Promise<FlowrSearchElements<ParentInformation>>;
34
35
  declare function generateFrom(_input: ReadonlyFlowrAnalysisProvider, args: {
@@ -36,6 +37,7 @@ declare function generateFrom(_input: ReadonlyFlowrAnalysisProvider, args: {
36
37
  }): FlowrSearchElements<ParentInformation>;
37
38
  declare function generateFromQuery(input: ReadonlyFlowrAnalysisProvider, args: {
38
39
  from: readonly Query[];
40
+ certainty?: LintingResultCertainty;
39
41
  }): Promise<FlowrSearchElements<ParentInformation, FlowrSearchElement<ParentInformation>[]>>;
40
42
  declare function generateSyntax(input: ReadonlyFlowrAnalysisProvider, args: {
41
43
  source: TreeSitter.Query | string;