Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Commit 2d1c14e

Browse files
committed
feat: update lsp_types to the latest version
1 parent 7241c6c commit 2d1c14e

File tree

16 files changed

+449
-211
lines changed

16 files changed

+449
-211
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ env_logger = "0.9"
3939
home = "0.5.1"
4040
itertools = "0.10"
4141
jsonrpc-core = "18"
42-
lsp-types = { version = "0.60", features = ["proposed"] }
42+
lsp-types = { version = "0.92", features = ["proposed"] }
4343
lazy_static = "1"
4444
log = "0.4"
4545
num_cpus = "1"

rls/src/actions/diagnostics.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ pub fn parse_diagnostics(
141141
source: Some(source.to_owned()),
142142
message: diagnostic_message,
143143
related_information,
144+
code_description: None,
145+
tags: None,
146+
data: None,
144147
};
145148

146149
(file_path, (diagnostic, suggestions))
@@ -193,9 +196,9 @@ fn format_notes(children: &[AssociatedMessage], primary: &DiagnosticSpan) -> Opt
193196

194197
fn severity(level: &str, is_primary_span: bool) -> DiagnosticSeverity {
195198
match (level, is_primary_span) {
196-
(_, false) => DiagnosticSeverity::Information,
197-
("error", _) => DiagnosticSeverity::Error,
198-
(..) => DiagnosticSeverity::Warning,
199+
(_, false) => DiagnosticSeverity::INFORMATION,
200+
("error", _) => DiagnosticSeverity::ERROR,
201+
(..) => DiagnosticSeverity::WARNING,
199202
}
200203
}
201204

rls/src/actions/format.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ impl Rustfmt {
9898
.into_iter()
9999
.map(|item| {
100100
// Rustfmt's line indices are 1-based
101-
let start_line = u64::from(item.line_number_orig) - 1;
102-
let end_line = start_line + u64::from(item.lines_removed);
101+
let start_line = item.line_number_orig - 1;
102+
let end_line = start_line + item.lines_removed;
103103

104104
let mut new_text = item.lines.join(newline);
105105

@@ -242,7 +242,7 @@ mod tests {
242242
Rustfmt::Internal.calc_text_edits(input.to_string(), config()).unwrap()
243243
}
244244

245-
fn test_case(input: &str, output: Vec<(u64, u64, u64, u64, &str)>) {
245+
fn test_case(input: &str, output: Vec<(u32, u32, u32, u32, &str)>) {
246246
assert_eq!(
247247
format(input),
248248
output

rls/src/actions/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ impl FileWatch {
579579
}
580580

581581
let local = &path[self.project_uri.len()..];
582-
local == "/Cargo.lock" || (local == "/target" && kind == FileChangeType::Deleted)
582+
local == "/Cargo.lock" || (local == "/target" && kind == FileChangeType::DELETED)
583583
}
584584

585585
#[inline]
@@ -589,7 +589,7 @@ impl FileWatch {
589589

590590
#[inline]
591591
pub fn is_relevant_save_doc(&self, did_save: &DidSaveTextDocumentParams) -> bool {
592-
self.relevant_change_kind(&did_save.text_document.uri, FileChangeType::Changed)
592+
self.relevant_change_kind(&did_save.text_document.uri, FileChangeType::CHANGED)
593593
}
594594
}
595595

@@ -629,12 +629,13 @@ mod test {
629629
}
630630

631631
fn change(url: &str) -> FileEvent {
632-
FileEvent::new(Url::parse(url).unwrap(), FileChangeType::Changed)
632+
FileEvent::new(Url::parse(url).unwrap(), FileChangeType::CHANGED)
633633
}
634634

635635
fn did_save(url: &str) -> DidSaveTextDocumentParams {
636636
DidSaveTextDocumentParams {
637637
text_document: TextDocumentIdentifier::new(Url::parse(url).unwrap()),
638+
text: None,
638639
}
639640
}
640641

rls/src/actions/notifications.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,14 @@ impl BlockingNotificationAction for DidChangeTextDocument {
7575

7676
ctx.quiescent.store(false, Ordering::SeqCst);
7777
let file_path = parse_file_path!(&params.text_document.uri, "on_change")?;
78-
let version_num = params.text_document.version.unwrap();
78+
let version_num = params.text_document.version as u64;
7979

8080
match ctx.check_change_version(&file_path, version_num) {
8181
VersionOrdering::Ok => {}
8282
VersionOrdering::Duplicate => return Ok(()),
8383
VersionOrdering::OutOfOrder => {
8484
out.notify(Notification::<ShowMessage>::new(ShowMessageParams {
85-
typ: MessageType::Warning,
85+
typ: MessageType::WARNING,
8686
message: format!("Out of order change in {:?}", file_path),
8787
}));
8888
return Ok(());
@@ -99,7 +99,7 @@ impl BlockingNotificationAction for DidChangeTextDocument {
9999
// LSP sends UTF-16 code units based offsets and length
100100
span: VfsSpan::from_utf16(
101101
Span::from_range(range, file_path.clone()),
102-
i.range_length,
102+
i.range_length.map(|l| l as u64),
103103
),
104104
text: i.text.clone(),
105105
}
@@ -311,7 +311,7 @@ mod test {
311311
let manifest_change = Url::parse(lsp_project_manifest).unwrap();
312312
DidChangeWatchedFiles::handle(
313313
DidChangeWatchedFilesParams {
314-
changes: vec![FileEvent::new(manifest_change, FileChangeType::Changed)],
314+
changes: vec![FileEvent::new(manifest_change, FileChangeType::CHANGED)],
315315
},
316316
&mut ctx,
317317
NoOutput,

rls/src/actions/post_build.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ impl PostBuildHandler {
137137
Diagnostic {
138138
range,
139139
message,
140-
severity: Some(DiagnosticSeverity::Error),
140+
severity: Some(DiagnosticSeverity::ERROR),
141141
..Diagnostic::default()
142142
},
143143
vec![],
@@ -206,10 +206,11 @@ impl PostBuildHandler {
206206
.iter()
207207
.map(|(diag, _)| diag)
208208
.filter(|diag| {
209-
self.show_warnings || diag.severity != Some(DiagnosticSeverity::Warning)
209+
self.show_warnings || diag.severity != Some(DiagnosticSeverity::WARNING)
210210
})
211211
.cloned()
212212
.collect(),
213+
version: None,
213214
};
214215

215216
self.notifier.notify_publish_diagnostics(params);

rls/src/actions/progress.rs

Lines changed: 54 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ use std::sync::atomic::{AtomicUsize, Ordering};
33
use crate::server::{Notification, Output};
44
use lazy_static::lazy_static;
55
use lsp_types::notification::{Progress, PublishDiagnostics, ShowMessage};
6-
use lsp_types::{MessageType, ProgressParams, PublishDiagnosticsParams, ShowMessageParams};
6+
use lsp_types::{
7+
MessageType, NumberOrString, ProgressParams, ProgressParamsValue, PublishDiagnosticsParams,
8+
ShowMessageParams, WorkDoneProgress, WorkDoneProgressBegin, WorkDoneProgressEnd,
9+
WorkDoneProgressReport,
10+
};
711

812
/// Communication of build progress back to the client.
913
pub trait ProgressNotifier: Send {
@@ -37,11 +41,16 @@ fn new_progress_params(title: String) -> ProgressParams {
3741
}
3842

3943
ProgressParams {
40-
id: format!("progress_{}", PROGRESS_ID_COUNTER.fetch_add(1, Ordering::SeqCst)),
41-
title,
42-
message: None,
43-
percentage: None,
44-
done: None,
44+
token: NumberOrString::String(format!(
45+
"progress_{}",
46+
PROGRESS_ID_COUNTER.fetch_add(1, Ordering::SeqCst)
47+
)),
48+
value: ProgressParamsValue::WorkDone(WorkDoneProgress::Begin(WorkDoneProgressBegin {
49+
title,
50+
cancellable: None,
51+
message: None,
52+
percentage: None,
53+
})),
4554
}
4655
}
4756

@@ -67,15 +76,45 @@ impl<O: Output> ProgressNotifier for BuildProgressNotifier<O> {
6776
}
6877
fn notify_progress(&self, update: ProgressUpdate) {
6978
let mut params = self.progress_params.clone();
70-
match update {
71-
ProgressUpdate::Message(s) => params.message = Some(s),
72-
ProgressUpdate::Percentage(p) => params.percentage = Some(p),
73-
}
79+
80+
// set the value to WorkDoneProgress::Report if it is not
81+
match &mut params.value {
82+
ProgressParamsValue::WorkDone(work) => match work {
83+
WorkDoneProgress::Report(_) => {}
84+
_ => {
85+
params.value = ProgressParamsValue::WorkDone(WorkDoneProgress::Report(
86+
WorkDoneProgressReport {
87+
cancellable: None,
88+
message: None,
89+
percentage: None,
90+
},
91+
))
92+
}
93+
},
94+
};
95+
96+
match &mut params.value {
97+
ProgressParamsValue::WorkDone(work) => match work {
98+
WorkDoneProgress::Report(value) => match update {
99+
ProgressUpdate::Message(m) => {
100+
value.message = Some(m);
101+
}
102+
ProgressUpdate::Percentage(p) => {
103+
value.percentage = Some(p as u32);
104+
}
105+
},
106+
_ => {
107+
unreachable!("params.value is set to WorkDoneProgress::Report");
108+
}
109+
},
110+
};
74111
self.out.notify(Notification::<Progress>::new(params));
75112
}
76113
fn notify_end_progress(&self) {
77114
let mut params = self.progress_params.clone();
78-
params.done = Some(true);
115+
params.value = ProgressParamsValue::WorkDone(WorkDoneProgress::End(WorkDoneProgressEnd {
116+
message: None,
117+
}));
79118
self.out.notify(Notification::<Progress>::new(params));
80119
}
81120
}
@@ -110,13 +149,15 @@ impl<O: Output> DiagnosticsNotifier for BuildDiagnosticsNotifier<O> {
110149
}
111150
fn notify_error_diagnostics(&self, message: String) {
112151
self.out.notify(Notification::<ShowMessage>::new(ShowMessageParams {
113-
typ: MessageType::Error,
152+
typ: MessageType::ERROR,
114153
message,
115154
}));
116155
}
117156
fn notify_end_diagnostics(&self) {
118157
let mut params = self.progress_params.clone();
119-
params.done = Some(true);
158+
params.value = ProgressParamsValue::WorkDone(WorkDoneProgress::End(WorkDoneProgressEnd {
159+
message: None,
160+
}));
120161
self.out.notify(Notification::<Progress>::new(params));
121162
}
122163
}

0 commit comments

Comments
 (0)