]> granicus.if.org Git - clang/commitdiff
Code completion after @dynamic
authorDouglas Gregor <dgregor@apple.com>
Wed, 18 Nov 2009 22:56:13 +0000 (22:56 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 18 Nov 2009 22:56:13 +0000 (22:56 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89265 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Parse/Action.h
lib/Parse/ParseObjc.cpp
lib/Sema/Sema.h
lib/Sema/SemaCodeComplete.cpp
test/Index/complete-properties.m

index 3165b0eb2f40e4b5f30c22c73d4dcb1d6a4dd88a..0c1335cb70bcf45d864cf588bc5e5ec77ccb8ed5 100644 (file)
@@ -2408,12 +2408,12 @@ public:
                                                    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) {
   }
 
index 305ed16a193d4c31d7ddd7dba90ba5e6aa8c7853..216d9345cb04c77d32a79835cdedd8af43409684 100644 (file)
@@ -1234,7 +1234,7 @@ Parser::DeclPtrTy Parser::ParseObjCPropertySynthesize(SourceLocation atLoc) {
 
   while (true) {
     if (Tok.is(tok::code_completion)) {
-      Actions.CodeCompleteObjCPropertySynthesize(CurScope, ObjCImpDecl);
+      Actions.CodeCompleteObjCPropertyDefinition(CurScope, ObjCImpDecl);
       ConsumeToken();
     }
     
@@ -1290,11 +1290,18 @@ Parser::DeclPtrTy Parser::ParseObjCPropertyDynamic(SourceLocation atLoc) {
   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,
index a4ff26669e25d5aefcf89966eaedbf56bf437cbe..2c50b88ddce38cd1e52ebbcbf85c3c848ed87c43 100644 (file)
@@ -3661,7 +3661,7 @@ public:
                                                  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,
index 0090e24a0f8961c59ab60696abf3c47fa06501d8..6ba0591dd0926d95c4e0a889555f5303f19eae0d 100644 (file)
@@ -2026,7 +2026,7 @@ void Sema::CodeCompleteObjCImplementationCategory(Scope *S,
   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);
 
index 5b567dfc005d98a0bd1b3c1df9c2d14ce97387e0..a99b1d1413d9b498a5a2bcad40514330123660f6 100644 (file)
@@ -6,25 +6,35 @@
   id StoredProp3;
   int RandomIVar;
 }
+@property int Prop0;
 @property int Prop1;
 @property float Prop2;
 @end
 
 @interface I2 : I1
 @property id Prop3;
+@property id Prop4;
 @end
 
 @implementation I2
 @synthesize Prop2, Prop1, Prop3 = StoredProp3;
+@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}