[cfe-commits] r83579 - in /cfe/trunk: clang.xcodeproj/project.pbxproj include/clang/Parse/Action.h lib/Parse/ParseObjc.cpp lib/Sema/Sema.h lib/Sema/SemaCodeComplete.cpp test/CodeCompletion/property.m
Steve Naroff
snaroff at apple.com
Thu Oct 8 14:55:06 PDT 2009
Author: snaroff
Date: Thu Oct 8 16:55:05 2009
New Revision: 83579
URL: http://llvm.org/viewvc/llvm-project?rev=83579&view=rev
Log:
Add code completion support for ObjC property declarations/attributes.
Added:
cfe/trunk/test/CodeCompletion/property.m
Modified:
cfe/trunk/clang.xcodeproj/project.pbxproj
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
Modified: cfe/trunk/clang.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/clang.xcodeproj/project.pbxproj?rev=83579&r1=83578&r2=83579&view=diff
==============================================================================
--- cfe/trunk/clang.xcodeproj/project.pbxproj (original)
+++ cfe/trunk/clang.xcodeproj/project.pbxproj Thu Oct 8 16:55:05 2009
@@ -503,6 +503,7 @@
35F9B1560D1C6B2E00DDFDAE /* UninitializedValues.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UninitializedValues.h; path = clang/Analysis/Analyses/UninitializedValues.h; sourceTree = "<group>"; };
35FE6BCE0DF6EE1F00739712 /* DeclBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; name = DeclBase.cpp; path = lib/AST/DeclBase.cpp; sourceTree = "<group>"; tabWidth = 2; };
72D16C1E0D9975C400E6DA4A /* HTMLRewrite.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = HTMLRewrite.cpp; path = lib/Rewrite/HTMLRewrite.cpp; sourceTree = "<group>"; };
+ 7F270AFE107A90010031B377 /* CodeCompleteConsumer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CodeCompleteConsumer.h; path = clang/Sema/CodeCompleteConsumer.h; sourceTree = "<group>"; };
84AF36A00CB17A3B00C820A5 /* DeclObjC.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 2; lastKnownFileType = sourcecode.c.h; name = DeclObjC.h; path = clang/AST/DeclObjC.h; sourceTree = "<group>"; tabWidth = 2; };
84D9A8870C1A57E100AC7ABC /* AttributeList.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; name = AttributeList.cpp; path = lib/Parse/AttributeList.cpp; sourceTree = "<group>"; tabWidth = 2; };
84D9A88B0C1A581300AC7ABC /* AttributeList.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 2; lastKnownFileType = sourcecode.c.h; name = AttributeList.h; path = clang/Parse/AttributeList.h; sourceTree = "<group>"; tabWidth = 2; };
@@ -1229,6 +1230,7 @@
DE67E7260C02108300F66BC5 /* Sema */ = {
isa = PBXGroup;
children = (
+ 7F270AFE107A90010031B377 /* CodeCompleteConsumer.h */,
9063F2210F9E8BDF002F7251 /* ExternalSemaSource.h */,
9063F2220F9E8BDF002F7251 /* SemaConsumer.h */,
DE67E7270C02109800F66BC5 /* ParseAST.h */,
Modified: cfe/trunk/include/clang/Parse/Action.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Action.h?rev=83579&r1=83578&r2=83579&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/Action.h (original)
+++ cfe/trunk/include/clang/Parse/Action.h Thu Oct 8 16:55:05 2009
@@ -2340,6 +2340,14 @@
///
/// \param S the scope in which the operator keyword occurs.
virtual void CodeCompleteOperatorName(Scope *S) { }
+
+ /// \brief Code completion for an ObjC property decl.
+ ///
+ /// This code completion action is invoked when the code-completion token is
+ /// found after the left paren.
+ ///
+ /// \param S the scope in which the operator keyword occurs.
+ virtual void CodeCompleteObjCProperty(Scope *S, ObjCDeclSpec &ODS) { }
//@}
};
Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=83579&r1=83578&r2=83579&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Thu Oct 8 16:55:05 2009
@@ -390,6 +390,10 @@
SourceLocation LHSLoc = ConsumeParen(); // consume '('
while (1) {
+ if (Tok.is(tok::code_completion)) {
+ Actions.CodeCompleteObjCProperty(CurScope, DS);
+ ConsumeToken();
+ }
const IdentifierInfo *II = Tok.getIdentifierInfo();
// If this is not an identifier at all, bail out early.
Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=83579&r1=83578&r2=83579&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Thu Oct 8 16:55:05 2009
@@ -3699,6 +3699,8 @@
virtual void CodeCompleteNamespaceDecl(Scope *S);
virtual void CodeCompleteNamespaceAliasDecl(Scope *S);
virtual void CodeCompleteOperatorName(Scope *S);
+
+ virtual void CodeCompleteObjCProperty(Scope *S, ObjCDeclSpec &ODS);
//@}
//===--------------------------------------------------------------------===//
Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=83579&r1=83578&r2=83579&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Thu Oct 8 16:55:05 2009
@@ -1393,3 +1393,30 @@
HandleCodeCompleteResults(CodeCompleter, Results.data(), Results.size());
}
+void Sema::CodeCompleteObjCProperty(Scope *S, ObjCDeclSpec &ODS) {
+ if (!CodeCompleter)
+ return;
+ unsigned Attributes = ODS.getPropertyAttributes();
+
+ typedef CodeCompleteConsumer::Result Result;
+ ResultBuilder Results(*this);
+ Results.EnterNewScope();
+ if (!(Attributes & ObjCDeclSpec::DQ_PR_readonly))
+ Results.MaybeAddResult(CodeCompleteConsumer::Result("readonly", 0));
+ if (!(Attributes & ObjCDeclSpec::DQ_PR_assign))
+ Results.MaybeAddResult(CodeCompleteConsumer::Result("assign", 0));
+ if (!(Attributes & ObjCDeclSpec::DQ_PR_readwrite))
+ Results.MaybeAddResult(CodeCompleteConsumer::Result("readwrite", 0));
+ if (!(Attributes & ObjCDeclSpec::DQ_PR_retain))
+ Results.MaybeAddResult(CodeCompleteConsumer::Result("retain", 0));
+ if (!(Attributes & ObjCDeclSpec::DQ_PR_copy))
+ Results.MaybeAddResult(CodeCompleteConsumer::Result("copy", 0));
+ if (!(Attributes & ObjCDeclSpec::DQ_PR_nonatomic))
+ Results.MaybeAddResult(CodeCompleteConsumer::Result("nonatomic", 0));
+ if (!(Attributes & ObjCDeclSpec::DQ_PR_setter))
+ Results.MaybeAddResult(CodeCompleteConsumer::Result("setter", 0));
+ if (!(Attributes & ObjCDeclSpec::DQ_PR_getter))
+ Results.MaybeAddResult(CodeCompleteConsumer::Result("getter", 0));
+ Results.ExitScope();
+ HandleCodeCompleteResults(CodeCompleter, Results.data(), Results.size());
+}
Added: cfe/trunk/test/CodeCompletion/property.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/property.m?rev=83579&view=auto
==============================================================================
--- cfe/trunk/test/CodeCompletion/property.m (added)
+++ cfe/trunk/test/CodeCompletion/property.m Thu Oct 8 16:55:05 2009
@@ -0,0 +1,29 @@
+// Note: the run lines follow their respective tests, since line/column
+// matter in this test.
+
+ at interface Foo {
+ void *isa;
+}
+ at property(copy) Foo *myprop;
+ at property(retain, nonatomic) id xx;
+// RUN: clang-cc -fsyntax-only -code-completion-at=%s:7:11 %s -o - | FileCheck -check-prefix=CC1 %s &&
+// CC1: readonly
+// CC1-NEXT: assign
+// CC1-NEXT: readwrite
+// CC1-NEXT: retain
+// CC1-NEXT: copy
+// CC1-NEXT: nonatomic
+// CC1-NEXT: setter
+// CC1-NEXT: getter
+// RUN: clang-cc -fsyntax-only -code-completion-at=%s:8:18 %s -o - | FileCheck -check-prefix=CC2 %s
+// CC2: readonly
+// CC2-NEXT: assign
+// CC2-NEXT: readwrite
+// CC2-NEXT: copy
+// CC2-NEXT: nonatomic
+// CC2-NEXT: setter
+// CC2-NEXT: getter
+ at end
+
+
+
More information about the cfe-commits
mailing list