Skip to content

Commit

Permalink
Add edition to plugin metadata. (#5922)
Browse files Browse the repository at this point in the history
  • Loading branch information
gilbens-starkware authored Jul 1, 2024
1 parent 7245376 commit ae5751b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
14 changes: 11 additions & 3 deletions crates/cairo-lang-defs/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,12 +430,20 @@ fn priv_module_data(db: &dyn DefsGroup, module_id: ModuleId) -> Maybe<ModuleData
let mut files = Vec::new();
let mut plugin_diagnostics = Vec::new();

let crate_id = module_id.owning_crate(db);
let cfg_set = db
.crate_config(module_id.owning_crate(db))
.crate_config(crate_id)
.and_then(|cfg| cfg.settings.cfg_set.map(Arc::new))
.unwrap_or(db.cfg_set());
let metadata =
MacroPluginMetadata { cfg_set: &cfg_set, declared_derives: &db.declared_derives() };
let edition = db
.crate_config(module_id.owning_crate(db))
.map(|cfg| cfg.settings.edition)
.unwrap_or_default();
let metadata = MacroPluginMetadata {
cfg_set: &cfg_set,
declared_derives: &db.declared_derives(),
edition,
};

let mut items = vec![];
generated_file_infos.push(main_file_info);
Expand Down
5 changes: 4 additions & 1 deletion crates/cairo-lang-defs/src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::sync::Arc;

use cairo_lang_diagnostics::Severity;
use cairo_lang_filesystem::cfg::CfgSet;
use cairo_lang_filesystem::db::Edition;
use cairo_lang_filesystem::ids::CodeMapping;
use cairo_lang_syntax::node::ast;
use cairo_lang_syntax::node::db::SyntaxGroup;
Expand Down Expand Up @@ -80,10 +81,12 @@ impl PluginDiagnostic {
/// A structure containing additional info about the current module item on which macro plugin
/// operates.
pub struct MacroPluginMetadata<'a> {
/// Config set of a crate to which the current item belongs.
/// Config set of the crate to which the current item belongs.
pub cfg_set: &'a CfgSet,
/// The possible derives declared by any plugin.
pub declared_derives: &'a OrderedHashSet<String>,
/// The edition of the crate to which the current item belongs.
pub edition: Edition,
}

// TOD(spapini): Move to another place.
Expand Down

0 comments on commit ae5751b

Please sign in to comment.