-
Notifications
You must be signed in to change notification settings - Fork 547
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduced queries for crate plugins in
DefsGroup
and SemanticGroup
commit-id:5dc187d6
- Loading branch information
1 parent
55db9be
commit 36226f4
Showing
5 changed files
with
253 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
use std::hash::{Hash, Hasher}; | ||
use std::sync::Arc; | ||
|
||
use cairo_lang_utils::define_short_id; | ||
|
||
use crate::db::SemanticGroup; | ||
use crate::plugin::AnalyzerPlugin; | ||
|
||
/// An Id allowing interning [`AnalyzerPlugin`] into Salsa database. | ||
#[derive(Debug)] | ||
pub struct AnalyzerPluginLongId(pub Arc<dyn AnalyzerPlugin>); | ||
|
||
impl AnalyzerPlugin for AnalyzerPluginLongId { | ||
fn diagnostics( | ||
&self, | ||
db: &dyn crate::db::SemanticGroup, | ||
module_id: cairo_lang_defs::ids::ModuleId, | ||
) -> Vec<cairo_lang_defs::plugin::PluginDiagnostic> { | ||
self.0.diagnostics(db, module_id) | ||
} | ||
|
||
fn declared_allows(&self) -> Vec<String> { | ||
self.0.declared_allows() | ||
} | ||
} | ||
|
||
impl Clone for AnalyzerPluginLongId { | ||
fn clone(&self) -> Self { | ||
Self(Arc::clone(&self.0)) | ||
} | ||
} | ||
|
||
// `PartialEq` and `Hash` cannot be derived on `Arc<dyn ...>`, | ||
// but pointer-based equality and hash semantics are enough in this case. | ||
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, | ||
SemanticGroup, | ||
lookup_intern_analyzer_plugin, | ||
intern_analyzer_plugin | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters