From 1834bae5b86c54ed9dece26e82436919d59e6cb7 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 4 Jul 2019 23:05:17 +0300 Subject: 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 --- crates/ra_ide_api/src/assists.rs | 4 +-- crates/ra_ide_api/src/call_info.rs | 8 ++--- crates/ra_ide_api/src/change.rs | 15 ++++----- crates/ra_ide_api/src/completion.rs | 14 ++++----- crates/ra_ide_api/src/completion/complete_dot.rs | 4 +-- .../ra_ide_api/src/completion/complete_fn_param.rs | 5 ++- .../ra_ide_api/src/completion/complete_keyword.rs | 9 ++++-- crates/ra_ide_api/src/completion/complete_path.rs | 6 ++-- .../ra_ide_api/src/completion/complete_pattern.rs | 2 +- .../ra_ide_api/src/completion/complete_postfix.rs | 15 +++------ crates/ra_ide_api/src/completion/complete_scope.rs | 10 +++--- .../ra_ide_api/src/completion/complete_snippet.rs | 7 +++-- .../src/completion/complete_struct_literal.rs | 2 +- .../src/completion/completion_context.rs | 10 +++--- .../ra_ide_api/src/completion/completion_item.rs | 4 +-- crates/ra_ide_api/src/completion/presentation.rs | 12 +++----- crates/ra_ide_api/src/db.rs | 12 ++++---- crates/ra_ide_api/src/diagnostics.rs | 17 +++++----- crates/ra_ide_api/src/display.rs | 11 ++++--- .../ra_ide_api/src/display/function_signature.rs | 7 +++-- crates/ra_ide_api/src/display/navigation_target.rs | 11 ++++--- crates/ra_ide_api/src/display/short_label.rs | 4 +-- crates/ra_ide_api/src/display/structure.rs | 2 +- crates/ra_ide_api/src/extend_selection.rs | 10 +++--- crates/ra_ide_api/src/folding_ranges.rs | 5 +-- crates/ra_ide_api/src/goto_definition.rs | 9 +++--- crates/ra_ide_api/src/goto_type_definition.rs | 7 ++--- crates/ra_ide_api/src/hover.rs | 22 ++++++++----- crates/ra_ide_api/src/impls.rs | 9 ++---- crates/ra_ide_api/src/join_lines.rs | 11 +++---- crates/ra_ide_api/src/lib.rs | 28 +++++++++-------- crates/ra_ide_api/src/line_index.rs | 2 +- crates/ra_ide_api/src/line_index_utils.rs | 6 ++-- crates/ra_ide_api/src/matching_brace.rs | 8 +---- crates/ra_ide_api/src/mock_analysis.rs | 5 ++- crates/ra_ide_api/src/name_ref_kind.rs | 2 +- crates/ra_ide_api/src/parent_module.rs | 8 ++--- crates/ra_ide_api/src/references.rs | 30 ++++++------------ crates/ra_ide_api/src/runnables.rs | 6 ++-- crates/ra_ide_api/src/status.rs | 22 ++++++------- crates/ra_ide_api/src/symbol_index.rs | 36 +++++++++------------- crates/ra_ide_api/src/syntax_highlighting.rs | 14 ++++----- crates/ra_ide_api/src/syntax_tree.rs | 8 ++--- crates/ra_ide_api/src/typing.rs | 11 ++++--- 44 files changed, 215 insertions(+), 235 deletions(-) (limited to 'crates/ra_ide_api/src') 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 @@ -use ra_db::{FileRange, FilePosition}; +use ra_db::{FilePosition, FileRange}; -use crate::{SourceFileEdit, SourceChange, db::RootDatabase}; +use crate::{db::RootDatabase, SourceChange, SourceFileEdit}; pub use ra_assists::AssistId; 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 @@ -use test_utils::tested_by; use ra_db::SourceDatabase; use ra_syntax::{ - AstNode, SyntaxNode, TextUnit, - ast::{self, ArgListOwner}, algo::find_node_at_offset, + ast::{self, ArgListOwner}, + AstNode, SyntaxNode, TextUnit, }; +use test_utils::tested_by; -use crate::{FilePosition, CallInfo, FunctionSignature, db::RootDatabase}; +use crate::{db::RootDatabase, CallInfo, FilePosition, FunctionSignature}; /// Computes parameter information for the given call expression. pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Option { 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 @@ -use std::{ - fmt, time, - sync::Arc, -}; +use std::{fmt, sync::Arc, time}; -use rustc_hash::FxHashMap; use ra_db::{ - SourceRootId, FileId, CrateGraph, SourceDatabase, SourceRoot, salsa::{Database, SweepStrategy}, + CrateGraph, FileId, SourceDatabase, SourceRoot, SourceRootId, }; +use ra_prof::{memory_usage, profile, Bytes}; use ra_syntax::SourceFile; -use ra_prof::{profile, Bytes, memory_usage}; -use relative_path::RelativePathBuf; use rayon::prelude::*; +use relative_path::RelativePathBuf; +use rustc_hash::FxHashMap; use crate::{ db::RootDatabase, - symbol_index::{SymbolIndex, SymbolsDatabase}, status::syntax_tree_stats, + symbol_index::{SymbolIndex, SymbolsDatabase}, }; #[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; use ra_db::SourceDatabase; +#[cfg(test)] +use crate::completion::completion_item::{check_completion, do_completion}; use crate::{ - db, - FilePosition, completion::{ - completion_item::{Completions, CompletionKind}, completion_context::CompletionContext, + completion_item::{CompletionKind, Completions}, }, - + db, FilePosition, }; -#[cfg(test)] -use crate::completion::completion_item::{do_completion, check_completion}; -pub use crate::completion::completion_item::{CompletionItem, CompletionItemKind, InsertTextFormat}; +pub use crate::completion::completion_item::{ + CompletionItem, CompletionItemKind, InsertTextFormat, +}; /// Main entry point for completion. We run completion as a two-phase process. /// 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 @@ -use hir::{Ty, AdtDef, TypeCtor}; +use hir::{AdtDef, Ty, TypeCtor}; use crate::completion::{CompletionContext, Completions}; use rustc_hash::FxHashSet; @@ -49,7 +49,7 @@ fn complete_methods(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty #[cfg(test)] mod tests { - use crate::completion::{do_completion, CompletionKind, CompletionItem}; + use crate::completion::{do_completion, CompletionItem, CompletionKind}; use insta::assert_debug_snapshot_matches; fn do_ref_completion(code: &str) -> Vec { 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 @@ use ra_syntax::{ algo::visit::{visitor_ctx, VisitorCtx}, - ast, - AstNode, + ast, AstNode, }; use rustc_hash::FxHashMap; -use crate::completion::{CompletionContext, Completions, CompletionKind, CompletionItem}; +use crate::completion::{CompletionContext, CompletionItem, CompletionKind, Completions}; /// Complete repeated parameters, both name and type. For example, if all /// 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 @@ use ra_syntax::{ algo::visit::{visitor, Visitor}, - AstNode, ast::{self, LoopBodyOwner}, - SyntaxKind::*, SyntaxToken, + AstNode, + SyntaxKind::*, + SyntaxToken, }; -use crate::completion::{CompletionContext, CompletionItem, Completions, CompletionKind, CompletionItemKind}; +use crate::completion::{ + CompletionContext, CompletionItem, CompletionItemKind, CompletionKind, Completions, +}; pub(super) fn complete_use_tree_keyword(acc: &mut Completions, ctx: &CompletionContext) { // 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 @@ -use hir::{Resolution, Either}; +use hir::{Either, Resolution}; use ra_syntax::AstNode; use test_utils::tested_by; -use crate::completion::{Completions, CompletionContext}; +use crate::completion::{CompletionContext, Completions}; pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) { let path = match &ctx.path_prefix { @@ -78,7 +78,7 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) { mod tests { use test_utils::covers; - use crate::completion::{CompletionKind, do_completion, CompletionItem}; + use crate::completion::{do_completion, CompletionItem, CompletionKind}; use insta::assert_debug_snapshot_matches; fn do_reference_completion(code: &str) -> Vec { 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) { #[cfg(test)] mod tests { + use crate::completion::{do_completion, CompletionItem, CompletionKind}; use insta::assert_debug_snapshot_matches; - use crate::completion::{CompletionItem, CompletionKind, do_completion}; fn complete(code: &str) -> Vec { 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 @@ use crate::{ completion::{ - completion_item::{ - Completions, - Builder, - CompletionKind, - }, completion_context::CompletionContext, + completion_item::{Builder, CompletionKind, Completions}, }, - CompletionItem -}; -use ra_syntax::{ - ast::AstNode, - TextRange + CompletionItem, }; +use ra_syntax::{ast::AstNode, TextRange}; use ra_text_edit::TextEditBuilder; 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) { #[cfg(test)] mod tests { - use crate::completion::{CompletionKind, check_completion}; + use crate::completion::{check_completion, CompletionKind}; fn check_snippet_completion(test_name: &str, code: &str) { 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 @@ -use rustc_hash::FxHashMap; -use ra_text_edit::TextEditBuilder; -use ra_syntax::{SmolStr, ast, AstNode}; use ra_assists::auto_import; +use ra_syntax::{ast, AstNode, SmolStr}; +use ra_text_edit::TextEditBuilder; +use rustc_hash::FxHashMap; -use crate::completion::{CompletionItem, Completions, CompletionKind, CompletionContext}; +use crate::completion::{CompletionContext, CompletionItem, CompletionKind, Completions}; pub(super) fn complete_scope(acc: &mut Completions, ctx: &CompletionContext) { if ctx.is_trivial_path { @@ -121,7 +121,7 @@ impl ImportResolver { #[cfg(test)] mod tests { - use crate::completion::{CompletionKind, check_completion}; + use crate::completion::{check_completion, CompletionKind}; fn check_reference_completion(name: &str, code: &str) { 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 @@ -use crate::completion::{CompletionItem, Completions, CompletionKind, CompletionItemKind, CompletionContext, completion_item::Builder}; +use crate::completion::{ + completion_item::Builder, CompletionContext, CompletionItem, CompletionItemKind, + CompletionKind, Completions, +}; fn snippet(ctx: &CompletionContext, label: &str, snippet: &str) -> Builder { CompletionItem::new(CompletionKind::Snippet, ctx.source_range(), label) @@ -36,7 +39,7 @@ fn ${1:feature}() { #[cfg(test)] mod tests { - use crate::completion::{CompletionKind, check_completion}; + use crate::completion::{check_completion, CompletionKind}; fn check_snippet_completion(name: &str, code: &str) { 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 #[cfg(test)] mod tests { + use crate::completion::{do_completion, CompletionItem, CompletionKind}; use insta::assert_debug_snapshot_matches; - use crate::completion::{CompletionItem, CompletionKind, do_completion}; fn complete(code: &str) -> Vec { 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 @@ -use ra_text_edit::AtomTextEdit; +use hir::source_binder; use ra_syntax::{ - AstNode, SyntaxNode, SourceFile, TextUnit, TextRange, SyntaxToken, Parse, - ast, - algo::{find_token_at_offset, find_covering_element, find_node_at_offset}, + algo::{find_covering_element, find_node_at_offset, find_token_at_offset}, + ast, AstNode, Parse, SourceFile, SyntaxKind::*, + SyntaxNode, SyntaxToken, TextRange, TextUnit, }; -use hir::source_binder; +use ra_text_edit::AtomTextEdit; use crate::{db, FilePosition}; 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; use hir::Documentation; use ra_syntax::TextRange; -use ra_text_edit::{TextEditBuilder, TextEdit}; +use ra_text_edit::{TextEdit, TextEditBuilder}; /// `CompletionItem` describes a single completion variant in the editor pop-up. /// It is basically a POD with various properties. To construct a @@ -285,8 +285,8 @@ impl Into> for Completions { #[cfg(test)] pub(crate) fn do_completion(code: &str, kind: CompletionKind) -> Vec { - use crate::mock_analysis::{single_file_with_position, analysis_and_position}; use crate::completion::completions; + use crate::mock_analysis::{analysis_and_position, single_file_with_position}; let (analysis, position) = if code.contains("//-") { analysis_and_position(code) } 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 @@ //! This modules takes care of rendering various defenitions as completion items. +use hir::{Docs, HasSource, HirDisplay, PerNs, Resolution}; use join_to_string::join; -use test_utils::tested_by; -use hir::{Docs, PerNs, Resolution, HirDisplay, HasSource}; use ra_syntax::ast::NameOwner; +use test_utils::tested_by; use crate::completion::{ - Completions, CompletionKind, CompletionItemKind, CompletionContext, CompletionItem, + CompletionContext, CompletionItem, CompletionItemKind, CompletionKind, Completions, }; -use crate::display::{ - function_label, const_label, type_label, -}; +use crate::display::{const_label, function_label, type_label}; impl Completions { pub(crate) fn add_field( @@ -178,7 +176,7 @@ impl Completions { mod tests { use test_utils::covers; - use crate::completion::{CompletionKind, check_completion}; + use crate::completion::{check_completion, CompletionKind}; fn check_reference_completion(code: &str, expected_completions: &str) { 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 @@ -use std::{ - sync::Arc, - time, -}; +use std::{sync::Arc, time}; use ra_db::{ - CheckCanceled, FileId, Canceled, SourceDatabase, salsa::{self, Database}, + Canceled, CheckCanceled, FileId, SourceDatabase, }; -use crate::{LineIndex, symbol_index::{self, SymbolsDatabase}}; +use crate::{ + symbol_index::{self, SymbolsDatabase}, + LineIndex, +}; #[salsa::database( 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 @@ use std::cell::RefCell; +use hir::{ + diagnostics::{Diagnostic as _, DiagnosticSink}, + source_binder, +}; use itertools::Itertools; -use hir::{source_binder, diagnostics::{Diagnostic as _, DiagnosticSink}}; +use ra_assists::ast_editor::{AstBuilder, AstEditor}; use ra_db::SourceDatabase; +use ra_prof::profile; use ra_syntax::{ - T, Location, TextRange, SyntaxNode, - ast::{self, AstNode, NamedFieldList, NamedField}, + ast::{self, AstNode, NamedField, NamedFieldList}, + Location, SyntaxNode, TextRange, T, }; -use ra_assists::ast_editor::{AstEditor, AstBuilder}; use ra_text_edit::{TextEdit, TextEditBuilder}; -use ra_prof::profile; -use crate::{Diagnostic, FileId, FileSystemEdit, SourceChange, SourceFileEdit, db::RootDatabase}; +use crate::{db::RootDatabase, Diagnostic, FileId, FileSystemEdit, SourceChange, SourceFileEdit}; #[derive(Debug, Copy, Clone)] pub enum Severity { @@ -170,9 +173,9 @@ fn check_struct_shorthand_initialization( #[cfg(test)] mod tests { - use test_utils::assert_eq_text; use insta::assert_debug_snapshot_matches; use ra_syntax::SourceFile; + use test_utils::assert_eq_text; use crate::mock_analysis::single_file; 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; mod structure; mod short_label; -use ra_syntax::{ast::{self, AstNode, TypeParamsOwner}, SyntaxKind::{ATTR, COMMENT}}; +use ra_syntax::{ + ast::{self, AstNode, TypeParamsOwner}, + SyntaxKind::{ATTR, COMMENT}, +}; -pub use navigation_target::NavigationTarget; -pub use structure::{StructureNode, file_structure}; pub use function_signature::FunctionSignature; +pub use navigation_target::NavigationTarget; +pub use structure::{file_structure, StructureNode}; +pub(crate) use navigation_target::{description_from_symbol, docs_from_symbol}; pub(crate) use short_label::ShortLabel; -pub(crate) use navigation_target::{docs_from_symbol, description_from_symbol}; pub(crate) fn function_label(node: &ast::FnDef) -> String { 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 @@ use std::fmt::{self, Display}; +use hir::{Docs, Documentation, HasSource}; use join_to_string::join; use ra_syntax::ast::{self, AstNode, NameOwner, VisibilityOwner}; use std::convert::From; -use hir::{Docs, Documentation, HasSource}; -use crate::{db, display::{where_predicates, generic_parameters}}; +use crate::{ + db, + display::{generic_parameters, where_predicates}, +}; /// Contains information about a function signature #[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 @@ +use hir::{FieldSource, HasSource, ImplItem, ModuleSource}; use ra_db::{FileId, SourceDatabase}; use ra_syntax::{ - SyntaxNode, AstNode, SmolStr, TextRange, AstPtr, TreeArc, - SyntaxKind::{self, NAME}, - ast::{self, DocCommentsOwner}, algo::visit::{visitor, Visitor}, + ast::{self, DocCommentsOwner}, + AstNode, AstPtr, SmolStr, + SyntaxKind::{self, NAME}, + SyntaxNode, TextRange, TreeArc, }; -use hir::{ModuleSource, FieldSource, ImplItem, HasSource}; -use crate::{FileSymbol, db::RootDatabase}; use super::short_label::ShortLabel; +use crate::{db::RootDatabase, FileSymbol}; /// `NavigationTarget` represents and element in the editor's UI which you can /// 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 @@ -use ra_syntax::{ - ast::{self, NameOwner, VisibilityOwner, TypeAscriptionOwner, AstNode}, -}; +use ra_syntax::ast::{self, AstNode, NameOwner, TypeAscriptionOwner, VisibilityOwner}; pub(crate) trait ShortLabel { fn short_label(&self) -> Option; 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; use ra_syntax::{ algo::visit::{visitor, Visitor}, - ast::{self, AttrsOwner, NameOwner, TypeParamsOwner, TypeAscriptionOwner}, + ast::{self, AttrsOwner, NameOwner, TypeAscriptionOwner, TypeParamsOwner}, AstNode, SourceFile, SyntaxKind, SyntaxNode, WalkEvent, }; 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 @@ use ra_db::SourceDatabase; use ra_syntax::{ - Direction, SyntaxNode, TextRange, TextUnit, SyntaxElement, algo::{find_covering_element, find_token_at_offset, TokenAtOffset}, - SyntaxKind::*, SyntaxToken, ast::{self, AstNode, AstToken}, - T + Direction, SyntaxElement, + SyntaxKind::*, + SyntaxNode, SyntaxToken, TextRange, TextUnit, T, }; -use crate::{FileRange, db::RootDatabase}; +use crate::{db::RootDatabase, FileRange}; // FIXME: restore macro support pub(crate) fn extend_selection(db: &RootDatabase, frange: FileRange) -> TextRange { @@ -205,7 +205,7 @@ fn adj_comments(comment: ast::Comment, dir: Direction) -> ast::Comment { #[cfg(test)] mod tests { - use ra_syntax::{SourceFile, AstNode}; + use ra_syntax::{AstNode, SourceFile}; use test_utils::extract_offset; 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 @@ use rustc_hash::FxHashSet; use ra_syntax::{ - SourceFile, SyntaxNode, TextRange, Direction, SyntaxElement, - SyntaxKind::{self, *}, ast::{self, AstNode, AstToken, VisibilityOwner}, + Direction, SourceFile, SyntaxElement, + SyntaxKind::{self, *}, + SyntaxNode, TextRange, }; #[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 @@ use ra_db::{FileId, SourceDatabase}; use ra_syntax::{ - AstNode, ast::{self, DocCommentsOwner}, algo::{ find_node_at_offset, visit::{visitor, Visitor}, }, - SyntaxNode, + ast::{self, DocCommentsOwner}, + AstNode, SyntaxNode, }; use crate::{ - FilePosition, NavigationTarget, db::RootDatabase, - RangeInfo, - name_ref_kind::{NameRefKind::*, classify_name_ref}, display::ShortLabel, + name_ref_kind::{classify_name_ref, NameRefKind::*}, + FilePosition, NavigationTarget, RangeInfo, }; 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 @@ use ra_db::SourceDatabase; -use ra_syntax::{ - AstNode, ast, - algo::find_token_at_offset -}; +use ra_syntax::{algo::find_token_at_offset, ast, AstNode}; -use crate::{FilePosition, NavigationTarget, db::RootDatabase, RangeInfo}; +use crate::{db::RootDatabase, FilePosition, NavigationTarget, RangeInfo}; pub(crate) fn goto_type_definition( 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 @@ +use hir::{HasSource, HirDisplay}; use ra_db::SourceDatabase; use ra_syntax::{ - AstNode, TreeArc, + algo::{ + ancestors_at_offset, find_covering_element, find_node_at_offset, + visit::{visitor, Visitor}, + }, ast::{self, DocCommentsOwner}, - algo::{find_covering_element, find_node_at_offset, ancestors_at_offset, visit::{visitor, Visitor}}, + AstNode, TreeArc, }; -use hir::{HirDisplay, HasSource}; use crate::{ db::RootDatabase, - RangeInfo, FilePosition, FileRange, - display::{rust_code_markup, rust_code_markup_with_doc, ShortLabel, docs_from_symbol, description_from_symbol}, - name_ref_kind::{NameRefKind::*, classify_name_ref}, + display::{ + description_from_symbol, docs_from_symbol, rust_code_markup, rust_code_markup_with_doc, + ShortLabel, + }, + name_ref_kind::{classify_name_ref, NameRefKind::*}, + FilePosition, FileRange, RangeInfo, }; /// Contains the results when hovering over an item @@ -256,8 +262,10 @@ pub(crate) fn type_of(db: &RootDatabase, frange: FileRange) -> Option { #[cfg(test)] mod tests { + use crate::mock_analysis::{ + analysis_and_position, single_file_with_position, single_file_with_range, + }; use ra_syntax::TextRange; - use crate::mock_analysis::{single_file_with_position, single_file_with_range, analysis_and_position}; fn trim_markup(s: &str) -> &str { 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 @@ -use ra_db::SourceDatabase; -use ra_syntax::{ - AstNode, ast, - algo::find_node_at_offset, -}; use hir::{db::HirDatabase, source_binder}; +use ra_db::SourceDatabase; +use ra_syntax::{algo::find_node_at_offset, ast, AstNode}; -use crate::{FilePosition, NavigationTarget, db::RootDatabase, RangeInfo}; +use crate::{db::RootDatabase, FilePosition, NavigationTarget, RangeInfo}; pub(crate) fn goto_implementation( 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 @@ use itertools::Itertools; +use ra_fmt::{compute_ws, extract_trivial_expression}; use ra_syntax::{ - T, - SourceFile, TextRange, TextUnit, SyntaxNode, SyntaxElement, SyntaxToken, - SyntaxKind::{self, WHITESPACE}, algo::{find_covering_element, non_trivia_sibling}, ast::{self, AstNode, AstToken}, - Direction, -}; -use ra_fmt::{ - compute_ws, extract_trivial_expression + Direction, SourceFile, SyntaxElement, + SyntaxKind::{self, WHITESPACE}, + SyntaxNode, SyntaxToken, TextRange, TextUnit, T, }; use ra_text_edit::{TextEdit, TextEditBuilder}; 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; use std::sync::Arc; -use ra_syntax::{SourceFile, TreeArc, TextRange, TextUnit}; -use ra_text_edit::TextEdit; use ra_db::{ - SourceDatabase, CheckCanceled, salsa::{self, ParallelDatabase}, + CheckCanceled, SourceDatabase, }; +use ra_syntax::{SourceFile, TextRange, TextUnit, TreeArc}; +use ra_text_edit::TextEdit; use relative_path::RelativePathBuf; -use crate::{symbol_index::FileSymbol, db::LineIndexDatabase}; +use crate::{db::LineIndexDatabase, symbol_index::FileSymbol}; pub use crate::{ + assists::{Assist, AssistId}, change::{AnalysisChange, LibraryData}, completion::{CompletionItem, CompletionItemKind, InsertTextFormat}, - runnables::{Runnable, RunnableKind}, - references::ReferenceSearchResult, - assists::{Assist, AssistId}, - hover::{HoverResult}, - line_index::{LineIndex, LineCol}, - line_index_utils::translate_offset_with_edit, + diagnostics::Severity, + display::{file_structure, FunctionSignature, NavigationTarget, StructureNode}, folding_ranges::{Fold, FoldKind}, + hover::HoverResult, + line_index::{LineCol, LineIndex}, + line_index_utils::translate_offset_with_edit, + references::ReferenceSearchResult, + runnables::{Runnable, RunnableKind}, syntax_highlighting::HighlightedRange, - diagnostics::Severity, - display::{FunctionSignature, NavigationTarget, StructureNode, file_structure}, }; -pub use ra_db::{Canceled, CrateGraph, CrateId, FileId, FilePosition, FileRange, SourceRootId, Edition}; pub use hir::Documentation; +pub use ra_db::{ + Canceled, CrateGraph, CrateId, Edition, FileId, FilePosition, FileRange, SourceRootId, +}; pub type Cancelable = Result; 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 { mod test_line_index { use super::*; use proptest::{prelude::*, proptest}; - use ra_text_edit::test_utils::{arb_text, arb_offset}; + use ra_text_edit::test_utils::{arb_offset, arb_text}; #[test] 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 @@ +use crate::{line_index::Utf16Char, LineCol, LineIndex}; +use ra_syntax::{TextRange, TextUnit}; use ra_text_edit::{AtomTextEdit, TextEdit}; -use ra_syntax::{TextUnit, TextRange}; -use crate::{LineIndex, LineCol, line_index::Utf16Char}; #[derive(Debug, Clone)] enum Step { @@ -292,8 +292,8 @@ pub fn translate_offset_with_edit( #[cfg(test)] mod test { use super::*; - use proptest::{prelude::*, proptest}; use crate::line_index; + use proptest::{prelude::*, proptest}; use ra_text_edit::test_utils::{arb_offset, arb_text_with_edit}; use ra_text_edit::TextEdit; 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 @@ -use ra_syntax::{ - SourceFile, TextUnit, - algo::find_token_at_offset, - SyntaxKind::{self}, - ast::AstNode, - T -}; +use ra_syntax::{algo::find_token_at_offset, ast::AstNode, SourceFile, SyntaxKind, TextUnit, T}; pub fn matching_brace(file: &SourceFile, offset: TextUnit) -> Option { 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; use relative_path::RelativePathBuf; use test_utils::{extract_offset, extract_range, parse_fixture, CURSOR_MARKER}; -use crate::{Analysis, AnalysisChange, AnalysisHost, CrateGraph, FileId, FilePosition, FileRange, SourceRootId, Edition::Edition2018}; +use crate::{ + Analysis, AnalysisChange, AnalysisHost, CrateGraph, Edition::Edition2018, FileId, FilePosition, + FileRange, SourceRootId, +}; /// Mock analysis is used in test to bootstrap an AnalysisHost/Analysis /// 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 @@ -use ra_syntax::{AstNode, AstPtr, ast}; use hir::Either; +use ra_syntax::{ast, AstNode, AstPtr}; use test_utils::tested_by; 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 @@ -use ra_db::{FilePosition, FileId, CrateId}; +use ra_db::{CrateId, FileId, FilePosition}; -use crate::{NavigationTarget, db::RootDatabase}; +use crate::{db::RootDatabase, NavigationTarget}; /// This returns `Vec` because a module may be included from several places. We /// 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 { #[cfg(test)] mod tests { use crate::{ - AnalysisChange, CrateGraph, mock_analysis::{analysis_and_position, MockAnalysis}, + AnalysisChange, CrateGraph, Edition::Edition2018, -}; + }; #[test] 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 @@ +use hir::{source_binder, Either, ModuleSource}; +use ra_db::SourceDatabase; +use ra_syntax::{algo::find_node_at_offset, ast, AstNode, SourceFile, SyntaxNode}; use relative_path::{RelativePath, RelativePathBuf}; -use hir::{ModuleSource, source_binder, Either}; -use ra_db::{SourceDatabase}; -use ra_syntax::{ - AstNode, SyntaxNode, SourceFile, - ast, - algo::find_node_at_offset, -}; use crate::{ - db::RootDatabase, - FilePosition, - FileRange, - FileId, - NavigationTarget, - FileSystemEdit, - SourceChange, - SourceFileEdit, - TextRange, + db::RootDatabase, FileId, FilePosition, FileRange, FileSystemEdit, NavigationTarget, + SourceChange, SourceFileEdit, TextRange, }; #[derive(Debug, Clone)] @@ -210,13 +199,12 @@ fn rename_reference( #[cfg(test)] mod tests { + use crate::{ + mock_analysis::analysis_and_position, mock_analysis::single_file_with_position, FileId, + ReferenceSearchResult, + }; use insta::assert_debug_snapshot_matches; use test_utils::assert_eq_text; - use crate::{ - mock_analysis::single_file_with_position, - mock_analysis::analysis_and_position, - FileId, ReferenceSearchResult -}; #[test] 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 @@ use itertools::Itertools; +use ra_db::SourceDatabase; use ra_syntax::{ - TextRange, SyntaxNode, - ast::{self, AstNode, NameOwner, ModuleItemOwner, AttrsOwner}, + ast::{self, AstNode, AttrsOwner, ModuleItemOwner, NameOwner}, + SyntaxNode, TextRange, }; -use ra_db::SourceDatabase; use crate::{db::RootDatabase, FileId}; 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 @@ -use std::{ - fmt, - iter::FromIterator, - sync::Arc, -}; +use std::{fmt, iter::FromIterator, sync::Arc}; -use ra_syntax::{TreeArc, SyntaxNode, Parse, AstNode}; +use hir::MacroFile; use ra_db::{ + salsa::{ + debug::{DebugQueryTable, TableEntry}, + Database, + }, FileTextQuery, SourceRootId, - salsa::{Database, debug::{DebugQueryTable, TableEntry}}, }; -use ra_prof::{Bytes, memory_usage}; -use hir::MacroFile; +use ra_prof::{memory_usage, Bytes}; +use ra_syntax::{AstNode, Parse, SyntaxNode, TreeArc}; use crate::{ - FileId, db::RootDatabase, - symbol_index::{SymbolIndex, LibrarySymbolsQuery}, + db::RootDatabase, + symbol_index::{LibrarySymbolsQuery, SymbolIndex}, + FileId, }; 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 @@ //! file in the current workspace, and run a query against the union of all //! those FSTs. use std::{ + fmt, hash::{Hash, Hasher}, - sync::Arc, mem, - fmt, + sync::Arc, }; use fst::{self, Streamer}; -use ra_syntax::{ - SyntaxNode, SyntaxNodePtr, SourceFile, SmolStr, TreeArc, AstNode, - algo::{visit::{visitor, Visitor}}, - SyntaxKind::{self, *}, - ast::{self, NameOwner}, - WalkEvent, - TextRange, -}; use ra_db::{ - SourceRootId, SourceDatabase, salsa::{self, ParallelDatabase}, + SourceDatabase, SourceRootId, +}; +use ra_syntax::{ + algo::visit::{visitor, Visitor}, + ast::{self, NameOwner}, + AstNode, SmolStr, SourceFile, + SyntaxKind::{self, *}, + SyntaxNode, SyntaxNodePtr, TextRange, TreeArc, WalkEvent, }; use rayon::prelude::*; -use crate::{ - FileId, Query, - db::RootDatabase, -}; +use crate::{db::RootDatabase, FileId, Query}; #[salsa::query_group(SymbolsDatabaseStorage)] pub(crate) trait SymbolsDatabase: hir::db::HirDatabase { @@ -305,15 +301,11 @@ fn to_file_symbol(node: &SyntaxNode, file_id: FileId) -> Option { #[cfg(test)] mod tests { + use crate::{display::NavigationTarget, mock_analysis::single_file, Query}; use ra_syntax::{ SmolStr, - SyntaxKind::{FN_DEF, STRUCT_DEF} -}; - use crate::{ - display::NavigationTarget, - mock_analysis::single_file, - Query, -}; + SyntaxKind::{FN_DEF, STRUCT_DEF}, + }; #[test] 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 @@ -use rustc_hash::{FxHashSet, FxHashMap}; +use rustc_hash::{FxHashMap, FxHashSet}; -use ra_syntax::{ - ast, AstNode, TextRange, Direction, SmolStr, SyntaxKind, SyntaxKind::*, SyntaxElement, T, -}; use ra_db::SourceDatabase; use ra_prof::profile; +use ra_syntax::{ + ast, AstNode, Direction, SmolStr, SyntaxElement, SyntaxKind, SyntaxKind::*, TextRange, T, +}; -use crate::{FileId, db::RootDatabase}; +use crate::{db::RootDatabase, FileId}; #[derive(Debug)] pub struct HighlightedRange { @@ -64,7 +64,7 @@ pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec Option { let file = db.parse(position.file_id).tree; -- cgit v1.2.3