diff options
Diffstat (limited to 'crates/libsyntax2/src')
-rw-r--r-- | crates/libsyntax2/src/ast/generated.rs | 14 | ||||
-rw-r--r-- | crates/libsyntax2/src/grammar.ron | 10 |
2 files changed, 21 insertions, 3 deletions
diff --git a/crates/libsyntax2/src/ast/generated.rs b/crates/libsyntax2/src/ast/generated.rs index e8a87eba5..610b5198c 100644 --- a/crates/libsyntax2/src/ast/generated.rs +++ b/crates/libsyntax2/src/ast/generated.rs | |||
@@ -127,6 +127,12 @@ impl<'a> File<'a> { | |||
127 | .children() | 127 | .children() |
128 | .filter_map(FnDef::cast) | 128 | .filter_map(FnDef::cast) |
129 | } | 129 | } |
130 | |||
131 | pub fn modules(self) -> impl Iterator<Item = Module<'a>> + 'a { | ||
132 | self.syntax() | ||
133 | .children() | ||
134 | .filter_map(Module::cast) | ||
135 | } | ||
130 | } | 136 | } |
131 | 137 | ||
132 | // FnDef | 138 | // FnDef |
@@ -239,7 +245,13 @@ impl<'a> AstNode<'a> for Module<'a> { | |||
239 | 245 | ||
240 | impl<'a> ast::NameOwner<'a> for Module<'a> {} | 246 | impl<'a> ast::NameOwner<'a> for Module<'a> {} |
241 | impl<'a> ast::AttrsOwner<'a> for Module<'a> {} | 247 | impl<'a> ast::AttrsOwner<'a> for Module<'a> {} |
242 | impl<'a> Module<'a> {} | 248 | impl<'a> Module<'a> { |
249 | pub fn modules(self) -> impl Iterator<Item = Module<'a>> + 'a { | ||
250 | self.syntax() | ||
251 | .children() | ||
252 | .filter_map(Module::cast) | ||
253 | } | ||
254 | } | ||
243 | 255 | ||
244 | // Name | 256 | // Name |
245 | #[derive(Debug, Clone, Copy)] | 257 | #[derive(Debug, Clone, Copy)] |
diff --git a/crates/libsyntax2/src/grammar.ron b/crates/libsyntax2/src/grammar.ron index abeffb2c3..8e644d3c4 100644 --- a/crates/libsyntax2/src/grammar.ron +++ b/crates/libsyntax2/src/grammar.ron | |||
@@ -218,7 +218,8 @@ Grammar( | |||
218 | ast: { | 218 | ast: { |
219 | "File": ( | 219 | "File": ( |
220 | collections: [ | 220 | collections: [ |
221 | ["functions", "FnDef"] | 221 | ["functions", "FnDef"], |
222 | ["modules", "Module"], | ||
222 | ] | 223 | ] |
223 | ), | 224 | ), |
224 | "FnDef": ( traits: ["NameOwner", "AttrsOwner"] ), | 225 | "FnDef": ( traits: ["NameOwner", "AttrsOwner"] ), |
@@ -231,7 +232,12 @@ Grammar( | |||
231 | "NamedField": ( traits: ["NameOwner", "AttrsOwner"] ), | 232 | "NamedField": ( traits: ["NameOwner", "AttrsOwner"] ), |
232 | "EnumDef": ( traits: ["NameOwner", "AttrsOwner"] ), | 233 | "EnumDef": ( traits: ["NameOwner", "AttrsOwner"] ), |
233 | "TraitDef": ( traits: ["NameOwner", "AttrsOwner"] ), | 234 | "TraitDef": ( traits: ["NameOwner", "AttrsOwner"] ), |
234 | "Module": ( traits: ["NameOwner", "AttrsOwner"] ), | 235 | "Module": ( |
236 | traits: ["NameOwner", "AttrsOwner"], | ||
237 | collections: [ | ||
238 | ["modules", "Module"] | ||
239 | ] | ||
240 | ), | ||
235 | "ConstDef": ( traits: ["NameOwner", "AttrsOwner"] ), | 241 | "ConstDef": ( traits: ["NameOwner", "AttrsOwner"] ), |
236 | "StaticDef": ( traits: ["NameOwner", "AttrsOwner"] ), | 242 | "StaticDef": ( traits: ["NameOwner", "AttrsOwner"] ), |
237 | "TypeDef": ( traits: ["NameOwner", "AttrsOwner"] ), | 243 | "TypeDef": ( traits: ["NameOwner", "AttrsOwner"] ), |