rust_analyzer/
hack_recover_crate_name.rsuse std::sync::{Mutex, MutexGuard, OnceLock};
use ide_db::FxHashMap;
static STORAGE: OnceLock<Mutex<FxHashMap<String, String>>> = OnceLock::new();
fn get_storage() -> MutexGuard<'static, FxHashMap<String, String>> {
STORAGE.get_or_init(|| Mutex::new(FxHashMap::default())).lock().unwrap()
}
pub(crate) fn insert_name(name_with_crate: String) {
let Some((_, name_without_crate)) = name_with_crate.split_once("::") else {
return;
};
get_storage().insert(name_without_crate.to_owned(), name_with_crate);
}
pub(crate) fn lookup_name(name_without_crate: String) -> Option<String> {
get_storage().get(&name_without_crate).cloned()
}