mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-25 20:43:21 +00:00
Pull in new lsp-types for VS compat
This commit is contained in:
parent
91cbda43c2
commit
edb03ad6f1
8 changed files with 81 additions and 76 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -865,9 +865,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "lsp-types"
|
||||
version = "0.90.1"
|
||||
version = "0.91.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6f3734ab1d7d157fc0c45110e06b587c31cd82bea2ccfd6b563cbff0aaeeb1d3"
|
||||
checksum = "be7801b458592d0998af808d97f6a85a6057af3aaf2a2a5c3c677702bbeb4ed7"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"serde",
|
||||
|
|
|
@ -22,7 +22,7 @@ crossbeam-channel = "0.5.0"
|
|||
dissimilar = "1.0.2"
|
||||
itertools = "0.10.0"
|
||||
jod-thread = "0.1.0"
|
||||
lsp-types = { version = "0.90.1", features = ["proposed"] }
|
||||
lsp-types = { version = "0.91", features = ["proposed"] }
|
||||
parking_lot = "0.11.0"
|
||||
xflags = "0.2.1"
|
||||
oorandom = "11.1.2"
|
||||
|
@ -34,7 +34,12 @@ rayon = "1.5"
|
|||
mimalloc = { version = "0.1.19", default-features = false, optional = true }
|
||||
lsp-server = "0.5.1"
|
||||
tracing = "0.1"
|
||||
tracing-subscriber = { version = "0.2", default-features = false, features = ["env-filter", "registry", "fmt", "tracing-log"] }
|
||||
tracing-subscriber = { version = "0.2", default-features = false, features = [
|
||||
"env-filter",
|
||||
"registry",
|
||||
"fmt",
|
||||
"tracing-log",
|
||||
] }
|
||||
tracing-log = "0.1.2"
|
||||
tracing-tree = { version = "0.1.10" }
|
||||
always-assert = "0.1"
|
||||
|
|
|
@ -20,7 +20,7 @@ pub fn server_capabilities(config: &Config) -> ServerCapabilities {
|
|||
ServerCapabilities {
|
||||
text_document_sync: Some(TextDocumentSyncCapability::Options(TextDocumentSyncOptions {
|
||||
open_close: Some(true),
|
||||
change: Some(TextDocumentSyncKind::Incremental),
|
||||
change: Some(TextDocumentSyncKind::INCREMENTAL),
|
||||
will_save: None,
|
||||
will_save_wait_until: None,
|
||||
save: Some(SaveOptions::default().into()),
|
||||
|
|
|
@ -18,19 +18,19 @@ fn diagnostic_severity(
|
|||
code: Option<flycheck::DiagnosticCode>,
|
||||
) -> Option<lsp_types::DiagnosticSeverity> {
|
||||
let res = match level {
|
||||
DiagnosticLevel::Ice => lsp_types::DiagnosticSeverity::Error,
|
||||
DiagnosticLevel::Error => lsp_types::DiagnosticSeverity::Error,
|
||||
DiagnosticLevel::Ice => lsp_types::DiagnosticSeverity::ERROR,
|
||||
DiagnosticLevel::Error => lsp_types::DiagnosticSeverity::ERROR,
|
||||
DiagnosticLevel::Warning => match &code {
|
||||
Some(code) if config.warnings_as_hint.contains(&code.code) => {
|
||||
lsp_types::DiagnosticSeverity::Hint
|
||||
lsp_types::DiagnosticSeverity::HINT
|
||||
}
|
||||
Some(code) if config.warnings_as_info.contains(&code.code) => {
|
||||
lsp_types::DiagnosticSeverity::Information
|
||||
lsp_types::DiagnosticSeverity::INFORMATION
|
||||
}
|
||||
_ => lsp_types::DiagnosticSeverity::Warning,
|
||||
_ => lsp_types::DiagnosticSeverity::WARNING,
|
||||
},
|
||||
DiagnosticLevel::Note => lsp_types::DiagnosticSeverity::Information,
|
||||
DiagnosticLevel::Help => lsp_types::DiagnosticSeverity::Hint,
|
||||
DiagnosticLevel::Note => lsp_types::DiagnosticSeverity::INFORMATION,
|
||||
DiagnosticLevel::Help => lsp_types::DiagnosticSeverity::HINT,
|
||||
_ => return None,
|
||||
};
|
||||
Some(res)
|
||||
|
@ -268,11 +268,11 @@ pub(crate) fn map_rust_diagnostic_to_lsp(
|
|||
| "unused_macros"
|
||||
| "unused_variables"
|
||||
) {
|
||||
tags.push(lsp_types::DiagnosticTag::Unnecessary);
|
||||
tags.push(lsp_types::DiagnosticTag::UNNECESSARY);
|
||||
}
|
||||
|
||||
if matches!(code, "deprecated") {
|
||||
tags.push(lsp_types::DiagnosticTag::Deprecated);
|
||||
tags.push(lsp_types::DiagnosticTag::DEPRECATED);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -337,7 +337,7 @@ pub(crate) fn map_rust_diagnostic_to_lsp(
|
|||
let diagnostic = lsp_types::Diagnostic {
|
||||
range: secondary_location.range,
|
||||
// downgrade to hint if we're pointing at the macro
|
||||
severity: Some(lsp_types::DiagnosticSeverity::Hint),
|
||||
severity: Some(lsp_types::DiagnosticSeverity::HINT),
|
||||
code: code.clone().map(lsp_types::NumberOrString::String),
|
||||
code_description: code_description.clone(),
|
||||
source: Some(source.clone()),
|
||||
|
@ -398,7 +398,7 @@ pub(crate) fn map_rust_diagnostic_to_lsp(
|
|||
fixes: sub.suggested_fix.iter().cloned().collect(),
|
||||
diagnostic: lsp_types::Diagnostic {
|
||||
range: sub.related.location.range,
|
||||
severity: Some(lsp_types::DiagnosticSeverity::Hint),
|
||||
severity: Some(lsp_types::DiagnosticSeverity::HINT),
|
||||
code: code.clone().map(lsp_types::NumberOrString::String),
|
||||
code_description: code_description.clone(),
|
||||
source: Some(source.clone()),
|
||||
|
|
|
@ -311,7 +311,7 @@ pub(crate) fn handle_document_symbol(
|
|||
for symbol in snap.analysis.file_structure(file_id)? {
|
||||
let mut tags = Vec::new();
|
||||
if symbol.deprecated {
|
||||
tags.push(SymbolTag::Deprecated)
|
||||
tags.push(SymbolTag::DEPRECATED)
|
||||
};
|
||||
|
||||
#[allow(deprecated)]
|
||||
|
@ -368,7 +368,7 @@ pub(crate) fn handle_document_symbol(
|
|||
|
||||
#[allow(deprecated)]
|
||||
if let Some(true) = symbol.deprecated {
|
||||
tags.push(SymbolTag::Deprecated)
|
||||
tags.push(SymbolTag::DEPRECATED)
|
||||
}
|
||||
|
||||
#[allow(deprecated)]
|
||||
|
@ -464,7 +464,7 @@ pub(crate) fn handle_workspace_symbol(
|
|||
kind: nav
|
||||
.kind
|
||||
.map(to_proto::symbol_kind)
|
||||
.unwrap_or(lsp_types::SymbolKind::Variable),
|
||||
.unwrap_or(lsp_types::SymbolKind::VARIABLE),
|
||||
tags: None,
|
||||
location: to_proto::location_from_nav(snap, nav)?,
|
||||
container_name,
|
||||
|
@ -1294,7 +1294,7 @@ pub(crate) fn publish_diagnostics(
|
|||
source: Some("rust-analyzer".to_string()),
|
||||
message: d.message,
|
||||
related_information: None,
|
||||
tags: if d.unused { Some(vec![DiagnosticTag::Unnecessary]) } else { None },
|
||||
tags: if d.unused { Some(vec![DiagnosticTag::UNNECESSARY]) } else { None },
|
||||
data: None,
|
||||
})
|
||||
.collect();
|
||||
|
|
|
@ -62,7 +62,7 @@ impl GlobalState {
|
|||
let from_source_build = env!("REV").contains("dev");
|
||||
let profiling_enabled = std::env::var("RA_PROFILE").is_ok();
|
||||
if from_source_build || profiling_enabled {
|
||||
self.show_message(lsp_types::MessageType::Error, message)
|
||||
self.show_message(lsp_types::MessageType::ERROR, message)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ impl GlobalState {
|
|||
&& self.config.notifications().cargo_toml_not_found
|
||||
{
|
||||
self.show_message(
|
||||
lsp_types::MessageType::Error,
|
||||
lsp_types::MessageType::ERROR,
|
||||
"rust-analyzer failed to discover workspace".to_string(),
|
||||
);
|
||||
};
|
||||
|
@ -395,7 +395,7 @@ impl GlobalState {
|
|||
flycheck::Progress::DidFinish(result) => {
|
||||
if let Err(err) = result {
|
||||
self.show_message(
|
||||
lsp_types::MessageType::Error,
|
||||
lsp_types::MessageType::ERROR,
|
||||
format!("cargo check failed: {}", err),
|
||||
);
|
||||
}
|
||||
|
@ -509,7 +509,7 @@ impl GlobalState {
|
|||
self.last_reported_status = Some(status.clone());
|
||||
|
||||
if let (lsp_ext::Health::Error, Some(message)) = (status.health, &status.message) {
|
||||
self.show_message(lsp_types::MessageType::Error, message.clone());
|
||||
self.show_message(lsp_types::MessageType::ERROR, message.clone());
|
||||
}
|
||||
|
||||
if self.config.server_status_notification() {
|
||||
|
|
|
@ -45,32 +45,32 @@ pub(crate) fn range(line_index: &LineIndex, range: TextRange) -> lsp_types::Rang
|
|||
|
||||
pub(crate) fn symbol_kind(symbol_kind: SymbolKind) -> lsp_types::SymbolKind {
|
||||
match symbol_kind {
|
||||
SymbolKind::Function => lsp_types::SymbolKind::Function,
|
||||
SymbolKind::Struct => lsp_types::SymbolKind::Struct,
|
||||
SymbolKind::Enum => lsp_types::SymbolKind::Enum,
|
||||
SymbolKind::Variant => lsp_types::SymbolKind::EnumMember,
|
||||
SymbolKind::Trait => lsp_types::SymbolKind::Interface,
|
||||
SymbolKind::Macro => lsp_types::SymbolKind::Function,
|
||||
SymbolKind::Module => lsp_types::SymbolKind::Module,
|
||||
SymbolKind::TypeAlias | SymbolKind::TypeParam => lsp_types::SymbolKind::TypeParameter,
|
||||
SymbolKind::Field => lsp_types::SymbolKind::Field,
|
||||
SymbolKind::Static => lsp_types::SymbolKind::Constant,
|
||||
SymbolKind::Const => lsp_types::SymbolKind::Constant,
|
||||
SymbolKind::ConstParam => lsp_types::SymbolKind::Constant,
|
||||
SymbolKind::Impl => lsp_types::SymbolKind::Object,
|
||||
SymbolKind::Function => lsp_types::SymbolKind::FUNCTION,
|
||||
SymbolKind::Struct => lsp_types::SymbolKind::STRUCT,
|
||||
SymbolKind::Enum => lsp_types::SymbolKind::ENUM,
|
||||
SymbolKind::Variant => lsp_types::SymbolKind::ENUM_MEMBER,
|
||||
SymbolKind::Trait => lsp_types::SymbolKind::INTERFACE,
|
||||
SymbolKind::Macro => lsp_types::SymbolKind::FUNCTION,
|
||||
SymbolKind::Module => lsp_types::SymbolKind::MODULE,
|
||||
SymbolKind::TypeAlias | SymbolKind::TypeParam => lsp_types::SymbolKind::TYPE_PARAMETER,
|
||||
SymbolKind::Field => lsp_types::SymbolKind::FIELD,
|
||||
SymbolKind::Static => lsp_types::SymbolKind::CONSTANT,
|
||||
SymbolKind::Const => lsp_types::SymbolKind::CONSTANT,
|
||||
SymbolKind::ConstParam => lsp_types::SymbolKind::CONSTANT,
|
||||
SymbolKind::Impl => lsp_types::SymbolKind::OBJECT,
|
||||
SymbolKind::Local
|
||||
| SymbolKind::SelfParam
|
||||
| SymbolKind::LifetimeParam
|
||||
| SymbolKind::ValueParam
|
||||
| SymbolKind::Label => lsp_types::SymbolKind::Variable,
|
||||
SymbolKind::Union => lsp_types::SymbolKind::Struct,
|
||||
| SymbolKind::Label => lsp_types::SymbolKind::VARIABLE,
|
||||
SymbolKind::Union => lsp_types::SymbolKind::STRUCT,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn structure_node_kind(kind: StructureNodeKind) -> lsp_types::SymbolKind {
|
||||
match kind {
|
||||
StructureNodeKind::SymbolKind(symbol) => symbol_kind(symbol),
|
||||
StructureNodeKind::Region => lsp_types::SymbolKind::Namespace,
|
||||
StructureNodeKind::Region => lsp_types::SymbolKind::NAMESPACE,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,15 +78,15 @@ pub(crate) fn document_highlight_kind(
|
|||
category: ReferenceCategory,
|
||||
) -> lsp_types::DocumentHighlightKind {
|
||||
match category {
|
||||
ReferenceCategory::Read => lsp_types::DocumentHighlightKind::Read,
|
||||
ReferenceCategory::Write => lsp_types::DocumentHighlightKind::Write,
|
||||
ReferenceCategory::Read => lsp_types::DocumentHighlightKind::READ,
|
||||
ReferenceCategory::Write => lsp_types::DocumentHighlightKind::WRITE,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn diagnostic_severity(severity: Severity) -> lsp_types::DiagnosticSeverity {
|
||||
match severity {
|
||||
Severity::Error => lsp_types::DiagnosticSeverity::Error,
|
||||
Severity::WeakWarning => lsp_types::DiagnosticSeverity::Hint,
|
||||
Severity::Error => lsp_types::DiagnosticSeverity::ERROR,
|
||||
Severity::WeakWarning => lsp_types::DiagnosticSeverity::HINT,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,34 +100,34 @@ pub(crate) fn completion_item_kind(
|
|||
completion_item_kind: CompletionItemKind,
|
||||
) -> lsp_types::CompletionItemKind {
|
||||
match completion_item_kind {
|
||||
CompletionItemKind::Attribute => lsp_types::CompletionItemKind::EnumMember,
|
||||
CompletionItemKind::Binding => lsp_types::CompletionItemKind::Variable,
|
||||
CompletionItemKind::BuiltinType => lsp_types::CompletionItemKind::Struct,
|
||||
CompletionItemKind::Keyword => lsp_types::CompletionItemKind::Keyword,
|
||||
CompletionItemKind::Method => lsp_types::CompletionItemKind::Method,
|
||||
CompletionItemKind::Snippet => lsp_types::CompletionItemKind::Snippet,
|
||||
CompletionItemKind::UnresolvedReference => lsp_types::CompletionItemKind::Reference,
|
||||
CompletionItemKind::Attribute => lsp_types::CompletionItemKind::ENUM_MEMBER,
|
||||
CompletionItemKind::Binding => lsp_types::CompletionItemKind::VARIABLE,
|
||||
CompletionItemKind::BuiltinType => lsp_types::CompletionItemKind::STRUCT,
|
||||
CompletionItemKind::Keyword => lsp_types::CompletionItemKind::KEYWORD,
|
||||
CompletionItemKind::Method => lsp_types::CompletionItemKind::METHOD,
|
||||
CompletionItemKind::Snippet => lsp_types::CompletionItemKind::SNIPPET,
|
||||
CompletionItemKind::UnresolvedReference => lsp_types::CompletionItemKind::REFERENCE,
|
||||
CompletionItemKind::SymbolKind(symbol) => match symbol {
|
||||
SymbolKind::Const => lsp_types::CompletionItemKind::Constant,
|
||||
SymbolKind::ConstParam => lsp_types::CompletionItemKind::TypeParameter,
|
||||
SymbolKind::Enum => lsp_types::CompletionItemKind::Enum,
|
||||
SymbolKind::Field => lsp_types::CompletionItemKind::Field,
|
||||
SymbolKind::Function => lsp_types::CompletionItemKind::Function,
|
||||
SymbolKind::Impl => lsp_types::CompletionItemKind::Text,
|
||||
SymbolKind::Label => lsp_types::CompletionItemKind::Variable,
|
||||
SymbolKind::LifetimeParam => lsp_types::CompletionItemKind::TypeParameter,
|
||||
SymbolKind::Local => lsp_types::CompletionItemKind::Variable,
|
||||
SymbolKind::Macro => lsp_types::CompletionItemKind::Method,
|
||||
SymbolKind::Module => lsp_types::CompletionItemKind::Module,
|
||||
SymbolKind::SelfParam => lsp_types::CompletionItemKind::Value,
|
||||
SymbolKind::Static => lsp_types::CompletionItemKind::Value,
|
||||
SymbolKind::Struct => lsp_types::CompletionItemKind::Struct,
|
||||
SymbolKind::Trait => lsp_types::CompletionItemKind::Interface,
|
||||
SymbolKind::TypeAlias => lsp_types::CompletionItemKind::Struct,
|
||||
SymbolKind::TypeParam => lsp_types::CompletionItemKind::TypeParameter,
|
||||
SymbolKind::Union => lsp_types::CompletionItemKind::Struct,
|
||||
SymbolKind::ValueParam => lsp_types::CompletionItemKind::Value,
|
||||
SymbolKind::Variant => lsp_types::CompletionItemKind::EnumMember,
|
||||
SymbolKind::Const => lsp_types::CompletionItemKind::CONSTANT,
|
||||
SymbolKind::ConstParam => lsp_types::CompletionItemKind::TYPE_PARAMETER,
|
||||
SymbolKind::Enum => lsp_types::CompletionItemKind::ENUM,
|
||||
SymbolKind::Field => lsp_types::CompletionItemKind::FIELD,
|
||||
SymbolKind::Function => lsp_types::CompletionItemKind::FUNCTION,
|
||||
SymbolKind::Impl => lsp_types::CompletionItemKind::TEXT,
|
||||
SymbolKind::Label => lsp_types::CompletionItemKind::VARIABLE,
|
||||
SymbolKind::LifetimeParam => lsp_types::CompletionItemKind::TYPE_PARAMETER,
|
||||
SymbolKind::Local => lsp_types::CompletionItemKind::VARIABLE,
|
||||
SymbolKind::Macro => lsp_types::CompletionItemKind::METHOD,
|
||||
SymbolKind::Module => lsp_types::CompletionItemKind::MODULE,
|
||||
SymbolKind::SelfParam => lsp_types::CompletionItemKind::VALUE,
|
||||
SymbolKind::Static => lsp_types::CompletionItemKind::VALUE,
|
||||
SymbolKind::Struct => lsp_types::CompletionItemKind::STRUCT,
|
||||
SymbolKind::Trait => lsp_types::CompletionItemKind::INTERFACE,
|
||||
SymbolKind::TypeAlias => lsp_types::CompletionItemKind::STRUCT,
|
||||
SymbolKind::TypeParam => lsp_types::CompletionItemKind::TYPE_PARAMETER,
|
||||
SymbolKind::Union => lsp_types::CompletionItemKind::STRUCT,
|
||||
SymbolKind::ValueParam => lsp_types::CompletionItemKind::VALUE,
|
||||
SymbolKind::Variant => lsp_types::CompletionItemKind::ENUM_MEMBER,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ pub(crate) fn snippet_text_edit(
|
|||
) -> lsp_ext::SnippetTextEdit {
|
||||
let text_edit = text_edit(line_index, indel);
|
||||
let insert_text_format =
|
||||
if is_snippet { Some(lsp_types::InsertTextFormat::Snippet) } else { None };
|
||||
if is_snippet { Some(lsp_types::InsertTextFormat::SNIPPET) } else { None };
|
||||
lsp_ext::SnippetTextEdit {
|
||||
range: text_edit.range,
|
||||
new_text: text_edit.new_text,
|
||||
|
@ -259,7 +259,7 @@ fn completion_item(
|
|||
set_score(&mut lsp_item, max_relevance, item.relevance());
|
||||
|
||||
if item.deprecated() {
|
||||
lsp_item.tags = Some(vec![lsp_types::CompletionItemTag::Deprecated])
|
||||
lsp_item.tags = Some(vec![lsp_types::CompletionItemTag::DEPRECATED])
|
||||
}
|
||||
|
||||
if item.trigger_call_info() && config.client_commands().trigger_parameter_hints {
|
||||
|
@ -267,7 +267,7 @@ fn completion_item(
|
|||
}
|
||||
|
||||
if item.is_snippet() {
|
||||
lsp_item.insert_text_format = Some(lsp_types::InsertTextFormat::Snippet);
|
||||
lsp_item.insert_text_format = Some(lsp_types::InsertTextFormat::SNIPPET);
|
||||
}
|
||||
if config.completion().enable_imports_on_the_fly {
|
||||
if let imports @ [_, ..] = item.imports_to_add() {
|
||||
|
@ -786,7 +786,7 @@ pub(crate) fn snippet_text_document_ops(
|
|||
let text_edit = lsp_ext::SnippetTextEdit {
|
||||
range: lsp_types::Range::default(),
|
||||
new_text: initial_contents,
|
||||
insert_text_format: Some(lsp_types::InsertTextFormat::PlainText),
|
||||
insert_text_format: Some(lsp_types::InsertTextFormat::PLAIN_TEXT),
|
||||
annotation_id: None,
|
||||
};
|
||||
let edit_file =
|
||||
|
@ -908,7 +908,7 @@ pub(crate) fn call_hierarchy_item(
|
|||
) -> Result<lsp_types::CallHierarchyItem> {
|
||||
let name = target.name.to_string();
|
||||
let detail = target.description.clone();
|
||||
let kind = target.kind.map(symbol_kind).unwrap_or(lsp_types::SymbolKind::Function);
|
||||
let kind = target.kind.map(symbol_kind).unwrap_or(lsp_types::SymbolKind::FUNCTION);
|
||||
let (uri, range, selection_range) = location_info(snap, target)?;
|
||||
Ok(lsp_types::CallHierarchyItem {
|
||||
name,
|
||||
|
|
Loading…
Reference in a new issue