Skip to main content

for_each_unit

Function for_each_unit 

Source
pub fn for_each_unit(
    doc_text: &str,
    files: Option<&HashMap<PathBuf, String>>,
    f: impl FnMut(&SourceUnit),
)
Expand description

Parse every project unit, plus the embedded first-party adapters (the bynk surface and the bynk.cloudflare platform adapter), and call f for each. Recovery parsing tolerates the in-progress edit at the cursor.

The embedded surface is parsed once (EMBEDDED_UNITS) and the project’s other files are served from a per-file parse cache (cached_project_unit), keyed on content rather than disk metadata (content-ownership track, #1086, slice 0+1) — files is a pre-read (path, content) map the caller (bynk-lsp) built by overlaying every open buffer over a disk sweep, so an unsaved edit to file A is visible here exactly like a saved one. Only doc_text — the buffer under the cursor, which changes per keystroke — is parsed fresh each call (#733), never looked up in files (the caller excludes the cursor’s own file from files for exactly this reason). Ordering is preserved (embedded, then the buffer, then the other files) so a callback’s first-name-wins dedup still prefers the live buffer.