diff options
Diffstat (limited to 'crates/ra_ide/src/completion/completion_context.rs')
-rw-r--r-- | crates/ra_ide/src/completion/completion_context.rs | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/crates/ra_ide/src/completion/completion_context.rs b/crates/ra_ide/src/completion/completion_context.rs index c84d43d77..6b03b30bb 100644 --- a/crates/ra_ide/src/completion/completion_context.rs +++ b/crates/ra_ide/src/completion/completion_context.rs | |||
@@ -35,12 +35,12 @@ pub(crate) struct CompletionContext<'a> { | |||
35 | pub(super) krate: Option<hir::Crate>, | 35 | pub(super) krate: Option<hir::Crate>, |
36 | pub(super) expected_type: Option<Type>, | 36 | pub(super) expected_type: Option<Type>, |
37 | pub(super) name_ref_syntax: Option<ast::NameRef>, | 37 | pub(super) name_ref_syntax: Option<ast::NameRef>, |
38 | pub(super) function_syntax: Option<ast::FnDef>, | 38 | pub(super) function_syntax: Option<ast::Fn>, |
39 | pub(super) use_item_syntax: Option<ast::UseItem>, | 39 | pub(super) use_item_syntax: Option<ast::Use>, |
40 | pub(super) record_lit_syntax: Option<ast::RecordLit>, | 40 | pub(super) record_lit_syntax: Option<ast::RecordExpr>, |
41 | pub(super) record_pat_syntax: Option<ast::RecordPat>, | 41 | pub(super) record_pat_syntax: Option<ast::RecordPat>, |
42 | pub(super) record_field_syntax: Option<ast::RecordField>, | 42 | pub(super) record_field_syntax: Option<ast::RecordExprField>, |
43 | pub(super) impl_def: Option<ast::ImplDef>, | 43 | pub(super) impl_def: Option<ast::Impl>, |
44 | /// FIXME: `ActiveParameter` is string-based, which is very very wrong | 44 | /// FIXME: `ActiveParameter` is string-based, which is very very wrong |
45 | pub(super) active_parameter: Option<ActiveParameter>, | 45 | pub(super) active_parameter: Option<ActiveParameter>, |
46 | pub(super) is_param: bool, | 46 | pub(super) is_param: bool, |
@@ -265,7 +265,7 @@ impl<'a> CompletionContext<'a> { | |||
265 | return; | 265 | return; |
266 | } | 266 | } |
267 | // FIXME: remove this (V) duplication and make the check more precise | 267 | // FIXME: remove this (V) duplication and make the check more precise |
268 | if name_ref.syntax().ancestors().find_map(ast::RecordFieldPatList::cast).is_some() { | 268 | if name_ref.syntax().ancestors().find_map(ast::RecordPatFieldList::cast).is_some() { |
269 | self.record_pat_syntax = | 269 | self.record_pat_syntax = |
270 | self.sema.find_node_at_offset_with_macros(&original_file, offset); | 270 | self.sema.find_node_at_offset_with_macros(&original_file, offset); |
271 | } | 271 | } |
@@ -275,7 +275,7 @@ impl<'a> CompletionContext<'a> { | |||
275 | // Otherwise, see if this is a declaration. We can use heuristics to | 275 | // Otherwise, see if this is a declaration. We can use heuristics to |
276 | // suggest declaration names, see `CompletionKind::Magic`. | 276 | // suggest declaration names, see `CompletionKind::Magic`. |
277 | if let Some(name) = find_node_at_offset::<ast::Name>(&file_with_fake_ident, offset) { | 277 | if let Some(name) = find_node_at_offset::<ast::Name>(&file_with_fake_ident, offset) { |
278 | if let Some(bind_pat) = name.syntax().ancestors().find_map(ast::BindPat::cast) { | 278 | if let Some(bind_pat) = name.syntax().ancestors().find_map(ast::IdentPat::cast) { |
279 | self.is_pat_binding_or_const = true; | 279 | self.is_pat_binding_or_const = true; |
280 | if bind_pat.at_token().is_some() | 280 | if bind_pat.at_token().is_some() |
281 | || bind_pat.ref_token().is_some() | 281 | || bind_pat.ref_token().is_some() |
@@ -283,7 +283,7 @@ impl<'a> CompletionContext<'a> { | |||
283 | { | 283 | { |
284 | self.is_pat_binding_or_const = false; | 284 | self.is_pat_binding_or_const = false; |
285 | } | 285 | } |
286 | if bind_pat.syntax().parent().and_then(ast::RecordFieldPatList::cast).is_some() { | 286 | if bind_pat.syntax().parent().and_then(ast::RecordPatFieldList::cast).is_some() { |
287 | self.is_pat_binding_or_const = false; | 287 | self.is_pat_binding_or_const = false; |
288 | } | 288 | } |
289 | if let Some(let_stmt) = bind_pat.syntax().ancestors().find_map(ast::LetStmt::cast) { | 289 | if let Some(let_stmt) = bind_pat.syntax().ancestors().find_map(ast::LetStmt::cast) { |
@@ -300,7 +300,7 @@ impl<'a> CompletionContext<'a> { | |||
300 | return; | 300 | return; |
301 | } | 301 | } |
302 | // FIXME: remove this (^) duplication and make the check more precise | 302 | // FIXME: remove this (^) duplication and make the check more precise |
303 | if name.syntax().ancestors().find_map(ast::RecordFieldPatList::cast).is_some() { | 303 | if name.syntax().ancestors().find_map(ast::RecordPatFieldList::cast).is_some() { |
304 | self.record_pat_syntax = | 304 | self.record_pat_syntax = |
305 | self.sema.find_node_at_offset_with_macros(&original_file, offset); | 305 | self.sema.find_node_at_offset_with_macros(&original_file, offset); |
306 | } | 306 | } |
@@ -316,7 +316,7 @@ impl<'a> CompletionContext<'a> { | |||
316 | self.name_ref_syntax = | 316 | self.name_ref_syntax = |
317 | find_node_at_offset(&original_file, name_ref.syntax().text_range().start()); | 317 | find_node_at_offset(&original_file, name_ref.syntax().text_range().start()); |
318 | let name_range = name_ref.syntax().text_range(); | 318 | let name_range = name_ref.syntax().text_range(); |
319 | if ast::RecordField::for_field_name(&name_ref).is_some() { | 319 | if ast::RecordExprField::for_field_name(&name_ref).is_some() { |
320 | self.record_lit_syntax = | 320 | self.record_lit_syntax = |
321 | self.sema.find_node_at_offset_with_macros(&original_file, offset); | 321 | self.sema.find_node_at_offset_with_macros(&original_file, offset); |
322 | } | 322 | } |
@@ -325,7 +325,7 @@ impl<'a> CompletionContext<'a> { | |||
325 | .sema | 325 | .sema |
326 | .ancestors_with_macros(self.token.parent()) | 326 | .ancestors_with_macros(self.token.parent()) |
327 | .take_while(|it| it.kind() != SOURCE_FILE && it.kind() != MODULE) | 327 | .take_while(|it| it.kind() != SOURCE_FILE && it.kind() != MODULE) |
328 | .find_map(ast::ImplDef::cast); | 328 | .find_map(ast::Impl::cast); |
329 | 329 | ||
330 | let top_node = name_ref | 330 | let top_node = name_ref |
331 | .syntax() | 331 | .syntax() |
@@ -343,13 +343,13 @@ impl<'a> CompletionContext<'a> { | |||
343 | } | 343 | } |
344 | 344 | ||
345 | self.use_item_syntax = | 345 | self.use_item_syntax = |
346 | self.sema.ancestors_with_macros(self.token.parent()).find_map(ast::UseItem::cast); | 346 | self.sema.ancestors_with_macros(self.token.parent()).find_map(ast::Use::cast); |
347 | 347 | ||
348 | self.function_syntax = self | 348 | self.function_syntax = self |
349 | .sema | 349 | .sema |
350 | .ancestors_with_macros(self.token.parent()) | 350 | .ancestors_with_macros(self.token.parent()) |
351 | .take_while(|it| it.kind() != SOURCE_FILE && it.kind() != MODULE) | 351 | .take_while(|it| it.kind() != SOURCE_FILE && it.kind() != MODULE) |
352 | .find_map(ast::FnDef::cast); | 352 | .find_map(ast::Fn::cast); |
353 | 353 | ||
354 | self.record_field_syntax = self | 354 | self.record_field_syntax = self |
355 | .sema | 355 | .sema |
@@ -357,7 +357,7 @@ impl<'a> CompletionContext<'a> { | |||
357 | .take_while(|it| { | 357 | .take_while(|it| { |
358 | it.kind() != SOURCE_FILE && it.kind() != MODULE && it.kind() != CALL_EXPR | 358 | it.kind() != SOURCE_FILE && it.kind() != MODULE && it.kind() != CALL_EXPR |
359 | }) | 359 | }) |
360 | .find_map(ast::RecordField::cast); | 360 | .find_map(ast::RecordExprField::cast); |
361 | 361 | ||
362 | let parent = match name_ref.syntax().parent() { | 362 | let parent = match name_ref.syntax().parent() { |
363 | Some(it) => it, | 363 | Some(it) => it, |
@@ -377,7 +377,7 @@ impl<'a> CompletionContext<'a> { | |||
377 | path.syntax().parent().and_then(ast::TupleStructPat::cast).is_some(); | 377 | path.syntax().parent().and_then(ast::TupleStructPat::cast).is_some(); |
378 | 378 | ||
379 | self.is_path_type = path.syntax().parent().and_then(ast::PathType::cast).is_some(); | 379 | self.is_path_type = path.syntax().parent().and_then(ast::PathType::cast).is_some(); |
380 | self.has_type_args = segment.type_arg_list().is_some(); | 380 | self.has_type_args = segment.generic_arg_list().is_some(); |
381 | 381 | ||
382 | #[allow(deprecated)] | 382 | #[allow(deprecated)] |
383 | if let Some(path) = hir::Path::from_ast(path.clone()) { | 383 | if let Some(path) = hir::Path::from_ast(path.clone()) { |