diff options
-rw-r--r-- | crates/ra_hir/src/db.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir/src/ids.rs | 34 | ||||
-rw-r--r-- | crates/ra_hir/src/lib.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir/src/macros.rs | 36 | ||||
-rw-r--r-- | crates/ra_hir/src/query_definitions.rs | 2 |
5 files changed, 40 insertions, 40 deletions
diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs index c0b56f30a..8259bd699 100644 --- a/crates/ra_hir/src/db.rs +++ b/crates/ra_hir/src/db.rs | |||
@@ -4,11 +4,11 @@ use ra_syntax::{SyntaxNode, SourceFileNode}; | |||
4 | use ra_db::{SourceRootId, LocationIntener, SyntaxDatabase, Cancelable}; | 4 | use ra_db::{SourceRootId, LocationIntener, SyntaxDatabase, Cancelable}; |
5 | 5 | ||
6 | use crate::{ | 6 | use crate::{ |
7 | DefLoc, DefId, Name, HirFileId, | 7 | DefLoc, DefId, MacroCallLoc, MacroCallId, Name, HirFileId, |
8 | SourceFileItems, SourceItemId, | 8 | SourceFileItems, SourceItemId, |
9 | query_definitions, | 9 | query_definitions, |
10 | FnScopes, | 10 | FnScopes, |
11 | macros::{MacroCallLoc, MacroCallId, MacroExpansion}, | 11 | macros::MacroExpansion, |
12 | module::{ModuleId, ModuleTree, ModuleSource, | 12 | module::{ModuleId, ModuleTree, ModuleSource, |
13 | nameres::{ItemMap, InputModuleItems}}, | 13 | nameres::{ItemMap, InputModuleItems}}, |
14 | ty::{InferenceResult, Ty}, | 14 | ty::{InferenceResult, Ty}, |
diff --git a/crates/ra_hir/src/ids.rs b/crates/ra_hir/src/ids.rs index cd32033f3..aa6b2d2aa 100644 --- a/crates/ra_hir/src/ids.rs +++ b/crates/ra_hir/src/ids.rs | |||
@@ -2,7 +2,7 @@ use ra_db::{SourceRootId, LocationIntener, Cancelable, FileId}; | |||
2 | use ra_syntax::{SourceFileNode, SyntaxKind, SyntaxNode, SyntaxNodeRef, SourceFile, AstNode, ast}; | 2 | use ra_syntax::{SourceFileNode, SyntaxKind, SyntaxNode, SyntaxNodeRef, SourceFile, AstNode, ast}; |
3 | 3 | ||
4 | use crate::{ | 4 | use crate::{ |
5 | MacroCallId, HirDatabase, PerNs, ModuleId, Module, Def, Function, Struct, Enum, | 5 | HirDatabase, PerNs, ModuleId, Module, Def, Function, Struct, Enum, |
6 | arena::{Arena, Id}, | 6 | arena::{Arena, Id}, |
7 | }; | 7 | }; |
8 | 8 | ||
@@ -77,6 +77,38 @@ impl From<MacroCallId> for HirFileId { | |||
77 | } | 77 | } |
78 | } | 78 | } |
79 | 79 | ||
80 | /// `MacroCallId` identifies a particular macro invocation, like | ||
81 | /// `println!("Hello, {}", world)`. | ||
82 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | ||
83 | pub struct MacroCallId(u32); | ||
84 | ra_db::impl_numeric_id!(MacroCallId); | ||
85 | |||
86 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | ||
87 | pub struct MacroCallLoc { | ||
88 | pub(crate) source_root_id: SourceRootId, | ||
89 | pub(crate) module_id: ModuleId, | ||
90 | pub(crate) source_item_id: SourceItemId, | ||
91 | } | ||
92 | |||
93 | impl MacroCallId { | ||
94 | pub(crate) fn loc( | ||
95 | self, | ||
96 | db: &impl AsRef<LocationIntener<MacroCallLoc, MacroCallId>>, | ||
97 | ) -> MacroCallLoc { | ||
98 | db.as_ref().id2loc(self) | ||
99 | } | ||
100 | } | ||
101 | |||
102 | impl MacroCallLoc { | ||
103 | #[allow(unused)] | ||
104 | pub(crate) fn id( | ||
105 | &self, | ||
106 | db: &impl AsRef<LocationIntener<MacroCallLoc, MacroCallId>>, | ||
107 | ) -> MacroCallId { | ||
108 | db.as_ref().loc2id(&self) | ||
109 | } | ||
110 | } | ||
111 | |||
80 | /// Def's are a core concept of hir. A `Def` is an Item (function, module, etc) | 112 | /// Def's are a core concept of hir. A `Def` is an Item (function, module, etc) |
81 | /// in a specific module. | 113 | /// in a specific module. |
82 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 114 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs index 5e939b79e..018ead9fb 100644 --- a/crates/ra_hir/src/lib.rs +++ b/crates/ra_hir/src/lib.rs | |||
@@ -42,8 +42,8 @@ pub use self::{ | |||
42 | path::{Path, PathKind}, | 42 | path::{Path, PathKind}, |
43 | name::Name, | 43 | name::Name, |
44 | krate::Crate, | 44 | krate::Crate, |
45 | ids::{HirFileId, DefId, DefLoc}, | 45 | ids::{HirFileId, DefId, DefLoc, MacroCallId, MacroCallLoc}, |
46 | macros::{MacroDef, MacroInput, MacroExpansion, MacroCallId, MacroCallLoc}, | 46 | macros::{MacroDef, MacroInput, MacroExpansion}, |
47 | module::{Module, ModuleId, Problem, nameres::{ItemMap, PerNs, Namespace}, ModuleScope, Resolution}, | 47 | module::{Module, ModuleId, Problem, nameres::{ItemMap, PerNs, Namespace}, ModuleScope, Resolution}, |
48 | function::{Function, FnScopes}, | 48 | function::{Function, FnScopes}, |
49 | adt::{Struct, Enum}, | 49 | adt::{Struct, Enum}, |
diff --git a/crates/ra_hir/src/macros.rs b/crates/ra_hir/src/macros.rs index 288fbe3c6..71646b22d 100644 --- a/crates/ra_hir/src/macros.rs +++ b/crates/ra_hir/src/macros.rs | |||
@@ -1,44 +1,12 @@ | |||
1 | use std::sync::Arc; | 1 | use std::sync::Arc; |
2 | 2 | ||
3 | use ra_db::{SourceRootId, LocalSyntaxPtr, LocationIntener}; | 3 | use ra_db::LocalSyntaxPtr; |
4 | use ra_syntax::{ | 4 | use ra_syntax::{ |
5 | TextRange, TextUnit, SourceFileNode, AstNode, SyntaxNode, | 5 | TextRange, TextUnit, SourceFileNode, AstNode, SyntaxNode, |
6 | ast::{self, NameOwner}, | 6 | ast::{self, NameOwner}, |
7 | }; | 7 | }; |
8 | 8 | ||
9 | use crate::{module::ModuleId, SourceItemId, HirDatabase}; | 9 | use crate::{HirDatabase, MacroCallId}; |
10 | |||
11 | /// Def's are a core concept of hir. A `Def` is an Item (function, module, etc) | ||
12 | /// in a specific module. | ||
13 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | ||
14 | pub struct MacroCallId(u32); | ||
15 | ra_db::impl_numeric_id!(MacroCallId); | ||
16 | |||
17 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | ||
18 | pub struct MacroCallLoc { | ||
19 | pub(crate) source_root_id: SourceRootId, | ||
20 | pub(crate) module_id: ModuleId, | ||
21 | pub(crate) source_item_id: SourceItemId, | ||
22 | } | ||
23 | |||
24 | impl MacroCallId { | ||
25 | pub(crate) fn loc( | ||
26 | self, | ||
27 | db: &impl AsRef<LocationIntener<MacroCallLoc, MacroCallId>>, | ||
28 | ) -> MacroCallLoc { | ||
29 | db.as_ref().id2loc(self) | ||
30 | } | ||
31 | } | ||
32 | |||
33 | impl MacroCallLoc { | ||
34 | #[allow(unused)] | ||
35 | pub(crate) fn id( | ||
36 | &self, | ||
37 | db: &impl AsRef<LocationIntener<MacroCallLoc, MacroCallId>>, | ||
38 | ) -> MacroCallId { | ||
39 | db.as_ref().loc2id(&self) | ||
40 | } | ||
41 | } | ||
42 | 10 | ||
43 | // Hard-coded defs for now :-( | 11 | // Hard-coded defs for now :-( |
44 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 12 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
diff --git a/crates/ra_hir/src/query_definitions.rs b/crates/ra_hir/src/query_definitions.rs index bc1f91938..a5d99beda 100644 --- a/crates/ra_hir/src/query_definitions.rs +++ b/crates/ra_hir/src/query_definitions.rs | |||
@@ -12,7 +12,7 @@ use ra_db::{SourceRootId, Cancelable,}; | |||
12 | 12 | ||
13 | use crate::{ | 13 | use crate::{ |
14 | SourceFileItems, SourceItemId, DefKind, Function, DefId, Name, AsName, HirFileId, | 14 | SourceFileItems, SourceItemId, DefKind, Function, DefId, Name, AsName, HirFileId, |
15 | macros::MacroCallLoc, | 15 | MacroCallLoc, |
16 | db::HirDatabase, | 16 | db::HirDatabase, |
17 | function::FnScopes, | 17 | function::FnScopes, |
18 | module::{ | 18 | module::{ |