fix ra_analysis to work with the new API

This commit is contained in:
Aleksey Kladov
2019-01-06 16:05:59 +03:00
parent a7f4f7bfcc
commit c303e6fbdf
4 changed files with 12 additions and 7 deletions

View File

@@ -20,14 +20,17 @@ pub(super) fn complete_scope(acc: &mut Completions, ctx: &CompletionContext) ->
} }
let module_scope = module.scope(ctx.db)?; let module_scope = module.scope(ctx.db)?;
let (file_id, _) = module.defenition_source(ctx.db)?;
module_scope module_scope
.entries() .entries()
.filter(|(_name, res)| { .filter(|(_name, res)| {
// Don't expose this item // Don't expose this item
// FIXME: this penetrates through all kinds of abstractions,
// we need to figura out the way to do it less ugly.
match res.import { match res.import {
None => true, None => true,
Some(import) => { Some(import) => {
let range = import.range(ctx.db, module.file_id()); let range = import.range(ctx.db, file_id);
!range.is_subrange(&ctx.leaf.range()) !range.is_subrange(&ctx.leaf.range())
} }
} }

View File

@@ -60,8 +60,8 @@ fn name_defenition(
if let Some(child_module) = if let Some(child_module) =
hir::source_binder::module_from_declaration(db, file_id, module)? hir::source_binder::module_from_declaration(db, file_id, module)?
{ {
let file_id = child_module.file_id(); let (file_id, _) = child_module.defenition_source(db)?;
let name = match child_module.name() { let name = match child_module.name(db)? {
Some(name) => name.to_string().into(), Some(name) => name.to_string().into(),
None => "".into(), None => "".into(),
}; };

View File

@@ -109,8 +109,7 @@ impl db::RootDatabase {
None => return Ok(Vec::new()), None => return Ok(Vec::new()),
Some(it) => it, Some(it) => it,
}; };
let (file_id, ast_module) = module.source(self); let (file_id, ast_module) = match module.declaration_source(self)? {
let ast_module = match ast_module {
None => return Ok(Vec::new()), None => return Ok(Vec::new()),
Some(it) => it, Some(it) => it,
}; };
@@ -206,7 +205,7 @@ impl db::RootDatabase {
}) })
.collect::<Vec<_>>(); .collect::<Vec<_>>();
if let Some(m) = source_binder::module_from_file_id(self, file_id)? { if let Some(m) = source_binder::module_from_file_id(self, file_id)? {
for (name_node, problem) in m.problems(self) { for (name_node, problem) in m.problems(self)? {
let source_root = self.file_source_root(file_id); let source_root = self.file_source_root(file_id);
let diag = match problem { let diag = match problem {
Problem::UnresolvedModule { candidate } => { Problem::UnresolvedModule { candidate } => {

View File

@@ -72,12 +72,15 @@ fn runnable_mod(db: &RootDatabase, file_id: FileId, module: ast::Module) -> Opti
let range = module.syntax().range(); let range = module.syntax().range();
let module = let module =
hir::source_binder::module_from_child_node(db, file_id, module.syntax()).ok()??; hir::source_binder::module_from_child_node(db, file_id, module.syntax()).ok()??;
// FIXME: thread cancellation instead of `.ok`ing
let path = module let path = module
.path_to_root(db) .path_to_root(db)
.ok()? .ok()?
.into_iter() .into_iter()
.rev() .rev()
.filter_map(|it| it.name(db).map(Clone::clone)) .filter_map(|it| it.name(db).ok())
.filter_map(|it| it)
.join("::"); .join("::");
Some(Runnable { Some(Runnable {
range, range,