aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ids.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/ids.rs')
-rw-r--r--crates/ra_hir/src/ids.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/crates/ra_hir/src/ids.rs b/crates/ra_hir/src/ids.rs
index 80e9cccd6..83f5c3f39 100644
--- a/crates/ra_hir/src/ids.rs
+++ b/crates/ra_hir/src/ids.rs
@@ -6,7 +6,7 @@ use std::{
6use mbe::MacroRules; 6use mbe::MacroRules;
7use ra_db::{salsa, FileId}; 7use ra_db::{salsa, FileId};
8use ra_prof::profile; 8use ra_prof::profile;
9use ra_syntax::{ast, AstNode, SyntaxNode, TreeArc}; 9use ra_syntax::{ast, AstNode, Parse, SyntaxNode, TreeArc};
10 10
11use crate::{AstDatabase, AstId, DefDatabase, FileAstId, InternDatabase, Module, Source}; 11use crate::{AstDatabase, AstId, DefDatabase, FileAstId, InternDatabase, Module, Source};
12 12
@@ -61,14 +61,16 @@ impl HirFileId {
61 ) -> Option<TreeArc<SyntaxNode>> { 61 ) -> Option<TreeArc<SyntaxNode>> {
62 match file_id.0 { 62 match file_id.0 {
63 HirFileIdRepr::File(file_id) => Some(db.parse(file_id).tree().syntax().to_owned()), 63 HirFileIdRepr::File(file_id) => Some(db.parse(file_id).tree().syntax().to_owned()),
64 HirFileIdRepr::Macro(macro_file) => db.parse_macro(macro_file), 64 HirFileIdRepr::Macro(macro_file) => {
65 db.parse_macro(macro_file).map(|it| it.tree().to_owned())
66 }
65 } 67 }
66 } 68 }
67 69
68 pub(crate) fn parse_macro_query( 70 pub(crate) fn parse_macro_query(
69 db: &impl AstDatabase, 71 db: &impl AstDatabase,
70 macro_file: MacroFile, 72 macro_file: MacroFile,
71 ) -> Option<TreeArc<SyntaxNode>> { 73 ) -> Option<Parse<SyntaxNode>> {
72 let _p = profile("parse_macro_query"); 74 let _p = profile("parse_macro_query");
73 let macro_call_id = macro_file.macro_call_id; 75 let macro_call_id = macro_file.macro_call_id;
74 let tt = db 76 let tt = db
@@ -85,10 +87,8 @@ impl HirFileId {
85 }) 87 })
86 .ok()?; 88 .ok()?;
87 match macro_file.macro_file_kind { 89 match macro_file.macro_file_kind {
88 MacroFileKind::Items => Some(mbe::token_tree_to_ast_item_list(&tt).syntax().to_owned()), 90 MacroFileKind::Items => Some(Parse::to_syntax(mbe::token_tree_to_ast_item_list(&tt))),
89 MacroFileKind::Expr => { 91 MacroFileKind::Expr => mbe::token_tree_to_expr(&tt).ok().map(Parse::to_syntax),
90 mbe::token_tree_to_expr(&tt).ok().map(|it| it.syntax().to_owned())
91 }
92 } 92 }
93 } 93 }
94} 94}