Skip to content

Commit

Permalink
Use proposed LSP extension window/progress message
Browse files Browse the repository at this point in the history
  • Loading branch information
Xanewok committed Apr 17, 2019
1 parent 032b47d commit 7aa3b22
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 51 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ failure = "0.1.1"
home = "0.3"
itertools = "0.8"
jsonrpc-core = "10"
lsp-types = "0.55.2"
lsp-types = { version = "0.57", features = ["proposed"] }
lazy_static = "1"
log = "0.4"
num_cpus = "1"
Expand Down
8 changes: 3 additions & 5 deletions rls/src/actions/progress.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
use std::sync::atomic::{AtomicUsize, Ordering};

use crate::lsp_data::{
MessageType, Progress, ProgressParams, PublishDiagnosticsParams, ShowMessageParams,
};
use crate::server::{Notification, Output};
use lazy_static::lazy_static;
use lsp_types::notification::{PublishDiagnostics, ShowMessage};
use lsp_types::notification::{Progress, PublishDiagnostics, ShowMessage};
use lsp_types::{MessageType, ProgressParams, PublishDiagnosticsParams, ShowMessageParams};

/// Communication of build progress back to the client.
pub trait ProgressNotifier: Send {
Expand Down Expand Up @@ -40,7 +38,7 @@ fn new_progress_params(title: String) -> ProgressParams {

ProgressParams {
id: format!("progress_{}", PROGRESS_ID_COUNTER.fetch_add(1, Ordering::SeqCst)),
title: Some(title),
title,
message: None,
percentage: None,
done: None,
Expand Down
1 change: 1 addition & 0 deletions rls/src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ fn initialize(root_path: String) -> Request<server::InitializeRequest> {
initialization_options: None,
capabilities: ClientCapabilities {
workspace: None,
window: Some(WindowClientCapabilities { progress: Some(true) }),
text_document: None,
experimental: None,
},
Expand Down
42 changes: 0 additions & 42 deletions rls/src/lsp_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,45 +341,3 @@ impl ClientCapabilities {
ClientCapabilities { code_completion_has_snippet_support, related_information_support }
}
}

/* ---------- Temporary LSP type until window/progress proposal is done --------- */

// Notification from server to client for build progress.
#[derive(Debug)]
pub struct Progress;

impl notification::Notification for Progress {
type Params = ProgressParams;
const METHOD: &'static str = NOTIFICATION__Progress;
}

// The progress notification is sent from the server to the client to ask the client
// to indicate progress.
#[allow(non_upper_case_globals)]
pub const NOTIFICATION__Progress: &str = "window/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,

// The title of the progress.
// This should be the same for all ProgressParams with the same id.
#[serde(skip_serializing_if = "Option::is_none")]
pub title: Option<String>,

// Optional progress message to display.
// If unset, the previous progress message (if any) is still valid.
#[serde(skip_serializing_if = "Option::is_none")]
pub message: Option<String>,

// Optional progress percentage to display.
// If unset, the previous progress percentage (if any) is still valid.
#[serde(skip_serializing_if = "Option::is_none")]
pub percentage: Option<f64>,

// Set to true on the final progress update.
// No more progress notifications with the same ID should be sent.
#[serde(skip_serializing_if = "Option::is_none")]
pub done: Option<bool>,
}
1 change: 1 addition & 0 deletions rls/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ mod test {
initialization_options: None,
capabilities: lsp_types::ClientCapabilities {
workspace: None,
window: None,
text_document: None,
experimental: None,
},
Expand Down
2 changes: 2 additions & 0 deletions tests/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ fn initialize_params(root_path: &Path) -> InitializeParams {
initialization_options: None,
capabilities: ClientCapabilities {
workspace: None,
window: Some(WindowClientCapabilities { progress: Some(true) }),
text_document: None,
experimental: None,
},
Expand Down Expand Up @@ -503,6 +504,7 @@ fn client_completion_suggests_arguments_in_statements() {
initialization_options: None,
capabilities: lsp_types::ClientCapabilities {
workspace: None,
window: Some(WindowClientCapabilities { progress: Some(true) }),
text_document: Some(TextDocumentClientCapabilities {
completion: Some(CompletionCapability {
completion_item: Some(CompletionItemCapability {
Expand Down

0 comments on commit 7aa3b22

Please sign in to comment.