From cd5f4121e3bfb345f730bdce4106450e728f9721 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Thu, 17 Jun 2021 12:09:28 +0200 Subject: Create modules in correct directory for nested modules in move_module assist --- crates/syntax/src/ast/node_ext.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'crates/syntax/src/ast') diff --git a/crates/syntax/src/ast/node_ext.rs b/crates/syntax/src/ast/node_ext.rs index 2bd9ad867..b057e6624 100644 --- a/crates/syntax/src/ast/node_ext.rs +++ b/crates/syntax/src/ast/node_ext.rs @@ -675,6 +675,14 @@ impl ast::LifetimeParam { } } +impl ast::Module { + /// Returns the parent ast::Module, this is different than the semantic parent in that this only + /// considers parent declarations in the AST + pub fn parent(&self) -> Option { + self.syntax().ancestors().nth(2).and_then(ast::Module::cast) + } +} + impl ast::RangePat { pub fn start(&self) -> Option { self.syntax() -- cgit v1.2.3