From 6d548d944fade78edd474433b2436bae3237737e Mon Sep 17 00:00:00 2001 From: DJMcNab <36049421+DJMcNab@users.noreply.github.com> Date: Sat, 8 Dec 2018 14:49:53 +0000 Subject: Fix typo in comment --- crates/ra_analysis/src/imp.rs | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'crates/ra_analysis/src/imp.rs') diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs index 975afc145..e9af98474 100644 --- a/crates/ra_analysis/src/imp.rs +++ b/crates/ra_analysis/src/imp.rs @@ -144,7 +144,7 @@ impl AnalysisImpl { } else { let files = &self.db.source_root(WORKSPACE).files; - /// Need to wrap Snapshot to provide `Clon` impl for `map_with` + /// Need to wrap Snapshot to provide `Clone` impl for `map_with` struct Snap(salsa::Snapshot); impl Clone for Snap { fn clone(&self) -> Snap { @@ -164,7 +164,7 @@ impl AnalysisImpl { .sweep(salsa::SweepStrategy::default().discard_values()); Ok(query.search(&buf)) } - /// This return `Vec`: a module may be included from several places. We + /// This returns `Vec` because a module may be included from several places. We /// don't handle this case yet though, so the Vec has length at most one. pub fn parent_module(&self, position: FilePosition) -> Cancelable> { let descr = match source_binder::module_from_position(&*self.db, position)? { @@ -206,7 +206,7 @@ impl AnalysisImpl { pub fn approximately_resolve_symbol( &self, position: FilePosition, - ) -> Cancelable> { + ) -> Cancelable)>> { let file = self.db.source_file(position.file_id); let syntax = file.syntax(); if let Some(name_ref) = find_node_at_offset::(syntax, position.offset) { @@ -218,20 +218,22 @@ impl AnalysisImpl { let scope = fn_descr.scope(&*self.db); // First try to resolve the symbol locally if let Some(entry) = scope.resolve_local_name(name_ref) { - let mut vec = vec![]; - vec.push(( + let vec = vec![( position.file_id, FileSymbol { name: entry.name().clone(), node_range: entry.ptr().range(), kind: NAME, }, - )); - return Ok(vec); + )]; + return Ok(Some((name_ref.syntax().range(), vec))); }; } // If that fails try the index based approach. - return self.index_resolve(name_ref); + return Ok(Some(( + name_ref.syntax().range(), + self.index_resolve(name_ref)?, + ))); } if let Some(name) = find_node_at_offset::(syntax, position.offset) { if let Some(module) = name.syntax().parent().and_then(ast::Module::cast) { @@ -248,7 +250,7 @@ impl AnalysisImpl { node_range: TextRange::offset_len(0.into(), 0.into()), kind: MODULE, }; - return Ok(vec![(file_id, symbol)]); + return Ok(Some((name.syntax().range(), vec![(file_id, symbol)]))); } } _ => (), @@ -256,7 +258,10 @@ impl AnalysisImpl { } } } - Ok(vec![]) + let range = + ctry!(ra_syntax::algo::find_leaf_at_offset(syntax, position.offset).left_biased()) + .range(); + Ok(Some((range, vec![]))) } pub fn find_all_refs(&self, position: FilePosition) -> Cancelable> { -- cgit v1.2.3