5325: Update lsp-types to account for new CodeActionKind structure r=kjeremy a=kjeremy



Co-authored-by: Jeremy Kolb <kjeremy@gmail.com>
This commit is contained in:
bors[bot] 2020-07-11 22:36:53 +00:00 committed by GitHub
commit 49fbd1b625
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 40 additions and 31 deletions

4
Cargo.lock generated
View file

@ -691,9 +691,9 @@ dependencies = [
[[package]] [[package]]
name = "lsp-types" name = "lsp-types"
version = "0.74.2" version = "0.75.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b360754e89e0e13c114245131382ba921d4ff1efabb918e549422938aaa8d392" checksum = "a1b4ab1df4a5538413c707860e13fff9e0c9bc2fa613efc15d78196bc06ae06d"
dependencies = [ dependencies = [
"base64", "base64",
"bitflags", "bitflags",

View file

@ -20,7 +20,7 @@ globset = "0.4.4"
itertools = "0.9.0" itertools = "0.9.0"
jod-thread = "0.1.0" jod-thread = "0.1.0"
log = "0.4.8" log = "0.4.8"
lsp-types = { version = "0.74.0", features = ["proposed"] } lsp-types = { version = "0.75.0", features = ["proposed"] }
parking_lot = "0.11.0" parking_lot = "0.11.0"
pico-args = "0.3.1" pico-args = "0.3.1"
rand = { version = "0.7.3", features = ["small_rng"] } rand = { version = "0.7.3", features = ["small_rng"] }

View file

@ -2,7 +2,7 @@
use std::env; use std::env;
use lsp_types::{ use lsp_types::{
CallHierarchyServerCapability, ClientCapabilities, CodeActionOptions, CallHierarchyServerCapability, ClientCapabilities, CodeActionKind, CodeActionOptions,
CodeActionProviderCapability, CodeLensOptions, CompletionOptions, CodeActionProviderCapability, CodeLensOptions, CompletionOptions,
DocumentOnTypeFormattingOptions, FoldingRangeProviderCapability, DocumentOnTypeFormattingOptions, FoldingRangeProviderCapability,
ImplementationProviderCapability, RenameOptions, RenameProviderCapability, SaveOptions, ImplementationProviderCapability, RenameOptions, RenameProviderCapability, SaveOptions,
@ -106,12 +106,12 @@ fn code_action_capabilities(client_caps: &ClientCapabilities) -> CodeActionProvi
// Ideally we would base this off of the client capabilities // Ideally we would base this off of the client capabilities
// but the client is supposed to fall back gracefully for unknown values. // but the client is supposed to fall back gracefully for unknown values.
code_action_kinds: Some(vec![ code_action_kinds: Some(vec![
lsp_types::code_action_kind::EMPTY.to_string(), CodeActionKind::EMPTY,
lsp_types::code_action_kind::QUICKFIX.to_string(), CodeActionKind::QUICKFIX,
lsp_types::code_action_kind::REFACTOR.to_string(), CodeActionKind::REFACTOR,
lsp_types::code_action_kind::REFACTOR_EXTRACT.to_string(), CodeActionKind::REFACTOR_EXTRACT,
lsp_types::code_action_kind::REFACTOR_INLINE.to_string(), CodeActionKind::REFACTOR_INLINE,
lsp_types::code_action_kind::REFACTOR_REWRITE.to_string(), CodeActionKind::REFACTOR_REWRITE,
]), ]),
work_done_progress_options: Default::default(), work_done_progress_options: Default::default(),
}) })

View file

@ -112,7 +112,7 @@ fn map_rust_child_diagnostic(
title: rd.message.clone(), title: rd.message.clone(),
id: None, id: None,
group: None, group: None,
kind: Some("quickfix".to_string()), kind: Some(lsp_types::CodeActionKind::QUICKFIX),
edit: Some(lsp_ext::SnippetWorkspaceEdit { edit: Some(lsp_ext::SnippetWorkspaceEdit {
// FIXME: there's no good reason to use edit_map here.... // FIXME: there's no good reason to use edit_map here....
changes: Some(edit_map), changes: Some(edit_map),

View file

@ -11,11 +11,11 @@ use lsp_server::ErrorCode;
use lsp_types::{ use lsp_types::{
CallHierarchyIncomingCall, CallHierarchyIncomingCallsParams, CallHierarchyItem, CallHierarchyIncomingCall, CallHierarchyIncomingCallsParams, CallHierarchyItem,
CallHierarchyOutgoingCall, CallHierarchyOutgoingCallsParams, CallHierarchyPrepareParams, CallHierarchyOutgoingCall, CallHierarchyOutgoingCallsParams, CallHierarchyPrepareParams,
CodeLens, Command, CompletionItem, Diagnostic, DocumentFormattingParams, DocumentHighlight, CodeActionKind, CodeLens, Command, CompletionItem, Diagnostic, DocumentFormattingParams,
DocumentSymbol, FoldingRange, FoldingRangeParams, HoverContents, Location, Position, DocumentHighlight, DocumentSymbol, FoldingRange, FoldingRangeParams, HoverContents, Location,
PrepareRenameResponse, Range, RenameParams, SemanticTokensParams, SemanticTokensRangeParams, Position, PrepareRenameResponse, Range, RenameParams, SemanticTokensParams,
SemanticTokensRangeResult, SemanticTokensResult, SymbolInformation, TextDocumentIdentifier, SemanticTokensRangeParams, SemanticTokensRangeResult, SemanticTokensResult, SymbolInformation,
Url, WorkspaceEdit, TextDocumentIdentifier, Url, WorkspaceEdit,
}; };
use ra_ide::{ use ra_ide::{
FileId, FilePosition, FileRange, HoverAction, HoverGotoTypeData, NavigationTarget, Query, FileId, FilePosition, FileRange, HoverAction, HoverGotoTypeData, NavigationTarget, Query,
@ -760,7 +760,7 @@ fn handle_fixes(
title, title,
id: None, id: None,
group: None, group: None,
kind: Some(lsp_types::code_action_kind::QUICKFIX.into()), kind: Some(CodeActionKind::QUICKFIX),
edit: Some(edit), edit: Some(edit),
}; };
res.push(action); res.push(action);

View file

@ -3,7 +3,9 @@
use std::{collections::HashMap, path::PathBuf}; use std::{collections::HashMap, path::PathBuf};
use lsp_types::request::Request; use lsp_types::request::Request;
use lsp_types::{notification::Notification, Position, Range, TextDocumentIdentifier}; use lsp_types::{
notification::Notification, CodeActionKind, Position, Range, TextDocumentIdentifier,
};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
pub enum AnalyzerStatus {} pub enum AnalyzerStatus {}
@ -248,7 +250,7 @@ pub struct CodeAction {
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub group: Option<String>, pub group: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub kind: Option<String>, pub kind: Option<CodeActionKind>,
// We don't handle commands on the client-side // We don't handle commands on the client-side
// #[serde(skip_serializing_if = "Option::is_none")] // #[serde(skip_serializing_if = "Option::is_none")]
// pub command: Option<lsp_types::Command>, // pub command: Option<lsp_types::Command>,

View file

@ -629,16 +629,15 @@ pub(crate) fn call_hierarchy_item(
Ok(lsp_types::CallHierarchyItem { name, kind, tags: None, detail, uri, range, selection_range }) Ok(lsp_types::CallHierarchyItem { name, kind, tags: None, detail, uri, range, selection_range })
} }
pub(crate) fn code_action_kind(kind: AssistKind) -> String { pub(crate) fn code_action_kind(kind: AssistKind) -> lsp_types::CodeActionKind {
match kind { match kind {
AssistKind::None | AssistKind::Generate => lsp_types::code_action_kind::EMPTY, AssistKind::None | AssistKind::Generate => lsp_types::CodeActionKind::EMPTY,
AssistKind::QuickFix => lsp_types::code_action_kind::QUICKFIX, AssistKind::QuickFix => lsp_types::CodeActionKind::QUICKFIX,
AssistKind::Refactor => lsp_types::code_action_kind::REFACTOR, AssistKind::Refactor => lsp_types::CodeActionKind::REFACTOR,
AssistKind::RefactorExtract => lsp_types::code_action_kind::REFACTOR_EXTRACT, AssistKind::RefactorExtract => lsp_types::CodeActionKind::REFACTOR_EXTRACT,
AssistKind::RefactorInline => lsp_types::code_action_kind::REFACTOR_INLINE, AssistKind::RefactorInline => lsp_types::CodeActionKind::REFACTOR_INLINE,
AssistKind::RefactorRewrite => lsp_types::code_action_kind::REFACTOR_REWRITE, AssistKind::RefactorRewrite => lsp_types::CodeActionKind::REFACTOR_REWRITE,
} }
.to_string()
} }
pub(crate) fn unresolved_code_action( pub(crate) fn unresolved_code_action(

View file

@ -37,8 +37,10 @@
id: None, id: None,
group: None, group: None,
kind: Some( kind: Some(
CodeActionKind(
"quickfix", "quickfix",
), ),
),
edit: Some( edit: Some(
SnippetWorkspaceEdit { SnippetWorkspaceEdit {
changes: Some( changes: Some(

View file

@ -37,8 +37,10 @@
id: None, id: None,
group: None, group: None,
kind: Some( kind: Some(
CodeActionKind(
"quickfix", "quickfix",
), ),
),
edit: Some( edit: Some(
SnippetWorkspaceEdit { SnippetWorkspaceEdit {
changes: Some( changes: Some(

View file

@ -37,8 +37,10 @@
id: None, id: None,
group: None, group: None,
kind: Some( kind: Some(
CodeActionKind(
"quickfix", "quickfix",
), ),
),
edit: Some( edit: Some(
SnippetWorkspaceEdit { SnippetWorkspaceEdit {
changes: Some( changes: Some(

View file

@ -52,8 +52,10 @@
id: None, id: None,
group: None, group: None,
kind: Some( kind: Some(
CodeActionKind(
"quickfix", "quickfix",
), ),
),
edit: Some( edit: Some(
SnippetWorkspaceEdit { SnippetWorkspaceEdit {
changes: Some( changes: Some(