[cfe-commits] r93361 - in /cfe/trunk: include/clang/Parse/Action.h lib/Parse/ParseObjc.cpp lib/Sema/Sema.h lib/Sema/SemaCodeComplete.cpp test/Index/complete-at-directives.m
Douglas Gregor
dgregor at apple.com
Wed Jan 13 13:54:15 PST 2010
Author: dgregor
Date: Wed Jan 13 15:54:15 2010
New Revision: 93361
URL: http://llvm.org/viewvc/llvm-project?rev=93361&view=rev
Log:
Code-completion for @public, @protected, @private, @package.
Modified:
cfe/trunk/include/clang/Parse/Action.h
cfe/trunk/lib/Parse/ParseObjc.cpp
cfe/trunk/lib/Sema/Sema.h
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/test/Index/complete-at-directives.m
Modified: cfe/trunk/include/clang/Parse/Action.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Action.h?rev=93361&r1=93360&r2=93361&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/Action.h (original)
+++ cfe/trunk/include/clang/Parse/Action.h Wed Jan 13 15:54:15 2010
@@ -2388,7 +2388,9 @@
/// \brief Code completion occurs within an Objective-C implementation or
/// category implementation
CCC_ObjCImplementation,
- /// \brief Code completion occurs within
+ /// \brief Code completion occurs within the list of instance variables
+ /// in an Objective-C interface, protocol, category, or implementation.
+ CCC_ObjCInstanceVariableList,
/// \brief Code completion occurs following one or more template
/// headers.
CCC_Template,
@@ -2531,6 +2533,9 @@
virtual void CodeCompleteObjCAtDirective(Scope *S, DeclPtrTy ObjCImpDecl,
bool InInterface) { }
+ /// \brief Code completion after the '@' in the list of instance variables.
+ virtual void CodeCompleteObjCAtVisibility(Scope *S) { }
+
/// \brief Code completion after the '@' in a statement.
virtual void CodeCompleteObjCAtStatement(Scope *S) { }
Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=93361&r1=93360&r2=93361&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Wed Jan 13 15:54:15 2010
@@ -973,6 +973,12 @@
// Set the default visibility to private.
if (Tok.is(tok::at)) { // parse objc-visibility-spec
ConsumeToken(); // eat the @ sign
+
+ if (Tok.is(tok::code_completion)) {
+ Actions.CodeCompleteObjCAtVisibility(CurScope);
+ ConsumeToken();
+ }
+
switch (Tok.getObjCKeywordID()) {
case tok::objc_private:
case tok::objc_public:
@@ -987,6 +993,12 @@
}
}
+ if (Tok.is(tok::code_completion)) {
+ Actions.CodeCompleteOrdinaryName(CurScope,
+ Action::CCC_ObjCInstanceVariableList);
+ ConsumeToken();
+ }
+
struct ObjCIvarCallback : FieldCallback {
Parser &P;
DeclPtrTy IDecl;
Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=93361&r1=93360&r2=93361&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Wed Jan 13 15:54:15 2010
@@ -3851,6 +3851,7 @@
virtual void CodeCompleteObjCAtDirective(Scope *S, DeclPtrTy ObjCImpDecl,
bool InInterface);
+ virtual void CodeCompleteObjCAtVisibility(Scope *S);
virtual void CodeCompleteObjCAtStatement(Scope *S);
virtual void CodeCompleteObjCAtExpression(Scope *S);
virtual void CodeCompleteObjCPropertyFlags(Scope *S, ObjCDeclSpec &ODS);
Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=93361&r1=93360&r2=93361&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Wed Jan 13 15:54:15 2010
@@ -893,6 +893,7 @@
Results.MaybeAddResult(Result("inline", Rank));
break;
+ case Action::CCC_ObjCInstanceVariableList:
case Action::CCC_Expression:
case Action::CCC_Statement:
case Action::CCC_ForInit:
@@ -905,6 +906,10 @@
bool NeedAt);
static void AddObjCStatementResults(unsigned Rank, ResultBuilder &Results,
bool NeedAt);
+static void AddObjCVisibilityResults(unsigned Rank,
+ const LangOptions &LangOpts,
+ ResultBuilder &Results,
+ bool NeedAt);
static void AddObjCImplementationResults(unsigned Rank,
const LangOptions &LangOpts,
ResultBuilder &Results,
@@ -1053,6 +1058,10 @@
AddFunctionSpecifiers(CCC, SemaRef.getLangOptions(), Rank, Results);
break;
+ case Action::CCC_ObjCInstanceVariableList:
+ AddObjCVisibilityResults(Rank, SemaRef.getLangOptions(), Results, true);
+ break;
+
case Action::CCC_Statement: {
Results.MaybeAddResult(Result("typedef", Rank));
@@ -1971,6 +1980,7 @@
case CCC_Class:
case CCC_ObjCInterface:
case CCC_ObjCImplementation:
+ case CCC_ObjCInstanceVariableList:
case CCC_Template:
case CCC_MemberTemplate:
Results.setFilter(&ResultBuilder::IsOrdinaryNonValueName);
@@ -2672,8 +2682,27 @@
Results.MaybeAddResult(Result(Pattern, 0));
}
-void Sema::CodeCompleteObjCAtStatement(Scope *S) {
+static void AddObjCVisibilityResults(unsigned Rank,
+ const LangOptions &LangOpts,
+ ResultBuilder &Results,
+ bool NeedAt) {
typedef CodeCompleteConsumer::Result Result;
+ Results.MaybeAddResult(Result(OBJC_AT_KEYWORD_NAME(NeedAt,private), Rank));
+ Results.MaybeAddResult(Result(OBJC_AT_KEYWORD_NAME(NeedAt,protected), Rank));
+ Results.MaybeAddResult(Result(OBJC_AT_KEYWORD_NAME(NeedAt,public), Rank));
+ if (LangOpts.ObjC2)
+ Results.MaybeAddResult(Result(OBJC_AT_KEYWORD_NAME(NeedAt,package), Rank));
+}
+
+void Sema::CodeCompleteObjCAtVisibility(Scope *S) {
+ ResultBuilder Results(*this);
+ Results.EnterNewScope();
+ AddObjCVisibilityResults(0, getLangOptions(), Results, false);
+ Results.ExitScope();
+ HandleCodeCompleteResults(this, CodeCompleter, Results.data(),Results.size());
+}
+
+void Sema::CodeCompleteObjCAtStatement(Scope *S) {
ResultBuilder Results(*this);
Results.EnterNewScope();
AddObjCStatementResults(0, Results, false);
Modified: cfe/trunk/test/Index/complete-at-directives.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-at-directives.m?rev=93361&r1=93360&r2=93361&view=diff
==============================================================================
--- cfe/trunk/test/Index/complete-at-directives.m (original)
+++ cfe/trunk/test/Index/complete-at-directives.m Wed Jan 13 15:54:15 2010
@@ -1,5 +1,5 @@
/* Run lines are at the end, since line/column matter in this test. */
- at interface MyClass { }
+ at interface MyClass { @public }
@end
@implementation MyClass
@@ -44,3 +44,16 @@
// CHECK-CC5: ObjCInterfaceDecl:{TypedText MyClass}
// CHECK-CC5: TypedefDecl:{TypedText SEL}
// CHECK-CC5: NotImplemented:{TypedText _Bool}
+
+// RUN: c-index-test -code-completion-at=%s:2:23 %s | FileCheck -check-prefix=CHECK-CC6 %s
+// CHECK-CC6: NotImplemented:{TypedText package}
+// CHECK-CC6: NotImplemented:{TypedText private}
+// CHECK-CC6: NotImplemented:{TypedText protected}
+// CHECK-CC6: NotImplemented:{TypedText public}
+
+// RUN: c-index-test -code-completion-at=%s:2:22 %s | FileCheck -check-prefix=CHECK-CC7 %s
+// CHECK-CC7: NotImplemented:{TypedText @package}
+// CHECK-CC7: NotImplemented:{TypedText @private}
+// CHECK-CC7: NotImplemented:{TypedText @protected}
+// CHECK-CC7: NotImplemented:{TypedText @public}
+// CHECK-CC7: NotImplemented:{TypedText _Bool}
More information about the cfe-commits
mailing list