1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
// Copyright Two Neutron Stars Incorporated and contributors
// SPDX-License-Identifier: BlueOak-1.0.0
use {
crate::{
TRACER,
Uri,
database::PartitionWriteContextRef,
protocol::{
jsonrpc,
lsp::{
DynamicRegistrationClientCapabilities,
PartialResultParams,
Range,
SymbolKind,
SymbolTag,
TextDocumentPositionParams,
WorkDoneProgressOptions,
WorkDoneProgressParams,
},
},
scheduler::{
lanes::{
self,
Lane,
},
task::TaskContext,
},
},
serde::{
Deserialize,
Serialize,
},
serde_json::Value,
};
pub type CallHierarchyClientCapabilities =
DynamicRegistrationClientCapabilities;
#[derive(Debug, Default, Clone, PartialEq, Eq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CallHierarchyOptions {
#[serde(flatten)]
pub work_done_progress_options: WorkDoneProgressOptions,
}
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
#[serde(untagged)]
pub enum CallHierarchyServerCapability {
Simple(bool),
Options(CallHierarchyOptions),
}
impl From<CallHierarchyOptions> for CallHierarchyServerCapability {
fn from(from: CallHierarchyOptions) -> Self {
Self::Options(from)
}
}
impl From<bool> for CallHierarchyServerCapability {
fn from(from: bool) -> Self {
Self::Simple(from)
}
}
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CallHierarchyPrepareParams {
#[serde(flatten)]
pub text_document_position_params: TextDocumentPositionParams,
#[serde(flatten)]
pub work_done_progress_params: WorkDoneProgressParams,
}
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CallHierarchyItem {
/// The name of this item.
pub name: String,
/// The kind of this item.
pub kind: SymbolKind,
/// Tags for this item.
#[serde(skip_serializing_if = "Option::is_none")]
pub tags: Option<Vec<SymbolTag>>,
/// More detail for this item, e.g. the signature of a function.
#[serde(skip_serializing_if = "Option::is_none")]
pub detail: Option<String>,
/// The resource identifier of this item.
pub uri: Uri,
/// The range enclosing this symbol not including leading/trailing whitespace
/// but everything else, e.g. comments and code.
pub range: Range,
/// The range that should be selected and revealed when this symbol is being
/// picked, e.g. the name of a function. Must be contained by the
/// [`range`](#CallHierarchyItem.range).
pub selection_range: Range,
/// A data entry field that is preserved between a call hierarchy prepare and
/// incoming calls or outgoing calls requests.
#[serde(skip_serializing_if = "Option::is_none")]
pub data: Option<Value>,
}
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CallHierarchyIncomingCallsParams {
pub item: CallHierarchyItem,
#[serde(flatten)]
pub work_done_progress_params: WorkDoneProgressParams,
#[serde(flatten)]
pub partial_result_params: PartialResultParams,
}
/// Represents an incoming call, e.g. a caller of a method or constructor.
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CallHierarchyIncomingCall {
/// The item that makes the call.
pub from: CallHierarchyItem,
/// The range at which at which the calls appears. This is relative to the
/// caller denoted by [`this.from`](#CallHierarchyIncomingCall.from).
pub from_ranges: Vec<Range>,
}
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CallHierarchyOutgoingCallsParams {
pub item: CallHierarchyItem,
#[serde(flatten)]
pub work_done_progress_params: WorkDoneProgressParams,
#[serde(flatten)]
pub partial_result_params: PartialResultParams,
}
/// Represents an outgoing call, e.g. calling a getter from a method or a method
/// from a constructor etc.
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CallHierarchyOutgoingCall {
/// The item that is called.
pub to: CallHierarchyItem,
/// The range at which this item is called. This is the range relative to the
/// caller, e.g the item passed to [`provideCallHierarchyOutgoingCalls`](#
/// CallHierarchyItemProvider.provideCallHierarchyOutgoingCalls)
/// and not [`this.to`](#CallHierarchyOutgoingCall.to).
pub from_ranges: Vec<Range>,
}
pub trait CallHierarchyService<
P: crate::database::storage::Partitions,
T: crate::protocol::lsp::LanguageServer<P>,
>: Send + Sync + 'static
{
/// The [`textDocument/prepareCallHierarchy`] request is sent from the client
/// to the server to return a call hierarchy for the language element of
/// given text document positions.
///
/// [`textDocument/prepareCallHierarchy`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_prepareCallHierarchy
///
/// The call hierarchy requests are executed in two steps:
///
/// 1. First, a call hierarchy item is resolved for the given text document
/// position (this method).
/// 2. For a call hierarchy item, the incoming or outgoing call hierarchy
/// items are resolved inside [`incoming_calls`] and [`outgoing_calls`],
/// respectively.
///
/// [`incoming_calls`]: Self::incoming_calls
/// [`outgoing_calls`]: Self::outgoing_calls
///
/// # Compatibility
///
/// This request was introduced in specification version 3.16.0.
fn prepare_call_hierarchy(
&self,
params: CallHierarchyPrepareParams,
ctx: &mut TaskContext<P, T>,
writer: &mut PartitionWriteContextRef<'_, P>,
) -> impl std::future::Future<
Output = jsonrpc::Result<Option<Vec<CallHierarchyItem>>>,
> + Send {
async move {
otel::span!(
"laburnum.lsp.prepare_call_hierarchy",
"document.uri" = params
.text_document_position_params
.text_document
.uri
.to_string(),
"position.line" =
params.text_document_position_params.position.line as i64,
"position.character" =
params.text_document_position_params.position.character as i64
);
let _ = (params, ctx, writer);
Err(jsonrpc::Error::method_not_found())
}
}
const PREPARE_CALL_HIERARCHY_LANE: Lane = lanes::DEFAULT_LANE;
/// The [`callHierarchy/incomingCalls`] request is sent from the client to the
/// server to resolve **incoming** calls for a given call hierarchy item.
///
/// The request doesn't define its own client and server capabilities. It is
/// only issued if a server registers for the
/// [`textDocument/prepareCallHierarchy`] request.
///
/// [`callHierarchy/incomingCalls`]: https://microsoft.github.io/language-server-protocol/specification#callHierarchy_incomingCalls
/// [`textDocument/prepareCallHierarchy`]: Self::prepare_call_hierarchy
///
/// # Compatibility
///
/// This request was introduced in specification version 3.16.0.
fn incoming_calls(
&self,
params: CallHierarchyIncomingCallsParams,
ctx: &mut TaskContext<P, T>,
writer: &mut PartitionWriteContextRef<'_, P>,
) -> impl std::future::Future<
Output = jsonrpc::Result<Option<Vec<CallHierarchyIncomingCall>>>,
> + Send {
async move {
otel::span!("laburnum.lsp.incoming_calls");
let _ = (params, ctx, writer);
Err(jsonrpc::Error::method_not_found())
}
}
const INCOMING_CALLS_LANE: Lane = lanes::DEFAULT_LANE;
/// The [`callHierarchy/outgoingCalls`] request is sent from the client to the
/// server to resolve **outgoing** calls for a given call hierarchy item.
///
/// The request doesn't define its own client and server capabilities. It is
/// only issued if a server registers for the
/// [`textDocument/prepareCallHierarchy`] request.
///
/// [`callHierarchy/outgoingCalls`]: https://microsoft.github.io/language-server-protocol/specification#callHierarchy_outgoingCalls
/// [`textDocument/prepareCallHierarchy`]: Self::prepare_call_hierarchy
///
/// # Compatibility
///
/// This request was introduced in specification version 3.16.0.
fn outgoing_calls(
&self,
params: CallHierarchyOutgoingCallsParams,
ctx: &mut TaskContext<P, T>,
writer: &mut PartitionWriteContextRef<'_, P>,
) -> impl std::future::Future<
Output = jsonrpc::Result<Option<Vec<CallHierarchyOutgoingCall>>>,
> + Send {
async move {
otel::span!("laburnum.lsp.outgoing_calls");
let _ = (params, ctx, writer);
Err(jsonrpc::Error::method_not_found())
}
}
const OUTGOING_CALLS_LANE: Lane = lanes::DEFAULT_LANE;
}