diff options
Diffstat (limited to 'crates/ra_ide_api')
-rw-r--r-- | crates/ra_ide_api/src/call_info.rs | 6 | ||||
-rw-r--r-- | crates/ra_ide_api/src/completion.rs | 4 | ||||
-rw-r--r-- | crates/ra_ide_api/src/db.rs | 24 | ||||
-rw-r--r-- | crates/ra_ide_api/src/extend_selection.rs | 4 | ||||
-rw-r--r-- | crates/ra_ide_api/src/goto_definition.rs | 4 | ||||
-rw-r--r-- | crates/ra_ide_api/src/hover.rs | 8 | ||||
-rw-r--r-- | crates/ra_ide_api/src/imp.rs | 12 | ||||
-rw-r--r-- | crates/ra_ide_api/src/lib.rs | 20 | ||||
-rw-r--r-- | crates/ra_ide_api/src/rename.rs | 4 | ||||
-rw-r--r-- | crates/ra_ide_api/src/runnables.rs | 4 | ||||
-rw-r--r-- | crates/ra_ide_api/src/status.rs | 4 | ||||
-rw-r--r-- | crates/ra_ide_api/src/symbol_index.rs | 12 | ||||
-rw-r--r-- | crates/ra_ide_api/src/syntax_highlighting.rs | 4 |
13 files changed, 57 insertions, 53 deletions
diff --git a/crates/ra_ide_api/src/call_info.rs b/crates/ra_ide_api/src/call_info.rs index 0449c1902..3267fff96 100644 --- a/crates/ra_ide_api/src/call_info.rs +++ b/crates/ra_ide_api/src/call_info.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | use ra_db::SyntaxDatabase; | 1 | use ra_db::SourceDatabase; |
2 | use ra_syntax::{ | 2 | use ra_syntax::{ |
3 | AstNode, SyntaxNode, TextUnit, TextRange, | 3 | AstNode, SyntaxNode, TextUnit, TextRange, |
4 | SyntaxKind::FN_DEF, | 4 | SyntaxKind::FN_DEF, |
@@ -10,7 +10,7 @@ use crate::{FilePosition, CallInfo, db::RootDatabase}; | |||
10 | 10 | ||
11 | /// Computes parameter information for the given call expression. | 11 | /// Computes parameter information for the given call expression. |
12 | pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Option<CallInfo> { | 12 | pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Option<CallInfo> { |
13 | let file = db.source_file(position.file_id); | 13 | let file = db.parse(position.file_id); |
14 | let syntax = file.syntax(); | 14 | let syntax = file.syntax(); |
15 | 15 | ||
16 | // Find the calling expression and it's NameRef | 16 | // Find the calling expression and it's NameRef |
@@ -22,7 +22,7 @@ pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Option<Cal | |||
22 | let symbol = file_symbols | 22 | let symbol = file_symbols |
23 | .into_iter() | 23 | .into_iter() |
24 | .find(|it| it.ptr.kind() == FN_DEF)?; | 24 | .find(|it| it.ptr.kind() == FN_DEF)?; |
25 | let fn_file = db.source_file(symbol.file_id); | 25 | let fn_file = db.parse(symbol.file_id); |
26 | let fn_def = symbol.ptr.to_node(&fn_file); | 26 | let fn_def = symbol.ptr.to_node(&fn_file); |
27 | let fn_def = ast::FnDef::cast(fn_def).unwrap(); | 27 | let fn_def = ast::FnDef::cast(fn_def).unwrap(); |
28 | let mut call_info = CallInfo::new(fn_def)?; | 28 | let mut call_info = CallInfo::new(fn_def)?; |
diff --git a/crates/ra_ide_api/src/completion.rs b/crates/ra_ide_api/src/completion.rs index 565d57c37..b1867de42 100644 --- a/crates/ra_ide_api/src/completion.rs +++ b/crates/ra_ide_api/src/completion.rs | |||
@@ -9,7 +9,7 @@ mod complete_path; | |||
9 | mod complete_scope; | 9 | mod complete_scope; |
10 | mod complete_postfix; | 10 | mod complete_postfix; |
11 | 11 | ||
12 | use ra_db::SyntaxDatabase; | 12 | use ra_db::SourceDatabase; |
13 | 13 | ||
14 | use crate::{ | 14 | use crate::{ |
15 | db, | 15 | db, |
@@ -45,7 +45,7 @@ pub use crate::completion::completion_item::{CompletionItem, CompletionItemKind, | |||
45 | /// identifier prefix/fuzzy match should be done higher in the stack, together | 45 | /// identifier prefix/fuzzy match should be done higher in the stack, together |
46 | /// with ordering of completions (currently this is done by the client). | 46 | /// with ordering of completions (currently this is done by the client). |
47 | pub(crate) fn completions(db: &db::RootDatabase, position: FilePosition) -> Option<Completions> { | 47 | pub(crate) fn completions(db: &db::RootDatabase, position: FilePosition) -> Option<Completions> { |
48 | let original_file = db.source_file(position.file_id); | 48 | let original_file = db.parse(position.file_id); |
49 | let ctx = CompletionContext::new(db, &original_file, position)?; | 49 | let ctx = CompletionContext::new(db, &original_file, position)?; |
50 | 50 | ||
51 | let mut acc = Completions::default(); | 51 | let mut acc = Completions::default(); |
diff --git a/crates/ra_ide_api/src/db.rs b/crates/ra_ide_api/src/db.rs index 30891aed4..3da93ec35 100644 --- a/crates/ra_ide_api/src/db.rs +++ b/crates/ra_ide_api/src/db.rs | |||
@@ -1,15 +1,14 @@ | |||
1 | use std::sync::Arc; | 1 | use std::sync::Arc; |
2 | 2 | ||
3 | use ra_db::{ | 3 | use ra_db::{ |
4 | BaseDatabase, FileId, Canceled, | 4 | CheckCanceled, FileId, Canceled, SourceDatabase, |
5 | salsa::{self, Database}, | 5 | salsa, |
6 | }; | 6 | }; |
7 | 7 | ||
8 | use crate::{symbol_index, LineIndex}; | 8 | use crate::{LineIndex, symbol_index::{self, SymbolsDatabase}}; |
9 | 9 | ||
10 | #[salsa::database( | 10 | #[salsa::database( |
11 | ra_db::FilesDatabaseStorage, | 11 | ra_db::SourceDatabaseStorage, |
12 | ra_db::SyntaxDatabaseStorage, | ||
13 | LineIndexDatabaseStorage, | 12 | LineIndexDatabaseStorage, |
14 | symbol_index::SymbolsDatabaseStorage, | 13 | symbol_index::SymbolsDatabaseStorage, |
15 | hir::db::HirDatabaseStorage | 14 | hir::db::HirDatabaseStorage |
@@ -35,12 +34,9 @@ impl Default for RootDatabase { | |||
35 | runtime: salsa::Runtime::default(), | 34 | runtime: salsa::Runtime::default(), |
36 | interner: Default::default(), | 35 | interner: Default::default(), |
37 | }; | 36 | }; |
38 | db.query_mut(ra_db::CrateGraphQuery) | 37 | db.set_crate_graph(Default::default()); |
39 | .set((), Default::default()); | 38 | db.set_local_roots(Default::default()); |
40 | db.query_mut(ra_db::LocalRootsQuery) | 39 | db.set_library_roots(Default::default()); |
41 | .set((), Default::default()); | ||
42 | db.query_mut(ra_db::LibraryRootsQuery) | ||
43 | .set((), Default::default()); | ||
44 | db | 40 | db |
45 | } | 41 | } |
46 | } | 42 | } |
@@ -54,7 +50,7 @@ impl salsa::ParallelDatabase for RootDatabase { | |||
54 | } | 50 | } |
55 | } | 51 | } |
56 | 52 | ||
57 | impl BaseDatabase for RootDatabase {} | 53 | impl CheckCanceled for RootDatabase {} |
58 | 54 | ||
59 | impl AsRef<hir::HirInterner> for RootDatabase { | 55 | impl AsRef<hir::HirInterner> for RootDatabase { |
60 | fn as_ref(&self) -> &hir::HirInterner { | 56 | fn as_ref(&self) -> &hir::HirInterner { |
@@ -63,11 +59,11 @@ impl AsRef<hir::HirInterner> for RootDatabase { | |||
63 | } | 59 | } |
64 | 60 | ||
65 | #[salsa::query_group(LineIndexDatabaseStorage)] | 61 | #[salsa::query_group(LineIndexDatabaseStorage)] |
66 | pub(crate) trait LineIndexDatabase: ra_db::FilesDatabase + BaseDatabase { | 62 | pub(crate) trait LineIndexDatabase: ra_db::SourceDatabase + CheckCanceled { |
67 | fn line_index(&self, file_id: FileId) -> Arc<LineIndex>; | 63 | fn line_index(&self, file_id: FileId) -> Arc<LineIndex>; |
68 | } | 64 | } |
69 | 65 | ||
70 | fn line_index(db: &impl ra_db::FilesDatabase, file_id: FileId) -> Arc<LineIndex> { | 66 | fn line_index(db: &impl ra_db::SourceDatabase, file_id: FileId) -> Arc<LineIndex> { |
71 | let text = db.file_text(file_id); | 67 | let text = db.file_text(file_id); |
72 | Arc::new(LineIndex::new(&*text)) | 68 | Arc::new(LineIndex::new(&*text)) |
73 | } | 69 | } |
diff --git a/crates/ra_ide_api/src/extend_selection.rs b/crates/ra_ide_api/src/extend_selection.rs index 718b4def5..cd2ebe471 100644 --- a/crates/ra_ide_api/src/extend_selection.rs +++ b/crates/ra_ide_api/src/extend_selection.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | use ra_db::SyntaxDatabase; | 1 | use ra_db::SourceDatabase; |
2 | use ra_syntax::{ | 2 | use ra_syntax::{ |
3 | SyntaxNode, AstNode, SourceFile, | 3 | SyntaxNode, AstNode, SourceFile, |
4 | ast, algo::find_covering_node, | 4 | ast, algo::find_covering_node, |
@@ -10,7 +10,7 @@ use crate::{ | |||
10 | }; | 10 | }; |
11 | 11 | ||
12 | pub(crate) fn extend_selection(db: &RootDatabase, frange: FileRange) -> TextRange { | 12 | pub(crate) fn extend_selection(db: &RootDatabase, frange: FileRange) -> TextRange { |
13 | let source_file = db.source_file(frange.file_id); | 13 | let source_file = db.parse(frange.file_id); |
14 | if let Some(range) = extend_selection_in_macro(db, &source_file, frange) { | 14 | if let Some(range) = extend_selection_in_macro(db, &source_file, frange) { |
15 | return range; | 15 | return range; |
16 | } | 16 | } |
diff --git a/crates/ra_ide_api/src/goto_definition.rs b/crates/ra_ide_api/src/goto_definition.rs index dc0c50918..2a20c20ee 100644 --- a/crates/ra_ide_api/src/goto_definition.rs +++ b/crates/ra_ide_api/src/goto_definition.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | use ra_db::{FileId, SyntaxDatabase}; | 1 | use ra_db::{FileId, SourceDatabase}; |
2 | use ra_syntax::{ | 2 | use ra_syntax::{ |
3 | AstNode, ast, | 3 | AstNode, ast, |
4 | algo::find_node_at_offset, | 4 | algo::find_node_at_offset, |
@@ -11,7 +11,7 @@ pub(crate) fn goto_definition( | |||
11 | db: &RootDatabase, | 11 | db: &RootDatabase, |
12 | position: FilePosition, | 12 | position: FilePosition, |
13 | ) -> Option<RangeInfo<Vec<NavigationTarget>>> { | 13 | ) -> Option<RangeInfo<Vec<NavigationTarget>>> { |
14 | let file = db.source_file(position.file_id); | 14 | let file = db.parse(position.file_id); |
15 | let syntax = file.syntax(); | 15 | let syntax = file.syntax(); |
16 | if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(syntax, position.offset) { | 16 | if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(syntax, position.offset) { |
17 | let navs = reference_definition(db, position.file_id, name_ref).to_vec(); | 17 | let navs = reference_definition(db, position.file_id, name_ref).to_vec(); |
diff --git a/crates/ra_ide_api/src/hover.rs b/crates/ra_ide_api/src/hover.rs index 4d4bfbc4d..ff9ae2d9c 100644 --- a/crates/ra_ide_api/src/hover.rs +++ b/crates/ra_ide_api/src/hover.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | use ra_db::{SyntaxDatabase}; | 1 | use ra_db::SourceDatabase; |
2 | use ra_syntax::{ | 2 | use ra_syntax::{ |
3 | AstNode, SyntaxNode, TreeArc, ast, | 3 | AstNode, SyntaxNode, TreeArc, ast, |
4 | algo::{find_covering_node, find_node_at_offset, find_leaf_at_offset, visit::{visitor, Visitor}}, | 4 | algo::{find_covering_node, find_node_at_offset, find_leaf_at_offset, visit::{visitor, Visitor}}, |
@@ -7,7 +7,7 @@ use ra_syntax::{ | |||
7 | use crate::{db::RootDatabase, RangeInfo, FilePosition, FileRange, NavigationTarget}; | 7 | use crate::{db::RootDatabase, RangeInfo, FilePosition, FileRange, NavigationTarget}; |
8 | 8 | ||
9 | pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeInfo<String>> { | 9 | pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeInfo<String>> { |
10 | let file = db.source_file(position.file_id); | 10 | let file = db.parse(position.file_id); |
11 | let mut res = Vec::new(); | 11 | let mut res = Vec::new(); |
12 | 12 | ||
13 | let mut range = None; | 13 | let mut range = None; |
@@ -53,7 +53,7 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeIn | |||
53 | } | 53 | } |
54 | 54 | ||
55 | pub(crate) fn type_of(db: &RootDatabase, frange: FileRange) -> Option<String> { | 55 | pub(crate) fn type_of(db: &RootDatabase, frange: FileRange) -> Option<String> { |
56 | let file = db.source_file(frange.file_id); | 56 | let file = db.parse(frange.file_id); |
57 | let syntax = file.syntax(); | 57 | let syntax = file.syntax(); |
58 | let leaf_node = find_covering_node(syntax, frange.range); | 58 | let leaf_node = find_covering_node(syntax, frange.range); |
59 | // if we picked identifier, expand to pattern/expression | 59 | // if we picked identifier, expand to pattern/expression |
@@ -88,7 +88,7 @@ fn doc_text_for(db: &RootDatabase, nav: NavigationTarget) -> Option<String> { | |||
88 | 88 | ||
89 | impl NavigationTarget { | 89 | impl NavigationTarget { |
90 | fn node(&self, db: &RootDatabase) -> Option<TreeArc<SyntaxNode>> { | 90 | fn node(&self, db: &RootDatabase) -> Option<TreeArc<SyntaxNode>> { |
91 | let source_file = db.source_file(self.file_id()); | 91 | let source_file = db.parse(self.file_id()); |
92 | let source_file = source_file.syntax(); | 92 | let source_file = source_file.syntax(); |
93 | let node = source_file | 93 | let node = source_file |
94 | .descendants() | 94 | .descendants() |
diff --git a/crates/ra_ide_api/src/imp.rs b/crates/ra_ide_api/src/imp.rs index bd9e3f1e3..399433a01 100644 --- a/crates/ra_ide_api/src/imp.rs +++ b/crates/ra_ide_api/src/imp.rs | |||
@@ -4,7 +4,7 @@ use hir::{ | |||
4 | self, Problem, source_binder | 4 | self, Problem, source_binder |
5 | }; | 5 | }; |
6 | use ra_db::{ | 6 | use ra_db::{ |
7 | FilesDatabase, SourceRoot, SourceRootId, SyntaxDatabase, | 7 | SourceDatabase, SourceRoot, SourceRootId, |
8 | salsa::{Database, SweepStrategy}, | 8 | salsa::{Database, SweepStrategy}, |
9 | }; | 9 | }; |
10 | use ra_ide_api_light::{self, assists, LocalEdit, Severity}; | 10 | use ra_ide_api_light::{self, assists, LocalEdit, Severity}; |
@@ -76,9 +76,9 @@ impl db::RootDatabase { | |||
76 | /// syntax trees. However, if we actually do that, everything is recomputed | 76 | /// syntax trees. However, if we actually do that, everything is recomputed |
77 | /// for some reason. Needs investigation. | 77 | /// for some reason. Needs investigation. |
78 | pub(crate) fn collect_garbage(&mut self) { | 78 | pub(crate) fn collect_garbage(&mut self) { |
79 | self.query(ra_db::SourceFileQuery) | 79 | self.query(ra_db::ParseQuery) |
80 | .sweep(SweepStrategy::default().discard_values()); | 80 | .sweep(SweepStrategy::default().discard_values()); |
81 | self.query(hir::db::HirSourceFileQuery) | 81 | self.query(hir::db::HirParseQuery) |
82 | .sweep(SweepStrategy::default().discard_values()); | 82 | .sweep(SweepStrategy::default().discard_values()); |
83 | self.query(hir::db::FileItemsQuery) | 83 | self.query(hir::db::FileItemsQuery) |
84 | .sweep(SweepStrategy::default().discard_values()); | 84 | .sweep(SweepStrategy::default().discard_values()); |
@@ -102,7 +102,7 @@ impl db::RootDatabase { | |||
102 | } | 102 | } |
103 | 103 | ||
104 | pub(crate) fn find_all_refs(&self, position: FilePosition) -> Vec<(FileId, TextRange)> { | 104 | pub(crate) fn find_all_refs(&self, position: FilePosition) -> Vec<(FileId, TextRange)> { |
105 | let file = self.source_file(position.file_id); | 105 | let file = self.parse(position.file_id); |
106 | // Find the binding associated with the offset | 106 | // Find the binding associated with the offset |
107 | let (binding, descr) = match find_binding(self, &file, position) { | 107 | let (binding, descr) = match find_binding(self, &file, position) { |
108 | None => return Vec::new(), | 108 | None => return Vec::new(), |
@@ -150,7 +150,7 @@ impl db::RootDatabase { | |||
150 | } | 150 | } |
151 | 151 | ||
152 | pub(crate) fn diagnostics(&self, file_id: FileId) -> Vec<Diagnostic> { | 152 | pub(crate) fn diagnostics(&self, file_id: FileId) -> Vec<Diagnostic> { |
153 | let syntax = self.source_file(file_id); | 153 | let syntax = self.parse(file_id); |
154 | 154 | ||
155 | let mut res = ra_ide_api_light::diagnostics(&syntax) | 155 | let mut res = ra_ide_api_light::diagnostics(&syntax) |
156 | .into_iter() | 156 | .into_iter() |
@@ -214,7 +214,7 @@ impl db::RootDatabase { | |||
214 | } | 214 | } |
215 | 215 | ||
216 | pub(crate) fn assists(&self, frange: FileRange) -> Vec<SourceChange> { | 216 | pub(crate) fn assists(&self, frange: FileRange) -> Vec<SourceChange> { |
217 | let file = self.source_file(frange.file_id); | 217 | let file = self.parse(frange.file_id); |
218 | assists::assists(&file, frange.range) | 218 | assists::assists(&file, frange.range) |
219 | .into_iter() | 219 | .into_iter() |
220 | .map(|local_edit| SourceChange::from_local_edit(frange.file_id, local_edit)) | 220 | .map(|local_edit| SourceChange::from_local_edit(frange.file_id, local_edit)) |
diff --git a/crates/ra_ide_api/src/lib.rs b/crates/ra_ide_api/src/lib.rs index ffd026b04..43c8bea71 100644 --- a/crates/ra_ide_api/src/lib.rs +++ b/crates/ra_ide_api/src/lib.rs | |||
@@ -34,7 +34,7 @@ use std::{fmt, sync::Arc}; | |||
34 | use ra_syntax::{SourceFile, TreeArc, TextRange, TextUnit}; | 34 | use ra_syntax::{SourceFile, TreeArc, TextRange, TextUnit}; |
35 | use ra_text_edit::TextEdit; | 35 | use ra_text_edit::TextEdit; |
36 | use ra_db::{ | 36 | use ra_db::{ |
37 | SyntaxDatabase, FilesDatabase, BaseDatabase, | 37 | SourceDatabase, CheckCanceled, |
38 | salsa::{self, ParallelDatabase}, | 38 | salsa::{self, ParallelDatabase}, |
39 | }; | 39 | }; |
40 | use rayon::prelude::*; | 40 | use rayon::prelude::*; |
@@ -313,7 +313,7 @@ impl Analysis { | |||
313 | 313 | ||
314 | /// Gets the syntax tree of the file. | 314 | /// Gets the syntax tree of the file. |
315 | pub fn parse(&self, file_id: FileId) -> TreeArc<SourceFile> { | 315 | pub fn parse(&self, file_id: FileId) -> TreeArc<SourceFile> { |
316 | self.db.source_file(file_id).clone() | 316 | self.db.parse(file_id).clone() |
317 | } | 317 | } |
318 | 318 | ||
319 | /// Gets the file's `LineIndex`: data structure to convert between absolute | 319 | /// Gets the file's `LineIndex`: data structure to convert between absolute |
@@ -330,21 +330,21 @@ impl Analysis { | |||
330 | /// Returns position of the mathcing brace (all types of braces are | 330 | /// Returns position of the mathcing brace (all types of braces are |
331 | /// supported). | 331 | /// supported). |
332 | pub fn matching_brace(&self, position: FilePosition) -> Option<TextUnit> { | 332 | pub fn matching_brace(&self, position: FilePosition) -> Option<TextUnit> { |
333 | let file = self.db.source_file(position.file_id); | 333 | let file = self.db.parse(position.file_id); |
334 | ra_ide_api_light::matching_brace(&file, position.offset) | 334 | ra_ide_api_light::matching_brace(&file, position.offset) |
335 | } | 335 | } |
336 | 336 | ||
337 | /// Returns a syntax tree represented as `String`, for debug purposes. | 337 | /// Returns a syntax tree represented as `String`, for debug purposes. |
338 | // FIXME: use a better name here. | 338 | // FIXME: use a better name here. |
339 | pub fn syntax_tree(&self, file_id: FileId) -> String { | 339 | pub fn syntax_tree(&self, file_id: FileId) -> String { |
340 | let file = self.db.source_file(file_id); | 340 | let file = self.db.parse(file_id); |
341 | ra_ide_api_light::syntax_tree(&file) | 341 | ra_ide_api_light::syntax_tree(&file) |
342 | } | 342 | } |
343 | 343 | ||
344 | /// Returns an edit to remove all newlines in the range, cleaning up minor | 344 | /// Returns an edit to remove all newlines in the range, cleaning up minor |
345 | /// stuff like trailing commas. | 345 | /// stuff like trailing commas. |
346 | pub fn join_lines(&self, frange: FileRange) -> SourceChange { | 346 | pub fn join_lines(&self, frange: FileRange) -> SourceChange { |
347 | let file = self.db.source_file(frange.file_id); | 347 | let file = self.db.parse(frange.file_id); |
348 | SourceChange::from_local_edit( | 348 | SourceChange::from_local_edit( |
349 | frange.file_id, | 349 | frange.file_id, |
350 | ra_ide_api_light::join_lines(&file, frange.range), | 350 | ra_ide_api_light::join_lines(&file, frange.range), |
@@ -354,7 +354,7 @@ impl Analysis { | |||
354 | /// Returns an edit which should be applied when opening a new line, fixing | 354 | /// Returns an edit which should be applied when opening a new line, fixing |
355 | /// up minor stuff like continuing the comment. | 355 | /// up minor stuff like continuing the comment. |
356 | pub fn on_enter(&self, position: FilePosition) -> Option<SourceChange> { | 356 | pub fn on_enter(&self, position: FilePosition) -> Option<SourceChange> { |
357 | let file = self.db.source_file(position.file_id); | 357 | let file = self.db.parse(position.file_id); |
358 | let edit = ra_ide_api_light::on_enter(&file, position.offset)?; | 358 | let edit = ra_ide_api_light::on_enter(&file, position.offset)?; |
359 | Some(SourceChange::from_local_edit(position.file_id, edit)) | 359 | Some(SourceChange::from_local_edit(position.file_id, edit)) |
360 | } | 360 | } |
@@ -363,14 +363,14 @@ impl Analysis { | |||
363 | /// this works when adding `let =`. | 363 | /// this works when adding `let =`. |
364 | // FIXME: use a snippet completion instead of this hack here. | 364 | // FIXME: use a snippet completion instead of this hack here. |
365 | pub fn on_eq_typed(&self, position: FilePosition) -> Option<SourceChange> { | 365 | pub fn on_eq_typed(&self, position: FilePosition) -> Option<SourceChange> { |
366 | let file = self.db.source_file(position.file_id); | 366 | let file = self.db.parse(position.file_id); |
367 | let edit = ra_ide_api_light::on_eq_typed(&file, position.offset)?; | 367 | let edit = ra_ide_api_light::on_eq_typed(&file, position.offset)?; |
368 | Some(SourceChange::from_local_edit(position.file_id, edit)) | 368 | Some(SourceChange::from_local_edit(position.file_id, edit)) |
369 | } | 369 | } |
370 | 370 | ||
371 | /// Returns an edit which should be applied when a dot ('.') is typed on a blank line, indenting the line appropriately. | 371 | /// Returns an edit which should be applied when a dot ('.') is typed on a blank line, indenting the line appropriately. |
372 | pub fn on_dot_typed(&self, position: FilePosition) -> Option<SourceChange> { | 372 | pub fn on_dot_typed(&self, position: FilePosition) -> Option<SourceChange> { |
373 | let file = self.db.source_file(position.file_id); | 373 | let file = self.db.parse(position.file_id); |
374 | let edit = ra_ide_api_light::on_dot_typed(&file, position.offset)?; | 374 | let edit = ra_ide_api_light::on_dot_typed(&file, position.offset)?; |
375 | Some(SourceChange::from_local_edit(position.file_id, edit)) | 375 | Some(SourceChange::from_local_edit(position.file_id, edit)) |
376 | } | 376 | } |
@@ -378,13 +378,13 @@ impl Analysis { | |||
378 | /// Returns a tree representation of symbols in the file. Useful to draw a | 378 | /// Returns a tree representation of symbols in the file. Useful to draw a |
379 | /// file outline. | 379 | /// file outline. |
380 | pub fn file_structure(&self, file_id: FileId) -> Vec<StructureNode> { | 380 | pub fn file_structure(&self, file_id: FileId) -> Vec<StructureNode> { |
381 | let file = self.db.source_file(file_id); | 381 | let file = self.db.parse(file_id); |
382 | ra_ide_api_light::file_structure(&file) | 382 | ra_ide_api_light::file_structure(&file) |
383 | } | 383 | } |
384 | 384 | ||
385 | /// Returns the set of folding ranges. | 385 | /// Returns the set of folding ranges. |
386 | pub fn folding_ranges(&self, file_id: FileId) -> Vec<Fold> { | 386 | pub fn folding_ranges(&self, file_id: FileId) -> Vec<Fold> { |
387 | let file = self.db.source_file(file_id); | 387 | let file = self.db.parse(file_id); |
388 | ra_ide_api_light::folding_ranges(&file) | 388 | ra_ide_api_light::folding_ranges(&file) |
389 | } | 389 | } |
390 | 390 | ||
diff --git a/crates/ra_ide_api/src/rename.rs b/crates/ra_ide_api/src/rename.rs index 5b767addd..db5ccf969 100644 --- a/crates/ra_ide_api/src/rename.rs +++ b/crates/ra_ide_api/src/rename.rs | |||
@@ -17,7 +17,7 @@ use crate::{ | |||
17 | SourceChange, | 17 | SourceChange, |
18 | SourceFileEdit, | 18 | SourceFileEdit, |
19 | }; | 19 | }; |
20 | use ra_db::{FilesDatabase, SyntaxDatabase}; | 20 | use ra_db::SourceDatabase; |
21 | use relative_path::RelativePath; | 21 | use relative_path::RelativePath; |
22 | 22 | ||
23 | pub(crate) fn rename( | 23 | pub(crate) fn rename( |
@@ -25,7 +25,7 @@ pub(crate) fn rename( | |||
25 | position: FilePosition, | 25 | position: FilePosition, |
26 | new_name: &str, | 26 | new_name: &str, |
27 | ) -> Option<SourceChange> { | 27 | ) -> Option<SourceChange> { |
28 | let source_file = db.source_file(position.file_id); | 28 | let source_file = db.parse(position.file_id); |
29 | let syntax = source_file.syntax(); | 29 | let syntax = source_file.syntax(); |
30 | 30 | ||
31 | if let Some((ast_name, ast_module)) = find_name_and_module_at_offset(syntax, position) { | 31 | if let Some((ast_name, ast_module)) = find_name_and_module_at_offset(syntax, position) { |
diff --git a/crates/ra_ide_api/src/runnables.rs b/crates/ra_ide_api/src/runnables.rs index 0f9f8deb3..dc8c40ea6 100644 --- a/crates/ra_ide_api/src/runnables.rs +++ b/crates/ra_ide_api/src/runnables.rs | |||
@@ -3,7 +3,7 @@ use ra_syntax::{ | |||
3 | TextRange, SyntaxNode, | 3 | TextRange, SyntaxNode, |
4 | ast::{self, AstNode, NameOwner, ModuleItemOwner}, | 4 | ast::{self, AstNode, NameOwner, ModuleItemOwner}, |
5 | }; | 5 | }; |
6 | use ra_db::SyntaxDatabase; | 6 | use ra_db::SourceDatabase; |
7 | 7 | ||
8 | use crate::{db::RootDatabase, FileId}; | 8 | use crate::{db::RootDatabase, FileId}; |
9 | 9 | ||
@@ -22,7 +22,7 @@ pub enum RunnableKind { | |||
22 | } | 22 | } |
23 | 23 | ||
24 | pub(crate) fn runnables(db: &RootDatabase, file_id: FileId) -> Vec<Runnable> { | 24 | pub(crate) fn runnables(db: &RootDatabase, file_id: FileId) -> Vec<Runnable> { |
25 | let source_file = db.source_file(file_id); | 25 | let source_file = db.parse(file_id); |
26 | source_file | 26 | source_file |
27 | .syntax() | 27 | .syntax() |
28 | .descendants() | 28 | .descendants() |
diff --git a/crates/ra_ide_api/src/status.rs b/crates/ra_ide_api/src/status.rs index 59159df98..e11eed223 100644 --- a/crates/ra_ide_api/src/status.rs +++ b/crates/ra_ide_api/src/status.rs | |||
@@ -6,7 +6,7 @@ use std::{ | |||
6 | 6 | ||
7 | use ra_syntax::{AstNode, TreeArc, SourceFile}; | 7 | use ra_syntax::{AstNode, TreeArc, SourceFile}; |
8 | use ra_db::{ | 8 | use ra_db::{ |
9 | SourceFileQuery, FileTextQuery, SourceRootId, | 9 | ParseQuery, FileTextQuery, SourceRootId, |
10 | salsa::{Database, debug::{DebugQueryTable, TableEntry}}, | 10 | salsa::{Database, debug::{DebugQueryTable, TableEntry}}, |
11 | }; | 11 | }; |
12 | 12 | ||
@@ -17,7 +17,7 @@ use crate::{ | |||
17 | 17 | ||
18 | pub(crate) fn status(db: &RootDatabase) -> String { | 18 | pub(crate) fn status(db: &RootDatabase) -> String { |
19 | let files_stats = db.query(FileTextQuery).entries::<FilesStats>(); | 19 | let files_stats = db.query(FileTextQuery).entries::<FilesStats>(); |
20 | let syntax_tree_stats = db.query(SourceFileQuery).entries::<SyntaxTreeStats>(); | 20 | let syntax_tree_stats = db.query(ParseQuery).entries::<SyntaxTreeStats>(); |
21 | let symbols_stats = db | 21 | let symbols_stats = db |
22 | .query(LibrarySymbolsQuery) | 22 | .query(LibrarySymbolsQuery) |
23 | .entries::<LibrarySymbolsStats>(); | 23 | .entries::<LibrarySymbolsStats>(); |
diff --git a/crates/ra_ide_api/src/symbol_index.rs b/crates/ra_ide_api/src/symbol_index.rs index e073a349e..72c93f530 100644 --- a/crates/ra_ide_api/src/symbol_index.rs +++ b/crates/ra_ide_api/src/symbol_index.rs | |||
@@ -34,7 +34,7 @@ use ra_syntax::{ | |||
34 | ast::{self, NameOwner}, | 34 | ast::{self, NameOwner}, |
35 | }; | 35 | }; |
36 | use ra_db::{ | 36 | use ra_db::{ |
37 | SourceRootId, FilesDatabase, | 37 | SourceRootId, SourceDatabase, |
38 | salsa::{self, ParallelDatabase}, | 38 | salsa::{self, ParallelDatabase}, |
39 | }; | 39 | }; |
40 | use rayon::prelude::*; | 40 | use rayon::prelude::*; |
@@ -49,11 +49,19 @@ pub(crate) trait SymbolsDatabase: hir::db::HirDatabase { | |||
49 | fn file_symbols(&self, file_id: FileId) -> Arc<SymbolIndex>; | 49 | fn file_symbols(&self, file_id: FileId) -> Arc<SymbolIndex>; |
50 | #[salsa::input] | 50 | #[salsa::input] |
51 | fn library_symbols(&self, id: SourceRootId) -> Arc<SymbolIndex>; | 51 | fn library_symbols(&self, id: SourceRootId) -> Arc<SymbolIndex>; |
52 | /// The set of "local" (that is, from the current workspace) roots. | ||
53 | /// Files in local roots are assumed to change frequently. | ||
54 | #[salsa::input] | ||
55 | fn local_roots(&self) -> Arc<Vec<SourceRootId>>; | ||
56 | /// The set of roots for crates.io libraries. | ||
57 | /// Files in libraries are assumed to never change. | ||
58 | #[salsa::input] | ||
59 | fn library_roots(&self) -> Arc<Vec<SourceRootId>>; | ||
52 | } | 60 | } |
53 | 61 | ||
54 | fn file_symbols(db: &impl SymbolsDatabase, file_id: FileId) -> Arc<SymbolIndex> { | 62 | fn file_symbols(db: &impl SymbolsDatabase, file_id: FileId) -> Arc<SymbolIndex> { |
55 | db.check_canceled(); | 63 | db.check_canceled(); |
56 | let source_file = db.source_file(file_id); | 64 | let source_file = db.parse(file_id); |
57 | let mut symbols = source_file | 65 | let mut symbols = source_file |
58 | .syntax() | 66 | .syntax() |
59 | .descendants() | 67 | .descendants() |
diff --git a/crates/ra_ide_api/src/syntax_highlighting.rs b/crates/ra_ide_api/src/syntax_highlighting.rs index a4d3ad005..26bde495b 100644 --- a/crates/ra_ide_api/src/syntax_highlighting.rs +++ b/crates/ra_ide_api/src/syntax_highlighting.rs | |||
@@ -1,5 +1,5 @@ | |||
1 | use ra_syntax::{ast, AstNode,}; | 1 | use ra_syntax::{ast, AstNode,}; |
2 | use ra_db::SyntaxDatabase; | 2 | use ra_db::SourceDatabase; |
3 | 3 | ||
4 | use crate::{ | 4 | use crate::{ |
5 | FileId, HighlightedRange, | 5 | FileId, HighlightedRange, |
@@ -7,7 +7,7 @@ use crate::{ | |||
7 | }; | 7 | }; |
8 | 8 | ||
9 | pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRange> { | 9 | pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRange> { |
10 | let source_file = db.source_file(file_id); | 10 | let source_file = db.parse(file_id); |
11 | let mut res = ra_ide_api_light::highlight(source_file.syntax()); | 11 | let mut res = ra_ide_api_light::highlight(source_file.syntax()); |
12 | for macro_call in source_file | 12 | for macro_call in source_file |
13 | .syntax() | 13 | .syntax() |