diff options
author | Aleksey Kladov <[email protected]> | 2018-10-31 17:59:17 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-10-31 18:01:51 +0000 |
commit | f3fb59d7077801a3a68d2d03eef17d59c2925ae8 (patch) | |
tree | 7665461636576d121063d7cc391351b284a399b9 /crates/ra_analysis/src/imp.rs | |
parent | c02be1502c76cc504ccf7f73dce929585c94377c (diff) |
Move completion to ra_analysis
While we should handle completion for isolated file, it's better
achieved by using empty Analysis, rather than working only with &File:
we need memoization for type inference even inside a single file.
Diffstat (limited to 'crates/ra_analysis/src/imp.rs')
-rw-r--r-- | crates/ra_analysis/src/imp.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs index 6473a1dbc..38d4b6a23 100644 --- a/crates/ra_analysis/src/imp.rs +++ b/crates/ra_analysis/src/imp.rs | |||
@@ -3,7 +3,7 @@ use std::{ | |||
3 | sync::Arc, | 3 | sync::Arc, |
4 | }; | 4 | }; |
5 | 5 | ||
6 | use ra_editor::{self, find_node_at_offset, FileSymbol, LineIndex, LocalEdit, CompletionItem}; | 6 | use ra_editor::{self, find_node_at_offset, FileSymbol, LineIndex, LocalEdit}; |
7 | use ra_syntax::{ | 7 | use ra_syntax::{ |
8 | ast::{self, ArgListOwner, Expr, NameOwner}, | 8 | ast::{self, ArgListOwner, Expr, NameOwner}, |
9 | AstNode, File, SmolStr, | 9 | AstNode, File, SmolStr, |
@@ -26,6 +26,7 @@ use crate::{ | |||
26 | module::{ModuleTree, Problem}, | 26 | module::{ModuleTree, Problem}, |
27 | function::{FnDescriptor, FnId}, | 27 | function::{FnDescriptor, FnId}, |
28 | }, | 28 | }, |
29 | completion::{scope_completion, resolve_based_completion, CompletionItem}, | ||
29 | symbol_index::SymbolIndex, | 30 | symbol_index::SymbolIndex, |
30 | syntax_ptr::SyntaxPtrDatabase, | 31 | syntax_ptr::SyntaxPtrDatabase, |
31 | CrateGraph, CrateId, Diagnostic, FileId, FileResolver, FileSystemEdit, Position, | 32 | CrateGraph, CrateId, Diagnostic, FileId, FileResolver, FileSystemEdit, Position, |
@@ -179,7 +180,7 @@ impl AnalysisHostImpl { | |||
179 | 180 | ||
180 | #[derive(Debug)] | 181 | #[derive(Debug)] |
181 | pub(crate) struct AnalysisImpl { | 182 | pub(crate) struct AnalysisImpl { |
182 | db: db::RootDatabase, | 183 | pub(crate) db: db::RootDatabase, |
183 | } | 184 | } |
184 | 185 | ||
185 | impl AnalysisImpl { | 186 | impl AnalysisImpl { |
@@ -249,12 +250,11 @@ impl AnalysisImpl { | |||
249 | pub fn completions(&self, file_id: FileId, offset: TextUnit) -> Cancelable<Option<Vec<CompletionItem>>> { | 250 | pub fn completions(&self, file_id: FileId, offset: TextUnit) -> Cancelable<Option<Vec<CompletionItem>>> { |
250 | let mut res = Vec::new(); | 251 | let mut res = Vec::new(); |
251 | let mut has_completions = false; | 252 | let mut has_completions = false; |
252 | let file = self.file_syntax(file_id); | 253 | if let Some(scope_based) = scope_completion(&self.db, file_id, offset) { |
253 | if let Some(scope_based) = ra_editor::scope_completion(&file, offset) { | ||
254 | res.extend(scope_based); | 254 | res.extend(scope_based); |
255 | has_completions = true; | 255 | has_completions = true; |
256 | } | 256 | } |
257 | if let Some(scope_based) = crate::completion::resolve_based_completion(&self.db, file_id, offset)? { | 257 | if let Some(scope_based) = resolve_based_completion(&self.db, file_id, offset)? { |
258 | res.extend(scope_based); | 258 | res.extend(scope_based); |
259 | has_completions = true; | 259 | has_completions = true; |
260 | } | 260 | } |