@eagleoutice/flowr 2.2.13 → 2.2.15

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 (145) hide show
  1. package/README.md +4 -4
  2. package/cli/repl/commands/repl-cfg.d.ts +2 -2
  3. package/cli/repl/commands/repl-cfg.js +4 -4
  4. package/cli/repl/commands/repl-commands.js +3 -3
  5. package/cli/repl/commands/repl-execute.js +2 -1
  6. package/cli/repl/server/connection.js +1 -1
  7. package/cli/script-core/statistics-helper-core.js +1 -1
  8. package/config.js +1 -1
  9. package/control-flow/basic-cfg-guided-visitor.d.ts +3 -3
  10. package/control-flow/cfg-dead-code.d.ts +4 -0
  11. package/control-flow/cfg-dead-code.js +81 -0
  12. package/control-flow/cfg-simplification.d.ts +17 -6
  13. package/control-flow/cfg-simplification.js +23 -19
  14. package/control-flow/control-flow-graph.d.ts +2 -1
  15. package/control-flow/control-flow-graph.js +1 -0
  16. package/control-flow/dfg-cfg-guided-visitor.d.ts +4 -4
  17. package/control-flow/dfg-cfg-guided-visitor.js +1 -1
  18. package/control-flow/extract-cfg.d.ts +2 -2
  19. package/control-flow/extract-cfg.js +70 -67
  20. package/control-flow/semantic-cfg-guided-visitor.d.ts +17 -8
  21. package/control-flow/semantic-cfg-guided-visitor.js +50 -17
  22. package/control-flow/simple-visitor.d.ts +4 -0
  23. package/control-flow/simple-visitor.js +14 -0
  24. package/control-flow/syntax-cfg-guided-visitor.d.ts +2 -2
  25. package/dataflow/environments/built-in-config.d.ts +1 -0
  26. package/dataflow/environments/built-in.d.ts +10 -1
  27. package/dataflow/environments/built-in.js +9 -3
  28. package/dataflow/environments/default-builtin-config.js +1 -1
  29. package/dataflow/environments/resolve-by-name.d.ts +0 -36
  30. package/dataflow/environments/resolve-by-name.js +0 -240
  31. package/dataflow/eval/resolve/alias-tracking.d.ts +87 -0
  32. package/dataflow/eval/resolve/alias-tracking.js +349 -0
  33. package/dataflow/eval/resolve/resolve.d.ts +34 -0
  34. package/dataflow/eval/resolve/resolve.js +93 -0
  35. package/dataflow/eval/values/general.d.ts +27 -0
  36. package/dataflow/eval/values/general.js +73 -0
  37. package/dataflow/eval/values/intervals/interval-constants.d.ts +4 -0
  38. package/dataflow/eval/values/intervals/interval-constants.js +27 -0
  39. package/dataflow/eval/values/logical/logical-constants.d.ts +7 -0
  40. package/dataflow/eval/values/logical/logical-constants.js +31 -0
  41. package/dataflow/eval/values/r-value.d.ts +58 -0
  42. package/dataflow/eval/values/r-value.js +90 -0
  43. package/dataflow/eval/values/scalar/scalar-consatnts.d.ts +15 -0
  44. package/dataflow/eval/values/scalar/scalar-consatnts.js +35 -0
  45. package/dataflow/eval/values/sets/set-constants.d.ts +7 -0
  46. package/dataflow/eval/values/sets/set-constants.js +34 -0
  47. package/dataflow/eval/values/string/string-constants.d.ts +8 -0
  48. package/dataflow/eval/values/string/string-constants.js +40 -0
  49. package/dataflow/eval/values/vectors/vector-constants.d.ts +14 -0
  50. package/dataflow/eval/values/vectors/vector-constants.js +35 -0
  51. package/dataflow/graph/unknown-replacement.d.ts +11 -0
  52. package/dataflow/graph/unknown-replacement.js +12 -0
  53. package/dataflow/graph/unknown-side-effect.d.ts +7 -0
  54. package/dataflow/graph/unknown-side-effect.js +13 -0
  55. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +8 -5
  56. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +4 -2
  57. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +12 -9
  58. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +5 -4
  59. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +9 -2
  60. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +12 -15
  61. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +23 -0
  62. package/dataflow/internal/process/functions/call/known-call-handling.js +2 -1
  63. package/documentation/doc-util/doc-cfg.d.ts +1 -1
  64. package/documentation/doc-util/doc-cfg.js +3 -3
  65. package/documentation/doc-util/doc-query.d.ts +6 -3
  66. package/documentation/doc-util/doc-query.js +3 -1
  67. package/documentation/print-cfg-wiki.js +31 -31
  68. package/documentation/print-dataflow-graph-wiki.js +4 -3
  69. package/documentation/print-engines-wiki.js +1 -1
  70. package/documentation/print-linter-wiki.d.ts +1 -0
  71. package/documentation/print-linter-wiki.js +76 -0
  72. package/documentation/print-query-wiki.js +80 -0
  73. package/linter/linter-executor.d.ts +9 -0
  74. package/linter/linter-executor.js +26 -0
  75. package/linter/linter-format.d.ts +65 -0
  76. package/linter/linter-format.js +9 -0
  77. package/linter/linter-rules.d.ts +42 -0
  78. package/linter/linter-rules.js +14 -0
  79. package/linter/rules/1-deprecated-functions.d.ts +34 -0
  80. package/linter/rules/1-deprecated-functions.js +54 -0
  81. package/linter/rules/2-file-path-validity.d.ts +48 -0
  82. package/linter/rules/2-file-path-validity.js +93 -0
  83. package/package.json +2 -1
  84. package/queries/catalog/call-context-query/call-context-query-executor.js +1 -1
  85. package/queries/catalog/call-context-query/call-context-query-format.d.ts +2 -2
  86. package/queries/catalog/call-context-query/call-context-query-format.js +5 -1
  87. package/queries/catalog/cluster-query/cluster-query-format.d.ts +2 -0
  88. package/queries/catalog/cluster-query/cluster-query-format.js +5 -1
  89. package/queries/catalog/config-query/config-query-format.d.ts +1 -0
  90. package/queries/catalog/config-query/config-query-format.js +2 -1
  91. package/queries/catalog/control-flow-query/control-flow-query-executor.d.ts +3 -0
  92. package/queries/catalog/control-flow-query/control-flow-query-executor.js +20 -0
  93. package/queries/catalog/control-flow-query/control-flow-query-format.d.ts +81 -0
  94. package/queries/catalog/control-flow-query/control-flow-query-format.js +34 -0
  95. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.d.ts +1 -0
  96. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.js +2 -1
  97. package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +2 -0
  98. package/queries/catalog/dataflow-query/dataflow-query-format.js +9 -1
  99. package/queries/catalog/dependencies-query/dependencies-query-executor.js +33 -32
  100. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +1 -0
  101. package/queries/catalog/dependencies-query/dependencies-query-format.js +10 -1
  102. package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +1 -0
  103. package/queries/catalog/happens-before-query/happens-before-query-format.js +2 -1
  104. package/queries/catalog/id-map-query/id-map-query-format.d.ts +1 -0
  105. package/queries/catalog/id-map-query/id-map-query-format.js +2 -1
  106. package/queries/catalog/lineage-query/lineage-query-format.d.ts +1 -0
  107. package/queries/catalog/lineage-query/lineage-query-format.js +5 -1
  108. package/queries/catalog/linter-query/linter-query-executor.d.ts +3 -0
  109. package/queries/catalog/linter-query/linter-query-executor.js +28 -0
  110. package/queries/catalog/linter-query/linter-query-format.d.ts +80 -0
  111. package/queries/catalog/linter-query/linter-query-format.js +44 -0
  112. package/queries/catalog/location-map-query/location-map-query-format.d.ts +1 -0
  113. package/queries/catalog/location-map-query/location-map-query-format.js +2 -1
  114. package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +1 -0
  115. package/queries/catalog/normalized-ast-query/normalized-ast-query-format.js +2 -1
  116. package/queries/catalog/origin-query/origin-query-format.d.ts +2 -0
  117. package/queries/catalog/origin-query/origin-query-format.js +5 -1
  118. package/queries/catalog/project-query/project-query-executor.js +1 -1
  119. package/queries/catalog/project-query/project-query-format.d.ts +1 -0
  120. package/queries/catalog/project-query/project-query-format.js +2 -1
  121. package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +3 -3
  122. package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +3 -1
  123. package/queries/catalog/resolve-value-query/resolve-value-query-format.js +4 -23
  124. package/queries/catalog/search-query/search-query-format.d.ts +1 -0
  125. package/queries/catalog/search-query/search-query-format.js +5 -1
  126. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +2 -0
  127. package/queries/catalog/static-slice-query/static-slice-query-format.js +9 -1
  128. package/queries/query.d.ts +143 -1
  129. package/queries/query.js +4 -0
  130. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +11 -4
  131. package/r-bridge/retriever.js +1 -1
  132. package/search/flowr-search-builder.d.ts +31 -2
  133. package/search/flowr-search-builder.js +30 -0
  134. package/search/flowr-search.d.ts +7 -1
  135. package/search/search-executor/search-enrichers.d.ts +73 -0
  136. package/search/search-executor/search-enrichers.js +101 -0
  137. package/search/search-executor/search-generators.d.ts +6 -1
  138. package/search/search-executor/search-generators.js +21 -1
  139. package/search/search-executor/search-mappers.d.ts +19 -0
  140. package/search/search-executor/search-mappers.js +21 -0
  141. package/search/search-executor/search-transformer.d.ts +12 -0
  142. package/search/search-executor/search-transformer.js +11 -1
  143. package/slicing/criterion/parse.d.ts +8 -0
  144. package/slicing/criterion/parse.js +20 -0
  145. package/util/version.js +1 -1
@@ -21,6 +21,7 @@ exports.ProjectQueryDefinition = {
21
21
  },
22
22
  schema: joi_1.default.object({
23
23
  type: joi_1.default.string().valid('project').required().description('The type of the query.'),
24
- }).description('The project query provides information on the analyzed project.')
24
+ }).description('The project query provides information on the analyzed project.'),
25
+ flattenInvolvedNodes: () => []
25
26
  };
26
27
  //# sourceMappingURL=project-query-format.js.map
@@ -4,7 +4,7 @@ exports.fingerPrintOfQuery = fingerPrintOfQuery;
4
4
  exports.executeResolveValueQuery = executeResolveValueQuery;
5
5
  const log_1 = require("../../../util/log");
6
6
  const parse_1 = require("../../../slicing/criterion/parse");
7
- const resolve_by_name_1 = require("../../../dataflow/environments/resolve-by-name");
7
+ const alias_tracking_1 = require("../../../dataflow/eval/resolve/alias-tracking");
8
8
  function fingerPrintOfQuery(query) {
9
9
  return JSON.stringify(query);
10
10
  }
@@ -18,9 +18,9 @@ function executeResolveValueQuery({ dataflow: { graph }, ast }, queries) {
18
18
  }
19
19
  const values = query.criteria
20
20
  .map(criteria => (0, parse_1.slicingCriterionToId)(criteria, ast.idMap))
21
- .flatMap(ident => (0, resolve_by_name_1.resolveIdToValue)(ident, { graph, full: true, idMap: ast.idMap }) ?? []);
21
+ .flatMap(ident => (0, alias_tracking_1.resolveIdToValue)(ident, { graph, full: true, idMap: ast.idMap }));
22
22
  results[key] = {
23
- values: values ? [...new Set(values)] : []
23
+ values: values
24
24
  };
25
25
  }
26
26
  return {
@@ -2,6 +2,7 @@ import type { BaseQueryFormat, BaseQueryResult } from '../../base-query-format';
2
2
  import type { SlicingCriteria } from '../../../slicing/criterion/parse';
3
3
  import Joi from 'joi';
4
4
  import { executeResolveValueQuery } from './resolve-value-query-executor';
5
+ import type { ResolveResult } from '../../../dataflow/eval/resolve/alias-tracking';
5
6
  export interface ResolveValueQuery extends BaseQueryFormat {
6
7
  readonly type: 'resolve-value';
7
8
  /** The slicing criteria to use */
@@ -9,7 +10,7 @@ export interface ResolveValueQuery extends BaseQueryFormat {
9
10
  }
10
11
  export interface ResolveValueQueryResult extends BaseQueryResult {
11
12
  results: Record<string, {
12
- values: unknown[];
13
+ values: ResolveResult[];
13
14
  }>;
14
15
  }
15
16
  export declare const ResolveValueQueryDefinition: {
@@ -69,4 +70,5 @@ export declare const ResolveValueQueryDefinition: {
69
70
  readonly dependencies: readonly ["normalize"];
70
71
  }>>, queryResults: BaseQueryResult, result: string[]) => true;
71
72
  readonly schema: Joi.ObjectSchema<any>;
73
+ readonly flattenInvolvedNodes: () => never[];
72
74
  };
@@ -8,27 +8,7 @@ const ansi_1 = require("../../../util/text/ansi");
8
8
  const time_1 = require("../../../util/text/time");
9
9
  const joi_1 = __importDefault(require("joi"));
10
10
  const resolve_value_query_executor_1 = require("./resolve-value-query-executor");
11
- function rValueToAscii(value) {
12
- if (value === null || value === undefined) {
13
- return 'undefined';
14
- }
15
- else if (typeof value === 'string') {
16
- return value;
17
- }
18
- else if (typeof value === 'object') {
19
- if ('num' in value) {
20
- return value.num.toString();
21
- }
22
- else if ('str' in value) {
23
- return `${value.quotes}${value.str}${value.quotes}`;
24
- }
25
- else {
26
- console.warn('omega lul');
27
- return JSON.stringify(value);
28
- }
29
- }
30
- return value;
31
- }
11
+ const r_value_1 = require("../../../dataflow/eval/values/r-value");
32
12
  exports.ResolveValueQueryDefinition = {
33
13
  executor: resolve_value_query_executor_1.executeResolveValueQuery,
34
14
  asciiSummarizer: (formatter, _processed, queryResults, result) => {
@@ -37,13 +17,14 @@ exports.ResolveValueQueryDefinition = {
37
17
  for (const [fingerprint, obj] of Object.entries(out.results)) {
38
18
  const { criteria } = JSON.parse(fingerprint);
39
19
  result.push(` ╰ Values for {${criteria.join(', ')}}`);
40
- result.push(` ╰ ${obj.values.map(v => rValueToAscii(v)).join(', ')}`);
20
+ result.push(` ╰ ${obj.values.map(v => (0, r_value_1.stringifyValue)(v)).join(', ')}`);
41
21
  }
42
22
  return true;
43
23
  },
44
24
  schema: joi_1.default.object({
45
25
  type: joi_1.default.string().valid('resolve-value').required().description('The type of the query.'),
46
26
  criteria: joi_1.default.array().items(joi_1.default.string()).min(1).required().description('The slicing criteria to use.'),
47
- }).description('The resolve value query used to get definitions of an identifier')
27
+ }).description('The resolve value query used to get definitions of an identifier'),
28
+ flattenInvolvedNodes: () => []
48
29
  };
49
30
  //# sourceMappingURL=resolve-value-query-format.js.map
@@ -70,4 +70,5 @@ export declare const SearchQueryDefinition: {
70
70
  readonly dependencies: readonly ["normalize"];
71
71
  }>>, queryResults: BaseQueryResult, result: string[]) => true;
72
72
  readonly schema: Joi.ObjectSchema<any>;
73
+ readonly flattenInvolvedNodes: (queryResults: BaseQueryResult) => NodeId[];
73
74
  };
@@ -24,6 +24,10 @@ exports.SearchQueryDefinition = {
24
24
  schema: joi_1.default.object({
25
25
  type: joi_1.default.string().valid('search').required().description('The type of the query.'),
26
26
  search: joi_1.default.object().required().description('The search query to execute.')
27
- }).description('The search query searches the normalized AST and dataflow graph for nodes that match the given search query.')
27
+ }).description('The search query searches the normalized AST and dataflow graph for nodes that match the given search query.'),
28
+ flattenInvolvedNodes: (queryResults) => {
29
+ const out = queryResults;
30
+ return out.results.flatMap(({ ids }) => ids);
31
+ }
28
32
  };
29
33
  //# sourceMappingURL=search-query-format.js.map
@@ -4,6 +4,7 @@ import type { DEFAULT_DATAFLOW_PIPELINE, DEFAULT_SLICE_WITHOUT_RECONSTRUCT_PIPEL
4
4
  import type { SlicingCriteria } from '../../../slicing/criterion/parse';
5
5
  import Joi from 'joi';
6
6
  import { executeStaticSliceQuery } from './static-slice-query-executor';
7
+ import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
7
8
  /** Calculates and returns all clusters encountered in the dataflow graph. */
8
9
  export interface StaticSliceQuery extends BaseQueryFormat {
9
10
  readonly type: 'static-slice';
@@ -81,4 +82,5 @@ export declare const StaticSliceQueryDefinition: {
81
82
  readonly dependencies: readonly ["normalize"];
82
83
  }>>, queryResults: BaseQueryResult, result: string[]) => true;
83
84
  readonly schema: Joi.ObjectSchema<any>;
85
+ readonly flattenInvolvedNodes: (queryResults: BaseQueryResult) => NodeId[];
84
86
  };
@@ -38,6 +38,14 @@ exports.StaticSliceQueryDefinition = {
38
38
  criteria: joi_1.default.array().items(joi_1.default.string()).min(0).required().description('The slicing criteria to use.'),
39
39
  noReconstruction: joi_1.default.boolean().optional().description('Do not reconstruct the slice into readable code.'),
40
40
  noMagicComments: joi_1.default.boolean().optional().description('Should the magic comments (force-including lines within the slice) be ignored?')
41
- }).description('Slice query used to slice the dataflow graph')
41
+ }).description('Slice query used to slice the dataflow graph'),
42
+ flattenInvolvedNodes: (queryResults) => {
43
+ const flattened = [];
44
+ const out = queryResults;
45
+ for (const [_, obj] of Object.entries(out.results)) {
46
+ flattened.push(...obj.slice.result);
47
+ }
48
+ return flattened;
49
+ }
42
50
  };
43
51
  //# sourceMappingURL=static-slice-query-format.js.map
@@ -21,7 +21,10 @@ import type { ResolveValueQuery } from './catalog/resolve-value-query/resolve-va
21
21
  import type { DataflowLensQuery } from './catalog/dataflow-lens-query/dataflow-lens-query-format';
22
22
  import type { ProjectQuery } from './catalog/project-query/project-query-format';
23
23
  import type { OriginQuery } from './catalog/origin-query/origin-query-format';
24
- export type Query = CallContextQuery | ConfigQuery | SearchQuery | DataflowQuery | DataflowLensQuery | NormalizedAstQuery | IdMapQuery | DataflowClusterQuery | StaticSliceQuery | LineageQuery | DependenciesQuery | LocationMapQuery | HappensBeforeQuery | ResolveValueQuery | ProjectQuery | OriginQuery;
24
+ import type { LinterQuery } from './catalog/linter-query/linter-query-format';
25
+ import type { NodeId } from '../r-bridge/lang-4.x/ast/model/processing/node-id';
26
+ import type { ControlFlowQuery } from './catalog/control-flow-query/control-flow-query-format';
27
+ export type Query = CallContextQuery | ConfigQuery | SearchQuery | DataflowQuery | ControlFlowQuery | DataflowLensQuery | NormalizedAstQuery | IdMapQuery | DataflowClusterQuery | StaticSliceQuery | LineageQuery | DependenciesQuery | LocationMapQuery | HappensBeforeQuery | ResolveValueQuery | ProjectQuery | OriginQuery | LinterQuery;
25
28
  export type QueryArgumentsWithType<QueryType extends BaseQueryFormat['type']> = Query & {
26
29
  type: QueryType;
27
30
  };
@@ -33,17 +36,83 @@ export interface SupportedQuery<QueryType extends BaseQueryFormat['type']> {
33
36
  executor: QueryExecutor<QueryArgumentsWithType<QueryType>, BaseQueryResult>;
34
37
  asciiSummarizer: (formatter: OutputFormatter, processed: PipelineOutput<typeof DEFAULT_DATAFLOW_PIPELINE>, queryResults: BaseQueryResult, resultStrings: string[]) => boolean;
35
38
  schema: Joi.ObjectSchema;
39
+ /**
40
+ * 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.
41
+ * If this query does not involve any nodes, an empty array can be returned.
42
+ */
43
+ flattenInvolvedNodes: (queryResults: BaseQueryResult) => NodeId[];
36
44
  }
37
45
  export declare const SupportedQueries: {
38
46
  readonly 'call-context': {
39
47
  readonly executor: typeof import("./catalog/call-context-query/call-context-query-executor").executeCallContextQueries;
40
48
  readonly asciiSummarizer: (formatter: OutputFormatter, processed: PipelineOutput<typeof DEFAULT_DATAFLOW_PIPELINE>, queryResults: BaseQueryResult, result: string[]) => boolean;
41
49
  readonly schema: Joi.ObjectSchema<any>;
50
+ readonly flattenInvolvedNodes: (queryResults: BaseQueryResult) => NodeId[];
42
51
  };
43
52
  readonly config: {
44
53
  readonly executor: typeof import("./catalog/config-query/config-query-executor").executeConfigQuery;
45
54
  readonly asciiSummarizer: (formatter: OutputFormatter, _processed: unknown, queryResults: BaseQueryResult, result: string[]) => boolean;
46
55
  readonly schema: Joi.ObjectSchema<any>;
56
+ readonly flattenInvolvedNodes: () => never[];
57
+ };
58
+ readonly 'control-flow': {
59
+ readonly executor: typeof import("./catalog/control-flow-query/control-flow-query-executor").executeControlFlowQuery;
60
+ readonly asciiSummarizer: (formatter: OutputFormatter, processed: PipelineOutput<import("../core/steps/pipeline/pipeline").Pipeline<{
61
+ readonly name: "parse";
62
+ readonly humanReadableName: "parse with R shell";
63
+ readonly description: "Parse the given R code into an AST";
64
+ readonly processor: (_results: unknown, input: Partial<import("../r-bridge/parser").ParseRequiredInput<string>>) => Promise<import("../r-bridge/parser").ParseStepOutput<string>>;
65
+ readonly executed: import("../core/steps/pipeline-step").PipelineStepStage.OncePerFile;
66
+ readonly printer: {
67
+ readonly 0: typeof import("../core/print/print").internalPrinter;
68
+ readonly 2: {
69
+ (value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string;
70
+ (value: any, replacer?: (number | string)[] | null, space?: string | number): string;
71
+ };
72
+ readonly 5: ({ parsed }: import("../r-bridge/parser").ParseStepOutput<string>, config: import("../util/quads").QuadSerializationConfiguration) => string;
73
+ };
74
+ readonly dependencies: readonly [];
75
+ readonly requiredInput: import("../r-bridge/parser").ParseRequiredInput<string>;
76
+ } | {
77
+ readonly name: "normalize";
78
+ readonly humanReadableName: "normalize";
79
+ readonly description: "Normalize the AST to flowR's AST";
80
+ readonly processor: (results: {
81
+ parse?: import("../r-bridge/parser").ParseStepOutput<string>;
82
+ }, input: Partial<import("../core/steps/all/core/10-normalize").NormalizeRequiredInput>) => import("../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../r-bridge/lang-4.x/ast/model/model").RNode<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>>;
83
+ readonly executed: import("../core/steps/pipeline-step").PipelineStepStage.OncePerFile;
84
+ readonly printer: {
85
+ readonly 0: typeof import("../core/print/print").internalPrinter;
86
+ readonly 2: typeof import("../core/print/normalize-printer").normalizedAstToJson;
87
+ readonly 5: typeof import("../core/print/normalize-printer").normalizedAstToQuads;
88
+ readonly 3: typeof import("../core/print/normalize-printer").printNormalizedAstToMermaid;
89
+ readonly 4: typeof import("../core/print/normalize-printer").printNormalizedAstToMermaidUrl;
90
+ };
91
+ readonly dependencies: readonly ["parse"];
92
+ readonly requiredInput: import("../core/steps/all/core/10-normalize").NormalizeRequiredInput;
93
+ } | {
94
+ readonly humanReadableName: "dataflow";
95
+ readonly processor: (results: {
96
+ normalize?: import("../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
97
+ }, input: {
98
+ request?: import("../r-bridge/retriever").RParseRequests;
99
+ parser?: import("../r-bridge/parser").Parser<import("../r-bridge/parser").KnownParserType>;
100
+ }) => import("../dataflow/info").DataflowInformation;
101
+ readonly requiredInput: {};
102
+ readonly name: "dataflow";
103
+ readonly description: "Construct the dataflow graph";
104
+ readonly executed: import("../core/steps/pipeline-step").PipelineStepStage.OncePerFile;
105
+ readonly printer: {
106
+ readonly 0: typeof import("../core/print/print").internalPrinter;
107
+ readonly 2: typeof import("../core/print/dataflow-printer").dataflowGraphToJson;
108
+ readonly 5: typeof import("../core/print/dataflow-printer").dataflowGraphToQuads;
109
+ readonly 3: typeof import("../core/print/dataflow-printer").dataflowGraphToMermaid;
110
+ readonly 4: typeof import("../core/print/dataflow-printer").dataflowGraphToMermaidUrl;
111
+ };
112
+ readonly dependencies: readonly ["normalize"];
113
+ }>>, queryResults: BaseQueryResult, result: string[]) => true;
114
+ readonly schema: Joi.ObjectSchema<any>;
115
+ readonly flattenInvolvedNodes: (queryResults: BaseQueryResult) => NodeId[];
47
116
  };
48
117
  readonly dataflow: {
49
118
  readonly executor: typeof import("./catalog/dataflow-query/dataflow-query-executor").executeDataflowQuery;
@@ -102,6 +171,7 @@ export declare const SupportedQueries: {
102
171
  readonly dependencies: readonly ["normalize"];
103
172
  }>>, queryResults: BaseQueryResult, result: string[]) => true;
104
173
  readonly schema: Joi.ObjectSchema<any>;
174
+ readonly flattenInvolvedNodes: (queryResults: BaseQueryResult) => NodeId[];
105
175
  };
106
176
  readonly 'dataflow-lens': {
107
177
  readonly executor: typeof import("./catalog/dataflow-lens-query/dataflow-lens-query-executor").executeDataflowLensQuery;
@@ -160,6 +230,7 @@ export declare const SupportedQueries: {
160
230
  readonly dependencies: readonly ["normalize"];
161
231
  }>>, queryResults: BaseQueryResult, result: string[]) => true;
162
232
  readonly schema: Joi.ObjectSchema<any>;
233
+ readonly flattenInvolvedNodes: () => never[];
163
234
  };
164
235
  readonly 'id-map': {
165
236
  readonly executor: typeof import("./catalog/id-map-query/id-map-query-executor").executeIdMapQuery;
@@ -218,6 +289,7 @@ export declare const SupportedQueries: {
218
289
  readonly dependencies: readonly ["normalize"];
219
290
  }>>, queryResults: BaseQueryResult, result: string[]) => true;
220
291
  readonly schema: Joi.ObjectSchema<any>;
292
+ readonly flattenInvolvedNodes: () => never[];
221
293
  };
222
294
  readonly 'normalized-ast': {
223
295
  readonly executor: typeof import("./catalog/normalized-ast-query/normalized-ast-query-executor").executeNormalizedAstQuery;
@@ -276,6 +348,7 @@ export declare const SupportedQueries: {
276
348
  readonly dependencies: readonly ["normalize"];
277
349
  }>>, queryResults: BaseQueryResult, result: string[]) => true;
278
350
  readonly schema: Joi.ObjectSchema<any>;
351
+ readonly flattenInvolvedNodes: () => never[];
279
352
  };
280
353
  readonly 'dataflow-cluster': {
281
354
  readonly executor: typeof import("./catalog/cluster-query/cluster-query-executor").executeDataflowClusterQuery;
@@ -334,6 +407,7 @@ export declare const SupportedQueries: {
334
407
  readonly dependencies: readonly ["normalize"];
335
408
  }>>, queryResults: BaseQueryResult, result: string[]) => true;
336
409
  readonly schema: Joi.ObjectSchema<any>;
410
+ readonly flattenInvolvedNodes: (queryResults: BaseQueryResult) => NodeId[];
337
411
  };
338
412
  readonly 'static-slice': {
339
413
  readonly executor: typeof import("./catalog/static-slice-query/static-slice-query-executor").executeStaticSliceQuery;
@@ -392,6 +466,7 @@ export declare const SupportedQueries: {
392
466
  readonly dependencies: readonly ["normalize"];
393
467
  }>>, queryResults: BaseQueryResult, result: string[]) => true;
394
468
  readonly schema: Joi.ObjectSchema<any>;
469
+ readonly flattenInvolvedNodes: (queryResults: BaseQueryResult) => NodeId[];
395
470
  };
396
471
  readonly lineage: {
397
472
  readonly executor: typeof import("./catalog/lineage-query/lineage-query-executor").executeLineageQuery;
@@ -450,6 +525,7 @@ export declare const SupportedQueries: {
450
525
  readonly dependencies: readonly ["normalize"];
451
526
  }>>, queryResults: BaseQueryResult, result: string[]) => true;
452
527
  readonly schema: Joi.ObjectSchema<any>;
528
+ readonly flattenInvolvedNodes: (queryResults: BaseQueryResult) => NodeId[];
453
529
  };
454
530
  readonly dependencies: {
455
531
  readonly executor: typeof import("./catalog/dependencies-query/dependencies-query-executor").executeDependenciesQuery;
@@ -508,11 +584,13 @@ export declare const SupportedQueries: {
508
584
  readonly dependencies: readonly ["normalize"];
509
585
  }>>, queryResults: BaseQueryResult, result: string[]) => true;
510
586
  readonly schema: Joi.ObjectSchema<any>;
587
+ readonly flattenInvolvedNodes: (queryResults: BaseQueryResult) => NodeId[];
511
588
  };
512
589
  readonly 'location-map': {
513
590
  readonly executor: typeof import("./catalog/location-map-query/location-map-query-executor").executeLocationMapQuery;
514
591
  readonly asciiSummarizer: (formatter: OutputFormatter, _processed: unknown, queryResults: BaseQueryResult, result: string[]) => boolean;
515
592
  readonly schema: Joi.ObjectSchema<any>;
593
+ readonly flattenInvolvedNodes: () => never[];
516
594
  };
517
595
  readonly search: {
518
596
  readonly executor: typeof import("./catalog/search-query/search-query-executor").executeSearch;
@@ -571,6 +649,7 @@ export declare const SupportedQueries: {
571
649
  readonly dependencies: readonly ["normalize"];
572
650
  }>>, queryResults: BaseQueryResult, result: string[]) => true;
573
651
  readonly schema: Joi.ObjectSchema<any>;
652
+ readonly flattenInvolvedNodes: (queryResults: BaseQueryResult) => NodeId[];
574
653
  };
575
654
  readonly 'happens-before': {
576
655
  readonly executor: typeof import("./catalog/happens-before-query/happens-before-query-executor").executeHappensBefore;
@@ -629,6 +708,7 @@ export declare const SupportedQueries: {
629
708
  readonly dependencies: readonly ["normalize"];
630
709
  }>>, queryResults: BaseQueryResult, result: string[]) => true;
631
710
  readonly schema: Joi.ObjectSchema<any>;
711
+ readonly flattenInvolvedNodes: () => never[];
632
712
  };
633
713
  readonly 'resolve-value': {
634
714
  readonly executor: typeof import("./catalog/resolve-value-query/resolve-value-query-executor").executeResolveValueQuery;
@@ -687,6 +767,7 @@ export declare const SupportedQueries: {
687
767
  readonly dependencies: readonly ["normalize"];
688
768
  }>>, queryResults: BaseQueryResult, result: string[]) => true;
689
769
  readonly schema: Joi.ObjectSchema<any>;
770
+ readonly flattenInvolvedNodes: () => never[];
690
771
  };
691
772
  readonly project: {
692
773
  readonly executor: typeof import("./catalog/project-query/project-query-executor").executeProjectQuery;
@@ -745,6 +826,7 @@ export declare const SupportedQueries: {
745
826
  readonly dependencies: readonly ["normalize"];
746
827
  }>>, queryResults: BaseQueryResult, result: string[]) => true;
747
828
  readonly schema: Joi.ObjectSchema<any>;
829
+ readonly flattenInvolvedNodes: () => never[];
748
830
  };
749
831
  readonly origin: {
750
832
  readonly executor: typeof import("./catalog/origin-query/origin-query-executor").executeResolveValueQuery;
@@ -803,6 +885,66 @@ export declare const SupportedQueries: {
803
885
  readonly dependencies: readonly ["normalize"];
804
886
  }>>, queryResults: BaseQueryResult, result: string[]) => true;
805
887
  readonly schema: Joi.ObjectSchema<any>;
888
+ readonly flattenInvolvedNodes: (queryResults: BaseQueryResult) => NodeId[];
889
+ };
890
+ readonly linter: {
891
+ readonly executor: typeof import("./catalog/linter-query/linter-query-executor").executeLinterQuery;
892
+ readonly asciiSummarizer: (formatter: OutputFormatter, _processed: PipelineOutput<import("../core/steps/pipeline/pipeline").Pipeline<{
893
+ readonly name: "parse";
894
+ readonly humanReadableName: "parse with R shell";
895
+ readonly description: "Parse the given R code into an AST";
896
+ readonly processor: (_results: unknown, input: Partial<import("../r-bridge/parser").ParseRequiredInput<string>>) => Promise<import("../r-bridge/parser").ParseStepOutput<string>>;
897
+ readonly executed: import("../core/steps/pipeline-step").PipelineStepStage.OncePerFile;
898
+ readonly printer: {
899
+ readonly 0: typeof import("../core/print/print").internalPrinter;
900
+ readonly 2: {
901
+ (value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string;
902
+ (value: any, replacer?: (number | string)[] | null, space?: string | number): string;
903
+ };
904
+ readonly 5: ({ parsed }: import("../r-bridge/parser").ParseStepOutput<string>, config: import("../util/quads").QuadSerializationConfiguration) => string;
905
+ };
906
+ readonly dependencies: readonly [];
907
+ readonly requiredInput: import("../r-bridge/parser").ParseRequiredInput<string>;
908
+ } | {
909
+ readonly name: "normalize";
910
+ readonly humanReadableName: "normalize";
911
+ readonly description: "Normalize the AST to flowR's AST";
912
+ readonly processor: (results: {
913
+ parse?: import("../r-bridge/parser").ParseStepOutput<string>;
914
+ }, input: Partial<import("../core/steps/all/core/10-normalize").NormalizeRequiredInput>) => import("../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../r-bridge/lang-4.x/ast/model/model").RNode<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>>;
915
+ readonly executed: import("../core/steps/pipeline-step").PipelineStepStage.OncePerFile;
916
+ readonly printer: {
917
+ readonly 0: typeof import("../core/print/print").internalPrinter;
918
+ readonly 2: typeof import("../core/print/normalize-printer").normalizedAstToJson;
919
+ readonly 5: typeof import("../core/print/normalize-printer").normalizedAstToQuads;
920
+ readonly 3: typeof import("../core/print/normalize-printer").printNormalizedAstToMermaid;
921
+ readonly 4: typeof import("../core/print/normalize-printer").printNormalizedAstToMermaidUrl;
922
+ };
923
+ readonly dependencies: readonly ["parse"];
924
+ readonly requiredInput: import("../core/steps/all/core/10-normalize").NormalizeRequiredInput;
925
+ } | {
926
+ readonly humanReadableName: "dataflow";
927
+ readonly processor: (results: {
928
+ normalize?: import("../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
929
+ }, input: {
930
+ request?: import("../r-bridge/retriever").RParseRequests;
931
+ parser?: import("../r-bridge/parser").Parser<import("../r-bridge/parser").KnownParserType>;
932
+ }) => import("../dataflow/info").DataflowInformation;
933
+ readonly requiredInput: {};
934
+ readonly name: "dataflow";
935
+ readonly description: "Construct the dataflow graph";
936
+ readonly executed: import("../core/steps/pipeline-step").PipelineStepStage.OncePerFile;
937
+ readonly printer: {
938
+ readonly 0: typeof import("../core/print/print").internalPrinter;
939
+ readonly 2: typeof import("../core/print/dataflow-printer").dataflowGraphToJson;
940
+ readonly 5: typeof import("../core/print/dataflow-printer").dataflowGraphToQuads;
941
+ readonly 3: typeof import("../core/print/dataflow-printer").dataflowGraphToMermaid;
942
+ readonly 4: typeof import("../core/print/dataflow-printer").dataflowGraphToMermaidUrl;
943
+ };
944
+ readonly dependencies: readonly ["normalize"];
945
+ }>>, queryResults: BaseQueryResult, result: string[]) => true;
946
+ readonly schema: Joi.ObjectSchema<any>;
947
+ readonly flattenInvolvedNodes: () => never[];
806
948
  };
807
949
  };
808
950
  export type SupportedQueryTypes = keyof typeof SupportedQueries;
package/queries/query.js CHANGED
@@ -29,9 +29,12 @@ const resolve_value_query_format_1 = require("./catalog/resolve-value-query/reso
29
29
  const dataflow_lens_query_format_1 = require("./catalog/dataflow-lens-query/dataflow-lens-query-format");
30
30
  const project_query_format_1 = require("./catalog/project-query/project-query-format");
31
31
  const origin_query_format_1 = require("./catalog/origin-query/origin-query-format");
32
+ const linter_query_format_1 = require("./catalog/linter-query/linter-query-format");
33
+ const control_flow_query_format_1 = require("./catalog/control-flow-query/control-flow-query-format");
32
34
  exports.SupportedQueries = {
33
35
  'call-context': call_context_query_format_1.CallContextQueryDefinition,
34
36
  'config': config_query_format_1.ConfigQueryDefinition,
37
+ 'control-flow': control_flow_query_format_1.ControlFlowQueryDefinition,
35
38
  'dataflow': dataflow_query_format_1.DataflowQueryDefinition,
36
39
  'dataflow-lens': dataflow_lens_query_format_1.DataflowLensQueryDefinition,
37
40
  'id-map': id_map_query_format_1.IdMapQueryDefinition,
@@ -46,6 +49,7 @@ exports.SupportedQueries = {
46
49
  'resolve-value': resolve_value_query_format_1.ResolveValueQueryDefinition,
47
50
  'project': project_query_format_1.ProjectQueryDefinition,
48
51
  'origin': origin_query_format_1.OriginQueryDefinition,
52
+ 'linter': linter_query_format_1.LinterQueryDefinition
49
53
  };
50
54
  function executeQueriesOfSameType(data, ...queries) {
51
55
  (0, assert_1.guard)(queries.length > 0, 'At least one query must be provided');
@@ -293,13 +293,20 @@ function convertTreeNode(node) {
293
293
  ...defaultInfo
294
294
  };
295
295
  }
296
- const args = (0, arrays_1.splitArrayOn)(nonErrorChildren(argsParentheses).slice(1, -1), x => x.type === 'comma');
296
+ const rawArgs = nonErrorChildren(argsParentheses);
297
+ const [comments, noCommentrawArgs] = splitComments(rawArgs);
298
+ const args = (0, arrays_1.splitArrayOn)(noCommentrawArgs.slice(1, -1), x => x.type === 'comma');
297
299
  const funcRange = makeSourceRange(func);
300
+ const mappedArgs = args.map(n => n.length == 0 ? r_function_call_1.EmptyArgument : convertTreeNode(n[0]));
298
301
  const call = {
299
- arguments: args.map(n => n.length == 0 ? r_function_call_1.EmptyArgument : convertTreeNode(n[0])),
302
+ arguments: mappedArgs,
300
303
  location: funcRange,
301
304
  lexeme: func.text,
302
- ...defaultInfo
305
+ ...defaultInfo,
306
+ info: {
307
+ ...defaultInfo.info,
308
+ additionalTokens: comments.map(c => c[1]),
309
+ }
303
310
  };
304
311
  if (func.type === tree_sitter_types_1.TreeSitterType.Identifier || func.type === tree_sitter_types_1.TreeSitterType.String || func.type === tree_sitter_types_1.TreeSitterType.NamespaceOperator || func.type === tree_sitter_types_1.TreeSitterType.Return) {
305
312
  let funcNode = convertTreeNode(func);
@@ -491,7 +498,7 @@ function convertTreeNode(node) {
491
498
  const nameRange = makeSourceRange(nameNode);
492
499
  return {
493
500
  type: type_1.RType.Argument,
494
- name: name,
501
+ name,
495
502
  value: valueNode ? convertTreeNode(valueNode) : undefined,
496
503
  location: nameRange,
497
504
  lexeme: nameNode.text,
@@ -72,7 +72,7 @@ function requestProviderFromText(text) {
72
72
  if (ignoreCase) {
73
73
  return Object.keys(text).find(p => p.toLowerCase() === path.toLowerCase());
74
74
  }
75
- return text[path] ? path : undefined;
75
+ return text[path] !== undefined ? path : undefined;
76
76
  },
77
77
  createRequest(path) {
78
78
  return {
@@ -1,10 +1,14 @@
1
1
  import type { NodeId } from '../r-bridge/lang-4.x/ast/model/processing/node-id';
2
- import type { FlowrSearchElement, FlowrSearchElements, FlowrSearchGetFilter } from './flowr-search';
2
+ import type { FlowrSearchElement, FlowrSearchElementFromQuery, FlowrSearchElements, FlowrSearchGetFilter } from './flowr-search';
3
3
  import type { FlowrFilterExpression } from './flowr-search-filters';
4
4
  import type { FlowrSearchGeneratorNode, GeneratorNames } from './search-executor/search-generators';
5
5
  import type { FlowrSearchTransformerNode, GetOutputOfTransformer, TransformerNames } from './search-executor/search-transformer';
6
6
  import type { SlicingCriteria } from '../slicing/criterion/parse';
7
7
  import type { ParentInformation } from '../r-bridge/lang-4.x/ast/model/processing/decorate';
8
+ import type { Enrichment, EnrichmentArguments } from './search-executor/search-enrichers';
9
+ import type { MapperArguments } from './search-executor/search-mappers';
10
+ import { Mapper } from './search-executor/search-mappers';
11
+ import type { Query } from '../queries/query';
8
12
  type FlowrCriteriaReturn<C extends SlicingCriteria> = FlowrSearchElements<ParentInformation, C extends [] ? never : C extends [infer _] ? [
9
13
  FlowrSearchElement<ParentInformation>
10
14
  ] : FlowrSearchElement<ParentInformation>[]>;
@@ -19,6 +23,12 @@ export declare const FlowrSearchGenerator: {
19
23
  * see {@link FlowrSearchGenerator.criterion} for a serializable alternative (passing the ids with `$id`).
20
24
  */
21
25
  readonly from: (from: FlowrSearchElement<ParentInformation> | FlowrSearchElement<ParentInformation>[]) => FlowrSearchBuilder<"from">;
26
+ /**
27
+ * Initializes a new search query based on the results of the given JSON query or queries.
28
+ * Internally, the {@link SupportedQuery#flattenInvolvedNodes} function is used to flatten the resulting nodes of the query.
29
+ * 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
+ */
31
+ readonly fromQuery: (...from: readonly Query[]) => FlowrSearchBuilder<"from-query", [], ParentInformation, FlowrSearchElements<ParentInformation, FlowrSearchElementFromQuery<ParentInformation>[]>>;
22
32
  /**
23
33
  * Returns all elements (nodes/dataflow vertices) from the given data.
24
34
  */
@@ -71,6 +81,12 @@ export declare const Q: {
71
81
  * see {@link FlowrSearchGenerator.criterion} for a serializable alternative (passing the ids with `$id`).
72
82
  */
73
83
  readonly from: (from: FlowrSearchElement<ParentInformation> | FlowrSearchElement<ParentInformation>[]) => FlowrSearchBuilder<"from">;
84
+ /**
85
+ * Initializes a new search query based on the results of the given JSON query or queries.
86
+ * Internally, the {@link SupportedQuery#flattenInvolvedNodes} function is used to flatten the resulting nodes of the query.
87
+ * 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.
88
+ */
89
+ readonly fromQuery: (...from: readonly Query[]) => FlowrSearchBuilder<"from-query", [], ParentInformation, FlowrSearchElements<ParentInformation, FlowrSearchElementFromQuery<ParentInformation>[]>>;
74
90
  /**
75
91
  * Returns all elements (nodes/dataflow vertices) from the given data.
76
92
  */
@@ -168,6 +184,19 @@ export declare class FlowrSearchBuilder<Generator extends GeneratorNames, Transf
168
184
  * select returns only the elements at the given indices.
169
185
  */
170
186
  select<Select extends number[]>(...select: Select): FlowrSearchBuilderOut<Generator, Transformers, Info, 'select'>;
187
+ /**
188
+ * Adds the given enrichment to each element of the search.
189
+ * Added enrichments can later be retrieved using the {@link enrichmentContent} function.
190
+ */
191
+ with<ConcreteEnrichment extends Enrichment>(enrichment: ConcreteEnrichment, args?: EnrichmentArguments<ConcreteEnrichment>): FlowrSearchBuilderOut<Generator, Transformers, Info, 'with'>;
192
+ /**
193
+ * Maps the elements of the search to new values using the given mapper function.
194
+ */
195
+ map<MapperType extends Mapper>(mapper: MapperType, args: MapperArguments<MapperType>): FlowrSearchBuilderOut<Generator, Transformers, Info, 'map'>;
196
+ /**
197
+ * A convenience function that combines {@link with} and the {@link Mapper.Enrichment} mapper to immediately add an enrichment and then map to its value(s).
198
+ */
199
+ get<ConcreteEnrichment extends Enrichment>(enrichment: ConcreteEnrichment, args?: EnrichmentArguments<ConcreteEnrichment>): FlowrSearchBuilderOut<Generator, Transformers, Info, 'with' | 'map'>;
171
200
  /**
172
201
  * merge combines the search results with those of another search.
173
202
  */
@@ -183,7 +212,7 @@ export declare class FlowrSearchBuilder<Generator extends GeneratorNames, Transf
183
212
  * This type summarizes all types that can be used in places in which the API expects you to provide a search query.
184
213
  * @see {@link FlowrSearch}
185
214
  */
186
- export type FlowrSearchLike = FlowrSearch | FlowrSearchBuilderType;
215
+ export type FlowrSearchLike<Info = ParentInformation, Generator extends GeneratorNames = GeneratorNames, Transformers extends TransformerNames[] = TransformerNames[], ElementType = FlowrSearchElements<Info, FlowrSearchElement<Info>[]>> = FlowrSearch<Info, Generator, Transformers, ElementType> | FlowrSearchBuilderType<Generator, Transformers, Info, ElementType>;
187
216
  export type SearchOutput<Search> = Search extends FlowrSearch ? Search : Search extends FlowrSearchBuilderType<infer Generator, infer Transformers, infer Info, infer Elements> ? FlowrSearch<Info, Generator, Transformers, Elements> : never;
188
217
  /**
189
218
  * Freezes any accepted {@link FlowrSearchLike} into a {@link FlowrSearch}.
@@ -4,6 +4,7 @@ exports.FlowrSearchBuilder = exports.Q = exports.FlowrSearchGenerator = void 0;
4
4
  exports.getFlowrSearch = getFlowrSearch;
5
5
  const search_optimizer_1 = require("./search-optimizer/search-optimizer");
6
6
  const assert_1 = require("../util/assert");
7
+ const search_mappers_1 = require("./search-executor/search-mappers");
7
8
  /**
8
9
  * This object holds all the methods to generate search queries.
9
10
  * For compatibility, please use the {@link Q} identifier object to access these methods.
@@ -17,6 +18,14 @@ exports.FlowrSearchGenerator = {
17
18
  from(from) {
18
19
  return new FlowrSearchBuilder({ type: 'generator', name: 'from', args: { from } });
19
20
  },
21
+ /**
22
+ * Initializes a new search query based on the results of the given JSON query or queries.
23
+ * Internally, the {@link SupportedQuery#flattenInvolvedNodes} function is used to flatten the resulting nodes of the query.
24
+ * 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.
25
+ */
26
+ fromQuery(...from) {
27
+ return new FlowrSearchBuilder({ type: 'generator', name: 'from-query', args: { from } });
28
+ },
20
29
  /**
21
30
  * Returns all elements (nodes/dataflow vertices) from the given data.
22
31
  */
@@ -158,6 +167,27 @@ class FlowrSearchBuilder {
158
167
  this.search.push({ type: 'transformer', name: 'select', args: { select } });
159
168
  return this;
160
169
  }
170
+ /**
171
+ * Adds the given enrichment to each element of the search.
172
+ * Added enrichments can later be retrieved using the {@link enrichmentContent} function.
173
+ */
174
+ with(enrichment, args) {
175
+ this.search.push({ type: 'transformer', name: 'with', args: { info: enrichment, args: args } });
176
+ return this;
177
+ }
178
+ /**
179
+ * Maps the elements of the search to new values using the given mapper function.
180
+ */
181
+ map(mapper, args) {
182
+ this.search.push({ type: 'transformer', name: 'map', args: { mapper: mapper, args: args } });
183
+ return this;
184
+ }
185
+ /**
186
+ * A convenience function that combines {@link with} and the {@link Mapper.Enrichment} mapper to immediately add an enrichment and then map to its value(s).
187
+ */
188
+ get(enrichment, args) {
189
+ return this.with(enrichment, args).map(search_mappers_1.Mapper.Enrichment, enrichment);
190
+ }
161
191
  /**
162
192
  * merge combines the search results with those of another search.
163
193
  */
@@ -3,6 +3,8 @@ import type { Pipeline, PipelineOutput, PipelineStepOutputWithName } from '../co
3
3
  import type { NormalizedAst } from '../r-bridge/lang-4.x/ast/model/processing/decorate';
4
4
  import type { NodeId } from '../r-bridge/lang-4.x/ast/model/processing/node-id';
5
5
  import type { DataflowInformation } from '../dataflow/info';
6
+ import type { BaseQueryResult } from '../queries/base-query-format';
7
+ import type { Query } from '../queries/query';
6
8
  /**
7
9
  * Yes, for now we do technically not need a wrapper around the RNode, but this allows us to attach caches etc.
8
10
  * just for the respective search.
@@ -10,6 +12,10 @@ import type { DataflowInformation } from '../dataflow/info';
10
12
  export interface FlowrSearchElement<Info> {
11
13
  readonly node: RNode<Info>;
12
14
  }
15
+ export interface FlowrSearchElementFromQuery<Info> extends FlowrSearchElement<Info> {
16
+ readonly query: Query['type'];
17
+ readonly queryResult: BaseQueryResult;
18
+ }
13
19
  export interface FlowrSearchNodeBase<Type extends string, Name extends string, Args extends Record<string, unknown> | undefined> {
14
20
  readonly type: Type;
15
21
  readonly name: Name;
@@ -52,7 +58,7 @@ export declare class FlowrSearchElements<Info = NoInfo, Elements extends FlowrSe
52
58
  constructor(elements?: Elements);
53
59
  add(element: FlowrSearchElement<Info>): this;
54
60
  addAll(elements: FlowrSearchElement<Info>[]): this;
55
- getElements(): readonly FlowrSearchElement<Info>[];
61
+ getElements(): Readonly<Elements>;
56
62
  mutate<OutElements extends Elements>(mutator: (elements: Elements) => OutElements): this;
57
63
  }
58
64
  export {};