mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 22:31:43 +00:00
Introduce AsMacroCall trait
This commit is contained in:
parent
d976772716
commit
2d4e79e1e6
4 changed files with 127 additions and 77 deletions
|
@ -15,11 +15,9 @@ use hir_def::{
|
|||
},
|
||||
expr::{ExprId, PatId},
|
||||
resolver::{self, resolver_for_scope, Resolver, TypeNs, ValueNs},
|
||||
DefWithBodyId, TraitId,
|
||||
};
|
||||
use hir_expand::{
|
||||
hygiene::Hygiene, name::AsName, AstId, HirFileId, InFile, MacroCallId, MacroCallKind,
|
||||
AsMacroCall, DefWithBodyId, TraitId,
|
||||
};
|
||||
use hir_expand::{hygiene::Hygiene, name::AsName, HirFileId, InFile, MacroCallId};
|
||||
use hir_ty::{InEnvironment, InferenceResult, TraitEnvironment};
|
||||
use ra_syntax::{
|
||||
ast::{self, AstNode},
|
||||
|
@ -363,12 +361,10 @@ impl SourceAnalyzer {
|
|||
db: &impl HirDatabase,
|
||||
macro_call: InFile<&ast::MacroCall>,
|
||||
) -> Option<Expansion> {
|
||||
let def = self.resolve_macro_call(db, macro_call)?.id;
|
||||
let ast_id = AstId::new(
|
||||
macro_call.file_id,
|
||||
db.ast_id_map(macro_call.file_id).ast_id(macro_call.value),
|
||||
);
|
||||
Some(Expansion { macro_call_id: def.as_call_id(db, MacroCallKind::FnLike(ast_id)) })
|
||||
let macro_call_id = macro_call.as_call_id(db, |path| {
|
||||
self.resolver.resolve_path_as_macro(db, &path).map(|it| it.into())
|
||||
})?;
|
||||
Some(Expansion { macro_call_id })
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue