aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/code_model_impl
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-01-08 08:28:42 +0000
committerAleksey Kladov <[email protected]>2019-01-08 08:28:42 +0000
commitda0b348ae9f629c5cbe4a836a90ed85e36ca18e5 (patch)
tree614fd83f614632e3c87130117421708a7a028c13 /crates/ra_hir/src/code_model_impl
parentd6020f516f2826dac7188171241e9a72d6248cf8 (diff)
migrate ra_hir to rowan 2.0
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))