/test/Index/complete-method-decls.m

https://gitlab.com/pranith/clang · Objective C · 184 lines · 59 code · 17 blank · 108 comment · 0 complexity · 79f6cc7c3025233208b97be819038940 MD5 · raw file

  1. /* Note: the RUN lines are near the end of the file, since line/column
  2. matter for this test. */
  3. #define IBAction void
  4. @protocol P1
  5. - (id)abc;
  6. - (id)initWithInt:(int)x;
  7. - (id)initWithTwoInts:(inout int)x second:(int)y;
  8. - (int)getInt;
  9. - (id)getSelf;
  10. @end
  11. @protocol P1;
  12. @protocol P2<P1>
  13. + (id)alloc;
  14. @end
  15. @interface A <P1>
  16. - (id)init;
  17. - (int)getValue;
  18. @end
  19. @interface B : A<P2>
  20. - (id)initWithInt:(int)x;
  21. - (int)getSecondValue;
  22. - (id)getSelf;
  23. - (int)setValue:(int)x;
  24. @end
  25. @interface B (FooBar)
  26. - (id)categoryFunction:(int)x;
  27. @end
  28. @implementation B
  29. - (int)getSecondValue { return 0; }
  30. - (id)init { return self; }
  31. - (id)getSelf { return self; }
  32. - (void)setValue:(int)x { }
  33. - (id)initWithTwoInts:(int)x second:(int)y { return self; }
  34. + (id)alloc { return 0; }
  35. @end
  36. @implementation B (FooBar)
  37. - (id)categoryFunction:(int)x { return self; }
  38. @end
  39. @interface C
  40. - (int)first:(int)x second:(float)y third:(double)z;
  41. - (id)first:(int)xx second2:(float)y2 third:(double)z;
  42. - (void*)first:(int)xxx second3:(float)y3 third:(double)z;
  43. @end
  44. @interface D
  45. - (int)first:(int)x second2:(float)y third:(double)z;
  46. @end
  47. @implementation D
  48. - (int)first:(int)x second2:(float)y third:(double)z { }
  49. @end
  50. @interface Passing
  51. - (oneway void)method:(in id)x;
  52. @end
  53. @interface Gaps
  54. - (void)method:(int)x :(int)y;
  55. @end
  56. @implementation Gaps
  57. - (void)method:(int)x :(int)y {}
  58. @end
  59. @implementation Passing
  60. - (oneway void)method:(in id x) {}
  61. @end
  62. // RUN: c-index-test -code-completion-at=%s:17:3 %s | FileCheck -check-prefix=CHECK-CC1 %s
  63. // CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText abc} (40)
  64. // CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text int}{RightParen )}{TypedText getInt} (40)
  65. // CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText getSelf} (40)
  66. // CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText initWithInt}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x} (40)
  67. // CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText initWithTwoInts}{TypedText :}{LeftParen (}{Text inout }{Text int}{RightParen )}{Text x}{HorizontalSpace }{TypedText second:}{LeftParen (}{Text int}{RightParen )}{Text y} (40)
  68. // RUN: c-index-test -code-completion-at=%s:17:7 %s | FileCheck -check-prefix=CHECK-CC2 %s
  69. // CHECK-CC2: ObjCInstanceMethodDecl:{TypedText abc}
  70. // CHECK-CC2-NEXT: ObjCInstanceMethodDecl:{TypedText getSelf}
  71. // CHECK-CC2: ObjCInstanceMethodDecl:{TypedText initWithInt}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}
  72. // CHECK-CC2: ObjCInstanceMethodDecl:{TypedText initWithTwoInts}{TypedText :}{LeftParen (}{Text inout }{Text int}{RightParen )}{Text x}{HorizontalSpace }{TypedText second:}{LeftParen (}{Text int}{RightParen )}{Text y}
  73. // RUN: c-index-test -code-completion-at=%s:24:7 %s | FileCheck -check-prefix=CHECK-CC3 %s
  74. // CHECK-CC3: ObjCInstanceMethodDecl:{TypedText abc}
  75. // CHECK-CC3-NEXT: ObjCInstanceMethodDecl:{TypedText getSelf}
  76. // CHECK-CC3: ObjCInstanceMethodDecl:{TypedText init}
  77. // CHECK-CC3: ObjCInstanceMethodDecl:{TypedText initWithInt}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}
  78. // CHECK-CC3: ObjCInstanceMethodDecl:{TypedText initWithTwoInts}{TypedText :}{LeftParen (}{Text inout }{Text int}{RightParen )}{Text x}{HorizontalSpace }{TypedText second:}{LeftParen (}{Text int}{RightParen )}{Text y}
  79. // RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:33:3 %s | FileCheck -check-prefix=CHECK-CC4 %s
  80. // CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText abc}{HorizontalSpace }{LeftBrace {}{VerticalSpace }{Text return}{HorizontalSpace }{Placeholder expression}{SemiColon ;}{VerticalSpace }{RightBrace }} (42)
  81. // CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text int}{RightParen )}{TypedText getInt}{HorizontalSpace }{LeftBrace {}{VerticalSpace
  82. // CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text int}{RightParen )}{TypedText getSecondValue}{HorizontalSpace }{LeftBrace {}{VerticalSpace
  83. // CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText getSelf}{HorizontalSpace }{LeftBrace {}{VerticalSpace }{Text return}{HorizontalSpace }{Placeholder expression}{SemiColon ;}{VerticalSpace }{RightBrace }} (40)
  84. // CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText initWithInt}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace
  85. // CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText initWithTwoInts}{TypedText :}{LeftParen (}{Text inout }{Text int}{RightParen )}{Text x}{HorizontalSpace }{TypedText second:}{LeftParen (}{Text int}{RightParen )}{Text y}{HorizontalSpace }{LeftBrace {}{VerticalSpace
  86. // CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text int}{RightParen )}{TypedText setValue}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace
  87. // RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:33:8 %s | FileCheck -check-prefix=CHECK-CC5 %s
  88. // CHECK-CC5: ObjCInstanceMethodDecl:{TypedText getInt}{HorizontalSpace }{LeftBrace {}{VerticalSpace }{Text return}{HorizontalSpace }{Placeholder expression}{SemiColon ;}{VerticalSpace }{RightBrace }} (42)
  89. // CHECK-CC5: ObjCInstanceMethodDecl:{TypedText getSecondValue}{HorizontalSpace }{LeftBrace {}{VerticalSpace }{Text return}{HorizontalSpace }{Placeholder expression}{SemiColon ;}{VerticalSpace }{RightBrace }} (40)
  90. // CHECK-CC5-NOT: {TypedText getSelf}{HorizontalSpace }{LeftBrace {}{VerticalSpace
  91. // CHECK-CC5: ObjCInstanceMethodDecl:{TypedText setValue}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace
  92. // RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:37:7 %s | FileCheck -check-prefix=CHECK-CC6 %s
  93. // CHECK-CC6: ObjCInstanceMethodDecl:{TypedText abc}{HorizontalSpace }{LeftBrace {}{VerticalSpace
  94. // CHECK-CC6: ObjCInstanceMethodDecl:{TypedText getSelf}{HorizontalSpace }{LeftBrace {}{VerticalSpace }{Text return}{HorizontalSpace }{Placeholder expression}{SemiColon ;}{VerticalSpace }{RightBrace }} (40)
  95. // CHECK-CC6: ObjCInstanceMethodDecl:{TypedText initWithInt}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace
  96. // CHECK-CC6: ObjCInstanceMethodDecl:{TypedText initWithTwoInts}{TypedText :}{LeftParen (}{Text inout }{Text int}{RightParen )}{Text x}{HorizontalSpace }{TypedText second:}{LeftParen (}{Text int}{RightParen )}{Text y}{HorizontalSpace }{LeftBrace {}{VerticalSpace
  97. // RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:42:3 %s | FileCheck -check-prefix=CHECK-CC7 %s
  98. // CHECK-CC7: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText abc}{HorizontalSpace }{LeftBrace {}{VerticalSpace }{Text return}{HorizontalSpace }{Placeholder expression}{SemiColon ;}{VerticalSpace }{RightBrace }} (42)
  99. // CHECK-CC7: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText categoryFunction}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace
  100. // CHECK-CC7: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText getSelf}{HorizontalSpace }{LeftBrace {}{VerticalSpace }{Text return}{HorizontalSpace }{Placeholder expression}{SemiColon ;}{VerticalSpace }{RightBrace }} (42)
  101. // RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:52:21 %s | FileCheck -check-prefix=CHECK-CC8 %s
  102. // CHECK-CC8: ObjCInstanceMethodDecl:{ResultType id}{Informative first:}{TypedText second2:}{Text (float)y2}{HorizontalSpace }{TypedText third:}{Text (double)z} (35)
  103. // CHECK-CC8: ObjCInstanceMethodDecl:{ResultType void *}{Informative first:}{TypedText second3:}{Text (float)y3}{HorizontalSpace }{TypedText third:}{Text (double)z} (35)
  104. // CHECK-CC8: ObjCInstanceMethodDecl:{ResultType int}{Informative first:}{TypedText second:}{Text (float)y}{HorizontalSpace }{TypedText third:}{Text (double)z} (8)
  105. // RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:52:19 %s | FileCheck -check-prefix=CHECK-CC9 %s
  106. // CHECK-CC9: NotImplemented:{TypedText x} (40)
  107. // CHECK-CC9: NotImplemented:{TypedText xx} (40)
  108. // CHECK-CC9: NotImplemented:{TypedText xxx} (40)
  109. // RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:52:36 %s | FileCheck -check-prefix=CHECK-CCA %s
  110. // CHECK-CCA: NotImplemented:{TypedText y2} (40)
  111. // RUN: c-index-test -code-completion-at=%s:56:3 %s | FileCheck -check-prefix=CHECK-CCB %s
  112. // CHECK-CCB: ObjCInstanceMethodDecl:{LeftParen (}{Text int}{RightParen )}{TypedText first}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{TypedText second2:}{LeftParen (}{Text float}{RightParen )}{Text y}{HorizontalSpace }{TypedText third:}{LeftParen (}{Text double}{RightParen )}{Text z} (40)
  113. // RUN: c-index-test -code-completion-at=%s:56:8 %s | FileCheck -check-prefix=CHECK-CCC %s
  114. // CHECK-CCC: ObjCInstanceMethodDecl:{TypedText first}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{TypedText second2:}{LeftParen (}{Text float}{RightParen )}{Text y}{HorizontalSpace }{TypedText third:}{LeftParen (}{Text double}{RightParen )}{Text z} (40)
  115. // RUN: c-index-test -code-completion-at=%s:56:21 %s | FileCheck -check-prefix=CHECK-CCD %s
  116. // CHECK-CCD: ObjCInstanceMethodDecl:{ResultType id}{Informative first:}{TypedText second2:}{Text (float)y2}{HorizontalSpace }{TypedText third:}{Text (double)z} (35)
  117. // CHECK-CCD: ObjCInstanceMethodDecl:{ResultType int}{Informative first:}{TypedText second2:}{Text (float)y}{HorizontalSpace }{TypedText third:}{Text (double)z} (8)
  118. // CHECK-CCD: ObjCInstanceMethodDecl:{ResultType void *}{Informative first:}{TypedText second3:}{Text (float)y3}{HorizontalSpace }{TypedText third:}{Text (double)z} (35)
  119. // CHECK-CCD: ObjCInstanceMethodDecl:{ResultType int}{Informative first:}{TypedText second:}{Text (float)y}{HorizontalSpace }{TypedText third:}{Text (double)z} (8)
  120. // RUN: c-index-test -code-completion-at=%s:56:38 %s | FileCheck -check-prefix=CHECK-CCE %s
  121. // CHECK-CCE: ObjCInstanceMethodDecl:{ResultType id}{Informative first:}{Informative second2:}{TypedText third:}{Text (double)z} (35)
  122. // CHECK-CCE: ObjCInstanceMethodDecl:{ResultType int}{Informative first:}{Informative second2:}{TypedText third:}{Text (double)z} (8)
  123. // RUN: c-index-test -code-completion-at=%s:60:4 %s | FileCheck -check-prefix=CHECK-CCF %s
  124. // CHECK-CCF: ObjCInterfaceDecl:{TypedText A} (50)
  125. // CHECK-CCF: ObjCInterfaceDecl:{TypedText B} (50)
  126. // CHECK-CCF: NotImplemented:{TypedText bycopy} (40)
  127. // CHECK-CCF: NotImplemented:{TypedText byref} (40)
  128. // CHECK-CCF: NotImplemented:{TypedText in} (40)
  129. // CHECK-CCF: NotImplemented:{TypedText inout} (40)
  130. // CHECK-CCF: NotImplemented:{TypedText oneway} (40)
  131. // CHECK-CCF: NotImplemented:{TypedText out} (40)
  132. // CHECK-CCF: NotImplemented:{TypedText unsigned} (50)
  133. // CHECK-CCF: NotImplemented:{TypedText void} (50)
  134. // CHECK-CCF: NotImplemented:{TypedText volatile} (50)
  135. // RUN: c-index-test -code-completion-at=%s:60:11 %s | FileCheck -check-prefix=CHECK-CCG %s
  136. // CHECK-CCG: ObjCInterfaceDecl:{TypedText A} (50)
  137. // CHECK-CCG: ObjCInterfaceDecl:{TypedText B} (50)
  138. // CHECK-CCG-NOT: NotImplemented:{TypedText bycopy} (40)
  139. // CHECK-CCG-NOT: NotImplemented:{TypedText byref} (40)
  140. // CHECK-CCG: NotImplemented:{TypedText in} (40)
  141. // CHECK-CCG: NotImplemented:{TypedText inout} (40)
  142. // CHECK-CCG-NOT: NotImplemented:{TypedText oneway} (40)
  143. // CHECK-CCG: NotImplemented:{TypedText out} (40)
  144. // CHECK-CCG: NotImplemented:{TypedText unsigned} (50)
  145. // CHECK-CCG: NotImplemented:{TypedText void} (50)
  146. // CHECK-CCG: NotImplemented:{TypedText volatile} (50)
  147. // RUN: c-index-test -code-completion-at=%s:60:24 %s | FileCheck -check-prefix=CHECK-CCF %s
  148. // RUN: c-index-test -code-completion-at=%s:60:26 %s | FileCheck -check-prefix=CHECK-CCH %s
  149. // CHECK-CCH: ObjCInterfaceDecl:{TypedText A} (50)
  150. // CHECK-CCH: ObjCInterfaceDecl:{TypedText B} (50)
  151. // CHECK-CCH: NotImplemented:{TypedText bycopy} (40)
  152. // CHECK-CCH: NotImplemented:{TypedText byref} (40)
  153. // CHECK-CCH-NOT: NotImplemented:{TypedText in} (40)
  154. // CHECK-CCH: NotImplemented:{TypedText inout} (40)
  155. // CHECK-CCH: NotImplemented:{TypedText oneway} (40)
  156. // CHECK-CCH: NotImplemented:{TypedText out} (40)
  157. // CHECK-CCH: NotImplemented:{TypedText unsigned} (50)
  158. // CHECK-CCH: NotImplemented:{TypedText void} (50)
  159. // CHECK-CCH: NotImplemented:{TypedText volatile} (50)
  160. // IBAction completion
  161. // RUN: c-index-test -code-completion-at=%s:5:4 %s | FileCheck -check-prefix=CHECK-IBACTION %s
  162. // CHECK-IBACTION: NotImplemented:{TypedText IBAction}{RightParen )}{Placeholder selector}{Colon :}{LeftParen (}{Text id}{RightParen )}{Text sender} (40)
  163. // <rdar://problem/8939352>
  164. // RUN: c-index-test -code-completion-at=%s:68:9 %s | FileCheck -check-prefix=CHECK-8939352 %s
  165. // CHECK-8939352: ObjCInstanceMethodDecl:{TypedText method}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text y} (40)
  166. // RUN: c-index-test -code-completion-at=%s:72:2 %s | FileCheck -check-prefix=CHECK-ONEWAY %s
  167. // CHECK-ONEWAY: ObjCInstanceMethodDecl:{LeftParen (}{Text oneway }{Text void}{RightParen )}{TypedText method}{TypedText :}{LeftParen (}{Text in }{Text id}{RightParen )}{Text x} (40)