This commit is contained in:
Aleksey Kladov 2018-11-27 18:45:16 +03:00
parent f4860870da
commit aa7fd563a4
4 changed files with 13 additions and 22 deletions

View file

@ -38,10 +38,7 @@ pub(crate) fn completions(
original_file.reparse(&edit)
};
let module = match ModuleDescriptor::guess_from_position(db, position)? {
None => return Ok(None),
Some(it) => it,
};
let module = ctry!(ModuleDescriptor::guess_from_position(db, position)?);
let mut res = Vec::new();
let mut has_completions = false;

View file

@ -17,7 +17,7 @@ use crate::{
descriptors::{Path, PathKind, DescriptorDatabase},
input::SourceRootId,
arena::{Arena, Id},
loc2id::DefLoc,
loc2id::{DefLoc, DefId},
};
pub(crate) use self::nameres::ModuleScope;
@ -153,15 +153,6 @@ impl ModuleDescriptor {
db: &impl DescriptorDatabase,
path: Path,
) -> Cancelable<Option<ModuleDescriptor>> {
macro_rules! ctry {
($expr:expr) => {
match $expr {
None => return Ok(None),
Some(it) => it,
}
};
};
let mut curr = match path.kind {
PathKind::Crate => self.crate_root(),
PathKind::Self_ | PathKind::Plain => self.clone(),

View file

@ -450,14 +450,8 @@ impl AnalysisImpl {
let syntax = file.syntax();
// Find the calling expression and it's NameRef
let calling_node = match FnCallNode::with_node(syntax, position.offset) {
Some(node) => node,
None => return Ok(None),
};
let name_ref = match calling_node.name_ref() {
Some(name) => name,
None => return Ok(None),
};
let calling_node = ctry!(FnCallNode::with_node(syntax, position.offset));
let name_ref = ctry!(calling_node.name_ref());
// Resolve the function's NameRef (NOTE: this isn't entirely accurate).
let file_symbols = self.index_resolve(name_ref)?;

View file

@ -9,6 +9,15 @@ extern crate relative_path;
extern crate rustc_hash;
extern crate salsa;
macro_rules! ctry {
($expr:expr) => {
match $expr {
None => return Ok(None),
Some(it) => it,
}
};
}
mod arena;
mod db;
mod loc2id;