Skip to content

Commit c7c4e91

Browse files
bors[bot]kjeremy
andauthored
Merge #6566
6566: Latest LSP 3.16 protocol r=matklad a=kjeremy Pulls in gluon-lang/lsp-types#186 Co-authored-by: kjeremy <[email protected]>
2 parents 0a658c4 + 233fdb1 commit c7c4e91

File tree

12 files changed

+32
-33
lines changed

12 files changed

+32
-33
lines changed

Cargo.lock

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

crates/rust-analyzer/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ env_logger = { version = "0.8.1", default-features = false }
2121
itertools = "0.9.0"
2222
jod-thread = "0.1.0"
2323
log = "0.4.8"
24-
lsp-types = { version = "0.83.0", features = ["proposed"] }
24+
lsp-types = { version = "0.83.1", features = ["proposed"] }
2525
parking_lot = "0.11.0"
2626
pico-args = "0.3.1"
2727
oorandom = "11.1.2"
@@ -31,7 +31,7 @@ serde_json = "1.0.48"
3131
threadpool = "1.7.1"
3232
rayon = "1.5"
3333
mimalloc = { version = "0.1.19", default-features = false, optional = true }
34-
lsp-server = "0.4.0"
34+
lsp-server = "0.5.0"
3535
tracing = "0.1"
3636
tracing-subscriber = { version = "0.2", default-features = false, features = ["env-filter", "registry"] }
3737
tracing-tree = { version = "0.1.4" }

crates/rust-analyzer/src/caps.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ pub fn server_capabilities(client_caps: &ClientCapabilities) -> ServerCapabiliti
6262
prepare_provider: Some(true),
6363
work_done_progress_options: WorkDoneProgressOptions { work_done_progress: None },
6464
})),
65+
on_type_rename_provider: None,
6566
document_link_provider: None,
6667
color_provider: None,
6768
execute_command_provider: None,

crates/rust-analyzer/src/diagnostics/to_proto.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ fn location_naive(workspace_root: &Path, span: &DiagnosticSpan) -> lsp_types::Lo
5555

5656
// FIXME: this doesn't handle UTF16 offsets correctly
5757
let range = lsp_types::Range::new(
58-
lsp_types::Position::new(span.line_start as u64 - 1, span.column_start as u64 - 1),
59-
lsp_types::Position::new(span.line_end as u64 - 1, span.column_end as u64 - 1),
58+
lsp_types::Position::new(span.line_start as u32 - 1, span.column_start as u32 - 1),
59+
lsp_types::Position::new(span.line_end as u32 - 1, span.column_end as u32 - 1),
6060
);
6161

6262
lsp_types::Location { uri, range }

crates/rust-analyzer/src/document.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
/// client notifications.
77
#[derive(Debug, Clone)]
88
pub(crate) struct DocumentData {
9-
pub(crate) version: Option<i64>,
9+
pub(crate) version: i32,
1010
}
1111

1212
impl DocumentData {
13-
pub(crate) fn new(version: i64) -> Self {
14-
DocumentData { version: Some(version) }
13+
pub(crate) fn new(version: i32) -> Self {
14+
DocumentData { version }
1515
}
1616
}

crates/rust-analyzer/src/global_state.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,9 @@ impl GlobalStateSnapshot {
263263
self.vfs.read().1[&id]
264264
}
265265

266-
pub(crate) fn url_file_version(&self, url: &Url) -> Option<i64> {
266+
pub(crate) fn url_file_version(&self, url: &Url) -> Option<i32> {
267267
let path = from_proto::vfs_path(&url).ok()?;
268-
self.mem_docs.get(&path)?.version
268+
Some(self.mem_docs.get(&path)?.version)
269269
}
270270

271271
pub(crate) fn anchored_path(&self, file_id: FileId, path: &str) -> Url {

crates/rust-analyzer/src/lsp_ext.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ pub enum SnippetDocumentChangeOperation {
302302
#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
303303
#[serde(rename_all = "camelCase")]
304304
pub struct SnippetTextDocumentEdit {
305-
pub text_document: lsp_types::VersionedTextDocumentIdentifier,
305+
pub text_document: lsp_types::OptionalVersionedTextDocumentIdentifier,
306306
pub edits: Vec<SnippetTextEdit>,
307307
}
308308

crates/rust-analyzer/src/lsp_utils.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl GlobalState {
5151
}
5252
let percentage = fraction.map(|f| {
5353
assert!(0.0 <= f && f <= 1.0);
54-
f * 100.0
54+
(f * 100.0) as u32
5555
});
5656
let token = lsp_types::ProgressToken::String(format!("rustAnalyzer/{}", title));
5757
let work_done_progress = match state {
@@ -98,11 +98,11 @@ pub(crate) fn apply_document_changes(
9898
// The VFS will normalize the end of lines to `\n`.
9999
enum IndexValid {
100100
All,
101-
UpToLineExclusive(u64),
101+
UpToLineExclusive(u32),
102102
}
103103

104104
impl IndexValid {
105-
fn covers(&self, line: u64) -> bool {
105+
fn covers(&self, line: u32) -> bool {
106106
match *self {
107107
IndexValid::UpToLineExclusive(to) => to > line,
108108
_ => true,

crates/rust-analyzer/src/main_loop.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ impl GlobalState {
368368
let url = file_id_to_url(&self.vfs.read().0, file_id);
369369
let diagnostics = self.diagnostics.diagnostics_for(file_id).cloned().collect();
370370
let version = from_proto::vfs_path(&url)
371-
.map(|path| self.mem_docs.get(&path)?.version)
371+
.map(|path| self.mem_docs.get(&path).map(|it| it.version))
372372
.unwrap_or_default();
373373

374374
self.send_notification::<lsp_types::notification::PublishDiagnostics>(
@@ -521,7 +521,7 @@ impl GlobalState {
521521
let mut version = None;
522522
if let Ok(path) = from_proto::vfs_path(&params.text_document.uri) {
523523
match this.mem_docs.remove(&path) {
524-
Some(doc) => version = doc.version,
524+
Some(doc) => version = Some(doc.version),
525525
None => log::error!("orphan DidCloseTextDocument: {}", path),
526526
}
527527

crates/rust-analyzer/src/to_proto.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ use crate::{
2121

2222
pub(crate) fn position(line_index: &LineIndex, offset: TextSize) -> lsp_types::Position {
2323
let line_col = line_index.line_col(offset);
24-
let line = u64::from(line_col.line);
25-
let character = u64::from(line_col.col_utf16);
26-
lsp_types::Position::new(line, character)
24+
lsp_types::Position::new(line_col.line, line_col.col_utf16)
2725
}
2826

2927
pub(crate) fn range(line_index: &LineIndex, range: TextRange) -> lsp_types::Range {
@@ -278,9 +276,9 @@ pub(crate) fn signature_help(
278276
label.push_str(", ");
279277
}
280278
first = false;
281-
let start = label.len() as u64;
279+
let start = label.len() as u32;
282280
label.push_str(param);
283-
let end = label.len() as u64;
281+
let end = label.len() as u32;
284282
params.push(lsp_types::ParameterInformation {
285283
label: lsp_types::ParameterLabel::LabelOffsets([start, end]),
286284
documentation: None,
@@ -302,7 +300,7 @@ pub(crate) fn signature_help(
302300
})
303301
};
304302

305-
let active_parameter = call_info.active_parameter.map(|it| it as i64);
303+
let active_parameter = call_info.active_parameter.map(|it| it as u32);
306304

307305
let signature = lsp_types::SignatureInformation {
308306
label,
@@ -518,13 +516,13 @@ pub(crate) fn url_from_abs_path(path: &Path) -> lsp_types::Url {
518516
lsp_types::Url::parse(&url).unwrap()
519517
}
520518

521-
pub(crate) fn versioned_text_document_identifier(
519+
pub(crate) fn optional_versioned_text_document_identifier(
522520
snap: &GlobalStateSnapshot,
523521
file_id: FileId,
524-
) -> lsp_types::VersionedTextDocumentIdentifier {
522+
) -> lsp_types::OptionalVersionedTextDocumentIdentifier {
525523
let url = url(snap, file_id);
526524
let version = snap.url_file_version(&url);
527-
lsp_types::VersionedTextDocumentIdentifier { uri: url, version }
525+
lsp_types::OptionalVersionedTextDocumentIdentifier { uri: url, version }
528526
}
529527

530528
pub(crate) fn location(
@@ -613,7 +611,7 @@ pub(crate) fn snippet_text_document_edit(
613611
is_snippet: bool,
614612
source_file_edit: SourceFileEdit,
615613
) -> Result<lsp_ext::SnippetTextDocumentEdit> {
616-
let text_document = versioned_text_document_identifier(snap, source_file_edit.file_id);
614+
let text_document = optional_versioned_text_document_identifier(snap, source_file_edit.file_id);
617615
let line_index = snap.analysis.file_line_index(source_file_edit.file_id)?;
618616
let line_endings = snap.file_line_endings(source_file_edit.file_id);
619617
let edits = source_file_edit

0 commit comments

Comments
 (0)