diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-07-04 21:09:32 +0100 |
---|---|---|
committer | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-07-04 21:09:32 +0100 |
commit | cacdb0eab8131bfb945eb7ed0150c92ec56eefe2 (patch) | |
tree | f762de90ce813591bc640ae0bce36493a3dcafa9 /crates/ra_ide_api/src | |
parent | 4e8664d9d37021e85d72b6228fa45e7edf4a1a74 (diff) | |
parent | 1834bae5b86c54ed9dece26e82436919d59e6cb7 (diff) |
Merge #1486
1486: allow rustfmt to reorder imports r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_ide_api/src')
44 files changed, 215 insertions, 235 deletions
diff --git a/crates/ra_ide_api/src/assists.rs b/crates/ra_ide_api/src/assists.rs index 355c0a42a..e3d1ac529 100644 --- a/crates/ra_ide_api/src/assists.rs +++ b/crates/ra_ide_api/src/assists.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | use ra_db::{FileRange, FilePosition}; | 1 | use ra_db::{FilePosition, FileRange}; |
2 | 2 | ||
3 | use crate::{SourceFileEdit, SourceChange, db::RootDatabase}; | 3 | use crate::{db::RootDatabase, SourceChange, SourceFileEdit}; |
4 | 4 | ||
5 | pub use ra_assists::AssistId; | 5 | pub use ra_assists::AssistId; |
6 | 6 | ||
diff --git a/crates/ra_ide_api/src/call_info.rs b/crates/ra_ide_api/src/call_info.rs index 2948c646b..368fdcaa1 100644 --- a/crates/ra_ide_api/src/call_info.rs +++ b/crates/ra_ide_api/src/call_info.rs | |||
@@ -1,12 +1,12 @@ | |||
1 | use test_utils::tested_by; | ||
2 | use ra_db::SourceDatabase; | 1 | use ra_db::SourceDatabase; |
3 | use ra_syntax::{ | 2 | use ra_syntax::{ |
4 | AstNode, SyntaxNode, TextUnit, | ||
5 | ast::{self, ArgListOwner}, | ||
6 | algo::find_node_at_offset, | 3 | algo::find_node_at_offset, |
4 | ast::{self, ArgListOwner}, | ||
5 | AstNode, SyntaxNode, TextUnit, | ||
7 | }; | 6 | }; |
7 | use test_utils::tested_by; | ||
8 | 8 | ||
9 | use crate::{FilePosition, CallInfo, FunctionSignature, db::RootDatabase}; | 9 | use crate::{db::RootDatabase, CallInfo, FilePosition, FunctionSignature}; |
10 | 10 | ||
11 | /// Computes parameter information for the given call expression. | 11 | /// Computes parameter information for the given call expression. |
12 | pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Option<CallInfo> { | 12 | pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Option<CallInfo> { |
diff --git a/crates/ra_ide_api/src/change.rs b/crates/ra_ide_api/src/change.rs index c0c289335..2a1af0a0a 100644 --- a/crates/ra_ide_api/src/change.rs +++ b/crates/ra_ide_api/src/change.rs | |||
@@ -1,22 +1,19 @@ | |||
1 | use std::{ | 1 | use std::{fmt, sync::Arc, time}; |
2 | fmt, time, | ||
3 | sync::Arc, | ||
4 | }; | ||
5 | 2 | ||
6 | use rustc_hash::FxHashMap; | ||
7 | use ra_db::{ | 3 | use ra_db::{ |
8 | SourceRootId, FileId, CrateGraph, SourceDatabase, SourceRoot, | ||
9 | salsa::{Database, SweepStrategy}, | 4 | salsa::{Database, SweepStrategy}, |
5 | CrateGraph, FileId, SourceDatabase, SourceRoot, SourceRootId, | ||
10 | }; | 6 | }; |
7 | use ra_prof::{memory_usage, profile, Bytes}; | ||
11 | use ra_syntax::SourceFile; | 8 | use ra_syntax::SourceFile; |
12 | use ra_prof::{profile, Bytes, memory_usage}; | ||
13 | use relative_path::RelativePathBuf; | ||
14 | use rayon::prelude::*; | 9 | use rayon::prelude::*; |
10 | use relative_path::RelativePathBuf; | ||
11 | use rustc_hash::FxHashMap; | ||
15 | 12 | ||
16 | use crate::{ | 13 | use crate::{ |
17 | db::RootDatabase, | 14 | db::RootDatabase, |
18 | symbol_index::{SymbolIndex, SymbolsDatabase}, | ||
19 | status::syntax_tree_stats, | 15 | status::syntax_tree_stats, |
16 | symbol_index::{SymbolIndex, SymbolsDatabase}, | ||
20 | }; | 17 | }; |
21 | 18 | ||
22 | #[derive(Default)] | 19 | #[derive(Default)] |
diff --git a/crates/ra_ide_api/src/completion.rs b/crates/ra_ide_api/src/completion.rs index 3a75bbf92..c23b5da59 100644 --- a/crates/ra_ide_api/src/completion.rs +++ b/crates/ra_ide_api/src/completion.rs | |||
@@ -14,19 +14,19 @@ mod complete_postfix; | |||
14 | 14 | ||
15 | use ra_db::SourceDatabase; | 15 | use ra_db::SourceDatabase; |
16 | 16 | ||
17 | #[cfg(test)] | ||
18 | use crate::completion::completion_item::{check_completion, do_completion}; | ||
17 | use crate::{ | 19 | use crate::{ |
18 | db, | ||
19 | FilePosition, | ||
20 | completion::{ | 20 | completion::{ |
21 | completion_item::{Completions, CompletionKind}, | ||
22 | completion_context::CompletionContext, | 21 | completion_context::CompletionContext, |
22 | completion_item::{CompletionKind, Completions}, | ||
23 | }, | 23 | }, |
24 | 24 | db, FilePosition, | |
25 | }; | 25 | }; |
26 | #[cfg(test)] | ||
27 | use crate::completion::completion_item::{do_completion, check_completion}; | ||
28 | 26 | ||
29 | pub use crate::completion::completion_item::{CompletionItem, CompletionItemKind, InsertTextFormat}; | 27 | pub use crate::completion::completion_item::{ |
28 | CompletionItem, CompletionItemKind, InsertTextFormat, | ||
29 | }; | ||
30 | 30 | ||
31 | /// Main entry point for completion. We run completion as a two-phase process. | 31 | /// Main entry point for completion. We run completion as a two-phase process. |
32 | /// | 32 | /// |
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); |
diff --git a/crates/ra_ide_api/src/db.rs b/crates/ra_ide_api/src/db.rs index 94977764c..fc5b06ca8 100644 --- a/crates/ra_ide_api/src/db.rs +++ b/crates/ra_ide_api/src/db.rs | |||
@@ -1,14 +1,14 @@ | |||
1 | use std::{ | 1 | use std::{sync::Arc, time}; |
2 | sync::Arc, | ||
3 | time, | ||
4 | }; | ||
5 | 2 | ||
6 | use ra_db::{ | 3 | use ra_db::{ |
7 | CheckCanceled, FileId, Canceled, SourceDatabase, | ||
8 | salsa::{self, Database}, | 4 | salsa::{self, Database}, |
5 | Canceled, CheckCanceled, FileId, SourceDatabase, | ||
9 | }; | 6 | }; |
10 | 7 | ||
11 | use crate::{LineIndex, symbol_index::{self, SymbolsDatabase}}; | 8 | use crate::{ |
9 | symbol_index::{self, SymbolsDatabase}, | ||
10 | LineIndex, | ||
11 | }; | ||
12 | 12 | ||
13 | #[salsa::database( | 13 | #[salsa::database( |
14 | ra_db::SourceDatabaseStorage, | 14 | ra_db::SourceDatabaseStorage, |
diff --git a/crates/ra_ide_api/src/diagnostics.rs b/crates/ra_ide_api/src/diagnostics.rs index 35b3d77df..9ab455b0e 100644 --- a/crates/ra_ide_api/src/diagnostics.rs +++ b/crates/ra_ide_api/src/diagnostics.rs | |||
@@ -1,17 +1,20 @@ | |||
1 | use std::cell::RefCell; | 1 | use std::cell::RefCell; |
2 | 2 | ||
3 | use hir::{ | ||
4 | diagnostics::{Diagnostic as _, DiagnosticSink}, | ||
5 | source_binder, | ||
6 | }; | ||
3 | use itertools::Itertools; | 7 | use itertools::Itertools; |
4 | use hir::{source_binder, diagnostics::{Diagnostic as _, DiagnosticSink}}; | 8 | use ra_assists::ast_editor::{AstBuilder, AstEditor}; |
5 | use ra_db::SourceDatabase; | 9 | use ra_db::SourceDatabase; |
10 | use ra_prof::profile; | ||
6 | use ra_syntax::{ | 11 | use ra_syntax::{ |
7 | T, Location, TextRange, SyntaxNode, | 12 | ast::{self, AstNode, NamedField, NamedFieldList}, |
8 | ast::{self, AstNode, NamedFieldList, NamedField}, | 13 | Location, SyntaxNode, TextRange, T, |
9 | }; | 14 | }; |
10 | use ra_assists::ast_editor::{AstEditor, AstBuilder}; | ||
11 | use ra_text_edit::{TextEdit, TextEditBuilder}; | 15 | use ra_text_edit::{TextEdit, TextEditBuilder}; |
12 | use ra_prof::profile; | ||
13 | 16 | ||
14 | use crate::{Diagnostic, FileId, FileSystemEdit, SourceChange, SourceFileEdit, db::RootDatabase}; | 17 | use crate::{db::RootDatabase, Diagnostic, FileId, FileSystemEdit, SourceChange, SourceFileEdit}; |
15 | 18 | ||
16 | #[derive(Debug, Copy, Clone)] | 19 | #[derive(Debug, Copy, Clone)] |
17 | pub enum Severity { | 20 | pub enum Severity { |
@@ -170,9 +173,9 @@ fn check_struct_shorthand_initialization( | |||
170 | 173 | ||
171 | #[cfg(test)] | 174 | #[cfg(test)] |
172 | mod tests { | 175 | mod tests { |
173 | use test_utils::assert_eq_text; | ||
174 | use insta::assert_debug_snapshot_matches; | 176 | use insta::assert_debug_snapshot_matches; |
175 | use ra_syntax::SourceFile; | 177 | use ra_syntax::SourceFile; |
178 | use test_utils::assert_eq_text; | ||
176 | 179 | ||
177 | use crate::mock_analysis::single_file; | 180 | use crate::mock_analysis::single_file; |
178 | 181 | ||
diff --git a/crates/ra_ide_api/src/display.rs b/crates/ra_ide_api/src/display.rs index 882518838..cc59e99d8 100644 --- a/crates/ra_ide_api/src/display.rs +++ b/crates/ra_ide_api/src/display.rs | |||
@@ -6,14 +6,17 @@ mod navigation_target; | |||
6 | mod structure; | 6 | mod structure; |
7 | mod short_label; | 7 | mod short_label; |
8 | 8 | ||
9 | use ra_syntax::{ast::{self, AstNode, TypeParamsOwner}, SyntaxKind::{ATTR, COMMENT}}; | 9 | use ra_syntax::{ |
10 | ast::{self, AstNode, TypeParamsOwner}, | ||
11 | SyntaxKind::{ATTR, COMMENT}, | ||
12 | }; | ||
10 | 13 | ||
11 | pub use navigation_target::NavigationTarget; | ||
12 | pub use structure::{StructureNode, file_structure}; | ||
13 | pub use function_signature::FunctionSignature; | 14 | pub use function_signature::FunctionSignature; |
15 | pub use navigation_target::NavigationTarget; | ||
16 | pub use structure::{file_structure, StructureNode}; | ||
14 | 17 | ||
18 | pub(crate) use navigation_target::{description_from_symbol, docs_from_symbol}; | ||
15 | pub(crate) use short_label::ShortLabel; | 19 | pub(crate) use short_label::ShortLabel; |
16 | pub(crate) use navigation_target::{docs_from_symbol, description_from_symbol}; | ||
17 | 20 | ||
18 | pub(crate) fn function_label(node: &ast::FnDef) -> String { | 21 | pub(crate) fn function_label(node: &ast::FnDef) -> String { |
19 | FunctionSignature::from(node).to_string() | 22 | FunctionSignature::from(node).to_string() |
diff --git a/crates/ra_ide_api/src/display/function_signature.rs b/crates/ra_ide_api/src/display/function_signature.rs index b0b0c7122..e7ad5a0d1 100644 --- a/crates/ra_ide_api/src/display/function_signature.rs +++ b/crates/ra_ide_api/src/display/function_signature.rs | |||
@@ -1,11 +1,14 @@ | |||
1 | use std::fmt::{self, Display}; | 1 | use std::fmt::{self, Display}; |
2 | 2 | ||
3 | use hir::{Docs, Documentation, HasSource}; | ||
3 | use join_to_string::join; | 4 | use join_to_string::join; |
4 | use ra_syntax::ast::{self, AstNode, NameOwner, VisibilityOwner}; | 5 | use ra_syntax::ast::{self, AstNode, NameOwner, VisibilityOwner}; |
5 | use std::convert::From; | 6 | use std::convert::From; |
6 | use hir::{Docs, Documentation, HasSource}; | ||
7 | 7 | ||
8 | use crate::{db, display::{where_predicates, generic_parameters}}; | 8 | use crate::{ |
9 | db, | ||
10 | display::{generic_parameters, where_predicates}, | ||
11 | }; | ||
9 | 12 | ||
10 | /// Contains information about a function signature | 13 | /// Contains information about a function signature |
11 | #[derive(Debug)] | 14 | #[derive(Debug)] |
diff --git a/crates/ra_ide_api/src/display/navigation_target.rs b/crates/ra_ide_api/src/display/navigation_target.rs index 823cdaaf3..1edb64e3d 100644 --- a/crates/ra_ide_api/src/display/navigation_target.rs +++ b/crates/ra_ide_api/src/display/navigation_target.rs | |||
@@ -1,14 +1,15 @@ | |||
1 | use hir::{FieldSource, HasSource, ImplItem, ModuleSource}; | ||
1 | use ra_db::{FileId, SourceDatabase}; | 2 | use ra_db::{FileId, SourceDatabase}; |
2 | use ra_syntax::{ | 3 | use ra_syntax::{ |
3 | SyntaxNode, AstNode, SmolStr, TextRange, AstPtr, TreeArc, | ||
4 | SyntaxKind::{self, NAME}, | ||
5 | ast::{self, DocCommentsOwner}, | ||
6 | algo::visit::{visitor, Visitor}, | 4 | algo::visit::{visitor, Visitor}, |
5 | ast::{self, DocCommentsOwner}, | ||
6 | AstNode, AstPtr, SmolStr, | ||
7 | SyntaxKind::{self, NAME}, | ||
8 | SyntaxNode, TextRange, TreeArc, | ||
7 | }; | 9 | }; |
8 | use hir::{ModuleSource, FieldSource, ImplItem, HasSource}; | ||
9 | 10 | ||
10 | use crate::{FileSymbol, db::RootDatabase}; | ||
11 | use super::short_label::ShortLabel; | 11 | use super::short_label::ShortLabel; |
12 | use crate::{db::RootDatabase, FileSymbol}; | ||
12 | 13 | ||
13 | /// `NavigationTarget` represents and element in the editor's UI which you can | 14 | /// `NavigationTarget` represents and element in the editor's UI which you can |
14 | /// click on to navigate to a particular piece of code. | 15 | /// click on to navigate to a particular piece of code. |
diff --git a/crates/ra_ide_api/src/display/short_label.rs b/crates/ra_ide_api/src/display/short_label.rs index dc8245c34..f926f631f 100644 --- a/crates/ra_ide_api/src/display/short_label.rs +++ b/crates/ra_ide_api/src/display/short_label.rs | |||
@@ -1,6 +1,4 @@ | |||
1 | use ra_syntax::{ | 1 | use ra_syntax::ast::{self, AstNode, NameOwner, TypeAscriptionOwner, VisibilityOwner}; |
2 | ast::{self, NameOwner, VisibilityOwner, TypeAscriptionOwner, AstNode}, | ||
3 | }; | ||
4 | 2 | ||
5 | pub(crate) trait ShortLabel { | 3 | pub(crate) trait ShortLabel { |
6 | fn short_label(&self) -> Option<String>; | 4 | fn short_label(&self) -> Option<String>; |
diff --git a/crates/ra_ide_api/src/display/structure.rs b/crates/ra_ide_api/src/display/structure.rs index e5057e833..e5b257b9b 100644 --- a/crates/ra_ide_api/src/display/structure.rs +++ b/crates/ra_ide_api/src/display/structure.rs | |||
@@ -2,7 +2,7 @@ use crate::TextRange; | |||
2 | 2 | ||
3 | use ra_syntax::{ | 3 | use ra_syntax::{ |
4 | algo::visit::{visitor, Visitor}, | 4 | algo::visit::{visitor, Visitor}, |
5 | ast::{self, AttrsOwner, NameOwner, TypeParamsOwner, TypeAscriptionOwner}, | 5 | ast::{self, AttrsOwner, NameOwner, TypeAscriptionOwner, TypeParamsOwner}, |
6 | AstNode, SourceFile, SyntaxKind, SyntaxNode, WalkEvent, | 6 | AstNode, SourceFile, SyntaxKind, SyntaxNode, WalkEvent, |
7 | }; | 7 | }; |
8 | 8 | ||
diff --git a/crates/ra_ide_api/src/extend_selection.rs b/crates/ra_ide_api/src/extend_selection.rs index a713b762c..655852514 100644 --- a/crates/ra_ide_api/src/extend_selection.rs +++ b/crates/ra_ide_api/src/extend_selection.rs | |||
@@ -1,13 +1,13 @@ | |||
1 | use ra_db::SourceDatabase; | 1 | use ra_db::SourceDatabase; |
2 | use ra_syntax::{ | 2 | use ra_syntax::{ |
3 | Direction, SyntaxNode, TextRange, TextUnit, SyntaxElement, | ||
4 | algo::{find_covering_element, find_token_at_offset, TokenAtOffset}, | 3 | algo::{find_covering_element, find_token_at_offset, TokenAtOffset}, |
5 | SyntaxKind::*, SyntaxToken, | ||
6 | ast::{self, AstNode, AstToken}, | 4 | ast::{self, AstNode, AstToken}, |
7 | T | 5 | Direction, SyntaxElement, |
6 | SyntaxKind::*, | ||
7 | SyntaxNode, SyntaxToken, TextRange, TextUnit, T, | ||
8 | }; | 8 | }; |
9 | 9 | ||
10 | use crate::{FileRange, db::RootDatabase}; | 10 | use crate::{db::RootDatabase, FileRange}; |
11 | 11 | ||
12 | // FIXME: restore macro support | 12 | // FIXME: restore macro support |
13 | pub(crate) fn extend_selection(db: &RootDatabase, frange: FileRange) -> TextRange { | 13 | pub(crate) fn extend_selection(db: &RootDatabase, frange: FileRange) -> TextRange { |
@@ -205,7 +205,7 @@ fn adj_comments(comment: ast::Comment, dir: Direction) -> ast::Comment { | |||
205 | 205 | ||
206 | #[cfg(test)] | 206 | #[cfg(test)] |
207 | mod tests { | 207 | mod tests { |
208 | use ra_syntax::{SourceFile, AstNode}; | 208 | use ra_syntax::{AstNode, SourceFile}; |
209 | use test_utils::extract_offset; | 209 | use test_utils::extract_offset; |
210 | 210 | ||
211 | use super::*; | 211 | use super::*; |
diff --git a/crates/ra_ide_api/src/folding_ranges.rs b/crates/ra_ide_api/src/folding_ranges.rs index 4400ff232..a1e6f94e0 100644 --- a/crates/ra_ide_api/src/folding_ranges.rs +++ b/crates/ra_ide_api/src/folding_ranges.rs | |||
@@ -1,9 +1,10 @@ | |||
1 | use rustc_hash::FxHashSet; | 1 | use rustc_hash::FxHashSet; |
2 | 2 | ||
3 | use ra_syntax::{ | 3 | use ra_syntax::{ |
4 | SourceFile, SyntaxNode, TextRange, Direction, SyntaxElement, | ||
5 | SyntaxKind::{self, *}, | ||
6 | ast::{self, AstNode, AstToken, VisibilityOwner}, | 4 | ast::{self, AstNode, AstToken, VisibilityOwner}, |
5 | Direction, SourceFile, SyntaxElement, | ||
6 | SyntaxKind::{self, *}, | ||
7 | SyntaxNode, TextRange, | ||
7 | }; | 8 | }; |
8 | 9 | ||
9 | #[derive(Debug, PartialEq, Eq)] | 10 | #[derive(Debug, PartialEq, Eq)] |
diff --git a/crates/ra_ide_api/src/goto_definition.rs b/crates/ra_ide_api/src/goto_definition.rs index 63ba6cf9d..08feed7dc 100644 --- a/crates/ra_ide_api/src/goto_definition.rs +++ b/crates/ra_ide_api/src/goto_definition.rs | |||
@@ -1,19 +1,18 @@ | |||
1 | use ra_db::{FileId, SourceDatabase}; | 1 | use ra_db::{FileId, SourceDatabase}; |
2 | use ra_syntax::{ | 2 | use ra_syntax::{ |
3 | AstNode, ast::{self, DocCommentsOwner}, | ||
4 | algo::{ | 3 | algo::{ |
5 | find_node_at_offset, | 4 | find_node_at_offset, |
6 | visit::{visitor, Visitor}, | 5 | visit::{visitor, Visitor}, |
7 | }, | 6 | }, |
8 | SyntaxNode, | 7 | ast::{self, DocCommentsOwner}, |
8 | AstNode, SyntaxNode, | ||
9 | }; | 9 | }; |
10 | 10 | ||
11 | use crate::{ | 11 | use crate::{ |
12 | FilePosition, NavigationTarget, | ||
13 | db::RootDatabase, | 12 | db::RootDatabase, |
14 | RangeInfo, | ||
15 | name_ref_kind::{NameRefKind::*, classify_name_ref}, | ||
16 | display::ShortLabel, | 13 | display::ShortLabel, |
14 | name_ref_kind::{classify_name_ref, NameRefKind::*}, | ||
15 | FilePosition, NavigationTarget, RangeInfo, | ||
17 | }; | 16 | }; |
18 | 17 | ||
19 | pub(crate) fn goto_definition( | 18 | pub(crate) fn goto_definition( |
diff --git a/crates/ra_ide_api/src/goto_type_definition.rs b/crates/ra_ide_api/src/goto_type_definition.rs index 6f5164e0b..d2d5eae9a 100644 --- a/crates/ra_ide_api/src/goto_type_definition.rs +++ b/crates/ra_ide_api/src/goto_type_definition.rs | |||
@@ -1,10 +1,7 @@ | |||
1 | use ra_db::SourceDatabase; | 1 | use ra_db::SourceDatabase; |
2 | use ra_syntax::{ | 2 | use ra_syntax::{algo::find_token_at_offset, ast, AstNode}; |
3 | AstNode, ast, | ||
4 | algo::find_token_at_offset | ||
5 | }; | ||
6 | 3 | ||
7 | use crate::{FilePosition, NavigationTarget, db::RootDatabase, RangeInfo}; | 4 | use crate::{db::RootDatabase, FilePosition, NavigationTarget, RangeInfo}; |
8 | 5 | ||
9 | pub(crate) fn goto_type_definition( | 6 | pub(crate) fn goto_type_definition( |
10 | db: &RootDatabase, | 7 | db: &RootDatabase, |
diff --git a/crates/ra_ide_api/src/hover.rs b/crates/ra_ide_api/src/hover.rs index df877c324..1edeb7579 100644 --- a/crates/ra_ide_api/src/hover.rs +++ b/crates/ra_ide_api/src/hover.rs | |||
@@ -1,16 +1,22 @@ | |||
1 | use hir::{HasSource, HirDisplay}; | ||
1 | use ra_db::SourceDatabase; | 2 | use ra_db::SourceDatabase; |
2 | use ra_syntax::{ | 3 | use ra_syntax::{ |
3 | AstNode, TreeArc, | 4 | algo::{ |
5 | ancestors_at_offset, find_covering_element, find_node_at_offset, | ||
6 | visit::{visitor, Visitor}, | ||
7 | }, | ||
4 | ast::{self, DocCommentsOwner}, | 8 | ast::{self, DocCommentsOwner}, |
5 | algo::{find_covering_element, find_node_at_offset, ancestors_at_offset, visit::{visitor, Visitor}}, | 9 | AstNode, TreeArc, |
6 | }; | 10 | }; |
7 | use hir::{HirDisplay, HasSource}; | ||
8 | 11 | ||
9 | use crate::{ | 12 | use crate::{ |
10 | db::RootDatabase, | 13 | db::RootDatabase, |
11 | RangeInfo, FilePosition, FileRange, | 14 | display::{ |
12 | display::{rust_code_markup, rust_code_markup_with_doc, ShortLabel, docs_from_symbol, description_from_symbol}, | 15 | description_from_symbol, docs_from_symbol, rust_code_markup, rust_code_markup_with_doc, |
13 | name_ref_kind::{NameRefKind::*, classify_name_ref}, | 16 | ShortLabel, |
17 | }, | ||
18 | name_ref_kind::{classify_name_ref, NameRefKind::*}, | ||
19 | FilePosition, FileRange, RangeInfo, | ||
14 | }; | 20 | }; |
15 | 21 | ||
16 | /// Contains the results when hovering over an item | 22 | /// Contains the results when hovering over an item |
@@ -256,8 +262,10 @@ pub(crate) fn type_of(db: &RootDatabase, frange: FileRange) -> Option<String> { | |||
256 | 262 | ||
257 | #[cfg(test)] | 263 | #[cfg(test)] |
258 | mod tests { | 264 | mod tests { |
265 | use crate::mock_analysis::{ | ||
266 | analysis_and_position, single_file_with_position, single_file_with_range, | ||
267 | }; | ||
259 | use ra_syntax::TextRange; | 268 | use ra_syntax::TextRange; |
260 | use crate::mock_analysis::{single_file_with_position, single_file_with_range, analysis_and_position}; | ||
261 | 269 | ||
262 | fn trim_markup(s: &str) -> &str { | 270 | fn trim_markup(s: &str) -> &str { |
263 | s.trim_start_matches("```rust\n").trim_end_matches("\n```") | 271 | s.trim_start_matches("```rust\n").trim_end_matches("\n```") |
diff --git a/crates/ra_ide_api/src/impls.rs b/crates/ra_ide_api/src/impls.rs index b80238d9e..f8a62bd71 100644 --- a/crates/ra_ide_api/src/impls.rs +++ b/crates/ra_ide_api/src/impls.rs | |||
@@ -1,11 +1,8 @@ | |||
1 | use ra_db::SourceDatabase; | ||
2 | use ra_syntax::{ | ||
3 | AstNode, ast, | ||
4 | algo::find_node_at_offset, | ||
5 | }; | ||
6 | use hir::{db::HirDatabase, source_binder}; | 1 | use hir::{db::HirDatabase, source_binder}; |
2 | use ra_db::SourceDatabase; | ||
3 | use ra_syntax::{algo::find_node_at_offset, ast, AstNode}; | ||
7 | 4 | ||
8 | use crate::{FilePosition, NavigationTarget, db::RootDatabase, RangeInfo}; | 5 | use crate::{db::RootDatabase, FilePosition, NavigationTarget, RangeInfo}; |
9 | 6 | ||
10 | pub(crate) fn goto_implementation( | 7 | pub(crate) fn goto_implementation( |
11 | db: &RootDatabase, | 8 | db: &RootDatabase, |
diff --git a/crates/ra_ide_api/src/join_lines.rs b/crates/ra_ide_api/src/join_lines.rs index 3978e9635..8ab485adb 100644 --- a/crates/ra_ide_api/src/join_lines.rs +++ b/crates/ra_ide_api/src/join_lines.rs | |||
@@ -1,14 +1,11 @@ | |||
1 | use itertools::Itertools; | 1 | use itertools::Itertools; |
2 | use ra_fmt::{compute_ws, extract_trivial_expression}; | ||
2 | use ra_syntax::{ | 3 | use ra_syntax::{ |
3 | T, | ||
4 | SourceFile, TextRange, TextUnit, SyntaxNode, SyntaxElement, SyntaxToken, | ||
5 | SyntaxKind::{self, WHITESPACE}, | ||
6 | algo::{find_covering_element, non_trivia_sibling}, | 4 | algo::{find_covering_element, non_trivia_sibling}, |
7 | ast::{self, AstNode, AstToken}, | 5 | ast::{self, AstNode, AstToken}, |
8 | Direction, | 6 | Direction, SourceFile, SyntaxElement, |
9 | }; | 7 | SyntaxKind::{self, WHITESPACE}, |
10 | use ra_fmt::{ | 8 | SyntaxNode, SyntaxToken, TextRange, TextUnit, T, |
11 | compute_ws, extract_trivial_expression | ||
12 | }; | 9 | }; |
13 | use ra_text_edit::{TextEdit, TextEditBuilder}; | 10 | use ra_text_edit::{TextEdit, TextEditBuilder}; |
14 | 11 | ||
diff --git a/crates/ra_ide_api/src/lib.rs b/crates/ra_ide_api/src/lib.rs index 817e65df0..95de9bcb8 100644 --- a/crates/ra_ide_api/src/lib.rs +++ b/crates/ra_ide_api/src/lib.rs | |||
@@ -46,33 +46,35 @@ mod test_utils; | |||
46 | 46 | ||
47 | use std::sync::Arc; | 47 | use std::sync::Arc; |
48 | 48 | ||
49 | use ra_syntax::{SourceFile, TreeArc, TextRange, TextUnit}; | ||
50 | use ra_text_edit::TextEdit; | ||
51 | use ra_db::{ | 49 | use ra_db::{ |
52 | SourceDatabase, CheckCanceled, | ||
53 | salsa::{self, ParallelDatabase}, | 50 | salsa::{self, ParallelDatabase}, |
51 | CheckCanceled, SourceDatabase, | ||
54 | }; | 52 | }; |
53 | use ra_syntax::{SourceFile, TextRange, TextUnit, TreeArc}; | ||
54 | use ra_text_edit::TextEdit; | ||
55 | use relative_path::RelativePathBuf; | 55 | use relative_path::RelativePathBuf; |
56 | 56 | ||
57 | use crate::{symbol_index::FileSymbol, db::LineIndexDatabase}; | 57 | use crate::{db::LineIndexDatabase, symbol_index::FileSymbol}; |
58 | 58 | ||
59 | pub use crate::{ | 59 | pub use crate::{ |
60 | assists::{Assist, AssistId}, | ||
60 | change::{AnalysisChange, LibraryData}, | 61 | change::{AnalysisChange, LibraryData}, |
61 | completion::{CompletionItem, CompletionItemKind, InsertTextFormat}, | 62 | completion::{CompletionItem, CompletionItemKind, InsertTextFormat}, |
62 | runnables::{Runnable, RunnableKind}, | 63 | diagnostics::Severity, |
63 | references::ReferenceSearchResult, | 64 | display::{file_structure, FunctionSignature, NavigationTarget, StructureNode}, |
64 | assists::{Assist, AssistId}, | ||
65 | hover::{HoverResult}, | ||
66 | line_index::{LineIndex, LineCol}, | ||
67 | line_index_utils::translate_offset_with_edit, | ||
68 | folding_ranges::{Fold, FoldKind}, | 65 | folding_ranges::{Fold, FoldKind}, |
66 | hover::HoverResult, | ||
67 | line_index::{LineCol, LineIndex}, | ||
68 | line_index_utils::translate_offset_with_edit, | ||
69 | references::ReferenceSearchResult, | ||
70 | runnables::{Runnable, RunnableKind}, | ||
69 | syntax_highlighting::HighlightedRange, | 71 | syntax_highlighting::HighlightedRange, |
70 | diagnostics::Severity, | ||
71 | display::{FunctionSignature, NavigationTarget, StructureNode, file_structure}, | ||
72 | }; | 72 | }; |
73 | 73 | ||
74 | pub use ra_db::{Canceled, CrateGraph, CrateId, FileId, FilePosition, FileRange, SourceRootId, Edition}; | ||
75 | pub use hir::Documentation; | 74 | pub use hir::Documentation; |
75 | pub use ra_db::{ | ||
76 | Canceled, CrateGraph, CrateId, Edition, FileId, FilePosition, FileRange, SourceRootId, | ||
77 | }; | ||
76 | 78 | ||
77 | pub type Cancelable<T> = Result<T, Canceled>; | 79 | pub type Cancelable<T> = Result<T, Canceled>; |
78 | 80 | ||
diff --git a/crates/ra_ide_api/src/line_index.rs b/crates/ra_ide_api/src/line_index.rs index a53cf9ee0..71de8a928 100644 --- a/crates/ra_ide_api/src/line_index.rs +++ b/crates/ra_ide_api/src/line_index.rs | |||
@@ -145,7 +145,7 @@ pub fn to_line_col(text: &str, offset: TextUnit) -> LineCol { | |||
145 | mod test_line_index { | 145 | mod test_line_index { |
146 | use super::*; | 146 | use super::*; |
147 | use proptest::{prelude::*, proptest}; | 147 | use proptest::{prelude::*, proptest}; |
148 | use ra_text_edit::test_utils::{arb_text, arb_offset}; | 148 | use ra_text_edit::test_utils::{arb_offset, arb_text}; |
149 | 149 | ||
150 | #[test] | 150 | #[test] |
151 | fn test_line_index() { | 151 | fn test_line_index() { |
diff --git a/crates/ra_ide_api/src/line_index_utils.rs b/crates/ra_ide_api/src/line_index_utils.rs index a03467011..f9073dca2 100644 --- a/crates/ra_ide_api/src/line_index_utils.rs +++ b/crates/ra_ide_api/src/line_index_utils.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | use crate::{line_index::Utf16Char, LineCol, LineIndex}; | ||
2 | use ra_syntax::{TextRange, TextUnit}; | ||
1 | use ra_text_edit::{AtomTextEdit, TextEdit}; | 3 | use ra_text_edit::{AtomTextEdit, TextEdit}; |
2 | use ra_syntax::{TextUnit, TextRange}; | ||
3 | use crate::{LineIndex, LineCol, line_index::Utf16Char}; | ||
4 | 4 | ||
5 | #[derive(Debug, Clone)] | 5 | #[derive(Debug, Clone)] |
6 | enum Step { | 6 | enum Step { |
@@ -292,8 +292,8 @@ pub fn translate_offset_with_edit( | |||
292 | #[cfg(test)] | 292 | #[cfg(test)] |
293 | mod test { | 293 | mod test { |
294 | use super::*; | 294 | use super::*; |
295 | use proptest::{prelude::*, proptest}; | ||
296 | use crate::line_index; | 295 | use crate::line_index; |
296 | use proptest::{prelude::*, proptest}; | ||
297 | use ra_text_edit::test_utils::{arb_offset, arb_text_with_edit}; | 297 | use ra_text_edit::test_utils::{arb_offset, arb_text_with_edit}; |
298 | use ra_text_edit::TextEdit; | 298 | use ra_text_edit::TextEdit; |
299 | 299 | ||
diff --git a/crates/ra_ide_api/src/matching_brace.rs b/crates/ra_ide_api/src/matching_brace.rs index 7f3e65b46..438b07896 100644 --- a/crates/ra_ide_api/src/matching_brace.rs +++ b/crates/ra_ide_api/src/matching_brace.rs | |||
@@ -1,10 +1,4 @@ | |||
1 | use ra_syntax::{ | 1 | use ra_syntax::{algo::find_token_at_offset, ast::AstNode, SourceFile, SyntaxKind, TextUnit, T}; |
2 | SourceFile, TextUnit, | ||
3 | algo::find_token_at_offset, | ||
4 | SyntaxKind::{self}, | ||
5 | ast::AstNode, | ||
6 | T | ||
7 | }; | ||
8 | 2 | ||
9 | pub fn matching_brace(file: &SourceFile, offset: TextUnit) -> Option<TextUnit> { | 3 | pub fn matching_brace(file: &SourceFile, offset: TextUnit) -> Option<TextUnit> { |
10 | const BRACES: &[SyntaxKind] = | 4 | const BRACES: &[SyntaxKind] = |
diff --git a/crates/ra_ide_api/src/mock_analysis.rs b/crates/ra_ide_api/src/mock_analysis.rs index cb12dd0b1..4dbbd489a 100644 --- a/crates/ra_ide_api/src/mock_analysis.rs +++ b/crates/ra_ide_api/src/mock_analysis.rs | |||
@@ -3,7 +3,10 @@ use std::sync::Arc; | |||
3 | use relative_path::RelativePathBuf; | 3 | use relative_path::RelativePathBuf; |
4 | use test_utils::{extract_offset, extract_range, parse_fixture, CURSOR_MARKER}; | 4 | use test_utils::{extract_offset, extract_range, parse_fixture, CURSOR_MARKER}; |
5 | 5 | ||
6 | use crate::{Analysis, AnalysisChange, AnalysisHost, CrateGraph, FileId, FilePosition, FileRange, SourceRootId, Edition::Edition2018}; | 6 | use crate::{ |
7 | Analysis, AnalysisChange, AnalysisHost, CrateGraph, Edition::Edition2018, FileId, FilePosition, | ||
8 | FileRange, SourceRootId, | ||
9 | }; | ||
7 | 10 | ||
8 | /// Mock analysis is used in test to bootstrap an AnalysisHost/Analysis | 11 | /// Mock analysis is used in test to bootstrap an AnalysisHost/Analysis |
9 | /// from a set of in-memory files. | 12 | /// from a set of in-memory files. |
diff --git a/crates/ra_ide_api/src/name_ref_kind.rs b/crates/ra_ide_api/src/name_ref_kind.rs index 000036db4..67381c9c8 100644 --- a/crates/ra_ide_api/src/name_ref_kind.rs +++ b/crates/ra_ide_api/src/name_ref_kind.rs | |||
@@ -1,5 +1,5 @@ | |||
1 | use ra_syntax::{AstNode, AstPtr, ast}; | ||
2 | use hir::Either; | 1 | use hir::Either; |
2 | use ra_syntax::{ast, AstNode, AstPtr}; | ||
3 | use test_utils::tested_by; | 3 | use test_utils::tested_by; |
4 | 4 | ||
5 | use crate::db::RootDatabase; | 5 | use crate::db::RootDatabase; |
diff --git a/crates/ra_ide_api/src/parent_module.rs b/crates/ra_ide_api/src/parent_module.rs index 27788c984..7d5f9ea2c 100644 --- a/crates/ra_ide_api/src/parent_module.rs +++ b/crates/ra_ide_api/src/parent_module.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | use ra_db::{FilePosition, FileId, CrateId}; | 1 | use ra_db::{CrateId, FileId, FilePosition}; |
2 | 2 | ||
3 | use crate::{NavigationTarget, db::RootDatabase}; | 3 | use crate::{db::RootDatabase, NavigationTarget}; |
4 | 4 | ||
5 | /// This returns `Vec` because a module may be included from several places. We | 5 | /// This returns `Vec` because a module may be included from several places. We |
6 | /// don't handle this case yet though, so the Vec has length at most one. | 6 | /// don't handle this case yet though, so the Vec has length at most one. |
@@ -29,10 +29,10 @@ pub(crate) fn crate_for(db: &RootDatabase, file_id: FileId) -> Vec<CrateId> { | |||
29 | #[cfg(test)] | 29 | #[cfg(test)] |
30 | mod tests { | 30 | mod tests { |
31 | use crate::{ | 31 | use crate::{ |
32 | AnalysisChange, CrateGraph, | ||
33 | mock_analysis::{analysis_and_position, MockAnalysis}, | 32 | mock_analysis::{analysis_and_position, MockAnalysis}, |
33 | AnalysisChange, CrateGraph, | ||
34 | Edition::Edition2018, | 34 | Edition::Edition2018, |
35 | }; | 35 | }; |
36 | 36 | ||
37 | #[test] | 37 | #[test] |
38 | fn test_resolve_parent_module() { | 38 | fn test_resolve_parent_module() { |
diff --git a/crates/ra_ide_api/src/references.rs b/crates/ra_ide_api/src/references.rs index 12cdc6a6d..766c0ad74 100644 --- a/crates/ra_ide_api/src/references.rs +++ b/crates/ra_ide_api/src/references.rs | |||
@@ -1,22 +1,11 @@ | |||
1 | use hir::{source_binder, Either, ModuleSource}; | ||
2 | use ra_db::SourceDatabase; | ||
3 | use ra_syntax::{algo::find_node_at_offset, ast, AstNode, SourceFile, SyntaxNode}; | ||
1 | use relative_path::{RelativePath, RelativePathBuf}; | 4 | use relative_path::{RelativePath, RelativePathBuf}; |
2 | use hir::{ModuleSource, source_binder, Either}; | ||
3 | use ra_db::{SourceDatabase}; | ||
4 | use ra_syntax::{ | ||
5 | AstNode, SyntaxNode, SourceFile, | ||
6 | ast, | ||
7 | algo::find_node_at_offset, | ||
8 | }; | ||
9 | 5 | ||
10 | use crate::{ | 6 | use crate::{ |
11 | db::RootDatabase, | 7 | db::RootDatabase, FileId, FilePosition, FileRange, FileSystemEdit, NavigationTarget, |
12 | FilePosition, | 8 | SourceChange, SourceFileEdit, TextRange, |
13 | FileRange, | ||
14 | FileId, | ||
15 | NavigationTarget, | ||
16 | FileSystemEdit, | ||
17 | SourceChange, | ||
18 | SourceFileEdit, | ||
19 | TextRange, | ||
20 | }; | 9 | }; |
21 | 10 | ||
22 | #[derive(Debug, Clone)] | 11 | #[derive(Debug, Clone)] |
@@ -210,13 +199,12 @@ fn rename_reference( | |||
210 | 199 | ||
211 | #[cfg(test)] | 200 | #[cfg(test)] |
212 | mod tests { | 201 | mod tests { |
202 | use crate::{ | ||
203 | mock_analysis::analysis_and_position, mock_analysis::single_file_with_position, FileId, | ||
204 | ReferenceSearchResult, | ||
205 | }; | ||
213 | use insta::assert_debug_snapshot_matches; | 206 | use insta::assert_debug_snapshot_matches; |
214 | use test_utils::assert_eq_text; | 207 | use test_utils::assert_eq_text; |
215 | use crate::{ | ||
216 | mock_analysis::single_file_with_position, | ||
217 | mock_analysis::analysis_and_position, | ||
218 | FileId, ReferenceSearchResult | ||
219 | }; | ||
220 | 208 | ||
221 | #[test] | 209 | #[test] |
222 | fn test_find_all_refs_for_local() { | 210 | fn test_find_all_refs_for_local() { |
diff --git a/crates/ra_ide_api/src/runnables.rs b/crates/ra_ide_api/src/runnables.rs index afe629d50..2d2d0b40e 100644 --- a/crates/ra_ide_api/src/runnables.rs +++ b/crates/ra_ide_api/src/runnables.rs | |||
@@ -1,9 +1,9 @@ | |||
1 | use itertools::Itertools; | 1 | use itertools::Itertools; |
2 | use ra_db::SourceDatabase; | ||
2 | use ra_syntax::{ | 3 | use ra_syntax::{ |
3 | TextRange, SyntaxNode, | 4 | ast::{self, AstNode, AttrsOwner, ModuleItemOwner, NameOwner}, |
4 | ast::{self, AstNode, NameOwner, ModuleItemOwner, AttrsOwner}, | 5 | SyntaxNode, TextRange, |
5 | }; | 6 | }; |
6 | use ra_db::SourceDatabase; | ||
7 | 7 | ||
8 | use crate::{db::RootDatabase, FileId}; | 8 | use crate::{db::RootDatabase, FileId}; |
9 | 9 | ||
diff --git a/crates/ra_ide_api/src/status.rs b/crates/ra_ide_api/src/status.rs index ce25f4a87..1bcba0b8b 100644 --- a/crates/ra_ide_api/src/status.rs +++ b/crates/ra_ide_api/src/status.rs | |||
@@ -1,20 +1,20 @@ | |||
1 | use std::{ | 1 | use std::{fmt, iter::FromIterator, sync::Arc}; |
2 | fmt, | ||
3 | iter::FromIterator, | ||
4 | sync::Arc, | ||
5 | }; | ||
6 | 2 | ||
7 | use ra_syntax::{TreeArc, SyntaxNode, Parse, AstNode}; | 3 | use hir::MacroFile; |
8 | use ra_db::{ | 4 | use ra_db::{ |
5 | salsa::{ | ||
6 | debug::{DebugQueryTable, TableEntry}, | ||
7 | Database, | ||
8 | }, | ||
9 | FileTextQuery, SourceRootId, | 9 | FileTextQuery, SourceRootId, |
10 | salsa::{Database, debug::{DebugQueryTable, TableEntry}}, | ||
11 | }; | 10 | }; |
12 | use ra_prof::{Bytes, memory_usage}; | 11 | use ra_prof::{memory_usage, Bytes}; |
13 | use hir::MacroFile; | 12 | use ra_syntax::{AstNode, Parse, SyntaxNode, TreeArc}; |
14 | 13 | ||
15 | use crate::{ | 14 | use crate::{ |
16 | FileId, db::RootDatabase, | 15 | db::RootDatabase, |
17 | symbol_index::{SymbolIndex, LibrarySymbolsQuery}, | 16 | symbol_index::{LibrarySymbolsQuery, SymbolIndex}, |
17 | FileId, | ||
18 | }; | 18 | }; |
19 | 19 | ||
20 | pub(crate) fn syntax_tree_stats(db: &RootDatabase) -> SyntaxTreeStats { | 20 | pub(crate) fn syntax_tree_stats(db: &RootDatabase) -> SyntaxTreeStats { |
diff --git a/crates/ra_ide_api/src/symbol_index.rs b/crates/ra_ide_api/src/symbol_index.rs index a6cd7bf61..2ca0a25d4 100644 --- a/crates/ra_ide_api/src/symbol_index.rs +++ b/crates/ra_ide_api/src/symbol_index.rs | |||
@@ -20,31 +20,27 @@ | |||
20 | //! file in the current workspace, and run a query against the union of all | 20 | //! file in the current workspace, and run a query against the union of all |
21 | //! those FSTs. | 21 | //! those FSTs. |
22 | use std::{ | 22 | use std::{ |
23 | fmt, | ||
23 | hash::{Hash, Hasher}, | 24 | hash::{Hash, Hasher}, |
24 | sync::Arc, | ||
25 | mem, | 25 | mem, |
26 | fmt, | 26 | sync::Arc, |
27 | }; | 27 | }; |
28 | 28 | ||
29 | use fst::{self, Streamer}; | 29 | use fst::{self, Streamer}; |
30 | use ra_syntax::{ | ||
31 | SyntaxNode, SyntaxNodePtr, SourceFile, SmolStr, TreeArc, AstNode, | ||
32 | algo::{visit::{visitor, Visitor}}, | ||
33 | SyntaxKind::{self, *}, | ||
34 | ast::{self, NameOwner}, | ||
35 | WalkEvent, | ||
36 | TextRange, | ||
37 | }; | ||
38 | use ra_db::{ | 30 | use ra_db::{ |
39 | SourceRootId, SourceDatabase, | ||
40 | salsa::{self, ParallelDatabase}, | 31 | salsa::{self, ParallelDatabase}, |
32 | SourceDatabase, SourceRootId, | ||
33 | }; | ||
34 | use ra_syntax::{ | ||
35 | algo::visit::{visitor, Visitor}, | ||
36 | ast::{self, NameOwner}, | ||
37 | AstNode, SmolStr, SourceFile, | ||
38 | SyntaxKind::{self, *}, | ||
39 | SyntaxNode, SyntaxNodePtr, TextRange, TreeArc, WalkEvent, | ||
41 | }; | 40 | }; |
42 | use rayon::prelude::*; | 41 | use rayon::prelude::*; |
43 | 42 | ||
44 | use crate::{ | 43 | use crate::{db::RootDatabase, FileId, Query}; |
45 | FileId, Query, | ||
46 | db::RootDatabase, | ||
47 | }; | ||
48 | 44 | ||
49 | #[salsa::query_group(SymbolsDatabaseStorage)] | 45 | #[salsa::query_group(SymbolsDatabaseStorage)] |
50 | pub(crate) trait SymbolsDatabase: hir::db::HirDatabase { | 46 | pub(crate) trait SymbolsDatabase: hir::db::HirDatabase { |
@@ -305,15 +301,11 @@ fn to_file_symbol(node: &SyntaxNode, file_id: FileId) -> Option<FileSymbol> { | |||
305 | 301 | ||
306 | #[cfg(test)] | 302 | #[cfg(test)] |
307 | mod tests { | 303 | mod tests { |
304 | use crate::{display::NavigationTarget, mock_analysis::single_file, Query}; | ||
308 | use ra_syntax::{ | 305 | use ra_syntax::{ |
309 | SmolStr, | 306 | SmolStr, |
310 | SyntaxKind::{FN_DEF, STRUCT_DEF} | 307 | SyntaxKind::{FN_DEF, STRUCT_DEF}, |
311 | }; | 308 | }; |
312 | use crate::{ | ||
313 | display::NavigationTarget, | ||
314 | mock_analysis::single_file, | ||
315 | Query, | ||
316 | }; | ||
317 | 309 | ||
318 | #[test] | 310 | #[test] |
319 | fn test_world_symbols_with_no_container() { | 311 | fn test_world_symbols_with_no_container() { |
diff --git a/crates/ra_ide_api/src/syntax_highlighting.rs b/crates/ra_ide_api/src/syntax_highlighting.rs index 3a04a51cd..7c4285b02 100644 --- a/crates/ra_ide_api/src/syntax_highlighting.rs +++ b/crates/ra_ide_api/src/syntax_highlighting.rs | |||
@@ -1,12 +1,12 @@ | |||
1 | use rustc_hash::{FxHashSet, FxHashMap}; | 1 | use rustc_hash::{FxHashMap, FxHashSet}; |
2 | 2 | ||
3 | use ra_syntax::{ | ||
4 | ast, AstNode, TextRange, Direction, SmolStr, SyntaxKind, SyntaxKind::*, SyntaxElement, T, | ||
5 | }; | ||
6 | use ra_db::SourceDatabase; | 3 | use ra_db::SourceDatabase; |
7 | use ra_prof::profile; | 4 | use ra_prof::profile; |
5 | use ra_syntax::{ | ||
6 | ast, AstNode, Direction, SmolStr, SyntaxElement, SyntaxKind, SyntaxKind::*, TextRange, T, | ||
7 | }; | ||
8 | 8 | ||
9 | use crate::{FileId, db::RootDatabase}; | 9 | use crate::{db::RootDatabase, FileId}; |
10 | 10 | ||
11 | #[derive(Debug)] | 11 | #[derive(Debug)] |
12 | pub struct HighlightedRange { | 12 | pub struct HighlightedRange { |
@@ -64,7 +64,7 @@ pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRa | |||
64 | if let Some(name_ref) = node.as_node().and_then(ast::NameRef::cast) { | 64 | if let Some(name_ref) = node.as_node().and_then(ast::NameRef::cast) { |
65 | // FIXME: revisit this after #1340 | 65 | // FIXME: revisit this after #1340 |
66 | use crate::name_ref_kind::{classify_name_ref, NameRefKind::*}; | 66 | use crate::name_ref_kind::{classify_name_ref, NameRefKind::*}; |
67 | use hir::{ModuleDef, ImplItem}; | 67 | use hir::{ImplItem, ModuleDef}; |
68 | 68 | ||
69 | // FIXME: try to reuse the SourceAnalyzers | 69 | // FIXME: try to reuse the SourceAnalyzers |
70 | let analyzer = hir::SourceAnalyzer::new(db, file_id, name_ref.syntax(), None); | 70 | let analyzer = hir::SourceAnalyzer::new(db, file_id, name_ref.syntax(), None); |
@@ -264,8 +264,8 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padding: 0.4e | |||
264 | 264 | ||
265 | #[cfg(test)] | 265 | #[cfg(test)] |
266 | mod tests { | 266 | mod tests { |
267 | use test_utils::{project_dir, read_text, assert_eq_text}; | ||
268 | use crate::mock_analysis::single_file; | 267 | use crate::mock_analysis::single_file; |
268 | use test_utils::{assert_eq_text, project_dir, read_text}; | ||
269 | 269 | ||
270 | #[test] | 270 | #[test] |
271 | fn test_highlighting() { | 271 | fn test_highlighting() { |
diff --git a/crates/ra_ide_api/src/syntax_tree.rs b/crates/ra_ide_api/src/syntax_tree.rs index 7165fa97a..8bdd08d58 100644 --- a/crates/ra_ide_api/src/syntax_tree.rs +++ b/crates/ra_ide_api/src/syntax_tree.rs | |||
@@ -1,9 +1,9 @@ | |||
1 | use ra_db::SourceDatabase; | ||
2 | use crate::db::RootDatabase; | 1 | use crate::db::RootDatabase; |
2 | use ra_db::SourceDatabase; | ||
3 | use ra_syntax::{ | 3 | use ra_syntax::{ |
4 | SourceFile, TextRange, AstNode, SyntaxToken, SyntaxElement, | 4 | algo, AstNode, SourceFile, SyntaxElement, |
5 | algo, | 5 | SyntaxKind::{RAW_STRING, STRING}, |
6 | SyntaxKind::{STRING, RAW_STRING}, | 6 | SyntaxToken, TextRange, |
7 | }; | 7 | }; |
8 | 8 | ||
9 | pub use ra_db::FileId; | 9 | pub use ra_db::FileId; |
diff --git a/crates/ra_ide_api/src/typing.rs b/crates/ra_ide_api/src/typing.rs index 3e35d8352..d3cb71ddb 100644 --- a/crates/ra_ide_api/src/typing.rs +++ b/crates/ra_ide_api/src/typing.rs | |||
@@ -1,13 +1,14 @@ | |||
1 | use crate::{db::RootDatabase, SourceChange, SourceFileEdit}; | ||
2 | use ra_db::{FilePosition, SourceDatabase}; | ||
3 | use ra_fmt::leading_indent; | ||
1 | use ra_syntax::{ | 4 | use ra_syntax::{ |
2 | AstNode, SourceFile, SyntaxKind::*, | ||
3 | TextUnit, TextRange, SyntaxToken, | ||
4 | algo::{find_node_at_offset, find_token_at_offset, TokenAtOffset}, | 5 | algo::{find_node_at_offset, find_token_at_offset, TokenAtOffset}, |
5 | ast::{self, AstToken}, | 6 | ast::{self, AstToken}, |
7 | AstNode, SourceFile, | ||
8 | SyntaxKind::*, | ||
9 | SyntaxToken, TextRange, TextUnit, | ||
6 | }; | 10 | }; |
7 | use ra_fmt::leading_indent; | ||
8 | use ra_text_edit::{TextEdit, TextEditBuilder}; | 11 | use ra_text_edit::{TextEdit, TextEditBuilder}; |
9 | use ra_db::{FilePosition, SourceDatabase}; | ||
10 | use crate::{db::RootDatabase, SourceChange, SourceFileEdit}; | ||
11 | 12 | ||
12 | pub(crate) fn on_enter(db: &RootDatabase, position: FilePosition) -> Option<SourceChange> { | 13 | pub(crate) fn on_enter(db: &RootDatabase, position: FilePosition) -> Option<SourceChange> { |
13 | let file = db.parse(position.file_id).tree; | 14 | let file = db.parse(position.file_id).tree; |