aboutsummaryrefslogtreecommitdiff
path: root/crates/assists
diff options
context:
space:
mode:
authorLukas Wirth <[email protected]>2020-10-25 13:27:32 +0000
committerLukas Wirth <[email protected]>2020-10-25 13:28:44 +0000
commit6675d4c57641135a73658d9ba66b78205bb45742 (patch)
tree6ffa001de7d79ea3ad8fca3d22be489580b4e700 /crates/assists
parent91c1af36120ed9b5ad1da4972ab18d0d042e991f (diff)
Don't keep parens around with remove-dbg when encountering method chaining
Diffstat (limited to 'crates/assists')
-rw-r--r--crates/assists/src/handlers/remove_dbg.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/crates/assists/src/handlers/remove_dbg.rs b/crates/assists/src/handlers/remove_dbg.rs
index e10616779..e7072d2b9 100644
--- a/crates/assists/src/handlers/remove_dbg.rs
+++ b/crates/assists/src/handlers/remove_dbg.rs
@@ -119,6 +119,7 @@ fn needs_parentheses_around_macro_contents(macro_contents: Vec<SyntaxElement>) -
119 let symbol_not_in_bracket = unpaired_brackets_in_contents.is_empty(); 119 let symbol_not_in_bracket = unpaired_brackets_in_contents.is_empty();
120 if symbol_not_in_bracket 120 if symbol_not_in_bracket
121 && symbol_kind != SyntaxKind::COLON 121 && symbol_kind != SyntaxKind::COLON
122 && symbol_kind != SyntaxKind::DOT
122 && symbol_kind.is_punct() 123 && symbol_kind.is_punct()
123 { 124 {
124 return true; 125 return true;
@@ -243,6 +244,25 @@ fn main() {
243 } 244 }
244 245
245 #[test] 246 #[test]
247 fn test_remove_dbg_method_chaining() {
248 check_assist(
249 remove_dbg,
250 r#"let res = <|>dbg!(foo().bar()).baz();"#,
251 r#"let res = foo().bar().baz();"#,
252 );
253 check_assist(
254 remove_dbg,
255 r#"let res = <|>dbg!(foo.bar()).baz();"#,
256 r#"let res = foo.bar().baz();"#,
257 );
258 }
259
260 #[test]
261 fn test_remove_dbg_field_chaining() {
262 check_assist(remove_dbg, r#"let res = <|>dbg!(foo.bar).baz;"#, r#"let res = foo.bar.baz;"#);
263 }
264
265 #[test]
246 fn test_remove_dbg_from_inside_fn() { 266 fn test_remove_dbg_from_inside_fn() {
247 check_assist_target( 267 check_assist_target(
248 remove_dbg, 268 remove_dbg,