diff options
Diffstat (limited to 'crates/ide_assists/src/lib.rs')
-rw-r--r-- | crates/ide_assists/src/lib.rs | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/crates/ide_assists/src/lib.rs b/crates/ide_assists/src/lib.rs index 88ae5c9a9..397d2a3d0 100644 --- a/crates/ide_assists/src/lib.rs +++ b/crates/ide_assists/src/lib.rs | |||
@@ -26,7 +26,7 @@ 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)] | 29 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
30 | pub enum AssistKind { | 30 | pub enum AssistKind { |
31 | // FIXME: does the None variant make sense? Probably not. | 31 | // FIXME: does the None variant make sense? Probably not. |
32 | None, | 32 | None, |
@@ -60,9 +60,27 @@ impl AssistKind { | |||
60 | 60 | ||
61 | /// Unique identifier of the assist, should not be shown to the user | 61 | /// Unique identifier of the assist, should not be shown to the user |
62 | /// directly. | 62 | /// directly. |
63 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] | 63 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
64 | pub struct AssistId(pub &'static str, pub AssistKind); | 64 | pub struct AssistId(pub &'static str, pub AssistKind); |
65 | 65 | ||
66 | // TODO kb docs | ||
67 | #[derive(Debug, Clone, Copy)] | ||
68 | pub enum AssistResolveStrategy { | ||
69 | None, | ||
70 | All, | ||
71 | Single(AssistId), | ||
72 | } | ||
73 | |||
74 | impl AssistResolveStrategy { | ||
75 | pub fn should_resolve(&self, id: &AssistId) -> bool { | ||
76 | match self { | ||
77 | AssistResolveStrategy::None => false, | ||
78 | AssistResolveStrategy::All => true, | ||
79 | AssistResolveStrategy::Single(id_to_resolve) => id_to_resolve == id, | ||
80 | } | ||
81 | } | ||
82 | } | ||
83 | |||
66 | #[derive(Clone, Debug)] | 84 | #[derive(Clone, Debug)] |
67 | pub struct GroupLabel(pub String); | 85 | pub struct GroupLabel(pub String); |
68 | 86 | ||
@@ -91,7 +109,7 @@ impl Assist { | |||
91 | pub fn get( | 109 | pub fn get( |
92 | db: &RootDatabase, | 110 | db: &RootDatabase, |
93 | config: &AssistConfig, | 111 | config: &AssistConfig, |
94 | resolve: bool, | 112 | resolve: AssistResolveStrategy, |
95 | range: FileRange, | 113 | range: FileRange, |
96 | ) -> Vec<Assist> { | 114 | ) -> Vec<Assist> { |
97 | let sema = Semantics::new(db); | 115 | let sema = Semantics::new(db); |