Allow navigation targets to be duplicated when the focus range lies in the macro definition site

This commit is contained in:
Lukas Wirth 2023-12-06 11:53:28 +01:00
parent 9b7ec5e31b
commit 9cb13b6efb
38 changed files with 851 additions and 488 deletions

View file

@ -380,6 +380,21 @@ impl MacroDefId {
db.intern_macro_call(MacroCallLoc { def: self, krate, eager: None, kind, call_site })
}
pub fn definition_range(&self, db: &dyn db::ExpandDatabase) -> InFile<TextRange> {
match self.kind {
MacroDefKind::Declarative(id)
| MacroDefKind::BuiltIn(_, id)
| MacroDefKind::BuiltInAttr(_, id)
| MacroDefKind::BuiltInDerive(_, id)
| MacroDefKind::BuiltInEager(_, id) => {
id.with_value(db.ast_id_map(id.file_id).get(id.value).text_range())
}
MacroDefKind::ProcMacro(_, _, id) => {
id.with_value(db.ast_id_map(id.file_id).get(id.value).text_range())
}
}
}
pub fn ast_id(&self) -> Either<AstId<ast::Macro>, AstId<ast::Fn>> {
match self.kind {
MacroDefKind::ProcMacro(.., id) => return Either::Right(id),