mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
parent
219e0e8c8d
commit
35a0f04128
4 changed files with 23 additions and 7 deletions
|
@ -76,7 +76,7 @@ pub use self::{
|
||||||
raw::ImportId,
|
raw::ImportId,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Contans all top-level defs from a macro-expanded crate
|
/// Contains all top-level defs from a macro-expanded crate
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
pub struct CrateDefMap {
|
pub struct CrateDefMap {
|
||||||
krate: Crate,
|
krate: Crate,
|
||||||
|
|
|
@ -508,8 +508,8 @@ where
|
||||||
}
|
}
|
||||||
.collect(&*items);
|
.collect(&*items);
|
||||||
}
|
}
|
||||||
// out of line module, resovle, parse and recurse
|
// out of line module, resolve, parse and recurse
|
||||||
raw::ModuleData::Declaration { name, ast_id } => {
|
raw::ModuleData::Declaration { name, ast_id, .. } => {
|
||||||
let ast_id = ast_id.with_file_id(self.file_id);
|
let ast_id = ast_id.with_file_id(self.file_id);
|
||||||
let is_root = self.def_collector.def_map.modules[self.module_id].parent.is_none();
|
let is_root = self.def_collector.def_map.modules[self.module_id].parent.is_none();
|
||||||
match resolve_submodule(self.def_collector.db, self.file_id, name, is_root) {
|
match resolve_submodule(self.def_collector.db, self.file_id, name, is_root) {
|
||||||
|
|
|
@ -3,7 +3,7 @@ use std::{ops::Index, sync::Arc};
|
||||||
use ra_arena::{impl_arena_id, map::ArenaMap, Arena, RawId};
|
use ra_arena::{impl_arena_id, map::ArenaMap, Arena, RawId};
|
||||||
use ra_syntax::{
|
use ra_syntax::{
|
||||||
ast::{self, AttrsOwner, NameOwner},
|
ast::{self, AttrsOwner, NameOwner},
|
||||||
AstNode, AstPtr, SourceFile, TreeArc,
|
AstNode, AstPtr, SmolStr, SourceFile, TreeArc,
|
||||||
};
|
};
|
||||||
use test_utils::tested_by;
|
use test_utils::tested_by;
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ impl_arena_id!(Module);
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
pub(super) enum ModuleData {
|
pub(super) enum ModuleData {
|
||||||
Declaration { name: Name, ast_id: FileAstId<ast::Module> },
|
Declaration { name: Name, ast_id: FileAstId<ast::Module>, attr_path: Option<SmolStr> },
|
||||||
Definition { name: Name, ast_id: FileAstId<ast::Module>, items: Vec<RawItem> },
|
Definition { name: Name, ast_id: FileAstId<ast::Module>, items: Vec<RawItem> },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,9 +255,12 @@ impl RawItemsCollector {
|
||||||
Some(it) => it.as_name(),
|
Some(it) => it.as_name(),
|
||||||
None => return,
|
None => return,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let attr_path = extract_mod_path_attribute(module);
|
||||||
let ast_id = self.source_ast_id_map.ast_id(module);
|
let ast_id = self.source_ast_id_map.ast_id(module);
|
||||||
if module.has_semi() {
|
if module.has_semi() {
|
||||||
let item = self.raw_items.modules.alloc(ModuleData::Declaration { name, ast_id });
|
let item =
|
||||||
|
self.raw_items.modules.alloc(ModuleData::Declaration { name, ast_id, attr_path });
|
||||||
self.push_item(current_module, RawItem::Module(item));
|
self.push_item(current_module, RawItem::Module(item));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -339,3 +342,16 @@ impl RawItemsCollector {
|
||||||
.push(item)
|
.push(item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn extract_mod_path_attribute(module: &ast::Module) -> Option<SmolStr> {
|
||||||
|
module.attrs().into_iter().find_map(|attr| {
|
||||||
|
attr.as_key_value().and_then(|(name, value)| {
|
||||||
|
let is_path = name == "path";
|
||||||
|
if is_path {
|
||||||
|
Some(value)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ pub fn set_filter(f: Filter) {
|
||||||
/// 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.
|
/// 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.
|
||||||
/// Profiling information is being printed in the stderr.
|
/// Profiling information is being printed in the stderr.
|
||||||
///
|
///
|
||||||
/// #Example
|
/// # Example
|
||||||
/// ```
|
/// ```
|
||||||
/// use ra_prof::{profile, set_filter, Filter};
|
/// use ra_prof::{profile, set_filter, Filter};
|
||||||
///
|
///
|
||||||
|
|
Loading…
Reference in a new issue