aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_hir/src/nameres.rs2
-rw-r--r--crates/ra_hir/src/nameres/collector.rs4
-rw-r--r--crates/ra_hir/src/nameres/raw.rs22
-rw-r--r--crates/ra_prof/src/lib.rs2
4 files changed, 23 insertions, 7 deletions
diff --git a/crates/ra_hir/src/nameres.rs b/crates/ra_hir/src/nameres.rs
index 53ef8d58a..cf9ff0636 100644
--- a/crates/ra_hir/src/nameres.rs
+++ b/crates/ra_hir/src/nameres.rs
@@ -76,7 +76,7 @@ pub use self::{
76 raw::ImportId, 76 raw::ImportId,
77}; 77};
78 78
79/// Contans all top-level defs from a macro-expanded crate 79/// Contains all top-level defs from a macro-expanded crate
80#[derive(Debug, PartialEq, Eq)] 80#[derive(Debug, PartialEq, Eq)]
81pub struct CrateDefMap { 81pub struct CrateDefMap {
82 krate: Crate, 82 krate: Crate,
diff --git a/crates/ra_hir/src/nameres/collector.rs b/crates/ra_hir/src/nameres/collector.rs
index d66be34db..951468a98 100644
--- a/crates/ra_hir/src/nameres/collector.rs
+++ b/crates/ra_hir/src/nameres/collector.rs
@@ -508,8 +508,8 @@ where
508 } 508 }
509 .collect(&*items); 509 .collect(&*items);
510 } 510 }
511 // out of line module, resovle, parse and recurse 511 // out of line module, resolve, parse and recurse
512 raw::ModuleData::Declaration { name, ast_id } => { 512 raw::ModuleData::Declaration { name, ast_id, .. } => {
513 let ast_id = ast_id.with_file_id(self.file_id); 513 let ast_id = ast_id.with_file_id(self.file_id);
514 let is_root = self.def_collector.def_map.modules[self.module_id].parent.is_none(); 514 let is_root = self.def_collector.def_map.modules[self.module_id].parent.is_none();
515 match resolve_submodule(self.def_collector.db, self.file_id, name, is_root) { 515 match resolve_submodule(self.def_collector.db, self.file_id, name, is_root) {
diff --git a/crates/ra_hir/src/nameres/raw.rs b/crates/ra_hir/src/nameres/raw.rs
index 7ea59cb75..46b2bef5b 100644
--- a/crates/ra_hir/src/nameres/raw.rs
+++ b/crates/ra_hir/src/nameres/raw.rs
@@ -3,7 +3,7 @@ use std::{ops::Index, sync::Arc};
3use ra_arena::{impl_arena_id, map::ArenaMap, Arena, RawId}; 3use ra_arena::{impl_arena_id, map::ArenaMap, Arena, RawId};
4use ra_syntax::{ 4use ra_syntax::{
5 ast::{self, AttrsOwner, NameOwner}, 5 ast::{self, AttrsOwner, NameOwner},
6 AstNode, AstPtr, SourceFile, TreeArc, 6 AstNode, AstPtr, SmolStr, SourceFile, TreeArc,
7}; 7};
8use test_utils::tested_by; 8use test_utils::tested_by;
9 9
@@ -130,7 +130,7 @@ impl_arena_id!(Module);
130 130
131#[derive(Debug, PartialEq, Eq)] 131#[derive(Debug, PartialEq, Eq)]
132pub(super) enum ModuleData { 132pub(super) enum ModuleData {
133 Declaration { name: Name, ast_id: FileAstId<ast::Module> }, 133 Declaration { name: Name, ast_id: FileAstId<ast::Module>, attr_path: Option<SmolStr> },
134 Definition { name: Name, ast_id: FileAstId<ast::Module>, items: Vec<RawItem> }, 134 Definition { name: Name, ast_id: FileAstId<ast::Module>, items: Vec<RawItem> },
135} 135}
136 136
@@ -255,9 +255,12 @@ impl RawItemsCollector {
255 Some(it) => it.as_name(), 255 Some(it) => it.as_name(),
256 None => return, 256 None => return,
257 }; 257 };
258
259 let attr_path = extract_mod_path_attribute(module);
258 let ast_id = self.source_ast_id_map.ast_id(module); 260 let ast_id = self.source_ast_id_map.ast_id(module);
259 if module.has_semi() { 261 if module.has_semi() {
260 let item = self.raw_items.modules.alloc(ModuleData::Declaration { name, ast_id }); 262 let item =
263 self.raw_items.modules.alloc(ModuleData::Declaration { name, ast_id, attr_path });
261 self.push_item(current_module, RawItem::Module(item)); 264 self.push_item(current_module, RawItem::Module(item));
262 return; 265 return;
263 } 266 }
@@ -339,3 +342,16 @@ impl RawItemsCollector {
339 .push(item) 342 .push(item)
340 } 343 }
341} 344}
345
346fn extract_mod_path_attribute(module: &ast::Module) -> Option<SmolStr> {
347 module.attrs().into_iter().find_map(|attr| {
348 attr.as_key_value().and_then(|(name, value)| {
349 let is_path = name == "path";
350 if is_path {
351 Some(value)
352 } else {
353 None
354 }
355 })
356 })
357}
diff --git a/crates/ra_prof/src/lib.rs b/crates/ra_prof/src/lib.rs
index 919cc1b3c..6d44fef33 100644
--- a/crates/ra_prof/src/lib.rs
+++ b/crates/ra_prof/src/lib.rs
@@ -52,7 +52,7 @@ pub fn set_filter(f: Filter) {
52/// It supports nested profiling scopes in case when this function invoked multiple times at the execution stack. In this case the profiling information will be nested at the output. 52/// It supports nested profiling scopes in case when this function invoked multiple times at the execution stack. In this case the profiling information will be nested at the output.
53/// Profiling information is being printed in the stderr. 53/// Profiling information is being printed in the stderr.
54/// 54///
55/// #Example 55/// # Example
56/// ``` 56/// ```
57/// use ra_prof::{profile, set_filter, Filter}; 57/// use ra_prof::{profile, set_filter, Filter};
58/// 58///