aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/nameres
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-03-26 10:53:50 +0000
committerAleksey Kladov <[email protected]>2019-03-26 10:53:50 +0000
commite4646ce0d5bc232fb525a9330bc0c64d826fd241 (patch)
tree884b57f27d090df3f002a5b918a21d36d535212b /crates/ra_hir/src/nameres
parent5270bca5f72fa65f0515be776e06d3d6a4d1efca (diff)
reduce visibility
Diffstat (limited to 'crates/ra_hir/src/nameres')
-rw-r--r--crates/ra_hir/src/nameres/raw.rs50
1 files changed, 27 insertions, 23 deletions
diff --git a/crates/ra_hir/src/nameres/raw.rs b/crates/ra_hir/src/nameres/raw.rs
index 7a516e556..ee0719ee0 100644
--- a/crates/ra_hir/src/nameres/raw.rs
+++ b/crates/ra_hir/src/nameres/raw.rs
@@ -15,6 +15,10 @@ use crate::{
15 ids::{SourceFileItemId, SourceFileItems}, 15 ids::{SourceFileItemId, SourceFileItems},
16}; 16};
17 17
18/// `RawItems` is a set of top-level items in a file (except for impls).
19///
20/// It is the input to name resolution algorithm. `RawItems` are not invalidated
21/// on most edits.
18#[derive(Debug, Default, PartialEq, Eq)] 22#[derive(Debug, Default, PartialEq, Eq)]
19pub struct RawItems { 23pub struct RawItems {
20 modules: Arena<Module, ModuleData>, 24 modules: Arena<Module, ModuleData>,
@@ -31,11 +35,11 @@ pub struct ImportSourceMap {
31} 35}
32 36
33impl ImportSourceMap { 37impl ImportSourceMap {
34 pub(crate) fn insert(&mut self, import: ImportId, segment: &ast::PathSegment) { 38 fn insert(&mut self, import: ImportId, segment: &ast::PathSegment) {
35 self.map.insert(import, AstPtr::new(segment)) 39 self.map.insert(import, AstPtr::new(segment))
36 } 40 }
37 41
38 pub fn get(&self, source: &ModuleSource, import: ImportId) -> TreeArc<ast::PathSegment> { 42 pub(crate) fn get(&self, source: &ModuleSource, import: ImportId) -> TreeArc<ast::PathSegment> {
39 let file = match source { 43 let file = match source {
40 ModuleSource::SourceFile(file) => &*file, 44 ModuleSource::SourceFile(file) => &*file,
41 ModuleSource::Module(m) => m.syntax().ancestors().find_map(SourceFile::cast).unwrap(), 45 ModuleSource::Module(m) => m.syntax().ancestors().find_map(SourceFile::cast).unwrap(),
@@ -64,7 +68,7 @@ impl RawItems {
64 (Arc::new(collector.raw_items), Arc::new(collector.source_map)) 68 (Arc::new(collector.raw_items), Arc::new(collector.source_map))
65 } 69 }
66 70
67 pub(crate) fn items(&self) -> &[RawItem] { 71 pub(super) fn items(&self) -> &[RawItem] {
68 &self.items 72 &self.items
69 } 73 }
70} 74}
@@ -98,7 +102,7 @@ impl Index<Macro> for RawItems {
98} 102}
99 103
100#[derive(Debug, PartialEq, Eq, Clone, Copy)] 104#[derive(Debug, PartialEq, Eq, Clone, Copy)]
101pub(crate) enum RawItem { 105pub(super) enum RawItem {
102 Module(Module), 106 Module(Module),
103 Import(ImportId), 107 Import(ImportId),
104 Def(Def), 108 Def(Def),
@@ -106,11 +110,11 @@ pub(crate) enum RawItem {
106} 110}
107 111
108#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 112#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
109pub(crate) struct Module(RawId); 113pub(super) struct Module(RawId);
110impl_arena_id!(Module); 114impl_arena_id!(Module);
111 115
112#[derive(Debug, PartialEq, Eq)] 116#[derive(Debug, PartialEq, Eq)]
113pub(crate) enum ModuleData { 117pub(super) enum ModuleData {
114 Declaration { name: Name, source_item_id: SourceFileItemId }, 118 Declaration { name: Name, source_item_id: SourceFileItemId },
115 Definition { name: Name, source_item_id: SourceFileItemId, items: Vec<RawItem> }, 119 Definition { name: Name, source_item_id: SourceFileItemId, items: Vec<RawItem> },
116} 120}
@@ -121,26 +125,26 @@ impl_arena_id!(ImportId);
121 125
122#[derive(Debug, Clone, PartialEq, Eq)] 126#[derive(Debug, Clone, PartialEq, Eq)]
123pub struct ImportData { 127pub struct ImportData {
124 pub(crate) path: Path, 128 pub(super) path: Path,
125 pub(crate) alias: Option<Name>, 129 pub(super) alias: Option<Name>,
126 pub(crate) is_glob: bool, 130 pub(super) is_glob: bool,
127 pub(crate) is_prelude: bool, 131 pub(super) is_prelude: bool,
128 pub(crate) is_extern_crate: bool, 132 pub(super) is_extern_crate: bool,
129} 133}
130 134
131#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 135#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
132pub(crate) struct Def(RawId); 136pub(super) struct Def(RawId);
133impl_arena_id!(Def); 137impl_arena_id!(Def);
134 138
135#[derive(Debug, PartialEq, Eq)] 139#[derive(Debug, PartialEq, Eq)]
136pub(crate) struct DefData { 140pub(super) struct DefData {
137 pub(crate) source_item_id: SourceFileItemId, 141 pub(super) source_item_id: SourceFileItemId,
138 pub(crate) name: Name, 142 pub(super) name: Name,
139 pub(crate) kind: DefKind, 143 pub(super) kind: DefKind,
140} 144}
141 145
142#[derive(Debug, PartialEq, Eq, Clone, Copy)] 146#[derive(Debug, PartialEq, Eq, Clone, Copy)]
143pub(crate) enum DefKind { 147pub(super) enum DefKind {
144 Function, 148 Function,
145 Struct, 149 Struct,
146 Enum, 150 Enum,
@@ -151,15 +155,15 @@ pub(crate) enum DefKind {
151} 155}
152 156
153#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 157#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
154pub(crate) struct Macro(RawId); 158pub(super) struct Macro(RawId);
155impl_arena_id!(Macro); 159impl_arena_id!(Macro);
156 160
157#[derive(Debug, PartialEq, Eq)] 161#[derive(Debug, PartialEq, Eq)]
158pub(crate) struct MacroData { 162pub(super) struct MacroData {
159 pub(crate) source_item_id: SourceFileItemId, 163 pub(super) source_item_id: SourceFileItemId,
160 pub(crate) path: Path, 164 pub(super) path: Path,
161 pub(crate) name: Option<Name>, 165 pub(super) name: Option<Name>,
162 pub(crate) export: bool, 166 pub(super) export: bool,
163} 167}
164 168
165struct RawItemsCollector { 169struct RawItemsCollector {