diff options
author | Kirill Bulatov <[email protected]> | 2021-02-20 21:32:21 +0000 |
---|---|---|
committer | Kirill Bulatov <[email protected]> | 2021-03-08 21:58:32 +0000 |
commit | 005bc49d744f6a7c2ef38a4abd3327b0804709d1 (patch) | |
tree | 9a971daee4d175859b454d7edf20e630982fa69b /crates/ide_assists/src | |
parent | c48478621fe9b50cb19bfd0ea4a5c2ff0de5d6ac (diff) |
Test and initial refactoring
Diffstat (limited to 'crates/ide_assists/src')
-rw-r--r-- | crates/ide_assists/src/handlers/auto_import.rs | 35 | ||||
-rw-r--r-- | crates/ide_assists/src/handlers/qualify_path.rs | 4 |
2 files changed, 2 insertions, 37 deletions
diff --git a/crates/ide_assists/src/handlers/auto_import.rs b/crates/ide_assists/src/handlers/auto_import.rs index 1422224ac..5fe3f47fd 100644 --- a/crates/ide_assists/src/handlers/auto_import.rs +++ b/crates/ide_assists/src/handlers/auto_import.rs | |||
@@ -221,41 +221,6 @@ mod tests { | |||
221 | } | 221 | } |
222 | 222 | ||
223 | #[test] | 223 | #[test] |
224 | fn auto_imports_are_merged() { | ||
225 | check_assist( | ||
226 | auto_import, | ||
227 | r" | ||
228 | use PubMod::PubStruct1; | ||
229 | |||
230 | struct Test { | ||
231 | test: Pub$0Struct2<u8>, | ||
232 | } | ||
233 | |||
234 | pub mod PubMod { | ||
235 | pub struct PubStruct1; | ||
236 | pub struct PubStruct2<T> { | ||
237 | _t: T, | ||
238 | } | ||
239 | } | ||
240 | ", | ||
241 | r" | ||
242 | use PubMod::{PubStruct1, PubStruct2}; | ||
243 | |||
244 | struct Test { | ||
245 | test: PubStruct2<u8>, | ||
246 | } | ||
247 | |||
248 | pub mod PubMod { | ||
249 | pub struct PubStruct1; | ||
250 | pub struct PubStruct2<T> { | ||
251 | _t: T, | ||
252 | } | ||
253 | } | ||
254 | ", | ||
255 | ); | ||
256 | } | ||
257 | |||
258 | #[test] | ||
259 | fn applicable_when_found_multiple_imports() { | 224 | fn applicable_when_found_multiple_imports() { |
260 | check_assist( | 225 | check_assist( |
261 | auto_import, | 226 | auto_import, |
diff --git a/crates/ide_assists/src/handlers/qualify_path.rs b/crates/ide_assists/src/handlers/qualify_path.rs index d3e34e540..1fb4931cd 100644 --- a/crates/ide_assists/src/handlers/qualify_path.rs +++ b/crates/ide_assists/src/handlers/qualify_path.rs | |||
@@ -45,7 +45,7 @@ pub(crate) fn qualify_path(acc: &mut Assists, ctx: &AssistContext) -> Option<()> | |||
45 | 45 | ||
46 | let qualify_candidate = match candidate { | 46 | let qualify_candidate = match candidate { |
47 | ImportCandidate::Path(candidate) => { | 47 | ImportCandidate::Path(candidate) => { |
48 | if candidate.qualifier.is_some() { | 48 | if candidate.unresolved_qualifier.is_some() { |
49 | cov_mark::hit!(qualify_path_qualifier_start); | 49 | cov_mark::hit!(qualify_path_qualifier_start); |
50 | let path = ast::Path::cast(syntax_under_caret)?; | 50 | let path = ast::Path::cast(syntax_under_caret)?; |
51 | let (prev_segment, segment) = (path.qualifier()?.segment()?, path.segment()?); | 51 | let (prev_segment, segment) = (path.qualifier()?.segment()?, path.segment()?); |
@@ -192,7 +192,7 @@ fn group_label(candidate: &ImportCandidate) -> GroupLabel { | |||
192 | fn label(candidate: &ImportCandidate, import: &hir::ModPath) -> String { | 192 | fn label(candidate: &ImportCandidate, import: &hir::ModPath) -> String { |
193 | match candidate { | 193 | match candidate { |
194 | ImportCandidate::Path(candidate) => { | 194 | ImportCandidate::Path(candidate) => { |
195 | if candidate.qualifier.is_some() { | 195 | if candidate.unresolved_qualifier.is_some() { |
196 | format!("Qualify with `{}`", &import) | 196 | format!("Qualify with `{}`", &import) |
197 | } else { | 197 | } else { |
198 | format!("Qualify as `{}`", &import) | 198 | format!("Qualify as `{}`", &import) |