diff options
-rw-r--r-- | Cargo.lock | 12 | ||||
-rw-r--r-- | crates/ra_analysis/Cargo.toml | 3 | ||||
-rw-r--r-- | crates/ra_analysis/src/imp.rs | 25 | ||||
-rw-r--r-- | crates/ra_analysis/src/lib.rs | 4 | ||||
-rw-r--r-- | crates/ra_analysis/src/roots.rs | 24 |
5 files changed, 18 insertions, 50 deletions
diff --git a/Cargo.lock b/Cargo.lock index 625f2aeac..d1a294c30 100644 --- a/Cargo.lock +++ b/Cargo.lock | |||
@@ -509,14 +509,6 @@ dependencies = [ | |||
509 | ] | 509 | ] |
510 | 510 | ||
511 | [[package]] | 511 | [[package]] |
512 | name = "once_cell" | ||
513 | version = "0.1.6" | ||
514 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
515 | dependencies = [ | ||
516 | "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", | ||
517 | ] | ||
518 | |||
519 | [[package]] | ||
520 | name = "owning_ref" | 512 | name = "owning_ref" |
521 | version = "0.3.3" | 513 | version = "0.3.3" |
522 | source = "registry+https://github.com/rust-lang/crates.io-index" | 514 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -610,9 +602,6 @@ name = "ra_analysis" | |||
610 | version = "0.1.0" | 602 | version = "0.1.0" |
611 | dependencies = [ | 603 | dependencies = [ |
612 | "fst 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", | 604 | "fst 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", |
613 | "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", | ||
614 | "once_cell 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", | ||
615 | "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", | ||
616 | "ra_editor 0.1.0", | 605 | "ra_editor 0.1.0", |
617 | "ra_syntax 0.1.0", | 606 | "ra_syntax 0.1.0", |
618 | "rayon 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", | 607 | "rayon 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -1330,7 +1319,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
1330 | "checksum num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "e83d528d2677f0518c570baf2b7abdcf0cd2d248860b68507bdcb3e91d4c0cea" | 1319 | "checksum num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "e83d528d2677f0518c570baf2b7abdcf0cd2d248860b68507bdcb3e91d4c0cea" |
1331 | "checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1" | 1320 | "checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1" |
1332 | "checksum num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c51a3322e4bca9d212ad9a158a02abc6934d005490c054a2778df73a70aa0a30" | 1321 | "checksum num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c51a3322e4bca9d212ad9a158a02abc6934d005490c054a2778df73a70aa0a30" |
1333 | "checksum once_cell 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "d7ce3535d54560c937c1652ba4a0da66bfc63e0f8e07bed127483afb6e5ee925" | ||
1334 | "checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37" | 1322 | "checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37" |
1335 | "checksum parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f0802bff09003b291ba756dc7e79313e51cc31667e94afbe847def490424cde5" | 1323 | "checksum parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f0802bff09003b291ba756dc7e79313e51cc31667e94afbe847def490424cde5" |
1336 | "checksum parking_lot_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad7f7e6ebdc79edff6fdcb87a55b620174f7a989e3eb31b65231f4af57f00b8c" | 1324 | "checksum parking_lot_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad7f7e6ebdc79edff6fdcb87a55b620174f7a989e3eb31b65231f4af57f00b8c" |
diff --git a/crates/ra_analysis/Cargo.toml b/crates/ra_analysis/Cargo.toml index 0f5ff6d24..75a9dc844 100644 --- a/crates/ra_analysis/Cargo.toml +++ b/crates/ra_analysis/Cargo.toml | |||
@@ -6,9 +6,6 @@ authors = ["Aleksey Kladov <[email protected]>"] | |||
6 | 6 | ||
7 | [dependencies] | 7 | [dependencies] |
8 | relative-path = "0.4.0" | 8 | relative-path = "0.4.0" |
9 | log = "0.4.2" | ||
10 | parking_lot = "0.6.3" | ||
11 | once_cell = "0.1.5" | ||
12 | rayon = "1.0.2" | 9 | rayon = "1.0.2" |
13 | fst = "0.3.1" | 10 | fst = "0.3.1" |
14 | ra_syntax = { path = "../ra_syntax" } | 11 | ra_syntax = { path = "../ra_syntax" } |
diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs index 83a0dc445..f142b6c43 100644 --- a/crates/ra_analysis/src/imp.rs +++ b/crates/ra_analysis/src/imp.rs | |||
@@ -16,7 +16,8 @@ use relative_path::RelativePath; | |||
16 | use rustc_hash::FxHashSet; | 16 | use rustc_hash::FxHashSet; |
17 | 17 | ||
18 | use crate::{ | 18 | use crate::{ |
19 | descriptors::module::{ModuleTree, Problem}, | 19 | db::SyntaxDatabase, |
20 | descriptors::module::{ModulesDatabase, ModuleTree, Problem}, | ||
20 | descriptors::{FnDescriptor}, | 21 | descriptors::{FnDescriptor}, |
21 | roots::{ReadonlySourceRoot, SourceRoot, WritableSourceRoot}, | 22 | roots::{ReadonlySourceRoot, SourceRoot, WritableSourceRoot}, |
22 | CrateGraph, CrateId, Diagnostic, FileId, FileResolver, FileSystemEdit, Position, | 23 | CrateGraph, CrateId, Diagnostic, FileId, FileResolver, FileSystemEdit, Position, |
@@ -143,10 +144,10 @@ impl AnalysisImpl { | |||
143 | .unwrap() | 144 | .unwrap() |
144 | } | 145 | } |
145 | pub fn file_syntax(&self, file_id: FileId) -> File { | 146 | pub fn file_syntax(&self, file_id: FileId) -> File { |
146 | self.root(file_id).syntax(file_id) | 147 | self.root(file_id).db().file_syntax(file_id) |
147 | } | 148 | } |
148 | pub fn file_line_index(&self, file_id: FileId) -> Arc<LineIndex> { | 149 | pub fn file_line_index(&self, file_id: FileId) -> Arc<LineIndex> { |
149 | self.root(file_id).lines(file_id) | 150 | self.root(file_id).db().file_lines(file_id) |
150 | } | 151 | } |
151 | pub fn world_symbols(&self, query: Query) -> Cancelable<Vec<(FileId, FileSymbol)>> { | 152 | pub fn world_symbols(&self, query: Query) -> Cancelable<Vec<(FileId, FileSymbol)>> { |
152 | let mut buf = Vec::new(); | 153 | let mut buf = Vec::new(); |
@@ -161,14 +162,14 @@ impl AnalysisImpl { | |||
161 | } | 162 | } |
162 | pub fn parent_module(&self, file_id: FileId) -> Cancelable<Vec<(FileId, FileSymbol)>> { | 163 | pub fn parent_module(&self, file_id: FileId) -> Cancelable<Vec<(FileId, FileSymbol)>> { |
163 | let root = self.root(file_id); | 164 | let root = self.root(file_id); |
164 | let module_tree = root.module_tree()?; | 165 | let module_tree = root.db().module_tree()?; |
165 | 166 | ||
166 | let res = module_tree.modules_for_file(file_id) | 167 | let res = module_tree.modules_for_file(file_id) |
167 | .into_iter() | 168 | .into_iter() |
168 | .filter_map(|module_id| { | 169 | .filter_map(|module_id| { |
169 | let link = module_id.parent_link(&module_tree)?; | 170 | let link = module_id.parent_link(&module_tree)?; |
170 | let file_id = link.owner(&module_tree).file_id(&module_tree); | 171 | let file_id = link.owner(&module_tree).file_id(&module_tree); |
171 | let syntax = root.syntax(file_id); | 172 | let syntax = root.db().file_syntax(file_id); |
172 | let decl = link.bind_source(&module_tree, syntax.ast()); | 173 | let decl = link.bind_source(&module_tree, syntax.ast()); |
173 | 174 | ||
174 | let sym = FileSymbol { | 175 | let sym = FileSymbol { |
@@ -182,7 +183,7 @@ impl AnalysisImpl { | |||
182 | Ok(res) | 183 | Ok(res) |
183 | } | 184 | } |
184 | pub fn crate_for(&self, file_id: FileId) -> Cancelable<Vec<CrateId>> { | 185 | pub fn crate_for(&self, file_id: FileId) -> Cancelable<Vec<CrateId>> { |
185 | let module_tree = self.root(file_id).module_tree()?; | 186 | let module_tree = self.root(file_id).db().module_tree()?; |
186 | let crate_graph = &self.data.crate_graph; | 187 | let crate_graph = &self.data.crate_graph; |
187 | let res = module_tree.modules_for_file(file_id) | 188 | let res = module_tree.modules_for_file(file_id) |
188 | .into_iter() | 189 | .into_iter() |
@@ -202,8 +203,8 @@ impl AnalysisImpl { | |||
202 | offset: TextUnit, | 203 | offset: TextUnit, |
203 | ) -> Cancelable<Vec<(FileId, FileSymbol)>> { | 204 | ) -> Cancelable<Vec<(FileId, FileSymbol)>> { |
204 | let root = self.root(file_id); | 205 | let root = self.root(file_id); |
205 | let module_tree = root.module_tree()?; | 206 | let module_tree = root.db().module_tree()?; |
206 | let file = root.syntax(file_id); | 207 | let file = root.db().file_syntax(file_id); |
207 | let syntax = file.syntax(); | 208 | let syntax = file.syntax(); |
208 | if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(syntax, offset) { | 209 | if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(syntax, offset) { |
209 | // First try to resolve the symbol locally | 210 | // First try to resolve the symbol locally |
@@ -253,7 +254,7 @@ impl AnalysisImpl { | |||
253 | 254 | ||
254 | pub fn find_all_refs(&self, file_id: FileId, offset: TextUnit) -> Vec<(FileId, TextRange)> { | 255 | pub fn find_all_refs(&self, file_id: FileId, offset: TextUnit) -> Vec<(FileId, TextRange)> { |
255 | let root = self.root(file_id); | 256 | let root = self.root(file_id); |
256 | let file = root.syntax(file_id); | 257 | let file = root.db().file_syntax(file_id); |
257 | let syntax = file.syntax(); | 258 | let syntax = file.syntax(); |
258 | 259 | ||
259 | let mut ret = vec![]; | 260 | let mut ret = vec![]; |
@@ -285,8 +286,8 @@ impl AnalysisImpl { | |||
285 | 286 | ||
286 | pub fn diagnostics(&self, file_id: FileId) -> Cancelable<Vec<Diagnostic>> { | 287 | pub fn diagnostics(&self, file_id: FileId) -> Cancelable<Vec<Diagnostic>> { |
287 | let root = self.root(file_id); | 288 | let root = self.root(file_id); |
288 | let module_tree = root.module_tree()?; | 289 | let module_tree = root.db().module_tree()?; |
289 | let syntax = root.syntax(file_id); | 290 | let syntax = root.db().file_syntax(file_id); |
290 | 291 | ||
291 | let mut res = ra_editor::diagnostics(&syntax) | 292 | let mut res = ra_editor::diagnostics(&syntax) |
292 | .into_iter() | 293 | .into_iter() |
@@ -376,7 +377,7 @@ impl AnalysisImpl { | |||
376 | offset: TextUnit, | 377 | offset: TextUnit, |
377 | ) -> Cancelable<Option<(FnDescriptor, Option<usize>)>> { | 378 | ) -> Cancelable<Option<(FnDescriptor, Option<usize>)>> { |
378 | let root = self.root(file_id); | 379 | let root = self.root(file_id); |
379 | let file = root.syntax(file_id); | 380 | let file = root.db().file_syntax(file_id); |
380 | let syntax = file.syntax(); | 381 | let syntax = file.syntax(); |
381 | 382 | ||
382 | // Find the calling expression and it's NameRef | 383 | // Find the calling expression and it's NameRef |
diff --git a/crates/ra_analysis/src/lib.rs b/crates/ra_analysis/src/lib.rs index a03f44205..67a239a5c 100644 --- a/crates/ra_analysis/src/lib.rs +++ b/crates/ra_analysis/src/lib.rs | |||
@@ -1,8 +1,4 @@ | |||
1 | extern crate parking_lot; | ||
2 | #[macro_use] | ||
3 | extern crate log; | ||
4 | extern crate fst; | 1 | extern crate fst; |
5 | extern crate once_cell; | ||
6 | extern crate ra_editor; | 2 | extern crate ra_editor; |
7 | extern crate ra_syntax; | 3 | extern crate ra_syntax; |
8 | extern crate rayon; | 4 | extern crate rayon; |
diff --git a/crates/ra_analysis/src/roots.rs b/crates/ra_analysis/src/roots.rs index 15081f555..aa0243720 100644 --- a/crates/ra_analysis/src/roots.rs +++ b/crates/ra_analysis/src/roots.rs | |||
@@ -17,9 +17,7 @@ use crate::{ | |||
17 | 17 | ||
18 | pub(crate) trait SourceRoot { | 18 | pub(crate) trait SourceRoot { |
19 | fn contains(&self, file_id: FileId) -> bool; | 19 | fn contains(&self, file_id: FileId) -> bool; |
20 | fn module_tree(&self) -> Cancelable<Arc<ModuleTree>>; | 20 | fn db(&self) -> &db::RootDatabase; |
21 | fn lines(&self, file_id: FileId) -> Arc<LineIndex>; | ||
22 | fn syntax(&self, file_id: FileId) -> File; | ||
23 | fn symbols(&self, acc: &mut Vec<Arc<SymbolIndex>>) -> Cancelable<()>; | 21 | fn symbols(&self, acc: &mut Vec<Arc<SymbolIndex>>) -> Cancelable<()>; |
24 | } | 22 | } |
25 | 23 | ||
@@ -63,17 +61,11 @@ impl WritableSourceRoot { | |||
63 | } | 61 | } |
64 | 62 | ||
65 | impl SourceRoot for WritableSourceRoot { | 63 | impl SourceRoot for WritableSourceRoot { |
66 | fn module_tree(&self) -> Cancelable<Arc<ModuleTree>> { | ||
67 | self.db.module_tree() | ||
68 | } | ||
69 | fn contains(&self, file_id: FileId) -> bool { | 64 | fn contains(&self, file_id: FileId) -> bool { |
70 | self.db.file_set().files.contains(&file_id) | 65 | self.db.file_set().files.contains(&file_id) |
71 | } | 66 | } |
72 | fn lines(&self, file_id: FileId) -> Arc<LineIndex> { | 67 | fn db(&self) -> &db::RootDatabase { |
73 | self.db.file_lines(file_id) | 68 | &self.db |
74 | } | ||
75 | fn syntax(&self, file_id: FileId) -> File { | ||
76 | self.db.file_syntax(file_id) | ||
77 | } | 69 | } |
78 | fn symbols<'a>(&'a self, acc: &mut Vec<Arc<SymbolIndex>>) -> Cancelable<()> { | 70 | fn symbols<'a>(&'a self, acc: &mut Vec<Arc<SymbolIndex>>) -> Cancelable<()> { |
79 | for &file_id in self.db.file_set().files.iter() { | 71 | for &file_id in self.db.file_set().files.iter() { |
@@ -114,17 +106,11 @@ impl ReadonlySourceRoot { | |||
114 | } | 106 | } |
115 | 107 | ||
116 | impl SourceRoot for ReadonlySourceRoot { | 108 | impl SourceRoot for ReadonlySourceRoot { |
117 | fn module_tree(&self) -> Cancelable<Arc<ModuleTree>> { | ||
118 | self.db.module_tree() | ||
119 | } | ||
120 | fn contains(&self, file_id: FileId) -> bool { | 109 | fn contains(&self, file_id: FileId) -> bool { |
121 | self.db.file_set().files.contains(&file_id) | 110 | self.db.file_set().files.contains(&file_id) |
122 | } | 111 | } |
123 | fn lines(&self, file_id: FileId) -> Arc<LineIndex> { | 112 | fn db(&self) -> &db::RootDatabase { |
124 | self.db.file_lines(file_id) | 113 | &self.db |
125 | } | ||
126 | fn syntax(&self, file_id: FileId) -> File { | ||
127 | self.db.file_syntax(file_id) | ||
128 | } | 114 | } |
129 | fn symbols(&self, acc: &mut Vec<Arc<SymbolIndex>>) -> Cancelable<()> { | 115 | fn symbols(&self, acc: &mut Vec<Arc<SymbolIndex>>) -> Cancelable<()> { |
130 | acc.push(Arc::clone(&self.symbol_index)); | 116 | acc.push(Arc::clone(&self.symbol_index)); |