From ed20a857f485a471369cd99b843af19a4d875ad0 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 13 Aug 2020 16:25:38 +0200 Subject: Rename ra_db -> base_db --- crates/ra_hir_expand/src/hygiene.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_hir_expand/src/hygiene.rs') diff --git a/crates/ra_hir_expand/src/hygiene.rs b/crates/ra_hir_expand/src/hygiene.rs index 23b5eac27..845e9cbc1 100644 --- a/crates/ra_hir_expand/src/hygiene.rs +++ b/crates/ra_hir_expand/src/hygiene.rs @@ -2,8 +2,8 @@ //! //! Specifically, `ast` + `Hygiene` allows you to create a `Name`. Note that, at //! this moment, this is horribly incomplete and handles only `$crate`. +use base_db::CrateId; use either::Either; -use ra_db::CrateId; use syntax::ast; use crate::{ -- cgit v1.2.3 From b7aa4898e0841ab8199643f89a0caa967b698ca8 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 13 Aug 2020 16:26:29 +0200 Subject: Rename ra_hir_expand -> hir_expand --- crates/ra_hir_expand/src/hygiene.rs | 66 ------------------------------------- 1 file changed, 66 deletions(-) delete mode 100644 crates/ra_hir_expand/src/hygiene.rs (limited to 'crates/ra_hir_expand/src/hygiene.rs') diff --git a/crates/ra_hir_expand/src/hygiene.rs b/crates/ra_hir_expand/src/hygiene.rs deleted file mode 100644 index 845e9cbc1..000000000 --- a/crates/ra_hir_expand/src/hygiene.rs +++ /dev/null @@ -1,66 +0,0 @@ -//! This modules handles hygiene information. -//! -//! Specifically, `ast` + `Hygiene` allows you to create a `Name`. Note that, at -//! this moment, this is horribly incomplete and handles only `$crate`. -use base_db::CrateId; -use either::Either; -use syntax::ast; - -use crate::{ - db::AstDatabase, - name::{AsName, Name}, - HirFileId, HirFileIdRepr, MacroCallId, MacroDefKind, -}; - -#[derive(Clone, Debug)] -pub struct Hygiene { - // This is what `$crate` expands to - def_crate: Option, - - // Indicate this is a local inner macro - local_inner: bool, -} - -impl Hygiene { - pub fn new(db: &dyn AstDatabase, file_id: HirFileId) -> Hygiene { - let (def_crate, local_inner) = match file_id.0 { - HirFileIdRepr::FileId(_) => (None, false), - HirFileIdRepr::MacroFile(macro_file) => match macro_file.macro_call_id { - MacroCallId::LazyMacro(id) => { - let loc = db.lookup_intern_macro(id); - match loc.def.kind { - MacroDefKind::Declarative => (loc.def.krate, loc.def.local_inner), - MacroDefKind::BuiltIn(_) => (None, false), - MacroDefKind::BuiltInDerive(_) => (None, false), - MacroDefKind::BuiltInEager(_) => (None, false), - MacroDefKind::CustomDerive(_) => (None, false), - } - } - MacroCallId::EagerMacro(_id) => (None, false), - }, - }; - Hygiene { def_crate, local_inner } - } - - pub fn new_unhygienic() -> Hygiene { - Hygiene { def_crate: None, local_inner: false } - } - - // FIXME: this should just return name - pub fn name_ref_to_name(&self, name_ref: ast::NameRef) -> Either { - if let Some(def_crate) = self.def_crate { - if name_ref.text() == "$crate" { - return Either::Right(def_crate); - } - } - Either::Left(name_ref.as_name()) - } - - pub fn local_inner_macros(&self) -> Option { - if self.local_inner { - self.def_crate - } else { - None - } - } -} -- cgit v1.2.3