aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_ide/Cargo.toml1
-rw-r--r--crates/ra_ide/src/lib.rs5
-rw-r--r--crates/ra_ide_db/Cargo.toml48
-rw-r--r--crates/ra_ide_db/src/change.rs (renamed from crates/ra_ide/src/ide_db/change.rs)12
-rw-r--r--crates/ra_ide_db/src/feature_flags.rs (renamed from crates/ra_ide/src/ide_db/feature_flags.rs)0
-rw-r--r--crates/ra_ide_db/src/lib.rs (renamed from crates/ra_ide/src/ide_db/mod.rs)15
-rw-r--r--crates/ra_ide_db/src/line_index.rs (renamed from crates/ra_ide/src/ide_db/line_index.rs)0
-rw-r--r--crates/ra_ide_db/src/line_index_utils.rs (renamed from crates/ra_ide/src/ide_db/line_index_utils.rs)4
-rw-r--r--crates/ra_ide_db/src/symbol_index.rs (renamed from crates/ra_ide/src/ide_db/symbol_index.rs)26
-rw-r--r--crates/ra_ide_db/src/wasm_shims.rs (renamed from crates/ra_ide/src/wasm_shims.rs)0
10 files changed, 80 insertions, 31 deletions
diff --git a/crates/ra_ide/Cargo.toml b/crates/ra_ide/Cargo.toml
index 53817d1f7..9ace35229 100644
--- a/crates/ra_ide/Cargo.toml
+++ b/crates/ra_ide/Cargo.toml
@@ -28,6 +28,7 @@ once_cell = "1.2.0"
28ra_syntax = { path = "../ra_syntax" } 28ra_syntax = { path = "../ra_syntax" }
29ra_text_edit = { path = "../ra_text_edit" } 29ra_text_edit = { path = "../ra_text_edit" }
30ra_db = { path = "../ra_db" } 30ra_db = { path = "../ra_db" }
31ra_ide_db = { path = "../ra_ide_db" }
31ra_cfg = { path = "../ra_cfg" } 32ra_cfg = { path = "../ra_cfg" }
32ra_fmt = { path = "../ra_fmt" } 33ra_fmt = { path = "../ra_fmt" }
33ra_prof = { path = "../ra_prof" } 34ra_prof = { path = "../ra_prof" }
diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs
index 66f365cc3..1527b27d4 100644
--- a/crates/ra_ide/src/lib.rs
+++ b/crates/ra_ide/src/lib.rs
@@ -10,7 +10,9 @@
10// For proving that RootDatabase is RefUnwindSafe. 10// For proving that RootDatabase is RefUnwindSafe.
11#![recursion_limit = "128"] 11#![recursion_limit = "128"]
12 12
13mod ide_db; 13mod ide_db {
14 pub use ra_ide_db::*;
15}
14 16
15mod db; 17mod db;
16pub mod mock_analysis; 18pub mod mock_analysis;
@@ -39,7 +41,6 @@ mod typing;
39mod matching_brace; 41mod matching_brace;
40mod display; 42mod display;
41mod inlay_hints; 43mod inlay_hints;
42mod wasm_shims;
43mod expand; 44mod expand;
44mod expand_macro; 45mod expand_macro;
45 46
diff --git a/crates/ra_ide_db/Cargo.toml b/crates/ra_ide_db/Cargo.toml
new file mode 100644
index 000000000..1b7905eb3
--- /dev/null
+++ b/crates/ra_ide_db/Cargo.toml
@@ -0,0 +1,48 @@
1[package]
2edition = "2018"
3name = "ra_ide_db"
4version = "0.1.0"
5authors = ["rust-analyzer developers"]
6
7[lib]
8doctest = false
9
10[features]
11wasm = []
12
13[dependencies]
14either = "1.5"
15format-buf = "1.0.0"
16indexmap = "1.3.0"
17itertools = "0.8.0"
18join_to_string = "0.1.3"
19log = "0.4.5"
20rayon = "1.0.2"
21fst = { version = "0.3.1", default-features = false }
22rustc-hash = "1.0"
23unicase = "2.2.0"
24superslice = "1.0.0"
25rand = { version = "0.7.0", features = ["small_rng"] }
26once_cell = "1.2.0"
27
28ra_syntax = { path = "../ra_syntax" }
29ra_text_edit = { path = "../ra_text_edit" }
30ra_db = { path = "../ra_db" }
31ra_cfg = { path = "../ra_cfg" }
32ra_fmt = { path = "../ra_fmt" }
33ra_prof = { path = "../ra_prof" }
34test_utils = { path = "../test_utils" }
35ra_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`.
39hir = { path = "../ra_hir", package = "ra_hir" }
40
41[dev-dependencies]
42insta = "0.13.0"
43
44[dev-dependencies.proptest]
45version = "0.9.0"
46# Disable `fork` feature to allow compiling on webassembly
47default-features = false
48features = ["std", "bit-set", "break-dead-code"]
diff --git a/crates/ra_ide/src/ide_db/change.rs b/crates/ra_ide_db/src/change.rs
index 62ffa6920..95a6ff287 100644
--- a/crates/ra_ide/src/ide_db/change.rs
+++ b/crates/ra_ide_db/src/change.rs
@@ -13,7 +13,7 @@ use ra_syntax::SourceFile;
13use rayon::prelude::*; 13use rayon::prelude::*;
14use rustc_hash::FxHashMap; 14use rustc_hash::FxHashMap;
15 15
16use crate::ide_db::{ 16use crate::{
17 symbol_index::{SymbolIndex, SymbolsDatabase}, 17 symbol_index::{SymbolIndex, SymbolsDatabase},
18 DebugData, RootDatabase, 18 DebugData, RootDatabase,
19}; 19};
@@ -168,12 +168,12 @@ impl LibraryData {
168const GC_COOLDOWN: time::Duration = time::Duration::from_millis(100); 168const GC_COOLDOWN: time::Duration = time::Duration::from_millis(100);
169 169
170impl RootDatabase { 170impl RootDatabase {
171 pub(crate) fn request_cancellation(&mut self) { 171 pub fn request_cancellation(&mut self) {
172 let _p = profile("RootDatabase::request_cancellation"); 172 let _p = profile("RootDatabase::request_cancellation");
173 self.salsa_runtime_mut().synthetic_write(Durability::LOW); 173 self.salsa_runtime_mut().synthetic_write(Durability::LOW);
174 } 174 }
175 175
176 pub(crate) fn apply_change(&mut self, change: AnalysisChange) { 176 pub fn apply_change(&mut self, change: AnalysisChange) {
177 let _p = profile("RootDatabase::apply_change"); 177 let _p = profile("RootDatabase::apply_change");
178 self.request_cancellation(); 178 self.request_cancellation();
179 log::info!("apply_change {:?}", change); 179 log::info!("apply_change {:?}", change);
@@ -245,7 +245,7 @@ impl RootDatabase {
245 self.set_source_root_with_durability(root_id, Arc::new(source_root), durability); 245 self.set_source_root_with_durability(root_id, Arc::new(source_root), durability);
246 } 246 }
247 247
248 pub(crate) fn maybe_collect_garbage(&mut self) { 248 pub fn maybe_collect_garbage(&mut self) {
249 if cfg!(feature = "wasm") { 249 if cfg!(feature = "wasm") {
250 return; 250 return;
251 } 251 }
@@ -255,7 +255,7 @@ impl RootDatabase {
255 } 255 }
256 } 256 }
257 257
258 pub(crate) fn collect_garbage(&mut self) { 258 pub fn collect_garbage(&mut self) {
259 if cfg!(feature = "wasm") { 259 if cfg!(feature = "wasm") {
260 return; 260 return;
261 } 261 }
@@ -282,7 +282,7 @@ impl RootDatabase {
282 self.query(hir::db::BodyQuery).sweep(sweep); 282 self.query(hir::db::BodyQuery).sweep(sweep);
283 } 283 }
284 284
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)> {
286 let mut acc: Vec<(String, Bytes)> = vec![]; 286 let mut acc: Vec<(String, Bytes)> = vec![];
287 let sweep = SweepStrategy::default().discard_values().sweep_all_revisions(); 287 let sweep = SweepStrategy::default().discard_values().sweep_all_revisions();
288 macro_rules! sweep_each_query { 288 macro_rules! sweep_each_query {
diff --git a/crates/ra_ide/src/ide_db/feature_flags.rs b/crates/ra_ide_db/src/feature_flags.rs
index 85617640d..85617640d 100644
--- a/crates/ra_ide/src/ide_db/feature_flags.rs
+++ b/crates/ra_ide_db/src/feature_flags.rs
diff --git a/crates/ra_ide/src/ide_db/mod.rs b/crates/ra_ide_db/src/lib.rs
index 0df4d510f..d04c59a4a 100644
--- a/crates/ra_ide/src/ide_db/mod.rs
+++ b/crates/ra_ide_db/src/lib.rs
@@ -5,6 +5,7 @@ pub mod line_index_utils;
5pub mod feature_flags; 5pub mod feature_flags;
6pub mod symbol_index; 6pub mod symbol_index;
7pub mod change; 7pub mod change;
8mod wasm_shims;
8 9
9use std::sync::Arc; 10use std::sync::Arc;
10 11
@@ -15,9 +16,7 @@ use ra_db::{
15}; 16};
16use rustc_hash::FxHashMap; 17use rustc_hash::FxHashMap;
17 18
18use crate::ide_db::{ 19use crate::{feature_flags::FeatureFlags, line_index::LineIndex, symbol_index::SymbolsDatabase};
19 feature_flags::FeatureFlags, line_index::LineIndex, symbol_index::SymbolsDatabase,
20};
21 20
22#[salsa::database( 21#[salsa::database(
23 ra_db::SourceDatabaseStorage, 22 ra_db::SourceDatabaseStorage,
@@ -30,12 +29,12 @@ use crate::ide_db::{
30 hir::db::HirDatabaseStorage 29 hir::db::HirDatabaseStorage
31)] 30)]
32#[derive(Debug)] 31#[derive(Debug)]
33pub(crate) struct RootDatabase { 32pub struct RootDatabase {
34 runtime: salsa::Runtime<RootDatabase>, 33 runtime: salsa::Runtime<RootDatabase>,
35 pub(crate) feature_flags: Arc<FeatureFlags>, 34 pub feature_flags: Arc<FeatureFlags>,
36 pub(crate) debug_data: Arc<DebugData>, 35 pub(crate) debug_data: Arc<DebugData>,
37 pub(crate) last_gc: crate::wasm_shims::Instant, 36 pub last_gc: crate::wasm_shims::Instant,
38 pub(crate) last_gc_check: crate::wasm_shims::Instant, 37 pub last_gc_check: crate::wasm_shims::Instant,
39} 38}
40 39
41impl FileLoader for RootDatabase { 40impl FileLoader for RootDatabase {
@@ -114,7 +113,7 @@ impl salsa::ParallelDatabase for RootDatabase {
114} 113}
115 114
116#[salsa::query_group(LineIndexDatabaseStorage)] 115#[salsa::query_group(LineIndexDatabaseStorage)]
117pub(crate) trait LineIndexDatabase: ra_db::SourceDatabase + CheckCanceled { 116pub trait LineIndexDatabase: ra_db::SourceDatabase + CheckCanceled {
118 fn line_index(&self, file_id: FileId) -> Arc<LineIndex>; 117 fn line_index(&self, file_id: FileId) -> Arc<LineIndex>;
119} 118}
120 119
diff --git a/crates/ra_ide/src/ide_db/line_index.rs b/crates/ra_ide_db/src/line_index.rs
index 6f99ca3a7..6f99ca3a7 100644
--- a/crates/ra_ide/src/ide_db/line_index.rs
+++ b/crates/ra_ide_db/src/line_index.rs
diff --git a/crates/ra_ide/src/ide_db/line_index_utils.rs b/crates/ra_ide_db/src/line_index_utils.rs
index faa3d665f..daf9d8ab9 100644
--- a/crates/ra_ide/src/ide_db/line_index_utils.rs
+++ b/crates/ra_ide_db/src/line_index_utils.rs
@@ -3,7 +3,7 @@
3use ra_syntax::{TextRange, TextUnit}; 3use ra_syntax::{TextRange, TextUnit};
4use ra_text_edit::{AtomTextEdit, TextEdit}; 4use ra_text_edit::{AtomTextEdit, TextEdit};
5 5
6use crate::ide_db::line_index::{LineCol, LineIndex, Utf16Char}; 6use crate::line_index::{LineCol, LineIndex, Utf16Char};
7 7
8#[derive(Debug, Clone)] 8#[derive(Debug, Clone)]
9enum Step { 9enum Step {
@@ -297,7 +297,7 @@ mod test {
297 use ra_text_edit::test_utils::{arb_offset, arb_text_with_edit}; 297 use ra_text_edit::test_utils::{arb_offset, arb_text_with_edit};
298 use ra_text_edit::TextEdit; 298 use ra_text_edit::TextEdit;
299 299
300 use crate::ide_db::line_index; 300 use crate::line_index;
301 301
302 use super::*; 302 use super::*;
303 303
diff --git a/crates/ra_ide/src/ide_db/symbol_index.rs b/crates/ra_ide_db/src/symbol_index.rs
index c66eeb8e2..33f042d88 100644
--- a/crates/ra_ide/src/ide_db/symbol_index.rs
+++ b/crates/ra_ide_db/src/symbol_index.rs
@@ -40,7 +40,7 @@ use ra_syntax::{
40#[cfg(not(feature = "wasm"))] 40#[cfg(not(feature = "wasm"))]
41use rayon::prelude::*; 41use rayon::prelude::*;
42 42
43use crate::ide_db::RootDatabase; 43use crate::RootDatabase;
44 44
45#[derive(Debug)] 45#[derive(Debug)]
46pub struct Query { 46pub struct Query {
@@ -83,7 +83,7 @@ impl Query {
83} 83}
84 84
85#[salsa::query_group(SymbolsDatabaseStorage)] 85#[salsa::query_group(SymbolsDatabaseStorage)]
86pub(crate) trait SymbolsDatabase: hir::db::HirDatabase { 86pub trait SymbolsDatabase: hir::db::HirDatabase {
87 fn file_symbols(&self, file_id: FileId) -> Arc<SymbolIndex>; 87 fn file_symbols(&self, file_id: FileId) -> Arc<SymbolIndex>;
88 #[salsa::input] 88 #[salsa::input]
89 fn library_symbols(&self, id: SourceRootId) -> Arc<SymbolIndex>; 89 fn library_symbols(&self, id: SourceRootId) -> Arc<SymbolIndex>;
@@ -108,7 +108,7 @@ fn file_symbols(db: &impl SymbolsDatabase, file_id: FileId) -> Arc<SymbolIndex>
108 Arc::new(SymbolIndex::new(symbols)) 108 Arc::new(SymbolIndex::new(symbols))
109} 109}
110 110
111pub(crate) fn world_symbols(db: &RootDatabase, query: Query) -> Vec<FileSymbol> { 111pub fn world_symbols(db: &RootDatabase, query: Query) -> Vec<FileSymbol> {
112 /// Need to wrap Snapshot to provide `Clone` impl for `map_with` 112 /// Need to wrap Snapshot to provide `Clone` impl for `map_with`
113 struct Snap(salsa::Snapshot<RootDatabase>); 113 struct Snap(salsa::Snapshot<RootDatabase>);
114 impl Clone for Snap { 114 impl Clone for Snap {
@@ -150,7 +150,7 @@ pub(crate) fn world_symbols(db: &RootDatabase, query: Query) -> Vec<FileSymbol>
150 query.search(&buf) 150 query.search(&buf)
151} 151}
152 152
153pub(crate) fn index_resolve(db: &RootDatabase, name_ref: &ast::NameRef) -> Vec<FileSymbol> { 153pub fn index_resolve(db: &RootDatabase, name_ref: &ast::NameRef) -> Vec<FileSymbol> {
154 let name = name_ref.text(); 154 let name = name_ref.text();
155 let mut query = Query::new(name.to_string()); 155 let mut query = Query::new(name.to_string());
156 query.exact(); 156 query.exact();
@@ -159,7 +159,7 @@ pub(crate) fn index_resolve(db: &RootDatabase, name_ref: &ast::NameRef) -> Vec<F
159} 159}
160 160
161#[derive(Default)] 161#[derive(Default)]
162pub(crate) struct SymbolIndex { 162pub struct SymbolIndex {
163 symbols: Vec<FileSymbol>, 163 symbols: Vec<FileSymbol>,
164 map: fst::Map, 164 map: fst::Map,
165} 165}
@@ -218,11 +218,11 @@ impl SymbolIndex {
218 SymbolIndex { symbols, map } 218 SymbolIndex { symbols, map }
219 } 219 }
220 220
221 pub(crate) fn len(&self) -> usize { 221 pub fn len(&self) -> usize {
222 self.symbols.len() 222 self.symbols.len()
223 } 223 }
224 224
225 pub(crate) fn memory_size(&self) -> usize { 225 pub fn memory_size(&self) -> usize {
226 self.map.as_fst().size() + self.symbols.len() * mem::size_of::<FileSymbol>() 226 self.map.as_fst().size() + self.symbols.len() * mem::size_of::<FileSymbol>()
227 } 227 }
228 228
@@ -302,12 +302,12 @@ fn is_type(kind: SyntaxKind) -> bool {
302/// The actual data that is stored in the index. It should be as compact as 302/// The actual data that is stored in the index. It should be as compact as
303/// possible. 303/// possible.
304#[derive(Debug, Clone, PartialEq, Eq, Hash)] 304#[derive(Debug, Clone, PartialEq, Eq, Hash)]
305pub(crate) struct FileSymbol { 305pub struct FileSymbol {
306 pub(crate) file_id: FileId, 306 pub file_id: FileId,
307 pub(crate) name: SmolStr, 307 pub name: SmolStr,
308 pub(crate) ptr: SyntaxNodePtr, 308 pub ptr: SyntaxNodePtr,
309 pub(crate) name_range: Option<TextRange>, 309 pub name_range: Option<TextRange>,
310 pub(crate) container_name: Option<SmolStr>, 310 pub container_name: Option<SmolStr>,
311} 311}
312 312
313fn source_file_to_file_symbols(source_file: &SourceFile, file_id: FileId) -> Vec<FileSymbol> { 313fn source_file_to_file_symbols(source_file: &SourceFile, file_id: FileId) -> Vec<FileSymbol> {
diff --git a/crates/ra_ide/src/wasm_shims.rs b/crates/ra_ide_db/src/wasm_shims.rs
index 088cc9be4..088cc9be4 100644
--- a/crates/ra_ide/src/wasm_shims.rs
+++ b/crates/ra_ide_db/src/wasm_shims.rs