aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis/src/completion/reference_completion.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_analysis/src/completion/reference_completion.rs')
-rw-r--r--crates/ra_analysis/src/completion/reference_completion.rs33
1 files changed, 3 insertions, 30 deletions
diff --git a/crates/ra_analysis/src/completion/reference_completion.rs b/crates/ra_analysis/src/completion/reference_completion.rs
index 46d381927..459ed8f6f 100644
--- a/crates/ra_analysis/src/completion/reference_completion.rs
+++ b/crates/ra_analysis/src/completion/reference_completion.rs
@@ -1,4 +1,4 @@
1use rustc_hash::{FxHashSet}; 1use rustc_hash::FxHashSet;
2use ra_syntax::{ 2use ra_syntax::{
3 SourceFileNode, AstNode, 3 SourceFileNode, AstNode,
4 ast, 4 ast,
@@ -6,7 +6,7 @@ use ra_syntax::{
6}; 6};
7use hir::{ 7use hir::{
8 self, 8 self,
9 FnScopes, Def, Path 9 FnScopes, Path
10}; 10};
11 11
12use crate::{ 12use crate::{
@@ -53,7 +53,7 @@ pub(super) fn completions(
53 .add_to(acc) 53 .add_to(acc)
54 }); 54 });
55 } 55 }
56 NameRefKind::Path(path) => complete_path(acc, db, module, path)?, 56 NameRefKind::Path(_) => (),
57 NameRefKind::BareIdentInMod => (), 57 NameRefKind::BareIdentInMod => (),
58 } 58 }
59 Ok(()) 59 Ok(())
@@ -121,33 +121,6 @@ fn complete_fn(name_ref: ast::NameRef, scopes: &FnScopes, acc: &mut Completions)
121 } 121 }
122} 122}
123 123
124fn complete_path(
125 acc: &mut Completions,
126 db: &RootDatabase,
127 module: &hir::Module,
128 mut path: Path,
129) -> Cancelable<()> {
130 if path.segments.is_empty() {
131 return Ok(());
132 }
133 path.segments.pop();
134 let def_id = match module.resolve_path(db, path)? {
135 None => return Ok(()),
136 Some(it) => it,
137 };
138 let target_module = match def_id.resolve(db)? {
139 Def::Module(it) => it,
140 _ => return Ok(()),
141 };
142 let module_scope = target_module.scope(db)?;
143 module_scope.entries().for_each(|(name, _res)| {
144 CompletionItem::new(name.to_string())
145 .kind(Reference)
146 .add_to(acc)
147 });
148 Ok(())
149}
150
151#[cfg(test)] 124#[cfg(test)]
152mod tests { 125mod tests {
153 use crate::completion::{CompletionKind, check_completion}; 126 use crate::completion::{CompletionKind, check_completion};