diff options
Diffstat (limited to 'crates/ra_analysis/src/completion/reference_completion.rs')
-rw-r--r-- | crates/ra_analysis/src/completion/reference_completion.rs | 33 |
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 @@ | |||
1 | use rustc_hash::{FxHashSet}; | 1 | use rustc_hash::FxHashSet; |
2 | use ra_syntax::{ | 2 | use ra_syntax::{ |
3 | SourceFileNode, AstNode, | 3 | SourceFileNode, AstNode, |
4 | ast, | 4 | ast, |
@@ -6,7 +6,7 @@ use ra_syntax::{ | |||
6 | }; | 6 | }; |
7 | use hir::{ | 7 | use hir::{ |
8 | self, | 8 | self, |
9 | FnScopes, Def, Path | 9 | FnScopes, Path |
10 | }; | 10 | }; |
11 | 11 | ||
12 | use crate::{ | 12 | use 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 | ||
124 | fn 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)] |
152 | mod tests { | 125 | mod tests { |
153 | use crate::completion::{CompletionKind, check_completion}; | 126 | use crate::completion::{CompletionKind, check_completion}; |