Start code_model::Module

This commit is contained in:
Aleksey Kladov
2019-01-05 01:37:40 +03:00
parent 9a820dc0ee
commit 147b0f94e6
4 changed files with 83 additions and 7 deletions

View File

@@ -224,7 +224,7 @@ impl ModuleTree {
/// `ModuleSource` is the syntax tree element that produced this module:
/// either a file, or an inlinde module.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct ModuleSource(SourceItemId);
pub struct ModuleSource(pub(crate) SourceItemId);
/// An owned syntax node for a module. Unlike `ModuleSource`,
/// this holds onto the AST for the whole file.
@@ -255,12 +255,12 @@ impl ModuleId {
let link = self.parent_link(tree)?;
Some(tree.links[link].owner)
}
fn crate_root(self, tree: &ModuleTree) -> ModuleId {
pub(crate) fn crate_root(self, tree: &ModuleTree) -> ModuleId {
generate(Some(self), move |it| it.parent(tree))
.last()
.unwrap()
}
fn child(self, tree: &ModuleTree, name: &Name) -> Option<ModuleId> {
pub(crate) fn child(self, tree: &ModuleTree, name: &Name) -> Option<ModuleId> {
let link = tree.mods[self]
.children
.iter()