aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaCodeComplete.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-12-07 09:27:33 +0000
committerDouglas Gregor <dgregor@apple.com>2009-12-07 09:27:33 +0000
commitc464ae8444edb6d07ea49b7a0eae1674c0fa1bb8 (patch)
tree596d020c3f29ae3b5d0851e634529b7766fc4c13 /lib/Sema/SemaCodeComplete.cpp
parent935ef90f4b065c7c865ee5b2a99c5f9b1a115d72 (diff)
Code completion for Objective-C @ directives
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90756 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaCodeComplete.cpp')
-rw-r--r--lib/Sema/SemaCodeComplete.cpp88
1 files changed, 88 insertions, 0 deletions
diff --git a/lib/Sema/SemaCodeComplete.cpp b/lib/Sema/SemaCodeComplete.cpp
index 5f9bba0f8c..5e231a54d1 100644
--- a/lib/Sema/SemaCodeComplete.cpp
+++ b/lib/Sema/SemaCodeComplete.cpp
@@ -1847,6 +1847,94 @@ void Sema::CodeCompleteOperatorName(Scope *S) {
HandleCodeCompleteResults(this, CodeCompleter, Results.data(),Results.size());
}
+void Sema::CodeCompleteObjCAtDirective(Scope *S, DeclPtrTy ObjCImpDecl,
+ bool InInterface) {
+ typedef CodeCompleteConsumer::Result Result;
+ ResultBuilder Results(*this);
+ Results.EnterNewScope();
+ if (ObjCImpDecl) {
+ // Since we have an implementation, we can end it.
+ Results.MaybeAddResult(Result("end", 0));
+
+ CodeCompletionString *Pattern = 0;
+ Decl *ImpDecl = ObjCImpDecl.getAs<Decl>();
+ if (isa<ObjCImplementationDecl>(ImpDecl) ||
+ isa<ObjCCategoryImplDecl>(ImpDecl)) {
+ // @dynamic
+ Pattern = new CodeCompletionString;
+ Pattern->AddTypedTextChunk("dynamic");
+ Pattern->AddTextChunk(" ");
+ Pattern->AddPlaceholderChunk("property");
+ Results.MaybeAddResult(Result(Pattern, 0));
+
+ // @synthesize
+ Pattern = new CodeCompletionString;
+ Pattern->AddTypedTextChunk("synthesize");
+ Pattern->AddTextChunk(" ");
+ Pattern->AddPlaceholderChunk("property");
+ Results.MaybeAddResult(Result(Pattern, 0));
+ }
+ } else if (InInterface) {
+ // Since we have an interface or protocol, we can end it.
+ Results.MaybeAddResult(Result("end", 0));
+
+ if (LangOpts.ObjC2) {
+ // @property
+ Results.MaybeAddResult(Result("property", 0));
+ }
+
+ // @required
+ Results.MaybeAddResult(Result("required", 0));
+
+ // @optional
+ Results.MaybeAddResult(Result("optional", 0));
+ } else {
+ CodeCompletionString *Pattern = 0;
+
+ // @class name ;
+ Pattern = new CodeCompletionString;
+ Pattern->AddTypedTextChunk("class");
+ Pattern->AddTextChunk(" ");
+ Pattern->AddPlaceholderChunk("identifier");
+ Pattern->AddTextChunk(";"); // add ';' chunk
+ Results.MaybeAddResult(Result(Pattern, 0));
+
+ // @interface name
+ // FIXME: Could introduce the whole pattern, including superclasses and
+ // such.
+ Pattern = new CodeCompletionString;
+ Pattern->AddTypedTextChunk("interface");
+ Pattern->AddTextChunk(" ");
+ Pattern->AddPlaceholderChunk("class");
+ Results.MaybeAddResult(Result(Pattern, 0));
+
+ // @protocol name
+ Pattern = new CodeCompletionString;
+ Pattern->AddTypedTextChunk("protocol");
+ Pattern->AddTextChunk(" ");
+ Pattern->AddPlaceholderChunk("protocol");
+ Results.MaybeAddResult(Result(Pattern, 0));
+
+ // @implementation name
+ Pattern = new CodeCompletionString;
+ Pattern->AddTypedTextChunk("implementation");
+ Pattern->AddTextChunk(" ");
+ Pattern->AddPlaceholderChunk("class");
+ Results.MaybeAddResult(Result(Pattern, 0));
+
+ // @compatibility_alias name
+ Pattern = new CodeCompletionString;
+ Pattern->AddTypedTextChunk("compatibility_alias");
+ Pattern->AddTextChunk(" ");
+ Pattern->AddPlaceholderChunk("alias");
+ Pattern->AddTextChunk(" ");
+ Pattern->AddPlaceholderChunk("class");
+ Results.MaybeAddResult(Result(Pattern, 0));
+ }
+ Results.ExitScope();
+ HandleCodeCompleteResults(this, CodeCompleter, Results.data(),Results.size());
+}
+
/// \brief Determine whether the addition of the given flag to an Objective-C
/// property's attributes will cause a conflict.
static bool ObjCPropertyFlagConflicts(unsigned Attributes, unsigned NewFlag) {