1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-24 08:09:08 -05:00

chore: upgrade lspower to 1.4.0 (#12894)

This commit is contained in:
Bartek Iwańczuk 2021-11-25 02:10:12 +01:00 committed by GitHub
parent c6f3493f18
commit e68a241946
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 109 additions and 106 deletions

20
Cargo.lock generated
View file

@ -198,9 +198,9 @@ dependencies = [
[[package]] [[package]]
name = "auto_impl" name = "auto_impl"
version = "0.4.1" version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42cbf586c80ada5e5ccdecae80d3ef0854f224e2dd74435f8d87e6831b8d0a38" checksum = "7862e21c893d65a1650125d157eaeec691439379a1cee17ee49031b79236ada4"
dependencies = [ dependencies = [
"proc-macro-error", "proc-macro-error",
"proc-macro2 1.0.29", "proc-macro2 1.0.29",
@ -2109,9 +2109,9 @@ dependencies = [
[[package]] [[package]]
name = "lsp-types" name = "lsp-types"
version = "0.89.2" version = "0.91.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "852e0dedfd52cc32325598b2631e0eba31b7b708959676a9f837042f276b09a2" checksum = "2368312c59425dd133cb9a327afee65be0a633a8ce471d248e2202a48f8f68ae"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"serde", "serde",
@ -2122,9 +2122,9 @@ dependencies = [
[[package]] [[package]]
name = "lspower" name = "lspower"
version = "1.1.0" version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3167a7555dbacd9ddf3c42eefcc2d4d5e46bb79cd1702bb25d4152bdf537d4b4" checksum = "c713fbfa0f03f0b8286a1e250281350aa07dee40e6ef5c0a4d5a2801146d7a54"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
@ -4113,9 +4113,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
[[package]] [[package]]
name = "tokio" name = "tokio"
version = "1.12.0" version = "1.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2c2416fdedca8443ae44b4527de1ea633af61d8f7169ffa6e72c5b53d24efcc" checksum = "70e992e41e0d2fb9f755b37446f20900f64446ef54874f40a60c78f021ac6144"
dependencies = [ dependencies = [
"autocfg 1.0.1", "autocfg 1.0.1",
"bytes", "bytes",
@ -4133,9 +4133,9 @@ dependencies = [
[[package]] [[package]]
name = "tokio-macros" name = "tokio-macros"
version = "1.4.1" version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "154794c8f499c2619acd19e839294703e9e32e7630ef5f46ea80d4ef0fbee5eb" checksum = "c9efc1aba077437943f7515666aa2b882dfabfbfdf89c819ea75a8d6e9eaba5e"
dependencies = [ dependencies = [
"proc-macro2 1.0.29", "proc-macro2 1.0.29",
"quote 1.0.10", "quote 1.0.10",

View file

@ -64,7 +64,7 @@ jsonc-parser = { version = "0.17.0", features = ["serde"] }
lazy_static = "1.4.0" lazy_static = "1.4.0"
libc = "0.2.106" libc = "0.2.106"
log = { version = "0.4.14", features = ["serde"] } log = { version = "0.4.14", features = ["serde"] }
lspower = "1.1.0" lspower = "1.4.0"
notify = "5.0.0-pre.12" notify = "5.0.0-pre.12"
num_cpus = "1.13.0" num_cpus = "1.13.0"
once_cell = "1.8.0" once_cell = "1.8.0"

View file

@ -95,7 +95,7 @@ impl Reference {
hint, hint,
} => lsp::Diagnostic { } => lsp::Diagnostic {
range: self.range, range: self.range,
severity: Some(lsp::DiagnosticSeverity::Warning), severity: Some(lsp::DiagnosticSeverity::WARNING),
code: Some(lsp::NumberOrString::String(code.to_string())), code: Some(lsp::NumberOrString::String(code.to_string())),
code_description: None, code_description: None,
source: Some("deno-lint".to_string()), source: Some("deno-lint".to_string()),
@ -785,7 +785,7 @@ mod tests {
}, },
lsp::Diagnostic { lsp::Diagnostic {
range, range,
severity: Some(lsp::DiagnosticSeverity::Warning), severity: Some(lsp::DiagnosticSeverity::WARNING),
code: Some(lsp::NumberOrString::String("code1".to_string())), code: Some(lsp::NumberOrString::String("code1".to_string())),
source: Some("deno-lint".to_string()), source: Some("deno-lint".to_string()),
message: "message1".to_string(), message: "message1".to_string(),
@ -803,7 +803,7 @@ mod tests {
}, },
lsp::Diagnostic { lsp::Diagnostic {
range, range,
severity: Some(lsp::DiagnosticSeverity::Warning), severity: Some(lsp::DiagnosticSeverity::WARNING),
code: Some(lsp::NumberOrString::String("code2".to_string())), code: Some(lsp::NumberOrString::String("code2".to_string())),
source: Some("deno-lint".to_string()), source: Some("deno-lint".to_string()),
message: "message2\nhint2".to_string(), message: "message2\nhint2".to_string(),

View file

@ -68,7 +68,7 @@ pub fn server_capabilities(
text_document_sync: Some(TextDocumentSyncCapability::Options( text_document_sync: Some(TextDocumentSyncCapability::Options(
TextDocumentSyncOptions { TextDocumentSyncOptions {
open_close: Some(true), open_close: Some(true),
change: Some(TextDocumentSyncKind::Incremental), change: Some(TextDocumentSyncKind::INCREMENTAL),
will_save: None, will_save: None,
will_save_wait_until: None, will_save_wait_until: None,
save: Some(SaveOptions::default().into()), save: Some(SaveOptions::default().into()),

View file

@ -150,7 +150,7 @@ pub(crate) async fn get_import_completions(
.iter() .iter()
.map(|s| lsp::CompletionItem { .map(|s| lsp::CompletionItem {
label: s.to_string(), label: s.to_string(),
kind: Some(lsp::CompletionItemKind::Folder), kind: Some(lsp::CompletionItemKind::FOLDER),
detail: Some("(local)".to_string()), detail: Some("(local)".to_string()),
sort_text: Some("1".to_string()), sort_text: Some("1".to_string()),
insert_text: Some(s.to_string()), insert_text: Some(s.to_string()),
@ -223,7 +223,7 @@ fn get_local_completions(
match de.file_type() { match de.file_type() {
Ok(file_type) if file_type.is_dir() => Some(lsp::CompletionItem { Ok(file_type) if file_type.is_dir() => Some(lsp::CompletionItem {
label, label,
kind: Some(lsp::CompletionItemKind::Folder), kind: Some(lsp::CompletionItemKind::FOLDER),
filter_text, filter_text,
sort_text: Some("1".to_string()), sort_text: Some("1".to_string()),
text_edit, text_edit,
@ -233,7 +233,7 @@ fn get_local_completions(
if is_supported_ext(&de.path()) { if is_supported_ext(&de.path()) {
Some(lsp::CompletionItem { Some(lsp::CompletionItem {
label, label,
kind: Some(lsp::CompletionItemKind::File), kind: Some(lsp::CompletionItemKind::FILE),
detail: Some("(local)".to_string()), detail: Some("(local)".to_string()),
filter_text, filter_text,
sort_text: Some("1".to_string()), sort_text: Some("1".to_string()),
@ -305,7 +305,7 @@ fn get_workspace_completions(
})); }));
Some(lsp::CompletionItem { Some(lsp::CompletionItem {
label, label,
kind: Some(lsp::CompletionItemKind::File), kind: Some(lsp::CompletionItemKind::FILE),
detail, detail,
sort_text: Some("1".to_string()), sort_text: Some("1".to_string()),
text_edit, text_edit,
@ -652,7 +652,7 @@ mod tests {
actual, actual,
vec![lsp::CompletionItem { vec![lsp::CompletionItem {
label: "https://deno.land/x/a/b/c.ts".to_string(), label: "https://deno.land/x/a/b/c.ts".to_string(),
kind: Some(lsp::CompletionItemKind::File), kind: Some(lsp::CompletionItemKind::FILE),
detail: Some("(remote)".to_string()), detail: Some("(remote)".to_string()),
sort_text: Some("1".to_string()), sort_text: Some("1".to_string()),
text_edit: Some(lsp::CompletionTextEdit::Edit(lsp::TextEdit { text_edit: Some(lsp::CompletionTextEdit::Edit(lsp::TextEdit {

View file

@ -197,15 +197,15 @@ impl DiagnosticsServer {
impl<'a> From<&'a diagnostics::DiagnosticCategory> for lsp::DiagnosticSeverity { impl<'a> From<&'a diagnostics::DiagnosticCategory> for lsp::DiagnosticSeverity {
fn from(category: &'a diagnostics::DiagnosticCategory) -> Self { fn from(category: &'a diagnostics::DiagnosticCategory) -> Self {
match category { match category {
diagnostics::DiagnosticCategory::Error => lsp::DiagnosticSeverity::Error, diagnostics::DiagnosticCategory::Error => lsp::DiagnosticSeverity::ERROR,
diagnostics::DiagnosticCategory::Warning => { diagnostics::DiagnosticCategory::Warning => {
lsp::DiagnosticSeverity::Warning lsp::DiagnosticSeverity::WARNING
} }
diagnostics::DiagnosticCategory::Suggestion => { diagnostics::DiagnosticCategory::Suggestion => {
lsp::DiagnosticSeverity::Hint lsp::DiagnosticSeverity::HINT
} }
diagnostics::DiagnosticCategory::Message => { diagnostics::DiagnosticCategory::Message => {
lsp::DiagnosticSeverity::Information lsp::DiagnosticSeverity::INFORMATION
} }
} }
} }
@ -286,9 +286,9 @@ fn ts_json_to_diagnostics(
tags: match d.code { tags: match d.code {
// These are codes that indicate the variable is unused. // These are codes that indicate the variable is unused.
2695 | 6133 | 6138 | 6192 | 6196 | 6198 | 6199 | 6205 | 7027 2695 | 6133 | 6138 | 6192 | 6196 | 6198 | 6199 | 6205 | 7027
| 7028 => Some(vec![lsp::DiagnosticTag::Unnecessary]), | 7028 => Some(vec![lsp::DiagnosticTag::UNNECESSARY]),
// These are codes that indicated the variable is deprecated. // These are codes that indicated the variable is deprecated.
2789 | 6385 | 6387 => Some(vec![lsp::DiagnosticTag::Deprecated]), 2789 | 6385 | 6387 => Some(vec![lsp::DiagnosticTag::DEPRECATED]),
_ => None, _ => None,
}, },
data: None, data: None,
@ -445,7 +445,7 @@ fn diagnose_dependency(
if let Some(message) = doc.maybe_warning() { if let Some(message) = doc.maybe_warning() {
diagnostics.push(lsp::Diagnostic { diagnostics.push(lsp::Diagnostic {
range: documents::to_lsp_range(range), range: documents::to_lsp_range(range),
severity: Some(lsp::DiagnosticSeverity::Warning), severity: Some(lsp::DiagnosticSeverity::WARNING),
code: Some(lsp::NumberOrString::String("deno-warn".to_string())), code: Some(lsp::NumberOrString::String("deno-warn".to_string())),
source: Some("deno".to_string()), source: Some("deno".to_string()),
message, message,
@ -461,7 +461,7 @@ fn diagnose_dependency(
}; };
diagnostics.push(lsp::Diagnostic { diagnostics.push(lsp::Diagnostic {
range: documents::to_lsp_range(range), range: documents::to_lsp_range(range),
severity: Some(lsp::DiagnosticSeverity::Error), severity: Some(lsp::DiagnosticSeverity::ERROR),
code, code,
source: Some("deno".to_string()), source: Some("deno".to_string()),
message, message,
@ -472,7 +472,7 @@ fn diagnose_dependency(
} }
Some(Err(err)) => diagnostics.push(lsp::Diagnostic { Some(Err(err)) => diagnostics.push(lsp::Diagnostic {
range: documents::to_lsp_range(err.range()), range: documents::to_lsp_range(err.range()),
severity: Some(lsp::DiagnosticSeverity::Error), severity: Some(lsp::DiagnosticSeverity::ERROR),
code: Some(resolution_error_as_code(err)), code: Some(resolution_error_as_code(err)),
source: Some("deno".to_string()), source: Some("deno".to_string()),
message: err.to_string(), message: err.to_string(),

View file

@ -579,7 +579,7 @@ impl Inner {
tsconfig.merge(&unstable_libs); tsconfig.merge(&unstable_libs);
} }
if let Err(err) = self.merge_user_tsconfig(&mut tsconfig) { if let Err(err) = self.merge_user_tsconfig(&mut tsconfig) {
self.client.show_message(MessageType::Warning, err).await; self.client.show_message(MessageType::WARNING, err).await;
} }
let _ok: bool = self let _ok: bool = self
.ts_server .ts_server
@ -669,13 +669,13 @@ impl Inner {
self.update_debug_flag(); self.update_debug_flag();
// Check to see if we need to change the cache path // Check to see if we need to change the cache path
if let Err(err) = self.update_cache() { if let Err(err) = self.update_cache() {
self.client.show_message(MessageType::Warning, err).await; self.client.show_message(MessageType::WARNING, err).await;
} }
if let Err(err) = self.update_config_file() { if let Err(err) = self.update_config_file() {
self.client.show_message(MessageType::Warning, err).await; self.client.show_message(MessageType::WARNING, err).await;
} }
if let Err(err) = self.update_tsconfig().await { if let Err(err) = self.update_tsconfig().await {
self.client.show_message(MessageType::Warning, err).await; self.client.show_message(MessageType::WARNING, err).await;
} }
if capabilities.code_action_provider.is_some() { if capabilities.code_action_provider.is_some() {
@ -692,11 +692,11 @@ impl Inner {
// Check to see if we need to setup the import map // Check to see if we need to setup the import map
if let Err(err) = self.update_import_map().await { if let Err(err) = self.update_import_map().await {
self.client.show_message(MessageType::Warning, err).await; self.client.show_message(MessageType::WARNING, err).await;
} }
// Check to see if we need to setup any module registries // Check to see if we need to setup any module registries
if let Err(err) = self.update_registries().await { if let Err(err) = self.update_registries().await {
self.client.show_message(MessageType::Warning, err).await; self.client.show_message(MessageType::WARNING, err).await;
} }
self.documents.update_config( self.documents.update_config(
self.maybe_import_map.clone(), self.maybe_import_map.clone(),
@ -893,19 +893,19 @@ impl Inner {
self.update_debug_flag(); self.update_debug_flag();
if let Err(err) = self.update_cache() { if let Err(err) = self.update_cache() {
self.client.show_message(MessageType::Warning, err).await; self.client.show_message(MessageType::WARNING, err).await;
} }
if let Err(err) = self.update_import_map().await { if let Err(err) = self.update_import_map().await {
self.client.show_message(MessageType::Warning, err).await; self.client.show_message(MessageType::WARNING, err).await;
} }
if let Err(err) = self.update_registries().await { if let Err(err) = self.update_registries().await {
self.client.show_message(MessageType::Warning, err).await; self.client.show_message(MessageType::WARNING, err).await;
} }
if let Err(err) = self.update_config_file() { if let Err(err) = self.update_config_file() {
self.client.show_message(MessageType::Warning, err).await; self.client.show_message(MessageType::WARNING, err).await;
} }
if let Err(err) = self.update_tsconfig().await { if let Err(err) = self.update_tsconfig().await {
self.client.show_message(MessageType::Warning, err).await; self.client.show_message(MessageType::WARNING, err).await;
} }
if let Err(err) = self.diagnostics_server.update() { if let Err(err) = self.diagnostics_server.update() {
error!("{}", err); error!("{}", err);
@ -936,7 +936,7 @@ impl Inner {
if let Some(import_map_uri) = &self.maybe_import_map_uri { if let Some(import_map_uri) = &self.maybe_import_map_uri {
if changes.iter().any(|uri| import_map_uri == uri) { if changes.iter().any(|uri| import_map_uri == uri) {
if let Err(err) = self.update_import_map().await { if let Err(err) = self.update_import_map().await {
self.client.show_message(MessageType::Warning, err).await; self.client.show_message(MessageType::WARNING, err).await;
} }
touched = true; touched = true;
} }
@ -945,10 +945,10 @@ impl Inner {
if let Some(config_uri) = &self.maybe_config_uri { if let Some(config_uri) = &self.maybe_config_uri {
if changes.iter().any(|uri| config_uri == uri) { if changes.iter().any(|uri| config_uri == uri) {
if let Err(err) = self.update_config_file() { if let Err(err) = self.update_config_file() {
self.client.show_message(MessageType::Warning, err).await; self.client.show_message(MessageType::WARNING, err).await;
} }
if let Err(err) = self.update_tsconfig().await { if let Err(err) = self.update_tsconfig().await {
self.client.show_message(MessageType::Warning, err).await; self.client.show_message(MessageType::WARNING, err).await;
} }
touched = true; touched = true;
} }
@ -1066,7 +1066,7 @@ impl Inner {
Ok(Some(text_edits)) Ok(Some(text_edits))
} }
} else { } else {
self.client.show_message(MessageType::Warning, format!("Unable to format \"{}\". Likely due to unrecoverable syntax errors in the file.", specifier)).await; self.client.show_message(MessageType::WARNING, format!("Unable to format \"{}\". Likely due to unrecoverable syntax errors in the file.", specifier)).await;
Ok(None) Ok(None)
} }
} }
@ -2613,7 +2613,7 @@ impl Inner {
} }
let cache_server = self.maybe_cache_server.as_ref().unwrap(); let cache_server = self.maybe_cache_server.as_ref().unwrap();
if let Err(err) = cache_server.cache(roots).await { if let Err(err) = cache_server.cache(roots).await {
self.client.show_message(MessageType::Warning, err).await; self.client.show_message(MessageType::WARNING, err).await;
} }
// now that we have dependencies loaded, we need to re-analyze them and // now that we have dependencies loaded, we need to re-analyze them and

View file

@ -348,7 +348,7 @@ impl ModuleRegistry {
s, s,
lsp::CompletionItem { lsp::CompletionItem {
label, label,
kind: Some(lsp::CompletionItemKind::Folder), kind: Some(lsp::CompletionItemKind::FOLDER),
filter_text, filter_text,
sort_text: Some("1".to_string()), sort_text: Some("1".to_string()),
text_edit, text_edit,
@ -508,9 +508,9 @@ impl ModuleRegistry {
item.clone() item.clone()
}; };
let kind = if key.name == last_key_name { let kind = if key.name == last_key_name {
Some(lsp::CompletionItemKind::File) Some(lsp::CompletionItemKind::FILE)
} else { } else {
Some(lsp::CompletionItemKind::Folder) Some(lsp::CompletionItemKind::FOLDER)
}; };
let mut params = match_result.params.clone(); let mut params = match_result.params.clone();
params.insert( params.insert(
@ -572,7 +572,7 @@ impl ModuleRegistry {
Token::String(s) => { Token::String(s) => {
if s.starts_with(path) { if s.starts_with(path) {
let label = s.to_string(); let label = s.to_string();
let kind = Some(lsp::CompletionItemKind::Folder); let kind = Some(lsp::CompletionItemKind::FOLDER);
let mut url = specifier.clone(); let mut url = specifier.clone();
url.set_path(s); url.set_path(s);
let full_text = url.as_str(); let full_text = url.as_str();
@ -606,7 +606,7 @@ impl ModuleRegistry {
let base = Url::parse(&origin).ok()?; let base = Url::parse(&origin).ok()?;
for (idx, item) in items.into_iter().enumerate() { for (idx, item) in items.into_iter().enumerate() {
let path = format!("{}{}", prefix, item); let path = format!("{}{}", prefix, item);
let kind = Some(lsp::CompletionItemKind::Folder); let kind = Some(lsp::CompletionItemKind::FOLDER);
let item_specifier = base.join(&path).ok()?; let item_specifier = base.join(&path).ok()?;
let full_text = item_specifier.as_str(); let full_text = item_specifier.as_str();
let text_edit = Some( let text_edit = Some(
@ -687,7 +687,7 @@ impl ModuleRegistry {
})); }));
Some(lsp::CompletionItem { Some(lsp::CompletionItem {
label: origin, label: origin,
kind: Some(lsp::CompletionItemKind::Folder), kind: Some(lsp::CompletionItemKind::FOLDER),
detail: Some("(registry)".to_string()), detail: Some("(registry)".to_string()),
sort_text: Some("2".to_string()), sort_text: Some("2".to_string()),
text_edit, text_edit,
@ -1036,10 +1036,10 @@ mod tests {
let completions = completions.unwrap(); let completions = completions.unwrap();
assert_eq!(completions.len(), 2); assert_eq!(completions.len(), 2);
assert_eq!(completions[0].detail, Some("(path)".to_string())); assert_eq!(completions[0].detail, Some("(path)".to_string()));
assert_eq!(completions[0].kind, Some(lsp::CompletionItemKind::File)); assert_eq!(completions[0].kind, Some(lsp::CompletionItemKind::FILE));
assert!(completions[0].command.is_some()); assert!(completions[0].command.is_some());
assert_eq!(completions[1].detail, Some("(path)".to_string())); assert_eq!(completions[1].detail, Some("(path)".to_string()));
assert_eq!(completions[0].kind, Some(lsp::CompletionItemKind::File)); assert_eq!(completions[0].kind, Some(lsp::CompletionItemKind::FILE));
assert!(completions[1].command.is_some()); assert!(completions[1].command.is_some());
} }

View file

@ -457,7 +457,7 @@ impl From<ScriptElementKind> for lsp::CompletionItemKind {
fn from(kind: ScriptElementKind) -> Self { fn from(kind: ScriptElementKind) -> Self {
match kind { match kind {
ScriptElementKind::PrimitiveType | ScriptElementKind::Keyword => { ScriptElementKind::PrimitiveType | ScriptElementKind::Keyword => {
lsp::CompletionItemKind::Keyword lsp::CompletionItemKind::KEYWORD
} }
ScriptElementKind::ConstElement ScriptElementKind::ConstElement
| ScriptElementKind::LetElement | ScriptElementKind::LetElement
@ -465,40 +465,40 @@ impl From<ScriptElementKind> for lsp::CompletionItemKind {
| ScriptElementKind::LocalVariableElement | ScriptElementKind::LocalVariableElement
| ScriptElementKind::Alias | ScriptElementKind::Alias
| ScriptElementKind::ParameterElement => { | ScriptElementKind::ParameterElement => {
lsp::CompletionItemKind::Variable lsp::CompletionItemKind::VARIABLE
} }
ScriptElementKind::MemberVariableElement ScriptElementKind::MemberVariableElement
| ScriptElementKind::MemberGetAccessorElement | ScriptElementKind::MemberGetAccessorElement
| ScriptElementKind::MemberSetAccessorElement => { | ScriptElementKind::MemberSetAccessorElement => {
lsp::CompletionItemKind::Field lsp::CompletionItemKind::FIELD
} }
ScriptElementKind::FunctionElement ScriptElementKind::FunctionElement
| ScriptElementKind::LocalFunctionElement => { | ScriptElementKind::LocalFunctionElement => {
lsp::CompletionItemKind::Function lsp::CompletionItemKind::FUNCTION
} }
ScriptElementKind::MemberFunctionElement ScriptElementKind::MemberFunctionElement
| ScriptElementKind::ConstructSignatureElement | ScriptElementKind::ConstructSignatureElement
| ScriptElementKind::CallSignatureElement | ScriptElementKind::CallSignatureElement
| ScriptElementKind::IndexSignatureElement => { | ScriptElementKind::IndexSignatureElement => {
lsp::CompletionItemKind::Method lsp::CompletionItemKind::METHOD
} }
ScriptElementKind::EnumElement => lsp::CompletionItemKind::Enum, ScriptElementKind::EnumElement => lsp::CompletionItemKind::ENUM,
ScriptElementKind::EnumMemberElement => { ScriptElementKind::EnumMemberElement => {
lsp::CompletionItemKind::EnumMember lsp::CompletionItemKind::ENUM_MEMBER
} }
ScriptElementKind::ModuleElement ScriptElementKind::ModuleElement
| ScriptElementKind::ExternalModuleName => { | ScriptElementKind::ExternalModuleName => {
lsp::CompletionItemKind::Module lsp::CompletionItemKind::MODULE
} }
ScriptElementKind::ClassElement | ScriptElementKind::TypeElement => { ScriptElementKind::ClassElement | ScriptElementKind::TypeElement => {
lsp::CompletionItemKind::Class lsp::CompletionItemKind::CLASS
} }
ScriptElementKind::InterfaceElement => lsp::CompletionItemKind::Interface, ScriptElementKind::InterfaceElement => lsp::CompletionItemKind::INTERFACE,
ScriptElementKind::Warning => lsp::CompletionItemKind::Text, ScriptElementKind::Warning => lsp::CompletionItemKind::TEXT,
ScriptElementKind::ScriptElement => lsp::CompletionItemKind::File, ScriptElementKind::ScriptElement => lsp::CompletionItemKind::FILE,
ScriptElementKind::Directory => lsp::CompletionItemKind::Folder, ScriptElementKind::Directory => lsp::CompletionItemKind::FOLDER,
ScriptElementKind::String => lsp::CompletionItemKind::Constant, ScriptElementKind::String => lsp::CompletionItemKind::CONSTANT,
_ => lsp::CompletionItemKind::Property, _ => lsp::CompletionItemKind::PROPERTY,
} }
} }
} }
@ -507,35 +507,35 @@ impl From<ScriptElementKind> for lsp::CompletionItemKind {
impl From<ScriptElementKind> for lsp::SymbolKind { impl From<ScriptElementKind> for lsp::SymbolKind {
fn from(kind: ScriptElementKind) -> Self { fn from(kind: ScriptElementKind) -> Self {
match kind { match kind {
ScriptElementKind::ModuleElement => Self::Module, ScriptElementKind::ModuleElement => Self::MODULE,
// this is only present in `getSymbolKind` in `workspaceSymbols` in // this is only present in `getSymbolKind` in `workspaceSymbols` in
// vscode, but seems strange it isn't consistent. // vscode, but seems strange it isn't consistent.
ScriptElementKind::TypeElement => Self::Class, ScriptElementKind::TypeElement => Self::CLASS,
ScriptElementKind::ClassElement => Self::Class, ScriptElementKind::ClassElement => Self::CLASS,
ScriptElementKind::EnumElement => Self::Enum, ScriptElementKind::EnumElement => Self::ENUM,
ScriptElementKind::EnumMemberElement => Self::EnumMember, ScriptElementKind::EnumMemberElement => Self::ENUM_MEMBER,
ScriptElementKind::InterfaceElement => Self::Interface, ScriptElementKind::InterfaceElement => Self::INTERFACE,
ScriptElementKind::IndexSignatureElement => Self::Method, ScriptElementKind::IndexSignatureElement => Self::METHOD,
ScriptElementKind::CallSignatureElement => Self::Method, ScriptElementKind::CallSignatureElement => Self::METHOD,
ScriptElementKind::MemberFunctionElement => Self::Method, ScriptElementKind::MemberFunctionElement => Self::METHOD,
// workspaceSymbols in vscode treats them as fields, which does seem more // workspaceSymbols in vscode treats them as fields, which does seem more
// semantically correct while `fromProtocolScriptElementKind` treats them // semantically correct while `fromProtocolScriptElementKind` treats them
// as properties. // as properties.
ScriptElementKind::MemberVariableElement => Self::Field, ScriptElementKind::MemberVariableElement => Self::FIELD,
ScriptElementKind::MemberGetAccessorElement => Self::Field, ScriptElementKind::MemberGetAccessorElement => Self::FIELD,
ScriptElementKind::MemberSetAccessorElement => Self::Field, ScriptElementKind::MemberSetAccessorElement => Self::FIELD,
ScriptElementKind::VariableElement => Self::Variable, ScriptElementKind::VariableElement => Self::VARIABLE,
ScriptElementKind::LetElement => Self::Variable, ScriptElementKind::LetElement => Self::VARIABLE,
ScriptElementKind::ConstElement => Self::Variable, ScriptElementKind::ConstElement => Self::VARIABLE,
ScriptElementKind::LocalVariableElement => Self::Variable, ScriptElementKind::LocalVariableElement => Self::VARIABLE,
ScriptElementKind::Alias => Self::Variable, ScriptElementKind::Alias => Self::VARIABLE,
ScriptElementKind::FunctionElement => Self::Function, ScriptElementKind::FunctionElement => Self::FUNCTION,
ScriptElementKind::LocalFunctionElement => Self::Function, ScriptElementKind::LocalFunctionElement => Self::FUNCTION,
ScriptElementKind::ConstructSignatureElement => Self::Constructor, ScriptElementKind::ConstructSignatureElement => Self::CONSTRUCTOR,
ScriptElementKind::ConstructorImplementationElement => Self::Constructor, ScriptElementKind::ConstructorImplementationElement => Self::CONSTRUCTOR,
ScriptElementKind::TypeParameterElement => Self::TypeParameter, ScriptElementKind::TypeParameterElement => Self::TYPE_PARAMETER,
ScriptElementKind::String => Self::String, ScriptElementKind::String => Self::STRING,
_ => Self::Variable, _ => Self::VARIABLE,
} }
} }
} }
@ -726,7 +726,7 @@ impl NavigateToItem {
let mut tags: Option<Vec<lsp::SymbolTag>> = None; let mut tags: Option<Vec<lsp::SymbolTag>> = None;
let kind_modifiers = parse_kind_modifier(&self.kind_modifiers); let kind_modifiers = parse_kind_modifier(&self.kind_modifiers);
if kind_modifiers.contains("deprecated") { if kind_modifiers.contains("deprecated") {
tags = Some(vec![lsp::SymbolTag::Deprecated]); tags = Some(vec![lsp::SymbolTag::DEPRECATED]);
} }
// The field `deprecated` is deprecated but SymbolInformation does not have // The field `deprecated` is deprecated but SymbolInformation does not have
@ -837,7 +837,7 @@ impl NavigationTree {
let mut tags: Option<Vec<lsp::SymbolTag>> = None; let mut tags: Option<Vec<lsp::SymbolTag>> = None;
let kind_modifiers = parse_kind_modifier(&self.kind_modifiers); let kind_modifiers = parse_kind_modifier(&self.kind_modifiers);
if kind_modifiers.contains("deprecated") { if kind_modifiers.contains("deprecated") {
tags = Some(vec![lsp::SymbolTag::Deprecated]); tags = Some(vec![lsp::SymbolTag::DEPRECATED]);
} }
let children = if !symbol_children.is_empty() { let children = if !symbol_children.is_empty() {
@ -1087,9 +1087,9 @@ impl DocumentHighlights {
range: hs.text_span.to_range(line_index.clone()), range: hs.text_span.to_range(line_index.clone()),
kind: match hs.kind { kind: match hs.kind {
HighlightSpanKind::WrittenReference => { HighlightSpanKind::WrittenReference => {
Some(lsp::DocumentHighlightKind::Write) Some(lsp::DocumentHighlightKind::WRITE)
} }
_ => Some(lsp::DocumentHighlightKind::Read), _ => Some(lsp::DocumentHighlightKind::READ),
}, },
}) })
.collect() .collect()
@ -1550,7 +1550,7 @@ impl CallHierarchyItem {
if let Some(modifiers) = self.kind_modifiers.as_ref() { if let Some(modifiers) = self.kind_modifiers.as_ref() {
let kind_modifiers = parse_kind_modifier(modifiers); let kind_modifiers = parse_kind_modifier(modifiers);
if kind_modifiers.contains("deprecated") { if kind_modifiers.contains("deprecated") {
tags = Some(vec![lsp::SymbolTag::Deprecated]); tags = Some(vec![lsp::SymbolTag::DEPRECATED]);
} }
} }
@ -1884,8 +1884,8 @@ impl CompletionEntry {
let preselect = self.is_recommended; let preselect = self.is_recommended;
let use_code_snippet = settings.complete_function_calls let use_code_snippet = settings.complete_function_calls
&& (kind == Some(lsp::CompletionItemKind::Function) && (kind == Some(lsp::CompletionItemKind::FUNCTION)
|| kind == Some(lsp::CompletionItemKind::Method)); || kind == Some(lsp::CompletionItemKind::METHOD));
// TODO(@kitsonk) missing from types: https://github.com/gluon-lang/lsp-types/issues/204 // TODO(@kitsonk) missing from types: https://github.com/gluon-lang/lsp-types/issues/204
let _commit_characters = self.get_commit_characters(info, settings); let _commit_characters = self.get_commit_characters(info, settings);
let mut insert_text = self.insert_text.clone(); let mut insert_text = self.insert_text.clone();
@ -1906,10 +1906,10 @@ impl CompletionEntry {
label += "?"; label += "?";
} }
if kind_modifiers.contains("deprecated") { if kind_modifiers.contains("deprecated") {
tags = Some(vec![lsp::CompletionItemTag::Deprecated]); tags = Some(vec![lsp::CompletionItemTag::DEPRECATED]);
} }
if kind_modifiers.contains("color") { if kind_modifiers.contains("color") {
kind = Some(lsp::CompletionItemKind::Color); kind = Some(lsp::CompletionItemKind::COLOR);
} }
if self.kind == ScriptElementKind::ScriptElement { if self.kind == ScriptElementKind::ScriptElement {
for ext_modifier in FILE_EXTENSION_KIND_MODIFIERS { for ext_modifier in FILE_EXTENSION_KIND_MODIFIERS {
@ -2669,14 +2669,17 @@ pub enum SignatureHelpTriggerKind {
Invoked, Invoked,
#[serde(rename = "retrigger")] #[serde(rename = "retrigger")]
Retrigger, Retrigger,
#[serde(rename = "unknown")]
Unknown,
} }
impl From<lsp::SignatureHelpTriggerKind> for SignatureHelpTriggerKind { impl From<lsp::SignatureHelpTriggerKind> for SignatureHelpTriggerKind {
fn from(kind: lsp::SignatureHelpTriggerKind) -> Self { fn from(kind: lsp::SignatureHelpTriggerKind) -> Self {
match kind { match kind {
lsp::SignatureHelpTriggerKind::Invoked => Self::Invoked, lsp::SignatureHelpTriggerKind::INVOKED => Self::Invoked,
lsp::SignatureHelpTriggerKind::TriggerCharacter => Self::CharacterTyped, lsp::SignatureHelpTriggerKind::TRIGGER_CHARACTER => Self::CharacterTyped,
lsp::SignatureHelpTriggerKind::ContentChange => Self::Retrigger, lsp::SignatureHelpTriggerKind::CONTENT_CHANGE => Self::Retrigger,
_ => Self::Unknown,
} }
} }
} }

View file

@ -179,7 +179,7 @@ fn lsp_tsconfig_bad_config_path() {
let (method, maybe_params) = client.read_notification().unwrap(); let (method, maybe_params) = client.read_notification().unwrap();
assert_eq!(method, "window/showMessage"); assert_eq!(method, "window/showMessage");
assert_eq!(maybe_params, Some(lsp::ShowMessageParams { assert_eq!(maybe_params, Some(lsp::ShowMessageParams {
typ: lsp::MessageType::Warning, typ: lsp::MessageType::WARNING,
message: "The path to the configuration file (\"bad_tsconfig.json\") is not resolvable.".to_string() message: "The path to the configuration file (\"bad_tsconfig.json\") is not resolvable.".to_string()
})); }));
let diagnostics = did_open( let diagnostics = did_open(
@ -3118,7 +3118,7 @@ fn lsp_diagnostics_warn() {
character: 60 character: 60
} }
}, },
severity: Some(lsp::DiagnosticSeverity::Warning), severity: Some(lsp::DiagnosticSeverity::WARNING),
code: Some(lsp::NumberOrString::String("deno-warn".to_string())), code: Some(lsp::NumberOrString::String("deno-warn".to_string())),
source: Some("deno".to_string()), source: Some("deno".to_string()),
message: "foobar".to_string(), message: "foobar".to_string(),