Skip to content

fix: Don't generate documentation in generate_setter #12275

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 1 addition & 15 deletions crates/ide-assists/src/handlers/generate_setter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use crate::{
// }
//
// impl Person {
// /// Set the person's name.
// fn set_name(&mut self, name: String) {
// self.name = name;
// }
Expand All @@ -32,7 +31,6 @@ pub(crate) fn generate_setter(acc: &mut Assists, ctx: &AssistContext) -> Option<
let strukt = ctx.find_node_at_offset::<ast::Struct>()?;
let field = ctx.find_node_at_offset::<ast::RecordField>()?;

let strukt_name = strukt.name()?;
let field_name = field.name()?;
let field_ty = field.ty()?;

Expand All @@ -53,23 +51,16 @@ pub(crate) fn generate_setter(acc: &mut Assists, ctx: &AssistContext) -> Option<
|builder| {
let mut buf = String::with_capacity(512);

let fn_name_spaced = fn_name.replace('_', " ");
let strukt_name_spaced =
to_lower_snake_case(&strukt_name.to_string()).replace('_', " ");

if impl_def.is_some() {
buf.push('\n');
}

let vis = strukt.visibility().map_or(String::new(), |v| format!("{} ", v));
format_to!(
buf,
" /// Set the {}'s {}.
{}fn set_{}(&mut self, {}: {}) {{
" {}fn set_{}(&mut self, {}: {}) {{
self.{} = {};
}}",
strukt_name_spaced,
fn_name_spaced,
vis,
fn_name,
fn_name,
Expand Down Expand Up @@ -114,7 +105,6 @@ struct Person<T: Clone> {
}

impl<T: Clone> Person<T> {
/// Set the person's data.
fn set_data(&mut self, data: T) {
self.data = data;
}
Expand Down Expand Up @@ -152,7 +142,6 @@ pub(crate) struct Person<T: Clone> {
}

impl<T: Clone> Person<T> {
/// Set the person's data.
pub(crate) fn set_data(&mut self, data: T) {
self.data = data;
}
Expand All @@ -171,7 +160,6 @@ struct Context<T: Clone> {
}

impl<T: Clone> Context<T> {
/// Set the context's data.
fn set_data(&mut self, data: T) {
self.data = data;
}
Expand All @@ -183,12 +171,10 @@ struct Context<T: Clone> {
}

impl<T: Clone> Context<T> {
/// Set the context's data.
fn set_data(&mut self, data: T) {
self.data = data;
}

/// Set the context's count.
fn set_count(&mut self, count: usize) {
self.count = count;
}
Expand Down
1 change: 0 additions & 1 deletion crates/ide-assists/src/tests/generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,6 @@ struct Person {
}

impl Person {
/// Set the person's name.
fn set_name(&mut self, name: String) {
self.name = name;
}
Expand Down