aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api_light/src/diagnostics.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-02-08 11:49:43 +0000
committerAleksey Kladov <[email protected]>2019-02-08 11:49:43 +0000
commit12e3b4c70b5ef23b2fdfc197296d483680e125f9 (patch)
tree71baa0e0a62f9f6b61450501c5f821f67badf9e4 /crates/ra_ide_api_light/src/diagnostics.rs
parent5cb1d41a30d25cbe136402644bf5434dd667f1e5 (diff)
reformat the world
Diffstat (limited to 'crates/ra_ide_api_light/src/diagnostics.rs')
-rw-r--r--crates/ra_ide_api_light/src/diagnostics.rs32
1 files changed, 6 insertions, 26 deletions
diff --git a/crates/ra_ide_api_light/src/diagnostics.rs b/crates/ra_ide_api_light/src/diagnostics.rs
index 2b695dfdf..7c383ca2a 100644
--- a/crates/ra_ide_api_light/src/diagnostics.rs
+++ b/crates/ra_ide_api_light/src/diagnostics.rs
@@ -72,14 +72,7 @@ fn text_edit_for_remove_unnecessary_braces_with_self_in_use_statement(
72 single_use_tree: &ast::UseTree, 72 single_use_tree: &ast::UseTree,
73) -> Option<TextEdit> { 73) -> Option<TextEdit> {
74 let use_tree_list_node = single_use_tree.syntax().parent()?; 74 let use_tree_list_node = single_use_tree.syntax().parent()?;
75 if single_use_tree 75 if single_use_tree.path()?.segment()?.syntax().first_child()?.kind() == SyntaxKind::SELF_KW {
76 .path()?
77 .segment()?
78 .syntax()
79 .first_child()?
80 .kind()
81 == SyntaxKind::SELF_KW
82 {
83 let start = use_tree_list_node.prev_sibling()?.range().start(); 76 let start = use_tree_list_node.prev_sibling()?.range().start();
84 let end = use_tree_list_node.range().end(); 77 let end = use_tree_list_node.range().end();
85 let range = TextRange::from_to(start, end); 78 let range = TextRange::from_to(start, end);
@@ -145,9 +138,8 @@ mod tests {
145 for node in file.syntax().descendants() { 138 for node in file.syntax().descendants() {
146 func(&mut diagnostics, node); 139 func(&mut diagnostics, node);
147 } 140 }
148 let diagnostic = diagnostics 141 let diagnostic =
149 .pop() 142 diagnostics.pop().unwrap_or_else(|| panic!("no diagnostics for:\n{}\n", before));
150 .unwrap_or_else(|| panic!("no diagnostics for:\n{}\n", before));
151 let fix = diagnostic.fix.unwrap(); 143 let fix = diagnostic.fix.unwrap();
152 let actual = fix.edit.apply(&before); 144 let actual = fix.edit.apply(&before);
153 assert_eq_text!(after, &actual); 145 assert_eq_text!(after, &actual);
@@ -162,21 +154,9 @@ mod tests {
162 ", 154 ",
163 check_unnecessary_braces_in_use_statement, 155 check_unnecessary_braces_in_use_statement,
164 ); 156 );
165 check_apply( 157 check_apply("use {b};", "use b;", check_unnecessary_braces_in_use_statement);
166 "use {b};", 158 check_apply("use a::{c};", "use a::c;", check_unnecessary_braces_in_use_statement);
167 "use b;", 159 check_apply("use a::{self};", "use a;", check_unnecessary_braces_in_use_statement);
168 check_unnecessary_braces_in_use_statement,
169 );
170 check_apply(
171 "use a::{c};",
172 "use a::c;",
173 check_unnecessary_braces_in_use_statement,
174 );
175 check_apply(
176 "use a::{self};",
177 "use a;",
178 check_unnecessary_braces_in_use_statement,
179 );
180 check_apply( 160 check_apply(
181 "use a::{c, d::{e}};", 161 "use a::{c, d::{e}};",
182 "use a::{c, d::e};", 162 "use a::{c, d::e};",