@eagleoutice/flowr 2.13.1 → 2.13.3
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 +46 -44
- package/abstract-interpretation/data-frame/mappers/access-mapper.js +1 -0
- package/abstract-interpretation/data-frame/mappers/function-mapper.d.ts +1 -1
- package/abstract-interpretation/data-frame/mappers/function-mapper.js +3 -0
- package/abstract-interpretation/domains/state-domain-like.d.ts +1 -1
- package/cli/flowr.js +21 -5
- package/cli/repl/commands/repl-commands.js +11 -9
- package/cli/repl/commands/repl-query.js +1 -1
- package/cli/repl/commands/repl-signature.js +8 -1
- package/cli/repl/core.js +13 -10
- package/cli/repl/print-version.js +1 -1
- package/cli/repl/server/connection.d.ts +1 -1
- package/cli/repl/server/net.js +15 -0
- package/config.d.ts +37 -0
- package/config.js +63 -3
- package/control-flow/control-flow-graph.js +2 -1
- package/control-flow/semantic-cfg-guided-visitor.d.ts +1 -1
- package/core/steps/all/core/11-normalize-tree-sitter.d.ts +1 -1
- package/data/sigdb/sigdb.remote.json +1 -1
- package/dataflow/environments/append.d.ts +1 -1
- package/dataflow/environments/clone.d.ts +1 -1
- package/dataflow/environments/environment.d.ts +28 -4
- package/dataflow/environments/environment.js +66 -11
- package/dataflow/environments/identifier.d.ts +9 -8
- package/dataflow/environments/identifier.js +21 -13
- package/dataflow/environments/overwrite.d.ts +1 -1
- package/dataflow/eval/resolve/alias-tracking.d.ts +1 -1
- package/dataflow/eval/resolve/resolve-working-directory.d.ts +29 -0
- package/dataflow/eval/resolve/resolve-working-directory.js +168 -0
- package/dataflow/extractor.js +2 -1
- package/dataflow/graph/dataflowgraph-builder.d.ts +1 -1
- package/dataflow/graph/df-helper.d.ts +3 -2
- package/dataflow/graph/df-helper.js +11 -15
- package/dataflow/graph/diff-dataflow-graph.js +1 -1
- package/dataflow/graph/graph-helper.js +2 -6
- package/dataflow/graph/graph.d.ts +24 -0
- package/dataflow/graph/graph.js +25 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +7 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +51 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +5 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +15 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-list.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-dispatch.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +7 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +9 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-vector.d.ts +1 -1
- package/documentation/doc-readme.js +14 -12
- package/documentation/doc-util/doc-normalized-ast.d.ts +1 -1
- package/documentation/wiki-dataflow-graph.js +4 -24
- package/documentation/wiki-linter.js +1 -0
- package/documentation/wiki-mk/doc-context.d.ts +10 -0
- package/documentation/wiki-mk/doc-context.js +3 -0
- package/documentation/wiki-query.js +47 -0
- package/documentation/wiki-signature-database.js +18 -7
- package/linter/linter-rules.d.ts +24 -2
- package/linter/linter-rules.js +3 -1
- package/linter/rules/absolute-path.d.ts +4 -4
- package/linter/rules/absolute-path.js +7 -5
- package/linter/rules/dataframe-access-validation.d.ts +1 -1
- package/linter/rules/file-path-validity.d.ts +1 -1
- package/linter/rules/file-path-validity.js +48 -8
- package/linter/rules/function-finder-util.d.ts +2 -1
- package/linter/rules/syntactically-valid.d.ts +58 -0
- package/linter/rules/syntactically-valid.js +203 -0
- package/linter/rules/undefined-symbol-util.js +3 -1
- package/linter/rules/undefined-symbol.js +6 -6
- package/package.json +25 -12
- package/project/context/classify-project-kind.d.ts +40 -0
- package/project/context/classify-project-kind.js +76 -0
- package/project/context/flowr-analyzer-context.d.ts +4 -4
- package/project/context/flowr-analyzer-context.js +3 -3
- package/project/context/flowr-analyzer-dependencies-context.d.ts +34 -9
- package/project/context/flowr-analyzer-dependencies-context.js +30 -3
- package/project/context/flowr-analyzer-files-context.d.ts +10 -8
- package/project/context/flowr-analyzer-files-context.js +26 -67
- package/project/context/flowr-analyzer-meta-context.d.ts +1 -0
- package/project/context/flowr-file.d.ts +5 -0
- package/project/context/flowr-file.js +5 -0
- package/project/dependency-version-space.d.ts +118 -26
- package/project/dependency-version-space.js +343 -87
- package/project/plugins/file-plugins/files/flowr-description-file.d.ts +4 -0
- package/project/plugins/file-plugins/files/flowr-description-file.js +8 -1
- package/project/plugins/file-plugins/files/flowr-rda-file.js +27 -25
- package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.d.ts +12 -4
- package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.js +25 -10
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-sweave-file-plugin.d.ts +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-description-file-plugin.js +2 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +4 -4
- package/project/plugins/package-version-plugins/package.d.ts +27 -10
- package/project/plugins/package-version-plugins/package.js +50 -25
- package/project/plugins/plugin-registry.d.ts +2 -1
- package/project/plugins/plugin-registry.js +4 -1
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.d.ts +57 -2
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +150 -28
- package/project/sigdb/decompress.d.ts +1 -1
- package/project/sigdb/decompress.js +4 -1
- package/project/sigdb/manifest.js +60 -26
- package/project/sigdb/reader.d.ts +26 -16
- package/project/sigdb/reader.js +52 -21
- package/project/sigdb/sigdb-download.d.ts +6 -7
- package/project/sigdb/sigdb-download.js +30 -9
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +1 -1
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +2 -12
- package/queries/catalog/dependencies-query/dependencies-query-format.js +2 -108
- package/queries/catalog/does-call-query/does-call-query-format.d.ts +1 -1
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +39 -77
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +12 -0
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +54 -24
- package/queries/catalog/input-sources-query/input-source-functions.d.ts +13 -0
- package/queries/catalog/input-sources-query/input-source-functions.js +96 -1
- package/queries/catalog/input-sources-query/input-sources-query-executor.js +40 -4
- package/queries/catalog/input-sources-query/input-sources-query-format.js +21 -3
- package/queries/catalog/input-sources-query/input-types.d.ts +58 -0
- package/queries/catalog/input-sources-query/input-types.js +64 -0
- package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +62 -52
- package/queries/catalog/input-sources-query/simple-input-classifier.js +334 -101
- package/queries/catalog/linter-query/linter-query-format.js +9 -2
- package/queries/catalog/project-query/project-query-executor.js +1 -1
- package/queries/catalog/signature-query/signature-query-executor.d.ts +7 -1
- package/queries/catalog/signature-query/signature-query-executor.js +115 -39
- package/queries/catalog/signature-query/signature-query-format.d.ts +5 -1
- package/queries/catalog/signature-query/signature-query-format.js +1 -1
- package/queries/catalog/signature-query/signature-query-render.js +12 -7
- package/queries/query.js +9 -2
- package/r-bridge/data/data.d.ts +5 -0
- package/r-bridge/data/data.js +6 -0
- package/r-bridge/lang-4.x/ast/parser/json/format.js +1 -1
- package/r-bridge/retriever.d.ts +1 -1
- package/r-bridge/retriever.js +6 -1
- package/r-bridge/shell.js +5 -0
- package/search/flowr-search-filters.d.ts +2 -1
- package/search/flowr-search-printer.js +10 -8
- package/slicing/static/static-slicer.d.ts +2 -2
- package/util/files.d.ts +6 -4
- package/util/files.js +30 -8
- package/util/mermaid/dfg.js +1 -1
- package/util/objects.js +6 -4
- package/util/r-base-packages.d.ts +2 -0
- package/util/r-base-packages.js +3 -0
- package/util/r-license.js +1 -4
- package/util/r-version.d.ts +12 -0
- package/util/r-version.js +16 -0
- package/util/range.d.ts +6 -2
- package/util/range.js +33 -15
- package/util/text/ansi.d.ts +7 -3
- package/util/text/ansi.js +8 -5
- package/util/version.js +4 -4
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SYNTACTICALLY_VALID = exports.SyntaxErrorFixPatterns = void 0;
|
|
4
|
+
const linter_format_1 = require("../linter-format");
|
|
5
|
+
const flowr_search_builder_1 = require("../../search/flowr-search-builder");
|
|
6
|
+
const range_1 = require("../../util/range");
|
|
7
|
+
const linter_tags_1 = require("../linter-tags");
|
|
8
|
+
const DelimiterInsert = new Map([[')', ')'], ['}', '}'], [']', ']'], [']]', ']]'], ['"', '"'], ['\'', '\''], ['`', '`'], [',', ','], [';', ';']]);
|
|
9
|
+
const KeywordInsert = new Map([['in', ' in '], ['else', ' else ']]);
|
|
10
|
+
const OperatorToken = /^([-+*/^:~!<>=&|@$]+|<-|<<-|->|->>|\|>|%[^%]*%)$/;
|
|
11
|
+
const KnownOperators = ['%%', '%/%', '%*%', '%o%', '%x%', '%in%', '%>%', '%<>%', '%+%', '%||%'];
|
|
12
|
+
// tree-sitter is 0-based with an exclusive end column (matching flowR), so only the 1-based start shifts
|
|
13
|
+
const point = (p) => [p.row + 1, p.column + 1, p.row + 1, p.column];
|
|
14
|
+
const span = (n) => [n.startPosition.row + 1, n.startPosition.column + 1, n.endPosition.row + 1, n.endPosition.column];
|
|
15
|
+
const isDanglingOperator = (n) => !!n && !n.isNamed && OperatorToken.test(n.type);
|
|
16
|
+
/** The closing delimiters an unbalanced error region is missing, innermost first (skips strings/comments; `({` needs `})`). */
|
|
17
|
+
function bracketDeficit(text) {
|
|
18
|
+
const stack = [];
|
|
19
|
+
let quote;
|
|
20
|
+
for (let i = 0; i < text.length; i++) {
|
|
21
|
+
const c = text[i];
|
|
22
|
+
if (quote) {
|
|
23
|
+
if (c === '\\') {
|
|
24
|
+
i++;
|
|
25
|
+
}
|
|
26
|
+
else if (c === quote) {
|
|
27
|
+
quote = undefined;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
else if (c === '"' || c === '\'' || c === '`') {
|
|
31
|
+
quote = c;
|
|
32
|
+
}
|
|
33
|
+
else if (c === '#') {
|
|
34
|
+
while (i < text.length && text[i] !== '\n') {
|
|
35
|
+
i++;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
else if (c === '(') {
|
|
39
|
+
stack.push(')');
|
|
40
|
+
}
|
|
41
|
+
else if (c === '[') {
|
|
42
|
+
stack.push(text[i + 1] === '[' ? (i++, ']]') : ']');
|
|
43
|
+
}
|
|
44
|
+
else if (c === '{') {
|
|
45
|
+
stack.push('}');
|
|
46
|
+
}
|
|
47
|
+
else if ((c === ')' || c === '}') && stack[stack.length - 1] === c) {
|
|
48
|
+
stack.pop();
|
|
49
|
+
}
|
|
50
|
+
else if (c === ']') {
|
|
51
|
+
if (stack[stack.length - 1] === ']') {
|
|
52
|
+
stack.pop();
|
|
53
|
+
}
|
|
54
|
+
else if (stack[stack.length - 1] === ']]') {
|
|
55
|
+
stack[stack.length - 1] = ']';
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return stack.reverse();
|
|
60
|
+
}
|
|
61
|
+
/** Fuzzy-complete the unfinished `%...` operator in an error region to the nearest known operator (else just close it). */
|
|
62
|
+
function operatorCompletion(node) {
|
|
63
|
+
const at = node.text.lastIndexOf('%');
|
|
64
|
+
const fragment = /^%[A-Za-z0-9]*/.exec(node.text.slice(at))?.[0] ?? '%';
|
|
65
|
+
const full = KnownOperators.find(op => op !== fragment && op.startsWith(fragment)) ?? fragment + '%';
|
|
66
|
+
const column = node.startPosition.column + at;
|
|
67
|
+
return { range: [node.startPosition.row + 1, column + 1, node.startPosition.row + 1, column + fragment.length], full };
|
|
68
|
+
}
|
|
69
|
+
const isMissingExpression = (f) => f.kind === 'missing' && !DelimiterInsert.has(f.node.type) && !KeywordInsert.has(f.node.type);
|
|
70
|
+
/** The built-in auto-fix patterns; append a {@link SyntaxErrorFixPattern} to add repairs. */
|
|
71
|
+
exports.SyntaxErrorFixPatterns = [
|
|
72
|
+
{
|
|
73
|
+
name: 'insert-missing-token',
|
|
74
|
+
description: 'Insert a delimiter, quote, or keyword the parser expected but did not find.',
|
|
75
|
+
direction: 'add',
|
|
76
|
+
appliesTo: f => f.kind === 'missing' && (DelimiterInsert.has(f.node.type) || KeywordInsert.has(f.node.type)),
|
|
77
|
+
quickFix: (f, file) => ({
|
|
78
|
+
type: 'replace',
|
|
79
|
+
loc: range_1.SourceLocation.from(point(f.node.startPosition), file),
|
|
80
|
+
description: `Insert missing \`${f.node.type}\``,
|
|
81
|
+
replacement: DelimiterInsert.get(f.node.type) ?? KeywordInsert.get(f.node.type)
|
|
82
|
+
})
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: 'remove-dangling-operator',
|
|
86
|
+
description: 'Drop a dangling operator whose operand the parser found missing.',
|
|
87
|
+
direction: 'remove',
|
|
88
|
+
appliesTo: f => isMissingExpression(f) && isDanglingOperator(f.node.previousSibling),
|
|
89
|
+
quickFix: (f, file) => ({ type: 'remove', loc: range_1.SourceLocation.from(span(f.node.previousSibling), file), description: `Remove the dangling \`${f.node.previousSibling.type}\`` })
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: 'insert-operand-placeholder',
|
|
93
|
+
description: 'Insert a `NULL` placeholder for a missing operand or body.',
|
|
94
|
+
direction: 'add',
|
|
95
|
+
appliesTo: isMissingExpression,
|
|
96
|
+
quickFix: (f, file) => ({ type: 'replace', loc: range_1.SourceLocation.from(point(f.node.startPosition), file), description: 'Insert placeholder `NULL`', replacement: ' NULL' })
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: 'balance-brackets',
|
|
100
|
+
description: 'Close an unbalanced region by appending the brackets that were left open.',
|
|
101
|
+
direction: 'add',
|
|
102
|
+
appliesTo: f => f.kind === 'error' && bracketDeficit(f.node.text).length > 0,
|
|
103
|
+
quickFix: (f, file) => {
|
|
104
|
+
const closers = bracketDeficit(f.node.text).join('');
|
|
105
|
+
return { type: 'replace', loc: range_1.SourceLocation.from(point(f.node.endPosition), file), description: `Add missing closing \`${closers}\``, replacement: closers };
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
name: 'complete-operator',
|
|
110
|
+
description: 'Complete an unfinished `%...%` operator to the nearest known one.',
|
|
111
|
+
direction: 'add',
|
|
112
|
+
appliesTo: f => f.kind === 'error' && !f.node.text.includes('\n') && (f.node.text.match(/%/g)?.length ?? 0) % 2 === 1,
|
|
113
|
+
quickFix: (f, file) => {
|
|
114
|
+
const { range, full } = operatorCompletion(f.node);
|
|
115
|
+
return { type: 'replace', loc: range_1.SourceLocation.from(range, file), description: `Complete operator to \`${full}\``, replacement: full };
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
name: 'comment-out',
|
|
120
|
+
description: 'Comment out an un-parseable region so the rest of the file still parses.',
|
|
121
|
+
direction: 'comment',
|
|
122
|
+
appliesTo: f => f.kind === 'error' && !f.node.text.includes('\n'),
|
|
123
|
+
quickFix: (f, file) => ({ type: 'replace', loc: range_1.SourceLocation.from(span(f.node), file), description: 'Comment out the offending code', replacement: '# ' + f.node.text })
|
|
124
|
+
}
|
|
125
|
+
];
|
|
126
|
+
/** Collect the outermost `missing`/`error` nodes, pruning subtrees the parser reports as clean. */
|
|
127
|
+
function collectFindings(node, out = []) {
|
|
128
|
+
if (node.isMissing) {
|
|
129
|
+
out.push({ kind: 'missing', node });
|
|
130
|
+
}
|
|
131
|
+
else if (node.isError) {
|
|
132
|
+
out.push({ kind: 'error', node });
|
|
133
|
+
}
|
|
134
|
+
else if (node.hasError) {
|
|
135
|
+
for (const child of node.children) {
|
|
136
|
+
collectFindings(child, out);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return out;
|
|
140
|
+
}
|
|
141
|
+
function describe(finding) {
|
|
142
|
+
if (finding.kind === 'missing') {
|
|
143
|
+
return `Missing \`${finding.node.type}\``;
|
|
144
|
+
}
|
|
145
|
+
const text = finding.node.text.replace(/\s+/g, ' ').trim();
|
|
146
|
+
return `Unexpected \`${text.length > 30 ? text.slice(0, 27) + '...' : text}\``;
|
|
147
|
+
}
|
|
148
|
+
exports.SYNTACTICALLY_VALID = {
|
|
149
|
+
createSearch: () => flowr_search_builder_1.Q.all(),
|
|
150
|
+
processSearchResult: async (_elements, config, data) => {
|
|
151
|
+
const parser = data.parserInformation().name;
|
|
152
|
+
const results = [];
|
|
153
|
+
// only tree-sitter recovers from syntax errors; a hard parser aborts before the linter ever runs
|
|
154
|
+
if (parser === 'tree-sitter') {
|
|
155
|
+
const patterns = exports.SyntaxErrorFixPatterns.filter(p => !config.disabledFixes.includes(p.name));
|
|
156
|
+
for (const file of (await data.parse()).files) {
|
|
157
|
+
const root = file.parsed.rootNode;
|
|
158
|
+
if (!root.hasError) {
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
for (const finding of collectFindings(root)) {
|
|
162
|
+
// a single fix per error, favouring the preferred direction (alternatives are never emitted together)
|
|
163
|
+
let fix;
|
|
164
|
+
let best = 2;
|
|
165
|
+
for (const p of patterns) {
|
|
166
|
+
const rank = p.direction === config.preferFix ? 0 : 1;
|
|
167
|
+
if (rank < best && p.appliesTo(finding)) {
|
|
168
|
+
fix = p.quickFix(finding, file.filePath);
|
|
169
|
+
best = rank;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
results.push({
|
|
173
|
+
certainty: linter_format_1.LintingResultCertainty.Certain,
|
|
174
|
+
kind: finding.kind,
|
|
175
|
+
involvedId: undefined,
|
|
176
|
+
loc: range_1.SourceLocation.from(span(finding.node), file.filePath),
|
|
177
|
+
message: describe(finding),
|
|
178
|
+
quickFix: fix ? [fix] : undefined
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return { results, '.meta': { parser, errors: results.length, fixable: results.filter(r => r.quickFix !== undefined).length } };
|
|
184
|
+
},
|
|
185
|
+
prettyPrint: {
|
|
186
|
+
[linter_format_1.LintingPrettyPrintContext.Query]: (result) => `${result.message} at ${range_1.SourceLocation.format(result.loc)}`,
|
|
187
|
+
[linter_format_1.LintingPrettyPrintContext.Full]: (result) => `Syntax error (${result.kind}): ${result.message} at ${range_1.SourceLocation.format(result.loc)}`
|
|
188
|
+
},
|
|
189
|
+
info: {
|
|
190
|
+
name: 'Syntactically Valid',
|
|
191
|
+
description: 'Checks whether the code is free of syntax errors, using the configured (error-tolerant) parser, and offers extensible quick-fixes to repair them.',
|
|
192
|
+
tags: [linter_tags_1.LintingRuleTag.Bug, linter_tags_1.LintingRuleTag.Robustness, linter_tags_1.LintingRuleTag.QuickFix],
|
|
193
|
+
// tree-sitter reports real syntax errors precisely, but a strict parse may collapse a region into fewer findings
|
|
194
|
+
certainty: linter_format_1.LintingRuleCertainty.BestEffort,
|
|
195
|
+
// only meaningful under tree-sitter, so opt-in rather than part of the default set
|
|
196
|
+
activeByDefault: false,
|
|
197
|
+
defaultConfig: {
|
|
198
|
+
disabledFixes: [],
|
|
199
|
+
preferFix: 'remove'
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
//# sourceMappingURL=syntactically-valid.js.map
|
|
@@ -117,7 +117,9 @@ function collectScopeDefinedNames(graph) {
|
|
|
117
117
|
if (!unconditional) {
|
|
118
118
|
continue;
|
|
119
119
|
}
|
|
120
|
-
|
|
120
|
+
const names = byScope.get(scope) ?? new Set();
|
|
121
|
+
names.add(name);
|
|
122
|
+
byScope.set(scope, names);
|
|
121
123
|
}
|
|
122
124
|
return byScope;
|
|
123
125
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UNDEFINED_SYMBOL = void 0;
|
|
4
4
|
const vertex_1 = require("../../dataflow/graph/vertex");
|
|
5
|
+
const graph_1 = require("../../dataflow/graph/graph");
|
|
5
6
|
const dfg_get_origin_1 = require("../../dataflow/origin/dfg-get-origin");
|
|
6
7
|
const identifier_1 = require("../../dataflow/environments/identifier");
|
|
7
8
|
const flowr_search_builder_1 = require("../../search/flowr-search-builder");
|
|
@@ -17,13 +18,12 @@ const undefined_symbol_util_1 = require("./undefined-symbol-util");
|
|
|
17
18
|
/** calls that load a package; an unresolved one means we cannot enumerate all exports in scope */
|
|
18
19
|
const LibraryLoadFunctions = new Set(['library', 'require', 'requireNamespace', 'loadNamespace', 'attachNamespace', 'load_all', 'use', 'p_load']);
|
|
19
20
|
// standard packages attached by default; exports are in scope without library()
|
|
20
|
-
const AttachedBasePackages = ['base', 'stats', 'graphics', 'grDevices', 'utils', 'datasets', 'methods'];
|
|
21
21
|
/** test frameworks whose namespace a test file runs under implicitly (e.g. `tests/testthat/test-*.R` sees testthat's exports without a `library()`) */
|
|
22
22
|
const ImplicitTestFrameworks = new Set(['testthat', 'tinytest', 'RUnit']);
|
|
23
23
|
/** whether name is an export of a default-attached base package (needs no library()) */
|
|
24
24
|
function isAttachedBaseName(name) {
|
|
25
25
|
const owner = (0, r_base_packages_1.baseRExportOwner)(name);
|
|
26
|
-
return owner !== undefined && AttachedBasePackages.includes(owner);
|
|
26
|
+
return owner !== undefined && r_base_packages_1.AttachedBasePackages.includes(owner);
|
|
27
27
|
}
|
|
28
28
|
/** upper bound on the number of packages named in a "did you forget to load it" hint */
|
|
29
29
|
const MaxHintPackages = 5;
|
|
@@ -56,12 +56,12 @@ exports.UNDEFINED_SYMBOL = {
|
|
|
56
56
|
// findings as low-confidence (`mayBeProvidedByUnresolvedLibrary`) so the severity can be lowered
|
|
57
57
|
const unknownIds = new Set();
|
|
58
58
|
for (const e of graph.unknownSideEffects) {
|
|
59
|
-
unknownIds.add(
|
|
59
|
+
unknownIds.add(graph_1.UnknownSideEffect.id(e));
|
|
60
60
|
}
|
|
61
61
|
let unresolvedLibraryInScope = false;
|
|
62
62
|
if (unknownIds.size > 0) {
|
|
63
63
|
for (const [id, v] of graph.verticesOfType(vertex_1.VertexType.FunctionCall)) {
|
|
64
|
-
if (LibraryLoadFunctions.has(identifier_1.Identifier.getName(v.name)) && unknownIds.has(
|
|
64
|
+
if (LibraryLoadFunctions.has(identifier_1.Identifier.getName(v.name)) && unknownIds.has(id)) {
|
|
65
65
|
unresolvedLibraryInScope = true;
|
|
66
66
|
break;
|
|
67
67
|
}
|
|
@@ -73,10 +73,10 @@ exports.UNDEFINED_SYMBOL = {
|
|
|
73
73
|
// packages, each resolved (exports enriched) from the package database via getDependency
|
|
74
74
|
const loadedPackages = [
|
|
75
75
|
...deps.getDependencies().map(p => deps.getDependency(p.name) ?? p),
|
|
76
|
-
...AttachedBasePackages.map(n => deps.getDependency(n)).filter(assert_1.isNotUndefined)
|
|
76
|
+
...r_base_packages_1.AttachedBasePackages.map(n => deps.getDependency(n)).filter(assert_1.isNotUndefined)
|
|
77
77
|
];
|
|
78
78
|
// hint an unloaded package that exports `name` (e.g. `ggplot` -> `ggplot2`), from the package database
|
|
79
|
-
const attached = new Set(AttachedBasePackages);
|
|
79
|
+
const attached = new Set(r_base_packages_1.AttachedBasePackages);
|
|
80
80
|
const hintPackagesFor = (name) => deps.packagesExporting(name).filter(p => !attached.has(p)).slice(0, MaxHintPackages);
|
|
81
81
|
const results = elements.getElements().map(element => {
|
|
82
82
|
const id = element.node.info.id;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eagleoutice/flowr",
|
|
3
|
-
"version": "2.13.
|
|
3
|
+
"version": "2.13.3",
|
|
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 gen:base-packages && npm run main-dev --",
|
|
18
|
+
"flowr:dev": "npm run sync:sigdb && 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",
|
|
@@ -29,14 +29,16 @@
|
|
|
29
29
|
"wiki:watch": "node -r ts-node/register --watch src/cli/wiki.ts --keep-alive",
|
|
30
30
|
"build": "npm run gen:base-packages && tsc --project . && npm run build:copy-data",
|
|
31
31
|
"gen:base-packages": "ts-node --transpile-only scripts/gen-base-packages.ts",
|
|
32
|
-
"sync:sigdb": "ts-node --transpile-only scripts/sigdb-
|
|
32
|
+
"sync:sigdb": "ts-node --transpile-only scripts/sigdb-sync.ts",
|
|
33
|
+
"gen:sigdb-remote": "ts-node --transpile-only scripts/sigdb-remote.ts",
|
|
33
34
|
"publish:sigdb": "ts-node scripts/publish-sigdb.ts",
|
|
34
35
|
"build:copy-data": "ts-node --transpile-only scripts/sigdb-copy.ts",
|
|
35
36
|
"build-dev": "npm run build && npm run build:copy-wasm",
|
|
36
37
|
"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",
|
|
37
38
|
"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/",
|
|
38
|
-
"
|
|
39
|
-
"lint": "npm run
|
|
39
|
+
"typecheck": "tsc --noEmit --project .",
|
|
40
|
+
"lint-local": "npm run typecheck && npx eslint --version && npx eslint src/ test/ scripts/ --concurrency=auto --cache --cache-location node_modules/.cache/eslint-local --rule \"no-warning-comments: off\"",
|
|
41
|
+
"lint": "npm run license-compat -- --summary && npm run typecheck && npx eslint --version && npx eslint src/ test/ scripts/ --concurrency=auto --cache --cache-location node_modules/.cache/eslint",
|
|
40
42
|
"license-compat": "license-checker-rseidelsohn --onlyAllow 'MIT;MPL-2.0;MIT OR X11;GPLv2;LGPL;GNUGPL;ISC;Apache-2.0;FreeBSD;BSD-2-Clause;clearbsd;ModifiedBSD;BSD-3-Clause;Python-2.0;Unlicense;WTFPL;BlueOak-1.0.0;CC-BY-4.0;CC-BY-3.0;CC0-1.0;0BSD' --clarificationsFile license-clarifications.json",
|
|
41
43
|
"doc": "typedoc",
|
|
42
44
|
"test": "vitest --exclude \"test/system-tests/**\" --config test/vitest.config.mts",
|
|
@@ -48,7 +50,7 @@
|
|
|
48
50
|
"test-full": "npm run test:coverage -- --no-watch -- --make-summary --test-installation",
|
|
49
51
|
"performance-test": "func() { cd test/performance/ && bash run-all-suites.sh $1 $2 $3 $4; cd ../../; }; func",
|
|
50
52
|
"test:performance": "npm run performance-test --",
|
|
51
|
-
"test:docker": "func() { for df in scripts/Dockerfile scripts/Dockerfile-NoR; do echo \"=== building $df ===\";
|
|
53
|
+
"test:docker": "func() { b() { docker build ${1:+--network=$1} -t flowr-docker-test -f \"$2\" .; }; r() { docker run --rm ${1:+--network=$1} flowr-docker-test --version; }; for df in scripts/Dockerfile scripts/Dockerfile-NoR; do echo \"=== building $df ===\"; b '' \"$df\" || { echo '(retrying with --network=host: bridge networking unavailable)'; b host \"$df\"; } || return 1; echo \"=== smoke-testing $df ===\"; r '' || r host || return 1; done; }; func",
|
|
52
54
|
"detect-circular-deps": "npx madge --extensions ts,tsx --circular src/",
|
|
53
55
|
"checkup": "ts-node scripts/checkup-parallel.ts"
|
|
54
56
|
},
|
|
@@ -180,10 +182,9 @@
|
|
|
180
182
|
"devDependencies": {
|
|
181
183
|
"@commitlint/cli": "^20.5.0",
|
|
182
184
|
"@commitlint/config-angular": "^20.5.0",
|
|
183
|
-
"@eagleoutice/eslint-config-flowr": "^
|
|
184
|
-
"@eslint/eslintrc": "^3.3.3",
|
|
185
|
-
"@eslint/js": "^9.39.2",
|
|
185
|
+
"@eagleoutice/eslint-config-flowr": "^2.0.1",
|
|
186
186
|
"@j-ulrich/release-it-regex-bumper": "^5.4.0",
|
|
187
|
+
"@stylistic/eslint-plugin": "^5.10.0",
|
|
187
188
|
"@types/command-line-args": "^5.2.3",
|
|
188
189
|
"@types/command-line-usage": "^5.0.4",
|
|
189
190
|
"@types/commonmark": "^0.27.10",
|
|
@@ -197,11 +198,16 @@
|
|
|
197
198
|
"@types/tmp": "^0.2.6",
|
|
198
199
|
"@types/ws": "^8.18.1",
|
|
199
200
|
"@typescript-eslint/eslint-plugin": "^8.40.0",
|
|
201
|
+
"@typescript-eslint/parser": "^8.65.0",
|
|
200
202
|
"@vitest/coverage-v8": "^4.1.8",
|
|
201
203
|
"esbuild": "^0.28.1",
|
|
202
|
-
"eslint": "^
|
|
203
|
-
"
|
|
204
|
-
"
|
|
204
|
+
"eslint": "^10.8.0",
|
|
205
|
+
"eslint-plugin-check-file": "^3.3.2",
|
|
206
|
+
"eslint-plugin-import-x": "^4.17.1",
|
|
207
|
+
"eslint-plugin-jsdoc": "^62.9.0",
|
|
208
|
+
"eslint-plugin-tsdoc": "^0.5.2",
|
|
209
|
+
"eslint-plugin-unused-imports": "^4.4.1",
|
|
210
|
+
"license-checker-rseidelsohn": "^5.0.1",
|
|
205
211
|
"release-it": "^20.0.0",
|
|
206
212
|
"ts-node": "^10.9.2",
|
|
207
213
|
"typedoc": "^0.28.17",
|
|
@@ -241,5 +247,12 @@
|
|
|
241
247
|
"web-tree-sitter": "^0.24.7",
|
|
242
248
|
"ws": "^8.18.0",
|
|
243
249
|
"xpath-ts2": "^1.4.2"
|
|
250
|
+
},
|
|
251
|
+
"allowScripts": {
|
|
252
|
+
"@davisvaughan/tree-sitter-r@1.2.0": true,
|
|
253
|
+
"core-js-pure@3.40.0": true,
|
|
254
|
+
"esbuild@0.28.1": true,
|
|
255
|
+
"plantuml-pipe@1.6.0": true,
|
|
256
|
+
"unrs-resolver@1.12.2": true
|
|
244
257
|
}
|
|
245
258
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ProjectKind } from './project-kind';
|
|
2
|
+
/** Lazily read a shiny-entry file's content; returns `undefined` when it cannot be read. */
|
|
3
|
+
export type ContentReader = () => string | undefined;
|
|
4
|
+
/** The evidence {@link classifyProjectKind} works from. */
|
|
5
|
+
export interface ProjectKindSignals {
|
|
6
|
+
/** lower-cased basenames of every file known so far */
|
|
7
|
+
readonly names: ReadonlySet<string>;
|
|
8
|
+
/** shiny-entry basename to a reader for its content */
|
|
9
|
+
readonly entries: ReadonlyMap<string, ContentReader>;
|
|
10
|
+
/** the lower-cased `Type:` of each known `DESCRIPTION` (`''` when absent) */
|
|
11
|
+
readonly descriptionTypes: readonly string[];
|
|
12
|
+
/** how many `DESCRIPTION` files are known */
|
|
13
|
+
readonly descriptionCount: number;
|
|
14
|
+
}
|
|
15
|
+
/** The configurable classification inputs, from `project.classification`. */
|
|
16
|
+
export interface ClassificationConfig {
|
|
17
|
+
readonly shinyDescriptionTypes?: readonly string[];
|
|
18
|
+
readonly shinyEntryFiles?: readonly string[];
|
|
19
|
+
readonly shinyUsagePattern?: string;
|
|
20
|
+
readonly notebookExtensions?: readonly string[];
|
|
21
|
+
}
|
|
22
|
+
/** {@link ClassificationConfig} resolved to matchers, falling back to the built-in defaults. */
|
|
23
|
+
export interface ResolvedClassifyOptions {
|
|
24
|
+
readonly shinyDescriptionTypes: ReadonlySet<string>;
|
|
25
|
+
readonly shinyEntryFiles: ReadonlySet<string>;
|
|
26
|
+
readonly shinyUsage: RegExp;
|
|
27
|
+
readonly notebookExtension: RegExp;
|
|
28
|
+
}
|
|
29
|
+
/** Resolve {@link ClassificationConfig} into {@link ResolvedClassifyOptions}, using the built-in defaults for unset fields. */
|
|
30
|
+
export declare function resolveClassifyOptions(cfg?: ClassificationConfig): ResolvedClassifyOptions;
|
|
31
|
+
/**
|
|
32
|
+
* Whether the project is a shiny app: it has the canonical entry files (a single `app.R`, or the `ui.R`+`server.R`
|
|
33
|
+
* pair) and one of them uses the shiny stack. When no entry file can be read we trust the file names alone.
|
|
34
|
+
*/
|
|
35
|
+
export declare function isShinyAppSignals(names: ReadonlySet<string>, entries: ReadonlyMap<string, ContentReader>, shinyUsagePattern?: RegExp): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Classify the {@link ProjectKind} from the given {@link ProjectKindSignals}. Shiny apps are detected first (they
|
|
38
|
+
* often ship a `DESCRIPTION` too), then packages, then notebooks; the rest is a single-file `Script` or a `Project`.
|
|
39
|
+
*/
|
|
40
|
+
export declare function classifyProjectKind(signals: ProjectKindSignals, opts?: ResolvedClassifyOptions): ProjectKind;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveClassifyOptions = resolveClassifyOptions;
|
|
4
|
+
exports.isShinyAppSignals = isShinyAppSignals;
|
|
5
|
+
exports.classifyProjectKind = classifyProjectKind;
|
|
6
|
+
const project_kind_1 = require("./project-kind");
|
|
7
|
+
/** default DESCRIPTION `Type:` values marking a shiny app */
|
|
8
|
+
const shinyDescriptionTypes = new Set(['shiny', 'shiny-app', 'shinyapp']);
|
|
9
|
+
/** default (lower-cased) file names a shiny app is assembled from */
|
|
10
|
+
const shinyEntryFiles = new Set(['app.r', 'ui.r', 'server.r', 'global.r']);
|
|
11
|
+
/** default evidence that a file is part of a shiny app (a load of the shiny stack or a call to one of its entry points) */
|
|
12
|
+
const shinyUsage = /(?:library|require|requireNamespace|loadNamespace)\s*\(\s*['"]?(?:shiny|bslib|shinydashboard|shinyMobile|golem|flexdashboard)\b|\b(?:shinyApp|shinyServer|shinyUI|runApp|fluidPage|fluidRow|navbarPage|bootstrapPage|fillPage|dashboardPage|page_fluid|page_sidebar|page_navbar|pageWithSidebar)\s*\(/;
|
|
13
|
+
/** default extensions marking a notebook / literate document */
|
|
14
|
+
const notebookExtension = /\.(ipynb|rmd|qmd|rnw)$/;
|
|
15
|
+
/** Resolve {@link ClassificationConfig} into {@link ResolvedClassifyOptions}, using the built-in defaults for unset fields. */
|
|
16
|
+
function resolveClassifyOptions(cfg) {
|
|
17
|
+
return {
|
|
18
|
+
shinyDescriptionTypes: cfg?.shinyDescriptionTypes ? new Set(cfg.shinyDescriptionTypes.map(s => s.toLowerCase())) : shinyDescriptionTypes,
|
|
19
|
+
shinyEntryFiles: cfg?.shinyEntryFiles ? new Set(cfg.shinyEntryFiles.map(s => s.toLowerCase())) : shinyEntryFiles,
|
|
20
|
+
shinyUsage: cfg?.shinyUsagePattern ? new RegExp(cfg.shinyUsagePattern) : shinyUsage,
|
|
21
|
+
notebookExtension: cfg?.notebookExtensions ? new RegExp(`\\.(${cfg.notebookExtensions.join('|')})$`, 'i') : notebookExtension
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
const defaultClassifyOptions = resolveClassifyOptions();
|
|
25
|
+
/**
|
|
26
|
+
* Whether the project is a shiny app: it has the canonical entry files (a single `app.R`, or the `ui.R`+`server.R`
|
|
27
|
+
* pair) and one of them uses the shiny stack. When no entry file can be read we trust the file names alone.
|
|
28
|
+
*/
|
|
29
|
+
function isShinyAppSignals(names, entries, shinyUsagePattern = shinyUsage) {
|
|
30
|
+
if (!names.has('app.r') && !(names.has('ui.r') && names.has('server.r'))) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
let couldRead = false;
|
|
34
|
+
for (const read of entries.values()) {
|
|
35
|
+
const content = read();
|
|
36
|
+
if (content === undefined) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
couldRead = true;
|
|
40
|
+
if (shinyUsagePattern.test(content)) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return !couldRead;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Classify the {@link ProjectKind} from the given {@link ProjectKindSignals}. Shiny apps are detected first (they
|
|
48
|
+
* often ship a `DESCRIPTION` too), then packages, then notebooks; the rest is a single-file `Script` or a `Project`.
|
|
49
|
+
*/
|
|
50
|
+
function classifyProjectKind(signals, opts = defaultClassifyOptions) {
|
|
51
|
+
if (signals.descriptionTypes.some(t => opts.shinyDescriptionTypes.has(t))) {
|
|
52
|
+
return project_kind_1.ProjectKind.ShinyApp;
|
|
53
|
+
}
|
|
54
|
+
if (isShinyAppSignals(signals.names, signals.entries, opts.shinyUsage)) {
|
|
55
|
+
return project_kind_1.ProjectKind.ShinyApp;
|
|
56
|
+
}
|
|
57
|
+
if (signals.descriptionCount > 0) {
|
|
58
|
+
return project_kind_1.ProjectKind.Package;
|
|
59
|
+
}
|
|
60
|
+
if (signals.names.size === 0) {
|
|
61
|
+
return project_kind_1.ProjectKind.Unknown;
|
|
62
|
+
}
|
|
63
|
+
for (const name of signals.names) {
|
|
64
|
+
if (opts.notebookExtension.test(name)) {
|
|
65
|
+
return project_kind_1.ProjectKind.Notebook;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
let rSources = 0;
|
|
69
|
+
for (const name of signals.names) {
|
|
70
|
+
if (name.endsWith('.r')) {
|
|
71
|
+
rSources++;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return rSources <= 1 ? project_kind_1.ProjectKind.Script : project_kind_1.ProjectKind.Project;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=classify-project-kind.js.map
|
|
@@ -42,8 +42,8 @@ export interface ReadOnlyFlowrAnalyzerContext {
|
|
|
42
42
|
readonly rVersionKnown: boolean;
|
|
43
43
|
/** Classify the {@link ProjectKind} of the project, see {@link ReadOnlyFlowrAnalyzerFilesContext#projectKind}. */
|
|
44
44
|
projectKind(): ProjectKind;
|
|
45
|
-
/** The versions a dependency can possibly have, see {@link ReadOnlyFlowrAnalyzerDependenciesContext#
|
|
46
|
-
|
|
45
|
+
/** The versions a dependency can possibly have, see {@link ReadOnlyFlowrAnalyzerDependenciesContext#inferredRange}. */
|
|
46
|
+
inferredRange(name: string): Range | undefined;
|
|
47
47
|
/**
|
|
48
48
|
* Resource-usage guard (gas).
|
|
49
49
|
* Call `ctx.gas.checkGas(key)` at expensive analysis sites to obtain the current pressure level.
|
|
@@ -127,8 +127,8 @@ export declare class FlowrAnalyzerContext implements ReadOnlyFlowrAnalyzerContex
|
|
|
127
127
|
get rVersionKnown(): boolean;
|
|
128
128
|
/** Classify the {@link ProjectKind} of the project (delegates to the cached {@link FlowrAnalyzerFilesContext#projectKind}). */
|
|
129
129
|
projectKind(): ProjectKind;
|
|
130
|
-
/** The versions a dependency can possibly have (delegates to {@link FlowrAnalyzerDependenciesContext#
|
|
131
|
-
|
|
130
|
+
/** The versions a dependency can possibly have (delegates to {@link FlowrAnalyzerDependenciesContext#inferredRange}). */
|
|
131
|
+
inferredRange(name: string): Range | undefined;
|
|
132
132
|
/** delegate request addition */
|
|
133
133
|
addRequests(requests: readonly RAnalysisRequest[]): void;
|
|
134
134
|
addFile(f: string | FlowrFileProvider | RParseRequestFromFile): void;
|
|
@@ -181,9 +181,9 @@ class FlowrAnalyzerContext {
|
|
|
181
181
|
projectKind() {
|
|
182
182
|
return this.files.projectKind();
|
|
183
183
|
}
|
|
184
|
-
/** The versions a dependency can possibly have (delegates to {@link FlowrAnalyzerDependenciesContext#
|
|
185
|
-
|
|
186
|
-
return this.deps.
|
|
184
|
+
/** The versions a dependency can possibly have (delegates to {@link FlowrAnalyzerDependenciesContext#inferredRange}). */
|
|
185
|
+
inferredRange(name) {
|
|
186
|
+
return this.deps.inferredRange(name);
|
|
187
187
|
}
|
|
188
188
|
/** delegate request addition */
|
|
189
189
|
addRequests(requests) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AbstractFlowrAnalyzerContext } from './abstract-flowr-analyzer-context';
|
|
2
2
|
import { FlowrAnalyzerPackageVersionsPlugin, type SigDbLoadedInfo } from '../plugins/package-version-plugins/flowr-analyzer-package-versions-plugin';
|
|
3
|
-
import
|
|
3
|
+
import { Package } from '../plugins/package-version-plugins/package';
|
|
4
4
|
import type { PackageSignatureSource } from '../sigdb/reader';
|
|
5
5
|
import { Identifier } from '../../dataflow/environments/identifier';
|
|
6
6
|
import type { DecodedFunction } from '../sigdb/decode';
|
|
@@ -22,28 +22,48 @@ export interface ReadOnlyFlowrAnalyzerDependenciesContext {
|
|
|
22
22
|
* Get the dependency with the given name, if it exists.
|
|
23
23
|
*
|
|
24
24
|
* If the static dependencies have not yet been loaded, this may trigger a resolution step.
|
|
25
|
-
*
|
|
25
|
+
* Pass `version` to pin the resolution to a constraint (an exact version string, or a {@link Range}; uncached;
|
|
26
|
+
* `versionOverrides` config still wins, base-R stays tied to the assumed R version); otherwise the version
|
|
27
|
+
* comes from the declared constraints.
|
|
28
|
+
* @param name - The name of the dependency to get.
|
|
29
|
+
* @param version - Optional version constraint to pin the resolution to (exact version string or a {@link Range}).
|
|
26
30
|
* @returns The dependency with the given name, or undefined if it does not exist.
|
|
27
31
|
*/
|
|
28
|
-
getDependency(name: string): Readonly<Package> | undefined;
|
|
32
|
+
getDependency(name: string, version?: string | Range): Readonly<Package> | undefined;
|
|
29
33
|
/**
|
|
30
|
-
* The versions a dependency can possibly have
|
|
31
|
-
*
|
|
32
|
-
*
|
|
34
|
+
* The versions a dependency can possibly have: its {@link Package.derivedRange|derived range}, but only once
|
|
35
|
+
* some version can satisfy it. `undefined` if the dependency is unknown, if nothing constrains it, or if the
|
|
36
|
+
* sources contradict each other, since then no version is possible at all.
|
|
33
37
|
*
|
|
34
38
|
* For *why* it is what it is (the individual constraints, or the version the database resolved to), take the
|
|
35
39
|
* {@link Package} from {@link getDependency}.
|
|
36
40
|
* @param name - The name of the dependency.
|
|
37
41
|
*/
|
|
38
|
-
|
|
42
|
+
inferredRange(name: string): Range | undefined;
|
|
39
43
|
/**
|
|
40
44
|
* Get all dependencies known to this context.
|
|
41
45
|
*/
|
|
42
46
|
getDependencies(): readonly Readonly<Package>[];
|
|
47
|
+
/**
|
|
48
|
+
* Every package name the project *declares* (`Depends`/`Imports`/`Suggests`/`LinkingTo`/`Enhances`), whether or
|
|
49
|
+
* not it became a loadable dependency here. `Suggests` do not, yet they still name packages the project may install.
|
|
50
|
+
*/
|
|
51
|
+
declaredPackageNames(): readonly string[];
|
|
43
52
|
/**
|
|
44
53
|
* Metadata of the signature databases the version plugins currently have loaded.
|
|
45
54
|
*/
|
|
46
55
|
loadedSignatureDatabases(): SigDbLoadedInfo[];
|
|
56
|
+
/**
|
|
57
|
+
* The identifying names (scopes, e.g. `base`/`current`/`history`) of the signature databases currently
|
|
58
|
+
* available, deduplicated. A simple view over {@link loadedSignatureDatabases} for checking what a project
|
|
59
|
+
* can resolve against; empty when the signature database is disabled or none is loaded.
|
|
60
|
+
*/
|
|
61
|
+
availableSignatureDatabases(): readonly string[];
|
|
62
|
+
/**
|
|
63
|
+
* Whether at least one signature database is available (i.e., {@link availableSignatureDatabases} is non-empty).
|
|
64
|
+
* Cheaper than materializing the list when only the presence matters.
|
|
65
|
+
*/
|
|
66
|
+
hasSignatureDatabase(): boolean;
|
|
47
67
|
/**
|
|
48
68
|
* The names of known packages that export `name` (from the version plugins' signature databases). Used to
|
|
49
69
|
* hint which `library()`/`::` might be missing for an otherwise-undefined symbol. Empty if no database is
|
|
@@ -76,6 +96,8 @@ export declare class FlowrAnalyzerDependenciesContext extends AbstractFlowrAnaly
|
|
|
76
96
|
/** Register a resolver consulted by {@link getDependency} to fill in a package's exports lazily. */
|
|
77
97
|
addLazyResolver(resolver: (name: string, existing?: Package) => Package | undefined): void;
|
|
78
98
|
loadedSignatureDatabases(): SigDbLoadedInfo[];
|
|
99
|
+
availableSignatureDatabases(): readonly string[];
|
|
100
|
+
hasSignatureDatabase(): boolean;
|
|
79
101
|
packagesExporting(name: string): readonly string[];
|
|
80
102
|
signatureSources(): readonly PackageSignatureSource[];
|
|
81
103
|
signatureOf(id: Identifier, version?: string): DecodedFunction | undefined;
|
|
@@ -99,7 +121,10 @@ export declare class FlowrAnalyzerDependenciesContext extends AbstractFlowrAnaly
|
|
|
99
121
|
*/
|
|
100
122
|
addDeclaredDependency(pkg: Package): this;
|
|
101
123
|
addDependency(pkg: Package): this;
|
|
102
|
-
getDependency(name: string): Package | undefined;
|
|
103
|
-
|
|
124
|
+
getDependency(name: string, version?: string | Range): Package | undefined;
|
|
125
|
+
/** Resolve `name` constrained to `range` via the plugins (uncached); falls back to the cached dependency. */
|
|
126
|
+
private resolvePinnedDependency;
|
|
127
|
+
inferredRange(name: string): Range | undefined;
|
|
104
128
|
getDependencies(): Package[];
|
|
129
|
+
declaredPackageNames(): string[];
|
|
105
130
|
}
|