Alex Lorenz | baef802 | 2016-11-09 13:43:18 +0000 | [diff] [blame] | 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 | |
| 8 | typedef int Foo; |
| 9 | typedef void (^FooBlock)(Foo *someParameter); |
| 10 | typedef 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 )} (35) |
| 44 | //CHECK-CC1-NEXT: ObjCPropertyDecl:{ResultType void (^)()}{TypedText block}{Equal = }{Placeholder ^(void)} (38) |
| 45 | //CHECK-CC1-NEXT: ObjCPropertyDecl:{ResultType Foo}{TypedText blocker}{LeftParen (}{Placeholder int x}{Comma , }{Placeholder Foo y}{Comma , }{Placeholder ^(Foo *someParameter)foo}{RightParen )} (35) |
| 46 | //CHECK-CC1-NEXT: ObjCPropertyDecl:{ResultType Foo (^)(int, Foo, FooBlock)}{TypedText blocker}{Equal = }{Placeholder ^Foo(int x, Foo y, FooBlock foo)} (38) |
| 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 )} (35) |
| 51 | //CHECK-CC1-NEXT: ObjCPropertyDecl:{ResultType int}{TypedText performB}{LeftParen (}{Placeholder int x}{Comma , }{Placeholder int y}{RightParen )} (35) |
| 52 | |
| 53 | @end |
Alex Lorenz | 01bcfc1 | 2016-11-23 16:28:34 +0000 | [diff] [blame] | 54 | |
| 55 | // rdar://25224416 |
| 56 | |
| 57 | @interface NoQualifierParens |
| 58 | |
| 59 | @property(copy) void (^blockProperty)(void); |
| 60 | @property BarBlock blockProperty2; |
| 61 | |
| 62 | @end |
| 63 | |
| 64 | void 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 BarBlock blockProperty2} (35) |
| 72 | //CHECK-CC2-NEXT: ObjCInstanceMethodDecl:{ResultType void}{TypedText setBlockProperty:}{Placeholder void (^)(void)blockProperty} (35) |
Alex Lorenz | feafdf6 | 2016-12-08 15:09:40 +0000 | [diff] [blame] | 73 | |
| 74 | @interface ClassProperties |
| 75 | |
| 76 | @property(class) void (^explicit)(); |
| 77 | @property(class, readonly) void (^explicitReadonly)(); |
| 78 | |
| 79 | @end |
| 80 | |
| 81 | void 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) |