From 13d2fd32ab5df598496c6abbf46591ff05cd3def Mon Sep 17 00:00:00 2001 From: gfreezy Date: Wed, 23 Jan 2019 13:21:29 +0800 Subject: fix completion bugs --- crates/ra_hir/src/code_model_impl/module.rs | 4 ++++ crates/ra_hir/src/nameres.rs | 9 +++++++-- crates/ra_hir/src/path.rs | 7 +++++++ crates/ra_ide_api/src/completion/complete_snippet.rs | 13 +++++++++++++ .../ra_ide_api/src/completion/completion_context.rs | 8 +++----- .../completion_item__bindings_from_for.snap | 8 ++++---- .../completion_item__bindings_from_if_let.snap | 10 +++++----- .../completion_item__bindings_from_let.snap | 10 +++++----- ...item__completes_break_and_continue_in_loops1.snap | 18 +++++++++--------- ...item__completes_break_and_continue_in_loops2.snap | 14 +++++++------- ...ont_add_semi_after_return_if_not_a_statement.snap | 14 +++++++------- ...em__dont_show_both_completions_for_shadowing.snap | 8 ++++---- .../completion_item__filter_postfix_completion3.snap | 20 ++++++++++---------- .../completion_item__keywords_in_function1.snap | 14 +++++++------- .../completion_item__keywords_in_function2.snap | 18 +++++++++--------- .../completion_item__keywords_in_function3.snap | 14 +++++++------- .../completion_item__keywords_in_function4.snap | 14 +++++++------- .../completion_item__keywords_in_use_stmt1.snap | 10 +++++----- .../completion_item__keywords_in_use_stmt3.snap | 8 ++++---- ...pletion_item__last_return_in_block_has_semi1.snap | 14 +++++++------- ...pletion_item__last_return_in_block_has_semi2.snap | 14 +++++++------- .../snapshots/completion_item__module_items.snap | 10 +++++----- ...pletion_item__module_items_in_nested_modules.snap | 8 ++++---- .../snapshots/completion_item__return_type.snap | 8 ++++---- .../snapshots/completion_item__self_in_methods.snap | 6 +++--- ...n_item__should_not_complete_snippets_in_path.snap | 5 +++++ ..._item__should_not_complete_snippets_in_path2.snap | 5 +++++ .../completion_item__snippets_in_expressions.snap | 8 ++++---- .../completion_item__snippets_in_items.snap | 8 ++++---- crates/ra_syntax/src/ast.rs | 7 +++++++ 30 files changed, 179 insertions(+), 135 deletions(-) create mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__should_not_complete_snippets_in_path.snap create mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__should_not_complete_snippets_in_path2.snap diff --git a/crates/ra_hir/src/code_model_impl/module.rs b/crates/ra_hir/src/code_model_impl/module.rs index 73c212de8..d94079f11 100644 --- a/crates/ra_hir/src/code_model_impl/module.rs +++ b/crates/ra_hir/src/code_model_impl/module.rs @@ -143,6 +143,10 @@ impl Module { return PerNs::none(); } } + PathKind::Abs => { + // TODO: absolute use is not supported + return PerNs::none(); + } } .def_id, ); diff --git a/crates/ra_hir/src/nameres.rs b/crates/ra_hir/src/nameres.rs index 4874e82f3..72791ed49 100644 --- a/crates/ra_hir/src/nameres.rs +++ b/crates/ra_hir/src/nameres.rs @@ -15,7 +15,8 @@ //! so that the results of name resolution can be preserved unless the module //! structure itself is modified. pub(crate) mod lower; -use lower::*; + +use crate::nameres::lower::*; use std::sync::Arc; @@ -59,7 +60,7 @@ impl ModuleScope { pub struct Resolution { /// None for unresolved pub def_id: PerNs, - /// ident by whitch this is imported into local scope. + /// ident by which this is imported into local scope. pub import: Option, } @@ -317,6 +318,10 @@ where } } PathKind::Crate => module_id.crate_root(&self.module_tree), + PathKind::Abs => { + // TODO: absolute use is not supported for now + return false; + } }; for (i, segment) in import.path.segments.iter().enumerate() { diff --git a/crates/ra_hir/src/path.rs b/crates/ra_hir/src/path.rs index c3d14c689..e13d84c57 100644 --- a/crates/ra_hir/src/path.rs +++ b/crates/ra_hir/src/path.rs @@ -38,6 +38,8 @@ pub enum PathKind { Self_, Super, Crate, + // Absolute path + Abs, } impl Path { @@ -57,6 +59,11 @@ impl Path { let mut segments = Vec::new(); loop { let segment = path.segment()?; + + if segment.has_colon_colon() { + kind = PathKind::Abs; + } + match segment.kind()? { ast::PathSegmentKind::Name(name) => { let args = segment diff --git a/crates/ra_ide_api/src/completion/complete_snippet.rs b/crates/ra_ide_api/src/completion/complete_snippet.rs index d3344b865..d1cea7375 100644 --- a/crates/ra_ide_api/src/completion/complete_snippet.rs +++ b/crates/ra_ide_api/src/completion/complete_snippet.rs @@ -10,6 +10,7 @@ pub(super) fn complete_expr_snippet(acc: &mut Completions, ctx: &CompletionConte if !(ctx.is_trivial_path && ctx.function_syntax.is_some()) { return; } + snippet(ctx, "pd", "eprintln!(\"$0 = {:?}\", $0);").add_to(acc); snippet(ctx, "ppd", "eprintln!(\"$0 = {:#?}\", $0);").add_to(acc); } @@ -47,6 +48,18 @@ mod tests { check_snippet_completion("snippets_in_expressions", r"fn foo(x: i32) { <|> }"); } + #[test] + fn should_not_complete_snippets_in_path() { + check_snippet_completion( + "should_not_complete_snippets_in_path", + r"fn foo(x: i32) { ::foo<|> }", + ); + check_snippet_completion( + "should_not_complete_snippets_in_path2", + r"fn foo(x: i32) { ::<|> }", + ); + } + #[test] fn completes_snippets_in_items() { check_snippet_completion( diff --git a/crates/ra_ide_api/src/completion/completion_context.rs b/crates/ra_ide_api/src/completion/completion_context.rs index b09c66c18..ca2069e2a 100644 --- a/crates/ra_ide_api/src/completion/completion_context.rs +++ b/crates/ra_ide_api/src/completion/completion_context.rs @@ -21,7 +21,7 @@ pub(crate) struct CompletionContext<'a> { pub(super) function_syntax: Option<&'a ast::FnDef>, pub(super) use_item_syntax: Option<&'a ast::UseItem>, pub(super) is_param: bool, - /// A single-indent path, like `foo`. + /// A single-indent path, like `foo`. `::foo` should not be considered a trivial path. pub(super) is_trivial_path: bool, /// If not a trivial, path, the prefix (qualifier). pub(super) path_prefix: Option, @@ -66,13 +66,11 @@ impl<'a> CompletionContext<'a> { } // The range of the identifier that is being completed. - // This is purely advisory and can be used, for example, to highlight this range in the editor. - // Clients are expected to ignore this field. pub(crate) fn source_range(&self) -> TextRange { match self.leaf.kind() { // workaroud when completion is triggered by trigger characters. - DOT | COLONCOLON => TextRange::from_to(self.offset, self.offset), - _ => self.leaf.range(), + IDENT => self.leaf.range(), + _ => TextRange::offset_len(self.offset, 0.into()), } } diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__bindings_from_for.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__bindings_from_for.snap index eb806ad62..329309c90 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__bindings_from_for.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__bindings_from_for.snap @@ -1,8 +1,8 @@ --- -created: "2019-01-22T15:38:19.841148300+00:00" +created: "2019-01-23T07:42:59.656273+00:00" creator: insta@0.4.0 expression: kind_completions -source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" +source: crates/ra_ide_api/src/completion/completion_item.rs --- [ CompletionItem { @@ -16,7 +16,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" lookup: None, insert_text: None, insert_text_format: PlainText, - source_range: [62; 100), + source_range: [83; 83), text_edit: None }, CompletionItem { @@ -34,7 +34,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "quux()$0" ), insert_text_format: Snippet, - source_range: [62; 100), + source_range: [83; 83), text_edit: None } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__bindings_from_if_let.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__bindings_from_if_let.snap index 4bb28c7e8..dbbe06c7b 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__bindings_from_if_let.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__bindings_from_if_let.snap @@ -1,8 +1,8 @@ --- -created: "2019-01-22T15:38:19.863089100+00:00" +created: "2019-01-23T07:42:59.658419+00:00" creator: insta@0.4.0 expression: kind_completions -source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" +source: crates/ra_ide_api/src/completion/completion_item.rs --- [ CompletionItem { @@ -16,7 +16,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" lookup: None, insert_text: None, insert_text_format: PlainText, - source_range: [213; 231), + source_range: [214; 214), text_edit: None }, CompletionItem { @@ -30,7 +30,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" lookup: None, insert_text: None, insert_text_format: PlainText, - source_range: [213; 231), + source_range: [214; 214), text_edit: None }, CompletionItem { @@ -48,7 +48,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "quux()$0" ), insert_text_format: Snippet, - source_range: [213; 231), + source_range: [214; 214), text_edit: None } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__bindings_from_let.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__bindings_from_let.snap index 0579d00ec..b727bb70c 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__bindings_from_let.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__bindings_from_let.snap @@ -1,8 +1,8 @@ --- -created: "2019-01-22T15:38:19.881041600+00:00" +created: "2019-01-23T07:42:59.657713+00:00" creator: insta@0.4.0 expression: kind_completions -source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" +source: crates/ra_ide_api/src/completion/completion_item.rs --- [ CompletionItem { @@ -16,7 +16,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" lookup: None, insert_text: None, insert_text_format: PlainText, - source_range: [78; 79), + source_range: [79; 79), text_edit: None }, CompletionItem { @@ -30,7 +30,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" lookup: None, insert_text: None, insert_text_format: PlainText, - source_range: [78; 79), + source_range: [79; 79), text_edit: None }, CompletionItem { @@ -48,7 +48,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "quux($0)" ), insert_text_format: Snippet, - source_range: [78; 79), + source_range: [79; 79), text_edit: None } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__completes_break_and_continue_in_loops1.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__completes_break_and_continue_in_loops1.snap index 2e763fe1d..8dcb773d0 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__completes_break_and_continue_in_loops1.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__completes_break_and_continue_in_loops1.snap @@ -1,8 +1,8 @@ --- -created: "2019-01-22T14:45:00.620177400+00:00" +created: "2019-01-23T05:27:32.197434+00:00" creator: insta@0.4.0 expression: kind_completions -source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" +source: crates/ra_ide_api/src/completion/completion_item.rs --- [ CompletionItem { @@ -18,7 +18,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "if $0 {}" ), insert_text_format: Snippet, - source_range: [54; 56), + source_range: [55; 55), text_edit: None }, CompletionItem { @@ -34,7 +34,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "match $0 {}" ), insert_text_format: Snippet, - source_range: [54; 56), + source_range: [55; 55), text_edit: None }, CompletionItem { @@ -50,7 +50,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "while $0 {}" ), insert_text_format: Snippet, - source_range: [54; 56), + source_range: [55; 55), text_edit: None }, CompletionItem { @@ -66,7 +66,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "loop {$0}" ), insert_text_format: Snippet, - source_range: [54; 56), + source_range: [55; 55), text_edit: None }, CompletionItem { @@ -82,7 +82,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "continue;" ), insert_text_format: Snippet, - source_range: [54; 56), + source_range: [55; 55), text_edit: None }, CompletionItem { @@ -98,7 +98,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "break;" ), insert_text_format: Snippet, - source_range: [54; 56), + source_range: [55; 55), text_edit: None }, CompletionItem { @@ -114,7 +114,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "return $0;" ), insert_text_format: Snippet, - source_range: [54; 56), + source_range: [55; 55), text_edit: None } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__completes_break_and_continue_in_loops2.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__completes_break_and_continue_in_loops2.snap index 9dcdbf63f..1c64c6548 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__completes_break_and_continue_in_loops2.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__completes_break_and_continue_in_loops2.snap @@ -1,8 +1,8 @@ --- -created: "2019-01-22T14:45:00.699965300+00:00" +created: "2019-01-23T05:27:32.314513+00:00" creator: insta@0.4.0 expression: kind_completions -source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" +source: crates/ra_ide_api/src/completion/completion_item.rs --- [ CompletionItem { @@ -18,7 +18,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "if $0 {}" ), insert_text_format: Snippet, - source_range: [59; 61), + source_range: [60; 60), text_edit: None }, CompletionItem { @@ -34,7 +34,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "match $0 {}" ), insert_text_format: Snippet, - source_range: [59; 61), + source_range: [60; 60), text_edit: None }, CompletionItem { @@ -50,7 +50,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "while $0 {}" ), insert_text_format: Snippet, - source_range: [59; 61), + source_range: [60; 60), text_edit: None }, CompletionItem { @@ -66,7 +66,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "loop {$0}" ), insert_text_format: Snippet, - source_range: [59; 61), + source_range: [60; 60), text_edit: None }, CompletionItem { @@ -82,7 +82,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "return $0;" ), insert_text_format: Snippet, - source_range: [59; 61), + source_range: [60; 60), text_edit: None } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__dont_add_semi_after_return_if_not_a_statement.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__dont_add_semi_after_return_if_not_a_statement.snap index e3f00d0f1..8c9657b5c 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__dont_add_semi_after_return_if_not_a_statement.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__dont_add_semi_after_return_if_not_a_statement.snap @@ -1,8 +1,8 @@ --- -created: "2019-01-22T14:45:00.642118600+00:00" +created: "2019-01-23T05:27:32.197678+00:00" creator: insta@0.4.0 expression: kind_completions -source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" +source: crates/ra_ide_api/src/completion/completion_item.rs --- [ CompletionItem { @@ -18,7 +18,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "if $0 {}" ), insert_text_format: Snippet, - source_range: [84; 102), + source_range: [85; 85), text_edit: None }, CompletionItem { @@ -34,7 +34,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "match $0 {}" ), insert_text_format: Snippet, - source_range: [84; 102), + source_range: [85; 85), text_edit: None }, CompletionItem { @@ -50,7 +50,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "while $0 {}" ), insert_text_format: Snippet, - source_range: [84; 102), + source_range: [85; 85), text_edit: None }, CompletionItem { @@ -66,7 +66,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "loop {$0}" ), insert_text_format: Snippet, - source_range: [84; 102), + source_range: [85; 85), text_edit: None }, CompletionItem { @@ -82,7 +82,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "return $0" ), insert_text_format: Snippet, - source_range: [84; 102), + source_range: [85; 85), text_edit: None } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__dont_show_both_completions_for_shadowing.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__dont_show_both_completions_for_shadowing.snap index 3e88d8c8e..8f8a3a56c 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__dont_show_both_completions_for_shadowing.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__dont_show_both_completions_for_shadowing.snap @@ -1,8 +1,8 @@ --- -created: "2019-01-22T15:38:19.914951100+00:00" +created: "2019-01-23T07:42:59.658375+00:00" creator: insta@0.4.0 expression: kind_completions -source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" +source: crates/ra_ide_api/src/completion/completion_item.rs --- [ CompletionItem { @@ -16,7 +16,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" lookup: None, insert_text: None, insert_text_format: PlainText, - source_range: [108; 146), + source_range: [129; 129), text_edit: None }, CompletionItem { @@ -34,7 +34,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "foo()$0" ), insert_text_format: Snippet, - source_range: [108; 146), + source_range: [129; 129), text_edit: None } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__filter_postfix_completion3.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__filter_postfix_completion3.snap index e8191596d..e0f4730e7 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__filter_postfix_completion3.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__filter_postfix_completion3.snap @@ -1,8 +1,8 @@ --- -created: "2019-01-22T14:45:00.830614900+00:00" +created: "2019-01-23T05:27:32.222118+00:00" creator: insta@0.4.0 expression: kind_completions -source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" +source: crates/ra_ide_api/src/completion/completion_item.rs --- [ CompletionItem { @@ -16,12 +16,12 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "!bar" ), insert_text_format: Snippet, - source_range: [76; 78), + source_range: [78; 78), text_edit: Some( TextEdit { atoms: [ AtomTextEdit { - delete: [72; 76), + delete: [72; 78), insert: "" } ] @@ -39,12 +39,12 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "if bar {$0}" ), insert_text_format: Snippet, - source_range: [76; 78), + source_range: [78; 78), text_edit: Some( TextEdit { atoms: [ AtomTextEdit { - delete: [72; 76), + delete: [72; 78), insert: "" } ] @@ -62,12 +62,12 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "match bar {\n${1:_} => {$0\\},\n}" ), insert_text_format: Snippet, - source_range: [76; 78), + source_range: [78; 78), text_edit: Some( TextEdit { atoms: [ AtomTextEdit { - delete: [72; 76), + delete: [72; 78), insert: "" } ] @@ -85,12 +85,12 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "while bar {\n$0\n}" ), insert_text_format: Snippet, - source_range: [76; 78), + source_range: [78; 78), text_edit: Some( TextEdit { atoms: [ AtomTextEdit { - delete: [72; 76), + delete: [72; 78), insert: "" } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function1.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function1.snap index f1de82bcc..2b6182578 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function1.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function1.snap @@ -1,8 +1,8 @@ --- -created: "2019-01-22T14:45:00.635137200+00:00" +created: "2019-01-23T05:27:32.197298+00:00" creator: insta@0.4.0 expression: kind_completions -source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" +source: crates/ra_ide_api/src/completion/completion_item.rs --- [ CompletionItem { @@ -18,7 +18,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "if $0 {}" ), insert_text_format: Snippet, - source_range: [24; 54), + source_range: [41; 41), text_edit: None }, CompletionItem { @@ -34,7 +34,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "match $0 {}" ), insert_text_format: Snippet, - source_range: [24; 54), + source_range: [41; 41), text_edit: None }, CompletionItem { @@ -50,7 +50,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "while $0 {}" ), insert_text_format: Snippet, - source_range: [24; 54), + source_range: [41; 41), text_edit: None }, CompletionItem { @@ -66,7 +66,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "loop {$0}" ), insert_text_format: Snippet, - source_range: [24; 54), + source_range: [41; 41), text_edit: None }, CompletionItem { @@ -82,7 +82,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "return;" ), insert_text_format: Snippet, - source_range: [24; 54), + source_range: [41; 41), text_edit: None } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function2.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function2.snap index c309ff9bc..a56105f0c 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function2.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function2.snap @@ -1,8 +1,8 @@ --- -created: "2019-01-22T14:45:00.626162800+00:00" +created: "2019-01-23T05:27:32.197423+00:00" creator: insta@0.4.0 expression: kind_completions -source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" +source: crates/ra_ide_api/src/completion/completion_item.rs --- [ CompletionItem { @@ -18,7 +18,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "if $0 {}" ), insert_text_format: Snippet, - source_range: [91; 105), + source_range: [92; 92), text_edit: None }, CompletionItem { @@ -34,7 +34,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "match $0 {}" ), insert_text_format: Snippet, - source_range: [91; 105), + source_range: [92; 92), text_edit: None }, CompletionItem { @@ -50,7 +50,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "while $0 {}" ), insert_text_format: Snippet, - source_range: [91; 105), + source_range: [92; 92), text_edit: None }, CompletionItem { @@ -66,7 +66,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "loop {$0}" ), insert_text_format: Snippet, - source_range: [91; 105), + source_range: [92; 92), text_edit: None }, CompletionItem { @@ -82,7 +82,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "else {$0}" ), insert_text_format: Snippet, - source_range: [91; 105), + source_range: [92; 92), text_edit: None }, CompletionItem { @@ -98,7 +98,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "else if $0 {}" ), insert_text_format: Snippet, - source_range: [91; 105), + source_range: [92; 92), text_edit: None }, CompletionItem { @@ -114,7 +114,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "return;" ), insert_text_format: Snippet, - source_range: [91; 105), + source_range: [92; 92), text_edit: None } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function3.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function3.snap index 950cc8045..84efab6f6 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function3.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function3.snap @@ -1,8 +1,8 @@ --- -created: "2019-01-22T14:45:00.701959300+00:00" +created: "2019-01-23T05:27:32.200056+00:00" creator: insta@0.4.0 expression: kind_completions -source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" +source: crates/ra_ide_api/src/completion/completion_item.rs --- [ CompletionItem { @@ -18,7 +18,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "if $0 {}" ), insert_text_format: Snippet, - source_range: [31; 65), + source_range: [48; 48), text_edit: None }, CompletionItem { @@ -34,7 +34,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "match $0 {}" ), insert_text_format: Snippet, - source_range: [31; 65), + source_range: [48; 48), text_edit: None }, CompletionItem { @@ -50,7 +50,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "while $0 {}" ), insert_text_format: Snippet, - source_range: [31; 65), + source_range: [48; 48), text_edit: None }, CompletionItem { @@ -66,7 +66,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "loop {$0}" ), insert_text_format: Snippet, - source_range: [31; 65), + source_range: [48; 48), text_edit: None }, CompletionItem { @@ -82,7 +82,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "return $0;" ), insert_text_format: Snippet, - source_range: [31; 65), + source_range: [48; 48), text_edit: None } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function4.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function4.snap index ae14d7e39..8b254ce99 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function4.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_function4.snap @@ -1,8 +1,8 @@ --- -created: "2019-01-22T14:45:00.788727100+00:00" +created: "2019-01-23T05:27:32.314468+00:00" creator: insta@0.4.0 expression: kind_completions -source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" +source: crates/ra_ide_api/src/completion/completion_item.rs --- [ CompletionItem { @@ -18,7 +18,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "if $0 {}" ), insert_text_format: Snippet, - source_range: [24; 58), + source_range: [41; 41), text_edit: None }, CompletionItem { @@ -34,7 +34,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "match $0 {}" ), insert_text_format: Snippet, - source_range: [24; 58), + source_range: [41; 41), text_edit: None }, CompletionItem { @@ -50,7 +50,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "while $0 {}" ), insert_text_format: Snippet, - source_range: [24; 58), + source_range: [41; 41), text_edit: None }, CompletionItem { @@ -66,7 +66,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "loop {$0}" ), insert_text_format: Snippet, - source_range: [24; 58), + source_range: [41; 41), text_edit: None }, CompletionItem { @@ -82,7 +82,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "return;" ), insert_text_format: Snippet, - source_range: [24; 58), + source_range: [41; 41), text_edit: None } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_use_stmt1.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_use_stmt1.snap index 2ec855bf6..9dd5b2254 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_use_stmt1.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_use_stmt1.snap @@ -1,8 +1,8 @@ --- -created: "2019-01-22T14:45:00.626162800+00:00" +created: "2019-01-23T05:27:32.196887+00:00" creator: insta@0.4.0 expression: kind_completions -source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" +source: crates/ra_ide_api/src/completion/completion_item.rs --- [ CompletionItem { @@ -18,7 +18,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "crate::" ), insert_text_format: PlainText, - source_range: [16; 30), + source_range: [17; 17), text_edit: None }, CompletionItem { @@ -32,7 +32,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" lookup: None, insert_text: None, insert_text_format: PlainText, - source_range: [16; 30), + source_range: [17; 17), text_edit: None }, CompletionItem { @@ -48,7 +48,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "super::" ), insert_text_format: PlainText, - source_range: [16; 30), + source_range: [17; 17), text_edit: None } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_use_stmt3.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_use_stmt3.snap index 952650ea3..965a0fbed 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_use_stmt3.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__keywords_in_use_stmt3.snap @@ -1,8 +1,8 @@ --- -created: "2019-01-22T14:45:00.779752+00:00" +created: "2019-01-23T05:27:32.303390+00:00" creator: insta@0.4.0 expression: kind_completions -source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" +source: crates/ra_ide_api/src/completion/completion_item.rs --- [ CompletionItem { @@ -16,7 +16,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" lookup: None, insert_text: None, insert_text_format: PlainText, - source_range: [23; 24), + source_range: [24; 24), text_edit: None }, CompletionItem { @@ -32,7 +32,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "super::" ), insert_text_format: PlainText, - source_range: [23; 24), + source_range: [24; 24), text_edit: None } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__last_return_in_block_has_semi1.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__last_return_in_block_has_semi1.snap index 1d8725d34..d36b555db 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__last_return_in_block_has_semi1.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__last_return_in_block_has_semi1.snap @@ -1,8 +1,8 @@ --- -created: "2019-01-22T14:45:00.642118600+00:00" +created: "2019-01-23T05:27:32.197624+00:00" creator: insta@0.4.0 expression: kind_completions -source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" +source: crates/ra_ide_api/src/completion/completion_item.rs --- [ CompletionItem { @@ -18,7 +18,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "if $0 {}" ), insert_text_format: Snippet, - source_range: [62; 100), + source_range: [83; 83), text_edit: None }, CompletionItem { @@ -34,7 +34,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "match $0 {}" ), insert_text_format: Snippet, - source_range: [62; 100), + source_range: [83; 83), text_edit: None }, CompletionItem { @@ -50,7 +50,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "while $0 {}" ), insert_text_format: Snippet, - source_range: [62; 100), + source_range: [83; 83), text_edit: None }, CompletionItem { @@ -66,7 +66,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "loop {$0}" ), insert_text_format: Snippet, - source_range: [62; 100), + source_range: [83; 83), text_edit: None }, CompletionItem { @@ -82,7 +82,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "return $0;" ), insert_text_format: Snippet, - source_range: [62; 100), + source_range: [83; 83), text_edit: None } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__last_return_in_block_has_semi2.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__last_return_in_block_has_semi2.snap index 54175c1a3..d74483c0b 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__last_return_in_block_has_semi2.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__last_return_in_block_has_semi2.snap @@ -1,8 +1,8 @@ --- -created: "2019-01-22T14:45:00.733874300+00:00" +created: "2019-01-23T05:27:32.302452+00:00" creator: insta@0.4.0 expression: kind_completions -source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" +source: crates/ra_ide_api/src/completion/completion_item.rs --- [ CompletionItem { @@ -18,7 +18,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "if $0 {}" ), insert_text_format: Snippet, - source_range: [62; 100), + source_range: [83; 83), text_edit: None }, CompletionItem { @@ -34,7 +34,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "match $0 {}" ), insert_text_format: Snippet, - source_range: [62; 100), + source_range: [83; 83), text_edit: None }, CompletionItem { @@ -50,7 +50,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "while $0 {}" ), insert_text_format: Snippet, - source_range: [62; 100), + source_range: [83; 83), text_edit: None }, CompletionItem { @@ -66,7 +66,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "loop {$0}" ), insert_text_format: Snippet, - source_range: [62; 100), + source_range: [83; 83), text_edit: None }, CompletionItem { @@ -82,7 +82,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "return $0;" ), insert_text_format: Snippet, - source_range: [62; 100), + source_range: [83; 83), text_edit: None } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__module_items.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__module_items.snap index df9677ba3..a87880ab3 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__module_items.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__module_items.snap @@ -1,8 +1,8 @@ --- -created: "2019-01-22T15:38:19.896999400+00:00" +created: "2019-01-23T07:42:59.657718+00:00" creator: insta@0.4.0 expression: kind_completions -source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" +source: crates/ra_ide_api/src/completion/completion_item.rs --- [ CompletionItem { @@ -20,7 +20,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "quux()$0" ), insert_text_format: Snippet, - source_range: [72; 102), + source_range: [89; 89), text_edit: None }, CompletionItem { @@ -34,7 +34,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" lookup: None, insert_text: None, insert_text_format: PlainText, - source_range: [72; 102), + source_range: [89; 89), text_edit: None }, CompletionItem { @@ -48,7 +48,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" lookup: None, insert_text: None, insert_text_format: PlainText, - source_range: [72; 102), + source_range: [89; 89), text_edit: None } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__module_items_in_nested_modules.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__module_items_in_nested_modules.snap index f4b38feb0..f95d10926 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__module_items_in_nested_modules.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__module_items_in_nested_modules.snap @@ -1,8 +1,8 @@ --- -created: "2019-01-22T15:38:19.896002200+00:00" +created: "2019-01-23T07:42:59.657837+00:00" creator: insta@0.4.0 expression: kind_completions -source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" +source: crates/ra_ide_api/src/completion/completion_item.rs --- [ CompletionItem { @@ -20,7 +20,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "quux()$0" ), insert_text_format: Snippet, - source_range: [100; 102), + source_range: [101; 101), text_edit: None }, CompletionItem { @@ -34,7 +34,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" lookup: None, insert_text: None, insert_text_format: PlainText, - source_range: [100; 102), + source_range: [101; 101), text_edit: None } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__return_type.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__return_type.snap index e6819f231..adc057d80 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__return_type.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__return_type.snap @@ -1,8 +1,8 @@ --- -created: "2019-01-22T14:45:00.898433800+00:00" +created: "2019-01-23T05:27:32.421411+00:00" creator: insta@0.4.0 expression: kind_completions -source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" +source: crates/ra_ide_api/src/completion/completion_item.rs --- [ CompletionItem { @@ -16,7 +16,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" lookup: None, insert_text: None, insert_text_format: PlainText, - source_range: [46; 60), + source_range: [47; 47), text_edit: None }, CompletionItem { @@ -34,7 +34,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "x()$0" ), insert_text_format: Snippet, - source_range: [46; 60), + source_range: [47; 47), text_edit: None } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__self_in_methods.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__self_in_methods.snap index efda72adf..6a49e325c 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__self_in_methods.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__self_in_methods.snap @@ -1,8 +1,8 @@ --- -created: "2019-01-22T14:45:00.894444600+00:00" +created: "2019-01-23T05:27:32.422259+00:00" creator: insta@0.4.0 expression: kind_completions -source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" +source: crates/ra_ide_api/src/completion/completion_item.rs --- [ CompletionItem { @@ -16,7 +16,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" lookup: None, insert_text: None, insert_text_format: PlainText, - source_range: [24; 26), + source_range: [25; 25), text_edit: None } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__should_not_complete_snippets_in_path.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__should_not_complete_snippets_in_path.snap new file mode 100644 index 000000000..cb3278edf --- /dev/null +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__should_not_complete_snippets_in_path.snap @@ -0,0 +1,5 @@ +Created: 2019-01-23T05:19:36.475253+00:00 +Creator: insta@0.1.4 +Source: crates/ra_ide_api/src/completion/completion_item.rs + +[] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__should_not_complete_snippets_in_path2.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__should_not_complete_snippets_in_path2.snap new file mode 100644 index 000000000..62c8e3de9 --- /dev/null +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__should_not_complete_snippets_in_path2.snap @@ -0,0 +1,5 @@ +Created: 2019-01-23T05:19:36.476869+00:00 +Creator: insta@0.1.4 +Source: crates/ra_ide_api/src/completion/completion_item.rs + +[] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__snippets_in_expressions.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__snippets_in_expressions.snap index 1d9aff5bb..580c90bdd 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__snippets_in_expressions.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__snippets_in_expressions.snap @@ -1,8 +1,8 @@ --- -created: "2019-01-22T14:45:00.944312600+00:00" +created: "2019-01-23T05:27:32.430450+00:00" creator: insta@0.4.0 expression: kind_completions -source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" +source: crates/ra_ide_api/src/completion/completion_item.rs --- [ CompletionItem { @@ -18,7 +18,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "eprintln!(\"$0 = {:?}\", $0);" ), insert_text_format: Snippet, - source_range: [16; 18), + source_range: [17; 17), text_edit: None }, CompletionItem { @@ -34,7 +34,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "eprintln!(\"$0 = {:#?}\", $0);" ), insert_text_format: Snippet, - source_range: [16; 18), + source_range: [17; 17), text_edit: None } ] diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__snippets_in_items.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__snippets_in_items.snap index 678335404..ec95e454c 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__snippets_in_items.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__snippets_in_items.snap @@ -1,8 +1,8 @@ --- -created: "2019-01-22T14:45:00.944312600+00:00" +created: "2019-01-23T05:27:32.435110+00:00" creator: insta@0.4.0 expression: kind_completions -source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" +source: crates/ra_ide_api/src/completion/completion_item.rs --- [ CompletionItem { @@ -20,7 +20,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "#[test]\nfn ${1:feature}() {\n $0\n}" ), insert_text_format: Snippet, - source_range: [49; 79), + source_range: [66; 66), text_edit: None }, CompletionItem { @@ -36,7 +36,7 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" "pub(crate) $0" ), insert_text_format: Snippet, - source_range: [49; 79), + source_range: [66; 66), text_edit: None } ] diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs index 5a5f56057..bcbd4c60c 100644 --- a/crates/ra_syntax/src/ast.rs +++ b/crates/ra_syntax/src/ast.rs @@ -334,6 +334,13 @@ impl PathSegment { }; Some(res) } + + pub fn has_colon_colon(&self) -> bool { + match self.syntax.first_child().map(|s| s.kind()) { + Some(COLONCOLON) => true, + _ => false, + } + } } impl Path { -- cgit v1.2.3