aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis/src/imp.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_analysis/src/imp.rs')
-rw-r--r--crates/ra_analysis/src/imp.rs22
1 files changed, 21 insertions, 1 deletions
diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs
index f142b6c43..f3e5b2887 100644
--- a/crates/ra_analysis/src/imp.rs
+++ b/crates/ra_analysis/src/imp.rs
@@ -5,7 +5,7 @@ use std::{
5 sync::Arc, 5 sync::Arc,
6}; 6};
7 7
8use ra_editor::{self, find_node_at_offset, resolve_local_name, FileSymbol, LineIndex, LocalEdit}; 8use ra_editor::{self, find_node_at_offset, resolve_local_name, FileSymbol, LineIndex, LocalEdit, CompletionItem};
9use ra_syntax::{ 9use ra_syntax::{
10 ast::{self, ArgListOwner, Expr, NameOwner}, 10 ast::{self, ArgListOwner, Expr, NameOwner},
11 AstNode, File, SmolStr, 11 AstNode, File, SmolStr,
@@ -197,6 +197,26 @@ impl AnalysisImpl {
197 pub fn crate_root(&self, crate_id: CrateId) -> FileId { 197 pub fn crate_root(&self, crate_id: CrateId) -> FileId {
198 self.data.crate_graph.crate_roots[&crate_id] 198 self.data.crate_graph.crate_roots[&crate_id]
199 } 199 }
200 pub fn completions(&self, file_id: FileId, offset: TextUnit) -> Cancelable<Option<Vec<CompletionItem>>> {
201 let mut res = Vec::new();
202 let mut has_completions = false;
203 let file = self.file_syntax(file_id);
204 if let Some(scope_based) = ra_editor::scope_completion(&file, offset) {
205 res.extend(scope_based);
206 has_completions = true;
207 }
208 let root = self.root(file_id);
209 if let Some(scope_based) = crate::completion::resolve_based_completion(root.db(), file_id, offset)? {
210 res.extend(scope_based);
211 has_completions = true;
212 }
213 let res = if has_completions {
214 Some(res)
215 } else {
216 None
217 };
218 Ok(res)
219 }
200 pub fn approximately_resolve_symbol( 220 pub fn approximately_resolve_symbol(
201 &self, 221 &self,
202 file_id: FileId, 222 file_id: FileId,