mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
Module map implementation
This commit is contained in:
parent
4d8be26584
commit
b937262c9b
7 changed files with 247 additions and 47 deletions
|
@ -127,6 +127,12 @@ impl<'a> File<'a> {
|
|||
.children()
|
||||
.filter_map(FnDef::cast)
|
||||
}
|
||||
|
||||
pub fn modules(self) -> impl Iterator<Item = Module<'a>> + 'a {
|
||||
self.syntax()
|
||||
.children()
|
||||
.filter_map(Module::cast)
|
||||
}
|
||||
}
|
||||
|
||||
// FnDef
|
||||
|
@ -239,7 +245,13 @@ impl<'a> AstNode<'a> for Module<'a> {
|
|||
|
||||
impl<'a> ast::NameOwner<'a> for Module<'a> {}
|
||||
impl<'a> ast::AttrsOwner<'a> for Module<'a> {}
|
||||
impl<'a> Module<'a> {}
|
||||
impl<'a> Module<'a> {
|
||||
pub fn modules(self) -> impl Iterator<Item = Module<'a>> + 'a {
|
||||
self.syntax()
|
||||
.children()
|
||||
.filter_map(Module::cast)
|
||||
}
|
||||
}
|
||||
|
||||
// Name
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
|
|
|
@ -218,7 +218,8 @@ Grammar(
|
|||
ast: {
|
||||
"File": (
|
||||
collections: [
|
||||
["functions", "FnDef"]
|
||||
["functions", "FnDef"],
|
||||
["modules", "Module"],
|
||||
]
|
||||
),
|
||||
"FnDef": ( traits: ["NameOwner", "AttrsOwner"] ),
|
||||
|
@ -231,7 +232,12 @@ Grammar(
|
|||
"NamedField": ( traits: ["NameOwner", "AttrsOwner"] ),
|
||||
"EnumDef": ( traits: ["NameOwner", "AttrsOwner"] ),
|
||||
"TraitDef": ( traits: ["NameOwner", "AttrsOwner"] ),
|
||||
"Module": ( traits: ["NameOwner", "AttrsOwner"] ),
|
||||
"Module": (
|
||||
traits: ["NameOwner", "AttrsOwner"],
|
||||
collections: [
|
||||
["modules", "Module"]
|
||||
]
|
||||
),
|
||||
"ConstDef": ( traits: ["NameOwner", "AttrsOwner"] ),
|
||||
"StaticDef": ( traits: ["NameOwner", "AttrsOwner"] ),
|
||||
"TypeDef": ( traits: ["NameOwner", "AttrsOwner"] ),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue