mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-01 04:18:20 +00:00
Fix IDE resolution of item macros
It wasn't inside the source, because there was no source map.
This commit is contained in:
parent
1511c5b7fd
commit
3e0ab7219a
6 changed files with 74 additions and 29 deletions
|
|
@ -422,6 +422,7 @@ fn macro_def(db: &dyn DefDatabase, id: MacroId) -> MacroDefId {
|
|||
let makro = &item_tree[loc.id.value];
|
||||
MacroDefId {
|
||||
krate: loc.container.krate,
|
||||
block: loc.container.block.map(|block| salsa::plumbing::AsId::as_id(&block)),
|
||||
kind: kind(loc.expander, loc.id.file_id(), makro.ast_id.upcast()),
|
||||
local_inner: false,
|
||||
allow_internal_unsafe: loc.allow_internal_unsafe,
|
||||
|
|
@ -435,6 +436,7 @@ fn macro_def(db: &dyn DefDatabase, id: MacroId) -> MacroDefId {
|
|||
let makro = &item_tree[loc.id.value];
|
||||
MacroDefId {
|
||||
krate: loc.container.krate,
|
||||
block: loc.container.block.map(|block| salsa::plumbing::AsId::as_id(&block)),
|
||||
kind: kind(loc.expander, loc.id.file_id(), makro.ast_id.upcast()),
|
||||
local_inner: loc.flags.contains(MacroRulesLocFlags::LOCAL_INNER),
|
||||
allow_internal_unsafe: loc
|
||||
|
|
@ -450,6 +452,7 @@ fn macro_def(db: &dyn DefDatabase, id: MacroId) -> MacroDefId {
|
|||
let makro = &item_tree[loc.id.value];
|
||||
MacroDefId {
|
||||
krate: loc.container.krate,
|
||||
block: None,
|
||||
kind: MacroDefKind::ProcMacro(
|
||||
InFile::new(loc.id.file_id(), makro.ast_id),
|
||||
loc.expander,
|
||||
|
|
|
|||
|
|
@ -696,6 +696,15 @@ impl<'db> Resolver<'db> {
|
|||
&def_map[local_id].scope
|
||||
}
|
||||
|
||||
pub fn item_scopes(&self) -> impl Iterator<Item = &ItemScope> {
|
||||
self.scopes()
|
||||
.filter_map(move |scope| match scope {
|
||||
Scope::BlockScope(m) => Some(&m.def_map[m.module_id].scope),
|
||||
_ => None,
|
||||
})
|
||||
.chain(std::iter::once(&self.module_scope.def_map[self.module_scope.module_id].scope))
|
||||
}
|
||||
|
||||
pub fn krate(&self) -> Crate {
|
||||
self.module_scope.def_map.krate()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue