diff options
Diffstat (limited to 'crates/ra_hir_def')
-rw-r--r-- | crates/ra_hir_def/src/attr.rs | 3 | ||||
-rw-r--r-- | crates/ra_hir_def/src/hygiene.rs | 40 | ||||
-rw-r--r-- | crates/ra_hir_def/src/lib.rs | 1 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres/raw.rs | 6 | ||||
-rw-r--r-- | crates/ra_hir_def/src/path.rs | 3 |
5 files changed, 6 insertions, 47 deletions
diff --git a/crates/ra_hir_def/src/attr.rs b/crates/ra_hir_def/src/attr.rs index 71f92adc2..0e961ca12 100644 --- a/crates/ra_hir_def/src/attr.rs +++ b/crates/ra_hir_def/src/attr.rs | |||
@@ -2,6 +2,7 @@ | |||
2 | 2 | ||
3 | use std::sync::Arc; | 3 | use std::sync::Arc; |
4 | 4 | ||
5 | use hir_expand::hygiene::Hygiene; | ||
5 | use mbe::ast_to_token_tree; | 6 | use mbe::ast_to_token_tree; |
6 | use ra_cfg::CfgOptions; | 7 | use ra_cfg::CfgOptions; |
7 | use ra_syntax::{ | 8 | use ra_syntax::{ |
@@ -10,7 +11,7 @@ use ra_syntax::{ | |||
10 | }; | 11 | }; |
11 | use tt::Subtree; | 12 | use tt::Subtree; |
12 | 13 | ||
13 | use crate::{hygiene::Hygiene, path::Path}; | 14 | use crate::path::Path; |
14 | 15 | ||
15 | #[derive(Debug, Clone, PartialEq, Eq)] | 16 | #[derive(Debug, Clone, PartialEq, Eq)] |
16 | pub struct Attr { | 17 | pub struct Attr { |
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 @@ | |||
1 | //! This modules handles hygiene information. | ||
2 | //! | ||
3 | //! Specifically, `ast` + `Hygiene` allows you to create a `Name`. Note that, at | ||
4 | //! this moment, this is horribly incomplete and handles only `$crate`. | ||
5 | // Should this be moved to `hir_expand`? Seems like it. | ||
6 | |||
7 | use hir_expand::{ | ||
8 | db::AstDatabase, | ||
9 | either::Either, | ||
10 | name::{AsName, Name}, | ||
11 | HirFileId, | ||
12 | }; | ||
13 | use ra_db::CrateId; | ||
14 | use ra_syntax::ast; | ||
15 | |||
16 | #[derive(Debug)] | ||
17 | pub struct Hygiene { | ||
18 | // This is what `$crate` expands to | ||
19 | def_crate: Option<CrateId>, | ||
20 | } | ||
21 | |||
22 | impl Hygiene { | ||
23 | pub fn new(db: &impl AstDatabase, file_id: HirFileId) -> Hygiene { | ||
24 | Hygiene { def_crate: file_id.macro_crate(db) } | ||
25 | } | ||
26 | |||
27 | pub(crate) fn new_unhygienic() -> Hygiene { | ||
28 | Hygiene { def_crate: None } | ||
29 | } | ||
30 | |||
31 | // FIXME: this should just return name | ||
32 | pub(crate) fn name_ref_to_name(&self, name_ref: ast::NameRef) -> Either<Name, CrateId> { | ||
33 | if let Some(def_crate) = self.def_crate { | ||
34 | if name_ref.text() == "$crate" { | ||
35 | return Either::B(def_crate); | ||
36 | } | ||
37 | } | ||
38 | Either::A(name_ref.as_name()) | ||
39 | } | ||
40 | } | ||
diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs index 5135dda56..7a6c7b301 100644 --- a/crates/ra_hir_def/src/lib.rs +++ b/crates/ra_hir_def/src/lib.rs | |||
@@ -11,7 +11,6 @@ pub mod db; | |||
11 | pub mod attr; | 11 | pub mod attr; |
12 | pub mod path; | 12 | pub mod path; |
13 | pub mod type_ref; | 13 | pub mod type_ref; |
14 | pub mod hygiene; | ||
15 | 14 | ||
16 | // FIXME: this should be private | 15 | // FIXME: this should be private |
17 | pub mod nameres; | 16 | pub mod nameres; |
diff --git a/crates/ra_hir_def/src/nameres/raw.rs b/crates/ra_hir_def/src/nameres/raw.rs index 56831e409..86c05d602 100644 --- a/crates/ra_hir_def/src/nameres/raw.rs +++ b/crates/ra_hir_def/src/nameres/raw.rs | |||
@@ -6,6 +6,7 @@ use hir_expand::{ | |||
6 | ast_id_map::AstIdMap, | 6 | ast_id_map::AstIdMap, |
7 | db::AstDatabase, | 7 | db::AstDatabase, |
8 | either::Either, | 8 | either::Either, |
9 | hygiene::Hygiene, | ||
9 | name::{AsName, Name}, | 10 | name::{AsName, Name}, |
10 | }; | 11 | }; |
11 | use ra_arena::{impl_arena_id, map::ArenaMap, Arena, RawId}; | 12 | use ra_arena::{impl_arena_id, map::ArenaMap, Arena, RawId}; |
@@ -14,10 +15,7 @@ use ra_syntax::{ | |||
14 | AstNode, AstPtr, SourceFile, | 15 | AstNode, AstPtr, SourceFile, |
15 | }; | 16 | }; |
16 | 17 | ||
17 | use crate::{ | 18 | use crate::{attr::Attr, db::DefDatabase2, path::Path, FileAstId, HirFileId, ModuleSource, Source}; |
18 | attr::Attr, db::DefDatabase2, hygiene::Hygiene, path::Path, FileAstId, HirFileId, ModuleSource, | ||
19 | Source, | ||
20 | }; | ||
21 | 19 | ||
22 | /// `RawItems` is a set of top-level items in a file (except for impls). | 20 | /// `RawItems` is a set of top-level items in a file (except for impls). |
23 | /// | 21 | /// |
diff --git a/crates/ra_hir_def/src/path.rs b/crates/ra_hir_def/src/path.rs index d0b842a6b..ddabc7ca6 100644 --- a/crates/ra_hir_def/src/path.rs +++ b/crates/ra_hir_def/src/path.rs | |||
@@ -4,6 +4,7 @@ use std::{iter, sync::Arc}; | |||
4 | 4 | ||
5 | use hir_expand::{ | 5 | use hir_expand::{ |
6 | either::Either, | 6 | either::Either, |
7 | hygiene::Hygiene, | ||
7 | name::{self, AsName, Name}, | 8 | name::{self, AsName, Name}, |
8 | }; | 9 | }; |
9 | use ra_db::CrateId; | 10 | use ra_db::CrateId; |
@@ -12,7 +13,7 @@ use ra_syntax::{ | |||
12 | AstNode, | 13 | AstNode, |
13 | }; | 14 | }; |
14 | 15 | ||
15 | use crate::{hygiene::Hygiene, type_ref::TypeRef, Source}; | 16 | use crate::{type_ref::TypeRef, Source}; |
16 | 17 | ||
17 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 18 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
18 | pub struct Path { | 19 | pub struct Path { |