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

Method is_allowed

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

Check if a physical path is allowed by the allowed_sources filter

(&self, path: &Path)

Source from the content-addressed store, hash-verified

277
278 /// Check if a physical path is allowed by the allowed_sources filter
279 pub fn is_allowed(&self, path: &Path) -> bool {
280 let Some(allowed) = self.allowed_sources.as_ref() else {
281 return true;
282 };
283
284 let check_allowed =
285 crate::utils::is_ts_source(path) || path.extension().is_some_and(|e| e == "js");
286
287 if !check_allowed {
288 return true;
289 }
290
291 // Check cache first to avoid expensive normalization, joins, and canonicalization.
292 {
293 let cache = self.is_allowed_cache.read().unwrap();
294 if let Some(&allowed) = cache.get(path) {
295 crate::perf::count(Counter::IsAllowedCacheHits, 1);
296 return allowed;
297 }
298 }
299
300 crate::perf::count(Counter::IsAllowedCacheMisses, 1);
301 let is_allowed = self.is_allowed_uncached(path, allowed);
302
303 let mut cache = self.is_allowed_cache.write().unwrap();
304 cache.insert(path.to_path_buf(), is_allowed);
305 is_allowed
306 }
307
308 fn is_allowed_uncached(&self, path: &Path, allowed: &HashSet<PathBuf>) -> bool {
309 // 1. Try checking the path normalized as-is (handles absolute paths and relative paths matching relative entries).

Callers 4

readMethod · 0.80
read_to_stringMethod · 0.80
metadataMethod · 0.80
symlink_metadataMethod · 0.80

Calls 9

is_ts_sourceFunction · 0.85
as_refMethod · 0.80
is_allowed_uncachedMethod · 0.80
unwrapMethod · 0.65
readMethod · 0.65
getMethod · 0.65
writeMethod · 0.65
countFunction · 0.50
insertMethod · 0.45

Tested by

no test coverage detected