3

私は次のような関数呼び出しを持っています(明白な理由はありません):

func
(
    a,
    b,
    c
)

unrustifyで関数を1行に折りたたむ方法はありますか?オンとオフではなく2日間試しています...

関数宣言では機能しましたが、関数呼び出しでは機能しません。

私たちがそれにいる間、私はそのように見える関数も持っています:

func
(
    a, // (IN) the A
    b, // (IN) something b
    c  // (OUT) the resulting value
)

コードを壊さずにそのケースを処理する方法もありますか?uncrustifyはコメントを残しているので、これは不可能だと思います。関数宣言を使用すると、最初のコメントに折りたたまれます。

4

2 に答える 2

2

ドキュメントを読んで、私はこれを思いついた:

# Add or remove newline between a function name and the opening '('
nl_func_paren                            = remove   # ignore/add/remove/force

# Add or remove newline between a function name and the opening '(' in the definition
nl_func_def_paren                        = remove   # ignore/add/remove/force

# Add or remove newline after '(' in a function declaration
nl_func_decl_start                       = remove   # ignore/add/remove/force

# Add or remove newline after '(' in a function definition
nl_func_def_start                        = remove   # ignore/add/remove/force

# Add or remove newline after each ',' in a function declaration
nl_func_decl_args                        = remove   # ignore/add/remove/force

# Add or remove newline after each ',' in a function definition
nl_func_def_args                         = remove   # ignore/add/remove/force

# Add or remove newline before the ')' in a function declaration
nl_func_decl_end                         = remove   # ignore/add/remove/force

# Add or remove newline before the ')' in a function definition
nl_func_def_end                          = remove   # ignore/add/remove/force

ご想像のとおり、コメントはそれを台無しにしてしまいます。ただし、単一行のコメント()をブロックコメント( )に変更するオプションがあります。これにより、手動で行を結合しやすくなります(vimなど) 。///* ... */v%J

# Whether to change cpp-comments into c-comments
cmt_cpp_to_c                             = true    # false/true

プロトタイプ、宣言呼び出しでテストしました。

通話は影響を受けません。次の関連オプションにも注意してください。

# Whether to fully split long function protos/calls at commas
ls_func_split_full                       = false    # false/true
于 2012-09-05T07:53:18.543 に答える
0

いくつかのLOOONGの調査の結果、私は結論に達しました。私のネズミイルカのために、私は小さなperlスクリプトを一緒にハッキングしました:

$filename = $ARGV[0];

{
    open(FILE, "<", $filename) or die "Cant open $filename for reading\n";
    local $/ = undef;
    $lines = <FILE>;
    close(FILE);
}

# squash comments in function calls and declarations
$lines =~ s/,[ \t]*\/\/[^\n\r]*/,/gm;
# squash last comment in function calls and declarations
$lines =~ s/[ \t]*\/\/[^\n\r]*\r\n[ \t]*\)/\)/gm;
# squash newlines at the start of a function call or declaration
$lines =~ s/\([ \t]*\r\n[ \t]*/\(/gm;
# squash newlines in function calls and declarations
$lines =~ s/,[ \t]*\r\n[ \t]*/, /gm;
# squash the last newline in a function call or declaration
$lines =~ s/[ \t]*\r\n[ \t]*\)/\)/gm;

{
    open(FILE, ">", $filename) or die "Cant open $filename for writing\n";
    print FILE $lines;
    close(FILE);
}

その機能をuncustifyに統合するパッチを作成できるかどうかを調べます。

于 2012-09-11T09:17:09.757 に答える