r176271 - objective-C code completion. Property accessors may not

Fariborz Jahanian fjahanian at apple.com
Thu Feb 28 09:47:14 PST 2013


Author: fjahanian
Date: Thu Feb 28 11:47:14 2013
New Revision: 176271

URL: http://llvm.org/viewvc/llvm-project?rev=176271&view=rev
Log:
objective-C code completion. Property accessors may not
have their own code completion comments. Use those in 
their properties in this case. 
// rdar://12791315

Added:
    cfe/trunk/test/Index/complete-documentation-properties.m
Modified:
    cfe/trunk/lib/Sema/SemaCodeComplete.cpp

Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=176271&r1=176270&r2=176271&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Thu Feb 28 11:47:14 2013
@@ -2605,7 +2605,12 @@ CodeCompletionResult::CreateCodeCompleti
     // Add documentation comment, if it exists.
     if (const RawComment *RC = Ctx.getRawCommentForAnyRedecl(ND)) {
       Result.addBriefComment(RC->getBriefText(Ctx));
-    }
+    } 
+    else if (const ObjCMethodDecl *OMD = dyn_cast<ObjCMethodDecl>(ND))
+      if (OMD->isPropertyAccessor())
+        if (const ObjCPropertyDecl *PDecl = OMD->findPropertyDecl())
+          if (const RawComment *RC = Ctx.getRawCommentForAnyRedecl(PDecl))
+            Result.addBriefComment(RC->getBriefText(Ctx));
   }
 
   if (StartsNestedNameSpecifier) {

Added: cfe/trunk/test/Index/complete-documentation-properties.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-documentation-properties.m?rev=176271&view=auto
==============================================================================
--- cfe/trunk/test/Index/complete-documentation-properties.m (added)
+++ cfe/trunk/test/Index/complete-documentation-properties.m Thu Feb 28 11:47:14 2013
@@ -0,0 +1,66 @@
+// Note: the run lines follow their respective tests, since line/column numbers
+// matter in this test.
+// rdar://12791315
+
+ at interface AppDelegate
+/**
+  \brief This is ReadonlyProperty
+*/
+ at property (readonly, getter = ReadonlyGetter) id MyProperty;
+
+/**
+  \brief This is GeneralProperty
+*/
+ at property int GeneralProperty;
+
+/**
+  \brief This is PropertyInPrimaryClass
+*/
+ at property (copy, nonatomic) id PropertyInPrimaryClass;
+
+- (void) setThisRecord : (id)arg;
+- (id) Record;
+ at end
+
+
+ at interface AppDelegate()
+- (id) GetterInClassExtension;
+/**
+  \brief This is Record
+*/
+ at property (copy, setter = setThisRecord:) id Record;
+ at end
+
+ at interface AppDelegate()
+/**
+  \brief This is PropertyInClassExtension
+*/
+ at property (copy, getter = GetterInClassExtension) id PropertyInClassExtension;
+
+- (id) PropertyInPrimaryClass;
+ at end
+  
+ at implementation AppDelegate
+- (id) PropertyInPrimaryClass { 
+  id p = [self ReadonlyGetter];
+  p = [self GetterInClassExtension];
+  p = [self PropertyInPrimaryClass];
+  p = [self Record];
+  [self setThisRecord : (id)0 ];
+  return 0; 
+}
+ at end
+// RUN: env CINDEXTEST_COMPLETION_BRIEF_COMMENTS=1 c-index-test -code-completion-at=%s:45:16 %s | FileCheck -check-prefix=CC1 %s
+// CHECK-CC1: {TypedText ReadonlyGetter}{{.*}}(brief comment: This is ReadonlyProperty)
+
+// RUN: env CINDEXTEST_COMPLETION_BRIEF_COMMENTS=1 c-index-test -code-completion-at=%s:46:13 %s | FileCheck -check-prefix=CC2 %s
+// CHECK-CC2: {TypedText GetterInClassExtension}{{.*}}(brief comment: This is PropertyInClassExtension) 
+
+// RUN: env CINDEXTEST_COMPLETION_BRIEF_COMMENTS=1 c-index-test -code-completion-at=%s:47:13 %s | FileCheck -check-prefix=CC3 %s
+// CHECK-CC3: {TypedText PropertyInPrimaryClass}{{.*}}(brief comment: This is PropertyInPrimaryClass)
+
+// RUN: env CINDEXTEST_COMPLETION_BRIEF_COMMENTS=1 c-index-test -code-completion-at=%s:48:13 %s | FileCheck -check-prefix=CC4 %s
+// CHECK-CC4: {TypedText Record}{{.*}}(brief comment: This is Record)
+
+// RUN: env CINDEXTEST_COMPLETION_BRIEF_COMMENTS=1 c-index-test -code-completion-at=%s:49:9 %s | FileCheck -check-prefix=CC5 %s
+// CHECK-CC5: {TypedText setThisRecord:}{Placeholder (id)}{{.*}}(brief comment: This is Record)





More information about the cfe-commits mailing list