use std::path::PathBuf;
use std::sync::Arc;
use tokio::sync::Mutex;
use crate::bridge::{NotificationCache, ResourceSubscriptions, Translator};
pub struct BridgeContext {
pub translator: Arc<Translator>,
pub notification_cache: Arc<Mutex<NotificationCache>>,
pub workspace_roots: Arc<[PathBuf]>,
pub subscriptions: Arc<ResourceSubscriptions>,
pub project_config_ignored: bool,
}
impl BridgeContext {
#[must_use]
pub const fn new(
translator: Arc<Translator>,
notification_cache: Arc<Mutex<NotificationCache>>,
workspace_roots: Arc<[PathBuf]>,
subscriptions: Arc<ResourceSubscriptions>,
project_config_ignored: bool,
) -> Self {
Self {
translator,
notification_cache,
workspace_roots,
subscriptions,
project_config_ignored,
}
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::bridge::Translator;
#[test]
fn test_bridge_context_creation() {
let translator = Arc::new(Translator::new());
let notification_cache = Arc::new(Mutex::new(NotificationCache::new()));
let workspace_roots: Arc<[PathBuf]> = Arc::from(Vec::new());
let subscriptions = Arc::new(ResourceSubscriptions::new());
let context = BridgeContext::new(
translator,
notification_cache,
workspace_roots,
subscriptions,
false,
);
assert_eq!(Arc::strong_count(&context.translator), 1);
}
}