mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 21:43:37 +00:00
Don't categorize things we don't care about
This commit is contained in:
parent
36cc81ac71
commit
4c9347ecc3
6 changed files with 51 additions and 67 deletions
|
@ -29,7 +29,7 @@ pub(crate) fn add_derive(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
|
||||||
let nominal = ctx.find_node_at_offset::<ast::NominalDef>()?;
|
let nominal = ctx.find_node_at_offset::<ast::NominalDef>()?;
|
||||||
let node_start = derive_insertion_offset(&nominal)?;
|
let node_start = derive_insertion_offset(&nominal)?;
|
||||||
let target = nominal.syntax().text_range();
|
let target = nominal.syntax().text_range();
|
||||||
acc.add(AssistId("add_derive", AssistKind::Refactor), "Add `#[derive]`", target, |builder| {
|
acc.add(AssistId("add_derive", AssistKind::None), "Add `#[derive]`", target, |builder| {
|
||||||
let derive_attr = nominal
|
let derive_attr = nominal
|
||||||
.attrs()
|
.attrs()
|
||||||
.filter_map(|x| x.as_simple_call())
|
.filter_map(|x| x.as_simple_call())
|
||||||
|
|
|
@ -62,11 +62,7 @@ pub(crate) fn add_function(acc: &mut Assists, ctx: &AssistContext) -> Option<()>
|
||||||
let function_builder = FunctionBuilder::from_call(&ctx, &call, &path, target_module)?;
|
let function_builder = FunctionBuilder::from_call(&ctx, &call, &path, target_module)?;
|
||||||
|
|
||||||
let target = call.syntax().text_range();
|
let target = call.syntax().text_range();
|
||||||
acc.add(
|
acc.add(AssistId("add_function", AssistKind::None), "Add function", target, |builder| {
|
||||||
AssistId("add_function", AssistKind::RefactorExtract),
|
|
||||||
"Add function",
|
|
||||||
target,
|
|
||||||
|builder| {
|
|
||||||
let function_template = function_builder.render();
|
let function_template = function_builder.render();
|
||||||
builder.edit_file(function_template.file);
|
builder.edit_file(function_template.file);
|
||||||
let new_fn = function_template.to_string(ctx.config.snippet_cap);
|
let new_fn = function_template.to_string(ctx.config.snippet_cap);
|
||||||
|
@ -74,8 +70,7 @@ pub(crate) fn add_function(acc: &mut Assists, ctx: &AssistContext) -> Option<()>
|
||||||
Some(cap) => builder.insert_snippet(cap, function_template.insert_offset, new_fn),
|
Some(cap) => builder.insert_snippet(cap, function_template.insert_offset, new_fn),
|
||||||
None => builder.insert(function_template.insert_offset, new_fn),
|
None => builder.insert(function_template.insert_offset, new_fn),
|
||||||
}
|
}
|
||||||
},
|
})
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct FunctionTemplate {
|
struct FunctionTemplate {
|
||||||
|
|
|
@ -42,11 +42,7 @@ pub(crate) fn add_new(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
|
||||||
let impl_def = find_struct_impl(&ctx, &strukt)?;
|
let impl_def = find_struct_impl(&ctx, &strukt)?;
|
||||||
|
|
||||||
let target = strukt.syntax().text_range();
|
let target = strukt.syntax().text_range();
|
||||||
acc.add(
|
acc.add(AssistId("add_new", AssistKind::None), "Add default constructor", target, |builder| {
|
||||||
AssistId("add_new", AssistKind::Refactor),
|
|
||||||
"Add default constructor",
|
|
||||||
target,
|
|
||||||
|builder| {
|
|
||||||
let mut buf = String::with_capacity(512);
|
let mut buf = String::with_capacity(512);
|
||||||
|
|
||||||
if impl_def.is_some() {
|
if impl_def.is_some() {
|
||||||
|
@ -89,8 +85,7 @@ pub(crate) fn add_new(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
|
||||||
builder.insert_snippet(cap, start_offset, buf);
|
builder.insert_snippet(cap, start_offset, buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
})
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generates the surrounding `impl Type { <code> }` including type and lifetime
|
// Generates the surrounding `impl Type { <code> }` including type and lifetime
|
||||||
|
|
|
@ -34,8 +34,6 @@ pub enum AssistKind {
|
||||||
RefactorExtract,
|
RefactorExtract,
|
||||||
RefactorInline,
|
RefactorInline,
|
||||||
RefactorRewrite,
|
RefactorRewrite,
|
||||||
Source,
|
|
||||||
OrganizeImports,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Unique identifier of the assist, should not be shown to the user
|
/// Unique identifier of the assist, should not be shown to the user
|
||||||
|
|
|
@ -112,8 +112,6 @@ fn code_action_capabilities(client_caps: &ClientCapabilities) -> CodeActionProvi
|
||||||
lsp_types::code_action_kind::REFACTOR_EXTRACT.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_INLINE.to_string(),
|
||||||
lsp_types::code_action_kind::REFACTOR_REWRITE.to_string(),
|
lsp_types::code_action_kind::REFACTOR_REWRITE.to_string(),
|
||||||
lsp_types::code_action_kind::SOURCE.to_string(),
|
|
||||||
lsp_types::code_action_kind::SOURCE_ORGANIZE_IMPORTS.to_string(),
|
|
||||||
]),
|
]),
|
||||||
work_done_progress_options: Default::default(),
|
work_done_progress_options: Default::default(),
|
||||||
})
|
})
|
||||||
|
|
|
@ -635,8 +635,6 @@ pub(crate) fn code_action_kind(kind: AssistKind) -> String {
|
||||||
AssistKind::RefactorExtract => lsp_types::code_action_kind::REFACTOR_EXTRACT,
|
AssistKind::RefactorExtract => lsp_types::code_action_kind::REFACTOR_EXTRACT,
|
||||||
AssistKind::RefactorInline => lsp_types::code_action_kind::REFACTOR_INLINE,
|
AssistKind::RefactorInline => lsp_types::code_action_kind::REFACTOR_INLINE,
|
||||||
AssistKind::RefactorRewrite => lsp_types::code_action_kind::REFACTOR_REWRITE,
|
AssistKind::RefactorRewrite => lsp_types::code_action_kind::REFACTOR_REWRITE,
|
||||||
AssistKind::Source => lsp_types::code_action_kind::SOURCE,
|
|
||||||
AssistKind::OrganizeImports => lsp_types::code_action_kind::SOURCE_ORGANIZE_IMPORTS,
|
|
||||||
}
|
}
|
||||||
.to_string()
|
.to_string()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue