aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2018-12-27 20:33:47 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2018-12-27 20:33:47 +0000
commitefb63a7666cc9532d97fa7e0da14b540ae8bd5df (patch)
treec4c1b80d8e2dfbb6533cfbdf0bb647ddbeff9419 /crates/ra_analysis
parentb26ab3603d8f73c8e57e9e90d44486a608bc9370 (diff)
parente0660506719476a0546e10bee816d7220be85440 (diff)
Merge #330
330: WIP: introduce hir::Name r=matklad a=matklad Currently we are using `SmolStr` throughout the hir as a name, but that is really suboptimal choice: we'll probably want some kind of interning in the future, and we'll definitely need to add hygene info to names. This PR aims to replace strings with a slightly more abstract `Name` type. Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_analysis')
-rw-r--r--crates/ra_analysis/src/imp.rs34
1 files changed, 16 insertions, 18 deletions
diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs
index 38a5c1a7d..0471a2fca 100644
--- a/crates/ra_analysis/src/imp.rs
+++ b/crates/ra_analysis/src/imp.rs
@@ -243,7 +243,7 @@ impl AnalysisImpl {
243 rr.add_resolution( 243 rr.add_resolution(
244 position.file_id, 244 position.file_id,
245 FileSymbol { 245 FileSymbol {
246 name: entry.name().clone(), 246 name: entry.name().to_string().into(),
247 node_range: entry.ptr().range(), 247 node_range: entry.ptr().range(),
248 kind: NAME, 248 kind: NAME,
249 }, 249 },
@@ -261,23 +261,21 @@ impl AnalysisImpl {
261 let mut rr = ReferenceResolution::new(name.syntax().range()); 261 let mut rr = ReferenceResolution::new(name.syntax().range());
262 if let Some(module) = name.syntax().parent().and_then(ast::Module::cast) { 262 if let Some(module) = name.syntax().parent().and_then(ast::Module::cast) {
263 if module.has_semi() { 263 if module.has_semi() {
264 let parent_module = 264 if let Some(child_module) =
265 source_binder::module_from_file_id(&*self.db, position.file_id)?; 265 source_binder::module_from_declaration(&*self.db, position.file_id, module)?
266 let child_name = module.name(); 266 {
267 match (parent_module, child_name) { 267 let file_id = child_module.source().file_id();
268 (Some(parent_module), Some(child_name)) => { 268 let name = match child_module.name() {
269 if let Some(child) = parent_module.child(&child_name.text()) { 269 Some(name) => name.to_string().into(),
270 let file_id = child.source().file_id(); 270 None => "".into(),
271 let symbol = FileSymbol { 271 };
272 name: child_name.text(), 272 let symbol = FileSymbol {
273 node_range: TextRange::offset_len(0.into(), 0.into()), 273 name,
274 kind: MODULE, 274 node_range: TextRange::offset_len(0.into(), 0.into()),
275 }; 275 kind: MODULE,
276 rr.add_resolution(file_id, symbol); 276 };
277 return Ok(Some(rr)); 277 rr.add_resolution(file_id, symbol);
278 } 278 return Ok(Some(rr));
279 }
280 _ => (),
281 } 279 }
282 } 280 }
283 } 281 }