1

我使用Uncrustify来格式化代码。

但是 Uncrustify 不支持 LLVM 4.0 的新 Objective-C 语法。

我要做什么?

Uncrustify 编写的代码:

@interface SJTLLVM4Tester()
@property (strong) NSNumber *number;
@end

@implementation SJTLLVM4Tester
-(id)init {
    self = [super init];
    if (self) {
        self.number = @'C';
        self.number = @123;
        self.number = @0x123ul;
        self.number = @-1.2e-3f;
        self.number = @YES;

        NSDictionary *dictionary = @{@"key1":@1,@"key2":@2,@"key3":@3};
        NSMutableArray *array = [[NSMutableArray alloc] initWithArray:@[@1,@2,@3]];

        self.number = dictionary[@"key1"];
        array[0] = self.number;
    }
    return self;
}
@end

执行结果: 结果

4

1 回答 1

1

这已在最新的 uncrustify 版本中得到修复:0.60。

你可以在这里获取它: https ://github.com/bengardner/uncrustify/archive/uncrustify-0.60.tar.gz

我正在使用 Brew,必须手动更新 URL 和 SHA1,brew edit uncrustify然后brew upgrade uncrustify.

以下是我的新公式:

require 'formula'

class Uncrustify < Formula
  url 'http://downloads.sourceforge.net/project/uncrustify/uncrustify/uncrustify-0.60/uncrustify-0.60.tar.gz'
  head 'https://github.com/bengardner/uncrustify.git'
  homepage 'http://uncrustify.sourceforge.net/'
  sha1 '769a7649a1cefb80beff9b67b11b4b87a8cc8e0e'

  def install
    system "./configure", "--prefix=#{prefix}", "--disable-dependency-tracking"
    system "make install"
  end
end

现在就像一个魅力。

于 2013-01-07T19:33:31.047 回答