1// Note: the run lines follow their respective tests, since line/column 2// matter in this test. 3 4// Block invocations should be presented when completing properties in 5// standalone statements. 6// rdar://28846196 7 8typedef int Foo; 9typedef void (^FooBlock)(Foo *someParameter); 10typedef int (^BarBlock)(int *); 11 12@interface Obj 13 14@property (readwrite, nonatomic, copy) void (^block)(); 15@property (readonly, nonatomic, copy) int (^performA)(); 16@property (readonly, nonatomic, copy) int (^performB)(int x, int y); 17@property (readwrite, nonatomic, copy) Foo (^blocker)(int x, Foo y, FooBlock foo); 18 19@end 20 21 22@interface Test : Obj 23 24@property (readonly, nonatomic, copy) FooBlock fooBlock; 25@property (readonly, nonatomic, copy) BarBlock barBlock; 26@property (readonly, nonatomic, copy) Test * (^getObject)(int index); 27@property (readwrite, nonatomic) int foo; 28 29@end 30 31@implementation Test 32 33- (void)test { 34 self.foo = 2; 35 int x = self.performA(); self.foo = 2; 36 self.getObject(0).foo = 2; 37} 38 39// RUN: c-index-test -code-completion-at=%s:34:8 %s | FileCheck -check-prefix=CHECK-CC1 %s 40// RUN: c-index-test -code-completion-at=%s:35:33 %s | FileCheck -check-prefix=CHECK-CC1 %s 41// RUN: c-index-test -code-completion-at=%s:36:21 %s | FileCheck -check-prefix=CHECK-CC1 %s 42//CHECK-CC1: ObjCPropertyDecl:{ResultType int}{TypedText barBlock}{LeftParen (}{Placeholder int *}{RightParen )} (35) 43//CHECK-CC1-NEXT: ObjCPropertyDecl:{ResultType void}{TypedText block}{LeftParen (}{RightParen )} (37) 44//CHECK-CC1-NEXT: ObjCPropertyDecl:{ResultType void (^)()}{TypedText block}{Equal = }{Placeholder ^(void)} (40) 45//CHECK-CC1-NEXT: ObjCPropertyDecl:{ResultType Foo}{TypedText blocker}{LeftParen (}{Placeholder int x}{Comma , }{Placeholder Foo y}{Comma , }{Placeholder ^(Foo *someParameter)foo}{RightParen )} (37) 46//CHECK-CC1-NEXT: ObjCPropertyDecl:{ResultType Foo (^)(int, Foo, FooBlock)}{TypedText blocker}{Equal = }{Placeholder ^Foo(int x, Foo y, FooBlock foo)} (34) 47//CHECK-CC1-NEXT: ObjCPropertyDecl:{ResultType int}{TypedText foo} (35) 48//CHECK-CC1-NEXT: ObjCPropertyDecl:{ResultType void}{TypedText fooBlock}{LeftParen (}{Placeholder Foo *someParameter}{RightParen )} (35) 49//CHECK-CC1-NEXT: ObjCPropertyDecl:{ResultType Test *}{TypedText getObject}{LeftParen (}{Placeholder int index}{RightParen )} (35) 50//CHECK-CC1-NEXT: ObjCPropertyDecl:{ResultType int}{TypedText performA}{LeftParen (}{RightParen )} (37) 51//CHECK-CC1-NEXT: ObjCPropertyDecl:{ResultType int}{TypedText performB}{LeftParen (}{Placeholder int x}{Comma , }{Placeholder int y}{RightParen )} (37) 52 53@end 54 55// rdar://25224416 56 57@interface NoQualifierParens 58 59@property(copy) void (^blockProperty)(void); 60@property BarBlock blockProperty2; 61 62@end 63 64void noQualifierParens(NoQualifierParens *f) { 65 [f setBlockProperty: ^{}]; 66} 67 68// RUN: c-index-test -code-completion-at=%s:65:6 %s | FileCheck -check-prefix=CHECK-CC2 %s 69//CHECK-CC2: ObjCInstanceMethodDecl:{ResultType void (^)(void)}{TypedText blockProperty} (35) 70//CHECK-CC2-NEXT: ObjCInstanceMethodDecl:{ResultType BarBlock}{TypedText blockProperty2} (35) 71//CHECK-CC2-NEXT: ObjCInstanceMethodDecl:{ResultType void}{TypedText setBlockProperty2:}{Placeholder ^int(int *)blockProperty2} (35) 72//CHECK-CC2-NEXT: ObjCInstanceMethodDecl:{ResultType void}{TypedText setBlockProperty:}{Placeholder ^(void)blockProperty} (35) 73 74@interface ClassProperties 75 76@property(class) void (^explicit)(); 77@property(class, readonly) void (^explicitReadonly)(); 78 79@end 80 81void classBlockProperties() { 82 ClassProperties.explicit; 83} 84 85// RUN: c-index-test -code-completion-at=%s:82:19 %s | FileCheck -check-prefix=CHECK-CC3 %s 86//CHECK-CC3: ObjCPropertyDecl:{ResultType void}{TypedText explicit}{LeftParen (}{RightParen )} (35) 87//CHECK-CC3-NEXT: ObjCPropertyDecl:{ResultType void (^)()}{TypedText explicit}{Equal = }{Placeholder ^(void)} (38) 88//CHECK-CC3-NEXT: ObjCPropertyDecl:{ResultType void}{TypedText explicitReadonly}{LeftParen (}{RightParen )} (35) 89 90void implicitSetterBlockPlaceholder(Test* test) { 91 [test setBlock: ^{}]; 92} 93// RUN: c-index-test -code-completion-at=%s:91:9 %s | FileCheck -check-prefix=CHECK-CC4 %s 94// CHECK-CC4: ObjCInstanceMethodDecl:{ResultType void}{TypedText setBlocker:}{Placeholder ^Foo(int x, Foo y, FooBlock foo)blocker} (37) 95