ls_types/
rename.rs

1use crate::{
2    Range, TextDocumentPositionParams, WorkDoneProgressOptions, WorkDoneProgressParams,
3    macros::lsp_enum,
4};
5use serde::{Deserialize, Serialize};
6
7#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
8#[serde(rename_all = "camelCase")]
9pub struct RenameParams {
10    /// Text Document and Position fields
11    #[serde(flatten)]
12    pub text_document_position: TextDocumentPositionParams,
13
14    /// The new name of the symbol. If the given name is not valid the
15    /// request must return a [`ResponseError`](#ResponseError) with an
16    /// appropriate message set.
17    pub new_name: String,
18
19    #[serde(flatten)]
20    pub work_done_progress_params: WorkDoneProgressParams,
21}
22
23#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
24#[serde(rename_all = "camelCase")]
25pub struct RenameOptions {
26    /// Renames should be checked and tested before being executed.
27    #[serde(skip_serializing_if = "Option::is_none")]
28    pub prepare_provider: Option<bool>,
29
30    #[serde(flatten)]
31    pub work_done_progress_options: WorkDoneProgressOptions,
32}
33
34#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
35#[serde(rename_all = "camelCase")]
36pub struct RenameClientCapabilities {
37    /// Whether rename supports dynamic registration.
38    #[serde(skip_serializing_if = "Option::is_none")]
39    pub dynamic_registration: Option<bool>,
40
41    /// Client supports testing for validity of rename operations before execution.
42    ///
43    /// @since 3.12.0
44    #[serde(skip_serializing_if = "Option::is_none")]
45    pub prepare_support: Option<bool>,
46
47    /// Client supports the default behavior result.
48    ///
49    /// The value indicates the default behavior used by the
50    /// client.
51    ///
52    /// @since 3.16.0
53    #[serde(skip_serializing_if = "Option::is_none")]
54    pub prepare_support_default_behavior: Option<PrepareSupportDefaultBehavior>,
55
56    /// Whether the client honors the change annotations in
57    /// text edits and resource operations returned via the
58    /// rename request's workspace edit by for example presenting
59    /// the workspace edit in the user interface and asking
60    /// for confirmation.
61    ///
62    /// @since 3.16.0
63    #[serde(skip_serializing_if = "Option::is_none")]
64    pub honors_change_annotations: Option<bool>,
65}
66
67#[derive(Clone, Copy, PartialEq, Eq, Deserialize, Serialize)]
68#[serde(transparent)]
69pub struct PrepareSupportDefaultBehavior(i32);
70
71lsp_enum! {
72    impl PrepareSupportDefaultBehavior {
73        /// The client's default behavior is to select the identifier
74        /// according the to language's syntax rule
75        const IDENTIFIER = 1;
76    }
77}
78
79#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
80#[serde(untagged)]
81#[serde(rename_all = "camelCase")]
82pub enum PrepareRenameResponse {
83    Range(Range),
84    RangeWithPlaceholder {
85        range: Range,
86        placeholder: String,
87    },
88    #[serde(rename_all = "camelCase")]
89    DefaultBehavior {
90        default_behavior: bool,
91    },
92}