@eagleoutice/flowr 2.2.13 → 2.2.14
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.
- package/README.md +4 -4
- package/cli/repl/commands/repl-cfg.d.ts +2 -2
- package/cli/repl/commands/repl-cfg.js +4 -4
- package/cli/repl/commands/repl-commands.js +2 -2
- package/cli/repl/server/connection.js +1 -1
- package/cli/script-core/statistics-helper-core.js +1 -1
- package/control-flow/extract-cfg.d.ts +2 -2
- package/control-flow/extract-cfg.js +10 -10
- package/documentation/doc-util/doc-cfg.d.ts +1 -1
- package/documentation/doc-util/doc-cfg.js +3 -3
- package/documentation/print-cfg-wiki.js +25 -25
- package/documentation/print-linter-wiki.d.ts +1 -0
- package/documentation/print-linter-wiki.js +76 -0
- package/linter/linter-executor.d.ts +9 -0
- package/linter/linter-executor.js +26 -0
- package/linter/linter-format.d.ts +65 -0
- package/linter/linter-format.js +9 -0
- package/linter/linter-rules.d.ts +42 -0
- package/linter/linter-rules.js +14 -0
- package/linter/rules/1-deprecated-functions.d.ts +34 -0
- package/linter/rules/1-deprecated-functions.js +54 -0
- package/linter/rules/2-file-path-validity.d.ts +48 -0
- package/linter/rules/2-file-path-validity.js +93 -0
- package/package.json +2 -1
- package/queries/catalog/call-context-query/call-context-query-executor.js +1 -1
- package/queries/catalog/call-context-query/call-context-query-format.d.ts +2 -2
- package/queries/catalog/call-context-query/call-context-query-format.js +5 -1
- package/queries/catalog/cluster-query/cluster-query-format.d.ts +2 -0
- package/queries/catalog/cluster-query/cluster-query-format.js +5 -1
- package/queries/catalog/config-query/config-query-format.d.ts +1 -0
- package/queries/catalog/config-query/config-query-format.js +2 -1
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.d.ts +1 -0
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.js +2 -1
- package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +2 -0
- package/queries/catalog/dataflow-query/dataflow-query-format.js +9 -1
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +1 -0
- package/queries/catalog/dependencies-query/dependencies-query-format.js +10 -1
- package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +1 -0
- package/queries/catalog/happens-before-query/happens-before-query-format.js +2 -1
- package/queries/catalog/id-map-query/id-map-query-format.d.ts +1 -0
- package/queries/catalog/id-map-query/id-map-query-format.js +2 -1
- package/queries/catalog/lineage-query/lineage-query-format.d.ts +1 -0
- package/queries/catalog/lineage-query/lineage-query-format.js +5 -1
- package/queries/catalog/linter-query/linter-query-executor.d.ts +3 -0
- package/queries/catalog/linter-query/linter-query-executor.js +28 -0
- package/queries/catalog/linter-query/linter-query-format.d.ts +80 -0
- package/queries/catalog/linter-query/linter-query-format.js +43 -0
- package/queries/catalog/location-map-query/location-map-query-format.d.ts +1 -0
- package/queries/catalog/location-map-query/location-map-query-format.js +2 -1
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +1 -0
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.js +2 -1
- package/queries/catalog/origin-query/origin-query-format.d.ts +2 -0
- package/queries/catalog/origin-query/origin-query-format.js +5 -1
- package/queries/catalog/project-query/project-query-executor.js +1 -1
- package/queries/catalog/project-query/project-query-format.d.ts +1 -0
- package/queries/catalog/project-query/project-query-format.js +2 -1
- package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +1 -0
- package/queries/catalog/resolve-value-query/resolve-value-query-format.js +2 -1
- package/queries/catalog/search-query/search-query-format.d.ts +1 -0
- package/queries/catalog/search-query/search-query-format.js +5 -1
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +2 -0
- package/queries/catalog/static-slice-query/static-slice-query-format.js +9 -1
- package/queries/query.d.ts +83 -1
- package/queries/query.js +2 -0
- package/r-bridge/retriever.js +1 -1
- package/search/flowr-search-builder.d.ts +31 -2
- package/search/flowr-search-builder.js +30 -0
- package/search/flowr-search.d.ts +7 -1
- package/search/search-executor/search-enrichers.d.ts +73 -0
- package/search/search-executor/search-enrichers.js +98 -0
- package/search/search-executor/search-generators.d.ts +6 -1
- package/search/search-executor/search-generators.js +21 -1
- package/search/search-executor/search-mappers.d.ts +19 -0
- package/search/search-executor/search-mappers.js +21 -0
- package/search/search-executor/search-transformer.d.ts +12 -0
- package/search/search-executor/search-transformer.js +11 -1
- package/util/version.js +1 -1
|
@@ -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
|
*/
|
package/search/flowr-search.d.ts
CHANGED
|
@@ -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():
|
|
61
|
+
getElements(): Readonly<Elements>;
|
|
56
62
|
mutate<OutElements extends Elements>(mutator: (elements: Elements) => OutElements): this;
|
|
57
63
|
}
|
|
58
64
|
export {};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { FlowrSearchElement, FlowrSearchInput } from '../flowr-search';
|
|
2
|
+
import type { ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
3
|
+
import type { Pipeline } from '../../core/steps/pipeline/pipeline';
|
|
4
|
+
import type { MergeableRecord } from '../../util/objects';
|
|
5
|
+
import type { Identifier } from '../../dataflow/environments/identifier';
|
|
6
|
+
import type { LinkToLastCall } from '../../queries/catalog/call-context-query/call-context-query-format';
|
|
7
|
+
/**
|
|
8
|
+
* A {@link FlowrSearchElement} that is enriched with a set of enrichments through {@link FlowrSearchBuilder.with}.
|
|
9
|
+
* Enrichments can be retrieved easily from an element through {@link enrichmentContent}.
|
|
10
|
+
*/
|
|
11
|
+
export interface EnrichedFlowrSearchElement<Info> extends FlowrSearchElement<Info> {
|
|
12
|
+
enrichments: {
|
|
13
|
+
[E in Enrichment]?: EnrichmentContent<E>;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export interface EnrichmentData<EnrichmentContent extends MergeableRecord, EnrichmentArguments = undefined> {
|
|
17
|
+
/**
|
|
18
|
+
* A function that is applied to each element of the search to enrich it with additional data.
|
|
19
|
+
*/
|
|
20
|
+
readonly enrich: (e: FlowrSearchElement<ParentInformation>, data: FlowrSearchInput<Pipeline>, args: EnrichmentArguments | undefined) => EnrichmentContent;
|
|
21
|
+
/**
|
|
22
|
+
* The mapping function used by the {@link Mapper.Enrichment} mapper.
|
|
23
|
+
*/
|
|
24
|
+
readonly mapper: (c: EnrichmentContent) => FlowrSearchElement<ParentInformation>[];
|
|
25
|
+
}
|
|
26
|
+
export type EnrichmentContent<E extends Enrichment> = typeof Enrichments[E] extends EnrichmentData<infer Content, infer _Args> ? Content : never;
|
|
27
|
+
export type EnrichmentArguments<E extends Enrichment> = typeof Enrichments[E] extends EnrichmentData<infer _Content, infer Args> ? Args : never;
|
|
28
|
+
/**
|
|
29
|
+
* An enumeration that stores the names of the available enrichments that can be applied to a set of search elements.
|
|
30
|
+
* See {@link FlowrSearchBuilder.with} for more information on how to apply enrichments.
|
|
31
|
+
*/
|
|
32
|
+
export declare enum Enrichment {
|
|
33
|
+
CallTargets = "call-targets",
|
|
34
|
+
LastCall = "last-call"
|
|
35
|
+
}
|
|
36
|
+
export interface CallTargetsContent extends MergeableRecord {
|
|
37
|
+
/**
|
|
38
|
+
* The call targets of the function call.
|
|
39
|
+
* For identifier call targets, the identifier is the name of the library function being called.
|
|
40
|
+
*/
|
|
41
|
+
targets: (FlowrSearchElement<ParentInformation> | Identifier)[];
|
|
42
|
+
}
|
|
43
|
+
export interface LastCallContent extends MergeableRecord {
|
|
44
|
+
linkedIds: FlowrSearchElement<ParentInformation>[];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The registry of enrichments that are currently supported by the search.
|
|
48
|
+
* See {@link FlowrSearchBuilder.with} for more information on how to apply enrichments.
|
|
49
|
+
*/
|
|
50
|
+
export declare const Enrichments: {
|
|
51
|
+
readonly "call-targets": {
|
|
52
|
+
enrich: (e: FlowrSearchElement<ParentInformation>, data: import("../../core/steps/pipeline/pipeline").PipelineOutput<Pipeline<import("../../core/steps/pipeline-step").IPipelineStep<import("../../core/steps/pipeline-step").PipelineStepName, (...args: any[]) => any>>> & {
|
|
53
|
+
normalize: import("../../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
|
|
54
|
+
dataflow: import("../../dataflow/info").DataflowInformation;
|
|
55
|
+
}) => CallTargetsContent;
|
|
56
|
+
mapper: ({ targets }: CallTargetsContent) => FlowrSearchElement<ParentInformation>[];
|
|
57
|
+
};
|
|
58
|
+
readonly "last-call": {
|
|
59
|
+
enrich: (e: FlowrSearchElement<ParentInformation>, data: import("../../core/steps/pipeline/pipeline").PipelineOutput<Pipeline<import("../../core/steps/pipeline-step").IPipelineStep<import("../../core/steps/pipeline-step").PipelineStepName, (...args: any[]) => any>>> & {
|
|
60
|
+
normalize: import("../../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
|
|
61
|
+
dataflow: import("../../dataflow/info").DataflowInformation;
|
|
62
|
+
}, args: Omit<LinkToLastCall<string | RegExp>, "type">[] | undefined) => LastCallContent;
|
|
63
|
+
mapper: ({ linkedIds }: LastCallContent) => FlowrSearchElement<ParentInformation>[];
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Returns the content of the given enrichment type from a {@link FlowrSearchElement}.
|
|
68
|
+
* If the search element is not enriched with the given enrichment, `undefined` is returned.
|
|
69
|
+
* @param e - The search element whose enrichment content should be retrieved.
|
|
70
|
+
* @param enrichment - The enrichment content, if present, else `undefined`.
|
|
71
|
+
*/
|
|
72
|
+
export declare function enrichmentContent<E extends Enrichment>(e: FlowrSearchElement<ParentInformation>, enrichment: E): EnrichmentContent<E>;
|
|
73
|
+
export declare function enrich<ElementIn extends FlowrSearchElement<ParentInformation>, ElementOut extends ElementIn & EnrichedFlowrSearchElement<ParentInformation>, ConcreteEnrichment extends Enrichment>(e: ElementIn, data: FlowrSearchInput<Pipeline>, enrichment: ConcreteEnrichment, args?: EnrichmentArguments<ConcreteEnrichment>): ElementOut;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Enrichments = exports.Enrichment = void 0;
|
|
4
|
+
exports.enrichmentContent = enrichmentContent;
|
|
5
|
+
exports.enrich = enrich;
|
|
6
|
+
const vertex_1 = require("../../dataflow/graph/vertex");
|
|
7
|
+
const log_1 = require("../../util/log");
|
|
8
|
+
const identify_link_to_last_call_relation_1 = require("../../queries/catalog/call-context-query/identify-link-to-last-call-relation");
|
|
9
|
+
const assert_1 = require("../../util/assert");
|
|
10
|
+
const extract_cfg_1 = require("../../control-flow/extract-cfg");
|
|
11
|
+
const dfg_get_origin_1 = require("../../dataflow/origin/dfg-get-origin");
|
|
12
|
+
/**
|
|
13
|
+
* An enumeration that stores the names of the available enrichments that can be applied to a set of search elements.
|
|
14
|
+
* See {@link FlowrSearchBuilder.with} for more information on how to apply enrichments.
|
|
15
|
+
*/
|
|
16
|
+
var Enrichment;
|
|
17
|
+
(function (Enrichment) {
|
|
18
|
+
Enrichment["CallTargets"] = "call-targets";
|
|
19
|
+
Enrichment["LastCall"] = "last-call";
|
|
20
|
+
})(Enrichment || (exports.Enrichment = Enrichment = {}));
|
|
21
|
+
/**
|
|
22
|
+
* The registry of enrichments that are currently supported by the search.
|
|
23
|
+
* See {@link FlowrSearchBuilder.with} for more information on how to apply enrichments.
|
|
24
|
+
*/
|
|
25
|
+
exports.Enrichments = {
|
|
26
|
+
[Enrichment.CallTargets]: {
|
|
27
|
+
enrich: (e, data) => {
|
|
28
|
+
// we don't resolve aliases here yet!
|
|
29
|
+
const content = { targets: [] };
|
|
30
|
+
const callVertex = data.dataflow.graph.getVertex(e.node.info.id);
|
|
31
|
+
if (callVertex?.tag === vertex_1.VertexType.FunctionCall) {
|
|
32
|
+
const origins = (0, dfg_get_origin_1.getOriginInDfg)(data.dataflow.graph, callVertex.id);
|
|
33
|
+
if (!origins || origins.length === 0) {
|
|
34
|
+
log_1.log.warn(`No origin found for call vertex ${callVertex.id}, cannot resolve call targets.`);
|
|
35
|
+
return content;
|
|
36
|
+
}
|
|
37
|
+
// find call targets in user code (which have ids!)
|
|
38
|
+
content.targets = content.targets.concat(origins.map(o => {
|
|
39
|
+
switch (o.type) {
|
|
40
|
+
case 2 /* OriginType.FunctionCallOrigin */:
|
|
41
|
+
return {
|
|
42
|
+
node: data.normalize.idMap.get(o.id),
|
|
43
|
+
};
|
|
44
|
+
case 3 /* OriginType.BuiltInFunctionOrigin */:
|
|
45
|
+
return o.fn.name;
|
|
46
|
+
default:
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
}).filter(assert_1.isNotUndefined));
|
|
50
|
+
}
|
|
51
|
+
return content;
|
|
52
|
+
},
|
|
53
|
+
// as built-in call target enrichments are not nodes, we don't return them as part of the mapper!
|
|
54
|
+
mapper: ({ targets }) => targets.map(t => t).filter(t => t.node !== undefined)
|
|
55
|
+
},
|
|
56
|
+
[Enrichment.LastCall]: {
|
|
57
|
+
enrich: (e, data, args) => {
|
|
58
|
+
(0, assert_1.guard)(args && args.length, `${Enrichment.LastCall} enrichment requires at least one argument`);
|
|
59
|
+
const content = { linkedIds: [] };
|
|
60
|
+
const vertex = data.dataflow.graph.get(e.node.info.id);
|
|
61
|
+
if (vertex !== undefined && vertex[0].tag === vertex_1.VertexType.FunctionCall) {
|
|
62
|
+
const cfg = (0, extract_cfg_1.extractSimpleCfg)(data.normalize);
|
|
63
|
+
for (const arg of args) {
|
|
64
|
+
const lastCalls = (0, identify_link_to_last_call_relation_1.identifyLinkToLastCallRelation)(vertex[0].id, cfg.graph, data.dataflow.graph, {
|
|
65
|
+
...arg,
|
|
66
|
+
callName: new RegExp(arg.callName),
|
|
67
|
+
type: 'link-to-last-call',
|
|
68
|
+
});
|
|
69
|
+
for (const lastCall of lastCalls) {
|
|
70
|
+
content.linkedIds.push({ node: data.normalize.idMap.get(lastCall) });
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return content;
|
|
75
|
+
},
|
|
76
|
+
mapper: ({ linkedIds }) => linkedIds
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Returns the content of the given enrichment type from a {@link FlowrSearchElement}.
|
|
81
|
+
* If the search element is not enriched with the given enrichment, `undefined` is returned.
|
|
82
|
+
* @param e - The search element whose enrichment content should be retrieved.
|
|
83
|
+
* @param enrichment - The enrichment content, if present, else `undefined`.
|
|
84
|
+
*/
|
|
85
|
+
function enrichmentContent(e, enrichment) {
|
|
86
|
+
return e?.enrichments?.[enrichment];
|
|
87
|
+
}
|
|
88
|
+
function enrich(e, data, enrichment, args) {
|
|
89
|
+
const enrichmentData = exports.Enrichments[enrichment];
|
|
90
|
+
return {
|
|
91
|
+
...e,
|
|
92
|
+
enrichments: {
|
|
93
|
+
...e?.enrichments ?? {},
|
|
94
|
+
[enrichment]: enrichmentData.enrich(e, data, args)
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=search-enrichers.js.map
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type { FlowrSearchElement, FlowrSearchGeneratorNodeBase, FlowrSearchGetFilter, FlowrSearchInput } from '../flowr-search';
|
|
1
|
+
import type { FlowrSearchElement, FlowrSearchElementFromQuery, FlowrSearchGeneratorNodeBase, FlowrSearchGetFilter, FlowrSearchInput } from '../flowr-search';
|
|
2
2
|
import { FlowrSearchElements } from '../flowr-search';
|
|
3
3
|
import type { Pipeline } from '../../core/steps/pipeline/pipeline';
|
|
4
4
|
import type { TailTypesOrUndefined } from '../../util/collections/arrays';
|
|
5
5
|
import type { ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
6
6
|
import type { SlicingCriteria } from '../../slicing/criterion/parse';
|
|
7
|
+
import type { Query } from '../../queries/query';
|
|
7
8
|
/**
|
|
8
9
|
* This is a union of all possible generator node types
|
|
9
10
|
*/
|
|
@@ -22,6 +23,7 @@ export declare const generators: {
|
|
|
22
23
|
readonly get: typeof generateGet;
|
|
23
24
|
readonly criterion: typeof generateCriterion;
|
|
24
25
|
readonly from: typeof generateFrom;
|
|
26
|
+
readonly 'from-query': typeof generateFromQuery;
|
|
25
27
|
};
|
|
26
28
|
declare function generateAll(data: FlowrSearchInput<Pipeline>): FlowrSearchElements<ParentInformation>;
|
|
27
29
|
declare function generateGet(data: FlowrSearchInput<Pipeline>, { filter: { line, column, id, name, nameIsRegex } }: {
|
|
@@ -30,6 +32,9 @@ declare function generateGet(data: FlowrSearchInput<Pipeline>, { filter: { line,
|
|
|
30
32
|
declare function generateFrom(data: FlowrSearchInput<Pipeline>, args: {
|
|
31
33
|
from: FlowrSearchElement<ParentInformation> | FlowrSearchElement<ParentInformation>[];
|
|
32
34
|
}): FlowrSearchElements<ParentInformation>;
|
|
35
|
+
declare function generateFromQuery(data: FlowrSearchInput<Pipeline>, args: {
|
|
36
|
+
from: readonly Query[];
|
|
37
|
+
}): FlowrSearchElements<ParentInformation, FlowrSearchElementFromQuery<ParentInformation>[]>;
|
|
33
38
|
declare function generateCriterion(data: FlowrSearchInput<Pipeline>, args: {
|
|
34
39
|
criterion: SlicingCriteria;
|
|
35
40
|
}): FlowrSearchElements<ParentInformation>;
|
|
@@ -5,6 +5,7 @@ exports.getGenerator = getGenerator;
|
|
|
5
5
|
const flowr_search_1 = require("../flowr-search");
|
|
6
6
|
const parse_1 = require("../../slicing/criterion/parse");
|
|
7
7
|
const assert_1 = require("../../util/assert");
|
|
8
|
+
const query_1 = require("../../queries/query");
|
|
8
9
|
/**
|
|
9
10
|
* All supported generators!
|
|
10
11
|
*/
|
|
@@ -12,7 +13,8 @@ exports.generators = {
|
|
|
12
13
|
all: generateAll,
|
|
13
14
|
get: generateGet,
|
|
14
15
|
criterion: generateCriterion,
|
|
15
|
-
from: generateFrom
|
|
16
|
+
from: generateFrom,
|
|
17
|
+
'from-query': generateFromQuery
|
|
16
18
|
};
|
|
17
19
|
function generateAll(data) {
|
|
18
20
|
return new flowr_search_1.FlowrSearchElements(getAllNodes(data)
|
|
@@ -52,6 +54,24 @@ function generateGet(data, { filter: { line, column, id, name, nameIsRegex } })
|
|
|
52
54
|
function generateFrom(data, args) {
|
|
53
55
|
return new flowr_search_1.FlowrSearchElements(Array.isArray(args.from) ? args.from : [args.from]);
|
|
54
56
|
}
|
|
57
|
+
function generateFromQuery(data, args) {
|
|
58
|
+
const nodes = new Set();
|
|
59
|
+
const result = (0, query_1.executeQueries)({ ast: data.normalize, dataflow: data.dataflow }, args.from);
|
|
60
|
+
for (const [query, content] of Object.entries(result)) {
|
|
61
|
+
if (query === '.meta') {
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
const queryDef = query_1.SupportedQueries[query];
|
|
65
|
+
for (const node of queryDef.flattenInvolvedNodes(content)) {
|
|
66
|
+
nodes.add({
|
|
67
|
+
node: data.normalize.idMap.get(node),
|
|
68
|
+
query: query,
|
|
69
|
+
queryResult: content
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return new flowr_search_1.FlowrSearchElements([...nodes]);
|
|
74
|
+
}
|
|
55
75
|
function generateCriterion(data, args) {
|
|
56
76
|
return new flowr_search_1.FlowrSearchElements(args.criterion.map(c => ({ node: data.normalize.idMap.get((0, parse_1.slicingCriterionToId)(c, data.normalize.idMap)) })));
|
|
57
77
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { FlowrSearchElement, FlowrSearchInput } from '../flowr-search';
|
|
2
|
+
import type { ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
3
|
+
import type { Enrichment } from './search-enrichers';
|
|
4
|
+
import type { MergeableRecord } from '../../util/objects';
|
|
5
|
+
import type { Pipeline } from '../../core/steps/pipeline/pipeline';
|
|
6
|
+
export declare enum Mapper {
|
|
7
|
+
Enrichment = "enrichment"
|
|
8
|
+
}
|
|
9
|
+
export interface MapperData<Arguments extends string | MergeableRecord> {
|
|
10
|
+
mapper: (e: FlowrSearchElement<ParentInformation>, data: FlowrSearchInput<Pipeline>, args: Arguments) => FlowrSearchElement<ParentInformation>[];
|
|
11
|
+
}
|
|
12
|
+
export type MapperArguments<M extends Mapper> = typeof Mappers[M] extends MapperData<infer Arguments> ? Arguments : never;
|
|
13
|
+
declare const Mappers: {
|
|
14
|
+
readonly enrichment: {
|
|
15
|
+
mapper: (e: FlowrSearchElement<ParentInformation>, _data: FlowrSearchInput<Pipeline>, enrichment: Enrichment) => FlowrSearchElement<ParentInformation>[];
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export declare function map<Element extends FlowrSearchElement<ParentInformation>, MapperType extends Mapper>(e: Element, data: FlowrSearchInput<Pipeline>, mapper: MapperType, args: MapperArguments<MapperType>): Element[];
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Mapper = void 0;
|
|
4
|
+
exports.map = map;
|
|
5
|
+
const search_enrichers_1 = require("./search-enrichers");
|
|
6
|
+
var Mapper;
|
|
7
|
+
(function (Mapper) {
|
|
8
|
+
Mapper["Enrichment"] = "enrichment";
|
|
9
|
+
})(Mapper || (exports.Mapper = Mapper = {}));
|
|
10
|
+
const Mappers = {
|
|
11
|
+
[Mapper.Enrichment]: {
|
|
12
|
+
mapper: (e, _data, enrichment) => {
|
|
13
|
+
const data = (0, search_enrichers_1.enrichmentContent)(e, enrichment);
|
|
14
|
+
return data !== undefined ? search_enrichers_1.Enrichments[enrichment].mapper(data) : [];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
function map(e, data, mapper, args) {
|
|
19
|
+
return Mappers[mapper].mapper(e, data, args);
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=search-mappers.js.map
|
|
@@ -4,6 +4,8 @@ import type { LastOfArray, Tail2TypesOrUndefined, TailOfArray } from '../../util
|
|
|
4
4
|
import type { FlowrFilterExpression } from '../flowr-search-filters';
|
|
5
5
|
import type { FlowrSearchGeneratorNode } from './search-generators';
|
|
6
6
|
import type { ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
7
|
+
import type { EnrichedFlowrSearchElement, Enrichment, EnrichmentArguments } from './search-enrichers';
|
|
8
|
+
import type { Mapper, MapperArguments } from './search-mappers';
|
|
7
9
|
/**
|
|
8
10
|
* This is a union of all possible transformer node types
|
|
9
11
|
*/
|
|
@@ -28,6 +30,8 @@ export declare const transformers: {
|
|
|
28
30
|
readonly filter: typeof getFilter;
|
|
29
31
|
readonly merge: typeof getMerge;
|
|
30
32
|
readonly select: typeof getSelect;
|
|
33
|
+
readonly with: typeof getWith;
|
|
34
|
+
readonly map: typeof getMap;
|
|
31
35
|
};
|
|
32
36
|
export declare function getTransformer<Name extends TransformerNames>(name: Name): typeof transformers[Name];
|
|
33
37
|
/** If we already have no more elements, cascade will not add any but keep the empty elements, otherwise it will now be NewElements */
|
|
@@ -50,6 +54,14 @@ declare function getSkip<Elements extends FlowrSearchElement<ParentInformation>[
|
|
|
50
54
|
declare function getFilter<Elements extends FlowrSearchElement<ParentInformation>[], FSE extends FlowrSearchElements<ParentInformation, Elements>>(data: FlowrSearchInput<Pipeline>, elements: FSE, { filter }: {
|
|
51
55
|
filter: FlowrFilterExpression;
|
|
52
56
|
}): CascadeEmpty<Elements, Elements | []>;
|
|
57
|
+
declare function getWith<Elements extends FlowrSearchElement<ParentInformation>[], FSE extends FlowrSearchElements<ParentInformation, Elements>>(data: FlowrSearchInput<Pipeline>, elements: FSE, { info, args }: {
|
|
58
|
+
info: Enrichment;
|
|
59
|
+
args?: EnrichmentArguments<Enrichment>;
|
|
60
|
+
}): FlowrSearchElements<ParentInformation, EnrichedFlowrSearchElement<ParentInformation>[]>;
|
|
61
|
+
declare function getMap<Elements extends FlowrSearchElement<ParentInformation>[], FSE extends FlowrSearchElements<ParentInformation, Elements>>(data: FlowrSearchInput<Pipeline>, elements: FSE, { mapper, args }: {
|
|
62
|
+
mapper: Mapper;
|
|
63
|
+
args: MapperArguments<Mapper>;
|
|
64
|
+
}): FlowrSearchElements<ParentInformation, Elements>;
|
|
53
65
|
declare function getMerge<Elements extends FlowrSearchElement<ParentInformation>[], FSE extends FlowrSearchElements<ParentInformation, Elements>>(data: FlowrSearchInput<Pipeline>, elements: FSE, other: {
|
|
54
66
|
search: unknown[];
|
|
55
67
|
generator: FlowrSearchGeneratorNode;
|
|
@@ -5,6 +5,8 @@ exports.getTransformer = getTransformer;
|
|
|
5
5
|
const flowr_search_filters_1 = require("../flowr-search-filters");
|
|
6
6
|
const flowr_search_executor_1 = require("../flowr-search-executor");
|
|
7
7
|
const assert_1 = require("../../util/assert");
|
|
8
|
+
const search_enrichers_1 = require("./search-enrichers");
|
|
9
|
+
const search_mappers_1 = require("./search-mappers");
|
|
8
10
|
/**
|
|
9
11
|
* All supported generators!
|
|
10
12
|
*/
|
|
@@ -17,7 +19,9 @@ exports.transformers = {
|
|
|
17
19
|
skip: getSkip,
|
|
18
20
|
filter: getFilter,
|
|
19
21
|
merge: getMerge,
|
|
20
|
-
select: getSelect
|
|
22
|
+
select: getSelect,
|
|
23
|
+
with: getWith,
|
|
24
|
+
map: getMap
|
|
21
25
|
};
|
|
22
26
|
function getTransformer(name) {
|
|
23
27
|
if (!exports.transformers[name]) {
|
|
@@ -90,6 +94,12 @@ function getSkip(data, elements, { count }) {
|
|
|
90
94
|
function getFilter(data, elements, { filter }) {
|
|
91
95
|
return elements.mutate(e => e.filter(({ node }) => (0, flowr_search_filters_1.evalFilter)(filter, { node, normalize: data.normalize, dataflow: data.dataflow })));
|
|
92
96
|
}
|
|
97
|
+
function getWith(data, elements, { info, args }) {
|
|
98
|
+
return elements.mutate(elements => elements.map(e => (0, search_enrichers_1.enrich)(e, data, info, args)));
|
|
99
|
+
}
|
|
100
|
+
function getMap(data, elements, { mapper, args }) {
|
|
101
|
+
return elements.mutate(elements => elements.flatMap(e => (0, search_mappers_1.map)(e, data, mapper, args)));
|
|
102
|
+
}
|
|
93
103
|
function getMerge(
|
|
94
104
|
/* search has to be unknown because it is a recursive type */
|
|
95
105
|
data, elements, other) {
|
package/util/version.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.flowrVersion = flowrVersion;
|
|
4
4
|
const semver_1 = require("semver");
|
|
5
5
|
// this is automatically replaced with the current version by release-it
|
|
6
|
-
const version = '2.2.
|
|
6
|
+
const version = '2.2.14';
|
|
7
7
|
function flowrVersion() {
|
|
8
8
|
return new semver_1.SemVer(version);
|
|
9
9
|
}
|