aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src/completion/completion_context.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide/src/completion/completion_context.rs')
-rw-r--r--crates/ra_ide/src/completion/completion_context.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/crates/ra_ide/src/completion/completion_context.rs b/crates/ra_ide/src/completion/completion_context.rs
index 8b3401595..cfc5c34df 100644
--- a/crates/ra_ide/src/completion/completion_context.rs
+++ b/crates/ra_ide/src/completion/completion_context.rs
@@ -1,6 +1,6 @@
1//! FIXME: write short doc here 1//! FIXME: write short doc here
2 2
3use hir::{Semantics, SemanticsScope}; 3use hir::{Semantics, SemanticsScope, Type};
4use ra_db::SourceDatabase; 4use ra_db::SourceDatabase;
5use ra_ide_db::RootDatabase; 5use ra_ide_db::RootDatabase;
6use ra_syntax::{ 6use ra_syntax::{
@@ -168,6 +168,17 @@ impl<'a> CompletionContext<'a> {
168 self.sema.scope_at_offset(&self.token.parent(), self.offset) 168 self.sema.scope_at_offset(&self.token.parent(), self.offset)
169 } 169 }
170 170
171 pub(crate) fn expected_type_of(&self, node: &SyntaxNode) -> Option<Type> {
172 for ancestor in node.ancestors() {
173 if let Some(pat) = ast::Pat::cast(ancestor.clone()) {
174 return self.sema.type_of_pat(&pat);
175 } else if let Some(expr) = ast::Expr::cast(ancestor) {
176 return self.sema.type_of_expr(&expr);
177 }
178 }
179 None
180 }
181
171 fn fill( 182 fn fill(
172 &mut self, 183 &mut self,
173 original_file: &SyntaxNode, 184 original_file: &SyntaxNode,