From ab559f170ee02e3bdd9aeeb55933bb143b520c34 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 30 Oct 2019 19:10:53 +0300 Subject: move hygiene to hir_expand --- crates/ra_hir_def/src/hygiene.rs | 40 ---------------------------------------- 1 file changed, 40 deletions(-) delete mode 100644 crates/ra_hir_def/src/hygiene.rs (limited to 'crates/ra_hir_def/src/hygiene.rs') diff --git a/crates/ra_hir_def/src/hygiene.rs b/crates/ra_hir_def/src/hygiene.rs deleted file mode 100644 index 94de2c57c..000000000 --- a/crates/ra_hir_def/src/hygiene.rs +++ /dev/null @@ -1,40 +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`. -// Should this be moved to `hir_expand`? Seems like it. - -use hir_expand::{ - db::AstDatabase, - either::Either, - name::{AsName, Name}, - HirFileId, -}; -use ra_db::CrateId; -use ra_syntax::ast; - -#[derive(Debug)] -pub struct Hygiene { - // This is what `$crate` expands to - def_crate: Option, -} - -impl Hygiene { - pub fn new(db: &impl AstDatabase, file_id: HirFileId) -> Hygiene { - Hygiene { def_crate: file_id.macro_crate(db) } - } - - pub(crate) fn new_unhygienic() -> Hygiene { - Hygiene { def_crate: None } - } - - // FIXME: this should just return name - pub(crate) 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::B(def_crate); - } - } - Either::A(name_ref.as_name()) - } -} -- cgit v1.2.3