aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-08-11 11:22:57 +0100
committerGitHub <[email protected]>2020-08-11 11:22:57 +0100
commitef20dfc78d2092f8b99db6716dde1928b15133a0 (patch)
treebcbead004c66dd50ee8b8a1628097a58872168bc /crates/ra_assists
parent61ee051455fdfd64ceca21960c5480be3b97fbf0 (diff)
parent6ef019bd4601b9dc36325e096d066a4ddbda1bdf (diff)
Merge #5707
5707: Address some FIXMEs for ra_assists r=jonas-schievink a=JmPotato Signed-off-by: JmPotato <[email protected]> Co-authored-by: JmPotato <[email protected]>
Diffstat (limited to 'crates/ra_assists')
-rw-r--r--crates/ra_assists/src/ast_transform.rs2
-rw-r--r--crates/ra_assists/src/lib.rs25
-rw-r--r--crates/ra_assists/src/tests.rs2
3 files changed, 22 insertions, 7 deletions
diff --git a/crates/ra_assists/src/ast_transform.rs b/crates/ra_assists/src/ast_transform.rs
index 15ec75c95..07c978378 100644
--- a/crates/ra_assists/src/ast_transform.rs
+++ b/crates/ra_assists/src/ast_transform.rs
@@ -51,7 +51,7 @@ impl<'a> SubstituteTypeParams<'a> {
51 // this is a trait impl, so we need to skip the first type parameter -- this is a bit hacky 51 // this is a trait impl, so we need to skip the first type parameter -- this is a bit hacky
52 .skip(1) 52 .skip(1)
53 // The actual list of trait type parameters may be longer than the one 53 // The actual list of trait type parameters may be longer than the one
54 // used in the `impl` block due to trailing default type parametrs. 54 // used in the `impl` block due to trailing default type parameters.
55 // For that case we extend the `substs` with an empty iterator so we 55 // For that case we extend the `substs` with an empty iterator so we
56 // can still hit those trailing values and check if they actually have 56 // can still hit those trailing values and check if they actually have
57 // a default type. If they do, go for that type from `hir` to `ast` so 57 // a default type. If they do, go for that type from `hir` to `ast` so
diff --git a/crates/ra_assists/src/lib.rs b/crates/ra_assists/src/lib.rs
index 507646cc8..890996a68 100644
--- a/crates/ra_assists/src/lib.rs
+++ b/crates/ra_assists/src/lib.rs
@@ -66,13 +66,13 @@ pub struct GroupLabel(pub String);
66 66
67#[derive(Debug, Clone)] 67#[derive(Debug, Clone)]
68pub struct Assist { 68pub struct Assist {
69 pub id: AssistId, 69 id: AssistId,
70 /// Short description of the assist, as shown in the UI. 70 /// Short description of the assist, as shown in the UI.
71 pub label: String, 71 label: String,
72 pub group: Option<GroupLabel>, 72 group: Option<GroupLabel>,
73 /// Target ranges are used to sort assists: the smaller the target range, 73 /// Target ranges are used to sort assists: the smaller the target range,
74 /// the more specific assist is, and so it should be sorted first. 74 /// the more specific assist is, and so it should be sorted first.
75 pub target: TextRange, 75 target: TextRange,
76} 76}
77 77
78#[derive(Debug, Clone)] 78#[derive(Debug, Clone)]
@@ -120,10 +120,25 @@ impl Assist {
120 group: Option<GroupLabel>, 120 group: Option<GroupLabel>,
121 target: TextRange, 121 target: TextRange,
122 ) -> Assist { 122 ) -> Assist {
123 // FIXME: make fields private, so that this invariant can't be broken
124 assert!(label.starts_with(|c: char| c.is_uppercase())); 123 assert!(label.starts_with(|c: char| c.is_uppercase()));
125 Assist { id, label, group, target } 124 Assist { id, label, group, target }
126 } 125 }
126
127 pub fn id(&self) -> AssistId {
128 self.id
129 }
130
131 pub fn label(&self) -> String {
132 self.label.clone()
133 }
134
135 pub fn group(&self) -> Option<GroupLabel> {
136 self.group.clone()
137 }
138
139 pub fn target(&self) -> TextRange {
140 self.target
141 }
127} 142}
128 143
129mod handlers { 144mod handlers {
diff --git a/crates/ra_assists/src/tests.rs b/crates/ra_assists/src/tests.rs
index 18fcb9049..e73836422 100644
--- a/crates/ra_assists/src/tests.rs
+++ b/crates/ra_assists/src/tests.rs
@@ -20,7 +20,7 @@ pub(crate) fn check_assist(assist: Handler, ra_fixture_before: &str, ra_fixture_
20 20
21// FIXME: instead of having a separate function here, maybe use 21// FIXME: instead of having a separate function here, maybe use
22// `extract_ranges` and mark the target as `<target> </target>` in the 22// `extract_ranges` and mark the target as `<target> </target>` in the
23// fixuture? 23// fixture?
24pub(crate) fn check_assist_target(assist: Handler, ra_fixture: &str, target: &str) { 24pub(crate) fn check_assist_target(assist: Handler, ra_fixture: &str, target: &str) {
25 check(assist, ra_fixture, ExpectedResult::Target(target)); 25 check(assist, ra_fixture, ExpectedResult::Target(target));
26} 26}