@eagleoutice/flowr 2.9.10 → 2.9.12
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 +48 -50
- package/abstract-interpretation/absint-visitor.js +2 -1
- package/abstract-interpretation/data-frame/mappers/arguments.d.ts +1 -1
- package/abstract-interpretation/data-frame/mappers/arguments.js +2 -2
- package/abstract-interpretation/domains/set-range-domain.js +1 -1
- 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/control-flow-graph.d.ts +1 -1
- package/control-flow/control-flow-graph.js +1 -2
- package/control-flow/extract-cfg.js +4 -3
- package/dataflow/cluster.js +12 -8
- package/dataflow/environments/built-in.d.ts +2 -15
- package/dataflow/environments/built-in.js +11 -31
- package/dataflow/eval/resolve/alias-tracking.d.ts +1 -1
- package/dataflow/eval/resolve/alias-tracking.js +2 -1
- package/dataflow/eval/resolve/resolve.js +4 -3
- 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 +4 -4
- package/dataflow/graph/graph.js +27 -22
- package/dataflow/graph/quads.js +4 -7
- package/dataflow/internal/linker.d.ts +2 -2
- package/dataflow/internal/linker.js +15 -14
- package/dataflow/internal/process/functions/call/argument/make-argument.d.ts +2 -1
- package/dataflow/internal/process/functions/call/argument/make-argument.js +2 -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-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-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 +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +3 -3
- 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/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-cfg.js +3 -3
- package/documentation/wiki-dataflow-graph.js +86 -31
- package/documentation/wiki-engine.js +18 -0
- package/documentation/wiki-mk/doc-context.d.ts +52 -11
- package/documentation/wiki-mk/doc-context.js +20 -13
- 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/file-path-validity.js +1 -1
- package/package.json +1 -1
- package/project/plugins/file-plugins/files/flowr-description-file.d.ts +5 -0
- package/project/plugins/file-plugins/files/flowr-description-file.js +8 -0
- 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/dependencies-query/function-info/library-functions.js +2 -1
- package/queries/catalog/dependencies-query/function-info/read-functions.js +1 -1
- package/queries/catalog/dependencies-query/function-info/visualize-functions.js +9 -1
- package/queries/catalog/dependencies-query/function-info/write-functions.js +1 -0
- 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/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/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 +2 -2
- 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 +4 -3
- 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 +2 -2
- package/util/mermaid/cfg.js +3 -4
- package/util/mermaid/dfg.d.ts +9 -1
- package/util/mermaid/dfg.js +13 -9
- package/util/quads.js +14 -6
- package/util/range.d.ts +3 -0
- package/util/range.js +3 -0
- 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
|
@@ -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,
|
|
@@ -13,6 +13,7 @@ exports.LibraryFunctions = [
|
|
|
13
13
|
{ package: 'easypackages', name: 'from_import', argIdx: 0, argName: 'package', resolveValue: true },
|
|
14
14
|
{ package: 'easypackages', name: 'libraries', argIdx: 'unnamed', resolveValue: true },
|
|
15
15
|
{ package: 'librarian', name: 'shelf', argIdx: 'unnamed', resolveValue: true },
|
|
16
|
-
{ package: 'devtools', name: 'load_all', argIdx: 0, argName: 'path', resolveValue: true }
|
|
16
|
+
{ package: 'devtools', name: 'load_all', argIdx: 0, argName: 'path', resolveValue: true, defaultValue: '.' },
|
|
17
|
+
{ package: 'devtools', name: 'load_code', argIdx: 0, argName: 'path', resolveValue: true, defaultValue: '.' },
|
|
17
18
|
];
|
|
18
19
|
//# sourceMappingURL=library-functions.js.map
|
|
@@ -93,7 +93,7 @@ exports.ReadFunctions = [
|
|
|
93
93
|
{ package: 'XLConnect', name: 'loadWorkbook', argIdx: 0, argName: 'filename', resolveValue: true },
|
|
94
94
|
{ package: 'DiagrammeR', name: 'import_graph', argIdx: 0, argName: 'graph_file', resolveValue: true },
|
|
95
95
|
{ package: 'DiagrammeR', name: 'open_graph', argIdx: 0, argName: 'file', resolveValue: true },
|
|
96
|
-
{ package: 'highcharter', name: 'download_map_data', argIdx: 0, argName: 'url', resolveValue: true },
|
|
96
|
+
{ package: 'highcharter', name: 'download_map_data', argIdx: 0, argName: 'url', resolveValue: true, defaultValue: 'custom/world.js' },
|
|
97
97
|
{ package: 'rvest', name: 'read_html', argIdx: 0, argName: 'x', resolveValue: true },
|
|
98
98
|
{ package: 'rvest', name: 'read_html_live', argIdx: 0, argName: 'url', resolveValue: true },
|
|
99
99
|
{ package: 'stats', name: 'read.ftable', argIdx: 0, argName: 'file', resolveValue: true },
|
|
@@ -9,5 +9,13 @@ exports.VisualizeFunctions =
|
|
|
9
9
|
// plot creation
|
|
10
10
|
default_builtin_config_1.GgPlotCreate.map(f => ({ package: 'ggplot2', name: f })).concat(default_builtin_config_1.TinyPlotCrate.map(f => ({ package: 'tinyplot', name: f })), default_builtin_config_1.GraphicsPlotCreate.map(f => ({ name: f })),
|
|
11
11
|
// plot modification
|
|
12
|
-
default_builtin_config_1.GgPlotImplicitAddons.concat(default_builtin_config_1.GgPlotAddons).map(f => ({ package: 'ggplot2', name: f, linkTo: LinkToPlotCreation })), default_builtin_config_1.TinyPlotAddons.map(f => ({ package: 'tinyplot', name: f, linkTo: LinkToPlotCreation })), default_builtin_config_1.GraphicsPlotAddons.map(f => ({ name: f, linkTo: LinkToPlotCreation })))
|
|
12
|
+
default_builtin_config_1.GgPlotImplicitAddons.concat(default_builtin_config_1.GgPlotAddons).map(f => ({ package: 'ggplot2', name: f, linkTo: LinkToPlotCreation })), default_builtin_config_1.TinyPlotAddons.map(f => ({ package: 'tinyplot', name: f, linkTo: LinkToPlotCreation })), default_builtin_config_1.GraphicsPlotAddons.map(f => ({ name: f, linkTo: LinkToPlotCreation }))).map(f => {
|
|
13
|
+
if (f.name !== 'hist') {
|
|
14
|
+
return f;
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
// ignore if plot is false.
|
|
18
|
+
return { ...f, ignoreIf: 'arg-false', additionalArgs: { val: { argIdx: 17, argName: 'plot', resolveValue: true } } };
|
|
19
|
+
}
|
|
20
|
+
});
|
|
13
21
|
//# sourceMappingURL=visualize-functions.js.map
|
|
@@ -115,5 +115,6 @@ exports.WriteFunctions = [
|
|
|
115
115
|
{ package: 'rpolars', name: 'write_csv', argIdx: 0, argName: 'file', resolveValue: true, ignoreIf: 'arg-missing' },
|
|
116
116
|
{ package: 'rpolars', name: 'write_ndjson', argIdx: 0, argName: 'file', resolveValue: true, ignoreIf: 'arg-missing' },
|
|
117
117
|
{ package: 'rpolars', name: 'write_parquet', argIdx: 0, argName: 'file', resolveValue: true, ignoreIf: 'arg-missing' },
|
|
118
|
+
{ package: 'magick', name: 'image_write', argIdx: 1, argName: 'path', resolveValue: true, ignoreIf: 'arg-missing' },
|
|
118
119
|
];
|
|
119
120
|
//# sourceMappingURL=write-functions.js.map
|
|
@@ -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 = [];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { SourceRange } from '../../../../util/range';
|
|
2
|
-
import
|
|
2
|
+
import { SourceLocation } from '../../../../util/range';
|
|
3
|
+
import { RType } from './type';
|
|
3
4
|
import type { MergeableRecord } from '../../../../util/objects';
|
|
4
5
|
import type { RNumber } from './nodes/r-number';
|
|
5
6
|
import type { RString } from './nodes/r-string';
|
|
@@ -14,7 +15,7 @@ import type { RRepeatLoop } from './nodes/r-repeat-loop';
|
|
|
14
15
|
import type { RWhileLoop } from './nodes/r-while-loop';
|
|
15
16
|
import type { RIfThenElse } from './nodes/r-if-then-else';
|
|
16
17
|
import type { RFunctionDefinition } from './nodes/r-function-definition';
|
|
17
|
-
import type { RFunctionCall } from './nodes/r-function-call';
|
|
18
|
+
import type { EmptyArgument, RFunctionCall } from './nodes/r-function-call';
|
|
18
19
|
import type { RParameter } from './nodes/r-parameter';
|
|
19
20
|
import type { RArgument } from './nodes/r-argument';
|
|
20
21
|
import type { RExpressionList } from './nodes/r-expression-list';
|
|
@@ -23,13 +24,17 @@ import type { RUnaryOp } from './nodes/r-unary-op';
|
|
|
23
24
|
import type { RBinaryOp } from './nodes/r-binary-op';
|
|
24
25
|
import type { RPipe } from './nodes/r-pipe';
|
|
25
26
|
import type { RDelimiter } from './nodes/info/r-delimiter';
|
|
27
|
+
import type { ParentInformation } from './processing/decorate';
|
|
28
|
+
import type { NodeId } from './processing/node-id';
|
|
29
|
+
import type { OnEnter, OnExit } from './processing/visitor';
|
|
30
|
+
import type { SingleOrArrayOrNothing } from '../../../../abstract-interpretation/normalized-ast-fold';
|
|
26
31
|
/** Simply an empty type constraint used to say that there are additional decorations (see {@link RAstNodeBase}). */
|
|
27
32
|
export type NoInfo = object;
|
|
28
33
|
/**
|
|
29
34
|
* Will be used to reconstruct the source of the given element in the R-ast.
|
|
30
35
|
* This will not be part of most comparisons as it is mainly of interest to the reconstruction of R code.
|
|
31
36
|
*/
|
|
32
|
-
interface Source {
|
|
37
|
+
export interface Source {
|
|
33
38
|
/**
|
|
34
39
|
* The range is different from the assigned {@link Location} as it refers to the complete source range covered by the given
|
|
35
40
|
* element.
|
|
@@ -98,30 +103,105 @@ export type NamespaceIdentifier = string;
|
|
|
98
103
|
* represented in the normalized AST.
|
|
99
104
|
*/
|
|
100
105
|
export type RConstant<Info> = RNumber<Info> | RString<Info> | RLogical<Info>;
|
|
106
|
+
/**
|
|
107
|
+
* Helper object to provide helper functions for {@link RConstant|RConstants}.
|
|
108
|
+
* @see {@link RNode} - for more general helper functions for all nodes
|
|
109
|
+
*/
|
|
110
|
+
export declare const RConstant: {
|
|
111
|
+
readonly name: "RConstant";
|
|
112
|
+
/**
|
|
113
|
+
* Type guard for {@link RConstant} nodes, i.e. checks whether a node is a number, string or logical constant.
|
|
114
|
+
* If you need the specific type, please either use the respective type guards (e.g., {@link RNumber.is}) or check the `type` node directly.
|
|
115
|
+
*/
|
|
116
|
+
readonly is: <Info = object>(this: void, node: RNode<Info> | undefined) => node is RConstant<Info>;
|
|
117
|
+
/**
|
|
118
|
+
* A set of all types of constants in the normalized AST, i.e. number, string and logical constants.
|
|
119
|
+
*/
|
|
120
|
+
readonly constantTypes: ReadonlySet<RType>;
|
|
121
|
+
};
|
|
101
122
|
/**
|
|
102
123
|
* This subtype of {@link RNode} represents all types of {@link Leaf} nodes in the
|
|
103
124
|
* normalized AST.
|
|
104
125
|
*/
|
|
105
126
|
export type RSingleNode<Info> = RComment<Info> | RSymbol<Info> | RConstant<Info> | RBreak<Info> | RNext<Info> | RLineDirective<Info>;
|
|
127
|
+
/**
|
|
128
|
+
* Represents a leaf node in the normalized AST, i.e. a node that does not have any children. This includes comment, symbol, constant, break, next and line directive nodes.
|
|
129
|
+
*/
|
|
130
|
+
export declare const RSingleNode: {
|
|
131
|
+
readonly name: "RSingleNode";
|
|
132
|
+
/**
|
|
133
|
+
* Type guard for {@link RSingleNode} nodes, i.e. checks whether a node is a comment, symbol, constant, break, next or line directive.
|
|
134
|
+
* If you need the specific type, please either use the respective type guards (e.g., {@link RComment.is}) or check the `type` node directly.
|
|
135
|
+
*/
|
|
136
|
+
readonly is: <Info = object>(this: void, node: RNode<Info> | undefined) => node is RSingleNode<Info>;
|
|
137
|
+
/**
|
|
138
|
+
* A set of all types of single nodes in the normalized AST, i.e. comment, symbol, constant, break, next and line directive nodes.
|
|
139
|
+
*/
|
|
140
|
+
readonly singleNodeTypes: ReadonlySet<RType>;
|
|
141
|
+
};
|
|
106
142
|
/**
|
|
107
143
|
* This subtype of {@link RNode} represents all looping constructs in the normalized AST.
|
|
108
144
|
*/
|
|
109
145
|
export type RLoopConstructs<Info> = RForLoop<Info> | RRepeatLoop<Info> | RWhileLoop<Info>;
|
|
146
|
+
export declare const RLoopConstructs: {
|
|
147
|
+
readonly name: "RLoopConstructs";
|
|
148
|
+
/**
|
|
149
|
+
* Type guard for {@link RLoopConstructs} nodes, i.e. checks whether a node is a for, repeat or while loop.
|
|
150
|
+
* If you need the specific type, please either use the respective type guards (e.g., {@link RForLoop.is}) or check the `type` node directly.
|
|
151
|
+
*/
|
|
152
|
+
readonly is: <Info = object>(this: void, node: RNode<Info> | undefined) => node is RLoopConstructs<Info>;
|
|
153
|
+
/**
|
|
154
|
+
* A set of all types of loop constructs in the normalized AST, i.e. for, repeat and while loops.
|
|
155
|
+
*/
|
|
156
|
+
readonly loopConstructTypes: ReadonlySet<RType>;
|
|
157
|
+
};
|
|
110
158
|
/**
|
|
111
159
|
* As an extension to {@link RLoopConstructs}, this subtype of {@link RNode} includes
|
|
112
160
|
* the {@link RIfThenElse} construct as well.
|
|
113
161
|
*/
|
|
114
162
|
export type RConstructs<Info> = RLoopConstructs<Info> | RIfThenElse<Info>;
|
|
163
|
+
export declare const RConstructs: {
|
|
164
|
+
readonly name: "RConstructs";
|
|
165
|
+
/**
|
|
166
|
+
* Type guard for {@link RConstructs} nodes, i.e. checks whether a node is a for, repeat or while loop or an if-then-else construct.
|
|
167
|
+
* If you need the specific type, please either use the respective type guards (e.g., {@link RForLoop.is}) or check the `type` node directly.
|
|
168
|
+
*/
|
|
169
|
+
readonly is: <Info = object>(this: void, node: RNode<Info> | undefined) => node is RConstructs<Info>;
|
|
170
|
+
/**
|
|
171
|
+
* A set of all types of constructs in the normalized AST, i.e. for, repeat and while loops and if-then-else constructs.
|
|
172
|
+
*/
|
|
173
|
+
readonly constructTypes: ReadonlySet<RType>;
|
|
174
|
+
};
|
|
115
175
|
/**
|
|
116
176
|
* This subtype of {@link RNode} represents all types related to functions
|
|
117
177
|
* (calls and definitions) in the normalized AST.
|
|
118
178
|
*/
|
|
119
179
|
export type RFunctions<Info> = RFunctionDefinition<Info> | RFunctionCall<Info> | RParameter<Info> | RArgument<Info>;
|
|
180
|
+
export declare const RFunctions: {
|
|
181
|
+
readonly name: "RFunctions";
|
|
182
|
+
/**
|
|
183
|
+
* Type guard for {@link RFunctions} nodes, i.e. checks whether a node is a function definition, function call, parameter or argument.
|
|
184
|
+
* If you need the specific type, please either use the respective type guards (e.g., {@link RFunctionDefinition.is}) or check the `type` node directly.
|
|
185
|
+
*/
|
|
186
|
+
readonly is: <Info = object>(this: void, node: RNode<Info> | undefined) => node is RFunctions<Info>;
|
|
187
|
+
/**
|
|
188
|
+
* A set of all types of function-related nodes in the normalized AST, i.e. function definitions, function calls, parameters and arguments.
|
|
189
|
+
*/
|
|
190
|
+
readonly functionTypes: ReadonlySet<RType>;
|
|
191
|
+
};
|
|
120
192
|
/**
|
|
121
193
|
* This subtype of {@link RNode} represents all types of otherwise hard to categorize
|
|
122
194
|
* nodes in the normalized AST. At the moment these are the comment-like nodes.
|
|
123
195
|
*/
|
|
124
196
|
export type ROther<Info> = RComment<Info> | RLineDirective<Info>;
|
|
197
|
+
export declare const ROther: {
|
|
198
|
+
readonly name: "ROther";
|
|
199
|
+
/**
|
|
200
|
+
* Type guard for {@link ROther} nodes, i.e. checks whether a node is a comment or line directive.
|
|
201
|
+
* If you need the specific type, please either use the respective type guards (e.g., {@link RComment.is}) or check the `type` node directly.
|
|
202
|
+
*/
|
|
203
|
+
readonly is: <Info = object>(this: void, node: RNode<Info> | undefined) => node is ROther<Info>;
|
|
204
|
+
};
|
|
125
205
|
/**
|
|
126
206
|
* The `RNode` type is the union of all possible nodes in the R-ast.
|
|
127
207
|
* It should be used whenever you either not care what kind of
|
|
@@ -133,7 +213,74 @@ export type ROther<Info> = RComment<Info> | RLineDirective<Info>;
|
|
|
133
213
|
* exclusive, some nodes can appear in multiple subtypes.
|
|
134
214
|
* @see {@link recoverName} - to receive the name/lexeme from such a node
|
|
135
215
|
* @see {@link recoverContent} - for a more rigorous approach to get the content of a node within a {@link DataflowGraph|dataflow graph}
|
|
216
|
+
* @see {@link RNode.getLocation} - to get the location of a node and other helpful functions provided by the {@link RNode} helper object
|
|
136
217
|
*/
|
|
137
218
|
export type RNode<Info = NoInfo> = RExpressionList<Info> | RFunctions<Info> | ROther<Info> | RConstructs<Info> | RNamedAccess<Info> | RIndexAccess<Info> | RUnaryOp<Info> | RBinaryOp<Info> | RSingleNode<Info> | RPipe<Info>;
|
|
219
|
+
/**
|
|
220
|
+
* Helper object to provide helper functions for {@link RNode|RNodes}.
|
|
221
|
+
* @see {@link DefaultNormalizedAstFold} - for a more powerful way to traverse the normalized AST
|
|
222
|
+
*/
|
|
223
|
+
export declare const RNode: {
|
|
224
|
+
readonly name: "RNode";
|
|
225
|
+
/**
|
|
226
|
+
* A helper function to retrieve the location of a given node, if available.
|
|
227
|
+
* @see SourceLocation.fromNode
|
|
228
|
+
*/
|
|
229
|
+
readonly getLocation: (this: void, node: RNode) => SourceLocation | undefined;
|
|
230
|
+
/**
|
|
231
|
+
* A helper function to retrieve the id of a given node, if available.
|
|
232
|
+
*/
|
|
233
|
+
readonly getId: (this: void, node: RNode<ParentInformation>) => NodeId;
|
|
234
|
+
/**
|
|
235
|
+
* A helper function to retrieve the type of a given node.
|
|
236
|
+
*/
|
|
237
|
+
readonly getType: (this: void, node: RNode) => RType;
|
|
238
|
+
/**
|
|
239
|
+
* Visits all node ids within a tree given by a respective root node using a depth-first search with prefix order.
|
|
240
|
+
* @param nodes - The root id nodes to start collecting from
|
|
241
|
+
* @param onVisit - Called before visiting the subtree of each node. Can be used to stop visiting the subtree starting with this node (return `true` stop)
|
|
242
|
+
* @param onExit - Called after the subtree of a node has been visited, called for leafs too (even though their subtree is empty)
|
|
243
|
+
* @see {@link RProject.visitAst} - to visit all nodes in a project
|
|
244
|
+
*/
|
|
245
|
+
readonly visitAst: <OtherInfo = object>(this: void, nodes: SingleOrArrayOrNothing<RNode<OtherInfo>>, onVisit?: OnEnter<OtherInfo>, onExit?: OnExit<OtherInfo>) => void;
|
|
246
|
+
/**
|
|
247
|
+
* Collects all node ids within a tree given by a respective root node
|
|
248
|
+
* @param nodes - The root id nodes to start collecting from
|
|
249
|
+
* @see {@link collectAllIdsWithStop} - to stop collecting at certain nodes
|
|
250
|
+
* @see {@link RProject.collectAllIds} - to collect all ids within a project
|
|
251
|
+
*/
|
|
252
|
+
readonly collectAllIds: <OtherInfo>(this: void, nodes: SingleOrArrayOrNothing<RNode<OtherInfo & ParentInformation>>) => Set<NodeId>;
|
|
253
|
+
/**
|
|
254
|
+
* Collects all direct children of a given node, i.e. all nodes that are directly reachable via a property of the given node.
|
|
255
|
+
*/
|
|
256
|
+
readonly directChildren: <OtherInfo>(this: void, node: RNode<OtherInfo>) => readonly (RNode<OtherInfo> | typeof EmptyArgument)[];
|
|
257
|
+
/**
|
|
258
|
+
* Returns the direct parent of a node.
|
|
259
|
+
* Usually, only root nodes do not have a parent, and you can assume that there is a
|
|
260
|
+
* linear chain of parents leading to the root node.
|
|
261
|
+
*/
|
|
262
|
+
readonly directParent: <OtherInfo>(this: void, node: RNode<OtherInfo & ParentInformation>, idMap: Map<NodeId, RNode<OtherInfo>>) => RNode<OtherInfo> | undefined;
|
|
263
|
+
/**
|
|
264
|
+
* In contrast to the nesting stored in the {@link RNode} structure,
|
|
265
|
+
* this function calculates the depth of a node by counting the number of parents until the root node is reached.
|
|
266
|
+
*/
|
|
267
|
+
readonly depth: (this: void, node: RNode, idMap: Map<NodeId, RNode>) => number;
|
|
268
|
+
/**
|
|
269
|
+
* Collects all node ids within a tree given by a respective root node, but stops collecting at nodes where the given `stop` function returns `true`.
|
|
270
|
+
* <p>
|
|
271
|
+
* This can be used to exclude certain subtrees from the collection, for example to exclude function bodies when collecting ids on the root level.
|
|
272
|
+
* @param nodes - The root id nodes to start collecting from
|
|
273
|
+
* @param stop - A function that determines whether to stop collecting at a given node, does not stop by default
|
|
274
|
+
* @see {@link collectAllIds} - to collect all ids without stopping
|
|
275
|
+
* @see {@link RProject.collectAllIdsWithStop} - to collect all ids within a project with stopping
|
|
276
|
+
*/
|
|
277
|
+
readonly collectAllIdsWithStop: <OtherInfo>(this: void, nodes: SingleOrArrayOrNothing<RNode<OtherInfo & ParentInformation>>, stop: (node: RNode<OtherInfo & ParentInformation>) => boolean) => Set<NodeId>;
|
|
278
|
+
/**
|
|
279
|
+
* A helper function to retrieve the lexeme of a given node, if available.
|
|
280
|
+
* If the `fullLexeme` is available, it will be returned, otherwise the `lexeme` will be returned.
|
|
281
|
+
*/
|
|
282
|
+
readonly lexeme: <R extends RNode<ParentInformation>>(this: void, node: R | undefined) => R extends {
|
|
283
|
+
lexeme: string;
|
|
284
|
+
} ? string : string | undefined;
|
|
285
|
+
};
|
|
138
286
|
export type OtherInfoNode = RNode | RDelimiter;
|
|
139
|
-
export {};
|