@@ -3078,6 +3078,7 @@ typedef llvm::SmallPtrSet<IdentifierInfo*, 16> AddedPropertiesSet;
3078
3078
3079
3079
static void AddObjCProperties (ObjCContainerDecl *Container,
3080
3080
bool AllowCategories,
3081
+ bool AllowNullaryMethods,
3081
3082
DeclContext *CurContext,
3082
3083
AddedPropertiesSet &AddedProperties,
3083
3084
ResultBuilder &Results) {
@@ -3092,41 +3093,84 @@ static void AddObjCProperties(ObjCContainerDecl *Container,
3092
3093
Results.MaybeAddResult (Result (*P, 0 ), CurContext);
3093
3094
}
3094
3095
3096
+ // Add nullary methods
3097
+ if (AllowNullaryMethods) {
3098
+ ASTContext &Context = Container->getASTContext ();
3099
+ for (ObjCContainerDecl::method_iterator M = Container->meth_begin (),
3100
+ MEnd = Container->meth_end ();
3101
+ M != MEnd; ++M) {
3102
+ if (M->getSelector ().isUnarySelector ())
3103
+ if (IdentifierInfo *Name = M->getSelector ().getIdentifierInfoForSlot (0 ))
3104
+ if (AddedProperties.insert (Name)) {
3105
+ CodeCompletionBuilder Builder (Results.getAllocator ());
3106
+ AddResultTypeChunk (Context, *M, Builder);
3107
+ Builder.AddTypedTextChunk (
3108
+ Results.getAllocator ().CopyString (Name->getName ()));
3109
+
3110
+ CXAvailabilityKind Availability = CXAvailability_Available;
3111
+ switch (M->getAvailability ()) {
3112
+ case AR_Available:
3113
+ case AR_NotYetIntroduced:
3114
+ Availability = CXAvailability_Available;
3115
+ break ;
3116
+
3117
+ case AR_Deprecated:
3118
+ Availability = CXAvailability_Deprecated;
3119
+ break ;
3120
+
3121
+ case AR_Unavailable:
3122
+ Availability = CXAvailability_NotAvailable;
3123
+ break ;
3124
+ }
3125
+
3126
+ Results.MaybeAddResult (Result (Builder.TakeString (),
3127
+ CCP_MemberDeclaration + CCD_MethodAsProperty,
3128
+ M->isInstanceMethod ()
3129
+ ? CXCursor_ObjCInstanceMethodDecl
3130
+ : CXCursor_ObjCClassMethodDecl,
3131
+ Availability),
3132
+ CurContext);
3133
+ }
3134
+ }
3135
+ }
3136
+
3137
+
3095
3138
// Add properties in referenced protocols.
3096
3139
if (ObjCProtocolDecl *Protocol = dyn_cast<ObjCProtocolDecl>(Container)) {
3097
3140
for (ObjCProtocolDecl::protocol_iterator P = Protocol->protocol_begin (),
3098
3141
PEnd = Protocol->protocol_end ();
3099
3142
P != PEnd; ++P)
3100
- AddObjCProperties (*P, AllowCategories, CurContext, AddedProperties ,
3101
- Results);
3143
+ AddObjCProperties (*P, AllowCategories, AllowNullaryMethods, CurContext ,
3144
+ AddedProperties, Results);
3102
3145
} else if (ObjCInterfaceDecl *IFace = dyn_cast<ObjCInterfaceDecl>(Container)){
3103
3146
if (AllowCategories) {
3104
3147
// Look through categories.
3105
3148
for (ObjCCategoryDecl *Category = IFace->getCategoryList ();
3106
3149
Category; Category = Category->getNextClassCategory ())
3107
- AddObjCProperties (Category, AllowCategories, CurContext ,
3108
- AddedProperties, Results);
3150
+ AddObjCProperties (Category, AllowCategories, AllowNullaryMethods ,
3151
+ CurContext, AddedProperties, Results);
3109
3152
}
3110
3153
3111
3154
// Look through protocols.
3112
3155
for (ObjCInterfaceDecl::all_protocol_iterator
3113
3156
I = IFace->all_referenced_protocol_begin (),
3114
3157
E = IFace->all_referenced_protocol_end (); I != E; ++I)
3115
- AddObjCProperties (*I, AllowCategories, CurContext, AddedProperties ,
3116
- Results);
3158
+ AddObjCProperties (*I, AllowCategories, AllowNullaryMethods, CurContext ,
3159
+ AddedProperties, Results);
3117
3160
3118
3161
// Look in the superclass.
3119
3162
if (IFace->getSuperClass ())
3120
- AddObjCProperties (IFace->getSuperClass (), AllowCategories, CurContext,
3163
+ AddObjCProperties (IFace->getSuperClass (), AllowCategories,
3164
+ AllowNullaryMethods, CurContext,
3121
3165
AddedProperties, Results);
3122
3166
} else if (const ObjCCategoryDecl *Category
3123
3167
= dyn_cast<ObjCCategoryDecl>(Container)) {
3124
3168
// Look through protocols.
3125
3169
for (ObjCCategoryDecl::protocol_iterator P = Category->protocol_begin (),
3126
3170
PEnd = Category->protocol_end ();
3127
3171
P != PEnd; ++P)
3128
- AddObjCProperties (*P, AllowCategories, CurContext, AddedProperties ,
3129
- Results);
3172
+ AddObjCProperties (*P, AllowCategories, AllowNullaryMethods, CurContext ,
3173
+ AddedProperties, Results);
3130
3174
}
3131
3175
}
3132
3176
@@ -3192,14 +3236,16 @@ void Sema::CodeCompleteMemberReferenceExpr(Scope *S, ExprTy *BaseE,
3192
3236
const ObjCObjectPointerType *ObjCPtr
3193
3237
= BaseType->getAsObjCInterfacePointerType ();
3194
3238
assert (ObjCPtr && " Non-NULL pointer guaranteed above!" );
3195
- AddObjCProperties (ObjCPtr->getInterfaceDecl (), true , CurContext,
3239
+ AddObjCProperties (ObjCPtr->getInterfaceDecl (), true ,
3240
+ /* AllowNullaryMethods=*/ true , CurContext,
3196
3241
AddedProperties, Results);
3197
3242
3198
3243
// Add properties from the protocols in a qualified interface.
3199
3244
for (ObjCObjectPointerType::qual_iterator I = ObjCPtr->qual_begin (),
3200
3245
E = ObjCPtr->qual_end ();
3201
3246
I != E; ++I)
3202
- AddObjCProperties (*I, true , CurContext, AddedProperties, Results);
3247
+ AddObjCProperties (*I, true , /* AllowNullaryMethods=*/ true , CurContext,
3248
+ AddedProperties, Results);
3203
3249
} else if ((IsArrow && BaseType->isObjCObjectPointerType ()) ||
3204
3250
(!IsArrow && BaseType->isObjCObjectType ())) {
3205
3251
// Objective-C instance variable access.
@@ -5334,11 +5380,13 @@ void Sema::CodeCompleteObjCPropertyDefinition(Scope *S, Decl *ObjCImpDecl) {
5334
5380
Results.EnterNewScope ();
5335
5381
if (ObjCImplementationDecl *ClassImpl
5336
5382
= dyn_cast<ObjCImplementationDecl>(Container))
5337
- AddObjCProperties (ClassImpl->getClassInterface (), false , CurContext,
5383
+ AddObjCProperties (ClassImpl->getClassInterface (), false ,
5384
+ /* AllowNullaryMethods=*/ false , CurContext,
5338
5385
AddedProperties, Results);
5339
5386
else
5340
5387
AddObjCProperties (cast<ObjCCategoryImplDecl>(Container)->getCategoryDecl (),
5341
- false , CurContext, AddedProperties, Results);
5388
+ false , /* AllowNullaryMethods=*/ false , CurContext,
5389
+ AddedProperties, Results);
5342
5390
Results.ExitScope ();
5343
5391
5344
5392
HandleCodeCompleteResults (this , CodeCompleter,
0 commit comments