diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-11-28 01:10:58 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-11-28 01:10:58 +0000 |
commit | 95c0c8f3986c8b3bcf0052d34d3ace09ebb9fa1b (patch) | |
tree | 0e5aa7337c000dd8c6ef3a7fedba68abf7feca8a /crates/ra_analysis/src/symbol_index.rs | |
parent | 9f08341aa486ea59cb488635f19e960523568fb8 (diff) | |
parent | 59e29aef633e906837f8fed604435976a46be691 (diff) |
Merge #247
247: Hir r=matklad a=matklad
This doesn't achive anything new, just a big refactoring.
The main change is that Descriptors are now called `hir`, and live in a separate crate.
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_analysis/src/symbol_index.rs')
-rw-r--r-- | crates/ra_analysis/src/symbol_index.rs | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/crates/ra_analysis/src/symbol_index.rs b/crates/ra_analysis/src/symbol_index.rs index 3a0667ecd..b48a37229 100644 --- a/crates/ra_analysis/src/symbol_index.rs +++ b/crates/ra_analysis/src/symbol_index.rs | |||
@@ -4,14 +4,36 @@ use std::{ | |||
4 | }; | 4 | }; |
5 | 5 | ||
6 | use fst::{self, Streamer}; | 6 | use fst::{self, Streamer}; |
7 | use ra_editor::{file_symbols, FileSymbol}; | 7 | use ra_editor::{self, FileSymbol}; |
8 | use ra_syntax::{ | 8 | use ra_syntax::{ |
9 | SourceFileNode, | 9 | SourceFileNode, |
10 | SyntaxKind::{self, *}, | 10 | SyntaxKind::{self, *}, |
11 | }; | 11 | }; |
12 | use ra_db::{SyntaxDatabase, SourceRootId}; | ||
12 | use rayon::prelude::*; | 13 | use rayon::prelude::*; |
13 | 14 | ||
14 | use crate::{FileId, Query}; | 15 | use crate::{ |
16 | Cancelable, | ||
17 | FileId, Query, | ||
18 | }; | ||
19 | |||
20 | salsa::query_group! { | ||
21 | pub(crate) trait SymbolsDatabase: SyntaxDatabase { | ||
22 | fn file_symbols(file_id: FileId) -> Cancelable<Arc<SymbolIndex>> { | ||
23 | type FileSymbolsQuery; | ||
24 | } | ||
25 | fn library_symbols(id: SourceRootId) -> Arc<SymbolIndex> { | ||
26 | type LibrarySymbolsQuery; | ||
27 | storage input; | ||
28 | } | ||
29 | } | ||
30 | } | ||
31 | |||
32 | fn file_symbols(db: &impl SyntaxDatabase, file_id: FileId) -> Cancelable<Arc<SymbolIndex>> { | ||
33 | db.check_canceled()?; | ||
34 | let syntax = db.source_file(file_id); | ||
35 | Ok(Arc::new(SymbolIndex::for_file(file_id, syntax))) | ||
36 | } | ||
15 | 37 | ||
16 | #[derive(Default, Debug)] | 38 | #[derive(Default, Debug)] |
17 | pub(crate) struct SymbolIndex { | 39 | pub(crate) struct SymbolIndex { |
@@ -39,7 +61,7 @@ impl SymbolIndex { | |||
39 | ) -> SymbolIndex { | 61 | ) -> SymbolIndex { |
40 | let mut symbols = files | 62 | let mut symbols = files |
41 | .flat_map(|(file_id, file)| { | 63 | .flat_map(|(file_id, file)| { |
42 | file_symbols(&file) | 64 | ra_editor::file_symbols(&file) |
43 | .into_iter() | 65 | .into_iter() |
44 | .map(move |symbol| (symbol.name.as_str().to_lowercase(), (file_id, symbol))) | 66 | .map(move |symbol| (symbol.name.as_str().to_lowercase(), (file_id, symbol))) |
45 | .collect::<Vec<_>>() | 67 | .collect::<Vec<_>>() |