@eagleoutice/flowr 2.9.9 → 2.9.11
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 +57 -54
- package/abstract-interpretation/absint-visitor.d.ts +16 -14
- package/abstract-interpretation/absint-visitor.js +93 -47
- package/abstract-interpretation/data-frame/mappers/arguments.d.ts +1 -1
- package/abstract-interpretation/data-frame/mappers/arguments.js +2 -2
- package/abstract-interpretation/data-frame/shape-inference.d.ts +2 -5
- package/abstract-interpretation/data-frame/shape-inference.js +4 -5
- package/abstract-interpretation/domains/abstract-domain.d.ts +4 -4
- package/abstract-interpretation/domains/abstract-domain.js +8 -8
- package/abstract-interpretation/domains/mapped-abstract-domain.d.ts +12 -5
- package/abstract-interpretation/domains/mapped-abstract-domain.js +47 -23
- package/abstract-interpretation/domains/set-range-domain.js +1 -1
- package/abstract-interpretation/domains/state-abstract-domain.d.ts +30 -1
- package/abstract-interpretation/domains/state-abstract-domain.js +130 -4
- package/abstract-interpretation/normalized-ast-fold.d.ts +2 -2
- package/abstract-interpretation/normalized-ast-fold.js +4 -3
- package/benchmark/slicer.js +5 -5
- package/benchmark/summarizer/first-phase/process.js +4 -4
- package/cli/repl/commands/repl-normalize.js +2 -2
- package/cli/repl/core.js +2 -2
- package/config.js +1 -1
- package/control-flow/cfg-simplification.d.ts +1 -0
- package/control-flow/cfg-simplification.js +1 -0
- package/control-flow/control-flow-graph.d.ts +1 -1
- package/control-flow/control-flow-graph.js +1 -2
- package/control-flow/extract-cfg.js +34 -15
- package/control-flow/semantic-cfg-guided-visitor.js +1 -0
- package/dataflow/cluster.js +1 -1
- package/dataflow/environments/built-in.d.ts +6 -15
- package/dataflow/environments/built-in.js +25 -33
- package/dataflow/environments/default-builtin-config.d.ts +4 -8
- package/dataflow/environments/default-builtin-config.js +8 -5
- package/dataflow/environments/reference-to-maybe.d.ts +8 -0
- package/dataflow/environments/reference-to-maybe.js +46 -3
- package/dataflow/eval/resolve/alias-tracking.d.ts +2 -2
- package/dataflow/eval/resolve/alias-tracking.js +6 -6
- package/dataflow/eval/resolve/resolve.js +12 -10
- package/dataflow/fn/exceptions-of-function.d.ts +1 -1
- package/dataflow/fn/exceptions-of-function.js +2 -1
- package/dataflow/graph/call-graph.d.ts +1 -1
- package/dataflow/graph/call-graph.js +4 -3
- package/dataflow/graph/dataflowgraph-builder.d.ts +1 -1
- package/dataflow/graph/dataflowgraph-builder.js +21 -21
- package/dataflow/graph/graph.d.ts +5 -5
- package/dataflow/graph/graph.js +36 -32
- package/dataflow/graph/unknown-side-effect.js +3 -1
- package/dataflow/info.d.ts +4 -0
- package/dataflow/info.js +2 -2
- package/dataflow/internal/linker.d.ts +4 -4
- package/dataflow/internal/linker.js +59 -33
- package/dataflow/internal/process/functions/call/argument/make-argument.d.ts +2 -1
- package/dataflow/internal/process/functions/call/argument/make-argument.js +3 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-access.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +3 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +6 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +15 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +3 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +4 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-local.js +3 -3
- 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 +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +7 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +22 -11
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +22 -19
- package/dataflow/internal/process/functions/call/common.d.ts +1 -1
- package/dataflow/internal/process/functions/call/common.js +43 -35
- package/dataflow/internal/process/functions/call/known-call-handling.js +0 -2
- package/dataflow/internal/process/functions/process-argument.d.ts +1 -1
- package/dataflow/internal/process/functions/process-argument.js +3 -3
- package/dataflow/internal/process/functions/process-parameter.js +2 -2
- package/dataflow/origin/dfg-get-origin.d.ts +1 -1
- package/dataflow/origin/dfg-get-origin.js +2 -2
- package/documentation/doc-util/doc-types.js +1 -1
- package/documentation/wiki-absint.js +7 -8
- package/documentation/wiki-cfg.js +3 -3
- package/documentation/wiki-mk/doc-context.d.ts +8 -0
- package/documentation/wiki-mk/doc-context.js +4 -0
- package/documentation/wiki-normalized-ast.d.ts +1 -1
- package/documentation/wiki-normalized-ast.js +9 -6
- package/linter/linter-format.d.ts +10 -0
- package/linter/linter-format.js +15 -0
- package/linter/rules/absolute-path.js +3 -3
- package/linter/rules/dead-code.js +1 -1
- package/linter/rules/file-path-validity.js +1 -1
- package/linter/rules/seeded-randomness.js +1 -1
- package/linter/rules/unused-definition.js +1 -1
- package/package.json +7 -7
- package/project/plugins/file-plugins/files/flowr-description-file.d.ts +9 -0
- package/project/plugins/file-plugins/files/flowr-description-file.js +12 -0
- package/queries/catalog/call-context-query/call-context-query-executor.js +1 -1
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.d.ts +1 -1
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +4 -5
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +2 -1
- package/queries/catalog/dependencies-query/dependencies-query-format.js +6 -5
- package/queries/catalog/df-shape-query/df-shape-query-format.d.ts +1 -1
- package/queries/catalog/df-shape-query/df-shape-query-format.js +3 -3
- package/queries/catalog/does-call-query/does-call-query-executor.js +3 -3
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.d.ts +1 -1
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +2 -2
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +1 -1
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +1 -1
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.d.ts +1 -1
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.js +1 -1
- package/queries/query-print.d.ts +1 -1
- package/queries/query-print.js +4 -3
- package/r-bridge/lang-4.x/ast/model/model.d.ts +151 -4
- package/r-bridge/lang-4.x/ast/model/model.js +249 -0
- package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.d.ts +11 -1
- package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.js +13 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +19 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.js +26 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +36 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.js +48 -13
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +16 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.js +21 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +11 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-break.js +14 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +8 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.js +11 -5
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +23 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.js +32 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +11 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.js +14 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +19 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +26 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +11 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.js +14 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +11 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.js +14 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +12 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.js +14 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +20 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-logical.js +26 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +12 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-next.js +14 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +8 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-number.js +11 -5
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +17 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.js +22 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +16 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.js +22 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-project.d.ts +45 -8
- package/r-bridge/lang-4.x/ast/model/nodes/r-project.js +57 -16
- package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +12 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.js +14 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +15 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.js +21 -6
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +21 -6
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.js +22 -5
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +16 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.js +21 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +11 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.js +14 -0
- package/r-bridge/lang-4.x/ast/model/processing/decorate.js +23 -17
- package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +39 -2
- package/r-bridge/lang-4.x/ast/model/processing/node-id.js +52 -9
- package/r-bridge/lang-4.x/ast/model/processing/role.d.ts +18 -17
- package/r-bridge/lang-4.x/ast/model/processing/visitor.d.ts +8 -7
- package/r-bridge/lang-4.x/ast/model/processing/visitor.js +6 -13
- package/r-bridge/lang-4.x/ast/parser/json/parser.d.ts +1 -1
- package/r-bridge/lang-4.x/ast/parser/json/parser.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/expression/normalize-expression.js +4 -2
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-number.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-string.js +2 -2
- package/r-bridge/lang-4.x/convert-values.d.ts +14 -5
- package/r-bridge/lang-4.x/convert-values.js +76 -72
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +33 -15
- package/r-bridge/roxygen2/roxygen-parse.js +1 -1
- package/r-bridge/shell-executor.js +1 -1
- package/reconstruct/auto-select/magic-comments.js +4 -4
- package/reconstruct/reconstruct.js +2 -1
- package/search/search-executor/search-generators.js +2 -2
- package/slicing/criterion/filters/all-variables.js +1 -1
- package/slicing/criterion/parse.d.ts +1 -1
- package/slicing/criterion/parse.js +5 -3
- package/slicing/static/slice-call.d.ts +1 -1
- package/slicing/static/slice-call.js +2 -2
- package/statistics/features/supported/assignments/assignments.js +2 -2
- package/statistics/features/supported/control-flow/control-flow.js +2 -2
- package/statistics/features/supported/data-access/data-access.js +6 -5
- package/statistics/features/supported/defined-functions/defined-functions.js +9 -8
- package/statistics/features/supported/expression-list/statistics-expression-list.js +2 -2
- package/statistics/features/supported/loops/loops.js +6 -5
- package/statistics/features/supported/used-functions/used-functions.js +2 -2
- package/statistics/features/supported/variables/variables.js +8 -8
- package/util/mermaid/ast.js +3 -3
- package/util/mermaid/cfg.js +3 -4
- package/util/mermaid/dfg.d.ts +1 -1
- package/util/mermaid/dfg.js +13 -12
- package/util/simple-df/dfg-ascii.js +1 -1
- package/util/version.js +1 -1
- package/r-bridge/lang-4.x/ast/model/collect.d.ts +0 -10
- package/r-bridge/lang-4.x/ast/model/collect.js +0 -25
|
@@ -46,7 +46,7 @@ function sampleCollectNumbers(cfg, ast) {
|
|
|
46
46
|
/* obtain the corresponding node from the AST */
|
|
47
47
|
const node = ast.idMap.get(id);
|
|
48
48
|
/* if it is present and a number, add the parsed value to the list */
|
|
49
|
-
if (
|
|
49
|
+
if (r_number_1.RNumber.is(node)) {
|
|
50
50
|
numbers.push(node.content);
|
|
51
51
|
}
|
|
52
52
|
});
|
|
@@ -61,7 +61,7 @@ class CollectNumbersVisitor extends basic_cfg_guided_visitor_1.BasicCfgGuidedVis
|
|
|
61
61
|
}
|
|
62
62
|
onVisitNode(node) {
|
|
63
63
|
const astNode = this.ast.idMap.get(node);
|
|
64
|
-
if (
|
|
64
|
+
if (r_number_1.RNumber.is(astNode)) {
|
|
65
65
|
this.numbers.push(astNode.content);
|
|
66
66
|
}
|
|
67
67
|
super.onVisitNode(node);
|
|
@@ -89,7 +89,7 @@ class CollectNumbersDataflowVisitor extends dfg_cfg_guided_visitor_1.DataflowAwa
|
|
|
89
89
|
}
|
|
90
90
|
visitValue(node) {
|
|
91
91
|
const astNode = this.config.dfg.idMap?.get(node.id);
|
|
92
|
-
if (
|
|
92
|
+
if (r_number_1.RNumber.is(astNode)) {
|
|
93
93
|
this.numbers.push(astNode.content);
|
|
94
94
|
}
|
|
95
95
|
}
|
|
@@ -98,10 +98,18 @@ export interface GeneralDocContext {
|
|
|
98
98
|
*
|
|
99
99
|
* Creates a (markdown) link to the `myMethod` member of the `MyClass` class in the code base.
|
|
100
100
|
* @see {@link GeneralWikiContext#link|link} - for the underlying impl.
|
|
101
|
+
* @see {@link GeneralWikiContext#linkO|linkO} - to link using an object reference instead of a class and member name (e.g. for helper objects).
|
|
101
102
|
*/
|
|
102
103
|
linkM<T extends NamedPrototype>(cls: T, element: ProtoKeys<T> | StaticKeys<T>, fmt?: LinkFormat & {
|
|
103
104
|
hideClass?: boolean;
|
|
104
105
|
}, filter?: ElementFilter): string;
|
|
106
|
+
/**
|
|
107
|
+
* Generate a hyperlink to a type/element definition in the code base which is displayed using the type/element name as link text.
|
|
108
|
+
* This is similar to {@link GeneralDocContext#link}, but it uses the type/element name as link text, which is especially useful for types with long or complex names.
|
|
109
|
+
*/
|
|
110
|
+
linkO<T extends object & {
|
|
111
|
+
name: string;
|
|
112
|
+
}>(obj: T, element: keyof T, fmt?: LinkFormat, filter?: ElementFilter): string;
|
|
105
113
|
/**
|
|
106
114
|
* Generate a hyperlink to a type/element definition in the code base which is displayed using the file path as name
|
|
107
115
|
* @param element - The element to create a link for, the name can be qualified with `::` to specify the class.
|
|
@@ -67,6 +67,10 @@ function makeDocContextForTypes(shell, ...rootFolders) {
|
|
|
67
67
|
const fullName = `${className}${sep}${String(element)}`;
|
|
68
68
|
return this.link(fullName, fmt, filter);
|
|
69
69
|
},
|
|
70
|
+
linkO(obj, element, fmt, filter) {
|
|
71
|
+
const fullName = `${obj.name}::${String(element)}`;
|
|
72
|
+
return this.link(fullName, fmt, filter);
|
|
73
|
+
},
|
|
70
74
|
linkFile(element) {
|
|
71
75
|
return (0, doc_types_1.shortLinkFile)(getNameFromElementIdOrRef(element), info);
|
|
72
76
|
},
|
|
@@ -2,7 +2,7 @@ import { DefaultNormalizedAstFold } from '../abstract-interpretation/normalized-
|
|
|
2
2
|
import type { DocMakerArgs } from './wiki-mk/doc-maker';
|
|
3
3
|
import { DocMaker } from './wiki-mk/doc-maker';
|
|
4
4
|
import type { RNumber } from '../r-bridge/lang-4.x/ast/model/nodes/r-number';
|
|
5
|
-
import
|
|
5
|
+
import { RBinaryOp } from '../r-bridge/lang-4.x/ast/model/nodes/r-binary-op';
|
|
6
6
|
export declare class MyMathFold<Info> extends DefaultNormalizedAstFold<number, Info> {
|
|
7
7
|
constructor();
|
|
8
8
|
protected concat(a: number, b: number): number;
|
|
@@ -7,14 +7,15 @@ const doc_files_1 = require("./doc-util/doc-files");
|
|
|
7
7
|
const doc_cli_option_1 = require("./doc-util/doc-cli-option");
|
|
8
8
|
const doc_structure_1 = require("./doc-util/doc-structure");
|
|
9
9
|
const retriever_1 = require("../r-bridge/retriever");
|
|
10
|
-
const visitor_1 = require("../r-bridge/lang-4.x/ast/model/processing/visitor");
|
|
11
|
-
const collect_1 = require("../r-bridge/lang-4.x/ast/model/collect");
|
|
12
10
|
const normalized_ast_fold_1 = require("../abstract-interpretation/normalized-ast-fold");
|
|
13
11
|
const flowr_analyzer_1 = require("../project/flowr-analyzer");
|
|
14
12
|
const flowr_analyzer_builder_1 = require("../project/flowr-analyzer-builder");
|
|
15
13
|
const flowr_file_1 = require("../project/context/flowr-file");
|
|
16
14
|
const doc_maker_1 = require("./wiki-mk/doc-maker");
|
|
17
15
|
const roxygen_parse_1 = require("../r-bridge/roxygen2/roxygen-parse");
|
|
16
|
+
const r_binary_op_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-binary-op");
|
|
17
|
+
const model_1 = require("../r-bridge/lang-4.x/ast/model/model");
|
|
18
|
+
const r_project_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-project");
|
|
18
19
|
async function quickNormalizedAstMultipleFiles() {
|
|
19
20
|
const analyzer = await new flowr_analyzer_builder_1.FlowrAnalyzerBuilder()
|
|
20
21
|
.setEngine('tree-sitter')
|
|
@@ -77,7 +78,9 @@ offering the following benefits:
|
|
|
77
78
|
3. decorate the AST with additional information, e.g., parent relations and nesting information
|
|
78
79
|
|
|
79
80
|
In general, the mapping should be rather intuitive and focused primarily on the
|
|
80
|
-
syntactic structure of the program.
|
|
81
|
+
syntactic structure of the program. As with other types in flowR, you get corresponding helper objects.
|
|
82
|
+
So if you want to work with an \`RBinaryOp\` node, you can use the ${ctx.link(r_binary_op_1.RBinaryOp)} object to check whether a node is an \`RBinaryOp\` and to access its fields
|
|
83
|
+
(e.g., with ${ctx.linkO(r_binary_op_1.RBinaryOp, 'is')}).
|
|
81
84
|
Consider the following example which shows the normalized AST of the code
|
|
82
85
|
|
|
83
86
|
${(0, doc_code_1.codeBlock)('r', 'x <- 2 * 3 + 1')}
|
|
@@ -120,7 +123,7 @@ Most notably, the \`info\` field holds the \`id\` of the node, which is used to
|
|
|
120
123
|
|
|
121
124
|
In summary, we have the following types:
|
|
122
125
|
|
|
123
|
-
${(0, doc_structure_1.details)('Normalized AST Node Types', ctx.hierarchy('RNode', { collapseFromNesting: Number.MAX_VALUE }))}
|
|
126
|
+
${(0, doc_structure_1.details)('Normalized AST Node Types', ctx.hierarchy('RNode', { collapseFromNesting: Number.MAX_VALUE, ignoredTypes: ['Info', 'LogLevel'] }))}
|
|
124
127
|
|
|
125
128
|
The following segments intend to give you an overview of how to work with the normalized AST:
|
|
126
129
|
|
|
@@ -177,11 +180,11 @@ ${(0, doc_structure_1.block)({
|
|
|
177
180
|
|
|
178
181
|
### Visitors
|
|
179
182
|
|
|
180
|
-
If you want a simple visitor which traverses the AST, the ${ctx.
|
|
183
|
+
If you want a simple visitor which traverses the AST, the ${ctx.linkO(model_1.RNode, 'visitAst')} function is a good starting point.
|
|
181
184
|
You may specify functions to be called whenever you enter and exit a node during the traversal, and any
|
|
182
185
|
computation is to be done by side effects.
|
|
183
186
|
For example, if you want to collect all the \`id\`s present within a normalized (sub-)AST,
|
|
184
|
-
as it is done by the ${ctx.
|
|
187
|
+
as it is done by the ${ctx.linkO(model_1.RNode, 'collectAllIds')} (and corresponding ${ctx.linkO(model_1.RNode, 'collectAllIdsWithStop')}, ${ctx.linkO(r_project_1.RProject, 'collectAllIds')}, ...) function, you can use the following visitor:
|
|
185
188
|
|
|
186
189
|
${(0, doc_code_1.codeBlock)('ts', `
|
|
187
190
|
const ids = new Set<NodeId>();
|
|
@@ -155,10 +155,20 @@ export declare const LintingResults: {
|
|
|
155
155
|
* If the results represent an error, an empty set is returned.
|
|
156
156
|
*/
|
|
157
157
|
readonly allInvolvedIds: <L extends LintingRuleNames>(this: void, res: LintingResults<L> | undefined) => Set<NodeId>;
|
|
158
|
+
/**
|
|
159
|
+
* Gets all locations from the given linting results, i.e. the `loc` property of all results that have a location.
|
|
160
|
+
*/
|
|
161
|
+
readonly allLocations: <L extends LintingRuleNames>(this: void, res: LintingResults<L> | undefined) => SourceLocation[];
|
|
158
162
|
/**
|
|
159
163
|
* Stringifies the error contained in the given linting results error.
|
|
160
164
|
*/
|
|
161
165
|
readonly stringifyError: (this: void, { error }: LintingResultsError) => string;
|
|
166
|
+
/**
|
|
167
|
+
* Checks whether the given linting result has a location, i.e. whether it has a `loc` property.
|
|
168
|
+
*/
|
|
169
|
+
readonly hasLocation: <R extends LintingResult>(this: void, res: R) => res is R & {
|
|
170
|
+
loc: SourceLocation;
|
|
171
|
+
};
|
|
162
172
|
};
|
|
163
173
|
export declare enum LintingResultCertainty {
|
|
164
174
|
/**
|
package/linter/linter-format.js
CHANGED
|
@@ -42,6 +42,15 @@ exports.LintingResults = {
|
|
|
42
42
|
}
|
|
43
43
|
return new Set(res.results.flatMap(r => r.involvedId).filter(assert_1.isNotUndefined));
|
|
44
44
|
},
|
|
45
|
+
/**
|
|
46
|
+
* Gets all locations from the given linting results, i.e. the `loc` property of all results that have a location.
|
|
47
|
+
*/
|
|
48
|
+
allLocations(res) {
|
|
49
|
+
if (!res || exports.LintingResults.isError(res)) {
|
|
50
|
+
return [];
|
|
51
|
+
}
|
|
52
|
+
return res.results.filter(exports.LintingResults.hasLocation).map(r => r.loc);
|
|
53
|
+
},
|
|
45
54
|
/**
|
|
46
55
|
* Stringifies the error contained in the given linting results error.
|
|
47
56
|
*/
|
|
@@ -58,6 +67,12 @@ exports.LintingResults = {
|
|
|
58
67
|
catch {
|
|
59
68
|
return String(error);
|
|
60
69
|
}
|
|
70
|
+
},
|
|
71
|
+
/**
|
|
72
|
+
* Checks whether the given linting result has a location, i.e. whether it has a `loc` property.
|
|
73
|
+
*/
|
|
74
|
+
hasLocation(res) {
|
|
75
|
+
return 'loc' in res;
|
|
61
76
|
}
|
|
62
77
|
};
|
|
63
78
|
var LintingResultCertainty;
|
|
@@ -11,7 +11,6 @@ const range_1 = require("../../util/range");
|
|
|
11
11
|
const linter_tags_1 = require("../linter-tags");
|
|
12
12
|
const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
|
|
13
13
|
const strings_1 = require("../../util/text/strings");
|
|
14
|
-
const r_string_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-string");
|
|
15
14
|
const assert_1 = require("../../util/assert");
|
|
16
15
|
const read_functions_1 = require("../../queries/catalog/dependencies-query/function-info/read-functions");
|
|
17
16
|
const write_functions_1 = require("../../queries/catalog/dependencies-query/function-info/write-functions");
|
|
@@ -21,6 +20,7 @@ const vertex_1 = require("../../dataflow/graph/vertex");
|
|
|
21
20
|
const dependencies_query_format_1 = require("../../queries/catalog/dependencies-query/dependencies-query-format");
|
|
22
21
|
const resolve_argument_1 = require("../../dataflow/eval/resolve/resolve-argument");
|
|
23
22
|
const path_1 = __importDefault(require("path"));
|
|
23
|
+
const r_string_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-string");
|
|
24
24
|
function inferWd(file, wd) {
|
|
25
25
|
if (wd === '@script') {
|
|
26
26
|
// we can use the script path as the working directory
|
|
@@ -36,7 +36,7 @@ function inferWd(file, wd) {
|
|
|
36
36
|
}
|
|
37
37
|
// this can be improved by respecting raw strings and supporting more scenarios
|
|
38
38
|
function buildQuickFix(str, filePath, wd) {
|
|
39
|
-
if (!wd || !
|
|
39
|
+
if (!wd || !str || !r_string_1.RString.is(str)) {
|
|
40
40
|
return undefined;
|
|
41
41
|
}
|
|
42
42
|
return [{
|
|
@@ -102,7 +102,7 @@ exports.ABSOLUTE_PATH = {
|
|
|
102
102
|
metadata.totalConsidered++;
|
|
103
103
|
const node = element.node;
|
|
104
104
|
const wd = inferWd(node.info.file, config.useAsWd);
|
|
105
|
-
if (
|
|
105
|
+
if (r_string_1.RString.is(node)) {
|
|
106
106
|
if (node.content.str.length >= 3 && (0, strings_1.isAbsolutePath)(node.content.str, regex)) {
|
|
107
107
|
return [{
|
|
108
108
|
certainty: linter_format_1.LintingResultCertainty.Uncertain,
|
|
@@ -22,7 +22,7 @@ exports.DEAD_CODE = {
|
|
|
22
22
|
.filter(element => {
|
|
23
23
|
meta.consideredNodes++;
|
|
24
24
|
const cfgInformation = (0, search_enrichers_1.enrichmentContent)(element, search_enrichers_1.Enrichment.CfgInformation);
|
|
25
|
-
return
|
|
25
|
+
return element.node.info.role !== "el-g" /* RoleInParent.ExpressionListGrouping */ && !cfgInformation.isReachable;
|
|
26
26
|
})
|
|
27
27
|
.map(element => ({
|
|
28
28
|
certainty: linter_format_1.LintingResultCertainty.Certain,
|
|
@@ -28,7 +28,7 @@ exports.FILE_PATH_VALIDITY = {
|
|
|
28
28
|
const results = elements.enrichmentContent(search_enrichers_1.Enrichment.QueryData).queries['dependencies'];
|
|
29
29
|
return {
|
|
30
30
|
results: elements.getElements().flatMap(element => {
|
|
31
|
-
const matchingRead = results.read.find(r => r.nodeId
|
|
31
|
+
const matchingRead = results.read.find(r => r.nodeId === element.node.info.id);
|
|
32
32
|
if (!matchingRead) {
|
|
33
33
|
return [];
|
|
34
34
|
}
|
|
@@ -35,7 +35,7 @@ exports.SEEDED_RANDOMNESS = {
|
|
|
35
35
|
{ callName: getDefaultAssignments().flatMap(b => b.names).map(identifier_1.Identifier.getName), cascadeIf: () => cascade_action_1.CascadeAction.Continue }
|
|
36
36
|
]),
|
|
37
37
|
processSearchResult: (elements, config, { dataflow, analyzer }) => {
|
|
38
|
-
const assignmentProducers = new Set(config.randomnessProducers.filter(p => p.type
|
|
38
|
+
const assignmentProducers = new Set(config.randomnessProducers.filter(p => p.type === 'assignment').map(p => p.name));
|
|
39
39
|
const assignmentArgIndexes = new Map(getDefaultAssignments().flatMap(a => a.names.map(n => ([identifier_1.Identifier.getName(n), a.config?.swapSourceAndTarget ? 1 : 0]))));
|
|
40
40
|
const metadata = {
|
|
41
41
|
consumerCalls: 0,
|
|
@@ -19,7 +19,7 @@ function getDefinitionArguments(def, dfg) {
|
|
|
19
19
|
function buildQuickFix(variable, dfg, ast) {
|
|
20
20
|
// first we check whether any of the 'Defined by' targets have any obligations - if so, we can not remove the definition
|
|
21
21
|
// otherwise we can automatically remove the full definition!
|
|
22
|
-
if (variable.info.role === "
|
|
22
|
+
if (variable.info.role === "acc" /* RoleInParent.Accessed */ || variable.info.role === "for-var" /* RoleInParent.ForVariable */) {
|
|
23
23
|
// this is an access or a for variable, we can not remove it currently
|
|
24
24
|
return undefined;
|
|
25
25
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eagleoutice/flowr",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.11",
|
|
4
4
|
"description": "Static Dataflow Analyzer and Program Slicer for the R Programming Language",
|
|
5
5
|
"types": "dist/src/index.d.ts",
|
|
6
6
|
"repository": {
|
|
@@ -199,7 +199,7 @@
|
|
|
199
199
|
},
|
|
200
200
|
"dependencies": {
|
|
201
201
|
"@eagleoutice/tree-sitter-r": "^1.1.2",
|
|
202
|
-
"@jupyterlab/nbformat": "^4.5.
|
|
202
|
+
"@jupyterlab/nbformat": "^4.5.4",
|
|
203
203
|
"@xmldom/xmldom": "^0.9.7",
|
|
204
204
|
"clipboardy": "^4.0.0",
|
|
205
205
|
"command-line-args": "^6.0.1",
|
|
@@ -209,17 +209,17 @@
|
|
|
209
209
|
"gray-matter": "^4.0.3",
|
|
210
210
|
"joi": "^18.0.1",
|
|
211
211
|
"lz-string": "^1.5.0",
|
|
212
|
-
"n-readlines": "^1.0.
|
|
213
|
-
"n3": "^1.
|
|
212
|
+
"n-readlines": "^1.0.3",
|
|
213
|
+
"n3": "^1.26.0",
|
|
214
214
|
"object-hash": "^3.0.0",
|
|
215
215
|
"object-sizeof": "^2.6.5",
|
|
216
|
-
"rotating-file-stream": "^3.2.
|
|
216
|
+
"rotating-file-stream": "^3.2.8",
|
|
217
217
|
"seedrandom": "^3.0.5",
|
|
218
|
-
"semver": "^7.7.
|
|
218
|
+
"semver": "^7.7.4",
|
|
219
219
|
"tar": "^7.4.3",
|
|
220
220
|
"tmp": "^0.2.3",
|
|
221
221
|
"ts-essentials": "^10.1.1",
|
|
222
|
-
"tslog": "^4.
|
|
222
|
+
"tslog": "^4.10.2",
|
|
223
223
|
"web-tree-sitter": "^0.24.7",
|
|
224
224
|
"ws": "^8.18.0",
|
|
225
225
|
"xpath-ts2": "^1.4.2"
|
|
@@ -24,6 +24,10 @@ export declare class FlowrDescriptionFile extends FlowrFile<DeepReadonly<DCF>> {
|
|
|
24
24
|
* @see {@link parseDCF} for details on the parsing logic.
|
|
25
25
|
*/
|
|
26
26
|
protected loadContent(): DCF;
|
|
27
|
+
/**
|
|
28
|
+
* Creates a FlowrDescriptionFile from given DCF content, path and optional roles.
|
|
29
|
+
* This is useful if you already have the DCF content parsed and want to create a description file instance without re-parsing.
|
|
30
|
+
*/
|
|
27
31
|
static fromDCF(dcf: DCF, path: string, roles?: FileRole[]): FlowrDescriptionFile;
|
|
28
32
|
/**
|
|
29
33
|
* Description file lifter, this does not re-create if already a description file
|
|
@@ -55,6 +59,11 @@ export declare class FlowrDescriptionFile extends FlowrFile<DeepReadonly<DCF>> {
|
|
|
55
59
|
* Returns the parsed dependencies from the 'Depends' field in the DESCRIPTION file.
|
|
56
60
|
*/
|
|
57
61
|
depends(): readonly Package[] | undefined;
|
|
62
|
+
/**
|
|
63
|
+
* Returns the parsed linking dependencies from the 'LinkingTo' field in the DESCRIPTION file.
|
|
64
|
+
* This field is used for packages that need to link to C/C++ code and is treated similarly to 'Imports'.
|
|
65
|
+
*/
|
|
66
|
+
linkingTo(): readonly Package[] | undefined;
|
|
58
67
|
/**
|
|
59
68
|
* Returns the parsed imports from the 'Imports' field in the DESCRIPTION file.
|
|
60
69
|
*/
|
|
@@ -34,6 +34,10 @@ class FlowrDescriptionFile extends flowr_file_1.FlowrFile {
|
|
|
34
34
|
loadContent() {
|
|
35
35
|
return parseDCF(this.wrapped);
|
|
36
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Creates a FlowrDescriptionFile from given DCF content, path and optional roles.
|
|
39
|
+
* This is useful if you already have the DCF content parsed and want to create a description file instance without re-parsing.
|
|
40
|
+
*/
|
|
37
41
|
static fromDCF(dcf, path, roles) {
|
|
38
42
|
const file = new FlowrDescriptionFile(new flowr_file_1.FlowrTextFile(path, roles));
|
|
39
43
|
file.setContent(dcf);
|
|
@@ -103,6 +107,14 @@ class FlowrDescriptionFile extends flowr_file_1.FlowrFile {
|
|
|
103
107
|
const deps = this.content().get('Depends');
|
|
104
108
|
return deps ? parsePackagesWithVersions(deps, 'r') : undefined;
|
|
105
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* Returns the parsed linking dependencies from the 'LinkingTo' field in the DESCRIPTION file.
|
|
112
|
+
* This field is used for packages that need to link to C/C++ code and is treated similarly to 'Imports'.
|
|
113
|
+
*/
|
|
114
|
+
linkingTo() {
|
|
115
|
+
const lt = this.content().get('LinkingTo');
|
|
116
|
+
return lt ? parsePackagesWithVersions(lt, 'package') : undefined;
|
|
117
|
+
}
|
|
106
118
|
/**
|
|
107
119
|
* Returns the parsed imports from the 'Imports' field in the DESCRIPTION file.
|
|
108
120
|
*/
|
|
@@ -173,7 +173,7 @@ function doesFilepathMatch(file, filter) {
|
|
|
173
173
|
function isParameterDefaultValue(nodeId, ast) {
|
|
174
174
|
let node = ast.idMap.get(nodeId);
|
|
175
175
|
while (node !== undefined) {
|
|
176
|
-
if (node.info.role === "param-
|
|
176
|
+
if (node.info.role === "param-v" /* RoleInParent.ParameterDefaultValue */) {
|
|
177
177
|
return true;
|
|
178
178
|
}
|
|
179
179
|
const nip = node.info.parent;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
2
2
|
import { type DataflowGraph } from '../../../dataflow/graph/graph';
|
|
3
3
|
import { type DataflowGraphVertexFunctionCall } from '../../../dataflow/graph/vertex';
|
|
4
4
|
import { RType } from '../../../r-bridge/lang-4.x/ast/model/type';
|
|
@@ -5,16 +5,15 @@ exports.satisfiesCallTargets = satisfiesCallTargets;
|
|
|
5
5
|
exports.getValueOfArgument = getValueOfArgument;
|
|
6
6
|
exports.identifyLinkToLastCallRelation = identifyLinkToLastCallRelation;
|
|
7
7
|
exports.identifyLinkToLastCallRelationSync = identifyLinkToLastCallRelationSync;
|
|
8
|
+
const node_id_1 = require("../../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
8
9
|
const graph_1 = require("../../../dataflow/graph/graph");
|
|
9
10
|
const simple_visitor_1 = require("../../../control-flow/simple-visitor");
|
|
10
11
|
const vertex_1 = require("../../../dataflow/graph/vertex");
|
|
11
12
|
const edge_1 = require("../../../dataflow/graph/edge");
|
|
12
13
|
const resolve_by_name_1 = require("../../../dataflow/environments/resolve-by-name");
|
|
13
14
|
const identifier_1 = require("../../../dataflow/environments/identifier");
|
|
14
|
-
const built_in_1 = require("../../../dataflow/environments/built-in");
|
|
15
15
|
const assert_1 = require("../../../util/assert");
|
|
16
16
|
const type_1 = require("../../../r-bridge/lang-4.x/ast/model/type");
|
|
17
|
-
const r_function_call_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
18
17
|
const cascade_action_1 = require("./cascade-action");
|
|
19
18
|
const cfg_kind_1 = require("../../../project/cfg-kind");
|
|
20
19
|
var CallTargets;
|
|
@@ -49,7 +48,7 @@ function satisfiesCallTargets(info, graph, callTarget) {
|
|
|
49
48
|
* including any potential built-in mapping.
|
|
50
49
|
*/
|
|
51
50
|
const reResolved = (0, resolve_by_name_1.resolveByName)(info.name, info.environment, identifier_1.ReferenceType.Unknown);
|
|
52
|
-
if (reResolved?.some(t =>
|
|
51
|
+
if (reResolved?.some(t => node_id_1.NodeId.isBuiltIn(t.definedAt))) {
|
|
53
52
|
builtIn = true;
|
|
54
53
|
}
|
|
55
54
|
}
|
|
@@ -63,7 +62,7 @@ function satisfiesCallTargets(info, graph, callTarget) {
|
|
|
63
62
|
case CallTargets.Any:
|
|
64
63
|
return callTargets;
|
|
65
64
|
case CallTargets.OnlyGlobal:
|
|
66
|
-
if (callTargets.every(
|
|
65
|
+
if (callTargets.every(node_id_1.NodeId.isBuiltIn)) {
|
|
67
66
|
return builtIn ? ['built-in'] : [];
|
|
68
67
|
}
|
|
69
68
|
else {
|
|
@@ -94,7 +93,7 @@ function getValueOfArgument(graph, call, argument, additionalAllowedTypes) {
|
|
|
94
93
|
const totalIndex = argument.name ? call.args.findIndex(arg => graph_1.FunctionArgument.hasName(arg, argument.name)) : -1;
|
|
95
94
|
let refAtIndex;
|
|
96
95
|
if (totalIndex < 0) {
|
|
97
|
-
const references = call.args.filter(
|
|
96
|
+
const references = call.args.filter(graph_1.FunctionArgument.isPositional).map(graph_1.FunctionArgument.getReference);
|
|
98
97
|
refAtIndex = references[argument.index];
|
|
99
98
|
}
|
|
100
99
|
else {
|
|
@@ -11,6 +11,7 @@ const identify_link_to_last_call_relation_1 = require("../call-context-query/ide
|
|
|
11
11
|
const resolve_argument_1 = require("../../../dataflow/eval/resolve/resolve-argument");
|
|
12
12
|
const assert_1 = require("../../../util/assert");
|
|
13
13
|
const log_1 = require("../../../util/log");
|
|
14
|
+
const model_1 = require("../../../r-bridge/lang-4.x/ast/model/model");
|
|
14
15
|
/**
|
|
15
16
|
* Executes a dependencies query.
|
|
16
17
|
*/
|
|
@@ -185,7 +186,7 @@ function getResults(queries, { dataflow, config, normalize }, results, kind, fun
|
|
|
185
186
|
if (get?.type === type_1.RType.Argument) {
|
|
186
187
|
get = get.value;
|
|
187
188
|
}
|
|
188
|
-
return
|
|
189
|
+
return model_1.RNode.lexeme(get);
|
|
189
190
|
}
|
|
190
191
|
}
|
|
191
192
|
function collectValuesFromLinks(args, data, linkedIds) {
|
|
@@ -14,10 +14,11 @@ const source_functions_1 = require("./function-info/source-functions");
|
|
|
14
14
|
const read_functions_1 = require("./function-info/read-functions");
|
|
15
15
|
const write_functions_1 = require("./function-info/write-functions");
|
|
16
16
|
const visualize_functions_1 = require("./function-info/visualize-functions");
|
|
17
|
-
const visitor_1 = require("../../../r-bridge/lang-4.x/ast/model/processing/visitor");
|
|
18
17
|
const type_1 = require("../../../r-bridge/lang-4.x/ast/model/type");
|
|
19
18
|
const test_functions_1 = require("./function-info/test-functions");
|
|
20
19
|
const identifier_1 = require("../../../dataflow/environments/identifier");
|
|
20
|
+
const r_project_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-project");
|
|
21
|
+
const model_1 = require("../../../r-bridge/lang-4.x/ast/model/model");
|
|
21
22
|
exports.Unknown = 'unknown';
|
|
22
23
|
exports.DefaultDependencyCategories = {
|
|
23
24
|
'library': {
|
|
@@ -27,14 +28,14 @@ exports.DefaultDependencyCategories = {
|
|
|
27
28
|
/* for libraries, we have to additionally track all uses of `::` and `:::`, for this we currently simply traverse all uses */
|
|
28
29
|
additionalAnalysis: async (data, ignoreDefault, _functions, _queryResults, result) => {
|
|
29
30
|
if (!ignoreDefault) {
|
|
30
|
-
|
|
31
|
+
r_project_1.RProject.visitAst((await data.analyzer.normalize()).ast, node => {
|
|
31
32
|
let ns;
|
|
32
|
-
if (
|
|
33
|
+
if (node.type === type_1.RType.Symbol && (ns = identifier_1.Identifier.getNamespace(node.content)) !== undefined) {
|
|
33
34
|
const dep = data.analyzer.inspectContext().deps.getDependency(ns);
|
|
34
35
|
/* we should improve the identification of ':::' */
|
|
35
36
|
result.push({
|
|
36
|
-
nodeId:
|
|
37
|
-
functionName:
|
|
37
|
+
nodeId: node.info.id,
|
|
38
|
+
functionName: model_1.RNode.lexeme(node).includes(':::') ? ':::' : '::',
|
|
38
39
|
value: ns,
|
|
39
40
|
versionConstraints: dep?.versionConstraints,
|
|
40
41
|
derivedVersion: dep?.derivedVersion,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Joi from 'joi';
|
|
2
2
|
import type { DataFrameDomain } from '../../../abstract-interpretation/data-frame/dataframe-domain';
|
|
3
|
-
import { StateAbstractDomain } from '../../../abstract-interpretation/domains/state-abstract-domain';
|
|
3
|
+
import type { StateAbstractDomain } from '../../../abstract-interpretation/domains/state-abstract-domain';
|
|
4
4
|
import type { ReplOutput } from '../../../cli/repl/commands/repl-main';
|
|
5
5
|
import type { FlowrConfigOptions } from '../../../config';
|
|
6
6
|
import type { SingleSlicingCriterion } from '../../../slicing/criterion/parse';
|
|
@@ -5,11 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.DfShapeQueryDefinition = void 0;
|
|
7
7
|
const joi_1 = __importDefault(require("joi"));
|
|
8
|
-
const state_abstract_domain_1 = require("../../../abstract-interpretation/domains/state-abstract-domain");
|
|
9
8
|
const slice_query_parser_1 = require("../../../cli/repl/parser/slice-query-parser");
|
|
10
9
|
const ansi_1 = require("../../../util/text/ansi");
|
|
11
10
|
const time_1 = require("../../../util/text/time");
|
|
12
11
|
const df_shape_query_executor_1 = require("./df-shape-query-executor");
|
|
12
|
+
const abstract_domain_1 = require("../../../abstract-interpretation/domains/abstract-domain");
|
|
13
13
|
function dfShapeQueryLineParser(_output, line, _config) {
|
|
14
14
|
const criterion = (0, slice_query_parser_1.sliceCriterionParser)(line[0]);
|
|
15
15
|
return {
|
|
@@ -24,7 +24,7 @@ exports.DfShapeQueryDefinition = {
|
|
|
24
24
|
executor: df_shape_query_executor_1.executeDfShapeQuery,
|
|
25
25
|
asciiSummarizer: (formatter, _analyzer, queryResults, result) => {
|
|
26
26
|
const out = queryResults;
|
|
27
|
-
const domains = out.domains instanceof
|
|
27
|
+
const domains = out.domains instanceof abstract_domain_1.AbstractDomain ? out.domains.value : out.domains;
|
|
28
28
|
result.push(`Query: ${(0, ansi_1.bold)('df-shape', formatter)} (${(0, time_1.printAsMs)(out['.meta'].timing, 0)})`);
|
|
29
29
|
result.push(...domains.entries().take(20).map(([key, domain]) => {
|
|
30
30
|
return ` ╰ ${key}: ${domain?.toString()}`;
|
|
@@ -36,7 +36,7 @@ exports.DfShapeQueryDefinition = {
|
|
|
36
36
|
},
|
|
37
37
|
jsonFormatter: (queryResults) => {
|
|
38
38
|
const { domains, ...out } = queryResults;
|
|
39
|
-
const state = domains instanceof
|
|
39
|
+
const state = domains instanceof abstract_domain_1.AbstractDomain ? domains.value : domains;
|
|
40
40
|
const json = Object.fromEntries(state.entries().map(([key, domain]) => [key, domain?.toJson() ?? null]));
|
|
41
41
|
const result = { domains: json, ...out };
|
|
42
42
|
return result;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.executeDoesCallQuery = executeDoesCallQuery;
|
|
4
4
|
const log_1 = require("../../../util/log");
|
|
5
|
+
const node_id_1 = require("../../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
5
6
|
const parse_1 = require("../../../slicing/criterion/parse");
|
|
6
|
-
const built_in_1 = require("../../../dataflow/environments/built-in");
|
|
7
7
|
const identifier_1 = require("../../../dataflow/environments/identifier");
|
|
8
8
|
/**
|
|
9
9
|
* Execute does call queries on the given analyzer.
|
|
@@ -77,8 +77,8 @@ function findCallersMatchingConstraints(cg, start, constraints) {
|
|
|
77
77
|
continue;
|
|
78
78
|
}
|
|
79
79
|
visited.add(cur);
|
|
80
|
-
if (
|
|
81
|
-
const name =
|
|
80
|
+
if (node_id_1.NodeId.isBuiltIn(cur)) {
|
|
81
|
+
const name = node_id_1.NodeId.fromBuiltIn(cur);
|
|
82
82
|
if (constraints({ id: cur, name }, cg)) {
|
|
83
83
|
return { call: start };
|
|
84
84
|
}
|
|
@@ -2,7 +2,7 @@ import type { BaseQueryFormat, BaseQueryResult } from '../../base-query-format';
|
|
|
2
2
|
import Joi from 'joi';
|
|
3
3
|
import type { ParsedQueryLine } from '../../query';
|
|
4
4
|
import { executeExceptionQuery } from './inspect-exception-query-executor';
|
|
5
|
-
import {
|
|
5
|
+
import { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
6
6
|
import type { ReplOutput } from '../../../cli/repl/commands/repl-main';
|
|
7
7
|
import type { FlowrConfigOptions } from '../../../config';
|
|
8
8
|
import type { ExceptionPoint } from '../../../dataflow/fn/exceptions-of-function';
|
|
@@ -28,11 +28,11 @@ exports.InspectExceptionQueryDefinition = {
|
|
|
28
28
|
result.push(`Query: ${(0, ansi_1.bold)('inspect-exception', formatter)} (${out['.meta'].timing.toFixed(0)}ms)`);
|
|
29
29
|
const n = await processed.normalize();
|
|
30
30
|
function getLoc(r) {
|
|
31
|
-
const node = n.idMap.get(
|
|
31
|
+
const node = n.idMap.get(node_id_1.NodeId.normalize(r));
|
|
32
32
|
return node ? range_1.SourceLocation.fromNode(node) : undefined;
|
|
33
33
|
}
|
|
34
34
|
function getLexeme(r) {
|
|
35
|
-
return n.idMap.get(
|
|
35
|
+
return n.idMap.get(node_id_1.NodeId.normalize(r))?.lexeme ?? String(r);
|
|
36
36
|
}
|
|
37
37
|
for (const [r, v] of Object.entries(out.exceptions)) {
|
|
38
38
|
result.push(` - Function ${(0, ansi_1.bold)(r, formatter)} (${range_1.SourceLocation.format(getLoc(r))}) ${v.length > 0 ? 'throws exceptions:' : 'does not throw exceptions.'}`);
|
|
@@ -2,7 +2,7 @@ import type { BaseQueryFormat, BaseQueryResult } from '../../base-query-format';
|
|
|
2
2
|
import Joi from 'joi';
|
|
3
3
|
import type { ParsedQueryLine } from '../../query';
|
|
4
4
|
import { executeHigherOrderQuery } from './inspect-higher-order-query-executor';
|
|
5
|
-
import {
|
|
5
|
+
import { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
6
6
|
import type { SingleSlicingCriterion } from '../../../slicing/criterion/parse';
|
|
7
7
|
import type { ReplOutput } from '../../../cli/repl/commands/repl-main';
|
|
8
8
|
import type { FlowrConfigOptions } from '../../../config';
|
|
@@ -26,7 +26,7 @@ exports.InspectHigherOrderQueryDefinition = {
|
|
|
26
26
|
const out = queryResults;
|
|
27
27
|
result.push(`Query: ${(0, ansi_1.bold)('inspect-higher-order', formatter)} (${out['.meta'].timing.toFixed(0)}ms)`);
|
|
28
28
|
for (const [r, v] of Object.entries(out.higherOrder)) {
|
|
29
|
-
const node = (await processed.normalize()).idMap.get(
|
|
29
|
+
const node = (await processed.normalize()).idMap.get(node_id_1.NodeId.normalize(r));
|
|
30
30
|
const loc = node ? range_1.SourceLocation.fromNode(node) : undefined;
|
|
31
31
|
result.push(` - Function ${(0, ansi_1.bold)(r, formatter)} (${range_1.SourceLocation.format(loc)}) is ${v ? '' : 'not '}a higher-order function`);
|
|
32
32
|
}
|
|
@@ -2,7 +2,7 @@ import type { BaseQueryFormat, BaseQueryResult } from '../../base-query-format';
|
|
|
2
2
|
import Joi from 'joi';
|
|
3
3
|
import type { ParsedQueryLine } from '../../query';
|
|
4
4
|
import { executeRecursionQuery } from './inspect-recursion-query-executor';
|
|
5
|
-
import {
|
|
5
|
+
import { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
6
6
|
import type { SingleSlicingCriterion } from '../../../slicing/criterion/parse';
|
|
7
7
|
import type { ReplOutput } from '../../../cli/repl/commands/repl-main';
|
|
8
8
|
import type { FlowrConfigOptions } from '../../../config';
|
|
@@ -26,7 +26,7 @@ exports.InspectRecursionQueryDefinition = {
|
|
|
26
26
|
const out = queryResults;
|
|
27
27
|
result.push(`Query: ${(0, ansi_1.bold)('inspect-recursion', formatter)} (${out['.meta'].timing.toFixed(0)}ms)`);
|
|
28
28
|
for (const [r, v] of Object.entries(out.recursive)) {
|
|
29
|
-
const node = (await processed.normalize()).idMap.get(
|
|
29
|
+
const node = (await processed.normalize()).idMap.get(node_id_1.NodeId.normalize(r));
|
|
30
30
|
const loc = node ? range_1.SourceLocation.fromNode(node) : undefined;
|
|
31
31
|
result.push(` - Function ${(0, ansi_1.bold)(r, formatter)} (${range_1.SourceLocation.format(loc)}) is ${v ? '' : 'not '}recursive`);
|
|
32
32
|
}
|
package/queries/query-print.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type OutputFormatter } from '../util/text/ansi';
|
|
2
2
|
import { type Queries, type QueryResults, type SupportedQueryTypes } from './query';
|
|
3
|
-
import
|
|
3
|
+
import { NodeId } from '../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
4
4
|
import type { AstIdMap, ParentInformation } from '../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
5
5
|
import type { ReadonlyFlowrAnalysisProvider } from '../project/flowr-analyzer';
|
|
6
6
|
/**
|
package/queries/query-print.js
CHANGED
|
@@ -5,21 +5,22 @@ exports.summarizeIdsIfTooLong = summarizeIdsIfTooLong;
|
|
|
5
5
|
exports.asciiSummaryOfQueryResult = asciiSummaryOfQueryResult;
|
|
6
6
|
const ansi_1 = require("../util/text/ansi");
|
|
7
7
|
const query_1 = require("./query");
|
|
8
|
+
const node_id_1 = require("../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
8
9
|
const html_hover_over_1 = require("../util/html-hover-over");
|
|
9
10
|
const time_1 = require("../util/text/time");
|
|
10
|
-
const
|
|
11
|
+
const model_1 = require("../r-bridge/lang-4.x/ast/model/model");
|
|
11
12
|
function nodeString(nodeId, formatter, idMap) {
|
|
12
13
|
const isObj = typeof nodeId === 'object' && nodeId !== null && 'id' in nodeId;
|
|
13
14
|
const id = isObj ? nodeId?.id : nodeId;
|
|
14
15
|
const info = isObj ? nodeId?.info : undefined;
|
|
15
|
-
if (
|
|
16
|
+
if (node_id_1.NodeId.isBuiltIn(id)) {
|
|
16
17
|
return (0, ansi_1.italic)(id, formatter) + (info ? ` (${JSON.stringify(info)})` : '');
|
|
17
18
|
}
|
|
18
19
|
const node = idMap.get(id);
|
|
19
20
|
if (node === undefined) {
|
|
20
21
|
return `UNKNOWN: ${id} (info: ${JSON.stringify(info)})`;
|
|
21
22
|
}
|
|
22
|
-
return `${(0, ansi_1.italic)('`' + (
|
|
23
|
+
return `${(0, ansi_1.italic)('`' + (model_1.RNode.lexeme(node) ?? 'UNKNOWN') + '`', formatter)} (L.${node.location?.[0]}${info ? ', ' + JSON.stringify(info) : ''})`;
|
|
23
24
|
}
|
|
24
25
|
function asciiCallContextSubHit(formatter, results, idMap) {
|
|
25
26
|
const result = [];
|