1 | use serde::{Deserialize, Serialize}; |
2 | use serde_json::Value; |
3 | use url::Url; |
4 | |
5 | use crate::{ |
6 | DynamicRegistrationClientCapabilities, PartialResultParams, Range, SymbolKind, SymbolTag, |
7 | TextDocumentPositionParams, WorkDoneProgressOptions, WorkDoneProgressParams, |
8 | }; |
9 | |
10 | pub type CallHierarchyClientCapabilities = DynamicRegistrationClientCapabilities; |
11 | |
12 | #[derive (Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize, Copy)] |
13 | #[serde(rename_all = "camelCase" )] |
14 | pub struct CallHierarchyOptions { |
15 | #[serde(flatten)] |
16 | pub work_done_progress_options: WorkDoneProgressOptions, |
17 | } |
18 | |
19 | #[derive (Debug, Eq, PartialEq, Clone, Deserialize, Serialize, Copy)] |
20 | #[serde(untagged)] |
21 | pub enum CallHierarchyServerCapability { |
22 | Simple(bool), |
23 | Options(CallHierarchyOptions), |
24 | } |
25 | |
26 | impl From<CallHierarchyOptions> for CallHierarchyServerCapability { |
27 | fn from(from: CallHierarchyOptions) -> Self { |
28 | Self::Options(from) |
29 | } |
30 | } |
31 | |
32 | impl From<bool> for CallHierarchyServerCapability { |
33 | fn from(from: bool) -> Self { |
34 | Self::Simple(from) |
35 | } |
36 | } |
37 | |
38 | #[derive (Debug, Eq, PartialEq, Clone, Deserialize, Serialize)] |
39 | #[serde(rename_all = "camelCase" )] |
40 | pub struct CallHierarchyPrepareParams { |
41 | #[serde(flatten)] |
42 | pub text_document_position_params: TextDocumentPositionParams, |
43 | |
44 | #[serde(flatten)] |
45 | pub work_done_progress_params: WorkDoneProgressParams, |
46 | } |
47 | |
48 | #[derive (Serialize, Deserialize, Debug, PartialEq, Clone)] |
49 | #[serde(rename_all = "camelCase" )] |
50 | pub struct CallHierarchyItem { |
51 | /// The name of this item. |
52 | pub name: String, |
53 | |
54 | /// The kind of this item. |
55 | pub kind: SymbolKind, |
56 | |
57 | /// Tags for this item. |
58 | #[serde(skip_serializing_if = "Option::is_none" )] |
59 | pub tags: Option<Vec<SymbolTag>>, |
60 | |
61 | /// More detail for this item, e.g. the signature of a function. |
62 | #[serde(skip_serializing_if = "Option::is_none" )] |
63 | pub detail: Option<String>, |
64 | |
65 | /// The resource identifier of this item. |
66 | pub uri: Url, |
67 | |
68 | /// The range enclosing this symbol not including leading/trailing whitespace but everything else, e.g. comments and code. |
69 | pub range: Range, |
70 | |
71 | /// The range that should be selected and revealed when this symbol is being picked, e.g. the name of a function. |
72 | /// Must be contained by the [`range`](#CallHierarchyItem.range). |
73 | pub selection_range: Range, |
74 | |
75 | /// A data entry field that is preserved between a call hierarchy prepare and incoming calls or outgoing calls requests. |
76 | #[serde(skip_serializing_if = "Option::is_none" )] |
77 | pub data: Option<Value>, |
78 | } |
79 | |
80 | #[derive (Debug, PartialEq, Clone, Deserialize, Serialize)] |
81 | #[serde(rename_all = "camelCase" )] |
82 | pub struct CallHierarchyIncomingCallsParams { |
83 | pub item: CallHierarchyItem, |
84 | |
85 | #[serde(flatten)] |
86 | pub work_done_progress_params: WorkDoneProgressParams, |
87 | |
88 | #[serde(flatten)] |
89 | pub partial_result_params: PartialResultParams, |
90 | } |
91 | |
92 | /// Represents an incoming call, e.g. a caller of a method or constructor. |
93 | #[derive (Serialize, Deserialize, Debug, PartialEq, Clone)] |
94 | #[serde(rename_all = "camelCase" )] |
95 | pub struct CallHierarchyIncomingCall { |
96 | /// The item that makes the call. |
97 | pub from: CallHierarchyItem, |
98 | |
99 | /// The range at which at which the calls appears. This is relative to the caller |
100 | /// denoted by [`this.from`](#CallHierarchyIncomingCall.from). |
101 | pub from_ranges: Vec<Range>, |
102 | } |
103 | |
104 | #[derive (Debug, PartialEq, Clone, Deserialize, Serialize)] |
105 | #[serde(rename_all = "camelCase" )] |
106 | pub struct CallHierarchyOutgoingCallsParams { |
107 | pub item: CallHierarchyItem, |
108 | |
109 | #[serde(flatten)] |
110 | pub work_done_progress_params: WorkDoneProgressParams, |
111 | |
112 | #[serde(flatten)] |
113 | pub partial_result_params: PartialResultParams, |
114 | } |
115 | |
116 | /// Represents an outgoing call, e.g. calling a getter from a method or a method from a constructor etc. |
117 | #[derive (Serialize, Deserialize, Debug, PartialEq, Clone)] |
118 | #[serde(rename_all = "camelCase" )] |
119 | pub struct CallHierarchyOutgoingCall { |
120 | /// The item that is called. |
121 | pub to: CallHierarchyItem, |
122 | |
123 | /// The range at which this item is called. This is the range relative to the caller, e.g the item |
124 | /// passed to [`provideCallHierarchyOutgoingCalls`](#CallHierarchyItemProvider.provideCallHierarchyOutgoingCalls) |
125 | /// and not [`this.to`](#CallHierarchyOutgoingCall.to). |
126 | pub from_ranges: Vec<Range>, |
127 | } |
128 | |