@eagleoutice/flowr 2.10.8 → 2.10.10
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 +106 -36
- package/abstract-interpretation/absint-visitor.js +6 -3
- package/abstract-interpretation/domains/abstract-domain.d.ts +1 -1
- package/abstract-interpretation/domains/bounded-set-domain.d.ts +1 -1
- package/abstract-interpretation/domains/bounded-set-domain.js +1 -1
- package/abstract-interpretation/domains/interval-domain.d.ts +1 -1
- package/abstract-interpretation/domains/interval-domain.js +1 -1
- package/abstract-interpretation/domains/lattice.d.ts +1 -1
- package/abstract-interpretation/domains/partial-product-domain.d.ts +1 -1
- package/abstract-interpretation/domains/partial-product-domain.js +2 -2
- package/abstract-interpretation/domains/set-range-domain.d.ts +1 -1
- package/abstract-interpretation/domains/set-range-domain.js +1 -1
- package/abstract-interpretation/domains/set-upper-bound-domain.d.ts +1 -1
- package/abstract-interpretation/domains/set-upper-bound-domain.js +1 -1
- package/abstract-interpretation/domains/singleton-domain.d.ts +1 -1
- package/abstract-interpretation/domains/singleton-domain.js +1 -1
- package/abstract-interpretation/domains/state-abstract-domain.d.ts +1 -1
- package/abstract-interpretation/domains/state-abstract-domain.js +2 -2
- package/abstract-interpretation/unsupported-functions.d.ts +3 -2
- package/abstract-interpretation/unsupported-functions.js +38 -28
- package/cli/benchmark-app.js +2 -1
- package/cli/common/script.js +3 -2
- package/cli/flowr.js +47 -10
- package/cli/repl/commands/repl-cfg.js +9 -9
- package/cli/repl/commands/repl-commands.js +5 -0
- package/cli/repl/commands/repl-dataflow.js +31 -24
- package/cli/repl/commands/repl-main.d.ts +6 -0
- package/cli/repl/commands/repl-normalize.js +15 -12
- package/cli/repl/commands/repl-parse.js +1 -1
- package/cli/repl/commands/repl-query.js +4 -5
- package/cli/repl/commands/repl-quit.js +2 -1
- package/cli/repl/core.d.ts +11 -0
- package/cli/repl/core.js +101 -3
- package/cli/repl/execute.js +3 -2
- package/cli/repl/parser/slice-query-parser.d.ts +16 -0
- package/cli/repl/parser/slice-query-parser.js +52 -0
- package/cli/repl/server/connection.d.ts +1 -0
- package/cli/repl/server/connection.js +25 -0
- package/cli/repl/server/messages/message-analysis.d.ts +10 -0
- package/cli/repl/server/messages/message-analysis.js +6 -2
- package/cli/repl/server/messages/message-slice.d.ts +1 -1
- package/cli/script-core/statistics-core.js +2 -1
- package/cli/script-core/statistics-helper-core.js +2 -1
- package/cli/wiki.d.ts +2 -1
- package/cli/wiki.js +4 -1
- package/config.d.ts +9 -0
- package/config.js +23 -1
- package/control-flow/diff-cfg.d.ts +1 -1
- package/control-flow/diff-cfg.js +1 -1
- package/control-flow/extract-cfg.js +9 -3
- package/control-flow/semantic-cfg-guided-visitor.js +1 -0
- package/control-flow/simple-visitor.js +6 -5
- package/control-flow/useless-loop.js +2 -2
- package/core/print/dataflow-printer.d.ts +2 -2
- package/core/print/dataflow-printer.js +2 -2
- package/core/steps/all/static-slicing/00-slice.js +1 -1
- package/core/steps/pipeline/default-pipelines.d.ts +146 -146
- package/dataflow/environments/append.d.ts +2 -1
- package/dataflow/environments/append.js +2 -1
- 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 +122 -66
- package/dataflow/environments/default-builtin-config.js +324 -145
- package/dataflow/environments/environment.d.ts +2 -1
- package/dataflow/environments/environment.js +13 -9
- package/dataflow/environments/identifier.d.ts +55 -2
- package/dataflow/environments/identifier.js +14 -2
- package/dataflow/environments/reference-to-maybe.d.ts +2 -0
- package/dataflow/environments/reference-to-maybe.js +56 -11
- package/dataflow/environments/resolve-by-name.js +13 -7
- package/dataflow/eval/values/general.js +4 -0
- package/dataflow/extractor.js +22 -3
- package/dataflow/graph/df-helper.d.ts +6 -0
- package/dataflow/graph/df-helper.js +33 -0
- package/dataflow/graph/graph.js +7 -3
- package/dataflow/info.d.ts +1 -1
- package/dataflow/info.js +3 -1
- package/dataflow/internal/linker.d.ts +5 -1
- package/dataflow/internal/linker.js +34 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +3 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +53 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-namespace-access.d.ts +13 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-namespace-access.js +58 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +38 -14
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +19 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +1 -1
- package/dataflow/internal/process/functions/call/known-call-handling.js +4 -3
- package/dataflow/internal/process/functions/call/named-call-handling.js +6 -0
- package/dataflow/origin/dfg-get-origin.d.ts +1 -1
- package/dataflow/origin/dfg-get-origin.js +1 -1
- package/dataflow/processor.d.ts +6 -0
- package/documentation/data/faq/faqs.d.ts +2 -1
- package/documentation/data/faq/faqs.js +75 -57
- package/documentation/data/server/doc-data-server-messages.d.ts +2 -1
- package/documentation/data/server/doc-data-server-messages.js +15 -7
- package/documentation/doc-readme.js +15 -15
- package/documentation/doc-util/doc-cfg.d.ts +3 -1
- package/documentation/doc-util/doc-cfg.js +3 -3
- package/documentation/doc-util/doc-dfg.d.ts +3 -1
- package/documentation/doc-util/doc-dfg.js +3 -3
- package/documentation/doc-util/doc-files.d.ts +3 -1
- package/documentation/doc-util/doc-files.js +9 -6
- package/documentation/doc-util/doc-normalized-ast.d.ts +3 -1
- package/documentation/doc-util/doc-normalized-ast.js +2 -2
- package/documentation/doc-util/doc-query.d.ts +2 -1
- package/documentation/doc-util/doc-query.js +2 -2
- package/documentation/doc-util/doc-repl.js +1 -0
- package/documentation/doc-util/doc-types.d.ts +6 -6
- package/documentation/doc-util/doc-types.js +11 -9
- package/documentation/issue-linting-rule.js +1 -2
- package/documentation/wiki-analyzer.js +9 -9
- package/documentation/wiki-cfg.js +40 -41
- package/documentation/wiki-core.js +119 -31
- package/documentation/wiki-create-linting-rules.d.ts +6 -0
- package/documentation/wiki-create-linting-rules.js +95 -0
- package/documentation/wiki-dataflow-graph.js +77 -76
- package/documentation/wiki-engine.js +1 -2
- package/documentation/wiki-faq.d.ts +2 -1
- package/documentation/wiki-faq.js +4 -4
- package/documentation/wiki-interface.js +19 -6
- package/documentation/wiki-linter.d.ts +1 -1
- package/documentation/wiki-linter.js +14 -6
- package/documentation/wiki-linting-and-testing.js +2 -2
- package/documentation/wiki-mk/doc-context.d.ts +3 -3
- package/documentation/wiki-mk/doc-maker.d.ts +2 -0
- package/documentation/wiki-mk/doc-maker.js +7 -1
- package/documentation/wiki-normalized-ast.js +5 -5
- package/documentation/wiki-onboarding.d.ts +2 -1
- package/documentation/wiki-onboarding.js +5 -5
- package/documentation/wiki-overview.js +3 -3
- package/documentation/wiki-query.js +85 -84
- package/documentation/wiki-search.js +4 -5
- package/documentation/wiki-setup.js +6 -7
- package/gas.d.ts +74 -0
- package/gas.js +18 -0
- package/linter/linter-executor.js +2 -8
- package/linter/linter-format.d.ts +4 -11
- package/linter/linter-rules.d.ts +88 -86
- package/linter/linter-rules.js +7 -1
- package/linter/rules/absolute-path.d.ts +2 -7
- package/linter/rules/absolute-path.js +6 -4
- package/linter/rules/dataframe-access-validation.d.ts +1 -6
- package/linter/rules/dataframe-access-validation.js +8 -6
- package/linter/rules/dead-code.d.ts +2 -11
- package/linter/rules/dead-code.js +16 -11
- package/linter/rules/deprecated-functions.d.ts +3 -3
- package/linter/rules/file-path-validity.d.ts +1 -6
- package/linter/rules/file-path-validity.js +5 -5
- package/linter/rules/function-finder-util.d.ts +7 -11
- package/linter/rules/function-finder-util.js +9 -6
- package/linter/rules/naming-convention.d.ts +2 -7
- package/linter/rules/naming-convention.js +3 -2
- package/linter/rules/network-functions.d.ts +2 -7
- package/linter/rules/network-functions.js +14 -12
- package/linter/rules/no-leaked-credentials.d.ts +36 -0
- package/linter/rules/no-leaked-credentials.js +75 -0
- package/linter/rules/problematic-inputs.d.ts +1 -8
- package/linter/rules/problematic-inputs.js +5 -4
- package/linter/rules/roxygen-arguments.d.ts +2 -7
- package/linter/rules/roxygen-arguments.js +13 -20
- package/linter/rules/seeded-randomness.d.ts +2 -7
- package/linter/rules/seeded-randomness.js +7 -4
- package/linter/rules/software-has-license.d.ts +31 -0
- package/linter/rules/software-has-license.js +46 -0
- package/linter/rules/software-has-tests.d.ts +38 -0
- package/linter/rules/software-has-tests.js +48 -0
- package/linter/rules/stop-with-call-arg.d.ts +2 -7
- package/linter/rules/stop-with-call-arg.js +3 -2
- package/linter/rules/unused-definition.d.ts +3 -8
- package/linter/rules/unused-definition.js +7 -5
- package/linter/rules/useless-loop.d.ts +2 -7
- package/linter/rules/useless-loop.js +5 -2
- package/package.json +3 -2
- package/project/context/flowr-analyzer-context.d.ts +13 -14
- package/project/context/flowr-analyzer-context.js +4 -0
- package/project/context/flowr-analyzer-files-context.d.ts +12 -0
- package/project/context/flowr-analyzer-files-context.js +12 -2
- package/project/context/flowr-analyzer-gas-context.d.ts +28 -0
- package/project/context/flowr-analyzer-gas-context.js +101 -0
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +13 -7
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +56 -11
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.js +2 -2
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.d.ts +2 -1
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.js +5 -5
- package/project/plugins/flowr-analyzer-plugin.d.ts +15 -8
- package/project/plugins/flowr-analyzer-plugin.js +14 -7
- package/project/plugins/gas-plugins/flowr-analyzer-gas-plugin.d.ts +19 -0
- package/project/plugins/gas-plugins/flowr-analyzer-gas-plugin.js +35 -0
- package/project/plugins/plugin-registry.d.ts +2 -1
- package/project/plugins/plugin-registry.js +3 -1
- package/project/plugins/project-discovery/flowr-analyzer-gitignore-project-discovery-plugin.d.ts +22 -0
- package/project/plugins/project-discovery/flowr-analyzer-gitignore-project-discovery-plugin.js +47 -0
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +1 -1
- package/queries/catalog/call-context-query/call-context-query-executor.js +54 -8
- package/queries/catalog/call-context-query/call-context-query-format.d.ts +2 -2
- package/queries/catalog/dependencies-query/function-info/test-functions.d.ts +2 -0
- package/queries/catalog/dependencies-query/function-info/test-functions.js +18 -177
- package/queries/catalog/df-shape-query/df-shape-query-format.js +1 -1
- package/queries/catalog/dice-query/dice-query-executor.d.ts +8 -0
- package/queries/catalog/dice-query/dice-query-executor.js +52 -0
- package/queries/catalog/dice-query/dice-query-format.d.ts +53 -0
- package/queries/catalog/dice-query/dice-query-format.js +102 -0
- package/queries/catalog/happens-before-query/happens-before-query-executor.js +2 -2
- 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 +1 -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 +1 -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 +1 -0
- package/queries/catalog/linter-query/linter-query-executor.js +7 -0
- 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 +1 -0
- package/queries/catalog/origin-query/origin-query-format.d.ts +2 -0
- package/queries/catalog/origin-query/origin-query-format.js +1 -0
- package/queries/catalog/provenance-query/provenance-query-format.d.ts +2 -0
- package/queries/catalog/provenance-query/provenance-query-format.js +1 -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 +1 -0
- package/queries/catalog/static-slice-query/static-slice-query-executor.js +1 -1
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +2 -0
- package/queries/catalog/static-slice-query/static-slice-query-format.js +1 -0
- package/queries/query.d.ts +18 -1
- package/queries/query.js +3 -1
- package/r-bridge/data/data.d.ts +5 -0
- package/r-bridge/data/data.js +6 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +0 -1
- package/r-bridge/lang-4.x/ast/model/processing/decorate.js +10 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-number.d.ts +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-number.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-string.d.ts +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-string.js +1 -1
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +63 -44
- package/r-bridge/parser.js +2 -9
- package/r-bridge/shell.d.ts +8 -1
- package/r-bridge/shell.js +26 -7
- package/search/flowr-search-builder.d.ts +2 -2
- package/search/flowr-search-builder.js +1 -1
- package/search/flowr-search-filters.d.ts +30 -9
- package/search/flowr-search-filters.js +26 -21
- package/search/search-executor/search-enrichers.d.ts +600 -0
- package/search/search-executor/search-enrichers.js +23 -2
- package/slicing/static/static-slicer.d.ts +39 -11
- package/slicing/static/static-slicer.js +44 -14
- package/util/collections/queue.d.ts +16 -0
- package/util/collections/queue.js +38 -0
- package/util/log.d.ts +1 -1
- package/util/log.js +1 -1
- package/util/mermaid/dfg.d.ts +2 -2
- package/util/mermaid/dfg.js +2 -2
- package/util/objects.d.ts +9 -0
- package/util/objects.js +57 -1
- package/util/proc.d.ts +6 -0
- package/util/proc.js +20 -0
- package/util/version.js +1 -1
package/project/plugins/project-discovery/flowr-analyzer-gitignore-project-discovery-plugin.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.FlowrAnalyzerGitignoreProjectDiscoveryPlugin = void 0;
|
|
7
|
+
const flowr_analyzer_project_discovery_plugin_1 = require("./flowr-analyzer-project-discovery-plugin");
|
|
8
|
+
const semver_1 = require("semver");
|
|
9
|
+
const retriever_1 = require("../../../r-bridge/retriever");
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const fs_1 = __importDefault(require("fs"));
|
|
12
|
+
const ignore_1 = __importDefault(require("ignore"));
|
|
13
|
+
/**
|
|
14
|
+
* Decorator around any {@link FlowrAnalyzerProjectDiscoveryPlugin} that filters discovered files
|
|
15
|
+
* by the rules in a `.gitignore` file found at the project root.
|
|
16
|
+
* If no `.gitignore` exists, the inner plugin's results are returned unchanged.
|
|
17
|
+
*
|
|
18
|
+
* Register as `'project-discovery:gitignore'` (see {@link BuiltInPlugins}) to replace the
|
|
19
|
+
* default discovery plugin with a gitignore-aware variant.
|
|
20
|
+
*/
|
|
21
|
+
class FlowrAnalyzerGitignoreProjectDiscoveryPlugin extends flowr_analyzer_project_discovery_plugin_1.FlowrAnalyzerProjectDiscoveryPlugin {
|
|
22
|
+
name = 'flowr-analyzer-gitignore-project-discovery-plugin';
|
|
23
|
+
description = 'Wraps a project discovery plugin and filters results by .gitignore rules.';
|
|
24
|
+
version = new semver_1.SemVer('0.1.0');
|
|
25
|
+
inner;
|
|
26
|
+
constructor(inner = flowr_analyzer_project_discovery_plugin_1.FlowrAnalyzerProjectDiscoveryPlugin.defaultPlugin()) {
|
|
27
|
+
super();
|
|
28
|
+
this.inner = inner;
|
|
29
|
+
}
|
|
30
|
+
process(context, args) {
|
|
31
|
+
const ig = (0, ignore_1.default)();
|
|
32
|
+
const gitignorePath = path_1.default.join(args.content, '.gitignore');
|
|
33
|
+
if (fs_1.default.existsSync(gitignorePath)) {
|
|
34
|
+
ig.add(fs_1.default.readFileSync(gitignorePath, 'utf-8'));
|
|
35
|
+
}
|
|
36
|
+
return this.inner.processor(context, args).filter(r => {
|
|
37
|
+
const filePath = (0, retriever_1.isParseRequest)(r) && r.request === 'file' ? r.content : !(0, retriever_1.isParseRequest)(r) ? r.path() : undefined;
|
|
38
|
+
if (filePath === undefined) {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
const relative = path_1.default.relative(args.content, filePath);
|
|
42
|
+
return relative === '' || !ig.ignores(relative);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.FlowrAnalyzerGitignoreProjectDiscoveryPlugin = FlowrAnalyzerGitignoreProjectDiscoveryPlugin;
|
|
47
|
+
//# sourceMappingURL=flowr-analyzer-gitignore-project-discovery-plugin.js.map
|
|
@@ -25,7 +25,7 @@ class FlowrAnalyzerProjectDiscoveryPlugin extends flowr_analyzer_plugin_1.FlowrA
|
|
|
25
25
|
}
|
|
26
26
|
exports.FlowrAnalyzerProjectDiscoveryPlugin = FlowrAnalyzerProjectDiscoveryPlugin;
|
|
27
27
|
const discoverRSourcesRegex = /\.(r|rmd|ipynb|qmd|rnw)$/i;
|
|
28
|
-
const ignorePathsWith = /(\.git|\.svn|\.hg|renv|packrat|node_modules|__pycache__|\.Rproj\.user)/i;
|
|
28
|
+
const ignorePathsWith = /(\.git|\.svn|\.hg|rv|renv|packrat|node_modules|__pycache__|\.Rproj\.user)/i;
|
|
29
29
|
const excludeRequestsForPaths = /vignettes?|tests?|revdep|inst|data/i;
|
|
30
30
|
/**
|
|
31
31
|
* This is the default dummy implementation of the {@link FlowrAnalyzerProjectDiscoveryPlugin}.
|
|
@@ -12,6 +12,7 @@ const cfg_kind_1 = require("../../../project/cfg-kind");
|
|
|
12
12
|
const extract_cfg_1 = require("../../../control-flow/extract-cfg");
|
|
13
13
|
const identify_link_to_relation_1 = require("./identify-link-to-relation");
|
|
14
14
|
const identifier_1 = require("../../../dataflow/environments/identifier");
|
|
15
|
+
const queue_1 = require("../../../util/collections/queue");
|
|
15
16
|
/* if the node is effected by nse, we have an ingoing nse edge */
|
|
16
17
|
function isQuoted(node, graph) {
|
|
17
18
|
const vertex = graph.ingoingEdges(node);
|
|
@@ -65,14 +66,23 @@ function promoteCallName(callName, exact = false) {
|
|
|
65
66
|
return (t) => r.test(t);
|
|
66
67
|
}
|
|
67
68
|
}
|
|
69
|
+
/** string arrays always match exactly, plain strings only if the query requests an exact match */
|
|
70
|
+
function exactNamesOf(callName, exact) {
|
|
71
|
+
if (Array.isArray(callName)) {
|
|
72
|
+
return callName;
|
|
73
|
+
}
|
|
74
|
+
return exact && typeof callName === 'string' ? [callName] : undefined;
|
|
75
|
+
}
|
|
68
76
|
function promoteQueryCallNames(queries) {
|
|
69
77
|
let requiresCfg = false;
|
|
70
|
-
const promotedQueries = queries.map(q => {
|
|
78
|
+
const promotedQueries = queries.map((q, idx) => {
|
|
71
79
|
if (isSubCallQuery(q)) {
|
|
72
80
|
requiresCfg = true;
|
|
73
81
|
return {
|
|
74
82
|
...q,
|
|
75
83
|
callName: promoteCallName(q.callName, q.callNameExact),
|
|
84
|
+
exactNames: exactNamesOf(q.callName, q.callNameExact),
|
|
85
|
+
idx,
|
|
76
86
|
fileFilter: q.fileFilter && {
|
|
77
87
|
...q.fileFilter,
|
|
78
88
|
filter: promoteCallName(q.fileFilter.filter)
|
|
@@ -91,6 +101,8 @@ function promoteQueryCallNames(queries) {
|
|
|
91
101
|
return {
|
|
92
102
|
...q,
|
|
93
103
|
callName: promoteCallName(q.callName, q.callNameExact),
|
|
104
|
+
exactNames: exactNamesOf(q.callName, q.callNameExact),
|
|
105
|
+
idx,
|
|
94
106
|
fileFilter: q.fileFilter && {
|
|
95
107
|
...q.fileFilter,
|
|
96
108
|
filter: promoteCallName(q.fileFilter.filter)
|
|
@@ -105,10 +117,10 @@ function retrieveAllCallAliases(nodeId, graph) {
|
|
|
105
117
|
/* we want the names of all functions called at the source id, including synonyms and returns */
|
|
106
118
|
const aliases = new Map();
|
|
107
119
|
const visited = new Set();
|
|
108
|
-
/* we store the current call name */
|
|
109
|
-
const queue = [[(0, node_id_1.recoverContent)(nodeId, graph) ?? '', nodeId]];
|
|
110
|
-
while (queue.
|
|
111
|
-
const [str, id] = queue.
|
|
120
|
+
/* we store the current call name alongside each id */
|
|
121
|
+
const queue = new queue_1.ArrayQueue([[(0, node_id_1.recoverContent)(nodeId, graph) ?? '', nodeId]]);
|
|
122
|
+
while (!queue.isEmpty()) {
|
|
123
|
+
const [str, id] = queue.dequeue();
|
|
112
124
|
if (visited.has(id)) {
|
|
113
125
|
continue;
|
|
114
126
|
}
|
|
@@ -134,7 +146,9 @@ function retrieveAllCallAliases(nodeId, graph) {
|
|
|
134
146
|
.map(([t]) => [(0, node_id_1.recoverContent)(t, graph) ?? '', t])
|
|
135
147
|
.toArray();
|
|
136
148
|
/** only follow defined-by and reads */
|
|
137
|
-
|
|
149
|
+
for (const e of x) {
|
|
150
|
+
queue.enqueue(e);
|
|
151
|
+
}
|
|
138
152
|
continue;
|
|
139
153
|
}
|
|
140
154
|
let track = edge_1.EdgeType.Calls | edge_1.EdgeType.Reads | edge_1.EdgeType.DefinedBy | edge_1.EdgeType.DefinedByOnCall;
|
|
@@ -145,7 +159,7 @@ function retrieveAllCallAliases(nodeId, graph) {
|
|
|
145
159
|
.filter(([, e]) => edge_1.DfEdge.includesType(e, track) && (nodeId !== id || edge_1.DfEdge.doesNotIncludeType(e, edge_1.EdgeType.Argument)))
|
|
146
160
|
.map(([t]) => t);
|
|
147
161
|
for (const call of out) {
|
|
148
|
-
queue.
|
|
162
|
+
queue.enqueue([(0, node_id_1.recoverContent)(call, graph) ?? (0, node_id_1.recoverContent)(id, graph) ?? '', call]);
|
|
149
163
|
}
|
|
150
164
|
}
|
|
151
165
|
return aliases;
|
|
@@ -210,6 +224,28 @@ async function executeCallContextQueries({ analyzer }, queries) {
|
|
|
210
224
|
}
|
|
211
225
|
const calls = cfg ? (0, extract_cfg_1.getCallsInCfg)(cfg, dataflow.graph) : undefined;
|
|
212
226
|
const queriesWhichWantAliases = promotedQueries.filter(q => q.includeAliases);
|
|
227
|
+
/* index exact-name queries so each vertex costs one map lookup instead of a predicate check per query */
|
|
228
|
+
const nonAliasByName = new Map();
|
|
229
|
+
const nonAliasPatterns = [];
|
|
230
|
+
for (const query of promotedQueries) {
|
|
231
|
+
if (query.includeAliases) {
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
234
|
+
if (query.exactNames) {
|
|
235
|
+
for (const name of query.exactNames) {
|
|
236
|
+
const present = nonAliasByName.get(name);
|
|
237
|
+
if (present) {
|
|
238
|
+
present.push(query);
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
nonAliasByName.set(name, [query]);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
nonAliasPatterns.push(query);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
213
249
|
for (const [nodeId, info] of dataflow.graph.verticesOfType(vertex_1.VertexType.FunctionCall)) {
|
|
214
250
|
/* if we have a vertex, and we check for aliased calls, we want to know if we define this as desired! */
|
|
215
251
|
if (queriesWhichWantAliases.length > 0) {
|
|
@@ -228,7 +264,17 @@ async function executeCallContextQueries({ analyzer }, queries) {
|
|
|
228
264
|
}
|
|
229
265
|
}
|
|
230
266
|
const n = identifier_1.Identifier.getName(info.name);
|
|
231
|
-
|
|
267
|
+
const byName = nonAliasByName.get(n) ?? [];
|
|
268
|
+
let matching;
|
|
269
|
+
if (nonAliasPatterns.length === 0) {
|
|
270
|
+
matching = byName;
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
const patternMatches = nonAliasPatterns.filter(q => q.callName(n));
|
|
274
|
+
matching = byName.length === 0 ? patternMatches
|
|
275
|
+
: [...byName, ...patternMatches].sort((a, b) => a.idx - b.idx);
|
|
276
|
+
}
|
|
277
|
+
for (const query of matching) {
|
|
232
278
|
const file = ast.idMap.get(nodeId)?.info.file;
|
|
233
279
|
if (!doesFilepathMatch(file, query.fileFilter)) {
|
|
234
280
|
continue;
|
|
@@ -22,9 +22,9 @@ export interface FileFilter<FilterType> {
|
|
|
22
22
|
}
|
|
23
23
|
export interface DefaultCallContextQueryFormat<RegexType extends CallNameTypes> extends BaseQueryFormat {
|
|
24
24
|
readonly type: 'call-context';
|
|
25
|
-
/**
|
|
25
|
+
/** The function name to match: a string (interpreted as a regex unless {@link callNameExact} is set), a RegExp, or an array of strings (always matched exactly). */
|
|
26
26
|
readonly callName: RegexType;
|
|
27
|
-
/**
|
|
27
|
+
/** For a string {@link callName}, match it literally instead of as a regex. For a RegExp, add `^` and `$` anchors. Arrays always match exactly, regardless of this flag. */
|
|
28
28
|
readonly callNameExact?: boolean;
|
|
29
29
|
/** kind may be a step or anything that you attach to the call, this can be used to group calls together (e.g., linking `ggplot` to `visualize`). Defaults to `.` */
|
|
30
30
|
readonly kind?: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TestFunctions = void 0;
|
|
4
|
-
|
|
3
|
+
exports.TestFunctions = exports.ExpectFunctions = void 0;
|
|
4
|
+
exports.ExpectFunctions = {
|
|
5
5
|
type: 'link-to-nested-call',
|
|
6
6
|
callName: new RegExp(/* testthat */ '^(expect_equal|expect_identical|expect_error|expect_warning|expect_message|expect_condition|' +
|
|
7
7
|
'expect_true|expect_false|expect_all_equal|expect_all_true|expect_all_false|expect_lt|expect_lte|expect_gt|expect_gte|' +
|
|
@@ -15,6 +15,8 @@ const ExpectFunctions = {
|
|
|
15
15
|
'exit_file|exit_if_not|expect_equal|expect_identical|expect_equivalent|expect_true|expect_false|expect_silent|expect_null|' +
|
|
16
16
|
'expect_inherits|expect_error|expect_warning|expect_message|expect_stdout|expect_equal_to_reference|' +
|
|
17
17
|
'expect_equivalent_to_reference|expect_length|expect_match|ignore|report_side_effects|' +
|
|
18
|
+
/* testit */
|
|
19
|
+
'assert|' +
|
|
18
20
|
/* RUnit */
|
|
19
21
|
'checkEquals|checkEqualsNumeric|checkIdentical|checkTrue|checkException|' +
|
|
20
22
|
/* checkmate */
|
|
@@ -37,180 +39,19 @@ const ContextFunctions = {
|
|
|
37
39
|
callName: new RegExp('^(context)$')
|
|
38
40
|
};
|
|
39
41
|
exports.TestFunctions = [
|
|
40
|
-
{ package: 'testthat', name: 'test_that', argName: 'desc', argIdx: 0, resolveValue: true, linkTo: [ExpectFunctions, ContextFunctions] },
|
|
41
|
-
{ package: 'testthat', name: 'describe', argName: 'description', argIdx: 0, resolveValue: true, linkTo: [ExpectFunctions, ContextFunctions] },
|
|
42
|
-
{ package: 'testthat', name: 'it', argName: 'description', argIdx: 0, resolveValue: true, linkTo: [ExpectFunctions, ContextFunctions] },
|
|
43
|
-
|
|
44
|
-
{ package: 'testthat', name: '
|
|
45
|
-
{ package: 'testthat', name: '
|
|
46
|
-
{ package: '
|
|
47
|
-
{ package: '
|
|
48
|
-
{ package: '
|
|
49
|
-
{ package: '
|
|
50
|
-
{ package: '
|
|
51
|
-
{ package: '
|
|
52
|
-
{ package: '
|
|
53
|
-
{ package: '
|
|
54
|
-
{ package: 'testthat', name: 'expect_setequal' },
|
|
55
|
-
{ package: 'testthat', name: 'expect_mapequal' },
|
|
56
|
-
{ package: 'testthat', name: 'expect_contains' },
|
|
57
|
-
{ package: 'testthat', name: 'expect_in' },
|
|
58
|
-
{ package: 'testthat', name: 'expect_disjoint' },
|
|
59
|
-
{ package: 'testthat', name: 'expect_type' },
|
|
60
|
-
{ package: 'testthat', name: 'expect_s3_class' },
|
|
61
|
-
{ package: 'testthat', name: 'expect_s4_class' },
|
|
62
|
-
{ package: 'testthat', name: 'expect_r6_class' },
|
|
63
|
-
{ package: 'testthat', name: 'expect_s7_class' },
|
|
64
|
-
{ package: 'testthat', name: 'expect_vector' },
|
|
65
|
-
{ package: 'testthat', name: 'expect_no_error' },
|
|
66
|
-
{ package: 'testthat', name: 'expect_no_warning' },
|
|
67
|
-
{ package: 'testthat', name: 'expect_no_message' },
|
|
68
|
-
{ package: 'testthat', name: 'expect_no_condition' },
|
|
69
|
-
{ package: 'testthat', name: 'expect_invisible' },
|
|
70
|
-
{ package: 'testthat', name: 'expect_visible' },
|
|
71
|
-
{ package: 'testthat', name: 'expect_output' },
|
|
72
|
-
{ package: 'testthat', name: 'expect_silent' },
|
|
73
|
-
{ package: 'testthat', name: 'expect_snapshot' },
|
|
74
|
-
{ package: 'testthat', name: 'expect_snapshot_value' },
|
|
75
|
-
{ package: 'testthat', name: 'expect_snapshot_file' },
|
|
76
|
-
{ package: 'testthat', name: 'announce_snapshot_file' },
|
|
77
|
-
{ package: 'testthat', name: 'compare_file_binary' },
|
|
78
|
-
{ package: 'testthat', name: 'compare_file_text' },
|
|
79
|
-
{ package: 'testthat', name: 'snapshot_accept' },
|
|
80
|
-
{ package: 'testthat', name: 'snapshot_reject' },
|
|
81
|
-
{ package: 'testthat', name: 'snapshot_review' },
|
|
82
|
-
{ package: 'testthat', name: 'fail' },
|
|
83
|
-
{ package: 'testthat', name: 'pass' },
|
|
84
|
-
{ package: 'testthat', name: 'expect_success' },
|
|
85
|
-
{ package: 'testthat', name: 'expect_failure' },
|
|
86
|
-
{ package: 'testthat', name: 'expect_snapshot_failure' },
|
|
87
|
-
{ package: 'testthat', name: 'show_failure' },
|
|
88
|
-
|
|
89
|
-
{ package: 'tinytest', name: 'exit_file', argName: 'msg', resolveValue: true },
|
|
90
|
-
{ package: 'tinytest', name: 'exit_if_not' },
|
|
91
|
-
{ package: 'tinytest', name: 'expect_equal', argName: 'info', resolveValue: true },
|
|
92
|
-
{ package: 'tinytest', name: 'expect_identical', argName: 'info', resolveValue: true },
|
|
93
|
-
{ package: 'tinytest', name: 'expect_equivalent', argName: 'info', resolveValue: true },
|
|
94
|
-
{ package: 'tinytest', name: 'expect_true', argName: 'info', resolveValue: true },
|
|
95
|
-
{ package: 'tinytest', name: 'expect_false', argName: 'info', resolveValue: true },
|
|
96
|
-
{ package: 'tinytest', name: 'expect_silent', argName: 'info', resolveValue: true },
|
|
97
|
-
{ package: 'tinytest', name: 'expect_null', argName: 'info', resolveValue: true },
|
|
98
|
-
{ package: 'tinytest', name: 'expect_inherits', argName: 'info', resolveValue: true },
|
|
99
|
-
{ package: 'tinytest', name: 'expect_error', argName: 'info', resolveValue: true },
|
|
100
|
-
{ package: 'tinytest', name: 'expect_warning', argName: 'info', resolveValue: true },
|
|
101
|
-
{ package: 'tinytest', name: 'expect_message', argName: 'info', resolveValue: true },
|
|
102
|
-
{ package: 'tinytest', name: 'expect_stdout', argName: 'info', resolveValue: true },
|
|
103
|
-
{ package: 'tinytest', name: 'expect_equal_to_reference', argName: 'info', resolveValue: true },
|
|
104
|
-
{ package: 'tinytest', name: 'expect_equivalent_to_reference', argName: 'info', resolveValue: true },
|
|
105
|
-
{ package: 'tinytest', name: 'expect_length', argName: 'info', resolveValue: true },
|
|
106
|
-
{ package: 'tinytest', name: 'expect_match', argName: 'info', resolveValue: true },
|
|
107
|
-
{ package: 'tinytest', name: 'ignore' },
|
|
108
|
-
{ package: 'tinytest', name: 'report_side_effects' },
|
|
109
|
-
|
|
110
|
-
{ package: 'RUnit', name: 'checkEquals', argName: 'msg', argIdx: 2, resolveValue: true },
|
|
111
|
-
{ package: 'RUnit', name: 'checkEqualsNumeric', argName: 'msg', argIdx: 2, resolveValue: true },
|
|
112
|
-
{ package: 'RUnit', name: 'checkIdentical', argName: 'msg', argIdx: 2, resolveValue: true },
|
|
113
|
-
{ package: 'RUnit', name: 'checkTrue', argName: 'msg', argIdx: 1, resolveValue: true },
|
|
114
|
-
{ package: 'RUnit', name: 'checkException', argName: 'msg', argIdx: 1, resolveValue: true },
|
|
115
|
-
|
|
116
|
-
{ package: 'checkmate', name: 'assertAccess' },
|
|
117
|
-
{ package: 'checkmate', name: 'assert_access' },
|
|
118
|
-
{ package: 'checkmate', name: 'assertArray' },
|
|
119
|
-
{ package: 'checkmate', name: 'assert_array' },
|
|
120
|
-
{ package: 'checkmate', name: 'assert_atomic' },
|
|
121
|
-
{ package: 'checkmate', name: 'assertAtomic' },
|
|
122
|
-
{ package: 'checkmate', name: 'assert_atomic_vector' },
|
|
123
|
-
{ package: 'checkmate', name: 'assertAtomicVector' },
|
|
124
|
-
{ package: 'checkmate', name: 'assert_character' },
|
|
125
|
-
{ package: 'checkmate', name: 'assertCharacter' },
|
|
126
|
-
{ package: 'checkmate', name: 'assert_choice' },
|
|
127
|
-
{ package: 'checkmate', name: 'assertChoice' },
|
|
128
|
-
{ package: 'checkmate', name: 'assert_class' },
|
|
129
|
-
{ package: 'checkmate', name: 'assertClass' },
|
|
130
|
-
{ package: 'checkmate', name: 'assert_complex' },
|
|
131
|
-
{ package: 'checkmate', name: 'assertComplex' },
|
|
132
|
-
{ package: 'checkmate', name: 'assert_count' },
|
|
133
|
-
{ package: 'checkmate', name: 'assertCount' },
|
|
134
|
-
{ package: 'checkmate', name: 'assert_data_frame' },
|
|
135
|
-
{ package: 'checkmate', name: 'assertDataFrame' },
|
|
136
|
-
{ package: 'checkmate', name: 'assert_data_table' },
|
|
137
|
-
{ package: 'checkmate', name: 'assertDataTable' },
|
|
138
|
-
{ package: 'checkmate', name: 'assert_date' },
|
|
139
|
-
{ package: 'checkmate', name: 'assertDate' },
|
|
140
|
-
{ package: 'checkmate', name: 'assert_directory' },
|
|
141
|
-
{ package: 'checkmate', name: 'assertDirectory' },
|
|
142
|
-
{ package: 'checkmate', name: 'assert_directory_exists' },
|
|
143
|
-
{ package: 'checkmate', name: 'assertDirectoryExists' },
|
|
144
|
-
{ package: 'checkmate', name: 'assert_disjunct' },
|
|
145
|
-
{ package: 'checkmate', name: 'assertDisjunct' },
|
|
146
|
-
{ package: 'checkmate', name: 'assert_double' },
|
|
147
|
-
{ package: 'checkmate', name: 'assertDouble' },
|
|
148
|
-
{ package: 'checkmate', name: 'assert_environment' },
|
|
149
|
-
{ package: 'checkmate', name: 'assertEnvironment' },
|
|
150
|
-
{ package: 'checkmate', name: 'assert_factor' },
|
|
151
|
-
{ package: 'checkmate', name: 'assertFactor' },
|
|
152
|
-
{ package: 'checkmate', name: 'assert_false' },
|
|
153
|
-
{ package: 'checkmate', name: 'assertFalse' },
|
|
154
|
-
{ package: 'checkmate', name: 'assert_file' },
|
|
155
|
-
{ package: 'checkmate', name: 'assertFile' },
|
|
156
|
-
{ package: 'checkmate', name: 'assert_file_exists' },
|
|
157
|
-
{ package: 'checkmate', name: 'assertFileExists' },
|
|
158
|
-
{ package: 'checkmate', name: 'assert_flag' },
|
|
159
|
-
{ package: 'checkmate', name: 'assertFlag' },
|
|
160
|
-
{ package: 'checkmate', name: 'assert_formula' },
|
|
161
|
-
{ package: 'checkmate', name: 'assertFormula' },
|
|
162
|
-
{ package: 'checkmate', name: 'assert_function' },
|
|
163
|
-
{ package: 'checkmate', name: 'assertFunction' },
|
|
164
|
-
{ package: 'checkmate', name: 'assert_int' },
|
|
165
|
-
{ package: 'checkmate', name: 'assertInt' },
|
|
166
|
-
{ package: 'checkmate', name: 'assert_integer' },
|
|
167
|
-
{ package: 'checkmate', name: 'assertInteger' },
|
|
168
|
-
{ package: 'checkmate', name: 'assert_list' },
|
|
169
|
-
{ package: 'checkmate', name: 'assertList' },
|
|
170
|
-
{ package: 'checkmate', name: 'assert_logical' },
|
|
171
|
-
{ package: 'checkmate', name: 'assertLogical' },
|
|
172
|
-
{ package: 'checkmate', name: 'assert_matrix' },
|
|
173
|
-
{ package: 'checkmate', name: 'assertMatrix' },
|
|
174
|
-
{ package: 'checkmate', name: 'assert_multi_class' },
|
|
175
|
-
{ package: 'checkmate', name: 'assertMultiClass' },
|
|
176
|
-
{ package: 'checkmate', name: 'assert_named' },
|
|
177
|
-
{ package: 'checkmate', name: 'assertNamed' },
|
|
178
|
-
{ package: 'checkmate', name: 'assert_names' },
|
|
179
|
-
{ package: 'checkmate', name: 'assertNames' },
|
|
180
|
-
{ package: 'checkmate', name: 'assert_null' },
|
|
181
|
-
{ package: 'checkmate', name: 'assertNull' },
|
|
182
|
-
{ package: 'checkmate', name: 'assert_number' },
|
|
183
|
-
{ package: 'checkmate', name: 'assertNumber' },
|
|
184
|
-
{ package: 'checkmate', name: 'assert_numeric' },
|
|
185
|
-
{ package: 'checkmate', name: 'assertNumeric' },
|
|
186
|
-
{ package: 'checkmate', name: 'assert_os' },
|
|
187
|
-
{ package: 'checkmate', name: 'assertOs' },
|
|
188
|
-
{ package: 'checkmate', name: 'assert_path_for_output' },
|
|
189
|
-
{ package: 'checkmate', name: 'assertPathForOutput' },
|
|
190
|
-
{ package: 'checkmate', name: 'assert_permutation' },
|
|
191
|
-
{ package: 'checkmate', name: 'assertPermutation' },
|
|
192
|
-
{ package: 'checkmate', name: 'assert_posixct' },
|
|
193
|
-
{ package: 'checkmate', name: 'assertPOSIXct' },
|
|
194
|
-
{ package: 'checkmate', name: 'assert_r6' },
|
|
195
|
-
{ package: 'checkmate', name: 'assertR6' },
|
|
196
|
-
{ package: 'checkmate', name: 'assert_raw' },
|
|
197
|
-
{ package: 'checkmate', name: 'assertRaw' },
|
|
198
|
-
{ package: 'checkmate', name: 'assert_scalar' },
|
|
199
|
-
{ package: 'checkmate', name: 'assertScalar' },
|
|
200
|
-
{ package: 'checkmate', name: 'assert_scalar_na' },
|
|
201
|
-
{ package: 'checkmate', name: 'assertScalarNA' },
|
|
202
|
-
{ package: 'checkmate', name: 'assert_set_equal' },
|
|
203
|
-
{ package: 'checkmate', name: 'assertSetEqual' },
|
|
204
|
-
{ package: 'checkmate', name: 'assert_string' },
|
|
205
|
-
{ package: 'checkmate', name: 'assertString' },
|
|
206
|
-
{ package: 'checkmate', name: 'assert_subset' },
|
|
207
|
-
{ package: 'checkmate', name: 'assertSubset' },
|
|
208
|
-
{ package: 'checkmate', name: 'assert_tibble' },
|
|
209
|
-
{ package: 'checkmate', name: 'assertTibble' },
|
|
210
|
-
{ package: 'checkmate', name: 'assert_true' },
|
|
211
|
-
{ package: 'checkmate', name: 'assertTrue' },
|
|
212
|
-
{ package: 'checkmate', name: 'assert_vector' },
|
|
213
|
-
{ package: 'checkmate', name: 'assertVector' }
|
|
214
|
-
*/
|
|
42
|
+
{ package: 'testthat', name: 'test_that', argName: 'desc', argIdx: 0, resolveValue: true, linkTo: [exports.ExpectFunctions, ContextFunctions] },
|
|
43
|
+
{ package: 'testthat', name: 'describe', argName: 'description', argIdx: 0, resolveValue: true, linkTo: [exports.ExpectFunctions, ContextFunctions] },
|
|
44
|
+
{ package: 'testthat', name: 'it', argName: 'description', argIdx: 0, resolveValue: true, linkTo: [exports.ExpectFunctions, ContextFunctions] },
|
|
45
|
+
{ package: 'testthat', name: 'test_file' },
|
|
46
|
+
{ package: 'testthat', name: 'test_dir' },
|
|
47
|
+
{ package: 'testthat', name: 'test_package' },
|
|
48
|
+
{ package: 'tinytest', name: 'run_test_dir' },
|
|
49
|
+
{ package: 'tinytest', name: 'run_test_file' },
|
|
50
|
+
{ package: 'tinytest', name: 'test_all' },
|
|
51
|
+
{ package: 'tinytest', name: 'test_package' },
|
|
52
|
+
{ package: 'testit', name: 'test_pkg' },
|
|
53
|
+
{ package: 'RUnit', name: 'runTestSuite' },
|
|
54
|
+
{ package: 'RUnit', name: 'runTestFile' },
|
|
55
|
+
{ package: 'RUnit', name: 'defineTestSuite' },
|
|
215
56
|
];
|
|
216
57
|
//# sourceMappingURL=test-functions.js.map
|
|
@@ -42,7 +42,7 @@ exports.DfShapeQueryDefinition = {
|
|
|
42
42
|
jsonFormatter: (queryResults) => {
|
|
43
43
|
const { domains, ...out } = queryResults;
|
|
44
44
|
const state = domains instanceof abstract_domain_1.AbstractDomain ? domains.value : domains;
|
|
45
|
-
const json = state === lattice_1.Bottom ? state.description : Object.fromEntries(state.entries().map(([key, domain]) => [key, domain?.
|
|
45
|
+
const json = state === lattice_1.Bottom ? state.description : Object.fromEntries(state.entries().map(([key, domain]) => [key, domain?.toJSON() ?? null]));
|
|
46
46
|
const result = { domains: json, ...out };
|
|
47
47
|
return result;
|
|
48
48
|
},
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { BasicQueryData } from '../../base-query-format';
|
|
2
|
+
import type { DiceQuery, DiceQueryResult } from './dice-query-format';
|
|
3
|
+
/**
|
|
4
|
+
* Execute dice queries. Each dice computes the intersection of a forward slice from `from`
|
|
5
|
+
* and a backward slice from `to`, yielding only those program points that lie on a path
|
|
6
|
+
* from the start criteria to the end criteria.
|
|
7
|
+
*/
|
|
8
|
+
export declare function executeDiceQuery({ analyzer }: BasicQueryData, queries: readonly DiceQuery[]): Promise<DiceQueryResult>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.executeDiceQuery = executeDiceQuery;
|
|
4
|
+
const static_slicer_1 = require("../../../slicing/static/static-slicer");
|
|
5
|
+
const reconstruct_1 = require("../../../reconstruct/reconstruct");
|
|
6
|
+
const auto_select_defaults_1 = require("../../../reconstruct/auto-select/auto-select-defaults");
|
|
7
|
+
const magic_comments_1 = require("../../../reconstruct/auto-select/magic-comments");
|
|
8
|
+
const parse_1 = require("../../../slicing/criterion/parse");
|
|
9
|
+
const log_1 = require("../../../util/log");
|
|
10
|
+
/**
|
|
11
|
+
* Execute dice queries. Each dice computes the intersection of a forward slice from `from`
|
|
12
|
+
* and a backward slice from `to`, yielding only those program points that lie on a path
|
|
13
|
+
* from the start criteria to the end criteria.
|
|
14
|
+
*/
|
|
15
|
+
async function executeDiceQuery({ analyzer }, queries) {
|
|
16
|
+
const start = Date.now();
|
|
17
|
+
const results = {};
|
|
18
|
+
const ast = await analyzer.normalize();
|
|
19
|
+
const df = await analyzer.dataflow();
|
|
20
|
+
for (const query of queries) {
|
|
21
|
+
const key = JSON.stringify(query);
|
|
22
|
+
if (results[key]) {
|
|
23
|
+
log_1.log.warn(`Duplicate key for dice-query: ${key}, skipping...`);
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
const { from, to, noReconstruction, noMagicComments } = query;
|
|
27
|
+
const startIds = parse_1.SlicingCriteria.convertAll(from, ast.idMap);
|
|
28
|
+
const endIds = parse_1.SlicingCriteria.convertAll(to, ast.idMap);
|
|
29
|
+
const sliceStart = Date.now();
|
|
30
|
+
const slice = (0, static_slicer_1.staticDice)(analyzer.inspectContext(), df, ast, startIds, endIds, analyzer.flowrConfig.solver.slicer?.threshold);
|
|
31
|
+
const sliceEnd = Date.now();
|
|
32
|
+
if (noReconstruction) {
|
|
33
|
+
results[key] = { slice: { ...slice, '.meta': { timing: sliceEnd - sliceStart } } };
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
const reconstructStart = Date.now();
|
|
37
|
+
const reconstruct = (0, reconstruct_1.reconstructToCode)(ast, { nodes: slice.result }, noMagicComments ? auto_select_defaults_1.doNotAutoSelect : (0, magic_comments_1.makeMagicCommentHandler)(auto_select_defaults_1.doNotAutoSelect));
|
|
38
|
+
const reconstructEnd = Date.now();
|
|
39
|
+
results[key] = {
|
|
40
|
+
slice: { ...slice, '.meta': { timing: sliceEnd - sliceStart } },
|
|
41
|
+
reconstruct: { ...reconstruct, '.meta': { timing: reconstructEnd - reconstructStart } }
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
'.meta': {
|
|
47
|
+
timing: Date.now() - start
|
|
48
|
+
},
|
|
49
|
+
results
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=dice-query-executor.js.map
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { BaseQueryFormat, BaseQueryResult } from '../../base-query-format';
|
|
2
|
+
import type { SlicingCriteria } from '../../../slicing/criterion/parse';
|
|
3
|
+
import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
4
|
+
import type { ParsedQueryLine } from '../../query';
|
|
5
|
+
import Joi from 'joi';
|
|
6
|
+
import { executeDiceQuery } from './dice-query-executor';
|
|
7
|
+
import type { ReplOutput } from '../../../cli/repl/commands/repl-main';
|
|
8
|
+
import type { CommandCompletions } from '../../../cli/repl/core';
|
|
9
|
+
import type { FlowrConfig } from '../../../config';
|
|
10
|
+
/**
|
|
11
|
+
* Computes a program dice: only those parts that lie on a path from the given start nodes to the given end nodes.
|
|
12
|
+
* Equivalent to the intersection of a forward slice from `from` and a backward slice from `to`.
|
|
13
|
+
*/
|
|
14
|
+
export interface DiceQuery extends BaseQueryFormat {
|
|
15
|
+
readonly type: 'dice';
|
|
16
|
+
/** Slicing criteria for the start of the dice (forward slice seeds) */
|
|
17
|
+
readonly from: SlicingCriteria;
|
|
18
|
+
/** Slicing criteria for the end of the dice (backward slice seeds) */
|
|
19
|
+
readonly to: SlicingCriteria;
|
|
20
|
+
/** Do not reconstruct the dice into readable code */
|
|
21
|
+
readonly noReconstruction?: boolean;
|
|
22
|
+
/** Should magic comments be ignored? */
|
|
23
|
+
readonly noMagicComments?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface DiceQueryResult extends BaseQueryResult {
|
|
26
|
+
results: Record<string, {
|
|
27
|
+
slice: {
|
|
28
|
+
timesHitThreshold: number;
|
|
29
|
+
result: ReadonlySet<NodeId>;
|
|
30
|
+
slicedFor: readonly NodeId[];
|
|
31
|
+
'.meta': {
|
|
32
|
+
timing: number;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
reconstruct?: {
|
|
36
|
+
code: string | string[];
|
|
37
|
+
'.meta': {
|
|
38
|
+
timing: number;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
}>;
|
|
42
|
+
}
|
|
43
|
+
declare function diceQueryLineParser(output: ReplOutput, line: readonly string[], _config: FlowrConfig): ParsedQueryLine<'dice'>;
|
|
44
|
+
declare function diceQueryCompleter(line: readonly string[], startingNewArg: boolean, _config: FlowrConfig): CommandCompletions;
|
|
45
|
+
export declare const DiceQueryDefinition: {
|
|
46
|
+
readonly executor: typeof executeDiceQuery;
|
|
47
|
+
readonly asciiSummarizer: (formatter: import("../../../util/text/ansi").OutputFormatter, _analyzer: import("../../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider<import("../../../r-bridge/parser").KnownParser>, queryResults: BaseQueryResult, result: string[]) => true;
|
|
48
|
+
readonly fromLine: typeof diceQueryLineParser;
|
|
49
|
+
readonly completer: typeof diceQueryCompleter;
|
|
50
|
+
readonly schema: Joi.ObjectSchema<any>;
|
|
51
|
+
readonly flattenInvolvedNodes: (queryResults: BaseQueryResult) => NodeId[];
|
|
52
|
+
};
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.DiceQueryDefinition = void 0;
|
|
7
|
+
const ansi_1 = require("../../../util/text/ansi");
|
|
8
|
+
const time_1 = require("../../../util/text/time");
|
|
9
|
+
const joi_1 = __importDefault(require("joi"));
|
|
10
|
+
const dice_query_executor_1 = require("./dice-query-executor");
|
|
11
|
+
const query_print_1 = require("../../query-print");
|
|
12
|
+
const slice_query_parser_1 = require("../../../cli/repl/parser/slice-query-parser");
|
|
13
|
+
const diceFormat = '(from1;from2->to1;to2)';
|
|
14
|
+
function diceQueryLineParser(output, line, _config) {
|
|
15
|
+
const parsed = (0, slice_query_parser_1.diceCriteriaParser)(line[0]);
|
|
16
|
+
if (!parsed) {
|
|
17
|
+
output.stderr(output.formatter.format(`Invalid dice query format. Expected ${diceFormat}, e.g. (2@x->12@x) or (1@a;2@b->5@c).`, { color: 1 /* Colors.Red */, effect: ansi_1.ColorEffect.Foreground, style: 1 /* FontStyles.Bold */ }));
|
|
18
|
+
return { query: [] };
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
query: [{ type: 'dice', from: parsed.from, to: parsed.to }],
|
|
22
|
+
rCode: line[1]
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function diceQueryCompleter(line, startingNewArg, _config) {
|
|
26
|
+
if (line.length === 0) {
|
|
27
|
+
return { completions: ['('] };
|
|
28
|
+
}
|
|
29
|
+
if (startingNewArg || line.length !== 1) {
|
|
30
|
+
return { completions: [] };
|
|
31
|
+
}
|
|
32
|
+
const arg = line[0];
|
|
33
|
+
if (arg.endsWith(')')) {
|
|
34
|
+
return { completions: [] };
|
|
35
|
+
}
|
|
36
|
+
const hasArrow = arg.includes('->');
|
|
37
|
+
const side = hasArrow ? arg.slice(arg.indexOf('->') + 2) : arg.slice(1);
|
|
38
|
+
const fragment = side.slice(side.lastIndexOf(';') + 1);
|
|
39
|
+
if (/^\d+$/.test(fragment)) {
|
|
40
|
+
return { completions: [`${arg}@`], argumentPart: arg };
|
|
41
|
+
}
|
|
42
|
+
if (/^\d+@\w+$/.test(fragment)) {
|
|
43
|
+
return { completions: [hasArrow ? `${arg}) ` : `${arg}->`], argumentPart: arg };
|
|
44
|
+
}
|
|
45
|
+
return { completions: [] };
|
|
46
|
+
}
|
|
47
|
+
exports.DiceQueryDefinition = {
|
|
48
|
+
executor: dice_query_executor_1.executeDiceQuery,
|
|
49
|
+
asciiSummarizer: (formatter, _analyzer, queryResults, result) => {
|
|
50
|
+
const out = queryResults;
|
|
51
|
+
if (Object.keys(out.results).length === 1) {
|
|
52
|
+
const [, obj] = Object.entries(out.results)[0];
|
|
53
|
+
const rec = obj.reconstruct;
|
|
54
|
+
if (rec !== undefined) {
|
|
55
|
+
const code = Array.isArray(rec.code) ? rec.code : [rec.code];
|
|
56
|
+
if (code.length === 1) {
|
|
57
|
+
result.push(code[0]);
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
result.push(`Query: ${(0, ansi_1.bold)('dice', formatter)} (${(0, time_1.printAsMs)(out['.meta'].timing, 0)})`);
|
|
63
|
+
for (const [fingerprint, obj] of Object.entries(out.results)) {
|
|
64
|
+
const { from, to, noReconstruction, noMagicComments } = JSON.parse(fingerprint);
|
|
65
|
+
const addons = [];
|
|
66
|
+
if (noReconstruction) {
|
|
67
|
+
addons.push('no reconstruction');
|
|
68
|
+
}
|
|
69
|
+
if (noMagicComments) {
|
|
70
|
+
addons.push('no magic comments');
|
|
71
|
+
}
|
|
72
|
+
result.push(` ╰ Dice from {${from.join(', ')}} to {${to.join(', ')}} ${addons.join(', ')}`);
|
|
73
|
+
const rec = obj.reconstruct;
|
|
74
|
+
if (rec !== undefined) {
|
|
75
|
+
const code = Array.isArray(rec.code) ? rec.code : [rec.code];
|
|
76
|
+
result.push(' ╰ Code (newline as <code>\n</code>): <code>' + code.flatMap(c => c.split('\n')).join('\\n') + '</code>');
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
result.push(` ╰ Id List: {${(0, query_print_1.summarizeIdsIfTooLong)(formatter, [...obj.slice.result])}}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return true;
|
|
83
|
+
},
|
|
84
|
+
fromLine: diceQueryLineParser,
|
|
85
|
+
completer: diceQueryCompleter,
|
|
86
|
+
schema: joi_1.default.object({
|
|
87
|
+
type: joi_1.default.string().valid('dice').required().description('The type of the query.'),
|
|
88
|
+
from: joi_1.default.array().items(joi_1.default.string()).min(1).required().description('Slicing criteria for the start of the dice (forward slice seeds).'),
|
|
89
|
+
to: joi_1.default.array().items(joi_1.default.string()).min(1).required().description('Slicing criteria for the end of the dice (backward slice seeds).'),
|
|
90
|
+
noReconstruction: joi_1.default.boolean().optional().description('Do not reconstruct the dice into readable code.'),
|
|
91
|
+
noMagicComments: joi_1.default.boolean().optional().description('Should the magic comments be ignored?'),
|
|
92
|
+
}).description('Dice query: selects only paths from the given start nodes that reach the given end nodes.'),
|
|
93
|
+
flattenInvolvedNodes: (queryResults) => {
|
|
94
|
+
const flattened = [];
|
|
95
|
+
const out = queryResults;
|
|
96
|
+
for (const [, obj] of Object.entries(out.results)) {
|
|
97
|
+
flattened.push(...obj.slice.result);
|
|
98
|
+
}
|
|
99
|
+
return flattened;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
//# sourceMappingURL=dice-query-format.js.map
|