Objective-C message receiver, the user is as likely to want to write a
type name as any other declaration, so give types the same priority as
other declarations. Fixes <rdar://problem/
12480600>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174038
91177308-0d34-0410-b5e6-
96231b3b80d8
if (isa<EnumConstantDecl>(ND))
return CCP_Constant;
- if ((isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND)))
+ // Use CCP_Type for type declarations unless we're in a statement, Objective-C
+ // message receiver, or parenthesized expression context. There, it's as
+ // likely that the user will want to write a type as other declarations.
+ if ((isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND)) &&
+ !(CompletionContext.getKind() == CodeCompletionContext::CCC_Statement ||
+ CompletionContext.getKind()
+ == CodeCompletionContext::CCC_ObjCMessageReceiver ||
+ CompletionContext.getKind()
+ == CodeCompletionContext::CCC_ParenthesizedExpression))
return CCP_Type;
return CCP_Declaration;
// CHECK-CC7: FunctionDecl:{ResultType void}{TypedText f3}{LeftParen (}{Placeholder const char *, ...}{Text , NULL}{RightParen )} (50)
// CHECK-CC7: FunctionDecl:{ResultType void}{TypedText f4}{LeftParen (}{Placeholder const char *str}{RightParen )} (50)
// CHECK-CC7: FunctionDecl:{ResultType void}{TypedText f5}{LeftParen (}{Placeholder float f}{RightParen )} (50)
-// CHECK-CC7: TypedefDecl:{TypedText type}
+// CHECK-CC7: TypedefDecl:{TypedText type} (50)
// CHECK-CC9: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{Informative Arg1:}{TypedText OtherArg:}{Placeholder (id)}
// CHECK-CC9: Objective-C selector: Method:Arg1:
// RUN: c-index-test -code-completion-at=%s:61:11 %s | FileCheck -check-prefix=CHECK-CCA %s
-// CHECK-CCA: TypedefDecl:{TypedText Class}
-// CHECK-CCA-NEXT: ObjCInterfaceDecl:{TypedText Foo}
-// CHECK-CCA-NOT: FunctionDecl:{ResultType void}{TypedText func}{LeftParen (}{RightParen )}
-// CHECK-CCA:FunctionDecl:{ResultType MyClass *}{TypedText getMyClass}{LeftParen (}{RightParen )}
-// CHECK-CCA: TypedefDecl:{TypedText id}
-// CHECK-CCA: ObjCInterfaceDecl:{TypedText MyClass}
-// CHECK-CCA: ObjCInterfaceDecl:{TypedText MySubClass}
-// CHECK-CCA: {ResultType Class}{TypedText self}
-// CHECK-CCA: {TypedText super}
+// CHECK-CCA: TypedefDecl:{TypedText Class} (50)
+// CHECK-CCA-NEXT: ObjCInterfaceDecl:{TypedText Foo} (50)
+// CHECK-CCA-NOT: FunctionDecl:{ResultType void}{TypedText func}{LeftParen (}{RightParen )} (50)
+// CHECK-CCA:FunctionDecl:{ResultType MyClass *}{TypedText getMyClass}{LeftParen (}{RightParen )} (50)
+// CHECK-CCA: TypedefDecl:{TypedText id} (50)
+// CHECK-CCA: ObjCInterfaceDecl:{TypedText MyClass} (50)
+// CHECK-CCA: ObjCInterfaceDecl:{TypedText MySubClass} (50)
+// CHECK-CCA: {ResultType Class}{TypedText self} (34)
+// CHECK-CCA: {TypedText super} (40)
// RUN: c-index-test -code-completion-at=%s:103:6 %s | FileCheck -check-prefix=CHECK-CCB %s
// CHECK-CCB: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (int), ...}
// CHECK-CCB: ObjCInstanceMethodDecl:{ResultType int}{TypedText SentinelMethod:}{Placeholder (int), ...}{Text , nil}
// Note: the run lines follow their respective tests, since line/column
// matter in this test.
-
+typedef int Integer;
void f(int x) {
if (x) {
}
// RUN: c-index-test -code-completion-at=%s:7:4 %s | FileCheck -check-prefix=CHECK-IF-ELSE-SIMPLE %s
// CHECK-IF-ELSE-SIMPLE: NotImplemented:{TypedText else} (40)
// CHECK-IF-ELSE-SIMPLE: NotImplemented:{TypedText else}{HorizontalSpace }{Text if}{HorizontalSpace }{LeftParen (}{Placeholder expression}{RightParen )} (40)
+
+// RUN: c-index-test -code-completion-at=%s:6:1 %s | FileCheck -check-prefix=CHECK-STMT %s
+// CHECK-STMT: NotImplemented:{TypedText char} (50)
+// CHECK-STMT: NotImplemented:{TypedText const} (50)
+// CHECK-STMT: NotImplemented:{TypedText double} (50)
+// CHECK-STMT: NotImplemented:{TypedText enum} (50)
+// CHECK-STMT: FunctionDecl:{ResultType void}{TypedText f}{LeftParen (}{Placeholder int x}{RightParen )} (50)
+// CHECK-STMT: TypedefDecl:{TypedText Integer} (50)
+// CHECK-STMT: ParmDecl:{ResultType int}{TypedText x} (34)