aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis/src/descriptors
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-11-20 16:40:37 +0000
committerAleksey Kladov <[email protected]>2018-11-20 16:40:37 +0000
commit8086107b6ac8555a226ceb294e2c633dfe36c6e1 (patch)
treee55c7ac4b6353885bd5f433914b1ab2d5705262f /crates/ra_analysis/src/descriptors
parentbcdcfa9df222667e6bfcbb1a8923bdc55bd57dc0 (diff)
implement path conversion
Diffstat (limited to 'crates/ra_analysis/src/descriptors')
-rw-r--r--crates/ra_analysis/src/descriptors/module/nameres.rs45
1 files changed, 44 insertions, 1 deletions
diff --git a/crates/ra_analysis/src/descriptors/module/nameres.rs b/crates/ra_analysis/src/descriptors/module/nameres.rs
index 137aa8b17..b65b6adb7 100644
--- a/crates/ra_analysis/src/descriptors/module/nameres.rs
+++ b/crates/ra_analysis/src/descriptors/module/nameres.rs
@@ -136,7 +136,50 @@ impl InputModuleItems {
136} 136}
137 137
138fn convert_path(prefix: Option<Path>, path: ast::Path) -> Option<Path> { 138fn convert_path(prefix: Option<Path>, path: ast::Path) -> Option<Path> {
139 prefix 139 let prefix = if let Some(qual) = path.qualifier() {
140 Some(convert_path(prefix, qual)?)
141 } else {
142 None
143 };
144 let segment = path.segment()?;
145 let res = match segment.kind()? {
146 ast::PathSegmentKind::Name(name) => {
147 let mut res = prefix.unwrap_or_else(|| Path {
148 kind: PathKind::Abs,
149 segments: Vec::with_capacity(1),
150 });
151 res.segments.push(name.text());
152 res
153 }
154 ast::PathSegmentKind::CrateKw => {
155 if prefix.is_some() {
156 return None;
157 }
158 Path {
159 kind: PathKind::Crate,
160 segments: Vec::new(),
161 }
162 }
163 ast::PathSegmentKind::SelfKw => {
164 if prefix.is_some() {
165 return None;
166 }
167 Path {
168 kind: PathKind::Self_,
169 segments: Vec::new(),
170 }
171 }
172 ast::PathSegmentKind::SuperKw => {
173 if prefix.is_some() {
174 return None;
175 }
176 Path {
177 kind: PathKind::Super,
178 segments: Vec::new(),
179 }
180 }
181 };
182 Some(res)
140} 183}
141 184
142impl ModuleItem { 185impl ModuleItem {