I want to use uncrustify to align my parameters on colon, and have some limited success.
Using the information in Can Uncrustify align colons in Objective-C method calls? I have the following in my config file:
align_oc_decl_colon = true
align_oc_msg_colon_span = 20
My .m
-files look great, like this:
- (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
but the very same method looks like this in the header:
- (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;
Any ideas on how I can get the header code to look like the implementation code?
That is a known bug on the latest release of uncrustify. At the time of this answer the latest one was 9 months ago. However a patch for this error was already committed and hopefully it will appear in the next release.
Look here: https://github.com/bengardner/uncrustify/issues/18
As a temporal fix you can compile yourself the current master. Compiling with XCode will generate just one single binary that you can use until the next official release.
The bug is on 0.59, should be solved on 0.60
来源:https://stackoverflow.com/questions/10901191/align-on-colons-in-objective-c-headers