diff options
author | Aleksey Kladov <aleksey.kladov@gmail.com> | 2019-07-04 21:05:17 +0100 |
---|---|---|
committer | Aleksey Kladov <aleksey.kladov@gmail.com> | 2019-07-04 21:09:09 +0100 |
commit | 1834bae5b86c54ed9dece26e82436919d59e6cb7 (patch) | |
tree | 92c8b984e874b67fa1831613464bbe356c1af3dd /crates/ra_ide_api/src/completion | |
parent | 2b2cd829b0f95aef338227deb05ec7503dae9b6c (diff) |
allow rustfmt to reorder imports
This wasn't a right decision in the first place, the feature flag was
broken in the last rustfmt release, and syntax highlighting of imports
is more important anyway
Diffstat (limited to 'crates/ra_ide_api/src/completion')
12 files changed, 41 insertions, 45 deletions
diff --git a/crates/ra_ide_api/src/completion/complete_dot.rs b/crates/ra_ide_api/src/completion/complete_dot.rs index a97e876e9..a5f071442 100644 --- a/crates/ra_ide_api/src/completion/complete_dot.rs +++ b/crates/ra_ide_api/src/completion/complete_dot.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | use hir::{Ty, AdtDef, TypeCtor}; | 1 | use hir::{AdtDef, Ty, TypeCtor}; |
2 | 2 | ||
3 | use crate::completion::{CompletionContext, Completions}; | 3 | use crate::completion::{CompletionContext, Completions}; |
4 | use rustc_hash::FxHashSet; | 4 | use rustc_hash::FxHashSet; |
@@ -49,7 +49,7 @@ fn complete_methods(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty | |||
49 | 49 | ||
50 | #[cfg(test)] | 50 | #[cfg(test)] |
51 | mod tests { | 51 | mod tests { |
52 | use crate::completion::{do_completion, CompletionKind, CompletionItem}; | 52 | use crate::completion::{do_completion, CompletionItem, CompletionKind}; |
53 | use insta::assert_debug_snapshot_matches; | 53 | use insta::assert_debug_snapshot_matches; |
54 | 54 | ||
55 | fn do_ref_completion(code: &str) -> Vec<CompletionItem> { | 55 | fn do_ref_completion(code: &str) -> Vec<CompletionItem> { |
diff --git a/crates/ra_ide_api/src/completion/complete_fn_param.rs b/crates/ra_ide_api/src/completion/complete_fn_param.rs index d738ffc13..5a117c485 100644 --- a/crates/ra_ide_api/src/completion/complete_fn_param.rs +++ b/crates/ra_ide_api/src/completion/complete_fn_param.rs | |||
@@ -1,11 +1,10 @@ | |||
1 | use ra_syntax::{ | 1 | use ra_syntax::{ |
2 | algo::visit::{visitor_ctx, VisitorCtx}, | 2 | algo::visit::{visitor_ctx, VisitorCtx}, |
3 | ast, | 3 | ast, AstNode, |
4 | AstNode, | ||
5 | }; | 4 | }; |
6 | use rustc_hash::FxHashMap; | 5 | use rustc_hash::FxHashMap; |
7 | 6 | ||
8 | use crate::completion::{CompletionContext, Completions, CompletionKind, CompletionItem}; | 7 | use crate::completion::{CompletionContext, CompletionItem, CompletionKind, Completions}; |
9 | 8 | ||
10 | /// Complete repeated parameters, both name and type. For example, if all | 9 | /// Complete repeated parameters, both name and type. For example, if all |
11 | /// functions in a file have a `spam: &mut Spam` parameter, a completion with | 10 | /// functions in a file have a `spam: &mut Spam` parameter, a completion with |
diff --git a/crates/ra_ide_api/src/completion/complete_keyword.rs b/crates/ra_ide_api/src/completion/complete_keyword.rs index cfb9fd6e8..034ed934d 100644 --- a/crates/ra_ide_api/src/completion/complete_keyword.rs +++ b/crates/ra_ide_api/src/completion/complete_keyword.rs | |||
@@ -1,11 +1,14 @@ | |||
1 | use ra_syntax::{ | 1 | use ra_syntax::{ |
2 | algo::visit::{visitor, Visitor}, | 2 | algo::visit::{visitor, Visitor}, |
3 | AstNode, | ||
4 | ast::{self, LoopBodyOwner}, | 3 | ast::{self, LoopBodyOwner}, |
5 | SyntaxKind::*, SyntaxToken, | 4 | AstNode, |
5 | SyntaxKind::*, | ||
6 | SyntaxToken, | ||
6 | }; | 7 | }; |
7 | 8 | ||
8 | use crate::completion::{CompletionContext, CompletionItem, Completions, CompletionKind, CompletionItemKind}; | 9 | use crate::completion::{ |
10 | CompletionContext, CompletionItem, CompletionItemKind, CompletionKind, Completions, | ||
11 | }; | ||
9 | 12 | ||
10 | pub(super) fn complete_use_tree_keyword(acc: &mut Completions, ctx: &CompletionContext) { | 13 | pub(super) fn complete_use_tree_keyword(acc: &mut Completions, ctx: &CompletionContext) { |
11 | // complete keyword "crate" in use stmt | 14 | // complete keyword "crate" in use stmt |
diff --git a/crates/ra_ide_api/src/completion/complete_path.rs b/crates/ra_ide_api/src/completion/complete_path.rs index da8fb9d8e..29586cd1f 100644 --- a/crates/ra_ide_api/src/completion/complete_path.rs +++ b/crates/ra_ide_api/src/completion/complete_path.rs | |||
@@ -1,8 +1,8 @@ | |||
1 | use hir::{Resolution, Either}; | 1 | use hir::{Either, Resolution}; |
2 | use ra_syntax::AstNode; | 2 | use ra_syntax::AstNode; |
3 | use test_utils::tested_by; | 3 | use test_utils::tested_by; |
4 | 4 | ||
5 | use crate::completion::{Completions, CompletionContext}; | 5 | use crate::completion::{CompletionContext, Completions}; |
6 | 6 | ||
7 | pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) { | 7 | pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) { |
8 | let path = match &ctx.path_prefix { | 8 | let path = match &ctx.path_prefix { |
@@ -78,7 +78,7 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) { | |||
78 | mod tests { | 78 | mod tests { |
79 | use test_utils::covers; | 79 | use test_utils::covers; |
80 | 80 | ||
81 | use crate::completion::{CompletionKind, do_completion, CompletionItem}; | 81 | use crate::completion::{do_completion, CompletionItem, CompletionKind}; |
82 | use insta::assert_debug_snapshot_matches; | 82 | use insta::assert_debug_snapshot_matches; |
83 | 83 | ||
84 | fn do_reference_completion(code: &str) -> Vec<CompletionItem> { | 84 | fn do_reference_completion(code: &str) -> Vec<CompletionItem> { |
diff --git a/crates/ra_ide_api/src/completion/complete_pattern.rs b/crates/ra_ide_api/src/completion/complete_pattern.rs index 6655a05a7..f12dfcc17 100644 --- a/crates/ra_ide_api/src/completion/complete_pattern.rs +++ b/crates/ra_ide_api/src/completion/complete_pattern.rs | |||
@@ -27,8 +27,8 @@ pub(super) fn complete_pattern(acc: &mut Completions, ctx: &CompletionContext) { | |||
27 | 27 | ||
28 | #[cfg(test)] | 28 | #[cfg(test)] |
29 | mod tests { | 29 | mod tests { |
30 | use crate::completion::{do_completion, CompletionItem, CompletionKind}; | ||
30 | use insta::assert_debug_snapshot_matches; | 31 | use insta::assert_debug_snapshot_matches; |
31 | use crate::completion::{CompletionItem, CompletionKind, do_completion}; | ||
32 | 32 | ||
33 | fn complete(code: &str) -> Vec<CompletionItem> { | 33 | fn complete(code: &str) -> Vec<CompletionItem> { |
34 | do_completion(code, CompletionKind::Reference) | 34 | do_completion(code, CompletionKind::Reference) |
diff --git a/crates/ra_ide_api/src/completion/complete_postfix.rs b/crates/ra_ide_api/src/completion/complete_postfix.rs index e20a12e2a..7042d8bff 100644 --- a/crates/ra_ide_api/src/completion/complete_postfix.rs +++ b/crates/ra_ide_api/src/completion/complete_postfix.rs | |||
@@ -1,18 +1,11 @@ | |||
1 | use crate::{ | 1 | use crate::{ |
2 | completion::{ | 2 | completion::{ |
3 | completion_item::{ | ||
4 | Completions, | ||
5 | Builder, | ||
6 | CompletionKind, | ||
7 | }, | ||
8 | completion_context::CompletionContext, | 3 | completion_context::CompletionContext, |
4 | completion_item::{Builder, CompletionKind, Completions}, | ||
9 | }, | 5 | }, |
10 | CompletionItem | 6 | CompletionItem, |
11 | }; | ||
12 | use ra_syntax::{ | ||
13 | ast::AstNode, | ||
14 | TextRange | ||
15 | }; | 7 | }; |
8 | use ra_syntax::{ast::AstNode, TextRange}; | ||
16 | use ra_text_edit::TextEditBuilder; | 9 | use ra_text_edit::TextEditBuilder; |
17 | 10 | ||
18 | fn postfix_snippet(ctx: &CompletionContext, label: &str, detail: &str, snippet: &str) -> Builder { | 11 | fn postfix_snippet(ctx: &CompletionContext, label: &str, detail: &str, snippet: &str) -> Builder { |
@@ -58,7 +51,7 @@ pub(super) fn complete_postfix(acc: &mut Completions, ctx: &CompletionContext) { | |||
58 | 51 | ||
59 | #[cfg(test)] | 52 | #[cfg(test)] |
60 | mod tests { | 53 | mod tests { |
61 | use crate::completion::{CompletionKind, check_completion}; | 54 | use crate::completion::{check_completion, CompletionKind}; |
62 | 55 | ||
63 | fn check_snippet_completion(test_name: &str, code: &str) { | 56 | fn check_snippet_completion(test_name: &str, code: &str) { |
64 | check_completion(test_name, code, CompletionKind::Postfix); | 57 | check_completion(test_name, code, CompletionKind::Postfix); |
diff --git a/crates/ra_ide_api/src/completion/complete_scope.rs b/crates/ra_ide_api/src/completion/complete_scope.rs index 0f8cfaae8..1ba871257 100644 --- a/crates/ra_ide_api/src/completion/complete_scope.rs +++ b/crates/ra_ide_api/src/completion/complete_scope.rs | |||
@@ -1,9 +1,9 @@ | |||
1 | use rustc_hash::FxHashMap; | ||
2 | use ra_text_edit::TextEditBuilder; | ||
3 | use ra_syntax::{SmolStr, ast, AstNode}; | ||
4 | use ra_assists::auto_import; | 1 | use ra_assists::auto_import; |
2 | use ra_syntax::{ast, AstNode, SmolStr}; | ||
3 | use ra_text_edit::TextEditBuilder; | ||
4 | use rustc_hash::FxHashMap; | ||
5 | 5 | ||
6 | use crate::completion::{CompletionItem, Completions, CompletionKind, CompletionContext}; | 6 | use crate::completion::{CompletionContext, CompletionItem, CompletionKind, Completions}; |
7 | 7 | ||
8 | pub(super) fn complete_scope(acc: &mut Completions, ctx: &CompletionContext) { | 8 | pub(super) fn complete_scope(acc: &mut Completions, ctx: &CompletionContext) { |
9 | if ctx.is_trivial_path { | 9 | if ctx.is_trivial_path { |
@@ -121,7 +121,7 @@ impl ImportResolver { | |||
121 | 121 | ||
122 | #[cfg(test)] | 122 | #[cfg(test)] |
123 | mod tests { | 123 | mod tests { |
124 | use crate::completion::{CompletionKind, check_completion}; | 124 | use crate::completion::{check_completion, CompletionKind}; |
125 | 125 | ||
126 | fn check_reference_completion(name: &str, code: &str) { | 126 | fn check_reference_completion(name: &str, code: &str) { |
127 | check_completion(name, code, CompletionKind::Reference); | 127 | check_completion(name, code, CompletionKind::Reference); |
diff --git a/crates/ra_ide_api/src/completion/complete_snippet.rs b/crates/ra_ide_api/src/completion/complete_snippet.rs index e1df9e625..d2d364b57 100644 --- a/crates/ra_ide_api/src/completion/complete_snippet.rs +++ b/crates/ra_ide_api/src/completion/complete_snippet.rs | |||
@@ -1,4 +1,7 @@ | |||
1 | use crate::completion::{CompletionItem, Completions, CompletionKind, CompletionItemKind, CompletionContext, completion_item::Builder}; | 1 | use crate::completion::{ |
2 | completion_item::Builder, CompletionContext, CompletionItem, CompletionItemKind, | ||
3 | CompletionKind, Completions, | ||
4 | }; | ||
2 | 5 | ||
3 | fn snippet(ctx: &CompletionContext, label: &str, snippet: &str) -> Builder { | 6 | fn snippet(ctx: &CompletionContext, label: &str, snippet: &str) -> Builder { |
4 | CompletionItem::new(CompletionKind::Snippet, ctx.source_range(), label) | 7 | CompletionItem::new(CompletionKind::Snippet, ctx.source_range(), label) |
@@ -36,7 +39,7 @@ fn ${1:feature}() { | |||
36 | 39 | ||
37 | #[cfg(test)] | 40 | #[cfg(test)] |
38 | mod tests { | 41 | mod tests { |
39 | use crate::completion::{CompletionKind, check_completion}; | 42 | use crate::completion::{check_completion, CompletionKind}; |
40 | 43 | ||
41 | fn check_snippet_completion(name: &str, code: &str) { | 44 | fn check_snippet_completion(name: &str, code: &str) { |
42 | check_completion(name, code, CompletionKind::Snippet); | 45 | check_completion(name, code, CompletionKind::Snippet); |
diff --git a/crates/ra_ide_api/src/completion/complete_struct_literal.rs b/crates/ra_ide_api/src/completion/complete_struct_literal.rs index 1eeea58f6..35fb21113 100644 --- a/crates/ra_ide_api/src/completion/complete_struct_literal.rs +++ b/crates/ra_ide_api/src/completion/complete_struct_literal.rs | |||
@@ -27,8 +27,8 @@ pub(super) fn complete_struct_literal(acc: &mut Completions, ctx: &CompletionCon | |||
27 | 27 | ||
28 | #[cfg(test)] | 28 | #[cfg(test)] |
29 | mod tests { | 29 | mod tests { |
30 | use crate::completion::{do_completion, CompletionItem, CompletionKind}; | ||
30 | use insta::assert_debug_snapshot_matches; | 31 | use insta::assert_debug_snapshot_matches; |
31 | use crate::completion::{CompletionItem, CompletionKind, do_completion}; | ||
32 | 32 | ||
33 | fn complete(code: &str) -> Vec<CompletionItem> { | 33 | fn complete(code: &str) -> Vec<CompletionItem> { |
34 | do_completion(code, CompletionKind::Reference) | 34 | do_completion(code, CompletionKind::Reference) |
diff --git a/crates/ra_ide_api/src/completion/completion_context.rs b/crates/ra_ide_api/src/completion/completion_context.rs index bda7d9bb2..55fdba50d 100644 --- a/crates/ra_ide_api/src/completion/completion_context.rs +++ b/crates/ra_ide_api/src/completion/completion_context.rs | |||
@@ -1,11 +1,11 @@ | |||
1 | use ra_text_edit::AtomTextEdit; | 1 | use hir::source_binder; |
2 | use ra_syntax::{ | 2 | use ra_syntax::{ |
3 | AstNode, SyntaxNode, SourceFile, TextUnit, TextRange, SyntaxToken, Parse, | 3 | algo::{find_covering_element, find_node_at_offset, find_token_at_offset}, |
4 | ast, | 4 | ast, AstNode, Parse, SourceFile, |
5 | algo::{find_token_at_offset, find_covering_element, find_node_at_offset}, | ||
6 | SyntaxKind::*, | 5 | SyntaxKind::*, |
6 | SyntaxNode, SyntaxToken, TextRange, TextUnit, | ||
7 | }; | 7 | }; |
8 | use hir::source_binder; | 8 | use ra_text_edit::AtomTextEdit; |
9 | 9 | ||
10 | use crate::{db, FilePosition}; | 10 | use crate::{db, FilePosition}; |
11 | 11 | ||
diff --git a/crates/ra_ide_api/src/completion/completion_item.rs b/crates/ra_ide_api/src/completion/completion_item.rs index 6f2a60640..f78c4c877 100644 --- a/crates/ra_ide_api/src/completion/completion_item.rs +++ b/crates/ra_ide_api/src/completion/completion_item.rs | |||
@@ -2,7 +2,7 @@ use std::fmt; | |||
2 | 2 | ||
3 | use hir::Documentation; | 3 | use hir::Documentation; |
4 | use ra_syntax::TextRange; | 4 | use ra_syntax::TextRange; |
5 | use ra_text_edit::{TextEditBuilder, TextEdit}; | 5 | use ra_text_edit::{TextEdit, TextEditBuilder}; |
6 | 6 | ||
7 | /// `CompletionItem` describes a single completion variant in the editor pop-up. | 7 | /// `CompletionItem` describes a single completion variant in the editor pop-up. |
8 | /// It is basically a POD with various properties. To construct a | 8 | /// It is basically a POD with various properties. To construct a |
@@ -285,8 +285,8 @@ impl Into<Vec<CompletionItem>> for Completions { | |||
285 | 285 | ||
286 | #[cfg(test)] | 286 | #[cfg(test)] |
287 | pub(crate) fn do_completion(code: &str, kind: CompletionKind) -> Vec<CompletionItem> { | 287 | pub(crate) fn do_completion(code: &str, kind: CompletionKind) -> Vec<CompletionItem> { |
288 | use crate::mock_analysis::{single_file_with_position, analysis_and_position}; | ||
289 | use crate::completion::completions; | 288 | use crate::completion::completions; |
289 | use crate::mock_analysis::{analysis_and_position, single_file_with_position}; | ||
290 | let (analysis, position) = if code.contains("//-") { | 290 | let (analysis, position) = if code.contains("//-") { |
291 | analysis_and_position(code) | 291 | analysis_and_position(code) |
292 | } else { | 292 | } else { |
diff --git a/crates/ra_ide_api/src/completion/presentation.rs b/crates/ra_ide_api/src/completion/presentation.rs index 973936736..98060947a 100644 --- a/crates/ra_ide_api/src/completion/presentation.rs +++ b/crates/ra_ide_api/src/completion/presentation.rs | |||
@@ -1,16 +1,14 @@ | |||
1 | //! This modules takes care of rendering various defenitions as completion items. | 1 | //! This modules takes care of rendering various defenitions as completion items. |
2 | use hir::{Docs, HasSource, HirDisplay, PerNs, Resolution}; | ||
2 | use join_to_string::join; | 3 | use join_to_string::join; |
3 | use test_utils::tested_by; | ||
4 | use hir::{Docs, PerNs, Resolution, HirDisplay, HasSource}; | ||
5 | use ra_syntax::ast::NameOwner; | 4 | use ra_syntax::ast::NameOwner; |
5 | use test_utils::tested_by; | ||
6 | 6 | ||
7 | use crate::completion::{ | 7 | use crate::completion::{ |
8 | Completions, CompletionKind, CompletionItemKind, CompletionContext, CompletionItem, | 8 | CompletionContext, CompletionItem, CompletionItemKind, CompletionKind, Completions, |
9 | }; | 9 | }; |
10 | 10 | ||
11 | use crate::display::{ | 11 | use crate::display::{const_label, function_label, type_label}; |
12 | function_label, const_label, type_label, | ||
13 | }; | ||
14 | 12 | ||
15 | impl Completions { | 13 | impl Completions { |
16 | pub(crate) fn add_field( | 14 | pub(crate) fn add_field( |
@@ -178,7 +176,7 @@ impl Completions { | |||
178 | mod tests { | 176 | mod tests { |
179 | use test_utils::covers; | 177 | use test_utils::covers; |
180 | 178 | ||
181 | use crate::completion::{CompletionKind, check_completion}; | 179 | use crate::completion::{check_completion, CompletionKind}; |
182 | 180 | ||
183 | fn check_reference_completion(code: &str, expected_completions: &str) { | 181 | fn check_reference_completion(code: &str, expected_completions: &str) { |
184 | check_completion(code, expected_completions, CompletionKind::Reference); | 182 | check_completion(code, expected_completions, CompletionKind::Reference); |