diff --git a/Cargo.lock b/Cargo.lock index 9878dd88fe..a99dd6e04a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -83,6 +83,21 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" +[[package]] +name = "base_db" +version = "0.0.0" +dependencies = [ + "cfg", + "profile", + "rustc-hash", + "salsa", + "stdx", + "syntax", + "test_utils", + "tt", + "vfs", +] + [[package]] name = "bitflags" version = "1.2.1" @@ -956,12 +971,12 @@ version = "0.0.0" dependencies = [ "anyhow", "arena", + "base_db", "cargo_metadata", "cfg", "log", "paths", "proc_macro_api", - "ra_db", "rustc-hash", "serde", "serde_json", @@ -982,10 +997,10 @@ dependencies = [ name = "ra_assists" version = "0.1.0" dependencies = [ + "base_db", "either", "itertools", "profile", - "ra_db", "ra_hir", "ra_ide_db", "rustc-hash", @@ -995,31 +1010,16 @@ dependencies = [ "text_edit", ] -[[package]] -name = "ra_db" -version = "0.1.0" -dependencies = [ - "cfg", - "profile", - "rustc-hash", - "salsa", - "stdx", - "syntax", - "test_utils", - "tt", - "vfs", -] - [[package]] name = "ra_hir" version = "0.1.0" dependencies = [ "arrayvec", + "base_db", "either", "itertools", "log", "profile", - "ra_db", "ra_hir_def", "ra_hir_expand", "ra_hir_ty", @@ -1034,6 +1034,7 @@ version = "0.1.0" dependencies = [ "anymap", "arena", + "base_db", "cfg", "drop_bomb", "either", @@ -1045,7 +1046,6 @@ dependencies = [ "mbe", "once_cell", "profile", - "ra_db", "ra_hir_expand", "rustc-hash", "smallvec", @@ -1060,12 +1060,12 @@ name = "ra_hir_expand" version = "0.1.0" dependencies = [ "arena", + "base_db", "either", "log", "mbe", "parser", "profile", - "ra_db", "rustc-hash", "syntax", "test_utils", @@ -1078,6 +1078,7 @@ version = "0.1.0" dependencies = [ "arena", "arrayvec", + "base_db", "chalk-ir", "chalk-recursive", "chalk-solve", @@ -1086,7 +1087,6 @@ dependencies = [ "itertools", "log", "profile", - "ra_db", "ra_hir_def", "ra_hir_expand", "rustc-hash", @@ -1104,6 +1104,7 @@ dependencies = [ name = "ra_ide" version = "0.1.0" dependencies = [ + "base_db", "cfg", "either", "expect", @@ -1113,7 +1114,6 @@ dependencies = [ "oorandom", "profile", "ra_assists", - "ra_db", "ra_hir", "ra_ide_db", "ra_ssr", @@ -1128,12 +1128,12 @@ dependencies = [ name = "ra_ide_db" version = "0.1.0" dependencies = [ + "base_db", "either", "fst", "log", "once_cell", "profile", - "ra_db", "ra_hir", "rayon", "rustc-hash", @@ -1147,8 +1147,8 @@ dependencies = [ name = "ra_ssr" version = "0.1.0" dependencies = [ + "base_db", "expect", - "ra_db", "ra_hir", "ra_ide_db", "rustc-hash", @@ -1230,6 +1230,7 @@ name = "rust-analyzer" version = "0.1.0" dependencies = [ "anyhow", + "base_db", "cfg", "crossbeam-channel", "env_logger", @@ -1248,7 +1249,6 @@ dependencies = [ "proc_macro_srv", "profile", "project_model", - "ra_db", "ra_hir", "ra_hir_def", "ra_hir_ty", diff --git a/crates/ra_db/Cargo.toml b/crates/base_db/Cargo.toml similarity index 91% rename from crates/ra_db/Cargo.toml rename to crates/base_db/Cargo.toml index ad432f096a..7347d7528c 100644 --- a/crates/ra_db/Cargo.toml +++ b/crates/base_db/Cargo.toml @@ -1,9 +1,9 @@ [package] -edition = "2018" -name = "ra_db" -version = "0.1.0" -authors = ["rust-analyzer developers"] +name = "base_db" +version = "0.0.0" license = "MIT OR Apache-2.0" +authors = ["rust-analyzer developers"] +edition = "2018" [lib] doctest = false diff --git a/crates/ra_db/src/cancellation.rs b/crates/base_db/src/cancellation.rs similarity index 100% rename from crates/ra_db/src/cancellation.rs rename to crates/base_db/src/cancellation.rs diff --git a/crates/ra_db/src/fixture.rs b/crates/base_db/src/fixture.rs similarity index 100% rename from crates/ra_db/src/fixture.rs rename to crates/base_db/src/fixture.rs diff --git a/crates/ra_db/src/input.rs b/crates/base_db/src/input.rs similarity index 100% rename from crates/ra_db/src/input.rs rename to crates/base_db/src/input.rs diff --git a/crates/ra_db/src/lib.rs b/crates/base_db/src/lib.rs similarity index 98% rename from crates/ra_db/src/lib.rs rename to crates/base_db/src/lib.rs index 73ac243d66..811057251d 100644 --- a/crates/ra_db/src/lib.rs +++ b/crates/base_db/src/lib.rs @@ -1,4 +1,4 @@ -//! ra_db defines basic database traits. The concrete DB is defined by ra_ide. +//! base_db defines basic database traits. The concrete DB is defined by ra_ide. mod cancellation; mod input; pub mod fixture; diff --git a/crates/project_model/Cargo.toml b/crates/project_model/Cargo.toml index 1c84c7d209..386f72f419 100644 --- a/crates/project_model/Cargo.toml +++ b/crates/project_model/Cargo.toml @@ -18,7 +18,7 @@ anyhow = "1.0.26" arena = { path = "../arena" } cfg = { path = "../cfg" } -ra_db = { path = "../ra_db" } +base_db = { path = "../base_db" } toolchain = { path = "../toolchain" } proc_macro_api = { path = "../proc_macro_api" } paths = { path = "../paths" } diff --git a/crates/project_model/src/cargo_workspace.rs b/crates/project_model/src/cargo_workspace.rs index abf8dca964..e5c2d2b256 100644 --- a/crates/project_model/src/cargo_workspace.rs +++ b/crates/project_model/src/cargo_workspace.rs @@ -9,9 +9,9 @@ use std::{ use anyhow::{Context, Result}; use arena::{Arena, Idx}; +use base_db::Edition; use cargo_metadata::{BuildScript, CargoOpt, Message, MetadataCommand, PackageId}; use paths::{AbsPath, AbsPathBuf}; -use ra_db::Edition; use rustc_hash::FxHashMap; use crate::cfg_flag::CfgFlag; diff --git a/crates/project_model/src/lib.rs b/crates/project_model/src/lib.rs index 234f908c9b..1f5a94d7f9 100644 --- a/crates/project_model/src/lib.rs +++ b/crates/project_model/src/lib.rs @@ -12,9 +12,9 @@ use std::{ }; use anyhow::{bail, Context, Result}; +use base_db::{CrateGraph, CrateId, CrateName, Edition, Env, FileId}; use cfg::CfgOptions; use paths::{AbsPath, AbsPathBuf}; -use ra_db::{CrateGraph, CrateId, CrateName, Edition, Env, FileId}; use rustc_hash::{FxHashMap, FxHashSet}; use crate::cfg_flag::CfgFlag; diff --git a/crates/project_model/src/project_json.rs b/crates/project_model/src/project_json.rs index e3f3163f6a..060ea5b7dc 100644 --- a/crates/project_model/src/project_json.rs +++ b/crates/project_model/src/project_json.rs @@ -2,8 +2,8 @@ use std::path::PathBuf; +use base_db::{CrateId, CrateName, Dependency, Edition}; use paths::{AbsPath, AbsPathBuf}; -use ra_db::{CrateId, CrateName, Dependency, Edition}; use rustc_hash::FxHashMap; use serde::{de, Deserialize}; diff --git a/crates/ra_assists/Cargo.toml b/crates/ra_assists/Cargo.toml index 83e44c1243..ebac09be62 100644 --- a/crates/ra_assists/Cargo.toml +++ b/crates/ra_assists/Cargo.toml @@ -18,7 +18,7 @@ stdx = { path = "../stdx" } syntax = { path = "../syntax" } text_edit = { path = "../text_edit" } profile = { path = "../profile" } -ra_db = { path = "../ra_db" } +base_db = { path = "../base_db" } ra_ide_db = { path = "../ra_ide_db" } hir = { path = "../ra_hir", package = "ra_hir" } test_utils = { path = "../test_utils" } diff --git a/crates/ra_assists/src/assist_context.rs b/crates/ra_assists/src/assist_context.rs index 368d48a712..2fdce037fb 100644 --- a/crates/ra_assists/src/assist_context.rs +++ b/crates/ra_assists/src/assist_context.rs @@ -3,8 +3,8 @@ use std::mem; use algo::find_covering_element; +use base_db::{FileId, FileRange}; use hir::Semantics; -use ra_db::{FileId, FileRange}; use ra_ide_db::{ source_change::{SourceChange, SourceFileEdit}, RootDatabase, diff --git a/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs b/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs index 497f887cd1..52fbc540eb 100644 --- a/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs +++ b/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs @@ -1,5 +1,5 @@ +use base_db::FileId; use hir::{EnumVariant, Module, ModuleDef, Name}; -use ra_db::FileId; use ra_ide_db::{defs::Definition, search::Reference, RootDatabase}; use rustc_hash::FxHashSet; use syntax::{ diff --git a/crates/ra_assists/src/handlers/fix_visibility.rs b/crates/ra_assists/src/handlers/fix_visibility.rs index b6cc1a3204..7cd76ea065 100644 --- a/crates/ra_assists/src/handlers/fix_visibility.rs +++ b/crates/ra_assists/src/handlers/fix_visibility.rs @@ -1,5 +1,5 @@ +use base_db::FileId; use hir::{db::HirDatabase, HasSource, HasVisibility, PathResolution}; -use ra_db::FileId; use syntax::{ast, AstNode, TextRange, TextSize}; use crate::{utils::vis_offset, AssistContext, AssistId, AssistKind, Assists}; diff --git a/crates/ra_assists/src/handlers/generate_function.rs b/crates/ra_assists/src/handlers/generate_function.rs index b5df441019..b38d640581 100644 --- a/crates/ra_assists/src/handlers/generate_function.rs +++ b/crates/ra_assists/src/handlers/generate_function.rs @@ -1,5 +1,5 @@ +use base_db::FileId; use hir::HirDisplay; -use ra_db::FileId; use rustc_hash::{FxHashMap, FxHashSet}; use syntax::{ ast::{ diff --git a/crates/ra_assists/src/lib.rs b/crates/ra_assists/src/lib.rs index e2ef561fee..5d062b88b8 100644 --- a/crates/ra_assists/src/lib.rs +++ b/crates/ra_assists/src/lib.rs @@ -17,8 +17,8 @@ mod tests; pub mod utils; pub mod ast_transform; +use base_db::FileRange; use hir::Semantics; -use ra_db::FileRange; use ra_ide_db::{source_change::SourceChange, RootDatabase}; use syntax::TextRange; diff --git a/crates/ra_assists/src/tests.rs b/crates/ra_assists/src/tests.rs index 1ae7aaa09b..75d9736882 100644 --- a/crates/ra_assists/src/tests.rs +++ b/crates/ra_assists/src/tests.rs @@ -1,7 +1,7 @@ mod generated; +use base_db::{fixture::WithFixture, FileId, FileRange, SourceDatabaseExt}; use hir::Semantics; -use ra_db::{fixture::WithFixture, FileId, FileRange, SourceDatabaseExt}; use ra_ide_db::RootDatabase; use syntax::TextRange; use test_utils::{assert_eq_text, extract_offset, extract_range}; diff --git a/crates/ra_hir/Cargo.toml b/crates/ra_hir/Cargo.toml index ee5622a7d9..5ccdb74fd6 100644 --- a/crates/ra_hir/Cargo.toml +++ b/crates/ra_hir/Cargo.toml @@ -18,7 +18,7 @@ itertools = "0.9.0" stdx = { path = "../stdx" } syntax = { path = "../syntax" } -ra_db = { path = "../ra_db" } +base_db = { path = "../base_db" } profile = { path = "../profile" } hir_expand = { path = "../ra_hir_expand", package = "ra_hir_expand" } hir_def = { path = "../ra_hir_def", package = "ra_hir_def" } diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index 98724c1462..d4d6b1759c 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs @@ -2,6 +2,7 @@ use std::{iter, sync::Arc}; use arrayvec::ArrayVec; +use base_db::{CrateId, Edition, FileId}; use either::Either; use hir_def::{ adt::ReprKind, @@ -30,7 +31,6 @@ use hir_ty::{ method_resolution, ApplicationTy, CallableDefId, Canonical, FnSig, GenericPredicate, InEnvironment, Substs, TraitEnvironment, Ty, TyDefId, TypeCtor, }; -use ra_db::{CrateId, Edition, FileId}; use rustc_hash::FxHashSet; use stdx::impl_from; use syntax::{ diff --git a/crates/ra_hir/src/from_id.rs b/crates/ra_hir/src/from_id.rs index 679ae81215..a53ac1e080 100644 --- a/crates/ra_hir/src/from_id.rs +++ b/crates/ra_hir/src/from_id.rs @@ -29,7 +29,7 @@ macro_rules! from_id { } from_id![ - (ra_db::CrateId, crate::Crate), + (base_db::CrateId, crate::Crate), (hir_def::ModuleId, crate::Module), (hir_def::StructId, crate::Struct), (hir_def::UnionId, crate::Union), diff --git a/crates/ra_hir/src/semantics.rs b/crates/ra_hir/src/semantics.rs index 2e0ef44085..1467d825d9 100644 --- a/crates/ra_hir/src/semantics.rs +++ b/crates/ra_hir/src/semantics.rs @@ -4,6 +4,7 @@ mod source_to_def; use std::{cell::RefCell, fmt, iter::successors}; +use base_db::{FileId, FileRange}; use hir_def::{ resolver::{self, HasResolver, Resolver}, AsMacroCall, FunctionId, TraitId, VariantId, @@ -11,7 +12,6 @@ use hir_def::{ use hir_expand::{hygiene::Hygiene, name::AsName, ExpansionInfo}; use hir_ty::associated_type_shorthand_candidates; use itertools::Itertools; -use ra_db::{FileId, FileRange}; use rustc_hash::{FxHashMap, FxHashSet}; use syntax::{ algo::{find_node_at_offset, skip_trivia_token}, diff --git a/crates/ra_hir/src/semantics/source_to_def.rs b/crates/ra_hir/src/semantics/source_to_def.rs index ab2fd0957f..5918b9541b 100644 --- a/crates/ra_hir/src/semantics/source_to_def.rs +++ b/crates/ra_hir/src/semantics/source_to_def.rs @@ -1,5 +1,6 @@ //! Maps *syntax* of various definitions to their semantic ids. +use base_db::FileId; use hir_def::{ child_by_source::ChildBySource, dyn_map::DynMap, @@ -9,7 +10,6 @@ use hir_def::{ ModuleId, StaticId, StructId, TraitId, TypeAliasId, TypeParamId, UnionId, VariantId, }; use hir_expand::{name::AsName, AstId, MacroDefKind}; -use ra_db::FileId; use rustc_hash::FxHashMap; use stdx::impl_from; use syntax::{ diff --git a/crates/ra_hir/src/source_analyzer.rs b/crates/ra_hir/src/source_analyzer.rs index 6b2de3a06f..8750584f94 100644 --- a/crates/ra_hir/src/source_analyzer.rs +++ b/crates/ra_hir/src/source_analyzer.rs @@ -31,7 +31,7 @@ use crate::{ MacroDef, ModPath, ModuleDef, Path, PathKind, Static, Struct, Trait, Type, TypeAlias, TypeParam, }; -use ra_db::CrateId; +use base_db::CrateId; /// `SourceAnalyzer` is a convenience wrapper which exposes HIR API in terms of /// original source files. It should not be used inside the HIR itself. diff --git a/crates/ra_hir_def/Cargo.toml b/crates/ra_hir_def/Cargo.toml index e7d3c4d5be..2b187bc4a0 100644 --- a/crates/ra_hir_def/Cargo.toml +++ b/crates/ra_hir_def/Cargo.toml @@ -23,7 +23,7 @@ smallvec = "1.4.0" stdx = { path = "../stdx" } arena = { path = "../arena" } -ra_db = { path = "../ra_db" } +base_db = { path = "../base_db" } syntax = { path = "../syntax" } profile = { path = "../profile" } hir_expand = { path = "../ra_hir_expand", package = "ra_hir_expand" } diff --git a/crates/ra_hir_def/src/body.rs b/crates/ra_hir_def/src/body.rs index fe659386a3..9a9a605ddb 100644 --- a/crates/ra_hir_def/src/body.rs +++ b/crates/ra_hir_def/src/body.rs @@ -6,11 +6,11 @@ pub mod scope; use std::{mem, ops::Index, sync::Arc}; use arena::{map::ArenaMap, Arena}; +use base_db::CrateId; use cfg::CfgOptions; use drop_bomb::DropBomb; use either::Either; use hir_expand::{ast_id_map::AstIdMap, hygiene::Hygiene, AstId, HirFileId, InFile, MacroDefId}; -use ra_db::CrateId; use rustc_hash::FxHashMap; use syntax::{ast, AstNode, AstPtr}; use test_utils::mark; @@ -320,7 +320,7 @@ impl BodySourceMap { #[cfg(test)] mod tests { - use ra_db::{fixture::WithFixture, SourceDatabase}; + use base_db::{fixture::WithFixture, SourceDatabase}; use test_utils::mark; use crate::ModuleDefId; diff --git a/crates/ra_hir_def/src/body/scope.rs b/crates/ra_hir_def/src/body/scope.rs index 079f14c298..9142bc05b8 100644 --- a/crates/ra_hir_def/src/body/scope.rs +++ b/crates/ra_hir_def/src/body/scope.rs @@ -169,8 +169,8 @@ fn compute_expr_scopes(expr: ExprId, body: &Body, scopes: &mut ExprScopes, scope #[cfg(test)] mod tests { + use base_db::{fixture::WithFixture, FileId, SourceDatabase}; use hir_expand::{name::AsName, InFile}; - use ra_db::{fixture::WithFixture, FileId, SourceDatabase}; use syntax::{algo::find_node_at_offset, ast, AstNode}; use test_utils::{assert_eq_text, extract_offset, mark}; diff --git a/crates/ra_hir_def/src/db.rs b/crates/ra_hir_def/src/db.rs index a925548b58..6d694de115 100644 --- a/crates/ra_hir_def/src/db.rs +++ b/crates/ra_hir_def/src/db.rs @@ -1,8 +1,8 @@ //! Defines database & queries for name resolution. use std::sync::Arc; +use base_db::{salsa, CrateId, SourceDatabase, Upcast}; use hir_expand::{db::AstDatabase, HirFileId}; -use ra_db::{salsa, CrateId, SourceDatabase, Upcast}; use syntax::SmolStr; use crate::{ diff --git a/crates/ra_hir_def/src/find_path.rs b/crates/ra_hir_def/src/find_path.rs index 5099f417d3..ac2c54ac53 100644 --- a/crates/ra_hir_def/src/find_path.rs +++ b/crates/ra_hir_def/src/find_path.rs @@ -292,8 +292,8 @@ fn find_local_import_locations( #[cfg(test)] mod tests { + use base_db::fixture::WithFixture; use hir_expand::hygiene::Hygiene; - use ra_db::fixture::WithFixture; use syntax::ast::AstNode; use test_utils::mark; diff --git a/crates/ra_hir_def/src/generics.rs b/crates/ra_hir_def/src/generics.rs index 4476f03162..835fe3fbdc 100644 --- a/crates/ra_hir_def/src/generics.rs +++ b/crates/ra_hir_def/src/generics.rs @@ -5,12 +5,12 @@ use std::sync::Arc; use arena::{map::ArenaMap, Arena}; +use base_db::FileId; use either::Either; use hir_expand::{ name::{name, AsName, Name}, InFile, }; -use ra_db::FileId; use syntax::ast::{self, GenericParamsOwner, NameOwner, TypeBoundsOwner}; use crate::{ diff --git a/crates/ra_hir_def/src/import_map.rs b/crates/ra_hir_def/src/import_map.rs index 431ff30abd..d32a0bdaf2 100644 --- a/crates/ra_hir_def/src/import_map.rs +++ b/crates/ra_hir_def/src/import_map.rs @@ -2,9 +2,9 @@ use std::{cmp::Ordering, fmt, hash::BuildHasherDefault, sync::Arc}; +use base_db::CrateId; use fst::{self, Streamer}; use indexmap::{map::Entry, IndexMap}; -use ra_db::CrateId; use rustc_hash::{FxHashMap, FxHasher}; use smallvec::SmallVec; use syntax::SmolStr; @@ -327,8 +327,8 @@ pub fn search_dependencies<'a>( #[cfg(test)] mod tests { + use base_db::{fixture::WithFixture, SourceDatabase, Upcast}; use expect::{expect, Expect}; - use ra_db::{fixture::WithFixture, SourceDatabase, Upcast}; use crate::{test_db::TestDB, AssocContainerId, Lookup}; diff --git a/crates/ra_hir_def/src/item_scope.rs b/crates/ra_hir_def/src/item_scope.rs index 8fee4b15e5..f1e9dfd5b1 100644 --- a/crates/ra_hir_def/src/item_scope.rs +++ b/crates/ra_hir_def/src/item_scope.rs @@ -3,9 +3,9 @@ use std::collections::hash_map::Entry; +use base_db::CrateId; use hir_expand::name::Name; use once_cell::sync::Lazy; -use ra_db::CrateId; use rustc_hash::{FxHashMap, FxHashSet}; use test_utils::mark; diff --git a/crates/ra_hir_def/src/item_tree/tests.rs b/crates/ra_hir_def/src/item_tree/tests.rs index 6c843e339a..2f62eddcba 100644 --- a/crates/ra_hir_def/src/item_tree/tests.rs +++ b/crates/ra_hir_def/src/item_tree/tests.rs @@ -1,6 +1,6 @@ +use base_db::fixture::WithFixture; use expect::{expect, Expect}; use hir_expand::{db::AstDatabase, HirFileId, InFile}; -use ra_db::fixture::WithFixture; use rustc_hash::FxHashSet; use std::sync::Arc; use stdx::format_to; diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs index 806ac731f5..f24a1dd77c 100644 --- a/crates/ra_hir_def/src/lib.rs +++ b/crates/ra_hir_def/src/lib.rs @@ -53,11 +53,11 @@ mod test_db; use std::hash::{Hash, Hasher}; use arena::Idx; +use base_db::{impl_intern_key, salsa, CrateId}; use hir_expand::{ ast_id_map::FileAstId, eager::expand_eager_macro, hygiene::Hygiene, AstId, HirFileId, InFile, MacroCallId, MacroCallKind, MacroDefId, MacroDefKind, }; -use ra_db::{impl_intern_key, salsa, CrateId}; use syntax::ast; use crate::builtin_type::BuiltinType; diff --git a/crates/ra_hir_def/src/nameres.rs b/crates/ra_hir_def/src/nameres.rs index d26c837cc8..bf302172d0 100644 --- a/crates/ra_hir_def/src/nameres.rs +++ b/crates/ra_hir_def/src/nameres.rs @@ -57,8 +57,8 @@ mod tests; use std::sync::Arc; use arena::Arena; +use base_db::{CrateId, Edition, FileId}; use hir_expand::{diagnostics::DiagnosticSink, name::Name, InFile}; -use ra_db::{CrateId, Edition, FileId}; use rustc_hash::FxHashMap; use stdx::format_to; use syntax::ast; diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs index 6a58919360..3e99c87737 100644 --- a/crates/ra_hir_def/src/nameres/collector.rs +++ b/crates/ra_hir_def/src/nameres/collector.rs @@ -3,6 +3,7 @@ //! `DefCollector::collect` contains the fixed-point iteration loop which //! resolves imports and expands macros. +use base_db::{CrateId, FileId, ProcMacroId}; use cfg::CfgOptions; use hir_expand::{ ast_id_map::FileAstId, @@ -12,7 +13,6 @@ use hir_expand::{ proc_macro::ProcMacroExpander, HirFileId, MacroCallId, MacroDefId, MacroDefKind, }; -use ra_db::{CrateId, FileId, ProcMacroId}; use rustc_hash::FxHashMap; use syntax::ast; use test_utils::mark; @@ -1209,7 +1209,7 @@ fn is_macro_rules(path: &ModPath) -> bool { mod tests { use crate::{db::DefDatabase, test_db::TestDB}; use arena::Arena; - use ra_db::{fixture::WithFixture, SourceDatabase}; + use base_db::{fixture::WithFixture, SourceDatabase}; use super::*; diff --git a/crates/ra_hir_def/src/nameres/mod_resolution.rs b/crates/ra_hir_def/src/nameres/mod_resolution.rs index 316245d6ba..e8389b4846 100644 --- a/crates/ra_hir_def/src/nameres/mod_resolution.rs +++ b/crates/ra_hir_def/src/nameres/mod_resolution.rs @@ -1,6 +1,6 @@ //! This module resolves `mod foo;` declaration to file. +use base_db::FileId; use hir_expand::name::Name; -use ra_db::FileId; use syntax::SmolStr; use crate::{db::DefDatabase, HirFileId}; diff --git a/crates/ra_hir_def/src/nameres/path_resolution.rs b/crates/ra_hir_def/src/nameres/path_resolution.rs index dbfa7fccb4..88e10574ef 100644 --- a/crates/ra_hir_def/src/nameres/path_resolution.rs +++ b/crates/ra_hir_def/src/nameres/path_resolution.rs @@ -12,8 +12,8 @@ use std::iter::successors; +use base_db::Edition; use hir_expand::name::Name; -use ra_db::Edition; use test_utils::mark; use crate::{ diff --git a/crates/ra_hir_def/src/nameres/tests.rs b/crates/ra_hir_def/src/nameres/tests.rs index 839b1de578..b105d56b24 100644 --- a/crates/ra_hir_def/src/nameres/tests.rs +++ b/crates/ra_hir_def/src/nameres/tests.rs @@ -6,8 +6,8 @@ mod primitives; use std::sync::Arc; +use base_db::{fixture::WithFixture, SourceDatabase}; use expect::{expect, Expect}; -use ra_db::{fixture::WithFixture, SourceDatabase}; use test_utils::mark; use crate::{db::DefDatabase, nameres::*, test_db::TestDB}; diff --git a/crates/ra_hir_def/src/nameres/tests/incremental.rs b/crates/ra_hir_def/src/nameres/tests/incremental.rs index 0c288a1085..cfbc62cc43 100644 --- a/crates/ra_hir_def/src/nameres/tests/incremental.rs +++ b/crates/ra_hir_def/src/nameres/tests/incremental.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use ra_db::SourceDatabaseExt; +use base_db::SourceDatabaseExt; use super::*; diff --git a/crates/ra_hir_def/src/path.rs b/crates/ra_hir_def/src/path.rs index 88be07c8a7..74d26f08b3 100644 --- a/crates/ra_hir_def/src/path.rs +++ b/crates/ra_hir_def/src/path.rs @@ -8,11 +8,11 @@ use std::{ }; use crate::body::LowerCtx; +use base_db::CrateId; use hir_expand::{ hygiene::Hygiene, name::{AsName, Name}, }; -use ra_db::CrateId; use syntax::ast; use crate::{ diff --git a/crates/ra_hir_def/src/resolver.rs b/crates/ra_hir_def/src/resolver.rs index 0bf51eb7b8..f8cc5e075e 100644 --- a/crates/ra_hir_def/src/resolver.rs +++ b/crates/ra_hir_def/src/resolver.rs @@ -1,11 +1,11 @@ //! Name resolution façade. use std::sync::Arc; +use base_db::CrateId; use hir_expand::{ name::{name, Name}, MacroDefId, }; -use ra_db::CrateId; use rustc_hash::FxHashSet; use crate::{ diff --git a/crates/ra_hir_def/src/test_db.rs b/crates/ra_hir_def/src/test_db.rs index 339f819b8b..42a762936d 100644 --- a/crates/ra_hir_def/src/test_db.rs +++ b/crates/ra_hir_def/src/test_db.rs @@ -5,15 +5,15 @@ use std::{ sync::{Arc, Mutex}, }; +use base_db::{salsa, CrateId, FileId, FileLoader, FileLoaderDelegate, Upcast}; use hir_expand::db::AstDatabase; -use ra_db::{salsa, CrateId, FileId, FileLoader, FileLoaderDelegate, Upcast}; use rustc_hash::FxHashSet; use crate::db::DefDatabase; #[salsa::database( - ra_db::SourceDatabaseExtStorage, - ra_db::SourceDatabaseStorage, + base_db::SourceDatabaseExtStorage, + base_db::SourceDatabaseStorage, hir_expand::db::AstDatabaseStorage, crate::db::InternDatabaseStorage, crate::db::DefDatabaseStorage diff --git a/crates/ra_hir_expand/Cargo.toml b/crates/ra_hir_expand/Cargo.toml index cbb0ac29b8..41acf37122 100644 --- a/crates/ra_hir_expand/Cargo.toml +++ b/crates/ra_hir_expand/Cargo.toml @@ -14,7 +14,7 @@ either = "1.5.3" rustc-hash = "1.0.0" arena = { path = "../arena" } -ra_db = { path = "../ra_db" } +base_db = { path = "../base_db" } syntax = { path = "../syntax" } parser = { path = "../parser" } profile = { path = "../profile" } diff --git a/crates/ra_hir_expand/src/builtin_derive.rs b/crates/ra_hir_expand/src/builtin_derive.rs index 2d2f8bcb84..988a60d56a 100644 --- a/crates/ra_hir_expand/src/builtin_derive.rs +++ b/crates/ra_hir_expand/src/builtin_derive.rs @@ -253,8 +253,8 @@ fn partial_ord_expand( #[cfg(test)] mod tests { + use base_db::{fixture::WithFixture, CrateId, SourceDatabase}; use name::{known, Name}; - use ra_db::{fixture::WithFixture, CrateId, SourceDatabase}; use crate::{test_db::TestDB, AstId, MacroCallId, MacroCallKind, MacroCallLoc}; diff --git a/crates/ra_hir_expand/src/builtin_macro.rs b/crates/ra_hir_expand/src/builtin_macro.rs index ae4c843820..86918b6269 100644 --- a/crates/ra_hir_expand/src/builtin_macro.rs +++ b/crates/ra_hir_expand/src/builtin_macro.rs @@ -4,10 +4,10 @@ use crate::{ MacroDefId, MacroDefKind, TextSize, }; +use base_db::FileId; use either::Either; use mbe::parse_to_token_tree; use parser::FragmentKind; -use ra_db::FileId; use syntax::ast::{self, AstToken, HasStringValue}; macro_rules! register_builtin { @@ -426,7 +426,7 @@ mod tests { name::AsName, test_db::TestDB, AstNode, EagerCallLoc, MacroCallId, MacroCallKind, MacroCallLoc, }; - use ra_db::{fixture::WithFixture, SourceDatabase}; + use base_db::{fixture::WithFixture, SourceDatabase}; use std::sync::Arc; use syntax::ast::NameOwner; diff --git a/crates/ra_hir_expand/src/db.rs b/crates/ra_hir_expand/src/db.rs index c275f6b017..dcc038bcd8 100644 --- a/crates/ra_hir_expand/src/db.rs +++ b/crates/ra_hir_expand/src/db.rs @@ -2,9 +2,9 @@ use std::sync::Arc; +use base_db::{salsa, SourceDatabase}; use mbe::{ExpandResult, MacroRules}; use parser::FragmentKind; -use ra_db::{salsa, SourceDatabase}; use syntax::{algo::diff, AstNode, GreenNode, Parse, SyntaxKind::*, SyntaxNode}; use crate::{ diff --git a/crates/ra_hir_expand/src/eager.rs b/crates/ra_hir_expand/src/eager.rs index bd3409f973..10c45646f0 100644 --- a/crates/ra_hir_expand/src/eager.rs +++ b/crates/ra_hir_expand/src/eager.rs @@ -25,8 +25,8 @@ use crate::{ EagerCallLoc, EagerMacroId, InFile, MacroCallId, MacroCallKind, MacroDefId, MacroDefKind, }; +use base_db::CrateId; use parser::FragmentKind; -use ra_db::CrateId; use std::sync::Arc; use syntax::{algo::SyntaxRewriter, SyntaxNode}; diff --git a/crates/ra_hir_expand/src/hygiene.rs b/crates/ra_hir_expand/src/hygiene.rs index 23b5eac270..845e9cbc19 100644 --- a/crates/ra_hir_expand/src/hygiene.rs +++ b/crates/ra_hir_expand/src/hygiene.rs @@ -2,8 +2,8 @@ //! //! Specifically, `ast` + `Hygiene` allows you to create a `Name`. Note that, at //! this moment, this is horribly incomplete and handles only `$crate`. +use base_db::CrateId; use either::Either; -use ra_db::CrateId; use syntax::ast; use crate::{ diff --git a/crates/ra_hir_expand/src/lib.rs b/crates/ra_hir_expand/src/lib.rs index af0cc445f7..7425b561ac 100644 --- a/crates/ra_hir_expand/src/lib.rs +++ b/crates/ra_hir_expand/src/lib.rs @@ -18,7 +18,7 @@ pub mod eager; use std::hash::Hash; use std::sync::Arc; -use ra_db::{impl_intern_key, salsa, CrateId, FileId}; +use base_db::{impl_intern_key, salsa, CrateId, FileId}; use syntax::{ algo, ast::{self, AstNode}, diff --git a/crates/ra_hir_expand/src/name.rs b/crates/ra_hir_expand/src/name.rs index 4dcaff0885..49841c7a12 100644 --- a/crates/ra_hir_expand/src/name.rs +++ b/crates/ra_hir_expand/src/name.rs @@ -115,7 +115,7 @@ impl AsName for ast::FieldKind { } } -impl AsName for ra_db::Dependency { +impl AsName for base_db::Dependency { fn as_name(&self) -> Name { Name::new_text(SmolStr::new(&*self.name)) } diff --git a/crates/ra_hir_expand/src/proc_macro.rs b/crates/ra_hir_expand/src/proc_macro.rs index 2c0ec41d24..80255ea327 100644 --- a/crates/ra_hir_expand/src/proc_macro.rs +++ b/crates/ra_hir_expand/src/proc_macro.rs @@ -1,7 +1,7 @@ //! Proc Macro Expander stub use crate::{db::AstDatabase, LazyMacroId}; -use ra_db::{CrateId, ProcMacroId}; +use base_db::{CrateId, ProcMacroId}; use tt::buffer::{Cursor, TokenBuffer}; #[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)] diff --git a/crates/ra_hir_expand/src/test_db.rs b/crates/ra_hir_expand/src/test_db.rs index 332fa556fa..86a5d867e6 100644 --- a/crates/ra_hir_expand/src/test_db.rs +++ b/crates/ra_hir_expand/src/test_db.rs @@ -5,12 +5,12 @@ use std::{ sync::{Arc, Mutex}, }; -use ra_db::{salsa, CrateId, FileId, FileLoader, FileLoaderDelegate}; +use base_db::{salsa, CrateId, FileId, FileLoader, FileLoaderDelegate}; use rustc_hash::FxHashSet; #[salsa::database( - ra_db::SourceDatabaseExtStorage, - ra_db::SourceDatabaseStorage, + base_db::SourceDatabaseExtStorage, + base_db::SourceDatabaseStorage, crate::db::AstDatabaseStorage )] #[derive(Default)] diff --git a/crates/ra_hir_ty/Cargo.toml b/crates/ra_hir_ty/Cargo.toml index 6156e4a854..720d171aca 100644 --- a/crates/ra_hir_ty/Cargo.toml +++ b/crates/ra_hir_ty/Cargo.toml @@ -21,7 +21,7 @@ stdx = { path = "../stdx" } hir_def = { path = "../ra_hir_def", package = "ra_hir_def" } hir_expand = { path = "../ra_hir_expand", package = "ra_hir_expand" } arena = { path = "../arena" } -ra_db = { path = "../ra_db" } +base_db = { path = "../base_db" } profile = { path = "../profile" } syntax = { path = "../syntax" } test_utils = { path = "../test_utils" } diff --git a/crates/ra_hir_ty/src/autoderef.rs b/crates/ra_hir_ty/src/autoderef.rs index c727012c69..ece68183e7 100644 --- a/crates/ra_hir_ty/src/autoderef.rs +++ b/crates/ra_hir_ty/src/autoderef.rs @@ -5,10 +5,10 @@ use std::iter::successors; +use base_db::CrateId; use hir_def::lang_item::LangItemTarget; use hir_expand::name::name; use log::{info, warn}; -use ra_db::CrateId; use crate::{ db::HirDatabase, diff --git a/crates/ra_hir_ty/src/db.rs b/crates/ra_hir_ty/src/db.rs index 7a28673b16..25cf9eb7f1 100644 --- a/crates/ra_hir_ty/src/db.rs +++ b/crates/ra_hir_ty/src/db.rs @@ -3,11 +3,11 @@ use std::sync::Arc; use arena::map::ArenaMap; +use base_db::{impl_intern_key, salsa, CrateId, Upcast}; use hir_def::{ db::DefDatabase, expr::ExprId, DefWithBodyId, FunctionId, GenericDefId, ImplId, LocalFieldId, TypeParamId, VariantId, }; -use ra_db::{impl_intern_key, salsa, CrateId, Upcast}; use crate::{ method_resolution::{InherentImpls, TraitImpls}, diff --git a/crates/ra_hir_ty/src/diagnostics.rs b/crates/ra_hir_ty/src/diagnostics.rs index bf35d2d0ee..ae0cf8d09b 100644 --- a/crates/ra_hir_ty/src/diagnostics.rs +++ b/crates/ra_hir_ty/src/diagnostics.rs @@ -208,12 +208,12 @@ impl Diagnostic for MismatchedArgCount { #[cfg(test)] mod tests { + use base_db::{fixture::WithFixture, FileId, SourceDatabase, SourceDatabaseExt}; use hir_def::{db::DefDatabase, AssocItemId, ModuleDefId}; use hir_expand::{ db::AstDatabase, diagnostics::{Diagnostic, DiagnosticSinkBuilder}, }; - use ra_db::{fixture::WithFixture, FileId, SourceDatabase, SourceDatabaseExt}; use rustc_hash::FxHashMap; use syntax::{TextRange, TextSize}; diff --git a/crates/ra_hir_ty/src/lib.rs b/crates/ra_hir_ty/src/lib.rs index 7698cb0d4b..1e748476ac 100644 --- a/crates/ra_hir_ty/src/lib.rs +++ b/crates/ra_hir_ty/src/lib.rs @@ -26,6 +26,7 @@ mod test_db; use std::{iter, mem, ops::Deref, sync::Arc}; +use base_db::{salsa, CrateId}; use hir_def::{ expr::ExprId, type_ref::{Mutability, Rawness}, @@ -33,7 +34,6 @@ use hir_def::{ TypeParamId, }; use itertools::Itertools; -use ra_db::{salsa, CrateId}; use crate::{ db::HirDatabase, diff --git a/crates/ra_hir_ty/src/lower.rs b/crates/ra_hir_ty/src/lower.rs index 7b805fe7ae..cd574e983f 100644 --- a/crates/ra_hir_ty/src/lower.rs +++ b/crates/ra_hir_ty/src/lower.rs @@ -8,6 +8,7 @@ use std::{iter, sync::Arc}; use arena::map::ArenaMap; +use base_db::CrateId; use hir_def::{ adt::StructKind, builtin_type::BuiltinType, @@ -20,7 +21,6 @@ use hir_def::{ UnionId, VariantId, }; use hir_expand::name::Name; -use ra_db::CrateId; use smallvec::SmallVec; use stdx::impl_from; use test_utils::mark; diff --git a/crates/ra_hir_ty/src/method_resolution.rs b/crates/ra_hir_ty/src/method_resolution.rs index 3b3bee6a70..ec59145c70 100644 --- a/crates/ra_hir_ty/src/method_resolution.rs +++ b/crates/ra_hir_ty/src/method_resolution.rs @@ -5,6 +5,7 @@ use std::{iter, sync::Arc}; use arrayvec::ArrayVec; +use base_db::CrateId; use hir_def::{ builtin_type::{IntBitness, Signedness}, lang_item::LangItemTarget, @@ -12,7 +13,6 @@ use hir_def::{ AssocContainerId, AssocItemId, FunctionId, HasModule, ImplId, Lookup, TraitId, }; use hir_expand::name::Name; -use ra_db::CrateId; use rustc_hash::{FxHashMap, FxHashSet}; use super::Substs; diff --git a/crates/ra_hir_ty/src/test_db.rs b/crates/ra_hir_ty/src/test_db.rs index 0e2a69eec2..15b8435e92 100644 --- a/crates/ra_hir_ty/src/test_db.rs +++ b/crates/ra_hir_ty/src/test_db.rs @@ -5,16 +5,16 @@ use std::{ sync::{Arc, Mutex}, }; +use base_db::{salsa, CrateId, FileId, FileLoader, FileLoaderDelegate, SourceDatabase, Upcast}; use hir_def::{db::DefDatabase, ModuleId}; use hir_expand::db::AstDatabase; -use ra_db::{salsa, CrateId, FileId, FileLoader, FileLoaderDelegate, SourceDatabase, Upcast}; use rustc_hash::{FxHashMap, FxHashSet}; use syntax::TextRange; use test_utils::extract_annotations; #[salsa::database( - ra_db::SourceDatabaseExtStorage, - ra_db::SourceDatabaseStorage, + base_db::SourceDatabaseExtStorage, + base_db::SourceDatabaseStorage, hir_expand::db::AstDatabaseStorage, hir_def::db::InternDatabaseStorage, hir_def::db::DefDatabaseStorage, diff --git a/crates/ra_hir_ty/src/tests.rs b/crates/ra_hir_ty/src/tests.rs index 5f6f8869ae..f6b172c3af 100644 --- a/crates/ra_hir_ty/src/tests.rs +++ b/crates/ra_hir_ty/src/tests.rs @@ -10,6 +10,7 @@ mod display_source_code; use std::sync::Arc; +use base_db::{fixture::WithFixture, FileRange, SourceDatabase, SourceDatabaseExt}; use expect::Expect; use hir_def::{ body::{BodySourceMap, SyntheticSyntax}, @@ -21,7 +22,6 @@ use hir_def::{ AssocItemId, DefWithBodyId, LocalModuleId, Lookup, ModuleDefId, }; use hir_expand::{db::AstDatabase, InFile}; -use ra_db::{fixture::WithFixture, FileRange, SourceDatabase, SourceDatabaseExt}; use stdx::format_to; use syntax::{ algo, diff --git a/crates/ra_hir_ty/src/traits.rs b/crates/ra_hir_ty/src/traits.rs index 2576a9dfc3..2553237170 100644 --- a/crates/ra_hir_ty/src/traits.rs +++ b/crates/ra_hir_ty/src/traits.rs @@ -1,10 +1,10 @@ //! Trait solving using Chalk. use std::sync::Arc; +use base_db::CrateId; use chalk_ir::cast::Cast; use chalk_solve::Solver; use hir_def::{lang_item::LangItemTarget, TraitId}; -use ra_db::CrateId; use crate::{db::HirDatabase, DebruijnIndex, Substs}; diff --git a/crates/ra_hir_ty/src/traits/chalk.rs b/crates/ra_hir_ty/src/traits/chalk.rs index 3b6af5c9a8..b336534179 100644 --- a/crates/ra_hir_ty/src/traits/chalk.rs +++ b/crates/ra_hir_ty/src/traits/chalk.rs @@ -6,11 +6,11 @@ use log::debug; use chalk_ir::{fold::shift::Shift, CanonicalVarKinds, GenericArg, TypeName}; use chalk_solve::rust_ir::{self, OpaqueTyDatumBound, WellKnownTrait}; +use base_db::{salsa::InternKey, CrateId}; use hir_def::{ lang_item::{lang_attr, LangItemTarget}, AssocContainerId, AssocItemId, HasModule, Lookup, TypeAliasId, }; -use ra_db::{salsa::InternKey, CrateId}; use super::ChalkContext; use crate::{ diff --git a/crates/ra_hir_ty/src/traits/chalk/interner.rs b/crates/ra_hir_ty/src/traits/chalk/interner.rs index 8d4c51a8ff..fc0f9c2019 100644 --- a/crates/ra_hir_ty/src/traits/chalk/interner.rs +++ b/crates/ra_hir_ty/src/traits/chalk/interner.rs @@ -2,9 +2,9 @@ //! representation of the various objects Chalk deals with (types, goals etc.). use super::tls; +use base_db::salsa::InternId; use chalk_ir::{GenericArg, Goal, GoalData}; use hir_def::TypeAliasId; -use ra_db::salsa::InternId; use std::{fmt, sync::Arc}; #[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)] diff --git a/crates/ra_hir_ty/src/traits/chalk/mapping.rs b/crates/ra_hir_ty/src/traits/chalk/mapping.rs index b3e92993d2..fe62f3fa7c 100644 --- a/crates/ra_hir_ty/src/traits/chalk/mapping.rs +++ b/crates/ra_hir_ty/src/traits/chalk/mapping.rs @@ -9,8 +9,8 @@ use chalk_ir::{ }; use chalk_solve::rust_ir; +use base_db::salsa::InternKey; use hir_def::{type_ref::Mutability, AssocContainerId, GenericDefId, Lookup, TypeAliasId}; -use ra_db::salsa::InternKey; use crate::{ db::HirDatabase, diff --git a/crates/ra_ide/Cargo.toml b/crates/ra_ide/Cargo.toml index 938398a41a..1af51f3ae8 100644 --- a/crates/ra_ide/Cargo.toml +++ b/crates/ra_ide/Cargo.toml @@ -23,7 +23,7 @@ stdx = { path = "../stdx" } syntax = { path = "../syntax" } text_edit = { path = "../text_edit" } -ra_db = { path = "../ra_db" } +base_db = { path = "../base_db" } ra_ide_db = { path = "../ra_ide_db" } cfg = { path = "../cfg" } profile = { path = "../profile" } diff --git a/crates/ra_ide/src/call_hierarchy.rs b/crates/ra_ide/src/call_hierarchy.rs index 116e6bf83e..3578b8d3ce 100644 --- a/crates/ra_ide/src/call_hierarchy.rs +++ b/crates/ra_ide/src/call_hierarchy.rs @@ -137,7 +137,7 @@ impl CallLocations { #[cfg(test)] mod tests { - use ra_db::FilePosition; + use base_db::FilePosition; use crate::mock_analysis::analysis_and_position; diff --git a/crates/ra_ide/src/completion/completion_context.rs b/crates/ra_ide/src/completion/completion_context.rs index b5efb6cd67..0e0a201d09 100644 --- a/crates/ra_ide/src/completion/completion_context.rs +++ b/crates/ra_ide/src/completion/completion_context.rs @@ -1,7 +1,7 @@ //! FIXME: write short doc here +use base_db::SourceDatabase; use hir::{Semantics, SemanticsScope, Type}; -use ra_db::SourceDatabase; use ra_ide_db::RootDatabase; use syntax::{ algo::{find_covering_element, find_node_at_offset}, diff --git a/crates/ra_ide/src/diagnostics.rs b/crates/ra_ide/src/diagnostics.rs index 18def6115d..4e59e3a480 100644 --- a/crates/ra_ide/src/diagnostics.rs +++ b/crates/ra_ide/src/diagnostics.rs @@ -6,9 +6,9 @@ use std::cell::RefCell; +use base_db::SourceDatabase; use hir::{diagnostics::DiagnosticSinkBuilder, Semantics}; use itertools::Itertools; -use ra_db::SourceDatabase; use ra_ide_db::RootDatabase; use syntax::{ ast::{self, AstNode}, diff --git a/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs b/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs index efcd631b31..7e126d7a6a 100644 --- a/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs +++ b/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs @@ -2,12 +2,12 @@ //! The same module also has all curret custom fixes for the diagnostics implemented. use crate::Fix; use ast::{edit::IndentLevel, make}; +use base_db::FileId; use hir::{ db::AstDatabase, diagnostics::{Diagnostic, MissingFields, MissingOkInTailExpr, NoSuchField, UnresolvedModule}, HasSource, HirDisplay, Semantics, VariantDef, }; -use ra_db::FileId; use ra_ide_db::{ source_change::{FileSystemEdit, SourceFileEdit}, RootDatabase, diff --git a/crates/ra_ide/src/display/navigation_target.rs b/crates/ra_ide/src/display/navigation_target.rs index 683088a748..09ec3f65e6 100644 --- a/crates/ra_ide/src/display/navigation_target.rs +++ b/crates/ra_ide/src/display/navigation_target.rs @@ -1,8 +1,8 @@ //! FIXME: write short doc here +use base_db::{FileId, SourceDatabase}; use either::Either; use hir::{original_range, AssocItem, FieldSource, HasSource, InFile, ModuleSource}; -use ra_db::{FileId, SourceDatabase}; use ra_ide_db::{defs::Definition, RootDatabase}; use syntax::{ ast::{self, DocCommentsOwner, NameOwner}, diff --git a/crates/ra_ide/src/goto_definition.rs b/crates/ra_ide/src/goto_definition.rs index 77f374ea2a..b93d116bf8 100644 --- a/crates/ra_ide/src/goto_definition.rs +++ b/crates/ra_ide/src/goto_definition.rs @@ -100,7 +100,7 @@ pub(crate) fn reference_definition( #[cfg(test)] mod tests { - use ra_db::FileRange; + use base_db::FileRange; use syntax::{TextRange, TextSize}; use crate::mock_analysis::MockAnalysis; diff --git a/crates/ra_ide/src/goto_implementation.rs b/crates/ra_ide/src/goto_implementation.rs index 91a8c1dd17..6dc2ccfd05 100644 --- a/crates/ra_ide/src/goto_implementation.rs +++ b/crates/ra_ide/src/goto_implementation.rs @@ -74,7 +74,7 @@ fn impls_for_trait( #[cfg(test)] mod tests { - use ra_db::FileRange; + use base_db::FileRange; use crate::mock_analysis::MockAnalysis; diff --git a/crates/ra_ide/src/goto_type_definition.rs b/crates/ra_ide/src/goto_type_definition.rs index 3ec2ee59de..8017ca58cb 100644 --- a/crates/ra_ide/src/goto_type_definition.rs +++ b/crates/ra_ide/src/goto_type_definition.rs @@ -54,7 +54,7 @@ fn pick_best(tokens: TokenAtOffset) -> Option { #[cfg(test)] mod tests { - use ra_db::FileRange; + use base_db::FileRange; use crate::mock_analysis::MockAnalysis; diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs index 37e68ff7a5..a74087f87a 100644 --- a/crates/ra_ide/src/hover.rs +++ b/crates/ra_ide/src/hover.rs @@ -1,9 +1,9 @@ +use base_db::SourceDatabase; use hir::{ Adt, AsAssocItem, AssocItemContainer, Documentation, FieldSource, HasSource, HirDisplay, Module, ModuleDef, ModuleSource, Semantics, }; use itertools::Itertools; -use ra_db::SourceDatabase; use ra_ide_db::{ defs::{classify_name, classify_name_ref, Definition}, RootDatabase, @@ -352,8 +352,8 @@ fn pick_best(tokens: TokenAtOffset) -> Option { #[cfg(test)] mod tests { + use base_db::FileLoader; use expect::{expect, Expect}; - use ra_db::FileLoader; use crate::mock_analysis::analysis_and_position; diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs index 1fdf17800d..789fbdaf23 100644 --- a/crates/ra_ide/src/lib.rs +++ b/crates/ra_ide/src/lib.rs @@ -47,11 +47,11 @@ mod typing; use std::sync::Arc; -use cfg::CfgOptions; -use ra_db::{ +use base_db::{ salsa::{self, ParallelDatabase}, CheckCanceled, Env, FileLoader, FileSet, SourceDatabase, VfsPath, }; +use cfg::CfgOptions; use ra_ide_db::{ symbol_index::{self, FileSymbol}, LineIndexDatabase, @@ -81,12 +81,12 @@ pub use crate::{ }, }; -pub use hir::{Documentation, Semantics}; -pub use ra_assists::{Assist, AssistConfig, AssistId, AssistKind, ResolvedAssist}; -pub use ra_db::{ +pub use base_db::{ Canceled, CrateGraph, CrateId, Edition, FileId, FilePosition, FileRange, SourceRoot, SourceRootId, }; +pub use hir::{Documentation, Semantics}; +pub use ra_assists::{Assist, AssistConfig, AssistId, AssistKind, ResolvedAssist}; pub use ra_ide_db::{ change::AnalysisChange, line_index::{LineCol, LineIndex}, diff --git a/crates/ra_ide/src/mock_analysis.rs b/crates/ra_ide/src/mock_analysis.rs index a4691f0284..363e6d27e5 100644 --- a/crates/ra_ide/src/mock_analysis.rs +++ b/crates/ra_ide/src/mock_analysis.rs @@ -1,8 +1,8 @@ //! FIXME: write short doc here use std::sync::Arc; +use base_db::{CrateName, FileSet, SourceRoot, VfsPath}; use cfg::CfgOptions; -use ra_db::{CrateName, FileSet, SourceRoot, VfsPath}; use test_utils::{ extract_annotations, extract_range_or_offset, Fixture, RangeOrOffset, CURSOR_MARKER, }; diff --git a/crates/ra_ide/src/parent_module.rs b/crates/ra_ide/src/parent_module.rs index b78388e6b1..8439e1d5d3 100644 --- a/crates/ra_ide/src/parent_module.rs +++ b/crates/ra_ide/src/parent_module.rs @@ -1,5 +1,5 @@ +use base_db::{CrateId, FileId, FilePosition}; use hir::Semantics; -use ra_db::{CrateId, FileId, FilePosition}; use ra_ide_db::RootDatabase; use syntax::{ algo::find_node_at_offset, @@ -63,8 +63,8 @@ pub(crate) fn crate_for(db: &RootDatabase, file_id: FileId) -> Vec { #[cfg(test)] mod tests { + use base_db::Env; use cfg::CfgOptions; - use ra_db::Env; use test_utils::mark; use crate::{ diff --git a/crates/ra_ide/src/references/rename.rs b/crates/ra_ide/src/references/rename.rs index a075618e74..5697b9d879 100644 --- a/crates/ra_ide/src/references/rename.rs +++ b/crates/ra_ide/src/references/rename.rs @@ -1,7 +1,7 @@ //! FIXME: write short doc here +use base_db::SourceDatabaseExt; use hir::{Module, ModuleDef, ModuleSource, Semantics}; -use ra_db::SourceDatabaseExt; use ra_ide_db::{ defs::{classify_name, classify_name_ref, Definition, NameClass, NameRefClass}, RootDatabase, diff --git a/crates/ra_ide/src/ssr.rs b/crates/ra_ide/src/ssr.rs index 8be862fd6e..97b82b70e5 100644 --- a/crates/ra_ide/src/ssr.rs +++ b/crates/ra_ide/src/ssr.rs @@ -1,4 +1,4 @@ -use ra_db::{FilePosition, FileRange}; +use base_db::{FilePosition, FileRange}; use ra_ide_db::RootDatabase; use crate::SourceFileEdit; diff --git a/crates/ra_ide/src/status.rs b/crates/ra_ide/src/status.rs index 797ead1ada..869c74accc 100644 --- a/crates/ra_ide/src/status.rs +++ b/crates/ra_ide/src/status.rs @@ -1,11 +1,11 @@ use std::{fmt, iter::FromIterator, sync::Arc}; -use hir::MacroFile; -use profile::{memory_usage, Bytes}; -use ra_db::{ +use base_db::{ salsa::debug::{DebugQueryTable, TableEntry}, FileTextQuery, SourceRootId, }; +use hir::MacroFile; +use profile::{memory_usage, Bytes}; use ra_ide_db::{ symbol_index::{LibrarySymbolsQuery, SymbolIndex}, RootDatabase, @@ -16,7 +16,7 @@ use syntax::{ast, Parse, SyntaxNode}; use crate::FileId; fn syntax_tree_stats(db: &RootDatabase) -> SyntaxTreeStats { - ra_db::ParseQuery.in_db(db).entries::() + base_db::ParseQuery.in_db(db).entries::() } fn macro_syntax_tree_stats(db: &RootDatabase) -> SyntaxTreeStats { hir::db::ParseMacroQuery.in_db(db).entries::() diff --git a/crates/ra_ide/src/syntax_highlighting/html.rs b/crates/ra_ide/src/syntax_highlighting/html.rs index 418122648a..249368ff81 100644 --- a/crates/ra_ide/src/syntax_highlighting/html.rs +++ b/crates/ra_ide/src/syntax_highlighting/html.rs @@ -1,7 +1,7 @@ //! Renders a bit of code as HTML. +use base_db::SourceDatabase; use oorandom::Rand32; -use ra_db::SourceDatabase; use syntax::{AstNode, TextRange, TextSize}; use crate::{syntax_highlighting::highlight, FileId, RootDatabase}; diff --git a/crates/ra_ide/src/syntax_tree.rs b/crates/ra_ide/src/syntax_tree.rs index d05ff22149..17daf06b66 100644 --- a/crates/ra_ide/src/syntax_tree.rs +++ b/crates/ra_ide/src/syntax_tree.rs @@ -1,4 +1,4 @@ -use ra_db::{FileId, SourceDatabase}; +use base_db::{FileId, SourceDatabase}; use ra_ide_db::RootDatabase; use syntax::{ algo, AstNode, NodeOrToken, SourceFile, diff --git a/crates/ra_ide/src/typing.rs b/crates/ra_ide/src/typing.rs index 7897c57b77..75f2a6b605 100644 --- a/crates/ra_ide/src/typing.rs +++ b/crates/ra_ide/src/typing.rs @@ -15,7 +15,7 @@ mod on_enter; -use ra_db::{FilePosition, SourceDatabase}; +use base_db::{FilePosition, SourceDatabase}; use ra_ide_db::{source_change::SourceFileEdit, RootDatabase}; use syntax::{ algo::find_node_at_offset, diff --git a/crates/ra_ide/src/typing/on_enter.rs b/crates/ra_ide/src/typing/on_enter.rs index 9cd153f94a..1939306590 100644 --- a/crates/ra_ide/src/typing/on_enter.rs +++ b/crates/ra_ide/src/typing/on_enter.rs @@ -1,7 +1,7 @@ //! Handles the `Enter` key press. At the momently, this only continues //! comments, but should handle indent some time in the future as well. -use ra_db::{FilePosition, SourceDatabase}; +use base_db::{FilePosition, SourceDatabase}; use ra_ide_db::RootDatabase; use syntax::{ ast::{self, AstToken}, diff --git a/crates/ra_ide_db/Cargo.toml b/crates/ra_ide_db/Cargo.toml index 9ed13a13db..0cda7090d3 100644 --- a/crates/ra_ide_db/Cargo.toml +++ b/crates/ra_ide_db/Cargo.toml @@ -23,7 +23,7 @@ stdx = { path = "../stdx" } syntax = { path = "../syntax" } text_edit = { path = "../text_edit" } -ra_db = { path = "../ra_db" } +base_db = { path = "../base_db" } profile = { path = "../profile" } test_utils = { path = "../test_utils" } diff --git a/crates/ra_ide_db/src/change.rs b/crates/ra_ide_db/src/change.rs index 7a4e04ca9b..8b4fd7ab84 100644 --- a/crates/ra_ide_db/src/change.rs +++ b/crates/ra_ide_db/src/change.rs @@ -3,11 +3,11 @@ use std::{fmt, sync::Arc, time}; -use profile::{memory_usage, Bytes}; -use ra_db::{ +use base_db::{ salsa::{Database, Durability, SweepStrategy}, CrateGraph, FileId, SourceDatabase, SourceDatabaseExt, SourceRoot, SourceRootId, }; +use profile::{memory_usage, Bytes}; use rustc_hash::FxHashSet; use crate::{symbol_index::SymbolsDatabase, RootDatabase}; @@ -146,7 +146,7 @@ impl RootDatabase { let sweep = SweepStrategy::default().discard_values().sweep_all_revisions(); - ra_db::ParseQuery.in_db(self).sweep(sweep); + base_db::ParseQuery.in_db(self).sweep(sweep); hir::db::ParseMacroQuery.in_db(self).sweep(sweep); // Macros do take significant space, but less then the syntax trees @@ -201,14 +201,14 @@ impl RootDatabase { } sweep_each_query![ // SourceDatabase - ra_db::ParseQuery - ra_db::CrateGraphQuery + base_db::ParseQuery + base_db::CrateGraphQuery // SourceDatabaseExt - ra_db::FileTextQuery - ra_db::FileSourceRootQuery - ra_db::SourceRootQuery - ra_db::SourceRootCratesQuery + base_db::FileTextQuery + base_db::FileSourceRootQuery + base_db::SourceRootQuery + base_db::SourceRootCratesQuery // AstDatabase hir::db::AstIdMapQuery diff --git a/crates/ra_ide_db/src/lib.rs b/crates/ra_ide_db/src/lib.rs index 6900cac73e..fd474cd0f4 100644 --- a/crates/ra_ide_db/src/lib.rs +++ b/crates/ra_ide_db/src/lib.rs @@ -13,19 +13,19 @@ mod wasm_shims; use std::{fmt, sync::Arc}; -use hir::db::{AstDatabase, DefDatabase, HirDatabase}; -use ra_db::{ +use base_db::{ salsa::{self, Durability}, Canceled, CheckCanceled, CrateId, FileId, FileLoader, FileLoaderDelegate, SourceDatabase, Upcast, }; +use hir::db::{AstDatabase, DefDatabase, HirDatabase}; use rustc_hash::FxHashSet; use crate::{line_index::LineIndex, symbol_index::SymbolsDatabase}; #[salsa::database( - ra_db::SourceDatabaseStorage, - ra_db::SourceDatabaseExtStorage, + base_db::SourceDatabaseStorage, + base_db::SourceDatabaseExtStorage, LineIndexDatabaseStorage, symbol_index::SymbolsDatabaseStorage, hir::db::InternDatabaseStorage, @@ -111,8 +111,8 @@ impl RootDatabase { } pub fn update_lru_capacity(&mut self, lru_capacity: Option) { - let lru_capacity = lru_capacity.unwrap_or(ra_db::DEFAULT_LRU_CAP); - ra_db::ParseQuery.in_db_mut(self).set_lru_capacity(lru_capacity); + let lru_capacity = lru_capacity.unwrap_or(base_db::DEFAULT_LRU_CAP); + base_db::ParseQuery.in_db_mut(self).set_lru_capacity(lru_capacity); hir::db::ParseMacroQuery.in_db_mut(self).set_lru_capacity(lru_capacity); hir::db::MacroExpandQuery.in_db_mut(self).set_lru_capacity(lru_capacity); } @@ -129,7 +129,7 @@ impl salsa::ParallelDatabase for RootDatabase { } #[salsa::query_group(LineIndexDatabaseStorage)] -pub trait LineIndexDatabase: ra_db::SourceDatabase + CheckCanceled { +pub trait LineIndexDatabase: base_db::SourceDatabase + CheckCanceled { fn line_index(&self, file_id: FileId) -> Arc; } diff --git a/crates/ra_ide_db/src/search.rs b/crates/ra_ide_db/src/search.rs index 7827cc71cf..b9360bf129 100644 --- a/crates/ra_ide_db/src/search.rs +++ b/crates/ra_ide_db/src/search.rs @@ -6,9 +6,9 @@ use std::{convert::TryInto, mem}; +use base_db::{FileId, FileRange, SourceDatabaseExt}; use hir::{DefWithBody, HasSource, Module, ModuleSource, Semantics, Visibility}; use once_cell::unsync::Lazy; -use ra_db::{FileId, FileRange, SourceDatabaseExt}; use rustc_hash::FxHashMap; use syntax::{ast, match_ast, AstNode, TextRange, TextSize}; diff --git a/crates/ra_ide_db/src/source_change.rs b/crates/ra_ide_db/src/source_change.rs index ae21132dd7..f1590ec663 100644 --- a/crates/ra_ide_db/src/source_change.rs +++ b/crates/ra_ide_db/src/source_change.rs @@ -3,7 +3,7 @@ //! //! It can be viewed as a dual for `AnalysisChange`. -use ra_db::FileId; +use base_db::FileId; use text_edit::TextEdit; #[derive(Default, Debug, Clone)] diff --git a/crates/ra_ide_db/src/symbol_index.rs b/crates/ra_ide_db/src/symbol_index.rs index 896092b467..654df898e9 100644 --- a/crates/ra_ide_db/src/symbol_index.rs +++ b/crates/ra_ide_db/src/symbol_index.rs @@ -28,12 +28,12 @@ use std::{ sync::Arc, }; -use fst::{self, Streamer}; -use hir::db::DefDatabase; -use ra_db::{ +use base_db::{ salsa::{self, ParallelDatabase}, CrateId, FileId, SourceDatabaseExt, SourceRootId, }; +use fst::{self, Streamer}; +use hir::db::DefDatabase; use rayon::prelude::*; use rustc_hash::{FxHashMap, FxHashSet}; use syntax::{ diff --git a/crates/ra_ssr/Cargo.toml b/crates/ra_ssr/Cargo.toml index 958baa2df7..f290939cfb 100644 --- a/crates/ra_ssr/Cargo.toml +++ b/crates/ra_ssr/Cargo.toml @@ -13,7 +13,7 @@ doctest = false [dependencies] text_edit = { path = "../text_edit" } syntax = { path = "../syntax" } -ra_db = { path = "../ra_db" } +base_db = { path = "../base_db" } ra_ide_db = { path = "../ra_ide_db" } hir = { path = "../ra_hir", package = "ra_hir" } rustc-hash = "1.1.0" diff --git a/crates/ra_ssr/src/lib.rs b/crates/ra_ssr/src/lib.rs index fb53212a3a..6725582e49 100644 --- a/crates/ra_ssr/src/lib.rs +++ b/crates/ra_ssr/src/lib.rs @@ -18,8 +18,8 @@ use crate::errors::bail; pub use crate::errors::SsrError; pub use crate::matching::Match; use crate::matching::MatchFailureReason; +use base_db::{FileId, FilePosition, FileRange}; use hir::Semantics; -use ra_db::{FileId, FilePosition, FileRange}; use ra_ide_db::source_change::SourceFileEdit; use resolving::ResolvedRule; use rustc_hash::FxHashMap; @@ -71,7 +71,7 @@ impl<'db> MatchFinder<'db> { /// Constructs an instance using the start of the first file in `db` as the lookup context. pub fn at_first_file(db: &'db ra_ide_db::RootDatabase) -> Result, SsrError> { - use ra_db::SourceDatabaseExt; + use base_db::SourceDatabaseExt; use ra_ide_db::symbol_index::SymbolsDatabase; if let Some(first_file_id) = db .local_roots() @@ -105,7 +105,7 @@ impl<'db> MatchFinder<'db> { /// Finds matches for all added rules and returns edits for all found matches. pub fn edits(&self) -> Vec { - use ra_db::SourceDatabaseExt; + use base_db::SourceDatabaseExt; let mut matches_by_file = FxHashMap::default(); for m in self.matches().matches { matches_by_file @@ -150,7 +150,7 @@ impl<'db> MatchFinder<'db> { /// them, while recording reasons why they don't match. This API is useful for command /// line-based debugging where providing a range is difficult. pub fn debug_where_text_equal(&self, file_id: FileId, snippet: &str) -> Vec { - use ra_db::SourceDatabaseExt; + use base_db::SourceDatabaseExt; let file = self.sema.parse(file_id); let mut res = Vec::new(); let file_text = self.sema.db.file_text(file_id); diff --git a/crates/ra_ssr/src/matching.rs b/crates/ra_ssr/src/matching.rs index 6e0b923528..e81a87c471 100644 --- a/crates/ra_ssr/src/matching.rs +++ b/crates/ra_ssr/src/matching.rs @@ -6,8 +6,8 @@ use crate::{ resolving::{ResolvedPattern, ResolvedRule, UfcsCallInfo}, SsrMatches, }; +use base_db::FileRange; use hir::Semantics; -use ra_db::FileRange; use rustc_hash::FxHashMap; use std::{cell::Cell, iter::Peekable}; use syntax::ast::{AstNode, AstToken}; diff --git a/crates/ra_ssr/src/resolving.rs b/crates/ra_ssr/src/resolving.rs index bfc20705b4..dac09bae80 100644 --- a/crates/ra_ssr/src/resolving.rs +++ b/crates/ra_ssr/src/resolving.rs @@ -2,8 +2,8 @@ use crate::errors::error; use crate::{parsing, SsrError}; +use base_db::FilePosition; use parsing::Placeholder; -use ra_db::FilePosition; use rustc_hash::FxHashMap; use syntax::{ast, SmolStr, SyntaxKind, SyntaxNode, SyntaxToken}; use test_utils::mark; diff --git a/crates/ra_ssr/src/search.rs b/crates/ra_ssr/src/search.rs index e44e149599..434953fb48 100644 --- a/crates/ra_ssr/src/search.rs +++ b/crates/ra_ssr/src/search.rs @@ -5,7 +5,7 @@ use crate::{ resolving::{ResolvedPath, ResolvedPattern, ResolvedRule}, Match, MatchFinder, }; -use ra_db::{FileId, FileRange}; +use base_db::{FileId, FileRange}; use ra_ide_db::{ defs::Definition, search::{Reference, SearchScope}, @@ -145,7 +145,7 @@ impl<'db> MatchFinder<'db> { fn search_files_do(&self, mut callback: impl FnMut(FileId)) { if self.restrict_ranges.is_empty() { // Unrestricted search. - use ra_db::SourceDatabaseExt; + use base_db::SourceDatabaseExt; use ra_ide_db::symbol_index::SymbolsDatabase; for &root in self.sema.db.local_roots().iter() { let sr = self.sema.db.source_root(root); diff --git a/crates/ra_ssr/src/tests.rs b/crates/ra_ssr/src/tests.rs index 4bc09c1e47..54c3da9db3 100644 --- a/crates/ra_ssr/src/tests.rs +++ b/crates/ra_ssr/src/tests.rs @@ -1,6 +1,6 @@ use crate::{MatchFinder, SsrRule}; +use base_db::{salsa::Durability, FileId, FilePosition, FileRange, SourceDatabaseExt}; use expect::{expect, Expect}; -use ra_db::{salsa::Durability, FileId, FilePosition, FileRange, SourceDatabaseExt}; use rustc_hash::FxHashSet; use std::sync::Arc; use test_utils::{mark, RangeOrOffset}; @@ -62,7 +62,7 @@ fn parser_undefined_placeholder_in_replacement() { /// `code` may optionally contain a cursor marker `<|>`. If it doesn't, then the position will be /// the start of the file. If there's a second cursor marker, then we'll return a single range. pub(crate) fn single_file(code: &str) -> (ra_ide_db::RootDatabase, FilePosition, Vec) { - use ra_db::fixture::WithFixture; + use base_db::fixture::WithFixture; use ra_ide_db::symbol_index::SymbolsDatabase; let (mut db, file_id, range_or_offset) = if code.contains(test_utils::CURSOR_MARKER) { ra_ide_db::RootDatabase::with_range_or_offset(code) @@ -83,7 +83,7 @@ pub(crate) fn single_file(code: &str) -> (ra_ide_db::RootDatabase, FilePosition, } } let mut local_roots = FxHashSet::default(); - local_roots.insert(ra_db::fixture::WORKSPACE); + local_roots.insert(base_db::fixture::WORKSPACE); db.set_local_roots_with_durability(Arc::new(local_roots), Durability::HIGH); (db, position, selections) } diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml index c6102bf272..210d9e9c88 100644 --- a/crates/rust-analyzer/Cargo.toml +++ b/crates/rust-analyzer/Cargo.toml @@ -46,7 +46,7 @@ cfg = { path = "../cfg" } toolchain = { path = "../toolchain" } # This should only be used in CLI -ra_db = { path = "../ra_db" } +base_db = { path = "../base_db" } ra_ide_db = { path = "../ra_ide_db" } ra_ssr = { path = "../ra_ssr" } hir = { path = "../ra_hir", package = "ra_hir" } diff --git a/crates/rust-analyzer/src/cli/analysis_bench.rs b/crates/rust-analyzer/src/cli/analysis_bench.rs index bc5f77e1a9..b20a1675e6 100644 --- a/crates/rust-analyzer/src/cli/analysis_bench.rs +++ b/crates/rust-analyzer/src/cli/analysis_bench.rs @@ -3,7 +3,7 @@ use std::{env, path::PathBuf, str::FromStr, sync::Arc, time::Instant}; use anyhow::{bail, format_err, Result}; -use ra_db::{ +use base_db::{ salsa::{Database, Durability}, FileId, }; diff --git a/crates/rust-analyzer/src/cli/analysis_stats.rs b/crates/rust-analyzer/src/cli/analysis_stats.rs index cfc1b22440..fb2b2b0001 100644 --- a/crates/rust-analyzer/src/cli/analysis_stats.rs +++ b/crates/rust-analyzer/src/cli/analysis_stats.rs @@ -6,6 +6,10 @@ use std::{ time::{SystemTime, UNIX_EPOCH}, }; +use base_db::{ + salsa::{self, ParallelDatabase}, + SourceDatabaseExt, +}; use hir::{ db::{AstDatabase, DefDatabase, HirDatabase}, original_range, AssocItem, Crate, HasSource, HirDisplay, ModuleDef, @@ -14,10 +18,6 @@ use hir_def::FunctionId; use hir_ty::{Ty, TypeWalk}; use itertools::Itertools; use oorandom::Rand32; -use ra_db::{ - salsa::{self, ParallelDatabase}, - SourceDatabaseExt, -}; use rayon::prelude::*; use rustc_hash::FxHashSet; use stdx::format_to; diff --git a/crates/rust-analyzer/src/cli/diagnostics.rs b/crates/rust-analyzer/src/cli/diagnostics.rs index f17fc5dfe9..56403cabe4 100644 --- a/crates/rust-analyzer/src/cli/diagnostics.rs +++ b/crates/rust-analyzer/src/cli/diagnostics.rs @@ -6,8 +6,8 @@ use std::path::Path; use anyhow::anyhow; use rustc_hash::FxHashSet; +use base_db::SourceDatabaseExt; use hir::Crate; -use ra_db::SourceDatabaseExt; use ra_ide::Severity; use crate::cli::{load_cargo::load_cargo, Result}; diff --git a/crates/rust-analyzer/src/cli/load_cargo.rs b/crates/rust-analyzer/src/cli/load_cargo.rs index f6cb144c67..5427348032 100644 --- a/crates/rust-analyzer/src/cli/load_cargo.rs +++ b/crates/rust-analyzer/src/cli/load_cargo.rs @@ -3,9 +3,9 @@ use std::{path::Path, sync::Arc}; use anyhow::Result; +use base_db::CrateGraph; use crossbeam_channel::{unbounded, Receiver}; use project_model::{CargoConfig, ProcMacroClient, ProjectManifest, ProjectWorkspace}; -use ra_db::CrateGraph; use ra_ide::{AnalysisChange, AnalysisHost}; use vfs::{loader::Handle, AbsPath, AbsPathBuf}; diff --git a/crates/rust-analyzer/src/cli/ssr.rs b/crates/rust-analyzer/src/cli/ssr.rs index 194bec008d..08788fb415 100644 --- a/crates/rust-analyzer/src/cli/ssr.rs +++ b/crates/rust-analyzer/src/cli/ssr.rs @@ -4,7 +4,7 @@ use crate::cli::{load_cargo::load_cargo, Result}; use ra_ssr::{MatchFinder, SsrPattern, SsrRule}; pub fn apply_ssr_rules(rules: Vec) -> Result<()> { - use ra_db::SourceDatabaseExt; + use base_db::SourceDatabaseExt; let (host, vfs) = load_cargo(&std::env::current_dir()?, true, true)?; let db = host.raw_database(); let mut match_finder = MatchFinder::at_first_file(db)?; @@ -26,7 +26,7 @@ pub fn apply_ssr_rules(rules: Vec) -> Result<()> { /// `debug_snippet`. This is intended for debugging and probably isn't in it's current form useful /// for much else. pub fn search_for_patterns(patterns: Vec, debug_snippet: Option) -> Result<()> { - use ra_db::SourceDatabaseExt; + use base_db::SourceDatabaseExt; use ra_ide_db::symbol_index::SymbolsDatabase; let (host, _vfs) = load_cargo(&std::env::current_dir()?, true, true)?; let db = host.raw_database(); diff --git a/crates/rust-analyzer/src/from_proto.rs b/crates/rust-analyzer/src/from_proto.rs index ad88ffdd72..945a353dd5 100644 --- a/crates/rust-analyzer/src/from_proto.rs +++ b/crates/rust-analyzer/src/from_proto.rs @@ -1,7 +1,7 @@ //! Conversion lsp_types types to rust-analyzer specific ones. use std::convert::TryFrom; -use ra_db::{FileId, FilePosition, FileRange}; +use base_db::{FileId, FilePosition, FileRange}; use ra_ide::{AssistKind, LineCol, LineIndex}; use syntax::{TextRange, TextSize}; use vfs::AbsPathBuf; diff --git a/crates/rust-analyzer/src/global_state.rs b/crates/rust-analyzer/src/global_state.rs index 2e8b708d0f..f04a0a59fd 100644 --- a/crates/rust-analyzer/src/global_state.rs +++ b/crates/rust-analyzer/src/global_state.rs @@ -5,12 +5,12 @@ use std::{sync::Arc, time::Instant}; +use base_db::{CrateId, VfsPath}; use crossbeam_channel::{unbounded, Receiver, Sender}; use flycheck::FlycheckHandle; use lsp_types::{SemanticTokens, Url}; use parking_lot::{Mutex, RwLock}; use project_model::{CargoWorkspace, ProcMacroClient, ProjectWorkspace, Target}; -use ra_db::{CrateId, VfsPath}; use ra_ide::{Analysis, AnalysisChange, AnalysisHost, FileId}; use rustc_hash::FxHashMap; diff --git a/crates/rust-analyzer/src/lsp_utils.rs b/crates/rust-analyzer/src/lsp_utils.rs index 0bc3ff115d..17d1550cdd 100644 --- a/crates/rust-analyzer/src/lsp_utils.rs +++ b/crates/rust-analyzer/src/lsp_utils.rs @@ -1,8 +1,8 @@ //! Utilities for LSP-related boilerplate code. use std::{error::Error, ops::Range}; +use base_db::Canceled; use lsp_server::Notification; -use ra_db::Canceled; use ra_ide::LineIndex; use crate::{from_proto, global_state::GlobalState}; diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index 9a779cb14e..5726820f91 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs @@ -5,10 +5,10 @@ use std::{ time::{Duration, Instant}, }; +use base_db::VfsPath; use crossbeam_channel::{select, Receiver}; use lsp_server::{Connection, Notification, Request, Response}; use lsp_types::notification::Notification as _; -use ra_db::VfsPath; use ra_ide::{Canceled, FileId}; use crate::{ diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs index 640417dc65..fd133e3124 100644 --- a/crates/rust-analyzer/src/reload.rs +++ b/crates/rust-analyzer/src/reload.rs @@ -1,9 +1,9 @@ //! Project loading & configuration updates use std::{mem, sync::Arc}; +use base_db::{CrateGraph, SourceRoot, VfsPath}; use flycheck::FlycheckHandle; use project_model::{ProcMacroClient, ProjectWorkspace}; -use ra_db::{CrateGraph, SourceRoot, VfsPath}; use ra_ide::AnalysisChange; use vfs::{file_set::FileSetConfig, AbsPath, AbsPathBuf, ChangeKind}; diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs index 278819a5c3..93a4b1f27d 100644 --- a/crates/rust-analyzer/src/to_proto.rs +++ b/crates/rust-analyzer/src/to_proto.rs @@ -4,8 +4,8 @@ use std::{ sync::atomic::{AtomicU32, Ordering}, }; +use base_db::{FileId, FileRange}; use itertools::Itertools; -use ra_db::{FileId, FileRange}; use ra_ide::{ Assist, AssistKind, CallInfo, CompletionItem, CompletionItemKind, Documentation, FileSystemEdit, Fold, FoldKind, Highlight, HighlightModifier, HighlightTag, HighlightedRange, diff --git a/docs/dev/architecture.md b/docs/dev/architecture.md index 21373729c7..746d41f83c 100644 --- a/docs/dev/architecture.md +++ b/docs/dev/architecture.md @@ -92,14 +92,14 @@ in particular: it shows off various methods of working with syntax tree. See [#93](https://github.com/rust-analyzer/rust-analyzer/pull/93) for an example PR which fixes a bug in the grammar. -### `crates/ra_db` +### `crates/base_db` We use the [salsa](https://github.com/salsa-rs/salsa) crate for incremental and on-demand computation. Roughly, you can think of salsa as a key-value store, but -it also can compute derived values using specified functions. The `ra_db` crate +it also can compute derived values using specified functions. The `base_db` crate provides basic infrastructure for interacting with salsa. Crucially, it defines most of the "input" queries: facts supplied by the client of the -analyzer. Reading the docs of the `ra_db::input` module should be useful: +analyzer. Reading the docs of the `base_db::input` module should be useful: everything else is strictly derived from those inputs. ### `crates/ra_hir*` crates diff --git a/docs/dev/guide.md b/docs/dev/guide.md index c3252f1f68..d14143226b 100644 --- a/docs/dev/guide.md +++ b/docs/dev/guide.md @@ -259,7 +259,7 @@ Salsa input queries are defined in [`FilesDatabase`] (which is a part of `RootDatabase`). They closely mirror the familiar `AnalysisChange` structure: indeed, what `apply_change` does is it sets the values of input queries. -[`FilesDatabase`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_db/src/input.rs#L150-L174 +[`FilesDatabase`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/base_db/src/input.rs#L150-L174 ## From text to semantic model @@ -392,7 +392,7 @@ integers which can "intern" a location and return an integer ID back. The salsa database we use includes a couple of [interners]. How to "garbage collect" unused locations is an open question. -[`LocationInterner`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_db/src/loc2id.rs#L65-L71 +[`LocationInterner`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/base_db/src/loc2id.rs#L65-L71 [interners]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/db.rs#L22-L23 For example, we use `LocationInterner` to assign IDs to definitions of functions,