aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-11-18 22:56:13 +0000
committerDouglas Gregor <dgregor@apple.com>2009-11-18 22:56:13 +0000
commit424b2a546dbd09cf70d43087771c7fff851ca158 (patch)
tree5d31614d8091b1bd9ed7e06726df95c502d7d4ff
parent6826314938f8510cd1a6b03b5d032592456ae27b (diff)
Code completion after @dynamic
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89265 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Parse/Action.h8
-rw-r--r--lib/Parse/ParseObjc.cpp19
-rw-r--r--lib/Sema/Sema.h2
-rw-r--r--lib/Sema/SemaCodeComplete.cpp2
-rw-r--r--test/Index/complete-properties.m16
5 files changed, 32 insertions, 15 deletions
diff --git a/include/clang/Parse/Action.h b/include/clang/Parse/Action.h
index 3165b0eb2f..0c1335cb70 100644
--- a/include/clang/Parse/Action.h
+++ b/include/clang/Parse/Action.h
@@ -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) {
}
diff --git a/lib/Parse/ParseObjc.cpp b/lib/Parse/ParseObjc.cpp
index 305ed16a19..216d9345cb 100644
--- a/lib/Parse/ParseObjc.cpp
+++ b/lib/Parse/ParseObjc.cpp
@@ -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,
diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h
index a4ff26669e..2c50b88ddc 100644
--- a/lib/Sema/Sema.h
+++ b/lib/Sema/Sema.h
@@ -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,
diff --git a/lib/Sema/SemaCodeComplete.cpp b/lib/Sema/SemaCodeComplete.cpp
index 0090e24a0f..6ba0591dd0 100644
--- a/lib/Sema/SemaCodeComplete.cpp
+++ b/lib/Sema/SemaCodeComplete.cpp
@@ -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);
diff --git a/test/Index/complete-properties.m b/test/Index/complete-properties.m
index 5b567dfc00..a99b1d1413 100644
--- a/test/Index/complete-properties.m
+++ b/test/Index/complete-properties.m
@@ -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}