remove Cancelable from source binders
This commit is contained in:
@@ -42,7 +42,7 @@ impl<'a> CompletionContext<'a> {
|
||||
original_file: &'a SourceFile,
|
||||
position: FilePosition,
|
||||
) -> Cancelable<Option<CompletionContext<'a>>> {
|
||||
let module = source_binder::module_from_position(db, position)?;
|
||||
let module = source_binder::module_from_position(db, position);
|
||||
let leaf =
|
||||
ctry!(find_leaf_at_offset(original_file.syntax(), position.offset).left_biased());
|
||||
let mut ctx = CompletionContext {
|
||||
|
||||
@@ -48,7 +48,7 @@ pub(crate) fn reference_definition(
|
||||
) -> Cancelable<ReferenceResult> {
|
||||
use self::ReferenceResult::*;
|
||||
if let Some(function) =
|
||||
hir::source_binder::function_from_child_node(db, file_id, name_ref.syntax())?
|
||||
hir::source_binder::function_from_child_node(db, file_id, name_ref.syntax())
|
||||
{
|
||||
let scope = function.scopes(db)?;
|
||||
// First try to resolve the symbol locally
|
||||
@@ -77,8 +77,7 @@ pub(crate) fn reference_definition(
|
||||
}
|
||||
}
|
||||
// Then try module name resolution
|
||||
if let Some(module) =
|
||||
hir::source_binder::module_from_child_node(db, file_id, name_ref.syntax())?
|
||||
if let Some(module) = hir::source_binder::module_from_child_node(db, file_id, name_ref.syntax())
|
||||
{
|
||||
if let Some(path) = name_ref
|
||||
.syntax()
|
||||
@@ -111,7 +110,7 @@ fn name_definition(
|
||||
if let Some(module) = name.syntax().parent().and_then(ast::Module::cast) {
|
||||
if module.has_semi() {
|
||||
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 nav = NavigationTarget::from_module(db, child_module)?;
|
||||
return Ok(Some(vec![nav]));
|
||||
|
||||
@@ -72,7 +72,7 @@ pub(crate) fn type_of(db: &RootDatabase, frange: FileRange) -> Cancelable<Option
|
||||
db,
|
||||
frange.file_id,
|
||||
parent_fn
|
||||
)?);
|
||||
));
|
||||
let infer = function.infer(db)?;
|
||||
let syntax_mapping = function.body_syntax_mapping(db)?;
|
||||
if let Some(expr) = ast::Expr::cast(node).and_then(|e| syntax_mapping.node_expr(e)) {
|
||||
|
||||
@@ -100,7 +100,7 @@ impl db::RootDatabase {
|
||||
impl db::RootDatabase {
|
||||
/// Returns `Vec` for the same reason as `parent_module`
|
||||
pub(crate) fn crate_for(&self, file_id: FileId) -> Cancelable<Vec<CrateId>> {
|
||||
let module = match source_binder::module_from_file_id(self, file_id)? {
|
||||
let module = match source_binder::module_from_file_id(self, file_id) {
|
||||
Some(it) => it,
|
||||
None => return Ok(Vec::new()),
|
||||
};
|
||||
@@ -147,7 +147,7 @@ impl db::RootDatabase {
|
||||
db,
|
||||
position.file_id,
|
||||
binding.syntax(),
|
||||
)?);
|
||||
));
|
||||
return Ok(Some((binding, descr)));
|
||||
};
|
||||
let name_ref = ctry!(find_node_at_offset::<ast::NameRef>(syntax, position.offset));
|
||||
@@ -155,7 +155,7 @@ impl db::RootDatabase {
|
||||
db,
|
||||
position.file_id,
|
||||
name_ref.syntax(),
|
||||
)?);
|
||||
));
|
||||
let scope = descr.scopes(db)?;
|
||||
let resolved = ctry!(scope.resolve_local_name(name_ref));
|
||||
let resolved = resolved.ptr().resolve(source_file);
|
||||
@@ -179,7 +179,7 @@ impl db::RootDatabase {
|
||||
fix: d.fix.map(|fix| SourceChange::from_local_edit(file_id, fix)),
|
||||
})
|
||||
.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)? {
|
||||
let source_root = self.file_source_root(file_id);
|
||||
let diag = match problem {
|
||||
|
||||
@@ -8,7 +8,7 @@ pub(crate) fn parent_module(
|
||||
db: &RootDatabase,
|
||||
position: FilePosition,
|
||||
) -> Cancelable<Vec<NavigationTarget>> {
|
||||
let module = match hir::source_binder::module_from_position(db, position)? {
|
||||
let module = match hir::source_binder::module_from_position(db, position) {
|
||||
None => return Ok(Vec::new()),
|
||||
Some(it) => it,
|
||||
};
|
||||
|
||||
@@ -75,8 +75,7 @@ fn runnable_mod(db: &RootDatabase, file_id: FileId, module: &ast::Module) -> Opt
|
||||
return None;
|
||||
}
|
||||
let range = module.syntax().range();
|
||||
let module =
|
||||
hir::source_binder::module_from_child_node(db, file_id, module.syntax()).ok()??;
|
||||
let module = hir::source_binder::module_from_child_node(db, file_id, module.syntax())?;
|
||||
|
||||
// FIXME: thread cancellation instead of `.ok`ing
|
||||
let path = module
|
||||
|
||||
@@ -63,7 +63,7 @@ fn file_symbols(db: &impl SymbolsDatabase, file_id: FileId) -> Cancelable<Arc<Sy
|
||||
.map(move |(name, ptr)| FileSymbol { name, ptr, file_id })
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
for (name, text_range) in hir::source_binder::macro_symbols(db, file_id)? {
|
||||
for (name, text_range) in hir::source_binder::macro_symbols(db, file_id) {
|
||||
let node = find_covering_node(source_file.syntax(), text_range);
|
||||
let ptr = LocalSyntaxPtr::new(node);
|
||||
symbols.push(FileSymbol { file_id, name, ptr })
|
||||
|
||||
Reference in New Issue
Block a user