@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
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.cranPageUrl = cranPageUrl;
|
|
4
4
|
exports.cranMirrorSourceUrl = cranMirrorSourceUrl;
|
|
5
|
+
exports.rSourceRef = rSourceRef;
|
|
5
6
|
exports.rdrrDocUrl = rdrrDocUrl;
|
|
6
7
|
exports.signatureFunctionInfo = signatureFunctionInfo;
|
|
7
8
|
exports.signaturePackageInfo = signaturePackageInfo;
|
|
@@ -99,7 +100,23 @@ function cranMirrorSourceUrl(pkg, version, file, line) {
|
|
|
99
100
|
const anchor = line !== undefined && line >= 0 ? `#L${line}` : '';
|
|
100
101
|
return `${cranMirrorRepoUrl(pkg)}/blob/${ref}/${file}${anchor}`;
|
|
101
102
|
}
|
|
102
|
-
/**
|
|
103
|
+
/** read-only GitHub mirror of R's own SVN; base packages live under `src/library/<pkg>` */
|
|
104
|
+
const RSourceMirror = 'https://github.com/wch/r-source';
|
|
105
|
+
/**
|
|
106
|
+
* The mirror ref holding an R version. The mirror carries no tags, only a `R-<major>-<minor>-branch` per release
|
|
107
|
+
* series, so a link is exact to the minor release and points at its latest patch; `trunk` stands in when the version
|
|
108
|
+
* is unknown.
|
|
109
|
+
*/
|
|
110
|
+
function rSourceRef(version) {
|
|
111
|
+
const series = /^(\d+)\.(\d+)/.exec(version ?? '');
|
|
112
|
+
return series ? `R-${series[1]}-${series[2]}-branch` : 'trunk';
|
|
113
|
+
}
|
|
114
|
+
/** deep-link a base-R definition into the R sources mirror at the release series of `version` */
|
|
115
|
+
function rSourceUrl(pkg, version, file, line) {
|
|
116
|
+
const anchor = line !== undefined && line >= 0 ? `#L${line}` : '';
|
|
117
|
+
return `${RSourceMirror}/blob/${rSourceRef(version)}/src/library/${encodeURIComponent(pkg)}/${file}${anchor}`;
|
|
118
|
+
}
|
|
119
|
+
/** function/topic names that map cleanly to a man page (skip operators like `+.gg`, `[.data.frame`; Rd topics allow hyphens, e.g. `dplyr-package`) */
|
|
103
120
|
const RdrrTopicName = /^[A-Za-z.][A-Za-z0-9._-]*$/;
|
|
104
121
|
/** best-effort rdrr.io documentation link: `/r/<pkg>/<fn>` for base R, `/cran/<pkg>/man/<fn>` for CRAN */
|
|
105
122
|
function rdrrDocUrl(pkg, fn, opts) {
|
|
@@ -114,18 +131,48 @@ function rdrrDocUrl(pkg, fn, opts) {
|
|
|
114
131
|
}
|
|
115
132
|
return undefined;
|
|
116
133
|
}
|
|
117
|
-
/**
|
|
118
|
-
|
|
119
|
-
|
|
134
|
+
/**
|
|
135
|
+
* The `.Rd` help source of a topic *at the queried version*, on the same mirrors the source links use. rdrr.io only
|
|
136
|
+
* serves a package's current release, so {@link rdrrDocUrl} silently answers for the wrong version whenever an older
|
|
137
|
+
* one was asked for; this link cannot drift.
|
|
138
|
+
*/
|
|
139
|
+
function manPageUrl(pkg, topic, version, opts) {
|
|
140
|
+
if (!RdrrTopicName.test(topic)) {
|
|
141
|
+
return undefined;
|
|
142
|
+
}
|
|
143
|
+
if (opts.base) {
|
|
144
|
+
return rSourceUrl(pkg, version, `man/${topic}.Rd`);
|
|
145
|
+
}
|
|
146
|
+
return opts.cran ? cranMirrorSourceUrl(pkg, version, `man/${topic}.Rd`) : undefined;
|
|
147
|
+
}
|
|
148
|
+
/** the doc links for a function: its help topic (else its name), or none when it is proven undocumented (`no-doc`) */
|
|
149
|
+
function docUrlsFor(pkg, fn, version, base, cran) {
|
|
150
|
+
if (fn.props.includes('no-doc')) {
|
|
151
|
+
return {};
|
|
152
|
+
}
|
|
153
|
+
const topic = fn.topic ?? fn.name;
|
|
154
|
+
const doc = rdrrDocUrl(pkg, topic, { base, cran });
|
|
155
|
+
const man = manPageUrl(pkg, topic, version, { base, cran });
|
|
156
|
+
return { ...(doc ? { docUrl: doc } : {}), ...(man ? { manUrl: man } : {}) };
|
|
157
|
+
}
|
|
158
|
+
/** the source link of a definition: the CRAN mirror at its version tag, or the R sources mirror for a base package */
|
|
159
|
+
function sourceUrlFor(pkg, fn, version, base, cran) {
|
|
160
|
+
if (!fn.file) {
|
|
161
|
+
return undefined;
|
|
162
|
+
}
|
|
163
|
+
if (base) {
|
|
164
|
+
return rSourceUrl(pkg, version, fn.file, fn.line);
|
|
165
|
+
}
|
|
166
|
+
return cran ? cranMirrorSourceUrl(pkg, version, fn.file, fn.line) : undefined;
|
|
120
167
|
}
|
|
121
|
-
/** the trailing fields shared by every function view: definition location,
|
|
168
|
+
/** the trailing fields shared by every function view: definition location, source link, and documentation links */
|
|
122
169
|
function locationFields(pkg, fn, version, base, cran) {
|
|
123
|
-
const
|
|
170
|
+
const source = sourceUrlFor(pkg, fn, version, base, cran);
|
|
124
171
|
return {
|
|
125
172
|
...(fn.file ? { file: fn.file } : {}),
|
|
126
173
|
...(fn.line >= 0 ? { line: fn.line } : {}),
|
|
127
|
-
...(
|
|
128
|
-
...(
|
|
174
|
+
...(source ? { sourceUrl: source } : {}),
|
|
175
|
+
...docUrlsFor(pkg, fn, version, base, cran)
|
|
129
176
|
};
|
|
130
177
|
}
|
|
131
178
|
/** the decoded view of one function, adding the CRAN-mirror source link */
|
|
@@ -148,7 +195,7 @@ function decodedToView(pkg, fn, version, opts) {
|
|
|
148
195
|
}
|
|
149
196
|
/**
|
|
150
197
|
* The detailed view of a single function within a package: its signature (parameters, forced/optional,
|
|
151
|
-
* defaults), properties, definition location, call graph, and
|
|
198
|
+
* defaults), properties, definition location, call graph, and for a CRAN package a deep link into the
|
|
152
199
|
* read-only CRAN GitHub mirror. `version` defaults to the source's latest; `undefined` when the source does
|
|
153
200
|
* not carry that function.
|
|
154
201
|
*/
|
|
@@ -160,40 +207,70 @@ function signatureFunctionInfo(src, pkg, fnName, version) {
|
|
|
160
207
|
}
|
|
161
208
|
const exports = src.lookup(pkg, version) ?? src.lookup(pkg);
|
|
162
209
|
const view = decodedToView(pkg, fn, exports?.version, { cran: exports?.cran ?? false, base: src.isBaseR(pkg) });
|
|
163
|
-
// an S3 generic's methods are the
|
|
164
|
-
//
|
|
210
|
+
// an S3 generic's methods are the `<generic>.<class>` functions that resolve back to it (see s3MethodParts);
|
|
211
|
+
// the reverse links a method to the generic it dispatches for
|
|
165
212
|
const methods = (fns ?? [])
|
|
166
|
-
.filter(f => f.name !== fn.name && f.name.startsWith(fn.name + '.') &&
|
|
213
|
+
.filter(f => f.name !== fn.name && f.name.startsWith(fn.name + '.') && s3MethodParts(src, pkg, fns, f)?.generic === fn.name)
|
|
167
214
|
.map(f => f.name)
|
|
168
215
|
.sort();
|
|
169
|
-
const s3method =
|
|
216
|
+
const s3method = s3MethodParts(src, pkg, fns, fn);
|
|
170
217
|
return {
|
|
171
218
|
...view,
|
|
172
219
|
...(methods.length > 0 ? { s3generic: true, s3methods: methods } : {}),
|
|
173
220
|
...(s3method ? { s3method } : {})
|
|
174
221
|
};
|
|
175
222
|
}
|
|
176
|
-
/** whether
|
|
177
|
-
function
|
|
178
|
-
return fn.
|
|
223
|
+
/** whether `fn` is an S3 generic: its body dispatches via `UseMethod`, so `<name>.<class>` functions can be its methods */
|
|
224
|
+
function dispatchesGeneric(fn) {
|
|
225
|
+
return fn.callees.includes('UseMethod');
|
|
226
|
+
}
|
|
227
|
+
/** the function named `generic`, resolved in `pkg` first, then base R, with the package it was found in */
|
|
228
|
+
function resolveGeneric(src, pkg, fns, generic) {
|
|
229
|
+
const local = fns?.find(f => f.name === generic);
|
|
230
|
+
if (local) {
|
|
231
|
+
return { fn: local, package: pkg };
|
|
232
|
+
}
|
|
233
|
+
for (const base of (0, r_base_packages_1.baseRPackages)()) {
|
|
234
|
+
if (base !== pkg) {
|
|
235
|
+
const fn = src.functionByName(base, generic);
|
|
236
|
+
if (fn) {
|
|
237
|
+
return { fn, package: base };
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return undefined;
|
|
242
|
+
}
|
|
243
|
+
/** whether `cls` is a class a loaded package registers S3 methods for (the method's own package, or base R) */
|
|
244
|
+
function isKnownS3Class(src, pkg, cls) {
|
|
245
|
+
if (src.lookup(pkg)?.s3Classes.includes(cls)) {
|
|
246
|
+
return true;
|
|
247
|
+
}
|
|
248
|
+
for (const base of (0, r_base_packages_1.baseRPackages)()) {
|
|
249
|
+
if (base !== pkg && src.lookup(base)?.s3Classes.includes(cls)) {
|
|
250
|
+
return true;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
return false;
|
|
254
|
+
}
|
|
255
|
+
/** the `generic.class` readings of a dotted name, longest generic first (`as.data.frame.matrix` before `as.data`) */
|
|
256
|
+
function* dottedSplits(name) {
|
|
257
|
+
for (let dot = name.lastIndexOf('.'); dot > 0; dot = name.lastIndexOf('.', dot - 1)) {
|
|
258
|
+
yield [name.slice(0, dot), name.slice(dot + 1)];
|
|
259
|
+
}
|
|
179
260
|
}
|
|
180
261
|
/**
|
|
181
|
-
* The generic and dispatch class of
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
262
|
+
* The generic and dispatch class of an S3 method named `generic.class`, or `undefined` when `fn` is not one.
|
|
263
|
+
*
|
|
264
|
+
* The crawled `s3-method` property settles it when present. It is missing for a base method whose generic lives in
|
|
265
|
+
* another package (`stats` never flags `print.acf`, since `print` is in `base`), so then the prefix must name a
|
|
266
|
+
* dispatching generic and the suffix a registered class. Dropping either check would split `data.frame` or `t.test`.
|
|
185
267
|
*/
|
|
186
|
-
function s3MethodParts(src, pkg, fns,
|
|
187
|
-
const
|
|
188
|
-
for (
|
|
189
|
-
const
|
|
190
|
-
if (
|
|
191
|
-
return { generic, class:
|
|
192
|
-
}
|
|
193
|
-
for (const base of bases) {
|
|
194
|
-
if (base !== pkg && src.functionByName(base, generic) !== undefined) {
|
|
195
|
-
return { generic, class: name.slice(dot + 1), package: base };
|
|
196
|
-
}
|
|
268
|
+
function s3MethodParts(src, pkg, fns, fn) {
|
|
269
|
+
const flagged = fn.props.includes('s3-method');
|
|
270
|
+
for (const [generic, cls] of dottedSplits(fn.name)) {
|
|
271
|
+
const g = resolveGeneric(src, pkg, fns, generic);
|
|
272
|
+
if (g && (flagged || (dispatchesGeneric(g.fn) && isKnownS3Class(src, pkg, cls)))) {
|
|
273
|
+
return { generic, class: cls, package: g.package };
|
|
197
274
|
}
|
|
198
275
|
}
|
|
199
276
|
return undefined;
|
|
@@ -260,7 +337,7 @@ function signatureCallGraphUrl(src, pkg, version, root) {
|
|
|
260
337
|
for (const callee of src.functionByName(cur.owner, cur.name, cur.ver)?.callees ?? []) {
|
|
261
338
|
const r = resolve(cur.owner, cur.ver, callee);
|
|
262
339
|
edges.push(` ${cur.id} --> ${node(r?.owner, r ? r.name : callee)}`);
|
|
263
|
-
// expand into a resolved same/other CRAN package (not base R
|
|
340
|
+
// expand into a resolved same/other CRAN package (not base R, whose internals explode the graph), avoiding cycles
|
|
264
341
|
if (r && !bases.has(r.owner) && !seen.has(`${r.owner}::${r.name}`) && nodes.size < CallGraphMaxNodes) {
|
|
265
342
|
queue.push({ owner: r.owner, ver: r.owner === cur.owner ? cur.ver : src.latestVersion(r.owner)?.str, name: r.name, id: node(r.owner, r.name) });
|
|
266
343
|
}
|
|
@@ -364,16 +441,12 @@ function matchedParamPreview(fn, q) {
|
|
|
364
441
|
}
|
|
365
442
|
/** a compact view for a wildcard search hit (signature/call-graph omitted; the JSON dump carries those per name) */
|
|
366
443
|
function compactMatch(pkg, fn, version, base, cran, params) {
|
|
367
|
-
const doc = docUrlFor(pkg, fn, base, cran);
|
|
368
444
|
return {
|
|
369
445
|
package: pkg,
|
|
370
446
|
name: fn.name,
|
|
371
447
|
exported: fn.exported,
|
|
372
448
|
...(version !== undefined ? { version } : {}),
|
|
373
|
-
...(
|
|
374
|
-
...(fn.line >= 0 ? { line: fn.line } : {}),
|
|
375
|
-
...(cran && !base && fn.file ? { sourceUrl: cranMirrorSourceUrl(pkg, version, fn.file, fn.line) } : {}),
|
|
376
|
-
...(doc ? { docUrl: doc } : {}),
|
|
449
|
+
...locationFields(pkg, fn, version, base, cran),
|
|
377
450
|
...(params && params.preview.length > 0 ? { parameters: params.preview } : {}),
|
|
378
451
|
...(params && params.matched.length > 0 ? { matchedParameters: params.matched } : {})
|
|
379
452
|
};
|
|
@@ -391,7 +464,7 @@ function allAvailableVersions(sources, pkg) {
|
|
|
391
464
|
return [...set].sort((a, b) => r_version_1.RVersion.compare(a, b));
|
|
392
465
|
}
|
|
393
466
|
/**
|
|
394
|
-
* The owning source that actually carries `version
|
|
467
|
+
* The owning source that actually carries `version`: `current` is checked before `history`, so a
|
|
395
468
|
* latest-version query never decompresses the (large) history shard. Returns the first owner when no version
|
|
396
469
|
* was asked, or `undefined` when an explicit version is carried by none of them.
|
|
397
470
|
*/
|
|
@@ -449,7 +522,7 @@ function searchSources(sources, allNames, q) {
|
|
|
449
522
|
}
|
|
450
523
|
const fnMatch = q.function ? nameMatcher(q.function) : () => true;
|
|
451
524
|
// an exact function name lets us seek that one record (decoding only it) instead of decoding every function of
|
|
452
|
-
// every package
|
|
525
|
+
// every package, the difference between a fast `* ggplot` and one that decodes the whole database
|
|
453
526
|
const exactName = q.function !== undefined && !hasGlob(q.function);
|
|
454
527
|
const matches = [];
|
|
455
528
|
let searched = 0;
|
|
@@ -631,6 +704,9 @@ async function executeSignatureQuery({ analyzer }, queries) {
|
|
|
631
704
|
return { ...meta(), message: versionNotFoundMessage(q.package, `no release of '${q.package}' matches '${q.version}'.`, avail, owning[0].isBaseR(q.package)) };
|
|
632
705
|
}
|
|
633
706
|
}
|
|
707
|
+
if (found.matchCount === 0 && q.function !== undefined && !hasGlob(q.function)) {
|
|
708
|
+
return { ...meta(), ...found, message: `No function named exactly '${q.function}'. Try a wildcard like '*${q.function}*'.` };
|
|
709
|
+
}
|
|
634
710
|
return { ...meta(), ...found };
|
|
635
711
|
}
|
|
636
712
|
// every source holding the package: `current` keeps the latest, `history` the older releases, so the resolved
|
|
@@ -49,10 +49,12 @@ export interface SignatureFunctionView {
|
|
|
49
49
|
readonly callees: readonly string[];
|
|
50
50
|
readonly file?: string;
|
|
51
51
|
readonly line?: number;
|
|
52
|
-
/** deep link
|
|
52
|
+
/** deep link to the definition on the read-only GitHub mirror of the sources (CRAN, or R's own for a base package) */
|
|
53
53
|
readonly sourceUrl?: string;
|
|
54
54
|
/** best-effort rdrr.io documentation link, when the function name maps to a documentable topic */
|
|
55
55
|
readonly docUrl?: string;
|
|
56
|
+
/** link to the `.Rd` help source *at the queried version*, which {@link docUrl} cannot offer (rdrr.io only serves the current release) */
|
|
57
|
+
readonly manUrl?: string;
|
|
56
58
|
/** whether the function looks like an S3 generic (has `<generic>.<class>` dispatch targets in the same package) */
|
|
57
59
|
readonly s3generic?: boolean;
|
|
58
60
|
/** the `<generic>.<class>` dispatch targets found in the same package */
|
|
@@ -108,6 +110,8 @@ export interface SignatureMatchView {
|
|
|
108
110
|
readonly sourceUrl?: string;
|
|
109
111
|
/** best-effort rdrr.io documentation link, when the function name maps to a documentable topic */
|
|
110
112
|
readonly docUrl?: string;
|
|
113
|
+
/** link to the `.Rd` help source at the queried version, see {@link SignatureFunctionView.manUrl} */
|
|
114
|
+
readonly manUrl?: string;
|
|
111
115
|
/** a preview of the function's parameters (the ones a parameter/required filter matched first), when such a filter is active */
|
|
112
116
|
readonly parameters?: readonly string[];
|
|
113
117
|
/** the subset of {@link parameters} that the `--param` filter actually matched, so the renderer can highlight them */
|
|
@@ -34,7 +34,7 @@ function signatureQueryLineParser(output, line, _config) {
|
|
|
34
34
|
positional.push(tok);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
// help only when it is the leading word or an explicit flag
|
|
37
|
+
// help only when it is the leading word or an explicit flag, never for a package/function literally named `help`
|
|
38
38
|
if (positional[0] === 'help' || line.includes('--help') || line.includes('-h')) {
|
|
39
39
|
(0, signature_query_render_1.printSignatureHelp)(output);
|
|
40
40
|
return { query: [] };
|
|
@@ -38,12 +38,12 @@ const MaxList = 25;
|
|
|
38
38
|
const baseSet = new Set((0, r_base_packages_1.baseRPackages)());
|
|
39
39
|
/** a package name linked to its CRAN page (unless it is base R / the `R` language pseudo-package) */
|
|
40
40
|
function linkPackage(name, f) {
|
|
41
|
-
return name === 'R' || baseSet.has(name) ? name : f.hyperlink(name, (0, signature_query_executor_1.cranPageUrl)(name));
|
|
41
|
+
return name === 'R' || baseSet.has(name) ? name : f.hyperlink(name, (0, signature_query_executor_1.cranPageUrl)(name), true);
|
|
42
42
|
}
|
|
43
43
|
/** a `file:line` location, linked to its source when a url is known */
|
|
44
44
|
function linkLocation(file, line, url, f) {
|
|
45
45
|
const text = `${file}${line !== undefined ? `:${line}` : ''}`;
|
|
46
|
-
return url ? f.hyperlink(text, url) : text;
|
|
46
|
+
return url ? f.hyperlink(text, url, true) : text;
|
|
47
47
|
}
|
|
48
48
|
/** render one parameter: required (no default) in yellow, non-forced (lazily evaluated) italicised, default dimmed */
|
|
49
49
|
function renderParameter(f, p) {
|
|
@@ -70,8 +70,12 @@ function pushFunction(result, f, fn) {
|
|
|
70
70
|
const loc = `${fn.file}${fn.line !== undefined ? `:${fn.line}` : ''}`;
|
|
71
71
|
result.push(` ╰ ${(0, ansi_1.italic)('source', f)} ${fn.sourceUrl ? `${loc} ${f.hyperlink(fn.sourceUrl, fn.sourceUrl)}` : loc}`);
|
|
72
72
|
}
|
|
73
|
-
if (fn.docUrl) {
|
|
74
|
-
|
|
73
|
+
if (fn.docUrl || fn.manUrl) {
|
|
74
|
+
const links = [
|
|
75
|
+
...(fn.docUrl ? [f.hyperlink('rdrr.io', fn.docUrl)] : []),
|
|
76
|
+
...(fn.manUrl ? [f.hyperlink(fn.version ? `man v${fn.version}` : 'man', fn.manUrl)] : [])
|
|
77
|
+
];
|
|
78
|
+
result.push(` ╰ ${(0, ansi_1.italic)('docs', f)} ${links.join(' ')}`);
|
|
75
79
|
}
|
|
76
80
|
if (fn.s3method) {
|
|
77
81
|
result.push(` ╰ ${(0, ansi_1.italic)('S3 method of', f)} ${(0, ansi_1.color)(`${fn.s3method.package}::${fn.s3method.generic}`, 5 /* Colors.Magenta */, f)} ${(0, ansi_1.italic)(`(class ${fn.s3method.class})`, f)}`);
|
|
@@ -86,7 +90,7 @@ function pushFunction(result, f, fn) {
|
|
|
86
90
|
listLine('dispatches to', fn.s3methods ?? [], MaxList);
|
|
87
91
|
listLine('calls', fn.callees, MaxList);
|
|
88
92
|
if (fn.callGraph) {
|
|
89
|
-
result.push(` ╰ ${(0, ansi_1.italic)('call graph', f)} ${f.hyperlink('mermaid', fn.callGraph)}`);
|
|
93
|
+
result.push(` ╰ ${(0, ansi_1.italic)('call graph', f)} ${f.hyperlink('mermaid', fn.callGraph, true)}`);
|
|
90
94
|
}
|
|
91
95
|
}
|
|
92
96
|
/** render the full view of a single package into `result` */
|
|
@@ -154,7 +158,8 @@ function pushMatches(result, f, out) {
|
|
|
154
158
|
? `${(0, ansi_1.italic)('(', f)}${m.parameters.map(p => matched.has(p) ? (0, ansi_1.color)(p, 3 /* Colors.Yellow */, f, { style: 1 /* FontStyles.Bold */ }) : (0, ansi_1.italic)(p, f)).join((0, ansi_1.italic)(', ', f))}${(0, ansi_1.italic)(')', f)}`
|
|
155
159
|
: '';
|
|
156
160
|
const loc = m.file ? ` ${linkLocation(m.file, m.line, m.sourceUrl, f)}` : '';
|
|
157
|
-
|
|
161
|
+
// one link on a search hit: the version-exact help page when there is one, else the rdrr.io page
|
|
162
|
+
const doc = m.manUrl ? ` ${f.hyperlink('man', m.manUrl)}` : (m.docUrl ? ` ${f.hyperlink('docs', m.docUrl)}` : '');
|
|
158
163
|
result.push(` ╰ ${(0, ansi_1.color)(m.package, 6 /* Colors.Cyan */, f)}::${(0, ansi_1.bold)(m.name, f)}${params}${m.version ? (0, ansi_1.italic)(` v${m.version}`, f) : ''}${loc}${doc}`);
|
|
159
164
|
}
|
|
160
165
|
}
|
|
@@ -164,7 +169,7 @@ function pushPackages(result, f, out) {
|
|
|
164
169
|
const cap = out.truncated ? (0, ansi_1.italic)(` (capped at ${packages.length})`, f) : '';
|
|
165
170
|
result.push(` ╰ ${(0, ansi_1.bold)(String(packages.length), f)} package${packages.length === 1 ? '' : 's'} matched${cap}`);
|
|
166
171
|
for (const pm of packages) {
|
|
167
|
-
const name = pm.cranPage ? f.hyperlink((0, ansi_1.color)(pm.name, 6 /* Colors.Cyan */, f), pm.cranPage) : (0, ansi_1.color)(pm.name, 6 /* Colors.Cyan */, f);
|
|
172
|
+
const name = pm.cranPage ? f.hyperlink((0, ansi_1.color)(pm.name, 6 /* Colors.Cyan */, f), pm.cranPage, true) : (0, ansi_1.color)(pm.name, 6 /* Colors.Cyan */, f);
|
|
168
173
|
const kind = pm.base ? (0, ansi_1.italic)(' base R', f) : pm.cran ? (0, ansi_1.italic)(' CRAN', f) : '';
|
|
169
174
|
const vers = pm.versions ? `: ${pm.versions.join(', ')}` : pm.latest ? ` ${(0, ansi_1.color)('v' + pm.latest, 2 /* Colors.Green */, f)}` : '';
|
|
170
175
|
result.push(` ╰ ${name}${vers}${kind}`);
|
package/queries/query.js
CHANGED
|
@@ -36,6 +36,7 @@ const linter_query_format_1 = require("./catalog/linter-query/linter-query-forma
|
|
|
36
36
|
const control_flow_query_format_1 = require("./catalog/control-flow-query/control-flow-query-format");
|
|
37
37
|
const inspect_higher_order_query_format_1 = require("./catalog/inspect-higher-order-query/inspect-higher-order-query-format");
|
|
38
38
|
const log_1 = require("../util/log");
|
|
39
|
+
const fs_1 = __importDefault(require("fs"));
|
|
39
40
|
const files_query_format_1 = require("./catalog/files-query/files-query-format");
|
|
40
41
|
const call_graph_query_format_1 = require("./catalog/call-graph-query/call-graph-query-format");
|
|
41
42
|
const inspect_recursion_query_format_1 = require("./catalog/inspect-recursion-query/inspect-recursion-query-format");
|
|
@@ -134,7 +135,7 @@ async function executeQueries(data, queries) {
|
|
|
134
135
|
}
|
|
135
136
|
catch (e) {
|
|
136
137
|
const message = e instanceof Error ? e.message : String(e);
|
|
137
|
-
log_1.log.error(`query of type '${type}' failed: ${message}`);
|
|
138
|
+
log_1.log.error(`query of type '${type}' failed: ${message.split('\n')[0]}`);
|
|
138
139
|
results.push([type, { '.meta': { timing: 0 }, error: message }]);
|
|
139
140
|
}
|
|
140
141
|
}
|
|
@@ -182,7 +183,13 @@ async function genericWrapReplFailIfNoRequest(fn, output, analyzer) {
|
|
|
182
183
|
return await fn();
|
|
183
184
|
}
|
|
184
185
|
catch (e) {
|
|
185
|
-
|
|
186
|
+
const files = analyzer.inspectContext().files;
|
|
187
|
+
if (files.loadingOrder.getUnorderedRequests().length === 0) {
|
|
188
|
+
const missing = files.getRequestedRoots().filter(p => !fs_1.default.existsSync(p));
|
|
189
|
+
if (missing.length > 0) {
|
|
190
|
+
output.stderr(output.formatter.format(`Path does not exist: ${missing.map(p => `'${p}'`).join(', ')}`, { color: 1 /* Colors.Red */, style: 1 /* FontStyles.Bold */, effect: ansi_1.ColorEffect.Foreground }));
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
186
193
|
output.stderr(output.formatter.format('No requests to analyze were found.', { color: 1 /* Colors.Red */, style: 1 /* FontStyles.Bold */, effect: ansi_1.ColorEffect.Foreground })
|
|
187
194
|
+ '\nIf you consider this an error, please report a bug: '
|
|
188
195
|
+ (0, assert_1.getGuardIssueUrl)('analyzer found no requests to analyze'));
|
package/r-bridge/data/data.d.ts
CHANGED
|
@@ -228,6 +228,11 @@ export declare const flowrCapabilities: {
|
|
|
228
228
|
readonly id: "functions-with-global-side-effects";
|
|
229
229
|
readonly supported: "partially";
|
|
230
230
|
readonly description: "_Support functions like `setwd` which have an impact on the subsequent program._";
|
|
231
|
+
}, {
|
|
232
|
+
readonly name: "Working Directory";
|
|
233
|
+
readonly id: "working-directory";
|
|
234
|
+
readonly supported: "partially";
|
|
235
|
+
readonly description: "_Track the effective working directory across `setwd` (control-flow- and location-sensitive) to resolve relative file paths. Interprocedural, sourced, and loop cases are treated as unbounded rather than guessed._";
|
|
231
236
|
}, {
|
|
232
237
|
readonly name: "Index Access";
|
|
233
238
|
readonly id: "index-access";
|
package/r-bridge/data/data.js
CHANGED
|
@@ -297,6 +297,12 @@ ${await (0, doc_dfg_1.printDfGraphForCode)(parser, code, { simplified: true })}
|
|
|
297
297
|
supported: 'partially',
|
|
298
298
|
description: '_Support functions like `setwd` which have an impact on the subsequent program._'
|
|
299
299
|
},
|
|
300
|
+
{
|
|
301
|
+
name: 'Working Directory',
|
|
302
|
+
id: 'working-directory',
|
|
303
|
+
supported: 'partially',
|
|
304
|
+
description: '_Track the effective working directory across `setwd` (control-flow- and location-sensitive) to resolve relative file paths. Interprocedural, sourced, and loop cases are treated as unbounded rather than guessed._'
|
|
305
|
+
},
|
|
300
306
|
{
|
|
301
307
|
name: 'Index Access',
|
|
302
308
|
id: 'index-access',
|
|
@@ -102,7 +102,7 @@ function prepareParsedData(data) {
|
|
|
102
102
|
json = JSON.parse(`[${jsonSafeRParseData(data.trim())}]`);
|
|
103
103
|
}
|
|
104
104
|
catch (e) {
|
|
105
|
-
throw new Error(`Failed to parse data [${data}]: ${e?.message}
|
|
105
|
+
throw new Error(`Failed to parse data [${data}]: ${e?.message}`, { cause: e });
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
(0, assert_1.guard)(Array.isArray(json), () => `Expected ${data} to be an array but was not`);
|
package/r-bridge/retriever.d.ts
CHANGED
package/r-bridge/retriever.js
CHANGED
|
@@ -21,6 +21,7 @@ const init_1 = require("./init");
|
|
|
21
21
|
const convert_values_1 = require("./lang-4.x/convert-values");
|
|
22
22
|
const decorate_1 = require("./lang-4.x/ast/model/processing/decorate");
|
|
23
23
|
const type_1 = require("./lang-4.x/ast/model/type");
|
|
24
|
+
const log_1 = require("../util/log");
|
|
24
25
|
const fs_1 = __importDefault(require("fs"));
|
|
25
26
|
const path_1 = __importDefault(require("path"));
|
|
26
27
|
exports.fileProtocol = 'file://';
|
|
@@ -73,12 +74,16 @@ function requestProviderFromFile() {
|
|
|
73
74
|
}
|
|
74
75
|
// walk the directory and find the first match
|
|
75
76
|
const dir = path_1.default.dirname(p);
|
|
77
|
+
if (!fs_1.default.existsSync(dir)) {
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
76
80
|
const file = path_1.default.basename(p);
|
|
77
81
|
const files = fs_1.default.readdirSync(dir);
|
|
78
82
|
const found = files.find(f => f.toLowerCase() === file.toLowerCase());
|
|
79
83
|
return found ? path_1.default.join(dir, found) : undefined;
|
|
80
84
|
}
|
|
81
|
-
catch {
|
|
85
|
+
catch (e) {
|
|
86
|
+
log_1.log.warn(`Could not resolve '${p}': ${e instanceof Error ? e.message : String(e)}`);
|
|
82
87
|
return undefined;
|
|
83
88
|
}
|
|
84
89
|
},
|
package/r-bridge/shell.js
CHANGED
|
@@ -316,6 +316,11 @@ class RShellSession {
|
|
|
316
316
|
this.onExit(() => {
|
|
317
317
|
this.end();
|
|
318
318
|
});
|
|
319
|
+
this.bareSession.on('error', (err) => {
|
|
320
|
+
log.error(`Failed to start R ("${options.pathToRExecutable}"): ${err.message}. `
|
|
321
|
+
+ 'Make sure R is installed and on PATH (point flowR to it with --r-path), '
|
|
322
|
+
+ 'or skip R entirely with --engine.r-shell.disabled / --default-engine tree-sitter.');
|
|
323
|
+
});
|
|
319
324
|
this.options = options;
|
|
320
325
|
// initialize the session
|
|
321
326
|
this.writeLine((0, init_1.initCommand)(options.eol));
|
|
@@ -6,6 +6,7 @@ import type { Enrichment } from './search-executor/search-enrichers';
|
|
|
6
6
|
import type { DataflowInformation } from '../dataflow/info';
|
|
7
7
|
import type { BuiltInProcName } from '../dataflow/environments/built-in-proc-name';
|
|
8
8
|
import type { RoleInParent } from '../r-bridge/lang-4.x/ast/model/processing/role';
|
|
9
|
+
import type { Identifier } from '../dataflow/environments/identifier';
|
|
9
10
|
export type FlowrFilterName = keyof typeof FlowrFilters;
|
|
10
11
|
interface FlowrFilterWithArgs<Filter extends FlowrFilterName, Args extends FlowrFilterArgs<Filter>> {
|
|
11
12
|
name: Filter;
|
|
@@ -80,7 +81,7 @@ export interface FilePathFilterArgs {
|
|
|
80
81
|
/**
|
|
81
82
|
* Helper to create a regular expression that matches function names, ignoring their package.
|
|
82
83
|
*/
|
|
83
|
-
export declare function testFunctionsIgnoringPackage(functions: readonly
|
|
84
|
+
export declare function testFunctionsIgnoringPackage(functions: readonly Identifier[]): RegExp;
|
|
84
85
|
type ValidFilterTypes<F extends FlowrFilter = FlowrFilter> = FlowrFilterName | FlowrFilterWithArgs<F, FlowrFilterArgs<F>> | RType | VertexType;
|
|
85
86
|
/**
|
|
86
87
|
* By default, we provide filter for every {@link RType} and {@link VertexType}.
|
|
@@ -59,14 +59,16 @@ function flowrSearchToCode(search) {
|
|
|
59
59
|
function flowrTransformerToCode(node) {
|
|
60
60
|
if (node.name === 'filter') {
|
|
61
61
|
const a = node.args.filter;
|
|
62
|
-
if (
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
62
|
+
if (typeof a === 'string') {
|
|
63
|
+
if (vertex_1.ValidVertexTypes.has(a)) {
|
|
64
|
+
return `${node.name}(VertexType.${vertex_1.ValidVertexTypeReverse[a]})`;
|
|
65
|
+
}
|
|
66
|
+
else if (type_1.ValidRTypes.has(a)) {
|
|
67
|
+
return `${node.name}(RType.${type_1.ValidRTypesReverse[a]})`;
|
|
68
|
+
}
|
|
69
|
+
else if (flowr_search_filters_1.ValidFlowrFilters.has(a)) {
|
|
70
|
+
return `${node.name}(FlowrFilter.${flowr_search_filters_1.ValidFlowrFiltersReverse[a]})`;
|
|
71
|
+
}
|
|
70
72
|
}
|
|
71
73
|
}
|
|
72
74
|
return `${node.name}(${argsToCodeString(node.args)})`;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { SliceResult } from './slicer-types';
|
|
2
|
-
import {
|
|
2
|
+
import type { Fingerprint } from './fingerprint';
|
|
3
3
|
import { VisitingQueue } from './visiting-queue';
|
|
4
4
|
import type { NormalizedAst } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
5
|
-
import {
|
|
5
|
+
import type { REnvironmentInformation } from '../../dataflow/environments/environment';
|
|
6
6
|
import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
7
7
|
import type { DataflowInformation } from '../../dataflow/info';
|
|
8
8
|
import type { DataflowGraph } from '../../dataflow/graph/graph';
|
package/util/files.d.ts
CHANGED
|
@@ -9,12 +9,13 @@ export interface Table {
|
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* Retrieves all files in the given directory recursively
|
|
12
|
-
* @param dir
|
|
13
|
-
* @param suffix
|
|
12
|
+
* @param dir - Directory path to start the search from
|
|
13
|
+
* @param suffix - Suffix of the files to be retrieved
|
|
14
|
+
* @param throwOnError - If `true`, a directory that cannot be read aborts the traversal; otherwise it is logged and skipped (the default)
|
|
14
15
|
* Based on {@link https://stackoverflow.com/a/45130990}
|
|
15
16
|
* @see {@link getAllFilesSync} for a synchronous version.
|
|
16
17
|
*/
|
|
17
|
-
export declare function getAllFiles(dir: string, suffix?: RegExp): AsyncGenerator<string>;
|
|
18
|
+
export declare function getAllFiles(dir: string, suffix?: RegExp, throwOnError?: boolean): AsyncGenerator<string>;
|
|
18
19
|
/**
|
|
19
20
|
* Retrieves all files in the given directory recursively (synchronously)
|
|
20
21
|
* @param dir - Directory path to start the search from
|
|
@@ -22,9 +23,10 @@ export declare function getAllFiles(dir: string, suffix?: RegExp): AsyncGenerato
|
|
|
22
23
|
* @param ignoreDirs - Directories to skip, tested against the posix path relative to `dir`
|
|
23
24
|
* (e.g. `packrat/lib`), so a pattern can address nested directories
|
|
24
25
|
* @param relativeTo - The path to which the returned paths are relative (used for `ignoreDirs`), defaults to `dir`
|
|
26
|
+
* @param throwOnError - If `true`, a directory that cannot be read aborts the traversal; otherwise it is logged and skipped (the default)
|
|
25
27
|
* @see {@link getAllFiles} - for an asynchronous version.
|
|
26
28
|
*/
|
|
27
|
-
export declare function getAllFilesSync(dir: string, suffix?: RegExp, ignoreDirs?: RegExp | undefined, relativeTo?: string): Generator<string>;
|
|
29
|
+
export declare function getAllFilesSync(dir: string, suffix?: RegExp, ignoreDirs?: RegExp | undefined, relativeTo?: string, throwOnError?: boolean): Generator<string>;
|
|
28
30
|
/**
|
|
29
31
|
* Retrieves all R files in a given directory (asynchronously)
|
|
30
32
|
* @param input - directory-path to start the search from, can be a file as well. Will just return the file then.
|
package/util/files.js
CHANGED
|
@@ -54,17 +54,28 @@ const log_1 = require("./log");
|
|
|
54
54
|
const n_readlines_1 = __importDefault(require("n-readlines"));
|
|
55
55
|
/**
|
|
56
56
|
* Retrieves all files in the given directory recursively
|
|
57
|
-
* @param dir
|
|
58
|
-
* @param suffix
|
|
57
|
+
* @param dir - Directory path to start the search from
|
|
58
|
+
* @param suffix - Suffix of the files to be retrieved
|
|
59
|
+
* @param throwOnError - If `true`, a directory that cannot be read aborts the traversal; otherwise it is logged and skipped (the default)
|
|
59
60
|
* Based on {@link https://stackoverflow.com/a/45130990}
|
|
60
61
|
* @see {@link getAllFilesSync} for a synchronous version.
|
|
61
62
|
*/
|
|
62
|
-
async function* getAllFiles(dir, suffix =
|
|
63
|
-
|
|
63
|
+
async function* getAllFiles(dir, suffix = /.*/, throwOnError = false) {
|
|
64
|
+
let entries;
|
|
65
|
+
try {
|
|
66
|
+
entries = await fs_1.promises.readdir(dir, { withFileTypes: true, recursive: false });
|
|
67
|
+
}
|
|
68
|
+
catch (e) {
|
|
69
|
+
if (throwOnError) {
|
|
70
|
+
throw e;
|
|
71
|
+
}
|
|
72
|
+
log_1.log.warn(`Skipping '${dir}' during file discovery: ${e instanceof Error ? e.message : String(e)}`);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
64
75
|
for (const subEntries of entries) {
|
|
65
76
|
const res = path_1.default.resolve(dir, subEntries.name);
|
|
66
77
|
if (subEntries.isDirectory()) {
|
|
67
|
-
yield* getAllFiles(res, suffix);
|
|
78
|
+
yield* getAllFiles(res, suffix, throwOnError);
|
|
68
79
|
}
|
|
69
80
|
else if (suffix.test(subEntries.name)) {
|
|
70
81
|
yield res;
|
|
@@ -78,15 +89,26 @@ async function* getAllFiles(dir, suffix = /.*/) {
|
|
|
78
89
|
* @param ignoreDirs - Directories to skip, tested against the posix path relative to `dir`
|
|
79
90
|
* (e.g. `packrat/lib`), so a pattern can address nested directories
|
|
80
91
|
* @param relativeTo - The path to which the returned paths are relative (used for `ignoreDirs`), defaults to `dir`
|
|
92
|
+
* @param throwOnError - If `true`, a directory that cannot be read aborts the traversal; otherwise it is logged and skipped (the default)
|
|
81
93
|
* @see {@link getAllFiles} - for an asynchronous version.
|
|
82
94
|
*/
|
|
83
|
-
function* getAllFilesSync(dir, suffix = /.*/, ignoreDirs = undefined, relativeTo = dir) {
|
|
84
|
-
|
|
95
|
+
function* getAllFilesSync(dir, suffix = /.*/, ignoreDirs = undefined, relativeTo = dir, throwOnError = false) {
|
|
96
|
+
let entries;
|
|
97
|
+
try {
|
|
98
|
+
entries = fs_1.default.readdirSync(dir, { withFileTypes: true, recursive: false });
|
|
99
|
+
}
|
|
100
|
+
catch (e) {
|
|
101
|
+
if (throwOnError) {
|
|
102
|
+
throw e;
|
|
103
|
+
}
|
|
104
|
+
log_1.log.warn(`Skipping '${dir}' during file discovery: ${e instanceof Error ? e.message : String(e)}`);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
85
107
|
for (const subEntries of entries) {
|
|
86
108
|
const res = path_1.default.resolve(dir, subEntries.name);
|
|
87
109
|
if (subEntries.isDirectory()) {
|
|
88
110
|
if (!ignoreDirs?.test(toPosixPath(path_1.default.relative(relativeTo, res)))) {
|
|
89
|
-
yield* getAllFilesSync(res, suffix, ignoreDirs, relativeTo);
|
|
111
|
+
yield* getAllFilesSync(res, suffix, ignoreDirs, relativeTo, throwOnError);
|
|
90
112
|
}
|
|
91
113
|
}
|
|
92
114
|
else if (suffix.test(subEntries.name)) {
|
package/util/mermaid/dfg.js
CHANGED
|
@@ -184,7 +184,7 @@ function vertexToMermaid(info, mermaid, id, idPrefix, mark, includeOnlyIds) {
|
|
|
184
184
|
const lexeme = node?.lexeme ?? (node?.type === type_1.RType.ExpressionList ? node?.grouping?.[0]?.lexeme : '') ?? '??';
|
|
185
185
|
let display = lexeme;
|
|
186
186
|
if (fCall && (0, vertex_1.isFunctionCallVertex)(info)) {
|
|
187
|
-
const q = identifier_1.Identifier.toQualified((0, dfg_get_origin_1.getOriginInDfg)(mermaid.rootGraph, origId), mermaid.qualifyBaseR
|
|
187
|
+
const q = identifier_1.Identifier.toQualified((0, dfg_get_origin_1.getOriginInDfg)(mermaid.rootGraph, origId), info.name, mermaid.qualifyBaseR !== false);
|
|
188
188
|
const qs = q !== undefined ? identifier_1.Identifier.toString(q) : undefined;
|
|
189
189
|
if (qs !== undefined && qs !== lexeme) {
|
|
190
190
|
display = qs;
|