@eagleoutice/flowr 2.1.11 → 2.2.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/benchmark/slicer.d.ts +5 -12
- package/benchmark/slicer.js +46 -28
- package/cli/benchmark-app.d.ts +2 -0
- package/cli/benchmark-app.js +2 -1
- package/cli/benchmark-helper-app.d.ts +2 -0
- package/cli/benchmark-helper-app.js +2 -2
- package/cli/common/options.js +3 -1
- package/cli/flowr-main-options.js +36 -2
- package/cli/flowr.d.ts +6 -0
- package/cli/flowr.js +51 -24
- package/cli/repl/commands/repl-cfg.js +2 -4
- package/cli/repl/commands/repl-dataflow.js +2 -4
- package/cli/repl/commands/repl-execute.d.ts +2 -2
- package/cli/repl/commands/repl-execute.js +15 -5
- package/cli/repl/commands/repl-lineage.js +2 -4
- package/cli/repl/commands/repl-main.d.ts +2 -2
- package/cli/repl/commands/repl-normalize.js +2 -4
- package/cli/repl/commands/repl-parse.js +2 -4
- package/cli/repl/commands/repl-query.js +7 -9
- package/cli/repl/commands/repl-version.d.ts +5 -4
- package/cli/repl/commands/repl-version.js +10 -9
- package/cli/repl/core.d.ts +5 -5
- package/cli/repl/core.js +8 -12
- package/cli/repl/print-version.d.ts +2 -2
- package/cli/repl/print-version.js +3 -3
- package/cli/repl/server/connection.d.ts +3 -3
- package/cli/repl/server/connection.js +6 -8
- package/cli/repl/server/messages/message-hello.js +2 -1
- package/cli/repl/server/server.d.ts +4 -3
- package/cli/repl/server/server.js +7 -5
- package/cli/slicer-app.js +1 -1
- package/config.d.ts +36 -4
- package/config.js +30 -1
- package/core/pipeline-executor.d.ts +1 -1
- package/core/pipeline-executor.js +1 -1
- package/core/steps/all/core/00-parse.d.ts +4 -18
- package/core/steps/all/core/00-parse.js +2 -11
- package/core/steps/all/core/01-parse-tree-sitter.d.ts +23 -0
- package/core/steps/all/core/01-parse-tree-sitter.js +19 -0
- package/core/steps/all/core/10-normalize.d.ts +3 -2
- package/core/steps/all/core/10-normalize.js +1 -0
- package/core/steps/all/core/11-normalize-tree-sitter.d.ts +25 -0
- package/core/steps/all/core/11-normalize-tree-sitter.js +27 -0
- package/core/steps/all/core/20-dataflow.d.ts +2 -0
- package/core/steps/all/core/20-dataflow.js +1 -1
- package/core/steps/pipeline/default-pipelines.d.ts +374 -23
- package/core/steps/pipeline/default-pipelines.js +48 -4
- package/dataflow/extractor.d.ts +2 -1
- package/dataflow/extractor.js +2 -1
- package/dataflow/graph/vertex.d.ts +4 -0
- package/dataflow/graph/vertex.js +3 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +6 -5
- package/dataflow/processor.d.ts +2 -0
- package/documentation/doc-util/doc-auto-gen.js +2 -1
- package/documentation/doc-util/doc-cfg.js +1 -1
- package/documentation/doc-util/doc-dfg.js +3 -3
- package/documentation/doc-util/doc-files.d.ts +1 -0
- package/documentation/doc-util/doc-files.js +4 -0
- package/documentation/doc-util/doc-normalized-ast.js +2 -3
- package/documentation/doc-util/doc-query.js +2 -2
- package/documentation/doc-util/doc-search.d.ts +25 -0
- package/documentation/doc-util/doc-search.js +121 -0
- package/documentation/doc-util/doc-types.d.ts +10 -2
- package/documentation/doc-util/doc-types.js +81 -3
- package/documentation/print-dataflow-graph-wiki.js +16 -16
- package/documentation/print-engines-wiki.d.ts +1 -0
- package/documentation/print-engines-wiki.js +82 -0
- package/documentation/print-interface-wiki.js +30 -20
- package/documentation/print-normalized-ast-wiki.js +5 -5
- package/documentation/print-query-wiki.js +22 -0
- package/documentation/print-search-wiki.d.ts +1 -0
- package/documentation/print-search-wiki.js +74 -0
- package/package.json +10 -5
- package/queries/base-query-format.d.ts +2 -2
- 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 +1 -1
- package/queries/catalog/cluster-query/cluster-query-executor.d.ts +1 -1
- package/queries/catalog/cluster-query/cluster-query-executor.js +1 -1
- package/queries/catalog/cluster-query/cluster-query-format.d.ts +5 -4
- package/queries/catalog/dataflow-query/dataflow-query-executor.d.ts +1 -1
- package/queries/catalog/dataflow-query/dataflow-query-executor.js +1 -1
- package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +5 -4
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +2 -2
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +5 -4
- package/queries/catalog/id-map-query/id-map-query-format.d.ts +5 -4
- package/queries/catalog/lineage-query/lineage-query-executor.d.ts +1 -1
- package/queries/catalog/lineage-query/lineage-query-executor.js +1 -1
- package/queries/catalog/lineage-query/lineage-query-format.d.ts +5 -4
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +5 -4
- package/queries/catalog/search-query/search-query-executor.d.ts +3 -0
- package/queries/catalog/search-query/search-query-executor.js +27 -0
- package/queries/catalog/search-query/search-query-format.d.ts +73 -0
- package/queries/catalog/search-query/search-query-format.js +29 -0
- 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 +1 -1
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +5 -4
- package/queries/query.d.ts +95 -29
- package/queries/query.js +3 -1
- package/r-bridge/lang-4.x/ast/model/type.d.ts +4 -0
- package/r-bridge/lang-4.x/ast/model/type.js +3 -1
- package/r-bridge/lang-4.x/ast/parser/json/parser.d.ts +4 -2
- package/r-bridge/lang-4.x/ast/parser/json/parser.js +5 -0
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.d.ts +18 -0
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +57 -0
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.d.ts +3 -0
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +541 -0
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-types.d.ts +35 -0
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-types.js +40 -0
- package/r-bridge/parser.d.ts +32 -0
- package/r-bridge/parser.js +14 -0
- package/r-bridge/shell-executor.d.ts +37 -1
- package/r-bridge/shell-executor.js +39 -0
- package/r-bridge/shell.d.ts +12 -6
- package/r-bridge/shell.js +15 -6
- package/search/flowr-search-builder.d.ts +193 -0
- package/search/flowr-search-builder.js +192 -0
- package/search/flowr-search-executor.d.ts +9 -0
- package/search/flowr-search-executor.js +16 -0
- package/search/flowr-search-filters.d.ts +74 -0
- package/search/flowr-search-filters.js +136 -0
- package/search/flowr-search-printer.d.ts +10 -0
- package/search/flowr-search-printer.js +85 -0
- package/search/flowr-search-traverse.d.ts +7 -0
- package/search/flowr-search-traverse.js +12 -0
- package/search/flowr-search.d.ts +58 -0
- package/search/flowr-search.js +29 -0
- package/search/search-executor/search-generators.d.ts +37 -0
- package/search/search-executor/search-generators.js +64 -0
- package/search/search-executor/search-transformer.d.ts +57 -0
- package/search/search-executor/search-transformer.js +99 -0
- package/search/search-optimizer/search-optimizer.d.ts +9 -0
- package/search/search-optimizer/search-optimizer.js +89 -0
- package/statistics/statistics.js +1 -1
- package/util/arrays.d.ts +13 -0
- package/util/assert.d.ts +1 -1
- package/util/mermaid/mermaid.js +17 -0
- package/util/version.js +1 -1
|
@@ -1,19 +1,63 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT_PARSE_PIPELINE = exports.DEFAULT_NORMALIZE_PIPELINE = exports.DEFAULT_DATAFLOW_PIPELINE = exports.DEFAULT_SLICE_WITHOUT_RECONSTRUCT_PIPELINE = exports.DEFAULT_SLICE_AND_RECONSTRUCT_PIPELINE = exports.DEFAULT_SLICING_PIPELINE = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
exports.TREE_SITTER_PARSE_PIPELINE = exports.DEFAULT_PARSE_PIPELINE = exports.TREE_SITTER_NORMALIZE_PIPELINE = exports.DEFAULT_NORMALIZE_PIPELINE = exports.TREE_SITTER_DATAFLOW_PIPELINE = exports.DEFAULT_DATAFLOW_PIPELINE = exports.TREE_SITTER_SLICE_WITHOUT_RECONSTRUCT_PIPELINE = exports.TREE_SITTER_SLICE_AND_RECONSTRUCT_PIPELINE = exports.TREE_SITTER_SLICING_PIPELINE = exports.DEFAULT_SLICE_WITHOUT_RECONSTRUCT_PIPELINE = exports.DEFAULT_SLICE_AND_RECONSTRUCT_PIPELINE = exports.DEFAULT_SLICING_PIPELINE = void 0;
|
|
4
|
+
exports.createParsePipeline = createParsePipeline;
|
|
5
|
+
exports.createSlicePipeline = createSlicePipeline;
|
|
6
|
+
exports.createNormalizePipeline = createNormalizePipeline;
|
|
7
|
+
exports.createDataflowPipeline = createDataflowPipeline;
|
|
7
8
|
const pipeline_1 = require("./pipeline");
|
|
8
9
|
const _00_parse_1 = require("../all/core/00-parse");
|
|
9
10
|
const _10_normalize_1 = require("../all/core/10-normalize");
|
|
10
11
|
const _20_dataflow_1 = require("../all/core/20-dataflow");
|
|
11
12
|
const _00_slice_1 = require("../all/static-slicing/00-slice");
|
|
12
13
|
const _10_reconstruct_1 = require("../all/static-slicing/10-reconstruct");
|
|
14
|
+
const _01_parse_tree_sitter_1 = require("../all/core/01-parse-tree-sitter");
|
|
15
|
+
const _11_normalize_tree_sitter_1 = require("../all/core/11-normalize-tree-sitter");
|
|
16
|
+
const pipeline_executor_1 = require("../../pipeline-executor");
|
|
13
17
|
exports.DEFAULT_SLICING_PIPELINE = (0, pipeline_1.createPipeline)(_00_parse_1.PARSE_WITH_R_SHELL_STEP, _10_normalize_1.NORMALIZE, _20_dataflow_1.STATIC_DATAFLOW, _00_slice_1.STATIC_SLICE, _10_reconstruct_1.NAIVE_RECONSTRUCT);
|
|
14
18
|
exports.DEFAULT_SLICE_AND_RECONSTRUCT_PIPELINE = exports.DEFAULT_SLICING_PIPELINE;
|
|
15
19
|
exports.DEFAULT_SLICE_WITHOUT_RECONSTRUCT_PIPELINE = (0, pipeline_1.createPipeline)(_00_parse_1.PARSE_WITH_R_SHELL_STEP, _10_normalize_1.NORMALIZE, _20_dataflow_1.STATIC_DATAFLOW, _00_slice_1.STATIC_SLICE);
|
|
20
|
+
exports.TREE_SITTER_SLICING_PIPELINE = (0, pipeline_1.createPipeline)(_01_parse_tree_sitter_1.PARSE_WITH_TREE_SITTER_STEP, _11_normalize_tree_sitter_1.NORMALIZE_TREE_SITTER, _20_dataflow_1.STATIC_DATAFLOW, _00_slice_1.STATIC_SLICE, _10_reconstruct_1.NAIVE_RECONSTRUCT);
|
|
21
|
+
exports.TREE_SITTER_SLICE_AND_RECONSTRUCT_PIPELINE = exports.TREE_SITTER_SLICING_PIPELINE;
|
|
22
|
+
exports.TREE_SITTER_SLICE_WITHOUT_RECONSTRUCT_PIPELINE = (0, pipeline_1.createPipeline)(_01_parse_tree_sitter_1.PARSE_WITH_TREE_SITTER_STEP, _11_normalize_tree_sitter_1.NORMALIZE_TREE_SITTER, _20_dataflow_1.STATIC_DATAFLOW, _00_slice_1.STATIC_SLICE);
|
|
23
|
+
/**
|
|
24
|
+
* The default pipeline for working with flowr, including the dataflow step,
|
|
25
|
+
* see the {@link DEFAULT_NORMALIZE_PIPELINE} for the pipeline without the dataflow step,
|
|
26
|
+
* and the {@link DEFAULT_SLICE_AND_RECONSTRUCT_PIPELINE} for the pipeline with slicing and reconstructing steps
|
|
27
|
+
*/
|
|
16
28
|
exports.DEFAULT_DATAFLOW_PIPELINE = (0, pipeline_1.createPipeline)(_00_parse_1.PARSE_WITH_R_SHELL_STEP, _10_normalize_1.NORMALIZE, _20_dataflow_1.STATIC_DATAFLOW);
|
|
29
|
+
exports.TREE_SITTER_DATAFLOW_PIPELINE = (0, pipeline_1.createPipeline)(_01_parse_tree_sitter_1.PARSE_WITH_TREE_SITTER_STEP, _11_normalize_tree_sitter_1.NORMALIZE_TREE_SITTER, _20_dataflow_1.STATIC_DATAFLOW);
|
|
30
|
+
/** The pipeline to use when you want to parse and normalize your R file, see {@link DEFAULT_DATAFLOW_PIPELINE} for the additional `dataflow` step */
|
|
17
31
|
exports.DEFAULT_NORMALIZE_PIPELINE = (0, pipeline_1.createPipeline)(_00_parse_1.PARSE_WITH_R_SHELL_STEP, _10_normalize_1.NORMALIZE);
|
|
32
|
+
exports.TREE_SITTER_NORMALIZE_PIPELINE = (0, pipeline_1.createPipeline)(_01_parse_tree_sitter_1.PARSE_WITH_TREE_SITTER_STEP, _11_normalize_tree_sitter_1.NORMALIZE_TREE_SITTER);
|
|
18
33
|
exports.DEFAULT_PARSE_PIPELINE = (0, pipeline_1.createPipeline)(_00_parse_1.PARSE_WITH_R_SHELL_STEP);
|
|
34
|
+
exports.TREE_SITTER_PARSE_PIPELINE = (0, pipeline_1.createPipeline)(_01_parse_tree_sitter_1.PARSE_WITH_TREE_SITTER_STEP);
|
|
35
|
+
function createParsePipeline(parser, inputs) {
|
|
36
|
+
const base = parser.name === 'tree-sitter' ? exports.TREE_SITTER_PARSE_PIPELINE : exports.DEFAULT_PARSE_PIPELINE;
|
|
37
|
+
return new pipeline_executor_1.PipelineExecutor(base, {
|
|
38
|
+
parser: parser,
|
|
39
|
+
...inputs
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
function createSlicePipeline(parser, inputs) {
|
|
43
|
+
const base = parser.name === 'tree-sitter' ? exports.TREE_SITTER_SLICING_PIPELINE : exports.DEFAULT_SLICING_PIPELINE;
|
|
44
|
+
return new pipeline_executor_1.PipelineExecutor(base, {
|
|
45
|
+
parser: parser,
|
|
46
|
+
...inputs
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
function createNormalizePipeline(parser, inputs) {
|
|
50
|
+
const base = parser.name === 'tree-sitter' ? exports.TREE_SITTER_NORMALIZE_PIPELINE : exports.DEFAULT_NORMALIZE_PIPELINE;
|
|
51
|
+
return new pipeline_executor_1.PipelineExecutor(base, {
|
|
52
|
+
parser: parser,
|
|
53
|
+
...inputs
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
function createDataflowPipeline(parser, inputs) {
|
|
57
|
+
const base = parser.name === 'tree-sitter' ? exports.TREE_SITTER_DATAFLOW_PIPELINE : exports.DEFAULT_DATAFLOW_PIPELINE;
|
|
58
|
+
return new pipeline_executor_1.PipelineExecutor(base, {
|
|
59
|
+
parser: parser,
|
|
60
|
+
...inputs
|
|
61
|
+
});
|
|
62
|
+
}
|
|
19
63
|
//# sourceMappingURL=default-pipelines.js.map
|
package/dataflow/extractor.d.ts
CHANGED
|
@@ -2,5 +2,6 @@ import type { DataflowInformation } from './info';
|
|
|
2
2
|
import type { DataflowProcessors } from './processor';
|
|
3
3
|
import type { NormalizedAst, ParentInformation } from '../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
4
4
|
import type { RParseRequests } from '../r-bridge/retriever';
|
|
5
|
+
import type { KnownParserType, Parser } from '../r-bridge/parser';
|
|
5
6
|
export declare const processors: DataflowProcessors<ParentInformation>;
|
|
6
|
-
export declare function produceDataFlowGraph<OtherInfo>(request: RParseRequests, ast: NormalizedAst<OtherInfo & ParentInformation>): DataflowInformation;
|
|
7
|
+
export declare function produceDataFlowGraph<OtherInfo>(parser: Parser<KnownParserType>, request: RParseRequests, ast: NormalizedAst<OtherInfo & ParentInformation>): DataflowInformation;
|
package/dataflow/extractor.js
CHANGED
|
@@ -68,7 +68,7 @@ function resolveLinkToSideEffects(ast, graph) {
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
-
function produceDataFlowGraph(request, ast) {
|
|
71
|
+
function produceDataFlowGraph(parser, request, ast) {
|
|
72
72
|
const multifile = Array.isArray(request);
|
|
73
73
|
let firstRequest;
|
|
74
74
|
if (multifile) {
|
|
@@ -78,6 +78,7 @@ function produceDataFlowGraph(request, ast) {
|
|
|
78
78
|
firstRequest = request;
|
|
79
79
|
}
|
|
80
80
|
const dfData = {
|
|
81
|
+
parser: parser,
|
|
81
82
|
completeAst: ast,
|
|
82
83
|
environment: (0, environment_1.initializeCleanEnvironments)(),
|
|
83
84
|
processors: exports.processors,
|
|
@@ -10,6 +10,10 @@ export declare enum VertexType {
|
|
|
10
10
|
VariableDefinition = "variable-definition",
|
|
11
11
|
FunctionDefinition = "function-definition"
|
|
12
12
|
}
|
|
13
|
+
export declare const ValidVertexTypes: Set<string>;
|
|
14
|
+
export declare const ValidVertexTypeReverse: {
|
|
15
|
+
[k: string]: string;
|
|
16
|
+
};
|
|
13
17
|
/**
|
|
14
18
|
* A single index of a container, which is not a container itself.
|
|
15
19
|
*
|
package/dataflow/graph/vertex.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.VertexType = void 0;
|
|
3
|
+
exports.ValidVertexTypeReverse = exports.ValidVertexTypes = exports.VertexType = void 0;
|
|
4
4
|
exports.isParentContainerIndex = isParentContainerIndex;
|
|
5
5
|
exports.isValueVertex = isValueVertex;
|
|
6
6
|
exports.isUseVertex = isUseVertex;
|
|
@@ -15,6 +15,8 @@ var VertexType;
|
|
|
15
15
|
VertexType["VariableDefinition"] = "variable-definition";
|
|
16
16
|
VertexType["FunctionDefinition"] = "function-definition";
|
|
17
17
|
})(VertexType || (exports.VertexType = VertexType = {}));
|
|
18
|
+
exports.ValidVertexTypes = new Set(Object.values(VertexType));
|
|
19
|
+
exports.ValidVertexTypeReverse = Object.fromEntries(Object.entries(VertexType).map(([k, v]) => [v, k]));
|
|
18
20
|
function isParentContainerIndex(index) {
|
|
19
21
|
return 'subIndices' in index;
|
|
20
22
|
}
|
|
@@ -7,11 +7,9 @@ exports.setSourceProvider = setSourceProvider;
|
|
|
7
7
|
exports.processSourceCall = processSourceCall;
|
|
8
8
|
exports.sourceRequest = sourceRequest;
|
|
9
9
|
exports.standaloneSourceFile = standaloneSourceFile;
|
|
10
|
-
const shell_executor_1 = require("../../../../../../r-bridge/shell-executor");
|
|
11
10
|
const processor_1 = require("../../../../../processor");
|
|
12
11
|
const info_1 = require("../../../../../info");
|
|
13
12
|
const config_1 = require("../../../../../../config");
|
|
14
|
-
const parser_1 = require("../../../../../../r-bridge/lang-4.x/ast/parser/json/parser");
|
|
15
13
|
const known_call_handling_1 = require("../known-call-handling");
|
|
16
14
|
const retriever_1 = require("../../../../../../r-bridge/retriever");
|
|
17
15
|
const decorate_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate");
|
|
@@ -21,6 +19,8 @@ const type_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/type");
|
|
|
21
19
|
const overwrite_1 = require("../../../../../environments/overwrite");
|
|
22
20
|
const log_1 = require("../../../../../../util/log");
|
|
23
21
|
const fs_1 = __importDefault(require("fs"));
|
|
22
|
+
const parser_1 = require("../../../../../../r-bridge/lang-4.x/ast/parser/json/parser");
|
|
23
|
+
const shell_executor_1 = require("../../../../../../r-bridge/shell-executor");
|
|
24
24
|
let sourceProvider = (0, retriever_1.requestProviderFromFile)();
|
|
25
25
|
function setSourceProvider(provider) {
|
|
26
26
|
sourceProvider = provider;
|
|
@@ -61,13 +61,14 @@ function sourceRequest(rootId, request, data, information, getId) {
|
|
|
61
61
|
return information;
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
const executor = new shell_executor_1.RShellExecutor();
|
|
65
64
|
// parse, normalize and dataflow the sourced file
|
|
66
65
|
let normalized;
|
|
67
66
|
let dataflow;
|
|
68
67
|
try {
|
|
69
|
-
const
|
|
70
|
-
|
|
68
|
+
const file = request.request === 'file' ? request.content : undefined;
|
|
69
|
+
const parsed = (!data.parser.async ? data.parser : new shell_executor_1.RShellExecutor()).parse(request);
|
|
70
|
+
normalized = (typeof parsed !== 'string' ?
|
|
71
|
+
(0, parser_1.normalizeTreeSitter)({ parsed }, getId, file) : (0, parser_1.normalize)({ parsed }, getId, file));
|
|
71
72
|
dataflow = (0, processor_1.processDataflowFor)(normalized.ast, {
|
|
72
73
|
...data,
|
|
73
74
|
currentRequest: request,
|
package/dataflow/processor.d.ts
CHANGED
|
@@ -6,7 +6,9 @@ import type { NormalizedAst, ParentInformation, RNodeWithParent } from '../r-bri
|
|
|
6
6
|
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
|
+
import type { KnownParserType, Parser } from '../r-bridge/parser';
|
|
9
10
|
export interface DataflowProcessorInformation<OtherInfo> {
|
|
11
|
+
readonly parser: Parser<KnownParserType>;
|
|
10
12
|
/**
|
|
11
13
|
* Initial and frozen ast-information
|
|
12
14
|
*/
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.autoGenHeader = autoGenHeader;
|
|
4
4
|
const version_1 = require("../../util/version");
|
|
5
|
+
const doc_files_1 = require("./doc-files");
|
|
5
6
|
function autoGenHeader({ rVersion, filename, purpose, currentDateAndTime = new Date().toISOString().replace('T', ', ').replace(/\.\d+Z$/, ' UTC') }) {
|
|
6
7
|
const shortenFilename = filename.replace(/^.*src\//, 'src/');
|
|
7
|
-
return `_This document was generated from '${shortenFilename}' on ${currentDateAndTime} presenting an overview of flowR's ${purpose} (v${(0, version_1.flowrVersion)().format()}${rVersion ? ', using R v' + rVersion : ''})._`;
|
|
8
|
+
return `_This document was generated from '${(0, doc_files_1.linkFlowRSourceFile)(shortenFilename)}' on ${currentDateAndTime} presenting an overview of flowR's ${purpose} (v${(0, version_1.flowrVersion)().format()}${rVersion ? ', using R v' + rVersion : ''}). Please do not edit this file/wiki page directly._`;
|
|
8
9
|
}
|
|
9
10
|
//# sourceMappingURL=doc-auto-gen.js.map
|
|
@@ -7,7 +7,7 @@ const default_pipelines_1 = require("../../core/steps/pipeline/default-pipelines
|
|
|
7
7
|
const retriever_1 = require("../../r-bridge/retriever");
|
|
8
8
|
async function getCfg(shell, code) {
|
|
9
9
|
const steps = await new pipeline_executor_1.PipelineExecutor(default_pipelines_1.DEFAULT_NORMALIZE_PIPELINE, {
|
|
10
|
-
shell,
|
|
10
|
+
parser: shell,
|
|
11
11
|
request: (0, retriever_1.requestFromInput)(code)
|
|
12
12
|
}).allRemainingSteps();
|
|
13
13
|
return {
|
|
@@ -35,14 +35,14 @@ function formatSideEffect(ef) {
|
|
|
35
35
|
async function printDfGraphForCode(shell, code, { mark, showCode = true, codeOpen = false, exposeResult, switchCodeAndGraph = false } = {}) {
|
|
36
36
|
const now = performance.now();
|
|
37
37
|
const result = await new pipeline_executor_1.PipelineExecutor(default_pipelines_1.DEFAULT_DATAFLOW_PIPELINE, {
|
|
38
|
-
shell,
|
|
38
|
+
parser: shell,
|
|
39
39
|
request: (0, retriever_1.requestFromInput)(code)
|
|
40
40
|
}).allRemainingSteps();
|
|
41
41
|
const duration = performance.now() - now;
|
|
42
42
|
if (switchCodeAndGraph) {
|
|
43
43
|
(0, assert_1.guard)(showCode, 'can not switch code and graph if code is not shown');
|
|
44
44
|
}
|
|
45
|
-
const metaInfo = `The analysis required _${(0, time_1.printAsMs)(duration)}_ (
|
|
45
|
+
const metaInfo = `The analysis required _${(0, time_1.printAsMs)(duration)}_ (including parse and normalize) within the generation environment.`;
|
|
46
46
|
const dfGraph = printDfGraph(result.dataflow.graph, mark);
|
|
47
47
|
let resultText = '\n\n';
|
|
48
48
|
if (showCode) {
|
|
@@ -74,7 +74,7 @@ ${switchCodeAndGraph ? dfGraph : codeText}
|
|
|
74
74
|
async function verifyExpectedSubgraph(shell, code, expectedSubgraph) {
|
|
75
75
|
/* we verify that we get what we want first! */
|
|
76
76
|
const info = await new pipeline_executor_1.PipelineExecutor(default_pipelines_1.DEFAULT_DATAFLOW_PIPELINE, {
|
|
77
|
-
shell,
|
|
77
|
+
parser: shell,
|
|
78
78
|
request: (0, retriever_1.requestFromInput)(code),
|
|
79
79
|
getId: (0, decorate_1.deterministicCountingIdGenerator)(0)
|
|
80
80
|
}).allRemainingSteps();
|
|
@@ -7,3 +7,4 @@ export declare const FlowrDockerRef = "https://hub.docker.com/r/eagleoutice/flow
|
|
|
7
7
|
export declare const FlowrCodecovRef = "https://app.codecov.io/gh/flowr-analysis/flowr";
|
|
8
8
|
export declare function getFilePathMd(path: string): string;
|
|
9
9
|
export declare function getFileContentFromRoot(path: string): string;
|
|
10
|
+
export declare function linkFlowRSourceFile(path: string): string;
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.FlowrCodecovRef = exports.FlowrDockerRef = exports.FlowrNpmRef = exports.FlowrWikiBaseRef = exports.RemoteFlowrFilePathBaseRef = exports.FlowrSiteBaseRef = exports.FlowrGithubBaseRef = void 0;
|
|
7
7
|
exports.getFilePathMd = getFilePathMd;
|
|
8
8
|
exports.getFileContentFromRoot = getFileContentFromRoot;
|
|
9
|
+
exports.linkFlowRSourceFile = linkFlowRSourceFile;
|
|
9
10
|
const fs_1 = __importDefault(require("fs"));
|
|
10
11
|
exports.FlowrGithubBaseRef = 'https://github.com/flowr-analysis';
|
|
11
12
|
exports.FlowrSiteBaseRef = 'https://flowr-analysis.github.io/flowr';
|
|
@@ -27,4 +28,7 @@ function getFileContentFromRoot(path) {
|
|
|
27
28
|
const fullpath = require.resolve('../../../' + path);
|
|
28
29
|
return fs_1.default.readFileSync(fullpath, 'utf-8');
|
|
29
30
|
}
|
|
31
|
+
function linkFlowRSourceFile(path) {
|
|
32
|
+
return `[${path}](${exports.RemoteFlowrFilePathBaseRef}/${path})`;
|
|
33
|
+
}
|
|
30
34
|
//# sourceMappingURL=doc-files.js.map
|
|
@@ -22,7 +22,7 @@ ${(0, ast_1.normalizedAstToMermaid)(ast, prefix)}
|
|
|
22
22
|
async function printNormalizedAstForCode(shell, code, { showCode = true, prefix = 'flowchart TD\n' } = {}) {
|
|
23
23
|
const now = performance.now();
|
|
24
24
|
const result = await new pipeline_executor_1.PipelineExecutor(default_pipelines_1.DEFAULT_NORMALIZE_PIPELINE, {
|
|
25
|
-
shell,
|
|
25
|
+
parser: shell,
|
|
26
26
|
request: (0, retriever_1.requestFromInput)(code)
|
|
27
27
|
}).allRemainingSteps();
|
|
28
28
|
const duration = performance.now() - now;
|
|
@@ -55,8 +55,7 @@ ${(0, ast_1.normalizedAstToMermaid)(result.normalize.ast, prefix)}
|
|
|
55
55
|
/** returns resolved expected df graph */
|
|
56
56
|
async function verifyExpectedSubgraph(shell, code, expectedSubgraph) {
|
|
57
57
|
/* we verify that we get what we want first! */
|
|
58
|
-
const info = await
|
|
59
|
-
shell,
|
|
58
|
+
const info = await (0, default_pipelines_1.createDataflowPipeline)(shell, {
|
|
60
59
|
request: (0, retriever_1.requestFromInput)(code),
|
|
61
60
|
getId: (0, decorate_1.deterministicCountingIdGenerator)(0)
|
|
62
61
|
}).allRemainingSteps();
|
|
@@ -20,10 +20,10 @@ const query_print_1 = require("../../queries/query-print");
|
|
|
20
20
|
async function showQuery(shell, code, queries, { showCode, collapseResult, collapseQuery } = {}) {
|
|
21
21
|
const now = performance.now();
|
|
22
22
|
const analysis = await new pipeline_executor_1.PipelineExecutor(default_pipelines_1.DEFAULT_DATAFLOW_PIPELINE, {
|
|
23
|
-
shell,
|
|
23
|
+
parser: shell,
|
|
24
24
|
request: (0, retriever_1.requestFromInput)(code)
|
|
25
25
|
}).allRemainingSteps();
|
|
26
|
-
const results = (0, query_1.executeQueries)({
|
|
26
|
+
const results = (0, query_1.executeQueries)({ dataflow: analysis.dataflow, ast: analysis.normalize }, queries);
|
|
27
27
|
const duration = performance.now() - now;
|
|
28
28
|
const metaInfo = `
|
|
29
29
|
The analysis required _${(0, time_1.printAsMs)(duration)}_ (including parsing and normalization and the query) within the generation environment.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { RShell } from '../../r-bridge/shell';
|
|
2
|
+
import type { SupportedQueryTypes } from '../../queries/query';
|
|
3
|
+
import type { SupportedVirtualQueryTypes } from '../../queries/virtual-query/virtual-queries';
|
|
4
|
+
import type { FlowrSearchLike } from '../../search/flowr-search-builder';
|
|
5
|
+
export interface ShowSearchOptions {
|
|
6
|
+
readonly showCode?: boolean;
|
|
7
|
+
readonly collapseResult?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function showSearch(shell: RShell, code: string, search: FlowrSearchLike, { collapseResult }?: ShowSearchOptions): Promise<string>;
|
|
10
|
+
export interface QueryDocumentation {
|
|
11
|
+
readonly name: string;
|
|
12
|
+
readonly type: 'virtual' | 'active';
|
|
13
|
+
readonly shortDescription: string;
|
|
14
|
+
readonly functionName: string;
|
|
15
|
+
readonly functionFile: string;
|
|
16
|
+
readonly buildExplanation: (shell: RShell) => Promise<string>;
|
|
17
|
+
}
|
|
18
|
+
export declare const RegisteredQueries: {
|
|
19
|
+
active: Map<string, QueryDocumentation>;
|
|
20
|
+
virtual: Map<string, QueryDocumentation>;
|
|
21
|
+
};
|
|
22
|
+
export declare function registerQueryDocumentation(query: SupportedQueryTypes | SupportedVirtualQueryTypes, doc: QueryDocumentation): void;
|
|
23
|
+
export declare function linkToQueryOfName(id: SupportedQueryTypes | SupportedVirtualQueryTypes): string;
|
|
24
|
+
export declare function tocForQueryType(type: 'active' | 'virtual'): string;
|
|
25
|
+
export declare function explainQueries(shell: RShell, type: 'active' | 'virtual'): Promise<string>;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RegisteredQueries = void 0;
|
|
4
|
+
exports.showSearch = showSearch;
|
|
5
|
+
exports.registerQueryDocumentation = registerQueryDocumentation;
|
|
6
|
+
exports.linkToQueryOfName = linkToQueryOfName;
|
|
7
|
+
exports.tocForQueryType = tocForQueryType;
|
|
8
|
+
exports.explainQueries = explainQueries;
|
|
9
|
+
const pipeline_executor_1 = require("../../core/pipeline-executor");
|
|
10
|
+
const default_pipelines_1 = require("../../core/steps/pipeline/default-pipelines");
|
|
11
|
+
const retriever_1 = require("../../r-bridge/retriever");
|
|
12
|
+
const doc_files_1 = require("./doc-files");
|
|
13
|
+
const doc_dfg_1 = require("./doc-dfg");
|
|
14
|
+
const doc_code_1 = require("./doc-code");
|
|
15
|
+
const time_1 = require("../../util/time");
|
|
16
|
+
const flowr_search_executor_1 = require("../../search/flowr-search-executor");
|
|
17
|
+
const flowr_search_printer_1 = require("../../search/flowr-search-printer");
|
|
18
|
+
const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
19
|
+
const dfg_1 = require("../../util/mermaid/dfg");
|
|
20
|
+
async function showSearch(shell, code, search, { collapseResult = true } = {}) {
|
|
21
|
+
const now = performance.now();
|
|
22
|
+
const analysis = await new pipeline_executor_1.PipelineExecutor(default_pipelines_1.DEFAULT_DATAFLOW_PIPELINE, {
|
|
23
|
+
parser: shell,
|
|
24
|
+
request: (0, retriever_1.requestFromInput)(code)
|
|
25
|
+
}).allRemainingSteps();
|
|
26
|
+
const result = (0, flowr_search_executor_1.runSearch)(search, analysis);
|
|
27
|
+
const duration = performance.now() - now;
|
|
28
|
+
const metaInfo = `
|
|
29
|
+
The search required _${(0, time_1.printAsMs)(duration)}_ (including parsing and normalization and the query) within the generation environment.
|
|
30
|
+
`.trim();
|
|
31
|
+
return `
|
|
32
|
+
|
|
33
|
+
${(0, doc_code_1.codeBlock)('ts', (0, flowr_search_printer_1.flowrSearchToCode)(search))}
|
|
34
|
+
|
|
35
|
+
<details style="color:gray"> <summary>Search Visualization</summary>
|
|
36
|
+
|
|
37
|
+
${(0, doc_code_1.codeBlock)('mermaid', (0, flowr_search_printer_1.flowrSearchToMermaid)(search))}
|
|
38
|
+
|
|
39
|
+
In the code:
|
|
40
|
+
|
|
41
|
+
${(0, doc_code_1.codeBlock)('r', code)}
|
|
42
|
+
|
|
43
|
+
<details style="color:gray"> <summary>JSON Representation</summary>
|
|
44
|
+
|
|
45
|
+
${(0, doc_code_1.codeBlock)('json', JSON.stringify(search, null, 2))}
|
|
46
|
+
|
|
47
|
+
</details>
|
|
48
|
+
|
|
49
|
+
</details>
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
${collapseResult ? ' <details> <summary style="color:gray">Show Results</summary>' : ''}
|
|
53
|
+
|
|
54
|
+
The query returns the following vetices (all references to \`x\` in the code):
|
|
55
|
+
${result.map(({ node }) => `<b>${node.info.id} ('${(0, node_id_1.recoverContent)(node.info.id, analysis.dataflow.graph)}')</b> at L${(0, dfg_1.formatRange)(node.location)}`).join(', ')}
|
|
56
|
+
|
|
57
|
+
${metaInfo}
|
|
58
|
+
|
|
59
|
+
The returned results are highlighted thick and blue within the dataflow graph:
|
|
60
|
+
|
|
61
|
+
${await (0, doc_dfg_1.printDfGraphForCode)(shell, code, { showCode: false, switchCodeAndGraph: false, mark: new Set(result.map(({ node }) => node.info.id)) })}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
${collapseResult ? '</details>' : ''}
|
|
65
|
+
|
|
66
|
+
`;
|
|
67
|
+
}
|
|
68
|
+
exports.RegisteredQueries = {
|
|
69
|
+
'active': new Map(),
|
|
70
|
+
'virtual': new Map()
|
|
71
|
+
};
|
|
72
|
+
function registerQueryDocumentation(query, doc) {
|
|
73
|
+
const map = exports.RegisteredQueries[doc.type];
|
|
74
|
+
if (map.has(query)) {
|
|
75
|
+
throw new Error(`Query ${query} already registered`);
|
|
76
|
+
}
|
|
77
|
+
map.set(query, doc);
|
|
78
|
+
}
|
|
79
|
+
function linkify(name) {
|
|
80
|
+
return name.toLowerCase().replace(/ /g, '-');
|
|
81
|
+
}
|
|
82
|
+
function linkToQueryOfName(id) {
|
|
83
|
+
const query = exports.RegisteredQueries.active.get(id) ?? exports.RegisteredQueries.virtual.get(id);
|
|
84
|
+
if (!query) {
|
|
85
|
+
throw new Error(`Query ${id} not found`);
|
|
86
|
+
}
|
|
87
|
+
return `[${query.name}](#${linkify(query.name)})`;
|
|
88
|
+
}
|
|
89
|
+
function tocForQueryType(type) {
|
|
90
|
+
const queries = [...exports.RegisteredQueries[type].entries()].sort(([, { name: a }], [, { name: b }]) => a.localeCompare(b));
|
|
91
|
+
const result = [];
|
|
92
|
+
for (const [id, { name, shortDescription }] of queries) {
|
|
93
|
+
result.push(`1. [${name}](#${linkify(name)}) (\`${id}\`):\\\n ${shortDescription}`);
|
|
94
|
+
}
|
|
95
|
+
return result.join('\n');
|
|
96
|
+
}
|
|
97
|
+
async function explainQuery(shell, { name, functionName, functionFile, buildExplanation }) {
|
|
98
|
+
return `
|
|
99
|
+
### ${name}
|
|
100
|
+
|
|
101
|
+
${await buildExplanation(shell)}
|
|
102
|
+
|
|
103
|
+
<details>
|
|
104
|
+
|
|
105
|
+
<summary style="color:gray">Implementation Details</summary>
|
|
106
|
+
|
|
107
|
+
Responsible for the execution of the ${name} query is \`${functionName}\` in ${(0, doc_files_1.getFilePathMd)(functionFile)}.
|
|
108
|
+
|
|
109
|
+
</details>
|
|
110
|
+
|
|
111
|
+
`;
|
|
112
|
+
}
|
|
113
|
+
async function explainQueries(shell, type) {
|
|
114
|
+
const queries = [...exports.RegisteredQueries[type].entries()].sort(([, { name: a }], [, { name: b }]) => a.localeCompare(b));
|
|
115
|
+
const result = [];
|
|
116
|
+
for (const [, doc] of queries) {
|
|
117
|
+
result.push(await explainQuery(shell, doc));
|
|
118
|
+
}
|
|
119
|
+
return result.join(`\n${'-'.repeat(5)}\n\n`);
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=doc-search.js.map
|
|
@@ -2,7 +2,7 @@ import ts from 'typescript';
|
|
|
2
2
|
export interface TypeElementInSource {
|
|
3
3
|
name: string;
|
|
4
4
|
node: ts.Node;
|
|
5
|
-
kind: 'interface' | 'type' | 'enum' | 'class';
|
|
5
|
+
kind: 'interface' | 'type' | 'enum' | 'class' | 'variable';
|
|
6
6
|
extends: string[];
|
|
7
7
|
generics: string[];
|
|
8
8
|
filePath: string;
|
|
@@ -25,7 +25,7 @@ export interface MermaidTypeReport {
|
|
|
25
25
|
program: ts.Program;
|
|
26
26
|
}
|
|
27
27
|
export declare function getTypesFromFolderAsMermaid(options: GetTypesAsMermaidOption): MermaidTypeReport;
|
|
28
|
-
export declare function implSnippet(node: TypeElementInSource | undefined, program: ts.Program, nesting?: number): string;
|
|
28
|
+
export declare function implSnippet(node: TypeElementInSource | undefined, program: ts.Program, showName?: boolean, nesting?: number): string;
|
|
29
29
|
export interface PrintHierarchyArguments {
|
|
30
30
|
readonly program: ts.Program;
|
|
31
31
|
readonly hierarchy: TypeElementInSource[];
|
|
@@ -36,3 +36,11 @@ export interface PrintHierarchyArguments {
|
|
|
36
36
|
}
|
|
37
37
|
export declare const mermaidHide: string[];
|
|
38
38
|
export declare function printHierarchy({ program, hierarchy, root, collapseFromNesting, initialNesting, maxDepth }: PrintHierarchyArguments): string;
|
|
39
|
+
/**
|
|
40
|
+
* Create a short link to a type in the documentation
|
|
41
|
+
* @param name - The name of the type, e.g. `MyType`, may include a container, e.g. `MyContainer::MyType` (this works with function nestings too)
|
|
42
|
+
* @param hierarchy - The hierarchy of types to search in
|
|
43
|
+
* @param codeStyle - Whether to use code style for the link
|
|
44
|
+
*/
|
|
45
|
+
export declare function shortLink(name: string, hierarchy: TypeElementInSource[], codeStyle?: boolean): string;
|
|
46
|
+
export declare function getDocumentationForType(name: string, hierarchy: TypeElementInSource[]): string;
|
|
@@ -10,6 +10,8 @@ exports.getTypePathLink = getTypePathLink;
|
|
|
10
10
|
exports.getTypesFromFolderAsMermaid = getTypesFromFolderAsMermaid;
|
|
11
11
|
exports.implSnippet = implSnippet;
|
|
12
12
|
exports.printHierarchy = printHierarchy;
|
|
13
|
+
exports.shortLink = shortLink;
|
|
14
|
+
exports.getDocumentationForType = getDocumentationForType;
|
|
13
15
|
const typescript_1 = __importDefault(require("typescript"));
|
|
14
16
|
const assert_1 = require("../../util/assert");
|
|
15
17
|
const doc_files_1 = require("./doc-files");
|
|
@@ -18,6 +20,7 @@ const path_1 = __importDefault(require("path"));
|
|
|
18
20
|
const mermaid_1 = require("../../util/mermaid/mermaid");
|
|
19
21
|
const doc_code_1 = require("./doc-code");
|
|
20
22
|
const doc_structure_1 = require("./doc-structure");
|
|
23
|
+
const html_hover_over_1 = require("../../util/html-hover-over");
|
|
21
24
|
function getSourceFiles(fileNames) {
|
|
22
25
|
try {
|
|
23
26
|
const program = typescript_1.default.createProgram(fileNames, { target: typescript_1.default.ScriptTarget.ESNext });
|
|
@@ -171,6 +174,42 @@ function collectHierarchyInformation(sourceFiles, options) {
|
|
|
171
174
|
}),
|
|
172
175
|
});
|
|
173
176
|
}
|
|
177
|
+
else if (typescript_1.default.isVariableDeclaration(node) || typescript_1.default.isExportDeclaration(node) || typescript_1.default.isExportAssignment(node) || typescript_1.default.isDeclarationStatement(node)) {
|
|
178
|
+
const name = node.name?.getText(sourceFile) ?? '';
|
|
179
|
+
const comments = getTextualComments(node);
|
|
180
|
+
hierarchyList.push({
|
|
181
|
+
name: dropGenericsFromType(name),
|
|
182
|
+
node,
|
|
183
|
+
kind: 'variable',
|
|
184
|
+
extends: [],
|
|
185
|
+
comments,
|
|
186
|
+
generics: [],
|
|
187
|
+
filePath: sourceFile.fileName,
|
|
188
|
+
lineNumber: getStartLine(node, sourceFile),
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
else if (typescript_1.default.isPropertyAssignment(node) || typescript_1.default.isPropertyDeclaration(node) || typescript_1.default.isPropertySignature(node)
|
|
192
|
+
|| typescript_1.default.isMethodDeclaration(node) || typescript_1.default.isMethodSignature(node) || typescript_1.default.isFunctionDeclaration(node)) {
|
|
193
|
+
const name = node.name?.getText(sourceFile) ?? '';
|
|
194
|
+
// get the name of the object/enclosing type
|
|
195
|
+
let parent = node.parent;
|
|
196
|
+
while (typeof parent === 'object' && parent !== undefined && !('name' in parent)) {
|
|
197
|
+
parent = parent.parent;
|
|
198
|
+
}
|
|
199
|
+
if (typeof parent === 'object' && 'name' in parent) {
|
|
200
|
+
const comments = getTextualComments(node);
|
|
201
|
+
hierarchyList.push({
|
|
202
|
+
name: dropGenericsFromType(name),
|
|
203
|
+
node,
|
|
204
|
+
kind: 'variable',
|
|
205
|
+
extends: [parent.name?.getText(sourceFile) ?? ''],
|
|
206
|
+
comments,
|
|
207
|
+
generics: [],
|
|
208
|
+
filePath: sourceFile.fileName,
|
|
209
|
+
lineNumber: getStartLine(node, sourceFile),
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
}
|
|
174
213
|
typescript_1.default.forEachChild(node, child => visit(child, sourceFile));
|
|
175
214
|
};
|
|
176
215
|
sourceFiles.forEach(sourceFile => {
|
|
@@ -266,7 +305,7 @@ function getTypesFromFolderAsMermaid(options) {
|
|
|
266
305
|
}
|
|
267
306
|
return getTypesFromFileAsMermaid(files, options);
|
|
268
307
|
}
|
|
269
|
-
function implSnippet(node, program, nesting = 0) {
|
|
308
|
+
function implSnippet(node, program, showName = true, nesting = 0) {
|
|
270
309
|
(0, assert_1.guard)(node !== undefined, 'Node must be defined => invalid change of type name?');
|
|
271
310
|
const indent = ' '.repeat(nesting * 2);
|
|
272
311
|
const bold = node.kind === 'interface' || node.kind === 'enum' ? '**' : '';
|
|
@@ -274,7 +313,8 @@ function implSnippet(node, program, nesting = 0) {
|
|
|
274
313
|
let text = node.comments?.join('\n') ?? '';
|
|
275
314
|
const code = node.node.getFullText(program.getSourceFile(node.node.getSourceFile().fileName));
|
|
276
315
|
text += `\n<details><summary style="color:gray">Defined at <a href="${getTypePathLink(node)}">${getTypePathLink(node, '.')}</a></summary>\n\n${(0, doc_code_1.codeBlock)('ts', code)}\n\n</details>\n`;
|
|
277
|
-
|
|
316
|
+
const init = showName ? ` * ${bold}[${node.name}](${getTypePathLink(node)})${bold} ${sep}${indent}` : '';
|
|
317
|
+
return ` ${indent} ${showName ? init : ''} ${text.replaceAll('\t', ' ').split(/\n/g).join(`\n${indent} `)}`;
|
|
278
318
|
}
|
|
279
319
|
exports.mermaidHide = ['Leaf', 'Location', 'Namespace', 'Base', 'WithChildren', 'Partial', 'RAccessBase'];
|
|
280
320
|
function printHierarchy({ program, hierarchy, root, collapseFromNesting = 1, initialNesting = 0, maxDepth = 20 }) {
|
|
@@ -285,7 +325,7 @@ function printHierarchy({ program, hierarchy, root, collapseFromNesting = 1, ini
|
|
|
285
325
|
if (!node) {
|
|
286
326
|
return '';
|
|
287
327
|
}
|
|
288
|
-
const thisLine = implSnippet(node, program, initialNesting);
|
|
328
|
+
const thisLine = implSnippet(node, program, true, initialNesting);
|
|
289
329
|
const result = [];
|
|
290
330
|
for (const baseType of node.extends) {
|
|
291
331
|
if (exports.mermaidHide.includes(baseType)) {
|
|
@@ -302,4 +342,42 @@ function printHierarchy({ program, hierarchy, root, collapseFromNesting = 1, ini
|
|
|
302
342
|
return thisLine + (out ? '\n' + out : '');
|
|
303
343
|
}
|
|
304
344
|
}
|
|
345
|
+
function retrieveNode(name, hierarchy) {
|
|
346
|
+
let container = undefined;
|
|
347
|
+
if (name.includes('::')) {
|
|
348
|
+
[container, name] = name.split('::');
|
|
349
|
+
}
|
|
350
|
+
const node = hierarchy.find(e => e.name === name);
|
|
351
|
+
if (!node) {
|
|
352
|
+
return undefined;
|
|
353
|
+
}
|
|
354
|
+
else if (container && !node.extends.includes(container)) {
|
|
355
|
+
return undefined;
|
|
356
|
+
}
|
|
357
|
+
return [container, name, node];
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Create a short link to a type in the documentation
|
|
361
|
+
* @param name - The name of the type, e.g. `MyType`, may include a container, e.g. `MyContainer::MyType` (this works with function nestings too)
|
|
362
|
+
* @param hierarchy - The hierarchy of types to search in
|
|
363
|
+
* @param codeStyle - Whether to use code style for the link
|
|
364
|
+
*/
|
|
365
|
+
function shortLink(name, hierarchy, codeStyle = true) {
|
|
366
|
+
const res = retrieveNode(name, hierarchy);
|
|
367
|
+
if (!res) {
|
|
368
|
+
return '';
|
|
369
|
+
}
|
|
370
|
+
const [pkg, mainName, node] = res;
|
|
371
|
+
const comments = node.comments?.join('\n').replace(/\\?\n|```[a-zA-Z]*|\s\s*/g, ' ').replace(/<\/?code>|`/g, '').replace(/"/g, '\'') ?? '';
|
|
372
|
+
return `[${codeStyle ? '<code>' : ''}${(node.comments?.length ?? 0) > 0 ?
|
|
373
|
+
(0, html_hover_over_1.textWithTooltip)(pkg ? `${pkg}::<b>${mainName}</b>` : mainName, comments.length > 400 ? comments.slice(0, 400) + '...' : comments) : node.name}${codeStyle ? '</code>' : ''}](${getTypePathLink(node)})`;
|
|
374
|
+
}
|
|
375
|
+
function getDocumentationForType(name, hierarchy) {
|
|
376
|
+
const res = retrieveNode(name, hierarchy);
|
|
377
|
+
if (!res) {
|
|
378
|
+
return '';
|
|
379
|
+
}
|
|
380
|
+
const [, , node] = res;
|
|
381
|
+
return node.comments?.join('\n') ?? '';
|
|
382
|
+
}
|
|
305
383
|
//# sourceMappingURL=doc-types.js.map
|