aboutsummaryrefslogtreecommitdiff
path: root/lib/Frontend/ASTUnit.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-07-07 16:03:39 +0000
committerDouglas Gregor <dgregor@apple.com>2011-07-07 16:03:39 +0000
commit3da626b4f38eb0350de960d71271ca77af7a9cc8 (patch)
tree7033914fa939a04b65cef3767a1e4524149f7ad9 /lib/Frontend/ASTUnit.cpp
parent63ff703393543904046462aee2ac0a53b8937a3e (diff)
Introduce a new libclang aPI function,
clang_codeCompleteGetContexts(), that provides the client with information about the context in which code completion has occurred and what kinds of entities make sense as completions at that point. Patch by Connor Wakamo! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134615 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/ASTUnit.cpp')
-rw-r--r--lib/Frontend/ASTUnit.cpp46
1 files changed, 30 insertions, 16 deletions
diff --git a/lib/Frontend/ASTUnit.cpp b/lib/Frontend/ASTUnit.cpp
index 4407d2d3e2..ad476455eb 100644
--- a/lib/Frontend/ASTUnit.cpp
+++ b/lib/Frontend/ASTUnit.cpp
@@ -182,6 +182,10 @@ static unsigned getDeclShowContexts(NamedDecl *ND,
// all types are available due to functional casts.
if (LangOpts.CPlusPlus || isa<ObjCInterfaceDecl>(ND))
Contexts |= (1 << (CodeCompletionContext::CCC_ObjCMessageReceiver - 1));
+
+ // In Objective-C, you can only be a subclass of another Objective-C class
+ if (isa<ObjCInterfaceDecl>(ND))
+ Contexts |= (1 << (CodeCompletionContext::CCC_ObjCSuperclass - 1));
// Deal with tag names.
if (isa<EnumDecl>(ND)) {
@@ -208,6 +212,8 @@ static unsigned getDeclShowContexts(NamedDecl *ND,
| (1 << (CodeCompletionContext::CCC_ObjCMessageReceiver - 1));
} else if (isa<ObjCProtocolDecl>(ND)) {
Contexts = (1 << (CodeCompletionContext::CCC_ObjCProtocolName - 1));
+ } else if (isa<ObjCCategoryDecl>(ND)) {
+ Contexts = (1 << (CodeCompletionContext::CCC_ObjCCategoryName - 1));
} else if (isa<NamespaceDecl>(ND) || isa<NamespaceAliasDecl>(ND)) {
Contexts = (1 << (CodeCompletionContext::CCC_Namespace - 1));
@@ -1902,7 +1908,7 @@ namespace {
/// results from an ASTUnit with the code-completion results provided to it,
/// then passes the result on to
class AugmentedCodeCompleteConsumer : public CodeCompleteConsumer {
- unsigned NormalContexts;
+ unsigned long long NormalContexts;
ASTUnit &AST;
CodeCompleteConsumer &Next;
@@ -1916,22 +1922,24 @@ namespace {
// Compute the set of contexts in which we will look when we don't have
// any information about the specific context.
NormalContexts
- = (1 << (CodeCompletionContext::CCC_TopLevel - 1))
- | (1 << (CodeCompletionContext::CCC_ObjCInterface - 1))
- | (1 << (CodeCompletionContext::CCC_ObjCImplementation - 1))
- | (1 << (CodeCompletionContext::CCC_ObjCIvarList - 1))
- | (1 << (CodeCompletionContext::CCC_Statement - 1))
- | (1 << (CodeCompletionContext::CCC_Expression - 1))
- | (1 << (CodeCompletionContext::CCC_ObjCMessageReceiver - 1))
- | (1 << (CodeCompletionContext::CCC_MemberAccess - 1))
- | (1 << (CodeCompletionContext::CCC_ObjCProtocolName - 1))
- | (1 << (CodeCompletionContext::CCC_ParenthesizedExpression - 1))
- | (1 << (CodeCompletionContext::CCC_Recovery - 1));
+ = (1LL << (CodeCompletionContext::CCC_TopLevel - 1))
+ | (1LL << (CodeCompletionContext::CCC_ObjCInterface - 1))
+ | (1LL << (CodeCompletionContext::CCC_ObjCImplementation - 1))
+ | (1LL << (CodeCompletionContext::CCC_ObjCIvarList - 1))
+ | (1LL << (CodeCompletionContext::CCC_Statement - 1))
+ | (1LL << (CodeCompletionContext::CCC_Expression - 1))
+ | (1LL << (CodeCompletionContext::CCC_ObjCMessageReceiver - 1))
+ | (1LL << (CodeCompletionContext::CCC_DotMemberAccess - 1))
+ | (1LL << (CodeCompletionContext::CCC_ArrowMemberAccess - 1))
+ | (1LL << (CodeCompletionContext::CCC_ObjCPropertyAccess - 1))
+ | (1LL << (CodeCompletionContext::CCC_ObjCProtocolName - 1))
+ | (1LL << (CodeCompletionContext::CCC_ParenthesizedExpression - 1))
+ | (1LL << (CodeCompletionContext::CCC_Recovery - 1));
if (AST.getASTContext().getLangOptions().CPlusPlus)
- NormalContexts |= (1 << (CodeCompletionContext::CCC_EnumTag - 1))
- | (1 << (CodeCompletionContext::CCC_UnionTag - 1))
- | (1 << (CodeCompletionContext::CCC_ClassOrStructTag - 1));
+ NormalContexts |= (1LL << (CodeCompletionContext::CCC_EnumTag - 1))
+ | (1LL << (CodeCompletionContext::CCC_UnionTag - 1))
+ | (1LL << (CodeCompletionContext::CCC_ClassOrStructTag - 1));
}
virtual void ProcessCodeCompleteResults(Sema &S,
@@ -1969,12 +1977,15 @@ static void CalculateHiddenNames(const CodeCompletionContext &Context,
case CodeCompletionContext::CCC_Statement:
case CodeCompletionContext::CCC_Expression:
case CodeCompletionContext::CCC_ObjCMessageReceiver:
- case CodeCompletionContext::CCC_MemberAccess:
+ case CodeCompletionContext::CCC_DotMemberAccess:
+ case CodeCompletionContext::CCC_ArrowMemberAccess:
+ case CodeCompletionContext::CCC_ObjCPropertyAccess:
case CodeCompletionContext::CCC_Namespace:
case CodeCompletionContext::CCC_Type:
case CodeCompletionContext::CCC_Name:
case CodeCompletionContext::CCC_PotentiallyQualifiedName:
case CodeCompletionContext::CCC_ParenthesizedExpression:
+ case CodeCompletionContext::CCC_ObjCSuperclass:
break;
case CodeCompletionContext::CCC_EnumTag:
@@ -1993,6 +2004,9 @@ static void CalculateHiddenNames(const CodeCompletionContext &Context,
case CodeCompletionContext::CCC_TypeQualifiers:
case CodeCompletionContext::CCC_Other:
case CodeCompletionContext::CCC_OtherWithMacros:
+ case CodeCompletionContext::CCC_ObjCInstanceMessage:
+ case CodeCompletionContext::CCC_ObjCClassMessage:
+ case CodeCompletionContext::CCC_ObjCCategoryName:
// We're looking for nothing, or we're looking for names that cannot
// be hidden.
return;