diff options
Diffstat (limited to 'crates/ra_assists/src')
-rw-r--r-- | crates/ra_assists/src/handlers/add_explicit_type.rs | 4 | ||||
-rw-r--r-- | crates/ra_assists/src/handlers/add_impl.rs | 2 | ||||
-rw-r--r-- | crates/ra_assists/src/handlers/add_new.rs | 3 | ||||
-rw-r--r-- | crates/ra_assists/src/handlers/inline_local_variable.rs | 2 | ||||
-rw-r--r-- | crates/ra_assists/src/handlers/introduce_variable.rs | 4 | ||||
-rw-r--r-- | crates/ra_assists/src/handlers/merge_imports.rs | 4 | ||||
-rw-r--r-- | crates/ra_assists/src/lib.rs | 6 |
7 files changed, 14 insertions, 11 deletions
diff --git a/crates/ra_assists/src/handlers/add_explicit_type.rs b/crates/ra_assists/src/handlers/add_explicit_type.rs index d86d804b2..e7dcfb44e 100644 --- a/crates/ra_assists/src/handlers/add_explicit_type.rs +++ b/crates/ra_assists/src/handlers/add_explicit_type.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | use hir::HirDisplay; | 1 | use hir::HirDisplay; |
2 | use ra_syntax::{ | 2 | use ra_syntax::{ |
3 | ast::{self, AstNode, LetStmt, NameOwner, TypeAscriptionOwner}, | 3 | ast::{self, AstNode, AstToken, LetStmt, NameOwner, TypeAscriptionOwner}, |
4 | TextRange, | 4 | TextRange, |
5 | }; | 5 | }; |
6 | 6 | ||
@@ -35,7 +35,7 @@ pub(crate) fn add_explicit_type(ctx: AssistCtx) -> Option<Assist> { | |||
35 | let name = pat.name()?; | 35 | let name = pat.name()?; |
36 | let name_range = name.syntax().text_range(); | 36 | let name_range = name.syntax().text_range(); |
37 | let stmt_range = stmt.syntax().text_range(); | 37 | let stmt_range = stmt.syntax().text_range(); |
38 | let eq_range = stmt.eq_token()?.text_range(); | 38 | let eq_range = stmt.eq_token()?.syntax().text_range(); |
39 | // Assist should only be applicable if cursor is between 'let' and '=' | 39 | // Assist should only be applicable if cursor is between 'let' and '=' |
40 | let let_range = TextRange::from_to(stmt_range.start(), eq_range.start()); | 40 | let let_range = TextRange::from_to(stmt_range.start(), eq_range.start()); |
41 | let cursor_in_range = ctx.frange.range.is_subrange(&let_range); | 41 | let cursor_in_range = ctx.frange.range.is_subrange(&let_range); |
diff --git a/crates/ra_assists/src/handlers/add_impl.rs b/crates/ra_assists/src/handlers/add_impl.rs index 6622eadb2..26dfed237 100644 --- a/crates/ra_assists/src/handlers/add_impl.rs +++ b/crates/ra_assists/src/handlers/add_impl.rs | |||
@@ -1,5 +1,5 @@ | |||
1 | use ra_syntax::{ | 1 | use ra_syntax::{ |
2 | ast::{self, AstNode, NameOwner, TypeParamsOwner}, | 2 | ast::{self, AstNode, AstToken, NameOwner, TypeParamsOwner}, |
3 | TextUnit, | 3 | TextUnit, |
4 | }; | 4 | }; |
5 | use stdx::{format_to, SepBy}; | 5 | use stdx::{format_to, SepBy}; |
diff --git a/crates/ra_assists/src/handlers/add_new.rs b/crates/ra_assists/src/handlers/add_new.rs index 240b19fa3..30360af94 100644 --- a/crates/ra_assists/src/handlers/add_new.rs +++ b/crates/ra_assists/src/handlers/add_new.rs | |||
@@ -1,7 +1,8 @@ | |||
1 | use hir::Adt; | 1 | use hir::Adt; |
2 | use ra_syntax::{ | 2 | use ra_syntax::{ |
3 | ast::{ | 3 | ast::{ |
4 | self, AstNode, NameOwner, StructKind, TypeAscriptionOwner, TypeParamsOwner, VisibilityOwner, | 4 | self, AstNode, AstToken, NameOwner, StructKind, TypeAscriptionOwner, TypeParamsOwner, |
5 | VisibilityOwner, | ||
5 | }, | 6 | }, |
6 | TextUnit, T, | 7 | TextUnit, T, |
7 | }; | 8 | }; |
diff --git a/crates/ra_assists/src/handlers/inline_local_variable.rs b/crates/ra_assists/src/handlers/inline_local_variable.rs index 3bfcba8ff..b9eb09676 100644 --- a/crates/ra_assists/src/handlers/inline_local_variable.rs +++ b/crates/ra_assists/src/handlers/inline_local_variable.rs | |||
@@ -29,7 +29,7 @@ pub(crate) fn inline_local_variable(ctx: AssistCtx) -> Option<Assist> { | |||
29 | ast::Pat::BindPat(pat) => pat, | 29 | ast::Pat::BindPat(pat) => pat, |
30 | _ => return None, | 30 | _ => return None, |
31 | }; | 31 | }; |
32 | if bind_pat.is_mutable() { | 32 | if bind_pat.mut_kw_token().is_some() { |
33 | tested_by!(test_not_inline_mut_variable); | 33 | tested_by!(test_not_inline_mut_variable); |
34 | return None; | 34 | return None; |
35 | } | 35 | } |
diff --git a/crates/ra_assists/src/handlers/introduce_variable.rs b/crates/ra_assists/src/handlers/introduce_variable.rs index 1edbdc14c..ab6bdf6bb 100644 --- a/crates/ra_assists/src/handlers/introduce_variable.rs +++ b/crates/ra_assists/src/handlers/introduce_variable.rs | |||
@@ -61,7 +61,7 @@ pub(crate) fn introduce_variable(ctx: AssistCtx) -> Option<Assist> { | |||
61 | }; | 61 | }; |
62 | if is_full_stmt { | 62 | if is_full_stmt { |
63 | tested_by!(test_introduce_var_expr_stmt); | 63 | tested_by!(test_introduce_var_expr_stmt); |
64 | if !full_stmt.unwrap().has_semi() { | 64 | if full_stmt.unwrap().semi_token().is_none() { |
65 | buf.push_str(";"); | 65 | buf.push_str(";"); |
66 | } | 66 | } |
67 | edit.replace(expr.syntax().text_range(), buf); | 67 | edit.replace(expr.syntax().text_range(), buf); |
@@ -124,7 +124,7 @@ fn anchor_stmt(expr: ast::Expr) -> Option<(SyntaxNode, bool)> { | |||
124 | } | 124 | } |
125 | } | 125 | } |
126 | 126 | ||
127 | if ast::Stmt::cast(node.clone()).is_some() { | 127 | if ast::Stmt::cast(node.clone().into()).is_some() { |
128 | return Some((node, false)); | 128 | return Some((node, false)); |
129 | } | 129 | } |
130 | 130 | ||
diff --git a/crates/ra_assists/src/handlers/merge_imports.rs b/crates/ra_assists/src/handlers/merge_imports.rs index 5d4b74e56..936d50ab4 100644 --- a/crates/ra_assists/src/handlers/merge_imports.rs +++ b/crates/ra_assists/src/handlers/merge_imports.rs | |||
@@ -3,7 +3,7 @@ use std::iter::successors; | |||
3 | use ra_syntax::{ | 3 | use ra_syntax::{ |
4 | algo::{neighbor, SyntaxRewriter}, | 4 | algo::{neighbor, SyntaxRewriter}, |
5 | ast::{self, edit::AstNodeEdit, make}, | 5 | ast::{self, edit::AstNodeEdit, make}, |
6 | AstNode, Direction, InsertPosition, SyntaxElement, T, | 6 | AstNode, AstToken, Direction, InsertPosition, SyntaxElement, T, |
7 | }; | 7 | }; |
8 | 8 | ||
9 | use crate::{Assist, AssistCtx, AssistId}; | 9 | use crate::{Assist, AssistCtx, AssistId}; |
@@ -82,7 +82,7 @@ fn try_merge_trees(old: &ast::UseTree, new: &ast::UseTree) -> Option<ast::UseTre | |||
82 | .filter(|it| it.kind() != T!['{'] && it.kind() != T!['}']), | 82 | .filter(|it| it.kind() != T!['{'] && it.kind() != T!['}']), |
83 | ); | 83 | ); |
84 | let use_tree_list = lhs.use_tree_list()?; | 84 | let use_tree_list = lhs.use_tree_list()?; |
85 | let pos = InsertPosition::Before(use_tree_list.r_curly()?.into()); | 85 | let pos = InsertPosition::Before(use_tree_list.r_curly_token()?.syntax().clone().into()); |
86 | let use_tree_list = use_tree_list.insert_children(pos, to_insert); | 86 | let use_tree_list = use_tree_list.insert_children(pos, to_insert); |
87 | Some(lhs.with_use_tree_list(use_tree_list)) | 87 | Some(lhs.with_use_tree_list(use_tree_list)) |
88 | } | 88 | } |
diff --git a/crates/ra_assists/src/lib.rs b/crates/ra_assists/src/lib.rs index c698d6e8c..5ba5254fd 100644 --- a/crates/ra_assists/src/lib.rs +++ b/crates/ra_assists/src/lib.rs | |||
@@ -132,13 +132,12 @@ mod handlers { | |||
132 | 132 | ||
133 | pub(crate) fn all() -> &'static [AssistHandler] { | 133 | pub(crate) fn all() -> &'static [AssistHandler] { |
134 | &[ | 134 | &[ |
135 | // These are alphabetic for the foolish consistency | ||
135 | add_custom_impl::add_custom_impl, | 136 | add_custom_impl::add_custom_impl, |
136 | add_derive::add_derive, | 137 | add_derive::add_derive, |
137 | add_explicit_type::add_explicit_type, | 138 | add_explicit_type::add_explicit_type, |
138 | add_function::add_function, | 139 | add_function::add_function, |
139 | add_impl::add_impl, | 140 | add_impl::add_impl, |
140 | add_missing_impl_members::add_missing_default_members, | ||
141 | add_missing_impl_members::add_missing_impl_members, | ||
142 | add_new::add_new, | 141 | add_new::add_new, |
143 | apply_demorgan::apply_demorgan, | 142 | apply_demorgan::apply_demorgan, |
144 | auto_import::auto_import, | 143 | auto_import::auto_import, |
@@ -168,6 +167,9 @@ mod handlers { | |||
168 | replace_unwrap_with_match::replace_unwrap_with_match, | 167 | replace_unwrap_with_match::replace_unwrap_with_match, |
169 | split_import::split_import, | 168 | split_import::split_import, |
170 | add_from_impl_for_enum::add_from_impl_for_enum, | 169 | add_from_impl_for_enum::add_from_impl_for_enum, |
170 | // These are manually sorted for better priorities | ||
171 | add_missing_impl_members::add_missing_impl_members, | ||
172 | add_missing_impl_members::add_missing_default_members, | ||
171 | ] | 173 | ] |
172 | } | 174 | } |
173 | } | 175 | } |