aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_assists')
-rw-r--r--crates/ra_assists/src/doc_tests.rs6
-rw-r--r--crates/ra_assists/src/lib.rs10
2 files changed, 9 insertions, 7 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;
8use ra_db::FileRange; 8use ra_db::FileRange;
9use test_utils::{assert_eq_text, extract_range_or_offset}; 9use test_utils::{assert_eq_text, extract_range_or_offset};
10 10
11use crate::resolved_assists;
12
11fn check(assist_id: &str, before: &str, after: &str) { 13fn 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.
62pub fn applicable_assists(db: &RootDatabase, range: FileRange) -> Vec<AssistLabel> { 62pub 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.
79pub fn assists(db: &RootDatabase, range: FileRange) -> Vec<ResolvedAssist> { 79pub 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");