@eagleoutice/flowr 2.8.14 → 2.9.0
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 +25 -26
- package/abstract-interpretation/data-frame/mappers/access-mapper.d.ts +4 -3
- package/abstract-interpretation/data-frame/mappers/access-mapper.js +4 -3
- package/abstract-interpretation/data-frame/mappers/arguments.d.ts +2 -1
- package/abstract-interpretation/data-frame/mappers/arguments.js +2 -1
- package/abstract-interpretation/data-frame/mappers/function-mapper.d.ts +4 -3
- package/abstract-interpretation/data-frame/mappers/function-mapper.js +13 -10
- package/abstract-interpretation/data-frame/mappers/replacement-mapper.js +7 -6
- package/abstract-interpretation/data-frame/resolve-args.js +2 -1
- package/benchmark/slicer.d.ts +0 -16
- package/benchmark/slicer.js +0 -47
- package/benchmark/stats/print.js +0 -6
- package/benchmark/stats/stats.d.ts +0 -3
- package/benchmark/summarizer/second-phase/process.js +0 -6
- package/cli/benchmark-app.d.ts +0 -1
- package/cli/benchmark-app.js +0 -1
- package/cli/benchmark-helper-app.d.ts +0 -1
- package/cli/benchmark-helper-app.js +1 -5
- package/cli/common/options.d.ts +0 -10
- package/cli/common/options.js +0 -2
- package/cli/common/scripts-info.d.ts +0 -10
- package/cli/repl/server/connection.js +1 -1
- package/config.d.ts +0 -15
- package/config.js +0 -21
- package/control-flow/cfg-dead-code.js +0 -3
- package/control-flow/extract-cfg.js +5 -1
- package/control-flow/semantic-cfg-guided-visitor.d.ts +7 -0
- package/control-flow/semantic-cfg-guided-visitor.js +11 -4
- package/dataflow/cluster.js +2 -2
- package/dataflow/environments/built-in-config.d.ts +1 -0
- package/dataflow/environments/built-in.d.ts +9 -3
- package/dataflow/environments/built-in.js +15 -7
- package/dataflow/environments/default-builtin-config.d.ts +10 -1
- package/dataflow/environments/default-builtin-config.js +6 -4
- package/dataflow/environments/define.d.ts +4 -11
- package/dataflow/environments/define.js +16 -96
- package/dataflow/environments/diff.js +3 -2
- package/dataflow/environments/environment.d.ts +17 -6
- package/dataflow/environments/environment.js +69 -18
- package/dataflow/environments/identifier.d.ts +92 -6
- package/dataflow/environments/identifier.js +159 -1
- package/dataflow/environments/reference-to-maybe.js +1 -1
- package/dataflow/environments/resolve-by-name.d.ts +4 -4
- package/dataflow/environments/resolve-by-name.js +24 -8
- package/dataflow/eval/resolve/resolve.d.ts +10 -6
- package/dataflow/eval/resolve/resolve.js +12 -7
- package/dataflow/extractor.js +6 -3
- package/dataflow/fn/exceptions-of-function.d.ts +3 -1
- package/dataflow/fn/exceptions-of-function.js +23 -6
- package/dataflow/fn/higher-order-function.js +7 -7
- package/dataflow/graph/call-graph.d.ts +13 -0
- package/dataflow/graph/call-graph.js +46 -20
- package/dataflow/graph/diff-dataflow-graph.js +6 -4
- package/dataflow/graph/edge.d.ts +48 -31
- package/dataflow/graph/edge.js +66 -60
- package/dataflow/graph/graph.d.ts +18 -9
- package/dataflow/graph/graph.js +29 -13
- package/dataflow/graph/quads.js +1 -1
- package/dataflow/graph/resolve-graph.js +1 -1
- package/dataflow/graph/unknown-replacement.d.ts +2 -1
- package/dataflow/graph/vertex.d.ts +2 -103
- package/dataflow/graph/vertex.js +0 -44
- package/dataflow/internal/linker.d.ts +2 -2
- package/dataflow/internal/linker.js +27 -19
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +3 -65
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +4 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +13 -47
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +5 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +8 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +4 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +6 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-list.js +1 -69
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-recall.d.ts +11 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-recall.js +46 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +3 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.d.ts +0 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +11 -72
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +1 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-stop-if-not.js +4 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +3 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-vector.js +1 -60
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +3 -3
- package/dataflow/internal/process/functions/call/common.d.ts +3 -1
- package/dataflow/internal/process/functions/call/common.js +4 -16
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +6 -2
- package/dataflow/internal/process/functions/call/known-call-handling.js +2 -3
- package/dataflow/internal/process/functions/call/unnamed-call-handling.d.ts +1 -1
- package/dataflow/internal/process/functions/call/unnamed-call-handling.js +1 -1
- package/dataflow/internal/process/functions/process-parameter.js +1 -1
- package/dataflow/internal/process/process-named-call.d.ts +2 -1
- package/dataflow/internal/process/process-named-call.js +0 -1
- package/dataflow/internal/process/process-symbol.d.ts +3 -1
- package/dataflow/internal/process/process-symbol.js +8 -5
- package/dataflow/origin/dfg-get-origin.d.ts +2 -2
- package/dataflow/origin/dfg-get-origin.js +4 -4
- package/dataflow/origin/dfg-get-symbol-refs.js +2 -2
- package/documentation/data/interface/doc-writing-code.d.ts +6 -0
- package/documentation/data/interface/doc-writing-code.js +176 -0
- package/documentation/doc-util/doc-types.d.ts +3 -1
- package/documentation/doc-util/doc-types.js +4 -2
- package/documentation/wiki-absint.js +2 -1
- package/documentation/wiki-analyzer.js +17 -2
- package/documentation/wiki-cfg.js +2 -2
- package/documentation/wiki-dataflow-graph.js +9 -8
- package/documentation/wiki-interface.js +8 -164
- package/documentation/wiki-mk/doc-context.d.ts +12 -1
- package/documentation/wiki-mk/doc-context.js +21 -4
- package/documentation/wiki-normalized-ast.js +5 -0
- package/linter/linter-rules.d.ts +6 -6
- package/linter/rules/absolute-path.js +23 -23
- package/linter/rules/dataframe-access-validation.js +2 -1
- package/linter/rules/deprecated-functions.d.ts +2 -2
- package/linter/rules/deprecated-functions.js +1 -1
- package/linter/rules/function-finder-util.d.ts +3 -3
- package/linter/rules/function-finder-util.js +1 -1
- package/linter/rules/network-functions.d.ts +2 -2
- package/linter/rules/seeded-randomness.d.ts +3 -3
- package/linter/rules/seeded-randomness.js +7 -5
- package/linter/rules/unused-definition.js +4 -4
- package/package.json +5 -5
- package/project/context/flowr-analyzer-context.d.ts +17 -1
- package/project/context/flowr-analyzer-context.js +17 -1
- package/project/context/flowr-analyzer-meta-context.d.ts +51 -0
- package/project/context/flowr-analyzer-meta-context.js +47 -0
- package/project/flowr-analyzer.d.ts +17 -1
- package/project/flowr-analyzer.js +18 -0
- package/project/plugins/file-plugins/files/flowr-description-file.d.ts +15 -0
- package/project/plugins/file-plugins/files/flowr-description-file.js +26 -0
- package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +17 -3
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +292 -10
- package/project/plugins/file-plugins/flowr-analyzer-namespace-files-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-namespace-files-plugin.js +2 -2
- package/project/plugins/flowr-analyzer-plugin-defaults.js +2 -0
- package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-description-file-plugin.js +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-description-file-plugin.d.ts +12 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-description-file-plugin.js +42 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.d.ts +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.js +2 -2
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-namespace-file-plugin.d.ts +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-namespace-file-plugin.js +2 -2
- package/project/plugins/plugin-registry.d.ts +2 -1
- package/project/plugins/plugin-registry.js +2 -0
- package/queries/catalog/call-context-query/call-context-query-executor.js +6 -4
- package/queries/catalog/call-context-query/call-context-query-format.d.ts +2 -1
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +4 -4
- package/queries/catalog/dependencies-query/dependencies-query-format.js +5 -3
- package/queries/catalog/does-call-query/does-call-query-executor.js +2 -1
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.d.ts +1 -1
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.js +14 -4
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +1 -1
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.js +1 -1
- package/r-bridge/data/data.d.ts +8 -3
- package/r-bridge/data/data.js +9 -3
- package/r-bridge/lang-4.x/ast/model/model.d.ts +0 -11
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +2 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +2 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +7 -3
- package/r-bridge/lang-4.x/ast/model/processing/node-id.js +2 -1
- package/r-bridge/lang-4.x/ast/model/processing/stateful-fold.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-argument.js +0 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.js +0 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-binary.js +0 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-number.js +0 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-symbol.d.ts +1 -2
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-symbol.js +12 -13
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +4 -11
- package/reconstruct/reconstruct.js +6 -5
- package/search/flowr-search-filters.d.ts +1 -1
- package/search/flowr-search-filters.js +37 -6
- package/search/search-executor/search-enrichers.d.ts +1 -2
- package/search/search-executor/search-enrichers.js +9 -7
- package/slicing/static/slice-call.js +5 -5
- package/slicing/static/static-slicer.js +2 -2
- package/statistics/features/common-syntax-probability.js +3 -2
- package/statistics/features/supported/defined-functions/defined-functions.js +3 -3
- package/statistics/features/supported/used-functions/used-functions.js +3 -2
- package/util/mermaid/dfg.js +3 -3
- package/util/simple-df/dfg-ascii.js +5 -5
- package/util/version.js +1 -1
- package/util/containers.d.ts +0 -66
- package/util/containers.js +0 -143
|
@@ -4,6 +4,7 @@ exports.executeDoesCallQuery = executeDoesCallQuery;
|
|
|
4
4
|
const log_1 = require("../../../util/log");
|
|
5
5
|
const parse_1 = require("../../../slicing/criterion/parse");
|
|
6
6
|
const built_in_1 = require("../../../dataflow/environments/built-in");
|
|
7
|
+
const identifier_1 = require("../../../dataflow/environments/identifier");
|
|
7
8
|
/**
|
|
8
9
|
* Execute does call queries on the given analyzer.
|
|
9
10
|
*/
|
|
@@ -43,7 +44,7 @@ function makeCallMatcher(constraint) {
|
|
|
43
44
|
}
|
|
44
45
|
else {
|
|
45
46
|
const regex = new RegExp(constraint.name);
|
|
46
|
-
return (vtx) => 'name' in vtx && vtx.name ? regex.test(vtx.name) : false;
|
|
47
|
+
return (vtx) => 'name' in vtx && vtx.name ? regex.test(identifier_1.Identifier.getName(vtx.name)) : false;
|
|
47
48
|
}
|
|
48
49
|
case 'and': {
|
|
49
50
|
let matchersAndRemain = constraint.calls.map(makeCallMatcher);
|
|
@@ -10,7 +10,7 @@ export declare function getFunctionsToConsiderInCallGraph(queries: readonly {
|
|
|
10
10
|
filter?: readonly SingleSlicingCriterion[];
|
|
11
11
|
}[], analyzer: ReadonlyFlowrAnalysisProvider, onlyDefinitions?: boolean): Promise<{
|
|
12
12
|
cg: import("../../../dataflow/graph/call-graph").CallGraph;
|
|
13
|
-
fns:
|
|
13
|
+
fns: MapIterator<[NodeId, Required<import("../../../dataflow/graph/vertex").DataflowGraphVertexFunctionCall | import("../../../dataflow/graph/vertex").DataflowGraphVertexFunctionDefinition>]>;
|
|
14
14
|
}>;
|
|
15
15
|
/**
|
|
16
16
|
* Execute exception function inspection queries on the given analyzer.
|
|
@@ -32,8 +32,10 @@ async function getFunctionsToConsiderInCallGraph(queries, analyzer, onlyDefiniti
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
const cg = await analyzer.callGraph();
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
let fns = (onlyDefinitions || filterFor.size === 0 ? cg.verticesOfType(vertex_1.VertexType.FunctionDefinition) : cg.vertices(true));
|
|
36
|
+
if (filterFor.size > 0) {
|
|
37
|
+
fns = fns.filter(([id]) => filterFor.has(id));
|
|
38
|
+
}
|
|
37
39
|
return { cg, fns };
|
|
38
40
|
}
|
|
39
41
|
/**
|
|
@@ -43,8 +45,16 @@ async function executeExceptionQuery({ analyzer }, queries) {
|
|
|
43
45
|
const start = Date.now();
|
|
44
46
|
const { cg, fns } = await getFunctionsToConsiderInCallGraph(queries, analyzer);
|
|
45
47
|
const result = {};
|
|
46
|
-
for (const [id
|
|
47
|
-
result[id]
|
|
48
|
+
for (const [id] of fns) {
|
|
49
|
+
if (result[id]) {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
const res = (0, exceptions_of_function_1.calculateExceptionsOfFunction)(id, cg, result);
|
|
53
|
+
for (const [k, v] of Object.entries(res)) {
|
|
54
|
+
if (!result[k]) {
|
|
55
|
+
result[k] = v;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
48
58
|
}
|
|
49
59
|
return {
|
|
50
60
|
'.meta': {
|
|
@@ -35,7 +35,7 @@ async function executeHigherOrderQuery({ analyzer }, queries) {
|
|
|
35
35
|
const fns = graph.verticesOfType(vertex_1.VertexType.FunctionDefinition)
|
|
36
36
|
.filter(([, v]) => filterFor.size === 0 || filterFor.has(v.id));
|
|
37
37
|
const result = {};
|
|
38
|
-
for (const [id
|
|
38
|
+
for (const [id] of fns) {
|
|
39
39
|
result[id] = (0, higher_order_function_1.isFunctionHigherOrder)(id, graph, analyzer.inspectContext());
|
|
40
40
|
}
|
|
41
41
|
return {
|
|
@@ -10,7 +10,7 @@ async function executeRecursionQuery({ analyzer }, queries) {
|
|
|
10
10
|
const start = Date.now();
|
|
11
11
|
const { cg, fns } = await (0, inspect_exception_query_executor_1.getFunctionsToConsiderInCallGraph)(queries, analyzer);
|
|
12
12
|
const result = {};
|
|
13
|
-
for (const [id
|
|
13
|
+
for (const [id] of fns) {
|
|
14
14
|
result[id] = (0, recursive_function_1.isFunctionRecursive)(id, cg);
|
|
15
15
|
}
|
|
16
16
|
return {
|
package/r-bridge/data/data.d.ts
CHANGED
|
@@ -86,12 +86,12 @@ export declare const flowrCapabilities: {
|
|
|
86
86
|
}, {
|
|
87
87
|
readonly name: "Search Path";
|
|
88
88
|
readonly id: "search-path";
|
|
89
|
-
readonly supported: "
|
|
89
|
+
readonly supported: "partially";
|
|
90
90
|
readonly description: "_Handling [R's search path](https://cran.r-project.org/doc/manuals/r-release/R-lang.html#Search-path) as explained in [Advanced R](https://adv-r.hadley.nz/environments.html#search-path)._ Currently, _flowR_ does not support dynamic modifications with `attach`, `search`, or `fn_env` and tests are definitely missing. Yet, theoretically, the tooling is all there.";
|
|
91
91
|
}, {
|
|
92
92
|
readonly name: "Namespaces";
|
|
93
93
|
readonly id: "namespaces";
|
|
94
|
-
readonly supported: "
|
|
94
|
+
readonly supported: "partially";
|
|
95
95
|
readonly description: "_Handling R's namespaces as explained in [Advanced R](https://adv-r.hadley.nz/environments.html#namespaces)_";
|
|
96
96
|
}, {
|
|
97
97
|
readonly name: "Accessing Exported Names";
|
|
@@ -101,7 +101,7 @@ export declare const flowrCapabilities: {
|
|
|
101
101
|
}, {
|
|
102
102
|
readonly name: "Accessing Internal Names";
|
|
103
103
|
readonly id: "accessing-internal-names";
|
|
104
|
-
readonly supported: "
|
|
104
|
+
readonly supported: "partially";
|
|
105
105
|
readonly description: "_Similar to `::` but for internal names._";
|
|
106
106
|
}, {
|
|
107
107
|
readonly name: "Library Loading";
|
|
@@ -113,6 +113,11 @@ export declare const flowrCapabilities: {
|
|
|
113
113
|
readonly id: "dynamic-scope-changes";
|
|
114
114
|
readonly supported: "partially";
|
|
115
115
|
readonly description: "_Manually changing scopes like [`local`](https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/eval)_";
|
|
116
|
+
}, {
|
|
117
|
+
readonly name: "Anonymous Bindings";
|
|
118
|
+
readonly id: "anonymous-bindings";
|
|
119
|
+
readonly supported: "fully";
|
|
120
|
+
readonly description: "_Support for [`Recall`](https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/Recall)_";
|
|
116
121
|
}];
|
|
117
122
|
}];
|
|
118
123
|
}, {
|
package/r-bridge/data/data.js
CHANGED
|
@@ -122,13 +122,13 @@ ${await (0, doc_dfg_1.printDfGraphForCode)(parser, code, { simplified: true })}
|
|
|
122
122
|
{
|
|
123
123
|
name: 'Search Path',
|
|
124
124
|
id: 'search-path',
|
|
125
|
-
supported: '
|
|
125
|
+
supported: 'partially',
|
|
126
126
|
description: "_Handling [R's search path](https://cran.r-project.org/doc/manuals/r-release/R-lang.html#Search-path) as explained in [Advanced R](https://adv-r.hadley.nz/environments.html#search-path)._ Currently, _flowR_ does not support dynamic modifications with `attach`, `search`, or `fn_env` and tests are definitely missing. Yet, theoretically, the tooling is all there."
|
|
127
127
|
},
|
|
128
128
|
{
|
|
129
129
|
name: 'Namespaces',
|
|
130
130
|
id: 'namespaces',
|
|
131
|
-
supported: '
|
|
131
|
+
supported: 'partially',
|
|
132
132
|
description: "_Handling R's namespaces as explained in [Advanced R](https://adv-r.hadley.nz/environments.html#namespaces)_"
|
|
133
133
|
},
|
|
134
134
|
{
|
|
@@ -140,7 +140,7 @@ ${await (0, doc_dfg_1.printDfGraphForCode)(parser, code, { simplified: true })}
|
|
|
140
140
|
{
|
|
141
141
|
name: 'Accessing Internal Names',
|
|
142
142
|
id: 'accessing-internal-names',
|
|
143
|
-
supported: '
|
|
143
|
+
supported: 'partially',
|
|
144
144
|
description: '_Similar to `::` but for internal names._'
|
|
145
145
|
},
|
|
146
146
|
{
|
|
@@ -155,6 +155,12 @@ ${await (0, doc_dfg_1.printDfGraphForCode)(parser, code, { simplified: true })}
|
|
|
155
155
|
supported: 'partially',
|
|
156
156
|
description: '_Manually changing scopes like [`local`](https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/eval)_'
|
|
157
157
|
},
|
|
158
|
+
{
|
|
159
|
+
name: 'Anonymous Bindings',
|
|
160
|
+
id: 'anonymous-bindings',
|
|
161
|
+
supported: 'fully',
|
|
162
|
+
description: '_Support for [`Recall`](https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/Recall)_'
|
|
163
|
+
}
|
|
158
164
|
]
|
|
159
165
|
}
|
|
160
166
|
]
|
|
@@ -93,17 +93,6 @@ export interface Location {
|
|
|
93
93
|
* At the moment, this is only the name of the namespace.
|
|
94
94
|
*/
|
|
95
95
|
export type NamespaceIdentifier = string;
|
|
96
|
-
/**
|
|
97
|
-
* Similar to {@link Location} this is an interface that indicates that
|
|
98
|
-
* the respective {@link RAstNodeBase} node has a respective property (a namespace).
|
|
99
|
-
*/
|
|
100
|
-
export interface Namespace {
|
|
101
|
-
/**
|
|
102
|
-
* The namespace attached to the given node
|
|
103
|
-
* (e.g., a namespaced symbol in `x::y`).
|
|
104
|
-
*/
|
|
105
|
-
namespace?: NamespaceIdentifier;
|
|
106
|
-
}
|
|
107
96
|
/**
|
|
108
97
|
* This subtype of {@link RNode} represents all types of constants
|
|
109
98
|
* represented in the normalized AST.
|
|
@@ -4,12 +4,13 @@ import type { RSymbol } from './r-symbol';
|
|
|
4
4
|
import type { ParentInformation } from '../processing/decorate';
|
|
5
5
|
import type { NodeId } from '../processing/node-id';
|
|
6
6
|
import type { RFunctionArgument } from './r-function-call';
|
|
7
|
+
import type { BrandedIdentifier } from '../../../../../dataflow/environments/identifier';
|
|
7
8
|
/**
|
|
8
9
|
* Represents a named or unnamed argument of a function definition in R.
|
|
9
10
|
*/
|
|
10
11
|
export interface RArgument<Info = NoInfo> extends RAstNodeBase<Info>, Location {
|
|
11
12
|
readonly type: RType.Argument;
|
|
12
|
-
name: RSymbol<Info> | undefined;
|
|
13
|
+
name: RSymbol<Info, BrandedIdentifier> | undefined;
|
|
13
14
|
value: RNode<Info> | undefined;
|
|
14
15
|
}
|
|
15
16
|
export interface RUnnamedArgument<Info = NoInfo> extends RArgument<Info> {
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { RAstNodeBase, Location, NoInfo, RNode } from '../model';
|
|
2
2
|
import type { RType } from '../type';
|
|
3
3
|
import type { RSymbol } from './r-symbol';
|
|
4
|
+
import type { BrandedIdentifier } from '../../../../../dataflow/environments/identifier';
|
|
4
5
|
/**
|
|
5
6
|
* Represents a parameter of a function definition in R.
|
|
6
7
|
*/
|
|
7
8
|
export interface RParameter<Info = NoInfo> extends RAstNodeBase<Info>, Location {
|
|
8
9
|
readonly type: RType.Parameter;
|
|
9
|
-
name: RSymbol<Info>;
|
|
10
|
+
name: RSymbol<Info, BrandedIdentifier>;
|
|
10
11
|
/** is it the special ... parameter? */
|
|
11
12
|
special: boolean;
|
|
12
13
|
defaultValue: RNode<Info> | undefined;
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import type { Leaf, Location,
|
|
1
|
+
import type { Leaf, Location, NoInfo } from '../model';
|
|
2
2
|
import type { RType } from '../type';
|
|
3
|
+
import type { Identifier } from '../../../../../dataflow/environments/identifier';
|
|
3
4
|
/**
|
|
4
5
|
*
|
|
5
6
|
*/
|
|
6
7
|
export declare function isSpecialSymbol(symbol: RSymbol): boolean;
|
|
7
8
|
/**
|
|
8
|
-
* Represents identifiers (variables)
|
|
9
|
+
* Represents identifiers (variables) such as `x` in `x <- 42` or `a::foo` in `a::foo()`.
|
|
10
|
+
* See {@link Identifier} for more information about how identifiers are represented.
|
|
11
|
+
* @typeParam Info - can be used to store additional information about the node
|
|
12
|
+
* @typeParam T - the type used to represent the identifier, by default {@link Identifier}
|
|
9
13
|
*/
|
|
10
|
-
export interface RSymbol<Info = NoInfo, T extends
|
|
14
|
+
export interface RSymbol<Info = NoInfo, T extends Identifier = Identifier> extends Leaf<Info>, Location {
|
|
11
15
|
readonly type: RType.Symbol;
|
|
12
16
|
content: T;
|
|
13
17
|
}
|
|
@@ -5,6 +5,7 @@ exports.recoverName = recoverName;
|
|
|
5
5
|
exports.recoverContent = recoverContent;
|
|
6
6
|
const vertex_1 = require("../../../../../dataflow/graph/vertex");
|
|
7
7
|
const retriever_1 = require("../../../../retriever");
|
|
8
|
+
const identifier_1 = require("../../../../../dataflow/environments/identifier");
|
|
8
9
|
const numIdRegex = /^\d+$/;
|
|
9
10
|
/** used so that we do not have to store strings for the default numeric ids */
|
|
10
11
|
function normalizeIdToNumberIfPossible(id) {
|
|
@@ -27,7 +28,7 @@ function recoverName(id, idMap) {
|
|
|
27
28
|
function recoverContent(id, graph) {
|
|
28
29
|
const vertex = graph.getVertex(id);
|
|
29
30
|
if (vertex && vertex.tag === vertex_1.VertexType.FunctionCall && vertex.name) {
|
|
30
|
-
return vertex.name;
|
|
31
|
+
return identifier_1.Identifier.toString(vertex.name);
|
|
31
32
|
}
|
|
32
33
|
const node = graph.idMap?.get(id);
|
|
33
34
|
if (node === undefined) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.foldAstStateful = foldAstStateful;
|
|
4
|
-
const assert_1 = require("../../../../../util/assert");
|
|
5
4
|
const type_1 = require("../type");
|
|
6
5
|
const r_function_call_1 = require("../nodes/r-function-call");
|
|
6
|
+
const assert_1 = require("../../../../../util/assert");
|
|
7
7
|
/**
|
|
8
8
|
* Folds in old functional-fashion over the AST structure but allowing for a down function which can pass context to child nodes.
|
|
9
9
|
*/
|
|
@@ -32,7 +32,6 @@ function tryToNormalizeArgument(data, objs) {
|
|
|
32
32
|
type: type_1.RType.Symbol,
|
|
33
33
|
location,
|
|
34
34
|
content: symbolOrExpr.name === type_1.RawRType.StringConst ? content.slice(1, -1) : ((0, strings_1.startAndEndsWith)(content, '`') ? content.slice(1, -1) : content),
|
|
35
|
-
namespace: undefined,
|
|
36
35
|
lexeme: content,
|
|
37
36
|
info: {
|
|
38
37
|
fullRange: location,
|
|
@@ -109,7 +109,6 @@ function parseNamedFunctionCall(data, symbolContent, mappedWithName, location, c
|
|
|
109
109
|
const stringBase = (0, normalize_string_1.normalizeString)(data, symbolContent[0].content);
|
|
110
110
|
functionName = {
|
|
111
111
|
type: type_1.RType.Symbol,
|
|
112
|
-
namespace: undefined,
|
|
113
112
|
lexeme: stringBase.lexeme,
|
|
114
113
|
info: stringBase.info,
|
|
115
114
|
location: stringBase.location,
|
|
@@ -3,10 +3,9 @@ import type { RSymbol } from '../../../../model/nodes/r-symbol';
|
|
|
3
3
|
import type { NamedJsonEntry } from '../../../json/format';
|
|
4
4
|
/**
|
|
5
5
|
* Normalize the given object as an R symbol (incorporating namespace information).
|
|
6
|
-
* <p>
|
|
7
|
-
* The special symbols `T` and `F` are parsed as logic values.
|
|
8
6
|
* @param data - The data used by the parser (see {@link NormalizerData})
|
|
9
7
|
* @param objs - The JSON object to extract the meta-information from
|
|
10
8
|
* @returns The parsed symbol (with populated namespace information) or `undefined` if the given object is not a symbol.
|
|
9
|
+
* @see {@link RSymbol} for more information about R symbols.
|
|
11
10
|
*/
|
|
12
11
|
export declare function tryNormalizeSymbol(data: NormalizerData, objs: readonly NamedJsonEntry[]): RSymbol | undefined;
|
|
@@ -3,41 +3,40 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.tryNormalizeSymbol = tryNormalizeSymbol;
|
|
4
4
|
const assert_1 = require("../../../../../../../util/assert");
|
|
5
5
|
const normalize_meta_1 = require("../../normalize-meta");
|
|
6
|
-
const strings_1 = require("../../../../../../../util/text/strings");
|
|
7
6
|
const type_1 = require("../../../../model/type");
|
|
7
|
+
const identifier_1 = require("../../../../../../../dataflow/environments/identifier");
|
|
8
8
|
/**
|
|
9
9
|
* Normalize the given object as an R symbol (incorporating namespace information).
|
|
10
|
-
* <p>
|
|
11
|
-
* The special symbols `T` and `F` are parsed as logic values.
|
|
12
10
|
* @param data - The data used by the parser (see {@link NormalizerData})
|
|
13
11
|
* @param objs - The JSON object to extract the meta-information from
|
|
14
12
|
* @returns The parsed symbol (with populated namespace information) or `undefined` if the given object is not a symbol.
|
|
13
|
+
* @see {@link RSymbol} for more information about R symbols.
|
|
15
14
|
*/
|
|
16
15
|
function tryNormalizeSymbol(data, objs) {
|
|
17
16
|
(0, assert_1.guard)(objs.length > 0, 'to parse symbols we need at least one object to work on!');
|
|
18
|
-
let
|
|
17
|
+
let content, location;
|
|
18
|
+
let meta;
|
|
19
19
|
if (objs.length === 1 && (0, type_1.isSymbol)(objs[0].name)) {
|
|
20
|
-
|
|
20
|
+
meta = (0, normalize_meta_1.retrieveMetaStructure)(objs[0].content);
|
|
21
21
|
location = meta.location;
|
|
22
|
-
content = meta.content;
|
|
23
|
-
namespace = undefined;
|
|
22
|
+
content = identifier_1.Identifier.make(meta.content);
|
|
24
23
|
}
|
|
25
24
|
else if (objs.length === 3 && (0, type_1.isSymbol)(objs[2].name)) {
|
|
26
|
-
|
|
25
|
+
meta = (0, normalize_meta_1.retrieveMetaStructure)(objs[2].content);
|
|
27
26
|
location = meta.location;
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
const namespace = objs[0].content.text;
|
|
28
|
+
const internal = objs[1].content.text === ':::';
|
|
29
|
+
content = identifier_1.Identifier.make(meta.content, namespace, internal);
|
|
30
30
|
}
|
|
31
31
|
else {
|
|
32
32
|
return undefined;
|
|
33
33
|
}
|
|
34
34
|
return {
|
|
35
35
|
type: type_1.RType.Symbol,
|
|
36
|
-
namespace,
|
|
37
36
|
location,
|
|
38
37
|
// remove backticks from symbol
|
|
39
|
-
content
|
|
40
|
-
lexeme: content,
|
|
38
|
+
content,
|
|
39
|
+
lexeme: meta.content,
|
|
41
40
|
info: {
|
|
42
41
|
fullRange: data.currentRange,
|
|
43
42
|
additionalTokens: [],
|
|
@@ -15,6 +15,7 @@ const r_function_call_1 = require("../ast/model/nodes/r-function-call");
|
|
|
15
15
|
const strings_1 = require("../../../util/text/strings");
|
|
16
16
|
const log_1 = require("../../../util/log");
|
|
17
17
|
const parser_1 = require("../ast/parser/json/parser");
|
|
18
|
+
const identifier_1 = require("../../../dataflow/environments/identifier");
|
|
18
19
|
/**
|
|
19
20
|
* @param tree - The tree to normalize
|
|
20
21
|
* @param lax - Whether to use lax parsing (i.e., ignore errors) or strict parsing (i.e., fail on errors)
|
|
@@ -125,14 +126,12 @@ function convertTreeNode(node) {
|
|
|
125
126
|
location: makeSourceRange(opening),
|
|
126
127
|
content: (0, retriever_1.removeRQuotes)(opening.text),
|
|
127
128
|
lexeme: opening.text,
|
|
128
|
-
namespace: undefined,
|
|
129
129
|
...defaultInfo
|
|
130
130
|
}, {
|
|
131
131
|
type: type_1.RType.Symbol,
|
|
132
132
|
location: makeSourceRange(closing),
|
|
133
133
|
content: (0, retriever_1.removeRQuotes)(closing.text),
|
|
134
134
|
lexeme: closing.text,
|
|
135
|
-
namespace: undefined,
|
|
136
135
|
...defaultInfo
|
|
137
136
|
}
|
|
138
137
|
],
|
|
@@ -169,7 +168,6 @@ function convertTreeNode(node) {
|
|
|
169
168
|
location: opSource,
|
|
170
169
|
lexeme: op.text,
|
|
171
170
|
content: op.text,
|
|
172
|
-
namespace: undefined,
|
|
173
171
|
info: {
|
|
174
172
|
treeSitterId: op.id
|
|
175
173
|
}
|
|
@@ -236,13 +234,12 @@ function convertTreeNode(node) {
|
|
|
236
234
|
};
|
|
237
235
|
}
|
|
238
236
|
case tree_sitter_types_1.TreeSitterType.NamespaceOperator: {
|
|
239
|
-
const [lhs,
|
|
237
|
+
const [lhs, int, rhs] = nonErrorChildren(node);
|
|
240
238
|
return {
|
|
241
239
|
type: type_1.RType.Symbol,
|
|
242
240
|
location: makeSourceRange(rhs),
|
|
243
|
-
content: rhs.text,
|
|
241
|
+
content: identifier_1.Identifier.make(rhs.text, lhs.text, int.text === ':::'),
|
|
244
242
|
lexeme: rhs.text,
|
|
245
|
-
namespace: lhs.text,
|
|
246
243
|
...defaultInfo
|
|
247
244
|
};
|
|
248
245
|
}
|
|
@@ -259,7 +256,6 @@ function convertTreeNode(node) {
|
|
|
259
256
|
location: range,
|
|
260
257
|
content: (0, strings_1.startAndEndsWith)(node.text, '`') ? node.text.slice(1, -1) : (0, retriever_1.removeRQuotes)(node.text),
|
|
261
258
|
lexeme: node.text,
|
|
262
|
-
namespace: undefined,
|
|
263
259
|
...defaultInfo
|
|
264
260
|
};
|
|
265
261
|
case tree_sitter_types_1.TreeSitterType.IfStatement: {
|
|
@@ -290,7 +286,6 @@ function convertTreeNode(node) {
|
|
|
290
286
|
location: makeSourceRange(variableNode),
|
|
291
287
|
content: (0, retriever_1.removeRQuotes)(variableNode.text),
|
|
292
288
|
lexeme: variableNode.text,
|
|
293
|
-
namespace: undefined,
|
|
294
289
|
info: {
|
|
295
290
|
fullRange: undefined,
|
|
296
291
|
additionalTokens: [],
|
|
@@ -361,7 +356,6 @@ function convertTreeNode(node) {
|
|
|
361
356
|
funcNode = {
|
|
362
357
|
...funcNode,
|
|
363
358
|
type: type_1.RType.Symbol,
|
|
364
|
-
namespace: undefined,
|
|
365
359
|
content: (0, retriever_1.removeRQuotes)(func.text)
|
|
366
360
|
};
|
|
367
361
|
}
|
|
@@ -542,8 +536,7 @@ function convertTreeNode(node) {
|
|
|
542
536
|
name = {
|
|
543
537
|
...name,
|
|
544
538
|
type: type_1.RType.Symbol,
|
|
545
|
-
content: name.content.str
|
|
546
|
-
namespace: undefined
|
|
539
|
+
content: name.content.str
|
|
547
540
|
};
|
|
548
541
|
}
|
|
549
542
|
else if ((0, strings_1.startAndEndsWith)(name.content, '`')) {
|
|
@@ -13,8 +13,9 @@ const type_1 = require("../r-bridge/lang-4.x/ast/model/type");
|
|
|
13
13
|
const r_function_call_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
14
14
|
const stateful_fold_1 = require("../r-bridge/lang-4.x/ast/model/processing/stateful-fold");
|
|
15
15
|
const auto_select_defaults_1 = require("./auto-select/auto-select-defaults");
|
|
16
|
+
const identifier_1 = require("../dataflow/environments/identifier");
|
|
16
17
|
function plain(text) {
|
|
17
|
-
return [{ line: text, indent: 0 }];
|
|
18
|
+
return [{ line: Array.isArray(text) ? identifier_1.Identifier.toString(text) : text, indent: 0 }];
|
|
18
19
|
}
|
|
19
20
|
exports.reconstructLogger = log_1.log.getSubLogger({ name: 'reconstruct' });
|
|
20
21
|
function getLexeme(n) {
|
|
@@ -49,8 +50,8 @@ function reconstructExpressionList(exprList, _grouping, expressions, config) {
|
|
|
49
50
|
if (g && fst.length > 0) {
|
|
50
51
|
const start = g[0].content;
|
|
51
52
|
const end = g[1].content;
|
|
52
|
-
fst[0].line = `${start}${start === '{' ? ' ' : ''}${fst[0].line}`;
|
|
53
|
-
fst[fst.length - 1].line = `${fst[fst.length - 1].line}${end === '}' ? ' ' : ''}${end}`;
|
|
53
|
+
fst[0].line = `${identifier_1.Identifier.toString(start)}${start === '{' ? ' ' : ''}${fst[0].line}`;
|
|
54
|
+
fst[fst.length - 1].line = `${fst[fst.length - 1].line}${end === '}' ? ' ' : ''}${identifier_1.Identifier.toString(end)}`;
|
|
54
55
|
}
|
|
55
56
|
return fst;
|
|
56
57
|
}
|
|
@@ -323,13 +324,13 @@ function reconstructSpecialInfixFunctionCall(args, call) {
|
|
|
323
324
|
const lhsText = lhs.map(l => `${getIndentString(l.indent)}${l.line}`).join('\n');
|
|
324
325
|
if (rhs !== r_function_call_1.EmptyArgument && rhs.length > 0) {
|
|
325
326
|
const rhsText = rhs.map(l => `${getIndentString(l.indent)}${l.line}`).join('\n');
|
|
326
|
-
return plain(`${lhsText} ${call.functionName.content} ${rhsText}`);
|
|
327
|
+
return plain(`${lhsText} ${identifier_1.Identifier.toString(call.functionName.content)} ${rhsText}`);
|
|
327
328
|
}
|
|
328
329
|
else {
|
|
329
330
|
return plain(lhsText);
|
|
330
331
|
}
|
|
331
332
|
}
|
|
332
|
-
return plain(`${getLexeme(call.arguments[0])} ${call.functionName.content} ${getLexeme(call.arguments[1])}`);
|
|
333
|
+
return plain(`${getLexeme(call.arguments[0])} ${identifier_1.Identifier.toString(call.functionName.content)} ${getLexeme(call.arguments[1])}`);
|
|
333
334
|
}
|
|
334
335
|
function reconstructFunctionCall(call, functionName, args, configuration) {
|
|
335
336
|
const selected = isSelected(configuration, call);
|
|
@@ -2,7 +2,7 @@ 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
4
|
import type { FlowrSearchElement } from './flowr-search';
|
|
5
|
-
import {
|
|
5
|
+
import { Enrichment } from './search-executor/search-enrichers';
|
|
6
6
|
import type { BuiltInProcName } from '../dataflow/environments/built-in';
|
|
7
7
|
import type { DataflowInformation } from '../dataflow/info';
|
|
8
8
|
export type FlowrFilterName = keyof typeof FlowrFilters;
|
|
@@ -8,6 +8,7 @@ exports.evalFilter = evalFilter;
|
|
|
8
8
|
const type_1 = require("../r-bridge/lang-4.x/ast/model/type");
|
|
9
9
|
const vertex_1 = require("../dataflow/graph/vertex");
|
|
10
10
|
const search_enrichers_1 = require("./search-executor/search-enrichers");
|
|
11
|
+
const identifier_1 = require("../dataflow/environments/identifier");
|
|
11
12
|
var FlowrFilter;
|
|
12
13
|
(function (FlowrFilter) {
|
|
13
14
|
/**
|
|
@@ -34,8 +35,25 @@ exports.FlowrFilters = {
|
|
|
34
35
|
return e.node.type !== type_1.RType.Argument || e.node.name !== undefined;
|
|
35
36
|
}),
|
|
36
37
|
[FlowrFilter.MatchesEnrichment]: ((e, args) => {
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
if (args.enrichment === search_enrichers_1.Enrichment.CallTargets) {
|
|
39
|
+
const c = (0, search_enrichers_1.enrichmentContent)(e, search_enrichers_1.Enrichment.CallTargets);
|
|
40
|
+
if (c === undefined || c.targets === undefined) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
for (const fn of c.targets) {
|
|
44
|
+
if (typeof fn === 'string' && args.test.test(fn)) {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
if (typeof fn === 'object' && 'node' in fn && fn.node.type === type_1.RType.FunctionCall && fn.node.named && args.test.test(identifier_1.Identifier.getName(fn.node.functionName.content))) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
const content = JSON.stringify((0, search_enrichers_1.enrichmentContent)(e, args.enrichment));
|
|
55
|
+
return content !== undefined && args.test.test(content);
|
|
56
|
+
}
|
|
39
57
|
}),
|
|
40
58
|
[FlowrFilter.OriginKind]: ((e, args, data) => {
|
|
41
59
|
const dfgNode = data.dataflow.graph.getVertex(e.node.info.id);
|
|
@@ -53,7 +71,7 @@ exports.FlowrFilters = {
|
|
|
53
71
|
* Helper to create a regular expression that matches function names, ignoring their package.
|
|
54
72
|
*/
|
|
55
73
|
function testFunctionsIgnoringPackage(functions) {
|
|
56
|
-
return new RegExp(
|
|
74
|
+
return new RegExp(`^(.+:::?)?(${functions.join('|')})$`);
|
|
57
75
|
}
|
|
58
76
|
/**
|
|
59
77
|
* @see {@link FlowrFilterCombinator.is}
|
|
@@ -185,8 +203,21 @@ function evalTree(tree, data) {
|
|
|
185
203
|
* Evaluates the given filter expression against the provided data.
|
|
186
204
|
*/
|
|
187
205
|
function evalFilter(filter, data) {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
206
|
+
if (filter instanceof FlowrFilterCombinator) {
|
|
207
|
+
return evalTree(filter.get(), data);
|
|
208
|
+
}
|
|
209
|
+
else if (typeof filter === 'string' && exports.ValidFlowrFilters.has(filter)) {
|
|
210
|
+
const handler = exports.FlowrFilters[filter];
|
|
211
|
+
return handler(data.element, undefined, data.data);
|
|
212
|
+
}
|
|
213
|
+
else if (typeof filter === 'object' && 'name' in filter) {
|
|
214
|
+
const handler = exports.FlowrFilters[filter.name];
|
|
215
|
+
const args = ('args' in filter ? filter.args : undefined);
|
|
216
|
+
return handler(data.element, args, data.data);
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
const tree = FlowrFilterCombinator.is(filter);
|
|
220
|
+
return evalTree(tree.get(), data);
|
|
221
|
+
}
|
|
191
222
|
}
|
|
192
223
|
//# sourceMappingURL=flowr-search-filters.js.map
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { FlowrSearchElement, FlowrSearchElements } from '../flowr-search';
|
|
2
2
|
import type { ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
3
3
|
import { type MergeableRecord } from '../../util/objects';
|
|
4
|
-
import type { Identifier } from '../../dataflow/environments/identifier';
|
|
5
4
|
import type { LinkToLastCall } from '../../queries/catalog/call-context-query/call-context-query-format';
|
|
6
5
|
import { type NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
7
6
|
import type { ControlFlowInformation } from '../../control-flow/control-flow-graph';
|
|
@@ -39,7 +38,7 @@ export interface CallTargetsContent extends MergeableRecord {
|
|
|
39
38
|
* The call targets of the function call.
|
|
40
39
|
* For identifier call targets, the identifier is the name of the library function being called.
|
|
41
40
|
*/
|
|
42
|
-
targets: (FlowrSearchElement<ParentInformation> |
|
|
41
|
+
targets: (FlowrSearchElement<ParentInformation> | string)[];
|
|
43
42
|
}
|
|
44
43
|
export interface LastCallContent extends MergeableRecord {
|
|
45
44
|
linkedIds: FlowrSearchElement<ParentInformation>[];
|
|
@@ -11,7 +11,8 @@ const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id"
|
|
|
11
11
|
const cfg_simplification_1 = require("../../control-flow/cfg-simplification");
|
|
12
12
|
const call_context_query_executor_1 = require("../../queries/catalog/call-context-query/call-context-query-executor");
|
|
13
13
|
const cfg_kind_1 = require("../../project/cfg-kind");
|
|
14
|
-
const
|
|
14
|
+
const identify_link_to_last_call_relation_1 = require("../../queries/catalog/call-context-query/identify-link-to-last-call-relation");
|
|
15
|
+
const identifier_1 = require("../../dataflow/environments/identifier");
|
|
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.
|
|
@@ -49,7 +50,7 @@ exports.Enrichments = {
|
|
|
49
50
|
node: n.idMap.get(o.id),
|
|
50
51
|
};
|
|
51
52
|
case 3 /* OriginType.BuiltInFunctionOrigin */:
|
|
52
|
-
return o.fn.name;
|
|
53
|
+
return identifier_1.Identifier.toString(o.fn.name);
|
|
53
54
|
default:
|
|
54
55
|
return undefined;
|
|
55
56
|
}
|
|
@@ -75,12 +76,13 @@ exports.Enrichments = {
|
|
|
75
76
|
enrichElement: async (e, _s, analyzer, args, prev) => {
|
|
76
77
|
(0, assert_1.guard)(args && args.length, `${Enrichment.LastCall} enrichment requires at least one argument`);
|
|
77
78
|
const content = prev ?? { linkedIds: [] };
|
|
78
|
-
const df = await analyzer.dataflow();
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
const df = (await analyzer.dataflow()).graph;
|
|
80
|
+
const vertex = df.getVertex(e.node.info.id);
|
|
81
|
+
if (vertex?.tag === vertex_1.VertexType.FunctionCall) {
|
|
82
|
+
const n = await analyzer.normalize();
|
|
83
|
+
const cfg = (await analyzer.controlflow(undefined, cfg_kind_1.CfgKind.Quick)).graph;
|
|
82
84
|
for (const arg of args) {
|
|
83
|
-
const lastCalls =
|
|
85
|
+
const lastCalls = (0, identify_link_to_last_call_relation_1.identifyLinkToLastCallRelationSync)(vertex.id, cfg, df, {
|
|
84
86
|
...arg,
|
|
85
87
|
callName: (0, call_context_query_executor_1.promoteCallName)(arg.callName),
|
|
86
88
|
type: 'link-to-last-call',
|