@eagleoutice/flowr 2.13.1 → 2.13.2

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.
Files changed (74) hide show
  1. package/cli/flowr.js +21 -5
  2. package/cli/repl/commands/repl-commands.js +11 -9
  3. package/cli/repl/commands/repl-query.js +1 -1
  4. package/cli/repl/commands/repl-signature.js +8 -1
  5. package/cli/repl/core.js +13 -10
  6. package/cli/repl/print-version.js +1 -1
  7. package/cli/repl/server/connection.d.ts +1 -1
  8. package/cli/repl/server/net.js +15 -0
  9. package/config.d.ts +29 -0
  10. package/config.js +54 -2
  11. package/data/sigdb/sigdb.remote.json +1 -1
  12. package/dataflow/environments/identifier.d.ts +9 -8
  13. package/dataflow/environments/identifier.js +21 -13
  14. package/dataflow/eval/resolve/resolve-working-directory.d.ts +29 -0
  15. package/dataflow/eval/resolve/resolve-working-directory.js +168 -0
  16. package/dataflow/extractor.js +2 -1
  17. package/dataflow/graph/df-helper.d.ts +3 -2
  18. package/dataflow/graph/df-helper.js +11 -15
  19. package/dataflow/graph/diff-dataflow-graph.js +1 -1
  20. package/dataflow/graph/graph-helper.js +2 -6
  21. package/dataflow/graph/graph.d.ts +24 -0
  22. package/dataflow/graph/graph.js +25 -1
  23. package/documentation/wiki-linter.js +1 -0
  24. package/documentation/wiki-mk/doc-context.d.ts +10 -0
  25. package/documentation/wiki-mk/doc-context.js +3 -0
  26. package/documentation/wiki-signature-database.js +16 -6
  27. package/linter/linter-rules.d.ts +24 -2
  28. package/linter/linter-rules.js +3 -1
  29. package/linter/rules/absolute-path.d.ts +4 -4
  30. package/linter/rules/absolute-path.js +7 -5
  31. package/linter/rules/file-path-validity.d.ts +1 -1
  32. package/linter/rules/file-path-validity.js +48 -8
  33. package/linter/rules/function-finder-util.d.ts +2 -1
  34. package/linter/rules/syntactically-valid.d.ts +58 -0
  35. package/linter/rules/syntactically-valid.js +203 -0
  36. package/linter/rules/undefined-symbol.js +3 -2
  37. package/package.json +5 -4
  38. package/project/context/classify-project-kind.d.ts +40 -0
  39. package/project/context/classify-project-kind.js +76 -0
  40. package/project/context/flowr-analyzer-dependencies-context.d.ts +23 -4
  41. package/project/context/flowr-analyzer-dependencies-context.js +23 -1
  42. package/project/context/flowr-analyzer-files-context.d.ts +10 -8
  43. package/project/context/flowr-analyzer-files-context.js +26 -67
  44. package/project/context/flowr-file.d.ts +5 -0
  45. package/project/context/flowr-file.js +5 -0
  46. package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.d.ts +12 -4
  47. package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.js +25 -10
  48. package/project/plugins/plugin-registry.d.ts +2 -1
  49. package/project/plugins/plugin-registry.js +4 -1
  50. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.d.ts +57 -2
  51. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +150 -28
  52. package/project/sigdb/decompress.d.ts +1 -1
  53. package/project/sigdb/decompress.js +4 -1
  54. package/project/sigdb/manifest.js +60 -26
  55. package/project/sigdb/sigdb-download.d.ts +6 -7
  56. package/project/sigdb/sigdb-download.js +30 -9
  57. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +0 -10
  58. package/queries/catalog/dependencies-query/dependencies-query-format.js +0 -106
  59. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +1 -1
  60. package/queries/catalog/linter-query/linter-query-format.js +9 -2
  61. package/queries/catalog/signature-query/signature-query-executor.js +3 -0
  62. package/queries/catalog/signature-query/signature-query-render.js +4 -4
  63. package/queries/query.js +9 -2
  64. package/r-bridge/data/data.d.ts +5 -0
  65. package/r-bridge/data/data.js +6 -0
  66. package/r-bridge/retriever.js +6 -1
  67. package/r-bridge/shell.js +5 -0
  68. package/search/flowr-search-filters.d.ts +2 -1
  69. package/util/files.d.ts +6 -4
  70. package/util/files.js +30 -8
  71. package/util/mermaid/dfg.js +1 -1
  72. package/util/text/ansi.d.ts +7 -3
  73. package/util/text/ansi.js +8 -5
  74. package/util/version.js +4 -4
@@ -18,6 +18,7 @@ const node_fs_1 = __importDefault(require("node:fs"));
18
18
  const node_path_1 = __importDefault(require("node:path"));
19
19
  const schema_1 = require("./schema");
20
20
  const codec_1 = require("./codec");
21
+ const decompress_1 = require("./decompress");
21
22
  exports.SigDbManifestMagic = 'flowr-sigdb-manifest';
22
23
  exports.SigDbManifestSchema = 2;
23
24
  /** write a {@link SigDbManifest} (compact JSON) plus a compressed copy per available codec (`.br` always, `.zst` when supported) beside it */
@@ -59,6 +60,20 @@ function readManifestDate(manifestFile) {
59
60
  const SigDbScopeOrder = ['full', 'current', 'base'];
60
61
  /** layouts a bundled sigdb may sit in, relative to a search root -- the root itself (e.g. a `$FLOWR_SIGDB_DIR` data mount), then the dev `src`, build `dist` and data-dir layouts */
61
62
  const SigDbSubDirs = ['', 'data/sigdb', 'src/data/sigdb', 'dist/src/data/sigdb'];
63
+ function sigDbBundleDirs() {
64
+ if (typeof node_fs_1.default?.readdirSync !== 'function') {
65
+ return [];
66
+ }
67
+ try {
68
+ const bundles = node_path_1.default.join((0, decompress_1.sigDbCacheDir)(undefined, false), 'bundles');
69
+ return node_fs_1.default.readdirSync(bundles, { withFileTypes: true })
70
+ .filter(e => e.isDirectory())
71
+ .map(e => node_path_1.default.join(bundles, e.name));
72
+ }
73
+ catch {
74
+ return [];
75
+ }
76
+ }
62
77
  /** roots to search for a bundled sigdb; extendable via `$FLOWR_SIGDB_DIR` (path-delimiter separated) */
63
78
  function sigDbSearchRoots(extra) {
64
79
  const roots = [...(extra ?? [])];
@@ -86,18 +101,25 @@ function defaultSigDbPath(scope, searchRoots) {
86
101
  return undefined;
87
102
  }
88
103
  const scopes = scope ? [scope] : SigDbScopeOrder;
89
- for (const root of sigDbSearchRoots(searchRoots)) {
90
- for (let dir = root, i = 0; i < 10; i++) {
91
- for (const sub of SigDbSubDirs) {
92
- for (const s of scopes) {
93
- for (const suffix of ['', ...(0, codec_1.readableExtsPreferred)()]) {
94
- const candidate = node_path_1.default.join(dir, sub, `${s}.manifest.json${suffix}`);
95
- if (node_fs_1.default.existsSync(candidate)) {
96
- return candidate;
97
- }
104
+ const probe = (dir) => {
105
+ for (const sub of SigDbSubDirs) {
106
+ for (const s of scopes) {
107
+ for (const suffix of ['', ...(0, codec_1.readableExtsPreferred)()]) {
108
+ const candidate = node_path_1.default.join(dir, sub, `${s}.manifest.json${suffix}`);
109
+ if (node_fs_1.default.existsSync(candidate)) {
110
+ return candidate;
98
111
  }
99
112
  }
100
113
  }
114
+ }
115
+ return undefined;
116
+ };
117
+ for (const root of sigDbSearchRoots(searchRoots)) {
118
+ for (let dir = root, i = 0; i < 10; i++) {
119
+ const hit = probe(dir);
120
+ if (hit !== undefined) {
121
+ return hit;
122
+ }
101
123
  const parent = node_path_1.default.dirname(dir);
102
124
  if (parent === dir) {
103
125
  break;
@@ -105,6 +127,12 @@ function defaultSigDbPath(scope, searchRoots) {
105
127
  dir = parent;
106
128
  }
107
129
  }
130
+ for (const bundle of sigDbBundleDirs()) {
131
+ const hit = probe(bundle);
132
+ if (hit !== undefined) {
133
+ return hit;
134
+ }
135
+ }
108
136
  return undefined;
109
137
  }
110
138
  /**
@@ -132,26 +160,29 @@ function defaultSigDbPaths(searchRoots) {
132
160
  into.set(key, file);
133
161
  }
134
162
  };
135
- for (const root of sigDbSearchRoots(searchRoots)) {
136
- for (let dir = root, i = 0; i < 10; i++) {
137
- for (const sub of SigDbSubDirs) {
138
- let entries;
139
- try {
140
- entries = node_fs_1.default.readdirSync(node_path_1.default.join(dir, sub));
141
- }
142
- catch {
143
- continue; // directory does not exist on this root
163
+ const scanDir = (base) => {
164
+ for (const sub of SigDbSubDirs) {
165
+ let entries;
166
+ try {
167
+ entries = node_fs_1.default.readdirSync(node_path_1.default.join(base, sub));
168
+ }
169
+ catch {
170
+ continue; // directory does not exist on this root
171
+ }
172
+ for (const file of entries) {
173
+ const full = node_path_1.default.join(base, sub, file);
174
+ if (new RegExp(`\\.manifest\\.json${codec_1.CompressedExtPattern}$`).test(file)) {
175
+ keep(manifests, (0, codec_1.stripCompressedExt)(file), full, node_path_1.default.join(base, sub));
144
176
  }
145
- for (const file of entries) {
146
- const full = node_path_1.default.join(dir, sub, file);
147
- if (new RegExp(`\\.manifest\\.json${codec_1.CompressedExtPattern}$`).test(file)) {
148
- keep(manifests, (0, codec_1.stripCompressedExt)(file), full, node_path_1.default.join(dir, sub));
149
- }
150
- else if (new RegExp(`${schema_1.SigDbExt.replace(/\./g, '\\.')}${codec_1.CompressedExtPattern}$`).test(file) && !file.includes('.dict' + schema_1.SigDbExt)) {
151
- keep(standalones, (0, codec_1.stripCompressedExt)(file), full, node_path_1.default.join(dir, sub));
152
- }
177
+ else if (new RegExp(`${schema_1.SigDbExt.replace(/\./g, '\\.')}${codec_1.CompressedExtPattern}$`).test(file) && !file.includes('.dict' + schema_1.SigDbExt)) {
178
+ keep(standalones, (0, codec_1.stripCompressedExt)(file), full, node_path_1.default.join(base, sub));
153
179
  }
154
180
  }
181
+ }
182
+ };
183
+ for (const root of sigDbSearchRoots(searchRoots)) {
184
+ for (let dir = root, i = 0; i < 10; i++) {
185
+ scanDir(dir);
155
186
  const parent = node_path_1.default.dirname(dir);
156
187
  if (parent === dir) {
157
188
  break;
@@ -159,6 +190,9 @@ function defaultSigDbPaths(searchRoots) {
159
190
  dir = parent;
160
191
  }
161
192
  }
193
+ for (const bundle of sigDbBundleDirs()) {
194
+ scanDir(bundle);
195
+ }
162
196
  // a standalone bundle is a `.sigs.ndjson` that is not a shard of a discovered manifest (`<manifest>.<shard>...`)
163
197
  const prefixes = [...manifests.keys()].map(k => k.replace(/\.manifest\.json$/, ''));
164
198
  const isShard = (name) => {
@@ -25,10 +25,11 @@ export declare function selectDownloadVariants(names: Iterable<string>): string[
25
25
  export interface SigDbDownloadOptions {
26
26
  /** GitHub `owner/repo` (default `flowr-analysis/flowr`) */
27
27
  readonly repo?: string;
28
- /** release version, i.e. tag `sigdb-v<version>` (default the running flowR version) */
28
+ /** release version, i.e. tag `sigdb-v<version>` (default the running flowR version); ignored when the committed `sigdb.remote.json` is present, whose `tag` then drives the download */
29
29
  readonly version?: string;
30
30
  /** progress callback (one line per asset) */
31
31
  readonly onProgress?: (msg: string) => void;
32
+ readonly force?: boolean;
32
33
  }
33
34
  export interface SigDbDownloadResult {
34
35
  /** the directory the bundle landed in (add it to `solver.sigdb.additionalPaths` to keep it mounted) */
@@ -50,16 +51,14 @@ export declare function downloadFullSigDb(opts?: SigDbDownloadOptions): Promise<
50
51
  * pointer is committed. Lets a caller mount an already-synced bundle via `solver.sigdb.additionalPaths` without
51
52
  * hitting the network.
52
53
  */
53
- export declare function syncedSigDbDir(opts?: {
54
- version?: string;
55
- }): string | undefined;
54
+ export declare function syncedSigDbDir(): string | undefined;
56
55
  /** the GitHub release (`{repo, tag, url}`) the committed pointer downloads from, or `undefined` when no pointer is committed */
57
56
  export declare function sigDbRemoteRelease(): {
58
57
  repo: string;
59
58
  tag: string;
60
59
  url: string;
61
60
  } | undefined;
61
+ /** Fast presence check (existence + byte size only, no hashing) for the shards the committed pointer selects for this runtime; `false` when no pointer is committed or any selected shard is missing/wrong-size. */
62
+ export declare function sigDbCacheComplete(): boolean;
62
63
  /** Startup check: `true` when a committed link file lists shards whose cached copies are missing or hash-mismatched */
63
- export declare function sigDbNeedsSync(opts?: {
64
- version?: string;
65
- }): boolean;
64
+ export declare function sigDbNeedsSync(): boolean;
@@ -8,6 +8,7 @@ exports.selectDownloadVariants = selectDownloadVariants;
8
8
  exports.downloadFullSigDb = downloadFullSigDb;
9
9
  exports.syncedSigDbDir = syncedSigDbDir;
10
10
  exports.sigDbRemoteRelease = sigDbRemoteRelease;
11
+ exports.sigDbCacheComplete = sigDbCacheComplete;
11
12
  exports.sigDbNeedsSync = sigDbNeedsSync;
12
13
  const fs_1 = __importDefault(require("fs"));
13
14
  const path_1 = __importDefault(require("path"));
@@ -134,7 +135,7 @@ async function downloadFullSigDb(opts = {}) {
134
135
  if (pointerPath) {
135
136
  const remote = readPointer(pointerPath);
136
137
  const repo = opts.repo ?? remote.repo ?? DefaultRepo;
137
- const tag = opts.version ? `sigdb-v${opts.version}` : remote.tag;
138
+ const tag = remote.tag;
138
139
  const dir = path_1.default.join((0, decompress_1.sigDbCacheDir)(), 'bundles', tag);
139
140
  fs_1.default.mkdirSync(dir, { recursive: true });
140
141
  // one variant per logical shard/dictionary -- the best this runtime can decompress (never both codecs)
@@ -144,7 +145,7 @@ async function downloadFullSigDb(opts = {}) {
144
145
  for (const name of picked) {
145
146
  const meta = remote.shards[name];
146
147
  const dest = path_1.default.join(dir, name);
147
- if (fs_1.default.existsSync(dest) && (0, exports.sha256File)(dest) === meta.sha256) {
148
+ if (!opts.force && fs_1.default.existsSync(dest) && (0, exports.sha256File)(dest) === meta.sha256) {
148
149
  progress(`have ${name}`);
149
150
  }
150
151
  else {
@@ -176,7 +177,7 @@ async function downloadFullSigDb(opts = {}) {
176
177
  for (const name of selectDownloadVariants(byName.keys())) {
177
178
  const a = byName.get(name);
178
179
  const dest = path_1.default.join(dir, name);
179
- if (fs_1.default.existsSync(dest) && fs_1.default.statSync(dest).size === a.size) {
180
+ if (!opts.force && fs_1.default.existsSync(dest) && fs_1.default.statSync(dest).size === a.size) {
180
181
  progress(`have ${name}`);
181
182
  }
182
183
  else {
@@ -192,13 +193,12 @@ async function downloadFullSigDb(opts = {}) {
192
193
  * pointer is committed. Lets a caller mount an already-synced bundle via `solver.sigdb.additionalPaths` without
193
194
  * hitting the network.
194
195
  */
195
- function syncedSigDbDir(opts = {}) {
196
+ function syncedSigDbDir() {
196
197
  const pointerPath = findRemotePointer();
197
198
  if (!pointerPath) {
198
199
  return undefined;
199
200
  }
200
- const tag = opts.version ? `sigdb-v${opts.version}` : readPointer(pointerPath).tag;
201
- return path_1.default.join((0, decompress_1.sigDbCacheDir)(), 'bundles', tag);
201
+ return path_1.default.join((0, decompress_1.sigDbCacheDir)(), 'bundles', readPointer(pointerPath).tag);
202
202
  }
203
203
  /** the GitHub release (`{repo, tag, url}`) the committed pointer downloads from, or `undefined` when no pointer is committed */
204
204
  function sigDbRemoteRelease() {
@@ -215,16 +215,37 @@ function sigDbRemoteRelease() {
215
215
  return undefined;
216
216
  }
217
217
  }
218
+ /** Fast presence check (existence + byte size only, no hashing) for the shards the committed pointer selects for this runtime; `false` when no pointer is committed or any selected shard is missing/wrong-size. */
219
+ function sigDbCacheComplete() {
220
+ const pointerPath = findRemotePointer();
221
+ if (!pointerPath) {
222
+ return false;
223
+ }
224
+ try {
225
+ const remote = readPointer(pointerPath);
226
+ const dir = path_1.default.join((0, decompress_1.sigDbCacheDir)(undefined, false), 'bundles', remote.tag);
227
+ return selectDownloadVariants(Object.keys(remote.shards)).every(name => {
228
+ try {
229
+ return fs_1.default.statSync(path_1.default.join(dir, name)).size === remote.shards[name].bytes;
230
+ }
231
+ catch {
232
+ return false;
233
+ }
234
+ });
235
+ }
236
+ catch {
237
+ return false;
238
+ }
239
+ }
218
240
  /** Startup check: `true` when a committed link file lists shards whose cached copies are missing or hash-mismatched */
219
- function sigDbNeedsSync(opts = {}) {
241
+ function sigDbNeedsSync() {
220
242
  const pointerPath = findRemotePointer();
221
243
  if (!pointerPath) {
222
244
  return false;
223
245
  }
224
246
  try {
225
247
  const remote = readPointer(pointerPath);
226
- const tag = opts.version ? `sigdb-v${opts.version}` : remote.tag;
227
- const dir = path_1.default.join((0, decompress_1.sigDbCacheDir)(), 'bundles', tag);
248
+ const dir = path_1.default.join((0, decompress_1.sigDbCacheDir)(), 'bundles', remote.tag);
228
249
  return Object.entries(remote.shards).some(([name, meta]) => {
229
250
  const dest = path_1.default.join(dir, name);
230
251
  return !fs_1.default.existsSync(dest) || (0, exports.sha256File)(dest) !== meta.sha256;
@@ -56,16 +56,6 @@ export declare const DefaultDependencyCategories: {
56
56
  readonly queryDisplayName: "Tests";
57
57
  readonly functions: FunctionInfo[];
58
58
  };
59
- readonly undeclared: {
60
- readonly queryDisplayName: "Undeclared Dependencies";
61
- readonly functions: [];
62
- readonly additionalAnalysis: (data: BasicQueryData, ignoreDefault: boolean, _functions: FunctionInfo[], _queryResults: CallContextQueryResult, result: DependencyInfo[]) => Promise<void>;
63
- };
64
- readonly unused: {
65
- readonly queryDisplayName: "Unused Dependencies";
66
- readonly functions: [];
67
- readonly additionalAnalysis: (data: BasicQueryData, ignoreDefault: boolean, _functions: FunctionInfo[], _queryResults: CallContextQueryResult, result: DependencyInfo[]) => Promise<void>;
68
- };
69
59
  };
70
60
  export type DefaultDependencyCategoryName = keyof typeof DefaultDependencyCategories;
71
61
  export type DependencyCategoryName = DefaultDependencyCategoryName | string;
@@ -20,71 +20,6 @@ const identifier_1 = require("../../../dataflow/environments/identifier");
20
20
  const r_project_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-project");
21
21
  const model_1 = require("../../../r-bridge/lang-4.x/ast/model/model");
22
22
  exports.Unknown = 'unknown';
23
- /** packages a default R session attaches without an explicit `library()` call, so missing them is not "undeclared" */
24
- const AttachedBasePackages = ['base', 'stats', 'graphics', 'grDevices', 'utils', 'datasets', 'methods'];
25
- /** {@link LibraryFunctions} indexed by name, to recognise a library-load call by its called function */
26
- const LibraryLoadFunctionInfo = new Map(library_functions_1.LibraryFunctions.map(f => [f.name, f]));
27
- /** the literal package name of a `library()`/`require()`-style argument (a bare symbol or a plain string constant) */
28
- function literalPackageName(node) {
29
- if (node?.type === type_1.RType.String) {
30
- return node.content.str;
31
- }
32
- else if (node?.type === type_1.RType.Symbol) {
33
- return identifier_1.Identifier.getName(node.content);
34
- }
35
- return undefined;
36
- }
37
- /** the argument value(s) of a library-load call that (statically) name the package(s) to load, per the matching {@link FunctionInfo} */
38
- function libraryCallArgumentValues(args, info) {
39
- const values = [];
40
- let position = 0;
41
- for (const arg of args) {
42
- if (typeof arg !== 'string' && arg.value !== undefined) {
43
- if (info.argIdx === 'unnamed') {
44
- if (arg.name === undefined) {
45
- values.push(arg.value);
46
- }
47
- }
48
- else if (arg.name !== undefined ? identifier_1.Identifier.getName(arg.name.content) === info.argName : position === info.argIdx) {
49
- values.push(arg.value);
50
- }
51
- }
52
- position++;
53
- }
54
- return values;
55
- }
56
- /**
57
- * The packages used by the code: attached via a `library()`-style call, or referenced via `::`/`:::`.
58
- * Maps each package name to the node id of one representative use site.
59
- *
60
- * This deliberately re-walks the AST instead of depending on the `library` category's result array: categories
61
- * run concurrently (see the executor's `Promise.all`), so another category's finished results are not available.
62
- * Only statically known package names are picked up (a bare symbol or string literal argument), matching the
63
- * `library` category's own `::`/`:::` detection in spirit but staying independent of it.
64
- */
65
- async function collectUsedPackages(data) {
66
- const used = new Map();
67
- r_project_1.RProject.visitAst((await data.analyzer.normalize()).ast, node => {
68
- if (node.type === type_1.RType.Symbol) {
69
- const ns = identifier_1.Identifier.getNamespace(node.content);
70
- if (ns !== undefined && !used.has(ns)) {
71
- used.set(ns, node.info.id);
72
- }
73
- }
74
- else if (node.type === type_1.RType.FunctionCall && node.named) {
75
- const info = LibraryLoadFunctionInfo.get(identifier_1.Identifier.getName(node.functionName.content));
76
- if (info !== undefined) {
77
- for (const value of libraryCallArgumentValues(node.arguments, info)) {
78
- const pkg = literalPackageName(value);
79
- if (pkg !== undefined && !used.has(pkg)) {
80
- used.set(pkg, node.info.id);
81
- }
82
- }
83
- }
84
- }
85
- });
86
- return used;
87
- }
88
23
  exports.DefaultDependencyCategories = {
89
24
  'library': {
90
25
  queryDisplayName: 'Libraries',
@@ -133,44 +68,6 @@ exports.DefaultDependencyCategories = {
133
68
  'test': {
134
69
  queryDisplayName: 'Tests',
135
70
  functions: test_functions_1.TestFunctions
136
- },
137
- 'undeclared': {
138
- queryDisplayName: 'Undeclared Dependencies',
139
- functions: [],
140
- /* packages that are used (via `library()`/`require()` or `::`/`:::`) but never declared as a project dependency */
141
- additionalAnalysis: async (data, ignoreDefault, _functions, _queryResults, result) => {
142
- if (ignoreDefault) {
143
- return;
144
- }
145
- const deps = data.analyzer.inspectContext().deps;
146
- const declared = new Set(deps.getDependencies().map(p => p.name));
147
- for (const [pkg, nodeId] of await collectUsedPackages(data)) {
148
- if (!declared.has(pkg) && !AttachedBasePackages.includes(pkg)) {
149
- result.push({ nodeId, functionName: pkg, value: pkg });
150
- }
151
- }
152
- }
153
- },
154
- 'unused': {
155
- queryDisplayName: 'Unused Dependencies',
156
- functions: [],
157
- /* packages declared as a project dependency but never used (via `library()`/`require()` or `::`/`:::`) */
158
- additionalAnalysis: async (data, ignoreDefault, _functions, _queryResults, result) => {
159
- if (ignoreDefault) {
160
- return;
161
- }
162
- const deps = data.analyzer.inspectContext().deps;
163
- const used = await collectUsedPackages(data);
164
- const nodeId = (await data.analyzer.normalize()).ast.files[0]?.root.info.id;
165
- if (nodeId === undefined) {
166
- return;
167
- }
168
- for (const pkg of deps.getDependencies()) {
169
- if (!used.has(pkg.name)) {
170
- result.push({ nodeId, functionName: pkg.name, value: pkg.name });
171
- }
172
- }
173
- }
174
71
  }
175
72
  };
176
73
  function printResultSection(title, infos, result, formatter) {
@@ -212,9 +109,6 @@ exports.DependenciesQueryDefinition = {
212
109
  const out = queryResults;
213
110
  result.push(`Query: ${(0, ansi_1.bold)('dependencies', formatter)} (${(0, time_1.printAsMs)(out['.meta'].timing, 0)})`);
214
111
  for (const [category, value] of Object.entries(getAllCategories(queries))) {
215
- if (category === 'unused') {
216
- continue; // the unused-dependency detection is unreliable; omit it from the summary for now
217
- }
218
112
  printResultSection(value.queryDisplayName ?? category, out[category] ?? [], result, formatter);
219
113
  }
220
114
  return true;
@@ -299,7 +299,7 @@ exports.GuessDepVersionsQueryDefinition = {
299
299
  const reasons = [evs.some(e => !e.parameter) ? 'new' : undefined, params.length > 0 ? `params: [${formatParams(params)}]` : undefined].filter(Boolean).join(', ');
300
300
  const name = identifier_1.Identifier.getName(identifier_1.Identifier.parse(fn));
301
301
  const url = (0, signature_query_executor_1.rdrrDocUrl)(dep.package, name, { base: dep.base, cran: !dep.base });
302
- const label = (url ? formatter.hyperlink(name, url) : name) + (reasons ? ` (${reasons})` : '');
302
+ const label = (url ? formatter.hyperlink(name, url, true) : name) + (reasons ? ` (${reasons})` : '');
303
303
  const redundant = !(geVer !== undefined && geVer === tightestGe) && !(leVer !== undefined && leVer === tightestLe);
304
304
  return { bounds: [ge, le].filter(Boolean).join(' '), label, redundant, geVer, leVer };
305
305
  }).sort((a, b) => r_version_1.RVersion.compare(b.geVer, a.geVer) || r_version_1.RVersion.compare(b.leVer, a.leVer));
@@ -12,6 +12,7 @@ const ansi_1 = require("../../../util/text/ansi");
12
12
  const time_1 = require("../../../util/text/time");
13
13
  const retriever_1 = require("../../../r-bridge/retriever");
14
14
  const assert_1 = require("../../../util/assert");
15
+ const fs_1 = __importDefault(require("fs"));
15
16
  const linter_output_1 = require("../../../linter/linter-output");
16
17
  function rulesFromInput(output, rulesPart) {
17
18
  return rulesPart
@@ -105,7 +106,13 @@ exports.LinterQueryDefinition = {
105
106
  const allDidFail = Object.values(out.results).every(linter_format_1.LintingResults.isError);
106
107
  if (allDidFail) {
107
108
  result.push('All linting rules failed to execute.');
108
- if (analyzer.inspectContext().files.loadingOrder.getUnorderedRequests().length === 0) {
109
+ const files = analyzer.inspectContext().files;
110
+ if (files.loadingOrder.getUnorderedRequests().length === 0) {
111
+ const missing = files.getRequestedRoots().filter(p => !fs_1.default.existsSync(p));
112
+ if (missing.length > 0) {
113
+ result.push(formatter.format(`Path does not exist: ${missing.map(p => `'${p}'`).join(', ')}`, { color: 1 /* Colors.Red */, effect: ansi_1.ColorEffect.Foreground, style: 1 /* FontStyles.Bold */ }));
114
+ return true;
115
+ }
109
116
  result.push(formatter.format('No requests to lint for were found in the analysis.', { color: 1 /* Colors.Red */, effect: ansi_1.ColorEffect.Foreground, style: 1 /* FontStyles.Bold */ }));
110
117
  result.push('If you consider this an error, please report a bug: ' + (0, assert_1.getGuardIssueUrl)('analyzer found no requests to lint for'));
111
118
  }
@@ -189,7 +196,7 @@ function hyperlinkLocations(pretty, formatter) {
189
196
  return pretty.replace(locationPattern, (match, path, position) => {
190
197
  const [line, col] = position.split('-')[0].split('.');
191
198
  const url = `file://${path}:${line}${col ? `:${col}` : ''}`;
192
- return formatter.hyperlink(match, url);
199
+ return formatter.hyperlink(match, url, true);
193
200
  });
194
201
  }
195
202
  function renderMetaData(metadata) {
@@ -631,6 +631,9 @@ async function executeSignatureQuery({ analyzer }, queries) {
631
631
  return { ...meta(), message: versionNotFoundMessage(q.package, `no release of '${q.package}' matches '${q.version}'.`, avail, owning[0].isBaseR(q.package)) };
632
632
  }
633
633
  }
634
+ if (found.matchCount === 0 && q.function !== undefined && !hasGlob(q.function)) {
635
+ return { ...meta(), ...found, message: `No function named exactly '${q.function}'. Try a wildcard like '*${q.function}*'.` };
636
+ }
634
637
  return { ...meta(), ...found };
635
638
  }
636
639
  // every source holding the package: `current` keeps the latest, `history` the older releases, so the resolved
@@ -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) {
@@ -86,7 +86,7 @@ function pushFunction(result, f, fn) {
86
86
  listLine('dispatches to', fn.s3methods ?? [], MaxList);
87
87
  listLine('calls', fn.callees, MaxList);
88
88
  if (fn.callGraph) {
89
- result.push(` ╰ ${(0, ansi_1.italic)('call graph', f)} ${f.hyperlink('mermaid', fn.callGraph)}`);
89
+ result.push(` ╰ ${(0, ansi_1.italic)('call graph', f)} ${f.hyperlink('mermaid', fn.callGraph, true)}`);
90
90
  }
91
91
  }
92
92
  /** render the full view of a single package into `result` */
@@ -164,7 +164,7 @@ function pushPackages(result, f, out) {
164
164
  const cap = out.truncated ? (0, ansi_1.italic)(` (capped at ${packages.length})`, f) : '';
165
165
  result.push(` ╰ ${(0, ansi_1.bold)(String(packages.length), f)} package${packages.length === 1 ? '' : 's'} matched${cap}`);
166
166
  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);
167
+ 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
168
  const kind = pm.base ? (0, ansi_1.italic)(' base R', f) : pm.cran ? (0, ansi_1.italic)(' CRAN', f) : '';
169
169
  const vers = pm.versions ? `: ${pm.versions.join(', ')}` : pm.latest ? ` ${(0, ansi_1.color)('v' + pm.latest, 2 /* Colors.Green */, f)}` : '';
170
170
  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
- if (analyzer.inspectContext().files.loadingOrder.getUnorderedRequests().length === 0) {
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'));
@@ -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";
@@ -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',
@@ -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 string[]): RegExp;
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}.
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 - Directory path to start the search from
13
- * @param suffix - Suffix of the files to be retrieved
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.