aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_assists/src
diff options
context:
space:
mode:
authorKirill Bulatov <[email protected]>2021-05-03 16:16:35 +0100
committerKirill Bulatov <[email protected]>2021-05-03 16:16:35 +0100
commit28293d370ffc4270bb6244579166f0df18962951 (patch)
treefe1261ad5d053b5f1a60b98456c2f3ecca7452e3 /crates/ide_assists/src
parent1679a376f30c5ad8971c0f855074a3f489fee5fa (diff)
Add docs and use better naming
Diffstat (limited to 'crates/ide_assists/src')
-rw-r--r--crates/ide_assists/src/lib.rs25
1 files changed, 20 insertions, 5 deletions
diff --git a/crates/ide_assists/src/lib.rs b/crates/ide_assists/src/lib.rs
index 01addffe9..5a0047f03 100644
--- a/crates/ide_assists/src/lib.rs
+++ b/crates/ide_assists/src/lib.rs
@@ -94,12 +94,27 @@ impl FromStr for AssistKind {
94#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 94#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
95pub struct AssistId(pub &'static str, pub AssistKind); 95pub struct AssistId(pub &'static str, pub AssistKind);
96 96
97// TODO kb docs 97/// A way to control how many asssist to resolve during the assist resolution.
98#[derive(Debug, Clone)] 98/// When an assist is resolved, its edits are calculated that might be costly to always do by default.
99#[derive(Debug)]
99pub enum AssistResolveStrategy { 100pub enum AssistResolveStrategy {
101 /// No assists should be resolved.
100 None, 102 None,
103 /// All assists should be resolved.
101 All, 104 All,
102 Single(String, AssistKind), 105 /// Only a certain assists should be resolved.
106 Single(SingleResolve),
107}
108
109/// Hold the [`AssistId`] data of a certain assist to resolve.
110/// The original id object cannot be used due to a `'static` lifetime
111/// and the requirement to construct this struct dynamically during the resolve handling.
112#[derive(Debug)]
113pub struct SingleResolve {
114 /// The id of the assist.
115 pub assist_id: String,
116 // The kind of the assist.
117 pub assist_kind: AssistKind,
103} 118}
104 119
105impl AssistResolveStrategy { 120impl AssistResolveStrategy {
@@ -107,8 +122,8 @@ impl AssistResolveStrategy {
107 match self { 122 match self {
108 AssistResolveStrategy::None => false, 123 AssistResolveStrategy::None => false,
109 AssistResolveStrategy::All => true, 124 AssistResolveStrategy::All => true,
110 AssistResolveStrategy::Single(id_to_resolve, kind) => { 125 AssistResolveStrategy::Single(single_resolve) => {
111 id_to_resolve == id.0 && kind == &id.1 126 single_resolve.assist_id == id.0 && single_resolve.assist_kind == id.1
112 } 127 }
113 } 128 }
114 } 129 }