aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/code_model_impl
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-01-08 09:05:55 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-01-08 09:05:55 +0000
commit3f4be819125ce4a22edd86721fa56b5caba99c2e (patch)
treebe93895ddc08c911585d9f7bc64623a3741f32c6 /crates/ra_hir/src/code_model_impl
parent4e444d2bc24d16284401444fd2154f63e0f96070 (diff)
parent122410d7aa34a32d468a3173858cbc8a2bbc68f5 (diff)
Merge #449
449: switch to new rowan API r=matklad a=matklad closes https://github.com/rust-analyzer/rust-analyzer/issues/448 Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/code_model_impl')
-rw-r--r--crates/ra_hir/src/code_model_impl/module.rs18
1 files changed, 10 insertions, 8 deletions
diff --git a/crates/ra_hir/src/code_model_impl/module.rs b/crates/ra_hir/src/code_model_impl/module.rs
index eb35779f1..0d22c9dbe 100644
--- a/crates/ra_hir/src/code_model_impl/module.rs
+++ b/crates/ra_hir/src/code_model_impl/module.rs
@@ -1,5 +1,5 @@
1use ra_db::{Cancelable, SourceRootId, FileId}; 1use ra_db::{Cancelable, SourceRootId, FileId};
2use ra_syntax::{ast, SyntaxNode, AstNode}; 2use ra_syntax::{ast, SyntaxNode, AstNode, TreePtr};
3 3
4use crate::{ 4use crate::{
5 Module, ModuleSource, Problem, 5 Module, ModuleSource, Problem,
@@ -43,12 +43,11 @@ impl Module {
43 let loc = self.def_id.loc(db); 43 let loc = self.def_id.loc(db);
44 let file_id = loc.source_item_id.file_id.as_original_file(); 44 let file_id = loc.source_item_id.file_id.as_original_file();
45 let syntax_node = db.file_item(loc.source_item_id); 45 let syntax_node = db.file_item(loc.source_item_id);
46 let syntax_node = syntax_node.borrowed(); 46 let module_source = if let Some(source_file) = ast::SourceFile::cast(&syntax_node) {
47 let module_source = if let Some(source_file) = ast::SourceFile::cast(syntax_node) { 47 ModuleSource::SourceFile(source_file.to_owned())
48 ModuleSource::SourceFile(source_file.owned())
49 } else { 48 } else {
50 let module = ast::Module::cast(syntax_node).unwrap(); 49 let module = ast::Module::cast(&syntax_node).unwrap();
51 ModuleSource::Module(module.owned()) 50 ModuleSource::Module(module.to_owned())
52 }; 51 };
53 Ok((file_id, module_source)) 52 Ok((file_id, module_source))
54 } 53 }
@@ -56,7 +55,7 @@ impl Module {
56 pub fn declaration_source_impl( 55 pub fn declaration_source_impl(
57 &self, 56 &self,
58 db: &impl HirDatabase, 57 db: &impl HirDatabase,
59 ) -> Cancelable<Option<(FileId, ast::ModuleNode)>> { 58 ) -> Cancelable<Option<(FileId, TreePtr<ast::Module>)>> {
60 let loc = self.def_id.loc(db); 59 let loc = self.def_id.loc(db);
61 let module_tree = db.module_tree(loc.source_root_id)?; 60 let module_tree = db.module_tree(loc.source_root_id)?;
62 let link = ctry!(loc.module_id.parent_link(&module_tree)); 61 let link = ctry!(loc.module_id.parent_link(&module_tree));
@@ -146,7 +145,10 @@ impl Module {
146 } 145 }
147 Ok(curr_per_ns) 146 Ok(curr_per_ns)
148 } 147 }
149 pub fn problems_impl(&self, db: &impl HirDatabase) -> Cancelable<Vec<(SyntaxNode, Problem)>> { 148 pub fn problems_impl(
149 &self,
150 db: &impl HirDatabase,
151 ) -> Cancelable<Vec<(TreePtr<SyntaxNode>, Problem)>> {
150 let loc = self.def_id.loc(db); 152 let loc = self.def_id.loc(db);
151 let module_tree = db.module_tree(loc.source_root_id)?; 153 let module_tree = db.module_tree(loc.source_root_id)?;
152 Ok(loc.module_id.problems(&module_tree, db)) 154 Ok(loc.module_id.problems(&module_tree, db))