Skip to content

Commit 3928255

Browse files
bors[bot]matklad
andcommitted
Merge #209
209: Owned nodes r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
2 parents 21797bf + 7f88fe8 commit 3928255

File tree

7 files changed

+1266
-1819
lines changed

7 files changed

+1266
-1819
lines changed

crates/ra_analysis/src/descriptors/function/imp.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ use crate::descriptors::{
1111
/// TODO: this should return something more type-safe then `SyntaxNode`
1212
pub(crate) fn fn_syntax(db: &impl DescriptorDatabase, fn_id: FnId) -> FnDefNode {
1313
let syntax = db.resolve_syntax_ptr(fn_id.0);
14-
FnDef::cast(syntax.borrowed()).unwrap().into()
14+
FnDef::cast(syntax.borrowed()).unwrap().owned()
1515
}
1616

1717
pub(crate) fn fn_scopes(db: &impl DescriptorDatabase, fn_id: FnId) -> Arc<FnScopes> {
1818
let syntax = db.fn_syntax(fn_id);
19-
let res = FnScopes::new(syntax.ast());
19+
let res = FnScopes::new(syntax.borrowed());
2020
Arc::new(res)
2121
}

crates/ra_analysis/src/descriptors/module/imp.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ pub(crate) fn submodules(
4141
db::check_canceled(db)?;
4242
let file_id = source.file_id();
4343
let submodules = match source.resolve(db) {
44-
ModuleSourceNode::Root(it) => collect_submodules(file_id, it.ast()),
44+
ModuleSourceNode::Root(it) => collect_submodules(file_id, it.borrowed()),
4545
ModuleSourceNode::Inline(it) => it
46-
.ast()
46+
.borrowed()
4747
.item_list()
4848
.map(|it| collect_submodules(file_id, it))
4949
.unwrap_or_else(Vec::new),
@@ -89,8 +89,8 @@ pub(crate) fn module_scope(
8989
let tree = db.module_tree(source_root_id)?;
9090
let source = module_id.source(&tree).resolve(db);
9191
let res = match source {
92-
ModuleSourceNode::Root(root) => ModuleScope::new(root.ast().items()),
93-
ModuleSourceNode::Inline(inline) => match inline.ast().item_list() {
92+
ModuleSourceNode::Root(root) => ModuleScope::new(root.borrowed().items()),
93+
ModuleSourceNode::Inline(inline) => match inline.borrowed().item_list() {
9494
Some(items) => ModuleScope::new(items.items()),
9595
None => ModuleScope::new(std::iter::empty()),
9696
},

crates/ra_analysis/src/descriptors/module/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ impl ModuleId {
117117
.filter_map(|&it| {
118118
let p = tree.link(it).problem.clone()?;
119119
let s = it.bind_source(tree, db);
120-
let s = s.ast().name().unwrap().syntax().owned();
120+
let s = s.borrowed().name().unwrap().syntax().owned();
121121
Some((s, p))
122122
})
123123
.collect()
@@ -136,11 +136,11 @@ impl LinkId {
136136
let owner = self.owner(tree);
137137
match owner.source(tree).resolve(db) {
138138
ModuleSourceNode::Root(root) => {
139-
let ast = imp::modules(root.ast())
139+
let ast = imp::modules(root.borrowed())
140140
.find(|(name, _)| name == &tree.link(self).name)
141141
.unwrap()
142142
.1;
143-
ast.into()
143+
ast.owned()
144144
}
145145
ModuleSourceNode::Inline(it) => it,
146146
}
@@ -179,13 +179,13 @@ impl ModuleSource {
179179
match self {
180180
ModuleSource::File(file_id) => {
181181
let syntax = db.file_syntax(file_id);
182-
ModuleSourceNode::Root(syntax.ast().into())
182+
ModuleSourceNode::Root(syntax.ast().owned())
183183
}
184184
ModuleSource::Inline(ptr) => {
185185
let syntax = db.resolve_syntax_ptr(ptr);
186186
let syntax = syntax.borrowed();
187187
let module = ast::Module::cast(syntax).unwrap();
188-
ModuleSourceNode::Inline(module.into())
188+
ModuleSourceNode::Inline(module.owned())
189189
}
190190
}
191191
}

crates/ra_analysis/src/imp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ impl AnalysisImpl {
236236
let link = module_id.parent_link(&module_tree)?;
237237
let file_id = link.owner(&module_tree).source(&module_tree).file_id();
238238
let decl = link.bind_source(&module_tree, &*self.db);
239-
let decl = decl.ast();
239+
let decl = decl.borrowed();
240240

241241
let decl_name = decl.name().unwrap();
242242

0 commit comments

Comments
 (0)