我想使用 uncrustify 将我的参数与冒号对齐,并取得了一些有限的成功。
使用 Can Uncrustify align colons in Objective-C method calls? 中的信息我的配置文件中有以下内容:
align_oc_decl_colon = true
align_oc_msg_colon_span = 20
我的 .m
- 文件看起来很棒,像这样:
- (id)initWithStreetName:(NSString *)streetName
areaCode:(NSString *)areaCode
city:(NSString *)city
country:(NSString *)country
positionLatitude:(NSString *)positionLatitude
positionLongitude:(NSString *)positionLongitude
serverAssignmentId:(NSString *)serverAssignmentId
comment:(NSString *)comment
timestamp:(NSDate *)timestamp
status:(AssignmentStatus)status
但同样的方法在标题中看起来像这样:
- (id)initWithStreetName:(NSString *)streetName
areaCode :(NSString *)areaCode
city :(NSString *)city
country :(NSString *)country
positionLatitude :(NSString *)positionLatitude
positionLongitude :(NSString *)positionLongitude
serverAssignmentId :(NSString *)serverAssignmentId
comment :(NSString *)comment
timestamp :(NSDate *)timestamp
status :(AssignmentStatus)status;
关于如何让 header 代码看起来像实现代码有什么想法吗?
最佳答案
这是 uncrustify 最新版本的一个已知错误。在回答这个问题时,最新的回答是在 9 个月前。然而,针对此错误的补丁已经提交,希望它会出现在下一个版本中。
看这里: https://github.com/bengardner/uncrustify/issues/18
作为临时修复,您可以自己编译当前的主控。使用 XCode 编译只会生成一个二进制文件,您可以在下一个正式版本发布之前使用它。
Bug 在 0.59 上,应该在 0.60 上解决
关于objective-c - 在 Objective-C header 中对齐冒号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10901191/