mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 04:53:34 +00:00
Merge #5325
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:
commit
49fbd1b625
11 changed files with 40 additions and 31 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -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",
|
||||
|
|
|
@ -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"] }
|
||||
|
|
|
@ -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(),
|
||||
})
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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>,
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -37,7 +37,9 @@
|
|||
id: None,
|
||||
group: None,
|
||||
kind: Some(
|
||||
"quickfix",
|
||||
CodeActionKind(
|
||||
"quickfix",
|
||||
),
|
||||
),
|
||||
edit: Some(
|
||||
SnippetWorkspaceEdit {
|
||||
|
|
|
@ -37,7 +37,9 @@
|
|||
id: None,
|
||||
group: None,
|
||||
kind: Some(
|
||||
"quickfix",
|
||||
CodeActionKind(
|
||||
"quickfix",
|
||||
),
|
||||
),
|
||||
edit: Some(
|
||||
SnippetWorkspaceEdit {
|
||||
|
|
|
@ -37,7 +37,9 @@
|
|||
id: None,
|
||||
group: None,
|
||||
kind: Some(
|
||||
"quickfix",
|
||||
CodeActionKind(
|
||||
"quickfix",
|
||||
),
|
||||
),
|
||||
edit: Some(
|
||||
SnippetWorkspaceEdit {
|
||||
|
|
|
@ -52,7 +52,9 @@
|
|||
id: None,
|
||||
group: None,
|
||||
kind: Some(
|
||||
"quickfix",
|
||||
CodeActionKind(
|
||||
"quickfix",
|
||||
),
|
||||
),
|
||||
edit: Some(
|
||||
SnippetWorkspaceEdit {
|
||||
|
|
Loading…
Reference in a new issue