[libclang] Implement proper code-completion in an ObjC type parameter position.
rdar://19670303 llvm-svn: 241561
This commit is contained in:
parent
7fa93c7730
commit
cedcd9f860
|
@ -1942,6 +1942,10 @@ public:
|
|||
Optional<ArrayRef<QualType>>
|
||||
getObjCSubstitutions(const DeclContext *dc) const;
|
||||
|
||||
/// Determines if this is an ObjC interface type that may accept type
|
||||
/// parameters.
|
||||
bool acceptsObjCTypeParams() const;
|
||||
|
||||
const char *getTypeClassName() const;
|
||||
|
||||
QualType getCanonicalTypeInternal() const {
|
||||
|
|
|
@ -1339,6 +1339,17 @@ Optional<ArrayRef<QualType>> Type::getObjCSubstitutions(
|
|||
return objectType->getTypeArgs();
|
||||
}
|
||||
|
||||
bool Type::acceptsObjCTypeParams() const {
|
||||
if (auto *IfaceT = getAsObjCInterfaceType()) {
|
||||
if (auto *ID = IfaceT->getInterface()) {
|
||||
if (ID->getTypeParamList())
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void ObjCObjectType::computeSuperClassTypeSlow() const {
|
||||
// Retrieve the class declaration for this type. If there isn't one
|
||||
// (e.g., this is some variant of "id" or "Class"), then there is no
|
||||
|
|
|
@ -1658,8 +1658,13 @@ void Parser::parseObjCTypeArgsOrProtocolQualifiers(
|
|||
identifierLocs[i]));
|
||||
}
|
||||
|
||||
Actions.CodeCompleteObjCProtocolReferences(identifierLocPairs.data(),
|
||||
identifierLocPairs.size());
|
||||
QualType BaseT = Actions.GetTypeFromParser(baseType);
|
||||
if (!BaseT.isNull() && BaseT->acceptsObjCTypeParams()) {
|
||||
Actions.CodeCompleteOrdinaryName(getCurScope(), Sema::PCC_Type);
|
||||
} else {
|
||||
Actions.CodeCompleteObjCProtocolReferences(identifierLocPairs.data(),
|
||||
identifierLocPairs.size());
|
||||
}
|
||||
cutOffParsing();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -37,6 +37,11 @@ void test2(Test *obj) {
|
|||
-(id)getit:(id)val {}
|
||||
@end
|
||||
|
||||
void test3() {
|
||||
Test<> t;
|
||||
NSObject<> n;
|
||||
}
|
||||
|
||||
// RUN: c-index-test -code-completion-at=%s:25:8 %s | FileCheck -check-prefix=CHECK-CC0 %s
|
||||
// CHECK-CC0: ObjCInstanceMethodDecl:{ResultType void}{TypedText apply2:}{Placeholder ^(MyClsA *, MyClsB *)block} (35)
|
||||
// CHECK-CC0: ObjCInstanceMethodDecl:{ResultType void}{TypedText apply:}{Placeholder ^(MyClsA *, MyClsB *)block} (35)
|
||||
|
@ -64,3 +69,11 @@ void test2(Test *obj) {
|
|||
// CHECK-CC6: ObjCInstanceMethodDecl:{LeftParen (}{Text void}{RightParen )}{TypedText apply}{TypedText :}{LeftParen (}{Text void (^)(id, NSObject *)}{RightParen )}{Text block} (40)
|
||||
// CHECK-CC6: ObjCInstanceMethodDecl:{LeftParen (}{Text NSObject *}{RightParen )}{TypedText getit}{TypedText :}{LeftParen (}{Text id}{RightParen )}{Text val} (40)
|
||||
// CHECK-CC6: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText prop} (40)
|
||||
|
||||
// RUN: c-index-test -code-completion-at=%s:41:8 %s | FileCheck -check-prefix=CHECK-CC7 %s
|
||||
// CHECK-CC7: ObjCInterfaceDecl:{TypedText MyClsA}
|
||||
// RUN: c-index-test -code-completion-at=%s:42:12 %s > %t.out
|
||||
// RUN: FileCheck -input-file=%t.out -check-prefix=CHECK-CC8 %s
|
||||
// RUN: FileCheck -input-file=%t.out -check-prefix=CHECK-CC9 %s
|
||||
// CHECK-CC8: ObjCProtocolDecl:{TypedText NSObject}
|
||||
// CHECK-CC9-NOT: ObjCInterfaceDecl:{TypedText MyClsA}
|
||||
|
|
Loading…
Reference in New Issue