Skip to content

Commit 939f05f

Browse files
committed
Move to a crate
1 parent 1bfb111 commit 939f05f

File tree

11 files changed

+111
-31
lines changed

11 files changed

+111
-31
lines changed

Cargo.lock

Lines changed: 31 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/ra_ide/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ once_cell = "1.2.0"
2828
ra_syntax = { path = "../ra_syntax" }
2929
ra_text_edit = { path = "../ra_text_edit" }
3030
ra_db = { path = "../ra_db" }
31+
ra_ide_db = { path = "../ra_ide_db" }
3132
ra_cfg = { path = "../ra_cfg" }
3233
ra_fmt = { path = "../ra_fmt" }
3334
ra_prof = { path = "../ra_prof" }

crates/ra_ide/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
// For proving that RootDatabase is RefUnwindSafe.
1111
#![recursion_limit = "128"]
1212

13-
mod ide_db;
13+
mod ide_db {
14+
pub use ra_ide_db::*;
15+
}
1416

1517
mod db;
1618
pub mod mock_analysis;
@@ -39,7 +41,6 @@ mod typing;
3941
mod matching_brace;
4042
mod display;
4143
mod inlay_hints;
42-
mod wasm_shims;
4344
mod expand;
4445
mod expand_macro;
4546

crates/ra_ide_db/Cargo.toml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
[package]
2+
edition = "2018"
3+
name = "ra_ide_db"
4+
version = "0.1.0"
5+
authors = ["rust-analyzer developers"]
6+
7+
[lib]
8+
doctest = false
9+
10+
[features]
11+
wasm = []
12+
13+
[dependencies]
14+
either = "1.5"
15+
format-buf = "1.0.0"
16+
indexmap = "1.3.0"
17+
itertools = "0.8.0"
18+
join_to_string = "0.1.3"
19+
log = "0.4.5"
20+
rayon = "1.0.2"
21+
fst = { version = "0.3.1", default-features = false }
22+
rustc-hash = "1.0"
23+
unicase = "2.2.0"
24+
superslice = "1.0.0"
25+
rand = { version = "0.7.0", features = ["small_rng"] }
26+
once_cell = "1.2.0"
27+
28+
ra_syntax = { path = "../ra_syntax" }
29+
ra_text_edit = { path = "../ra_text_edit" }
30+
ra_db = { path = "../ra_db" }
31+
ra_cfg = { path = "../ra_cfg" }
32+
ra_fmt = { path = "../ra_fmt" }
33+
ra_prof = { path = "../ra_prof" }
34+
test_utils = { path = "../test_utils" }
35+
ra_assists = { path = "../ra_assists" }
36+
37+
# ra_ide should depend only on the top-level `hir` package. if you need
38+
# something from some `hir_xxx` subpackage, reexport the API via `hir`.
39+
hir = { path = "../ra_hir", package = "ra_hir" }
40+
41+
[dev-dependencies]
42+
insta = "0.13.0"
43+
44+
[dev-dependencies.proptest]
45+
version = "0.9.0"
46+
# Disable `fork` feature to allow compiling on webassembly
47+
default-features = false
48+
features = ["std", "bit-set", "break-dead-code"]

crates/ra_ide/src/ide_db/change.rs renamed to crates/ra_ide_db/src/change.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use ra_syntax::SourceFile;
1313
use rayon::prelude::*;
1414
use rustc_hash::FxHashMap;
1515

16-
use crate::ide_db::{
16+
use crate::{
1717
symbol_index::{SymbolIndex, SymbolsDatabase},
1818
DebugData, RootDatabase,
1919
};
@@ -168,12 +168,12 @@ impl LibraryData {
168168
const GC_COOLDOWN: time::Duration = time::Duration::from_millis(100);
169169

170170
impl RootDatabase {
171-
pub(crate) fn request_cancellation(&mut self) {
171+
pub fn request_cancellation(&mut self) {
172172
let _p = profile("RootDatabase::request_cancellation");
173173
self.salsa_runtime_mut().synthetic_write(Durability::LOW);
174174
}
175175

176-
pub(crate) fn apply_change(&mut self, change: AnalysisChange) {
176+
pub fn apply_change(&mut self, change: AnalysisChange) {
177177
let _p = profile("RootDatabase::apply_change");
178178
self.request_cancellation();
179179
log::info!("apply_change {:?}", change);
@@ -245,7 +245,7 @@ impl RootDatabase {
245245
self.set_source_root_with_durability(root_id, Arc::new(source_root), durability);
246246
}
247247

248-
pub(crate) fn maybe_collect_garbage(&mut self) {
248+
pub fn maybe_collect_garbage(&mut self) {
249249
if cfg!(feature = "wasm") {
250250
return;
251251
}
@@ -255,7 +255,7 @@ impl RootDatabase {
255255
}
256256
}
257257

258-
pub(crate) fn collect_garbage(&mut self) {
258+
pub fn collect_garbage(&mut self) {
259259
if cfg!(feature = "wasm") {
260260
return;
261261
}
@@ -282,7 +282,7 @@ impl RootDatabase {
282282
self.query(hir::db::BodyQuery).sweep(sweep);
283283
}
284284

285-
pub(crate) fn per_query_memory_usage(&mut self) -> Vec<(String, Bytes)> {
285+
pub fn per_query_memory_usage(&mut self) -> Vec<(String, Bytes)> {
286286
let mut acc: Vec<(String, Bytes)> = vec![];
287287
let sweep = SweepStrategy::default().discard_values().sweep_all_revisions();
288288
macro_rules! sweep_each_query {

crates/ra_ide/src/ide_db/mod.rs renamed to crates/ra_ide_db/src/lib.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ pub mod line_index_utils;
55
pub mod feature_flags;
66
pub mod symbol_index;
77
pub mod change;
8+
mod wasm_shims;
89

910
use std::sync::Arc;
1011

@@ -15,9 +16,7 @@ use ra_db::{
1516
};
1617
use rustc_hash::FxHashMap;
1718

18-
use crate::ide_db::{
19-
feature_flags::FeatureFlags, line_index::LineIndex, symbol_index::SymbolsDatabase,
20-
};
19+
use crate::{feature_flags::FeatureFlags, line_index::LineIndex, symbol_index::SymbolsDatabase};
2120

2221
#[salsa::database(
2322
ra_db::SourceDatabaseStorage,
@@ -30,12 +29,12 @@ use crate::ide_db::{
3029
hir::db::HirDatabaseStorage
3130
)]
3231
#[derive(Debug)]
33-
pub(crate) struct RootDatabase {
32+
pub struct RootDatabase {
3433
runtime: salsa::Runtime<RootDatabase>,
35-
pub(crate) feature_flags: Arc<FeatureFlags>,
34+
pub feature_flags: Arc<FeatureFlags>,
3635
pub(crate) debug_data: Arc<DebugData>,
37-
pub(crate) last_gc: crate::wasm_shims::Instant,
38-
pub(crate) last_gc_check: crate::wasm_shims::Instant,
36+
pub last_gc: crate::wasm_shims::Instant,
37+
pub last_gc_check: crate::wasm_shims::Instant,
3938
}
4039

4140
impl FileLoader for RootDatabase {
@@ -114,7 +113,7 @@ impl salsa::ParallelDatabase for RootDatabase {
114113
}
115114

116115
#[salsa::query_group(LineIndexDatabaseStorage)]
117-
pub(crate) trait LineIndexDatabase: ra_db::SourceDatabase + CheckCanceled {
116+
pub trait LineIndexDatabase: ra_db::SourceDatabase + CheckCanceled {
118117
fn line_index(&self, file_id: FileId) -> Arc<LineIndex>;
119118
}
120119

crates/ra_ide/src/ide_db/line_index_utils.rs renamed to crates/ra_ide_db/src/line_index_utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use ra_syntax::{TextRange, TextUnit};
44
use ra_text_edit::{AtomTextEdit, TextEdit};
55

6-
use crate::ide_db::line_index::{LineCol, LineIndex, Utf16Char};
6+
use crate::line_index::{LineCol, LineIndex, Utf16Char};
77

88
#[derive(Debug, Clone)]
99
enum Step {
@@ -297,7 +297,7 @@ mod test {
297297
use ra_text_edit::test_utils::{arb_offset, arb_text_with_edit};
298298
use ra_text_edit::TextEdit;
299299

300-
use crate::ide_db::line_index;
300+
use crate::line_index;
301301

302302
use super::*;
303303

crates/ra_ide/src/ide_db/symbol_index.rs renamed to crates/ra_ide_db/src/symbol_index.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ use ra_syntax::{
4040
#[cfg(not(feature = "wasm"))]
4141
use rayon::prelude::*;
4242

43-
use crate::ide_db::RootDatabase;
43+
use crate::RootDatabase;
4444

4545
#[derive(Debug)]
4646
pub struct Query {
@@ -83,7 +83,7 @@ impl Query {
8383
}
8484

8585
#[salsa::query_group(SymbolsDatabaseStorage)]
86-
pub(crate) trait SymbolsDatabase: hir::db::HirDatabase {
86+
pub trait SymbolsDatabase: hir::db::HirDatabase {
8787
fn file_symbols(&self, file_id: FileId) -> Arc<SymbolIndex>;
8888
#[salsa::input]
8989
fn library_symbols(&self, id: SourceRootId) -> Arc<SymbolIndex>;
@@ -108,7 +108,7 @@ fn file_symbols(db: &impl SymbolsDatabase, file_id: FileId) -> Arc<SymbolIndex>
108108
Arc::new(SymbolIndex::new(symbols))
109109
}
110110

111-
pub(crate) fn world_symbols(db: &RootDatabase, query: Query) -> Vec<FileSymbol> {
111+
pub fn world_symbols(db: &RootDatabase, query: Query) -> Vec<FileSymbol> {
112112
/// Need to wrap Snapshot to provide `Clone` impl for `map_with`
113113
struct Snap(salsa::Snapshot<RootDatabase>);
114114
impl Clone for Snap {
@@ -150,7 +150,7 @@ pub(crate) fn world_symbols(db: &RootDatabase, query: Query) -> Vec<FileSymbol>
150150
query.search(&buf)
151151
}
152152

153-
pub(crate) fn index_resolve(db: &RootDatabase, name_ref: &ast::NameRef) -> Vec<FileSymbol> {
153+
pub fn index_resolve(db: &RootDatabase, name_ref: &ast::NameRef) -> Vec<FileSymbol> {
154154
let name = name_ref.text();
155155
let mut query = Query::new(name.to_string());
156156
query.exact();
@@ -159,7 +159,7 @@ pub(crate) fn index_resolve(db: &RootDatabase, name_ref: &ast::NameRef) -> Vec<F
159159
}
160160

161161
#[derive(Default)]
162-
pub(crate) struct SymbolIndex {
162+
pub struct SymbolIndex {
163163
symbols: Vec<FileSymbol>,
164164
map: fst::Map,
165165
}
@@ -218,11 +218,11 @@ impl SymbolIndex {
218218
SymbolIndex { symbols, map }
219219
}
220220

221-
pub(crate) fn len(&self) -> usize {
221+
pub fn len(&self) -> usize {
222222
self.symbols.len()
223223
}
224224

225-
pub(crate) fn memory_size(&self) -> usize {
225+
pub fn memory_size(&self) -> usize {
226226
self.map.as_fst().size() + self.symbols.len() * mem::size_of::<FileSymbol>()
227227
}
228228

@@ -302,12 +302,12 @@ fn is_type(kind: SyntaxKind) -> bool {
302302
/// The actual data that is stored in the index. It should be as compact as
303303
/// possible.
304304
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
305-
pub(crate) struct FileSymbol {
306-
pub(crate) file_id: FileId,
307-
pub(crate) name: SmolStr,
308-
pub(crate) ptr: SyntaxNodePtr,
309-
pub(crate) name_range: Option<TextRange>,
310-
pub(crate) container_name: Option<SmolStr>,
305+
pub struct FileSymbol {
306+
pub file_id: FileId,
307+
pub name: SmolStr,
308+
pub ptr: SyntaxNodePtr,
309+
pub name_range: Option<TextRange>,
310+
pub container_name: Option<SmolStr>,
311311
}
312312

313313
fn source_file_to_file_symbols(source_file: &SourceFile, file_id: FileId) -> Vec<FileSymbol> {

0 commit comments

Comments
 (0)