From 3256917b91e4d6999452664431a4be641882536a Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Fri, 12 Apr 2019 22:44:43 +0200 Subject: [PATCH 1/3] Add proposed 'window/progress' notification --- Cargo.toml | 5 +++++ src/lib.rs | 53 +++++++++++++++++++++++++++++++++++++++++++++ src/notification.rs | 25 +++++++++++++++++++++ 3 files changed, 83 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 9f0b58e..5930463 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,3 +24,8 @@ serde_json = "1.0.0" url = "1.1.0" url_serde = "0.2.0" +[features] +default = [] +# Enables proposed LSP extensions. +# NOTE: No semver compatibility is guaranteed for types enabled by this feature. +proposed = [] \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 3fbbd0e..8a07939 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1360,6 +1360,19 @@ pub struct TextDocumentClientCapabilities { pub folding_range: Option, } +/** + * Window specific client capabilities. + */ +#[derive(Debug, PartialEq, Default, Deserialize, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct WindowClientCapabilities { + /** + * Whether `window/progress` server notifications are supported. + */ + #[cfg(feature = "proposed")] + pub progress: Option, +} + /** * Where ClientCapabilities are currently empty: */ @@ -1378,6 +1391,12 @@ pub struct ClientCapabilities { #[serde(skip_serializing_if = "Option::is_none")] pub text_document: Option, + /** + * Window specific client capabilities. + */ + #[serde(skip_serializing_if = "Option::is_none")] + pub window: Option, + /** * Experimental client capabilities. */ @@ -3350,6 +3369,40 @@ pub struct MarkupContent { pub value: String, } +#[cfg(feature = "proposed")] +pub use proposed::*; + +#[cfg(feature = "proposed")] +mod proposed { + /// The progress notification is sent from the server to the client to ask + /// the client to indicate progress. + #[derive(Debug, PartialEq, Deserialize, Serialize, Clone)] + pub struct ProgressParams { + /// A unique identifier to associate multiple progress notifications + /// with the same progress. + pub id: String, + + /// Mandatory title of the progress operation. Used to briefly inform + /// about the kind of operation being performed. + /// Examples: "Indexing" or "Linking dependencies". + pub title: String, + + /// Optional, more detailed associated progress message. Contains + /// complementary information to the `title`. + /// Examples: "3/25 files", "project/src/module2", "node_modules/some_dep". + /// If unset, the previous progress message (if any) is still valid. + pub message: Option, + + /// Optional progress percentage to display (value 100 is considered 100%). + /// If unset, the previous progress percentage (if any) is still valid. + pub percentage: Option, + + /// Set to true on the final progress update. + /// No more progress notifications with the same ID should be sent. + pub done: Option, + } +} + #[cfg(test)] mod tests { use super::*; diff --git a/src/notification.rs b/src/notification.rs index 67d2722..3fc321e 100644 --- a/src/notification.rs +++ b/src/notification.rs @@ -59,6 +59,10 @@ macro_rules! lsp_notification { ("workspace/didChangeWorkspaceFolders") => { $crate::notification::DidChangeWorkspaceFolders }; + // Proposed + // ("window/progress") => { + // $crate::notification::Progress + // }; } /// The base protocol now offers support for request cancellation. To cancel a request, @@ -252,6 +256,24 @@ impl Notification for PublishDiagnostics { const METHOD: &'static str = "textDocument/publishDiagnostics"; } +#[cfg(feature = "proposed")] +pub use proposed::*; + +#[cfg(feature = "proposed")] +pub mod proposed { + use super::*; + + /// The progress notification is sent from the server to the client to ask + /// the client to indicate progress. + #[derive(Debug)] + pub enum Progress {} + + impl Notification for Progress { + type Params = ProgressParams; + const METHOD: &'static str = "window/progress"; + } +} + #[cfg(test)] mod test { use super::*; @@ -290,5 +312,8 @@ mod test { check_macro!("workspace/didChangeConfiguration"); check_macro!("workspace/didChangeWatchedFiles"); check_macro!("workspace/didChangeWorkspaceFolders"); + + // Proposed + // check_macro!("window/progress"); } } From 2d2d2b0bed39bc5750fe2b0bc62d8f590852e78b Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Sat, 13 Apr 2019 00:00:38 +0200 Subject: [PATCH 2/3] Implement review feedback --- Cargo.toml | 2 +- src/lib.rs | 55 +++++++++++++++++++++------------------------ src/notification.rs | 33 ++++++++++++--------------- 3 files changed, 40 insertions(+), 50 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5930463..3a1c26d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,4 +28,4 @@ url_serde = "0.2.0" default = [] # Enables proposed LSP extensions. # NOTE: No semver compatibility is guaranteed for types enabled by this feature. -proposed = [] \ No newline at end of file +proposed = [] diff --git a/src/lib.rs b/src/lib.rs index 8a07939..ffb749f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3370,37 +3370,32 @@ pub struct MarkupContent { } #[cfg(feature = "proposed")] -pub use proposed::*; +/// The progress notification is sent from the server to the client to ask +/// the client to indicate progress. +#[derive(Debug, PartialEq, Deserialize, Serialize, Clone)] +pub struct ProgressParams { + /// A unique identifier to associate multiple progress notifications + /// with the same progress. + pub id: String, -#[cfg(feature = "proposed")] -mod proposed { - /// The progress notification is sent from the server to the client to ask - /// the client to indicate progress. - #[derive(Debug, PartialEq, Deserialize, Serialize, Clone)] - pub struct ProgressParams { - /// A unique identifier to associate multiple progress notifications - /// with the same progress. - pub id: String, - - /// Mandatory title of the progress operation. Used to briefly inform - /// about the kind of operation being performed. - /// Examples: "Indexing" or "Linking dependencies". - pub title: String, - - /// Optional, more detailed associated progress message. Contains - /// complementary information to the `title`. - /// Examples: "3/25 files", "project/src/module2", "node_modules/some_dep". - /// If unset, the previous progress message (if any) is still valid. - pub message: Option, - - /// Optional progress percentage to display (value 100 is considered 100%). - /// If unset, the previous progress percentage (if any) is still valid. - pub percentage: Option, - - /// Set to true on the final progress update. - /// No more progress notifications with the same ID should be sent. - pub done: Option, - } + /// Mandatory title of the progress operation. Used to briefly inform + /// about the kind of operation being performed. + /// Examples: "Indexing" or "Linking dependencies". + pub title: String, + + /// Optional, more detailed associated progress message. Contains + /// complementary information to the `title`. + /// Examples: "3/25 files", "project/src/module2", "node_modules/some_dep". + /// If unset, the previous progress message (if any) is still valid. + pub message: Option, + + /// Optional progress percentage to display (value 100 is considered 100%). + /// If unset, the previous progress percentage (if any) is still valid. + pub percentage: Option, + + /// Set to true on the final progress update. + /// No more progress notifications with the same ID should be sent. + pub done: Option, } #[cfg(test)] diff --git a/src/notification.rs b/src/notification.rs index 3fc321e..c2f2ea7 100644 --- a/src/notification.rs +++ b/src/notification.rs @@ -59,10 +59,11 @@ macro_rules! lsp_notification { ("workspace/didChangeWorkspaceFolders") => { $crate::notification::DidChangeWorkspaceFolders }; - // Proposed - // ("window/progress") => { - // $crate::notification::Progress - // }; + + // Requires #[cfg(feature = "proposed")] + ("window/progress") => { + $crate::notification::Progress + }; } /// The base protocol now offers support for request cancellation. To cancel a request, @@ -257,21 +258,15 @@ impl Notification for PublishDiagnostics { } #[cfg(feature = "proposed")] -pub use proposed::*; +/// The progress notification is sent from the server to the client to ask +/// the client to indicate progress. +#[derive(Debug)] +pub enum Progress {} #[cfg(feature = "proposed")] -pub mod proposed { - use super::*; - - /// The progress notification is sent from the server to the client to ask - /// the client to indicate progress. - #[derive(Debug)] - pub enum Progress {} - - impl Notification for Progress { - type Params = ProgressParams; - const METHOD: &'static str = "window/progress"; - } +impl Notification for Progress { + type Params = ProgressParams; + const METHOD: &'static str = "window/progress"; } #[cfg(test)] @@ -313,7 +308,7 @@ mod test { check_macro!("workspace/didChangeWatchedFiles"); check_macro!("workspace/didChangeWorkspaceFolders"); - // Proposed - // check_macro!("window/progress"); + #[cfg(feature = "proposed")] + check_macro!("window/progress"); } } From 565f1c751b0ee9cb5b9e71faafaac7fb68e63f79 Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Sat, 13 Apr 2019 00:05:01 +0200 Subject: [PATCH 3/3] Test also stable and proposed features --- .travis.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f26a8ad..82b8379 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,12 @@ language: Rust cache: cargo sudo: false + rust: -- nightly + - stable + - nightly +env: + - FEATURES="" + - FEATURES="proposed" + +script: cargo build --verbose; cargo test --verbose --features ${FEATURES:-""}