@eagleoutice/flowr 2.12.2 → 2.13.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 +38 -91
- package/abstract-interpretation/data-frame/dataframe-domain.d.ts +3 -3
- package/abstract-interpretation/data-frame/dataframe-domain.js +14 -6
- package/abstract-interpretation/data-frame/semantics.js +12 -16
- package/abstract-interpretation/domains/abstract-domain.d.ts +46 -44
- package/abstract-interpretation/domains/abstract-domain.js +146 -6
- package/abstract-interpretation/domains/bounded-set-domain.d.ts +16 -25
- package/abstract-interpretation/domains/bounded-set-domain.js +22 -69
- package/abstract-interpretation/domains/interval-domain.d.ts +27 -36
- package/abstract-interpretation/domains/interval-domain.js +111 -146
- package/abstract-interpretation/domains/lattice.d.ts +3 -3
- package/abstract-interpretation/domains/multi-value-state-domain.js +3 -3
- package/abstract-interpretation/domains/partial-product-domain.d.ts +12 -19
- package/abstract-interpretation/domains/partial-product-domain.js +21 -54
- package/abstract-interpretation/domains/positive-interval-domain.d.ts +8 -12
- package/abstract-interpretation/domains/positive-interval-domain.js +21 -50
- package/abstract-interpretation/domains/product-domain.d.ts +1 -1
- package/abstract-interpretation/domains/product-domain.js +4 -4
- package/abstract-interpretation/domains/set-range-domain.d.ts +60 -56
- package/abstract-interpretation/domains/set-range-domain.js +141 -200
- package/abstract-interpretation/domains/set-upper-bound-domain.d.ts +17 -23
- package/abstract-interpretation/domains/set-upper-bound-domain.js +59 -103
- package/abstract-interpretation/domains/singleton-domain.d.ts +15 -18
- package/abstract-interpretation/domains/singleton-domain.js +33 -72
- package/abstract-interpretation/domains/state-abstract-domain.d.ts +12 -16
- package/abstract-interpretation/domains/state-abstract-domain.js +36 -126
- package/abstract-interpretation/domains/state-domain-like.d.ts +2 -2
- package/abstract-interpretation/domains/value-abstract-domain.d.ts +120 -0
- package/abstract-interpretation/domains/{satisfiable-domain.js → value-abstract-domain.js} +14 -2
- package/benchmark/slicer.d.ts +2 -2
- package/benchmark/slicer.js +6 -5
- package/cli/common/options.d.ts +10 -0
- package/cli/common/options.js +2 -0
- package/cli/common/scripts-info.d.ts +10 -0
- package/cli/flowr-main-options.d.ts +4 -0
- package/cli/flowr-main-options.js +5 -0
- package/cli/flowr.d.ts +5 -0
- package/cli/flowr.js +15 -7
- package/cli/repl/commands/repl-query.js +42 -20
- package/cli/repl/commands/repl-signature.js +2 -2
- package/cli/repl/core.d.ts +14 -5
- package/cli/repl/core.js +32 -17
- package/cli/repl/parser/slice-query-parser.d.ts +69 -8
- package/cli/repl/parser/slice-query-parser.js +82 -13
- package/cli/repl/path-input.d.ts +6 -0
- package/cli/repl/path-input.js +41 -0
- package/cli/repl/print-version.js +3 -5
- package/cli/slicer-app.d.ts +2 -0
- package/cli/slicer-app.js +2 -1
- package/config.d.ts +54 -6
- package/config.js +133 -12
- package/control-flow/control-flow-graph.d.ts +3 -2
- package/control-flow/control-flow-graph.js +34 -14
- package/control-flow/semantic-cfg-guided-visitor.d.ts +3 -0
- package/control-flow/semantic-cfg-guided-visitor.js +3 -0
- package/core/steps/all/static-slicing/10-reconstruct.d.ts +6 -0
- package/core/steps/all/static-slicing/10-reconstruct.js +3 -1
- package/data/r-base-packages.generated.d.ts +1 -1
- package/data/r-base-packages.generated.js +3 -3
- package/data/sigdb/sigdb.remote.json +53 -53
- package/dataflow/environments/built-in-proc-name.d.ts +2 -0
- package/dataflow/environments/built-in-proc-name.js +2 -0
- package/dataflow/environments/built-in.d.ts +2 -0
- package/dataflow/environments/built-in.js +2 -0
- package/dataflow/environments/default-builtin-config.d.ts +3 -5
- package/dataflow/environments/default-builtin-config.js +2 -2
- package/dataflow/environments/environment.d.ts +9 -0
- package/dataflow/environments/environment.js +28 -7
- package/dataflow/environments/identifier.d.ts +1 -2
- package/dataflow/environments/identifier.js +1 -5
- package/dataflow/extractor.js +1 -2
- package/dataflow/graph/dataflowgraph-builder.js +42 -3
- package/dataflow/graph/df-helper.d.ts +15 -0
- package/dataflow/graph/df-helper.js +20 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +4 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +7 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +13 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +4 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +57 -11
- package/dataflow/internal/process/functions/call/built-in/built-in-load.d.ts +12 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-load.js +233 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +5 -3
- package/documentation/data/faq/faqs.js +12 -1
- package/documentation/doc-readme.js +1 -1
- package/documentation/doc-util/doc-files.d.ts +2 -2
- package/documentation/doc-util/doc-files.js +4 -7
- package/documentation/doc-util/doc-query.d.ts +12 -9
- package/documentation/doc-util/doc-query.js +63 -28
- package/documentation/wiki-absint.js +1 -4
- package/documentation/wiki-analyzer.js +8 -3
- package/documentation/wiki-cfg.js +3 -2
- package/documentation/wiki-dataflow-graph.js +14 -4
- package/documentation/wiki-interface.js +29 -16
- package/documentation/wiki-mk/doc-maker.js +1 -1
- package/documentation/wiki-query.js +189 -30
- package/documentation/wiki-signature-database.d.ts +1 -1
- package/documentation/wiki-signature-database.js +53 -27
- package/linter/linter-output.d.ts +24 -0
- package/linter/linter-output.js +117 -0
- package/linter/linter-rules.d.ts +2 -4
- package/linter/rules/dataframe-access-validation.js +4 -4
- package/linter/rules/deprecated-functions.d.ts +2 -4
- package/linter/rules/deprecated-functions.js +58 -3
- package/linter/rules/undefined-symbol.js +18 -10
- package/linter/rules/unused-definition.js +24 -0
- package/package.json +5 -2
- package/project/context/flowr-analyzer-context.d.ts +59 -1
- package/project/context/flowr-analyzer-context.js +118 -3
- package/project/context/flowr-analyzer-dependencies-context.d.ts +32 -7
- package/project/context/flowr-analyzer-dependencies-context.js +33 -3
- package/project/context/flowr-analyzer-files-context.d.ts +32 -0
- package/project/context/flowr-analyzer-files-context.js +132 -14
- package/project/context/flowr-analyzer-loading-order-context.d.ts +6 -0
- package/project/context/flowr-analyzer-loading-order-context.js +20 -0
- package/project/context/flowr-analyzer-meta-context.d.ts +92 -10
- package/project/context/flowr-analyzer-meta-context.js +64 -23
- package/project/context/flowr-file.d.ts +7 -0
- package/project/context/flowr-file.js +7 -0
- package/project/context/project-kind.d.ts +22 -0
- package/project/context/project-kind.js +27 -0
- package/project/dependency-version-space.d.ts +166 -0
- package/project/dependency-version-space.js +564 -0
- package/project/flowr-analyzer-builder.js +1 -1
- package/project/flowr-analyzer.d.ts +4 -0
- package/project/flowr-analyzer.js +5 -0
- package/project/plugins/file-plugins/files/flowr-description-file.d.ts +4 -0
- package/project/plugins/file-plugins/files/flowr-description-file.js +7 -0
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +5 -1
- package/project/plugins/file-plugins/files/flowr-rda-file.d.ts +739 -0
- package/project/plugins/file-plugins/files/flowr-rda-file.js +2407 -0
- package/project/plugins/file-plugins/files/flowr-rproject-file.d.ts +31 -0
- package/project/plugins/file-plugins/files/flowr-rproject-file.js +66 -0
- package/project/plugins/file-plugins/files/r-fun-tab.d.ts +828 -0
- package/project/plugins/file-plugins/files/r-fun-tab.js +1039 -0
- package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.js +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-file-plugin.js +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-inst-file-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-inst-file-plugin.js +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-license-file-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-license-file-plugin.js +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-namespace-files-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-namespace-files-plugin.js +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-news-file-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-news-file-plugin.js +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-rda-file-plugin.d.ts +26 -0
- package/project/plugins/file-plugins/flowr-analyzer-rda-file-plugin.js +38 -0
- package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.d.ts +17 -0
- package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.js +30 -0
- package/project/plugins/file-plugins/flowr-analyzer-rproject-file-plugin.d.ts +22 -0
- package/project/plugins/file-plugins/flowr-analyzer-rproject-file-plugin.js +36 -0
- package/project/plugins/file-plugins/flowr-analyzer-test-file-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-test-file-plugin.js +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-vignette-file-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-vignette-file-plugin.js +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.d.ts +3 -4
- package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.js +5 -6
- package/project/plugins/flowr-analyzer-plugin.js +5 -0
- package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-description-file-plugin.d.ts +1 -1
- package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-description-file-plugin.js +1 -1
- package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-implicit-sources-plugin.d.ts +14 -0
- package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-implicit-sources-plugin.js +53 -0
- package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-plugin.js +1 -1
- package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-rprofile-plugin.d.ts +15 -0
- package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-rprofile-plugin.js +33 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-description-file-plugin.d.ts +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-description-file-plugin.js +18 -13
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-rproject-file-plugin.d.ts +13 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-rproject-file-plugin.js +32 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.d.ts +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.js +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.d.ts +8 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +70 -7
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-namespace-file-plugin.d.ts +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-namespace-file-plugin.js +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.js +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-session-info-plugin.d.ts +18 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-session-info-plugin.js +62 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +4 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +5 -13
- package/project/plugins/package-version-plugins/package.d.ts +4 -1
- package/project/plugins/package-version-plugins/package.js +8 -5
- package/project/plugins/plugin-registry.d.ts +11 -3
- package/project/plugins/plugin-registry.js +24 -5
- package/project/plugins/project-discovery/flowr-analyzer-ignore-file-project-discovery-plugin.d.ts +51 -0
- package/project/plugins/project-discovery/flowr-analyzer-ignore-file-project-discovery-plugin.js +101 -0
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +10 -5
- package/project/sigdb/build.js +12 -2
- package/project/sigdb/decode.d.ts +7 -0
- package/project/sigdb/decode.js +35 -4
- package/project/sigdb/decompress.d.ts +2 -0
- package/project/sigdb/decompress.js +5 -0
- package/project/sigdb/manifest.d.ts +5 -0
- package/project/sigdb/manifest.js +37 -6
- package/project/sigdb/reader.d.ts +82 -2
- package/project/sigdb/reader.js +226 -14
- package/project/sigdb/schema.d.ts +31 -5
- package/project/sigdb/schema.js +7 -3
- package/project/sigdb/{version.d.ts → sigdb-version.d.ts} +21 -1
- package/project/sigdb/sigdb-version.js +119 -0
- package/queries/catalog/absint-query/absint-query-format.d.ts +2 -0
- package/queries/catalog/absint-query/absint-query-format.js +2 -0
- package/queries/catalog/call-context-query/call-context-query-executor.js +30 -3
- package/queries/catalog/call-context-query/call-context-query-format.d.ts +1 -0
- package/queries/catalog/call-context-query/call-context-query-format.js +1 -0
- package/queries/catalog/call-graph-query/call-graph-query-executor.js +3 -1
- package/queries/catalog/call-graph-query/call-graph-query-format.d.ts +6 -0
- package/queries/catalog/call-graph-query/call-graph-query-format.js +2 -0
- package/queries/catalog/call-graph-query/expand-library-internals.d.ts +19 -0
- package/queries/catalog/call-graph-query/expand-library-internals.js +59 -0
- package/queries/catalog/cluster-query/cluster-query-format.d.ts +1 -0
- package/queries/catalog/cluster-query/cluster-query-format.js +1 -0
- package/queries/catalog/config-query/config-query-executor.js +15 -6
- package/queries/catalog/config-query/config-query-format.d.ts +18 -4
- package/queries/catalog/config-query/config-query-format.js +246 -96
- package/queries/catalog/control-flow-query/control-flow-query-format.d.ts +1 -0
- package/queries/catalog/control-flow-query/control-flow-query-format.js +1 -0
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.d.ts +1 -0
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.js +1 -0
- package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +1 -0
- package/queries/catalog/dataflow-query/dataflow-query-format.js +1 -0
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +2 -7
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +13 -1
- package/queries/catalog/dependencies-query/dependencies-query-format.js +117 -17
- package/queries/catalog/dice-query/dice-query-executor.js +6 -9
- package/queries/catalog/dice-query/dice-query-format.d.ts +4 -5
- package/queries/catalog/dice-query/dice-query-format.js +10 -6
- package/queries/catalog/does-call-query/does-call-query-executor.js +15 -2
- package/queries/catalog/does-call-query/does-call-query-format.d.ts +8 -0
- package/queries/catalog/does-call-query/does-call-query-format.js +4 -1
- package/queries/catalog/files-query/files-query-format.d.ts +2 -0
- package/queries/catalog/files-query/files-query-format.js +2 -0
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.d.ts +6 -0
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +277 -0
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +119 -0
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +331 -0
- package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +1 -0
- package/queries/catalog/happens-before-query/happens-before-query-format.js +1 -0
- package/queries/catalog/id-map-query/id-map-query-format.d.ts +1 -0
- package/queries/catalog/id-map-query/id-map-query-format.js +1 -0
- package/queries/catalog/input-sources-query/input-sources-query-format.d.ts +2 -0
- package/queries/catalog/input-sources-query/input-sources-query-format.js +2 -0
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.d.ts +2 -0
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +2 -0
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +2 -0
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +2 -0
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.d.ts +2 -0
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.js +2 -0
- package/queries/catalog/linter-query/linter-query-executor.js +11 -2
- package/queries/catalog/linter-query/linter-query-format.d.ts +9 -4
- package/queries/catalog/linter-query/linter-query-format.js +44 -21
- package/queries/catalog/location-map-query/location-map-query-format.d.ts +2 -0
- package/queries/catalog/location-map-query/location-map-query-format.js +2 -0
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +1 -0
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.js +1 -0
- package/queries/catalog/origin-query/origin-query-format.d.ts +2 -0
- package/queries/catalog/origin-query/origin-query-format.js +2 -0
- package/queries/catalog/project-query/project-query-executor.d.ts +0 -15
- package/queries/catalog/project-query/project-query-executor.js +19 -62
- package/queries/catalog/project-query/project-query-format.d.ts +7 -18
- package/queries/catalog/project-query/project-query-format.js +3 -18
- package/queries/catalog/provenance-query/provenance-query-format.d.ts +2 -0
- package/queries/catalog/provenance-query/provenance-query-format.js +2 -0
- package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +2 -0
- package/queries/catalog/resolve-value-query/resolve-value-query-format.js +2 -0
- package/queries/catalog/search-query/search-query-format.d.ts +1 -0
- package/queries/catalog/search-query/search-query-format.js +1 -0
- package/queries/catalog/signature-query/signature-query-executor.d.ts +5 -0
- package/queries/catalog/signature-query/signature-query-executor.js +267 -57
- package/queries/catalog/signature-query/signature-query-format.d.ts +37 -6
- package/queries/catalog/signature-query/signature-query-format.js +41 -5
- package/queries/catalog/signature-query/signature-query-render.js +48 -6
- package/queries/catalog/slice-query-options.d.ts +49 -0
- package/queries/catalog/slice-query-options.js +50 -0
- package/queries/catalog/static-slice-query/static-slice-query-executor.js +4 -12
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +4 -15
- package/queries/catalog/static-slice-query/static-slice-query-format.js +9 -10
- package/queries/query-print.js +3 -1
- package/queries/query.d.ts +63 -3
- package/queries/query.js +9 -2
- package/r-bridge/data/data.d.ts +16 -0
- package/r-bridge/data/data.js +20 -0
- package/r-bridge/lang-4.x/ast/model/model.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/processing/decorate.js +2 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/normalize-access.js +2 -1
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +19 -16
- package/reconstruct/reconstruct.d.ts +18 -1
- package/reconstruct/reconstruct.js +42 -19
- package/slicing/criterion/parse.d.ts +4 -0
- package/slicing/criterion/parse.js +4 -0
- package/slicing/static/slice-call.js +17 -9
- package/slicing/static/static-slicer.d.ts +1 -1
- package/slicing/static/static-slicer.js +5 -4
- package/util/files.d.ts +19 -1
- package/util/files.js +45 -3
- package/util/glob.d.ts +19 -0
- package/util/glob.js +67 -0
- package/util/log.d.ts +12 -0
- package/util/log.js +17 -1
- package/util/logic.d.ts +6 -0
- package/util/logic.js +31 -1
- package/util/mermaid/dfg.js +17 -12
- package/util/mermaid/mermaid.js +2 -2
- package/util/objects.d.ts +5 -0
- package/util/objects.js +8 -0
- package/util/r-version.d.ts +9 -1
- package/util/r-version.js +27 -2
- package/util/schema.d.ts +16 -0
- package/util/schema.js +89 -4
- package/util/text/ansi.d.ts +4 -0
- package/util/text/ansi.js +27 -3
- package/util/text/strings.d.ts +9 -0
- package/util/text/strings.js +29 -0
- package/util/version.js +79 -6
- package/abstract-interpretation/domains/satisfiable-domain.d.ts +0 -29
- package/project/plugins/project-discovery/flowr-analyzer-gitignore-project-discovery-plugin.d.ts +0 -22
- package/project/plugins/project-discovery/flowr-analyzer-gitignore-project-discovery-plugin.js +0 -52
- package/project/sigdb/version.js +0 -55
|
@@ -22,6 +22,16 @@ exports.reconstructLogger = log_1.log.getSubLogger({ name: 'reconstruct' });
|
|
|
22
22
|
function getLexeme(n) {
|
|
23
23
|
return model_1.RNode.lexeme(n) ?? '';
|
|
24
24
|
}
|
|
25
|
+
function codeToText(code) {
|
|
26
|
+
return code.map(l => `${getIndentString(l.indent)}${l.line}`).join('\n');
|
|
27
|
+
}
|
|
28
|
+
/** the arguments synthesized for infix operands have no `fullLexeme`, so resolve through the value */
|
|
29
|
+
function getArgumentLexeme(n) {
|
|
30
|
+
if (n === undefined || n === r_function_call_1.EmptyArgument) {
|
|
31
|
+
return '';
|
|
32
|
+
}
|
|
33
|
+
return n.info.fullLexeme ?? (n.value !== undefined ? getLexeme(n.value) : getLexeme(n));
|
|
34
|
+
}
|
|
25
35
|
function reconstructAsLeaf(leaf, configuration) {
|
|
26
36
|
const selectionHasLeaf = configuration.selection.has(leaf.info.id) || configuration.autoSelectIf(leaf, configuration.fullAst);
|
|
27
37
|
return selectionHasLeaf ? foldToConst(leaf) : [];
|
|
@@ -314,19 +324,23 @@ function reconstructSpecialInfixFunctionCall(args, call) {
|
|
|
314
324
|
if ((lhs === undefined || lhs.length === 0) && (rhs === undefined || rhs.length === 0)) {
|
|
315
325
|
return [];
|
|
316
326
|
}
|
|
317
|
-
// else if (rhs === undefined || rhs.length === 0) {
|
|
318
327
|
// if rhs is undefined we still have to keep both now, but reconstruct manually :/
|
|
319
328
|
if (lhs !== r_function_call_1.EmptyArgument && lhs.length > 0) {
|
|
320
|
-
const lhsText = lhs
|
|
329
|
+
const lhsText = codeToText(lhs);
|
|
321
330
|
if (rhs !== r_function_call_1.EmptyArgument && rhs.length > 0) {
|
|
322
|
-
|
|
323
|
-
return plain(`${lhsText} ${identifier_1.Identifier.toString(call.functionName.content)} ${rhsText}`);
|
|
331
|
+
return plain(`${lhsText} ${identifier_1.Identifier.toString(call.functionName.content)} ${codeToText(rhs)}`);
|
|
324
332
|
}
|
|
325
333
|
else {
|
|
326
334
|
return plain(lhsText);
|
|
327
335
|
}
|
|
328
336
|
}
|
|
329
|
-
|
|
337
|
+
// only the operands' lexemes are left to go by; a `{` block has none, so keep the call as it was written
|
|
338
|
+
const lhsLexeme = getArgumentLexeme(call.arguments[0]);
|
|
339
|
+
const rhsLexeme = getArgumentLexeme(call.arguments[1]);
|
|
340
|
+
if (lhsLexeme.length === 0 || rhsLexeme.length === 0) {
|
|
341
|
+
return plain(getLexeme(call));
|
|
342
|
+
}
|
|
343
|
+
return plain(`${lhsLexeme} ${identifier_1.Identifier.toString(call.functionName.content)} ${rhsLexeme}`);
|
|
330
344
|
}
|
|
331
345
|
/**
|
|
332
346
|
* If `inlineSources` is active and this call is a selected `source()` that we can resolve, this returns the
|
|
@@ -485,22 +499,31 @@ function reconstructToCode(ast, selection, autoSelectIf = auto_select_defaults_1
|
|
|
485
499
|
}
|
|
486
500
|
return result;
|
|
487
501
|
};
|
|
488
|
-
//
|
|
489
|
-
//
|
|
490
|
-
if (selection.inlineSources) {
|
|
502
|
+
// both inlinings splice every resolvable `source()` in place, overriding `reconstructFiles`: `inlineSources`
|
|
503
|
+
// emits the main file alone, `inlineFull` every file flowR loads, minus the ones already spliced into a call.
|
|
504
|
+
if (selection.inlineFull || selection.inlineSources) {
|
|
491
505
|
const warnings = [];
|
|
492
|
-
const
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
506
|
+
const sourceMap = selection.sourceMap ?? new Map();
|
|
507
|
+
const splicedIn = new Set(sourceMap.values());
|
|
508
|
+
const indices = selection.inlineFull ? ast.ast.files.map((_, i) => i).filter(i => !splicedIn.has(i)) : [0];
|
|
509
|
+
const parts = [];
|
|
510
|
+
for (const i of indices) {
|
|
511
|
+
const code = removeOuterExpressionListIfApplicable(reconstructFileCode(ast, i, {
|
|
512
|
+
selection: selection.nodes,
|
|
513
|
+
autoSelectIf: autoSelectIfWrapper,
|
|
514
|
+
fullAst: ast,
|
|
515
|
+
inlineSources: true,
|
|
516
|
+
sourceMap,
|
|
517
|
+
visited: new Set([i]),
|
|
518
|
+
currentFile: i,
|
|
519
|
+
warnings
|
|
520
|
+
}));
|
|
521
|
+
if (code.length > 0) {
|
|
522
|
+
parts.push(selection.inlineFull === 'banner' ? `# ---- ${ast.ast.files[i].filePath ?? '<inline>'} ----\n${code}` : code);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
502
525
|
return {
|
|
503
|
-
code,
|
|
526
|
+
code: parts.join('\n'),
|
|
504
527
|
linesWithAutoSelected: linesWithAutoSelected.size,
|
|
505
528
|
inlineWarnings: warnings
|
|
506
529
|
};
|
|
@@ -37,6 +37,10 @@ export declare const SlicingCriterion: {
|
|
|
37
37
|
*
|
|
38
38
|
* A negative line counts from the end of the input (`-1` being the last line). Every criterion but `$id`
|
|
39
39
|
* accepts a trailing `(file-regex)` (e.g. `2@x(tmp/.*)`) restricting it to a matching file.
|
|
40
|
+
*
|
|
41
|
+
* Lines, columns, and the `[n]` occurrence are all *1-based*, so a `0` anywhere (`2:0`, `0@x`, `2@[0]x`)
|
|
42
|
+
* addresses nothing and resolves to `undefined` -- it is not a wildcard for the whole line. A criterion
|
|
43
|
+
* always denotes at most a single node; use one criterion per node to select several.
|
|
40
44
|
* @see {@link SlicingCriterion.parse} for the version that throws an error
|
|
41
45
|
*/
|
|
42
46
|
readonly tryParse: (this: void, criterion: SlicingCriterion | NodeId, idMap: AstIdMap) => NodeId | undefined;
|
|
@@ -44,6 +44,10 @@ exports.SlicingCriterion = {
|
|
|
44
44
|
*
|
|
45
45
|
* A negative line counts from the end of the input (`-1` being the last line). Every criterion but `$id`
|
|
46
46
|
* accepts a trailing `(file-regex)` (e.g. `2@x(tmp/.*)`) restricting it to a matching file.
|
|
47
|
+
*
|
|
48
|
+
* Lines, columns, and the `[n]` occurrence are all *1-based*, so a `0` anywhere (`2:0`, `0@x`, `2@[0]x`)
|
|
49
|
+
* addresses nothing and resolves to `undefined` -- it is not a wildcard for the whole line. A criterion
|
|
50
|
+
* always denotes at most a single node; use one criterion per node to select several.
|
|
47
51
|
* @see {@link SlicingCriterion.parse} for the version that throws an error
|
|
48
52
|
*/
|
|
49
53
|
tryParse(criterion, idMap) {
|
|
@@ -39,13 +39,13 @@ function getAllFunctionCallTargetsForSlice(dataflowGraph, callerInfo, baseEnviro
|
|
|
39
39
|
const functionCallTargets = queue.memoizeCallTargets(functionCallDefs.join(';'), () => (0, linker_1.getAllLinkedFunctionDefinitions)(new Set(functionCallDefs), dataflowGraph)[0]);
|
|
40
40
|
return [functionCallTargets, activeEnvironment];
|
|
41
41
|
}
|
|
42
|
-
function includeArgumentFunctionCallClosure(arg, activeEnvironment, queue, dataflowGraph) {
|
|
42
|
+
function includeArgumentFunctionCallClosure(arg, activeEnvironment, activeEnvironmentFingerprint, queue, dataflowGraph) {
|
|
43
43
|
const valueRoot = graph_1.FunctionArgument.getReference(arg);
|
|
44
44
|
if (!valueRoot) {
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
47
47
|
const callTargets = queue.memoizeCallTargets(valueRoot, () => (0, linker_1.getAllLinkedFunctionDefinitions)(new Set([valueRoot]), dataflowGraph)[0]);
|
|
48
|
-
linkCallTargets(false, callTargets, activeEnvironment,
|
|
48
|
+
linkCallTargets(false, callTargets, activeEnvironment, activeEnvironmentFingerprint, queue);
|
|
49
49
|
}
|
|
50
50
|
function linkCallTargets(onlyForSideEffects, functionCallTargets, activeEnvironment, activeEnvironmentFingerprint, queue) {
|
|
51
51
|
for (const functionCallTarget of functionCallTargets) {
|
|
@@ -72,8 +72,9 @@ function sliceForCall(current, callerInfo, { graph }, queue, ctx) {
|
|
|
72
72
|
* if we do not have any call to resolve this function, we have to assume that every function passed is actually called!
|
|
73
73
|
* hence, we add a new flag and add all argument values to the queue causing directly
|
|
74
74
|
*/
|
|
75
|
+
const argEnvironmentFingerprint = (0, fingerprint_1.envFingerprint)(activeEnvironment);
|
|
75
76
|
for (const arg of callerInfo.args) {
|
|
76
|
-
includeArgumentFunctionCallClosure(arg, activeEnvironment, queue, graph);
|
|
77
|
+
includeArgumentFunctionCallClosure(arg, activeEnvironment, argEnvironmentFingerprint, queue, graph);
|
|
77
78
|
}
|
|
78
79
|
return;
|
|
79
80
|
}
|
|
@@ -167,15 +168,22 @@ function includeCalleesOfDefinition(fnDefId, graph, queue, baseEnvironment, base
|
|
|
167
168
|
const PotentialFollowOnReturn = edge_1.EdgeType.DefinesOnCall | edge_1.EdgeType.DefinedByOnCall | edge_1.EdgeType.Argument;
|
|
168
169
|
/** Returns true if we found at least one return edge */
|
|
169
170
|
function handleReturns(from, queue, currentEdges, baseEnvFingerprint, baseEnvironment) {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
171
|
+
let returns = false;
|
|
172
|
+
for (const edge of currentEdges.values()) {
|
|
173
|
+
if (edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Returns)) {
|
|
174
|
+
returns = true;
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
if (!returns) {
|
|
173
179
|
return false;
|
|
174
180
|
}
|
|
175
|
-
for (const [target] of
|
|
176
|
-
|
|
181
|
+
for (const [target, edge] of currentEdges) {
|
|
182
|
+
if (edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Returns)) {
|
|
183
|
+
queue.add(target, baseEnvironment, baseEnvFingerprint, false);
|
|
184
|
+
}
|
|
177
185
|
}
|
|
178
|
-
for (const [target, edge] of
|
|
186
|
+
for (const [target, edge] of currentEdges) {
|
|
179
187
|
if (edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Reads)) {
|
|
180
188
|
queue.add(target, baseEnvironment, baseEnvFingerprint, false);
|
|
181
189
|
}
|
|
@@ -55,7 +55,7 @@ export declare function staticSlice(options: StaticSliceOptions): Readonly<Slice
|
|
|
55
55
|
* reduced to that set and its edges are inverted in a single pass via {@link Dataflow.reduceAndInvertGraph}.
|
|
56
56
|
* The forward traversal then runs only within that subgraph, avoiding nodes that cannot contribute to the dice.
|
|
57
57
|
*/
|
|
58
|
-
export declare function staticDice(ctx: ReadOnlyFlowrAnalyzerContext, info: DataflowInformation, ast: NormalizedAst, startIds: readonly NodeId[], endIds: readonly NodeId[], threshold?: number): Readonly<SliceResult>;
|
|
58
|
+
export declare function staticDice(ctx: ReadOnlyFlowrAnalyzerContext, info: DataflowInformation, ast: NormalizedAst, startIds: readonly NodeId[], endIds: readonly NodeId[], threshold?: number, includeCallees?: boolean): Readonly<SliceResult>;
|
|
59
59
|
/**
|
|
60
60
|
* Updates the potential addition for the given target node in the visiting queue.
|
|
61
61
|
* This describes vertices that might be added *if* another path reaches them.
|
|
@@ -138,11 +138,12 @@ function staticSlice(options) {
|
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
|
+
const status = queue.status();
|
|
141
142
|
if (ctx.config.solver.slicer?.autoExtend) {
|
|
142
|
-
return { ...
|
|
143
|
+
return { ...status, slicedFor: ids, result: extendSlices(status.result, idMap) };
|
|
143
144
|
}
|
|
144
145
|
else {
|
|
145
|
-
return { ...
|
|
146
|
+
return { ...status, slicedFor: ids };
|
|
146
147
|
}
|
|
147
148
|
}
|
|
148
149
|
/**
|
|
@@ -153,9 +154,9 @@ function staticSlice(options) {
|
|
|
153
154
|
* reduced to that set and its edges are inverted in a single pass via {@link Dataflow.reduceAndInvertGraph}.
|
|
154
155
|
* The forward traversal then runs only within that subgraph, avoiding nodes that cannot contribute to the dice.
|
|
155
156
|
*/
|
|
156
|
-
function staticDice(ctx, info, ast, startIds, endIds, threshold = 75) {
|
|
157
|
+
function staticDice(ctx, info, ast, startIds, endIds, threshold = 75, includeCallees = false) {
|
|
157
158
|
(0, assert_1.guard)(startIds.length > 0 && endIds.length > 0, 'must have at least one start and one end id for dicing');
|
|
158
|
-
const backward = staticSlice({ ctx, info, ast, ids: endIds, direction: slice_direction_1.SliceDirection.Backward, threshold });
|
|
159
|
+
const backward = staticSlice({ ctx, info, ast, ids: endIds, direction: slice_direction_1.SliceDirection.Backward, threshold, includeCallees });
|
|
159
160
|
// reduce to backward result and invert edges in one pass; original info kept for sliceForCall
|
|
160
161
|
const invertedReduced = df_helper_1.Dataflow.reduceAndInvertGraph(info.graph, backward.result, ctx.env.makeCleanEnv());
|
|
161
162
|
const forward = staticSlice({ ctx, info, ast, ids: startIds, direction: slice_direction_1.SliceDirection.Backward, threshold, sliceGraph: invertedReduced });
|
package/util/files.d.ts
CHANGED
|
@@ -17,9 +17,14 @@ export interface Table {
|
|
|
17
17
|
export declare function getAllFiles(dir: string, suffix?: RegExp): AsyncGenerator<string>;
|
|
18
18
|
/**
|
|
19
19
|
* Retrieves all files in the given directory recursively (synchronously)
|
|
20
|
+
* @param dir - Directory path to start the search from
|
|
21
|
+
* @param suffix - Suffix of the files to be retrieved, tested against the file name
|
|
22
|
+
* @param ignoreDirs - Directories to skip, tested against the posix path relative to `dir`
|
|
23
|
+
* (e.g. `packrat/lib`), so a pattern can address nested directories
|
|
24
|
+
* @param relativeTo - The path to which the returned paths are relative (used for `ignoreDirs`), defaults to `dir`
|
|
20
25
|
* @see {@link getAllFiles} - for an asynchronous version.
|
|
21
26
|
*/
|
|
22
|
-
export declare function getAllFilesSync(dir: string, suffix?: RegExp, ignoreDirs?: RegExp | undefined): Generator<string>;
|
|
27
|
+
export declare function getAllFilesSync(dir: string, suffix?: RegExp, ignoreDirs?: RegExp | undefined, relativeTo?: string): Generator<string>;
|
|
23
28
|
/**
|
|
24
29
|
* Retrieves all R files in a given directory (asynchronously)
|
|
25
30
|
* @param input - directory-path to start the search from, can be a file as well. Will just return the file then.
|
|
@@ -69,6 +74,19 @@ export declare function readLineByLineSync(filePath: string, onLine: (line: Buff
|
|
|
69
74
|
* @param directory - The directory whose parent to return
|
|
70
75
|
*/
|
|
71
76
|
export declare function getParentDirectory(directory: string): string;
|
|
77
|
+
/**
|
|
78
|
+
* A path with backslashes rewritten to forward slashes, i.e. POSIX form. R accepts these on every OS, so this is
|
|
79
|
+
* also how a filesystem path is made safe to interpolate into an R string literal (where a raw `\` would escape).
|
|
80
|
+
*/
|
|
81
|
+
export declare function toPosixPath(p: string): string;
|
|
82
|
+
/**
|
|
83
|
+
* The directory all given paths share, e.g. `/a` for `/a/b.R` and `/a/c/d.R`; `undefined` if they share none.
|
|
84
|
+
*/
|
|
85
|
+
export declare function commonDirectory(paths: readonly string[]): string | undefined;
|
|
86
|
+
/**
|
|
87
|
+
* The path of `filePath` seen from `root` (`s.R` instead of `/tmp/s.R`), or unchanged if it lies outside of `root`.
|
|
88
|
+
*/
|
|
89
|
+
export declare function relativeTo(root: string, filePath: string): string;
|
|
72
90
|
/**
|
|
73
91
|
* Checks whether the given path-like object is a file that exists on the local filesystem.
|
|
74
92
|
*/
|
package/util/files.js
CHANGED
|
@@ -44,6 +44,9 @@ exports.writeTableAsCsv = writeTableAsCsv;
|
|
|
44
44
|
exports.readLineByLine = readLineByLine;
|
|
45
45
|
exports.readLineByLineSync = readLineByLineSync;
|
|
46
46
|
exports.getParentDirectory = getParentDirectory;
|
|
47
|
+
exports.toPosixPath = toPosixPath;
|
|
48
|
+
exports.commonDirectory = commonDirectory;
|
|
49
|
+
exports.relativeTo = relativeTo;
|
|
47
50
|
exports.isFilePath = isFilePath;
|
|
48
51
|
const fs_1 = __importStar(require("fs"));
|
|
49
52
|
const path_1 = __importDefault(require("path"));
|
|
@@ -70,15 +73,20 @@ async function* getAllFiles(dir, suffix = /.*/) {
|
|
|
70
73
|
}
|
|
71
74
|
/**
|
|
72
75
|
* Retrieves all files in the given directory recursively (synchronously)
|
|
76
|
+
* @param dir - Directory path to start the search from
|
|
77
|
+
* @param suffix - Suffix of the files to be retrieved, tested against the file name
|
|
78
|
+
* @param ignoreDirs - Directories to skip, tested against the posix path relative to `dir`
|
|
79
|
+
* (e.g. `packrat/lib`), so a pattern can address nested directories
|
|
80
|
+
* @param relativeTo - The path to which the returned paths are relative (used for `ignoreDirs`), defaults to `dir`
|
|
73
81
|
* @see {@link getAllFiles} - for an asynchronous version.
|
|
74
82
|
*/
|
|
75
|
-
function* getAllFilesSync(dir, suffix = /.*/, ignoreDirs = undefined) {
|
|
83
|
+
function* getAllFilesSync(dir, suffix = /.*/, ignoreDirs = undefined, relativeTo = dir) {
|
|
76
84
|
const entries = fs_1.default.readdirSync(dir, { withFileTypes: true, recursive: false });
|
|
77
85
|
for (const subEntries of entries) {
|
|
78
86
|
const res = path_1.default.resolve(dir, subEntries.name);
|
|
79
87
|
if (subEntries.isDirectory()) {
|
|
80
|
-
if (!ignoreDirs?.test(
|
|
81
|
-
yield* getAllFilesSync(res, suffix);
|
|
88
|
+
if (!ignoreDirs?.test(toPosixPath(path_1.default.relative(relativeTo, res)))) {
|
|
89
|
+
yield* getAllFilesSync(res, suffix, ignoreDirs, relativeTo);
|
|
82
90
|
}
|
|
83
91
|
}
|
|
84
92
|
else if (suffix.test(subEntries.name)) {
|
|
@@ -202,6 +210,40 @@ function getParentDirectory(directory) {
|
|
|
202
210
|
// apparently this is somehow the best way to do it in node, what
|
|
203
211
|
return directory.split(path_1.default.sep).slice(0, -1).join(path_1.default.sep);
|
|
204
212
|
}
|
|
213
|
+
/**
|
|
214
|
+
* A path with backslashes rewritten to forward slashes, i.e. POSIX form. R accepts these on every OS, so this is
|
|
215
|
+
* also how a filesystem path is made safe to interpolate into an R string literal (where a raw `\` would escape).
|
|
216
|
+
*/
|
|
217
|
+
function toPosixPath(p) {
|
|
218
|
+
return p.replaceAll('\\', '/');
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* The directory all given paths share, e.g. `/a` for `/a/b.R` and `/a/c/d.R`; `undefined` if they share none.
|
|
222
|
+
*/
|
|
223
|
+
function commonDirectory(paths) {
|
|
224
|
+
if (paths.length === 0) {
|
|
225
|
+
return undefined;
|
|
226
|
+
}
|
|
227
|
+
const split = paths.map(p => path_1.default.resolve(p).split(path_1.default.sep));
|
|
228
|
+
const common = [];
|
|
229
|
+
for (let i = 0; i < split[0].length; i++) {
|
|
230
|
+
if (!split.every(s => s[i] === split[0][i])) {
|
|
231
|
+
break;
|
|
232
|
+
}
|
|
233
|
+
common.push(split[0][i]);
|
|
234
|
+
}
|
|
235
|
+
if (common.length === 0) {
|
|
236
|
+
return undefined;
|
|
237
|
+
}
|
|
238
|
+
return common.length === 1 && common[0] === '' ? path_1.default.sep : common.join(path_1.default.sep);
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* The path of `filePath` seen from `root` (`s.R` instead of `/tmp/s.R`), or unchanged if it lies outside of `root`.
|
|
242
|
+
*/
|
|
243
|
+
function relativeTo(root, filePath) {
|
|
244
|
+
const relative = toPosixPath(path_1.default.relative(root, filePath));
|
|
245
|
+
return relative.length > 0 && !relative.startsWith('..') ? relative : filePath;
|
|
246
|
+
}
|
|
205
247
|
/**
|
|
206
248
|
* Checks whether the given path-like object is a file that exists on the local filesystem.
|
|
207
249
|
*/
|
package/util/glob.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Matching paths against gitignore-style patterns, as used for `.gitignore` rules and configured file globs.
|
|
3
|
+
* @module
|
|
4
|
+
*/
|
|
5
|
+
import type ignore from 'ignore';
|
|
6
|
+
/** The `ignore` factory, required on first use only. */
|
|
7
|
+
export declare function loadIgnore(): typeof ignore;
|
|
8
|
+
/**
|
|
9
|
+
* Tests paths against `pattern`, ignoring capitalization: `?` and `*` stay within one path segment, `**` spans them.
|
|
10
|
+
* A pattern anchored with a leading `/` has to match from the start, any other matches at any depth
|
|
11
|
+
* (`global.R` matches `pkg/R/global.R`).
|
|
12
|
+
*/
|
|
13
|
+
export declare function globMatcher(pattern: string): (filePath: string) => boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Unlike `.gitignore`, the lines of an `.Rbuildignore` are (Perl-compatible) *regular expressions* rather than
|
|
16
|
+
* globs, matched unanchored and case-insensitively against the path relative to the package root, as `R CMD build` does.
|
|
17
|
+
* Invalid lines are dropped with a warning.
|
|
18
|
+
*/
|
|
19
|
+
export declare function rbuildignoreMatcher(content: string): (relativePath: string) => boolean;
|
package/util/glob.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadIgnore = loadIgnore;
|
|
4
|
+
exports.globMatcher = globMatcher;
|
|
5
|
+
exports.rbuildignoreMatcher = rbuildignoreMatcher;
|
|
6
|
+
const files_1 = require("./files");
|
|
7
|
+
const log_1 = require("./log");
|
|
8
|
+
const rbuildignoreLog = log_1.log.getSubLogger({ name: 'rbuildignore' });
|
|
9
|
+
let ignoreFactory;
|
|
10
|
+
/** The `ignore` factory, required on first use only. */
|
|
11
|
+
function loadIgnore() {
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports -- loaded on demand, see above
|
|
13
|
+
return ignoreFactory ??= require('ignore');
|
|
14
|
+
}
|
|
15
|
+
/** `ignore` rejects absolute and windows paths */
|
|
16
|
+
function relative(filePath) {
|
|
17
|
+
return (0, files_1.toPosixPath)(filePath).replace(/^([a-zA-Z]:)?\/+/, '');
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Tests paths against `pattern`, ignoring capitalization: `?` and `*` stay within one path segment, `**` spans them.
|
|
21
|
+
* A pattern anchored with a leading `/` has to match from the start, any other matches at any depth
|
|
22
|
+
* (`global.R` matches `pkg/R/global.R`).
|
|
23
|
+
*/
|
|
24
|
+
function globMatcher(pattern) {
|
|
25
|
+
const cleaned = relative(pattern);
|
|
26
|
+
const ig = loadIgnore()({ ignorecase: true }).add(pattern.startsWith('/') ? cleaned : `**/${cleaned}`);
|
|
27
|
+
return filePath => ig.ignores(relative(filePath));
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Unlike `.gitignore`, the lines of an `.Rbuildignore` are (Perl-compatible) *regular expressions* rather than
|
|
31
|
+
* globs, matched unanchored and case-insensitively against the path relative to the package root, as `R CMD build` does.
|
|
32
|
+
* Invalid lines are dropped with a warning.
|
|
33
|
+
*/
|
|
34
|
+
function rbuildignoreMatcher(content) {
|
|
35
|
+
const patterns = [];
|
|
36
|
+
for (const line of content.split(/\r?\n/)) {
|
|
37
|
+
const trimmed = line.trim();
|
|
38
|
+
if (trimmed.length === 0) {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
try {
|
|
42
|
+
patterns.push(new RegExp(trimmed, 'i'));
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
rbuildignoreLog.warn(`Ignoring invalid .Rbuildignore pattern '${trimmed}'.`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (patterns.length === 0) {
|
|
49
|
+
return () => false;
|
|
50
|
+
}
|
|
51
|
+
return relativePath => {
|
|
52
|
+
const posix = relative(relativePath);
|
|
53
|
+
if (posix === '') {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
const segments = posix.split('/');
|
|
57
|
+
// R walks the tree, so a match on any ancestor prefix drops the whole subtree
|
|
58
|
+
for (let i = 1; i <= segments.length; i++) {
|
|
59
|
+
const prefix = segments.slice(0, i).join('/');
|
|
60
|
+
if (patterns.some(p => p.test(prefix))) {
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return false;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=glob.js.map
|
package/util/log.d.ts
CHANGED
|
@@ -20,4 +20,16 @@ export declare const enum LogLevel {
|
|
|
20
20
|
Error = 5,
|
|
21
21
|
Fatal = 6
|
|
22
22
|
}
|
|
23
|
+
export declare const LogLevelNames: {
|
|
24
|
+
readonly silly: LogLevel.Silly;
|
|
25
|
+
readonly trace: LogLevel.Trace;
|
|
26
|
+
readonly debug: LogLevel.Debug;
|
|
27
|
+
readonly info: LogLevel.Info;
|
|
28
|
+
readonly warn: LogLevel.Warn;
|
|
29
|
+
readonly error: LogLevel.Error;
|
|
30
|
+
readonly fatal: LogLevel.Fatal;
|
|
31
|
+
};
|
|
32
|
+
export type LogLevelName = keyof typeof LogLevelNames;
|
|
33
|
+
/** Set the global minimum log level by name. */
|
|
34
|
+
export declare function setLogLevel(level: LogLevelName): void;
|
|
23
35
|
export declare const log: FlowrLogger;
|
package/util/log.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.log = exports.FlowrLogger = exports.expensiveTrace = void 0;
|
|
3
|
+
exports.log = exports.LogLevelNames = exports.FlowrLogger = exports.expensiveTrace = void 0;
|
|
4
|
+
exports.setLogLevel = setLogLevel;
|
|
4
5
|
const tslog_1 = require("tslog");
|
|
5
6
|
const rotating_file_stream_1 = require("rotating-file-stream");
|
|
6
7
|
const expensiveTrace = (log, supplier) => {
|
|
@@ -38,6 +39,21 @@ class FlowrLogger extends tslog_1.Logger {
|
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
41
|
exports.FlowrLogger = FlowrLogger;
|
|
42
|
+
exports.LogLevelNames = {
|
|
43
|
+
silly: 0 /* LogLevel.Silly */,
|
|
44
|
+
trace: 1 /* LogLevel.Trace */,
|
|
45
|
+
debug: 2 /* LogLevel.Debug */,
|
|
46
|
+
info: 3 /* LogLevel.Info */,
|
|
47
|
+
warn: 4 /* LogLevel.Warn */,
|
|
48
|
+
error: 5 /* LogLevel.Error */,
|
|
49
|
+
fatal: 6 /* LogLevel.Fatal */
|
|
50
|
+
};
|
|
51
|
+
/** Set the global minimum log level by name. */
|
|
52
|
+
function setLogLevel(level) {
|
|
53
|
+
exports.log.updateSettings(l => {
|
|
54
|
+
l.settings.minLevel = exports.LogLevelNames[level];
|
|
55
|
+
});
|
|
56
|
+
}
|
|
41
57
|
function getActiveLog() {
|
|
42
58
|
return new FlowrLogger({
|
|
43
59
|
// set the default minimum level as Warn, and let all apps
|
package/util/logic.d.ts
CHANGED
|
@@ -3,3 +3,9 @@ export declare enum Ternary {
|
|
|
3
3
|
Maybe = "maybe",
|
|
4
4
|
Never = "never"
|
|
5
5
|
}
|
|
6
|
+
export declare const TernaryLogic: {
|
|
7
|
+
name: string;
|
|
8
|
+
negate(this: void, value: Ternary): Ternary;
|
|
9
|
+
or(this: void, ...values: Ternary[]): Ternary;
|
|
10
|
+
and(this: void, ...values: Ternary[]): Ternary;
|
|
11
|
+
};
|
package/util/logic.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Ternary = void 0;
|
|
3
|
+
exports.TernaryLogic = exports.Ternary = void 0;
|
|
4
4
|
// diverging from boolean | maybe requires explicit handling
|
|
5
5
|
var Ternary;
|
|
6
6
|
(function (Ternary) {
|
|
@@ -8,4 +8,34 @@ var Ternary;
|
|
|
8
8
|
Ternary["Maybe"] = "maybe";
|
|
9
9
|
Ternary["Never"] = "never";
|
|
10
10
|
})(Ternary || (exports.Ternary = Ternary = {}));
|
|
11
|
+
exports.TernaryLogic = {
|
|
12
|
+
name: 'Ternary',
|
|
13
|
+
negate(value) {
|
|
14
|
+
if (value === Ternary.Always) {
|
|
15
|
+
return Ternary.Never;
|
|
16
|
+
}
|
|
17
|
+
else if (value === Ternary.Never) {
|
|
18
|
+
return Ternary.Always;
|
|
19
|
+
}
|
|
20
|
+
return Ternary.Maybe;
|
|
21
|
+
},
|
|
22
|
+
or(...values) {
|
|
23
|
+
if (values.some(value => value === Ternary.Always)) {
|
|
24
|
+
return Ternary.Always;
|
|
25
|
+
}
|
|
26
|
+
else if (values.some(value => value === Ternary.Maybe)) {
|
|
27
|
+
return Ternary.Maybe;
|
|
28
|
+
}
|
|
29
|
+
return Ternary.Never;
|
|
30
|
+
},
|
|
31
|
+
and(...values) {
|
|
32
|
+
if (values.every(value => value === Ternary.Always)) {
|
|
33
|
+
return Ternary.Always;
|
|
34
|
+
}
|
|
35
|
+
else if (values.every(value => value === Ternary.Always || value === Ternary.Maybe)) {
|
|
36
|
+
return Ternary.Maybe;
|
|
37
|
+
}
|
|
38
|
+
return Ternary.Never;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
11
41
|
//# sourceMappingURL=logic.js.map
|
package/util/mermaid/dfg.js
CHANGED
|
@@ -22,6 +22,7 @@ function subflowToMermaid(nodeId, subflow, mermaid, idPrefix = '') {
|
|
|
22
22
|
if (subflow === undefined) {
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
|
+
const id = mermaid_1.Mermaid.escapeId(nodeId);
|
|
25
26
|
const subflowId = mermaid_1.Mermaid.escapeId(`${idPrefix}flow-${nodeId}`);
|
|
26
27
|
if (mermaid.simplified) {
|
|
27
28
|
// get parent
|
|
@@ -32,7 +33,7 @@ function subflowToMermaid(nodeId, subflow, mermaid, idPrefix = '') {
|
|
|
32
33
|
mermaid.nodeLines.push(`\nsubgraph "${subflowId}" ["${mermaid_1.Mermaid.escape(nodeLexeme)}${location}"]`);
|
|
33
34
|
}
|
|
34
35
|
else {
|
|
35
|
-
mermaid.nodeLines.push(`\nsubgraph "${subflowId}" [function ${
|
|
36
|
+
mermaid.nodeLines.push(`\nsubgraph "${subflowId}" [function ${id}]`);
|
|
36
37
|
}
|
|
37
38
|
const subgraph = graphToMermaidGraph(subflow.graph, {
|
|
38
39
|
graph: mermaid.rootGraph,
|
|
@@ -53,14 +54,14 @@ function subflowToMermaid(nodeId, subflow, mermaid, idPrefix = '') {
|
|
|
53
54
|
for (const out of pool) {
|
|
54
55
|
if (!mermaid.mark?.has(out.nodeId)) {
|
|
55
56
|
// in/out/active for unmarked
|
|
56
|
-
mermaid.nodeLines.push(` style ${idPrefix}${out.nodeId} stroke:${color},stroke-width:4px; `);
|
|
57
|
+
mermaid.nodeLines.push(` style ${idPrefix}${mermaid_1.Mermaid.escapeId(out.nodeId)} stroke:${color},stroke-width:4px; `);
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
61
|
mermaid.nodeLines.push('end');
|
|
61
|
-
mermaid.edgeLines.push(`${idPrefix}${
|
|
62
|
+
mermaid.edgeLines.push(`${idPrefix}${id} -.-|function| ${subflowId}\n`);
|
|
62
63
|
/* mark edge as present */
|
|
63
|
-
const edgeId = encodeEdge(idPrefix +
|
|
64
|
+
const edgeId = encodeEdge(idPrefix + id, subflowId, new Set(['function']));
|
|
64
65
|
mermaid.presentEdges.add(edgeId);
|
|
65
66
|
}
|
|
66
67
|
function printArg(arg) {
|
|
@@ -71,11 +72,11 @@ function printArg(arg) {
|
|
|
71
72
|
return '[empty]';
|
|
72
73
|
}
|
|
73
74
|
else if (graph_1.FunctionArgument.isNamed(arg)) {
|
|
74
|
-
const deps = arg.cds ? ',
|
|
75
|
+
const deps = arg.cds ? ', ' + arg.cds.map(c => c.id + (c.when ? '+' : '-')).join(', ') : '';
|
|
75
76
|
return `${arg.name} (${arg.nodeId}${deps})`;
|
|
76
77
|
}
|
|
77
78
|
else if (graph_1.FunctionArgument.isPositional(arg)) {
|
|
78
|
-
const deps = arg.cds ? ' (
|
|
79
|
+
const deps = arg.cds ? ' (' + arg.cds.map(c => c.id + (c.when ? '+' : '-')).join(', ') + ')' : '';
|
|
79
80
|
return `${arg.nodeId}${deps}`;
|
|
80
81
|
}
|
|
81
82
|
else {
|
|
@@ -135,6 +136,9 @@ function mermaidNodeBrackets(tag) {
|
|
|
135
136
|
function printIdentifier(id) {
|
|
136
137
|
return `**${id.name ? identifier_1.Identifier.toString(id.name) : 'undefined'}** (id: ${id.nodeId}, type: ${identifier_1.ReferenceTypeReverseMapping.get(id.type)},${id.cds ? ' cds: {' + id.cds.map(c => c.id + (c.when ? '+' : '-')).join(',') + '},' : ''} def. @${id.definedAt})`;
|
|
137
138
|
}
|
|
139
|
+
function environmentLevel(env) {
|
|
140
|
+
return env === undefined || env.builtInEnv ? 0 : environmentLevel(env.parent) + 1;
|
|
141
|
+
}
|
|
138
142
|
function printEnvironmentToLines(env) {
|
|
139
143
|
if (env === undefined) {
|
|
140
144
|
return ['??'];
|
|
@@ -142,7 +146,7 @@ function printEnvironmentToLines(env) {
|
|
|
142
146
|
else if (env.builtInEnv) {
|
|
143
147
|
return ['Built-in'];
|
|
144
148
|
}
|
|
145
|
-
const lines = [...printEnvironmentToLines(env.parent), `${env
|
|
149
|
+
const lines = [...printEnvironmentToLines(env.parent), `${environmentLevel(env)}${'-'.repeat(40)}`];
|
|
146
150
|
const longestName = Math.max(...[...env.memory.keys()].map(x => x.length));
|
|
147
151
|
for (const [name, defs] of env.memory.entries()) {
|
|
148
152
|
const printName = `${name}:`;
|
|
@@ -193,9 +197,10 @@ function vertexToMermaid(info, mermaid, id, idPrefix, mark, includeOnlyIds) {
|
|
|
193
197
|
}
|
|
194
198
|
else {
|
|
195
199
|
const escapedName = node ? `*${mermaid_1.Mermaid.escape(`[${node.type}]`)}* ${boldLexeme(lexeme, display)}` : '??';
|
|
196
|
-
const deps = info.cds ? ',
|
|
197
|
-
const lnks = info.link?.origin ? ',
|
|
198
|
-
const
|
|
200
|
+
const deps = info.cds ? ', ' + info.cds.map(c => mermaid_1.Mermaid.escapeId(c.id) + (c.when ? '+' : '-')).join(', ') : '';
|
|
201
|
+
const lnks = info.link?.origin ? ', links: ' + info.link.origin.map(o => mermaid_1.Mermaid.escapeId(o)).join(', ') : '';
|
|
202
|
+
const source = info.tag === vertex_1.VertexType.VariableDefinition ? info.source : undefined;
|
|
203
|
+
const sources = source ? ', v: ' + source.map(s => mermaid_1.Mermaid.escapeId(s)).join(', ') : '';
|
|
199
204
|
const n = node?.info.fullRange ?? node?.location ?? (node?.type === type_1.RType.ExpressionList ? node?.grouping?.[0].location : undefined);
|
|
200
205
|
mermaid.nodeLines.push(` ${idPrefix}${id}${open}"\`${escapedName}\n *${range_1.SourceRange.format(n)}* (**id: ${id}**${deps}${lnks}${sources})${fCall ? displayFunctionArgMapping(info.args) : '' + (info.tag === vertex_1.VertexType.FunctionDefinition && info.mode && info.mode.length > 0 ? mermaid_1.Mermaid.escape(JSON.stringify(info.mode)) : '')}\`"${close}`);
|
|
201
206
|
}
|
|
@@ -206,7 +211,7 @@ function vertexToMermaid(info, mermaid, id, idPrefix, mark, includeOnlyIds) {
|
|
|
206
211
|
mermaid.nodeLines.push(` style ${idPrefix}${id} stroke:red,stroke-width:5px; `);
|
|
207
212
|
}
|
|
208
213
|
if (info.tag === vertex_1.VertexType.FunctionDefinition) {
|
|
209
|
-
subflowToMermaid(
|
|
214
|
+
subflowToMermaid(origId, info.subflow, mermaid, idPrefix);
|
|
210
215
|
}
|
|
211
216
|
const edges = mermaid.rootGraph.outgoingEdges(node_id_1.NodeId.normalize(origId));
|
|
212
217
|
if (edges === undefined) {
|
|
@@ -226,7 +231,7 @@ function vertexToMermaid(info, mermaid, id, idPrefix, mark, includeOnlyIds) {
|
|
|
226
231
|
if (!mermaid.presentEdges.has(edgeId)) {
|
|
227
232
|
mermaid.presentEdges.add(edgeId);
|
|
228
233
|
const style = node_id_1.NodeId.isBuiltIn(target) ? '-.->' : '-->';
|
|
229
|
-
mermaid.edgeLines.push(` ${idPrefix}${id} ${style}|"${[...edgeTypes].map(e => typeof e === 'number' ? edge_1.DfEdge.typeToName(e) : e).join(', ')}${'file' in edge && edge.file ? `, from: ${edge.file}` : ''}"| ${idPrefix}${target}`);
|
|
234
|
+
mermaid.edgeLines.push(` ${idPrefix}${id} ${style}|"${[...edgeTypes].map(e => typeof e === 'number' ? edge_1.DfEdge.typeToName(e) : e).join(', ')}${'file' in edge && edge.file ? `, from: ${mermaid_1.Mermaid.escape(String(edge.file))}` : ''}"| ${idPrefix}${target}`);
|
|
230
235
|
if (mermaid.mark?.has(id + '->' + target)) {
|
|
231
236
|
// who invented this syntax?!
|
|
232
237
|
mermaid.edgeLines.push(` linkStyle ${mermaid.presentEdges.size - 1} ${mermaid.markStyle.edge}`);
|
package/util/mermaid/mermaid.js
CHANGED
|
@@ -66,8 +66,8 @@ exports.Mermaid = {
|
|
|
66
66
|
* Escapes a string or number to be used as a mermaid node id.
|
|
67
67
|
*/
|
|
68
68
|
escapeId(text) {
|
|
69
|
-
text = String(text).replace(/[^a-zA-Z0-9
|
|
70
|
-
return text.replace(/(^|[
|
|
69
|
+
text = String(text).replace(/[^a-zA-Z0-9:\-./]/g, '_');
|
|
70
|
+
return text.replace(/(^|[:\-./])([a-zA-Z0-9_]+)/g, (_m, sep, tok) => sep + (exports.Mermaid.reservedIds.has(tok) ? tok + '_' : tok));
|
|
71
71
|
},
|
|
72
72
|
/**
|
|
73
73
|
* Converts mermaid code (potentially produced by {@link DataflowMermaid.convert}) to an url that presents the graph in the mermaid editor.
|
package/util/objects.d.ts
CHANGED
|
@@ -4,6 +4,11 @@ import type { ILogObj, Logger } from 'tslog';
|
|
|
4
4
|
* checks if `item` is an object (it may be an array, ...)
|
|
5
5
|
*/
|
|
6
6
|
export declare function isObjectOrArray(item: unknown): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* checks if `item` is a record with keys, i.e. an object that is neither `null` nor an array
|
|
9
|
+
* @see {@link isObjectOrArray} to allow arrays as well
|
|
10
|
+
*/
|
|
11
|
+
export declare function isPlainObject(item: unknown): item is Record<string, unknown>;
|
|
7
12
|
export type MergeableRecord = Record<string, unknown>;
|
|
8
13
|
export type MergeableArray = unknown[];
|
|
9
14
|
export type Mergeable = MergeableRecord | MergeableArray;
|