mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 22:01:37 +00:00
Extract the import code into the shared module
This commit is contained in:
parent
0993f9067c
commit
f4ae3650d8
30 changed files with 298 additions and 254 deletions
|
@ -1,5 +1,5 @@
|
|||
//! Complete fields in record literals and patterns.
|
||||
use assists::utils::FamousDefs;
|
||||
use ide_helpers::FamousDefs;
|
||||
use syntax::ast::Expr;
|
||||
|
||||
use crate::{
|
||||
|
@ -45,8 +45,8 @@ pub(crate) fn complete_record(acc: &mut Completions, ctx: &CompletionContext) ->
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use assists::utils::FamousDefs;
|
||||
use expect_test::{expect, Expect};
|
||||
use ide_helpers::FamousDefs;
|
||||
|
||||
use crate::{test_utils::completion_list, CompletionKind};
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
//! Completion of names from the current scope, e.g. locals and imported items.
|
||||
|
||||
use assists::utils::ImportScope;
|
||||
use either::Either;
|
||||
use hir::{Adt, ModuleDef, ScopeDef, Type};
|
||||
use ide_db::imports_locator;
|
||||
use ide_helpers::insert_use::ImportScope;
|
||||
use syntax::AstNode;
|
||||
use test_utils::mark;
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
//! module, and we use to statically check that we only produce snippet
|
||||
//! completions if we are allowed to.
|
||||
|
||||
use assists::utils::MergeBehaviour;
|
||||
use ide_helpers::insert_use::MergeBehaviour;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct CompletionConfig {
|
||||
|
|
|
@ -2,8 +2,11 @@
|
|||
|
||||
use std::fmt;
|
||||
|
||||
use assists::utils::{insert_use, mod_path_to_ast, ImportScope, MergeBehaviour};
|
||||
use hir::{Documentation, ModPath, Mutability};
|
||||
use ide_helpers::{
|
||||
insert_use::{self, ImportScope, MergeBehaviour},
|
||||
mod_path_to_ast,
|
||||
};
|
||||
use syntax::{algo, TextRange};
|
||||
use text_edit::TextEdit;
|
||||
|
||||
|
@ -300,7 +303,7 @@ impl Builder {
|
|||
label = format!("{}::{}", import_path_without_last_segment, label);
|
||||
}
|
||||
|
||||
let rewriter = insert_use(&import_scope, import, merge_behaviour);
|
||||
let rewriter = insert_use::insert_use(&import_scope, import, merge_behaviour);
|
||||
if let Some(old_ast) = rewriter.rewrite_root() {
|
||||
algo::diff(&old_ast, &rewriter.rewrite(&old_ast)).into_text_edit(&mut text_edits);
|
||||
}
|
||||
|
|
|
@ -9,9 +9,9 @@ pub(crate) mod type_alias;
|
|||
|
||||
mod builder_ext;
|
||||
|
||||
use assists::utils::{ImportScope, MergeBehaviour};
|
||||
use hir::{Documentation, HasAttrs, HirDisplay, ModPath, Mutability, ScopeDef, Type};
|
||||
use ide_db::RootDatabase;
|
||||
use ide_helpers::insert_use::{ImportScope, MergeBehaviour};
|
||||
use syntax::TextRange;
|
||||
use test_utils::mark;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//! Renderer for `enum` variants.
|
||||
|
||||
use assists::utils::{ImportScope, MergeBehaviour};
|
||||
use hir::{HasAttrs, HirDisplay, ModPath, StructKind};
|
||||
use ide_helpers::insert_use::{ImportScope, MergeBehaviour};
|
||||
use itertools::Itertools;
|
||||
use test_utils::mark;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//! Renderer for function calls.
|
||||
|
||||
use assists::utils::{ImportScope, MergeBehaviour};
|
||||
use hir::{HasSource, ModPath, Type};
|
||||
use ide_helpers::insert_use::{ImportScope, MergeBehaviour};
|
||||
use syntax::{ast::Fn, display::function_declaration};
|
||||
|
||||
use crate::{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//! Renderer for macro invocations.
|
||||
|
||||
use assists::utils::{ImportScope, MergeBehaviour};
|
||||
use hir::{Documentation, HasSource, ModPath};
|
||||
use ide_helpers::insert_use::{ImportScope, MergeBehaviour};
|
||||
use syntax::display::macro_label;
|
||||
use test_utils::mark;
|
||||
|
||||
|
@ -12,6 +12,7 @@ use crate::{
|
|||
|
||||
pub(crate) fn render_macro<'a>(
|
||||
ctx: RenderContext<'a>,
|
||||
// TODO kb add some object instead of a tuple?
|
||||
import_data: Option<(ModPath, ImportScope, Option<MergeBehaviour>)>,
|
||||
name: String,
|
||||
macro_: hir::MacroDef,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue