aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/module.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/module.rs')
-rw-r--r--crates/ra_hir/src/module.rs25
1 files changed, 14 insertions, 11 deletions
diff --git a/crates/ra_hir/src/module.rs b/crates/ra_hir/src/module.rs
index d1005eab6..ebaf5f47a 100644
--- a/crates/ra_hir/src/module.rs
+++ b/crates/ra_hir/src/module.rs
@@ -1,8 +1,6 @@
1pub(super) mod imp; 1pub(super) mod imp;
2pub(super) mod nameres; 2pub(super) mod nameres;
3 3
4use log;
5
6use ra_syntax::{ 4use ra_syntax::{
7 algo::generate, 5 algo::generate,
8 ast::{self, AstNode, NameOwner}, 6 ast::{self, AstNode, NameOwner},
@@ -11,10 +9,7 @@ use ra_syntax::{
11use ra_arena::{Arena, RawId, impl_arena_id}; 9use ra_arena::{Arena, RawId, impl_arena_id};
12use relative_path::RelativePathBuf; 10use relative_path::RelativePathBuf;
13 11
14use crate::{ 12use crate::{Name, HirDatabase, SourceItemId, SourceFileItemId, HirFileId};
15 Name, HirDatabase, SourceItemId, SourceFileItemId,
16 HirFileId,
17};
18 13
19pub use self::nameres::{ModuleScope, Resolution, Namespace, PerNs}; 14pub use self::nameres::{ModuleScope, Resolution, Namespace, PerNs};
20 15
@@ -78,7 +73,7 @@ impl ModuleId {
78 pub(crate) fn source(self, tree: &ModuleTree) -> ModuleSource { 73 pub(crate) fn source(self, tree: &ModuleTree) -> ModuleSource {
79 tree.mods[self].source 74 tree.mods[self].source
80 } 75 }
81 fn parent_link(self, tree: &ModuleTree) -> Option<LinkId> { 76 pub(crate) fn parent_link(self, tree: &ModuleTree) -> Option<LinkId> {
82 tree.mods[self].parent 77 tree.mods[self].parent
83 } 78 }
84 pub(crate) fn parent(self, tree: &ModuleTree) -> Option<ModuleId> { 79 pub(crate) fn parent(self, tree: &ModuleTree) -> Option<ModuleId> {
@@ -105,7 +100,11 @@ impl ModuleId {
105 Some((link.name.clone(), module)) 100 Some((link.name.clone(), module))
106 }) 101 })
107 } 102 }
108 fn problems(self, tree: &ModuleTree, db: &impl HirDatabase) -> Vec<(SyntaxNode, Problem)> { 103 pub(crate) fn problems(
104 self,
105 tree: &ModuleTree,
106 db: &impl HirDatabase,
107 ) -> Vec<(SyntaxNode, Problem)> {
109 tree.mods[self] 108 tree.mods[self]
110 .children 109 .children
111 .iter() 110 .iter()
@@ -120,13 +119,17 @@ impl ModuleId {
120} 119}
121 120
122impl LinkId { 121impl LinkId {
123 fn owner(self, tree: &ModuleTree) -> ModuleId { 122 pub(crate) fn owner(self, tree: &ModuleTree) -> ModuleId {
124 tree.links[self].owner 123 tree.links[self].owner
125 } 124 }
126 fn name(self, tree: &ModuleTree) -> &Name { 125 pub(crate) fn name(self, tree: &ModuleTree) -> &Name {
127 &tree.links[self].name 126 &tree.links[self].name
128 } 127 }
129 fn bind_source<'a>(self, tree: &ModuleTree, db: &impl HirDatabase) -> ast::ModuleNode { 128 pub(crate) fn bind_source<'a>(
129 self,
130 tree: &ModuleTree,
131 db: &impl HirDatabase,
132 ) -> ast::ModuleNode {
130 let owner = self.owner(tree); 133 let owner = self.owner(tree);
131 match owner.source(tree).resolve(db) { 134 match owner.source(tree).resolve(db) {
132 ModuleSourceNode::SourceFile(root) => { 135 ModuleSourceNode::SourceFile(root) => {