1use serde::{Deserialize, Serialize};
2use serde_json::Value;
3
4use crate::{
5 Command, DynamicRegistrationClientCapabilities, PartialResultParams, Range,
6 TextDocumentIdentifier, WorkDoneProgressParams,
7};
8
9pub type CodeLensClientCapabilities = DynamicRegistrationClientCapabilities;
10
11/// Code Lens options.
12#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize, Copy)]
13#[serde(rename_all = "camelCase")]
14pub struct CodeLensOptions {
15 /// Code lens has a resolve provider as well.
16 #[serde(skip_serializing_if = "Option::is_none")]
17 pub resolve_provider: Option<bool>,
18}
19
20#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
21#[serde(rename_all = "camelCase")]
22pub struct CodeLensParams {
23 /// The document to request code lens for.
24 pub text_document: TextDocumentIdentifier,
25
26 #[serde(flatten)]
27 pub work_done_progress_params: WorkDoneProgressParams,
28
29 #[serde(flatten)]
30 pub partial_result_params: PartialResultParams,
31}
32
33/// A code lens represents a command that should be shown along with
34/// source text, like the number of references, a way to run tests, etc.
35///
36/// A code lens is _unresolved_ when no command is associated to it. For performance
37/// reasons the creation of a code lens and resolving should be done in two stages.
38#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
39#[serde(rename_all = "camelCase")]
40pub struct CodeLens {
41 /// The range in which this code lens is valid. Should only span a single line.
42 pub range: Range,
43
44 /// The command this code lens represents.
45 #[serde(skip_serializing_if = "Option::is_none")]
46 pub command: Option<Command>,
47
48 /// A data entry field that is preserved on a code lens item between
49 /// a code lens and a code lens resolve request.
50 #[serde(skip_serializing_if = "Option::is_none")]
51 pub data: Option<Value>,
52}
53
54#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
55#[serde(rename_all = "camelCase")]
56pub struct CodeLensWorkspaceClientCapabilities {
57 /// Whether the client implementation supports a refresh request sent from the
58 /// server to the client.
59 ///
60 /// Note that this event is global and will force the client to refresh all
61 /// code lenses currently shown. It should be used with absolute care and is
62 /// useful for situation where a server for example detect a project wide
63 /// change that requires such a calculation.
64 #[serde(skip_serializing_if = "Option::is_none")]
65 pub refresh_support: Option<bool>,
66}
67