mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
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
This commit is contained in:
parent
2b2cd829b0
commit
1834bae5b8
166 changed files with 798 additions and 814 deletions
|
@ -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;
|
||||
|
||||
|
|
|
@ -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<CallInfo> {
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -14,19 +14,19 @@ mod complete_postfix;
|
|||
|
||||
use ra_db::SourceDatabase;
|
||||
|
||||
use crate::{
|
||||
db,
|
||||
FilePosition,
|
||||
completion::{
|
||||
completion_item::{Completions, CompletionKind},
|
||||
completion_context::CompletionContext,
|
||||
},
|
||||
|
||||
};
|
||||
#[cfg(test)]
|
||||
use crate::completion::completion_item::{do_completion, check_completion};
|
||||
use crate::completion::completion_item::{check_completion, do_completion};
|
||||
use crate::{
|
||||
completion::{
|
||||
completion_context::CompletionContext,
|
||||
completion_item::{CompletionKind, Completions},
|
||||
},
|
||||
db, FilePosition,
|
||||
};
|
||||
|
||||
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.
|
||||
///
|
||||
|
|
|
@ -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<CompletionItem> {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<CompletionItem> {
|
||||
|
|
|
@ -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<CompletionItem> {
|
||||
do_completion(code, CompletionKind::Reference)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<CompletionItem> {
|
||||
do_completion(code, CompletionKind::Reference)
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
use ra_text_edit::AtomTextEdit;
|
||||
use ra_syntax::{
|
||||
AstNode, SyntaxNode, SourceFile, TextUnit, TextRange, SyntaxToken, Parse,
|
||||
ast,
|
||||
algo::{find_token_at_offset, find_covering_element, find_node_at_offset},
|
||||
SyntaxKind::*,
|
||||
};
|
||||
use hir::source_binder;
|
||||
use ra_syntax::{
|
||||
algo::{find_covering_element, find_node_at_offset, find_token_at_offset},
|
||||
ast, AstNode, Parse, SourceFile,
|
||||
SyntaxKind::*,
|
||||
SyntaxNode, SyntaxToken, TextRange, TextUnit,
|
||||
};
|
||||
use ra_text_edit::AtomTextEdit;
|
||||
|
||||
use crate::{db, FilePosition};
|
||||
|
||||
|
|
|
@ -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<Vec<CompletionItem>> for Completions {
|
|||
|
||||
#[cfg(test)]
|
||||
pub(crate) fn do_completion(code: &str, kind: CompletionKind) -> Vec<CompletionItem> {
|
||||
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 {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -1,17 +1,20 @@
|
|||
use std::cell::RefCell;
|
||||
|
||||
use itertools::Itertools;
|
||||
use hir::{source_binder, diagnostics::{Diagnostic as _, DiagnosticSink}};
|
||||
use ra_db::SourceDatabase;
|
||||
use ra_syntax::{
|
||||
T, Location, TextRange, SyntaxNode,
|
||||
ast::{self, AstNode, NamedFieldList, NamedField},
|
||||
use hir::{
|
||||
diagnostics::{Diagnostic as _, DiagnosticSink},
|
||||
source_binder,
|
||||
};
|
||||
use ra_assists::ast_editor::{AstEditor, AstBuilder};
|
||||
use ra_text_edit::{TextEdit, TextEditBuilder};
|
||||
use itertools::Itertools;
|
||||
use ra_assists::ast_editor::{AstBuilder, AstEditor};
|
||||
use ra_db::SourceDatabase;
|
||||
use ra_prof::profile;
|
||||
use ra_syntax::{
|
||||
ast::{self, AstNode, NamedField, NamedFieldList},
|
||||
Location, SyntaxNode, TextRange, T,
|
||||
};
|
||||
use ra_text_edit::{TextEdit, TextEditBuilder};
|
||||
|
||||
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;
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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<String>;
|
||||
|
|
|
@ -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,
|
||||
};
|
||||
|
||||
|
|
|
@ -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::*;
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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<String> {
|
|||
|
||||
#[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```")
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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};
|
||||
|
||||
|
|
|
@ -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,
|
||||
folding_ranges::{Fold, FoldKind},
|
||||
syntax_highlighting::HighlightedRange,
|
||||
diagnostics::Severity,
|
||||
display::{FunctionSignature, NavigationTarget, StructureNode, file_structure},
|
||||
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,
|
||||
};
|
||||
|
||||
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<T> = Result<T, Canceled>;
|
||||
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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<TextUnit> {
|
||||
const BRACES: &[SyntaxKind] =
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<CrateId> {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{
|
||||
AnalysisChange, CrateGraph,
|
||||
mock_analysis::{analysis_and_position, MockAnalysis},
|
||||
AnalysisChange, CrateGraph,
|
||||
Edition::Edition2018,
|
||||
};
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn test_resolve_parent_module() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use itertools::Itertools;
|
||||
use ra_syntax::{
|
||||
TextRange, SyntaxNode,
|
||||
ast::{self, AstNode, NameOwner, ModuleItemOwner, AttrsOwner},
|
||||
};
|
||||
use ra_db::SourceDatabase;
|
||||
use ra_syntax::{
|
||||
ast::{self, AstNode, AttrsOwner, ModuleItemOwner, NameOwner},
|
||||
SyntaxNode, TextRange,
|
||||
};
|
||||
|
||||
use crate::{db::RootDatabase, FileId};
|
||||
|
||||
|
|
|
@ -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 ra_db::{
|
||||
FileTextQuery, SourceRootId,
|
||||
salsa::{Database, debug::{DebugQueryTable, TableEntry}},
|
||||
};
|
||||
use ra_prof::{Bytes, memory_usage};
|
||||
use hir::MacroFile;
|
||||
use ra_db::{
|
||||
salsa::{
|
||||
debug::{DebugQueryTable, TableEntry},
|
||||
Database,
|
||||
},
|
||||
FileTextQuery, SourceRootId,
|
||||
};
|
||||
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 {
|
||||
|
|
|
@ -20,31 +20,27 @@
|
|||
//! file in the current workspace, and run a query against the union of all
|
||||
//! those FSTs.
|
||||
use std::{
|
||||
hash::{Hash, Hasher},
|
||||
sync::Arc,
|
||||
mem,
|
||||
fmt,
|
||||
hash::{Hash, Hasher},
|
||||
mem,
|
||||
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<FileSymbol> {
|
|||
|
||||
#[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() {
|
||||
|
|
|
@ -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<HighlightedRa
|
|||
if let Some(name_ref) = node.as_node().and_then(ast::NameRef::cast) {
|
||||
// FIXME: revisit this after #1340
|
||||
use crate::name_ref_kind::{classify_name_ref, NameRefKind::*};
|
||||
use hir::{ModuleDef, ImplItem};
|
||||
use hir::{ImplItem, ModuleDef};
|
||||
|
||||
// FIXME: try to reuse the SourceAnalyzers
|
||||
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
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use test_utils::{project_dir, read_text, assert_eq_text};
|
||||
use crate::mock_analysis::single_file;
|
||||
use test_utils::{assert_eq_text, project_dir, read_text};
|
||||
|
||||
#[test]
|
||||
fn test_highlighting() {
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use ra_db::SourceDatabase;
|
||||
use crate::db::RootDatabase;
|
||||
use ra_db::SourceDatabase;
|
||||
use ra_syntax::{
|
||||
SourceFile, TextRange, AstNode, SyntaxToken, SyntaxElement,
|
||||
algo,
|
||||
SyntaxKind::{STRING, RAW_STRING},
|
||||
algo, AstNode, SourceFile, SyntaxElement,
|
||||
SyntaxKind::{RAW_STRING, STRING},
|
||||
SyntaxToken, TextRange,
|
||||
};
|
||||
|
||||
pub use ra_db::FileId;
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
use crate::{db::RootDatabase, SourceChange, SourceFileEdit};
|
||||
use ra_db::{FilePosition, SourceDatabase};
|
||||
use ra_fmt::leading_indent;
|
||||
use ra_syntax::{
|
||||
AstNode, SourceFile, SyntaxKind::*,
|
||||
TextUnit, TextRange, SyntaxToken,
|
||||
algo::{find_node_at_offset, find_token_at_offset, TokenAtOffset},
|
||||
ast::{self, AstToken},
|
||||
AstNode, SourceFile,
|
||||
SyntaxKind::*,
|
||||
SyntaxToken, TextRange, TextUnit,
|
||||
};
|
||||
use ra_fmt::leading_indent;
|
||||
use ra_text_edit::{TextEdit, TextEditBuilder};
|
||||
use ra_db::{FilePosition, SourceDatabase};
|
||||
use crate::{db::RootDatabase, SourceChange, SourceFileEdit};
|
||||
|
||||
pub(crate) fn on_enter(db: &RootDatabase, position: FilePosition) -> Option<SourceChange> {
|
||||
let file = db.parse(position.file_id).tree;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue