aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_assists/src/assist_ctx.rs2
-rw-r--r--crates/ra_assists/src/assists/add_derive.rs2
-rw-r--r--crates/ra_assists/src/assists/add_explicit_type.rs2
-rw-r--r--crates/ra_assists/src/assists/add_impl.rs2
-rw-r--r--crates/ra_assists/src/assists/add_missing_impl_members.rs2
-rw-r--r--crates/ra_assists/src/assists/apply_demorgan.rs2
-rw-r--r--crates/ra_assists/src/assists/auto_import.rs2
-rw-r--r--crates/ra_assists/src/assists/change_visibility.rs2
-rw-r--r--crates/ra_assists/src/assists/early_return.rs2
-rw-r--r--crates/ra_assists/src/assists/fill_match_arms.rs2
-rw-r--r--crates/ra_assists/src/assists/flip_binexpr.rs2
-rw-r--r--crates/ra_assists/src/assists/inline_local_variable.rs2
-rw-r--r--crates/ra_assists/src/assists/merge_match_arms.rs2
-rw-r--r--crates/ra_assists/src/assists/move_bounds.rs2
-rw-r--r--crates/ra_assists/src/assists/move_guard.rs4
-rw-r--r--crates/ra_assists/src/assists/remove_dbg.rs2
-rw-r--r--crates/ra_assists/src/assists/replace_if_let_with_match.rs2
17 files changed, 18 insertions, 18 deletions
diff --git a/crates/ra_assists/src/assist_ctx.rs b/crates/ra_assists/src/assist_ctx.rs
index 20d33fb16..5f85f20e2 100644
--- a/crates/ra_assists/src/assist_ctx.rs
+++ b/crates/ra_assists/src/assist_ctx.rs
@@ -115,7 +115,7 @@ impl<'a, DB: HirDatabase> AssistCtx<'a, DB> {
115 self.token_at_offset().find(|it| it.kind() == kind) 115 self.token_at_offset().find(|it| it.kind() == kind)
116 } 116 }
117 117
118 pub(crate) fn node_at_offset<N: AstNode>(&self) -> Option<N> { 118 pub(crate) fn find_node_at_offset<N: AstNode>(&self) -> Option<N> {
119 find_node_at_offset(self.source_file.syntax(), self.frange.range.start()) 119 find_node_at_offset(self.source_file.syntax(), self.frange.range.start())
120 } 120 }
121 pub(crate) fn covering_element(&self) -> SyntaxElement { 121 pub(crate) fn covering_element(&self) -> SyntaxElement {
diff --git a/crates/ra_assists/src/assists/add_derive.rs b/crates/ra_assists/src/assists/add_derive.rs
index b077acb81..d1e925b71 100644
--- a/crates/ra_assists/src/assists/add_derive.rs
+++ b/crates/ra_assists/src/assists/add_derive.rs
@@ -26,7 +26,7 @@ use crate::{Assist, AssistCtx, AssistId};
26// } 26// }
27// ``` 27// ```
28pub(crate) fn add_derive(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { 28pub(crate) fn add_derive(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
29 let nominal = ctx.node_at_offset::<ast::NominalDef>()?; 29 let nominal = ctx.find_node_at_offset::<ast::NominalDef>()?;
30 let node_start = derive_insertion_offset(&nominal)?; 30 let node_start = derive_insertion_offset(&nominal)?;
31 ctx.add_action(AssistId("add_derive"), "add `#[derive]`", |edit| { 31 ctx.add_action(AssistId("add_derive"), "add `#[derive]`", |edit| {
32 let derive_attr = nominal 32 let derive_attr = nominal
diff --git a/crates/ra_assists/src/assists/add_explicit_type.rs b/crates/ra_assists/src/assists/add_explicit_type.rs
index 2903c1781..ffbdc0b62 100644
--- a/crates/ra_assists/src/assists/add_explicit_type.rs
+++ b/crates/ra_assists/src/assists/add_explicit_type.rs
@@ -22,7 +22,7 @@ use crate::{Assist, AssistCtx, AssistId};
22// } 22// }
23// ``` 23// ```
24pub(crate) fn add_explicit_type(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { 24pub(crate) fn add_explicit_type(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
25 let stmt = ctx.node_at_offset::<LetStmt>()?; 25 let stmt = ctx.find_node_at_offset::<LetStmt>()?;
26 let expr = stmt.initializer()?; 26 let expr = stmt.initializer()?;
27 let pat = stmt.pat()?; 27 let pat = stmt.pat()?;
28 // Must be a binding 28 // Must be a binding
diff --git a/crates/ra_assists/src/assists/add_impl.rs b/crates/ra_assists/src/assists/add_impl.rs
index 142777b06..fd3588d24 100644
--- a/crates/ra_assists/src/assists/add_impl.rs
+++ b/crates/ra_assists/src/assists/add_impl.rs
@@ -28,7 +28,7 @@ use crate::{Assist, AssistCtx, AssistId};
28// } 28// }
29// ``` 29// ```
30pub(crate) fn add_impl(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { 30pub(crate) fn add_impl(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
31 let nominal = ctx.node_at_offset::<ast::NominalDef>()?; 31 let nominal = ctx.find_node_at_offset::<ast::NominalDef>()?;
32 let name = nominal.name()?; 32 let name = nominal.name()?;
33 ctx.add_action(AssistId("add_impl"), "add impl", |edit| { 33 ctx.add_action(AssistId("add_impl"), "add impl", |edit| {
34 edit.target(nominal.syntax().text_range()); 34 edit.target(nominal.syntax().text_range());
diff --git a/crates/ra_assists/src/assists/add_missing_impl_members.rs b/crates/ra_assists/src/assists/add_missing_impl_members.rs
index 4ee4d47fa..2585f3045 100644
--- a/crates/ra_assists/src/assists/add_missing_impl_members.rs
+++ b/crates/ra_assists/src/assists/add_missing_impl_members.rs
@@ -96,7 +96,7 @@ fn add_missing_impl_members_inner(
96 assist_id: &'static str, 96 assist_id: &'static str,
97 label: &'static str, 97 label: &'static str,
98) -> Option<Assist> { 98) -> Option<Assist> {
99 let impl_node = ctx.node_at_offset::<ast::ImplBlock>()?; 99 let impl_node = ctx.find_node_at_offset::<ast::ImplBlock>()?;
100 let impl_item_list = impl_node.item_list()?; 100 let impl_item_list = impl_node.item_list()?;
101 101
102 let trait_def = { 102 let trait_def = {
diff --git a/crates/ra_assists/src/assists/apply_demorgan.rs b/crates/ra_assists/src/assists/apply_demorgan.rs
index 75144cefe..8d5984a58 100644
--- a/crates/ra_assists/src/assists/apply_demorgan.rs
+++ b/crates/ra_assists/src/assists/apply_demorgan.rs
@@ -24,7 +24,7 @@ use crate::{Assist, AssistCtx, AssistId};
24// } 24// }
25// ``` 25// ```
26pub(crate) fn apply_demorgan(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { 26pub(crate) fn apply_demorgan(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
27 let expr = ctx.node_at_offset::<ast::BinExpr>()?; 27 let expr = ctx.find_node_at_offset::<ast::BinExpr>()?;
28 let op = expr.op_kind()?; 28 let op = expr.op_kind()?;
29 let op_range = expr.op_token()?.text_range(); 29 let op_range = expr.op_token()?.text_range();
30 let opposite_op = opposite_logic_op(op)?; 30 let opposite_op = opposite_logic_op(op)?;
diff --git a/crates/ra_assists/src/assists/auto_import.rs b/crates/ra_assists/src/assists/auto_import.rs
index 02c58e7c6..a1c2aaa72 100644
--- a/crates/ra_assists/src/assists/auto_import.rs
+++ b/crates/ra_assists/src/assists/auto_import.rs
@@ -547,7 +547,7 @@ pub fn auto_import_text_edit(
547} 547}
548 548
549pub(crate) fn auto_import(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { 549pub(crate) fn auto_import(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
550 let path: ast::Path = ctx.node_at_offset()?; 550 let path: ast::Path = ctx.find_node_at_offset()?;
551 // We don't want to mess with use statements 551 // We don't want to mess with use statements
552 if path.syntax().ancestors().find_map(ast::UseItem::cast).is_some() { 552 if path.syntax().ancestors().find_map(ast::UseItem::cast).is_some() {
553 return None; 553 return None;
diff --git a/crates/ra_assists/src/assists/change_visibility.rs b/crates/ra_assists/src/assists/change_visibility.rs
index bed343677..770ea04fa 100644
--- a/crates/ra_assists/src/assists/change_visibility.rs
+++ b/crates/ra_assists/src/assists/change_visibility.rs
@@ -23,7 +23,7 @@ use crate::{Assist, AssistCtx, AssistId};
23// pub(crate) fn frobnicate() {} 23// pub(crate) fn frobnicate() {}
24// ``` 24// ```
25pub(crate) fn change_visibility(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { 25pub(crate) fn change_visibility(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
26 if let Some(vis) = ctx.node_at_offset::<ast::Visibility>() { 26 if let Some(vis) = ctx.find_node_at_offset::<ast::Visibility>() {
27 return change_vis(ctx, vis); 27 return change_vis(ctx, vis);
28 } 28 }
29 add_vis(ctx) 29 add_vis(ctx)
diff --git a/crates/ra_assists/src/assists/early_return.rs b/crates/ra_assists/src/assists/early_return.rs
index 48782db42..75822dc65 100644
--- a/crates/ra_assists/src/assists/early_return.rs
+++ b/crates/ra_assists/src/assists/early_return.rs
@@ -36,7 +36,7 @@ use crate::{
36// } 36// }
37// ``` 37// ```
38pub(crate) fn convert_to_guarded_return(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { 38pub(crate) fn convert_to_guarded_return(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
39 let if_expr: ast::IfExpr = ctx.node_at_offset()?; 39 let if_expr: ast::IfExpr = ctx.find_node_at_offset()?;
40 let expr = if_expr.condition()?.expr()?; 40 let expr = if_expr.condition()?.expr()?;
41 let then_block = if_expr.then_branch()?.block()?; 41 let then_block = if_expr.then_branch()?.block()?;
42 if if_expr.else_branch().is_some() { 42 if if_expr.else_branch().is_some() {
diff --git a/crates/ra_assists/src/assists/fill_match_arms.rs b/crates/ra_assists/src/assists/fill_match_arms.rs
index b6166f947..c62c0efbe 100644
--- a/crates/ra_assists/src/assists/fill_match_arms.rs
+++ b/crates/ra_assists/src/assists/fill_match_arms.rs
@@ -32,7 +32,7 @@ use crate::{Assist, AssistCtx, AssistId};
32// } 32// }
33// ``` 33// ```
34pub(crate) fn fill_match_arms(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { 34pub(crate) fn fill_match_arms(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
35 let match_expr = ctx.node_at_offset::<ast::MatchExpr>()?; 35 let match_expr = ctx.find_node_at_offset::<ast::MatchExpr>()?;
36 let match_arm_list = match_expr.match_arm_list()?; 36 let match_arm_list = match_expr.match_arm_list()?;
37 37
38 // We already have some match arms, so we don't provide any assists. 38 // We already have some match arms, so we don't provide any assists.
diff --git a/crates/ra_assists/src/assists/flip_binexpr.rs b/crates/ra_assists/src/assists/flip_binexpr.rs
index 3a1e5cbe1..9765d5ddd 100644
--- a/crates/ra_assists/src/assists/flip_binexpr.rs
+++ b/crates/ra_assists/src/assists/flip_binexpr.rs
@@ -19,7 +19,7 @@ use crate::{Assist, AssistCtx, AssistId};
19// } 19// }
20// ``` 20// ```
21pub(crate) fn flip_binexpr(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { 21pub(crate) fn flip_binexpr(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
22 let expr = ctx.node_at_offset::<BinExpr>()?; 22 let expr = ctx.find_node_at_offset::<BinExpr>()?;
23 let lhs = expr.lhs()?.syntax().clone(); 23 let lhs = expr.lhs()?.syntax().clone();
24 let rhs = expr.rhs()?.syntax().clone(); 24 let rhs = expr.rhs()?.syntax().clone();
25 let op_range = expr.op_token()?.text_range(); 25 let op_range = expr.op_token()?.text_range();
diff --git a/crates/ra_assists/src/assists/inline_local_variable.rs b/crates/ra_assists/src/assists/inline_local_variable.rs
index 1997781db..fe8fa2a86 100644
--- a/crates/ra_assists/src/assists/inline_local_variable.rs
+++ b/crates/ra_assists/src/assists/inline_local_variable.rs
@@ -24,7 +24,7 @@ use crate::{Assist, AssistCtx, AssistId};
24// } 24// }
25// ``` 25// ```
26pub(crate) fn inline_local_varialbe(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { 26pub(crate) fn inline_local_varialbe(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
27 let let_stmt = ctx.node_at_offset::<ast::LetStmt>()?; 27 let let_stmt = ctx.find_node_at_offset::<ast::LetStmt>()?;
28 let bind_pat = match let_stmt.pat()? { 28 let bind_pat = match let_stmt.pat()? {
29 ast::Pat::BindPat(pat) => pat, 29 ast::Pat::BindPat(pat) => pat,
30 _ => return None, 30 _ => return None,
diff --git a/crates/ra_assists/src/assists/merge_match_arms.rs b/crates/ra_assists/src/assists/merge_match_arms.rs
index f5ddd7159..b0c4ee78b 100644
--- a/crates/ra_assists/src/assists/merge_match_arms.rs
+++ b/crates/ra_assists/src/assists/merge_match_arms.rs
@@ -27,7 +27,7 @@ use ra_syntax::ast::{AstNode, MatchArm};
27// } 27// }
28// ``` 28// ```
29pub(crate) fn merge_match_arms(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { 29pub(crate) fn merge_match_arms(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
30 let current_arm = ctx.node_at_offset::<MatchArm>()?; 30 let current_arm = ctx.find_node_at_offset::<MatchArm>()?;
31 31
32 // We check if the following match arm matches this one. We could, but don't, 32 // We check if the following match arm matches this one. We could, but don't,
33 // compare to the previous match arm as well. 33 // compare to the previous match arm as well.
diff --git a/crates/ra_assists/src/assists/move_bounds.rs b/crates/ra_assists/src/assists/move_bounds.rs
index f96e19a9f..edf2897c6 100644
--- a/crates/ra_assists/src/assists/move_bounds.rs
+++ b/crates/ra_assists/src/assists/move_bounds.rs
@@ -23,7 +23,7 @@ use crate::{Assist, AssistCtx, AssistId};
23// } 23// }
24// ``` 24// ```
25pub(crate) fn move_bounds_to_where_clause(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { 25pub(crate) fn move_bounds_to_where_clause(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
26 let type_param_list = ctx.node_at_offset::<ast::TypeParamList>()?; 26 let type_param_list = ctx.find_node_at_offset::<ast::TypeParamList>()?;
27 27
28 let mut type_params = type_param_list.type_params(); 28 let mut type_params = type_param_list.type_params();
29 if type_params.all(|p| p.type_bound_list().is_none()) { 29 if type_params.all(|p| p.type_bound_list().is_none()) {
diff --git a/crates/ra_assists/src/assists/move_guard.rs b/crates/ra_assists/src/assists/move_guard.rs
index 36c95128d..e820a73c8 100644
--- a/crates/ra_assists/src/assists/move_guard.rs
+++ b/crates/ra_assists/src/assists/move_guard.rs
@@ -33,7 +33,7 @@ use crate::{Assist, AssistCtx, AssistId};
33// } 33// }
34// ``` 34// ```
35pub(crate) fn move_guard_to_arm_body(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { 35pub(crate) fn move_guard_to_arm_body(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
36 let match_arm = ctx.node_at_offset::<MatchArm>()?; 36 let match_arm = ctx.find_node_at_offset::<MatchArm>()?;
37 let guard = match_arm.guard()?; 37 let guard = match_arm.guard()?;
38 let space_before_guard = guard.syntax().prev_sibling_or_token(); 38 let space_before_guard = guard.syntax().prev_sibling_or_token();
39 39
@@ -91,7 +91,7 @@ pub(crate) fn move_guard_to_arm_body(mut ctx: AssistCtx<impl HirDatabase>) -> Op
91// } 91// }
92// ``` 92// ```
93pub(crate) fn move_arm_cond_to_match_guard(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { 93pub(crate) fn move_arm_cond_to_match_guard(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
94 let match_arm: MatchArm = ctx.node_at_offset::<MatchArm>()?; 94 let match_arm: MatchArm = ctx.find_node_at_offset::<MatchArm>()?;
95 let last_match_pat = match_arm.pats().last()?; 95 let last_match_pat = match_arm.pats().last()?;
96 96
97 let arm_body = match_arm.expr()?; 97 let arm_body = match_arm.expr()?;
diff --git a/crates/ra_assists/src/assists/remove_dbg.rs b/crates/ra_assists/src/assists/remove_dbg.rs
index 1a7e2b305..ac2c43e1a 100644
--- a/crates/ra_assists/src/assists/remove_dbg.rs
+++ b/crates/ra_assists/src/assists/remove_dbg.rs
@@ -8,7 +8,7 @@ use ra_syntax::{
8}; 8};
9 9
10pub(crate) fn remove_dbg(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { 10pub(crate) fn remove_dbg(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
11 let macro_call = ctx.node_at_offset::<ast::MacroCall>()?; 11 let macro_call = ctx.find_node_at_offset::<ast::MacroCall>()?;
12 12
13 if !is_valid_macrocall(&macro_call, "dbg")? { 13 if !is_valid_macrocall(&macro_call, "dbg")? {
14 return None; 14 return None;
diff --git a/crates/ra_assists/src/assists/replace_if_let_with_match.rs b/crates/ra_assists/src/assists/replace_if_let_with_match.rs
index 749ff338a..da276e47b 100644
--- a/crates/ra_assists/src/assists/replace_if_let_with_match.rs
+++ b/crates/ra_assists/src/assists/replace_if_let_with_match.rs
@@ -8,7 +8,7 @@ use ra_syntax::{ast, AstNode};
8use crate::{Assist, AssistCtx, AssistId}; 8use crate::{Assist, AssistCtx, AssistId};
9 9
10pub(crate) fn replace_if_let_with_match(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { 10pub(crate) fn replace_if_let_with_match(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
11 let if_expr: ast::IfExpr = ctx.node_at_offset()?; 11 let if_expr: ast::IfExpr = ctx.find_node_at_offset()?;
12 let cond = if_expr.condition()?; 12 let cond = if_expr.condition()?;
13 let pat = cond.pat()?; 13 let pat = cond.pat()?;
14 let expr = cond.expr()?; 14 let expr = cond.expr()?;