aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/source_binder.rs
diff options
context:
space:
mode:
authorEdwin Cheng <[email protected]>2019-11-26 07:05:53 +0000
committerEdwin Cheng <[email protected]>2019-11-26 07:05:53 +0000
commit245a9b165acb179c40b8c9d4a085e5ccdd4b75d3 (patch)
tree8074ef35c99dd6345536e11f5fe030daebade95a /crates/ra_hir/src/source_binder.rs
parent58a3b3b502580e9f49dcfc9b7223e8aec258adf6 (diff)
Add hygiene information to SourceAnalyzer
Diffstat (limited to 'crates/ra_hir/src/source_binder.rs')
-rw-r--r--crates/ra_hir/src/source_binder.rs13
1 files changed, 8 insertions, 5 deletions
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs
index cbfeca3ab..287cea880 100644
--- a/crates/ra_hir/src/source_binder.rs
+++ b/crates/ra_hir/src/source_binder.rs
@@ -14,7 +14,8 @@ use hir_def::{
14 DefWithBodyId, 14 DefWithBodyId,
15}; 15};
16use hir_expand::{ 16use hir_expand::{
17 name::AsName, AstId, HirFileId, MacroCallId, MacroCallLoc, MacroFileKind, Source, 17 hygiene::Hygiene, name::AsName, AstId, HirFileId, MacroCallId, MacroCallLoc, MacroFileKind,
18 Source,
18}; 19};
19use ra_syntax::{ 20use ra_syntax::{
20 ast::{self, AstNode}, 21 ast::{self, AstNode},
@@ -236,10 +237,10 @@ impl SourceAnalyzer {
236 pub fn resolve_macro_call( 237 pub fn resolve_macro_call(
237 &self, 238 &self,
238 db: &impl HirDatabase, 239 db: &impl HirDatabase,
239 macro_call: &ast::MacroCall, 240 macro_call: Source<&ast::MacroCall>,
240 ) -> Option<MacroDef> { 241 ) -> Option<MacroDef> {
241 // This must be a normal source file rather than macro file. 242 let hygiene = Hygiene::new(db, macro_call.file_id);
242 let path = macro_call.path().and_then(Path::from_ast)?; 243 let path = macro_call.value.path().and_then(|ast| Path::from_src(ast, &hygiene))?;
243 self.resolver.resolve_path_as_macro(db, &path).map(|it| it.into()) 244 self.resolver.resolve_path_as_macro(db, &path).map(|it| it.into())
244 } 245 }
245 246
@@ -441,12 +442,14 @@ impl SourceAnalyzer {
441 db: &impl HirDatabase, 442 db: &impl HirDatabase,
442 macro_call: Source<&ast::MacroCall>, 443 macro_call: Source<&ast::MacroCall>,
443 ) -> Option<Expansion> { 444 ) -> Option<Expansion> {
444 let def = self.resolve_macro_call(db, macro_call.value)?.id; 445 let def = self.resolve_macro_call(db, macro_call)?.id;
445 let ast_id = AstId::new( 446 let ast_id = AstId::new(
446 macro_call.file_id, 447 macro_call.file_id,
447 db.ast_id_map(macro_call.file_id).ast_id(macro_call.value), 448 db.ast_id_map(macro_call.file_id).ast_id(macro_call.value),
448 ); 449 );
449 let macro_call_loc = MacroCallLoc { def, ast_id }; 450 let macro_call_loc = MacroCallLoc { def, ast_id };
451 let kind = to_macro_file_kind(macro_call.value);
452 dbg!(kind);
450 Some(Expansion { 453 Some(Expansion {
451 macro_call_id: db.intern_macro(macro_call_loc), 454 macro_call_id: db.intern_macro(macro_call_loc),
452 macro_file_kind: to_macro_file_kind(macro_call.value), 455 macro_file_kind: to_macro_file_kind(macro_call.value),