@eagleoutice/flowr 2.2.14 → 2.2.16
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 +210 -6
- package/benchmark/slicer.d.ts +3 -1
- package/benchmark/slicer.js +8 -5
- package/benchmark/summarizer/first-phase/process.d.ts +2 -1
- package/benchmark/summarizer/first-phase/process.js +2 -2
- package/cli/benchmark-app.d.ts +1 -0
- package/cli/benchmark-app.js +4 -1
- package/cli/benchmark-helper-app.d.ts +1 -0
- package/cli/benchmark-helper-app.js +7 -8
- package/cli/common/options.js +2 -0
- package/cli/export-quads-app.js +2 -1
- package/cli/flowr.js +58 -57
- package/cli/repl/commands/repl-cfg.js +13 -13
- package/cli/repl/commands/repl-commands.js +3 -3
- package/cli/repl/commands/repl-dataflow.js +10 -10
- package/cli/repl/commands/repl-execute.d.ts +2 -3
- package/cli/repl/commands/repl-execute.js +5 -4
- package/cli/repl/commands/repl-lineage.js +4 -4
- package/cli/repl/commands/repl-main.d.ts +12 -1
- package/cli/repl/commands/repl-normalize.js +6 -6
- package/cli/repl/commands/repl-parse.js +2 -2
- package/cli/repl/commands/repl-query.js +9 -9
- package/cli/repl/commands/repl-version.js +1 -1
- package/cli/repl/core.d.ts +5 -2
- package/cli/repl/core.js +10 -8
- package/cli/repl/server/connection.d.ts +3 -1
- package/cli/repl/server/connection.js +7 -5
- package/cli/repl/server/server.d.ts +3 -2
- package/cli/repl/server/server.js +4 -2
- package/cli/script-core/statistics-core.d.ts +2 -1
- package/cli/script-core/statistics-core.js +2 -2
- package/cli/script-core/statistics-helper-core.d.ts +2 -1
- package/cli/script-core/statistics-helper-core.js +5 -4
- package/cli/slicer-app.js +4 -2
- package/cli/statistics-app.js +2 -1
- package/cli/statistics-helper-app.js +2 -1
- package/config.d.ts +12 -10
- package/config.js +27 -43
- package/control-flow/basic-cfg-guided-visitor.d.ts +3 -3
- package/control-flow/cfg-dead-code.d.ts +4 -0
- package/control-flow/cfg-dead-code.js +124 -0
- package/control-flow/cfg-simplification.d.ts +19 -6
- package/control-flow/cfg-simplification.js +23 -19
- package/control-flow/control-flow-graph.d.ts +3 -1
- package/control-flow/control-flow-graph.js +5 -0
- package/control-flow/dfg-cfg-guided-visitor.d.ts +9 -7
- package/control-flow/dfg-cfg-guided-visitor.js +16 -5
- package/control-flow/extract-cfg.d.ts +4 -2
- package/control-flow/extract-cfg.js +63 -59
- package/control-flow/semantic-cfg-guided-visitor.d.ts +36 -9
- package/control-flow/semantic-cfg-guided-visitor.js +73 -20
- package/control-flow/simple-visitor.d.ts +4 -0
- package/control-flow/simple-visitor.js +14 -0
- package/control-flow/syntax-cfg-guided-visitor.d.ts +2 -2
- package/core/pipeline-executor.d.ts +4 -1
- package/core/pipeline-executor.js +6 -5
- package/core/steps/all/core/10-normalize.d.ts +2 -0
- package/core/steps/all/core/10-normalize.js +1 -1
- package/core/steps/all/core/11-normalize-tree-sitter.d.ts +2 -1
- package/core/steps/all/core/11-normalize-tree-sitter.js +2 -2
- package/core/steps/all/core/20-dataflow.d.ts +2 -1
- package/core/steps/all/core/20-dataflow.js +2 -2
- package/core/steps/all/static-slicing/00-slice.d.ts +2 -1
- package/core/steps/all/static-slicing/00-slice.js +2 -2
- package/core/steps/pipeline/default-pipelines.d.ts +32 -31
- package/core/steps/pipeline/default-pipelines.js +8 -8
- package/core/steps/pipeline-step.d.ts +2 -1
- package/dataflow/environments/built-in-config.d.ts +4 -3
- package/dataflow/environments/built-in.d.ts +16 -1
- package/dataflow/environments/built-in.js +11 -5
- package/dataflow/environments/default-builtin-config.js +5 -3
- package/dataflow/environments/define.d.ts +2 -1
- package/dataflow/environments/define.js +4 -5
- package/dataflow/environments/remove.d.ts +6 -0
- package/dataflow/environments/remove.js +29 -0
- package/dataflow/environments/resolve-by-name.d.ts +0 -36
- package/dataflow/environments/resolve-by-name.js +0 -240
- package/dataflow/eval/resolve/alias-tracking.d.ts +92 -0
- package/dataflow/eval/resolve/alias-tracking.js +352 -0
- package/dataflow/eval/resolve/resolve-argument.d.ts +8 -0
- package/dataflow/eval/resolve/resolve-argument.js +118 -0
- package/dataflow/eval/resolve/resolve.d.ts +37 -0
- package/dataflow/eval/resolve/resolve.js +95 -0
- package/dataflow/eval/values/general.d.ts +27 -0
- package/dataflow/eval/values/general.js +73 -0
- package/dataflow/eval/values/intervals/interval-constants.d.ts +4 -0
- package/dataflow/eval/values/intervals/interval-constants.js +27 -0
- package/dataflow/eval/values/logical/logical-constants.d.ts +7 -0
- package/dataflow/eval/values/logical/logical-constants.js +31 -0
- package/dataflow/eval/values/r-value.d.ts +58 -0
- package/dataflow/eval/values/r-value.js +90 -0
- package/dataflow/eval/values/scalar/scalar-consatnts.d.ts +15 -0
- package/dataflow/eval/values/scalar/scalar-consatnts.js +35 -0
- package/dataflow/eval/values/sets/set-constants.d.ts +7 -0
- package/dataflow/eval/values/sets/set-constants.js +34 -0
- package/dataflow/eval/values/string/string-constants.d.ts +8 -0
- package/dataflow/eval/values/string/string-constants.js +45 -0
- package/dataflow/eval/values/vectors/vector-constants.d.ts +14 -0
- package/dataflow/eval/values/vectors/vector-constants.js +35 -0
- package/dataflow/extractor.d.ts +2 -1
- package/dataflow/extractor.js +2 -1
- package/dataflow/graph/unknown-replacement.d.ts +11 -0
- package/dataflow/graph/unknown-replacement.js +12 -0
- package/dataflow/graph/unknown-side-effect.d.ts +7 -0
- package/dataflow/graph/unknown-side-effect.js +13 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +5 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +8 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +4 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +15 -13
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +20 -18
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +7 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +2 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +5 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-list.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +11 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +5 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +26 -29
- 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 +23 -0
- package/dataflow/internal/process/functions/call/common.js +1 -1
- package/dataflow/internal/process/functions/call/known-call-handling.js +2 -1
- package/dataflow/internal/process/functions/process-parameter.js +1 -1
- package/dataflow/origin/dfg-get-symbol-refs.d.ts +21 -0
- package/dataflow/origin/dfg-get-symbol-refs.js +50 -0
- package/dataflow/processor.d.ts +5 -0
- package/documentation/doc-util/doc-cfg.js +4 -3
- package/documentation/doc-util/doc-code.d.ts +1 -1
- package/documentation/doc-util/doc-dfg.js +3 -2
- package/documentation/doc-util/doc-functions.d.ts +24 -0
- package/documentation/doc-util/doc-functions.js +65 -0
- package/documentation/doc-util/doc-normalized-ast.js +3 -2
- package/documentation/doc-util/doc-print.d.ts +5 -0
- package/documentation/doc-util/doc-print.js +36 -0
- package/documentation/doc-util/doc-query.d.ts +6 -3
- package/documentation/doc-util/doc-query.js +6 -3
- package/documentation/doc-util/doc-repl.js +2 -1
- package/documentation/doc-util/doc-search.js +3 -2
- package/documentation/doc-util/doc-types.d.ts +28 -6
- package/documentation/doc-util/doc-types.js +89 -45
- package/documentation/print-cfg-wiki.js +10 -11
- package/documentation/print-core-wiki.js +5 -5
- package/documentation/print-dataflow-graph-wiki.js +14 -13
- package/documentation/print-engines-wiki.js +2 -3
- package/documentation/print-faq-wiki.js +8 -2
- package/documentation/print-interface-wiki.js +1 -2
- package/documentation/print-linter-issue.d.ts +1 -0
- package/documentation/print-linter-issue.js +71 -0
- package/documentation/print-linter-wiki.js +219 -34
- package/documentation/print-linting-and-testing-wiki.js +2 -4
- package/documentation/print-normalized-ast-wiki.js +3 -3
- package/documentation/print-query-wiki.js +81 -2
- package/documentation/print-readme.js +24 -1
- package/documentation/print-search-wiki.js +1 -2
- package/linter/linter-executor.d.ts +3 -1
- package/linter/linter-executor.js +3 -2
- package/linter/linter-format.d.ts +67 -7
- package/linter/linter-format.js +12 -1
- package/linter/linter-rules.d.ts +155 -16
- package/linter/linter-rules.js +12 -4
- package/linter/linter-tags.d.ts +80 -0
- package/linter/linter-tags.js +85 -0
- package/linter/rules/absolute-path.d.ts +71 -0
- package/linter/rules/absolute-path.js +177 -0
- package/linter/rules/deprecated-functions.d.ts +43 -0
- package/linter/rules/deprecated-functions.js +58 -0
- package/linter/rules/{2-file-path-validity.d.ts → file-path-validity.d.ts} +16 -6
- package/linter/rules/{2-file-path-validity.js → file-path-validity.js} +21 -13
- package/linter/rules/naming-convention.d.ts +71 -0
- package/linter/rules/naming-convention.js +164 -0
- package/linter/rules/seeded-randomness.d.ts +65 -0
- package/linter/rules/seeded-randomness.js +122 -0
- package/linter/rules/unused-definition.d.ts +41 -0
- package/linter/rules/unused-definition.js +105 -0
- package/package.json +4 -1
- package/queries/base-query-format.d.ts +2 -0
- package/queries/catalog/call-context-query/call-context-query-executor.d.ts +1 -1
- package/queries/catalog/call-context-query/call-context-query-executor.js +2 -2
- package/queries/catalog/cluster-query/cluster-query-format.d.ts +1 -1
- package/queries/catalog/config-query/config-query-executor.d.ts +1 -1
- package/queries/catalog/config-query/config-query-executor.js +2 -3
- package/queries/catalog/control-flow-query/control-flow-query-executor.d.ts +3 -0
- package/queries/catalog/control-flow-query/control-flow-query-executor.js +20 -0
- package/queries/catalog/control-flow-query/control-flow-query-format.d.ts +81 -0
- package/queries/catalog/control-flow-query/control-flow-query-format.js +34 -0
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.d.ts +1 -1
- package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +1 -1
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +4 -115
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +1 -1
- package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +1 -1
- package/queries/catalog/id-map-query/id-map-query-format.d.ts +1 -1
- package/queries/catalog/lineage-query/lineage-query-format.d.ts +1 -1
- package/queries/catalog/linter-query/linter-query-executor.d.ts +1 -1
- package/queries/catalog/linter-query/linter-query-executor.js +2 -2
- package/queries/catalog/linter-query/linter-query-format.d.ts +1 -1
- package/queries/catalog/linter-query/linter-query-format.js +17 -12
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +1 -1
- package/queries/catalog/origin-query/origin-query-format.d.ts +1 -1
- package/queries/catalog/project-query/project-query-format.d.ts +1 -1
- package/queries/catalog/resolve-value-query/resolve-value-query-executor.d.ts +1 -1
- package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +4 -4
- package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +3 -2
- package/queries/catalog/resolve-value-query/resolve-value-query-format.js +2 -22
- package/queries/catalog/search-query/search-query-executor.d.ts +1 -1
- package/queries/catalog/search-query/search-query-executor.js +2 -2
- package/queries/catalog/search-query/search-query-format.d.ts +1 -1
- package/queries/catalog/static-slice-query/static-slice-query-executor.d.ts +1 -1
- package/queries/catalog/static-slice-query/static-slice-query-executor.js +2 -2
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +1 -1
- package/queries/query.d.ts +75 -15
- package/queries/query.js +2 -0
- package/r-bridge/lang-4.x/ast/parser/json/parser.d.ts +2 -1
- package/r-bridge/lang-4.x/ast/parser/json/parser.js +4 -2
- package/r-bridge/lang-4.x/convert-values.js +2 -1
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.d.ts +3 -1
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +4 -4
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.d.ts +1 -1
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +18 -9
- package/r-bridge/shell.d.ts +3 -2
- package/r-bridge/shell.js +4 -5
- package/search/flowr-search-builder.d.ts +6 -2
- package/search/flowr-search-builder.js +7 -0
- package/search/flowr-search-filters.d.ts +32 -8
- package/search/flowr-search-filters.js +42 -15
- package/search/flowr-search.d.ts +4 -0
- package/search/search-executor/search-enrichers.d.ts +7 -3
- package/search/search-executor/search-enrichers.js +32 -20
- package/search/search-executor/search-generators.js +1 -1
- package/search/search-executor/search-transformer.d.ts +2 -0
- package/search/search-executor/search-transformer.js +10 -1
- package/slicing/criterion/parse.d.ts +8 -0
- package/slicing/criterion/parse.js +20 -0
- package/slicing/static/static-slicer.d.ts +1 -1
- package/slicing/static/static-slicer.js +2 -3
- package/statistics/statistics.d.ts +3 -1
- package/statistics/statistics.js +5 -4
- package/util/containers.d.ts +12 -9
- package/util/containers.js +12 -9
- package/util/objects.d.ts +5 -4
- package/util/range.d.ts +5 -1
- package/util/range.js +11 -3
- package/util/text/strings.d.ts +6 -0
- package/util/text/strings.js +35 -0
- package/util/version.js +1 -1
- package/linter/rules/1-deprecated-functions.d.ts +0 -34
- package/linter/rules/1-deprecated-functions.js +0 -54
|
@@ -11,6 +11,8 @@ const logger_1 = require("../../../../../logger");
|
|
|
11
11
|
const environment_1 = require("../../../../../environments/environment");
|
|
12
12
|
const edge_1 = require("../../../../../graph/edge");
|
|
13
13
|
const identifier_1 = require("../../../../../environments/identifier");
|
|
14
|
+
const general_1 = require("../../../../../eval/values/general");
|
|
15
|
+
const alias_tracking_1 = require("../../../../../eval/resolve/alias-tracking");
|
|
14
16
|
function processWhileLoop(name, args, rootId, data) {
|
|
15
17
|
if (args.length !== 2 || args[1] === r_function_call_1.EmptyArgument) {
|
|
16
18
|
logger_1.dataflowLogger.warn(`While-Loop ${name.content} does not have 2 arguments, skipping`);
|
|
@@ -21,6 +23,13 @@ function processWhileLoop(name, args, rootId, data) {
|
|
|
21
23
|
logger_1.dataflowLogger.warn(`While-Loop ${name.content} has empty arguments in ${JSON.stringify(args)}, skipping`);
|
|
22
24
|
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information;
|
|
23
25
|
}
|
|
26
|
+
// we should defer this to the abstract interpretation
|
|
27
|
+
const values = (0, alias_tracking_1.resolveIdToValue)(unpackedArgs[0]?.info.id, { environment: data.environment, idMap: data.completeAst.idMap, resolve: data.flowrConfig.solver.variables });
|
|
28
|
+
const conditionIsAlwaysFalse = (0, general_1.valueSetGuard)(values)?.elements.every(d => d.type === 'logical' && d.value === false) ?? false;
|
|
29
|
+
//We don't care about the body if it never executes
|
|
30
|
+
if (conditionIsAlwaysFalse) {
|
|
31
|
+
unpackedArgs.pop();
|
|
32
|
+
}
|
|
24
33
|
/* we inject the cf-dependency of the while-loop after the condition */
|
|
25
34
|
const { information, processedArguments } = (0, known_call_handling_1.processKnownFunctionCall)({
|
|
26
35
|
name,
|
|
@@ -36,10 +45,24 @@ function processWhileLoop(name, args, rootId, data) {
|
|
|
36
45
|
}, origin: 'builtin:while-loop'
|
|
37
46
|
});
|
|
38
47
|
const [condition, body] = processedArguments;
|
|
48
|
+
// If the condition is always false, we don't include the body
|
|
49
|
+
if (condition !== undefined && conditionIsAlwaysFalse) {
|
|
50
|
+
information.graph.addEdge(name.info.id, condition.entryPoint, edge_1.EdgeType.Reads);
|
|
51
|
+
return {
|
|
52
|
+
unknownReferences: [],
|
|
53
|
+
in: [{ nodeId: name.info.id, name: name.lexeme, controlDependencies: data.controlDependencies, type: identifier_1.ReferenceType.Function }],
|
|
54
|
+
out: condition.out,
|
|
55
|
+
entryPoint: name.info.id,
|
|
56
|
+
exitPoints: [],
|
|
57
|
+
graph: information.graph,
|
|
58
|
+
environment: information.environment
|
|
59
|
+
};
|
|
60
|
+
}
|
|
39
61
|
(0, assert_1.guard)(condition !== undefined && body !== undefined, () => `While-Loop ${name.content} has no condition or body, impossible!`);
|
|
40
62
|
const originalDependency = data.controlDependencies;
|
|
41
63
|
if ((0, info_1.alwaysExits)(condition)) {
|
|
42
64
|
logger_1.dataflowLogger.warn(`While-Loop ${rootId} forces exit in condition, skipping rest`);
|
|
65
|
+
information.graph.addEdge(name.info.id, condition.entryPoint, edge_1.EdgeType.Reads);
|
|
43
66
|
return condition;
|
|
44
67
|
}
|
|
45
68
|
const remainingInputs = (0, linker_1.linkInputs)([
|
|
@@ -83,7 +83,7 @@ function processAllArguments({ functionName, args, data, finalGraph, functionRoo
|
|
|
83
83
|
// When only a single index is referenced, we don't need to reference the whole object
|
|
84
84
|
const resolvedInGraphDef = resolved;
|
|
85
85
|
const isContainer = checkForContainer(resolvedInGraphDef?.indicesCollection);
|
|
86
|
-
if (isContainer
|
|
86
|
+
if (isContainer !== false) {
|
|
87
87
|
finalGraph.addEdge(ingoing.nodeId, resolved.nodeId, edge_1.EdgeType.Reads);
|
|
88
88
|
}
|
|
89
89
|
}
|
|
@@ -10,6 +10,7 @@ const edge_1 = require("../../../../graph/edge");
|
|
|
10
10
|
const logger_1 = require("../../../../logger");
|
|
11
11
|
const vertex_1 = require("../../../../graph/vertex");
|
|
12
12
|
const log_1 = require("../../../../../util/log");
|
|
13
|
+
const unknown_side_effect_1 = require("../../../../graph/unknown-side-effect");
|
|
13
14
|
function markNonStandardEvaluationEdges(markAsNSE, callArgs, finalGraph, rootId) {
|
|
14
15
|
for (const nse of markAsNSE) {
|
|
15
16
|
if (nse < callArgs.length) {
|
|
@@ -46,7 +47,7 @@ function processKnownFunctionCall({ name, args, rootId, data, reverseOrder = fal
|
|
|
46
47
|
origin: origin === 'default' ? ['function'] : [origin]
|
|
47
48
|
});
|
|
48
49
|
if (hasUnknownSideEffect) {
|
|
49
|
-
finalGraph.
|
|
50
|
+
(0, unknown_side_effect_1.handleUnknownSideEffect)(finalGraph, data.environment, rootId);
|
|
50
51
|
}
|
|
51
52
|
const inIds = remainingReadInArgs;
|
|
52
53
|
const fnRef = { nodeId: rootId, name: functionCallName, controlDependencies: data.controlDependencies, type: identifier_1.ReferenceType.Function };
|
|
@@ -20,7 +20,7 @@ function processFunctionParameter(parameter, data) {
|
|
|
20
20
|
for (const writtenNode of writtenNodes) {
|
|
21
21
|
log_1.log.trace(`parameter ${writtenNode.name} (${writtenNode.nodeId}) is defined at id ${writtenNode.definedAt} with ${defaultValue === undefined ? 'no default value' : ' no default value'}`);
|
|
22
22
|
graph.setDefinitionOfVertex(writtenNode);
|
|
23
|
-
environment = (0, define_1.define)(writtenNode, false, environment);
|
|
23
|
+
environment = (0, define_1.define)(writtenNode, false, environment, data.flowrConfig);
|
|
24
24
|
if (defaultValue !== undefined) {
|
|
25
25
|
if (parameter.defaultValue?.type === type_1.RType.FunctionDefinition) {
|
|
26
26
|
graph.addEdge(writtenNode, parameter.defaultValue.info.id, edge_1.EdgeType.DefinedBy);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
2
|
+
import type { DataflowGraph } from '../graph/graph';
|
|
3
|
+
/**
|
|
4
|
+
* Finds the definition of a variable and all other uses from that point on
|
|
5
|
+
*
|
|
6
|
+
* For example, for the following code
|
|
7
|
+
* ```ts
|
|
8
|
+
* y <- 5
|
|
9
|
+
* f <- function() {
|
|
10
|
+
* y <- 8
|
|
11
|
+
* print(y)
|
|
12
|
+
* }
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* @example getAllRefsToSymbol('3\@y') returns ['3\@y', '4\@y']
|
|
16
|
+
*
|
|
17
|
+
* @param graph - Dataflow Graph
|
|
18
|
+
* @param nodeId - NodeId of Symbol to resolve
|
|
19
|
+
* @returns List including the Definitions and Refereneces to that definition
|
|
20
|
+
*/
|
|
21
|
+
export declare function getAllRefsToSymbol(graph: DataflowGraph, nodeId: NodeId): NodeId[] | undefined;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAllRefsToSymbol = getAllRefsToSymbol;
|
|
4
|
+
const edge_1 = require("../graph/edge");
|
|
5
|
+
const info_1 = require("../info");
|
|
6
|
+
const dfg_get_origin_1 = require("./dfg-get-origin");
|
|
7
|
+
/**
|
|
8
|
+
* Finds the definition of a variable and all other uses from that point on
|
|
9
|
+
*
|
|
10
|
+
* For example, for the following code
|
|
11
|
+
* ```ts
|
|
12
|
+
* y <- 5
|
|
13
|
+
* f <- function() {
|
|
14
|
+
* y <- 8
|
|
15
|
+
* print(y)
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @example getAllRefsToSymbol('3\@y') returns ['3\@y', '4\@y']
|
|
20
|
+
*
|
|
21
|
+
* @param graph - Dataflow Graph
|
|
22
|
+
* @param nodeId - NodeId of Symbol to resolve
|
|
23
|
+
* @returns List including the Definitions and Refereneces to that definition
|
|
24
|
+
*/
|
|
25
|
+
function getAllRefsToSymbol(graph, nodeId) {
|
|
26
|
+
// Get all origins and filter for ones that happen for sure
|
|
27
|
+
const origins = (0, dfg_get_origin_1.getOriginInDfg)(graph, nodeId);
|
|
28
|
+
if (origins === undefined) {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
const definitiveOrigins = origins.filter(o => (0, info_1.happensInEveryBranch)(graph.getVertex(o.id)?.cds));
|
|
32
|
+
if (definitiveOrigins.length === 0) {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
// Gather all the references
|
|
36
|
+
const res = new Set();
|
|
37
|
+
for (const origin of definitiveOrigins) {
|
|
38
|
+
res.add(origin.id);
|
|
39
|
+
graph.ingoingEdges(origin.id)
|
|
40
|
+
?.entries()
|
|
41
|
+
.filter(([_, edge]) => (0, edge_1.edgeIncludesType)(edge.types, edge_1.EdgeType.Reads))
|
|
42
|
+
.forEach(([node, _]) => res.add(node));
|
|
43
|
+
graph.outgoingEdges(origin.id)
|
|
44
|
+
?.entries()
|
|
45
|
+
.filter(([_, edge]) => (0, edge_1.edgeIncludesType)(edge.types, edge_1.EdgeType.DefinedByOnCall))
|
|
46
|
+
.forEach(([node, _]) => res.add(node));
|
|
47
|
+
}
|
|
48
|
+
return [...res];
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=dfg-get-symbol-refs.js.map
|
package/dataflow/processor.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import type { REnvironmentInformation } from './environments/environment';
|
|
|
7
7
|
import type { RParseRequest } from '../r-bridge/retriever';
|
|
8
8
|
import type { RNode } from '../r-bridge/lang-4.x/ast/model/model';
|
|
9
9
|
import type { KnownParserType, Parser } from '../r-bridge/parser';
|
|
10
|
+
import type { FlowrConfigOptions } from '../config';
|
|
10
11
|
export interface DataflowProcessorInformation<OtherInfo> {
|
|
11
12
|
readonly parser: Parser<KnownParserType>;
|
|
12
13
|
/**
|
|
@@ -35,6 +36,10 @@ export interface DataflowProcessorInformation<OtherInfo> {
|
|
|
35
36
|
* The chain of control-flow {@link NodeId}s that lead to the current node (e.g., of known ifs).
|
|
36
37
|
*/
|
|
37
38
|
readonly controlDependencies: ControlDependency[] | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* The flowr configuration used for environment seeding, and precision control
|
|
41
|
+
*/
|
|
42
|
+
readonly flowrConfig: FlowrConfigOptions;
|
|
38
43
|
}
|
|
39
44
|
export type DataflowProcessor<OtherInfo, NodeType extends RNodeWithParent<OtherInfo>> = (node: NodeType, data: DataflowProcessorInformation<OtherInfo>) => DataflowInformation;
|
|
40
45
|
type NodeWithKey<OtherInfo, Key> = RNode<OtherInfo & ParentInformation> & {
|
|
@@ -11,13 +11,14 @@ const doc_files_1 = require("./doc-files");
|
|
|
11
11
|
const cfg_1 = require("../../util/mermaid/cfg");
|
|
12
12
|
const doc_code_1 = require("./doc-code");
|
|
13
13
|
const cfg_simplification_1 = require("../../control-flow/cfg-simplification");
|
|
14
|
+
const config_1 = require("../../config");
|
|
14
15
|
async function getCfg(parser, code, simplifications = [], useDfg = true) {
|
|
15
16
|
const result = useDfg ? await (0, default_pipelines_1.createDataflowPipeline)(parser, {
|
|
16
17
|
request: (0, retriever_1.requestFromInput)(code)
|
|
17
|
-
}).allRemainingSteps() : await (0, default_pipelines_1.createNormalizePipeline)(parser, {
|
|
18
|
+
}, config_1.defaultConfigOptions).allRemainingSteps() : await (0, default_pipelines_1.createNormalizePipeline)(parser, {
|
|
18
19
|
request: (0, retriever_1.requestFromInput)(code)
|
|
19
|
-
}).allRemainingSteps();
|
|
20
|
-
const cfg = (0, extract_cfg_1.extractCfg)(result.normalize, useDfg ? result.dataflow.graph : undefined, [...cfg_simplification_1.DefaultCfgSimplificationOrder, ...simplifications]);
|
|
20
|
+
}, config_1.defaultConfigOptions).allRemainingSteps();
|
|
21
|
+
const cfg = (0, extract_cfg_1.extractCfg)(result.normalize, config_1.defaultConfigOptions, useDfg ? result.dataflow.graph : undefined, [...cfg_simplification_1.DefaultCfgSimplificationOrder, ...simplifications]);
|
|
21
22
|
return {
|
|
22
23
|
info: cfg,
|
|
23
24
|
ast: result.normalize,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare function codeBlock(language: string, code: string
|
|
1
|
+
export declare function codeBlock(language: string, code: string): string;
|
|
2
2
|
export declare function codeInline(code: string): string;
|
|
3
3
|
export declare function jsonWithLimit(object: object, maxLength?: number, tooLongText?: string): string;
|
|
@@ -15,6 +15,7 @@ const assert_1 = require("../../util/assert");
|
|
|
15
15
|
const time_1 = require("../../util/text/time");
|
|
16
16
|
const doc_files_1 = require("./doc-files");
|
|
17
17
|
const doc_code_1 = require("./doc-code");
|
|
18
|
+
const config_1 = require("../../config");
|
|
18
19
|
function printDfGraph(graph, mark, simplified = false) {
|
|
19
20
|
return `
|
|
20
21
|
${(0, doc_code_1.codeBlock)('mermaid', (0, dfg_1.graphToMermaid)({
|
|
@@ -37,7 +38,7 @@ async function printDfGraphForCode(parser, code, { simplified = false, mark, sho
|
|
|
37
38
|
const now = performance.now();
|
|
38
39
|
const result = await (0, default_pipelines_1.createDataflowPipeline)(parser, {
|
|
39
40
|
request: (0, retriever_1.requestFromInput)(code)
|
|
40
|
-
}).allRemainingSteps();
|
|
41
|
+
}, config_1.defaultConfigOptions).allRemainingSteps();
|
|
41
42
|
const duration = performance.now() - now;
|
|
42
43
|
if (switchCodeAndGraph) {
|
|
43
44
|
(0, assert_1.guard)(showCode, 'can not switch code and graph if code is not shown');
|
|
@@ -76,7 +77,7 @@ async function verifyExpectedSubgraph(shell, code, expectedSubgraph) {
|
|
|
76
77
|
parser: shell,
|
|
77
78
|
request: (0, retriever_1.requestFromInput)(code),
|
|
78
79
|
getId: (0, decorate_1.deterministicCountingIdGenerator)(0)
|
|
79
|
-
}).allRemainingSteps();
|
|
80
|
+
}, config_1.defaultConfigOptions).allRemainingSteps();
|
|
80
81
|
expectedSubgraph.setIdMap(info.normalize.idMap);
|
|
81
82
|
expectedSubgraph = (0, resolve_graph_1.resolveDataflowGraph)(expectedSubgraph);
|
|
82
83
|
const report = (0, diff_dataflow_graph_1.diffOfDataflowGraphs)({ name: 'expected', graph: expectedSubgraph }, { name: 'got', graph: info.dataflow.graph }, {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Expression } from 'typescript';
|
|
2
|
+
import ts from 'typescript';
|
|
3
|
+
export interface FunctionElementInSource {
|
|
4
|
+
name: string;
|
|
5
|
+
node: ts.Node;
|
|
6
|
+
source: ts.SourceFile;
|
|
7
|
+
kind: 'function';
|
|
8
|
+
arguments: Expression[];
|
|
9
|
+
lineNumber: number;
|
|
10
|
+
comments?: string[];
|
|
11
|
+
}
|
|
12
|
+
export interface GetFunctionsOption {
|
|
13
|
+
readonly rootFolder?: string;
|
|
14
|
+
readonly files?: readonly string[];
|
|
15
|
+
readonly fname?: RegExp;
|
|
16
|
+
}
|
|
17
|
+
export interface FunctionsReport {
|
|
18
|
+
info: FunctionElementInSource[];
|
|
19
|
+
program: ts.Program;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Inspect typescript source code for types and return a report.
|
|
23
|
+
*/
|
|
24
|
+
export declare function getFunctionsFromFolder(options: GetFunctionsOption): FunctionsReport;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getFunctionsFromFolder = getFunctionsFromFolder;
|
|
7
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
8
|
+
const assert_1 = require("../../util/assert");
|
|
9
|
+
const fs_1 = __importDefault(require("fs"));
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const doc_types_1 = require("./doc-types");
|
|
12
|
+
function collectHierarchyInformation(sourceFiles, options, fname) {
|
|
13
|
+
const hierarchyList = [];
|
|
14
|
+
const visit = (node, sourceFile) => {
|
|
15
|
+
if (!node) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (typescript_1.default.isCallExpression(node) || typescript_1.default.isNewExpression(node)) {
|
|
19
|
+
const name = node.expression.getText(sourceFile);
|
|
20
|
+
if (!fname || fname.test(name)) {
|
|
21
|
+
const comments = typescript_1.default.getLeadingCommentRanges(sourceFile.getText(sourceFile), node.getFullStart())?.map(c => {
|
|
22
|
+
return (0, doc_types_1.removeCommentSymbolsFromTypeScriptComment)(sourceFile.getText(sourceFile).substring(c.pos, c.end).trim());
|
|
23
|
+
});
|
|
24
|
+
hierarchyList.push({
|
|
25
|
+
name: (0, doc_types_1.dropGenericsFromTypeName)(name),
|
|
26
|
+
node,
|
|
27
|
+
kind: 'function',
|
|
28
|
+
comments,
|
|
29
|
+
lineNumber: (0, doc_types_1.getStartLineOfTypeScriptNode)(node, sourceFile),
|
|
30
|
+
source: sourceFile,
|
|
31
|
+
arguments: node.arguments?.map(n => n) ?? []
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
typescript_1.default.forEachChild(node, child => visit(child, sourceFile));
|
|
36
|
+
};
|
|
37
|
+
sourceFiles.forEach(sourceFile => {
|
|
38
|
+
visit(sourceFile, sourceFile);
|
|
39
|
+
});
|
|
40
|
+
return hierarchyList;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Inspect typescript source code for types and return a report.
|
|
44
|
+
*/
|
|
45
|
+
function getFunctionsFromFolder(options) {
|
|
46
|
+
(0, assert_1.guard)(options.rootFolder !== undefined || options.files !== undefined, 'Either rootFolder or files must be provided');
|
|
47
|
+
const fileNames = [...options.files ?? []];
|
|
48
|
+
if (options.rootFolder) {
|
|
49
|
+
for (const fileBuff of fs_1.default.readdirSync(options.rootFolder, { recursive: true })) {
|
|
50
|
+
const file = fileBuff.toString();
|
|
51
|
+
if (file.endsWith('.ts')) {
|
|
52
|
+
fileNames.push(path_1.default.join(options.rootFolder, file));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const { files, program } = (0, doc_types_1.getTypeScriptSourceFiles)(fileNames);
|
|
57
|
+
(0, assert_1.guard)(files.length > 0, () => `No source files found for ${JSON.stringify(fileNames)}`);
|
|
58
|
+
const withProgram = { ...options, program };
|
|
59
|
+
const hierarchyList = collectHierarchyInformation(files, withProgram, options.fname);
|
|
60
|
+
return {
|
|
61
|
+
info: hierarchyList,
|
|
62
|
+
program
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=doc-functions.js.map
|
|
@@ -12,6 +12,7 @@ const assert_1 = require("../../util/assert");
|
|
|
12
12
|
const ast_1 = require("../../util/mermaid/ast");
|
|
13
13
|
const time_1 = require("../../util/text/time");
|
|
14
14
|
const doc_files_1 = require("./doc-files");
|
|
15
|
+
const config_1 = require("../../config");
|
|
15
16
|
function printNormalizedAst(ast, prefix = 'flowchart TD\n') {
|
|
16
17
|
return `
|
|
17
18
|
\`\`\`mermaid
|
|
@@ -23,7 +24,7 @@ async function printNormalizedAstForCode(parser, code, { showCode = true, prefix
|
|
|
23
24
|
const now = performance.now();
|
|
24
25
|
const result = await (0, default_pipelines_1.createNormalizePipeline)(parser, {
|
|
25
26
|
request: (0, retriever_1.requestFromInput)(code)
|
|
26
|
-
}).allRemainingSteps();
|
|
27
|
+
}, config_1.defaultConfigOptions).allRemainingSteps();
|
|
27
28
|
const duration = performance.now() - now;
|
|
28
29
|
const metaInfo = `The analysis required _${(0, time_1.printAsMs)(duration)}_ (including parsing with the [${parser.name}](${doc_files_1.FlowrWikiBaseRef}/Engines) engine) within the generation environment.`;
|
|
29
30
|
return '\n\n' + printNormalizedAst(result.normalize.ast, prefix) + (showCode ? `
|
|
@@ -57,7 +58,7 @@ async function verifyExpectedSubgraph(shell, code, expectedSubgraph) {
|
|
|
57
58
|
const info = await (0, default_pipelines_1.createDataflowPipeline)(shell, {
|
|
58
59
|
request: (0, retriever_1.requestFromInput)(code),
|
|
59
60
|
getId: (0, decorate_1.deterministicCountingIdGenerator)(0)
|
|
60
|
-
}).allRemainingSteps();
|
|
61
|
+
}, config_1.defaultConfigOptions).allRemainingSteps();
|
|
61
62
|
expectedSubgraph.setIdMap(info.normalize.idMap);
|
|
62
63
|
expectedSubgraph = (0, resolve_graph_1.resolveDataflowGraph)(expectedSubgraph);
|
|
63
64
|
const report = (0, diff_dataflow_graph_1.diffOfDataflowGraphs)({ name: 'expected', graph: expectedSubgraph }, { name: 'got', graph: info.dataflow.graph }, {
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.writeWikiTo = writeWikiTo;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
/* eslint-disable */
|
|
10
|
+
const IgnoreRegex = /[0-9]+(\.[0-9]+)? ?ms|"timing":\s*[0-9]+(\.0-9)?,?|tmp-[A-Za-z0-9-]+/g;
|
|
11
|
+
/* eslint-enable */
|
|
12
|
+
/**
|
|
13
|
+
* Checks whether the file contains a different content, but ignores timing and some other non-semantic changes.
|
|
14
|
+
*/
|
|
15
|
+
function didFileChange(filePath, content) {
|
|
16
|
+
if (!fs_1.default.existsSync(filePath)) {
|
|
17
|
+
return true; // If the file does not exist, it is considered changed.
|
|
18
|
+
}
|
|
19
|
+
const currentContent = fs_1.default.readFileSync(filePath, 'utf-8');
|
|
20
|
+
const cleanedCurrentContent = currentContent.replace(IgnoreRegex, '');
|
|
21
|
+
const cleanedNewContent = content.replace(IgnoreRegex, '');
|
|
22
|
+
return cleanedCurrentContent !== cleanedNewContent;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Writes the wiki documentation to the specified output path.
|
|
26
|
+
* Returns true if the file was updated, false if it was unchanged.
|
|
27
|
+
*/
|
|
28
|
+
function writeWikiTo(text, output_path, check_change = true) {
|
|
29
|
+
if (!check_change || didFileChange(output_path, text)) {
|
|
30
|
+
fs_1.default.mkdirSync(path_1.default.dirname(output_path), { recursive: true });
|
|
31
|
+
fs_1.default.writeFileSync(output_path, text, 'utf-8');
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=doc-print.js.map
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import type { RShell } from '../../r-bridge/shell';
|
|
2
|
-
import type { Queries, SupportedQueryTypes } from '../../queries/query';
|
|
2
|
+
import type { Queries, QueryResults, SupportedQueryTypes } from '../../queries/query';
|
|
3
|
+
import { DEFAULT_DATAFLOW_PIPELINE } from '../../core/steps/pipeline/default-pipelines';
|
|
3
4
|
import type { SupportedVirtualQueryTypes } from '../../queries/virtual-query/virtual-queries';
|
|
4
5
|
import type { VirtualCompoundConstraint } from '../../queries/virtual-query/compound-query';
|
|
5
|
-
|
|
6
|
+
import type { PipelineOutput } from '../../core/steps/pipeline/pipeline';
|
|
7
|
+
export interface ShowQueryOptions<Base extends SupportedQueryTypes> {
|
|
6
8
|
readonly showCode?: boolean;
|
|
7
9
|
readonly collapseResult?: boolean;
|
|
8
10
|
readonly collapseQuery?: boolean;
|
|
11
|
+
readonly addOutput?: (result: QueryResults<Base>, pipeline: PipelineOutput<typeof DEFAULT_DATAFLOW_PIPELINE>) => string;
|
|
9
12
|
}
|
|
10
|
-
export declare function showQuery<Base extends SupportedQueryTypes, VirtualArguments extends VirtualCompoundConstraint<Base> = VirtualCompoundConstraint<Base>>(shell: RShell, code: string, queries: Queries<Base, VirtualArguments>, { showCode, collapseResult, collapseQuery }?: ShowQueryOptions): Promise<string>;
|
|
13
|
+
export declare function showQuery<Base extends SupportedQueryTypes, VirtualArguments extends VirtualCompoundConstraint<Base> = VirtualCompoundConstraint<Base>>(shell: RShell, code: string, queries: Queries<Base, VirtualArguments>, { showCode, collapseResult, collapseQuery, addOutput }?: ShowQueryOptions<Base>): Promise<string>;
|
|
11
14
|
export interface QueryDocumentation {
|
|
12
15
|
readonly name: string;
|
|
13
16
|
readonly type: 'virtual' | 'active';
|
|
@@ -17,13 +17,14 @@ const doc_dfg_1 = require("./doc-dfg");
|
|
|
17
17
|
const doc_code_1 = require("./doc-code");
|
|
18
18
|
const time_1 = require("../../util/text/time");
|
|
19
19
|
const query_print_1 = require("../../queries/query-print");
|
|
20
|
-
|
|
20
|
+
const config_1 = require("../../config");
|
|
21
|
+
async function showQuery(shell, code, queries, { showCode, collapseResult, collapseQuery, addOutput = () => '' } = {}) {
|
|
21
22
|
const now = performance.now();
|
|
22
23
|
const analysis = await new pipeline_executor_1.PipelineExecutor(default_pipelines_1.DEFAULT_DATAFLOW_PIPELINE, {
|
|
23
24
|
parser: shell,
|
|
24
25
|
request: (0, retriever_1.requestFromInput)(code)
|
|
25
|
-
}).allRemainingSteps();
|
|
26
|
-
const results = (0, query_1.executeQueries)({ dataflow: analysis.dataflow, ast: analysis.normalize }, queries);
|
|
26
|
+
}, config_1.defaultConfigOptions).allRemainingSteps();
|
|
27
|
+
const results = (0, query_1.executeQueries)({ dataflow: analysis.dataflow, ast: analysis.normalize, config: config_1.defaultConfigOptions }, queries);
|
|
27
28
|
const duration = performance.now() - now;
|
|
28
29
|
const metaInfo = `
|
|
29
30
|
The analysis required _${(0, time_1.printAsMs)(duration)}_ (including parsing and normalization and the query) within the generation environment.
|
|
@@ -60,6 +61,8 @@ ${await (0, doc_dfg_1.printDfGraphForCode)(shell, code, { switchCodeAndGraph: tr
|
|
|
60
61
|
|
|
61
62
|
${collapseResult ? '</details>' : ''}
|
|
62
63
|
|
|
64
|
+
${addOutput(results, analysis)}
|
|
65
|
+
|
|
63
66
|
`;
|
|
64
67
|
}
|
|
65
68
|
exports.RegisteredQueries = {
|
|
@@ -11,6 +11,7 @@ const doc_docker_1 = require("./doc-docker");
|
|
|
11
11
|
const prompt_1 = require("../../cli/repl/prompt");
|
|
12
12
|
const doc_code_1 = require("./doc-code");
|
|
13
13
|
const print_version_1 = require("../../cli/repl/print-version");
|
|
14
|
+
const config_1 = require("../../config");
|
|
14
15
|
function printHelpForScript(script, starredVersion) {
|
|
15
16
|
let base = `| **${(0, doc_cli_option_1.getReplCommand)(script[0], false, starredVersion !== undefined)}** | ${script[1].description}`;
|
|
16
17
|
if (starredVersion) {
|
|
@@ -51,7 +52,7 @@ async function documentReplSession(parser, commands, options) {
|
|
|
51
52
|
entry.lines.push(msg);
|
|
52
53
|
}
|
|
53
54
|
};
|
|
54
|
-
await (0, core_1.replProcessAnswer)(collectingOutput, command.command, parser, options?.allowRSessionAccess ?? false);
|
|
55
|
+
await (0, core_1.replProcessAnswer)(config_1.defaultConfigOptions, collectingOutput, command.command, parser, options?.allowRSessionAccess ?? false);
|
|
55
56
|
collect.push(entry);
|
|
56
57
|
}
|
|
57
58
|
let result = '';
|
|
@@ -17,13 +17,14 @@ const flowr_search_executor_1 = require("../../search/flowr-search-executor");
|
|
|
17
17
|
const flowr_search_printer_1 = require("../../search/flowr-search-printer");
|
|
18
18
|
const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
19
19
|
const dfg_1 = require("../../util/mermaid/dfg");
|
|
20
|
+
const config_1 = require("../../config");
|
|
20
21
|
async function showSearch(shell, code, search, { collapseResult = true } = {}) {
|
|
21
22
|
const now = performance.now();
|
|
22
23
|
const analysis = await new pipeline_executor_1.PipelineExecutor(default_pipelines_1.DEFAULT_DATAFLOW_PIPELINE, {
|
|
23
24
|
parser: shell,
|
|
24
25
|
request: (0, retriever_1.requestFromInput)(code)
|
|
25
|
-
}).allRemainingSteps();
|
|
26
|
-
const result = (0, flowr_search_executor_1.runSearch)(search, analysis);
|
|
26
|
+
}, config_1.defaultConfigOptions).allRemainingSteps();
|
|
27
|
+
const result = (0, flowr_search_executor_1.runSearch)(search, { ...analysis, config: config_1.defaultConfigOptions });
|
|
27
28
|
const duration = performance.now() - now;
|
|
28
29
|
const metaInfo = `
|
|
29
30
|
The search required _${(0, time_1.printAsMs)(duration)}_ (including parsing and normalization and the query) within the generation environment.
|
|
@@ -10,21 +10,42 @@ export interface TypeElementInSource {
|
|
|
10
10
|
comments?: string[];
|
|
11
11
|
readonly properties?: string[];
|
|
12
12
|
}
|
|
13
|
+
export declare function getTypeScriptSourceFiles(fileNames: readonly string[]): {
|
|
14
|
+
files: ts.SourceFile[];
|
|
15
|
+
program: ts.Program;
|
|
16
|
+
};
|
|
17
|
+
export declare function dropGenericsFromTypeName(type: string): string;
|
|
18
|
+
export declare function removeCommentSymbolsFromTypeScriptComment(comment: string): string;
|
|
19
|
+
export declare function getTextualCommentsFromTypeScript(node: ts.Node): string[];
|
|
20
|
+
export declare function getStartLineOfTypeScriptNode(node: ts.Node, sourceFile: ts.SourceFile): number;
|
|
13
21
|
export declare function getType(node: ts.Node, typeChecker: ts.TypeChecker): string;
|
|
14
22
|
export declare function followTypeReference(type: ts.TypeReferenceNode, sourceFile: ts.SourceFile): string[];
|
|
15
|
-
export declare function
|
|
23
|
+
export declare function getTypePathForTypeScript({ filePath }: Pick<TypeElementInSource, 'filePath'>): string;
|
|
24
|
+
export declare function getTypePathLink(elem: Pick<TypeElementInSource, 'filePath' | 'lineNumber'>, prefix?: string): string;
|
|
16
25
|
export interface GetTypesAsMermaidOption {
|
|
17
26
|
readonly rootFolder?: string;
|
|
18
27
|
readonly files?: readonly string[];
|
|
19
|
-
|
|
28
|
+
/** if you request a type name, we will generate a mermaid diagram for that type */
|
|
29
|
+
readonly typeNameForMermaid?: string;
|
|
20
30
|
readonly inlineTypes?: readonly string[];
|
|
21
31
|
}
|
|
22
|
-
export interface
|
|
23
|
-
|
|
32
|
+
export interface TypeReport {
|
|
33
|
+
/** if you request a type name this will include the mermaid diagram for the type */
|
|
34
|
+
mermaid: string | undefined;
|
|
24
35
|
info: TypeElementInSource[];
|
|
25
36
|
program: ts.Program;
|
|
26
37
|
}
|
|
27
|
-
export declare function
|
|
38
|
+
export declare function getTypesFromFolder(options: GetTypesAsMermaidOption & {
|
|
39
|
+
typeNameForMermaid: string;
|
|
40
|
+
}): (TypeReport & {
|
|
41
|
+
mermaid: string;
|
|
42
|
+
});
|
|
43
|
+
export declare function getTypesFromFolder(options: GetTypesAsMermaidOption & {
|
|
44
|
+
typeNameForMermaid?: undefined;
|
|
45
|
+
}): (TypeReport & {
|
|
46
|
+
mermaid: undefined;
|
|
47
|
+
});
|
|
48
|
+
export declare function getTypesFromFolder(options: GetTypesAsMermaidOption): TypeReport;
|
|
28
49
|
export declare function implSnippet(node: TypeElementInSource | undefined, program: ts.Program, showName?: boolean, nesting?: number, open?: boolean): string;
|
|
29
50
|
export interface PrintHierarchyArguments {
|
|
30
51
|
readonly program: ts.Program;
|
|
@@ -51,5 +72,6 @@ export declare function printCodeOfElement({ program, info }: FnInfo, name: stri
|
|
|
51
72
|
* @param realNameWrapper - How to highlight the function in name in the `x::y` format?
|
|
52
73
|
*/
|
|
53
74
|
export declare function shortLink(name: string, hierarchy: readonly TypeElementInSource[], codeStyle?: boolean, realNameWrapper?: string): string;
|
|
54
|
-
export declare function
|
|
75
|
+
export declare function shortLinkFile(name: string, hierarchy: readonly TypeElementInSource[]): string;
|
|
76
|
+
export declare function getDocumentationForType(name: string, hierarchy: TypeElementInSource[], prefix?: string, fuzzy?: boolean): string;
|
|
55
77
|
export {};
|