diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-01-26 08:55:38 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-01-26 08:55:38 +0000 |
commit | 8b6dea348fa02a7ce8107a1e73917f0597f2a91d (patch) | |
tree | 36b2bc1e21eccda2c624e3dd70ddd7052b9f9907 /crates | |
parent | c869ee219a80af1993496e00490dc107202ff55c (diff) | |
parent | 9457b1f0e64d38e7dc24d8c66a52ffef759d4dbf (diff) |
Merge #666
666: rename source_file -> parse r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_db/src/lib.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir/src/db.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir/src/ids.rs | 9 | ||||
-rw-r--r-- | crates/ra_hir/src/nameres/lower.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir/src/query_definitions.rs | 7 | ||||
-rw-r--r-- | crates/ra_hir/src/source_binder.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/tests.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide_api/src/call_info.rs | 4 | ||||
-rw-r--r-- | crates/ra_ide_api/src/completion.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide_api/src/extend_selection.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide_api/src/goto_definition.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide_api/src/hover.rs | 6 | ||||
-rw-r--r-- | crates/ra_ide_api/src/imp.rs | 10 | ||||
-rw-r--r-- | crates/ra_ide_api/src/lib.rs | 18 | ||||
-rw-r--r-- | crates/ra_ide_api/src/rename.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide_api/src/runnables.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide_api/src/status.rs | 4 | ||||
-rw-r--r-- | crates/ra_ide_api/src/symbol_index.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide_api/src/syntax_highlighting.rs | 2 |
19 files changed, 41 insertions, 47 deletions
diff --git a/crates/ra_db/src/lib.rs b/crates/ra_db/src/lib.rs index 2664dc69a..6e17f33f0 100644 --- a/crates/ra_db/src/lib.rs +++ b/crates/ra_db/src/lib.rs | |||
@@ -71,7 +71,7 @@ pub trait SourceDatabase: salsa::Database + CheckCanceled { | |||
71 | #[salsa::input] | 71 | #[salsa::input] |
72 | fn file_text(&self, file_id: FileId) -> Arc<String>; | 72 | fn file_text(&self, file_id: FileId) -> Arc<String>; |
73 | // Parses the file into the syntax tree. | 73 | // Parses the file into the syntax tree. |
74 | fn source_file(&self, file_id: FileId) -> TreeArc<SourceFile>; | 74 | fn parse(&self, file_id: FileId) -> TreeArc<SourceFile>; |
75 | /// Path to a file, relative to the root of its source root. | 75 | /// Path to a file, relative to the root of its source root. |
76 | #[salsa::input] | 76 | #[salsa::input] |
77 | fn file_relative_path(&self, file_id: FileId) -> RelativePathBuf; | 77 | fn file_relative_path(&self, file_id: FileId) -> RelativePathBuf; |
@@ -98,7 +98,7 @@ fn source_root_crates(db: &impl SourceDatabase, id: SourceRootId) -> Arc<Vec<Cra | |||
98 | Arc::new(res) | 98 | Arc::new(res) |
99 | } | 99 | } |
100 | 100 | ||
101 | fn source_file(db: &impl SourceDatabase, file_id: FileId) -> TreeArc<SourceFile> { | 101 | fn parse(db: &impl SourceDatabase, file_id: FileId) -> TreeArc<SourceFile> { |
102 | let text = db.file_text(file_id); | 102 | let text = db.file_text(file_id); |
103 | SourceFile::parse(&*text) | 103 | SourceFile::parse(&*text) |
104 | } | 104 | } |
diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs index 9b5b79d38..5df4bd4a1 100644 --- a/crates/ra_hir/src/db.rs +++ b/crates/ra_hir/src/db.rs | |||
@@ -20,8 +20,8 @@ use crate::{ | |||
20 | 20 | ||
21 | #[salsa::query_group(HirDatabaseStorage)] | 21 | #[salsa::query_group(HirDatabaseStorage)] |
22 | pub trait HirDatabase: SourceDatabase + AsRef<HirInterner> { | 22 | pub trait HirDatabase: SourceDatabase + AsRef<HirInterner> { |
23 | #[salsa::invoke(HirFileId::hir_source_file)] | 23 | #[salsa::invoke(HirFileId::hir_parse)] |
24 | fn hir_source_file(&self, file_id: HirFileId) -> TreeArc<SourceFile>; | 24 | fn hir_parse(&self, file_id: HirFileId) -> TreeArc<SourceFile>; |
25 | 25 | ||
26 | #[salsa::invoke(crate::macros::expand_macro_invocation)] | 26 | #[salsa::invoke(crate::macros::expand_macro_invocation)] |
27 | fn expand_macro_invocation(&self, invoc: MacroCallId) -> Option<Arc<MacroExpansion>>; | 27 | fn expand_macro_invocation(&self, invoc: MacroCallId) -> Option<Arc<MacroExpansion>>; |
diff --git a/crates/ra_hir/src/ids.rs b/crates/ra_hir/src/ids.rs index 5272656ec..7dd4b540e 100644 --- a/crates/ra_hir/src/ids.rs +++ b/crates/ra_hir/src/ids.rs | |||
@@ -86,12 +86,9 @@ impl HirFileId { | |||
86 | } | 86 | } |
87 | } | 87 | } |
88 | 88 | ||
89 | pub(crate) fn hir_source_file( | 89 | pub(crate) fn hir_parse(db: &impl HirDatabase, file_id: HirFileId) -> TreeArc<SourceFile> { |
90 | db: &impl HirDatabase, | ||
91 | file_id: HirFileId, | ||
92 | ) -> TreeArc<SourceFile> { | ||
93 | match file_id.0 { | 90 | match file_id.0 { |
94 | HirFileIdRepr::File(file_id) => db.source_file(file_id), | 91 | HirFileIdRepr::File(file_id) => db.parse(file_id), |
95 | HirFileIdRepr::Macro(m) => { | 92 | HirFileIdRepr::Macro(m) => { |
96 | if let Some(exp) = db.expand_macro_invocation(m) { | 93 | if let Some(exp) = db.expand_macro_invocation(m) { |
97 | return exp.file(); | 94 | return exp.file(); |
@@ -370,7 +367,7 @@ impl SourceFileItems { | |||
370 | self.arena.iter().map(|(_id, i)| i).collect::<Vec<_>>(), | 367 | self.arena.iter().map(|(_id, i)| i).collect::<Vec<_>>(), |
371 | ); | 368 | ); |
372 | } | 369 | } |
373 | pub fn id_of_source_file(&self) -> SourceFileItemId { | 370 | pub fn id_of_parse(&self) -> SourceFileItemId { |
374 | let (id, _syntax) = self.arena.iter().next().unwrap(); | 371 | let (id, _syntax) = self.arena.iter().next().unwrap(); |
375 | id | 372 | id |
376 | } | 373 | } |
diff --git a/crates/ra_hir/src/nameres/lower.rs b/crates/ra_hir/src/nameres/lower.rs index b4fe99ea7..1d77548f3 100644 --- a/crates/ra_hir/src/nameres/lower.rs +++ b/crates/ra_hir/src/nameres/lower.rs | |||
@@ -129,7 +129,7 @@ impl LoweredModule { | |||
129 | let id = loc.id(db); | 129 | let id = loc.id(db); |
130 | let file_id = HirFileId::from(id); | 130 | let file_id = HirFileId::from(id); |
131 | //FIXME: expand recursively | 131 | //FIXME: expand recursively |
132 | for item in db.hir_source_file(file_id).items() { | 132 | for item in db.hir_parse(file_id).items() { |
133 | self.add_def_id(source_map, db, module, file_id, item); | 133 | self.add_def_id(source_map, db, module, file_id, item); |
134 | } | 134 | } |
135 | } | 135 | } |
diff --git a/crates/ra_hir/src/query_definitions.rs b/crates/ra_hir/src/query_definitions.rs index cf8c7e435..61c93a964 100644 --- a/crates/ra_hir/src/query_definitions.rs +++ b/crates/ra_hir/src/query_definitions.rs | |||
@@ -23,7 +23,7 @@ pub(super) fn fn_scopes(db: &impl HirDatabase, func: Function) -> Arc<FnScopes> | |||
23 | } | 23 | } |
24 | 24 | ||
25 | pub(super) fn file_items(db: &impl HirDatabase, file_id: HirFileId) -> Arc<SourceFileItems> { | 25 | pub(super) fn file_items(db: &impl HirDatabase, file_id: HirFileId) -> Arc<SourceFileItems> { |
26 | let source_file = db.hir_source_file(file_id); | 26 | let source_file = db.hir_parse(file_id); |
27 | let res = SourceFileItems::new(file_id, &source_file); | 27 | let res = SourceFileItems::new(file_id, &source_file); |
28 | Arc::new(res) | 28 | Arc::new(res) |
29 | } | 29 | } |
@@ -34,10 +34,7 @@ pub(super) fn file_item( | |||
34 | ) -> TreeArc<SyntaxNode> { | 34 | ) -> TreeArc<SyntaxNode> { |
35 | match source_item_id.item_id { | 35 | match source_item_id.item_id { |
36 | Some(id) => db.file_items(source_item_id.file_id)[id].to_owned(), | 36 | Some(id) => db.file_items(source_item_id.file_id)[id].to_owned(), |
37 | None => db | 37 | None => db.hir_parse(source_item_id.file_id).syntax().to_owned(), |
38 | .hir_source_file(source_item_id.file_id) | ||
39 | .syntax() | ||
40 | .to_owned(), | ||
41 | } | 38 | } |
42 | } | 39 | } |
43 | 40 | ||
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs index dbe040805..c0b3f1cd4 100644 --- a/crates/ra_hir/src/source_binder.rs +++ b/crates/ra_hir/src/source_binder.rs | |||
@@ -43,7 +43,7 @@ pub fn module_from_declaration( | |||
43 | 43 | ||
44 | /// Locates the module by position in the source code. | 44 | /// Locates the module by position in the source code. |
45 | pub fn module_from_position(db: &impl HirDatabase, position: FilePosition) -> Option<Module> { | 45 | pub fn module_from_position(db: &impl HirDatabase, position: FilePosition) -> Option<Module> { |
46 | let file = db.source_file(position.file_id); | 46 | let file = db.parse(position.file_id); |
47 | match find_node_at_offset::<ast::Module>(file.syntax(), position.offset) { | 47 | match find_node_at_offset::<ast::Module>(file.syntax(), position.offset) { |
48 | Some(m) if !m.has_semi() => module_from_inline(db, position.file_id.into(), m), | 48 | Some(m) if !m.has_semi() => module_from_inline(db, position.file_id.into(), m), |
49 | _ => module_from_file_id(db, position.file_id.into()), | 49 | _ => module_from_file_id(db, position.file_id.into()), |
@@ -95,7 +95,7 @@ fn module_from_source(db: &impl HirDatabase, source: SourceItemId) -> Option<Mod | |||
95 | } | 95 | } |
96 | 96 | ||
97 | pub fn function_from_position(db: &impl HirDatabase, position: FilePosition) -> Option<Function> { | 97 | pub fn function_from_position(db: &impl HirDatabase, position: FilePosition) -> Option<Function> { |
98 | let file = db.source_file(position.file_id); | 98 | let file = db.parse(position.file_id); |
99 | let fn_def = find_node_at_offset::<ast::FnDef>(file.syntax(), position.offset)?; | 99 | let fn_def = find_node_at_offset::<ast::FnDef>(file.syntax(), position.offset)?; |
100 | function_from_source(db, position.file_id, fn_def) | 100 | function_from_source(db, position.file_id, fn_def) |
101 | } | 101 | } |
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index 0eb4da06e..e0b0689f8 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs | |||
@@ -547,7 +547,7 @@ fn quux() { | |||
547 | 547 | ||
548 | fn infer(content: &str) -> String { | 548 | fn infer(content: &str) -> String { |
549 | let (db, _, file_id) = MockDatabase::with_single_file(content); | 549 | let (db, _, file_id) = MockDatabase::with_single_file(content); |
550 | let source_file = db.source_file(file_id); | 550 | let source_file = db.parse(file_id); |
551 | let mut acc = String::new(); | 551 | let mut acc = String::new(); |
552 | for fn_def in source_file | 552 | for fn_def in source_file |
553 | .syntax() | 553 | .syntax() |
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. |
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 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). |
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/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 | ||
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 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::{ | |||
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 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 | ||
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 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 | ||
62 | fn file_symbols(db: &impl SymbolsDatabase, file_id: FileId) -> Arc<SymbolIndex> { | 62 | fn 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 | ||
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() |