aboutsummaryrefslogtreecommitdiff
path: root/crates/syntax
diff options
context:
space:
mode:
authorLukas Wirth <[email protected]>2021-06-18 22:11:56 +0100
committerLukas Wirth <[email protected]>2021-06-18 22:11:56 +0100
commit2ee090faaf69474a2baadf0494ef3c6ed4fdbcbc (patch)
treee67e1f3404fefb2dc3999b94f86bc9cbcca33dd1 /crates/syntax
parent84507a0b9c2e8f6e632ad9ec649cd1f21a7e0887 (diff)
Allow to disable import insertion on single path glob imports
Diffstat (limited to 'crates/syntax')
-rw-r--r--crates/syntax/src/ast/node_ext.rs9
1 files changed, 9 insertions, 0 deletions
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 {
281 successors(self.qualifier(), |p| p.qualifier()) 281 successors(self.qualifier(), |p| p.qualifier())
282 } 282 }
283} 283}
284
285impl ast::Use {
286 pub fn is_simple_glob(&self) -> bool {
287 self.use_tree()
288 .map(|use_tree| use_tree.use_tree_list().is_none() && use_tree.star_token().is_some())
289 .unwrap_or(false)
290 }
291}
292
284impl ast::UseTree { 293impl ast::UseTree {
285 pub fn is_simple_path(&self) -> bool { 294 pub fn is_simple_path(&self) -> bool {
286 self.use_tree_list().is_none() && self.star_token().is_none() 295 self.use_tree_list().is_none() && self.star_token().is_none()