@eagleoutice/flowr 2.2.15 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +226 -6
- package/abstract-interpretation/data-frame/absint-info.d.ts +109 -0
- package/abstract-interpretation/data-frame/absint-info.js +31 -0
- package/abstract-interpretation/data-frame/absint-visitor.d.ts +59 -0
- package/abstract-interpretation/data-frame/absint-visitor.js +173 -0
- package/abstract-interpretation/data-frame/domain.d.ts +107 -0
- package/abstract-interpretation/data-frame/domain.js +315 -0
- package/abstract-interpretation/data-frame/mappers/access-mapper.d.ts +17 -0
- package/abstract-interpretation/data-frame/mappers/access-mapper.js +166 -0
- package/abstract-interpretation/data-frame/mappers/arguments.d.ts +117 -0
- package/abstract-interpretation/data-frame/mappers/arguments.js +188 -0
- package/abstract-interpretation/data-frame/mappers/assignment-mapper.d.ts +20 -0
- package/abstract-interpretation/data-frame/mappers/assignment-mapper.js +34 -0
- package/abstract-interpretation/data-frame/mappers/function-mapper.d.ts +261 -0
- package/abstract-interpretation/data-frame/mappers/function-mapper.js +1219 -0
- package/abstract-interpretation/data-frame/mappers/replacement-mapper.d.ts +12 -0
- package/abstract-interpretation/data-frame/mappers/replacement-mapper.js +206 -0
- package/abstract-interpretation/data-frame/resolve-args.d.ts +42 -0
- package/abstract-interpretation/data-frame/resolve-args.js +118 -0
- package/abstract-interpretation/data-frame/semantics.d.ts +213 -0
- package/abstract-interpretation/data-frame/semantics.js +366 -0
- package/abstract-interpretation/data-frame/shape-inference.d.ts +38 -0
- package/abstract-interpretation/data-frame/shape-inference.js +117 -0
- package/benchmark/slicer.d.ts +18 -2
- package/benchmark/slicer.js +143 -5
- package/benchmark/stats/print.js +123 -45
- package/benchmark/stats/size-of.d.ts +7 -0
- package/benchmark/stats/size-of.js +1 -0
- package/benchmark/stats/stats.d.ts +30 -1
- package/benchmark/stats/stats.js +4 -2
- package/benchmark/summarizer/data.d.ts +33 -2
- package/benchmark/summarizer/first-phase/input.js +5 -1
- package/benchmark/summarizer/first-phase/process.d.ts +2 -1
- package/benchmark/summarizer/first-phase/process.js +49 -3
- package/benchmark/summarizer/second-phase/process.js +101 -3
- package/cli/benchmark-app.d.ts +2 -0
- package/cli/benchmark-app.js +5 -1
- package/cli/benchmark-helper-app.d.ts +2 -0
- package/cli/benchmark-helper-app.js +13 -8
- package/cli/common/options.js +4 -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 +2 -2
- 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 +4 -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 +43 -10
- package/config.js +47 -43
- package/control-flow/cfg-dead-code.js +45 -2
- package/control-flow/cfg-simplification.d.ts +2 -0
- package/control-flow/control-flow-graph.d.ts +2 -0
- package/control-flow/control-flow-graph.js +8 -0
- package/control-flow/dfg-cfg-guided-visitor.d.ts +5 -3
- package/control-flow/dfg-cfg-guided-visitor.js +15 -4
- package/control-flow/extract-cfg.d.ts +4 -2
- package/control-flow/extract-cfg.js +4 -3
- package/control-flow/semantic-cfg-guided-visitor.d.ts +20 -2
- package/control-flow/semantic-cfg-guided-visitor.js +24 -4
- 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 +3 -3
- package/dataflow/environments/built-in.d.ts +11 -3
- package/dataflow/environments/built-in.js +5 -3
- package/dataflow/environments/default-builtin-config.js +4 -2
- 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/eval/resolve/alias-tracking.d.ts +7 -2
- package/dataflow/eval/resolve/alias-tracking.js +11 -8
- 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 +65 -18
- package/dataflow/eval/resolve/resolve.js +144 -48
- package/dataflow/eval/values/string/string-constants.d.ts +1 -1
- package/dataflow/eval/values/string/string-constants.js +7 -2
- package/dataflow/extractor.d.ts +2 -1
- package/dataflow/extractor.js +2 -1
- 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 +1 -1
- 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 +11 -11
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +10 -11
- 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 +1 -1
- 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 +2 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +6 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +19 -15
- 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 +1 -1
- package/dataflow/internal/process/functions/call/common.js +1 -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.js +13 -2
- 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 +6 -7
- package/documentation/print-core-wiki.js +5 -5
- package/documentation/print-dataflow-graph-wiki.js +10 -10
- package/documentation/print-engines-wiki.js +1 -2
- package/documentation/print-faq-wiki.js +8 -2
- package/documentation/print-interface-wiki.js +12 -2
- package/documentation/print-linter-issue.d.ts +1 -0
- package/documentation/print-linter-issue.js +71 -0
- package/documentation/print-linter-wiki.js +223 -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 +18 -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 +178 -16
- package/linter/linter-rules.js +14 -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/dataframe-access-validation.d.ts +53 -0
- package/linter/rules/dataframe-access-validation.js +116 -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 +168 -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 +5 -2
- 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 +1 -1
- package/queries/catalog/control-flow-query/control-flow-query-executor.js +2 -2
- package/queries/catalog/control-flow-query/control-flow-query-format.d.ts +1 -1
- 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 -116
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +1 -1
- package/queries/catalog/df-shape-query/df-shape-query-executor.d.ts +3 -0
- package/queries/catalog/df-shape-query/df-shape-query-executor.js +46 -0
- package/queries/catalog/df-shape-query/df-shape-query-format.d.ts +72 -0
- package/queries/catalog/df-shape-query/df-shape-query-format.js +31 -0
- 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 +16 -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 +2 -2
- package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +1 -1
- 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 +76 -16
- 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 +7 -5
- 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 +29 -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/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/files.d.ts +8 -2
- package/util/files.js +22 -4
- package/util/objects.d.ts +5 -4
- package/util/r-value.d.ts +23 -0
- package/util/r-value.js +113 -0
- 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
- package/util/cfg/cfg.d.ts +0 -0
- package/util/cfg/cfg.js +0 -2
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type DataflowProcessorInformation } from '../../../../../processor';
|
|
2
2
|
import type { DataflowInformation } from '../../../../../info';
|
|
3
|
+
import type { FlowrLaxSourcingOptions } from '../../../../../../config';
|
|
3
4
|
import { InferWorkingDirectory } from '../../../../../../config';
|
|
4
5
|
import type { RParseRequest, RParseRequestProvider } from '../../../../../../r-bridge/retriever';
|
|
5
6
|
import type { IdGenerator, ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
@@ -7,14 +8,16 @@ import type { RFunctionArgument } from '../../../../../../r-bridge/lang-4.x/ast/
|
|
|
7
8
|
import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
|
|
8
9
|
import type { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
9
10
|
import type { NoInfo } from '../../../../../../r-bridge/lang-4.x/ast/model/model';
|
|
11
|
+
export declare function getSourceProvider(): RParseRequestProvider;
|
|
10
12
|
export declare function setSourceProvider(provider: RParseRequestProvider): void;
|
|
11
13
|
export declare function inferWdFromScript(option: InferWorkingDirectory, referenceChain: readonly RParseRequest[]): string[];
|
|
12
14
|
/**
|
|
13
15
|
* Tries to find sourced by a source request and returns the first path that exists
|
|
14
|
-
* @param
|
|
15
|
-
* @param
|
|
16
|
+
* @param resolveSource - options for lax file sourcing
|
|
17
|
+
* @param seed - the path originally requested in the `source` call
|
|
18
|
+
* @param data - more information on the loading context
|
|
16
19
|
*/
|
|
17
|
-
export declare function findSource(seed: string, data: {
|
|
20
|
+
export declare function findSource(resolveSource: FlowrLaxSourcingOptions | undefined, seed: string, data: {
|
|
18
21
|
referenceChain: readonly RParseRequest[];
|
|
19
22
|
}): string[] | undefined;
|
|
20
23
|
export declare function processSourceCall<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly RFunctionArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, config: {
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getSourceProvider = getSourceProvider;
|
|
6
7
|
exports.setSourceProvider = setSourceProvider;
|
|
7
8
|
exports.inferWdFromScript = inferWdFromScript;
|
|
8
9
|
exports.findSource = findSource;
|
|
@@ -30,6 +31,9 @@ const r_value_1 = require("../../../../../eval/values/r-value");
|
|
|
30
31
|
const unknown_side_effect_1 = require("../../../../../graph/unknown-side-effect");
|
|
31
32
|
const alias_tracking_1 = require("../../../../../eval/resolve/alias-tracking");
|
|
32
33
|
let sourceProvider = (0, retriever_1.requestProviderFromFile)();
|
|
34
|
+
function getSourceProvider() {
|
|
35
|
+
return sourceProvider;
|
|
36
|
+
}
|
|
33
37
|
function setSourceProvider(provider) {
|
|
34
38
|
sourceProvider = provider;
|
|
35
39
|
}
|
|
@@ -68,18 +72,18 @@ function applyReplacements(path, replacements) {
|
|
|
68
72
|
}
|
|
69
73
|
/**
|
|
70
74
|
* Tries to find sourced by a source request and returns the first path that exists
|
|
71
|
-
* @param
|
|
72
|
-
* @param
|
|
75
|
+
* @param resolveSource - options for lax file sourcing
|
|
76
|
+
* @param seed - the path originally requested in the `source` call
|
|
77
|
+
* @param data - more information on the loading context
|
|
73
78
|
*/
|
|
74
|
-
function findSource(seed, data) {
|
|
75
|
-
const
|
|
76
|
-
const capitalization = config?.ignoreCapitalization ?? false;
|
|
79
|
+
function findSource(resolveSource, seed, data) {
|
|
80
|
+
const capitalization = resolveSource?.ignoreCapitalization ?? false;
|
|
77
81
|
const explorePaths = [
|
|
78
|
-
...(
|
|
79
|
-
...(inferWdFromScript(
|
|
82
|
+
...(resolveSource?.searchPath ?? []),
|
|
83
|
+
...(inferWdFromScript(resolveSource?.inferWorkingDirectory ?? config_1.InferWorkingDirectory.No, data.referenceChain))
|
|
80
84
|
];
|
|
81
85
|
let tryPaths = [seed];
|
|
82
|
-
switch (
|
|
86
|
+
switch (resolveSource?.dropPaths ?? config_1.DropPathsOption.No) {
|
|
83
87
|
case config_1.DropPathsOption.Once: {
|
|
84
88
|
const first = platformBasename(seed);
|
|
85
89
|
tryPaths.push(first);
|
|
@@ -101,8 +105,8 @@ function findSource(seed, data) {
|
|
|
101
105
|
case config_1.DropPathsOption.No:
|
|
102
106
|
break;
|
|
103
107
|
}
|
|
104
|
-
if (
|
|
105
|
-
const r =
|
|
108
|
+
if (resolveSource?.applyReplacements) {
|
|
109
|
+
const r = resolveSource.applyReplacements;
|
|
106
110
|
tryPaths = tryPaths.flatMap(t => applyReplacements(t, r));
|
|
107
111
|
}
|
|
108
112
|
const found = [];
|
|
@@ -129,7 +133,7 @@ function processSourceCall(name, args, rootId, data, config) {
|
|
|
129
133
|
(0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'builtin:source' }).information
|
|
130
134
|
: (0, info_1.initializeCleanDataflowInformation)(rootId, data);
|
|
131
135
|
const sourceFileArgument = args[0];
|
|
132
|
-
if (!config.forceFollow &&
|
|
136
|
+
if (!config.forceFollow && data.flowrConfig.ignoreSourceCalls) {
|
|
133
137
|
(0, log_1.expensiveTrace)(logger_1.dataflowLogger, () => `Skipping source call ${JSON.stringify(sourceFileArgument)} (disabled in config file)`);
|
|
134
138
|
(0, unknown_side_effect_1.handleUnknownSideEffect)(information.graph, information.environment, rootId);
|
|
135
139
|
return information;
|
|
@@ -139,19 +143,19 @@ function processSourceCall(name, args, rootId, data, config) {
|
|
|
139
143
|
sourceFile = [(0, retriever_1.removeRQuotes)(sourceFileArgument.lexeme)];
|
|
140
144
|
}
|
|
141
145
|
else if (sourceFileArgument !== r_function_call_1.EmptyArgument) {
|
|
142
|
-
const resolved = (0, general_1.valueSetGuard)((0, alias_tracking_1.resolveIdToValue)(sourceFileArgument.info.id, { environment: data.environment, idMap: data.completeAst.idMap }));
|
|
146
|
+
const resolved = (0, general_1.valueSetGuard)((0, alias_tracking_1.resolveIdToValue)(sourceFileArgument.info.id, { environment: data.environment, idMap: data.completeAst.idMap, resolve: data.flowrConfig.solver.variables }));
|
|
143
147
|
sourceFile = resolved?.elements.map(r => r.type === 'string' && (0, r_value_1.isValue)(r.value) ? r.value.str : undefined).filter(assert_1.isNotUndefined);
|
|
144
148
|
}
|
|
145
149
|
if (sourceFile && sourceFile.length === 1) {
|
|
146
150
|
const path = (0, retriever_1.removeRQuotes)(sourceFile[0]);
|
|
147
|
-
let filepath = path ? findSource(path, data) : path;
|
|
151
|
+
let filepath = path ? findSource(data.flowrConfig.solver.resolveSource, path, data) : path;
|
|
148
152
|
if (Array.isArray(filepath)) {
|
|
149
153
|
filepath = filepath?.[0];
|
|
150
154
|
}
|
|
151
155
|
if (filepath !== undefined) {
|
|
152
156
|
const request = sourceProvider.createRequest(filepath);
|
|
153
157
|
// check if the sourced file has already been dataflow analyzed, and if so, skip it
|
|
154
|
-
const limit =
|
|
158
|
+
const limit = data.flowrConfig.solver.resolveSource?.repeatedSourceLimit ?? 0;
|
|
155
159
|
const findCount = data.referenceChain.filter(e => e.request === request.request && e.content === request.content).length;
|
|
156
160
|
if (findCount > limit) {
|
|
157
161
|
logger_1.dataflowLogger.warn(`Found cycle (>=${limit + 1}) in dataflow analysis for ${JSON.stringify(request)}: ${JSON.stringify(data.referenceChain)}, skipping further dataflow analysis`);
|
|
@@ -181,7 +185,7 @@ function sourceRequest(rootId, request, data, information, getId) {
|
|
|
181
185
|
const file = request.request === 'file' ? request.content : undefined;
|
|
182
186
|
const parsed = (!data.parser.async ? data.parser : new shell_executor_1.RShellExecutor()).parse(request);
|
|
183
187
|
normalized = (typeof parsed !== 'string' ?
|
|
184
|
-
(0, parser_1.normalizeTreeSitter)({ parsed }, getId, file) : (0, parser_1.normalize)({ parsed }, getId, file));
|
|
188
|
+
(0, parser_1.normalizeTreeSitter)({ parsed }, getId, data.flowrConfig, file) : (0, parser_1.normalize)({ parsed }, getId, file));
|
|
185
189
|
dataflow = (0, processor_1.processDataflowFor)(normalized.ast, {
|
|
186
190
|
...data,
|
|
187
191
|
currentRequest: request,
|
|
@@ -16,7 +16,7 @@ const containers_1 = require("../../../../../../util/containers");
|
|
|
16
16
|
*/
|
|
17
17
|
function processVector(name, args, rootId, data) {
|
|
18
18
|
const fnCall = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'builtin:vector' });
|
|
19
|
-
if (!
|
|
19
|
+
if (!data.flowrConfig.solver.pointerTracking) {
|
|
20
20
|
return fnCall.information;
|
|
21
21
|
}
|
|
22
22
|
let vectorArgs = [];
|
|
@@ -52,7 +52,7 @@ function processVector(name, args, rootId, data) {
|
|
|
52
52
|
vectorArgs = vectorArgs.concat(flattenedIndices);
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
if ((0, config_1.isOverPointerAnalysisThreshold)(vectorArgs.length)) {
|
|
55
|
+
if ((0, config_1.isOverPointerAnalysisThreshold)(data.flowrConfig, vectorArgs.length)) {
|
|
56
56
|
return fnCall.information;
|
|
57
57
|
}
|
|
58
58
|
const indices = {
|
|
@@ -24,7 +24,7 @@ function processWhileLoop(name, args, rootId, data) {
|
|
|
24
24
|
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information;
|
|
25
25
|
}
|
|
26
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 });
|
|
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
28
|
const conditionIsAlwaysFalse = (0, general_1.valueSetGuard)(values)?.elements.every(d => d.type === 'logical' && d.value === false) ?? false;
|
|
29
29
|
//We don't care about the body if it never executes
|
|
30
30
|
if (conditionIsAlwaysFalse) {
|
|
@@ -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
|
}
|
|
@@ -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
|
|
@@ -17,13 +17,15 @@ 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
|
+
const doc_cli_option_1 = require("./doc-cli-option");
|
|
21
|
+
const config_1 = require("../../config");
|
|
20
22
|
async function showQuery(shell, code, queries, { showCode, collapseResult, collapseQuery, addOutput = () => '' } = {}) {
|
|
21
23
|
const now = performance.now();
|
|
22
24
|
const analysis = await new pipeline_executor_1.PipelineExecutor(default_pipelines_1.DEFAULT_DATAFLOW_PIPELINE, {
|
|
23
25
|
parser: shell,
|
|
24
26
|
request: (0, retriever_1.requestFromInput)(code)
|
|
25
|
-
}).allRemainingSteps();
|
|
26
|
-
const results = (0, query_1.executeQueries)({ dataflow: analysis.dataflow, ast: analysis.normalize }, queries);
|
|
27
|
+
}, config_1.defaultConfigOptions).allRemainingSteps();
|
|
28
|
+
const results = (0, query_1.executeQueries)({ dataflow: analysis.dataflow, ast: analysis.normalize, config: config_1.defaultConfigOptions }, queries);
|
|
27
29
|
const duration = performance.now() - now;
|
|
28
30
|
const metaInfo = `
|
|
29
31
|
The analysis required _${(0, time_1.printAsMs)(duration)}_ (including parsing and normalization and the query) within the generation environment.
|
|
@@ -33,6 +35,15 @@ The analysis required _${(0, time_1.printAsMs)(duration)}_ (including parsing an
|
|
|
33
35
|
|
|
34
36
|
${(0, doc_code_1.codeBlock)('json', collapseQuery ? str.split('\n').join(' ').replace(/([{[])\s{2,}/g, '$1 ').replace(/\s{2,}([\]}])/g, ' $1') : str)}
|
|
35
37
|
|
|
38
|
+
${(function () {
|
|
39
|
+
if (queries.length === 1 && Object.keys(queries[0]).length === 1) {
|
|
40
|
+
return `(This query can be shortened to \`@${queries[0].type}\` when used within the REPL command ${(0, doc_cli_option_1.getReplCommand)('query')}).`;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
return '';
|
|
44
|
+
}
|
|
45
|
+
})()}
|
|
46
|
+
|
|
36
47
|
${collapseResult ? ' <details> <summary style="color:gray">Show Results</summary>' : ''}
|
|
37
48
|
|
|
38
49
|
_Results (prettified and summarized):_
|
|
@@ -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 {};
|