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
// Copyright Two Neutron Stars Incorporated and contributors
// SPDX-License-Identifier: BlueOak-1.0.0
use {
crate::{
TRACER,
Uri,
database::PartitionWriteContextRef,
protocol::{
jsonrpc,
lsp::{
PartialResultParams,
Range,
TextDocumentIdentifier,
WorkDoneProgressOptions,
WorkDoneProgressParams,
},
},
scheduler::task::TaskContext,
},
serde::{
Deserialize,
Serialize,
},
serde_json::Value,
};
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct DocumentLinkClientCapabilities {
/// Whether document link supports dynamic registration.
#[serde(skip_serializing_if = "Option::is_none")]
pub dynamic_registration: Option<bool>,
/// Whether the client support the `tooltip` property on `DocumentLink`.
#[serde(skip_serializing_if = "Option::is_none")]
pub tooltip_support: Option<bool>,
}
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct DocumentLinkOptions {
/// Document links have a resolve provider as well.
#[serde(skip_serializing_if = "Option::is_none")]
pub resolve_provider: Option<bool>,
#[serde(flatten)]
pub work_done_progress_options: WorkDoneProgressOptions,
}
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct DocumentLinkParams {
/// The document to provide document links for.
pub text_document: TextDocumentIdentifier,
#[serde(flatten)]
pub work_done_progress_params: WorkDoneProgressParams,
#[serde(flatten)]
pub partial_result_params: PartialResultParams,
}
/// A document link is a range in a text document that links to an internal or
/// external resource, like another text document or a web site.
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
pub struct DocumentLink {
/// The range this link applies to.
pub range: Range,
/// The uri this link points to.
#[serde(skip_serializing_if = "Option::is_none")]
pub target: Option<Uri>,
/// The tooltip text when you hover over this link.
///
/// If a tooltip is provided, is will be displayed in a string that includes
/// instructions on how to trigger the link, such as `{0} (ctrl + click)`.
/// The specific instructions vary depending on OS, user settings, and
/// localization.
#[serde(skip_serializing_if = "Option::is_none")]
pub tooltip: Option<String>,
/// A data entry field that is preserved on a document link between a
/// `DocumentLinkRequest` and a `DocumentLinkResolveRequest`.
#[serde(skip_serializing_if = "Option::is_none")]
pub data: Option<Value>,
}
pub trait DocumentLinkService<
P: crate::database::storage::Partitions,
T: crate::protocol::lsp::LanguageServer<P>,
>: Send + Sync + 'static
{
/// The [`documentLink/resolve`] request is sent from the client to the server
/// to resolve the target of a given document link.
///
/// [`documentLink/resolve`]: https://microsoft.github.io/language-server-protocol/specification#documentLink_resolve
///
/// A document link is a range in a text document that links to an internal or
/// external resource, like another text document or a web site.
fn document_link_resolve(
&self,
params: DocumentLink,
ctx: &mut TaskContext<P, T>,
writer: &mut PartitionWriteContextRef<'_, P>,
) -> impl std::future::Future<Output = jsonrpc::Result<DocumentLink>> + Send
{
async move {
otel::span!("laburnum.lsp.document_link_resolve");
let _ = params;
Err(jsonrpc::Error::method_not_found())
}
}
const DOCUMENT_LINK_RESOLVE_LANE: crate::scheduler::lanes::Lane =
crate::scheduler::lanes::DEFAULT_LANE;
/// The [`textDocument/documentLink`] request is sent from the client to the
/// server to request the location of links in a document.
///
/// A document link is a range in a text document that links to an internal or
/// external resource, like another text document or a web site.
///
/// [`textDocument/documentLink`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_documentLink
///
/// # Compatibility
///
/// The [`DocumentLink::tooltip`] field was introduced in specification
/// version 3.15.0 and requires client-side support in order to be used. It
/// can be returned if the client set the following field to `true` in the
/// [`initialize`](Self::initialize) method:
///
/// ```text
/// InitializeParams::capabilities::text_document::document_link::tooltip_support
/// ```
fn document_link(
&self,
params: DocumentLinkParams,
ctx: &mut TaskContext<P, T>,
writer: &mut PartitionWriteContextRef<'_, P>,
) -> impl std::future::Future<
Output = jsonrpc::Result<Option<Vec<DocumentLink>>>,
> + Send {
async move {
otel::span!(
"laburnum.lsp.document_link",
"document.uri" = params.text_document.uri.to_string()
);
let _ = params;
Err(jsonrpc::Error::method_not_found())
}
}
const DOCUMENT_LINK_LANE: crate::scheduler::lanes::Lane =
crate::scheduler::lanes::DEFAULT_LANE;
}