Skip to content

Commit

Permalink
feat(inlayHint): add request impls
Browse files Browse the repository at this point in the history
  • Loading branch information
sno2 committed Mar 21, 2022
1 parent 69f21e7 commit 393aefa
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 10 deletions.
36 changes: 26 additions & 10 deletions src/inlay_hint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,8 @@ use serde::{Deserialize, Serialize};
#[serde(rename_all = "camelCase")]
#[serde(untagged)]
pub enum InlayHintServerCapabilities {
Options(InlayHintOptions),
RegistrationOptions(InlayHintRegistrationOptions),
}

#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct InlayHintClientCapabilitiesResolveSupport {
/// The properties that a client can resolve lazily.
pub properties: Vec<String>,
Options(InlayHintOptions),
RegistrationOptions(InlayHintRegistrationOptions),
}

/// Inlay hint client capabilities.
Expand All @@ -35,7 +28,7 @@ pub struct InlayHintClientCapabilities {
/// Indicates which properties a client can resolve lazily on a inlay
/// hint.
#[serde(skip_serializing_if = "Option::is_none")]
pub resolve_support: Option<InlayHintClientCapabilitiesResolveSupport>,
pub resolve_support: Option<InlayHintResolveClientCapabilities>,
}

/// Inlay hint options used during static registration.
Expand Down Expand Up @@ -259,3 +252,26 @@ impl InlayHintKind {
pub const PARAMETER: InlayHintKind = InlayHintKind(2);
}
}

#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct InlayHintResolveClientCapabilities {
pub properties: Vec<String>,
}

/// Client workspace capabilities specific to inlay hints.
///
/// @since 3.17.0 - proposed state
#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct InlayHintWorkspaceClientCapabilities {
/// Whether the client implementation supports a refresh request sent from
/// the server to the client.
///
/// Note that this event is global and will force the client to refresh all
/// inlay hints currently shown. It should be used with absolute care and
/// is useful for situation where a server for example detects a project wide
/// change that requires such a calculation.
#[serde(skip_serializing_if = "Option::is_none")]
pub refresh_support: Option<bool>,
}
5 changes: 5 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1252,6 +1252,11 @@ pub struct WorkspaceClientCapabilities {
/// since 3.16.0
#[serde(skip_serializing_if = "Option::is_none")]
pub file_operations: Option<WorkspaceFileOperationsClientCapabilities>,


#[serde(skip_serializing_if = "Option::is_none")]
#[cfg(feature = "proposed")]
pub inlay_hint: Option<InlayHintWorkspaceClientCapabilities>,
}

#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
Expand Down
30 changes: 30 additions & 0 deletions src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,36 @@ impl Request for MonikerRequest {
const METHOD: &'static str = "textDocument/moniker";
}

#[cfg(feature = "proposed")]
pub enum InlayHintRequest {}

#[cfg(feature = "proposed")]
impl Request for InlayHintRequest {
type Params = InlayHintParams;
type Result = Option<Vec<InlayHint>>;
const METHOD: &'static str = "textDocument/inlayHint";
}

#[cfg(feature = "proposed")]
pub enum InlayHintResolveRequest {}

#[cfg(feature = "proposed")]
impl Request for InlayHintResolveRequest {
type Params = InlayHint;
type Result = InlayHint;
const METHOD: &'static str = "inlayHint/resolve";
}

#[cfg(feature = "proposed")]
pub enum InlayHintRefreshRequest {}

#[cfg(feature = "proposed")]
impl Request for InlayHintRefreshRequest {
type Params = ();
type Result = ();
const METHOD: &'static str = "workspace/inlayHint/refresh";
}

#[cfg(test)]
mod test {
use super::*;
Expand Down

0 comments on commit 393aefa

Please sign in to comment.