Skip to content

Commit

Permalink
Merge pull request #103 from Xanewok/window-progress
Browse files Browse the repository at this point in the history
Add proposed 'window/progress' notification
  • Loading branch information
Marwes committed Apr 15, 2019
2 parents b719f15 + 565f1c7 commit d01bed5
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 1 deletion.
9 changes: 8 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -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:-""}
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
48 changes: 48 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1360,6 +1360,19 @@ pub struct TextDocumentClientCapabilities {
pub folding_range: Option<FoldingRangeCapability>,
}

/**
* 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<bool>,
}

/**
* Where ClientCapabilities are currently empty:
*/
Expand All @@ -1378,6 +1391,12 @@ pub struct ClientCapabilities {
#[serde(skip_serializing_if = "Option::is_none")]
pub text_document: Option<TextDocumentClientCapabilities>,

/**
* Window specific client capabilities.
*/
#[serde(skip_serializing_if = "Option::is_none")]
pub window: Option<WindowClientCapabilities>,

/**
* Experimental client capabilities.
*/
Expand Down Expand Up @@ -3350,6 +3369,35 @@ pub struct MarkupContent {
pub value: String,
}

#[cfg(feature = "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<String>,

/// Optional progress percentage to display (value 100 is considered 100%).
/// If unset, the previous progress percentage (if any) is still valid.
pub percentage: Option<f64>,

/// Set to true on the final progress update.
/// No more progress notifications with the same ID should be sent.
pub done: Option<bool>,
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
20 changes: 20 additions & 0 deletions src/notification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ macro_rules! lsp_notification {
("workspace/didChangeWorkspaceFolders") => {
$crate::notification::DidChangeWorkspaceFolders
};

// Requires #[cfg(feature = "proposed")]
("window/progress") => {
$crate::notification::Progress
};
}

/// The base protocol now offers support for request cancellation. To cancel a request,
Expand Down Expand Up @@ -252,6 +257,18 @@ impl Notification for PublishDiagnostics {
const METHOD: &'static str = "textDocument/publishDiagnostics";
}

#[cfg(feature = "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")]
impl Notification for Progress {
type Params = ProgressParams;
const METHOD: &'static str = "window/progress";
}

#[cfg(test)]
mod test {
use super::*;
Expand Down Expand Up @@ -290,5 +307,8 @@ mod test {
check_macro!("workspace/didChangeConfiguration");
check_macro!("workspace/didChangeWatchedFiles");
check_macro!("workspace/didChangeWorkspaceFolders");

#[cfg(feature = "proposed")]
check_macro!("window/progress");
}
}

0 comments on commit d01bed5

Please sign in to comment.