aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src/completion/completion_context.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-10-09 09:16:18 +0100
committerGitHub <[email protected]>2019-10-09 09:16:18 +0100
commitd5a6cac3357f22dea2e630e17d0f091988cdd558 (patch)
tree416648fde13020d33d62068a5d52221c66c210b5 /crates/ra_ide_api/src/completion/completion_context.rs
parent06a8deae4a29949f438d66c54eed4e016ac35432 (diff)
parente0b1c17dcb367a3edfd9df4b1d7cfbcd059cd207 (diff)
Merge #1970
1970: Add <> when completing generics r=matklad a=matklad @flodiebold wdyt? Is it correct that we always need to add `<>` in generic types? Co-authored-by: Aleksey Kladov <[email protected]>
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();