]> granicus.if.org Git - clang/commitdiff
documentation parsing. Provide code completion comment
authorFariborz Jahanian <fjahanian@apple.com>
Fri, 22 Mar 2013 17:55:27 +0000 (17:55 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Fri, 22 Mar 2013 17:55:27 +0000 (17:55 +0000)
for self.GetterName where GetterName is the getter method
for a property with name different from the property name
(declared via a property getter attribute) // rdar://12791315

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177744 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Sema/CodeCompleteConsumer.h
lib/Sema/SemaCodeComplete.cpp
test/Index/complete-documentation-properties.m

index 307dd57e109c2384b9c9c98522ad353f5065f49b..a1ddec7520ad8b3e6715e894bd24f6bc011e0482 100644 (file)
@@ -632,6 +632,7 @@ public:
   /// \brief Add the parent context information to this code completion.
   void addParentContext(const DeclContext *DC);
 
+  const char *getBriefComment() const { return BriefComment; }
   void addBriefComment(StringRef Comment);
   
   StringRef getParentName() const { return ParentName; }
index 6bb954315ab3bfd11ded85879fea621e303d1751..1cb264265aa6a1ad11e928cfc43cb6fdeb6756ae 100644 (file)
@@ -2541,6 +2541,20 @@ CodeCompletionResult::CreateCodeCompletionString(ASTContext &Ctx,
     if (Declaration) {
       Result.addParentContext(Declaration->getDeclContext());
       Pattern->ParentName = Result.getParentName();
+      // Provide code completion comment for self.GetterName where
+      // GetterName is the getter method for a property with name
+      // different from the property name (declared via a property
+      // getter attribute.
+      const NamedDecl *ND = Declaration;
+      if (const ObjCMethodDecl *M = dyn_cast<ObjCMethodDecl>(ND))
+        if (M->isPropertyAccessor())
+          if (const ObjCPropertyDecl *PDecl = M->findPropertyDecl())
+            if (PDecl->getGetterName() == M->getSelector() &&
+                PDecl->getIdentifier() != M->getIdentifier())
+              if (const RawComment *RC = Ctx.getRawCommentForAnyRedecl(PDecl)) {
+                Result.addBriefComment(RC->getBriefText(Ctx));
+                Pattern->BriefComment = Result.getBriefComment();
+              }
     }
     
     return Pattern;
index d423f84d227a57243764d982faee8cd3211c3087..ea41d958da12385351eea7eb7e6609414a36937d 100644 (file)
@@ -49,6 +49,7 @@
   p = [self PropertyInPrimaryClass];
   p = [self Record];
   [self setThisRecord : (id)0 ];
+  p = self.GetterInClassExtension;
   return 0; 
 }
 @end
@@ -66,3 +67,6 @@
 
 // RUN: env CINDEXTEST_COMPLETION_BRIEF_COMMENTS=1 c-index-test -code-completion-at=%s:51:9 %s | FileCheck -check-prefix=CC5 %s
 // CHECK-CC5: {TypedText setThisRecord:}{Placeholder (id)}{{.*}}(brief comment: This is Record)
+
+// RUN: env CINDEXTEST_COMPLETION_BRIEF_COMMENTS=1 c-index-test -code-completion-at=%s:52:12 %s | FileCheck -check-prefix=CC6 %s
+// CHECK-CC6: {TypedText GetterInClassExtension}{{.*}}(brief comment: This is PropertyInClassExtension)