mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 20:09:19 +00:00
internal: Implement module_path
macro
This commit is contained in:
parent
9b7b93e031
commit
d44a3ab30c
20 changed files with 279 additions and 71 deletions
|
@ -839,12 +839,25 @@ impl SourceAnalyzer {
|
|||
db: &dyn HirDatabase,
|
||||
macro_call: InFile<&ast::MacroCall>,
|
||||
) -> Option<MacroFileId> {
|
||||
let krate = self.resolver.krate();
|
||||
// FIXME: This causes us to parse, generally this is the wrong approach for resolving a
|
||||
// macro call to a macro call id!
|
||||
let macro_call_id = macro_call.as_call_id(db.upcast(), krate, |path| {
|
||||
self.resolver.resolve_path_as_macro_def(db.upcast(), path, Some(MacroSubNs::Bang))
|
||||
})?;
|
||||
let macro_call_id = macro_call
|
||||
.as_call_id(
|
||||
db.upcast(),
|
||||
self.resolver.module(),
|
||||
|path| {
|
||||
self.resolver.resolve_path_as_macro_def(
|
||||
db.upcast(),
|
||||
path,
|
||||
Some(MacroSubNs::Bang),
|
||||
)
|
||||
},
|
||||
|module| {
|
||||
self.resolver.module().def_map(db.upcast()).path_for_module(db.upcast(), module)
|
||||
},
|
||||
)
|
||||
.ok()?
|
||||
.value?;
|
||||
// why the 64?
|
||||
Some(macro_call_id.as_macro_file()).filter(|it| it.expansion_level(db.upcast()) < 64)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue