@eagleoutice/flowr 2.5.0 → 2.6.1
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 +46 -35
- package/abstract-interpretation/data-frame/absint-visitor.d.ts +1 -1
- package/abstract-interpretation/data-frame/absint-visitor.js +1 -1
- package/cli/flowr.js +11 -33
- package/cli/repl/commands/repl-cfg.d.ts +5 -5
- package/cli/repl/commands/repl-cfg.js +21 -22
- package/cli/repl/commands/repl-commands.d.ts +3 -3
- package/cli/repl/commands/repl-commands.js +2 -0
- package/cli/repl/commands/repl-dataflow.d.ts +5 -5
- package/cli/repl/commands/repl-dataflow.js +27 -30
- package/cli/repl/commands/repl-execute.d.ts +1 -1
- package/cli/repl/commands/repl-execute.js +8 -7
- package/cli/repl/commands/repl-lineage.d.ts +2 -2
- package/cli/repl/commands/repl-lineage.js +11 -11
- package/cli/repl/commands/repl-main.d.ts +35 -7
- package/cli/repl/commands/repl-normalize.d.ts +3 -3
- package/cli/repl/commands/repl-normalize.js +15 -19
- package/cli/repl/commands/repl-parse.d.ts +2 -2
- package/cli/repl/commands/repl-parse.js +14 -8
- package/cli/repl/commands/repl-query.d.ts +3 -3
- package/cli/repl/commands/repl-query.js +29 -19
- package/cli/repl/commands/repl-quit.js +1 -0
- package/cli/repl/commands/repl-version.d.ts +1 -16
- package/cli/repl/commands/repl-version.js +2 -18
- package/cli/repl/core.d.ts +12 -9
- package/cli/repl/core.js +26 -12
- package/cli/repl/print-version.js +2 -2
- package/cli/repl/server/connection.d.ts +7 -3
- package/cli/repl/server/connection.js +46 -50
- package/cli/repl/server/messages/message-hello.d.ts +1 -1
- package/cli/repl/server/messages/message-slice.d.ts +1 -1
- package/cli/repl/server/server.js +2 -2
- package/cli/slicer-app.js +1 -1
- package/config.d.ts +1 -1
- package/config.js +4 -1
- package/control-flow/extract-cfg.d.ts +1 -1
- package/control-flow/extract-cfg.js +1 -1
- package/core/pipeline-executor.d.ts +5 -0
- package/core/pipeline-executor.js +5 -0
- package/core/steps/all/core/20-dataflow.d.ts +3 -1
- package/core/steps/pipeline/create-pipeline.js +1 -1
- package/core/steps/pipeline/default-pipelines.d.ts +24 -8
- package/core/steps/pipeline/default-pipelines.js +4 -1
- package/dataflow/environments/default-builtin-config.js +8 -0
- package/dataflow/eval/resolve/alias-tracking.js +2 -0
- package/dataflow/eval/resolve/resolve.js +3 -0
- package/dataflow/eval/values/r-value.d.ts +4 -1
- package/dataflow/eval/values/r-value.js +2 -0
- package/dataflow/extractor.d.ts +4 -1
- package/dataflow/extractor.js +7 -5
- package/dataflow/fn/higher-order-function.d.ts +9 -0
- package/dataflow/fn/higher-order-function.js +75 -0
- package/dataflow/graph/dataflowgraph-builder.d.ts +11 -12
- package/dataflow/graph/dataflowgraph-builder.js +6 -6
- package/documentation/doc-util/doc-query.d.ts +3 -6
- package/documentation/doc-util/doc-query.js +5 -17
- package/documentation/doc-util/doc-repl.js +5 -2
- package/documentation/doc-util/doc-search.js +7 -10
- package/documentation/doc-util/doc-structure.d.ts +4 -0
- package/documentation/doc-util/doc-structure.js +28 -0
- package/documentation/doc-util/doc-types.d.ts +5 -1
- package/documentation/doc-util/doc-types.js +29 -3
- package/documentation/print-analyzer-wiki.d.ts +1 -0
- package/documentation/print-analyzer-wiki.js +137 -0
- package/documentation/print-core-wiki.d.ts +2 -1
- package/documentation/print-core-wiki.js +58 -4
- package/documentation/print-dataflow-graph-wiki.js +16 -23
- package/documentation/print-interface-wiki.js +18 -1
- package/documentation/print-linter-wiki.js +5 -1
- package/documentation/print-normalized-ast-wiki.js +6 -8
- package/documentation/print-query-wiki.js +20 -0
- package/documentation/print-readme.js +1 -1
- package/engines.d.ts +9 -0
- package/engines.js +38 -0
- package/linter/linter-executor.d.ts +2 -8
- package/linter/linter-executor.js +9 -4
- package/linter/linter-format.d.ts +8 -9
- package/linter/linter-rules.d.ts +57 -15
- package/linter/linter-rules.js +2 -0
- package/linter/rules/absolute-path.d.ts +1 -0
- package/linter/rules/dataframe-access-validation.d.ts +4 -3
- package/linter/rules/dataframe-access-validation.js +7 -4
- package/linter/rules/dead-code.d.ts +2 -1
- package/linter/rules/deprecated-functions.d.ts +15 -28
- package/linter/rules/deprecated-functions.js +5 -43
- package/linter/rules/file-path-validity.d.ts +2 -1
- package/linter/rules/file-path-validity.js +1 -1
- package/linter/rules/function-finder-util.d.ts +51 -0
- package/linter/rules/function-finder-util.js +77 -0
- package/linter/rules/naming-convention.d.ts +2 -1
- package/linter/rules/network-functions.d.ts +40 -0
- package/linter/rules/network-functions.js +24 -0
- package/linter/rules/seeded-randomness.d.ts +2 -1
- package/linter/rules/unused-definition.d.ts +2 -1
- package/linter/rules/useless-loop.d.ts +3 -2
- package/linter/rules/useless-loop.js +4 -6
- package/package.json +2 -1
- package/project/cache/flowr-analyzer-cache.d.ts +94 -0
- package/project/cache/flowr-analyzer-cache.js +164 -0
- package/project/cache/flowr-cache.d.ts +28 -0
- package/project/cache/flowr-cache.js +49 -0
- package/project/cfg-kind.d.ts +17 -0
- package/project/cfg-kind.js +22 -0
- package/project/context/abstract-flowr-analyzer-context.d.ts +39 -0
- package/project/context/abstract-flowr-analyzer-context.js +46 -0
- package/project/context/flowr-analyzer-context.d.ts +54 -0
- package/project/context/flowr-analyzer-context.js +58 -0
- package/project/context/flowr-analyzer-dependencies-context.d.ts +39 -0
- package/project/context/flowr-analyzer-dependencies-context.js +43 -0
- package/project/context/flowr-analyzer-files-context.d.ts +87 -0
- package/project/context/flowr-analyzer-files-context.js +134 -0
- package/project/context/flowr-analyzer-loading-order-context.d.ts +77 -0
- package/project/context/flowr-analyzer-loading-order-context.js +96 -0
- package/project/context/flowr-file.d.ts +89 -0
- package/project/context/flowr-file.js +78 -0
- package/project/flowr-analyzer-builder.d.ts +106 -0
- package/project/flowr-analyzer-builder.js +197 -0
- package/project/flowr-analyzer.d.ts +126 -0
- package/project/flowr-analyzer.js +88 -0
- package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.d.ts +17 -0
- package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.js +28 -0
- package/project/plugins/file-plugins/flowr-analyzer-file-plugin.d.ts +21 -0
- package/project/plugins/file-plugins/flowr-analyzer-file-plugin.js +34 -0
- package/project/plugins/file-plugins/flowr-description-file.d.ts +24 -0
- package/project/plugins/file-plugins/flowr-description-file.js +38 -0
- package/project/plugins/flowr-analyzer-plugin.d.ts +90 -0
- package/project/plugins/flowr-analyzer-plugin.js +82 -0
- package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-description-file-plugin.d.ts +14 -0
- package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-description-file-plugin.js +56 -0
- package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-plugin.d.ts +13 -0
- package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-plugin.js +33 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.d.ts +14 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.js +41 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.d.ts +10 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.js +29 -0
- package/project/plugins/package-version-plugins/package.d.ts +15 -0
- package/project/plugins/package-version-plugins/package.js +56 -0
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.d.ts +15 -0
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +44 -0
- package/queries/base-query-format.d.ts +2 -8
- package/queries/catalog/call-context-query/call-context-query-executor.d.ts +1 -1
- package/queries/catalog/call-context-query/call-context-query-executor.js +21 -13
- package/queries/catalog/call-context-query/call-context-query-format.d.ts +2 -3
- package/queries/catalog/call-context-query/call-context-query-format.js +2 -2
- package/queries/catalog/cluster-query/cluster-query-executor.d.ts +1 -1
- package/queries/catalog/cluster-query/cluster-query-executor.js +2 -2
- package/queries/catalog/cluster-query/cluster-query-format.d.ts +1 -54
- package/queries/catalog/cluster-query/cluster-query-format.js +2 -2
- package/queries/catalog/config-query/config-query-executor.d.ts +1 -1
- package/queries/catalog/config-query/config-query-executor.js +5 -5
- package/queries/catalog/config-query/config-query-format.d.ts +1 -1
- package/queries/catalog/config-query/config-query-format.js +1 -1
- package/queries/catalog/control-flow-query/control-flow-query-executor.d.ts +1 -1
- package/queries/catalog/control-flow-query/control-flow-query-executor.js +3 -3
- package/queries/catalog/control-flow-query/control-flow-query-format.d.ts +1 -54
- package/queries/catalog/control-flow-query/control-flow-query-format.js +2 -2
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.d.ts +1 -1
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.js +2 -2
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.d.ts +1 -54
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.js +1 -1
- package/queries/catalog/dataflow-query/dataflow-query-executor.d.ts +1 -1
- package/queries/catalog/dataflow-query/dataflow-query-executor.js +2 -2
- package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +1 -54
- package/queries/catalog/dataflow-query/dataflow-query-format.js +1 -1
- package/queries/catalog/dependencies-query/dependencies-query-executor.d.ts +1 -1
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +19 -12
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +7 -56
- package/queries/catalog/dependencies-query/dependencies-query-format.js +7 -4
- package/queries/catalog/df-shape-query/df-shape-query-executor.d.ts +1 -1
- package/queries/catalog/df-shape-query/df-shape-query-executor.js +4 -4
- package/queries/catalog/df-shape-query/df-shape-query-format.d.ts +1 -54
- package/queries/catalog/df-shape-query/df-shape-query-format.js +1 -1
- package/queries/catalog/happens-before-query/happens-before-query-executor.d.ts +1 -1
- package/queries/catalog/happens-before-query/happens-before-query-executor.js +2 -1
- package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +1 -54
- package/queries/catalog/happens-before-query/happens-before-query-format.js +1 -1
- package/queries/catalog/id-map-query/id-map-query-executor.d.ts +1 -1
- package/queries/catalog/id-map-query/id-map-query-executor.js +2 -2
- package/queries/catalog/id-map-query/id-map-query-format.d.ts +1 -54
- package/queries/catalog/id-map-query/id-map-query-format.js +2 -2
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.d.ts +3 -0
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +45 -0
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +22 -0
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +32 -0
- package/queries/catalog/lineage-query/lineage-query-executor.d.ts +1 -1
- package/queries/catalog/lineage-query/lineage-query-executor.js +2 -2
- package/queries/catalog/lineage-query/lineage-query-format.d.ts +1 -54
- package/queries/catalog/lineage-query/lineage-query-format.js +1 -1
- package/queries/catalog/linter-query/linter-query-executor.d.ts +1 -1
- package/queries/catalog/linter-query/linter-query-executor.js +2 -3
- package/queries/catalog/linter-query/linter-query-format.d.ts +1 -54
- package/queries/catalog/linter-query/linter-query-format.js +1 -1
- package/queries/catalog/location-map-query/location-map-query-executor.d.ts +1 -1
- package/queries/catalog/location-map-query/location-map-query-executor.js +3 -2
- package/queries/catalog/location-map-query/location-map-query-format.d.ts +1 -1
- package/queries/catalog/location-map-query/location-map-query-format.js +1 -1
- package/queries/catalog/normalized-ast-query/normalized-ast-query-executor.d.ts +1 -1
- package/queries/catalog/normalized-ast-query/normalized-ast-query-executor.js +2 -2
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +1 -54
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.js +1 -1
- package/queries/catalog/origin-query/origin-query-executor.d.ts +2 -2
- package/queries/catalog/origin-query/origin-query-executor.js +3 -3
- package/queries/catalog/origin-query/origin-query-format.d.ts +1 -54
- package/queries/catalog/origin-query/origin-query-format.js +1 -1
- package/queries/catalog/project-query/project-query-executor.d.ts +1 -1
- package/queries/catalog/project-query/project-query-executor.js +2 -2
- package/queries/catalog/project-query/project-query-format.d.ts +1 -54
- package/queries/catalog/project-query/project-query-format.js +1 -1
- package/queries/catalog/resolve-value-query/resolve-value-query-executor.d.ts +1 -1
- package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +4 -2
- package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +1 -54
- package/queries/catalog/resolve-value-query/resolve-value-query-format.js +1 -1
- package/queries/catalog/search-query/search-query-executor.d.ts +1 -1
- package/queries/catalog/search-query/search-query-executor.js +3 -3
- package/queries/catalog/search-query/search-query-format.d.ts +1 -54
- package/queries/catalog/search-query/search-query-format.js +1 -1
- package/queries/catalog/static-slice-query/static-slice-query-executor.d.ts +1 -1
- package/queries/catalog/static-slice-query/static-slice-query-executor.js +3 -3
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +1 -54
- package/queries/catalog/static-slice-query/static-slice-query-format.js +1 -1
- package/queries/query-print.d.ts +4 -4
- package/queries/query-print.js +12 -12
- package/queries/query.d.ts +37 -885
- package/queries/query.js +3 -1
- package/r-bridge/parser.d.ts +7 -0
- package/r-bridge/retriever.d.ts +6 -5
- package/r-bridge/retriever.js +9 -5
- package/search/flowr-search-executor.d.ts +3 -5
- package/search/flowr-search-executor.js +6 -4
- package/search/flowr-search-filters.d.ts +12 -6
- package/search/flowr-search-filters.js +1 -1
- package/search/flowr-search.d.ts +5 -16
- package/search/flowr-search.js +14 -5
- package/search/search-executor/search-enrichers.d.ts +37 -36
- package/search/search-executor/search-enrichers.js +5 -4
- package/search/search-executor/search-generators.d.ts +12 -12
- package/search/search-executor/search-generators.js +27 -19
- package/search/search-executor/search-mappers.d.ts +5 -5
- package/search/search-executor/search-transformer.d.ts +17 -17
- package/search/search-executor/search-transformer.js +14 -7
- package/util/collections/arrays.d.ts +1 -0
- package/util/collections/arrays.js +15 -0
- package/util/collections/objectmap.d.ts +17 -0
- package/util/collections/objectmap.js +28 -0
- package/util/containers.d.ts +0 -1
- package/util/containers.js +0 -1
- package/util/files.d.ts +17 -0
- package/util/files.js +65 -0
- package/util/formats/adapter.d.ts +4 -2
- package/util/formats/adapter.js +11 -4
- package/util/r-value.d.ts +1 -1
- package/util/r-value.js +2 -0
- package/util/version.d.ts +17 -0
- package/util/version.js +28 -1
package/queries/query.js
CHANGED
|
@@ -32,6 +32,7 @@ const origin_query_format_1 = require("./catalog/origin-query/origin-query-forma
|
|
|
32
32
|
const linter_query_format_1 = require("./catalog/linter-query/linter-query-format");
|
|
33
33
|
const control_flow_query_format_1 = require("./catalog/control-flow-query/control-flow-query-format");
|
|
34
34
|
const df_shape_query_format_1 = require("./catalog/df-shape-query/df-shape-query-format");
|
|
35
|
+
const inspect_higher_order_query_format_1 = require("./catalog/inspect-higher-order-query/inspect-higher-order-query-format");
|
|
35
36
|
exports.SupportedQueries = {
|
|
36
37
|
'call-context': call_context_query_format_1.CallContextQueryDefinition,
|
|
37
38
|
'config': config_query_format_1.ConfigQueryDefinition,
|
|
@@ -48,12 +49,13 @@ exports.SupportedQueries = {
|
|
|
48
49
|
'location-map': location_map_query_format_1.LocationMapQueryDefinition,
|
|
49
50
|
'search': search_query_format_1.SearchQueryDefinition,
|
|
50
51
|
'happens-before': happens_before_query_format_1.HappensBeforeQueryDefinition,
|
|
52
|
+
'inspect-higher-order': inspect_higher_order_query_format_1.InspectHigherOrderQueryDefinition,
|
|
51
53
|
'resolve-value': resolve_value_query_format_1.ResolveValueQueryDefinition,
|
|
52
54
|
'project': project_query_format_1.ProjectQueryDefinition,
|
|
53
55
|
'origin': origin_query_format_1.OriginQueryDefinition,
|
|
54
56
|
'linter': linter_query_format_1.LinterQueryDefinition
|
|
55
57
|
};
|
|
56
|
-
function executeQueriesOfSameType(data, queries) {
|
|
58
|
+
async function executeQueriesOfSameType(data, queries) {
|
|
57
59
|
(0, assert_1.guard)(queries.length > 0, 'At least one query must be provided');
|
|
58
60
|
/* every query must have the same type */
|
|
59
61
|
(0, assert_1.guard)(queries.every(q => q.type === queries[0].type), 'All queries must have the same type');
|
package/r-bridge/parser.d.ts
CHANGED
|
@@ -8,6 +8,13 @@ interface ParserContent<T> {
|
|
|
8
8
|
parse(request: RParseRequest): T;
|
|
9
9
|
close(): void;
|
|
10
10
|
}
|
|
11
|
+
export interface TreeSitterInformation {
|
|
12
|
+
name: TreeSitterExecutor['name'];
|
|
13
|
+
}
|
|
14
|
+
export interface RShellInformation {
|
|
15
|
+
name: RShell['name'];
|
|
16
|
+
rVersion: string;
|
|
17
|
+
}
|
|
11
18
|
export type SyncParser<T> = ParserContent<Awaited<T>> & {
|
|
12
19
|
readonly async?: false;
|
|
13
20
|
};
|
package/r-bridge/retriever.d.ts
CHANGED
|
@@ -4,10 +4,10 @@ import { RShellExecutor } from './shell-executor';
|
|
|
4
4
|
import type { NormalizedAst } from './lang-4.x/ast/model/processing/decorate';
|
|
5
5
|
import type { SupportedFormats } from '../util/formats/adapter-format';
|
|
6
6
|
export declare const fileProtocol = "file://";
|
|
7
|
-
export interface
|
|
7
|
+
export interface ParseRequestAdditionalInfoBase {
|
|
8
8
|
type: SupportedFormats;
|
|
9
9
|
}
|
|
10
|
-
export interface RParseRequestFromFile<AdditionalInfo extends
|
|
10
|
+
export interface RParseRequestFromFile<AdditionalInfo extends ParseRequestAdditionalInfoBase = ParseRequestAdditionalInfoBase> {
|
|
11
11
|
readonly request: 'file';
|
|
12
12
|
/**
|
|
13
13
|
* The path to the file (an absolute path is probably best here).
|
|
@@ -15,11 +15,11 @@ export interface RParseRequestFromFile<AdditionalInfo extends PraseRequestAdditi
|
|
|
15
15
|
*/
|
|
16
16
|
readonly content: string;
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
18
|
+
* Additional info from different file formates like .Rmd
|
|
19
19
|
*/
|
|
20
20
|
readonly info?: AdditionalInfo;
|
|
21
21
|
}
|
|
22
|
-
export interface RParseRequestFromText<AdditionalInfo extends
|
|
22
|
+
export interface RParseRequestFromText<AdditionalInfo extends ParseRequestAdditionalInfoBase = ParseRequestAdditionalInfoBase> {
|
|
23
23
|
readonly request: 'text';
|
|
24
24
|
/**
|
|
25
25
|
* Source code to parse (not a file path).
|
|
@@ -29,7 +29,7 @@ export interface RParseRequestFromText<AdditionalInfo extends PraseRequestAdditi
|
|
|
29
29
|
*/
|
|
30
30
|
readonly content: string;
|
|
31
31
|
/**
|
|
32
|
-
*
|
|
32
|
+
* Additional info from different file formates like .Rmd
|
|
33
33
|
*/
|
|
34
34
|
readonly info?: AdditionalInfo;
|
|
35
35
|
}
|
|
@@ -46,6 +46,7 @@ export type RParseRequest = RParseRequestFromFile | RParseRequestFromText;
|
|
|
46
46
|
* Several requests that can be passed along to {@link retrieveParseDataFromRCode}.
|
|
47
47
|
*/
|
|
48
48
|
export type RParseRequests = RParseRequest | ReadonlyArray<RParseRequest>;
|
|
49
|
+
export declare function isParseRequest(request: unknown): request is RParseRequest;
|
|
49
50
|
export declare function requestFromInput(input: `${typeof fileProtocol}${string}`): RParseRequestFromFile;
|
|
50
51
|
export declare function requestFromInput(input: `${typeof fileProtocol}${string}`[]): RParseRequestFromFile[];
|
|
51
52
|
export declare function requestFromInput(input: string): RParseRequestFromText;
|
package/r-bridge/retriever.js
CHANGED
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.fileProtocol = void 0;
|
|
7
|
+
exports.isParseRequest = isParseRequest;
|
|
7
8
|
exports.requestFromInput = requestFromInput;
|
|
8
9
|
exports.requestProviderFromFile = requestProviderFromFile;
|
|
9
10
|
exports.requestProviderFromText = requestProviderFromText;
|
|
@@ -24,13 +25,19 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
24
25
|
const path_1 = __importDefault(require("path"));
|
|
25
26
|
const adapter_1 = require("../util/formats/adapter");
|
|
26
27
|
exports.fileProtocol = 'file://';
|
|
28
|
+
function isParseRequest(request) {
|
|
29
|
+
if (typeof request !== 'object' || request === null) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
return 'request' in request;
|
|
33
|
+
}
|
|
27
34
|
/**
|
|
28
35
|
* Creates a {@link RParseRequests} from a given input.
|
|
29
36
|
* If your input starts with {@link fileProtocol}, it is assumed to be a file path and will be processed as such.
|
|
30
37
|
* Giving an array, you can mix file paths and text content (again using the {@link fileProtocol}).
|
|
31
38
|
*
|
|
32
39
|
*/
|
|
33
|
-
function requestFromInput(input) {
|
|
40
|
+
function requestFromInput(input, fileTypeHint) {
|
|
34
41
|
if (Array.isArray(input)) {
|
|
35
42
|
return input.flatMap(requestFromInput);
|
|
36
43
|
}
|
|
@@ -40,10 +47,7 @@ function requestFromInput(input) {
|
|
|
40
47
|
return (0, adapter_1.requestFromFile)(content.slice(7));
|
|
41
48
|
}
|
|
42
49
|
else {
|
|
43
|
-
return
|
|
44
|
-
request: 'text',
|
|
45
|
-
content: content
|
|
46
|
-
};
|
|
50
|
+
return (0, adapter_1.requestFromText)(content, fileTypeHint);
|
|
47
51
|
}
|
|
48
52
|
}
|
|
49
53
|
function requestProviderFromFile() {
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type { FlowrSearch, FlowrSearchLike, SearchOutput } from './flowr-search-builder';
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
type GetSearchElements<S> = S extends FlowrSearch<infer _, infer _, infer _, infer Elements> ? Elements : never;
|
|
2
|
+
import type { FlowrAnalysisProvider } from '../project/flowr-analyzer';
|
|
3
|
+
export type GetSearchElements<S> = S extends FlowrSearch<infer _, infer _, infer _, infer Elements> ? Elements : never;
|
|
5
4
|
/**
|
|
6
5
|
* Run a search with the given search query and data.
|
|
7
6
|
*/
|
|
8
|
-
export declare function runSearch<S extends FlowrSearchLike
|
|
9
|
-
export {};
|
|
7
|
+
export declare function runSearch<S extends FlowrSearchLike>(search: S, input: FlowrAnalysisProvider): Promise<GetSearchElements<SearchOutput<S>>>;
|
|
@@ -7,10 +7,12 @@ const search_transformer_1 = require("./search-executor/search-transformer");
|
|
|
7
7
|
/**
|
|
8
8
|
* Run a search with the given search query and data.
|
|
9
9
|
*/
|
|
10
|
-
function runSearch(search,
|
|
10
|
+
async function runSearch(search, input) {
|
|
11
11
|
const s = (0, flowr_search_builder_1.getFlowrSearch)(search);
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
let acc = await (0, search_generators_1.getGenerator)(s.generator.name)(input, s.generator.args);
|
|
13
|
+
for (const transformer of s.search) {
|
|
14
|
+
acc = await (0, search_transformer_1.getTransformer)(transformer.name)(input, acc, transformer.args);
|
|
15
|
+
}
|
|
16
|
+
return acc;
|
|
15
17
|
}
|
|
16
18
|
//# sourceMappingURL=flowr-search-executor.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { RType } from '../r-bridge/lang-4.x/ast/model/type';
|
|
2
2
|
import { VertexType } from '../dataflow/graph/vertex';
|
|
3
3
|
import type { ParentInformation } from '../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
4
|
-
import type { FlowrSearchElement
|
|
4
|
+
import type { FlowrSearchElement } from './flowr-search';
|
|
5
5
|
import type { Enrichment } from './search-executor/search-enrichers';
|
|
6
6
|
import type { BuiltInMappingName } from '../dataflow/environments/built-in';
|
|
7
|
-
import type {
|
|
7
|
+
import type { DataflowInformation } from '../dataflow/info';
|
|
8
8
|
export type FlowrFilterName = keyof typeof FlowrFilters;
|
|
9
9
|
interface FlowrFilterWithArgs<Filter extends FlowrFilterName, Args extends FlowrFilterArgs<Filter>> {
|
|
10
10
|
name: Filter;
|
|
@@ -28,7 +28,9 @@ export declare enum FlowrFilter {
|
|
|
28
28
|
*/
|
|
29
29
|
OriginKind = "origin-kind"
|
|
30
30
|
}
|
|
31
|
-
export type FlowrFilterFunction<T> = (e: FlowrSearchElement<ParentInformation>, args: T, data:
|
|
31
|
+
export type FlowrFilterFunction<T> = (e: FlowrSearchElement<ParentInformation>, args: T, data: {
|
|
32
|
+
dataflow: DataflowInformation;
|
|
33
|
+
}) => boolean;
|
|
32
34
|
export declare const ValidFlowrFilters: Set<string>;
|
|
33
35
|
export declare const ValidFlowrFiltersReverse: {
|
|
34
36
|
[k: string]: string;
|
|
@@ -36,7 +38,9 @@ export declare const ValidFlowrFiltersReverse: {
|
|
|
36
38
|
export declare const FlowrFilters: {
|
|
37
39
|
readonly "drop-empty-arguments": (e: FlowrSearchElement<ParentInformation>, _args: never) => boolean;
|
|
38
40
|
readonly "matches-enrichment": (e: FlowrSearchElement<ParentInformation>, args: MatchesEnrichmentArgs<Enrichment>) => boolean;
|
|
39
|
-
readonly "origin-kind": (e: FlowrSearchElement<ParentInformation>, args: OriginKindArgs, data:
|
|
41
|
+
readonly "origin-kind": (e: FlowrSearchElement<ParentInformation>, args: OriginKindArgs, data: {
|
|
42
|
+
dataflow: DataflowInformation;
|
|
43
|
+
}) => boolean;
|
|
40
44
|
};
|
|
41
45
|
export type FlowrFilterArgs<F extends FlowrFilter> = typeof FlowrFilters[F] extends FlowrFilterFunction<infer Args> ? Args : never;
|
|
42
46
|
export interface MatchesEnrichmentArgs<E extends Enrichment> {
|
|
@@ -48,7 +52,7 @@ export interface OriginKindArgs {
|
|
|
48
52
|
matchType?: 'some' | 'every';
|
|
49
53
|
keepNonFunctionCalls?: boolean;
|
|
50
54
|
}
|
|
51
|
-
export declare function testFunctionsIgnoringPackage(functions: string[]): RegExp;
|
|
55
|
+
export declare function testFunctionsIgnoringPackage(functions: readonly string[]): RegExp;
|
|
52
56
|
type ValidFilterTypes<F extends FlowrFilter = FlowrFilter> = FlowrFilterName | FlowrFilterWithArgs<F, FlowrFilterArgs<F>> | RType | VertexType;
|
|
53
57
|
/**
|
|
54
58
|
* By default, we provide filter for every {@link RType} and {@link VertexType}.
|
|
@@ -102,7 +106,9 @@ export declare function isBinaryTree(tree: unknown): tree is {
|
|
|
102
106
|
};
|
|
103
107
|
interface FilterData {
|
|
104
108
|
readonly element: FlowrSearchElement<ParentInformation>;
|
|
105
|
-
readonly data:
|
|
109
|
+
readonly data: {
|
|
110
|
+
dataflow: DataflowInformation;
|
|
111
|
+
};
|
|
106
112
|
}
|
|
107
113
|
export declare function evalFilter<Filter extends FlowrFilter>(filter: FlowrFilterExpression<Filter>, data: FilterData): boolean;
|
|
108
114
|
export {};
|
|
@@ -156,7 +156,7 @@ const evalVisit = {
|
|
|
156
156
|
xor: ({ left, right }, data) => evalTree(left, data) !== evalTree(right, data),
|
|
157
157
|
not: ({ operand }, data) => !evalTree(operand, data),
|
|
158
158
|
'r-type': ({ value }, { element }) => element.node.type === value,
|
|
159
|
-
'vertex-type': ({ value }, { data
|
|
159
|
+
'vertex-type': ({ value }, { data, element }) => data.dataflow.graph.getVertex(element.node.info.id)?.tag === value,
|
|
160
160
|
'special': ({ value }, { data, element }) => {
|
|
161
161
|
const name = typeof value === 'string' ? value : value.name;
|
|
162
162
|
const args = typeof value === 'string' ? undefined : value.args;
|
package/search/flowr-search.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import type { NoInfo, RNode } from '../r-bridge/lang-4.x/ast/model/model';
|
|
2
|
-
import type { Pipeline, PipelineOutput, PipelineStepOutputWithName } from '../core/steps/pipeline/pipeline';
|
|
3
|
-
import type { NormalizedAst } from '../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
4
2
|
import type { NodeId } from '../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
7
|
-
import type { Enrichment, EnrichmentSearchArguments, EnrichmentElementContent, EnrichmentSearchContent } from './search-executor/search-enrichers';
|
|
3
|
+
import type { Enrichment, EnrichmentElementContent, EnrichmentSearchArguments, EnrichmentSearchContent } from './search-executor/search-enrichers';
|
|
4
|
+
import type { FlowrAnalysisProvider } from '../project/flowr-analyzer';
|
|
8
5
|
/**
|
|
9
6
|
* Yes, for now we do technically not need a wrapper around the RNode, but this allows us to attach caches etc.
|
|
10
7
|
* just for the respective search.
|
|
@@ -45,13 +42,6 @@ export interface FlowrSearchGetFilter extends Record<string, unknown> {
|
|
|
45
42
|
*/
|
|
46
43
|
readonly id?: NodeId;
|
|
47
44
|
}
|
|
48
|
-
type MinimumInputForFlowrSearch<P extends Pipeline> = PipelineStepOutputWithName<P, 'normalize'> extends NormalizedAst ? (PipelineStepOutputWithName<P, 'dataflow'> extends DataflowInformation ? PipelineOutput<P> & {
|
|
49
|
-
normalize: NormalizedAst;
|
|
50
|
-
dataflow: DataflowInformation;
|
|
51
|
-
config: FlowrConfigOptions;
|
|
52
|
-
} : never) : never;
|
|
53
|
-
/** we allow any pipeline, which provides us with a 'normalize' and 'dataflow' step */
|
|
54
|
-
export type FlowrSearchInput<P extends Pipeline> = MinimumInputForFlowrSearch<P>;
|
|
55
45
|
/** Intentionally, we abstract away from an array to avoid the use of conventional typescript operations */
|
|
56
46
|
export declare class FlowrSearchElements<Info = NoInfo, Elements extends FlowrSearchElement<Info>[] = FlowrSearchElement<Info>[]> {
|
|
57
47
|
private elements;
|
|
@@ -60,14 +50,13 @@ export declare class FlowrSearchElements<Info = NoInfo, Elements extends FlowrSe
|
|
|
60
50
|
add(element: FlowrSearchElement<Info>): this;
|
|
61
51
|
addAll(elements: FlowrSearchElement<Info>[]): this;
|
|
62
52
|
getElements(): Readonly<Elements>;
|
|
63
|
-
mutate<OutElements extends Elements>(mutator: (elements: Elements) => OutElements): this
|
|
53
|
+
mutate<OutElements extends Elements>(mutator: (elements: Elements) => OutElements | Promise<OutElements>): this | Promise<this>;
|
|
64
54
|
/**
|
|
65
55
|
* Enriches this flowr search element collection with the given enrichment.
|
|
66
56
|
* To retrieve enrichment content for a given enrichment type, use {@link enrichmentContent}.
|
|
67
57
|
*
|
|
68
|
-
* Please note that this function does not also enrich individual elements, which is done through {@link enrichElement}. Both functions are called in a
|
|
58
|
+
* Please note that this function does not also enrich individual elements, which is done through {@link enrichElement}. Both functions are called in a concise manner in {@link FlowrSearchBuilder.with}, which is the preferred way to add enrichments to a search.
|
|
69
59
|
*/
|
|
70
|
-
enrich<E extends Enrichment>(data:
|
|
60
|
+
enrich<E extends Enrichment>(data: FlowrAnalysisProvider, enrichment: E, args?: EnrichmentSearchArguments<E>): Promise<this>;
|
|
71
61
|
enrichmentContent<E extends Enrichment>(enrichment: E): EnrichmentSearchContent<E>;
|
|
72
62
|
}
|
|
73
|
-
export {};
|
package/search/flowr-search.js
CHANGED
|
@@ -23,21 +23,30 @@ class FlowrSearchElements {
|
|
|
23
23
|
return this.elements;
|
|
24
24
|
}
|
|
25
25
|
mutate(mutator) {
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
const result = mutator(this.elements);
|
|
27
|
+
if (result instanceof Promise) {
|
|
28
|
+
return result.then(resolvedElements => {
|
|
29
|
+
this.elements = resolvedElements;
|
|
30
|
+
return this;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
this.elements = result;
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
28
37
|
}
|
|
29
38
|
/**
|
|
30
39
|
* Enriches this flowr search element collection with the given enrichment.
|
|
31
40
|
* To retrieve enrichment content for a given enrichment type, use {@link enrichmentContent}.
|
|
32
41
|
*
|
|
33
|
-
* Please note that this function does not also enrich individual elements, which is done through {@link enrichElement}. Both functions are called in a
|
|
42
|
+
* Please note that this function does not also enrich individual elements, which is done through {@link enrichElement}. Both functions are called in a concise manner in {@link FlowrSearchBuilder.with}, which is the preferred way to add enrichments to a search.
|
|
34
43
|
*/
|
|
35
|
-
enrich(data, enrichment, args) {
|
|
44
|
+
async enrich(data, enrichment, args) {
|
|
36
45
|
const enrichmentData = search_enrichers_1.Enrichments[enrichment];
|
|
37
46
|
if (enrichmentData.enrichSearch !== undefined) {
|
|
38
47
|
this.enrichments = {
|
|
39
48
|
...this.enrichments ?? {},
|
|
40
|
-
[enrichment]: enrichmentData.enrichSearch(this, data, args, this.enrichments?.[enrichment])
|
|
49
|
+
[enrichment]: await enrichmentData.enrichSearch(this, data, args, this.enrichments?.[enrichment])
|
|
41
50
|
};
|
|
42
51
|
}
|
|
43
52
|
return this;
|
|
@@ -1,20 +1,25 @@
|
|
|
1
|
-
import type { FlowrSearchElement, FlowrSearchElements
|
|
2
|
-
import type { ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
3
|
-
import type { Pipeline } from '../../core/steps/pipeline/pipeline';
|
|
1
|
+
import type { FlowrSearchElement, FlowrSearchElements } from '../flowr-search';
|
|
2
|
+
import type { NormalizedAst, ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
4
3
|
import type { MergeableRecord } from '../../util/objects';
|
|
5
4
|
import type { Identifier } from '../../dataflow/environments/identifier';
|
|
6
5
|
import type { LinkToLastCall } from '../../queries/catalog/call-context-query/call-context-query-format';
|
|
7
6
|
import { type NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
8
7
|
import type { ControlFlowInformation } from '../../control-flow/control-flow-graph';
|
|
9
|
-
import type {
|
|
8
|
+
import type { Query, QueryResult } from '../../queries/query';
|
|
10
9
|
import type { CfgSimplificationPassName } from '../../control-flow/cfg-simplification';
|
|
11
|
-
import type {
|
|
10
|
+
import type { AsyncOrSync } from 'ts-essentials';
|
|
11
|
+
import type { FlowrAnalysisProvider } from '../../project/flowr-analyzer';
|
|
12
|
+
import type { DataflowInformation } from '../../dataflow/info';
|
|
12
13
|
export interface EnrichmentData<ElementContent extends MergeableRecord, ElementArguments = undefined, SearchContent extends MergeableRecord = never, SearchArguments = ElementArguments> {
|
|
13
14
|
/**
|
|
14
15
|
* A function that is applied to each element of the search to enrich it with additional data.
|
|
15
16
|
*/
|
|
16
|
-
readonly enrichElement?: (element: FlowrSearchElement<ParentInformation>, search: FlowrSearchElements<ParentInformation>, data:
|
|
17
|
-
|
|
17
|
+
readonly enrichElement?: (element: FlowrSearchElement<ParentInformation>, search: FlowrSearchElements<ParentInformation>, data: {
|
|
18
|
+
dataflow: DataflowInformation;
|
|
19
|
+
normalize: NormalizedAst;
|
|
20
|
+
cfg: ControlFlowInformation;
|
|
21
|
+
}, args: ElementArguments | undefined, previousValue: ElementContent | undefined) => AsyncOrSync<ElementContent>;
|
|
22
|
+
readonly enrichSearch?: (search: FlowrSearchElements<ParentInformation>, data: FlowrAnalysisProvider, args: SearchArguments | undefined, previousValue: SearchContent | undefined) => AsyncOrSync<SearchContent>;
|
|
18
23
|
/**
|
|
19
24
|
* The mapping function used by the {@link Mapper.Enrichment} mapper.
|
|
20
25
|
*/
|
|
@@ -76,11 +81,11 @@ export interface CfgInformationArguments extends MergeableRecord {
|
|
|
76
81
|
}
|
|
77
82
|
export interface QueryDataElementContent extends MergeableRecord {
|
|
78
83
|
/** The name of the query that this element originated from. To get each query's data, see {@link QueryDataSearchContent}. */
|
|
79
|
-
query:
|
|
84
|
+
query: Query['type'];
|
|
80
85
|
}
|
|
81
86
|
export interface QueryDataSearchContent extends MergeableRecord {
|
|
82
87
|
queries: {
|
|
83
|
-
[QueryType in
|
|
88
|
+
[QueryType in Query['type']]: Awaited<QueryResult<QueryType>>;
|
|
84
89
|
};
|
|
85
90
|
}
|
|
86
91
|
/**
|
|
@@ -89,49 +94,41 @@ export interface QueryDataSearchContent extends MergeableRecord {
|
|
|
89
94
|
*/
|
|
90
95
|
export declare const Enrichments: {
|
|
91
96
|
readonly "call-targets": {
|
|
92
|
-
enrichElement: (e: FlowrSearchElement<ParentInformation>, _s: FlowrSearchElements<ParentInformation, FlowrSearchElement<ParentInformation>[]>, data:
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
97
|
+
enrichElement: (e: FlowrSearchElement<ParentInformation>, _s: FlowrSearchElements<ParentInformation, FlowrSearchElement<ParentInformation>[]>, data: {
|
|
98
|
+
dataflow: DataflowInformation;
|
|
99
|
+
normalize: NormalizedAst;
|
|
100
|
+
cfg: ControlFlowInformation;
|
|
96
101
|
}, args: {
|
|
97
102
|
onlyBuiltin?: boolean;
|
|
98
103
|
} | undefined, prev: CallTargetsContent | undefined) => CallTargetsContent;
|
|
99
104
|
mapper: ({ targets }: CallTargetsContent) => FlowrSearchElement<ParentInformation>[];
|
|
100
105
|
};
|
|
101
106
|
readonly "last-call": {
|
|
102
|
-
enrichElement: (e: FlowrSearchElement<ParentInformation>, _s: FlowrSearchElements<ParentInformation, FlowrSearchElement<ParentInformation>[]>, data:
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
107
|
+
enrichElement: (e: FlowrSearchElement<ParentInformation>, _s: FlowrSearchElements<ParentInformation, FlowrSearchElement<ParentInformation>[]>, data: {
|
|
108
|
+
dataflow: DataflowInformation;
|
|
109
|
+
normalize: NormalizedAst;
|
|
110
|
+
cfg: ControlFlowInformation;
|
|
106
111
|
}, args: Omit<LinkToLastCall<import("../../queries/catalog/call-context-query/call-context-query-format").CallNameTypes>, "type">[] | undefined, prev: LastCallContent | undefined) => LastCallContent;
|
|
107
112
|
mapper: ({ linkedIds }: LastCallContent) => FlowrSearchElement<ParentInformation>[];
|
|
108
113
|
};
|
|
109
114
|
readonly "cfg-information": {
|
|
110
|
-
enrichElement: (e: FlowrSearchElement<ParentInformation>, search: FlowrSearchElements<ParentInformation, FlowrSearchElement<ParentInformation>[]>, _data:
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
115
|
+
enrichElement: (e: FlowrSearchElement<ParentInformation>, search: FlowrSearchElements<ParentInformation, FlowrSearchElement<ParentInformation>[]>, _data: {
|
|
116
|
+
dataflow: DataflowInformation;
|
|
117
|
+
normalize: NormalizedAst;
|
|
118
|
+
cfg: ControlFlowInformation;
|
|
114
119
|
}, _args: CfgInformationArguments | undefined, prev: CfgInformationElementContent | undefined) => {
|
|
115
120
|
isRoot: boolean;
|
|
116
121
|
isReachable: boolean | undefined;
|
|
117
122
|
};
|
|
118
|
-
enrichSearch: (_search: FlowrSearchElements<ParentInformation, FlowrSearchElement<ParentInformation>[]>, data:
|
|
119
|
-
normalize: import("../../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
|
|
120
|
-
dataflow: import("../../dataflow/info").DataflowInformation;
|
|
121
|
-
config: import("../../config").FlowrConfigOptions;
|
|
122
|
-
}, args: CfgInformationArguments | undefined, prev: CfgInformationSearchContent | undefined) => CfgInformationSearchContent;
|
|
123
|
+
enrichSearch: (_search: FlowrSearchElements<ParentInformation, FlowrSearchElement<ParentInformation>[]>, data: FlowrAnalysisProvider, args: CfgInformationArguments | undefined, prev: CfgInformationSearchContent | undefined) => Promise<CfgInformationSearchContent>;
|
|
123
124
|
};
|
|
124
125
|
readonly "query-data": {
|
|
125
|
-
enrichElement: (_e: FlowrSearchElement<ParentInformation>, _search: FlowrSearchElements<ParentInformation, FlowrSearchElement<ParentInformation>[]>, _data:
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
enrichElement: (_e: FlowrSearchElement<ParentInformation>, _search: FlowrSearchElements<ParentInformation, FlowrSearchElement<ParentInformation>[]>, _data: {
|
|
127
|
+
dataflow: DataflowInformation;
|
|
128
|
+
normalize: NormalizedAst;
|
|
129
|
+
cfg: ControlFlowInformation;
|
|
129
130
|
}, args: QueryDataElementContent | undefined, prev: QueryDataElementContent | undefined) => QueryDataElementContent;
|
|
130
|
-
enrichSearch: (_search: FlowrSearchElements<ParentInformation, FlowrSearchElement<ParentInformation>[]>, _data:
|
|
131
|
-
normalize: import("../../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
|
|
132
|
-
dataflow: import("../../dataflow/info").DataflowInformation;
|
|
133
|
-
config: import("../../config").FlowrConfigOptions;
|
|
134
|
-
}, args: QueryDataSearchContent | undefined, prev: QueryDataSearchContent | undefined) => Required<QueryDataSearchContent>;
|
|
131
|
+
enrichSearch: (_search: FlowrSearchElements<ParentInformation, FlowrSearchElement<ParentInformation>[]>, _data: FlowrAnalysisProvider, args: QueryDataSearchContent | undefined, prev: QueryDataSearchContent | undefined) => Required<QueryDataSearchContent>;
|
|
135
132
|
};
|
|
136
133
|
};
|
|
137
134
|
/**
|
|
@@ -141,4 +138,8 @@ export declare const Enrichments: {
|
|
|
141
138
|
* @param enrichment - The enrichment content, if present, else `undefined`.
|
|
142
139
|
*/
|
|
143
140
|
export declare function enrichmentContent<E extends Enrichment>(e: FlowrSearchElement<ParentInformation>, enrichment: E): EnrichmentElementContent<E>;
|
|
144
|
-
export declare function enrichElement<Element extends FlowrSearchElement<ParentInformation>, E extends Enrichment>(e: Element, s: FlowrSearchElements<ParentInformation>, data:
|
|
141
|
+
export declare function enrichElement<Element extends FlowrSearchElement<ParentInformation>, E extends Enrichment>(e: Element, s: FlowrSearchElements<ParentInformation>, data: {
|
|
142
|
+
dataflow: DataflowInformation;
|
|
143
|
+
normalize: NormalizedAst;
|
|
144
|
+
cfg: ControlFlowInformation;
|
|
145
|
+
}, enrichment: E, args?: EnrichmentElementArguments<E>): Promise<Element>;
|
|
@@ -12,6 +12,7 @@ const dfg_get_origin_1 = require("../../dataflow/origin/dfg-get-origin");
|
|
|
12
12
|
const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
13
13
|
const cfg_simplification_1 = require("../../control-flow/cfg-simplification");
|
|
14
14
|
const call_context_query_executor_1 = require("../../queries/catalog/call-context-query/call-context-query-executor");
|
|
15
|
+
const cfg_kind_1 = require("../../project/cfg-kind");
|
|
15
16
|
/**
|
|
16
17
|
* An enumeration that stores the names of the available enrichments that can be applied to a set of search elements.
|
|
17
18
|
* See {@link FlowrSearchBuilder.with} for more information on how to apply enrichments.
|
|
@@ -100,7 +101,7 @@ exports.Enrichments = {
|
|
|
100
101
|
isReachable: searchContent.reachableNodes?.has(e.node.info.id)
|
|
101
102
|
};
|
|
102
103
|
},
|
|
103
|
-
enrichSearch: (_search, data, args, prev) => {
|
|
104
|
+
enrichSearch: async (_search, data, args, prev) => {
|
|
104
105
|
args = {
|
|
105
106
|
forceRefresh: false,
|
|
106
107
|
checkReachable: false,
|
|
@@ -113,7 +114,7 @@ exports.Enrichments = {
|
|
|
113
114
|
}
|
|
114
115
|
const content = {
|
|
115
116
|
...prev,
|
|
116
|
-
cfg:
|
|
117
|
+
cfg: await data.controlflow(args.simplificationPasses, cfg_kind_1.CfgKind.WithDataflow),
|
|
117
118
|
};
|
|
118
119
|
if (args.checkReachable) {
|
|
119
120
|
content.reachableNodes = (0, cfg_simplification_1.cfgFindAllReachable)(content.cfg);
|
|
@@ -136,14 +137,14 @@ exports.Enrichments = {
|
|
|
136
137
|
function enrichmentContent(e, enrichment) {
|
|
137
138
|
return e?.enrichments?.[enrichment];
|
|
138
139
|
}
|
|
139
|
-
function enrichElement(e, s, data, enrichment, args) {
|
|
140
|
+
async function enrichElement(e, s, data, enrichment, args) {
|
|
140
141
|
const enrichmentData = exports.Enrichments[enrichment];
|
|
141
142
|
const prev = e?.enrichments;
|
|
142
143
|
return {
|
|
143
144
|
...e,
|
|
144
145
|
enrichments: {
|
|
145
146
|
...prev ?? {},
|
|
146
|
-
[enrichment]: enrichmentData.enrichElement?.(e, s, data, args, prev?.[enrichment])
|
|
147
|
+
[enrichment]: await enrichmentData.enrichElement?.(e, s, data, args, prev?.[enrichment])
|
|
147
148
|
}
|
|
148
149
|
};
|
|
149
150
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { FlowrSearchElement, FlowrSearchGeneratorNodeBase, FlowrSearchGetFilter
|
|
1
|
+
import type { FlowrSearchElement, FlowrSearchGeneratorNodeBase, FlowrSearchGetFilter } from '../flowr-search';
|
|
2
2
|
import { FlowrSearchElements } from '../flowr-search';
|
|
3
|
-
import type { Pipeline } from '../../core/steps/pipeline/pipeline';
|
|
4
3
|
import type { TailTypesOrUndefined } from '../../util/collections/arrays';
|
|
5
4
|
import type { ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
6
5
|
import type { SlicingCriteria } from '../../slicing/criterion/parse';
|
|
7
|
-
import type {
|
|
6
|
+
import type { Query } from '../../queries/query';
|
|
7
|
+
import type { FlowrAnalysisProvider } from '../../project/flowr-analyzer';
|
|
8
8
|
/**
|
|
9
9
|
* This is a union of all possible generator node types
|
|
10
10
|
*/
|
|
@@ -25,18 +25,18 @@ export declare const generators: {
|
|
|
25
25
|
readonly from: typeof generateFrom;
|
|
26
26
|
readonly 'from-query': typeof generateFromQuery;
|
|
27
27
|
};
|
|
28
|
-
declare function generateAll(data:
|
|
29
|
-
declare function generateGet(
|
|
28
|
+
declare function generateAll(data: FlowrAnalysisProvider): Promise<FlowrSearchElements<ParentInformation>>;
|
|
29
|
+
declare function generateGet(input: FlowrAnalysisProvider, { filter: { line, column, id, name, nameIsRegex } }: {
|
|
30
30
|
filter: FlowrSearchGetFilter;
|
|
31
|
-
}): FlowrSearchElements<ParentInformation
|
|
32
|
-
declare function generateFrom(
|
|
31
|
+
}): Promise<FlowrSearchElements<ParentInformation>>;
|
|
32
|
+
declare function generateFrom(_input: FlowrAnalysisProvider, args: {
|
|
33
33
|
from: FlowrSearchElement<ParentInformation> | FlowrSearchElement<ParentInformation>[];
|
|
34
34
|
}): FlowrSearchElements<ParentInformation>;
|
|
35
|
-
declare function generateFromQuery(
|
|
36
|
-
from: readonly
|
|
37
|
-
}): FlowrSearchElements<ParentInformation, FlowrSearchElement<ParentInformation>[]
|
|
38
|
-
declare function generateCriterion(
|
|
35
|
+
declare function generateFromQuery(input: FlowrAnalysisProvider, args: {
|
|
36
|
+
from: readonly Query[];
|
|
37
|
+
}): Promise<FlowrSearchElements<ParentInformation, FlowrSearchElement<ParentInformation>[]>>;
|
|
38
|
+
declare function generateCriterion(input: FlowrAnalysisProvider, args: {
|
|
39
39
|
criterion: SlicingCriteria;
|
|
40
|
-
}): FlowrSearchElements<ParentInformation
|
|
40
|
+
}): Promise<FlowrSearchElements<ParentInformation>>;
|
|
41
41
|
export declare function getGenerator<Name extends GeneratorNames>(name: Name): typeof generators[Name];
|
|
42
42
|
export {};
|
|
@@ -17,21 +17,23 @@ exports.generators = {
|
|
|
17
17
|
from: generateFrom,
|
|
18
18
|
'from-query': generateFromQuery
|
|
19
19
|
};
|
|
20
|
-
function generateAll(data) {
|
|
21
|
-
return new flowr_search_1.FlowrSearchElements(getAllNodes(data)
|
|
20
|
+
async function generateAll(data) {
|
|
21
|
+
return new flowr_search_1.FlowrSearchElements((await getAllNodes(data))
|
|
22
22
|
.map(node => ({ node })));
|
|
23
23
|
}
|
|
24
|
-
function getAllNodes(data) {
|
|
25
|
-
|
|
24
|
+
async function getAllNodes(data) {
|
|
25
|
+
const normalize = await data.normalize();
|
|
26
|
+
return [...new Map([...normalize.idMap.values()].map(n => [n.info.id, n]))
|
|
26
27
|
.values()];
|
|
27
28
|
}
|
|
28
|
-
function generateGet(
|
|
29
|
+
async function generateGet(input, { filter: { line, column, id, name, nameIsRegex } }) {
|
|
30
|
+
const normalize = await input.normalize();
|
|
29
31
|
let potentials = (id ?
|
|
30
|
-
[
|
|
31
|
-
getAllNodes(
|
|
32
|
+
[normalize.idMap.get(id)].filter(assert_1.isNotUndefined) :
|
|
33
|
+
await getAllNodes(input));
|
|
32
34
|
if (line && line < 0) {
|
|
33
|
-
const maxLines =
|
|
34
|
-
(id ? getAllNodes(
|
|
35
|
+
const maxLines = normalize.ast.info.fullRange?.[2] ??
|
|
36
|
+
(id ? (await getAllNodes(input)) : potentials).reduce((maxLine, { location }) => location && location[2] > maxLine ? location[2] : maxLine, 0);
|
|
35
37
|
line = maxLines + line + 1;
|
|
36
38
|
}
|
|
37
39
|
if (line && column) {
|
|
@@ -52,11 +54,11 @@ function generateGet(data, { filter: { line, column, id, name, nameIsRegex } })
|
|
|
52
54
|
}
|
|
53
55
|
return new flowr_search_1.FlowrSearchElements(potentials.map(node => ({ node })));
|
|
54
56
|
}
|
|
55
|
-
function generateFrom(
|
|
57
|
+
function generateFrom(_input, args) {
|
|
56
58
|
return new flowr_search_1.FlowrSearchElements(Array.isArray(args.from) ? args.from : [args.from]);
|
|
57
59
|
}
|
|
58
|
-
function generateFromQuery(
|
|
59
|
-
const result = (0, query_1.executeQueries)({
|
|
60
|
+
async function generateFromQuery(input, args) {
|
|
61
|
+
const result = await (0, query_1.executeQueries)({ analyzer: input }, args.from);
|
|
60
62
|
// collect involved nodes
|
|
61
63
|
const nodesByQuery = new Map();
|
|
62
64
|
for (const [query, content] of Object.entries(result)) {
|
|
@@ -66,19 +68,25 @@ function generateFromQuery(data, args) {
|
|
|
66
68
|
const nodes = new Set();
|
|
67
69
|
const queryDef = query_1.SupportedQueries[query];
|
|
68
70
|
for (const node of queryDef.flattenInvolvedNodes(content, args.from)) {
|
|
69
|
-
nodes.add({ node:
|
|
71
|
+
nodes.add({ node: (await input.normalize()).idMap.get(node) });
|
|
70
72
|
}
|
|
71
73
|
nodesByQuery.set(query, nodes);
|
|
72
74
|
}
|
|
73
75
|
// enrich elements with query data
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
+
const normalize = await input.normalize();
|
|
77
|
+
const dataflow = await input.dataflow();
|
|
78
|
+
const cfg = await input.controlflow();
|
|
79
|
+
const elements = await new flowr_search_1.FlowrSearchElements([...nodesByQuery]
|
|
80
|
+
.flatMap(([_, nodes]) => [...nodes]))
|
|
81
|
+
.enrich(input, search_enrichers_1.Enrichment.QueryData, { queries: result });
|
|
82
|
+
return elements.mutate(s => Promise.all(s.map(async (e) => {
|
|
76
83
|
const [query, _] = [...nodesByQuery].find(([_, nodes]) => nodes.has(e));
|
|
77
|
-
return (0, search_enrichers_1.enrichElement)(e, elements,
|
|
78
|
-
}));
|
|
84
|
+
return await (0, search_enrichers_1.enrichElement)(e, elements, { normalize, dataflow, cfg }, search_enrichers_1.Enrichment.QueryData, { query });
|
|
85
|
+
})));
|
|
79
86
|
}
|
|
80
|
-
function generateCriterion(
|
|
81
|
-
|
|
87
|
+
async function generateCriterion(input, args) {
|
|
88
|
+
const idMap = (await input.normalize()).idMap;
|
|
89
|
+
return new flowr_search_1.FlowrSearchElements(args.criterion.map(c => ({ node: idMap.get((0, parse_1.slicingCriterionToId)(c, idMap)) })));
|
|
82
90
|
}
|
|
83
91
|
function getGenerator(name) {
|
|
84
92
|
if (!exports.generators[name]) {
|