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 46e243192..dd7c8a873 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::{
@@ -172,6 +172,17 @@ impl<'a> CompletionContext<'a> {
172 self.sema.scope_at_offset(&self.token.parent(), self.offset) 172 self.sema.scope_at_offset(&self.token.parent(), self.offset)
173 } 173 }
174 174
175 pub(crate) fn expected_type_of(&self, node: &SyntaxNode) -> Option<Type> {
176 for ancestor in node.ancestors() {
177 if let Some(pat) = ast::Pat::cast(ancestor.clone()) {
178 return self.sema.type_of_pat(&pat);
179 } else if let Some(expr) = ast::Expr::cast(ancestor) {
180 return self.sema.type_of_expr(&expr);
181 }
182 }
183 None
184 }
185
175 fn fill( 186 fn fill(
176 &mut self, 187 &mut self,
177 original_file: &SyntaxNode, 188 original_file: &SyntaxNode,