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