diff options
author | Aleksey Kladov <[email protected]> | 2020-02-06 17:46:11 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-02-06 17:47:26 +0000 |
commit | 7e73b7a5f8d594a85627786a13e76d9d70163770 (patch) | |
tree | ac72b45b25756f1ef95a552053a88285d2f2b4f5 /crates | |
parent | 918115c32e9a3882d1dd65f2403bd109fc64c798 (diff) |
Minor rename
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_assists/src/doc_tests.rs | 6 | ||||
-rw-r--r-- | crates/ra_assists/src/lib.rs | 10 | ||||
-rw-r--r-- | crates/ra_ide/src/assists.rs | 4 |
3 files changed, 11 insertions, 9 deletions
diff --git a/crates/ra_assists/src/doc_tests.rs b/crates/ra_assists/src/doc_tests.rs index 56020028c..ae0e5605c 100644 --- a/crates/ra_assists/src/doc_tests.rs +++ b/crates/ra_assists/src/doc_tests.rs | |||
@@ -8,19 +8,21 @@ mod generated; | |||
8 | use ra_db::FileRange; | 8 | use ra_db::FileRange; |
9 | use test_utils::{assert_eq_text, extract_range_or_offset}; | 9 | use test_utils::{assert_eq_text, extract_range_or_offset}; |
10 | 10 | ||
11 | use crate::resolved_assists; | ||
12 | |||
11 | fn check(assist_id: &str, before: &str, after: &str) { | 13 | fn check(assist_id: &str, before: &str, after: &str) { |
12 | let (selection, before) = extract_range_or_offset(before); | 14 | let (selection, before) = extract_range_or_offset(before); |
13 | let (db, file_id) = crate::helpers::with_single_file(&before); | 15 | let (db, file_id) = crate::helpers::with_single_file(&before); |
14 | let frange = FileRange { file_id, range: selection.into() }; | 16 | let frange = FileRange { file_id, range: selection.into() }; |
15 | 17 | ||
16 | let assist = crate::assists(&db, frange) | 18 | let assist = resolved_assists(&db, frange) |
17 | .into_iter() | 19 | .into_iter() |
18 | .find(|assist| assist.label.id.0 == assist_id) | 20 | .find(|assist| assist.label.id.0 == assist_id) |
19 | .unwrap_or_else(|| { | 21 | .unwrap_or_else(|| { |
20 | panic!( | 22 | panic!( |
21 | "\n\nAssist is not applicable: {}\nAvailable assists: {}", | 23 | "\n\nAssist is not applicable: {}\nAvailable assists: {}", |
22 | assist_id, | 24 | assist_id, |
23 | crate::assists(&db, frange) | 25 | resolved_assists(&db, frange) |
24 | .into_iter() | 26 | .into_iter() |
25 | .map(|assist| assist.label.id.0) | 27 | .map(|assist| assist.label.id.0) |
26 | .collect::<Vec<_>>() | 28 | .collect::<Vec<_>>() |
diff --git a/crates/ra_assists/src/lib.rs b/crates/ra_assists/src/lib.rs index 1343043dd..3f3df3f96 100644 --- a/crates/ra_assists/src/lib.rs +++ b/crates/ra_assists/src/lib.rs | |||
@@ -59,7 +59,7 @@ impl ResolvedAssist { | |||
59 | /// | 59 | /// |
60 | /// Assists are returned in the "unresolved" state, that is only labels are | 60 | /// Assists are returned in the "unresolved" state, that is only labels are |
61 | /// returned, without actual edits. | 61 | /// returned, without actual edits. |
62 | pub fn applicable_assists(db: &RootDatabase, range: FileRange) -> Vec<AssistLabel> { | 62 | pub fn unresolved_assists(db: &RootDatabase, range: FileRange) -> Vec<AssistLabel> { |
63 | AssistCtx::with_ctx(db, range, false, |ctx| { | 63 | AssistCtx::with_ctx(db, range, false, |ctx| { |
64 | assists::all() | 64 | assists::all() |
65 | .iter() | 65 | .iter() |
@@ -76,7 +76,7 @@ pub fn applicable_assists(db: &RootDatabase, range: FileRange) -> Vec<AssistLabe | |||
76 | /// | 76 | /// |
77 | /// Assists are returned in the "resolved" state, that is with edit fully | 77 | /// Assists are returned in the "resolved" state, that is with edit fully |
78 | /// computed. | 78 | /// computed. |
79 | pub fn assists(db: &RootDatabase, range: FileRange) -> Vec<ResolvedAssist> { | 79 | pub fn resolved_assists(db: &RootDatabase, range: FileRange) -> Vec<ResolvedAssist> { |
80 | AssistCtx::with_ctx(db, range, true, |ctx| { | 80 | AssistCtx::with_ctx(db, range, true, |ctx| { |
81 | let mut a = assists::all() | 81 | let mut a = assists::all() |
82 | .iter() | 82 | .iter() |
@@ -301,7 +301,7 @@ mod tests { | |||
301 | use ra_syntax::TextRange; | 301 | use ra_syntax::TextRange; |
302 | use test_utils::{extract_offset, extract_range}; | 302 | use test_utils::{extract_offset, extract_range}; |
303 | 303 | ||
304 | use crate::helpers; | 304 | use crate::{helpers, resolved_assists}; |
305 | 305 | ||
306 | #[test] | 306 | #[test] |
307 | fn assist_order_field_struct() { | 307 | fn assist_order_field_struct() { |
@@ -310,7 +310,7 @@ mod tests { | |||
310 | let (db, file_id) = helpers::with_single_file(&before); | 310 | let (db, file_id) = helpers::with_single_file(&before); |
311 | let frange = | 311 | let frange = |
312 | FileRange { file_id, range: TextRange::offset_len(before_cursor_pos, 0.into()) }; | 312 | FileRange { file_id, range: TextRange::offset_len(before_cursor_pos, 0.into()) }; |
313 | let assists = super::assists(&db, frange); | 313 | let assists = resolved_assists(&db, frange); |
314 | let mut assists = assists.iter(); | 314 | let mut assists = assists.iter(); |
315 | 315 | ||
316 | assert_eq!( | 316 | assert_eq!( |
@@ -333,7 +333,7 @@ mod tests { | |||
333 | let (range, before) = extract_range(before); | 333 | let (range, before) = extract_range(before); |
334 | let (db, file_id) = helpers::with_single_file(&before); | 334 | let (db, file_id) = helpers::with_single_file(&before); |
335 | let frange = FileRange { file_id, range }; | 335 | let frange = FileRange { file_id, range }; |
336 | let assists = super::assists(&db, frange); | 336 | let assists = resolved_assists(&db, frange); |
337 | let mut assists = assists.iter(); | 337 | let mut assists = assists.iter(); |
338 | 338 | ||
339 | assert_eq!(assists.next().expect("expected assist").label.label, "Extract into variable"); | 339 | assert_eq!(assists.next().expect("expected assist").label.label, "Extract into variable"); |
diff --git a/crates/ra_ide/src/assists.rs b/crates/ra_ide/src/assists.rs index c3b2c638b..b60b1a60d 100644 --- a/crates/ra_ide/src/assists.rs +++ b/crates/ra_ide/src/assists.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! FIXME: write short doc here |
2 | 2 | ||
3 | use either::Either; | 3 | use either::Either; |
4 | use ra_assists::{AssistAction, AssistLabel}; | 4 | use ra_assists::{resolved_assists, AssistAction, AssistLabel}; |
5 | use ra_db::{FilePosition, FileRange}; | 5 | use ra_db::{FilePosition, FileRange}; |
6 | use ra_ide_db::RootDatabase; | 6 | use ra_ide_db::RootDatabase; |
7 | 7 | ||
@@ -17,7 +17,7 @@ pub struct Assist { | |||
17 | } | 17 | } |
18 | 18 | ||
19 | pub(crate) fn assists(db: &RootDatabase, frange: FileRange) -> Vec<Assist> { | 19 | pub(crate) fn assists(db: &RootDatabase, frange: FileRange) -> Vec<Assist> { |
20 | ra_assists::assists(db, frange) | 20 | resolved_assists(db, frange) |
21 | .into_iter() | 21 | .into_iter() |
22 | .map(|assist| { | 22 | .map(|assist| { |
23 | let file_id = frange.file_id; | 23 | let file_id = frange.file_id; |