mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 20:42:04 +00:00
Allow navigation targets to be duplicated when the focus range lies in the macro definition site
This commit is contained in:
parent
9b7ec5e31b
commit
9cb13b6efb
38 changed files with 851 additions and 488 deletions
|
@ -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),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue