aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src/auto_import.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_assists/src/auto_import.rs')
-rw-r--r--crates/ra_assists/src/auto_import.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/crates/ra_assists/src/auto_import.rs b/crates/ra_assists/src/auto_import.rs
index 7c856c19b..1566cf179 100644
--- a/crates/ra_assists/src/auto_import.rs
+++ b/crates/ra_assists/src/auto_import.rs
@@ -2,8 +2,9 @@ use ra_text_edit::TextEditBuilder;
2use hir::{ self, db::HirDatabase}; 2use hir::{ self, db::HirDatabase};
3 3
4use ra_syntax::{ 4use ra_syntax::{
5 T,
5 ast::{ self, NameOwner }, AstNode, SyntaxNode, Direction, TextRange, SmolStr, 6 ast::{ self, NameOwner }, AstNode, SyntaxNode, Direction, TextRange, SmolStr,
6 SyntaxKind::{ PATH, PATH_SEGMENT, COLONCOLON, COMMA } 7 SyntaxKind::{ PATH, PATH_SEGMENT }
7}; 8};
8use crate::{ 9use crate::{
9 AssistId, 10 AssistId,
@@ -23,7 +24,7 @@ fn collect_path_segments_raw<'a>(
23 children.next().map(|n| (n, n.kind())), 24 children.next().map(|n| (n, n.kind())),
24 ); 25 );
25 match (first, second, third) { 26 match (first, second, third) {
26 (Some((subpath, PATH)), Some((_, COLONCOLON)), Some((segment, PATH_SEGMENT))) => { 27 (Some((subpath, PATH)), Some((_, T![::])), Some((segment, PATH_SEGMENT))) => {
27 path = ast::Path::cast(subpath.as_node()?)?; 28 path = ast::Path::cast(subpath.as_node()?)?;
28 segments.push(ast::PathSegment::cast(segment.as_node()?)?); 29 segments.push(ast::PathSegment::cast(segment.as_node()?)?);
29 } 30 }
@@ -421,7 +422,7 @@ fn make_assist_add_in_tree_list(
421 let last = tree_list.use_trees().last(); 422 let last = tree_list.use_trees().last();
422 if let Some(last) = last { 423 if let Some(last) = last {
423 let mut buf = String::new(); 424 let mut buf = String::new();
424 let comma = last.syntax().siblings(Direction::Next).find(|n| n.kind() == COMMA); 425 let comma = last.syntax().siblings(Direction::Next).find(|n| n.kind() == T![,]);
425 let offset = if let Some(comma) = comma { 426 let offset = if let Some(comma) = comma {
426 comma.range().end() 427 comma.range().end()
427 } else { 428 } else {