取消拆分函数调用参数 [英] Uncrustify split function call parameters

查看:84
本文介绍了取消拆分函数调用参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想这样格式化代码:


  • a)最大行宽120

  • a) line width maximum 120

b)-如果调用了函数的长度,则每行缩进的函数调用参数为> 120,否则一行中的函数调用

b)- function call parameters one per line with indent if the length of the function is called is > 120 else function call in one line

c)-如果函数调用位于if,for,while等内,则参数的格式应为 b)

c)- it the function call is inside a if, for, while, etc... the parameters should be formatted as written at b)

我有代码(只是虚构的):

I have the code (it is just a fictive):

void a_function()
{
    if(verify_if_the_conditions_are_meet(first_parameter, second_parameter, third_parameter, fourth_parameter, fifth_parameter, sixth_parameter ))
    {
        call_a_function_with_many_parameters(first_parameter, second_parameter, third_parameter, fourth_parameter, fifth_parameter, sixth_parameter);       
    }

    save(first_parameter, second_parameter, third_parameter, fourth_parameter, fifth_parameter, sixth_parameter);
}

现在,我想得到结果:

void a_function()
{
    if(verify_if_the_conditions_are_meet(
        first_parameter, 
        second_parameter, 
        third_parameter, 
        fourth_parameter, 
        fifth_parameter, 
        sixth_parameter ))
    {
        call_a_function_with_many_parameters(
            first_parameter, 
            second_parameter, 
            third_parameter, 
            fourth_parameter, 
            fifth_parameter, 
            sixth_parameter);
    }

    save(first_parameter, second_parameter, third_parameter, fourth_parameter, fifth_parameter, sixth_parameter);
}

我在Uncrustify 0.63中使用了以下选项:

I've used the following options in Uncrustify 0.63:


code_width = 120

code_width = 120

ls_func_split_full = true

ls_func_split_full = true

ls_code_width = false

ls_code_width = false

nl_func_leave_one_liners = true

nl_func_leave_one_liners = true

indent_func_call_param = true

indent_func_call_param = true

nl_func_def_start =添加

nl_func_def_start = add

nl_func_def_start_single =删除

nl_func_def_start_single = remove

align_oc_msg_colon_first = false

align_oc_msg_colon_first = false

使用此设置,我会像这样:

With this settings I get just like this:

void a_function()
{
    if(verify_if_the_conditions_are_meet(first_parameter, second_parameter, third_parameter, fourth_parameter, 
        fifth_parameter, sixth_parameter ))
    {
        call_a_function_with_many_parameters(
            first_parameter, 
            second_parameter, 
            third_parameter, 
            fourth_parameter, 
            fifth_parameter, 
            sixth_parameter);
    }

    save(first_parameter, second_parameter, third_parameter, fourth_parameter, fifth_parameter, sixth_parameter);
}

任何人都有函数调用位于if / for / while内的情况并需要像这样拆分参数?

Have anyone a situation where the function call is inside a if/for/while and needs to have the parameters split like this?

推荐答案

使用以下设置:

nl_func_call_start_multi_line   = true
nl_func_call_args_multi_line    = true
code_width                      = 120




  • code_width :尝试将代码宽度限制为 N

  • nl_func_call_start_multi_line :如果<$ c $,是否在函数调用中的之后添加换行符c>(和不在同一行。

  • nl_func_call_args_multi_line :如果和<$ c $,则在函数调用中的每个之后是否添加换行符c>)在不同的行中。

    • code_width: Try to limit code width to N columns
    • nl_func_call_start_multi_line: Whether to add newline after ( in a function call if ( and ) are in different lines.
    • nl_func_call_args_multi_line: Whether to add newline after each , in a function call if ( and ) are in different lines.
    • (可选):

      nl_func_call_end_multi_line     = true
      




      • nl_func_call_end_multi_line :是否在之前添加换行符)如果在不同的行中。

        • nl_func_call_end_multi_line: Whether to add newline before ) in a function call if ( and ) are in different lines.
        • 这篇关于取消拆分函数调用参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆