1 use serde::{Deserialize, Serialize}; 2 3 use crate::{ 4 Documentation, MarkupKind, TextDocumentPositionParams, TextDocumentRegistrationOptions, 5 WorkDoneProgressOptions, WorkDoneProgressParams, 6 }; 7 8 #[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)] 9 #[serde(rename_all = "camelCase")] 10 pub struct SignatureInformationSettings { 11 /// Client supports the follow content formats for the documentation 12 /// property. The order describes the preferred format of the client. 13 #[serde(skip_serializing_if = "Option::is_none")] 14 pub documentation_format: Option<Vec<MarkupKind>>, 15 16 #[serde(skip_serializing_if = "Option::is_none")] 17 pub parameter_information: Option<ParameterInformationSettings>, 18 19 /// The client support the `activeParameter` property on `SignatureInformation` 20 /// literal. 21 /// 22 /// @since 3.16.0 23 #[serde(skip_serializing_if = "Option::is_none")] 24 pub active_parameter_support: Option<bool>, 25 } 26 27 #[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)] 28 #[serde(rename_all = "camelCase")] 29 pub struct ParameterInformationSettings { 30 /// The client supports processing label offsets instead of a 31 /// simple label string. 32 /// 33 /// @since 3.14.0 34 #[serde(skip_serializing_if = "Option::is_none")] 35 pub label_offset_support: Option<bool>, 36 } 37 38 #[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)] 39 #[serde(rename_all = "camelCase")] 40 pub struct SignatureHelpClientCapabilities { 41 /// Whether completion supports dynamic registration. 42 #[serde(skip_serializing_if = "Option::is_none")] 43 pub dynamic_registration: Option<bool>, 44 45 /// The client supports the following `SignatureInformation` 46 /// specific properties. 47 #[serde(skip_serializing_if = "Option::is_none")] 48 pub signature_information: Option<SignatureInformationSettings>, 49 50 /// The client supports to send additional context information for a 51 /// `textDocument/signatureHelp` request. A client that opts into 52 /// contextSupport will also support the `retriggerCharacters` on 53 /// `SignatureHelpOptions`. 54 /// 55 /// @since 3.15.0 56 #[serde(skip_serializing_if = "Option::is_none")] 57 pub context_support: Option<bool>, 58 } 59 60 /// Signature help options. 61 #[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)] 62 #[serde(rename_all = "camelCase")] 63 pub struct SignatureHelpOptions { 64 /// The characters that trigger signature help automatically. 65 #[serde(skip_serializing_if = "Option::is_none")] 66 pub trigger_characters: Option<Vec<String>>, 67 68 /// List of characters that re-trigger signature help. 69 /// These trigger characters are only active when signature help is already showing. All trigger characters 70 /// are also counted as re-trigger characters. 71 #[serde(skip_serializing_if = "Option::is_none")] 72 pub retrigger_characters: Option<Vec<String>>, 73 74 #[serde(flatten)] 75 pub work_done_progress_options: WorkDoneProgressOptions, 76 } 77 78 /// Signature help options. 79 #[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)] 80 pub struct SignatureHelpRegistrationOptions { 81 #[serde(flatten)] 82 pub text_document_registration_options: TextDocumentRegistrationOptions, 83 } 84 85 /// Signature help options. 86 #[derive(Eq, PartialEq, Clone, Deserialize, Serialize)] 87 #[serde(transparent)] 88 pub struct SignatureHelpTriggerKind(i32); 89 lsp_enum! { 90 impl SignatureHelpTriggerKind { 91 /// Signature help was invoked manually by the user or by a command. 92 pub const INVOKED: SignatureHelpTriggerKind = SignatureHelpTriggerKind(1); 93 /// Signature help was triggered by a trigger character. 94 pub const TRIGGER_CHARACTER: SignatureHelpTriggerKind = SignatureHelpTriggerKind(2); 95 /// Signature help was triggered by the cursor moving or by the document content changing. 96 pub const CONTENT_CHANGE: SignatureHelpTriggerKind = SignatureHelpTriggerKind(3); 97 } 98 } 99 100 #[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)] 101 #[serde(rename_all = "camelCase")] 102 pub struct SignatureHelpParams { 103 /// The signature help context. This is only available if the client specifies 104 /// to send this using the client capability `textDocument.signatureHelp.contextSupport === true` 105 #[serde(skip_serializing_if = "Option::is_none")] 106 pub context: Option<SignatureHelpContext>, 107 108 #[serde(flatten)] 109 pub text_document_position_params: TextDocumentPositionParams, 110 111 #[serde(flatten)] 112 pub work_done_progress_params: WorkDoneProgressParams, 113 } 114 115 #[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)] 116 #[serde(rename_all = "camelCase")] 117 pub struct SignatureHelpContext { 118 /// Action that caused signature help to be triggered. 119 pub trigger_kind: SignatureHelpTriggerKind, 120 121 /// Character that caused signature help to be triggered. 122 /// This is undefined when `triggerKind !== SignatureHelpTriggerKind.TriggerCharacter` 123 #[serde(skip_serializing_if = "Option::is_none")] 124 pub trigger_character: Option<String>, 125 126 /// `true` if signature help was already showing when it was triggered. 127 /// Retriggers occur when the signature help is already active and can be caused by actions such as 128 /// typing a trigger character, a cursor move, or document content changes. 129 pub is_retrigger: bool, 130 131 /// The currently active `SignatureHelp`. 132 /// The `activeSignatureHelp` has its `SignatureHelp.activeSignature` field updated based on 133 /// the user navigating through available signatures. 134 #[serde(skip_serializing_if = "Option::is_none")] 135 pub active_signature_help: Option<SignatureHelp>, 136 } 137 138 /// Signature help represents the signature of something 139 /// callable. There can be multiple signature but only one 140 /// active and only one active parameter. 141 #[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)] 142 #[serde(rename_all = "camelCase")] 143 pub struct SignatureHelp { 144 /// One or more signatures. 145 pub signatures: Vec<SignatureInformation>, 146 147 /// The active signature. 148 #[serde(skip_serializing_if = "Option::is_none")] 149 pub active_signature: Option<u32>, 150 151 /// The active parameter of the active signature. 152 #[serde(skip_serializing_if = "Option::is_none")] 153 pub active_parameter: Option<u32>, 154 } 155 156 /// Represents the signature of something callable. A signature 157 /// can have a label, like a function-name, a doc-comment, and 158 /// a set of parameters. 159 #[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)] 160 #[serde(rename_all = "camelCase")] 161 pub struct SignatureInformation { 162 /// The label of this signature. Will be shown in 163 /// the UI. 164 pub label: String, 165 166 /// The human-readable doc-comment of this signature. Will be shown 167 /// in the UI but can be omitted. 168 #[serde(skip_serializing_if = "Option::is_none")] 169 pub documentation: Option<Documentation>, 170 171 /// The parameters of this signature. 172 #[serde(skip_serializing_if = "Option::is_none")] 173 pub parameters: Option<Vec<ParameterInformation>>, 174 175 /// The index of the active parameter. 176 /// 177 /// If provided, this is used in place of `SignatureHelp.activeParameter`. 178 /// 179 /// @since 3.16.0 180 #[serde(skip_serializing_if = "Option::is_none")] 181 pub active_parameter: Option<u32>, 182 } 183 184 /// Represents a parameter of a callable-signature. A parameter can 185 /// have a label and a doc-comment. 186 #[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)] 187 #[serde(rename_all = "camelCase")] 188 pub struct ParameterInformation { 189 /// The label of this parameter information. 190 /// 191 /// Either a string or an inclusive start and exclusive end offsets within its containing 192 /// signature label. (see SignatureInformation.label). *Note*: A label of type string must be 193 /// a substring of its containing signature label. 194 pub label: ParameterLabel, 195 196 /// The human-readable doc-comment of this parameter. Will be shown 197 /// in the UI but can be omitted. 198 #[serde(skip_serializing_if = "Option::is_none")] 199 pub documentation: Option<Documentation>, 200 } 201 202 #[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)] 203 #[serde(untagged)] 204 pub enum ParameterLabel { 205 Simple(String), 206 LabelOffsets([u32; 2]), 207 } 208