r177744 - documentation parsing. Provide code completion comment
Fariborz Jahanian
fjahanian at apple.com
Fri Mar 22 10:55:28 PDT 2013
Author: fjahanian
Date: Fri Mar 22 12:55:27 2013
New Revision: 177744
URL: http://llvm.org/viewvc/llvm-project?rev=177744&view=rev
Log:
documentation parsing. 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) // rdar://12791315
Modified:
cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/test/Index/complete-documentation-properties.m
Modified: cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h?rev=177744&r1=177743&r2=177744&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h (original)
+++ cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h Fri Mar 22 12:55:27 2013
@@ -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; }
Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=177744&r1=177743&r2=177744&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Fri Mar 22 12:55:27 2013
@@ -2541,6 +2541,20 @@ CodeCompletionResult::CreateCodeCompleti
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;
Modified: cfe/trunk/test/Index/complete-documentation-properties.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-documentation-properties.m?rev=177744&r1=177743&r2=177744&view=diff
==============================================================================
--- cfe/trunk/test/Index/complete-documentation-properties.m (original)
+++ cfe/trunk/test/Index/complete-documentation-properties.m Fri Mar 22 12:55:27 2013
@@ -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)
More information about the cfe-commits
mailing list