[cfe-commits] r89265 - in /cfe/trunk: include/clang/Parse/Action.h lib/Parse/ParseObjc.cpp lib/Sema/Sema.h lib/Sema/SemaCodeComplete.cpp test/Index/complete-properties.m

Douglas Gregor dgregor at apple.com
Wed Nov 18 14:56:13 PST 2009


Author: dgregor
Date: Wed Nov 18 16:56:13 2009
New Revision: 89265

URL: http://llvm.org/viewvc/llvm-project?rev=89265&view=rev
Log:
Code completion after @dynamic

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-properties.m

Modified: cfe/trunk/include/clang/Parse/Action.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Action.h?rev=89265&r1=89264&r2=89265&view=diff

==============================================================================
--- cfe/trunk/include/clang/Parse/Action.h (original)
+++ cfe/trunk/include/clang/Parse/Action.h Wed Nov 18 16:56:13 2009
@@ -2408,12 +2408,12 @@
                                                    IdentifierInfo *ClassName) {
   }
   
-  /// \brief Code completion for the property names when synthesizing an
+  /// \brief Code completion for the property names when defining an
   /// Objective-C property.
   ///
-  /// This code completion action is invoked after the @synthesized and after
-  /// each "," in an @synthesized definition.
-  virtual void CodeCompleteObjCPropertySynthesize(Scope *S, 
+  /// This code completion action is invoked after @synthesize or @dynamic and
+  /// after each "," within one of those definitions.
+  virtual void CodeCompleteObjCPropertyDefinition(Scope *S, 
                                                   DeclPtrTy ObjCImpDecl) {
   }
 

Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=89265&r1=89264&r2=89265&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Wed Nov 18 16:56:13 2009
@@ -1234,7 +1234,7 @@
 
   while (true) {
     if (Tok.is(tok::code_completion)) {
-      Actions.CodeCompleteObjCPropertySynthesize(CurScope, ObjCImpDecl);
+      Actions.CodeCompleteObjCPropertyDefinition(CurScope, ObjCImpDecl);
       ConsumeToken();
     }
     
@@ -1290,11 +1290,18 @@
   assert(Tok.isObjCAtKeyword(tok::objc_dynamic) &&
          "ParseObjCPropertyDynamic(): Expected '@dynamic'");
   SourceLocation loc = ConsumeToken(); // consume dynamic
-  if (Tok.isNot(tok::identifier)) {
-    Diag(Tok, diag::err_expected_ident);
-    return DeclPtrTy();
-  }
-  while (Tok.is(tok::identifier)) {
+  while (true) {
+    if (Tok.is(tok::code_completion)) {
+      Actions.CodeCompleteObjCPropertyDefinition(CurScope, ObjCImpDecl);
+      ConsumeToken();
+    }
+    
+    if (Tok.isNot(tok::identifier)) {
+      Diag(Tok, diag::err_expected_ident);
+      SkipUntil(tok::semi);
+      return DeclPtrTy();
+    }
+    
     IdentifierInfo *propertyId = Tok.getIdentifierInfo();
     SourceLocation propertyLoc = ConsumeToken(); // consume property name
     Actions.ActOnPropertyImplDecl(atLoc, propertyLoc, false, ObjCImpDecl,

Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=89265&r1=89264&r2=89265&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Wed Nov 18 16:56:13 2009
@@ -3661,7 +3661,7 @@
                                                  IdentifierInfo *ClassName);
   virtual void CodeCompleteObjCImplementationCategory(Scope *S, 
                                                     IdentifierInfo *ClassName);
-  virtual void CodeCompleteObjCPropertySynthesize(Scope *S, 
+  virtual void CodeCompleteObjCPropertyDefinition(Scope *S, 
                                                   DeclPtrTy ObjCImpDecl);
   virtual void CodeCompleteObjCPropertySynthesizeIvar(Scope *S, 
                                                   IdentifierInfo *PropertyName,

Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=89265&r1=89264&r2=89265&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Wed Nov 18 16:56:13 2009
@@ -2026,7 +2026,7 @@
   HandleCodeCompleteResults(this, CodeCompleter, Results.data(),Results.size());  
 }
 
-void Sema::CodeCompleteObjCPropertySynthesize(Scope *S, DeclPtrTy ObjCImpDecl) {
+void Sema::CodeCompleteObjCPropertyDefinition(Scope *S, DeclPtrTy ObjCImpDecl) {
   typedef CodeCompleteConsumer::Result Result;
   ResultBuilder Results(*this);
 

Modified: cfe/trunk/test/Index/complete-properties.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-properties.m?rev=89265&r1=89264&r2=89265&view=diff

==============================================================================
--- cfe/trunk/test/Index/complete-properties.m (original)
+++ cfe/trunk/test/Index/complete-properties.m Wed Nov 18 16:56:13 2009
@@ -6,25 +6,35 @@
   id StoredProp3;
   int RandomIVar;
 }
+ at property int Prop0;
 @property int Prop1;
 @property float Prop2;
 @end
 
 @interface I2 : I1
 @property id Prop3;
+ at property id Prop4;
 @end
 
 @implementation I2
 @synthesize Prop2, Prop1, Prop3 = StoredProp3;
+ at dynamic Prop4;
 @end
 
-// RUN: c-index-test -code-completion-at=%s:18:13 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: c-index-test -code-completion-at=%s:20:13 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: ObjCPropertyDecl:{TypedText Prop0}
 // CHECK-CC1: ObjCPropertyDecl:{TypedText Prop1}
 // CHECK-CC1: ObjCPropertyDecl:{TypedText Prop2}
 // CHECK-CC1: ObjCPropertyDecl:{TypedText Prop3}
-// RUN: c-index-test -code-completion-at=%s:18:20 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC1: ObjCPropertyDecl:{TypedText Prop4}
+// RUN: c-index-test -code-completion-at=%s:20:20 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC2: ObjCPropertyDecl:{TypedText Prop0}
 // CHECK-CC2: ObjCPropertyDecl:{TypedText Prop1}
 // CHECK-CC2-NEXT: ObjCPropertyDecl:{TypedText Prop3}
-// RUN: c-index-test -code-completion-at=%s:18:35 %s | FileCheck -check-prefix=CHECK-CC3 %s
+// CHECK-CC2: ObjCPropertyDecl:{TypedText Prop4}
+// RUN: c-index-test -code-completion-at=%s:20:35 %s | FileCheck -check-prefix=CHECK-CC3 %s
 // CHECK-CC3: ObjCIvarDecl:{TypedText RandomIVar}
 // CHECK-CC3: ObjCIvarDecl:{TypedText StoredProp3}
+// RUN: c-index-test -code-completion-at=%s:21:10 %s | FileCheck -check-prefix=CHECK-CC4 %s
+// CHECK-CC4: ObjCPropertyDecl:{TypedText Prop0}
+// CHECK-CC4-NEXT: ObjCPropertyDecl:{TypedText Prop4}





More information about the cfe-commits mailing list