@@ -1305,6 +1305,7 @@ bool CompletionLookup::isImplicitlyCurriedInstanceMethod(
1305
1305
1306
1306
switch (Kind) {
1307
1307
case LookupKind::ValueExpr:
1308
+ case LookupKind::StoredProperty:
1308
1309
return ExprType->is <AnyMetatypeType>();
1309
1310
case LookupKind::ValueInDeclContext:
1310
1311
if (InsideStaticMethod)
@@ -2248,6 +2249,13 @@ void CompletionLookup::foundDecl(ValueDecl *D, DeclVisibilityKind Reason,
2248
2249
}
2249
2250
2250
2251
return ;
2252
+ case LookupKind::StoredProperty:
2253
+ if (auto *VD = dyn_cast<VarDecl>(D)) {
2254
+ if (VD->hasStorage ()) {
2255
+ addVarDeclRef (VD, Reason, dynamicLookupInfo);
2256
+ }
2257
+ return ;
2258
+ }
2251
2259
}
2252
2260
}
2253
2261
@@ -2463,6 +2471,17 @@ void CompletionLookup::getValueExprCompletions(Type ExprType, ValueDecl *VD,
2463
2471
/* includeProtocolExtensionMembers*/ true );
2464
2472
}
2465
2473
2474
+ void CompletionLookup::getStoredPropertyCompletions (const NominalTypeDecl *D) {
2475
+ Kind = LookupKind::StoredProperty;
2476
+ NeedLeadingDot = false ;
2477
+
2478
+ lookupVisibleMemberDecls (*this , D->getDeclaredInterfaceType (),
2479
+ /* DotLoc=*/ SourceLoc (), CurrDeclContext,
2480
+ /* IncludeInstanceMembers*/ true ,
2481
+ /* includeDerivedRequirements*/ false ,
2482
+ /* includeProtocolExtensionMembers*/ false );
2483
+ }
2484
+
2466
2485
void CompletionLookup::collectOperators (
2467
2486
SmallVectorImpl<OperatorDecl *> &results) {
2468
2487
assert (CurrDeclContext);
@@ -3051,6 +3070,43 @@ void CompletionLookup::getAttributeDeclParamCompletions(
3051
3070
break ;
3052
3071
}
3053
3072
break ;
3073
+ case CustomSyntaxAttributeKind::StorageRestrictions: {
3074
+ bool suggestInitializesLabel = false ;
3075
+ bool suggestAccessesLabel = false ;
3076
+ bool suggestArgument = false ;
3077
+ switch (static_cast <StorageRestrictionsCompletionKind>(ParamIndex)) {
3078
+ case StorageRestrictionsCompletionKind::Label:
3079
+ suggestAccessesLabel = true ;
3080
+ suggestInitializesLabel = true ;
3081
+ break ;
3082
+ case StorageRestrictionsCompletionKind::Argument:
3083
+ suggestArgument = true ;
3084
+ break ;
3085
+ case StorageRestrictionsCompletionKind::ArgumentOrInitializesLabel:
3086
+ suggestArgument = true ;
3087
+ suggestInitializesLabel = true ;
3088
+ break ;
3089
+ case StorageRestrictionsCompletionKind::ArgumentOrAccessesLabel:
3090
+ suggestArgument = true ;
3091
+ suggestAccessesLabel = true ;
3092
+ break ;
3093
+ }
3094
+ if (suggestInitializesLabel) {
3095
+ addDeclAttrParamKeyword (
3096
+ " initializes" , /* Parameters=*/ {},
3097
+ " Specify stored properties initialized by the accessor" , true );
3098
+ }
3099
+ if (suggestAccessesLabel) {
3100
+ addDeclAttrParamKeyword (
3101
+ " accesses" , /* Parameters=*/ {},
3102
+ " Specify stored properties accessed by the accessor" , true );
3103
+ }
3104
+ if (suggestArgument) {
3105
+ if (auto NT = dyn_cast<NominalTypeDecl>(CurrDeclContext)) {
3106
+ getStoredPropertyCompletions (NT);
3107
+ }
3108
+ }
3109
+ }
3054
3110
}
3055
3111
}
3056
3112
0 commit comments