@eagleoutice/flowr 2.1.10 → 2.1.12

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 (74) hide show
  1. package/README.md +1 -0
  2. package/cli/flowr.js +8 -0
  3. package/cli/repl/commands/repl-query.js +14 -3
  4. package/cli/repl/server/connection.js +1 -1
  5. package/core/steps/pipeline/default-pipelines.d.ts +6 -0
  6. package/core/steps/pipeline/default-pipelines.js +6 -0
  7. package/dataflow/environments/resolve-by-name.d.ts +2 -1
  8. package/dataflow/environments/resolve-by-name.js +2 -1
  9. package/dataflow/graph/vertex.d.ts +4 -0
  10. package/dataflow/graph/vertex.js +3 -1
  11. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +29 -26
  12. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +1 -2
  13. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +28 -24
  14. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +2 -1
  15. package/documentation/doc-util/doc-dfg.js +1 -1
  16. package/documentation/doc-util/doc-query.js +1 -1
  17. package/documentation/doc-util/doc-search.d.ts +25 -0
  18. package/documentation/doc-util/doc-search.js +121 -0
  19. package/documentation/doc-util/doc-types.d.ts +10 -2
  20. package/documentation/doc-util/doc-types.js +81 -3
  21. package/documentation/print-dataflow-graph-wiki.js +1 -1
  22. package/documentation/print-interface-wiki.js +31 -15
  23. package/documentation/print-normalized-ast-wiki.js +4 -4
  24. package/documentation/print-query-wiki.js +35 -0
  25. package/documentation/print-search-wiki.d.ts +1 -0
  26. package/documentation/print-search-wiki.js +74 -0
  27. package/package.json +2 -1
  28. package/queries/base-query-format.d.ts +2 -2
  29. package/queries/catalog/call-context-query/call-context-query-executor.d.ts +1 -1
  30. package/queries/catalog/call-context-query/call-context-query-executor.js +1 -1
  31. package/queries/catalog/cluster-query/cluster-query-executor.d.ts +1 -1
  32. package/queries/catalog/cluster-query/cluster-query-executor.js +1 -1
  33. package/queries/catalog/config-query/config-query-executor.d.ts +3 -0
  34. package/queries/catalog/config-query/config-query-executor.js +18 -0
  35. package/queries/catalog/config-query/config-query-format.d.ts +16 -0
  36. package/queries/catalog/config-query/config-query-format.js +24 -0
  37. package/queries/catalog/dataflow-query/dataflow-query-executor.d.ts +1 -1
  38. package/queries/catalog/dataflow-query/dataflow-query-executor.js +1 -1
  39. package/queries/catalog/dependencies-query/dependencies-query-executor.js +2 -2
  40. package/queries/catalog/lineage-query/lineage-query-executor.d.ts +1 -1
  41. package/queries/catalog/lineage-query/lineage-query-executor.js +1 -1
  42. package/queries/catalog/location-map-query/location-map-query-format.js +1 -1
  43. package/queries/catalog/search-query/search-query-executor.d.ts +3 -0
  44. package/queries/catalog/search-query/search-query-executor.js +27 -0
  45. package/queries/catalog/search-query/search-query-format.d.ts +72 -0
  46. package/queries/catalog/search-query/search-query-format.js +29 -0
  47. package/queries/catalog/static-slice-query/static-slice-query-executor.d.ts +1 -1
  48. package/queries/catalog/static-slice-query/static-slice-query-executor.js +1 -1
  49. package/queries/query.d.ts +65 -1
  50. package/queries/query.js +5 -1
  51. package/r-bridge/lang-4.x/ast/model/type.d.ts +4 -0
  52. package/r-bridge/lang-4.x/ast/model/type.js +3 -1
  53. package/search/flowr-search-builder.d.ts +193 -0
  54. package/search/flowr-search-builder.js +192 -0
  55. package/search/flowr-search-executor.d.ts +9 -0
  56. package/search/flowr-search-executor.js +16 -0
  57. package/search/flowr-search-filters.d.ts +74 -0
  58. package/search/flowr-search-filters.js +136 -0
  59. package/search/flowr-search-printer.d.ts +10 -0
  60. package/search/flowr-search-printer.js +85 -0
  61. package/search/flowr-search-traverse.d.ts +7 -0
  62. package/search/flowr-search-traverse.js +12 -0
  63. package/search/flowr-search.d.ts +58 -0
  64. package/search/flowr-search.js +29 -0
  65. package/search/search-executor/search-generators.d.ts +37 -0
  66. package/search/search-executor/search-generators.js +64 -0
  67. package/search/search-executor/search-transformer.d.ts +57 -0
  68. package/search/search-executor/search-transformer.js +99 -0
  69. package/search/search-optimizer/search-optimizer.d.ts +9 -0
  70. package/search/search-optimizer/search-optimizer.js +89 -0
  71. package/util/arrays.d.ts +13 -0
  72. package/util/assert.d.ts +1 -1
  73. package/util/mermaid/mermaid.js +17 -0
  74. package/util/version.js +1 -1
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.executeSearch = executeSearch;
4
+ const log_1 = require("../../../util/log");
5
+ const flowr_search_executor_1 = require("../../../search/flowr-search-executor");
6
+ function executeSearch({ ast, dataflow }, queries) {
7
+ const start = Date.now();
8
+ if (queries.length !== 1) {
9
+ log_1.log.warn('Id-Map query expects only up to one query, but got', queries.length);
10
+ }
11
+ const results = [];
12
+ for (const query of queries) {
13
+ const { search } = query;
14
+ results.push({
15
+ ids: (0, flowr_search_executor_1.runSearch)(search, { normalize: ast, dataflow })
16
+ .map(({ node }) => node.info.id),
17
+ search
18
+ });
19
+ }
20
+ return {
21
+ '.meta': {
22
+ timing: Date.now() - start
23
+ },
24
+ results
25
+ };
26
+ }
27
+ //# sourceMappingURL=search-query-executor.js.map
@@ -0,0 +1,72 @@
1
+ import type { BaseQueryFormat, BaseQueryResult } from '../../base-query-format';
2
+ import Joi from 'joi';
3
+ import type { FlowrSearch } from '../../../search/flowr-search-builder';
4
+ import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
5
+ import { executeSearch } from './search-query-executor';
6
+ export interface SearchQuery extends BaseQueryFormat {
7
+ readonly type: 'search';
8
+ readonly search: FlowrSearch;
9
+ }
10
+ export interface SearchQueryResult extends BaseQueryResult {
11
+ readonly results: {
12
+ ids: NodeId[];
13
+ search: FlowrSearch;
14
+ }[];
15
+ }
16
+ export declare const SearchQueryDefinition: {
17
+ readonly executor: typeof executeSearch;
18
+ readonly asciiSummarizer: (formatter: import("../../../util/ansi").OutputFormatter, _processed: import("../../../core/steps/pipeline/pipeline").PipelineOutput<import("../../../core/steps/pipeline/pipeline").Pipeline<{
19
+ readonly name: "parse";
20
+ readonly humanReadableName: "parse with R shell";
21
+ readonly description: "Parse the given R code into an AST";
22
+ readonly processor: (_results: unknown, input: Partial<import("../../../core/steps/all/core/00-parse").ParseRequiredInput>) => Promise<import("../../../core/steps/all/core/00-parse").ParseStepOutput>;
23
+ readonly executed: import("../../../core/steps/pipeline-step").PipelineStepStage.OncePerFile;
24
+ readonly printer: {
25
+ readonly 0: typeof import("../../../core/print/print").internalPrinter;
26
+ readonly 2: {
27
+ (value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string;
28
+ (value: any, replacer?: (number | string)[] | null, space?: string | number): string;
29
+ };
30
+ readonly 5: ({ parsed }: import("../../../core/steps/all/core/00-parse").ParseStepOutput, config: import("../../../util/quads").QuadSerializationConfiguration) => string;
31
+ };
32
+ readonly dependencies: readonly [];
33
+ readonly requiredInput: import("../../../core/steps/all/core/00-parse").ParseRequiredInput;
34
+ } | {
35
+ readonly name: "normalize";
36
+ readonly humanReadableName: "normalize";
37
+ readonly description: "Normalize the AST to flowR's AST";
38
+ readonly processor: (results: {
39
+ parse?: import("../../../core/steps/all/core/00-parse").ParseStepOutput;
40
+ }, 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>>;
41
+ readonly executed: import("../../../core/steps/pipeline-step").PipelineStepStage.OncePerFile;
42
+ readonly printer: {
43
+ readonly 0: typeof import("../../../core/print/print").internalPrinter;
44
+ readonly 2: typeof import("../../../core/print/normalize-printer").normalizedAstToJson;
45
+ readonly 5: typeof import("../../../core/print/normalize-printer").normalizedAstToQuads;
46
+ readonly 3: typeof import("../../../core/print/normalize-printer").printNormalizedAstToMermaid;
47
+ readonly 4: typeof import("../../../core/print/normalize-printer").printNormalizedAstToMermaidUrl;
48
+ };
49
+ readonly dependencies: readonly ["parse"];
50
+ readonly requiredInput: import("../../../core/steps/all/core/10-normalize").NormalizeRequiredInput;
51
+ } | {
52
+ readonly humanReadableName: "dataflow";
53
+ readonly processor: (results: {
54
+ normalize?: import("../../../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
55
+ }, input: {
56
+ request?: import("../../../r-bridge/retriever").RParseRequests;
57
+ }) => import("../../../dataflow/info").DataflowInformation;
58
+ readonly requiredInput: {};
59
+ readonly name: "dataflow";
60
+ readonly description: "Construct the dataflow graph";
61
+ readonly executed: import("../../../core/steps/pipeline-step").PipelineStepStage.OncePerFile;
62
+ readonly printer: {
63
+ readonly 0: typeof import("../../../core/print/print").internalPrinter;
64
+ readonly 2: typeof import("../../../core/print/dataflow-printer").dataflowGraphToJson;
65
+ readonly 5: typeof import("../../../core/print/dataflow-printer").dataflowGraphToQuads;
66
+ readonly 3: typeof import("../../../core/print/dataflow-printer").dataflowGraphToMermaid;
67
+ readonly 4: typeof import("../../../core/print/dataflow-printer").dataflowGraphToMermaidUrl;
68
+ };
69
+ readonly dependencies: readonly ["normalize"];
70
+ }>>, queryResults: BaseQueryResult, result: string[]) => true;
71
+ readonly schema: Joi.ObjectSchema<any>;
72
+ };
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.SearchQueryDefinition = void 0;
7
+ const ansi_1 = require("../../../util/ansi");
8
+ const time_1 = require("../../../util/time");
9
+ const joi_1 = __importDefault(require("joi"));
10
+ const query_print_1 = require("../../query-print");
11
+ const search_query_executor_1 = require("./search-query-executor");
12
+ const flowr_search_printer_1 = require("../../../search/flowr-search-printer");
13
+ const mermaid_1 = require("../../../util/mermaid/mermaid");
14
+ exports.SearchQueryDefinition = {
15
+ executor: search_query_executor_1.executeSearch,
16
+ asciiSummarizer: (formatter, _processed, queryResults, result) => {
17
+ const out = queryResults;
18
+ result.push(`Query: ${(0, ansi_1.bold)('search', formatter)} (${(0, time_1.printAsMs)(out['.meta'].timing, 0)})`);
19
+ for (const [, { ids, search }] of out.results.entries()) {
20
+ result.push(` ╰ [query](${(0, mermaid_1.mermaidCodeToUrl)((0, flowr_search_printer_1.flowrSearchToMermaid)(search))}): {${(0, query_print_1.summarizeIdsIfTooLong)(formatter, ids)}}`);
21
+ }
22
+ return true;
23
+ },
24
+ schema: joi_1.default.object({
25
+ type: joi_1.default.string().valid('search').required().description('The type of the query.'),
26
+ search: joi_1.default.object().required().description('The search query to execute.')
27
+ }).description('The id map query retrieves the id map from the normalized AST.')
28
+ };
29
+ //# sourceMappingURL=search-query-format.js.map
@@ -1,4 +1,4 @@
1
1
  import type { StaticSliceQuery, StaticSliceQueryResult } from './static-slice-query-format';
2
2
  import type { BasicQueryData } from '../../base-query-format';
3
3
  export declare function fingerPrintOfQuery(query: StaticSliceQuery): string;
4
- export declare function executeStaticSliceQuery({ graph, ast }: BasicQueryData, queries: readonly StaticSliceQuery[]): StaticSliceQueryResult;
4
+ export declare function executeStaticSliceQuery({ dataflow: { graph }, ast }: BasicQueryData, queries: readonly StaticSliceQuery[]): StaticSliceQueryResult;
@@ -10,7 +10,7 @@ const log_1 = require("../../../util/log");
10
10
  function fingerPrintOfQuery(query) {
11
11
  return JSON.stringify(query);
12
12
  }
13
- function executeStaticSliceQuery({ graph, ast }, queries) {
13
+ function executeStaticSliceQuery({ dataflow: { graph }, ast }, queries) {
14
14
  const start = Date.now();
15
15
  const results = {};
16
16
  for (const query of queries) {
@@ -14,7 +14,9 @@ import type { PipelineOutput } from '../core/steps/pipeline/pipeline';
14
14
  import type { DEFAULT_DATAFLOW_PIPELINE } from '../core/steps/pipeline/default-pipelines';
15
15
  import Joi from 'joi';
16
16
  import type { LocationMapQuery } from './catalog/location-map-query/location-map-query-format';
17
- export type Query = CallContextQuery | DataflowQuery | NormalizedAstQuery | IdMapQuery | DataflowClusterQuery | StaticSliceQuery | LineageQuery | DependenciesQuery | LocationMapQuery;
17
+ import type { ConfigQuery } from './catalog/config-query/config-query-format';
18
+ import type { SearchQuery } from './catalog/search-query/search-query-format';
19
+ export type Query = CallContextQuery | ConfigQuery | SearchQuery | DataflowQuery | NormalizedAstQuery | IdMapQuery | DataflowClusterQuery | StaticSliceQuery | LineageQuery | DependenciesQuery | LocationMapQuery;
18
20
  export type QueryArgumentsWithType<QueryType extends BaseQueryFormat['type']> = Query & {
19
21
  type: QueryType;
20
22
  };
@@ -33,6 +35,11 @@ export declare const SupportedQueries: {
33
35
  readonly asciiSummarizer: (formatter: OutputFormatter, processed: PipelineOutput<typeof DEFAULT_DATAFLOW_PIPELINE>, queryResults: BaseQueryResult, result: string[]) => boolean;
34
36
  readonly schema: Joi.ObjectSchema<any>;
35
37
  };
38
+ readonly config: {
39
+ readonly executor: typeof import("./catalog/config-query/config-query-executor").executeConfigQuery;
40
+ readonly asciiSummarizer: (formatter: OutputFormatter, _processed: unknown, queryResults: BaseQueryResult, result: string[]) => boolean;
41
+ readonly schema: Joi.ObjectSchema<any>;
42
+ };
36
43
  readonly dataflow: {
37
44
  readonly executor: typeof import("./catalog/dataflow-query/dataflow-query-executor").executeDataflowQuery;
38
45
  readonly asciiSummarizer: (formatter: OutputFormatter, _processed: PipelineOutput<import("../core/steps/pipeline/pipeline").Pipeline<{
@@ -437,6 +444,63 @@ export declare const SupportedQueries: {
437
444
  readonly asciiSummarizer: (formatter: OutputFormatter, _processed: unknown, queryResults: BaseQueryResult, result: string[]) => boolean;
438
445
  readonly schema: Joi.ObjectSchema<any>;
439
446
  };
447
+ readonly search: {
448
+ readonly executor: typeof import("./catalog/search-query/search-query-executor").executeSearch;
449
+ readonly asciiSummarizer: (formatter: OutputFormatter, _processed: PipelineOutput<import("../core/steps/pipeline/pipeline").Pipeline<{
450
+ readonly name: "parse";
451
+ readonly humanReadableName: "parse with R shell";
452
+ readonly description: "Parse the given R code into an AST";
453
+ readonly processor: (_results: unknown, input: Partial<import("../core/steps/all/core/00-parse").ParseRequiredInput>) => Promise<import("../core/steps/all/core/00-parse").ParseStepOutput>;
454
+ readonly executed: import("../core/steps/pipeline-step").PipelineStepStage.OncePerFile;
455
+ readonly printer: {
456
+ readonly 0: typeof import("../core/print/print").internalPrinter;
457
+ readonly 2: {
458
+ (value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string;
459
+ (value: any, replacer?: (number | string)[] | null, space?: string | number): string;
460
+ };
461
+ readonly 5: ({ parsed }: import("../core/steps/all/core/00-parse").ParseStepOutput, config: import("../util/quads").QuadSerializationConfiguration) => string;
462
+ };
463
+ readonly dependencies: readonly [];
464
+ readonly requiredInput: import("../core/steps/all/core/00-parse").ParseRequiredInput;
465
+ } | {
466
+ readonly name: "normalize";
467
+ readonly humanReadableName: "normalize";
468
+ readonly description: "Normalize the AST to flowR's AST";
469
+ readonly processor: (results: {
470
+ parse?: import("../core/steps/all/core/00-parse").ParseStepOutput;
471
+ }, 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>>;
472
+ readonly executed: import("../core/steps/pipeline-step").PipelineStepStage.OncePerFile;
473
+ readonly printer: {
474
+ readonly 0: typeof import("../core/print/print").internalPrinter;
475
+ readonly 2: typeof import("../core/print/normalize-printer").normalizedAstToJson;
476
+ readonly 5: typeof import("../core/print/normalize-printer").normalizedAstToQuads;
477
+ readonly 3: typeof import("../core/print/normalize-printer").printNormalizedAstToMermaid;
478
+ readonly 4: typeof import("../core/print/normalize-printer").printNormalizedAstToMermaidUrl;
479
+ };
480
+ readonly dependencies: readonly ["parse"];
481
+ readonly requiredInput: import("../core/steps/all/core/10-normalize").NormalizeRequiredInput;
482
+ } | {
483
+ readonly humanReadableName: "dataflow";
484
+ readonly processor: (results: {
485
+ normalize?: import("../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
486
+ }, input: {
487
+ request?: import("../r-bridge/retriever").RParseRequests;
488
+ }) => import("../dataflow/info").DataflowInformation;
489
+ readonly requiredInput: {};
490
+ readonly name: "dataflow";
491
+ readonly description: "Construct the dataflow graph";
492
+ readonly executed: import("../core/steps/pipeline-step").PipelineStepStage.OncePerFile;
493
+ readonly printer: {
494
+ readonly 0: typeof import("../core/print/print").internalPrinter;
495
+ readonly 2: typeof import("../core/print/dataflow-printer").dataflowGraphToJson;
496
+ readonly 5: typeof import("../core/print/dataflow-printer").dataflowGraphToQuads;
497
+ readonly 3: typeof import("../core/print/dataflow-printer").dataflowGraphToMermaid;
498
+ readonly 4: typeof import("../core/print/dataflow-printer").dataflowGraphToMermaidUrl;
499
+ };
500
+ readonly dependencies: readonly ["normalize"];
501
+ }>>, queryResults: BaseQueryResult, result: string[]) => true;
502
+ readonly schema: Joi.ObjectSchema<any>;
503
+ };
440
504
  };
441
505
  export type SupportedQueryTypes = keyof typeof SupportedQueries;
442
506
  export type QueryResult<Type extends Query['type']> = ReturnType<typeof SupportedQueries[Type]['executor']>;
package/queries/query.js CHANGED
@@ -22,8 +22,11 @@ const cluster_query_format_1 = require("./catalog/cluster-query/cluster-query-fo
22
22
  const dependencies_query_format_1 = require("./catalog/dependencies-query/dependencies-query-format");
23
23
  const joi_1 = __importDefault(require("joi"));
24
24
  const location_map_query_format_1 = require("./catalog/location-map-query/location-map-query-format");
25
+ const config_query_format_1 = require("./catalog/config-query/config-query-format");
26
+ const search_query_format_1 = require("./catalog/search-query/search-query-format");
25
27
  exports.SupportedQueries = {
26
28
  'call-context': call_context_query_format_1.CallContextQueryDefinition,
29
+ 'config': config_query_format_1.ConfigQueryDefinition,
27
30
  'dataflow': dataflow_query_format_1.DataflowQueryDefinition,
28
31
  'id-map': id_map_query_format_1.IdMapQueryDefinition,
29
32
  'normalized-ast': normalized_ast_query_format_1.NormalizedAstQueryDefinition,
@@ -31,7 +34,8 @@ exports.SupportedQueries = {
31
34
  'static-slice': static_slice_query_format_1.StaticSliceQueryDefinition,
32
35
  'lineage': lineage_query_format_1.LineageQueryDefinition,
33
36
  'dependencies': dependencies_query_format_1.DependenciesQueryDefinition,
34
- 'location-map': location_map_query_format_1.LocationMapQueryDefinition
37
+ 'location-map': location_map_query_format_1.LocationMapQueryDefinition,
38
+ 'search': search_query_format_1.SearchQueryDefinition
35
39
  };
36
40
  function executeQueriesOfSameType(data, ...queries) {
37
41
  (0, assert_1.guard)(queries.length > 0, 'At least one query must be provided');
@@ -204,6 +204,10 @@ export declare enum RType {
204
204
  */
205
205
  Delimiter = "RDelimiter"
206
206
  }
207
+ export declare const ValidRTypes: Set<string>;
208
+ export declare const ValidRTypesReverse: {
209
+ [k: string]: string;
210
+ };
207
211
  /**
208
212
  * Validates, whether the given type can be used as a symbol in R
209
213
  *
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RType = exports.RawRType = void 0;
3
+ exports.ValidRTypesReverse = exports.ValidRTypes = exports.RType = exports.RawRType = void 0;
4
4
  exports.isSymbol = isSymbol;
5
5
  /**
6
6
  * Token types as they are produced by the R parser.
@@ -211,6 +211,8 @@ var RType;
211
211
  */
212
212
  RType["Delimiter"] = "RDelimiter";
213
213
  })(RType || (exports.RType = RType = {}));
214
+ exports.ValidRTypes = new Set(Object.values(RType));
215
+ exports.ValidRTypesReverse = Object.fromEntries(Object.entries(RType).map(([k, v]) => [v, k]));
214
216
  const validSymbolTypes = new Set([
215
217
  RawRType.Symbol,
216
218
  RawRType.SymbolPackage,
@@ -0,0 +1,193 @@
1
+ import type { NodeId } from '../r-bridge/lang-4.x/ast/model/processing/node-id';
2
+ import type { FlowrSearchElement, FlowrSearchElements, FlowrSearchGetFilter } from './flowr-search';
3
+ import type { FlowrFilterExpression } from './flowr-search-filters';
4
+ import type { FlowrSearchGeneratorNode, GeneratorNames } from './search-executor/search-generators';
5
+ import type { FlowrSearchTransformerNode, GetOutputOfTransformer, TransformerNames } from './search-executor/search-transformer';
6
+ import type { SlicingCriteria } from '../slicing/criterion/parse';
7
+ import type { ParentInformation } from '../r-bridge/lang-4.x/ast/model/processing/decorate';
8
+ type FlowrCriteriaReturn<C extends SlicingCriteria> = FlowrSearchElements<ParentInformation, C extends [] ? never : C extends [infer _] ? [
9
+ FlowrSearchElement<ParentInformation>
10
+ ] : FlowrSearchElement<ParentInformation>[]>;
11
+ /**
12
+ * This object holds all the methods to generate search queries.
13
+ * For compatibility, please use the {@link Q} identifier object to access these methods.
14
+ */
15
+ export declare const FlowrSearchGenerator: {
16
+ /**
17
+ * Initialize a search query with the given elements.
18
+ * <b>This is not intended to serialize well</b> wrt. the nodes,
19
+ * see {@link FlowrSearchGenerator.criterion} for a serializable alternative (passing the ids with `$id`).
20
+ */
21
+ readonly from: (from: FlowrSearchElement<ParentInformation> | FlowrSearchElement<ParentInformation>[]) => FlowrSearchBuilder<"from">;
22
+ /**
23
+ * Returns all elements (nodes/dataflow vertices) from the given data.
24
+ */
25
+ readonly all: () => FlowrSearchBuilder<"all">;
26
+ /**
27
+ * Returns all elements that match the given {@link FlowrSearchGetFilters|filters}.
28
+ * You may pass a negative line number to count from the back.
29
+ * Please note that this is currently only working for single files, it approximates over the nodes, and it is not to be used for "production".
30
+ */
31
+ readonly get: (filter: FlowrSearchGetFilter) => FlowrSearchBuilder<"get">;
32
+ /**
33
+ * Returns all elements that match the given {@link SlicingCriteria|criteria}
34
+ * (e.g., `criterion('2@x', '3@<-')`,
35
+ * to retrieve the first use of `x` in the second line and the first `<-` assignment in the third line).
36
+ * This will throw an error, if any criteria cannot be resolved to an id.
37
+ */
38
+ readonly criterion: <Criteria extends SlicingCriteria>(...criterion: Criteria) => FlowrSearchBuilder<"criterion", [], ParentInformation, FlowrCriteriaReturn<Criteria>>;
39
+ /**
40
+ * Short form of {@link get} with only the
41
+ * {@link FlowrSearchGetFilters#line|line} and {@link FlowrSearchGetFilters#column|column} filters:
42
+ * `get({line, column})`.
43
+ */
44
+ readonly loc: (line?: number, column?: number) => FlowrSearchBuilder<"get">;
45
+ /**
46
+ * Short form of {@link get} with only the {@link FlowrSearchGetFilters#name|name} and {@link FlowrSearchGetFilters#line|line} filters:
47
+ * `get({name, line})`.
48
+ */
49
+ readonly varInLine: (name: string, line: number) => FlowrSearchBuilder<"get">;
50
+ /**
51
+ * Short form of {@link get} with only the {@link FlowrSearchGetFilters#name|name} filter:
52
+ * `get({name})`.
53
+ */
54
+ readonly var: (name: string) => FlowrSearchBuilder<"get">;
55
+ /**
56
+ * Short form of {@link get} with only the {@link FlowrSearchGetFilters#id|id} filter:
57
+ * `get({id})`.
58
+ */
59
+ readonly id: (id: NodeId) => FlowrSearchBuilder<"get">;
60
+ };
61
+ /**
62
+ * This is the root object to use for creating searches.
63
+ * See the {@link FlowrSearchGenerator} for the available methods.
64
+ * After the query is generated,
65
+ * you can use what is provided by the {@link FlowrSearchBuilder} to further refine the search.
66
+ */
67
+ export declare const Q: {
68
+ /**
69
+ * Initialize a search query with the given elements.
70
+ * <b>This is not intended to serialize well</b> wrt. the nodes,
71
+ * see {@link FlowrSearchGenerator.criterion} for a serializable alternative (passing the ids with `$id`).
72
+ */
73
+ readonly from: (from: FlowrSearchElement<ParentInformation> | FlowrSearchElement<ParentInformation>[]) => FlowrSearchBuilder<"from">;
74
+ /**
75
+ * Returns all elements (nodes/dataflow vertices) from the given data.
76
+ */
77
+ readonly all: () => FlowrSearchBuilder<"all">;
78
+ /**
79
+ * Returns all elements that match the given {@link FlowrSearchGetFilters|filters}.
80
+ * You may pass a negative line number to count from the back.
81
+ * Please note that this is currently only working for single files, it approximates over the nodes, and it is not to be used for "production".
82
+ */
83
+ readonly get: (filter: FlowrSearchGetFilter) => FlowrSearchBuilder<"get">;
84
+ /**
85
+ * Returns all elements that match the given {@link SlicingCriteria|criteria}
86
+ * (e.g., `criterion('2@x', '3@<-')`,
87
+ * to retrieve the first use of `x` in the second line and the first `<-` assignment in the third line).
88
+ * This will throw an error, if any criteria cannot be resolved to an id.
89
+ */
90
+ readonly criterion: <Criteria extends SlicingCriteria>(...criterion: Criteria) => FlowrSearchBuilder<"criterion", [], ParentInformation, FlowrCriteriaReturn<Criteria>>;
91
+ /**
92
+ * Short form of {@link get} with only the
93
+ * {@link FlowrSearchGetFilters#line|line} and {@link FlowrSearchGetFilters#column|column} filters:
94
+ * `get({line, column})`.
95
+ */
96
+ readonly loc: (line?: number, column?: number) => FlowrSearchBuilder<"get">;
97
+ /**
98
+ * Short form of {@link get} with only the {@link FlowrSearchGetFilters#name|name} and {@link FlowrSearchGetFilters#line|line} filters:
99
+ * `get({name, line})`.
100
+ */
101
+ readonly varInLine: (name: string, line: number) => FlowrSearchBuilder<"get">;
102
+ /**
103
+ * Short form of {@link get} with only the {@link FlowrSearchGetFilters#name|name} filter:
104
+ * `get({name})`.
105
+ */
106
+ readonly var: (name: string) => FlowrSearchBuilder<"get">;
107
+ /**
108
+ * Short form of {@link get} with only the {@link FlowrSearchGetFilters#id|id} filter:
109
+ * `get({id})`.
110
+ */
111
+ readonly id: (id: NodeId) => FlowrSearchBuilder<"get">;
112
+ };
113
+ export type FlowrSearchBuilderType<Generator extends GeneratorNames = GeneratorNames, Transformers extends TransformerNames[] = TransformerNames[], Info = ParentInformation, ElementType = FlowrSearchElements<Info, FlowrSearchElement<Info>[]>> = FlowrSearchBuilder<Generator, Transformers, Info, ElementType>;
114
+ type GetElements<F> = F extends FlowrSearchElements<infer Info, infer Elements> ? Elements extends FlowrSearchElement<Info>[] ? Elements : never : never;
115
+ /**
116
+ * The search query is a combination of a generator and a list of transformers
117
+ * and allows this view to pass such queries in a serialized form.
118
+ *
119
+ * @typeParam Transformers - The list of transformers that are applied to the generator's output.
120
+ */
121
+ export interface FlowrSearch<Info = ParentInformation, _Generator extends GeneratorNames = GeneratorNames, _Transformers extends readonly TransformerNames[] = readonly TransformerNames[], _ElementType = FlowrSearchElements<Info, FlowrSearchElement<Info>[]>> {
122
+ readonly generator: FlowrSearchGeneratorNode;
123
+ readonly search: readonly FlowrSearchTransformerNode[];
124
+ }
125
+ type FlowrSearchBuilderOut<Generator extends GeneratorNames, Transformers extends TransformerNames[], Info, Transformer extends TransformerNames> = FlowrSearchBuilder<Generator, [...Transformers, Transformer], Info, GetOutputOfTransformer<Transformer>>;
126
+ /**
127
+ * Allows you to construct a search query from a {@link FlowrSearchGeneratorNode}.
128
+ * Please use the {@link Q} object to create an object of this class!
129
+ * In the end, you _can_ freeze the search by calling {@link FlowrSearchBuilder#build},
130
+ * however, the search executors may do that for you.
131
+ *
132
+ * @see {@link FlowrSearchGenerator}
133
+ * @see {@link FlowrSearch}
134
+ * @see {@link FlowrSearchLike}
135
+ */
136
+ export declare class FlowrSearchBuilder<Generator extends GeneratorNames, Transformers extends TransformerNames[] = [], Info = ParentInformation, ElementType = FlowrSearchElements<Info, FlowrSearchElement<Info>[]>> {
137
+ private readonly generator;
138
+ private readonly search;
139
+ constructor(generator: FlowrSearchGeneratorNode);
140
+ /**
141
+ * only returns the elements that match the given filter.
142
+ */
143
+ filter(filter: FlowrFilterExpression): FlowrSearchBuilderOut<Generator, Transformers, Info, 'filter'>;
144
+ /**
145
+ * first either returns the first element of the search or nothing, if no elements are present.
146
+ */
147
+ first(): FlowrSearchBuilderOut<Generator, Transformers, Info, 'first'>;
148
+ /**
149
+ * last either returns the last element of the search or nothing, if no elements are present.
150
+ */
151
+ last(): FlowrSearchBuilderOut<Generator, Transformers, Info, 'last'>;
152
+ /**
153
+ * index returns the element at the given index if it exists
154
+ */
155
+ index<Idx extends number>(index: Idx): FlowrSearchBuilderOut<Generator, Transformers, Info, 'index'>;
156
+ /**
157
+ * tail returns all elements of the search except the first one.
158
+ */
159
+ tail(): FlowrSearchBuilderOut<Generator, Transformers, Info, 'tail'>;
160
+ /**
161
+ * take returns the first `count` elements of the search.
162
+ */
163
+ take<Count extends number>(count: Count): FlowrSearchBuilderOut<Generator, Transformers, Info, 'take'>;
164
+ /**
165
+ * skip returns all elements of the search except the first `count` ones.
166
+ */
167
+ skip<Count extends number>(count: Count): FlowrSearchBuilderOut<Generator, Transformers, Info, 'skip'>;
168
+ /**
169
+ * select returns only the elements at the given indices.
170
+ */
171
+ select<Select extends number[]>(...select: Select): FlowrSearchBuilderOut<Generator, Transformers, Info, 'select'>;
172
+ /**
173
+ * merge combines the search results with those of another search.
174
+ */
175
+ merge<Generator2 extends GeneratorNames, Transformers2 extends TransformerNames[], OtherElementType extends FlowrSearchElements<Info, FlowrSearchElement<Info>[]>>(other: FlowrSearchBuilder<Generator2, Transformers2, Info, OtherElementType>): FlowrSearchBuilder<Generator, Transformers, Info, FlowrSearchElements<Info, [...GetElements<ElementType>, ...GetElements<OtherElementType>]>>;
176
+ /**
177
+ * Construct the final search (this may happen automatically with most search handlers).
178
+ *
179
+ * @param shouldOptimize - This may optimize the search.
180
+ */
181
+ build(shouldOptimize?: boolean): FlowrSearch<Info, Generator, Transformers, ElementType>;
182
+ }
183
+ /**
184
+ * This type summarizes all types that can be used in places in which the API expects you to provide a search query.
185
+ * @see {@link FlowrSearch}
186
+ */
187
+ export type FlowrSearchLike = FlowrSearch | FlowrSearchBuilderType;
188
+ 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;
189
+ /**
190
+ * Freezes any accepted {@link FlowrSearchLike} into a {@link FlowrSearch}.
191
+ */
192
+ export declare function getFlowrSearch<Search extends FlowrSearchLike>(search: Search, optimizeIfBuild?: boolean): SearchOutput<Search>;
193
+ export {};