-
Notifications
You must be signed in to change notification settings - Fork 80
Expand file tree
/
Copy pathinfer_cache_manager.rs
More file actions
38 lines (32 loc) · 1.05 KB
/
Copy pathinfer_cache_manager.rs
File metadata and controls
38 lines (32 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use hashbrown::HashMap;
use crate::{CacheOptions, FileId, LuaAnalysisPhase, semantic::LuaInferCache};
#[derive(Debug, Default)]
pub struct InferCacheManager {
infer_map: HashMap<FileId, LuaInferCache>,
cache_options: CacheOptions,
}
impl InferCacheManager {
pub fn new(cache_options: CacheOptions) -> Self {
InferCacheManager {
infer_map: HashMap::new(),
cache_options,
}
}
pub fn get_infer_cache(&mut self, file_id: FileId) -> &mut LuaInferCache {
let mut cache_options = self.cache_options;
cache_options.analysis_phase = LuaAnalysisPhase::Ordered;
self.infer_map
.entry(file_id)
.or_insert_with(|| LuaInferCache::new(file_id, cache_options))
}
pub fn set_force(&mut self) {
for (_, infer_cache) in self.infer_map.iter_mut() {
infer_cache.set_phase(LuaAnalysisPhase::Force);
}
}
pub fn clear(&mut self) {
for (_, infer_cache) in self.infer_map.iter_mut() {
infer_cache.clear();
}
}
}