aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api/src')
-rw-r--r--crates/ra_ide_api/src/call_info.rs4
-rw-r--r--crates/ra_ide_api/src/completion.rs2
-rw-r--r--crates/ra_ide_api/src/extend_selection.rs2
-rw-r--r--crates/ra_ide_api/src/goto_definition.rs2
-rw-r--r--crates/ra_ide_api/src/hover.rs6
-rw-r--r--crates/ra_ide_api/src/imp.rs10
-rw-r--r--crates/ra_ide_api/src/lib.rs18
-rw-r--r--crates/ra_ide_api/src/rename.rs2
-rw-r--r--crates/ra_ide_api/src/runnables.rs2
-rw-r--r--crates/ra_ide_api/src/status.rs4
-rw-r--r--crates/ra_ide_api/src/symbol_index.rs2
-rw-r--r--crates/ra_ide_api/src/syntax_highlighting.rs2
12 files changed, 28 insertions, 28 deletions
diff --git a/crates/ra_ide_api/src/call_info.rs b/crates/ra_ide_api/src/call_info.rs
index 728f2df30..3267fff96 100644
--- a/crates/ra_ide_api/src/call_info.rs
+++ b/crates/ra_ide_api/src/call_info.rs
@@ -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.
12pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Option<CallInfo> { 12pub(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 be64f2c5a..b1867de42 100644
--- a/crates/ra_ide_api/src/completion.rs
+++ b/crates/ra_ide_api/src/completion.rs
@@ -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).
47pub(crate) fn completions(db: &db::RootDatabase, position: FilePosition) -> Option<Completions> { 47pub(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/extend_selection.rs b/crates/ra_ide_api/src/extend_selection.rs
index 1cd955357..cd2ebe471 100644
--- a/crates/ra_ide_api/src/extend_selection.rs
+++ b/crates/ra_ide_api/src/extend_selection.rs
@@ -10,7 +10,7 @@ use crate::{
10}; 10};
11 11
12pub(crate) fn extend_selection(db: &RootDatabase, frange: FileRange) -> TextRange { 12pub(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 180cc7c80..2a20c20ee 100644
--- a/crates/ra_ide_api/src/goto_definition.rs
+++ b/crates/ra_ide_api/src/goto_definition.rs
@@ -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 b6d727399..ff9ae2d9c 100644
--- a/crates/ra_ide_api/src/hover.rs
+++ b/crates/ra_ide_api/src/hover.rs
@@ -7,7 +7,7 @@ use ra_syntax::{
7use crate::{db::RootDatabase, RangeInfo, FilePosition, FileRange, NavigationTarget}; 7use crate::{db::RootDatabase, RangeInfo, FilePosition, FileRange, NavigationTarget};
8 8
9pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeInfo<String>> { 9pub(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
55pub(crate) fn type_of(db: &RootDatabase, frange: FileRange) -> Option<String> { 55pub(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
89impl NavigationTarget { 89impl 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 1222fdc44..399433a01 100644
--- a/crates/ra_ide_api/src/imp.rs
+++ b/crates/ra_ide_api/src/imp.rs
@@ -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 62a1934f4..43c8bea71 100644
--- a/crates/ra_ide_api/src/lib.rs
+++ b/crates/ra_ide_api/src/lib.rs
@@ -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 81ca0537c..db5ccf969 100644
--- a/crates/ra_ide_api/src/rename.rs
+++ b/crates/ra_ide_api/src/rename.rs
@@ -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 0f2d00f13..dc8c40ea6 100644
--- a/crates/ra_ide_api/src/runnables.rs
+++ b/crates/ra_ide_api/src/runnables.rs
@@ -22,7 +22,7 @@ pub enum RunnableKind {
22} 22}
23 23
24pub(crate) fn runnables(db: &RootDatabase, file_id: FileId) -> Vec<Runnable> { 24pub(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
7use ra_syntax::{AstNode, TreeArc, SourceFile}; 7use ra_syntax::{AstNode, TreeArc, SourceFile};
8use ra_db::{ 8use 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
18pub(crate) fn status(db: &RootDatabase) -> String { 18pub(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 230ff410e..72c93f530 100644
--- a/crates/ra_ide_api/src/symbol_index.rs
+++ b/crates/ra_ide_api/src/symbol_index.rs
@@ -61,7 +61,7 @@ pub(crate) trait SymbolsDatabase: hir::db::HirDatabase {
61 61
62fn file_symbols(db: &impl SymbolsDatabase, file_id: FileId) -> Arc<SymbolIndex> { 62fn file_symbols(db: &impl SymbolsDatabase, file_id: FileId) -> Arc<SymbolIndex> {
63 db.check_canceled(); 63 db.check_canceled();
64 let source_file = db.source_file(file_id); 64 let source_file = db.parse(file_id);
65 let mut symbols = source_file 65 let mut symbols = source_file
66 .syntax() 66 .syntax()
67 .descendants() 67 .descendants()
diff --git a/crates/ra_ide_api/src/syntax_highlighting.rs b/crates/ra_ide_api/src/syntax_highlighting.rs
index 16d23e140..26bde495b 100644
--- a/crates/ra_ide_api/src/syntax_highlighting.rs
+++ b/crates/ra_ide_api/src/syntax_highlighting.rs
@@ -7,7 +7,7 @@ use crate::{
7}; 7};
8 8
9pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRange> { 9pub(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()