-
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
25c59d2
commit 864ea77
Showing
6 changed files
with
212 additions
and
4 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,49 @@ | ||
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. | ||
#[allow(clippy::derived_hash_with_manual_eq)] | ||
#[derive(Debug, Hash)] | ||
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` cannot be derived because of the `Arc`, but since [`AnalyzerPlugin`] has | ||
// `DynEq` providing `PartialEq`'s functionality, the implementation is easily delegated. | ||
impl PartialEq for AnalyzerPluginLongId { | ||
fn eq(&self, other: &Self) -> bool { | ||
*self.0 == *other.0 | ||
} | ||
} | ||
|
||
impl Eq for AnalyzerPluginLongId {} | ||
|
||
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
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