Skip to content

Commit

Permalink
ast: cleanup in stringify_fn_after_name()
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyi98 committed Jul 3, 2024
1 parent 209063f commit 6080e96
Showing 1 changed file with 6 additions and 25 deletions.
31 changes: 6 additions & 25 deletions vlib/v/ast/str.v
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ pub fn (t &Table) stringify_fn_decl(node &FnDecl, cur_mod string, m2a map[string
fn (t &Table) stringify_fn_after_name(node &FnDecl, mut f strings.Builder, cur_mod string, m2a map[string]string,
needs_wrap bool) {
mut add_para_types := true
mut is_wrap_needed := false
if node.generic_names.len > 0 {
if node.is_method {
sym := t.sym(node.params[0].typ)
Expand Down Expand Up @@ -174,22 +173,6 @@ fn (t &Table) stringify_fn_after_name(node &FnDecl, mut f strings.Builder, cur_m
}
is_last_param := i == node.params.len - 1
is_type_only := param.name == ''
should_add_type := true // is_last_param || is_type_only || node.params[i + 1].typ != param.typ ||
// (node.is_variadic && i == node.params.len - 2)
pre_comments := param.comments.filter(it.pos.pos < param.pos.pos)
if pre_comments.len > 0 {
if i == 0 {
is_wrap_needed = true
f.write_string('\n\t')
}
write_comments(pre_comments, mut f)
if !f.last_n(1)[0].is_space() {
f.write_string(' ')
}
}
if is_wrap_needed {
f.write_string('\t')
}
if param.is_mut {
f.write_string(param.typ.share().str() + ' ')
}
Expand Down Expand Up @@ -219,15 +202,13 @@ fn (t &Table) stringify_fn_after_name(node &FnDecl, mut f strings.Builder, cur_m
}
s = util.no_cur_mod(s, cur_mod)
s = shorten_full_name_based_on_aliases(s, m2a)
if should_add_type {
if !is_type_only {
f.write_string(' ')
}
if node.is_variadic && is_last_param {
f.write_string('...')
}
f.write_string(s)
if !is_type_only {
f.write_string(' ')
}
if node.is_variadic && is_last_param {
f.write_string('...')
}
f.write_string(s)
}
if !is_last_param {
if needs_wrap && f.len - last_len > 100 {
Expand Down

0 comments on commit 6080e96

Please sign in to comment.