Align on colons in Objective-C headers

社会主义新天地 提交于 2019-12-06 07:53:36

问题


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?


回答1:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!