mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
migrate ra_hir to rowan 2.0
This commit is contained in:
parent
d6020f516f
commit
da0b348ae9
20 changed files with 238 additions and 197 deletions
|
@ -1,5 +1,5 @@
|
|||
use ra_db::{Cancelable, SourceRootId, FileId};
|
||||
use ra_syntax::{ast, SyntaxNode, AstNode};
|
||||
use ra_syntax::{ast, SyntaxNode, AstNode, TreePtr};
|
||||
|
||||
use crate::{
|
||||
Module, ModuleSource, Problem,
|
||||
|
@ -43,12 +43,11 @@ impl Module {
|
|||
let loc = self.def_id.loc(db);
|
||||
let file_id = loc.source_item_id.file_id.as_original_file();
|
||||
let syntax_node = db.file_item(loc.source_item_id);
|
||||
let syntax_node = syntax_node.borrowed();
|
||||
let module_source = if let Some(source_file) = ast::SourceFile::cast(syntax_node) {
|
||||
ModuleSource::SourceFile(source_file.owned())
|
||||
let module_source = if let Some(source_file) = ast::SourceFile::cast(&syntax_node) {
|
||||
ModuleSource::SourceFile(source_file.to_owned())
|
||||
} else {
|
||||
let module = ast::Module::cast(syntax_node).unwrap();
|
||||
ModuleSource::Module(module.owned())
|
||||
let module = ast::Module::cast(&syntax_node).unwrap();
|
||||
ModuleSource::Module(module.to_owned())
|
||||
};
|
||||
Ok((file_id, module_source))
|
||||
}
|
||||
|
@ -56,7 +55,7 @@ impl Module {
|
|||
pub fn declaration_source_impl(
|
||||
&self,
|
||||
db: &impl HirDatabase,
|
||||
) -> Cancelable<Option<(FileId, ast::ModuleNode)>> {
|
||||
) -> Cancelable<Option<(FileId, TreePtr<ast::Module>)>> {
|
||||
let loc = self.def_id.loc(db);
|
||||
let module_tree = db.module_tree(loc.source_root_id)?;
|
||||
let link = ctry!(loc.module_id.parent_link(&module_tree));
|
||||
|
@ -146,7 +145,10 @@ impl Module {
|
|||
}
|
||||
Ok(curr_per_ns)
|
||||
}
|
||||
pub fn problems_impl(&self, db: &impl HirDatabase) -> Cancelable<Vec<(SyntaxNode, Problem)>> {
|
||||
pub fn problems_impl(
|
||||
&self,
|
||||
db: &impl HirDatabase,
|
||||
) -> Cancelable<Vec<(TreePtr<SyntaxNode>, Problem)>> {
|
||||
let loc = self.def_id.loc(db);
|
||||
let module_tree = db.module_tree(loc.source_root_id)?;
|
||||
Ok(loc.module_id.problems(&module_tree, db))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue