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