}
.collect(&*items);
}
- // out of line module, resovle, parse and recurse
- raw::ModuleData::Declaration { name, ast_id } => {
+ // out of line module, resolve, parse and recurse
+ raw::ModuleData::Declaration { name, ast_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();
match resolve_submodule(self.def_collector.db, self.file_id, name, is_root) {
use ra_arena::{impl_arena_id, map::ArenaMap, Arena, RawId};
use ra_syntax::{
ast::{self, AttrsOwner, NameOwner},
- AstNode, AstPtr, SourceFile, TreeArc,
+ AstNode, AstPtr, SmolStr, SourceFile, TreeArc,
};
use test_utils::tested_by;
#[derive(Debug, PartialEq, Eq)]
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> },
}
Some(it) => it.as_name(),
None => return,
};
+
+ let attr_path = extract_mod_path_attribute(module);
let ast_id = self.source_ast_id_map.ast_id(module);
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));
return;
}
.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
+ }
+ })
+ })
+}