use std::hash::{Hash, Hasher};
use std::sync::Arc;
use cairo_lang_proc_macros::HeapSize;
use cairo_lang_utils::define_short_id;
use salsa::Database;
use crate::plugin::AnalyzerPlugin;
#[derive(Clone, Debug, HeapSize)]
pub struct AnalyzerPluginLongId(pub Arc<dyn AnalyzerPlugin>);
impl AnalyzerPlugin for AnalyzerPluginLongId {
fn diagnostics<'db>(
&self,
db: &'db dyn Database,
module_id: cairo_lang_defs::ids::ModuleId<'db>,
) -> Vec<cairo_lang_defs::plugin::PluginDiagnostic<'db>> {
self.0.diagnostics(db, module_id)
}
fn declared_allows(&self) -> Vec<String> {
self.0.declared_allows()
}
fn plugin_type_id(&self) -> std::any::TypeId {
self.0.plugin_type_id()
}
}
impl PartialEq for AnalyzerPluginLongId {
fn eq(&self, other: &Self) -> bool {
Arc::ptr_eq(&self.0, &other.0)
}
}
impl Eq for AnalyzerPluginLongId {}
impl Hash for AnalyzerPluginLongId {
fn hash<H: Hasher>(&self, state: &mut H) {
Arc::as_ptr(&self.0).hash(state)
}
}
define_short_id!(AnalyzerPluginId, AnalyzerPluginLongId);