aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src/completion/completion_context.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api/src/completion/completion_context.rs')
-rw-r--r--crates/ra_ide_api/src/completion/completion_context.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/crates/ra_ide_api/src/completion/completion_context.rs b/crates/ra_ide_api/src/completion/completion_context.rs
index e9ad06965..73f3f3960 100644
--- a/crates/ra_ide_api/src/completion/completion_context.rs
+++ b/crates/ra_ide_api/src/completion/completion_context.rs
@@ -40,6 +40,8 @@ pub(crate) struct CompletionContext<'a> {
40 pub(super) dot_receiver: Option<ast::Expr>, 40 pub(super) dot_receiver: Option<ast::Expr>,
41 /// If this is a call (method or function) in particular, i.e. the () are already there. 41 /// If this is a call (method or function) in particular, i.e. the () are already there.
42 pub(super) is_call: bool, 42 pub(super) is_call: bool,
43 pub(super) is_path_type: bool,
44 pub(super) has_type_args: bool,
43} 45}
44 46
45impl<'a> CompletionContext<'a> { 47impl<'a> CompletionContext<'a> {
@@ -76,6 +78,8 @@ impl<'a> CompletionContext<'a> {
76 is_new_item: false, 78 is_new_item: false,
77 dot_receiver: None, 79 dot_receiver: None,
78 is_call: false, 80 is_call: false,
81 is_path_type: false,
82 has_type_args: false,
79 }; 83 };
80 ctx.fill(&original_parse, position.offset); 84 ctx.fill(&original_parse, position.offset);
81 Some(ctx) 85 Some(ctx)
@@ -176,6 +180,9 @@ impl<'a> CompletionContext<'a> {
176 .and_then(|it| it.syntax().parent().and_then(ast::CallExpr::cast)) 180 .and_then(|it| it.syntax().parent().and_then(ast::CallExpr::cast))
177 .is_some(); 181 .is_some();
178 182
183 self.is_path_type = path.syntax().parent().and_then(ast::PathType::cast).is_some();
184 self.has_type_args = segment.type_arg_list().is_some();
185
179 if let Some(mut path) = hir::Path::from_ast(path.clone()) { 186 if let Some(mut path) = hir::Path::from_ast(path.clone()) {
180 if !path.is_ident() { 187 if !path.is_ident() {
181 path.segments.pop().unwrap(); 188 path.segments.pop().unwrap();