mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-10 07:04:22 +00:00
Move the helpers into ide_db
This commit is contained in:
parent
7b145bd99c
commit
3f612d37c6
27 changed files with 29 additions and 70 deletions
18
Cargo.lock
generated
18
Cargo.lock
generated
|
@ -53,7 +53,6 @@ dependencies = [
|
|||
"either",
|
||||
"hir",
|
||||
"ide_db",
|
||||
"ide_helpers",
|
||||
"itertools",
|
||||
"profile",
|
||||
"rustc-hash",
|
||||
|
@ -259,7 +258,6 @@ dependencies = [
|
|||
"expect-test",
|
||||
"hir",
|
||||
"ide_db",
|
||||
"ide_helpers",
|
||||
"itertools",
|
||||
"log",
|
||||
"profile",
|
||||
|
@ -658,7 +656,6 @@ dependencies = [
|
|||
"expect-test",
|
||||
"hir",
|
||||
"ide_db",
|
||||
"ide_helpers",
|
||||
"indexmap",
|
||||
"itertools",
|
||||
"log",
|
||||
|
@ -684,6 +681,7 @@ dependencies = [
|
|||
"expect-test",
|
||||
"fst",
|
||||
"hir",
|
||||
"itertools",
|
||||
"log",
|
||||
"once_cell",
|
||||
"profile",
|
||||
|
@ -695,19 +693,6 @@ dependencies = [
|
|||
"text_edit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ide_helpers"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"either",
|
||||
"hir",
|
||||
"ide_db",
|
||||
"itertools",
|
||||
"profile",
|
||||
"syntax",
|
||||
"test_utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "idna"
|
||||
version = "0.2.0"
|
||||
|
@ -1376,7 +1361,6 @@ dependencies = [
|
|||
"hir_ty",
|
||||
"ide",
|
||||
"ide_db",
|
||||
"ide_helpers",
|
||||
"itertools",
|
||||
"jod-thread",
|
||||
"log",
|
||||
|
|
|
@ -21,4 +21,3 @@ profile = { path = "../profile", version = "0.0.0" }
|
|||
ide_db = { path = "../ide_db", version = "0.0.0" }
|
||||
hir = { path = "../hir", version = "0.0.0" }
|
||||
test_utils = { path = "../test_utils", version = "0.0.0" }
|
||||
ide_helpers = { path = "../ide_helpers", version = "0.0.0" }
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
//! assists if we are allowed to.
|
||||
|
||||
use hir::PrefixKind;
|
||||
use ide_helpers::insert_use::MergeBehaviour;
|
||||
use ide_db::helpers::insert_use::MergeBehaviour;
|
||||
|
||||
use crate::AssistKind;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
//! `AstTransformer`s are functions that replace nodes in an AST and can be easily combined.
|
||||
use hir::{HirDisplay, PathResolution, SemanticsScope};
|
||||
use ide_helpers::mod_path_to_ast;
|
||||
use ide_db::helpers::mod_path_to_ast;
|
||||
use rustc_hash::FxHashMap;
|
||||
use syntax::{
|
||||
algo::SyntaxRewriter,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use ide_helpers::{
|
||||
use ide_db::helpers::{
|
||||
insert_use::{insert_use, ImportScope},
|
||||
mod_path_to_ast,
|
||||
};
|
||||
|
|
|
@ -2,11 +2,11 @@ use std::iter;
|
|||
|
||||
use either::Either;
|
||||
use hir::{AsName, EnumVariant, Module, ModuleDef, Name};
|
||||
use ide_db::{defs::Definition, search::Reference, RootDatabase};
|
||||
use ide_helpers::{
|
||||
use ide_db::helpers::{
|
||||
insert_use::{insert_use, ImportScope},
|
||||
mod_path_to_ast,
|
||||
};
|
||||
use ide_db::{defs::Definition, search::Reference, RootDatabase};
|
||||
use rustc_hash::{FxHashMap, FxHashSet};
|
||||
use syntax::{
|
||||
algo::{find_node_at_offset, SyntaxRewriter},
|
||||
|
@ -237,7 +237,7 @@ fn update_reference(
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use ide_helpers::FamousDefs;
|
||||
use ide_db::helpers::FamousDefs;
|
||||
|
||||
use crate::tests::{check_assist, check_assist_not_applicable};
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use std::iter;
|
||||
|
||||
use hir::{Adt, HasSource, ModuleDef, Semantics};
|
||||
use ide_db::helpers::{mod_path_to_ast, FamousDefs};
|
||||
use ide_db::RootDatabase;
|
||||
use ide_helpers::{mod_path_to_ast, FamousDefs};
|
||||
use itertools::Itertools;
|
||||
use syntax::ast::{self, make, AstNode, MatchArm, NameOwner, Pat};
|
||||
use test_utils::mark;
|
||||
|
@ -213,7 +213,7 @@ fn build_pat(db: &RootDatabase, module: hir::Module, var: hir::EnumVariant) -> O
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use ide_helpers::FamousDefs;
|
||||
use ide_db::helpers::FamousDefs;
|
||||
use test_utils::mark;
|
||||
|
||||
use crate::tests::{check_assist, check_assist_not_applicable, check_assist_target};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use ide_db::helpers::FamousDefs;
|
||||
use ide_db::RootDatabase;
|
||||
use ide_helpers::FamousDefs;
|
||||
use syntax::ast::{self, AstNode, NameOwner};
|
||||
use test_utils::mark;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use ide_helpers::insert_use::{try_merge_imports, try_merge_trees, MergeBehaviour};
|
||||
use ide_db::helpers::insert_use::{try_merge_imports, try_merge_trees, MergeBehaviour};
|
||||
use syntax::{
|
||||
algo::{neighbor, SyntaxRewriter},
|
||||
ast, AstNode,
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use std::iter;
|
||||
|
||||
use hir::AsName;
|
||||
use ide_db::helpers::mod_path_to_ast;
|
||||
use ide_db::RootDatabase;
|
||||
use ide_helpers::mod_path_to_ast;
|
||||
use syntax::{
|
||||
ast,
|
||||
ast::{make, ArgListOwner},
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use ide_db::helpers::mod_path_to_ast;
|
||||
use ide_db::imports_locator;
|
||||
use ide_helpers::mod_path_to_ast;
|
||||
use itertools::Itertools;
|
||||
use syntax::{
|
||||
ast::{self, make, AstNode},
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use ide_helpers::insert_use::{insert_use, ImportScope};
|
||||
use ide_db::helpers::insert_use::{insert_use, ImportScope};
|
||||
use syntax::{algo::SyntaxRewriter, ast, match_ast, AstNode, SyntaxNode};
|
||||
use test_utils::mark;
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ base_db = { path = "../base_db", version = "0.0.0" }
|
|||
ide_db = { path = "../ide_db", version = "0.0.0" }
|
||||
profile = { path = "../profile", version = "0.0.0" }
|
||||
test_utils = { path = "../test_utils", version = "0.0.0" }
|
||||
ide_helpers = { path = "../ide_helpers", version = "0.0.0" }
|
||||
|
||||
# completions crate should depend only on the top-level `hir` package. if you need
|
||||
# something from some `hir_xxx` subpackage, reexport the API via `hir`.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//! Complete fields in record literals and patterns.
|
||||
use ide_helpers::FamousDefs;
|
||||
use ide_db::helpers::FamousDefs;
|
||||
use syntax::ast::Expr;
|
||||
|
||||
use crate::{
|
||||
|
@ -46,7 +46,7 @@ pub(crate) fn complete_record(acc: &mut Completions, ctx: &CompletionContext) ->
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use expect_test::{expect, Expect};
|
||||
use ide_helpers::FamousDefs;
|
||||
use ide_db::helpers::FamousDefs;
|
||||
|
||||
use crate::{test_utils::completion_list, CompletionKind};
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
use either::Either;
|
||||
use hir::{Adt, ModuleDef, ScopeDef, Type};
|
||||
use ide_db::helpers::insert_use::ImportScope;
|
||||
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 ide_helpers::insert_use::MergeBehaviour;
|
||||
use ide_db::helpers::insert_use::MergeBehaviour;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct CompletionConfig {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
use std::fmt;
|
||||
|
||||
use hir::{Documentation, ModPath, Mutability};
|
||||
use ide_helpers::{
|
||||
use ide_db::helpers::{
|
||||
insert_use::{self, ImportScope, MergeBehaviour},
|
||||
mod_path_to_ast,
|
||||
};
|
||||
|
|
|
@ -10,8 +10,8 @@ pub(crate) mod type_alias;
|
|||
mod builder_ext;
|
||||
|
||||
use hir::{Documentation, HasAttrs, HirDisplay, ModPath, Mutability, ScopeDef, Type};
|
||||
use ide_db::helpers::insert_use::{ImportScope, MergeBehaviour};
|
||||
use ide_db::RootDatabase;
|
||||
use ide_helpers::insert_use::{ImportScope, MergeBehaviour};
|
||||
use syntax::TextRange;
|
||||
use test_utils::mark;
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@ stdx = { path = "../stdx", version = "0.0.0" }
|
|||
syntax = { path = "../syntax", version = "0.0.0" }
|
||||
text_edit = { path = "../text_edit", version = "0.0.0" }
|
||||
ide_db = { path = "../ide_db", version = "0.0.0" }
|
||||
ide_helpers = { path = "../ide_helpers", version = "0.0.0" }
|
||||
cfg = { path = "../cfg", version = "0.0.0" }
|
||||
profile = { path = "../profile", version = "0.0.0" }
|
||||
test_utils = { path = "../test_utils", version = "0.0.0" }
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use either::Either;
|
||||
use hir::{known, Callable, HirDisplay, Semantics};
|
||||
use ide_db::helpers::FamousDefs;
|
||||
use ide_db::RootDatabase;
|
||||
use ide_helpers::FamousDefs;
|
||||
use stdx::to_lower_snake_case;
|
||||
use syntax::{
|
||||
ast::{self, ArgListOwner, AstNode, NameOwner},
|
||||
|
@ -428,7 +428,7 @@ fn get_callable(sema: &Semantics<RootDatabase>, expr: &ast::Expr) -> Option<hir:
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use expect_test::{expect, Expect};
|
||||
use ide_helpers::FamousDefs;
|
||||
use ide_db::helpers::FamousDefs;
|
||||
use test_utils::extract_annotations;
|
||||
|
||||
use crate::{fixture, inlay_hints::InlayHintsConfig};
|
||||
|
|
|
@ -18,7 +18,8 @@ rayon = "1.5.0"
|
|||
fst = { version = "0.4", default-features = false }
|
||||
rustc-hash = "1.1.0"
|
||||
once_cell = "1.3.1"
|
||||
either = "1.5.3"
|
||||
either = "1.6.1"
|
||||
itertools = "0.9.0"
|
||||
|
||||
stdx = { path = "../stdx", version = "0.0.0" }
|
||||
syntax = { path = "../syntax", version = "0.0.0" }
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
//! A module with ide helpers for high-level ide features.
|
||||
use crate::RootDatabase;
|
||||
use hir::{Crate, Enum, Module, ScopeDef, Semantics, Trait};
|
||||
use ide_db::RootDatabase;
|
||||
use syntax::ast::{self, make};
|
||||
|
||||
pub mod insert_use;
|
|
@ -1,8 +1,8 @@
|
|||
//! Handle syntactic aspects of inserting a new `use`.
|
||||
use std::{cmp::Ordering, iter::successors};
|
||||
|
||||
use crate::RootDatabase;
|
||||
use hir::Semantics;
|
||||
use ide_db::RootDatabase;
|
||||
use itertools::{EitherOrBoth, Itertools};
|
||||
use syntax::{
|
||||
algo::SyntaxRewriter,
|
|
@ -13,6 +13,7 @@ pub mod source_change;
|
|||
pub mod ty_filter;
|
||||
pub mod traits;
|
||||
pub mod call_info;
|
||||
pub mod helpers;
|
||||
|
||||
use std::{fmt, sync::Arc};
|
||||
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
[package]
|
||||
name = "ide_helpers"
|
||||
version = "0.0.0"
|
||||
description = "A set of helper methods shared between various ide-level modules"
|
||||
license = "MIT OR Apache-2.0"
|
||||
authors = ["rust-analyzer developers"]
|
||||
edition = "2018"
|
||||
|
||||
[lib]
|
||||
doctest = false
|
||||
|
||||
[features]
|
||||
wasm = []
|
||||
|
||||
[dependencies]
|
||||
either = "1.6.1"
|
||||
itertools = "0.9.0"
|
||||
|
||||
syntax = { path = "../syntax", version = "0.0.0" }
|
||||
ide_db = { path = "../ide_db", version = "0.0.0" }
|
||||
hir = { path = "../hir", version = "0.0.0" }
|
||||
profile = { path = "../profile", version = "0.0.0" }
|
||||
test_utils = { path = "../test_utils", version = "0.0.0" }
|
|
@ -39,7 +39,7 @@ tracing-tree = { version = "0.1.4" }
|
|||
stdx = { path = "../stdx", version = "0.0.0" }
|
||||
flycheck = { path = "../flycheck", version = "0.0.0" }
|
||||
ide = { path = "../ide", version = "0.0.0" }
|
||||
ide_helpers = { path = "../ide_helpers", version = "0.0.0" }
|
||||
ide_db = { path = "../ide_db", version = "0.0.0" }
|
||||
profile = { path = "../profile", version = "0.0.0" }
|
||||
project_model = { path = "../project_model", version = "0.0.0" }
|
||||
syntax = { path = "../syntax", version = "0.0.0" }
|
||||
|
@ -50,7 +50,6 @@ cfg = { path = "../cfg", version = "0.0.0" }
|
|||
toolchain = { path = "../toolchain", version = "0.0.0" }
|
||||
|
||||
# This should only be used in CLI
|
||||
ide_db = { path = "../ide_db", version = "0.0.0" }
|
||||
ssr = { path = "../ssr", version = "0.0.0" }
|
||||
hir = { path = "../hir", version = "0.0.0" }
|
||||
hir_def = { path = "../hir_def", version = "0.0.0" }
|
||||
|
|
|
@ -12,7 +12,7 @@ use std::{convert::TryFrom, ffi::OsString, path::PathBuf};
|
|||
use flycheck::FlycheckConfig;
|
||||
use hir::PrefixKind;
|
||||
use ide::{AssistConfig, CompletionConfig, DiagnosticsConfig, HoverConfig, InlayHintsConfig};
|
||||
use ide_helpers::insert_use::MergeBehaviour;
|
||||
use ide_db::helpers::insert_use::MergeBehaviour;
|
||||
use lsp_types::{ClientCapabilities, MarkupKind};
|
||||
use project_model::{CargoConfig, ProjectJson, ProjectJsonData, ProjectManifest};
|
||||
use rustc_hash::FxHashSet;
|
||||
|
|
Loading…
Reference in a new issue