MCPcopy Create free account
hub / github.com/angular/angular / get_virtual_file

Method get_virtual_file

packages/compiler-cli/preprocessor/ng-analyze/src/fs.rs:405–429  ·  view source on GitHub ↗

Get a virtual file by path, checking raw path first then normalized path if needed.

(
        &'a self,
        path: &Path,
        files: &'a HashMap<PathBuf, VirtualFile>,
    )

Source from the content-addressed store, hash-verified

403
404 /// Get a virtual file by path, checking raw path first then normalized path if needed.
405 fn get_virtual_file<'a>(
406 &'a self,
407 path: &Path,
408 files: &'a HashMap<PathBuf, VirtualFile>,
409 ) -> Option<&'a VirtualFile> {
410 if let Some(vf) = files.get(path) {
411 return Some(vf);
412 }
413 let normalized = normalize_path(path);
414 if let Some(vf) = files.get(&*normalized) {
415 return Some(vf);
416 }
417 let clean_path = path
418 .strip_prefix("/")
419 .unwrap_or_else(|_| path.strip_prefix(".").unwrap_or(path));
420 if let Some((_, vf)) = files.iter().find(|(k, _)| {
421 let clean_k = k
422 .strip_prefix("/")
423 .unwrap_or_else(|_| k.strip_prefix(".").unwrap_or(k));
424 clean_k == clean_path
425 }) {
426 return Some(vf);
427 }
428 None
429 }
430
431 /// Retrieve a cloned VirtualFile entry if virtual files are enabled.
432 fn get_virtual_entry(&self, path: &Path) -> Option<VirtualFile> {

Callers 2

exists_rawMethod · 0.80
get_virtual_entryMethod · 0.80

Calls 4

normalize_pathFunction · 0.85
getMethod · 0.65
findMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected