Skip to content

Commit edb03ad

Browse files
committed
Pull in new lsp-types for VS compat
1 parent 91cbda4 commit edb03ad

File tree

8 files changed

+81
-76
lines changed

8 files changed

+81
-76
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.

crates/rust-analyzer/Cargo.toml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ crossbeam-channel = "0.5.0"
2222
dissimilar = "1.0.2"
2323
itertools = "0.10.0"
2424
jod-thread = "0.1.0"
25-
lsp-types = { version = "0.90.1", features = ["proposed"] }
25+
lsp-types = { version = "0.91", features = ["proposed"] }
2626
parking_lot = "0.11.0"
2727
xflags = "0.2.1"
2828
oorandom = "11.1.2"
@@ -34,7 +34,12 @@ rayon = "1.5"
3434
mimalloc = { version = "0.1.19", default-features = false, optional = true }
3535
lsp-server = "0.5.1"
3636
tracing = "0.1"
37-
tracing-subscriber = { version = "0.2", default-features = false, features = ["env-filter", "registry", "fmt", "tracing-log"] }
37+
tracing-subscriber = { version = "0.2", default-features = false, features = [
38+
"env-filter",
39+
"registry",
40+
"fmt",
41+
"tracing-log",
42+
] }
3843
tracing-log = "0.1.2"
3944
tracing-tree = { version = "0.1.10" }
4045
always-assert = "0.1"

crates/rust-analyzer/src/caps.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub fn server_capabilities(config: &Config) -> ServerCapabilities {
2020
ServerCapabilities {
2121
text_document_sync: Some(TextDocumentSyncCapability::Options(TextDocumentSyncOptions {
2222
open_close: Some(true),
23-
change: Some(TextDocumentSyncKind::Incremental),
23+
change: Some(TextDocumentSyncKind::INCREMENTAL),
2424
will_save: None,
2525
will_save_wait_until: None,
2626
save: Some(SaveOptions::default().into()),

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,19 @@ fn diagnostic_severity(
1818
code: Option<flycheck::DiagnosticCode>,
1919
) -> Option<lsp_types::DiagnosticSeverity> {
2020
let res = match level {
21-
DiagnosticLevel::Ice => lsp_types::DiagnosticSeverity::Error,
22-
DiagnosticLevel::Error => lsp_types::DiagnosticSeverity::Error,
21+
DiagnosticLevel::Ice => lsp_types::DiagnosticSeverity::ERROR,
22+
DiagnosticLevel::Error => lsp_types::DiagnosticSeverity::ERROR,
2323
DiagnosticLevel::Warning => match &code {
2424
Some(code) if config.warnings_as_hint.contains(&code.code) => {
25-
lsp_types::DiagnosticSeverity::Hint
25+
lsp_types::DiagnosticSeverity::HINT
2626
}
2727
Some(code) if config.warnings_as_info.contains(&code.code) => {
28-
lsp_types::DiagnosticSeverity::Information
28+
lsp_types::DiagnosticSeverity::INFORMATION
2929
}
30-
_ => lsp_types::DiagnosticSeverity::Warning,
30+
_ => lsp_types::DiagnosticSeverity::WARNING,
3131
},
32-
DiagnosticLevel::Note => lsp_types::DiagnosticSeverity::Information,
33-
DiagnosticLevel::Help => lsp_types::DiagnosticSeverity::Hint,
32+
DiagnosticLevel::Note => lsp_types::DiagnosticSeverity::INFORMATION,
33+
DiagnosticLevel::Help => lsp_types::DiagnosticSeverity::HINT,
3434
_ => return None,
3535
};
3636
Some(res)
@@ -268,11 +268,11 @@ pub(crate) fn map_rust_diagnostic_to_lsp(
268268
| "unused_macros"
269269
| "unused_variables"
270270
) {
271-
tags.push(lsp_types::DiagnosticTag::Unnecessary);
271+
tags.push(lsp_types::DiagnosticTag::UNNECESSARY);
272272
}
273273

274274
if matches!(code, "deprecated") {
275-
tags.push(lsp_types::DiagnosticTag::Deprecated);
275+
tags.push(lsp_types::DiagnosticTag::DEPRECATED);
276276
}
277277
}
278278

@@ -337,7 +337,7 @@ pub(crate) fn map_rust_diagnostic_to_lsp(
337337
let diagnostic = lsp_types::Diagnostic {
338338
range: secondary_location.range,
339339
// downgrade to hint if we're pointing at the macro
340-
severity: Some(lsp_types::DiagnosticSeverity::Hint),
340+
severity: Some(lsp_types::DiagnosticSeverity::HINT),
341341
code: code.clone().map(lsp_types::NumberOrString::String),
342342
code_description: code_description.clone(),
343343
source: Some(source.clone()),
@@ -398,7 +398,7 @@ pub(crate) fn map_rust_diagnostic_to_lsp(
398398
fixes: sub.suggested_fix.iter().cloned().collect(),
399399
diagnostic: lsp_types::Diagnostic {
400400
range: sub.related.location.range,
401-
severity: Some(lsp_types::DiagnosticSeverity::Hint),
401+
severity: Some(lsp_types::DiagnosticSeverity::HINT),
402402
code: code.clone().map(lsp_types::NumberOrString::String),
403403
code_description: code_description.clone(),
404404
source: Some(source.clone()),

crates/rust-analyzer/src/handlers.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ pub(crate) fn handle_document_symbol(
311311
for symbol in snap.analysis.file_structure(file_id)? {
312312
let mut tags = Vec::new();
313313
if symbol.deprecated {
314-
tags.push(SymbolTag::Deprecated)
314+
tags.push(SymbolTag::DEPRECATED)
315315
};
316316

317317
#[allow(deprecated)]
@@ -368,7 +368,7 @@ pub(crate) fn handle_document_symbol(
368368

369369
#[allow(deprecated)]
370370
if let Some(true) = symbol.deprecated {
371-
tags.push(SymbolTag::Deprecated)
371+
tags.push(SymbolTag::DEPRECATED)
372372
}
373373

374374
#[allow(deprecated)]
@@ -464,7 +464,7 @@ pub(crate) fn handle_workspace_symbol(
464464
kind: nav
465465
.kind
466466
.map(to_proto::symbol_kind)
467-
.unwrap_or(lsp_types::SymbolKind::Variable),
467+
.unwrap_or(lsp_types::SymbolKind::VARIABLE),
468468
tags: None,
469469
location: to_proto::location_from_nav(snap, nav)?,
470470
container_name,
@@ -1294,7 +1294,7 @@ pub(crate) fn publish_diagnostics(
12941294
source: Some("rust-analyzer".to_string()),
12951295
message: d.message,
12961296
related_information: None,
1297-
tags: if d.unused { Some(vec![DiagnosticTag::Unnecessary]) } else { None },
1297+
tags: if d.unused { Some(vec![DiagnosticTag::UNNECESSARY]) } else { None },
12981298
data: None,
12991299
})
13001300
.collect();

crates/rust-analyzer/src/lsp_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ impl GlobalState {
6262
let from_source_build = env!("REV").contains("dev");
6363
let profiling_enabled = std::env::var("RA_PROFILE").is_ok();
6464
if from_source_build || profiling_enabled {
65-
self.show_message(lsp_types::MessageType::Error, message)
65+
self.show_message(lsp_types::MessageType::ERROR, message)
6666
}
6767
}
6868

crates/rust-analyzer/src/main_loop.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ impl GlobalState {
112112
&& self.config.notifications().cargo_toml_not_found
113113
{
114114
self.show_message(
115-
lsp_types::MessageType::Error,
115+
lsp_types::MessageType::ERROR,
116116
"rust-analyzer failed to discover workspace".to_string(),
117117
);
118118
};
@@ -395,7 +395,7 @@ impl GlobalState {
395395
flycheck::Progress::DidFinish(result) => {
396396
if let Err(err) = result {
397397
self.show_message(
398-
lsp_types::MessageType::Error,
398+
lsp_types::MessageType::ERROR,
399399
format!("cargo check failed: {}", err),
400400
);
401401
}
@@ -509,7 +509,7 @@ impl GlobalState {
509509
self.last_reported_status = Some(status.clone());
510510

511511
if let (lsp_ext::Health::Error, Some(message)) = (status.health, &status.message) {
512-
self.show_message(lsp_types::MessageType::Error, message.clone());
512+
self.show_message(lsp_types::MessageType::ERROR, message.clone());
513513
}
514514

515515
if self.config.server_status_notification() {

crates/rust-analyzer/src/to_proto.rs

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -45,48 +45,48 @@ pub(crate) fn range(line_index: &LineIndex, range: TextRange) -> lsp_types::Rang
4545

4646
pub(crate) fn symbol_kind(symbol_kind: SymbolKind) -> lsp_types::SymbolKind {
4747
match symbol_kind {
48-
SymbolKind::Function => lsp_types::SymbolKind::Function,
49-
SymbolKind::Struct => lsp_types::SymbolKind::Struct,
50-
SymbolKind::Enum => lsp_types::SymbolKind::Enum,
51-
SymbolKind::Variant => lsp_types::SymbolKind::EnumMember,
52-
SymbolKind::Trait => lsp_types::SymbolKind::Interface,
53-
SymbolKind::Macro => lsp_types::SymbolKind::Function,
54-
SymbolKind::Module => lsp_types::SymbolKind::Module,
55-
SymbolKind::TypeAlias | SymbolKind::TypeParam => lsp_types::SymbolKind::TypeParameter,
56-
SymbolKind::Field => lsp_types::SymbolKind::Field,
57-
SymbolKind::Static => lsp_types::SymbolKind::Constant,
58-
SymbolKind::Const => lsp_types::SymbolKind::Constant,
59-
SymbolKind::ConstParam => lsp_types::SymbolKind::Constant,
60-
SymbolKind::Impl => lsp_types::SymbolKind::Object,
48+
SymbolKind::Function => lsp_types::SymbolKind::FUNCTION,
49+
SymbolKind::Struct => lsp_types::SymbolKind::STRUCT,
50+
SymbolKind::Enum => lsp_types::SymbolKind::ENUM,
51+
SymbolKind::Variant => lsp_types::SymbolKind::ENUM_MEMBER,
52+
SymbolKind::Trait => lsp_types::SymbolKind::INTERFACE,
53+
SymbolKind::Macro => lsp_types::SymbolKind::FUNCTION,
54+
SymbolKind::Module => lsp_types::SymbolKind::MODULE,
55+
SymbolKind::TypeAlias | SymbolKind::TypeParam => lsp_types::SymbolKind::TYPE_PARAMETER,
56+
SymbolKind::Field => lsp_types::SymbolKind::FIELD,
57+
SymbolKind::Static => lsp_types::SymbolKind::CONSTANT,
58+
SymbolKind::Const => lsp_types::SymbolKind::CONSTANT,
59+
SymbolKind::ConstParam => lsp_types::SymbolKind::CONSTANT,
60+
SymbolKind::Impl => lsp_types::SymbolKind::OBJECT,
6161
SymbolKind::Local
6262
| SymbolKind::SelfParam
6363
| SymbolKind::LifetimeParam
6464
| SymbolKind::ValueParam
65-
| SymbolKind::Label => lsp_types::SymbolKind::Variable,
66-
SymbolKind::Union => lsp_types::SymbolKind::Struct,
65+
| SymbolKind::Label => lsp_types::SymbolKind::VARIABLE,
66+
SymbolKind::Union => lsp_types::SymbolKind::STRUCT,
6767
}
6868
}
6969

7070
pub(crate) fn structure_node_kind(kind: StructureNodeKind) -> lsp_types::SymbolKind {
7171
match kind {
7272
StructureNodeKind::SymbolKind(symbol) => symbol_kind(symbol),
73-
StructureNodeKind::Region => lsp_types::SymbolKind::Namespace,
73+
StructureNodeKind::Region => lsp_types::SymbolKind::NAMESPACE,
7474
}
7575
}
7676

7777
pub(crate) fn document_highlight_kind(
7878
category: ReferenceCategory,
7979
) -> lsp_types::DocumentHighlightKind {
8080
match category {
81-
ReferenceCategory::Read => lsp_types::DocumentHighlightKind::Read,
82-
ReferenceCategory::Write => lsp_types::DocumentHighlightKind::Write,
81+
ReferenceCategory::Read => lsp_types::DocumentHighlightKind::READ,
82+
ReferenceCategory::Write => lsp_types::DocumentHighlightKind::WRITE,
8383
}
8484
}
8585

8686
pub(crate) fn diagnostic_severity(severity: Severity) -> lsp_types::DiagnosticSeverity {
8787
match severity {
88-
Severity::Error => lsp_types::DiagnosticSeverity::Error,
89-
Severity::WeakWarning => lsp_types::DiagnosticSeverity::Hint,
88+
Severity::Error => lsp_types::DiagnosticSeverity::ERROR,
89+
Severity::WeakWarning => lsp_types::DiagnosticSeverity::HINT,
9090
}
9191
}
9292

@@ -100,34 +100,34 @@ pub(crate) fn completion_item_kind(
100100
completion_item_kind: CompletionItemKind,
101101
) -> lsp_types::CompletionItemKind {
102102
match completion_item_kind {
103-
CompletionItemKind::Attribute => lsp_types::CompletionItemKind::EnumMember,
104-
CompletionItemKind::Binding => lsp_types::CompletionItemKind::Variable,
105-
CompletionItemKind::BuiltinType => lsp_types::CompletionItemKind::Struct,
106-
CompletionItemKind::Keyword => lsp_types::CompletionItemKind::Keyword,
107-
CompletionItemKind::Method => lsp_types::CompletionItemKind::Method,
108-
CompletionItemKind::Snippet => lsp_types::CompletionItemKind::Snippet,
109-
CompletionItemKind::UnresolvedReference => lsp_types::CompletionItemKind::Reference,
103+
CompletionItemKind::Attribute => lsp_types::CompletionItemKind::ENUM_MEMBER,
104+
CompletionItemKind::Binding => lsp_types::CompletionItemKind::VARIABLE,
105+
CompletionItemKind::BuiltinType => lsp_types::CompletionItemKind::STRUCT,
106+
CompletionItemKind::Keyword => lsp_types::CompletionItemKind::KEYWORD,
107+
CompletionItemKind::Method => lsp_types::CompletionItemKind::METHOD,
108+
CompletionItemKind::Snippet => lsp_types::CompletionItemKind::SNIPPET,
109+
CompletionItemKind::UnresolvedReference => lsp_types::CompletionItemKind::REFERENCE,
110110
CompletionItemKind::SymbolKind(symbol) => match symbol {
111-
SymbolKind::Const => lsp_types::CompletionItemKind::Constant,
112-
SymbolKind::ConstParam => lsp_types::CompletionItemKind::TypeParameter,
113-
SymbolKind::Enum => lsp_types::CompletionItemKind::Enum,
114-
SymbolKind::Field => lsp_types::CompletionItemKind::Field,
115-
SymbolKind::Function => lsp_types::CompletionItemKind::Function,
116-
SymbolKind::Impl => lsp_types::CompletionItemKind::Text,
117-
SymbolKind::Label => lsp_types::CompletionItemKind::Variable,
118-
SymbolKind::LifetimeParam => lsp_types::CompletionItemKind::TypeParameter,
119-
SymbolKind::Local => lsp_types::CompletionItemKind::Variable,
120-
SymbolKind::Macro => lsp_types::CompletionItemKind::Method,
121-
SymbolKind::Module => lsp_types::CompletionItemKind::Module,
122-
SymbolKind::SelfParam => lsp_types::CompletionItemKind::Value,
123-
SymbolKind::Static => lsp_types::CompletionItemKind::Value,
124-
SymbolKind::Struct => lsp_types::CompletionItemKind::Struct,
125-
SymbolKind::Trait => lsp_types::CompletionItemKind::Interface,
126-
SymbolKind::TypeAlias => lsp_types::CompletionItemKind::Struct,
127-
SymbolKind::TypeParam => lsp_types::CompletionItemKind::TypeParameter,
128-
SymbolKind::Union => lsp_types::CompletionItemKind::Struct,
129-
SymbolKind::ValueParam => lsp_types::CompletionItemKind::Value,
130-
SymbolKind::Variant => lsp_types::CompletionItemKind::EnumMember,
111+
SymbolKind::Const => lsp_types::CompletionItemKind::CONSTANT,
112+
SymbolKind::ConstParam => lsp_types::CompletionItemKind::TYPE_PARAMETER,
113+
SymbolKind::Enum => lsp_types::CompletionItemKind::ENUM,
114+
SymbolKind::Field => lsp_types::CompletionItemKind::FIELD,
115+
SymbolKind::Function => lsp_types::CompletionItemKind::FUNCTION,
116+
SymbolKind::Impl => lsp_types::CompletionItemKind::TEXT,
117+
SymbolKind::Label => lsp_types::CompletionItemKind::VARIABLE,
118+
SymbolKind::LifetimeParam => lsp_types::CompletionItemKind::TYPE_PARAMETER,
119+
SymbolKind::Local => lsp_types::CompletionItemKind::VARIABLE,
120+
SymbolKind::Macro => lsp_types::CompletionItemKind::METHOD,
121+
SymbolKind::Module => lsp_types::CompletionItemKind::MODULE,
122+
SymbolKind::SelfParam => lsp_types::CompletionItemKind::VALUE,
123+
SymbolKind::Static => lsp_types::CompletionItemKind::VALUE,
124+
SymbolKind::Struct => lsp_types::CompletionItemKind::STRUCT,
125+
SymbolKind::Trait => lsp_types::CompletionItemKind::INTERFACE,
126+
SymbolKind::TypeAlias => lsp_types::CompletionItemKind::STRUCT,
127+
SymbolKind::TypeParam => lsp_types::CompletionItemKind::TYPE_PARAMETER,
128+
SymbolKind::Union => lsp_types::CompletionItemKind::STRUCT,
129+
SymbolKind::ValueParam => lsp_types::CompletionItemKind::VALUE,
130+
SymbolKind::Variant => lsp_types::CompletionItemKind::ENUM_MEMBER,
131131
},
132132
}
133133
}
@@ -165,7 +165,7 @@ pub(crate) fn snippet_text_edit(
165165
) -> lsp_ext::SnippetTextEdit {
166166
let text_edit = text_edit(line_index, indel);
167167
let insert_text_format =
168-
if is_snippet { Some(lsp_types::InsertTextFormat::Snippet) } else { None };
168+
if is_snippet { Some(lsp_types::InsertTextFormat::SNIPPET) } else { None };
169169
lsp_ext::SnippetTextEdit {
170170
range: text_edit.range,
171171
new_text: text_edit.new_text,
@@ -259,15 +259,15 @@ fn completion_item(
259259
set_score(&mut lsp_item, max_relevance, item.relevance());
260260

261261
if item.deprecated() {
262-
lsp_item.tags = Some(vec![lsp_types::CompletionItemTag::Deprecated])
262+
lsp_item.tags = Some(vec![lsp_types::CompletionItemTag::DEPRECATED])
263263
}
264264

265265
if item.trigger_call_info() && config.client_commands().trigger_parameter_hints {
266266
lsp_item.command = Some(command::trigger_parameter_hints());
267267
}
268268

269269
if item.is_snippet() {
270-
lsp_item.insert_text_format = Some(lsp_types::InsertTextFormat::Snippet);
270+
lsp_item.insert_text_format = Some(lsp_types::InsertTextFormat::SNIPPET);
271271
}
272272
if config.completion().enable_imports_on_the_fly {
273273
if let imports @ [_, ..] = item.imports_to_add() {
@@ -786,7 +786,7 @@ pub(crate) fn snippet_text_document_ops(
786786
let text_edit = lsp_ext::SnippetTextEdit {
787787
range: lsp_types::Range::default(),
788788
new_text: initial_contents,
789-
insert_text_format: Some(lsp_types::InsertTextFormat::PlainText),
789+
insert_text_format: Some(lsp_types::InsertTextFormat::PLAIN_TEXT),
790790
annotation_id: None,
791791
};
792792
let edit_file =
@@ -908,7 +908,7 @@ pub(crate) fn call_hierarchy_item(
908908
) -> Result<lsp_types::CallHierarchyItem> {
909909
let name = target.name.to_string();
910910
let detail = target.description.clone();
911-
let kind = target.kind.map(symbol_kind).unwrap_or(lsp_types::SymbolKind::Function);
911+
let kind = target.kind.map(symbol_kind).unwrap_or(lsp_types::SymbolKind::FUNCTION);
912912
let (uri, range, selection_range) = location_info(snap, target)?;
913913
Ok(lsp_types::CallHierarchyItem {
914914
name,

0 commit comments

Comments
 (0)