diff options
author | Aleksey Kladov <[email protected]> | 2019-01-15 15:26:29 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-01-15 15:26:29 +0000 |
commit | ca52cf1ecd4f65ff2a8c3953c35b006e73a60ea8 (patch) | |
tree | 0cb202b9c3a670dee6667d7f636b01a71ae554c6 /crates/ra_hir/src/code_model_impl | |
parent | 91feed736f91a3790b2f5a5d0d879c06843bce95 (diff) |
remove Cancelable from Module API
Diffstat (limited to 'crates/ra_hir/src/code_model_impl')
-rw-r--r-- | crates/ra_hir/src/code_model_impl/module.rs | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/crates/ra_hir/src/code_model_impl/module.rs b/crates/ra_hir/src/code_model_impl/module.rs index 67808d282..127dcc570 100644 --- a/crates/ra_hir/src/code_model_impl/module.rs +++ b/crates/ra_hir/src/code_model_impl/module.rs | |||
@@ -30,17 +30,14 @@ impl Module { | |||
30 | Module::new(def_id) | 30 | Module::new(def_id) |
31 | } | 31 | } |
32 | 32 | ||
33 | pub(crate) fn name_impl(&self, db: &impl HirDatabase) -> Cancelable<Option<Name>> { | 33 | pub(crate) fn name_impl(&self, db: &impl HirDatabase) -> Option<Name> { |
34 | let loc = self.def_id.loc(db); | 34 | let loc = self.def_id.loc(db); |
35 | let module_tree = db.module_tree(loc.source_root_id); | 35 | let module_tree = db.module_tree(loc.source_root_id); |
36 | let link = ctry!(loc.module_id.parent_link(&module_tree)); | 36 | let link = loc.module_id.parent_link(&module_tree)?; |
37 | Ok(Some(link.name(&module_tree).clone())) | 37 | Some(link.name(&module_tree).clone()) |
38 | } | 38 | } |
39 | 39 | ||
40 | pub fn definition_source_impl( | 40 | pub fn definition_source_impl(&self, db: &impl HirDatabase) -> (FileId, ModuleSource) { |
41 | &self, | ||
42 | db: &impl HirDatabase, | ||
43 | ) -> Cancelable<(FileId, ModuleSource)> { | ||
44 | let loc = self.def_id.loc(db); | 41 | let loc = self.def_id.loc(db); |
45 | let file_id = loc.source_item_id.file_id.as_original_file(); | 42 | let file_id = loc.source_item_id.file_id.as_original_file(); |
46 | let syntax_node = db.file_item(loc.source_item_id); | 43 | let syntax_node = db.file_item(loc.source_item_id); |
@@ -50,23 +47,23 @@ impl Module { | |||
50 | let module = ast::Module::cast(&syntax_node).unwrap(); | 47 | let module = ast::Module::cast(&syntax_node).unwrap(); |
51 | ModuleSource::Module(module.to_owned()) | 48 | ModuleSource::Module(module.to_owned()) |
52 | }; | 49 | }; |
53 | Ok((file_id, module_source)) | 50 | (file_id, module_source) |
54 | } | 51 | } |
55 | 52 | ||
56 | pub fn declaration_source_impl( | 53 | pub fn declaration_source_impl( |
57 | &self, | 54 | &self, |
58 | db: &impl HirDatabase, | 55 | db: &impl HirDatabase, |
59 | ) -> Cancelable<Option<(FileId, TreeArc<ast::Module>)>> { | 56 | ) -> Option<(FileId, TreeArc<ast::Module>)> { |
60 | let loc = self.def_id.loc(db); | 57 | let loc = self.def_id.loc(db); |
61 | let module_tree = db.module_tree(loc.source_root_id); | 58 | let module_tree = db.module_tree(loc.source_root_id); |
62 | let link = ctry!(loc.module_id.parent_link(&module_tree)); | 59 | let link = loc.module_id.parent_link(&module_tree)?; |
63 | let file_id = link | 60 | let file_id = link |
64 | .owner(&module_tree) | 61 | .owner(&module_tree) |
65 | .source(&module_tree) | 62 | .source(&module_tree) |
66 | .file_id | 63 | .file_id |
67 | .as_original_file(); | 64 | .as_original_file(); |
68 | let src = link.source(&module_tree, db); | 65 | let src = link.source(&module_tree, db); |
69 | Ok(Some((file_id, src))) | 66 | Some((file_id, src)) |
70 | } | 67 | } |
71 | 68 | ||
72 | pub(crate) fn krate_impl(&self, db: &impl HirDatabase) -> Cancelable<Option<Crate>> { | 69 | pub(crate) fn krate_impl(&self, db: &impl HirDatabase) -> Cancelable<Option<Crate>> { |