@eagleoutice/flowr 2.13.16 → 2.14.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 +31 -31
- package/abstract-interpretation/absint-visitor.js +1 -1
- package/abstract-interpretation/data-frame/mappers/access-mapper.js +4 -4
- package/abstract-interpretation/data-frame/mappers/arguments.js +7 -4
- package/abstract-interpretation/data-frame/mappers/function-mapper.js +18 -17
- package/abstract-interpretation/data-frame/mappers/replacement-mapper.js +6 -6
- package/abstract-interpretation/data-frame/resolve-args.d.ts +9 -4
- package/abstract-interpretation/data-frame/resolve-args.js +10 -5
- package/benchmark/calibration.d.ts +12 -5
- package/benchmark/calibration.js +42 -14
- package/benchmark/slicer.d.ts +1 -1
- package/benchmark/slicer.js +5 -4
- package/benchmark/stats/size-of.js +1 -1
- package/benchmark/summarizer/first-phase/process.d.ts +2 -0
- package/benchmark/summarizer/first-phase/process.js +2 -0
- package/cli/common/options.d.ts +0 -31
- package/cli/common/options.js +1 -8
- package/cli/common/scripts-info.d.ts +0 -38
- package/cli/common/scripts-info.js +0 -8
- package/cli/repl/core.js +1 -1
- package/cli/repl/parser/slice-query-parser.js +1 -1
- package/cli/repl/print-version.js +2 -2
- package/config.d.ts +16 -0
- package/config.js +79 -0
- package/control-flow/extract-cfg.js +1 -1
- package/control-flow/semantic-cfg-guided-visitor.d.ts +1 -1
- package/control-flow/semantic-cfg-guided-visitor.js +1 -1
- package/control-flow/useless-loop.js +1 -1
- package/core/print/slice-diff-ansi.js +1 -1
- package/core/steps/pipeline/create-pipeline.js +1 -1
- package/dataflow/cluster.js +2 -2
- package/dataflow/environments/built-in-props.d.ts +8 -1
- package/dataflow/environments/built-in-props.js +18 -0
- package/dataflow/environments/built-in.d.ts +7 -1
- package/dataflow/environments/built-in.js +42 -3
- package/dataflow/environments/default-builtin-config.d.ts +442 -10
- package/dataflow/environments/default-builtin-config.js +188 -18
- package/dataflow/environments/environment.d.ts +1 -1
- package/dataflow/environments/identifier.d.ts +7 -2
- package/dataflow/environments/identifier.js +6 -1
- package/dataflow/environments/query-fn-props.js +2 -2
- package/dataflow/environments/reference-to-maybe.js +5 -5
- package/dataflow/environments/resolve-by-name.d.ts +3 -0
- package/dataflow/environments/resolve-by-name.js +30 -5
- package/dataflow/environments/resolve-helper.d.ts +6 -0
- package/dataflow/environments/resolve-helper.js +6 -0
- package/dataflow/eval/resolve/alias-tracking.d.ts +5 -0
- package/dataflow/eval/resolve/alias-tracking.js +21 -14
- package/dataflow/eval/resolve/node-value.d.ts +6 -0
- package/dataflow/eval/resolve/node-value.js +15 -9
- package/dataflow/eval/resolve/resolve-argument.js +2 -2
- package/dataflow/eval/resolve/resolve-numbers.js +2 -2
- package/dataflow/eval/resolve/resolve-operators.js +4 -3
- package/dataflow/eval/resolve/resolve-strings.js +3 -3
- package/dataflow/eval/resolve/resolve-working-directory.js +2 -1
- package/dataflow/eval/resolve/resolve.d.ts +5 -5
- package/dataflow/eval/resolve/resolve.js +10 -11
- package/dataflow/eval/values/general.d.ts +4 -1
- package/dataflow/eval/values/general.js +1 -1
- package/dataflow/extractor.js +2 -1
- package/dataflow/fn/exceptions-of-function.js +5 -4
- package/dataflow/fn/higher-order-function.js +5 -4
- package/dataflow/graph/call-graph.js +14 -14
- package/dataflow/graph/df-helper.d.ts +15 -0
- package/dataflow/graph/df-helper.js +10 -4
- package/dataflow/graph/diff-dataflow-graph.js +6 -6
- package/dataflow/graph/edge.d.ts +27 -0
- package/dataflow/graph/edge.js +33 -0
- package/dataflow/graph/graph-helper.d.ts +3 -4
- package/dataflow/graph/graph-helper.js +4 -5
- package/dataflow/graph/graph.d.ts +11 -1
- package/dataflow/graph/graph.js +16 -5
- package/dataflow/graph/vertex.d.ts +42 -6
- package/dataflow/graph/vertex.js +42 -6
- package/dataflow/internal/linker.d.ts +1 -0
- package/dataflow/internal/linker.js +11 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +2 -2
- 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.js +6 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +6 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +7 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +1 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +19 -18
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +6 -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-local.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.js +5 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +3 -1
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +15 -12
- package/dataflow/internal/process/functions/call/common.d.ts +9 -1
- package/dataflow/internal/process/functions/call/common.js +17 -6
- package/dataflow/internal/process/functions/call/deferred.js +2 -1
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +3 -1
- package/dataflow/internal/process/functions/call/known-call-handling.js +6 -3
- package/dataflow/internal/process/functions/call/named-call-handling.js +44 -12
- package/dataflow/internal/process/functions/call/nse.d.ts +33 -5
- package/dataflow/internal/process/functions/call/nse.js +113 -6
- package/dataflow/internal/process/functions/call/quoted.d.ts +5 -0
- package/dataflow/internal/process/functions/call/quoted.js +21 -9
- package/dataflow/origin/dfg-get-origin.d.ts +1 -0
- package/dataflow/origin/dfg-get-origin.js +9 -6
- package/documentation/data/faq/faqs.js +88 -88
- package/documentation/data/faq/recommended-configs.js +1 -1
- package/documentation/data/faq/wiki-faq-store.js +1 -1
- package/documentation/doc-capabilities.js +1 -1
- package/documentation/doc-readme.js +1 -1
- package/documentation/doc-util/doc-auto-gen.js +6 -2
- package/documentation/doc-util/doc-functions.js +1 -1
- package/documentation/wiki-cfg.js +2 -2
- package/documentation/wiki-create-linting-rules.js +45 -45
- package/documentation/wiki-dataflow-graph.js +17 -18
- package/documentation/wiki-linting-and-testing.js +93 -5
- package/documentation/wiki-mk/doc-maker.js +1 -1
- package/documentation/wiki-overview.js +12 -1
- package/documentation/wiki-signature-database.js +3 -0
- package/linter/rules/file-path-validity.js +1 -1
- package/linter/rules/function-finder-util.js +1 -1
- package/linter/rules/naming-convention.js +1 -1
- package/linter/rules/no-leaked-credentials.js +2 -1
- package/linter/rules/stop-with-call-arg.js +4 -4
- package/linter/rules/undefined-symbol-util.d.ts +1 -1
- package/linter/rules/undefined-symbol-util.js +5 -4
- package/linter/rules/undefined-symbol.js +3 -3
- package/linter/rules/unused-definition.js +2 -1
- package/package.json +35 -45
- package/project/context/flowr-analyzer-environment-context.d.ts +23 -0
- package/project/context/flowr-analyzer-environment-context.js +25 -0
- package/project/dependency-version-space.js +1 -2
- package/project/flowr-analyzer.js +1 -1
- package/project/plugins/file-plugins/files/flowr-rda-file.js +3 -3
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +2 -2
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +3 -1
- package/project/sigdb/build.js +16 -16
- package/project/sigdb/codec.d.ts +1 -1
- package/project/sigdb/codec.js +13 -13
- package/project/sigdb/decompress.d.ts +1 -1
- package/project/sigdb/decompress.js +33 -33
- package/project/sigdb/index-format.js +2 -2
- package/project/sigdb/manifest.js +21 -21
- package/project/sigdb/memory-source.d.ts +64 -0
- package/project/sigdb/memory-source.js +133 -0
- package/project/sigdb/reader.js +13 -13
- package/queries/catalog/call-context-query/call-context-query-executor.js +1 -1
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +2 -2
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +2 -2
- package/queries/catalog/dependencies-query/dependencies-query-format.js +1 -1
- package/queries/catalog/dependencies-query/link-devices.js +2 -2
- package/queries/catalog/does-call-query/does-call-query-executor.js +2 -1
- package/queries/catalog/input-sources-query/simple-input-classifier.js +4 -4
- package/queries/catalog/location-map-query/location-map-query-format.js +1 -1
- package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +2 -2
- package/queries/catalog/signature-query/signature-query-executor.d.ts +2 -0
- package/queries/catalog/signature-query/signature-query-executor.js +3 -2
- package/r-bridge/lang-4.x/ast/model/processing/node-id.js +3 -3
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-definition.js +1 -1
- package/r-bridge/retriever.d.ts +2 -1
- package/r-bridge/retriever.js +3 -2
- package/r-bridge/roxygen2/documentation-provider.d.ts +1 -0
- package/r-bridge/roxygen2/documentation-provider.js +1 -0
- package/r-bridge/roxygen2/roxygen-parse.d.ts +1 -1
- package/r-bridge/roxygen2/roxygen-parse.js +1 -1
- package/search/flowr-search-filters.d.ts +1 -1
- package/search/flowr-search-filters.js +2 -2
- package/search/search-executor/search-enrichers.js +4 -4
- package/search/search-executor/search-generators.js +1 -1
- package/slicing/criterion/parse.js +3 -3
- package/slicing/static/slice-call.d.ts +1 -1
- package/slicing/static/slice-call.js +2 -2
- package/slicing/static/static-slicer.js +4 -3
- package/util/assert.js +1 -1
- package/util/log.d.ts +4 -1
- package/util/log.js +15 -2
- package/util/logic.js +2 -2
- package/util/mermaid/cfg.js +1 -1
- package/util/mermaid/dfg.js +6 -6
- package/util/mermaid/mermaid.js +3 -1
- package/util/quads.js +19 -6
- package/util/schema.js +2 -2
- package/util/text/ansi.d.ts +2 -0
- package/util/text/ansi.js +8 -0
- package/util/text/name-rank.d.ts +29 -0
- package/util/text/name-rank.js +39 -0
- package/util/text/url-encoding.d.ts +15 -0
- package/util/text/url-encoding.js +59 -0
- package/util/version.js +1 -1
- package/cli/export-quads-app.d.ts +0 -7
- package/cli/export-quads-app.js +0 -44
|
@@ -101,7 +101,7 @@ exports.DefaultDependencyCategories = {
|
|
|
101
101
|
continue;
|
|
102
102
|
}
|
|
103
103
|
const vertex = dataflow.graph.getVertex(statement.info.id);
|
|
104
|
-
const functionName =
|
|
104
|
+
const functionName = vertex_1.FunctionCallVertex.is(vertex)
|
|
105
105
|
? df_helper_1.Dataflow.qualify(statement.info.id, dataflow.graph, false) ?? vertex.name : undefined;
|
|
106
106
|
if (functionName === undefined) {
|
|
107
107
|
continue;
|
|
@@ -9,7 +9,7 @@ const range_1 = require("../../../util/range");
|
|
|
9
9
|
/** the {@link CallProp} bits of the call `id` makes */
|
|
10
10
|
function propsOf(id, { graph, environment }) {
|
|
11
11
|
const vertex = graph.getVertex(id);
|
|
12
|
-
if (
|
|
12
|
+
if (!vertex_1.FunctionCallVertex.is(vertex)) {
|
|
13
13
|
return 0;
|
|
14
14
|
}
|
|
15
15
|
const name = df_helper_1.Dataflow.qualify(id, graph, false) ?? vertex.name;
|
|
@@ -32,7 +32,7 @@ function linkPlotsToDevices(written, plots, dataflow, ast) {
|
|
|
32
32
|
.filter(w => w.value !== undefined && (propsOf(w.nodeId, dataflow) & built_in_props_1.CallProp.Graphics) !== 0)
|
|
33
33
|
.map(w => [w.nodeId, w.value]));
|
|
34
34
|
const closed = new Set(dataflow.graph.vertices(true)
|
|
35
|
-
.filter(([id, v]) =>
|
|
35
|
+
.filter(([id, v]) => vertex_1.FunctionCallVertex.is(v) && (propsOf(id, dataflow) & built_in_props_1.CallProp.Closes) !== 0)
|
|
36
36
|
.map(([id]) => id));
|
|
37
37
|
const plotAt = new Map(plots.map((p, index) => [p.nodeId, index]));
|
|
38
38
|
const located = [...opened.keys(), ...closed, ...plotAt.keys()]
|
|
@@ -6,6 +6,7 @@ const node_id_1 = require("../../../r-bridge/lang-4.x/ast/model/processing/node-
|
|
|
6
6
|
const identifier_1 = require("../../../dataflow/environments/identifier");
|
|
7
7
|
const parse_1 = require("../../../slicing/criterion/parse");
|
|
8
8
|
const expand_library_internals_1 = require("../call-graph-query/expand-library-internals");
|
|
9
|
+
const graph_1 = require("../../../dataflow/graph/graph");
|
|
9
10
|
/**
|
|
10
11
|
* Execute does call queries on the given analyzer.
|
|
11
12
|
*/
|
|
@@ -97,7 +98,7 @@ function findCallersMatchingConstraints(cg, start, constraints, expandDeps) {
|
|
|
97
98
|
if (constraints(vtx, cg)) {
|
|
98
99
|
return { call: start };
|
|
99
100
|
}
|
|
100
|
-
for (const out of cg.outgoingEdges(cur) ??
|
|
101
|
+
for (const out of cg.outgoingEdges(cur) ?? graph_1.NoEdges) {
|
|
101
102
|
toVisit.push(out[0]);
|
|
102
103
|
}
|
|
103
104
|
}
|
|
@@ -173,10 +173,10 @@ class InputClassifier {
|
|
|
173
173
|
if (vtx === undefined) {
|
|
174
174
|
return;
|
|
175
175
|
}
|
|
176
|
-
else if (
|
|
176
|
+
else if (vertex_1.FunctionDefinitionVertex.is(vtx)) {
|
|
177
177
|
yield vtx.id;
|
|
178
178
|
}
|
|
179
|
-
else if (
|
|
179
|
+
else if (vertex_1.VariableDefinitionVertex.is(vtx)) {
|
|
180
180
|
for (const source of vtx.source ?? []) {
|
|
181
181
|
yield* this.functionDefinitionsAt(source, depth + 1);
|
|
182
182
|
}
|
|
@@ -538,7 +538,7 @@ class InputClassifier {
|
|
|
538
538
|
acc.allPure = false;
|
|
539
539
|
}
|
|
540
540
|
// if this is a variable definition that is a parameter, classify as Parameter
|
|
541
|
-
if (
|
|
541
|
+
if (vertex_1.VariableDefinitionVertex.is(v) && this.dfg.idMap?.get(v.id)?.info.role === "param-n" /* RoleInParent.ParameterName */) {
|
|
542
542
|
acc.types.push(this.matchWholeLinkedObject(v.id)?.type ?? input_types_1.InputType.Parameter);
|
|
543
543
|
acc.values.push(undefined);
|
|
544
544
|
return;
|
|
@@ -657,7 +657,7 @@ function classifyInput(id, dfg, config, fullDfg, packages) {
|
|
|
657
657
|
return [];
|
|
658
658
|
}
|
|
659
659
|
const c = new InputClassifier(dfg, config, fullDfg, packages);
|
|
660
|
-
if (
|
|
660
|
+
if (vertex_1.FunctionCallVertex.is(vtx)) {
|
|
661
661
|
const ret = [];
|
|
662
662
|
const args = vtx.args;
|
|
663
663
|
for (const arg of args) {
|
|
@@ -46,7 +46,7 @@ exports.LocationMapQueryDefinition = {
|
|
|
46
46
|
for (const [id, file] of Object.entries(out.map.files)) {
|
|
47
47
|
result.push(` ╰ ${id}: \`${file}\``);
|
|
48
48
|
}
|
|
49
|
-
result.push(` ╰ Id List: {${(0, query_print_1.summarizeIdsIfTooLong)(formatter,
|
|
49
|
+
result.push(` ╰ Id List: {${(0, query_print_1.summarizeIdsIfTooLong)(formatter, Object.keys(out.map.ids))}}`);
|
|
50
50
|
return true;
|
|
51
51
|
},
|
|
52
52
|
fromLine: locationMapLineParser,
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.fingerPrintOfQuery = fingerPrintOfQuery;
|
|
4
4
|
exports.executeResolveValueQuery = executeResolveValueQuery;
|
|
5
5
|
const log_1 = require("../../../util/log");
|
|
6
|
-
const alias_tracking_1 = require("../../../dataflow/eval/resolve/alias-tracking");
|
|
7
6
|
const parse_1 = require("../../../slicing/criterion/parse");
|
|
7
|
+
const resolve_helper_1 = require("../../../dataflow/environments/resolve-helper");
|
|
8
8
|
/**
|
|
9
9
|
* Naive fingerprint to filter out duplicate queries.
|
|
10
10
|
*/
|
|
@@ -26,7 +26,7 @@ async function executeResolveValueQuery({ analyzer }, queries) {
|
|
|
26
26
|
}
|
|
27
27
|
const values = query.criteria
|
|
28
28
|
.map(criteria => parse_1.SlicingCriterion.parse(criteria, idMap))
|
|
29
|
-
.flatMap(ident =>
|
|
29
|
+
.flatMap(ident => resolve_helper_1.Resolve.toValue(ident, { graph, full: true, idMap, resolve: analyzer.flowrConfig.solver.variables, ctx: analyzer.inspectContext() }));
|
|
30
30
|
results[key] = {
|
|
31
31
|
values: values
|
|
32
32
|
};
|
|
@@ -13,6 +13,8 @@ export declare function cranMirrorSourceUrl(pkg: string, version: string | undef
|
|
|
13
13
|
* is unknown.
|
|
14
14
|
*/
|
|
15
15
|
export declare function rSourceRef(version: string | undefined): string;
|
|
16
|
+
/** deep-link a base-R definition into the R sources mirror at the release series of `version` */
|
|
17
|
+
export declare function rSourceUrl(pkg: string, version: string | undefined, file: string, line?: number): string;
|
|
16
18
|
/** best-effort rdrr.io documentation link: `/r/<pkg>/<fn>` for base R, `/cran/<pkg>/man/<fn>` for CRAN */
|
|
17
19
|
export declare function rdrrDocUrl(pkg: string, fn: string, opts: {
|
|
18
20
|
base: boolean;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.cranPageUrl = cranPageUrl;
|
|
4
4
|
exports.cranMirrorSourceUrl = cranMirrorSourceUrl;
|
|
5
5
|
exports.rSourceRef = rSourceRef;
|
|
6
|
+
exports.rSourceUrl = rSourceUrl;
|
|
6
7
|
exports.rdrrDocUrl = rdrrDocUrl;
|
|
7
8
|
exports.signatureFunctionInfo = signatureFunctionInfo;
|
|
8
9
|
exports.signaturePackageInfo = signaturePackageInfo;
|
|
@@ -15,12 +16,12 @@ const schema_1 = require("../../../project/sigdb/schema");
|
|
|
15
16
|
const attached_packages_1 = require("../../../project/attached-packages");
|
|
16
17
|
const manifest_1 = require("../../../project/sigdb/manifest");
|
|
17
18
|
const query_fn_props_1 = require("../../../dataflow/environments/query-fn-props");
|
|
18
|
-
const resolve_by_name_1 = require("../../../dataflow/environments/resolve-by-name");
|
|
19
19
|
const built_in_props_1 = require("../../../dataflow/environments/built-in-props");
|
|
20
20
|
const identifier_1 = require("../../../dataflow/environments/identifier");
|
|
21
21
|
const r_version_1 = require("../../../util/r-version");
|
|
22
22
|
const r_base_packages_1 = require("../../../util/r-base-packages");
|
|
23
23
|
const mermaid_1 = require("../../../util/mermaid/mermaid");
|
|
24
|
+
const resolve_helper_1 = require("../../../dataflow/environments/resolve-helper");
|
|
24
25
|
/** the CRAN package landing page (only meaningful for CRAN packages, not base R) */
|
|
25
26
|
function cranPageUrl(pkg) {
|
|
26
27
|
return `https://cran.r-project.org/package=${encodeURIComponent(pkg)}`;
|
|
@@ -219,7 +220,7 @@ function flowrOnlyFunctionInfo(env, pkg, name) {
|
|
|
219
220
|
if (env === undefined) {
|
|
220
221
|
return undefined;
|
|
221
222
|
}
|
|
222
|
-
const resolved =
|
|
223
|
+
const resolved = resolve_helper_1.Resolve.byNameAndType(pkg === undefined ? name : identifier_1.Identifier.make(name, pkg), env, identifier_1.ReferenceType.Function);
|
|
223
224
|
const definition = resolved?.find(d => d.type === identifier_1.ReferenceType.BuiltInFunction);
|
|
224
225
|
if (definition === undefined) {
|
|
225
226
|
return undefined;
|
|
@@ -84,7 +84,7 @@ exports.NodeId = {
|
|
|
84
84
|
*/
|
|
85
85
|
mapBuiltInProc(proc) {
|
|
86
86
|
const bi = 'builtin:';
|
|
87
|
-
return exports.NodeId.toBuiltIn(proc.startsWith(bi) ? proc.
|
|
87
|
+
return exports.NodeId.toBuiltIn(proc.startsWith(bi) ? proc.slice(bi.length) : proc);
|
|
88
88
|
},
|
|
89
89
|
/**
|
|
90
90
|
* Recovers the built-in function or operator name from a built-in id by removing the built-in prefix.
|
|
@@ -108,7 +108,7 @@ function recoverName(id, idMap) {
|
|
|
108
108
|
*/
|
|
109
109
|
function recoverContent(id, graph) {
|
|
110
110
|
const vertex = graph.getVertex(id);
|
|
111
|
-
if (vertex &&
|
|
111
|
+
if (vertex && vertex_1.FunctionCallVertex.is(vertex) && vertex.name) {
|
|
112
112
|
return identifier_1.Identifier.toString(vertex.name);
|
|
113
113
|
}
|
|
114
114
|
const node = graph.idMap?.get(id);
|
|
@@ -116,7 +116,7 @@ function recoverContent(id, graph) {
|
|
|
116
116
|
return undefined;
|
|
117
117
|
}
|
|
118
118
|
const lexeme = node.lexeme ?? node.info.fullLexeme ?? '';
|
|
119
|
-
if (
|
|
119
|
+
if (vertex_1.UseVertex.is(vertex)) {
|
|
120
120
|
return (0, retriever_1.removeRQuotes)(lexeme);
|
|
121
121
|
}
|
|
122
122
|
return lexeme;
|
|
@@ -35,7 +35,7 @@ function tryNormalizeFunctionCall(data, mappedWithName) {
|
|
|
35
35
|
// special handling when someone calls a function by string
|
|
36
36
|
return parseNamedFunctionCall(data, namedSymbolContent, mappedWithName, location, content);
|
|
37
37
|
}
|
|
38
|
-
else if (namedSymbolContent.
|
|
38
|
+
else if (!namedSymbolContent.some(x => x.name === type_1.RawRType.SymbolFunctionCall)) {
|
|
39
39
|
parser_1.parseLog.trace(`is not named function call, as the name is not of type ${type_1.RType.FunctionCall}, but: ${namedSymbolContent.map(n => n.name).join(',')}`);
|
|
40
40
|
return tryParseUnnamedFunctionCall(data, mappedWithName, location, content);
|
|
41
41
|
}
|
|
@@ -27,7 +27,7 @@ function tryNormalizeFunctionDefinition(data, mappedWithName) {
|
|
|
27
27
|
(0, assert_1.guard)(closingParenIndex !== -1, () => `expected closing parenthesis, yet received ${JSON.stringify(mappedWithName)}`);
|
|
28
28
|
const splitParameters = (0, arrays_1.splitArrayOn)(mappedWithName.slice(2, closingParenIndex), x => x.name === type_1.RawRType.Comma);
|
|
29
29
|
const parameters = splitParameters.map(x => (0, normalize_parameter_1.tryNormalizeParameter)(data, x));
|
|
30
|
-
if (parameters.
|
|
30
|
+
if (parameters.includes(undefined)) {
|
|
31
31
|
parser_1.parseLog.error(`function had unexpected unknown parameters: ${JSON.stringify(parameters.filter(assert_1.isNotUndefined))}, aborting.`);
|
|
32
32
|
return undefined;
|
|
33
33
|
}
|
package/r-bridge/retriever.d.ts
CHANGED
|
@@ -70,7 +70,8 @@ export declare function retrieveParseDataFromRCode(request: RParseRequest, shell
|
|
|
70
70
|
/**
|
|
71
71
|
* Uses {@link retrieveParseDataFromRCode} and returns the nicely formatted object-AST.
|
|
72
72
|
* If successful, allows further querying the last result with {@link retrieveNumberOfRTokensOfLastParse}.
|
|
73
|
-
* This function is outdated and should only be used for legacy reasons.
|
|
73
|
+
* This function is outdated and should only be used for legacy reasons.
|
|
74
|
+
* @useInstead {@link FlowrAnalyzer}
|
|
74
75
|
*/
|
|
75
76
|
export declare function retrieveNormalizedAstFromRCode(request: RParseRequest, shell: RShell): Promise<NormalizedAst>;
|
|
76
77
|
/**
|
package/r-bridge/retriever.js
CHANGED
|
@@ -50,7 +50,7 @@ function requestFromInput(input) {
|
|
|
50
50
|
if (file) {
|
|
51
51
|
return {
|
|
52
52
|
request: 'file',
|
|
53
|
-
content: content.
|
|
53
|
+
content: content.slice(exports.fileProtocol.length),
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
56
|
else {
|
|
@@ -148,7 +148,8 @@ function retrieveParseDataFromRCode(request, shell) {
|
|
|
148
148
|
/**
|
|
149
149
|
* Uses {@link retrieveParseDataFromRCode} and returns the nicely formatted object-AST.
|
|
150
150
|
* If successful, allows further querying the last result with {@link retrieveNumberOfRTokensOfLastParse}.
|
|
151
|
-
* This function is outdated and should only be used for legacy reasons.
|
|
151
|
+
* This function is outdated and should only be used for legacy reasons.
|
|
152
|
+
* @useInstead {@link FlowrAnalyzer}
|
|
152
153
|
*/
|
|
153
154
|
async function retrieveNormalizedAstFromRCode(request, shell) {
|
|
154
155
|
const data = await retrieveParseDataFromRCode(request, shell);
|
|
@@ -11,5 +11,6 @@ export type Documentation = RoxygenTag | readonly RoxygenTag[];
|
|
|
11
11
|
* Additionally, this function instruments the normalized AST to cache the parsed documentation for future queries.
|
|
12
12
|
* @param idMap - The AST ID map to use for looking up nodes and traversing the AST.
|
|
13
13
|
* @param nodeId - The ID of the node to get documentation for.
|
|
14
|
+
* @useInstead {@link RNode.documentation}
|
|
14
15
|
*/
|
|
15
16
|
export declare function getDocumentationOf(nodeId: NodeId, idMap: AstIdMap<ParentInformation & DocumentationInfo>): Documentation | undefined;
|
|
@@ -36,6 +36,7 @@ const defaultRetriever = (c, a) => (0, roxygen_parse_1.parseRoxygenCommentsOfNod
|
|
|
36
36
|
* Additionally, this function instruments the normalized AST to cache the parsed documentation for future queries.
|
|
37
37
|
* @param idMap - The AST ID map to use for looking up nodes and traversing the AST.
|
|
38
38
|
* @param nodeId - The ID of the node to get documentation for.
|
|
39
|
+
* @useInstead {@link RNode.documentation}
|
|
39
40
|
*/
|
|
40
41
|
function getDocumentationOf(nodeId, idMap) {
|
|
41
42
|
const node = idMap.get(nodeId);
|
|
@@ -5,7 +5,7 @@ import type { AstIdMap, ParentInformation } from '../lang-4.x/ast/model/processi
|
|
|
5
5
|
* Parses the roxygen comments attached to a node into a RoxygenBlock AST node.
|
|
6
6
|
* Will return `undefined` if there are no valid roxygen comments attached to the node.
|
|
7
7
|
* Please note that this does *not* do any clever mapping of parameters or requests.
|
|
8
|
-
* For a higher-level function that also traverses up the AST to find comments attached to parent nodes, see {@link
|
|
8
|
+
* For a higher-level function that also traverses up the AST to find comments attached to parent nodes, see {@link RNode.documentation}.
|
|
9
9
|
* @param node - The node to parse the roxygen comments for
|
|
10
10
|
* @param idMap - An optional id map to traverse up the AST to find comments attached to parent nodes
|
|
11
11
|
*/
|
|
@@ -27,7 +27,7 @@ function prepareCommentContext(commentText) {
|
|
|
27
27
|
* Parses the roxygen comments attached to a node into a RoxygenBlock AST node.
|
|
28
28
|
* Will return `undefined` if there are no valid roxygen comments attached to the node.
|
|
29
29
|
* Please note that this does *not* do any clever mapping of parameters or requests.
|
|
30
|
-
* For a higher-level function that also traverses up the AST to find comments attached to parent nodes, see {@link
|
|
30
|
+
* For a higher-level function that also traverses up the AST to find comments attached to parent nodes, see {@link RNode.documentation}.
|
|
31
31
|
* @param node - The node to parse the roxygen comments for
|
|
32
32
|
* @param idMap - An optional id map to traverse up the AST to find comments attached to parent nodes
|
|
33
33
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RType } from '../r-bridge/lang-4.x/ast/model/type';
|
|
2
|
-
import { VertexType } from '../dataflow/graph/vertex';
|
|
2
|
+
import type { VertexType } from '../dataflow/graph/vertex';
|
|
3
3
|
import type { ParentInformation } from '../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
4
4
|
import type { FlowrSearchElement } from './flowr-search';
|
|
5
5
|
import type { Enrichment } from './search-executor/search-enrichers';
|
|
@@ -60,7 +60,7 @@ exports.FlowrFilters = {
|
|
|
60
60
|
}),
|
|
61
61
|
[FlowrFilter.OriginKind]: ((e, args, data) => {
|
|
62
62
|
const dfgNode = data.dataflow.graph.getVertex(e.node.info.id);
|
|
63
|
-
if (!dfgNode ||
|
|
63
|
+
if (!dfgNode || !vertex_1.FunctionCallVertex.is(dfgNode)) {
|
|
64
64
|
return args.keepNonFunctionCalls ?? false;
|
|
65
65
|
}
|
|
66
66
|
const match = typeof args.origin === 'string' ?
|
|
@@ -80,7 +80,7 @@ exports.FlowrFilters = {
|
|
|
80
80
|
[FlowrFilter.CallProps]: ((e, args, data) => {
|
|
81
81
|
const graph = data.dataflow.graph;
|
|
82
82
|
const vertex = graph.getVertex(e.node.info.id);
|
|
83
|
-
if (
|
|
83
|
+
if (!vertex_1.FunctionCallVertex.is(vertex)) {
|
|
84
84
|
return false;
|
|
85
85
|
}
|
|
86
86
|
/* what the call resolved to decides, as a definition in the analyzed code shadows the built-in; a call
|
|
@@ -13,7 +13,7 @@ const cfg_kind_1 = require("../../project/cfg-kind");
|
|
|
13
13
|
const identify_link_to_last_call_relation_1 = require("../../queries/catalog/call-context-query/identify-link-to-last-call-relation");
|
|
14
14
|
const identifier_1 = require("../../dataflow/environments/identifier");
|
|
15
15
|
const df_helper_1 = require("../../dataflow/graph/df-helper");
|
|
16
|
-
const
|
|
16
|
+
const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
|
|
17
17
|
/**
|
|
18
18
|
* An enumeration that stores the names of the available enrichments that can be applied to a set of search elements.
|
|
19
19
|
* See {@link FlowrSearchBuilder.with} for more information on how to apply enrichments.
|
|
@@ -43,7 +43,7 @@ exports.Enrichments = {
|
|
|
43
43
|
const df = shared?.dfg ?? await analyzer.dataflow();
|
|
44
44
|
const n = shared?.ast ?? await analyzer.normalize();
|
|
45
45
|
const callVertex = df.graph.getVertex(e.node.info.id);
|
|
46
|
-
if (
|
|
46
|
+
if (vertex_1.FunctionCallVertex.is(callVertex)) {
|
|
47
47
|
const origins = df_helper_1.Dataflow.origin(df.graph, callVertex.id);
|
|
48
48
|
if (!origins || origins.length === 0) {
|
|
49
49
|
const name = (0, node_id_1.recoverName)(callVertex.id, n.idMap);
|
|
@@ -111,7 +111,7 @@ exports.Enrichments = {
|
|
|
111
111
|
const shared = s.enrichmentContent(Enrichment.LastCall);
|
|
112
112
|
const df = (shared?.dfg ?? await analyzer.dataflow()).graph;
|
|
113
113
|
const vertex = df.getVertex(e.node.info.id);
|
|
114
|
-
if (
|
|
114
|
+
if (vertex_1.FunctionCallVertex.is(vertex)) {
|
|
115
115
|
const n = shared?.ast ?? await analyzer.normalize();
|
|
116
116
|
const cfg = (shared?.cfg ?? await analyzer.controlflow(undefined, cfg_kind_1.CfgKind.Quick)).graph;
|
|
117
117
|
for (const arg of args) {
|
|
@@ -168,7 +168,7 @@ exports.Enrichments = {
|
|
|
168
168
|
});
|
|
169
169
|
const shared = search.enrichmentContent(Enrichment.Roxygen);
|
|
170
170
|
const normalize = shared?.ast ?? await analyzer.normalize();
|
|
171
|
-
const roxygen =
|
|
171
|
+
const roxygen = model_1.RNode.documentation(e.node.info.id, normalize.idMap);
|
|
172
172
|
if (roxygen !== undefined) {
|
|
173
173
|
const comments = (Array.isArray(roxygen) ? roxygen : [roxygen]);
|
|
174
174
|
content.documentation.push(...comments);
|
|
@@ -114,7 +114,7 @@ async function generateSyntax(input, args) {
|
|
|
114
114
|
args.captures = [defaultCaptureName];
|
|
115
115
|
}
|
|
116
116
|
// allow specifying capture names with or without the @ in front :)
|
|
117
|
-
const captures = new Set(args.captures.map(c => c.startsWith('@') ? c.
|
|
117
|
+
const captures = new Set(args.captures.map(c => c.startsWith('@') ? c.slice(1) : c));
|
|
118
118
|
const info = input.parserInformation();
|
|
119
119
|
(0, assert_1.guard)(info.name === 'tree-sitter', 'treeSitterQuery can only be used with TreeSitterExecutor parsers!');
|
|
120
120
|
const result = await info.treeSitterQuery(args.source);
|
|
@@ -48,7 +48,7 @@ exports.SlicingCriterion = {
|
|
|
48
48
|
tryParse(criterion, idMap) {
|
|
49
49
|
criterion = criterion.toString(); // in case it's a number
|
|
50
50
|
if (criterion.startsWith('$')) {
|
|
51
|
-
return node_id_1.NodeId.normalize(criterion.
|
|
51
|
+
return node_id_1.NodeId.normalize(criterion.slice(1));
|
|
52
52
|
}
|
|
53
53
|
const split = splitFileFilter(criterion);
|
|
54
54
|
if (split === undefined) {
|
|
@@ -57,8 +57,8 @@ exports.SlicingCriterion = {
|
|
|
57
57
|
const { rest: base, file } = split;
|
|
58
58
|
if (base.includes('@')) {
|
|
59
59
|
const at = base.indexOf('@');
|
|
60
|
-
const line = parseLineNumber(base.
|
|
61
|
-
const name = base.
|
|
60
|
+
const line = parseLineNumber(base.slice(0, Math.max(0, at)), idMap, file);
|
|
61
|
+
const name = base.slice(Math.max(0, at + 1));
|
|
62
62
|
if (line === undefined || name.length === 0) {
|
|
63
63
|
return undefined;
|
|
64
64
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { NodeToSlice } from './slicer-types';
|
|
2
2
|
import type { VisitingQueue } from './visiting-queue';
|
|
3
3
|
import { type Fingerprint } from './fingerprint';
|
|
4
|
-
import {
|
|
4
|
+
import type { DataflowGraphVertexFunctionCall, DataflowGraphVertexInfo } from '../../dataflow/graph/vertex';
|
|
5
5
|
import type { REnvironmentInformation } from '../../dataflow/environments/environment';
|
|
6
6
|
import { type DataflowGraph, type OutgoingEdges } from '../../dataflow/graph/graph';
|
|
7
7
|
import { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
@@ -9,7 +9,6 @@ exports.handleReturns = handleReturns;
|
|
|
9
9
|
const assert_1 = require("../../util/assert");
|
|
10
10
|
const fingerprint_1 = require("./fingerprint");
|
|
11
11
|
const linker_1 = require("../../dataflow/internal/linker");
|
|
12
|
-
const vertex_1 = require("../../dataflow/graph/vertex");
|
|
13
12
|
const graph_1 = require("../../dataflow/graph/graph");
|
|
14
13
|
const resolve_helper_1 = require("../../dataflow/environments/resolve-helper");
|
|
15
14
|
const edge_1 = require("../../dataflow/graph/edge");
|
|
@@ -19,6 +18,7 @@ const built_in_function_definition_1 = require("../../dataflow/internal/process/
|
|
|
19
18
|
const static_slicer_1 = require("./static-slicer");
|
|
20
19
|
const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
|
|
21
20
|
const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
|
|
21
|
+
const vertex_1 = require("../../dataflow/graph/vertex");
|
|
22
22
|
/**
|
|
23
23
|
* Returns the function call targets (definitions) by the given caller
|
|
24
24
|
*/
|
|
@@ -105,7 +105,7 @@ function findEnclosingFunctionDefinition(id, idMap) {
|
|
|
105
105
|
*/
|
|
106
106
|
function sliceReachesFunctionInterface(fnDefId, graph, queue, idMap, ctx) {
|
|
107
107
|
const vertex = graph.getVertex(fnDefId);
|
|
108
|
-
if (vertex === undefined ||
|
|
108
|
+
if (vertex === undefined || !vertex_1.FunctionDefinitionVertex.is(vertex)) {
|
|
109
109
|
return false;
|
|
110
110
|
}
|
|
111
111
|
// (a) the slice reaches a parameter of this definition
|
|
@@ -14,6 +14,7 @@ const edge_1 = require("../../dataflow/graph/edge");
|
|
|
14
14
|
const df_helper_1 = require("../../dataflow/graph/df-helper");
|
|
15
15
|
const slice_direction_1 = require("../../util/slice-direction");
|
|
16
16
|
const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
|
|
17
|
+
const graph_1 = require("../../dataflow/graph/graph");
|
|
17
18
|
exports.slicerLogger = log_1.log.getSubLogger({ name: 'slicer' });
|
|
18
19
|
/**
|
|
19
20
|
* Computes the node ids to include in a static slice, starting from the given seed ids.
|
|
@@ -98,7 +99,7 @@ function staticSlice(options) {
|
|
|
98
99
|
}
|
|
99
100
|
}
|
|
100
101
|
if (!onlyForSideEffects) {
|
|
101
|
-
if (
|
|
102
|
+
if (vertex_1.FunctionCallVertex.is(currentVertex) && !currentVertex.onlyBuiltin) {
|
|
102
103
|
(0, slice_call_1.sliceForCall)(current, currentVertex, info, queue, ctx);
|
|
103
104
|
}
|
|
104
105
|
const ret = (0, slice_call_1.handleReturns)(id, queue, currentEdges, baseEnvFingerprint, baseEnvironment);
|
|
@@ -151,11 +152,11 @@ function staticSlice(options) {
|
|
|
151
152
|
function freeNamesOf(slice, graph) {
|
|
152
153
|
const free = new Set();
|
|
153
154
|
for (const id of slice) {
|
|
154
|
-
if (graph.getVertex(id)
|
|
155
|
+
if (!vertex_1.UseVertex.is(graph.getVertex(id))) {
|
|
155
156
|
continue;
|
|
156
157
|
}
|
|
157
158
|
let defined = false;
|
|
158
|
-
for (const [target, edge] of graph.outgoingEdges(id) ??
|
|
159
|
+
for (const [target, edge] of graph.outgoingEdges(id) ?? graph_1.NoEdges) {
|
|
159
160
|
if (edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Reads) && (slice.has(target) || node_id_1.NodeId.isBuiltIn(target))) {
|
|
160
161
|
defined = true;
|
|
161
162
|
break;
|
package/util/assert.js
CHANGED
|
@@ -102,7 +102,7 @@ node version: ${process.version}
|
|
|
102
102
|
node arch: ${process.arch}
|
|
103
103
|
node platform: ${process.platform}
|
|
104
104
|
message: \`${message}\`
|
|
105
|
-
stack trace:\n\`\`\`\n${prepareStack(new Error().stack)}\n\`\`\`
|
|
105
|
+
stack trace:\n\`\`\`\n${prepareStack(new Error('stack capture for the issue report').stack)}\n\`\`\`
|
|
106
106
|
|
|
107
107
|
---
|
|
108
108
|
`).replaceAll('(', '%28').replaceAll(')', '%29').replaceAll('-', '%2D');
|
package/util/log.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ILogObj, type ISettingsParam, Logger } from 'tslog';
|
|
2
|
-
import {
|
|
2
|
+
import type { Options } from 'rotating-file-stream';
|
|
3
3
|
export declare const expensiveTrace: (log: Logger<ILogObj> | undefined, supplier: () => string) => void;
|
|
4
4
|
export declare class FlowrLogger extends Logger<ILogObj> {
|
|
5
5
|
/** by keeping track of all children we can propagate updates of the settings (e.g., in tests) */
|
|
@@ -8,6 +8,9 @@ export declare class FlowrLogger extends Logger<ILogObj> {
|
|
|
8
8
|
updateSettings(updater: (logger: Logger<ILogObj>) => void): void;
|
|
9
9
|
/**
|
|
10
10
|
* make the logger log to a file as well
|
|
11
|
+
*
|
|
12
|
+
* Rotation needs the optional `rotating-file-stream` dependency. Without it (the slim runtime images install with
|
|
13
|
+
* `--omit=optional`) the log is appended to a single file instead.
|
|
11
14
|
*/
|
|
12
15
|
logToFile(filename?: string, options?: Options): void;
|
|
13
16
|
}
|
package/util/log.js
CHANGED
|
@@ -3,13 +3,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.log = exports.LogLevelNames = exports.FlowrLogger = exports.expensiveTrace = void 0;
|
|
4
4
|
exports.setLogLevel = setLogLevel;
|
|
5
5
|
const tslog_1 = require("tslog");
|
|
6
|
-
const
|
|
6
|
+
const fs_1 = require("fs");
|
|
7
7
|
const expensiveTrace = (log, supplier) => {
|
|
8
8
|
if (log !== undefined && log.settings.minLevel <= 1 /* LogLevel.Trace */) {
|
|
9
9
|
log.trace(supplier());
|
|
10
10
|
}
|
|
11
11
|
};
|
|
12
12
|
exports.expensiveTrace = expensiveTrace;
|
|
13
|
+
/** The rotating stream, or `undefined` if the optional dependency is not installed. */
|
|
14
|
+
function rotatingStream(filename, options) {
|
|
15
|
+
try {
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports -- optional dependency, absent by design in slim installs
|
|
17
|
+
return require('rotating-file-stream').createStream(filename, options);
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
13
23
|
class FlowrLogger extends tslog_1.Logger {
|
|
14
24
|
/** by keeping track of all children we can propagate updates of the settings (e.g., in tests) */
|
|
15
25
|
childLoggers = [];
|
|
@@ -26,13 +36,16 @@ class FlowrLogger extends tslog_1.Logger {
|
|
|
26
36
|
}
|
|
27
37
|
/**
|
|
28
38
|
* make the logger log to a file as well
|
|
39
|
+
*
|
|
40
|
+
* Rotation needs the optional `rotating-file-stream` dependency. Without it (the slim runtime images install with
|
|
41
|
+
* `--omit=optional`) the log is appended to a single file instead.
|
|
29
42
|
*/
|
|
30
43
|
logToFile(filename = 'flowr.log', options = {
|
|
31
44
|
size: '10M',
|
|
32
45
|
interval: '1d',
|
|
33
46
|
compress: 'gzip',
|
|
34
47
|
}) {
|
|
35
|
-
const stream = (0,
|
|
48
|
+
const stream = rotatingStream(filename, options) ?? (0, fs_1.createWriteStream)(filename, { flags: 'a' });
|
|
36
49
|
exports.log.attachTransport((logObj) => {
|
|
37
50
|
stream.write(`${JSON.stringify(logObj)}\n`);
|
|
38
51
|
});
|
package/util/logic.js
CHANGED
|
@@ -20,10 +20,10 @@ exports.TernaryLogic = {
|
|
|
20
20
|
return Ternary.Maybe;
|
|
21
21
|
},
|
|
22
22
|
or(...values) {
|
|
23
|
-
if (values.
|
|
23
|
+
if (values.includes(Ternary.Always)) {
|
|
24
24
|
return Ternary.Always;
|
|
25
25
|
}
|
|
26
|
-
else if (values.
|
|
26
|
+
else if (values.includes(Ternary.Maybe)) {
|
|
27
27
|
return Ternary.Maybe;
|
|
28
28
|
}
|
|
29
29
|
return Ternary.Never;
|
package/util/mermaid/cfg.js
CHANGED
package/util/mermaid/dfg.js
CHANGED
|
@@ -12,12 +12,12 @@ const identifier_1 = require("../../dataflow/environments/identifier");
|
|
|
12
12
|
const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
13
13
|
const edge_1 = require("../../dataflow/graph/edge");
|
|
14
14
|
const vertex_1 = require("../../dataflow/graph/vertex");
|
|
15
|
-
const dfg_get_origin_1 = require("../../dataflow/origin/dfg-get-origin");
|
|
16
15
|
const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
|
|
17
16
|
const info_1 = require("./info");
|
|
18
17
|
const range_1 = require("../range");
|
|
19
18
|
const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
|
|
20
19
|
const info_2 = require("../../dataflow/info");
|
|
20
|
+
const df_helper_1 = require("../../dataflow/graph/df-helper");
|
|
21
21
|
function subflowToMermaid(nodeId, subflow, mermaid, idPrefix = '') {
|
|
22
22
|
if (subflow === undefined) {
|
|
23
23
|
return;
|
|
@@ -160,7 +160,7 @@ function builtInDisplayName(builtInId) {
|
|
|
160
160
|
return pkgFn ? `${pkgFn[0]}::${pkgFn[1]}` : String(builtInId).replace('built-in:', '');
|
|
161
161
|
}
|
|
162
162
|
function vertexToMermaid(info, mermaid, id, idPrefix, mark, includeOnlyIds) {
|
|
163
|
-
const fCall =
|
|
163
|
+
const fCall = vertex_1.FunctionCallVertex.is(info);
|
|
164
164
|
const { open, close } = mermaidNodeBrackets(info.tag);
|
|
165
165
|
const origId = id;
|
|
166
166
|
id = mermaid_1.Mermaid.escapeId(id);
|
|
@@ -184,7 +184,7 @@ function vertexToMermaid(info, mermaid, id, idPrefix, mark, includeOnlyIds) {
|
|
|
184
184
|
const lexeme = node?.lexeme ?? (node?.type === type_1.RType.ExpressionList ? node?.grouping?.[0]?.lexeme : '') ?? '??';
|
|
185
185
|
let display = lexeme;
|
|
186
186
|
if (fCall && vertex_1.FunctionCallVertex.is(info)) {
|
|
187
|
-
const q = identifier_1.Identifier.toQualified(
|
|
187
|
+
const q = identifier_1.Identifier.toQualified(df_helper_1.Dataflow.origin(mermaid.rootGraph, origId), info.name, mermaid.qualifyBaseR !== false);
|
|
188
188
|
const qs = q !== undefined ? identifier_1.Identifier.toString(q) : undefined;
|
|
189
189
|
if (qs !== undefined && qs !== lexeme) {
|
|
190
190
|
display = qs;
|
|
@@ -199,10 +199,10 @@ function vertexToMermaid(info, mermaid, id, idPrefix, mark, includeOnlyIds) {
|
|
|
199
199
|
const escapedName = node ? `*${mermaid_1.Mermaid.escape(`[${node.type}]`)}* ${boldLexeme(lexeme, display)}` : '??';
|
|
200
200
|
const deps = info.cds ? ', ' + info.cds.map(c => mermaid_1.Mermaid.escapeId(c.id) + (c.when ? '+' : '-')).join(', ') : '';
|
|
201
201
|
const lnks = info.link?.origin ? ', links: ' + info.link.origin.map(o => mermaid_1.Mermaid.escapeId(o)).join(', ') : '';
|
|
202
|
-
const source =
|
|
202
|
+
const source = vertex_1.VariableDefinitionVertex.is(info) ? info.source : undefined;
|
|
203
203
|
const sources = source ? ', v: ' + source.map(s => mermaid_1.Mermaid.escapeId(s)).join(', ') : '';
|
|
204
204
|
const n = node?.info.fullRange ?? node?.location ?? (node?.type === type_1.RType.ExpressionList ? node?.grouping?.[0].location : undefined);
|
|
205
|
-
mermaid.nodeLines.push(` ${idPrefix}${id}${open}"\`${escapedName}\n *${range_1.SourceRange.format(n)}* (**id: ${id}**${deps}${lnks}${sources})${fCall ? displayFunctionArgMapping(info.args) : '' + (
|
|
205
|
+
mermaid.nodeLines.push(` ${idPrefix}${id}${open}"\`${escapedName}\n *${range_1.SourceRange.format(n)}* (**id: ${id}**${deps}${lnks}${sources})${fCall ? displayFunctionArgMapping(info.args) : '' + (vertex_1.FunctionDefinitionVertex.is(info) && info.mode && info.mode.length > 0 ? mermaid_1.Mermaid.escape(JSON.stringify(info.mode)) : '')}\`"${close}`);
|
|
206
206
|
}
|
|
207
207
|
if (mark?.has(id)) {
|
|
208
208
|
mermaid.nodeLines.push(` style ${idPrefix}${id} ${mermaid.markStyle.vertex} `);
|
|
@@ -210,7 +210,7 @@ function vertexToMermaid(info, mermaid, id, idPrefix, mark, includeOnlyIds) {
|
|
|
210
210
|
if (mermaid.rootGraph.unknownSideEffects.values().some(l => node_id_1.NodeId.normalize(l) === node_id_1.NodeId.normalize(origId))) {
|
|
211
211
|
mermaid.nodeLines.push(` style ${idPrefix}${id} stroke:red,stroke-width:5px; `);
|
|
212
212
|
}
|
|
213
|
-
if (
|
|
213
|
+
if (vertex_1.FunctionDefinitionVertex.is(info)) {
|
|
214
214
|
subflowToMermaid(origId, info.subflow, mermaid, idPrefix);
|
|
215
215
|
}
|
|
216
216
|
const edges = mermaid.rootGraph.outgoingEdges(node_id_1.NodeId.normalize(origId));
|
package/util/mermaid/mermaid.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Mermaid = void 0;
|
|
4
|
+
const url_encoding_1 = require("../text/url-encoding");
|
|
4
5
|
/**
|
|
5
6
|
* Global mermaid helper object with useful functions.
|
|
6
7
|
*/
|
|
@@ -81,7 +82,8 @@ exports.Mermaid = {
|
|
|
81
82
|
autoSync: true
|
|
82
83
|
}
|
|
83
84
|
};
|
|
84
|
-
|
|
85
|
+
/* `btoa` rather than a `Buffer`, so the pages flowR ships can build this url as well */
|
|
86
|
+
return `https://mermaid.live/${edit ? 'edit' : 'view'}#base64:${(0, url_encoding_1.toBase64)(new TextEncoder().encode(JSON.stringify(obj)))}`;
|
|
85
87
|
}
|
|
86
88
|
};
|
|
87
89
|
//# sourceMappingURL=mermaid.js.map
|