From df33e7685bdb0f63bf6aa809b9046708d563a1a7 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 18 Jul 2019 23:19:04 +0300 Subject: use Parse in mbe --- crates/ra_hir/src/db.rs | 4 ++-- crates/ra_hir/src/ids.rs | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'crates/ra_hir') diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs index 040c782e6..da9f3e32d 100644 --- a/crates/ra_hir/src/db.rs +++ b/crates/ra_hir/src/db.rs @@ -2,7 +2,7 @@ use std::sync::Arc; use parking_lot::Mutex; use ra_db::{salsa, SourceDatabase}; -use ra_syntax::{ast, SmolStr, SyntaxNode, TreeArc}; +use ra_syntax::{ast, Parse, SmolStr, SyntaxNode, TreeArc}; use crate::{ adt::{EnumData, StructData}, @@ -69,7 +69,7 @@ pub trait AstDatabase: InternDatabase { fn parse_or_expand(&self, file_id: HirFileId) -> Option>; #[salsa::invoke(crate::ids::HirFileId::parse_macro_query)] - fn parse_macro(&self, macro_file: ids::MacroFile) -> Option>; + fn parse_macro(&self, macro_file: ids::MacroFile) -> Option>; #[salsa::invoke(crate::ids::macro_def_query)] fn macro_def(&self, macro_id: MacroDefId) -> Option>; 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::{ use mbe::MacroRules; use ra_db::{salsa, FileId}; use ra_prof::profile; -use ra_syntax::{ast, AstNode, SyntaxNode, TreeArc}; +use ra_syntax::{ast, AstNode, Parse, SyntaxNode, TreeArc}; use crate::{AstDatabase, AstId, DefDatabase, FileAstId, InternDatabase, Module, Source}; @@ -61,14 +61,16 @@ impl HirFileId { ) -> Option> { match file_id.0 { HirFileIdRepr::File(file_id) => Some(db.parse(file_id).tree().syntax().to_owned()), - HirFileIdRepr::Macro(macro_file) => db.parse_macro(macro_file), + HirFileIdRepr::Macro(macro_file) => { + db.parse_macro(macro_file).map(|it| it.tree().to_owned()) + } } } pub(crate) fn parse_macro_query( db: &impl AstDatabase, macro_file: MacroFile, - ) -> Option> { + ) -> Option> { let _p = profile("parse_macro_query"); let macro_call_id = macro_file.macro_call_id; let tt = db @@ -85,10 +87,8 @@ impl HirFileId { }) .ok()?; match macro_file.macro_file_kind { - MacroFileKind::Items => Some(mbe::token_tree_to_ast_item_list(&tt).syntax().to_owned()), - MacroFileKind::Expr => { - mbe::token_tree_to_expr(&tt).ok().map(|it| it.syntax().to_owned()) - } + MacroFileKind::Items => Some(Parse::to_syntax(mbe::token_tree_to_ast_item_list(&tt))), + MacroFileKind::Expr => mbe::token_tree_to_expr(&tt).ok().map(Parse::to_syntax), } } } -- cgit v1.2.3