1use serde::{Deserialize, Serialize};
2use serde_json::Value;
3use url::Url;
45use crate::{
6 DynamicRegistrationClientCapabilities, PartialResultParams, Range, SymbolKind, SymbolTag,
7 TextDocumentPositionParams, WorkDoneProgressOptions, WorkDoneProgressParams,
8};
910pub type CallHierarchyClientCapabilities = DynamicRegistrationClientCapabilities;
1112#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize, Copy)]
13#[serde(rename_all = "camelCase")]
14pub struct CallHierarchyOptions {
15#[serde(flatten)]
16pub work_done_progress_options: WorkDoneProgressOptions,
17}
1819#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize, Copy)]
20#[serde(untagged)]
21pub enum CallHierarchyServerCapability {
22 Simple(bool),
23 Options(CallHierarchyOptions),
24}
2526impl From<CallHierarchyOptions> for CallHierarchyServerCapability {
27fn from(from: CallHierarchyOptions) -> Self {
28Self::Options(from)
29 }
30}
3132impl From<bool> for CallHierarchyServerCapability {
33fn from(from: bool) -> Self {
34Self::Simple(from)
35 }
36}
3738#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
39#[serde(rename_all = "camelCase")]
40pub struct CallHierarchyPrepareParams {
41#[serde(flatten)]
42pub text_document_position_params: TextDocumentPositionParams,
4344#[serde(flatten)]
45pub work_done_progress_params: WorkDoneProgressParams,
46}
4748#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
49#[serde(rename_all = "camelCase")]
50pub struct CallHierarchyItem {
51/// The name of this item.
52pub name: String,
5354/// The kind of this item.
55pub kind: SymbolKind,
5657/// Tags for this item.
58#[serde(skip_serializing_if = "Option::is_none")]
59pub tags: Option<Vec<SymbolTag>>,
6061/// More detail for this item, e.g. the signature of a function.
62#[serde(skip_serializing_if = "Option::is_none")]
63pub detail: Option<String>,
6465/// The resource identifier of this item.
66pub uri: Url,
6768/// The range enclosing this symbol not including leading/trailing whitespace but everything else, e.g. comments and code.
69pub range: Range,
7071/// 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).
73pub selection_range: Range,
7475/// 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")]
77pub data: Option<Value>,
78}
7980#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
81#[serde(rename_all = "camelCase")]
82pub struct CallHierarchyIncomingCallsParams {
83pub item: CallHierarchyItem,
8485#[serde(flatten)]
86pub work_done_progress_params: WorkDoneProgressParams,
8788#[serde(flatten)]
89pub partial_result_params: PartialResultParams,
90}
9192/// 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")]
95pub struct CallHierarchyIncomingCall {
96/// The item that makes the call.
97pub from: CallHierarchyItem,
9899/// The range at which at which the calls appears. This is relative to the caller
100 /// denoted by [`this.from`](#CallHierarchyIncomingCall.from).
101pub from_ranges: Vec<Range>,
102}
103104#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
105#[serde(rename_all = "camelCase")]
106pub struct CallHierarchyOutgoingCallsParams {
107pub item: CallHierarchyItem,
108109#[serde(flatten)]
110pub work_done_progress_params: WorkDoneProgressParams,
111112#[serde(flatten)]
113pub partial_result_params: PartialResultParams,
114}
115116/// 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")]
119pub struct CallHierarchyOutgoingCall {
120/// The item that is called.
121pub to: CallHierarchyItem,
122123/// 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).
126pub from_ranges: Vec<Range>,
127}