| 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 |
|
| 7 |
typedef int Foo; |
| 8 |
typedef void (^FooBlock)(Foo *someParameter); |
| 9 |
typedef int (^BarBlock)(int *); |
| 10 |
|
| 11 |
@interface Obj |
| 12 |
|
| 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 |
@end |
| 19 |
|
| 20 |
|
| 21 |
@interface Test : Obj |
| 22 |
|
| 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 |
@end |
| 29 |
|
| 30 |
@implementation Test |
| 31 |
|
| 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 %s |
| 39 |
// RUN: c-index-test -code-completion-at=%s:34:33 %s | FileCheck -check-prefix=CHECK-CC1 %s |
| 40 |
// RUN: c-index-test -code-completion-at=%s:35:21 %s | FileCheck -check-prefix=CHECK-CC1 %s |
| 41 |
//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 |
@end |
| 53 |
|
| 54 |
@interface NoQualifierParens |
| 55 |
|
| 56 |
@property(copy) void (^blockProperty)(void); |
| 57 |
@property BarBlock blockProperty2; |
| 58 |
|
| 59 |
@end |
| 60 |
|
| 61 |
void 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 %s |
| 66 |
//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 ClassProperties |
| 72 |
|
| 73 |
@property(class) void (^explicit)(); |
| 74 |
@property(class, readonly) void (^explicitReadonly)(); |
| 75 |
|
| 76 |
@end |
| 77 |
|
| 78 |
void classBlockProperties() { |
| 79 |
ClassProperties.explicit; |
| 80 |
} |
| 81 |
|
| 82 |
// RUN: c-index-test -code-completion-at=%s:79:19 %s | FileCheck -check-prefix=CHECK-CC3 %s |
| 83 |
//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 |
|
| 87 |
void implicitSetterBlockPlaceholder(Test* test) { |
| 88 |
[test setBlock: ^{}]; |
| 89 |
} |
| 90 |
// RUN: c-index-test -code-completion-at=%s:88:9 %s | FileCheck -check-prefix=CHECK-CC4 %s |
| 91 |
// CHECK-CC4: ObjCInstanceMethodDecl:{ResultType void}{TypedText setBlocker:}{Placeholder ^Foo(int x, Foo y, FooBlock foo)blocker} (37) |