@eagleoutice/flowr 2.11.1 → 2.12.1
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 +187 -257
- package/abstract-interpretation/absint-visitor.d.ts +1 -0
- package/abstract-interpretation/data-frame/mappers/arguments.js +7 -1
- package/abstract-interpretation/domains/set-range-domain.js +1 -1
- package/abstract-interpretation/domains/set-upper-bound-domain.js +6 -2
- package/benchmark/slicer.d.ts +1 -1
- package/benchmark/slicer.js +3 -1
- package/benchmark/summarizer/second-phase/graph.js +5 -0
- package/cli/common/options.d.ts +8 -0
- package/cli/common/options.js +2 -0
- package/cli/common/scripts-info.d.ts +8 -0
- package/cli/repl/commands/repl-commands.d.ts +1 -0
- package/cli/repl/commands/repl-commands.js +66 -15
- package/cli/repl/commands/repl-dataflow.js +48 -4
- package/cli/repl/commands/repl-main.d.ts +2 -0
- package/cli/repl/commands/repl-main.js +5 -0
- package/cli/repl/commands/repl-query.d.ts +4 -1
- package/cli/repl/commands/repl-query.js +72 -22
- package/cli/repl/commands/repl-signature.d.ts +7 -0
- package/cli/repl/commands/repl-signature.js +119 -0
- package/cli/repl/core.d.ts +8 -1
- package/cli/repl/core.js +46 -6
- package/cli/repl/ghost-hint.d.ts +37 -0
- package/cli/repl/ghost-hint.js +72 -0
- package/cli/repl/parser/slice-query-parser.d.ts +11 -1
- package/cli/repl/parser/slice-query-parser.js +45 -16
- package/cli/repl/print-version.d.ts +2 -4
- package/cli/repl/print-version.js +41 -23
- package/cli/repl/server/connection.js +19 -17
- package/cli/slicer-app.d.ts +2 -0
- package/cli/slicer-app.js +3 -3
- package/cli/wiki.d.ts +2 -2
- package/cli/wiki.js +2 -2
- package/config.d.ts +63 -2
- package/config.js +64 -8
- package/control-flow/cfg-dead-code.js +0 -1
- package/control-flow/control-flow-graph.js +6 -6
- package/control-flow/diff-cfg.js +2 -2
- package/control-flow/semantic-cfg-guided-visitor.js +2 -0
- package/core/print/slice-diff-ansi.js +8 -8
- package/core/steps/all/core/20-dataflow.d.ts +2 -2
- package/core/steps/all/static-slicing/00-slice.d.ts +5 -0
- package/core/steps/all/static-slicing/00-slice.js +1 -1
- package/core/steps/all/static-slicing/10-reconstruct.d.ts +7 -0
- package/core/steps/all/static-slicing/10-reconstruct.js +6 -2
- package/core/steps/pipeline/default-pipelines.d.ts +20 -16
- package/data/r-base-packages.generated.d.ts +44 -0
- package/data/r-base-packages.generated.js +32 -0
- package/data/r-base-primitives.generated.d.ts +1 -0
- package/data/r-base-primitives.generated.js +15 -0
- package/data/sigdb/sigdb.remote.json +112 -0
- package/dataflow/environments/built-in-proc-name.d.ts +4 -0
- package/dataflow/environments/built-in-proc-name.js +4 -0
- package/dataflow/environments/built-in.d.ts +14 -4
- package/dataflow/environments/built-in.js +13 -2
- package/dataflow/environments/data-masking-functions.d.ts +12 -0
- package/dataflow/environments/data-masking-functions.js +46 -0
- package/dataflow/environments/default-builtin-config.d.ts +72 -19
- package/dataflow/environments/default-builtin-config.js +48 -14
- package/dataflow/environments/diff.js +1 -1
- package/dataflow/environments/environment.js +1 -2
- package/dataflow/environments/identifier.d.ts +11 -4
- package/dataflow/environments/identifier.js +28 -10
- package/dataflow/environments/resolve-by-name.js +16 -2
- package/dataflow/extractor.js +6 -3
- package/dataflow/graph/call-graph.d.ts +2 -2
- package/dataflow/graph/df-helper.d.ts +4 -4
- package/dataflow/graph/diff-dataflow-graph.js +2 -2
- package/dataflow/graph/edge.d.ts +3 -3
- package/dataflow/graph/edge.js +3 -3
- package/dataflow/graph/graph-helper.d.ts +2 -2
- package/dataflow/internal/linker.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +7 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +20 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +1 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +2 -49
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +6 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +7 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +19 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +111 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +13 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +2 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +9 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +19 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +12 -4
- package/dataflow/internal/process/functions/call/common.js +8 -1
- package/dataflow/internal/process/functions/call/default-call-handling.js +6 -0
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +17 -0
- package/dataflow/internal/process/functions/call/known-call-handling.js +32 -0
- package/dataflow/internal/process/functions/call/named-call-handling.js +29 -7
- package/dataflow/internal/process/functions/process-argument.js +12 -1
- package/dataflow/internal/process/process-named-call.d.ts +18 -1
- package/dataflow/internal/process/process-named-call.js +94 -0
- package/dataflow/processor.d.ts +18 -0
- package/documentation/data/faq/faqs.js +5 -1
- package/documentation/doc-capabilities.js +1 -1
- package/documentation/doc-util/doc-cli-option.d.ts +10 -0
- package/documentation/doc-util/doc-cli-option.js +23 -0
- package/documentation/doc-util/doc-dfg.js +2 -1
- package/documentation/doc-util/doc-query.d.ts +9 -3
- package/documentation/doc-util/doc-query.js +9 -4
- package/documentation/wiki-dataflow-graph.js +8 -5
- package/documentation/wiki-interface.js +4 -2
- package/documentation/wiki-linter.js +1 -1
- package/documentation/wiki-linting-and-testing.js +4 -1
- package/documentation/wiki-mk/doc-context.d.ts +14 -0
- package/documentation/wiki-mk/doc-context.js +3 -0
- package/documentation/wiki-mk/doc-maker.js +3 -1
- package/documentation/wiki-query.js +36 -15
- package/documentation/wiki-setup.js +10 -7
- package/documentation/wiki-signature-database.d.ts +16 -0
- package/documentation/wiki-signature-database.js +293 -0
- package/linter/linter-format.d.ts +7 -0
- package/linter/linter-rules.d.ts +10 -9
- package/linter/rules/naming-convention.d.ts +1 -0
- package/linter/rules/naming-convention.js +2 -0
- package/linter/rules/no-leaked-credentials.js +1 -2
- package/linter/rules/roxygen-arguments.js +18 -5
- package/linter/rules/stop-with-call-arg.js +2 -2
- package/linter/rules/undefined-symbol-util.d.ts +36 -0
- package/linter/rules/undefined-symbol-util.js +149 -0
- package/linter/rules/undefined-symbol.d.ts +58 -17
- package/linter/rules/undefined-symbol.js +143 -33
- package/linter/rules/unused-definition.d.ts +8 -1
- package/linter/rules/unused-definition.js +126 -1
- package/package.json +22 -10
- package/project/context/abstract-flowr-analyzer-context.js +7 -1
- package/project/context/flowr-analyzer-context.d.ts +8 -0
- package/project/context/flowr-analyzer-context.js +10 -0
- package/project/context/flowr-analyzer-dependencies-context.d.ts +28 -4
- package/project/context/flowr-analyzer-dependencies-context.js +51 -2
- package/project/context/flowr-analyzer-files-context.d.ts +1 -0
- package/project/context/flowr-analyzer-files-context.js +2 -1
- package/project/context/flowr-analyzer-functions-context.js +1 -1
- package/project/context/flowr-file.d.ts +5 -0
- package/project/context/flowr-file.js +5 -0
- package/project/flowr-analyzer-builder.js +12 -2
- package/project/plugins/file-plugins/files/flowr-description-file.js +6 -3
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +9 -3
- package/project/plugins/file-plugins/files/flowr-news-file.js +1 -3
- package/project/plugins/file-plugins/flowr-analyzer-inst-file-plugin.d.ts +26 -0
- package/project/plugins/file-plugins/flowr-analyzer-inst-file-plugin.js +39 -0
- 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.js +2 -2
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-namespace-file-plugin.js +1 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.d.ts +18 -2
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.js +19 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +120 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +518 -0
- package/project/plugins/package-version-plugins/package.d.ts +5 -3
- package/project/plugins/package-version-plugins/package.js +27 -25
- package/project/plugins/plugin-registry.d.ts +3 -2
- package/project/plugins/plugin-registry.js +4 -2
- package/project/plugins/project-discovery/flowr-analyzer-gitignore-project-discovery-plugin.js +7 -2
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +3 -1
- package/project/sigdb/build.d.ts +131 -0
- package/project/sigdb/build.js +628 -0
- package/project/sigdb/codec.d.ts +51 -0
- package/project/sigdb/codec.js +122 -0
- package/project/sigdb/decode.d.ts +58 -0
- package/project/sigdb/decode.js +129 -0
- package/project/sigdb/decompress.d.ts +44 -0
- package/project/sigdb/decompress.js +176 -0
- package/project/sigdb/hash.d.ts +9 -0
- package/project/sigdb/hash.js +54 -0
- package/project/sigdb/index-format.d.ts +40 -0
- package/project/sigdb/index-format.js +28 -0
- package/project/sigdb/manifest.d.ts +68 -0
- package/project/sigdb/manifest.js +146 -0
- package/project/sigdb/reader.d.ts +250 -0
- package/project/sigdb/reader.js +692 -0
- package/project/sigdb/schema.d.ts +196 -0
- package/project/sigdb/schema.js +33 -0
- package/project/sigdb/sigdb-download.d.ts +65 -0
- package/project/sigdb/sigdb-download.js +237 -0
- package/project/sigdb/signature-match.d.ts +26 -0
- package/project/sigdb/signature-match.js +40 -0
- package/project/sigdb/version.d.ts +20 -0
- package/project/sigdb/version.js +55 -0
- package/queries/catalog/absint-query/absint-query-executor.d.ts +6 -0
- package/queries/catalog/absint-query/absint-query-executor.js +63 -0
- package/queries/catalog/absint-query/absint-query-format.d.ts +37 -0
- package/queries/catalog/absint-query/absint-query-format.js +102 -0
- package/queries/catalog/call-context-query/call-context-query-executor.js +1 -3
- package/queries/catalog/config-query/config-query-format.d.ts +3 -1
- package/queries/catalog/config-query/config-query-format.js +68 -9
- package/queries/catalog/dataflow-query/dataflow-query-format.js +11 -1
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +1 -1
- package/queries/catalog/linter-query/linter-query-executor.d.ts +2 -0
- package/queries/catalog/linter-query/linter-query-executor.js +6 -1
- package/queries/catalog/linter-query/linter-query-format.d.ts +2 -1
- package/queries/catalog/linter-query/linter-query-format.js +40 -8
- package/queries/catalog/project-query/project-query-executor.d.ts +15 -0
- package/queries/catalog/project-query/project-query-executor.js +96 -4
- package/queries/catalog/project-query/project-query-format.d.ts +44 -0
- package/queries/catalog/project-query/project-query-format.js +33 -2
- package/queries/catalog/signature-query/signature-query-executor.d.ts +29 -0
- package/queries/catalog/signature-query/signature-query-executor.js +461 -0
- package/queries/catalog/signature-query/signature-query-format.d.ts +138 -0
- package/queries/catalog/signature-query/signature-query-format.js +76 -0
- package/queries/catalog/signature-query/signature-query-render.d.ts +15 -0
- package/queries/catalog/signature-query/signature-query-render.js +155 -0
- package/queries/catalog/static-slice-query/static-slice-query-executor.js +9 -3
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +10 -0
- package/queries/catalog/static-slice-query/static-slice-query-format.js +19 -1
- package/queries/query-print.js +5 -0
- package/queries/query.d.ts +15 -5
- package/queries/query.js +7 -4
- package/r-bridge/init.js +5 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +10 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +55 -0
- package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +16 -0
- package/r-bridge/lang-4.x/ast/model/processing/node-id.js +27 -0
- package/r-bridge/lang-4.x/ast/parser/json/format.js +89 -2
- package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-expressions.js +2 -4
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +2 -1
- package/r-bridge/parser.d.ts +2 -0
- package/r-bridge/retriever.js +4 -1
- package/r-bridge/roxygen2/documentation-provider.js +2 -1
- package/r-bridge/shell.d.ts +5 -0
- package/r-bridge/shell.js +17 -1
- package/reconstruct/inline/source-inline-map.d.ts +48 -0
- package/reconstruct/inline/source-inline-map.js +94 -0
- package/reconstruct/reconstruct.d.ts +19 -2
- package/reconstruct/reconstruct.js +79 -16
- package/search/search-executor/search-generators.js +5 -22
- package/search/search-executor/search-transformer.js +10 -6
- package/slicing/criterion/parse.d.ts +28 -4
- package/slicing/criterion/parse.js +133 -18
- package/slicing/static/slice-call.d.ts +24 -1
- package/slicing/static/slice-call.js +90 -0
- package/slicing/static/static-slicer.d.ts +7 -0
- package/slicing/static/static-slicer.js +38 -3
- package/util/collections/arrays.d.ts +4 -5
- package/util/collections/arrays.js +7 -18
- package/util/hash.d.ts +14 -0
- package/util/hash.js +31 -0
- package/util/mermaid/dfg.d.ts +7 -2
- package/util/mermaid/dfg.js +53 -13
- package/util/r-base-packages.d.ts +19 -0
- package/util/r-base-packages.js +72 -0
- package/util/r-license.js +2 -10
- package/util/r-version.d.ts +45 -15
- package/util/r-version.js +97 -36
- package/util/range.d.ts +15 -0
- package/util/range.js +39 -0
- package/util/schema.d.ts +10 -0
- package/util/schema.js +22 -0
- package/util/text/ansi.d.ts +3 -0
- package/util/text/ansi.js +10 -0
- package/util/text/args.js +1 -2
- package/util/version.js +28 -8
- package/data/pkgdb/pkgdb-latest.json.br +0 -0
- package/data/pkgdb/pkgdb-tiny.json.br +0 -0
- package/documentation/wiki-package-database.d.ts +0 -9
- package/documentation/wiki-package-database.js +0 -63
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin.d.ts +0 -63
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin.js +0 -176
- package/project/plugins/package-version-plugins/pkgdb.d.ts +0 -133
- package/project/plugins/package-version-plugins/pkgdb.js +0 -370
- package/queries/catalog/df-shape-query/df-shape-query-executor.d.ts +0 -6
- package/queries/catalog/df-shape-query/df-shape-query-executor.js +0 -58
- package/queries/catalog/df-shape-query/df-shape-query-format.d.ts +0 -27
- package/queries/catalog/df-shape-query/df-shape-query-format.js +0 -56
|
@@ -9,6 +9,121 @@ const assert_1 = require("../../util/assert");
|
|
|
9
9
|
const vertex_1 = require("../../dataflow/graph/vertex");
|
|
10
10
|
const edge_1 = require("../../dataflow/graph/edge");
|
|
11
11
|
const flowr_search_filters_1 = require("../../search/flowr-search-filters");
|
|
12
|
+
const flowr_file_1 = require("../../project/context/flowr-file");
|
|
13
|
+
const flowr_namespace_file_1 = require("../../project/plugins/file-plugins/files/flowr-namespace-file");
|
|
14
|
+
const identifier_1 = require("../../dataflow/environments/identifier");
|
|
15
|
+
const retriever_1 = require("../../r-bridge/retriever");
|
|
16
|
+
const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
17
|
+
const r_function_definition_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
|
|
18
|
+
/**
|
|
19
|
+
* The dots parameter is a special parameter and must never be reported as an unused definition.
|
|
20
|
+
*/
|
|
21
|
+
const DotsParameter = '...';
|
|
22
|
+
/**
|
|
23
|
+
* Common base/standard-library S3 generics. A definition named `generic.class` where `generic` is one of these
|
|
24
|
+
* is an S3 method dispatched indirectly (e.g. `print(x)` on an object of class `class`), so it is used even
|
|
25
|
+
* without a direct textual call.
|
|
26
|
+
*/
|
|
27
|
+
const KnownS3Generics = new Set([
|
|
28
|
+
'print', 'format', 'summary', 'plot', 'coef', 'vcov', 'residuals', 'fitted', 'predict',
|
|
29
|
+
'as.character', 'as.data.frame', 'as.list', 'as.matrix', 'as.vector', 'as.numeric',
|
|
30
|
+
'length', 'dim', 'dimnames', 'names', 'str', 'toString', 'all.equal', 'aggregate',
|
|
31
|
+
'update', 'anova', 'confint', 'logLik', 'AIC', 'BIC', 'deviance', 'df.residual',
|
|
32
|
+
'model.matrix', 'terms', 'weights', 'simulate', 'lines', 'points', 'head', 'tail',
|
|
33
|
+
'merge', 'rbind', 'cbind', 'split', 'window', 'subset', 'sort', 'rev', 'unique',
|
|
34
|
+
'mean', 'median', 'quantile', 'range', 'diff', 't'
|
|
35
|
+
]);
|
|
36
|
+
/**
|
|
37
|
+
* R package lifecycle hooks called automatically by R's package machinery.
|
|
38
|
+
* These functions are invoked by the package system, so they are used even without textual callers.
|
|
39
|
+
*/
|
|
40
|
+
const PackageHookFunctions = new Set([
|
|
41
|
+
'.onLoad', '.onAttach', '.onUnload', '.onDetach', '.Last.lib', '.First.lib'
|
|
42
|
+
]);
|
|
43
|
+
/** Gathers the analyzed project's own `NAMESPACE` exports and declared S3 generics (empty when it is not a package). */
|
|
44
|
+
function collectPackageInfo(data) {
|
|
45
|
+
const exported = new Set();
|
|
46
|
+
const s3Generics = new Set();
|
|
47
|
+
for (const ns of data.inspectContext().files.getFilesByRole(flowr_file_1.FileRole.Namespace)) {
|
|
48
|
+
const info = ns.content().current;
|
|
49
|
+
for (const name of (0, flowr_namespace_file_1.getExportedNames)(info)) {
|
|
50
|
+
exported.add(name);
|
|
51
|
+
}
|
|
52
|
+
for (const generic of info.exportS3Generics.keys()) {
|
|
53
|
+
s3Generics.add(generic);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return { exported, s3Generics };
|
|
57
|
+
}
|
|
58
|
+
/** Collects the names of every function call in the graph, so we can tell whether an S3 generic is dispatched anywhere. */
|
|
59
|
+
function collectCalledNames(dfg) {
|
|
60
|
+
const names = new Set();
|
|
61
|
+
for (const [, vertex] of dfg.verticesOfType(vertex_1.VertexType.FunctionCall)) {
|
|
62
|
+
names.add(identifier_1.Identifier.getName(vertex.name));
|
|
63
|
+
}
|
|
64
|
+
return names;
|
|
65
|
+
}
|
|
66
|
+
/** Checks if a function body is a single call to UseMethod. */
|
|
67
|
+
function isUseMethodOnlyBody(node) {
|
|
68
|
+
// Direct call to UseMethod
|
|
69
|
+
if (r_function_call_1.RFunctionCall.isNamed(node) && identifier_1.Identifier.getName(node.functionName.content) === 'UseMethod') {
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
const nodeWithChildren = node;
|
|
73
|
+
if (Array.isArray(nodeWithChildren.children) && nodeWithChildren.children.length === 1) {
|
|
74
|
+
const child = nodeWithChildren.children[0];
|
|
75
|
+
if (child && r_function_call_1.RFunctionCall.isNamed(child) && identifier_1.Identifier.getName(child.functionName.content) === 'UseMethod') {
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
/** Collects the parameter IDs of S3 generic functions (functions whose body is just UseMethod). */
|
|
82
|
+
function collectS3GenericParameterIds(ast) {
|
|
83
|
+
const paramIds = new Set();
|
|
84
|
+
for (const [, node] of ast.idMap) {
|
|
85
|
+
if (!r_function_definition_1.RFunctionDefinition.is(node)) {
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
if (isUseMethodOnlyBody(node.body)) {
|
|
89
|
+
for (const param of node.parameters) {
|
|
90
|
+
paramIds.add(param.name.info.id);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return paramIds;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* A definition is treated as used (and hence not reported) if it is the dots parameter, a package lifecycle hook,
|
|
98
|
+
* an S3 method for a dispatched generic, or - when {@link UnusedDefinitionConfig#excludeExportedDefinitions} is set -
|
|
99
|
+
* a package export.
|
|
100
|
+
*/
|
|
101
|
+
function isConsideredUsed(lexeme, config, pkg, called) {
|
|
102
|
+
if (lexeme === undefined) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
// non-syntactic definition names (e.g. S3 methods like `"[.irts"`) carry their R quotes in the lexeme
|
|
106
|
+
const name = (0, retriever_1.removeRQuotes)(lexeme);
|
|
107
|
+
// the dots are a special parameter and must never be reported
|
|
108
|
+
if (name === DotsParameter) {
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
// package lifecycle hooks are called by R's package machinery
|
|
112
|
+
if (PackageHookFunctions.has(name)) {
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
const dot = name.indexOf('.');
|
|
116
|
+
if (dot > 0) {
|
|
117
|
+
const generic = name.slice(0, dot);
|
|
118
|
+
if (KnownS3Generics.has(generic) || pkg.s3Generics.has(generic) || called.has(generic)) {
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (config.excludeExportedDefinitions && pkg.exported.has(name)) {
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
12
127
|
const InterestingEdgesVariable = edge_1.EdgeType.Reads | edge_1.EdgeType.Calls | edge_1.EdgeType.DefinesOnCall;
|
|
13
128
|
const InterestingEdgesFunction = edge_1.EdgeType.Reads | edge_1.EdgeType.Calls; // include read as this could print the function definition
|
|
14
129
|
const InterestingEdgesTargets = edge_1.EdgeType.SideEffectOnCall;
|
|
@@ -62,6 +177,9 @@ exports.UNUSED_DEFINITION = {
|
|
|
62
177
|
processSearchResult: async (elements, config, data) => {
|
|
63
178
|
const normalize = await data.normalize();
|
|
64
179
|
const dataflow = await data.dataflow();
|
|
180
|
+
const packageInfo = collectPackageInfo(data);
|
|
181
|
+
const calledNames = collectCalledNames(dataflow.graph);
|
|
182
|
+
const s3GenericParams = collectS3GenericParameterIds(normalize);
|
|
65
183
|
const metadata = {
|
|
66
184
|
totalConsidered: 0
|
|
67
185
|
};
|
|
@@ -73,6 +191,12 @@ exports.UNUSED_DEFINITION = {
|
|
|
73
191
|
&& (0, vertex_1.isFunctionDefinitionVertex)(dfgVertex) && !config.includeFunctionDefinitions)) {
|
|
74
192
|
return undefined;
|
|
75
193
|
}
|
|
194
|
+
if (s3GenericParams.has(element.node.info.id)) {
|
|
195
|
+
return undefined;
|
|
196
|
+
}
|
|
197
|
+
if (isConsideredUsed(element.node.lexeme, config, packageInfo, calledNames)) {
|
|
198
|
+
return undefined;
|
|
199
|
+
}
|
|
76
200
|
const ingoingEdges = dataflow.graph.ingoingEdges(dfgVertex.id);
|
|
77
201
|
const interestedIn = (0, vertex_1.isVariableDefinitionVertex)(dfgVertex) ? InterestingEdgesVariable : InterestingEdgesFunction;
|
|
78
202
|
const ingoingInteresting = ingoingEdges?.values().some(e => edge_1.DfEdge.includesType(e, interestedIn));
|
|
@@ -103,7 +227,8 @@ exports.UNUSED_DEFINITION = {
|
|
|
103
227
|
// our limited analysis causes unused definitions involving complex reflection etc. not to be included in our result, but unused definitions are correctly validated
|
|
104
228
|
certainty: linter_format_1.LintingRuleCertainty.BestEffort,
|
|
105
229
|
defaultConfig: {
|
|
106
|
-
includeFunctionDefinitions: true
|
|
230
|
+
includeFunctionDefinitions: true,
|
|
231
|
+
excludeExportedDefinitions: true
|
|
107
232
|
}
|
|
108
233
|
}
|
|
109
234
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eagleoutice/flowr",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.12.1",
|
|
4
4
|
"description": "Static Dataflow Analyzer and Program Slicer for the R Programming Language",
|
|
5
5
|
"types": "dist/src/index.d.ts",
|
|
6
6
|
"repository": {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"setup:dev": "git lfs fetch && npm ci && git config --local core.hooksPath .githooks/ && git push --dry-run",
|
|
16
16
|
"main": "npm run build:bundle-flowr && node dist/src/cli/flowr.min.js",
|
|
17
17
|
"flowr": "npm run main --",
|
|
18
|
-
"flowr:dev": "npm run main-dev --",
|
|
18
|
+
"flowr:dev": "npm run gen:base-packages && npm run main-dev --",
|
|
19
19
|
"main-dev": "node -r ts-node/register --watch src/cli/flowr.ts",
|
|
20
20
|
"publish-library": "cp .npmignore package.json README.md LICENSE dist/src/ && cd dist/src && npm publish --access public",
|
|
21
21
|
"release": "npx release-it --ci",
|
|
@@ -27,8 +27,11 @@
|
|
|
27
27
|
"capabilities-markdown": "ts-node src/documentation/doc-capabilities.ts",
|
|
28
28
|
"wiki": "ts-node src/cli/wiki.ts",
|
|
29
29
|
"wiki:watch": "node -r ts-node/register --watch src/cli/wiki.ts --keep-alive",
|
|
30
|
-
"build": "tsc --project . && npm run build:copy-data",
|
|
31
|
-
"
|
|
30
|
+
"build": "npm run gen:base-packages && tsc --project . && npm run build:copy-data",
|
|
31
|
+
"gen:base-packages": "ts-node --transpile-only scripts/gen-base-packages.ts",
|
|
32
|
+
"sync:sigdb": "ts-node --transpile-only scripts/sigdb-remote.ts",
|
|
33
|
+
"publish:sigdb": "ts-node scripts/publish-sigdb.ts",
|
|
34
|
+
"build:copy-data": "npm run sync:sigdb && ts-node --transpile-only scripts/sigdb-copy.ts",
|
|
32
35
|
"build-dev": "npm run build && npm run build:copy-wasm",
|
|
33
36
|
"build:bundle-flowr": "npm run build && esbuild --bundle dist/src/cli/flowr.js --platform=node --tree-shaking=true --minify --external:clipboardy --target=node22 --outfile=dist/src/cli/flowr.min.js && npm run build:copy-wasm",
|
|
34
37
|
"build:copy-wasm": "mkdir -p dist/node_modules/@davisvaughan/tree-sitter-r/ && mkdir -p dist/node_modules/web-tree-sitter && cp node_modules/@davisvaughan/tree-sitter-r/tree-sitter-r.wasm dist/node_modules/@davisvaughan/tree-sitter-r/ && cp node_modules/web-tree-sitter/tree-sitter.wasm dist/node_modules/web-tree-sitter/",
|
|
@@ -47,7 +50,7 @@
|
|
|
47
50
|
"test:performance": "npm run performance-test --",
|
|
48
51
|
"test:docker": "func() { for df in scripts/Dockerfile scripts/Dockerfile-NoR; do echo \"=== building $df ===\"; docker build -t flowr-docker-test -f \"$df\" . || return 1; echo \"=== smoke-testing $df ===\"; docker run --rm flowr-docker-test --version || return 1; done; }; func",
|
|
49
52
|
"detect-circular-deps": "npx madge --extensions ts,tsx --circular src/",
|
|
50
|
-
"checkup": "
|
|
53
|
+
"checkup": "ts-node scripts/checkup-parallel.ts"
|
|
51
54
|
},
|
|
52
55
|
"keywords": [
|
|
53
56
|
"static code analysis",
|
|
@@ -158,11 +161,19 @@
|
|
|
158
161
|
},
|
|
159
162
|
"plugins": {
|
|
160
163
|
"@j-ulrich/release-it-regex-bumper": {
|
|
161
|
-
"out":
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
164
|
+
"out": [
|
|
165
|
+
{
|
|
166
|
+
"file": "src/util/version.ts",
|
|
167
|
+
"search": "const version = '[\\d.]+'",
|
|
168
|
+
"replace": "const version = '{{version}}'"
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
"file": "src/util/version.ts",
|
|
172
|
+
"search": "const versionDate = '[\\d-]+'",
|
|
173
|
+
"replace": "const versionDate = '{{now}}'",
|
|
174
|
+
"dateFormat": "yyyy-MM-dd"
|
|
175
|
+
}
|
|
176
|
+
]
|
|
166
177
|
}
|
|
167
178
|
}
|
|
168
179
|
},
|
|
@@ -209,6 +220,7 @@
|
|
|
209
220
|
"commonmark": "^0.31.2",
|
|
210
221
|
"dagre": "^0.8.5",
|
|
211
222
|
"gray-matter": "^4.0.3",
|
|
223
|
+
"ignore": "^5.3.2",
|
|
212
224
|
"joi": "^18.0.1",
|
|
213
225
|
"lz-string": "^1.5.0",
|
|
214
226
|
"n-readlines": "^3.4.1",
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AbstractFlowrAnalyzerContext = void 0;
|
|
4
4
|
const assert_1 = require("../../util/assert");
|
|
5
|
+
const log_1 = require("../../util/log");
|
|
5
6
|
/**
|
|
6
7
|
* Abstract class representing the context, a context may be modified and enriched by plugins (see {@link FlowrAnalyzerPlugin}).
|
|
7
8
|
*
|
|
@@ -31,7 +32,12 @@ class AbstractFlowrAnalyzerContext {
|
|
|
31
32
|
applyPlugins(args) {
|
|
32
33
|
const res = [];
|
|
33
34
|
for (const plugin of this.plugins) {
|
|
34
|
-
|
|
35
|
+
try {
|
|
36
|
+
res.push(plugin.processor(this.ctx, args));
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
log_1.log.warn(`Plugin ${plugin.name} fail in ctx ${this.name}: ${e instanceof Error ? e.message : String(e)}`);
|
|
40
|
+
}
|
|
35
41
|
}
|
|
36
42
|
return res.filter(assert_1.isNotUndefined);
|
|
37
43
|
}
|
|
@@ -26,6 +26,8 @@ export interface ReadOnlyFlowrAnalyzerContext {
|
|
|
26
26
|
readonly env: ReadOnlyFlowrAnalyzerEnvironmentContext;
|
|
27
27
|
/** The configuration options used by the analyzer. */
|
|
28
28
|
readonly config: FlowrConfig;
|
|
29
|
+
/** The R version analysis assumes when resolving versioned (base-R) exports (see `solver.sigdb.assumedRVersion`). */
|
|
30
|
+
readonly resolvedRVersion: string;
|
|
29
31
|
/**
|
|
30
32
|
* Resource-usage guard (gas).
|
|
31
33
|
* Call `ctx.gas.checkGas(key)` at expensive analysis sites to obtain the current pressure level.
|
|
@@ -52,6 +54,8 @@ export declare class FlowrAnalyzerContext implements ReadOnlyFlowrAnalyzerContex
|
|
|
52
54
|
readonly env: FlowrAnalyzerEnvironmentContext;
|
|
53
55
|
readonly gas: FlowrAnalyzerGasContext;
|
|
54
56
|
private _analyzer;
|
|
57
|
+
/** an auto-detected R version (from the engine), recorded once at the analyzer boundary; see {@link resolvedRVersion} */
|
|
58
|
+
private _detectedR;
|
|
55
59
|
readonly config: FlowrConfig;
|
|
56
60
|
constructor(config: FlowrConfig, plugins: ReadonlyMap<PluginType, readonly FlowrAnalyzerPlugin[]>);
|
|
57
61
|
/**
|
|
@@ -61,6 +65,10 @@ export declare class FlowrAnalyzerContext implements ReadOnlyFlowrAnalyzerContex
|
|
|
61
65
|
*/
|
|
62
66
|
get analyzer(): FlowrAnalyzer | undefined;
|
|
63
67
|
setAnalyzer(analyzer: FlowrAnalyzer): void;
|
|
68
|
+
/** Record the engine's auto-detected R version (used when `solver.sigdb.assumedRVersion` is `"auto"`). */
|
|
69
|
+
setDetectedRVersion(version: string): void;
|
|
70
|
+
/** The R version analysis assumes when resolving versioned (base-R) exports (see {@link resolveAssumedRVersion}). */
|
|
71
|
+
get resolvedRVersion(): string;
|
|
64
72
|
/** delegate request addition */
|
|
65
73
|
addRequests(requests: readonly RAnalysisRequest[]): void;
|
|
66
74
|
addFile(f: string | FlowrFileProvider | RParseRequestFromFile): void;
|
|
@@ -33,6 +33,8 @@ class FlowrAnalyzerContext {
|
|
|
33
33
|
env;
|
|
34
34
|
gas;
|
|
35
35
|
_analyzer;
|
|
36
|
+
/** an auto-detected R version (from the engine), recorded once at the analyzer boundary; see {@link resolvedRVersion} */
|
|
37
|
+
_detectedR;
|
|
36
38
|
config;
|
|
37
39
|
constructor(config, plugins) {
|
|
38
40
|
this.config = config;
|
|
@@ -55,6 +57,14 @@ class FlowrAnalyzerContext {
|
|
|
55
57
|
setAnalyzer(analyzer) {
|
|
56
58
|
this._analyzer = analyzer;
|
|
57
59
|
}
|
|
60
|
+
/** Record the engine's auto-detected R version (used when `solver.sigdb.assumedRVersion` is `"auto"`). */
|
|
61
|
+
setDetectedRVersion(version) {
|
|
62
|
+
this._detectedR = version;
|
|
63
|
+
}
|
|
64
|
+
/** The R version analysis assumes when resolving versioned (base-R) exports (see {@link resolveAssumedRVersion}). */
|
|
65
|
+
get resolvedRVersion() {
|
|
66
|
+
return (0, config_1.resolveAssumedRVersion)(this.config, this._detectedR);
|
|
67
|
+
}
|
|
58
68
|
/** delegate request addition */
|
|
59
69
|
addRequests(requests) {
|
|
60
70
|
this.files.addRequests(requests);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AbstractFlowrAnalyzerContext } from './abstract-flowr-analyzer-context';
|
|
2
|
-
import { FlowrAnalyzerPackageVersionsPlugin, type
|
|
2
|
+
import { FlowrAnalyzerPackageVersionsPlugin, type SigDbLoadedInfo } from '../plugins/package-version-plugins/flowr-analyzer-package-versions-plugin';
|
|
3
3
|
import type { Package } from '../plugins/package-version-plugins/package';
|
|
4
|
+
import type { PackageSignatureSource } from '../sigdb/reader';
|
|
4
5
|
import type { FlowrAnalyzerFunctionsContext, ReadOnlyFlowrAnalyzerFunctionsContext } from './flowr-analyzer-functions-context';
|
|
5
6
|
/**
|
|
6
7
|
* Read-only interface to the {@link FlowrAnalyzerDependenciesContext} for inspecting dependencies without modifying them.
|
|
@@ -29,7 +30,15 @@ export interface ReadOnlyFlowrAnalyzerDependenciesContext {
|
|
|
29
30
|
/**
|
|
30
31
|
* Metadata of the package databases the version plugins currently have loaded.
|
|
31
32
|
*/
|
|
32
|
-
loadedPackageDatabases():
|
|
33
|
+
loadedPackageDatabases(): SigDbLoadedInfo[];
|
|
34
|
+
/**
|
|
35
|
+
* The names of known packages that export `name` (from the version plugins' package databases). Used to
|
|
36
|
+
* hint which `library()`/`::` might be missing for an otherwise-undefined symbol. Empty if no database is
|
|
37
|
+
* available or the package db is disabled.
|
|
38
|
+
*/
|
|
39
|
+
packagesExporting(name: string): readonly string[];
|
|
40
|
+
/** The signature sources the version plugins currently have loaded (backs the signature query). */
|
|
41
|
+
signatureSources(): readonly PackageSignatureSource[];
|
|
33
42
|
}
|
|
34
43
|
/**
|
|
35
44
|
* Manages the project's dependencies, their versions, and their interplay with {@link FlowrAnalyzerPackageVersionsPlugin}s.
|
|
@@ -45,11 +54,26 @@ export declare class FlowrAnalyzerDependenciesContext extends AbstractFlowrAnaly
|
|
|
45
54
|
reset(): void;
|
|
46
55
|
/** Register a resolver consulted by {@link getDependency} to fill in a package's exports lazily. */
|
|
47
56
|
addLazyResolver(resolver: (name: string, existing?: Package) => Package | undefined): void;
|
|
48
|
-
loadedPackageDatabases():
|
|
49
|
-
|
|
57
|
+
loadedPackageDatabases(): SigDbLoadedInfo[];
|
|
58
|
+
packagesExporting(name: string): readonly string[];
|
|
59
|
+
signatureSources(): readonly PackageSignatureSource[];
|
|
60
|
+
/** Whether any version plugin can resolve the base-R packages (a versioned signature source is available). */
|
|
61
|
+
hasBaseRSource(): boolean;
|
|
62
|
+
/** Cheap fingerprint of only the base-R-providing databases, so base-R-derived caches survive unrelated database changes. */
|
|
63
|
+
baseRSourceFingerprint(): string;
|
|
64
|
+
/** Mount an additional signature database/source by path (a plain `.sigs.ndjson`, a `.br`, or a manifest). */
|
|
65
|
+
addDatabaseSource(source: string): Promise<void>;
|
|
66
|
+
/** Eagerly mount every version plugin's package database up front (see `solver.sigdb.eagerlyLoad`). */
|
|
50
67
|
eagerlyLoadPackageDatabases(): void;
|
|
51
68
|
constructor(functionsContext: FlowrAnalyzerFunctionsContext, plugins?: readonly FlowrAnalyzerPackageVersionsPlugin[]);
|
|
52
69
|
resolveStaticDependencies(): void;
|
|
70
|
+
/**
|
|
71
|
+
* Register a dependency declared by a project metadata file (`DESCRIPTION`, `renv.lock`, `rv.lock`). Gated by
|
|
72
|
+
* `solver.sigdb.loadProjectDependencies`: when project-dependency loading is disabled this is a no-op, so the
|
|
73
|
+
* declared deps never enter the context (unlike {@link addDependency}, used for on-demand signature-database
|
|
74
|
+
* resolution).
|
|
75
|
+
*/
|
|
76
|
+
addDeclaredDependency(pkg: Package): this;
|
|
53
77
|
addDependency(pkg: Package): this;
|
|
54
78
|
getDependency(name: string): Package | undefined;
|
|
55
79
|
getDependencies(): Package[];
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.FlowrAnalyzerDependenciesContext = void 0;
|
|
4
4
|
const abstract_flowr_analyzer_context_1 = require("./abstract-flowr-analyzer-context");
|
|
5
5
|
const flowr_analyzer_package_versions_plugin_1 = require("../plugins/package-version-plugins/flowr-analyzer-package-versions-plugin");
|
|
6
|
+
const config_1 = require("../../config");
|
|
6
7
|
/**
|
|
7
8
|
* Manages the project's dependencies, their versions, and their interplay with {@link FlowrAnalyzerPackageVersionsPlugin}s.
|
|
8
9
|
*/
|
|
@@ -25,12 +26,48 @@ class FlowrAnalyzerDependenciesContext extends abstract_flowr_analyzer_context_1
|
|
|
25
26
|
this.lazyResolvers.push(resolver);
|
|
26
27
|
}
|
|
27
28
|
loadedPackageDatabases() {
|
|
28
|
-
if (!this.ctx.config
|
|
29
|
+
if (!(0, config_1.isSigDbEnabled)(this.ctx.config)) {
|
|
29
30
|
return [];
|
|
30
31
|
}
|
|
31
32
|
return this.plugins.flatMap(p => p.loadedDatabases());
|
|
32
33
|
}
|
|
33
|
-
|
|
34
|
+
packagesExporting(name) {
|
|
35
|
+
if (!(0, config_1.isSigDbEnabled)(this.ctx.config)) {
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
const out = new Set();
|
|
39
|
+
for (const p of this.plugins) {
|
|
40
|
+
for (const pkg of p.packagesExporting(name)) {
|
|
41
|
+
out.add(pkg);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return [...out];
|
|
45
|
+
}
|
|
46
|
+
signatureSources() {
|
|
47
|
+
if (!(0, config_1.isSigDbEnabled)(this.ctx.config)) {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
return this.plugins.flatMap(p => [...p.signatureSources(this.ctx.config)]);
|
|
51
|
+
}
|
|
52
|
+
/** Whether any version plugin can resolve the base-R packages (a versioned signature source is available). */
|
|
53
|
+
hasBaseRSource() {
|
|
54
|
+
return (0, config_1.isSigDbEnabled)(this.ctx.config) && this.plugins.some(p => p.providesBaseRPackages());
|
|
55
|
+
}
|
|
56
|
+
/** Cheap fingerprint of only the base-R-providing databases, so base-R-derived caches survive unrelated database changes. */
|
|
57
|
+
baseRSourceFingerprint() {
|
|
58
|
+
if (!(0, config_1.isSigDbEnabled)(this.ctx.config)) {
|
|
59
|
+
return '';
|
|
60
|
+
}
|
|
61
|
+
return this.plugins.filter(p => p.providesBaseRPackages())
|
|
62
|
+
.flatMap(p => p.loadedDatabases()).map(d => d.hash).join(',');
|
|
63
|
+
}
|
|
64
|
+
/** Mount an additional signature database/source by path (a plain `.sigs.ndjson`, a `.br`, or a manifest). */
|
|
65
|
+
async addDatabaseSource(source) {
|
|
66
|
+
for (const p of this.plugins) {
|
|
67
|
+
await p.addDatabaseSource(source);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/** Eagerly mount every version plugin's package database up front (see `solver.sigdb.eagerlyLoad`). */
|
|
34
71
|
eagerlyLoadPackageDatabases() {
|
|
35
72
|
for (const p of this.plugins) {
|
|
36
73
|
p.preloadDatabasesSync();
|
|
@@ -44,6 +81,18 @@ class FlowrAnalyzerDependenciesContext extends abstract_flowr_analyzer_context_1
|
|
|
44
81
|
this.applyPlugins(undefined);
|
|
45
82
|
this.staticsLoaded = true;
|
|
46
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Register a dependency declared by a project metadata file (`DESCRIPTION`, `renv.lock`, `rv.lock`). Gated by
|
|
86
|
+
* `solver.sigdb.loadProjectDependencies`: when project-dependency loading is disabled this is a no-op, so the
|
|
87
|
+
* declared deps never enter the context (unlike {@link addDependency}, used for on-demand signature-database
|
|
88
|
+
* resolution).
|
|
89
|
+
*/
|
|
90
|
+
addDeclaredDependency(pkg) {
|
|
91
|
+
if (!this.ctx.config.solver.sigdb.loadProjectDependencies) {
|
|
92
|
+
return this;
|
|
93
|
+
}
|
|
94
|
+
return this.addDependency(pkg);
|
|
95
|
+
}
|
|
47
96
|
addDependency(pkg) {
|
|
48
97
|
const p = this.dependencies.get(pkg.name);
|
|
49
98
|
if (p) {
|
|
@@ -24,6 +24,7 @@ export type RoleBasedFiles = {
|
|
|
24
24
|
[FileRole.Namespace]: FlowrNamespaceFile[];
|
|
25
25
|
[FileRole.Vignette]: FlowrFileProvider[];
|
|
26
26
|
[FileRole.Test]: FlowrFileProvider[];
|
|
27
|
+
[FileRole.Install]: FlowrFileProvider[];
|
|
27
28
|
[FileRole.License]: FlowrFileProvider[];
|
|
28
29
|
[FileRole.VirtualEnv]: FlowrFileProvider[];
|
|
29
30
|
[FileRole.Source]: FlowrFileProvider[];
|
|
@@ -143,10 +143,11 @@ class FlowrAnalyzerFilesContext extends abstract_flowr_analyzer_context_1.Abstra
|
|
|
143
143
|
}
|
|
144
144
|
// walk the directory and find the first match
|
|
145
145
|
const dir = path_1.default.dirname(p);
|
|
146
|
+
const dirLower = dir.toLowerCase();
|
|
146
147
|
const file = path_1.default.basename(p).toLowerCase();
|
|
147
148
|
// try to find in local known files first
|
|
148
149
|
for (const f of this.files.keys()) {
|
|
149
|
-
if (path_1.default.dirname(f).toLowerCase() !==
|
|
150
|
+
if (path_1.default.dirname(f).toLowerCase() !== dirLower) {
|
|
150
151
|
continue;
|
|
151
152
|
}
|
|
152
153
|
const lf = path_1.default.basename(f).toLowerCase();
|
|
@@ -54,7 +54,7 @@ class FlowrAnalyzerFunctionsContext extends abstract_flowr_analyzer_context_1.Ab
|
|
|
54
54
|
}
|
|
55
55
|
getFunctionInfo(pkg, name, s3TypeDispatch) {
|
|
56
56
|
if (s3TypeDispatch) {
|
|
57
|
-
return this.functionInfo.get(
|
|
57
|
+
return this.functionInfo.get(name)?.find(e => e.packageOrigin === pkg && e.s3TypeDispatch === s3TypeDispatch);
|
|
58
58
|
}
|
|
59
59
|
else if (name.includes('.')) {
|
|
60
60
|
const parts = name.split('.');
|
|
@@ -21,6 +21,11 @@ export declare enum FileRole {
|
|
|
21
21
|
Vignette = "vignette",
|
|
22
22
|
/** Test source files, e.g., files in the `tests/` folder */
|
|
23
23
|
Test = "test",
|
|
24
|
+
/**
|
|
25
|
+
* Files below an `inst/` folder, which R installs verbatim into the package root (resources/scripts, e.g., `inst/REFERENCES.R`, `inst/CITATION`, `inst/extdata/...`).
|
|
26
|
+
* These are not part of the package namespace source, so tooling may want to treat them separately.
|
|
27
|
+
*/
|
|
28
|
+
Install = "install",
|
|
24
29
|
/** Data files, e.g., `R/sysdata.rda`, currently not specially supported. */
|
|
25
30
|
Data = "data",
|
|
26
31
|
/** Signals separate license files, but please note, that DESCRIPTION files may contain license info too */
|
|
@@ -22,6 +22,11 @@ var FileRole;
|
|
|
22
22
|
FileRole["Vignette"] = "vignette";
|
|
23
23
|
/** Test source files, e.g., files in the `tests/` folder */
|
|
24
24
|
FileRole["Test"] = "test";
|
|
25
|
+
/**
|
|
26
|
+
* Files below an `inst/` folder, which R installs verbatim into the package root (resources/scripts, e.g., `inst/REFERENCES.R`, `inst/CITATION`, `inst/extdata/...`).
|
|
27
|
+
* These are not part of the package namespace source, so tooling may want to treat them separately.
|
|
28
|
+
*/
|
|
29
|
+
FileRole["Install"] = "install";
|
|
25
30
|
/** Data files, e.g., `R/sysdata.rda`, currently not specially supported. */
|
|
26
31
|
FileRole["Data"] = "data";
|
|
27
32
|
/** Signals separate license files, but please note, that DESCRIPTION files may contain license info too */
|
|
@@ -150,7 +150,17 @@ class FlowrAnalyzerBuilder {
|
|
|
150
150
|
const engines = await (0, engines_1.retrieveEngineInstances)(this.flowrConfig, true);
|
|
151
151
|
this.parser = engines.engines[engines.default];
|
|
152
152
|
}
|
|
153
|
-
|
|
153
|
+
const analyzer = this.buildSync();
|
|
154
|
+
// when the assumed R version is auto (the default), detect the engine's R version once and record it, so
|
|
155
|
+
// versioned (base-R) resolution and `:version` reflect the installed R (or the default when it reports none)
|
|
156
|
+
const assumed = this.flowrConfig.solver.sigdb.assumedRVersion;
|
|
157
|
+
if (assumed === undefined || assumed === 'auto') {
|
|
158
|
+
try {
|
|
159
|
+
analyzer.context().setDetectedRVersion(await this.parser.rVersion());
|
|
160
|
+
}
|
|
161
|
+
catch { /* leave undetected: resolveAssumedRVersion falls back to the default assumed version */ }
|
|
162
|
+
}
|
|
163
|
+
return analyzer;
|
|
154
164
|
}
|
|
155
165
|
/**
|
|
156
166
|
* Synchronous version of {@link FlowrAnalyzerBuilder#build}, please only use this if you have set the parser using
|
|
@@ -159,7 +169,7 @@ class FlowrAnalyzerBuilder {
|
|
|
159
169
|
buildSync() {
|
|
160
170
|
(0, assert_1.guard)(this.parser !== undefined, 'No parser set, please use the setParser or setEngine method to set a parser before building the analyzer');
|
|
161
171
|
const context = new flowr_analyzer_context_1.FlowrAnalyzerContext(this.flowrConfig, this.plugins);
|
|
162
|
-
if (this.flowrConfig.solver.
|
|
172
|
+
if (this.flowrConfig.solver.sigdb.enabled && this.flowrConfig.solver.sigdb.eagerlyLoad) {
|
|
163
173
|
context.deps.eagerlyLoadPackageDatabases();
|
|
164
174
|
}
|
|
165
175
|
const cache = flowr_analyzer_cache_1.FlowrAnalyzerCache.create({
|
|
@@ -71,7 +71,7 @@ class FlowrDescriptionFile extends flowr_file_1.FlowrFile {
|
|
|
71
71
|
return undefined;
|
|
72
72
|
}
|
|
73
73
|
const verStr = v[0].trim();
|
|
74
|
-
return
|
|
74
|
+
return r_version_1.RVersion.parse(verStr);
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
77
77
|
* Returns the parsed authors from the `Authors@R` field in the DESCRIPTION file.
|
|
@@ -169,7 +169,10 @@ function parseDCF(file) {
|
|
|
169
169
|
let currentValue = '';
|
|
170
170
|
const indentRegex = new RegExp(/^\s/);
|
|
171
171
|
const firstColonRegex = new RegExp(/:(.*)/s);
|
|
172
|
-
|
|
172
|
+
// strip a leading UTF-8 BOM (U+FEFF): it matches `indentRegex` (JS `\s` includes U+FEFF), so without this
|
|
173
|
+
// the first field (typically `Package:`) would be misread as a continuation line and silently dropped
|
|
174
|
+
const raw = file.content().toString();
|
|
175
|
+
const fileContent = (raw.charCodeAt(0) === 0xFEFF ? raw.slice(1) : raw).split(/\r?\n/);
|
|
173
176
|
for (const line of fileContent) {
|
|
174
177
|
if (indentRegex.test(line)) {
|
|
175
178
|
currentValue += '\n' + line.trim();
|
|
@@ -203,7 +206,7 @@ function parsePackagesWithVersions(packageStrings, type) {
|
|
|
203
206
|
// match until exhaustion
|
|
204
207
|
while ((match = VersionRegex.exec(str)) !== null) {
|
|
205
208
|
const [, name, operator, version] = match;
|
|
206
|
-
const range = package_1.Package.
|
|
209
|
+
const range = package_1.Package.parsePkgVersionRange(operator, version);
|
|
207
210
|
packages.push(new package_1.Package({
|
|
208
211
|
name: name,
|
|
209
212
|
type: type,
|
|
@@ -91,7 +91,7 @@ function isExportedInInfo(name, nsInfo) {
|
|
|
91
91
|
}
|
|
92
92
|
if (name.includes('.')) {
|
|
93
93
|
for (const [k, m] of nsInfo.exportS3Generics.entries()) {
|
|
94
|
-
if (m.
|
|
94
|
+
if (m.some(method => `${k}.${method}` === name)) {
|
|
95
95
|
return true;
|
|
96
96
|
}
|
|
97
97
|
}
|
|
@@ -419,6 +419,10 @@ function mergeNamespaceInfo(target, source) {
|
|
|
419
419
|
conditional: mergedConditional.size > 0 ? mergedConditional : undefined,
|
|
420
420
|
};
|
|
421
421
|
}
|
|
422
|
+
/** Split a NAMESPACE directive's argument list (`a, "b", c`) into individual, quote-stripped names. */
|
|
423
|
+
function splitNamespaceArgs(args) {
|
|
424
|
+
return args.split(',').map(s => (0, retriever_1.removeRQuotes)(s.trim())).filter(s => s.length > 0);
|
|
425
|
+
}
|
|
422
426
|
/**
|
|
423
427
|
* Parses the given NAMESPACE file
|
|
424
428
|
*/
|
|
@@ -435,7 +439,8 @@ function parseNamespaceSimple(file) {
|
|
|
435
439
|
switch (type) {
|
|
436
440
|
case 'exportClasses':
|
|
437
441
|
case 'exportMethods':
|
|
438
|
-
|
|
442
|
+
// a single directive may list several symbols, e.g. `exportMethods(show, summary)`
|
|
443
|
+
result.current.exportedFunctions.push(...splitNamespaceArgs(args));
|
|
439
444
|
break;
|
|
440
445
|
case 'S3method':
|
|
441
446
|
{
|
|
@@ -453,7 +458,8 @@ function parseNamespaceSimple(file) {
|
|
|
453
458
|
break;
|
|
454
459
|
}
|
|
455
460
|
case 'export':
|
|
456
|
-
|
|
461
|
+
// `export(a, b)` exports both `a` and `b`, so split rather than storing the literal `"a, b"`
|
|
462
|
+
result.current.exportedSymbols.push(...splitNamespaceArgs(args));
|
|
457
463
|
break;
|
|
458
464
|
case 'useDynLib':
|
|
459
465
|
{
|
|
@@ -109,10 +109,8 @@ function parseNews(file) {
|
|
|
109
109
|
.filter(l => !noiseRegex.test(l));
|
|
110
110
|
// this is a port of the incredible complex R NEWS regex, but luckily it is not too liberal :D
|
|
111
111
|
const regexVersion = makeRversionRegex();
|
|
112
|
-
// filter lines that match the version regex
|
|
113
|
-
const versionLines = lines.map(line => regexVersion.test(line));
|
|
114
112
|
// drop the header by removing everything before the first match
|
|
115
|
-
const firstVersionIndex =
|
|
113
|
+
const firstVersionIndex = lines.findIndex(line => regexVersion.test(line));
|
|
116
114
|
const relevantLines = lines.slice(firstVersionIndex);
|
|
117
115
|
// split at every version line
|
|
118
116
|
const lineChunks = splitLinesRegex(relevantLines, regexVersion);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { FlowrAnalyzerFilePlugin } from './flowr-analyzer-file-plugin';
|
|
2
|
+
import { SemVer } from 'semver';
|
|
3
|
+
import type { PathLike } from 'fs';
|
|
4
|
+
import type { FlowrAnalyzerContext } from '../../context/flowr-analyzer-context';
|
|
5
|
+
import type { FlowrFileProvider } from '../../context/flowr-file';
|
|
6
|
+
/**
|
|
7
|
+
* This plugin provides supports for the identification of installed files (files below an `inst/` folder).
|
|
8
|
+
* If you use multiple plugins, this should be included *before* other plugins.
|
|
9
|
+
*/
|
|
10
|
+
export declare class FlowrAnalyzerMetaInstFilesPlugin extends FlowrAnalyzerFilePlugin {
|
|
11
|
+
readonly name = "flowr-analyzer-inst-files-plugin";
|
|
12
|
+
readonly description = "This plugin provides support for loading installed files.";
|
|
13
|
+
readonly version: SemVer;
|
|
14
|
+
private readonly pathPattern;
|
|
15
|
+
/**
|
|
16
|
+
* Creates a new instance of the INST file plugin.
|
|
17
|
+
* @param pathPattern - The pathPattern to identify INST files, see {@link InstPathPattern} for the default pathPattern.
|
|
18
|
+
*/
|
|
19
|
+
constructor(pathPattern?: RegExp);
|
|
20
|
+
applies(file: PathLike): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Processes the given file, assigning it the {@link FileRole.Install} role.
|
|
23
|
+
* Given that the file may still need to be processed by other plugins, this method returns the `true` flag for that purpose.
|
|
24
|
+
*/
|
|
25
|
+
process(_ctx: FlowrAnalyzerContext, file: FlowrFileProvider): [FlowrFileProvider, true];
|
|
26
|
+
}
|