diff options
author | Aleksey Kladov <[email protected]> | 2019-01-06 13:10:25 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-01-06 14:35:57 +0000 |
commit | 5a505189a8f7ed274893a45aed0d0249083d1277 (patch) | |
tree | 3a155da5450cec94a32e97d7a3dc330fdffa7602 | |
parent | c303e6fbdfd8d04b645796489766e912d2cb3009 (diff) |
adjust comments
-rw-r--r-- | crates/ra_analysis/tests/test/main.rs | 1 | ||||
-rw-r--r-- | crates/ra_hir/src/code_model_api.rs | 12 |
2 files changed, 8 insertions, 5 deletions
diff --git a/crates/ra_analysis/tests/test/main.rs b/crates/ra_analysis/tests/test/main.rs index 26da7c10c..85911de92 100644 --- a/crates/ra_analysis/tests/test/main.rs +++ b/crates/ra_analysis/tests/test/main.rs | |||
@@ -31,6 +31,7 @@ fn test_unresolved_module_diagnostic() { | |||
31 | ); | 31 | ); |
32 | } | 32 | } |
33 | 33 | ||
34 | // FIXME: move this test to hir | ||
34 | #[test] | 35 | #[test] |
35 | fn test_unresolved_module_diagnostic_no_diag_for_inline_mode() { | 36 | fn test_unresolved_module_diagnostic_no_diag_for_inline_mode() { |
36 | let (analysis, file_id) = single_file("mod foo {}"); | 37 | let (analysis, file_id) = single_file("mod foo {}"); |
diff --git a/crates/ra_hir/src/code_model_api.rs b/crates/ra_hir/src/code_model_api.rs index 0c7f743d4..d00d3246f 100644 --- a/crates/ra_hir/src/code_model_api.rs +++ b/crates/ra_hir/src/code_model_api.rs | |||
@@ -34,22 +34,23 @@ pub struct Module { | |||
34 | pub(crate) def_id: DefId, | 34 | pub(crate) def_id: DefId, |
35 | } | 35 | } |
36 | 36 | ||
37 | /// An owned syntax node for a module. Unlike `ModuleSource`, | ||
38 | /// this holds onto the AST for the whole file. | ||
39 | pub enum ModuleSource { | 37 | pub enum ModuleSource { |
40 | SourceFile(ast::SourceFileNode), | 38 | SourceFile(ast::SourceFileNode), |
41 | Module(ast::ModuleNode), | 39 | Module(ast::ModuleNode), |
42 | } | 40 | } |
43 | 41 | ||
44 | impl Module { | 42 | impl Module { |
43 | /// Name of this module. | ||
45 | pub fn name(&self, db: &impl HirDatabase) -> Cancelable<Option<Name>> { | 44 | pub fn name(&self, db: &impl HirDatabase) -> Cancelable<Option<Name>> { |
46 | self.name_impl(db) | 45 | self.name_impl(db) |
47 | } | 46 | } |
48 | 47 | ||
48 | /// Returns a node which defines this module. That is, a file or a `mod foo {}` with items. | ||
49 | pub fn defenition_source(&self, db: &impl HirDatabase) -> Cancelable<(FileId, ModuleSource)> { | 49 | pub fn defenition_source(&self, db: &impl HirDatabase) -> Cancelable<(FileId, ModuleSource)> { |
50 | self.defenition_source_impl(db) | 50 | self.defenition_source_impl(db) |
51 | } | 51 | } |
52 | 52 | /// Returns a node which declares this module, either a `mod foo;` or a `mod foo {}`. | |
53 | /// `None` for the crate root. | ||
53 | pub fn declaration_source( | 54 | pub fn declaration_source( |
54 | &self, | 55 | &self, |
55 | db: &impl HirDatabase, | 56 | db: &impl HirDatabase, |
@@ -61,11 +62,12 @@ impl Module { | |||
61 | pub fn krate(&self, db: &impl HirDatabase) -> Cancelable<Option<Crate>> { | 62 | pub fn krate(&self, db: &impl HirDatabase) -> Cancelable<Option<Crate>> { |
62 | self.krate_impl(db) | 63 | self.krate_impl(db) |
63 | } | 64 | } |
64 | 65 | /// Topmost parent of this module. Every module has a `crate_root`, but some | |
66 | /// might miss `krate`. This can happen if a module's file is not included | ||
67 | /// into any module tree of any target from Cargo.toml. | ||
65 | pub fn crate_root(&self, db: &impl HirDatabase) -> Cancelable<Module> { | 68 | pub fn crate_root(&self, db: &impl HirDatabase) -> Cancelable<Module> { |
66 | self.crate_root_impl(db) | 69 | self.crate_root_impl(db) |
67 | } | 70 | } |
68 | |||
69 | /// Finds a child module with the specified name. | 71 | /// Finds a child module with the specified name. |
70 | pub fn child(&self, db: &impl HirDatabase, name: &Name) -> Cancelable<Option<Module>> { | 72 | pub fn child(&self, db: &impl HirDatabase, name: &Name) -> Cancelable<Option<Module>> { |
71 | self.child_impl(db, name) | 73 | self.child_impl(db, name) |