mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
Eagerly lower enum variants in CrateDefMap construction
This commit is contained in:
parent
9d8889cdfc
commit
d80d2fcae0
49 changed files with 553 additions and 593 deletions
|
@ -5,8 +5,8 @@ use la_arena::ArenaMap;
|
|||
use syntax::ast;
|
||||
|
||||
use crate::{
|
||||
db::DefDatabase, item_tree::ItemTreeNode, AssocItemLoc, ItemLoc, Lookup, Macro2Loc,
|
||||
MacroRulesLoc, ProcMacroLoc, UseId,
|
||||
db::DefDatabase, item_tree::ItemTreeNode, AssocItemLoc, EnumVariantLoc, ItemLoc, Lookup,
|
||||
Macro2Loc, MacroRulesLoc, ProcMacroLoc, UseId,
|
||||
};
|
||||
|
||||
pub trait HasSource {
|
||||
|
@ -40,6 +40,19 @@ impl<N: ItemTreeNode> HasSource for ItemLoc<N> {
|
|||
}
|
||||
}
|
||||
|
||||
impl HasSource for EnumVariantLoc {
|
||||
type Value = ast::Variant;
|
||||
|
||||
fn source(&self, db: &dyn DefDatabase) -> InFile<ast::Variant> {
|
||||
let tree = self.id.item_tree(db);
|
||||
let ast_id_map = db.ast_id_map(self.id.file_id());
|
||||
let root = db.parse_or_expand(self.id.file_id());
|
||||
let node = &tree[self.id.value];
|
||||
|
||||
InFile::new(self.id.file_id(), ast_id_map.get(node.ast_id).to_node(&root))
|
||||
}
|
||||
}
|
||||
|
||||
impl HasSource for Macro2Loc {
|
||||
type Value = ast::MacroDef;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue