Skip to main content

Module discovery

Module discovery 

Source
Expand description

Walking a directory tree for .bynk files and reading them — the driver’s side of CompileOptions.sources (#1077, R2.3/T0.7 residue).

The real CLI entry points (project_options/try_project_options below) now walk and read every file up front, via this module, and hand the result to CompileOptions::sources.

#1077 review: this module’s own original doc claimed the CLI path was already fully independent of bynk-emit’s disk reads — false as written. project_options/try_project_options still read bynk.toml itself via read_project_paths/try_read_project_paths, which reach discovery::read_source’s overlay-miss fallback (fs::read_to_string) with an always-empty overlay — one real disk read inside bynk-emit on every real CLI invocation, unnoticed because fs_below_driver scans bynk-emit’s own text, not who calls into it. Both entry points now read bynk.toml themselves (manifest_overlay) and hand it to try_read_project_paths_with’s overlay instead, so that read genuinely moves above bynk-emit when bynk.toml exists. A conventional project with no manifest at all still reaches try_read_project_paths_with with an empty overlay, which still tries (and fails to find) bynk.toml via read_source’s own fs::read_to_string before falling back to ProjectPaths::conventional — a real, if harmless (the read fails and is discarded), disk touch still inside bynk-emit for that case.

bynk-emit’s own on-disk discovery (project::discover_bynk_files) and read_source’s overlay-miss fallback are not removed, and can’t be yet: analyse_project_with (the LSP’s own analysis path, bynk-emit/src/project.rs) hardcodes discovered: None and passes an overlay that deliberately covers only open editor buffers — it depends on that exact fallback to see every other project file, including its own bynk.toml read (AnalysisRoots::lower, bynk-ide/src/lib.rs, has the same gap this module just closed for the CLI, unclosed). #1079’s issue text scopes only bynk-ide’s completion.rs/symbols.rs — it does not mention analyse_project_with or the diagnose_project(&root, &HashMap::new()) pattern that is bynk-ide’s (and bynkc’s test suite’s) dominant way of exercising this whole analysis path (100+ call sites spanning bynk-ide’s own inline test modules, bynk-lsp/tests, and bynkc/tests) — every one depends on read_source’s fallback today. Closing discovery.rs for good needs all of that migrated first, which is bigger than either #1077 or #1079’s issue text currently describes; #1077 stays open pending that combined, design-reviewed effort. fs_below_driver does not move for bynk-emit from this module alone.

Structs§

DiscoveryError
An I/O failure while walking a project tree for .bynk files, or reading one found there.

Functions§

read_bynk_tree
Walk root for every .bynk file (skipping excludes and hidden directories, mirroring bynk-emit’s former discover_bynk_files exactly) and read each one’s content. Keys are the same literal (non-canonicalised) path shape a plain recursive walk produces — CompileOptions.sources’s own contract, and what read_source’s overlay lookup tries first.
read_bynk_tree_single
read_bynk_tree with no excludes — the common case for a single-root project (CompileOptions::single, whose own Roots::excludes() is always empty) and for test fixtures, which rarely declare an exclude list.
read_bynk_tree_split
read_bynk_tree merged across every one of a split project’s include roots, matching Roots::trees’ shape — the primary root’s paths.exclude (plus the tool’s own out/node_modules caches) applies to all of them.
sources_for_roots
The complete CompileOptions.sources map for a project rooted at roots.