From a5301e94d5467db8e48ed31c4abd562c79edb841 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 6 Nov 2018 21:52:00 +0300 Subject: Generalize Owned nodes --- crates/ra_analysis/src/descriptors/function/imp.rs | 4 ++-- crates/ra_analysis/src/descriptors/module/imp.rs | 8 ++++---- crates/ra_analysis/src/descriptors/module/mod.rs | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) (limited to 'crates/ra_analysis/src/descriptors') diff --git a/crates/ra_analysis/src/descriptors/function/imp.rs b/crates/ra_analysis/src/descriptors/function/imp.rs index 755e05819..a989a04cd 100644 --- a/crates/ra_analysis/src/descriptors/function/imp.rs +++ b/crates/ra_analysis/src/descriptors/function/imp.rs @@ -11,11 +11,11 @@ use crate::descriptors::{ /// TODO: this should return something more type-safe then `SyntaxNode` pub(crate) fn fn_syntax(db: &impl DescriptorDatabase, fn_id: FnId) -> FnDefNode { let syntax = db.resolve_syntax_ptr(fn_id.0); - FnDef::cast(syntax.borrowed()).unwrap().into() + FnDef::cast(syntax.borrowed()).unwrap().owned() } pub(crate) fn fn_scopes(db: &impl DescriptorDatabase, fn_id: FnId) -> Arc { let syntax = db.fn_syntax(fn_id); - let res = FnScopes::new(syntax.ast()); + let res = FnScopes::new(syntax.borrowed()); Arc::new(res) } diff --git a/crates/ra_analysis/src/descriptors/module/imp.rs b/crates/ra_analysis/src/descriptors/module/imp.rs index b3b1f1f21..b5c232ea4 100644 --- a/crates/ra_analysis/src/descriptors/module/imp.rs +++ b/crates/ra_analysis/src/descriptors/module/imp.rs @@ -41,9 +41,9 @@ pub(crate) fn submodules( db::check_canceled(db)?; let file_id = source.file_id(); let submodules = match source.resolve(db) { - ModuleSourceNode::Root(it) => collect_submodules(file_id, it.ast()), + ModuleSourceNode::Root(it) => collect_submodules(file_id, it.borrowed()), ModuleSourceNode::Inline(it) => it - .ast() + .borrowed() .item_list() .map(|it| collect_submodules(file_id, it)) .unwrap_or_else(Vec::new), @@ -89,8 +89,8 @@ pub(crate) fn module_scope( let tree = db.module_tree(source_root_id)?; let source = module_id.source(&tree).resolve(db); let res = match source { - ModuleSourceNode::Root(root) => ModuleScope::new(root.ast().items()), - ModuleSourceNode::Inline(inline) => match inline.ast().item_list() { + ModuleSourceNode::Root(root) => ModuleScope::new(root.borrowed().items()), + ModuleSourceNode::Inline(inline) => match inline.borrowed().item_list() { Some(items) => ModuleScope::new(items.items()), None => ModuleScope::new(std::iter::empty()), }, diff --git a/crates/ra_analysis/src/descriptors/module/mod.rs b/crates/ra_analysis/src/descriptors/module/mod.rs index 3d799ba05..03330240d 100644 --- a/crates/ra_analysis/src/descriptors/module/mod.rs +++ b/crates/ra_analysis/src/descriptors/module/mod.rs @@ -117,7 +117,7 @@ impl ModuleId { .filter_map(|&it| { let p = tree.link(it).problem.clone()?; let s = it.bind_source(tree, db); - let s = s.ast().name().unwrap().syntax().owned(); + let s = s.borrowed().name().unwrap().syntax().owned(); Some((s, p)) }) .collect() @@ -136,11 +136,11 @@ impl LinkId { let owner = self.owner(tree); match owner.source(tree).resolve(db) { ModuleSourceNode::Root(root) => { - let ast = imp::modules(root.ast()) + let ast = imp::modules(root.borrowed()) .find(|(name, _)| name == &tree.link(self).name) .unwrap() .1; - ast.into() + ast.owned() } ModuleSourceNode::Inline(it) => it, } @@ -179,13 +179,13 @@ impl ModuleSource { match self { ModuleSource::File(file_id) => { let syntax = db.file_syntax(file_id); - ModuleSourceNode::Root(syntax.ast().into()) + ModuleSourceNode::Root(syntax.ast().owned()) } ModuleSource::Inline(ptr) => { let syntax = db.resolve_syntax_ptr(ptr); let syntax = syntax.borrowed(); let module = ast::Module::cast(syntax).unwrap(); - ModuleSourceNode::Inline(module.into()) + ModuleSourceNode::Inline(module.owned()) } } } -- cgit v1.2.3