@eagleoutice/flowr 2.9.13 → 2.9.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -10
- package/abstract-interpretation/absint-visitor.d.ts +1 -1
- package/abstract-interpretation/absint-visitor.js +20 -20
- package/abstract-interpretation/data-frame/mappers/replacement-mapper.js +2 -2
- package/benchmark/slicer.d.ts +1 -1
- package/benchmark/slicer.js +7 -5
- package/cli/repl/commands/repl-dataflow.js +5 -5
- package/cli/repl/parser/slice-query-parser.d.ts +1 -1
- package/cli/repl/parser/slice-query-parser.js +2 -2
- package/cli/repl/server/connection.js +2 -2
- package/cli/repl/server/messages/message-slice.d.ts +1 -1
- package/cli/repl/server/messages/message-slice.js +2 -2
- package/config.d.ts +8 -8
- package/control-flow/extract-cfg.js +2 -2
- package/control-flow/semantic-cfg-guided-visitor.d.ts +1 -1
- package/control-flow/semantic-cfg-guided-visitor.js +43 -43
- package/control-flow/useless-loop.d.ts +1 -1
- package/control-flow/useless-loop.js +3 -3
- package/core/print/dataflow-printer.d.ts +0 -14
- package/core/print/dataflow-printer.js +0 -21
- package/core/steps/all/core/20-dataflow.d.ts +3 -3
- package/core/steps/all/core/20-dataflow.js +3 -2
- package/core/steps/all/static-slicing/00-slice.d.ts +2 -5
- package/core/steps/all/static-slicing/00-slice.js +6 -8
- package/core/steps/pipeline/default-pipelines.d.ts +89 -89
- package/dataflow/environments/built-in-proc-name.d.ts +83 -0
- package/dataflow/environments/built-in-proc-name.js +88 -0
- package/dataflow/environments/built-in.d.ts +1 -83
- package/dataflow/environments/built-in.js +37 -120
- package/dataflow/environments/default-builtin-config.d.ts +1 -1
- package/dataflow/environments/default-builtin-config.js +75 -75
- package/dataflow/environments/identifier.d.ts +1 -0
- package/dataflow/environments/identifier.js +1 -0
- package/dataflow/eval/resolve/resolve.js +2 -2
- package/dataflow/fn/exceptions-of-function.d.ts +1 -1
- package/dataflow/fn/exceptions-of-function.js +2 -2
- package/dataflow/graph/call-graph.d.ts +49 -19
- package/dataflow/graph/call-graph.js +117 -114
- package/dataflow/graph/dataflowgraph-builder.d.ts +1 -1
- package/dataflow/graph/dataflowgraph-builder.js +2 -2
- package/dataflow/graph/df-helper.d.ts +132 -0
- package/dataflow/graph/df-helper.js +131 -0
- package/dataflow/graph/diff-dataflow-graph.d.ts +5 -10
- package/dataflow/graph/diff-dataflow-graph.js +3 -28
- package/dataflow/graph/edge.d.ts +1 -0
- package/dataflow/graph/edge.js +1 -0
- package/dataflow/graph/graph-helper.d.ts +55 -0
- package/dataflow/graph/graph-helper.js +105 -0
- package/dataflow/graph/graph.d.ts +6 -1
- package/dataflow/graph/graph.js +6 -1
- package/dataflow/graph/vertex.d.ts +1 -1
- package/dataflow/info.d.ts +14 -4
- package/dataflow/info.js +28 -16
- package/dataflow/internal/linker.d.ts +14 -10
- package/dataflow/internal/linker.js +29 -32
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +5 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +4 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +7 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +2 -2
- 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 +4 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-list.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-local.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-local.js +5 -5
- 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 +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-recall.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.js +5 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +5 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-dispatch.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +7 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-stop-if-not.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +6 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-vector.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +2 -2
- package/dataflow/internal/process/functions/call/known-call-handling.js +2 -2
- package/dataflow/internal/process/functions/call/named-call-handling.d.ts +1 -1
- package/dataflow/internal/process/functions/call/named-call-handling.js +1 -1
- package/dataflow/internal/process/functions/call/unnamed-call-handling.js +2 -2
- package/dataflow/internal/process/process-uninteresting-leaf.d.ts +1 -1
- package/dataflow/internal/process/process-uninteresting-leaf.js +1 -1
- package/dataflow/origin/dfg-get-origin.d.ts +1 -1
- package/dataflow/origin/dfg-get-symbol-refs.js +6 -6
- package/documentation/doc-util/doc-dfg.d.ts +3 -0
- package/documentation/doc-util/doc-dfg.js +5 -7
- package/documentation/doc-util/doc-normalized-ast.d.ts +0 -6
- package/documentation/doc-util/doc-normalized-ast.js +0 -23
- package/documentation/doc-util/doc-structure.js +3 -3
- package/documentation/doc-util/doc-types.js +3 -3
- package/documentation/wiki-core.js +5 -4
- package/documentation/wiki-dataflow-graph.js +14 -12
- package/documentation/wiki-interface.js +3 -3
- package/documentation/wiki-linter.js +1 -0
- package/documentation/wiki-normalized-ast.js +5 -4
- package/documentation/wiki-query.js +28 -3
- package/linter/linter-rules.d.ts +24 -1
- package/linter/linter-rules.js +3 -1
- package/linter/rules/seeded-randomness.js +2 -2
- package/linter/rules/stop-with-call-arg.d.ts +35 -0
- package/linter/rules/stop-with-call-arg.js +72 -0
- package/linter/rules/useless-loop.d.ts +1 -1
- package/package.json +1 -1
- package/project/cache/flowr-analyzer-cache.d.ts +1 -1
- package/project/cache/flowr-analyzer-cache.js +1 -1
- package/project/flowr-analyzer-builder.d.ts +3 -0
- package/project/flowr-analyzer.d.ts +1 -1
- package/queries/catalog/call-context-query/identify-link-to-nested-call-relation.js +2 -2
- package/queries/catalog/call-graph-query/call-graph-query-format.d.ts +1 -1
- package/queries/catalog/call-graph-query/call-graph-query-format.js +2 -2
- package/queries/catalog/cluster-query/cluster-query-format.js +2 -2
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.js +2 -2
- package/queries/catalog/dataflow-query/dataflow-query-format.js +2 -2
- package/queries/catalog/df-shape-query/df-shape-query-executor.js +1 -2
- package/queries/catalog/does-call-query/does-call-query-executor.js +2 -2
- package/queries/catalog/happens-before-query/happens-before-query-executor.js +2 -2
- 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 +1 -1
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +3 -3
- package/queries/catalog/location-map-query/location-map-query-executor.js +2 -2
- package/queries/catalog/origin-query/origin-query-executor.d.ts +1 -1
- package/queries/catalog/origin-query/origin-query-executor.js +3 -3
- package/queries/catalog/provenance-query/provenance-query-executor.d.ts +9 -0
- package/queries/catalog/provenance-query/provenance-query-executor.js +37 -0
- package/queries/catalog/provenance-query/provenance-query-format.d.ts +35 -0
- package/queries/catalog/provenance-query/provenance-query-format.js +62 -0
- package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +2 -2
- package/queries/catalog/search-query/search-query-format.js +1 -1
- package/queries/catalog/static-slice-query/static-slice-query-executor.js +4 -2
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +2 -2
- package/queries/catalog/static-slice-query/static-slice-query-format.js +3 -3
- package/queries/query.d.ts +9 -1
- package/queries/query.js +2 -0
- package/r-bridge/lang-4.x/ast/model/model.d.ts +6 -0
- package/r-bridge/lang-4.x/ast/model/model.js +7 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +8 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.js +13 -0
- package/search/flowr-search-filters.d.ts +1 -1
- package/search/flowr-search-printer.js +3 -3
- package/search/search-executor/search-enrichers.js +2 -2
- package/search/search-executor/search-generators.js +1 -1
- package/slicing/criterion/parse.d.ts +40 -16
- package/slicing/criterion/parse.js +67 -63
- package/slicing/static/slicer-types.d.ts +2 -3
- package/slicing/static/static-slicer.d.ts +3 -4
- package/slicing/static/static-slicer.js +9 -12
- package/util/diff.d.ts +2 -2
- package/util/mermaid/ast.js +4 -4
- package/util/mermaid/cfg.js +5 -5
- package/util/mermaid/dfg.d.ts +33 -18
- package/util/mermaid/dfg.js +46 -31
- package/util/mermaid/mermaid.d.ts +57 -12
- package/util/mermaid/mermaid.js +74 -67
- package/util/range.d.ts +8 -0
- package/util/range.js +13 -1
- package/util/slice-direction.d.ts +7 -0
- package/util/slice-direction.js +12 -0
- package/util/version.js +1 -1
- package/dataflow/graph/invert-dfg.d.ts +0 -6
- package/dataflow/graph/invert-dfg.js +0 -20
- package/dataflow/graph/resolve-graph.d.ts +0 -8
- package/dataflow/graph/resolve-graph.js +0 -59
|
@@ -38,11 +38,12 @@ const flowr_analyzer_builder_1 = require("../project/flowr-analyzer-builder");
|
|
|
38
38
|
const flowr_analyzer_context_1 = require("../project/context/flowr-analyzer-context");
|
|
39
39
|
const doc_maker_1 = require("./wiki-mk/doc-maker");
|
|
40
40
|
const flowr_analyzer_1 = require("../project/flowr-analyzer");
|
|
41
|
-
const built_in_1 = require("../dataflow/environments/built-in");
|
|
42
41
|
const dfg_1 = require("../util/mermaid/dfg");
|
|
43
42
|
const r_number_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-number");
|
|
44
43
|
const model_1 = require("../r-bridge/lang-4.x/ast/model/model");
|
|
45
44
|
const range_1 = require("../util/range");
|
|
45
|
+
const df_helper_1 = require("../dataflow/graph/df-helper");
|
|
46
|
+
const built_in_proc_name_1 = require("../dataflow/environments/built-in-proc-name");
|
|
46
47
|
async function subExplanation(parser, { description, code, expectedSubgraph }) {
|
|
47
48
|
expectedSubgraph = await (0, doc_dfg_1.verifyExpectedSubgraph)(parser, code, expectedSubgraph);
|
|
48
49
|
const marks = [];
|
|
@@ -170,7 +171,7 @@ ${(0, doc_structure_1.block)({
|
|
|
170
171
|
content: `
|
|
171
172
|
If you want to obtain the locations where a variable is defined, or read, or re-defined, refrain from tracking these details manually in the dataflow graph
|
|
172
173
|
as there are some edge-cases that require special attention.
|
|
173
|
-
In general, the ${ctx.link(dfg_get_origin_1.getOriginInDfg)} function explained below in [working with the dataflow graph](${doc_files_1.FlowrWikiBaseRef}/Dataflow%20Graph#working-with-the-dataflow-graph) will help you to get the information you need.
|
|
174
|
+
In general, the ${ctx.link(dfg_get_origin_1.getOriginInDfg)} (which is also available as ${ctx.linkO(df_helper_1.Dataflow, 'origin')}) function explained below in [working with the dataflow graph](${doc_files_1.FlowrWikiBaseRef}/Dataflow%20Graph#working-with-the-dataflow-graph) will help you to get the information you need.
|
|
174
175
|
`
|
|
175
176
|
})}
|
|
176
177
|
|
|
@@ -196,8 +197,8 @@ ${ctx.hierarchy('FunctionArgument')}
|
|
|
196
197
|
|
|
197
198
|
There is another element of potential interest to you, the \`origin\` property which records how flowR created the respective function call.
|
|
198
199
|
These origins may hold the name of any processor that is part of the ${ctx.link('BuiltInProcName')} enumeration to signal that the respective processor (cf. ${ctx.link('BuiltInProcessorMapper')}) was responsible for creating the vertex.
|
|
199
|
-
The entry \`${
|
|
200
|
-
However, in general, flowR may use any fitting handler as an origin (see the ${ctx.link('BuiltInProcName')} enum for a *complete* list). For example, within a access definition, flowR will correspondingly redefine the meaning of \`:=\` to that of the \`${
|
|
200
|
+
The entry \`${built_in_proc_name_1.BuiltInProcName.Function}\` signals that flowR used a processor for a user-defined function defined within the source code, \`${built_in_proc_name_1.BuiltInProcName.Unnamed}\` signals that the function as an anonymous function definition.
|
|
201
|
+
However, in general, flowR may use any fitting handler as an origin (see the ${ctx.link('BuiltInProcName')} enum for a *complete* list). For example, within a access definition, flowR will correspondingly redefine the meaning of \`:=\` to that of the \`${built_in_proc_name_1.BuiltInProcName.TableAssignment}\`.
|
|
201
202
|
|
|
202
203
|
${(0, doc_structure_1.details)('Example: Simple Function Call (unresolved)', await (async () => {
|
|
203
204
|
const code = 'foo(x,3,y=3,)';
|
|
@@ -367,7 +368,7 @@ ${(0, doc_structure_1.block)({
|
|
|
367
368
|
content: `Now you might be asking yourself how to differentiate anonymous and named functions and what you have to keep in mind when working with them?
|
|
368
369
|
|
|
369
370
|
Unnamed functions have an array of signatures which you can use to identify them.
|
|
370
|
-
But in short: the \`origin\` attribute of the ${ctx.link('DataflowGraphVertexFunctionCall')} is \`${
|
|
371
|
+
But in short: the \`origin\` attribute of the ${ctx.link('DataflowGraphVertexFunctionCall')} is \`${built_in_proc_name_1.BuiltInProcName.Unnamed}\`.
|
|
371
372
|
Please be aware that unnamed functions still have a \`name\` property to give it a unique identifier that can be used for debugging and reference.
|
|
372
373
|
This name _always_ starts with \`${unnamed_call_handling_1.UnnamedFunctionCallPrefix}\`.
|
|
373
374
|
|
|
@@ -1052,7 +1053,8 @@ ${await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'alias <- unknown\nalias(
|
|
|
1052
1053
|
${(0, doc_structure_1.section)('Working with the Dataflow Graph', 2, 'dfg-working')}
|
|
1053
1054
|
|
|
1054
1055
|
The ${ctx.link('DataflowInformation')} is the core result of _flowR_ and summarizes a lot of information.
|
|
1055
|
-
Depending on what you are interested in, there exists a plethora of functions and queries to help you out, answering the most important questions
|
|
1056
|
+
Depending on what you are interested in, there exists a plethora of functions and queries to help you out, answering the most important questions.
|
|
1057
|
+
Generally, we recommend you check out the ${ctx.link(df_helper_1.Dataflow, undefined, { type: 'variable' })} helper object!
|
|
1056
1058
|
|
|
1057
1059
|
* The **${ctx.linkPage('wiki/Query API')}** provides many functions to query the dataflow graph for specific information (dependencies, calls, slices, clusters, ...)
|
|
1058
1060
|
* The **${ctx.linkPage('wiki/Search API')}** allows you to search for specific vertices or edges in the dataflow graph or the original program
|
|
@@ -1064,9 +1066,9 @@ Depending on what you are interested in, there exists a plethora of functions an
|
|
|
1064
1066
|
|
|
1065
1067
|
FlowR also provides various helper objects (with the same name as the corresponding type) to help you work with the dataflow graph:
|
|
1066
1068
|
|
|
1067
|
-
* ${ctx.link(
|
|
1068
|
-
* ${ctx.link(
|
|
1069
|
-
* ${ctx.link(
|
|
1069
|
+
* ${ctx.link(edge_1.DfEdge, undefined, { type: 'variable' })} to get helpful functions wrt. edges (see [below](#dfg-resolving-values))
|
|
1070
|
+
* ${ctx.link(identifier_1.Identifier, undefined, { type: 'variable' })} to get helpful functions wrt. identifiers
|
|
1071
|
+
* ${ctx.link(graph_1.FunctionArgument, undefined, { type: 'variable' })} to get helpful functions wrt. function arguments
|
|
1070
1072
|
|
|
1071
1073
|
Some of these functions have been explained in their respective wiki pages. However, some are part of the ${ctx.linkPage('wiki/Dataflow Graph', 'Dataflow Graph API')} and so we explain them here.
|
|
1072
1074
|
If you are interested in which features we support and which features are still to be worked on, please refer to our ${ctx.linkPage('wiki/Capabilities', 'capabilities')} page.
|
|
@@ -1107,14 +1109,14 @@ ${await (async () => {
|
|
|
1107
1109
|
}
|
|
1108
1110
|
throw new Error('Could not find edge');
|
|
1109
1111
|
})()}—which is usually not very helpful.
|
|
1110
|
-
You can use ${ctx.
|
|
1111
|
-
${ctx.
|
|
1112
|
+
You can use ${ctx.linkO(edge_1.DfEdge, 'splitTypes')} to get the individual bitmasks of all included types, and
|
|
1113
|
+
${ctx.linkO(edge_1.DfEdge, 'includesType')} to check whether a specific type (or one of a collection of types) is included in the edge.
|
|
1112
1114
|
|
|
1113
1115
|
${(0, doc_structure_1.section)('Handling Origins', 3, 'dfg-handling-origins')}
|
|
1114
1116
|
|
|
1115
1117
|
If you are writing another analysis on top of the dataflow graph, you probably want to know all definitions that serve as the source of a read, all functions
|
|
1116
1118
|
that are called by an invocation, and more.
|
|
1117
|
-
For this, the ${ctx.link(dfg_get_origin_1.getOriginInDfg)} function provides you with a collection of ${ctx.link('Origin')} objects:
|
|
1119
|
+
For this, the ${ctx.link(dfg_get_origin_1.getOriginInDfg)} (this is also accessible with ${ctx.linkO(df_helper_1.Dataflow, 'origin')}) function provides you with a collection of ${ctx.link('Origin')} objects:
|
|
1118
1120
|
|
|
1119
1121
|
${ctx.hierarchy('Origin', { openTop: true })}
|
|
1120
1122
|
|
|
@@ -18,8 +18,8 @@ const flowr_main_options_1 = require("../cli/flowr-main-options");
|
|
|
18
18
|
const doc_issue_1 = require("./doc-util/doc-issue");
|
|
19
19
|
const doc_structure_1 = require("./doc-util/doc-structure");
|
|
20
20
|
const doc_maker_1 = require("./wiki-mk/doc-maker");
|
|
21
|
-
const built_in_1 = require("../dataflow/environments/built-in");
|
|
22
21
|
const doc_writing_code_1 = require("./data/interface/doc-writing-code");
|
|
22
|
+
const built_in_proc_name_1 = require("../dataflow/environments/built-in-proc-name");
|
|
23
23
|
async function explainServer(parser) {
|
|
24
24
|
(0, doc_data_server_messages_1.documentAllServerMessages)();
|
|
25
25
|
return `
|
|
@@ -236,7 +236,7 @@ ${(0, doc_code_1.codeBlock)('json', JSON.stringify({
|
|
|
236
236
|
environment: {
|
|
237
237
|
overwriteBuiltIns: {
|
|
238
238
|
definitions: [
|
|
239
|
-
{ type: 'function', names: ['foo'], processor:
|
|
239
|
+
{ type: 'function', names: ['foo'], processor: built_in_proc_name_1.BuiltInProcName.Assignment, config: {} }
|
|
240
240
|
]
|
|
241
241
|
}
|
|
242
242
|
}
|
|
@@ -290,7 +290,7 @@ ${(0, doc_code_1.codeBlock)('json', JSON.stringify({
|
|
|
290
290
|
| Type | Description | Example |
|
|
291
291
|
| --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
|
|
292
292
|
| \`constant\` | Additionally allows for a \`value\` this should resolve to. | \`{ type: 'constant', names: ['NULL', 'NA'], value: null }\` |
|
|
293
|
-
| \`function\` | Is a rather flexible way to define and bind built-in functions. For the time, we do not have extensive documentation to cover all the cases, so please either consult the sources with the \`default-builtin-config.ts\` or open a [new issue](${doc_issue_1.NewIssueUrl}). | \`{ type: 'function', names: ['next'], processor: '${
|
|
293
|
+
| \`function\` | Is a rather flexible way to define and bind built-in functions. For the time, we do not have extensive documentation to cover all the cases, so please either consult the sources with the \`default-builtin-config.ts\` or open a [new issue](${doc_issue_1.NewIssueUrl}). | \`{ type: 'function', names: ['next'], processor: '${built_in_proc_name_1.BuiltInProcName.Default}', config: { cfg: ExitPointType.Next } }\` |
|
|
294
294
|
| \`replacement\` | A comfortable way to specify replacement functions like \`$<-\` or \`names<-\`. \`suffixes\` describes the... suffixes to attach automatically. | \`{ type: 'replacement', suffixes: ['<-', '<<-'], names: ['[', '[['] }\` |
|
|
295
295
|
|
|
296
296
|
|
|
@@ -122,6 +122,7 @@ df[6, "value"]
|
|
|
122
122
|
`, tagTypes);
|
|
123
123
|
rule(knownParser, 'dead-code', 'DeadCodeConfig', 'DEAD_CODE', 'lint-dead-code', 'if(TRUE) 1 else 2', tagTypes);
|
|
124
124
|
rule(knownParser, 'useless-loop', 'UselessLoopConfig', 'USELESS_LOOP', 'lint-useless-loop', 'for(i in c(1)) { print(i) }', tagTypes);
|
|
125
|
+
rule(knownParser, 'stop-call', 'StopWithCallConfig', 'STOP_WITH_CALL_ARG', 'lint-stop-call', 'stop(42)', tagTypes);
|
|
125
126
|
function rule(parser, name, configType, ruleType, testfile, example, types) {
|
|
126
127
|
const rule = linter_rules_1.LintingRules[name];
|
|
127
128
|
const tags = rule.info.tags.toSorted((a, b) => {
|
|
@@ -16,6 +16,7 @@ const roxygen_parse_1 = require("../r-bridge/roxygen2/roxygen-parse");
|
|
|
16
16
|
const r_binary_op_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-binary-op");
|
|
17
17
|
const model_1 = require("../r-bridge/lang-4.x/ast/model/model");
|
|
18
18
|
const r_project_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-project");
|
|
19
|
+
const r_expression_list_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-expression-list");
|
|
19
20
|
async function quickNormalizedAstMultipleFiles() {
|
|
20
21
|
const analyzer = await new flowr_analyzer_builder_1.FlowrAnalyzerBuilder()
|
|
21
22
|
.setEngine('tree-sitter')
|
|
@@ -95,8 +96,8 @@ ${await (0, doc_normalized_ast_1.printNormalizedAstForCode)(treeSitter, 'x <- 2
|
|
|
95
96
|
> you can either use the [Visual Studio Code extension](${doc_files_1.FlowrGithubBaseRef}/vscode-flowr) or the ${(0, doc_cli_option_1.getReplCommand)('normalize*')}
|
|
96
97
|
> command in the REPL (see the [Interface wiki page](${doc_files_1.FlowrWikiBaseRef}/Interface) for more information).
|
|
97
98
|
|
|
98
|
-
Indicative of the normalization is the root ${ctx.link(
|
|
99
|
-
and provides the ${ctx.link(
|
|
99
|
+
Indicative of the normalization is the root ${ctx.link(r_project_1.RProject)} node, which is present in every normalized AST
|
|
100
|
+
and provides the ${ctx.link(r_expression_list_1.RExpressionList)} nodes for each file in the project.
|
|
100
101
|
In general, we provide node types for:
|
|
101
102
|
|
|
102
103
|
1. literals (e.g., numbers and strings)
|
|
@@ -112,7 +113,7 @@ In general, we provide node types for:
|
|
|
112
113
|
Every node is a link, which directly refers to the implementation in the source code.
|
|
113
114
|
Grayed-out parts are used for structuring the AST, grouping together related nodes.
|
|
114
115
|
|
|
115
|
-
${(0, doc_code_1.codeBlock)('mermaid', ctx.mermaid(
|
|
116
|
+
${(0, doc_code_1.codeBlock)('mermaid', ctx.mermaid(model_1.RNode))}
|
|
116
117
|
|
|
117
118
|
</details>
|
|
118
119
|
|
|
@@ -123,7 +124,7 @@ Most notably, the \`info\` field holds the \`id\` of the node, which is used to
|
|
|
123
124
|
|
|
124
125
|
In summary, we have the following types:
|
|
125
126
|
|
|
126
|
-
${(0, doc_structure_1.details)('Normalized AST Node Types', ctx.hierarchy(
|
|
127
|
+
${(0, doc_structure_1.details)('Normalized AST Node Types', ctx.hierarchy(model_1.RNode, { collapseFromNesting: Number.MAX_VALUE, ignoredTypes: ['Info', 'LogLevel'] }))}
|
|
127
128
|
|
|
128
129
|
The following segments intend to give you an overview of how to work with the normalized AST:
|
|
129
130
|
|
|
@@ -29,7 +29,6 @@ const vertex_1 = require("../dataflow/graph/vertex");
|
|
|
29
29
|
const control_flow_query_executor_1 = require("../queries/catalog/control-flow-query/control-flow-query-executor");
|
|
30
30
|
const doc_cfg_1 = require("./doc-util/doc-cfg");
|
|
31
31
|
const df_shape_query_executor_1 = require("../queries/catalog/df-shape-query/df-shape-query-executor");
|
|
32
|
-
const _00_slice_1 = require("../core/steps/all/static-slicing/00-slice");
|
|
33
32
|
const doc_repl_1 = require("./doc-util/doc-repl");
|
|
34
33
|
const inspect_higher_order_query_executor_1 = require("../queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor");
|
|
35
34
|
const doc_escape_1 = require("./doc-util/doc-escape");
|
|
@@ -39,6 +38,8 @@ const call_graph_query_executor_1 = require("../queries/catalog/call-graph-query
|
|
|
39
38
|
const inspect_recursion_query_executor_1 = require("../queries/catalog/inspect-recursion-query/inspect-recursion-query-executor");
|
|
40
39
|
const does_call_query_executor_1 = require("../queries/catalog/does-call-query/does-call-query-executor");
|
|
41
40
|
const inspect_exception_query_executor_1 = require("../queries/catalog/inspect-exceptions-query/inspect-exception-query-executor");
|
|
41
|
+
const slice_direction_1 = require("../util/slice-direction");
|
|
42
|
+
const provenance_query_executor_1 = require("../queries/catalog/provenance-query/provenance-query-executor");
|
|
42
43
|
(0, doc_query_1.registerQueryDocumentation)('call-context', {
|
|
43
44
|
name: 'Call-Context Query',
|
|
44
45
|
type: 'active',
|
|
@@ -554,7 +555,7 @@ To specify a variable of interest, you have to present flowR with a [slicing cri
|
|
|
554
555
|
|
|
555
556
|
To exemplify the capabilities, consider the following code:
|
|
556
557
|
${(0, doc_code_1.codeBlock)('r', exampleCode)}
|
|
557
|
-
If you are interested in the parts required for the use of \`x\` in the last line
|
|
558
|
+
If you are interested in the parts required for the use of \`x\` in the last line and \`z\`, you can use the following query:
|
|
558
559
|
|
|
559
560
|
${await (0, doc_query_1.showQuery)(shell, exampleCode, [{
|
|
560
561
|
type: 'static-slice',
|
|
@@ -575,7 +576,7 @@ Likewise, if you want the forward slice for the first use of \`x\`, you can do i
|
|
|
575
576
|
${await (0, doc_query_1.showQuery)(shell, exampleCode, [{
|
|
576
577
|
type: 'static-slice',
|
|
577
578
|
criteria: ['1@x'],
|
|
578
|
-
direction:
|
|
579
|
+
direction: slice_direction_1.SliceDirection.Forward
|
|
579
580
|
}], { showCode: false, shorthand: (0, doc_query_1.sliceQueryShorthand)(['1@x'], (0, doc_escape_1.escapeNewline)(exampleCode), true) })}
|
|
580
581
|
|
|
581
582
|
You can disable [magic comments](${doc_files_1.FlowrWikiBaseRef}/Interface#slice-magic-comments) using the \`noMagicComments\` flag.
|
|
@@ -583,6 +584,30 @@ This query replaces the old [\`request-slice\`](${doc_files_1.FlowrWikiBaseRef}/
|
|
|
583
584
|
`;
|
|
584
585
|
}
|
|
585
586
|
});
|
|
587
|
+
(0, doc_query_1.registerQueryDocumentation)('provenance', {
|
|
588
|
+
name: 'Provenance Query',
|
|
589
|
+
type: 'active',
|
|
590
|
+
shortDescription: 'Calculate the provenance of a given variable, optionally restricted to its enveloping fdef',
|
|
591
|
+
functionName: provenance_query_executor_1.executeProvenanceQuery.name,
|
|
592
|
+
functionFile: '../queries/catalog/provenance-query/provenance-query-executor.ts',
|
|
593
|
+
buildExplanation: async (shell) => {
|
|
594
|
+
const exampleCode = 'x <- 1\ny <- 2\nz <- 3\nx';
|
|
595
|
+
const criterion = '4@x';
|
|
596
|
+
return `
|
|
597
|
+
Given a [slicing criterion](${doc_files_1.FlowrWikiBaseRef}/Terminology#slicing-criterion), flowR will return the provenance
|
|
598
|
+
of the given program element (i.e., all related vertices in a non-interprocedural and non-context sensitive backward slice).
|
|
599
|
+
|
|
600
|
+
To exemplify the capabilities, consider the following code:
|
|
601
|
+
${(0, doc_code_1.codeBlock)('r', exampleCode)}
|
|
602
|
+
If you are interested in the provenance of the \`x\` in the last line you can use:
|
|
603
|
+
|
|
604
|
+
${await (0, doc_query_1.showQuery)(shell, exampleCode, [{
|
|
605
|
+
type: 'provenance',
|
|
606
|
+
criterion
|
|
607
|
+
}], { showCode: false, shorthand: (0, doc_query_1.sliceQueryShorthand)([criterion], (0, doc_escape_1.escapeNewline)(exampleCode)) })}
|
|
608
|
+
`;
|
|
609
|
+
}
|
|
610
|
+
});
|
|
586
611
|
(0, doc_query_1.registerQueryDocumentation)('dependencies', {
|
|
587
612
|
name: 'Dependencies Query',
|
|
588
613
|
type: 'active',
|
package/linter/linter-rules.d.ts
CHANGED
|
@@ -277,10 +277,33 @@ export declare const LintingRules: {
|
|
|
277
277
|
readonly certainty: import("./linter-format").LintingRuleCertainty.BestEffort;
|
|
278
278
|
readonly tags: readonly [import("./linter-tags").LintingRuleTag.Smell, import("./linter-tags").LintingRuleTag.Readability];
|
|
279
279
|
readonly defaultConfig: {
|
|
280
|
-
readonly loopyFunctions: Set<import("../dataflow/environments/built-in").BuiltInProcName>;
|
|
280
|
+
readonly loopyFunctions: Set<import("../dataflow/environments/built-in-proc-name").BuiltInProcName>;
|
|
281
281
|
};
|
|
282
282
|
};
|
|
283
283
|
};
|
|
284
|
+
readonly 'stop-call': {
|
|
285
|
+
readonly createSearch: () => import("../search/flowr-search-builder").FlowrSearchBuilder<"get", ["filter"], import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, Promise<import("../search/flowr-search").FlowrSearchElements<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, [] | import("../search/flowr-search").FlowrSearchElement<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>>;
|
|
286
|
+
readonly processSearchResult: (elements: import("../search/flowr-search").FlowrSearchElements<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../search/flowr-search").FlowrSearchElement<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>, _config: import("../util/objects").MergeableRecord, { dataflow, analyzer }: {
|
|
287
|
+
normalize: import("../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
|
|
288
|
+
dataflow: import("../dataflow/info").DataflowInformation;
|
|
289
|
+
cfg: import("../control-flow/control-flow-graph").ControlFlowInformation;
|
|
290
|
+
analyzer: import("../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider;
|
|
291
|
+
}) => {
|
|
292
|
+
results: import("ts-essentials").Writable<import("./rules/stop-with-call-arg").StopWithCallResult>[];
|
|
293
|
+
'.meta': import("./rules/stop-with-call-arg").StopWithCallMetadata;
|
|
294
|
+
};
|
|
295
|
+
readonly prettyPrint: {
|
|
296
|
+
readonly query: (result: import("./rules/stop-with-call-arg").StopWithCallResult) => string;
|
|
297
|
+
readonly full: (result: import("./rules/stop-with-call-arg").StopWithCallResult) => string;
|
|
298
|
+
};
|
|
299
|
+
readonly info: {
|
|
300
|
+
readonly name: "Stop without call.=False argument";
|
|
301
|
+
readonly tags: readonly [import("./linter-tags").LintingRuleTag.Smell];
|
|
302
|
+
readonly certainty: import("./linter-format").LintingRuleCertainty.BestEffort;
|
|
303
|
+
readonly description: "Checks whether stop calls without call. argument set to FALSE are used.";
|
|
304
|
+
readonly defaultConfig: {};
|
|
305
|
+
};
|
|
306
|
+
};
|
|
284
307
|
};
|
|
285
308
|
export type LintingRuleNames = keyof typeof LintingRules;
|
|
286
309
|
export type LintingRuleMetadata<Name extends LintingRuleNames> = typeof LintingRules[Name] extends LintingRule<infer _Result, infer Metadata, infer _Config, infer _Info, infer _Elements> ? Metadata : never;
|
package/linter/linter-rules.js
CHANGED
|
@@ -11,6 +11,7 @@ const naming_convention_1 = require("./rules/naming-convention");
|
|
|
11
11
|
const dataframe_access_validation_1 = require("./rules/dataframe-access-validation");
|
|
12
12
|
const useless_loop_1 = require("./rules/useless-loop");
|
|
13
13
|
const network_functions_1 = require("./rules/network-functions");
|
|
14
|
+
const stop_with_call_arg_1 = require("./rules/stop-with-call-arg");
|
|
14
15
|
/**
|
|
15
16
|
* The registry of currently supported linting rules.
|
|
16
17
|
* A linting rule can be executed on a dataflow pipeline result using {@link executeLintingRule}.
|
|
@@ -25,6 +26,7 @@ exports.LintingRules = {
|
|
|
25
26
|
'network-functions': network_functions_1.NETWORK_FUNCTIONS,
|
|
26
27
|
'dataframe-access-validation': dataframe_access_validation_1.DATA_FRAME_ACCESS_VALIDATION,
|
|
27
28
|
'dead-code': dead_code_1.DEAD_CODE,
|
|
28
|
-
'useless-loop': useless_loop_1.USELESS_LOOP
|
|
29
|
+
'useless-loop': useless_loop_1.USELESS_LOOP,
|
|
30
|
+
'stop-call': stop_with_call_arg_1.STOP_WITH_CALL_ARG
|
|
29
31
|
};
|
|
30
32
|
//# sourceMappingURL=linter-rules.js.map
|
|
@@ -19,7 +19,7 @@ const vertex_1 = require("../../dataflow/graph/vertex");
|
|
|
19
19
|
const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
20
20
|
const r_value_1 = require("../../dataflow/eval/values/r-value");
|
|
21
21
|
const info_1 = require("../../dataflow/info");
|
|
22
|
-
const
|
|
22
|
+
const built_in_proc_name_1 = require("../../dataflow/environments/built-in-proc-name");
|
|
23
23
|
exports.SEEDED_RANDOMNESS = {
|
|
24
24
|
createSearch: (config) => flowr_search_builder_1.Q.all().filter(vertex_1.VertexType.FunctionCall)
|
|
25
25
|
.with(search_enrichers_1.Enrichment.CallTargets, { onlyBuiltin: true })
|
|
@@ -140,7 +140,7 @@ exports.SEEDED_RANDOMNESS = {
|
|
|
140
140
|
}
|
|
141
141
|
};
|
|
142
142
|
function getDefaultAssignments() {
|
|
143
|
-
return default_builtin_config_1.DefaultBuiltinConfig.filter(b => b.type === 'function' && (b.processor ===
|
|
143
|
+
return default_builtin_config_1.DefaultBuiltinConfig.filter(b => b.type === 'function' && (b.processor === built_in_proc_name_1.BuiltInProcName.Assignment || b.processor === built_in_proc_name_1.BuiltInProcName.AssignmentLike));
|
|
144
144
|
}
|
|
145
145
|
function isConstantArgument(graph, call, argIndex, ctx) {
|
|
146
146
|
const args = call.args.filter(arg => arg !== r_function_call_1.EmptyArgument && !arg.name).map(graph_1.FunctionArgument.getReference);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type LintingResult, LintingRuleCertainty } from '../linter-format';
|
|
2
|
+
import { SourceLocation } from '../../util/range';
|
|
3
|
+
import type { MergeableRecord } from '../../util/objects';
|
|
4
|
+
import { LintingRuleTag } from '../linter-tags';
|
|
5
|
+
import type { Writable } from 'ts-essentials';
|
|
6
|
+
export interface StopWithCallResult extends LintingResult {
|
|
7
|
+
readonly loc: SourceLocation;
|
|
8
|
+
}
|
|
9
|
+
export type StopWithCallConfig = MergeableRecord;
|
|
10
|
+
export interface StopWithCallMetadata extends MergeableRecord {
|
|
11
|
+
consideredNodes: number;
|
|
12
|
+
}
|
|
13
|
+
export declare const STOP_WITH_CALL_ARG: {
|
|
14
|
+
readonly createSearch: () => import("../../search/flowr-search-builder").FlowrSearchBuilder<"get", ["filter"], import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, Promise<import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, [] | import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>>;
|
|
15
|
+
readonly processSearchResult: (elements: import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>, _config: MergeableRecord, { dataflow, analyzer }: {
|
|
16
|
+
normalize: import("../../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
|
|
17
|
+
dataflow: import("../../dataflow/info").DataflowInformation;
|
|
18
|
+
cfg: import("../../control-flow/control-flow-graph").ControlFlowInformation;
|
|
19
|
+
analyzer: import("../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider;
|
|
20
|
+
}) => {
|
|
21
|
+
results: Writable<StopWithCallResult>[];
|
|
22
|
+
'.meta': StopWithCallMetadata;
|
|
23
|
+
};
|
|
24
|
+
readonly prettyPrint: {
|
|
25
|
+
readonly query: (result: StopWithCallResult) => string;
|
|
26
|
+
readonly full: (result: StopWithCallResult) => string;
|
|
27
|
+
};
|
|
28
|
+
readonly info: {
|
|
29
|
+
readonly name: "Stop without call.=False argument";
|
|
30
|
+
readonly tags: readonly [LintingRuleTag.Smell];
|
|
31
|
+
readonly certainty: LintingRuleCertainty.BestEffort;
|
|
32
|
+
readonly description: "Checks whether stop calls without call. argument set to FALSE are used.";
|
|
33
|
+
readonly defaultConfig: {};
|
|
34
|
+
};
|
|
35
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.STOP_WITH_CALL_ARG = void 0;
|
|
4
|
+
const linter_format_1 = require("../linter-format");
|
|
5
|
+
const range_1 = require("../../util/range");
|
|
6
|
+
const flowr_search_builder_1 = require("../../search/flowr-search-builder");
|
|
7
|
+
const linter_tags_1 = require("../linter-tags");
|
|
8
|
+
const assert_1 = require("../../util/assert");
|
|
9
|
+
const vertex_1 = require("../../dataflow/graph/vertex");
|
|
10
|
+
const alias_tracking_1 = require("../../dataflow/eval/resolve/alias-tracking");
|
|
11
|
+
const dfg_get_origin_1 = require("../../dataflow/origin/dfg-get-origin");
|
|
12
|
+
const linker_1 = require("../../dataflow/internal/linker");
|
|
13
|
+
const general_1 = require("../../dataflow/eval/values/general");
|
|
14
|
+
exports.STOP_WITH_CALL_ARG = {
|
|
15
|
+
createSearch: () => flowr_search_builder_1.Q.var('stop').filter(vertex_1.VertexType.FunctionCall),
|
|
16
|
+
processSearchResult: (elements, _config, { dataflow, analyzer }) => {
|
|
17
|
+
const meta = {
|
|
18
|
+
consideredNodes: 0
|
|
19
|
+
};
|
|
20
|
+
return {
|
|
21
|
+
results: elements.getElements()
|
|
22
|
+
.filter(element => {
|
|
23
|
+
//only built-in functions
|
|
24
|
+
const origins = (0, dfg_get_origin_1.getOriginInDfg)(dataflow.graph, element.node.info.id);
|
|
25
|
+
if ((0, assert_1.isNotUndefined)(origins)) {
|
|
26
|
+
const builtIn = origins.every(e => e.type === 3 /* OriginType.BuiltInFunctionOrigin */);
|
|
27
|
+
if (!builtIn) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const fCall = dataflow.graph.getVertex(element.node.info.id);
|
|
32
|
+
//filter out function calls with argument "call." set to false
|
|
33
|
+
const stopParamMap = {
|
|
34
|
+
'...': '...',
|
|
35
|
+
'call.': 'call.',
|
|
36
|
+
'domain': 'domain'
|
|
37
|
+
};
|
|
38
|
+
const mapping = (0, linker_1.pMatch)(fCall.args, stopParamMap);
|
|
39
|
+
const mappedToStop = mapping.get('call.') ?? [];
|
|
40
|
+
for (const argId of mappedToStop) {
|
|
41
|
+
const res = (0, alias_tracking_1.resolveIdToValue)(argId, { graph: dataflow.graph, environment: fCall.environment, ctx: analyzer.inspectContext() });
|
|
42
|
+
const values = (0, general_1.valueSetGuard)(res);
|
|
43
|
+
if (values?.type === 'set' && values.elements.length !== 0) {
|
|
44
|
+
if (values.elements[0].type === 'logical') {
|
|
45
|
+
return values.elements[0].value;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return true;
|
|
50
|
+
})
|
|
51
|
+
.map(element => ({
|
|
52
|
+
certainty: linter_format_1.LintingResultCertainty.Uncertain,
|
|
53
|
+
involvedId: element.node.info.id,
|
|
54
|
+
loc: range_1.SourceLocation.fromNode(element.node)
|
|
55
|
+
}))
|
|
56
|
+
.filter(element => (0, assert_1.isNotUndefined)(element.loc)),
|
|
57
|
+
'.meta': meta
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
prettyPrint: {
|
|
61
|
+
[linter_format_1.LintingPrettyPrintContext.Query]: result => `Code at ${range_1.SourceLocation.format(result.loc)}`,
|
|
62
|
+
[linter_format_1.LintingPrettyPrintContext.Full]: result => `Code at ${range_1.SourceLocation.format(result.loc)} does call stop without setting call. to FALSE`,
|
|
63
|
+
},
|
|
64
|
+
info: {
|
|
65
|
+
name: 'Stop without call.=False argument',
|
|
66
|
+
tags: [linter_tags_1.LintingRuleTag.Smell],
|
|
67
|
+
certainty: linter_format_1.LintingRuleCertainty.BestEffort,
|
|
68
|
+
description: 'Checks whether stop calls without call. argument set to FALSE are used.',
|
|
69
|
+
defaultConfig: {}
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
//# sourceMappingURL=stop-with-call-arg.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { BuiltInProcName } from '../../dataflow/environments/built-in';
|
|
2
1
|
import type { MergeableRecord } from '../../util/objects';
|
|
3
2
|
import { SourceLocation } from '../../util/range';
|
|
4
3
|
import { type LintingResult, LintingResultCertainty, LintingRuleCertainty } from '../linter-format';
|
|
5
4
|
import { LintingRuleTag } from '../linter-tags';
|
|
5
|
+
import type { BuiltInProcName } from '../../dataflow/environments/built-in-proc-name';
|
|
6
6
|
export interface UselessLoopResult extends LintingResult {
|
|
7
7
|
name: string;
|
|
8
8
|
loc: SourceLocation;
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@ import type { CfgSimplificationPassName } from '../../control-flow/cfg-simplific
|
|
|
9
9
|
import type { ControlFlowInformation } from '../../control-flow/control-flow-graph';
|
|
10
10
|
import type { CfgKind } from '../cfg-kind';
|
|
11
11
|
import type { FlowrAnalyzerContext } from '../context/flowr-analyzer-context';
|
|
12
|
-
import
|
|
12
|
+
import { CallGraph } from '../../dataflow/graph/call-graph';
|
|
13
13
|
interface FlowrAnalyzerCacheOptions<Parser extends KnownParser> {
|
|
14
14
|
parser: Parser;
|
|
15
15
|
context: FlowrAnalyzerContext;
|
|
@@ -141,7 +141,7 @@ class FlowrAnalyzerCache extends flowr_cache_1.FlowrCache {
|
|
|
141
141
|
*/
|
|
142
142
|
async callGraph(force) {
|
|
143
143
|
if (!this.callGraphCache || force) {
|
|
144
|
-
this.callGraphCache =
|
|
144
|
+
this.callGraphCache = call_graph_1.CallGraph.compute((await this.dataflow(force)).graph);
|
|
145
145
|
}
|
|
146
146
|
return this.callGraphCache;
|
|
147
147
|
}
|
|
@@ -56,6 +56,9 @@ export declare class FlowrAnalyzerBuilder {
|
|
|
56
56
|
* @param config - The new configuration.
|
|
57
57
|
*/
|
|
58
58
|
setConfig(config: FlowrConfig): this;
|
|
59
|
+
/**
|
|
60
|
+
* Set a specific value in the configuration used by the resulting analyzer.
|
|
61
|
+
*/
|
|
59
62
|
configure<K extends AutocompletablePaths<FlowrConfig>>(key: K, value: PathValue<FlowrConfig, K>): this;
|
|
60
63
|
/**
|
|
61
64
|
* Set the parser instance used by the analyzer.
|
|
@@ -15,8 +15,8 @@ import type { RAnalysisRequest } from './context/flowr-analyzer-files-context';
|
|
|
15
15
|
import type { RParseRequest, RParseRequestFromFile } from '../r-bridge/retriever';
|
|
16
16
|
import { fileProtocol } from '../r-bridge/retriever';
|
|
17
17
|
import type { FlowrFileProvider } from './context/flowr-file';
|
|
18
|
-
import type { CallGraph } from '../dataflow/graph/call-graph';
|
|
19
18
|
import type { Tree } from 'web-tree-sitter';
|
|
19
|
+
import type { CallGraph } from '../dataflow/graph/call-graph';
|
|
20
20
|
/**
|
|
21
21
|
* Extends the {@link ReadonlyFlowrAnalysisProvider} with methods that allow modifying the analyzer state.
|
|
22
22
|
*/
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.identifyLinkToNestedRelation = identifyLinkToNestedRelation;
|
|
4
|
-
const call_graph_1 = require("../../../dataflow/graph/call-graph");
|
|
5
4
|
const vertex_1 = require("../../../dataflow/graph/vertex");
|
|
6
5
|
const identifier_1 = require("../../../dataflow/environments/identifier");
|
|
6
|
+
const call_graph_1 = require("../../../dataflow/graph/call-graph");
|
|
7
7
|
/**
|
|
8
8
|
* **Please refer to {@link identifyLinkToRelation}.**
|
|
9
9
|
*
|
|
@@ -19,7 +19,7 @@ async function identifyLinkToNestedRelation(from, analyzer, { callName, ignoreIf
|
|
|
19
19
|
const test = callName instanceof RegExp ? (t) => callName.test(t) : callName;
|
|
20
20
|
const found = [];
|
|
21
21
|
const cg = await analyzer.callGraph();
|
|
22
|
-
const subCg =
|
|
22
|
+
const subCg = call_graph_1.CallGraph.computeSubCallGraph(cg, new Set([from]));
|
|
23
23
|
for (const [, t] of subCg.vertices(true)) {
|
|
24
24
|
if (!(0, vertex_1.isFunctionCallVertex)(t)) {
|
|
25
25
|
continue;
|
|
@@ -2,7 +2,7 @@ import type { BaseQueryFormat, BaseQueryResult } from '../../base-query-format';
|
|
|
2
2
|
import { executeCallGraphQuery } from './call-graph-query-executor';
|
|
3
3
|
import Joi from 'joi';
|
|
4
4
|
import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
5
|
-
import
|
|
5
|
+
import { CallGraph } from '../../../dataflow/graph/call-graph';
|
|
6
6
|
/**
|
|
7
7
|
* Computes the Call Graph of the analyzed project.
|
|
8
8
|
*/
|
|
@@ -7,14 +7,14 @@ exports.CallGraphQueryDefinition = void 0;
|
|
|
7
7
|
const call_graph_query_executor_1 = require("./call-graph-query-executor");
|
|
8
8
|
const ansi_1 = require("../../../util/text/ansi");
|
|
9
9
|
const time_1 = require("../../../util/text/time");
|
|
10
|
-
const dfg_1 = require("../../../util/mermaid/dfg");
|
|
11
10
|
const joi_1 = __importDefault(require("joi"));
|
|
11
|
+
const call_graph_1 = require("../../../dataflow/graph/call-graph");
|
|
12
12
|
exports.CallGraphQueryDefinition = {
|
|
13
13
|
executor: call_graph_query_executor_1.executeCallGraphQuery,
|
|
14
14
|
asciiSummarizer: (formatter, _analyzer, queryResults, result) => {
|
|
15
15
|
const out = queryResults;
|
|
16
16
|
result.push(`Query: ${(0, ansi_1.bold)('call-graph', formatter)} (${(0, time_1.printAsMs)(out['.meta'].timing, 0)})`);
|
|
17
|
-
result.push(` ╰ [Call Graph](${
|
|
17
|
+
result.push(` ╰ [Call Graph](${call_graph_1.CallGraph.visualize.mermaid.url(out.graph)})`);
|
|
18
18
|
return true;
|
|
19
19
|
},
|
|
20
20
|
schema: joi_1.default.object({
|
|
@@ -7,8 +7,8 @@ exports.ClusterQueryDefinition = void 0;
|
|
|
7
7
|
const ansi_1 = require("../../../util/text/ansi");
|
|
8
8
|
const joi_1 = __importDefault(require("joi"));
|
|
9
9
|
const cluster_query_executor_1 = require("./cluster-query-executor");
|
|
10
|
-
const dfg_1 = require("../../../util/mermaid/dfg");
|
|
11
10
|
const query_print_1 = require("../../query-print");
|
|
11
|
+
const df_helper_1 = require("../../../dataflow/graph/df-helper");
|
|
12
12
|
exports.ClusterQueryDefinition = {
|
|
13
13
|
executor: cluster_query_executor_1.executeDataflowClusterQuery,
|
|
14
14
|
asciiSummarizer: async (formatter, analyzer, queryResults, result) => {
|
|
@@ -19,7 +19,7 @@ exports.ClusterQueryDefinition = {
|
|
|
19
19
|
const unknownSideEffects = cluster.hasUnknownSideEffects ? '(has unknown side effect)' : '';
|
|
20
20
|
let suffix = '';
|
|
21
21
|
if (formatter === ansi_1.markdownFormatter) {
|
|
22
|
-
suffix = `([marked](${
|
|
22
|
+
suffix = `([marked](${df_helper_1.Dataflow.visualize.mermaid.url((await analyzer.dataflow()).graph, false, new Set(cluster.members))}))`;
|
|
23
23
|
}
|
|
24
24
|
result.push(` ╰ ${unknownSideEffects} {${(0, query_print_1.summarizeIdsIfTooLong)(formatter, cluster.members)}} ${suffix}`);
|
|
25
25
|
}
|
|
@@ -7,14 +7,14 @@ exports.DataflowLensQueryDefinition = void 0;
|
|
|
7
7
|
const dataflow_lens_query_executor_1 = require("./dataflow-lens-query-executor");
|
|
8
8
|
const ansi_1 = require("../../../util/text/ansi");
|
|
9
9
|
const time_1 = require("../../../util/text/time");
|
|
10
|
-
const dfg_1 = require("../../../util/mermaid/dfg");
|
|
11
10
|
const joi_1 = __importDefault(require("joi"));
|
|
11
|
+
const df_helper_1 = require("../../../dataflow/graph/df-helper");
|
|
12
12
|
exports.DataflowLensQueryDefinition = {
|
|
13
13
|
executor: dataflow_lens_query_executor_1.executeDataflowLensQuery,
|
|
14
14
|
asciiSummarizer: (formatter, _analyzer, queryResults, result) => {
|
|
15
15
|
const out = queryResults;
|
|
16
16
|
result.push(`Query: ${(0, ansi_1.bold)('dataflow-lens', formatter)} (${(0, time_1.printAsMs)(out['.meta'].timing, 0)})`);
|
|
17
|
-
result.push(` ╰ [Simplified Graph](${
|
|
17
|
+
result.push(` ╰ [Simplified Graph](${df_helper_1.Dataflow.visualize.mermaid.url(out.simplifiedGraph, false, undefined, true)})`);
|
|
18
18
|
return true;
|
|
19
19
|
},
|
|
20
20
|
schema: joi_1.default.object({
|
|
@@ -7,14 +7,14 @@ exports.DataflowQueryDefinition = void 0;
|
|
|
7
7
|
const dataflow_query_executor_1 = require("./dataflow-query-executor");
|
|
8
8
|
const ansi_1 = require("../../../util/text/ansi");
|
|
9
9
|
const time_1 = require("../../../util/text/time");
|
|
10
|
-
const dfg_1 = require("../../../util/mermaid/dfg");
|
|
11
10
|
const joi_1 = __importDefault(require("joi"));
|
|
11
|
+
const df_helper_1 = require("../../../dataflow/graph/df-helper");
|
|
12
12
|
exports.DataflowQueryDefinition = {
|
|
13
13
|
executor: dataflow_query_executor_1.executeDataflowQuery,
|
|
14
14
|
asciiSummarizer: (formatter, _analyzer, queryResults, result) => {
|
|
15
15
|
const out = queryResults;
|
|
16
16
|
result.push(`Query: ${(0, ansi_1.bold)('dataflow', formatter)} (${(0, time_1.printAsMs)(out['.meta'].timing, 0)})`);
|
|
17
|
-
result.push(` ╰ [Dataflow Graph](${
|
|
17
|
+
result.push(` ╰ [Dataflow Graph](${df_helper_1.Dataflow.visualize.mermaid.url(out.graph)})`);
|
|
18
18
|
return true;
|
|
19
19
|
},
|
|
20
20
|
schema: joi_1.default.object({
|
|
@@ -39,14 +39,13 @@ async function executeDfShapeQuery({ analyzer }, queries) {
|
|
|
39
39
|
continue;
|
|
40
40
|
}
|
|
41
41
|
try {
|
|
42
|
-
const nodeId =
|
|
42
|
+
const nodeId = parse_1.SingleSlicingCriterion.parse(query.criterion, ast.idMap);
|
|
43
43
|
const node = ast.idMap.get(nodeId);
|
|
44
44
|
const value = inference.getAbstractValue(node?.info.id);
|
|
45
45
|
result.set(query.criterion, value);
|
|
46
46
|
}
|
|
47
47
|
catch (e) {
|
|
48
48
|
console.error(e instanceof Error ? e.message : e);
|
|
49
|
-
continue;
|
|
50
49
|
}
|
|
51
50
|
}
|
|
52
51
|
return {
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.executeDoesCallQuery = executeDoesCallQuery;
|
|
4
4
|
const log_1 = require("../../../util/log");
|
|
5
5
|
const node_id_1 = require("../../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
6
|
-
const parse_1 = require("../../../slicing/criterion/parse");
|
|
7
6
|
const identifier_1 = require("../../../dataflow/environments/identifier");
|
|
7
|
+
const parse_1 = require("../../../slicing/criterion/parse");
|
|
8
8
|
/**
|
|
9
9
|
* Execute does call queries on the given analyzer.
|
|
10
10
|
*/
|
|
@@ -19,7 +19,7 @@ async function executeDoesCallQuery({ analyzer }, queries) {
|
|
|
19
19
|
log_1.log.warn(`Duplicate query id '${id}' in does-call queries, SKIP.`);
|
|
20
20
|
continue;
|
|
21
21
|
}
|
|
22
|
-
const nodeId =
|
|
22
|
+
const nodeId = parse_1.SingleSlicingCriterion.tryParse(query.call, idMap);
|
|
23
23
|
if (!nodeId) {
|
|
24
24
|
results[id] = false;
|
|
25
25
|
continue;
|