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]]
name = "lsp-types"
version = "0.74.2"
version = "0.75.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b360754e89e0e13c114245131382ba921d4ff1efabb918e549422938aaa8d392"
checksum = "a1b4ab1df4a5538413c707860e13fff9e0c9bc2fa613efc15d78196bc06ae06d"
dependencies = [
"base64",
"bitflags",

View file

@ -20,7 +20,7 @@ globset = "0.4.4"
itertools = "0.9.0"
jod-thread = "0.1.0"
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"
pico-args = "0.3.1"
rand = { version = "0.7.3", features = ["small_rng"] }

View file

@ -2,7 +2,7 @@
use std::env;
use lsp_types::{
CallHierarchyServerCapability, ClientCapabilities, CodeActionOptions,
CallHierarchyServerCapability, ClientCapabilities, CodeActionKind, CodeActionOptions,
CodeActionProviderCapability, CodeLensOptions, CompletionOptions,
DocumentOnTypeFormattingOptions, FoldingRangeProviderCapability,
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
// but the client is supposed to fall back gracefully for unknown values.
code_action_kinds: Some(vec![
lsp_types::code_action_kind::EMPTY.to_string(),
lsp_types::code_action_kind::QUICKFIX.to_string(),
lsp_types::code_action_kind::REFACTOR.to_string(),
lsp_types::code_action_kind::REFACTOR_EXTRACT.to_string(),
lsp_types::code_action_kind::REFACTOR_INLINE.to_string(),
lsp_types::code_action_kind::REFACTOR_REWRITE.to_string(),
CodeActionKind::EMPTY,
CodeActionKind::QUICKFIX,
CodeActionKind::REFACTOR,
CodeActionKind::REFACTOR_EXTRACT,
CodeActionKind::REFACTOR_INLINE,
CodeActionKind::REFACTOR_REWRITE,
]),
work_done_progress_options: Default::default(),
})

View file

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

View file

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

View file

@ -3,7 +3,9 @@
use std::{collections::HashMap, path::PathBuf};
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};
pub enum AnalyzerStatus {}
@ -248,7 +250,7 @@ pub struct CodeAction {
#[serde(skip_serializing_if = "Option::is_none")]
pub group: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub kind: Option<String>,
pub kind: Option<CodeActionKind>,
// We don't handle commands on the client-side
// #[serde(skip_serializing_if = "Option::is_none")]
// 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 })
}
pub(crate) fn code_action_kind(kind: AssistKind) -> String {
pub(crate) fn code_action_kind(kind: AssistKind) -> lsp_types::CodeActionKind {
match kind {
AssistKind::None | AssistKind::Generate => lsp_types::code_action_kind::EMPTY,
AssistKind::QuickFix => lsp_types::code_action_kind::QUICKFIX,
AssistKind::Refactor => lsp_types::code_action_kind::REFACTOR,
AssistKind::RefactorExtract => lsp_types::code_action_kind::REFACTOR_EXTRACT,
AssistKind::RefactorInline => lsp_types::code_action_kind::REFACTOR_INLINE,
AssistKind::RefactorRewrite => lsp_types::code_action_kind::REFACTOR_REWRITE,
AssistKind::None | AssistKind::Generate => lsp_types::CodeActionKind::EMPTY,
AssistKind::QuickFix => lsp_types::CodeActionKind::QUICKFIX,
AssistKind::Refactor => lsp_types::CodeActionKind::REFACTOR,
AssistKind::RefactorExtract => lsp_types::CodeActionKind::REFACTOR_EXTRACT,
AssistKind::RefactorInline => lsp_types::CodeActionKind::REFACTOR_INLINE,
AssistKind::RefactorRewrite => lsp_types::CodeActionKind::REFACTOR_REWRITE,
}
.to_string()
}
pub(crate) fn unresolved_code_action(

View file

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

View file

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

View file

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

View file

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