diff options
author | kjeremy <[email protected]> | 2020-07-02 22:48:35 +0100 |
---|---|---|
committer | kjeremy <[email protected]> | 2020-07-02 22:48:35 +0100 |
commit | 36cc81ac71e4246bf58a3758735cc68f7adb5e0f (patch) | |
tree | 9d14ddf58d873049fa5efc79dbdb83ed165aec8b /crates/ra_assists/src/lib.rs | |
parent | 1d58e168246e1ca64f3ce3936e90077922b82d05 (diff) |
Move AssistKind into AssistId
Diffstat (limited to 'crates/ra_assists/src/lib.rs')
-rw-r--r-- | crates/ra_assists/src/lib.rs | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/crates/ra_assists/src/lib.rs b/crates/ra_assists/src/lib.rs index dd26e192f..201213c73 100644 --- a/crates/ra_assists/src/lib.rs +++ b/crates/ra_assists/src/lib.rs | |||
@@ -26,10 +26,22 @@ pub(crate) use crate::assist_context::{AssistContext, Assists}; | |||
26 | 26 | ||
27 | pub use assist_config::AssistConfig; | 27 | pub use assist_config::AssistConfig; |
28 | 28 | ||
29 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] | ||
30 | pub enum AssistKind { | ||
31 | None, | ||
32 | QuickFix, | ||
33 | Refactor, | ||
34 | RefactorExtract, | ||
35 | RefactorInline, | ||
36 | RefactorRewrite, | ||
37 | Source, | ||
38 | OrganizeImports, | ||
39 | } | ||
40 | |||
29 | /// Unique identifier of the assist, should not be shown to the user | 41 | /// Unique identifier of the assist, should not be shown to the user |
30 | /// directly. | 42 | /// directly. |
31 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] | 43 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] |
32 | pub struct AssistId(pub &'static str); | 44 | pub struct AssistId(pub &'static str, pub AssistKind); |
33 | 45 | ||
34 | #[derive(Clone, Debug)] | 46 | #[derive(Clone, Debug)] |
35 | pub struct GroupLabel(pub String); | 47 | pub struct GroupLabel(pub String); |
@@ -37,7 +49,6 @@ pub struct GroupLabel(pub String); | |||
37 | #[derive(Debug, Clone)] | 49 | #[derive(Debug, Clone)] |
38 | pub struct Assist { | 50 | pub struct Assist { |
39 | pub id: AssistId, | 51 | pub id: AssistId, |
40 | pub kind: AssistKind, | ||
41 | /// Short description of the assist, as shown in the UI. | 52 | /// Short description of the assist, as shown in the UI. |
42 | pub label: String, | 53 | pub label: String, |
43 | pub group: Option<GroupLabel>, | 54 | pub group: Option<GroupLabel>, |
@@ -52,18 +63,6 @@ pub struct ResolvedAssist { | |||
52 | pub source_change: SourceChange, | 63 | pub source_change: SourceChange, |
53 | } | 64 | } |
54 | 65 | ||
55 | #[derive(Debug, Copy, Clone)] | ||
56 | pub enum AssistKind { | ||
57 | None, | ||
58 | QuickFix, | ||
59 | Refactor, | ||
60 | RefactorExtract, | ||
61 | RefactorInline, | ||
62 | RefactorRewrite, | ||
63 | Source, | ||
64 | OrganizeImports, | ||
65 | } | ||
66 | |||
67 | impl Assist { | 66 | impl Assist { |
68 | /// Return all the assists applicable at the given position. | 67 | /// Return all the assists applicable at the given position. |
69 | /// | 68 | /// |
@@ -99,14 +98,13 @@ impl Assist { | |||
99 | 98 | ||
100 | pub(crate) fn new( | 99 | pub(crate) fn new( |
101 | id: AssistId, | 100 | id: AssistId, |
102 | kind: AssistKind, | ||
103 | label: String, | 101 | label: String, |
104 | group: Option<GroupLabel>, | 102 | group: Option<GroupLabel>, |
105 | target: TextRange, | 103 | target: TextRange, |
106 | ) -> Assist { | 104 | ) -> Assist { |
107 | // FIXME: make fields private, so that this invariant can't be broken | 105 | // FIXME: make fields private, so that this invariant can't be broken |
108 | assert!(label.starts_with(|c: char| c.is_uppercase())); | 106 | assert!(label.starts_with(|c: char| c.is_uppercase())); |
109 | Assist { id, kind, label, group, target } | 107 | Assist { id, label, group, target } |
110 | } | 108 | } |
111 | } | 109 | } |
112 | 110 | ||