【问题标题】:Xcode with uncrustify: how to align function declaration to colons?Xcode with uncrustify:如何将函数声明与冒号对齐?
【发布时间】:2014-09-26 08:19:24
【问题描述】:

我有以下代码

@interface TRYoutubeManager : AFHTTPRequestOperationManager

- (void)getVideosForDefaultChannelsWithSuccess:(void (^)(NSArray *youtubeVideosArray))successBlock failure:(void (^)(NSError *error))failureBlock;

@end

所以我想保留 120 个字符的行限制。并在冒号上对齐声明,如下所示:

@interface TRYoutubeManager : AFHTTPRequestOperationManager

- (void)getVideosForDefaultChannelsWithSuccess:(void (^)(NSArray *youtubeVideosArray))successBlock
                                       failure:(void (^)(NSError *error))failureBlock;

@end

但是当我对其应用 Uncrustify 时,我得到

@interface TRYoutubeManager : AFHTTPRequestOperationManager

- (void)getVideosForDefaultChannelsWithSuccess:(void (^)(NSArray *youtubeVideosArray))successBlock failure:(void (^)(
                                                                                                                     NSError *
                                                                                                                     error))
failureBlock;

@end

插件破坏了整个事情。甚至超出了行限制。 这是一些关键的(我猜)参数:

# Align ObjC declaration params on colon
align_oc_decl_colon                     = true          # 
# Alignment span for ObjC message colons
align_oc_msg_colon_span                 = 20            # number

# Alignment span for ObjC message spec
align_oc_msg_spec_span                  = 0             # number
# Code width
code_width                              = 120           # number

整个配置文件HERE

请帮我正确设置 Uncrustify 配置。

【问题讨论】:

    标签: ios objective-c xcode uncrustify


    【解决方案1】:

    您是否尝试过调查:

    nl_oc_msg_leave_one_liner                 { False, True }   Don't
    split one-line OC messages
    
    nl_oc_msg_args                            { False, True }   Whether to
    put each OC message parameter on a separate line   See
    nl_oc_msg_leave_one_liner
    

    我认为格式化程序实际上不会为您将声明中的参数移动到新行,align_oc_decl_colon 只会将它们与冒号对齐,如果它们已经在多行中。

    【讨论】:

    • 是的,看起来 Uncrustify 不会将参数移动到新行。毕竟,我最终使用 BBUncrustifyPlugin 使用 Clang-Format + Xcode 语法重新缩进。以更可预测的方式工作。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-10-30
    • 2014-12-27
    • 2018-01-06
    • 1970-01-01
    • 2016-11-18
    相关资源
    最近更新 更多