mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-15 17:28:09 +00:00
fix ra_analysis to work with the new API
This commit is contained in:
parent
a7f4f7bfcc
commit
c303e6fbdf
4 changed files with 12 additions and 7 deletions
|
@ -20,14 +20,17 @@ pub(super) fn complete_scope(acc: &mut Completions, ctx: &CompletionContext) ->
|
|||
}
|
||||
|
||||
let module_scope = module.scope(ctx.db)?;
|
||||
let (file_id, _) = module.defenition_source(ctx.db)?;
|
||||
module_scope
|
||||
.entries()
|
||||
.filter(|(_name, res)| {
|
||||
// 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 {
|
||||
None => true,
|
||||
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())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,8 +60,8 @@ fn name_defenition(
|
|||
if let Some(child_module) =
|
||||
hir::source_binder::module_from_declaration(db, file_id, module)?
|
||||
{
|
||||
let file_id = child_module.file_id();
|
||||
let name = match child_module.name() {
|
||||
let (file_id, _) = child_module.defenition_source(db)?;
|
||||
let name = match child_module.name(db)? {
|
||||
Some(name) => name.to_string().into(),
|
||||
None => "".into(),
|
||||
};
|
||||
|
|
|
@ -109,8 +109,7 @@ impl db::RootDatabase {
|
|||
None => return Ok(Vec::new()),
|
||||
Some(it) => it,
|
||||
};
|
||||
let (file_id, ast_module) = module.source(self);
|
||||
let ast_module = match ast_module {
|
||||
let (file_id, ast_module) = match module.declaration_source(self)? {
|
||||
None => return Ok(Vec::new()),
|
||||
Some(it) => it,
|
||||
};
|
||||
|
@ -206,7 +205,7 @@ impl db::RootDatabase {
|
|||
})
|
||||
.collect::<Vec<_>>();
|
||||
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 diag = match problem {
|
||||
Problem::UnresolvedModule { candidate } => {
|
||||
|
|
|
@ -72,12 +72,15 @@ fn runnable_mod(db: &RootDatabase, file_id: FileId, module: ast::Module) -> Opti
|
|||
let range = module.syntax().range();
|
||||
let module =
|
||||
hir::source_binder::module_from_child_node(db, file_id, module.syntax()).ok()??;
|
||||
|
||||
// FIXME: thread cancellation instead of `.ok`ing
|
||||
let path = module
|
||||
.path_to_root(db)
|
||||
.ok()?
|
||||
.into_iter()
|
||||
.rev()
|
||||
.filter_map(|it| it.name(db).map(Clone::clone))
|
||||
.filter_map(|it| it.name(db).ok())
|
||||
.filter_map(|it| it)
|
||||
.join("::");
|
||||
Some(Runnable {
|
||||
range,
|
||||
|
|
Loading…
Reference in a new issue