From 2ee090faaf69474a2baadf0494ef3c6ed4fdbcbc Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Fri, 18 Jun 2021 23:11:56 +0200 Subject: Allow to disable import insertion on single path glob imports --- crates/syntax/src/ast/node_ext.rs | 9 +++++++++ 1 file changed, 9 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 b057e6624..3c92a486f 100644 --- a/crates/syntax/src/ast/node_ext.rs +++ b/crates/syntax/src/ast/node_ext.rs @@ -281,6 +281,15 @@ impl ast::Path { successors(self.qualifier(), |p| p.qualifier()) } } + +impl ast::Use { + pub fn is_simple_glob(&self) -> bool { + self.use_tree() + .map(|use_tree| use_tree.use_tree_list().is_none() && use_tree.star_token().is_some()) + .unwrap_or(false) + } +} + impl ast::UseTree { pub fn is_simple_path(&self) -> bool { self.use_tree_list().is_none() && self.star_token().is_none() -- cgit v1.2.3